#ifndef __SEMAPHORE_LOADED #define __SEMAPHORE_LOADED /**************************************************************************** ** ** - POSIX semaphore system calls ** ***************************************************************************** ** ** Copyright 2009 Hewlett-Packard Development Company, L.P. ** ** Confidential computer software. Valid license from HP and/or ** its subsidiaries required for possession, use, or copying. ** ** Consistent with FAR 12.211 and 12.212, Commercial Computer Software, ** Computer Software Documentation, and Technical Data for Commercial ** Items are licensed to the U.S. Government under vendor's standard ** commercial license. ** ** Neither HP nor any of its subsidiaries shall be liable for technical ** or editorial errors or omissions contained herein. The information ** in this document is provided "as is" without warranty of any kind and ** is subject to change without notice. The warranties for HP products ** are set forth in the express limited warranty statements accompanying ** such products. Nothing herein should be construed as constituting an ** additional warranty. ** ***************************************************************************** */ #pragma __nostandard #include #ifdef __cplusplus extern "C" { #endif #if __INITIAL_POINTER_SIZE # pragma __pointer_size __save # pragma __pointer_size 64 #endif #include #include #include /* Constants definition */ #define SEM_FAILED ((sem_t *)-1) #define PSEM_MAX_PATHNAME 256 #define PSEM_MAX_SECNAME 256 #define SEM_VALUE_MAX INT_MAX /* Data structure describing a semaphores. */ typedef struct { unsigned int __unused1; // padding char signature[24]; /* used internally */ int sem_named_flag; /* 1 = named semaphore */ int wait_count; /* used for unnamed semaphroes */ unsigned int sem_value; /* semaphore value (used only in case of unnamed semaphore) */ void *sem_internal_ptr; /* pointer to the internal semaphore struct (used only in case of named semaphores) */ unsigned int __unused2; // padding }sem_t; /* Open a named semaphore */ sem_t *sem_open (const char *name, int oflag, ...); /* Remove the name of the semaphore */ int sem_unlink (const char *name); /* close the semaphore opened through sem_open */ int sem_close (sem_t *sem); /* Initialize the specified semaphore */ int sem_init (sem_t *sem, int pshared, unsigned value); /* Remove the semaphore */ int sem_destroy (sem_t *sem); /* Lock the semaphore (blocking) */ int sem_wait (sem_t *sem); /* Lock the specified semaphore (non-blocking) */ int sem_trywait (sem_t *sem); /* Wait for semaphore (blocking with timeout) */ int sem_timedwait (sem_t *sem, struct timespec * abs_timeout); /* Unlock the specified semaphore */ int sem_post (sem_t *sem); /* Get the semaphore value */ int sem_getvalue (sem_t *sem, int *sval); /* ** Restore the users pointer context */ #if __INITIAL_POINTER_SIZE # pragma __pointer_size __restore #endif #ifdef __cplusplus } #endif #pragma __standard #endif /* __SEMAPHORE_LOADED */