2 * $Id: sysdep.c 5691 2007-11-04 23:19:17Z dothebart $
4 * Citadel "system dependent" stuff.
5 * See copyright.txt for copyright information.
7 * Here's where we (hopefully) have most parts of the Citadel server that
8 * would need to be altered to run the server in a non-POSIX environment.
10 * If we ever port to a different platform and either have multiple
11 * variants of this file or simply load it up with #ifdefs.
22 #include <sys/types.h>
25 #include <sys/socket.h>
27 #include <sys/syslog.h>
29 #if TIME_WITH_SYS_TIME
30 # include <sys/time.h>
34 # include <sys/time.h>
41 #include <sys/resource.h>
42 #include <netinet/in.h>
43 #include <netinet/tcp.h>
44 #include <arpa/inet.h>
58 #ifdef HAVE_SYS_SELECT_H
59 #include <sys/select.h>
66 pthread_mutex_t Critters
[MAX_SEMAPHORES
]; /* Things needing locking */
67 pthread_key_t MyConKey
; /* TSD key for MyContext() */
68 pthread_key_t MyReq
; /* TSD key for MyReq() */
70 void InitialiseSemaphores(void)
74 /* Set up a bunch of semaphores to be used for critical sections */
75 for (i
=0; i
<MAX_SEMAPHORES
; ++i
) {
76 pthread_mutex_init(&Critters
[i
], NULL
);
81 * Obtain a semaphore lock to begin a critical section.
83 void begin_critical_section(int which_one
)
85 /* lprintf(CTDL_DEBUG, "begin_critical_section(%d)\n", which_one); */
86 pthread_mutex_lock(&Critters
[which_one
]);
90 * Release a semaphore lock to end a critical section.
92 void end_critical_section(int which_one
)
94 pthread_mutex_unlock(&Critters
[which_one
]);