Browse Source

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

Andrei Pelinescu-Onciul 22 years ago
parent
commit
0bd532974f
6 changed files with 31 additions and 29 deletions
  1. 1 1
      Makefile.defs
  2. 24 23
      locking.h
  3. 3 2
      mem/shm_mem.c
  4. 1 1
      mem/shm_mem.h
  5. 1 1
      tcp_conn.h
  6. 1 1
      tcp_main.c

+ 1 - 1
Makefile.defs

@@ -8,7 +8,7 @@
 VERSION = 0
 VERSION = 0
 PATCHLEVEL = 8
 PATCHLEVEL = 8
 SUBLEVEL =   11
 SUBLEVEL =   11
-EXTRAVERSION = pre6-tcp5-tm
+EXTRAVERSION = pre6-tcp6-tm
 
 
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]")
 OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]")

+ 24 - 23
locking.h

@@ -28,17 +28,18 @@
 /*
 /*
  *   ser locking library
  *   ser locking library
  *
  *
- *  2002-12-16 created by andrei
- *
+ *  2002-12-16  created by andrei
+ *  2003-02-20  s/gen_lock_t/gen_lock_t/ to avoid a type conflict 
+ *               on solaris  (andrei)
  *
  *
 Implements:
 Implements:
 
 
-	lock_t* lock_alloc();                    - allocates a lock in shared mem.
-	lock_t* lock_init(lock_t* lock);         - inits the lock
-	void    lock_destroy(lock_t* lock);      - removes the lock (e.g sysv rmid)
-	void    lock_dealloc(lock_t* lock);      - deallocates the lock's shared m.
-	void    lock_get(lock_t* lock);          - lock (mutex down)
-	void    lock_release(lock_t* lock);      - unlock (mutex up)
+	gen_lock_t* lock_alloc();               - allocates a lock in shared mem.
+	gen_lock_t* lock_init(gen_lock_t* lock);    - inits the lock
+	void    lock_destroy(gen_lock_t* lock); - removes the lock (e.g sysv rmid)
+	void    lock_dealloc(gen_lock_t* lock); - deallocates the lock's shared m.
+	void    lock_get(gen_lock_t* lock);     - lock (mutex down)
+	void    lock_release(gen_lock_t* lock); - unlock (mutex up)
 */
 */
 
 
 #ifndef _locking_h
 #ifndef _locking_h
@@ -48,13 +49,13 @@ Implements:
 #ifdef FAST_LOCK
 #ifdef FAST_LOCK
 #include "fastlock.h"
 #include "fastlock.h"
 
 
-typedef fl_lock_t lock_t;
+typedef fl_lock_t gen_lock_t;
 
 
-#define lock_alloc() shm_malloc(sizeof(lock_t))
+#define lock_alloc() shm_malloc(sizeof(gen_lock_t))
 #define lock_destroy(lock) /* do nothing */ 
 #define lock_destroy(lock) /* do nothing */ 
 #define lock_dealloc(lock) shm_free(lock)
 #define lock_dealloc(lock) shm_free(lock)
 
 
