Browse Source

- mac os x support ported from stable
- version increased to 0.8.99-dev
- makefile gcc version detection update (should correctly detect the version on gentoo now)
- other small 0.8.14 fixes

Andrei Pelinescu-Onciul 21 years ago
parent
commit
194b6a3575
13 changed files with 123 additions and 61 deletions
  1. 0 3
      INSTALL
  2. 2 1
      Makefile
  3. 35 7
      Makefile.defs
  4. 21 7
      README-MODULES
  5. 5 5
      ccver.sh
  6. 4 4
      cfg.y
  7. 13 10
      lock_alloc.h
  8. 15 13
      lock_ops.h
  9. 9 7
      locking.h
  10. 6 0
      mem/shm_mem.c
  11. 5 3
      modules/tm/lock.c
  12. 3 1
      modules/tm/lock.h
  13. 5 0
      resolve.h

+ 0 - 3
INSTALL

@@ -71,9 +71,6 @@ OS Notes:
 - FreeBSD/OpenBSD/NetBSD: make sure gmake, bison or yacc & flex are installed
 - Solaris: as above; you can use Solaris's yacc instead of bison. You might
   need also gtar and ginstall.
-- Windows: it works in windows (only the core, w/o shared mem. support) but you
-  must install a recent cygwin version (http://www.cygwin.com/) and also 
-  install a newer regex library version (>=0.12). 
     
 
 2. Howto Build ser From Source Distribution

+ 2 - 1
Makefile

@@ -82,7 +82,6 @@ modules_basenames=$(shell echo $(modules)| \
 #modules_names=$(patsubst modules/%, %.so, $(modules))
 modules_full_path=$(join  $(modules), $(addprefix /, $(modules_names)))
 
-NAME=ser
 
 ALLDEP=Makefile Makefile.sources Makefile.defs Makefile.rules
 
@@ -93,6 +92,8 @@ makefile_defs=0
 DEFS:=
 include Makefile.defs
 
+NAME=$(MAIN_NAME)
+
 #export relevant variables to the sub-makes
 export DEFS PROFILE CC  LD MKDEP MKTAGS CFLAGS LDFLAGS MOD_CFLAGS MOD_LDFLAGS
 export LEX YACC YACC_FLAGS

+ 35 - 7
Makefile.defs

@@ -31,6 +31,7 @@
 #              code exists (sobomax)
 #  2003-11-08  mips1 support introduced (andrei)
 #  2003-11-24  openbsd 3.4 (elf) fixes (andrei)
+#  2004-07-27  darwin (mac os x) port  (andrei)
 
 
 # check if already included/exported
@@ -40,17 +41,19 @@ else
 makefile_defs=1
 export makefile_defs
 
+# main binary name
+MAIN_NAME=ser
 
 #version number
 VERSION = 0
 PATCHLEVEL = 8
-SUBLEVEL =   13
-EXTRAVERSION = -dev-36-malloc
+SUBLEVEL =   99
+EXTRAVERSION = -dev
 
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]")
 ARCH = $(shell uname -m |sed -e s/i.86/i386/ -e s/sun4u/sparc64/  \
-			-e s/armv4l/arm/)
+			-e s/armv4l/arm/ -e "s/Power Macintosh/ppc/" )
 OSREL = $(shell uname -r)
 
 # TLS support
@@ -100,6 +103,10 @@ else
 ifeq ($(OS), netbsd)
 	doc-dir = share/doc/ser
 	man-dir = man/
+else
+ifeq ($(OS), darwin)
+	doc-dir = share/doc/ser/
+	man-dir = man/
 else
 	doc-dir = doc/ser/
 	man-dir = man/
@@ -107,6 +114,7 @@ endif
 endif
 endif
 endif
+endif
 ut-prefix = bin/
 # target dirs for various stuff
 cfg-target = $(prefix)/$(cfg-dir)
@@ -154,8 +162,8 @@ MKTAGS=ctags -R .
 
 ifneq (,$(findstring gcc, $(CC_LONGVER)))
 	CC_NAME=gcc
-	CC_VER=$(CC) $(shell $(CC) --version|head -1| \
-				 sed -e 's/.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/' -e 's/[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/')
+	CC_VER=$(CC) $(shell $(CC) --version|head -n 1| \
+				 sed -e 's/^[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/' -e 's/^[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/')
 	# sun sed is a little brain damaged => this complicated expression
 	MKDEP=$(CC) -MM 
 	#transform gcc version into 2.9x or 3.0
