00001 /* 00002 * Copyright (c) 2008-2011 Marius Zwicker / Elefant Racing Bayreuth. 00003 * All rights reserved. 00004 * 00005 * @ERB_OPEN_LICENSE_HEADER_START@ 00006 * 00007 * Licensed under the Apache License, Version 2.0 (the "License"); 00008 * you may not use this file except in compliance with the License. 00009 * You may obtain a copy of the License at 00010 * 00011 * http://www.apache.org/licenses/LICENSE-2.0 00012 * 00013 * Unless required by applicable law or agreed to in writing, software 00014 * distributed under the License is distributed on an "AS IS" BASIS, 00015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00016 * See the License for the specific language governing permissions and 00017 * limitations under the License. 00018 * 00019 * http://www.elefantracing.de 00020 * 00021 * @ERB_OPEN_LICENSE_HEADER_END@ 00022 */ 00023 00040 #ifndef BCS_SEMAPHORE_H_ 00041 #define BCS_SEMAPHORE_H_ 00042 00043 #ifdef __cplusplus 00044 extern "C" { 00045 #endif 00046 00047 #include "bcs_general.h" 00048 00049 #ifdef USE_POSIX_SEM 00050 #define BCS_SEM_FAILED SEM_FAILED 00051 #define BCS_SEM_VALUE_MAX SEM_VALUE_MAX 00052 #endif 00053 #ifdef USE_SYSV_SEM 00054 #define BCS_SEM_FAILED -1 00055 #endif 00056 00088 BCS_Semaphore BCS_sem_open(const char* name, int oflag, int mode, int initial); 00089 00100 inline BCS_ERROR BCS_sem_post(BCS_Semaphore sem); 00101 00111 inline BCS_ERROR BCS_sem_wait(BCS_Semaphore sem); 00112 00122 inline BCS_ERROR BCS_sem_trywait(BCS_Semaphore sem); 00123 00131 inline BCS_ERROR BCS_sem_close(BCS_Semaphore sem); 00132 00141 inline BCS_ERROR BCS_sem_unlink(const char* name); 00142 00143 #ifdef __cplusplus 00144 } 00145 #endif 00146 00147 #endif /* BCS_SEMAPHORE_H_ */