-inline static lock_t* lock_init(lock_t* lock)
+inline static gen_lock_t* lock_init(gen_lock_t* lock)
 {
 {
 	init_lock(*lock);
 	init_lock(*lock);
 	return lock;
 	return lock;
@@ -68,13 +69,13 @@ inline static lock_t* lock_init(lock_t* lock)
 #elif defined USE_PTHREAD_MUTEX
 #elif defined USE_PTHREAD_MUTEX
 #include <pthread.h>
 #include <pthread.h>
 
 
-typedef pthread_mutex_t lock_t;
+typedef pthread_mutex_t gen_lock_t;
 
 
-#define lock_alloc() shm_malloc(sizeof(lock_t))
+#define lock_alloc() shm_malloc(sizeof(gen_lock_t))
 #define lock_destroy(lock) /* do nothing */ 
 #define lock_destroy(lock) /* do nothing */ 
 #define lock_dealloc(lock) shm_free(lock)
 #define lock_dealloc(lock) shm_free(lock)
 
 
-inline static lock_t* lock_init(lock_t* lock)
+inline static gen_lock_t* lock_init(gen_lock_t* lock)
 {
 {
 	if (pthread_mutex_init(lock, 0)==0) return lock;
 	if (pthread_mutex_init(lock, 0)==0) return lock;
 	else return 0;
 	else return 0;
@@ -88,13 +89,13 @@ inline static lock_t* lock_init(lock_t* lock)
 #elif defined USE_POSIX_SEM
 #elif defined USE_POSIX_SEM
 #include <semaphore.h>
 #include <semaphore.h>
 
 
-typedef sem_t lock_t;
+typedef sem_t gen_lock_t;
 
 
-#define lock_alloc() shm_malloc(sizeof(lock_t))
+#define lock_alloc() shm_malloc(sizeof(gen_lock_t))
 #define lock_destroy(lock) /* do nothing */ 
 #define lock_destroy(lock) /* do nothing */ 
 #define lock_dealloc(lock) shm_free(lock)
 #define lock_dealloc(lock) shm_free(lock)
 
 
-inline static lock_t* lock_init(lock_t* lock)
+inline static gen_lock_t* lock_init(gen_lock_t* lock)
 {
 {
 	if (sem_init(lock, 1, 1)<0) return 0;
 	if (sem_init(lock, 1, 1)<0) return 0;
 	return lock;
 	return lock;
@@ -121,13 +122,13 @@ inline static lock_t* lock_init(lock_t* lock)
 	};
 	};
 #endif
 #endif
 
 
-typedef int lock_t;
+typedef int gen_lock_t;
 
 
-#define lock_alloc() shm_malloc(sizeof(lock_t))
+#define lock_alloc() shm_malloc(sizeof(gen_lock_t))
 #define lock_dealloc(lock) shm_free(lock)
 #define lock_dealloc(lock) shm_free(lock)
 
 
 
 
-inline static lock_t* lock_init(lock_t* lock)
+inline static gen_lock_t* lock_init(gen_lock_t* lock)
 {
 {
 	union semun su;
 	union semun su;
 	
 	
@@ -141,14 +142,14 @@ inline static lock_t* lock_init(lock_t* lock)
 	return lock;
 	return lock;
 }
 }
 
 
-inline static void lock_destroy(lock_t* lock)
+inline static void lock_destroy(gen_lock_t* lock)
 {
 {
 	semctl(*lock, 0, IPC_RMID, (union semun)(int)0);
 	semctl(*lock, 0, IPC_RMID, (union semun)(int)0);
 }
 }
 
 
 #define lock_dealloc(lock) shm_free(lock)
 #define lock_dealloc(lock) shm_free(lock)
 
 
-inline static void lock_get(lock_t* lock)
+inline static void lock_get(gen_lock_t* lock)
 {
 {
 	struct sembuf sop;
 	struct sembuf sop;
 
 
@@ -158,7 +159,7 @@ inline static void lock_get(lock_t* lock)
 	semop(*lock, &sop, 1);
 	semop(*lock, &sop, 1);
 }
 }
 
 
-inline static void lock_release(lock_t* lock)
+inline static void lock_release(gen_lock_t* lock)
 {
 {
 	struct sembuf sop;
 	struct sembuf sop;
 	
 	

+ 3 - 2
mem/shm_mem.c

@@ -51,7 +51,7 @@
 static int shm_shmid=-1; /*shared memory id*/
 static int shm_shmid=-1; /*shared memory id*/
 #endif
 #endif
 
 
-lock_t* mem_lock=0;
+gen_lock_t* mem_lock=0;
 
 
 static void* shm_mempool=(void*)-1;
 static void* shm_mempool=(void*)-1;
 #ifdef VQ_MALLOC
 #ifdef VQ_MALLOC
@@ -224,7 +224,8 @@ int shm_mem_init()
 		shm_mem_destroy();
 		shm_mem_destroy();
 		return -1;
 		return -1;
 	}
 	}
-	mem_lock=shm_malloc_unsafe(sizeof(lock_t)); /* skip lock_alloc, race cond*/
+	mem_lock=shm_malloc_unsafe(sizeof(gen_lock_t)); /* skip lock_alloc, 
+													   race cond*/
 	if (mem_lock==0){
 	if (mem_lock==0){
 		LOG(L_CRIT, "ERROR: shm_mem_init: could not allocate lock\n");
 		LOG(L_CRIT, "ERROR: shm_mem_init: could not allocate lock\n");
 		shm_mem_destroy();
 		shm_mem_destroy();

+ 1 - 1
mem/shm_mem.h

@@ -73,7 +73,7 @@
 #endif
 #endif
 
 
 	
 	
-	extern lock_t* mem_lock;
+	extern gen_lock_t* mem_lock;
 
 
 
 
 int shm_mem_init();
 int shm_mem_init();

+ 1 - 1
tcp_conn.h

@@ -84,7 +84,7 @@ struct tcp_req{
 struct tcp_connection{
 struct tcp_connection{
 	int s; /*socket, used by "tcp main" */
 	int s; /*socket, used by "tcp main" */
 	int fd; /* used only by "children", don't modify it! private data! */
 	int fd; /* used only by "children", don't modify it! private data! */
-	lock_t write_lock;
+	gen_lock_t write_lock;
 	int id; /* id (unique!) used to retrieve a specific connection when
 	int id; /* id (unique!) used to retrieve a specific connection when
 	           reply-ing*/
 	           reply-ing*/
 	struct receive_info rcv; /* src & dst ip, ports, proto a.s.o*/
 	struct receive_info rcv; /* src & dst ip, ports, proto a.s.o*/

+ 1 - 1
tcp_main.c

@@ -80,7 +80,7 @@ struct tcp_child{
 struct tcp_connection** tcpconn_addr_hash=0;
 struct tcp_connection** tcpconn_addr_hash=0;
 /* connection hash table (after connection id) */
 /* connection hash table (after connection id) */
 struct tcp_connection** tcpconn_id_hash=0;
 struct tcp_connection** tcpconn_id_hash=0;
-lock_t* tcpconn_lock=0;
+gen_lock_t* tcpconn_lock=0;
 
 
 struct tcp_child tcp_children[MAX_TCP_CHILDREN];
 struct tcp_child tcp_children[MAX_TCP_CHILDREN];
 static int connection_id=1; /*  unique for each connection, used for 
 static int connection_id=1; /*  unique for each connection, used for