Fix typo 'ation'.
[privoxy.git] / src / ipc.h
1 #ifndef IPC_H_INCLUDED
2 #define IPC_H_INCLUDED
3 #define IPC_H_VERSION "$Id: ipc.h,v 2.0 2002/06/04 14:34:21 jongfoster Exp $"
4 /*********************************************************************
5  *
6  * File        :  $Source: /cvsroot/ijbswa/current/src/ipc.h,v $
7  *
8  * Purpose     :  Functions to provide portable interprocess
9  *                communications: semaphores, sleeping, etc.
10  *
11  * Copyright   :  Written by and Copyright (C) 2002, 2003 the SourceForge
12  *                Privoxy team. http://www.privoxy.org/
13  *
14  *                Based on the Internet Junkbuster originally written
15  *                by and Copyright (C) 1997 Anonymous Coders and 
16  *                Junkbusters Corporation.  http://www.junkbusters.com
17  *
18  *                This program is free software; you can redistribute it 
19  *                and/or modify it under the terms of the GNU General
20  *                Public License as published by the Free Software
21  *                Foundation; either version 2 of the License, or (at
22  *                your option) any later version.
23  *
24  *                This program is distributed in the hope that it will
25  *                be useful, but WITHOUT ANY WARRANTY; without even the
26  *                implied warranty of MERCHANTABILITY or FITNESS FOR A
27  *                PARTICULAR PURPOSE.  See the GNU General Public
28  *                License for more details.
29  *
30  *                The GNU General Public License should be included with
31  *                this file.  If not, you can view it at
32  *                http://www.gnu.org/copyleft/gpl.html
33  *                or write to the Free Software Foundation, Inc., 59
34  *                Temple Place - Suite 330, Boston, MA  02111-1307, USA.
35  *
36  * Revisions   :
37  *    $Log: ipc.h,v $
38  *
39  *********************************************************************/
40 \f
41
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45
46 /*
47  * Here, we define common ways of defining mutual exclusion variables
48  * and the manipulation thereof.  We define an alias for the type that
49  * particular OSes like to see, and we have a common model of locking
50  * and unlocking them.
51  */
52
53 #ifdef _WIN32
54   #include <windows.h>
55   #define IPC_MUTEX_LOCK HANDLE
56   #define IPC_CREATE_MUTEX(lock) InitializeCriticalSection(&lock)
57   #define IPC_LOCK_MUTEX(lock) EnterCriticalSection(lock)
58   #define IPC_UNLOCK_MUTEX(lock) LeaveCriticalSection(lock)
59   #define IPC_SLEEP_SECONDS(seconds) Sleep(seconds * 1000)
60 #elif __OS2__
61   #define INCL_DOSSEMAPHORES
62   #define INCL_DOSPROCESS
63   #include <os2.h>
64   #define IPC_MUTEX_LOCK HMTX
65   #define IPC_CREATE_MUTEX(lock) DosCreateMutexSem(NULL, &lock, 0, FALSE)
66   #define IPC_LOCK_MUTEX(lock) DosRequestMutexSem(lock,SEM_INDEFINITE_WAIT)
67   #define IPC_UNLOCK_MUTEX(lock) DosReleaseMutexSem(lock)
68   #define IPC_SLEEP_SECONDS(seconds) DosSleep(seconds * 1000)
69 #else
70   /* Generic unix processing.  This will probably need tweaking for variants. */
71   #include <sys/signal.h>
72   #include <pthread.h>
73   #define IPC_MUTEX_LOCK pthread_mutex_t
74   #define IPC_CREATE_MUTEX(lock) pthread_mutex_init(&lock,0)
75   #define IPC_LOCK_MUTEX(lock) pthread_mutex_lock(&lock)
76   #define IPC_UNLOCK_MUTEX(lock) pthread_mutex_unlock(&lock)
77   #define IPC_SLEEP_SECONDS(seconds) sleep(seconds)
78 #endif
79
80 #ifdef __cplusplus
81 } /* extern "C" */
82 #endif
83
84 #endif /* ndef IPC_H_INCLUDED */
85
86 /*
87   Local Variables:
88   tab-width: 3
89   end:
90 */