072339664d
* pthread.cc (+mangle_sem_name): New function. (sem_open): Ditto. (sem_close: Ditto. (sem_timedwait): Ditto. (sem_getvalue): Ditto. * thread.cc (semaphore::semaphore): Rearrange member initialization. Use appropriate security attribute for process shared semaphores. (semaphore::semaphore): New constructor for named semaphores. (semaphore::~semaphore): Care for semaphore name. (semaphore::_post): Accomodate failing ReleaseSemaphore. Use value returned by ReleaseSemaphore vor currentvalue. (semaphore::_getvalue): New method. (semaphore::_timedwait): Ditto. (semaphore::_fixup_after_fork): Rearrange. Don't fail for process shared semaphores. (semaphore::open): New method. (semaphore::timedwait): Ditto. (semaphore::post): Fix return value. Set errno appropriately. (semaphore::getvalue): New method. * thread.h (class semaphore): Add prototypes for open, getvalue, timedwait, _getvalue, _timedwait. Add prototypes for new constructor. Add name member. * include/semaphore.h: Add prototypes for sem_open, sem_close, sem_timedwait and sem_getvalue. include/cygwin/version.h: Bump API minor number.
46 lines
1.0 KiB
C
46 lines
1.0 KiB
C
/* semaphore.h: POSIX semaphore interface
|
|
|
|
Copyright 2001, 2003 Red Hat, Inc.
|
|
|
|
Written by Robert Collins <rbtcollins@hotmail.com>
|
|
|
|
This file is part of Cygwin.
|
|
|
|
This software is a copyrighted work licensed under the terms of the
|
|
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
|
details. */
|
|
|
|
#include <sys/types.h>
|
|
|
|
#ifndef _SEMAPHORE_H
|
|
#define _SEMAPHORE_H
|
|
|
|
#ifdef __cplusplus
|
|
extern "C"
|
|
{
|
|
#endif
|
|
|
|
#ifndef __INSIDE_CYGWIN__
|
|
typedef struct __sem_t {char __dummy;} *sem_t;
|
|
#endif
|
|
|
|
#define SEM_FAILED 0
|
|
#define SEM_VALUE_MAX 1147483648
|
|
|
|
/* Semaphores */
|
|
int sem_init (sem_t * sem, int pshared, unsigned int value);
|
|
int sem_destroy (sem_t * sem);
|
|
sem_t *sem_open (const char *name, int oflag, ...);
|
|
int sem_close (sem_t *sem);
|
|
int sem_wait (sem_t * sem);
|
|
int sem_trywait (sem_t * sem);
|
|
int sem_timedwait (sem_t * sem, const struct timespec *abstime);
|
|
int sem_post (sem_t * sem);
|
|
int sem_getvalue (sem_t * sem, int *sval);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* _SEMAPHORE_H */
|