Change SEM_VALUE_MAX (maximum value of a POSIX semaphore) from UINT_MAX

to INT_MAX.  Otherwise, a process could create a semaphore (or increase
its value via ksem_post()) beyond INT_MAX and sem_getvalue() would return
a negative value.  sem_getvalue() is only supposed to return a negative
value if that is the number of waiters for that semaphore.

MFC after:	2 weeks
This commit is contained in:
jhb 2008-06-26 13:51:25 +00:00
parent fd5bd912ed
commit ed2c19947c

View File

@ -37,12 +37,14 @@
#ifndef _SEMAPHORE_H_
#define _SEMAPHORE_H_
#include <machine/_limits.h>
/* Opaque type definition. */
struct sem;
typedef struct sem * sem_t;
#define SEM_FAILED ((sem_t *)0)
#define SEM_VALUE_MAX (~0U) /* Equivalent to UINT_MAX. */
#define SEM_VALUE_MAX __INT_MAX
#ifndef _KERNEL
#include <sys/cdefs.h>