source: Daodan/MinGW/include/semaphore.h@ 1051

Last change on this file since 1051 was 1046, checked in by alloc, 8 years ago

Daodan: Added Windows MinGW and build batch file

File size: 3.9 KB
Line 
1/*
2 * Module: semaphore.h
3 *
4 * Purpose:
5 * Semaphores aren't actually part of the PThreads standard.
6 * They are defined by the POSIX Standard:
7 *
8 * POSIX 1003.1b-1993 (POSIX.1b)
9 *
10 * --------------------------------------------------------------------------
11 *
12 * Pthreads-win32 - POSIX Threads Library for Win32
13 * Copyright(C) 1998 John E. Bossom
14 * Copyright(C) 1999-2012, 2016, Pthreads-win32 contributors
15 *
16 * Homepage1: http://sourceware.org/pthreads-win32/
17 * Homepage2: http://sourceforge.net/projects/pthreads4w/
18 *
19 * The current list of contributors is contained
20 * in the file CONTRIBUTORS included with the source
21 * code distribution. The list can also be seen at the
22 * following World Wide Web location:
23 * http://sources.redhat.com/pthreads-win32/contributors.html
24 *
25 * This library is free software; you can redistribute it and/or
26 * modify it under the terms of the GNU Lesser General Public
27 * License as published by the Free Software Foundation; either
28 * version 2 of the License, or (at your option) any later version.
29 *
30 * This library is distributed in the hope that it will be useful,
31 * but WITHOUT ANY WARRANTY; without even the implied warranty of
32 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
33 * Lesser General Public License for more details.
34 *
35 * You should have received a copy of the GNU Lesser General Public
36 * License along with this library in the file COPYING.LIB;
37 * if not, write to the Free Software Foundation, Inc.,
38 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
39 */
40#ifndef _SEMAPHORE_H
41#define _SEMAPHORE_H
42
43/* FIXME: POSIX.1 says that _POSIX_SEMAPHORES should be defined
44 * in <unistd.h>, not here; for later POSIX.1 versions, its value
45 * should match the corresponding _POSIX_VERSION number, but in
46 * the case of POSIX.1b-1993, the value is unspecified.
47 *
48 * Notwithstanding the above, since POSIX semaphores, (and indeed
49 * having any <unistd.h> to #include), are not a standard feature
50 * on MS-Windows, it is convenient to retain this definition here;
51 * we may consider adding a hook, to make it selectively available
52 * for inclusion by <unistd.h>, in those cases (e.g. MinGW) where
53 * <unistd.h> is provided.
54 */
55#define _POSIX_SEMAPHORES
56
57/* Internal macros, common to the public interfaces for various
58 * pthreads-win32 components, are defined in <_ptw32.h>; we must
59 * include them here.
60 */
61#include <_ptw32.h>
62
63/* The sem_timedwait() function was added in POSIX.1-2001; it
64 * requires struct timespec to be defined, at least as a partial
65 * (a.k.a. incomplete) data type. Forward declare it as such.
66 */
67struct timespec;
68
69/* The data type used to represent our semaphore implementation,
70 * as required by POSIX.1; FIXME: consider renaming the underlying
71 * structure tag, to avoid possible pollution of user namespace.
72 */
73typedef struct sem_t_ * sem_t;
74
75/* POSIX.1b (and later) mandates SEM_FAILED as the value to be
76 * returned on failure of sem_open(); (our implementation is a
77 * stub, which will always return this).
78 */
79#define SEM_FAILED (sem_t *)(-1)
80
81__PTW32_BEGIN_C_DECLS
82
83/* Function prototypes: some are implemented as stubs, which
84 * always fail; (FIXME: identify them).
85 */
86__PTW32_DECLSPEC int sem_init (sem_t * sem, int pshared, unsigned int value);
87__PTW32_DECLSPEC int sem_destroy (sem_t * sem);
88__PTW32_DECLSPEC int sem_trywait (sem_t * sem);
89__PTW32_DECLSPEC int sem_wait (sem_t * sem);
90__PTW32_DECLSPEC int sem_timedwait (sem_t * sem, const struct timespec * abstime);
91__PTW32_DECLSPEC int sem_post (sem_t * sem);
92__PTW32_DECLSPEC int sem_post_multiple (sem_t * sem, int count);
93__PTW32_DECLSPEC sem_t *sem_open (const char *, int, ...);
94__PTW32_DECLSPEC int sem_close (sem_t * sem);
95__PTW32_DECLSPEC int sem_unlink (const char * name);
96__PTW32_DECLSPEC int sem_getvalue (sem_t * sem, int * sval);
97
98__PTW32_END_C_DECLS
99
100#endif /* !_SEMAPHORE_H */
Note: See TracBrowser for help on using the repository browser.