Răsfoiți Sursa

-x86_64 experimental support
-various 64 bit warning fixes

Andrei Pelinescu-Onciul 21 ani în urmă
părinte
comite
4d080f498e
12 a modificat fișierele cu 65 adăugiri și 16 ștergeri
  1. 49 1
      Makefile.defs
  2. 2 1
      cfg.y
  3. 1 1
      db/db_fifo.c
  4. 2 2
      fastlock.h
  5. 1 1
      fifo_server.c
  6. 2 2
      mem/f_malloc.c
  7. 2 2
      mem/q_malloc.c
  8. 1 1
      mem/q_malloc.h
  9. 1 1
      pass_fd.c
  10. 2 2
      tcp_main.c
  11. 1 1
      udp_server.c
  12. 1 1
      version.h

+ 49 - 1
Makefile.defs

@@ -33,6 +33,7 @@
 #  2003-11-24  openbsd 3.4 (elf) fixes (andrei)
 #  2004-07-27  darwin (mac os x) port  (andrei)
 #  2004-09-12  mips2 & cobalt support introduced (andrei)
+#  2004-09-28  x86_64 support introduced (andrei)
 
 
 # check if already included/exported
@@ -49,7 +50,7 @@ MAIN_NAME=ser
 VERSION = 0
 PATCHLEVEL = 8
 SUBLEVEL =   99
-EXTRAVERSION = -dev6
+EXTRAVERSION = -dev7
 
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]")
@@ -385,6 +386,10 @@ ifeq ($(ARCH), i386)
 	use_fast_lock=yes
 endif
 
+ifeq ($(ARCH), x86_64)
+	use_fast_lock=yes
+endif
+
 ifeq ($(ARCH), sparc64)
 ifeq 	($(CC_NAME), gcc)
 	use_fast_lock=yes
@@ -462,6 +467,49 @@ endif		#CC_NAME, icc
 endif		#CC_NAME, gcc
 endif	#ARCH, i386
 
+#x86_64
+ifeq	($(ARCH), x86_64)
+		# if gcc 
+ifeq		($(CC_NAME), gcc)
+				#common stuff
+				CFLAGS=-g -O9 -funroll-loops  -Wcast-align $(PROFILE) \
+					-Wall   \
+			#if gcc 3.0
+ifeq			($(CC_SHORTVER), 3.0)
+					CPU ?= athlon64
+					CFLAGS+=-minline-all-stringops \
+							-falign-loops \
+							-mcpu=$(CPU) \
+							#-mcpu=athlon
+else
+ifeq			($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
+$(warning 			Old gcc detected ($(CC_SHORTVER)), use  gcc >= 3.1 \
+					for better results)
+					
+					CFLAGS+=-m486 \
+							-malign-loops=4
+else
+				#really old version
+$(warning			You are using an old and unsupported gcc \
+					 version  ($(CC_SHORTVER)), compile at your own risk!)
+
+endif			# CC_SHORTVER, 2.9x
+endif			# CC_SHORTVER, 3.0
+
+else		# CC_NAME, gcc
+ifeq		($(CC_NAME), icc)
+			CFLAGS=-g -O3  -ipo -ipo_obj -unroll  $(PROFILE) \
+					 -tpp6 -xK  #-openmp  #optimize for PIII 
+				# -prefetch doesn't seem to work
+				#( ty to inline acroos files, unroll loops,prefetch,
+				# optimize for PIII, use PIII instructions & vect.,
+				# mutlithread loops)
+else
+				#other compilers
+$(error 			Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
+endif		#CC_NAME, icc
+endif		#CC_NAME, gcc
+endif	#ARCH, x86_64
 
 	#if sparc
 ifeq	($(ARCH), sparc64)

+ 2 - 1
cfg.y

@@ -1494,7 +1494,8 @@ cmd:		FORWARD LPAREN host RPAREN	{ $$=mk_action(	FORWARD_T,
 			if (str2q(&q, $5, strlen($5)) < 0) {
 				yyerror("bad argument, q value expected");
 			}
-			$$=mk_action(APPEND_BRANCH_T, STRING_ST, NUMBER_ST, $3, (void *)q); } 
+			$$=mk_action(APPEND_BRANCH_T, STRING_ST, NUMBER_ST, $3, 
+							(void *)(long)q); } 
 		}
 	
 		| APPEND_BRANCH LPAREN STRING RPAREN { $$=mk_action( APPEND_BRANCH_T,

+ 1 - 1
db/db_fifo.c

@@ -451,7 +451,7 @@ static inline int get_avps( FILE *fifo , db_key_t *keys, db_op_t *ops,
 	}
 parse_error:
 	LOG(L_ERR,"ERROR:get_avps: parse error in \"%.*s\" at char [%d][%c] "
-		"offset %d\n",line.len,line.s,*c,*c,c-line.s);
+		"offset %d\n",line.len,line.s,*c,*c, (unsigned)(c-line.s));
 	double_log("Broken AVP(attr|op|val) in DB command");
 error:
 	for(;*nr;(*nr)--)

+ 2 - 2
fastlock.h

@@ -65,7 +65,7 @@ inline static int tsl(fl_lock_t* lock)
 {
 	int val;
 
-#ifdef __CPU_i386
+#if defined(__CPU_i386) || defined(__CPU_x86_64)
 
 #ifdef NOSMP
 	val=0;
@@ -154,7 +154,7 @@ inline static void get_lock(fl_lock_t* lock)
 
 inline static void release_lock(fl_lock_t* lock)
 {
-#ifdef __CPU_i386
+#if defined(__CPU_i386) || defined(__CPU_x86_64)
 	char val;
 	val=0;
 	asm volatile(

+ 1 - 1
fifo_server.c

@@ -345,7 +345,7 @@ static int fifo_check(int fd, char* fname)
 	/* check if hard-linked */
 	if (fst.st_nlink>1){
 		LOG(L_ERR, "ERROR: security: fifo_check: %s is hard-linked %d times\n",
-				fname, fst.st_nlink);
+				fname, (unsigned)fst.st_nlink);
 		return -1;
 	}
 	

+ 2 - 2
mem/f_malloc.c

@@ -88,7 +88,7 @@
 
 
 /* computes hash number for big buckets*/
-inline static int big_hash_idx(int s)
+inline static int big_hash_idx(unsigned long s)
 {
 	int idx;
 	/* s is rounded => s = k*2^n (ROUNDTO=2^n) 
@@ -96,7 +96,7 @@ inline static int big_hash_idx(int s)
 	 *
 	 * => index = number of the first non null bit in s*/
 	idx=sizeof(long)*8-1;
-	for (; !(s&(1<<(sizeof(long)*8-1))) ; s<<=1, idx--);
+	for (; !(s&(1UL<<(sizeof(long)*8-1))) ; s<<=1, idx--);
 	return idx;
 }
 

+ 2 - 2
mem/q_malloc.c

@@ -104,7 +104,7 @@
 
 
 /* computes hash number for big buckets*/
-inline static int big_hash_idx(int s)
+inline static int big_hash_idx(unsigned long s)
 {
 	int idx;
 	/* s is rounded => s = k*2^n (ROUNDTO=2^n) 
@@ -112,7 +112,7 @@ inline static int big_hash_idx(int s)
 	 *
 	 * => index = number of the first non null bit in s*/
 	idx=sizeof(long)*8-1;
-	for (; !(s&(1<<(sizeof(long)*8-1))) ; s<<=1, idx--);
+	for (; !(s&(1UL<<(sizeof(long)*8-1))) ; s<<=1, idx--);
 	return idx;
 }
 

+ 1 - 1
mem/q_malloc.h

@@ -68,7 +68,7 @@
 									must be 2^k */
 
 #define QM_HASH_SIZE ((unsigned long)(QM_MALLOC_OPTIMIZE/ROUNDTO + \
-		(sizeof(long)-QM_MALLOC_OPTIMIZE_FACTOR)+1))
+		(sizeof(long)*8-QM_MALLOC_OPTIMIZE_FACTOR)+1))
 
 /* hash structure:
  * 0 .... QM_MALLOC_OPTIMIE/ROUNDTO  - small buckets, size increases with

+ 1 - 1
pass_fd.c

@@ -205,7 +205,7 @@ again:
 		*fd=*((int*) CMSG_DATA(cmsg));
 	}else{
 		LOG(L_ERR, "ERROR: receive_fd: no descriptor passed, cmsg=%p,"
-				"len=%d\n", cmsg, cmsg->cmsg_len);
+				"len=%d\n", cmsg, (unsigned)cmsg->cmsg_len);
 		*fd=-1;
 		/* it's not really an error */
 	}

