/[libspopc]/mutex.h
ViewVC logotype

Contents of /mutex.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4 - (show annotations)
Thu Oct 15 23:10:35 2009 UTC (11 years ago) by ben
File MIME type: text/plain
File size: 1754 byte(s)
added possiblilty to use POSIX mutexes instead of unix semaphores
1 /* this is mutex.h file, part of the libspopc library sources
2 * copyright © 2002- Benoit Rouits <brouits@free.fr>
3 * released under the terms of the GNU Lesser General Public Licence.
4 *
5 * libspopc offers simple API for a pop3 client.
6 * See RFC 1725 for pop3 specifications.
7 * more information on http://herewe.servebeer.com/libspopc/
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24 #ifndef MUTEX_H
25 #define MUTEX_H
26
27 #ifdef USE_SEM /* no posix thread mutex */
28 #include <semaphore.h>
29 typedef sem_t mutex; /* use unix rt semaphores from librt */
30 #else
31 #ifdef USE_PMUTEX
32 #include <pthread.h>
33 typedef pthread_mutex_t mutex; /* use posix thread mutexes */
34 #else
35 typedef int mutex;
36 #endif
37 #endif
38
39 /* initializes a thread-wide mutex */
40 int mutex_init(mutex* id);
41
42 /* acquire the given mutex to enter in a critical section */
43 int mutex_in (mutex* id);
44
45 /* quit the critical section, by releasing the given mutex */
46 int mutex_out (mutex* id);
47
48 /* clean the mutex, thus re-initable by mutex_init() */
49 int mutex_clean(mutex* id);
50
51 #endif

  ViewVC Help
Powered by ViewVC 1.1.26