nfs-ganesha 1.4

SemN.c

Go to the documentation of this file.
00001 /*
00002  * vim:expandtab:shiftwidth=8:tabstop=8:
00003  *
00004  * Copyright CEA/DAM/DIF  (2008)
00005  * contributeur : Philippe DENIEL   philippe.deniel@cea.fr
00006  *                Thomas LEIBOVICI  thomas.leibovici@cea.fr
00007  *
00008  *
00009  * This program is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU Lesser General Public
00011  * License as published by the Free Software Foundation; either
00012  * version 3 of the License, or (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017  * Lesser General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU Lesser General Public
00020  * License along with this library; if not, write to the Free Software
00021  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00022  *
00023  * ---------------------------------------
00024  */
00025 
00063 #ifdef HAVE_CONFIG_H
00064 #include "config.h"
00065 #endif
00066 
00067 #include <errno.h>
00068 #include "SemN.h"
00069 #include <stdio.h>
00070 #include <semaphore.h>
00071 
00072 #define MODULE "SemN"
00073 
00074 int semaphore_init(semaphore_t * sem, unsigned int value)
00075 {
00076   if(!sem)
00077     return EINVAL;
00078 
00079    return sem_init(&sem->semaphore,
00080                    0 /* Not shared accross processes */, 
00081                    value) ;
00082 }
00083 
00084 int semaphore_destroy(semaphore_t * sem)
00085 {
00086 
00087   if(!sem)
00088     return EINVAL;
00089 
00090   return sem_destroy( &sem->semaphore ) ;
00091 }
00092 
00093 void semaphore_P(semaphore_t * sem)
00094 {
00095     sem_wait( &sem->semaphore ); 
00096 }
00097 
00098 void semaphore_V(semaphore_t * sem)
00099 {
00100     sem_post( &sem->semaphore ) ;
00101 }