-x86_64 experimental support
authorAndrei Pelinescu-Onciul <andrei@iptel.org>
Tue, 28 Sep 2004 18:10:08 +0000 (18:10 +0000)
committerAndrei Pelinescu-Onciul <andrei@iptel.org>
Tue, 28 Sep 2004 18:10:08 +0000 (18:10 +0000)
 -various 64 bit warning fixes

12 files changed:
Makefile.defs
cfg.y
db/db_fifo.c
fastlock.h
fifo_server.c
mem/f_malloc.c
mem/q_malloc.c
mem/q_malloc.h
pass_fd.c
tcp_main.c
udp_server.c
version.h

index 3caf0cd..f434e7f 100644 (file)
@@ -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)
diff --git a/cfg.y b/cfg.y
index 4b90a52..560dbb9 100644 (file)
--- a/cfg.y
+++ b/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,
index b0cdef9..27f1c78 100644 (file)
@@ -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)--)
index 2b53c69..9f674da 100644 (file)
@@ -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(
index e8e7ab1..0e85dd2 100644 (file)
@@ -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;
        }
        
index 617b74c..463ecf0 100644 (file)
@@ -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;
 }
 
index 996f94f..fd0241d 100644 (file)
 
 
 /* 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;
 }
 
index 98c0d7d..d3f2210 100644 (file)
@@ -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
index e721419..02c0bef 100644 (file)
--- a/pass_fd.c
+++ b/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 */
        }
index 294e7f9..f174aed 100644 (file)
@@ -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;
index 46e97b9..ed18ccc 100644 (file)
@@ -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
index fa0a1ba..68cb33a 100644 (file)
--- a/version.h
+++ b/version.h
 
 
 #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 \