Subject: pkg/33187: Zaptel don't build on amd64
To: None <pkg-manager@netbsd.org, gnats-admin@netbsd.org,>
From: None <ole.hellqvist@spray.se>
List: pkgsrc-bugs
Date: 04/03/2006 23:00:07
>Number:         33187
>Category:       pkg
>Synopsis:       Zaptel don't build on amd64
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Apr 03 23:00:06 +0000 2006
>Originator:     Ole
>Release:        3
>Organization:
>Environment:
NetBSD amd64.oxen 3.0 NetBSD 3.0 (GENERIC) #0: Sun Dec 18 21:51:37 UTC 2005  builds@works.netbsd.org:/home/builds/ab/netbsd-3-0-RELEASE/amd64/200512182024Z-obj/home/builds/ab/netbsd-3-0-RELEASE/src/sys/arch/amd64/compile/GENERIC amd64
>Description:
#   compile  zaptel/zaptel.o
cc -O2 -I/usr/pkg/include -g  -Werror  -ffreestanding  -mcmodel=kernel -I/usr/pkg/include  -nostdinc -I. -I/usr/pkgsrc/comms/za
ptel-netbsd/work/zaptel-netbsd-20060127/zaptel -isystem /usr/src/sys -isystem /usr/src/sys/arch -D_KERNEL -D_LKM -c    zaptel.c
zaptel.c: In function `ioctl_load_zone':
zaptel.c:2645: warning: cast to pointer from integer of different size
zaptel.c: In function `zt_common_ioctl':
zaptel.c:3383: warning: cast from pointer to integer of different size
zaptel.c:3383: warning: cast from pointer to integer of different size
zaptel.c:3385: warning: cast from pointer to integer of different size
zaptel.c:3385: warning: cast from pointer to integer of different size
zaptel.c:3387: warning: cast from pointer to integer of different size
zaptel.c:3395: warning: cast from pointer to integer of different size
zaptel.c:3395: warning: cast from pointer to integer of different size
zaptel.c:3402: warning: cast from pointer to integer of different size
zaptel.c:3402: warning: cast from pointer to integer of different size
zaptel.c: In function `zt_fcntl':
zaptel.c:4750: warning: cast from pointer to integer of different size
*** Error code 1

Stop.
make: stopped in /usr/pkgsrc/comms/zaptel-netbsd/work/zaptel-netbsd-20060127/zaptel
*** Error code 1
>How-To-Repeat:
cd /usr/pkgsrc/comms/zaptel
make
>Fix:
I managed to make it build with the two patches below, if it still does on some other platform than AMD64 i dont know..

--- zaptel/zaptel.c.orig        2006-01-28 00:48:22.000000000 +0100
+++ zaptel/zaptel.c     2006-04-03 22:52:34.000000000 +0200
@@ -1602,7 +1602,7 @@
        int x,oldbuf;
        unsigned int fcs;
        unsigned char *data;
-       long flags;
+       intptr_t flags;
        int retval = 0;
 
        /* See if we have any buffers */
@@ -1679,7 +1679,7 @@
        return retval;
 }
 
-static int zt_ppp_ioctl(struct ppp_channel *ppp, unsigned int cmd, unsigned long flags)
+static int zt_ppp_ioctl(struct ppp_channel *ppp, unsigned int cmd, uintptr_t flags)
 {
        return EIO;
 }
@@ -2619,20 +2619,20 @@
 #define MAX_TONES 128
 
 static int
-ioctl_load_zone(unsigned long data)
+ioctl_load_zone(uintptr_t data)
 {
        struct zt_tone *samples[MAX_TONES];
        int next[MAX_TONES];
        struct zt_tone_def_header th;
        void *slab, *ptr;
-       long size;
+       intptr_t size;
        struct zt_zone *z;
        struct zt_tone_def td;
        struct zt_tone *t;
        int x;
        int space;
        int res;
-       int addr;
+       uintptr_t addr;
        
        /* XXX Unnecessary XXX */
        memset(samples, 0, sizeof(samples));
@@ -3380,11 +3380,11 @@
                printf("Dump of Zaptel Channel %d (%s,%d,%d):\n\n",j,
                        mychan.name,mychan.channo,mychan.chanpos);
                printf("flags: %x hex, writechunk: %08x, readchunk: %08x\n",
-                       mychan.flags, (int) mychan.writechunk, (int) mychan.readchunk);
+                       mychan.flags, (intptr_t) mychan.writechunk, (intptr_t) mychan.readchunk);
                printf("rxgain: %08x, txgain: %08x, gainalloc: %d\n",
-                       (int) mychan.rxgain, (int)mychan.txgain, mychan.gainalloc);
+                       (intptr_t) mychan.rxgain, (intptr_t)mychan.txgain, mychan.gainalloc);
                printf("span: %08x, sig: %x hex, sigcap: %x hex\n",
-                       (int)mychan.span, mychan.sig, mychan.sigcap);
+                       (intptr_t)mychan.span, mychan.sig, mychan.sigcap);
                printf("inreadbuf: %d, outreadbuf: %d, inwritebuf: %d, outwritebuf: %d\n",
                        mychan.inreadbuf, mychan.outreadbuf, mychan.inwritebuf, mychan.outwritebuf);
                printf("blocksize: %d, numbufs: %d, txbufpolicy: %d, txbufpolicy: %d\n",
@@ -3392,14 +3392,14 @@
                printf("txdisable: %d, rxdisable: %d, iomask: %d\n",
                        mychan.txdisable, mychan.rxdisable, mychan.iomask);
                printf("curzone: %08x, tonezone: %d, curtone: %08x, tonep: %d\n",
-                       (int) mychan.curzone, mychan.tonezone, (int) mychan.curtone, mychan.tonep);
                printf("digitmode: %d, txdialbuf: %s, dialing: %d, aftdialtimer: %d, cadpos. %d\n",
                        mychan.digitmode, mychan.txdialbuf, mychan.dialing,
                                mychan.afterdialingtimer, mychan.cadencepos);
                printf("confna: %d, confn: %d, confmode: %d, confmute: %d\n",
                        mychan.confna, mychan._confn, mychan.confmode, mychan.confmute);
                printf("ec: %08x, echocancel: %d, deflaw: %d, xlaw: %08x\n",
-                       (int) mychan.ec, mychan.echocancel, mychan.deflaw, (int) mychan.xlaw);
+                       (intptr_t) mychan.ec, mychan.echocancel, mychan.deflaw, (intptr_t) mychan.xlaw);
                printf("echostate: %02x, echotimer: %d, echolastupdate: %d\n",
                        (int) mychan.echostate, mychan.echotimer, mychan.echolastupdate);
                printf("itimer: %d, otimer: %d, ringdebtimer: %d\n\n",
@@ -3420,9 +3420,9 @@
        return 0;
 }
 
-static int (*zt_dynamic_ioctl)(unsigned int cmd, unsigned long data);
+static int (*zt_dynamic_ioctl)(unsigned int cmd, uintptr_t data);
 
-void zt_set_dynamic_ioctl(int (*func)(unsigned int cmd, unsigned long data)) 
+void zt_set_dynamic_ioctl(int (*func)(unsigned int cmd, uintptr_t data)) 
 {
        zt_dynamic_ioctl = func;
 }
@@ -3719,7 +3719,7 @@
                ZAP_MGR_LOCK(zone_lock, LK_RELEASE);
                return 0;
        case ZT_LOADZONE:
-               return ioctl_load_zone((unsigned long)arg);
+               return ioctl_load_zone((uintptr_t)arg);
        case ZT_FREEZONE:
                bcopy(arg, &j, sizeof(int));
                if ((j < 0) || (j >= ZT_TONE_ZONE_MAX)) return (EINVAL);
@@ -3792,11 +3792,11 @@
        case ZT_DYNAMIC_CREATE:
        case ZT_DYNAMIC_DESTROY:
                if (zt_dynamic_ioctl)
-                       return zt_dynamic_ioctl(cmd, (unsigned long)arg);
+                       return zt_dynamic_ioctl(cmd, (uintptr_t)arg);
                else {
                        /* TODO: request_module("ztdynamic"); */
                        if (zt_dynamic_ioctl)
-                               return zt_dynamic_ioctl(cmd, (unsigned long)arg);
+                               return zt_dynamic_ioctl(cmd, (uintptr_t)arg);
                }
                return ENOSYS;
        default:
@@ -4302,7 +4302,7 @@
  * way because the ppp_generic layer functions may not be called
  * at interrupt level.
  */
-static void do_ppp_calls(unsigned long data)
+static void do_ppp_calls(uintptr_t data)
 {
        struct zt_chan *chan = (struct zt_chan *) data;
        struct sk_buff *skb;
@@ -4398,7 +4398,7 @@
                                        skb_queue_head_init(&chan->ppp_rq);
                                        chan->do_ppp_wakeup = 0;
                                        tasklet_init(&chan->ppp_calls, do_ppp_calls,
-                                                        (unsigned long)chan);
+                                                        (uintptr_t)chan);
                                        if ((ret = zt_reallocbufs(chan, ZT_DEFAULT_MTU_MRU, ZT_DEFAULT_NUM_BUFS))) {
                                                free(chan->ppp);
                                                chan->ppp = NULL;
@@ -4739,7 +4739,7 @@
 
 int zt_fcntl(struct file *fp, u_int cmd, void *data, ZPROC *p)
 {
-       int flags;
+    intptr_t    flags;
 
        /* Take appropriate actions */
        switch(cmd) {
@@ -4747,7 +4747,7 @@
                return(fp->f_flag);
                break;
        case F_SETFL:
-               flags = (u_int)data;
+               flags = (intptr_t)data;
                fp->f_flag = flags | FREAD | FWRITE;
                return(0);
                break;
@@ -5693,7 +5693,7 @@
                                 int samples,long p1, long p2, long p3)
 {
 int     i,rv = 0;
-long x,y;
+int32_t x,y;
 
 #define        SF_DETECT_SAMPLES (ZT_CHUNKSIZE * 5)
 #define        SF_DETECT_MIN_ENERGY 500
@@ -6617,10 +6617,10 @@
 #ifdef CONFIG_ZAPTEL_WATCHDOG
 static struct timer_list watchdogtimer;
 
-static void watchdog_check(unsigned long ignored)
+static void watchdog_check(uintptr_t ignored)
 {
        int x;
-       long flags;
+       intptr_t flags;

        static int wdcheck=0;
        
        local_irq_save(flags);








--- zaptel/zaptel.h.orig        2006-01-28 00:48:22.000000000 +0100
+++ zaptel/zaptel.h     2006-04-03 22:33:01.000000000 +0200
@@ -38,7 +38,6 @@
 #include "os.h"
 #include <sys/select.h>
 #include <sys/param.h>
-
 #if defined(__NetBSD__) || (defined(__FreeBSD__) && \
        (__FreeBSD_version < 500000))
 #include <sys/lock.h>
@@ -51,6 +50,7 @@
 #include "fasthdlc.h"
 #endif /* _KERNEL */
 
+#include <sys/stdint.h>
 
 
 
@@ -363,12 +363,12 @@
 
 typedef struct
 {
-       long    x1;
-       long    x2;
-       long    y1;
-       long    y2;
-       long    e1;
-       long    e2;
+       int32_t x1;
+       int32_t x2;
+       int32_t y1;
+       int32_t y2;
+       int32_t e1;
+       int32_t e2;
        int     samps;
        int     lastdetect;
 } sf_detect_state_t;
@@ -398,9 +398,9 @@
        int channo;                     /* Zaptel Channel number */
        int chanpos;
        int flags;
-       long rxp1;
-       long rxp2;
-       long rxp3;
+       int32_t rxp1;
+       int32_t rxp2;
+       int32_t rxp3;
        int txtone;
        int tx_v2;
        int tx_v3;
@@ -772,7 +772,7 @@
 struct zt_tone *       zt_dtmf_tone(char digit, int mf);
 void                           zt_sethook(struct zt_chan *chan, int state );
 void                           zt_set_dynamic_ioctl(int (*func)(unsigned int cmd, 
-                                                                                                        unsigned long data));
+                                                                                                         uintptr_t data));
 
 #endif /* _KERNEL */
 
@@ -850,14 +850,13 @@
        unsigned char rxgain[256];      /* Receive gain table */
        unsigned char txgain[256];      /* Transmit gain table */
 } ZT_GAINS;
-
 typedef struct zt_sfconfig
 {
        int     chan;           /* Channel we're applying this to (0 to use name) */
        char name[40];          /* Name of channel to use */
-       long    rxp1;           /* receive tone det. p1 */
-       long    rxp2;           /* receive tone det. p2 */
-       long    rxp3;           /* receive tone det. p3 */
+       int32_t rxp1;           /* receive tone det. p1 */
+       int32_t rxp2;           /* receive tone det. p2 */
+       int32_t rxp3;           /* receive tone det. p3 */
        int     txtone;         /* Tx tone factor */
        int     tx_v2;          /* initial v2 value */
        int     tx_v3;          /* initial v3 value */