Browse code

- s/lock_t/gen_lock_t/ to avoid a type conflict on solaris

Andrei Pelinescu-Onciul authored on 20/02/2003 18:30:15
Showing 6 changed files
... ...
@@ -8,7 +8,7 @@
8 8
 VERSION = 0
9 9
 PATCHLEVEL = 8
10 10
 SUBLEVEL =   11
11
-EXTRAVERSION = pre6-tcp5-tm
11
+EXTRAVERSION = pre6-tcp6-tm
12 12
 
13 13
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
14 14
 OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]")
... ...
@@ -28,17 +28,18 @@
28 28
 /*
29 29
  *   ser locking library
30 30
  *
31
- *  2002-12-16 created by andrei
32
- *
31
+ *  2002-12-16  created by andrei
32
+ *  2003-02-20  s/gen_lock_t/gen_lock_t/ to avoid a type conflict 
33
+ *               on solaris  (andrei)
33 34
  *
34 35
 Implements:
35 36
 
36
-	lock_t* lock_alloc();                    - allocates a lock in shared mem.
37
-	lock_t* lock_init(lock_t* lock);         - inits the lock
38
-	void    lock_destroy(lock_t* lock);      - removes the lock (e.g sysv rmid)
39
-	void    lock_dealloc(lock_t* lock);      - deallocates the lock's shared m.
40
-	void    lock_get(lock_t* lock);          - lock (mutex down)
41
-	void    lock_release(lock_t* lock);      - unlock (mutex up)
37
+	gen_lock_t* lock_alloc();               - allocates a lock in shared mem.
38
+	gen_lock_t* lock_init(gen_lock_t* lock);    - inits the lock
39
+	void    lock_destroy(gen_lock_t* lock); - removes the lock (e.g sysv rmid)
40
+	void    lock_dealloc(gen_lock_t* lock); - deallocates the lock's shared m.
41
+	void    lock_get(gen_lock_t* lock);     - lock (mutex down)
42
+	void    lock_release(gen_lock_t* lock); - unlock (mutex up)
42 43
 */
43 44
 
44 45
 #ifndef _locking_h
... ...
@@ -48,13 +49,13 @@ Implements:
48 48
 #ifdef FAST_LOCK
49 49
 #include "fastlock.h"
50 50
 
51
-typedef fl_lock_t lock_t;
51
+typedef fl_lock_t gen_lock_t;
52 52
 
53
-#define lock_alloc() shm_malloc(sizeof(lock_t))
53
+#define lock_alloc() shm_malloc(sizeof(gen_lock_t))
54 54
 #define lock_destroy(lock) /* do nothing */ 
55 55
 #define lock_dealloc(lock) shm_free(lock)
56 56
 
