Main Page | Data Structures | File List | Data Fields | Globals | Related Pages

include/semaphore.h

Go to the documentation of this file.
00001 
00006 /*
00007  *  The contents of this file are subject to the Mozilla Public License
00008  *  Version 1.0 (the "License"); you may not use this file except in
00009  *  compliance with the License. You may obtain a copy of the License
00010  *  at http://www.mozilla.org/MPL/
00011  *
00012  *  Software distributed under the License is distributed on an "AS IS"
00013  *  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
00014  *  the License for the specific language governing rights and
00015  *  limitations under the License.
00016  *
00017  *  The Original Code is legOS code, released October 17, 1999.
00018  *
00019  *  The Initial Developer of the Original Code is Markus L. Noga.
00020  *  Portions created by Markus L. Noga are Copyright (C) 1999
00021  *  Markus L. Noga. All Rights Reserved.
00022  *
00023  *  Contributor(s): Markus L. Noga <markus@noga.de>
00024  *                  Henner Zeller <H.Zeller@acm.org> (sem_timedwait())
00025  */
00026 
00027 #ifndef __semaphore_h__
00028 #define __semaphore_h__
00029 
00030 #ifdef  __cplusplus
00031 extern "C" {
00032 #endif
00033 
00034 #include <config.h>
00035 #include <time.h> /* time_t */
00036 #include <atomic.h>
00037 
00038 #ifdef CONF_SEMAPHORES
00039 
00041 //
00042 // Definitions
00043 //
00045 
00046 typedef atomic_t sem_t;                         
00047 
00048 #define EAGAIN  0xffff                          
00049 
00050 
00051 //
00052 // Functions
00053 //
00055 
00057 
00064 extern inline int sem_init(sem_t * sem, int pshared, unsigned int value)
00065 {
00066   *sem = (sem_t) value;
00067   return 0;
00068 }
00069 
00071 
00078 extern int sem_wait(sem_t * sem);
00079 
00100 extern int sem_timedwait(sem_t * sem,
00101                          const time_t abs_timeout);
00102 
00104 
00114 extern int sem_trywait(sem_t * sem);
00115 
00117 
00123 extern inline int sem_post(sem_t * sem) 
00124 { 
00125         atomic_inc(sem);
00126         return 0;
00127 }
00128 
00129 //
00131 //
00132 extern inline int sem_getvalue(sem_t * sem, int *sval)
00133 {
00134   *sval = *sem;
00135   return 0;
00136 }
00137 
00139 
00147 extern inline int sem_destroy(sem_t * sem)
00148 {
00149   return 0;
00150 }
00151 
00152 #endif // CONF_SEMAPHORES
00153 
00154 #ifdef  __cplusplus
00155 }
00156 #endif
00157 
00158 #endif // __semaphore_h__

brickOS is released under the Mozilla Public License.
Original code copyright 1998-2002 by the authors.

Generated on Mon Feb 16 21:01:52 2004 for brickOS C by doxygen 1.3.5