@@ -167,7 +175,7 @@ endif
 
 ifneq (, $(findstring Sun, $(CC_LONGVER)))
 	CC_NAME=suncc
-	CC_SHORTVER=$(shell echo "$(CC_LONGVER)"|head -1| \
+	CC_SHORTVER=$(shell echo "$(CC_LONGVER)"|head -n 1| \
 					sed -e 's/.*\([0-9]\.[0-9]\).*/\1/g' )
 	CC_VER=$(CC) $(CC_SHORTVER)
 	MKDEP=$(CC) -xM1 
@@ -176,7 +184,7 @@ endif
 ifneq (, $(findstring Intel(R) C++ Compiler, $(CC_LONGVER)))
 	# very nice: gcc compatible
 	CC_NAME=icc
-	CC_FULLVER=$(shell echo "$(CC_LONGVER)"|head -1| \
+	CC_FULLVER=$(shell echo "$(CC_LONGVER)"|head -n 1| \
 					sed -e 's/.*Version \([0-9]\.[0-9]\.[0-9]*\).*/\1/g' )
 	CC_SHORTVER=$(shell echo "$(CC_FULLVER)" | cut -d. -f1,2 )
 	CC_VER=$(CC) $(CC_FULLVER)
@@ -733,6 +741,26 @@ ifeq ($(OS), netbsd)
 	LIBS= -lfl 
 endif
 
+# OS X support, same as freebsd
+ifeq ($(OS), darwin)
+	DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN \
+		-DHAVE_SCHED_YIELD -DHAVE_MSGHDR_MSG_CONTROL \
+		-DUSE_ANON_MMAP \
+		-DNDEBUG
+	# -DNDEBUG used to turn off assert (assert wants to call
+	# eprintf which doesn't seem to be defined in any shared lib
+	ifneq ($(found_lock_method), yes)
+		DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
+		found_lock_method=yes
+		LIBS= -pthread -lfl -lresolv  #dlopen is in libc
+	else
+		LIBS= -lfl -lresolv  #dlopen is in libc
+	endif
+	LDFLAGS=        # darwin doesn't like -O2 or -E
+	MOD_LDFLAGS= -bundle -bundle_loader ../../$(MAIN_NAME)
+	YACC=yacc
+endif
+
 ifneq (,$(findstring CYGWIN, $(OS)))
 	#cygwin is the same as common
 	ifneq ($(found_lock_method), yes)

+ 21 - 7
README-MODULES

@@ -52,13 +52,6 @@ Maturity:   beta
 Depends on: auth
 Purpose:    Radius support for digest authentication
 
-Name:       cpl
-Owner:      bogdan
-Use:        experimental
-Maturity:   alpha
-Depends on: -
-Purpose:    Call Processing Language
-
 Name:       cpl-c
 Owner:      bogdan
 Use:        experimental
@@ -235,6 +228,13 @@ Maturity:   alpha
 Depends on: tm
 Purpose:    Voicemail interface
 
+Name:       xlog
+Owner:      ramona
+Use:        regular
+Maturity:   stable
+Depends on: 
+Purpose:    formatted logging (printf style)
+
 Contributions
 -------------
 Name:       domain
@@ -258,6 +258,20 @@ Maturity:   beta
 Depends on: -
 Purpose:    support for maintenance of multiple domains
 
+Name:       mediaproxy
+Owner:      danp, agprojects
+Use:        regular
+Maturity:   stable
+Depends on: mediaproxy media relay
+Purpose:    nat traversal
+
+Name:       nathelper
+Owner:      sobomax
+Use:        regular
+Maturity:   stable
+Depends on: rtpproxy
+Purpose:    nat traversal
+
 Name:		permissions
 Owner:		tirpi
 Use:		experimental

+ 5 - 5
ccver.sh

@@ -48,18 +48,18 @@ then
 	if echo "$FULLVER"|grep gcc >/dev/null
 	then
 		NAME=gcc
-		VER=`$CC --version|head -1| \
-				sed -e 's/.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/'\
-				    -e 's/.*[^.0-9]\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/'`
+		VER=`$CC --version|head -n 1| \
+				sed -e 's/^[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/'\
+				    -e 's/^[^.0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/'`
 	elif echo "$FULLVER"|grep Sun >/dev/null
 	then
 		NAME=suncc
-		VER=`echo "$FULLVER"|head -1| \
+		VER=`echo "$FULLVER"|head -n 1| \
 				sed -e 's/.*\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/'`
 	elif echo "$FULLVER"|grep "Intel(R) C++ Compiler" >/dev/null
 	then
 		NAME=icc
-		VER=`echo "$FULLVER"|head -1| \
+		VER=`echo "$FULLVER"|head -n 1| \
 				sed -e 's/.*Version \([0-9]\.[0-9]\.[0-9]*\).*/\1/' ` 
 	fi
 	

+ 4 - 4
cfg.y

@@ -106,7 +106,7 @@ struct id_list{
 };
 
 extern int yylex();
-void yyerror(char* s);
+static void yyerror(char* s);
 static char* tmp;
 static int i_tmp;
 static void* f_tmp;
@@ -116,7 +116,7 @@ static str* str_tmp;
 static str s_tmp;
 static struct ip_addr* ip_tmp;
 
-void warn(char* s);
+static void warn(char* s);
 static struct id_list* mk_listen_id(char*, int, int);
  
 
@@ -1697,14 +1697,14 @@ cmd:		FORWARD LPAREN host RPAREN	{ $$=mk_action(	FORWARD_T,
 extern int line;
 extern int column;
 extern int startcolumn;
-void warn(char* s)
+static void warn(char* s)
 {
 	LOG(L_WARN, "cfg. warning: (%d,%d-%d): %s\n", line, startcolumn, 
 			column, s);
 	cfg_errors++;
 }
 
-void yyerror(char* s)
+static void yyerror(char* s)
 {
 	LOG(L_CRIT, "parse error (%d,%d-%d): %s\n", line, startcolumn, 
 			column, s);

+ 13 - 10
lock_alloc.h

@@ -28,9 +28,12 @@
 /*
  *   ser locking library
  *   WARNING: don't include this directly include instead locking.h!
- *
+ * History:
+ * --------
  *  2003-03-06  created by andrei (contains parts of the original locking.h)
  *  2003-03-17  fixed cast warning in shm_free (forced to void*) (andrei)
+ *  2004-07-28  s/lock_set_t/gen_lock_set_t/ because of a type conflict
+ *              on darwin (andrei)
  *
 Implements: (see also locking.h)
 
@@ -41,8 +44,8 @@ Implements: (see also locking.h)
 	
 	lock sets: [implemented only for FL & SYSV so far]
 	----------
-	lock_set_t* lock_set_alloc(no)               - allocs a lock set in shm.
-	void lock_set_dealloc(lock_set_t* s);        - deallocs the lock set shm.
+	gen_lock_set_t* lock_set_alloc(no)               - allocs a lock set in shm.
+	void lock_set_dealloc(gen_lock_set_t* s);        - deallocs the lock set shm.
 
 */
 
@@ -63,14 +66,14 @@ Implements: (see also locking.h)
 #define lock_dealloc(lock) shm_free((void*)lock)
 /* lock sets */
 
-inline static lock_set_t* lock_set_alloc(int n)
+inline static gen_lock_set_t* lock_set_alloc(int n)
 {
-	lock_set_t* ls;
-	ls=(lock_set_t*)shm_malloc(sizeof(lock_set_t)+n*sizeof(gen_lock_t));
+	gen_lock_set_t* ls;
+	ls=(gen_lock_set_t*)shm_malloc(sizeof(gen_lock_set_t)+n*sizeof(gen_lock_t));
 	if (ls==0){
 		LOG(L_CRIT, "ERROR: lock_set_alloc (FL): could not allocate lock_set\n");
 	}else{
-		ls->locks=(gen_lock_t*)((char*)ls+sizeof(lock_set_t));
+		ls->locks=(gen_lock_t*)((char*)ls+sizeof(gen_lock_set_t));
 		ls->size=n;
 	}
 	return ls;
@@ -85,10 +88,10 @@ inline static lock_set_t* lock_set_alloc(int n)
 #define lock_dealloc(lock) shm_free((void*)lock)
 /* lock sets */
 
-inline static lock_set_t* lock_set_alloc(int n)
+inline static gen_lock_set_t* lock_set_alloc(int n)
 {
-	lock_set_t* ls;
-	ls=(lock_set_t*)shm_malloc(sizeof(lock_set_t));
+	gen_lock_set_t* ls;
+	ls=(gen_lock_set_t*)shm_malloc(sizeof(gen_lock_set_t));
 	if (ls){
 		ls->size=n;
 		ls->semid=-1;

+ 15 - 13
lock_ops.h

@@ -40,6 +40,8 @@
  *  2003-03-10  lock set support added also for PTHREAD_MUTEX & POSIX_SEM
  *               (andrei)
  *  2003-03-17  possible signal interruptions treated for sysv (andrei)
+ *  2004-07-28  s/lock_set_t/gen_lock_set_t/ because of a type conflict
+ *              on darwin (andrei)
  *
 Implements:
 
@@ -52,10 +54,10 @@ Implements:
 	
 	lock sets: [implemented only for FL & SYSV so far]
 	----------
-	lock_set_t* lock_set_init(lock_set_t* set);  - inits the lock set
-	void lock_set_destroy(lock_set_t* s);        - removes the lock set
-	void lock_set_get(lock_set_t* s, int i);     - locks sem i from the set
-	void lock_set_release(lock_set_t* s, int i)  - unlocks sem i from the set
+	gen_lock_set_t* lock_set_init(gen_lock_set_t* set);  - inits the lock set
+	void lock_set_destroy(gen_lock_set_t* s);        - removes the lock set
+	void lock_set_get(gen_lock_set_t* s, int i);     - locks sem i from the set
+	void lock_set_release(gen_lock_set_t* s, int i)  - unlocks sem i from the set
 
 WARNING: - lock_set_init may fail for large number of sems (e.g. sysv). 
          - signals are not treated! (some locks are "awakened" by the signals)
@@ -209,16 +211,16 @@ tryagain:
 #if defined(FAST_LOCK) || defined(USE_PTHREAD_MUTEX) || defined(USE_POSIX_SEM)
 #define GEN_LOCK_T_PREFERED
 
-struct lock_set_t_ {
+struct gen_lock_set_t_ {
 	long size;
 	gen_lock_t* locks;
 }; /* must be  aligned (32 bits or 64 depending on the arch)*/
-typedef struct lock_set_t_ lock_set_t;
+typedef struct gen_lock_set_t_ gen_lock_set_t;
 
 
 #define lock_set_destroy(lock_set) /* do nothing */
 
-inline static lock_set_t* lock_set_init(lock_set_t* s)
+inline static gen_lock_set_t* lock_set_init(gen_lock_set_t* s)
 {
 	int r;
 	for (r=0; r<s->size; r++) if (lock_init(&s->locks[r])==0) return 0;
@@ -232,14 +234,14 @@ inline static lock_set_t* lock_set_init(lock_set_t* s)
 #elif defined(USE_SYSV_SEM)
 #undef GEN_LOCK_T_PREFERED
 
-struct lock_set_t_ {
+struct gen_lock_set_t_ {
 	int size;
 	int semid;
 };
 
 
-typedef struct lock_set_t_ lock_set_t;
-inline static lock_set_t* lock_set_init(lock_set_t* s)
+typedef struct gen_lock_set_t_ gen_lock_set_t;
+inline static gen_lock_set_t* lock_set_init(gen_lock_set_t* s)
 {
 	union semun su;
 	int r;
@@ -262,12 +264,12 @@ inline static lock_set_t* lock_set_init(lock_set_t* s)
 	return s;
 }
 
-inline static void lock_set_destroy(lock_set_t* s)
+inline static void lock_set_destroy(gen_lock_set_t* s)
 {
 	semctl(s->semid, 0, IPC_RMID, (union semun)(int)0);
 }
 
-inline static void lock_set_get(lock_set_t* s, int n)
+inline static void lock_set_get(gen_lock_set_t* s, int n)
 {
 	struct sembuf sop;
 	sop.sem_num=n;
@@ -285,7 +287,7 @@ tryagain:
 	}
 }
 
-inline static void lock_set_release(lock_set_t* s, int n)
+inline static void lock_set_release(gen_lock_set_t* s, int n)
 {
 	struct sembuf sop;
 	sop.sem_num=n;

+ 9 - 7
locking.h

@@ -34,6 +34,8 @@
  *  2003-03-05  lock set support added for FAST_LOCK & SYSV (andrei)
  *  2003-03-06  splited in two: lock_ops.h & lock_alloc.h, to avoid
  *               shm_mem.h<->locking.h interdependency (andrei)
+ *  2004-07-28  s/lock_set_t/gen_lock_set_t/ because of a type conflict
+ *              on darwin (andrei)
  *
 Implements (in lock_ops.h & lock_alloc.h):
 
@@ -49,13 +51,13 @@ Implements (in lock_ops.h & lock_alloc.h):
 	
 	lock sets:
 	----------
-	type: lock_set_t
-	lock_set_t* lock_set_alloc(no)               - allocs a lock set in shm.
-	lock_set_t* lock_set_init(lock_set_t* set);  - inits the lock set
-	void lock_set_destroy(lock_set_t* s);        - removes the lock set
-	void lock_set_dealloc(lock_set_t* s);        - deallocs the lock set shm.
-	void lock_set_get(lock_set_t* s, int i);     - locks sem i from the set
-	void lock_set_release(lock_set_t* s, int i)  - unlocks sem i from the set
+	type: gen_lock_set_t
+	gen_lock_set_t* lock_set_alloc(no)               - allocs a lock set in shm.
+	gen_lock_set_t* lock_set_init(gen_lock_set_t* set);  - inits the lock set
+	void lock_set_destroy(gen_lock_set_t* s);        - removes the lock set
+	void lock_set_dealloc(gen_lock_set_t* s);        - deallocs the lock set shm.
+	void lock_set_get(gen_lock_set_t* s, int i);     - locks sem i from the set
+	void lock_set_release(gen_lock_set_t* s, int i)  - unlocks sem i from the set
 
 WARNING: - lock_set_init may fail for large number of sems (e.g. sysv). 
          - signals are not treated! (some locks are "awakened" by the signals)

+ 6 - 0
mem/shm_mem.c

@@ -30,6 +30,7 @@
  * --------
  *  2003-03-12  splited shm_mem_init in shm_getmem & shm_mem_init_mallocs
  *               (andrei)
+ *  2004-07-27  ANON mmap support, needed on darwin (andrei)
  */
 
 
@@ -140,6 +141,10 @@ int shm_getmem()
 	}
 	
 #ifdef SHM_MMAP
+#ifdef USE_ANON_MMAP
+	shm_mempool=mmap(0, shm_mem_size, PROT_READ|PROT_WRITE,
+					 MAP_ANON|MAP_SHARED, -1 ,0);
+#else
 	fd=open("/dev/zero", O_RDWR);
 	if (fd==-1){
 		LOG(L_CRIT, "ERROR: shm_mem_init: could not open /dev/zero: %s\n",
@@ -149,6 +154,7 @@ int shm_getmem()
 	shm_mempool=mmap(0, shm_mem_size, PROT_READ|PROT_WRITE, MAP_SHARED, fd ,0);
 	/* close /dev/zero */
 	close(fd);
+#endif /* USE_ANON_MMAP */
 #else
 	
 	shm_shmid=shmget(IPC_PRIVATE, /* SHM_MEM_SIZE */ shm_mem_size , 0700);

+ 5 - 3
modules/tm/lock.c

@@ -28,6 +28,8 @@
  * History:
  * --------
  *  2003-03-17  converted to locking.h (andrei)
+ *  2004-07-28  s/lock_set_t/gen_lock_set_t/ because of a type conflict
+ *              on darwin (andrei)
  */
 
 
@@ -70,9 +72,9 @@
 
 /* and the maximum number of semaphores in the entry_semaphore set */
 static int sem_nr;
-lock_set_t* timer_semaphore=0;
-lock_set_t* entry_semaphore=0;
-lock_set_t* reply_semaphore=0;
+gen_lock_set_t* timer_semaphore=0;
+gen_lock_set_t* entry_semaphore=0;
+gen_lock_set_t* reply_semaphore=0;
 #endif
 
 /* timer group locks */

+ 3 - 1
modules/tm/lock.h

@@ -28,6 +28,8 @@
  * History:
  * --------
  *  2003-03-17  converted to locking.h (andrei)
+ *  2004-07-28  s/lock_set_t/gen_lock_set_t/ because of a type conflict
+ *              on darwin (andrei)
  */
 
 #include "defs.h"
@@ -47,7 +49,7 @@
 /* typedef to structure we use for mutexing;
    currently, index to a semaphore set identifier now */
 typedef struct {
-	lock_set_t* semaphore_set;
+	gen_lock_set_t* semaphore_set;
 	int semaphore_index;
 } ser_lock_t;
 #endif

+ 5 - 0
resolve.h

@@ -29,6 +29,7 @@
 /* History:
  * --------
  *  2003-04-12  support for resolving ipv6 address references added (andrei)
+ *  2004-07-28  darwin needs nameser_compat.h (andrei)
  */
 
 
@@ -41,6 +42,10 @@
 #include <netdb.h>
 #include <arpa/nameser.h>
 
+#ifdef __OS_darwin
+#include <arpa/nameser_compat.h>
+#endif
+
 #include "ip_addr.h"