57
-inline static lock_t* lock_init(lock_t* lock)
57
+inline static gen_lock_t* lock_init(gen_lock_t* lock)
58 58
 {
59 59
 	init_lock(*lock);
60 60
 	return lock;
... ...
@@ -68,13 +69,13 @@ inline static lock_t* lock_init(lock_t* lock)
68 68
 #elif defined USE_PTHREAD_MUTEX
69 69
 #include <pthread.h>
70 70
 
71
-typedef pthread_mutex_t lock_t;
71
+typedef pthread_mutex_t gen_lock_t;
72 72
 
73
-#define lock_alloc() shm_malloc(sizeof(lock_t))
73
+#define lock_alloc() shm_malloc(sizeof(gen_lock_t))
74 74
 #define lock_destroy(lock) /* do nothing */ 
75 75
 #define lock_dealloc(lock) shm_free(lock)
76 76
 
77
-inline static lock_t* lock_init(lock_t* lock)
77
+inline static gen_lock_t* lock_init(gen_lock_t* lock)
78 78
 {
79 79
 	if (pthread_mutex_init(lock, 0)==0) return lock;
80 80
 	else return 0;
... ...
@@ -88,13 +89,13 @@ inline static lock_t* lock_init(lock_t* lock)
88 88
 #elif defined USE_POSIX_SEM
89 89
 #include <semaphore.h>
90 90
 
91
-typedef sem_t lock_t;
91
+typedef sem_t gen_lock_t;
92 92
 
93
-#define lock_alloc() shm_malloc(sizeof(lock_t))
93
+#define lock_alloc() shm_malloc(sizeof(gen_lock_t))
94 94
 #define lock_destroy(lock) /* do nothing */ 
95 95
 #define lock_dealloc(lock) shm_free(lock)
96 96
 
97
-inline static lock_t* lock_init(lock_t* lock)
97
+inline static gen_lock_t* lock_init(gen_lock_t* lock)
98 98
 {
99 99
 	if (sem_init(lock, 1, 1)<0) return 0;
100 100
 	return lock;
... ...
@@ -121,13 +122,13 @@ inline static lock_t* lock_init(lock_t* lock)
121 121
 	};
122 122
 #endif
123 123
 
124
-typedef int lock_t;
124
+typedef int gen_lock_t;
125 125
 
126
-#define lock_alloc() shm_malloc(sizeof(lock_t))
126
+#define lock_alloc() shm_malloc(sizeof(gen_lock_t))
127 127
 #define lock_dealloc(lock) shm_free(lock)
128 128
 
129 129
 
130
-inline static lock_t* lock_init(lock_t* lock)
130
+inline static gen_lock_t* lock_init(gen_lock_t* lock)
131 131
 {
132 132
 	union semun su;
133 133
 	
... ...
@@ -141,14 +142,14 @@ inline static lock_t* lock_init(lock_t* lock)
141 141
 	return lock;
142 142
 }
143 143
 
144
-inline static void lock_destroy(lock_t* lock)
144
+inline static void lock_destroy(gen_lock_t* lock)
145 145
 {
146 146
 	semctl(*lock, 0, IPC_RMID, (union semun)(int)0);
147 147
 }
148 148
 
149 149
 #define lock_dealloc(lock) shm_free(lock)
150 150
 
151
-inline static void lock_get(lock_t* lock)
151
+inline static void lock_get(gen_lock_t* lock)
152 152
 {
153 153
 	struct sembuf sop;
154 154
 
... ...
@@ -158,7 +159,7 @@ inline static void lock_get(lock_t* lock)
158 158
 	semop(*lock, &sop, 1);
159 159
 }
160 160
 
161
-inline static void lock_release(lock_t* lock)
161
+inline static void lock_release(gen_lock_t* lock)
162 162
 {
163 163
 	struct sembuf sop;
164 164
 	
... ...
@@ -51,7 +51,7 @@
51 51
 static int shm_shmid=-1; /*shared memory id*/
52 52
 #endif
53 53
 
54
-lock_t* mem_lock=0;
54
+gen_lock_t* mem_lock=0;
55 55
 
56 56
 static void* shm_mempool=(void*)-1;
57 57
 #ifdef VQ_MALLOC
... ...
@@ -224,7 +224,8 @@ int shm_mem_init()
224 224
 		shm_mem_destroy();
225 225
 		return -1;
226 226
 	}
227
-	mem_lock=shm_malloc_unsafe(sizeof(lock_t)); /* skip lock_alloc, race cond*/
227
+	mem_lock=shm_malloc_unsafe(sizeof(gen_lock_t)); /* skip lock_alloc, 
228
+													   race cond*/
228 229
 	if (mem_lock==0){
229 230
 		LOG(L_CRIT, "ERROR: shm_mem_init: could not allocate lock\n");
230 231
 		shm_mem_destroy();
... ...
@@ -73,7 +73,7 @@
73 73
 #endif
74 74
 
75 75
 	
76
-	extern lock_t* mem_lock;
76
+	extern gen_lock_t* mem_lock;
77 77
 
78 78
 
79 79
 int shm_mem_init();
... ...
@@ -84,7 +84,7 @@ struct tcp_req{
84 84
 struct tcp_connection{
85 85
 	int s; /*socket, used by "tcp main" */
86 86
 	int fd; /* used only by "children", don't modify it! private data! */
87
-	lock_t write_lock;
87
+	gen_lock_t write_lock;
88 88
 	int id; /* id (unique!) used to retrieve a specific connection when
89 89
 	           reply-ing*/
90 90
 	struct receive_info rcv; /* src & dst ip, ports, proto a.s.o*/
... ...
@@ -80,7 +80,7 @@ struct tcp_child{
80 80
 struct tcp_connection** tcpconn_addr_hash=0;
81 81
 /* connection hash table (after connection id) */
82 82
 struct tcp_connection** tcpconn_id_hash=0;
83
-lock_t* tcpconn_lock=0;
83
+gen_lock_t* tcpconn_lock=0;
84 84
 
85 85
 struct tcp_child tcp_children[MAX_TCP_CHILDREN];
86 86
 static int connection_id=1; /*  unique for each connection, used for