• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • Examples
  • File List
  • Globals

include/posix/semaphore.h

00001 /*
00002  * Copyright (C) 2005 Philippe Gerum <rpm@xenomai.org>.
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License as
00006  * published by the Free Software Foundation; either version 2 of the
00007  * License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017  */
00018 
00019 #ifndef _XENO_POSIX_SEMAPHORE_H
00020 #define _XENO_POSIX_SEMAPHORE_H
00021 
00022 #if defined(__KERNEL__) || defined(__XENO_SIM__)
00023 
00024 #include <nucleus/xenomai.h>
00025 
00026 #ifdef __KERNEL__
00027 #include <linux/kernel.h>
00028 #include <linux/fcntl.h>
00029 #endif /* __KERNEL__ */
00030 
00031 #ifdef __XENO_SIM__
00032 #include <posix_overrides.h>
00033 #endif /* __XENO_SIM__ */
00034 
00035 #define SEM_VALUE_MAX (INT_MAX)
00036 #define SEM_FAILED    NULL
00037 
00038 #ifdef __KERNEL__
00039 /* Copied from Linuxthreads semaphore.h. */
00040 struct _sem_fastlock
00041 {
00042   long int __status;
00043   int __spinlock;
00044 };
00045 
00046 typedef struct
00047 {
00048   struct _sem_fastlock __sem_lock;
00049   int __sem_value;
00050   long __sem_waiting;
00051 } sem_t;
00052 #endif /* __KERNEL__ */
00053 
00054 #else /* !(__KERNEL__ || __XENO_SIM__) */
00055 
00056 #include <fcntl.h>              /* For sem_open flags. */
00057 #include_next <semaphore.h>
00058 
00059 #endif /* !(__KERNEL__ || __XENO_SIM__) */
00060 
00061 struct pse51_sem;
00062 
00063 union __xeno_sem {
00064     sem_t native_sem;
00065     struct __shadow_sem {
00066         unsigned magic;
00067         struct pse51_sem *sem;
00068     } shadow_sem;
00069 };
00070 
00071 #if defined(__KERNEL__) || defined(__XENO_SIM__)
00072 
00073 #ifdef __cplusplus
00074 extern "C" {
00075 #endif
00076 
00077 #undef sem_init
00078 #define sem_init pse51_sem_init
00079 
00080 int pse51_sem_init(sem_t *sem,
00081                    int pshared,
00082                    unsigned int value);
00083 
00084 int sem_destroy(sem_t *sem);
00085 
00086 int sem_post(sem_t *sem);
00087 
00088 int sem_trywait(sem_t *sem);
00089 
00090 int sem_wait(sem_t *sem);
00091 
00092 int sem_timedwait(sem_t *sem,
00093                   const struct timespec *abs_timeout);
00094 
00095 int sem_getvalue(sem_t *sem,
00096                  int *value);
00097 
00098 sem_t *sem_open(const char *name, int oflag, ...);
00099 
00100 int sem_close(sem_t *sem);
00101 
00102 int sem_unlink(const char *name);
00103 
00104 #ifdef __cplusplus
00105 }
00106 #endif
00107 
00108 #else /* !(__KERNEL__ || __XENO_SIM__) */
00109 
00110 #ifdef __cplusplus
00111 extern "C" {
00112 #endif
00113 
00114 int __real_sem_init(sem_t *sem,
00115                     int pshared,
00116                     unsigned value);
00117 
00118 int __real_sem_destroy(sem_t *sem);
00119 
00120 int __real_sem_post(sem_t *sem);
00121 
00122 int __real_sem_wait(sem_t *sem);
00123 
00124 int __real_sem_timedwait(sem_t *sem, const struct timespec *abs_timeout);
00125 
00126 int __real_sem_trywait(sem_t *sem);
00127 
00128 int __real_sem_getvalue(sem_t *sem, int *value);
00129 
00130 sem_t *__real_sem_open(const char *name, int oflags, ...);
00131 
00132 int __real_sem_close(sem_t *sem);
00133 
00134 int __real_sem_unlink(const char *name);
00135 
00136 #ifdef __cplusplus
00137 }
00138 #endif
00139 
00140 #endif /* !(__KERNEL__ || __XENO_SIM__) */
00141 
00142 #endif /* _XENO_POSIX_SEMAPHORE_H */

Generated on Tue Jul 10 2012 20:41:22 for Xenomai API by  doxygen 1.7.1