Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / ace / os_include / os_semaphore.h
blob98e5f210902ef4c9b76695b7dcfa6b65196e1baf
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file os_semaphore.h
7 * semaphores (REALTIME)
9 * @author Don Hinton <dhinton@dresystems.com>
10 * @author This code was originally in various places including ace/OS.h.
12 //=============================================================================
14 #ifndef ACE_OS_INCLUDE_OS_SEMAPHORE_H
15 #define ACE_OS_INCLUDE_OS_SEMAPHORE_H
17 #include /**/ "ace/pre.h"
19 #include /**/ "ace/config-all.h"
21 #if !defined (ACE_LACKS_PRAGMA_ONCE)
22 # pragma once
23 #endif /* ACE_LACKS_PRAGMA_ONCE */
25 #include "ace/os_include/os_time.h"
27 #if !defined (ACE_LACKS_SEMAPHORE_H)
28 # include /**/ <semaphore.h>
29 #endif /* !ACE_LACKS_SEMAPHORE_H */
31 // Place all additions (especially function declarations) within extern "C" {}
32 #ifdef __cplusplus
33 extern "C"
35 #endif /* __cplusplus */
37 #if defined (ACE_HAS_POSIX_SEM)
38 # if !defined (SEM_FAILED) && !defined (ACE_LACKS_NAMED_POSIX_SEM)
39 # define SEM_FAILED ((sem_t *) -1)
40 # endif /* !SEM_FAILED */
42 typedef struct
44 /// Pointer to semaphore handle. This is allocated by ACE if we are
45 /// working with an unnamed POSIX semaphore or by the OS if we are
46 /// working with a named POSIX semaphore.
47 sem_t *sema_;
49 /// Name of the semaphore (if this is non-NULL then this is a named
50 /// POSIX semaphore, else its an unnamed POSIX semaphore).
51 char *name_;
53 /// Do not unlink the named semaphore. This lets the logical entity
54 /// of the semaphore outlive any one process that opens it. The semaphore
55 /// must be manually unlinked with ACE_OS::sema_unlink().
56 bool avoid_unlink_;
58 # if defined (ACE_LACKS_NAMED_POSIX_SEM)
59 /// this->sema_ doesn't always get created dynamically if a platform
60 /// doesn't support named posix semaphores. We use this flag to
61 /// remember if we need to delete <sema_> or not.
62 bool new_sema_;
63 # endif /* ACE_LACKS_NAMED_POSIX_SEM */
65 # if !defined (ACE_HAS_POSIX_SEM_TIMEOUT) && !defined (ACE_DISABLE_POSIX_SEM_TIMEOUT_EMULATION)
66 /// Serialize access to internal state.
67 ACE_mutex_t lock_;
69 /// Block until there are no waiters.
70 ACE_cond_t count_nonzero_;
71 # endif /* !ACE_HAS_POSIX_SEM_TIMEOUT && !ACE_DISABLE_POSIX_SEM_TIMEOUT_EMULATION */
72 } ACE_sema_t;
73 #endif /* ACE_HAS_POSIX_SEM */
75 #ifdef __cplusplus
77 #endif /* __cplusplus */
79 #include /**/ "ace/post.h"
80 #endif /* ACE_OS_INCLUDE_OS_SEMAPHORE_H */