3 #define IPC_H_VERSION "$Id: ipc.h,v 2.0 2002/06/04 14:34:21 jongfoster Exp $"
4 /*********************************************************************
6 * File : $Source: /cvsroot/ijbswa/current/src/ipc.h,v $
8 * Purpose : Functions to provide portable interprocess
9 * communications: semaphores, sleeping, etc.
11 * Copyright : Written by and Copyright (C) 2002, 2003 the SourceForge
12 * Privoxy team. http://www.privoxy.org/
14 * Based on the Internet Junkbuster originally written
15 * by and Copyright (C) 1997 Anonymous Coders and
16 * Junkbusters Corporation. http://www.junkbusters.com
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.
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.
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.
39 *********************************************************************/
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
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)
61 #define INCL_DOSSEMAPHORES
62 #define INCL_DOSPROCESS
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)
70 /* Generic unix processing. This will probably need tweaking for variants. */
71 #include <sys/signal.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)
84 #endif /* ndef IPC_H_INCLUDED */