+ 2 - 2
tcp_main.c

@@ -895,7 +895,7 @@ int tcp_init(struct socket_info* sock_info)
 	if (bind(sock_info->socket, &addr->s, sockaddru_len(*addr))==-1){
 		LOG(L_ERR, "ERROR: tcp_init: bind(%x, %p, %d) on %s: %s\n",
 				sock_info->socket, &addr->s, 
-				sockaddru_len(*addr),
+				(unsigned)sockaddru_len(*addr),
 				sock_info->address_str.s,
 				strerror(errno));
 		goto error;
@@ -903,7 +903,7 @@ int tcp_init(struct socket_info* sock_info)
 	if (listen(sock_info->socket, 10)==-1){
 		LOG(L_ERR, "ERROR: tcp_init: listen(%x, %p, %d) on %s: %s\n",
 				sock_info->socket, &addr->s, 
-				sockaddru_len(*addr),
+				(unsigned)sockaddru_len(*addr),
 				sock_info->address_str.s,
 				strerror(errno));
 		goto error;

+ 1 - 1
udp_server.c

@@ -349,7 +349,7 @@ int udp_init(struct socket_info* sock_info)
 	if (bind(sock_info->socket,  &addr->s, sockaddru_len(*addr))==-1){
 		LOG(L_ERR, "ERROR: udp_init: bind(%x, %p, %d) on %s: %s\n",
 				sock_info->socket, &addr->s, 
-				sockaddru_len(*addr),
+				(unsigned)sockaddru_len(*addr),
 				sock_info->address_str.s,
 				strerror(errno));
 	#ifdef USE_IPV6

+ 1 - 1
version.h

@@ -189,7 +189,7 @@
 
 
 #define SER_COMPILE_FLAGS \
-	EXTRA_DEBUG_STR STATS_STR USE_IPV6_STR USE_TCP_STR USE_TLS_STR \
+	STATS_STR EXTRA_DEBUG_STR USE_IPV6_STR USE_TCP_STR USE_TLS_STR \
 	DISABLE_NAGLE_STR USE_MCAST_STR NO_DEBUG_STR NO_LOG_STR DNS_IP_HACK_STR \
 	SHM_MEM_STR SHM_MMAP_STR PKG_MALLOC_STR VQ_MALLOC_STR F_MALLOC_STR \
 	USE_SHM_MEM_STR DBG_QM_MALLOC_STR DBG_F_MALLOC_STR DEBUG_DMALLOC_STR \