comparison packages/compat/posix/current/include/semaphore.h @ 115:6ed91473a1cd ecos-sw-2000-08-21

Merge from eCos master repository on 2000-08-21-22:40:54-BST
author jlarmour
date Fri, 25 Aug 2000 17:32:38 +0000
parents
children e0c0827131d1
comparison
equal deleted inserted replaced
114:5ad2b71d525e 115:6ed91473a1cd
1 #ifndef CYGONCE_SEMAPHORE_H
2 #define CYGONCE_SEMAPHORE_H
3 //=============================================================================
4 //
5 // semaphore.h
6 //
7 // POSIX semaphore header
8 //
9 //=============================================================================
10 //####COPYRIGHTBEGIN####
11 //
12 // -------------------------------------------
13 // The contents of this file are subject to the Red Hat eCos Public License
14 // Version 1.1 (the "License"); you may not use this file except in
15 // compliance with the License. You may obtain a copy of the License at
16 // http://www.redhat.com/
17 //
18 // Software distributed under the License is distributed on an "AS IS"
19 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
20 // License for the specific language governing rights and limitations under
21 // the License.
22 //
23 // The Original Code is eCos - Embedded Configurable Operating System,
24 // released September 30, 1998.
25 //
26 // The Initial Developer of the Original Code is Red Hat.
27 // Portions created by Red Hat are
28 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc.
29 // All Rights Reserved.
30 // -------------------------------------------
31 //
32 //####COPYRIGHTEND####
33 //=============================================================================
34 //#####DESCRIPTIONBEGIN####
35 //
36 // Author(s): nickg
37 // Contributors: nickg
38 // Date: 2000-03-17
39 // Purpose: POSIX semaphore header
40 // Description: This header contains all the definitions needed to support
41 // semaphores under eCos. The reader is referred to the POSIX
42 // standard or equivalent documentation for details of the
43 // functionality contained herein.
44 //
45 // Usage:
46 // #include <semaphore.h>
47 // ...
48 //
49 //
50 //####DESCRIPTIONEND####
51 //
52 //=============================================================================
53
54 #include <pkgconf/hal.h>
55 #include <pkgconf/kernel.h>
56 #include <pkgconf/posix.h>
57
58 #include <stddef.h> // NULL, size_t
59
60 #include <limits.h>
61
62 #include <sys/types.h>
63
64 //-----------------------------------------------------------------------------
65 // Semaphore object definition
66
67 // This structure must exactly correspond in size and layout to the underlying
68 // eCos C++ class that implements this object.
69
70 typedef struct
71 {
72 CYG_WORD32 sem_value;
73 CYG_ADDRESS sem_queue;
74 } sem_t;
75
76 //-----------------------------------------------------------------------------
77 // Semaphore functions
78
79 // Initialize semaphore to value.
80 // pshared is not supported under eCos.
81 externC int sem_init (sem_t *sem, int pshared, unsigned int value);
82
83 // Destroy the semaphore.
84 externC int sem_destroy (sem_t *sem);
85
86 // Decrement value if >0 or wait for a post.
87 externC int sem_wait (sem_t *sem);
88
89 // Decrement value if >0, return -1 if not.
90 externC int sem_trywait (sem_t *sem);
91
92 // Increment value and wake a waiter if one is present.
93 externC int sem_post (sem_t *sem);
94
95 // Get current value
96 externC int sem_getvalue (sem_t *sem, int *sval);
97
98 //-----------------------------------------------------------------------------
99 // Named semaphore functions
100 // These are an optional feature under eCos
101
102 // Open an existing named semaphore, or create it.
103 externC sem_t *sem_open (const char *name, int oflag, ...);
104
105 // Close descriptor for semaphore.
106 externC int sem_close (sem_t *sem);
107
108 // Remove named semaphore
109 externC int sem_unlink (const char *name);
110
111 //-----------------------------------------------------------------------------
112 // Special return value for sem_open()
113
114 #define SEM_FAILED ((sem_t *)NULL)
115
116 //-----------------------------------------------------------------------------
117 #endif // ifndef CYGONCE_SEMAPHORE_H
118 // End of semaphore.h