Revision: 54922
          http://brlcad.svn.sourceforge.net/brlcad/?rev=54922&view=rev
Author:   r_weiss
Date:     2013-03-27 21:17:29 +0000 (Wed, 27 Mar 2013)
Log Message:
-----------
Updates to libfb to support bu_lseek and improve Windows 64bit. Changed many 
"long" and "int" to "off_t", "size_t" or "ssize_t".

Modified Paths:
--------------
    brlcad/trunk/src/libfb/if_X.c
    brlcad/trunk/src/libfb/if_X24.c
    brlcad/trunk/src/libfb/if_debug.c
    brlcad/trunk/src/libfb/if_disk.c
    brlcad/trunk/src/libfb/if_mem.c
    brlcad/trunk/src/libfb/if_null.c
    brlcad/trunk/src/libfb/if_ogl.c
    brlcad/trunk/src/libfb/if_remote.c
    brlcad/trunk/src/libfb/if_stack.c

Modified: brlcad/trunk/src/libfb/if_X.c
===================================================================
--- brlcad/trunk/src/libfb/if_X.c       2013-03-27 19:43:55 UTC (rev 54921)
+++ brlcad/trunk/src/libfb/if_X.c       2013-03-27 21:17:29 UTC (rev 54922)
@@ -768,7 +768,7 @@
 }
 
 
-HIDDEN int
+HIDDEN ssize_t
 X_read(FBIO *ifp, int x, int y, unsigned char *pixelp, size_t count)
 {
     unsigned char *bytebuf = XI(ifp)->bytebuf;
@@ -781,7 +781,7 @@
     /* return 24bit store if available */
     if (XI(ifp)->mem) {
        memcpy(pixelp, &(XI(ifp)->mem[(y*ifp->if_width+x)*sizeof(RGBpixel)]), 
count*sizeof(RGBpixel));
-       return (int)count;
+       return count;
     }
 
     /* 1st -> 4th quadrant */
@@ -794,7 +794,7 @@
        *pixelp++ = *cp;
        *pixelp++ = *cp++;
     }
-    return (int)count;
+    return count;
 }
 
 
@@ -1097,12 +1097,12 @@
  * Decompose a write of more than one scanline into multiple single
  * scanline writes.
  */
-HIDDEN int
+HIDDEN ssize_t
 X_write(FBIO *ifp, int x, int y, const unsigned char *pixelp, size_t count)
 {
     size_t maxcount;
     size_t todo;
-    int num;
+    size_t num;
 
     /* check origin bounds */
     if (x < 0 || x >= ifp->if_width || y < 0 || y >= ifp->if_height)
@@ -1123,7 +1123,7 @@
        if (x + todo > (size_t)ifp->if_width)
            num = ifp->if_width - x;
        else
-           num = (int)todo;
+           num = todo;
        if (X_scanwrite(ifp, x, y, pixelp, num, 1) == 0)
            return 0;
        x = 0;
@@ -1131,7 +1131,7 @@
        todo -= num;
        pixelp += num;
     }
-    return (int)count;
+    return count;
 }
 
 

Modified: brlcad/trunk/src/libfb/if_X24.c
===================================================================
--- brlcad/trunk/src/libfb/if_X24.c     2013-03-27 19:43:55 UTC (rev 54921)
+++ brlcad/trunk/src/libfb/if_X24.c     2013-03-27 21:17:29 UTC (rev 54922)
@@ -3211,7 +3211,7 @@
 }
 
 
-HIDDEN int
+HIDDEN ssize_t
 X24_read(FBIO *ifp, int x, int y, unsigned char *pixelp, size_t count)
 {
     struct xinfo *xi = XI(ifp);
@@ -3228,11 +3228,11 @@
        count = maxcount;
 
     memcpy(pixelp, &(xi->xi_mem[(y*xi->xi_iwidth+x)*sizeof(RGBpixel)]), 
count*sizeof(RGBpixel));
-    return (int)count;
+    return count;
 }
 
 
-HIDDEN int
+HIDDEN ssize_t
 X24_write(FBIO *ifp, int x, int y, const unsigned char *pixelp, size_t count)
 {
     struct xinfo *xi = XI(ifp);
@@ -3241,8 +3241,8 @@
     FB_CK_FBIO(ifp);
 
 #if X_DBG
-    printf("X24_write(ifp:0x%x, x:%d, y:%d, pixelp:0x%x, count:%ld) 
entered.\n",
-          ifp, x, y, pixelp, (long)count);
+    printf("X24_write(ifp:0x%x, x:%d, y:%d, pixelp:0x%x, count:%lu) 
entered.\n",
+          ifp, x, y, pixelp, count);
 #endif
 
     /* Check origin bounds */
@@ -3273,7 +3273,7 @@
        X24_blit(ifp, 0, y, xi->xi_iwidth, ylines, BLIT_DISP);
     }
 
-    return (int)count;
+    return count;
 }
 
 

Modified: brlcad/trunk/src/libfb/if_debug.c
===================================================================
--- brlcad/trunk/src/libfb/if_debug.c   2013-03-27 19:43:55 UTC (rev 54921)
+++ brlcad/trunk/src/libfb/if_debug.c   2013-03-27 21:17:29 UTC (rev 54922)
@@ -92,18 +92,18 @@
 }
 
 
-HIDDEN int
+HIDDEN ssize_t
 deb_read(FBIO *ifp, int x, int y, unsigned char *pixelp, size_t count)
 {
     FB_CK_FBIO(ifp);
-    fb_log("fb_read(%p, %4d, %4d, %p, %ld)\n",
+    fb_log("fb_read(%p, %4d, %4d, %p, %lu)\n",
           (void *)ifp, x, y,
-          (void *)pixelp, (long)count);
+          (void *)pixelp, count);
     return count;
 }
 
 
-HIDDEN int
+HIDDEN ssize_t
 deb_write(FBIO *ifp, int x, int y, const unsigned char *pixelp, size_t count)
 {
     size_t i;
@@ -127,7 +127,7 @@
            fb_log("\n");
     }
 
-    return (int)count;
+    return count;
 }
 
 

Modified: brlcad/trunk/src/libfb/if_disk.c
===================================================================
--- brlcad/trunk/src/libfb/if_disk.c    2013-03-27 19:43:55 UTC (rev 54921)
+++ brlcad/trunk/src/libfb/if_disk.c    2013-03-27 21:17:29 UTC (rev 54922)
@@ -31,7 +31,7 @@
 #include "fb.h"
 
 
-#define FILE_CMAP_ADDR ((long) ifp->if_width*ifp->if_height    \
+#define FILE_CMAP_ADDR ((off_t) ifp->if_width*ifp->if_height   \
                        *sizeof(RGBpixel))
 
 /* Ensure integer number of pixels per DMA */
@@ -63,7 +63,7 @@
        ifp->if_fd = 1;         /* fileno(stdout) */
        ifp->if_width = width;
        ifp->if_height = height;
-       ifp->if_seekpos = 0L;
+       ifp->if_seekpos = 0;
        return 0;
     }
 
@@ -89,11 +89,11 @@
 
     ifp->if_width = width;
     ifp->if_height = height;
-    if (bu_lseek(ifp->if_fd, 0, 0) == -1L) {
+    if (bu_lseek(ifp->if_fd, 0, 0) == -1) {
        fb_log("disk_device_open : can not seek to beginning.\n");
        return -1;
     }
-    ifp->if_seekpos = 0L;
+    ifp->if_seekpos = 0;
     return 0;
 }
 
@@ -139,7 +139,7 @@
 
     /* Set start of framebuffer */
     fd = ifp->if_fd;
-    if (ifp->if_seekpos != 0L && bu_lseek(fd, 0, 0) == -1) {
+    if (ifp->if_seekpos != 0 && bu_lseek(fd, 0, 0) == -1) {
        fb_log("disk_color_clear : seek failed.\n");
        return -1;
     }
@@ -170,14 +170,14 @@
 }
 
 
-HIDDEN int
+HIDDEN ssize_t
 dsk_read(FBIO *ifp, int x, int y, unsigned char *pixelp, size_t count)
 {
-    size_t bytes = count * (long) sizeof(RGBpixel);
+    size_t bytes = count * sizeof(RGBpixel);
     size_t todo;
-    long got;
+    ssize_t got;
     size_t dest;
-    long bytes_read = 0;
+    size_t bytes_read = 0;
     int fd = ifp->if_fd;
 
     /* Reads on stdout make no sense.  Take reads from stdin. */
@@ -191,7 +191,7 @@
     ifp->if_seekpos = dest;
     while (bytes > 0) {
        todo = bytes;
-       if ((got = read(fd, (char *) pixelp, todo)) != (long)todo) {
+       if ((got = read(fd, (char *) pixelp, todo)) != (ssize_t)todo) {
            if (got <= 0) {
                if (got < 0) {
                    perror("READ ERROR");
@@ -205,8 +205,8 @@
            }
            if (fd != 0) {
                /* This happens all the time reading from pipes */
-               fb_log("disk_buffer_read(fd=%d): y=%d read of %ld got %ld 
bytes\n",
-                      fd, y, (long)todo, got);
+               fb_log("disk_buffer_read(fd=%d): y=%d read of %lu got %ld 
bytes\n",
+                      fd, y, todo, got);
            }
        }
        bytes -= got;
@@ -218,15 +218,15 @@
 }
 
 
-HIDDEN int
+HIDDEN ssize_t
 dsk_write(FBIO *ifp, int x, int y, const unsigned char *pixelp, size_t count)
 {
-    register long bytes = count * (long) sizeof(RGBpixel);
-    size_t todo;
-    size_t dest;
+    register ssize_t bytes = count * sizeof(RGBpixel);
+    ssize_t todo;
+    off_t dest;
 
     dest = (y * ifp->if_width + x) * sizeof(RGBpixel);
-    if (dest != ifp->if_seekpos) {
+    if (dest != (off_t)ifp->if_seekpos) {
        if (bu_lseek(ifp->if_fd, dest, 0) == -1) {
            fb_log("disk_buffer_write : seek to %ld failed.\n", dest);
            return -1;
@@ -235,9 +235,9 @@
     }
     while (bytes > 0) {
        ssize_t ret;
-       todo = (size_t)bytes;
-       ret = (ssize_t)write(ifp->if_fd, (char *) pixelp, todo);
-       if (ret != (ssize_t)todo) {
+       todo = bytes;
+       ret = write(ifp->if_fd, (char *) pixelp, todo);
+       if (ret != todo) {
            fb_log("disk_buffer_write: write failed\n");
            return -1;
        }
@@ -245,7 +245,7 @@
        pixelp += todo / sizeof(RGBpixel);
        ifp->if_seekpos += todo;
     }
-    return (int)count;
+    return count;
 }
 
 

Modified: brlcad/trunk/src/libfb/if_mem.c
===================================================================
--- brlcad/trunk/src/libfb/if_mem.c     2013-03-27 19:43:55 UTC (rev 54921)
+++ brlcad/trunk/src/libfb/if_mem.c     2013-03-27 21:17:29 UTC (rev 54922)
@@ -245,7 +245,7 @@
 }
 
 
-HIDDEN int
+HIDDEN ssize_t
 mem_read(FBIO *ifp, int x, int y, unsigned char *pixelp, size_t count)
 {
     size_t pixels_to_end;
@@ -260,11 +260,11 @@
 
     memcpy((char *)pixelp, &(MI(ifp)->mem[(y*ifp->if_width + x)*3]), count*3);
 
-    return (int)count;
+    return count;
 }
 
 
-HIDDEN int
+HIDDEN ssize_t
 mem_write(FBIO *ifp, int x, int y, const unsigned char *pixelp, size_t count)
 {
     size_t pixels_to_end;
@@ -284,7 +284,7 @@
     } else {
        MI(ifp)->mem_dirty = 1;
     }
-    return (int)count;
+    return count;
 }
 
 

Modified: brlcad/trunk/src/libfb/if_null.c
===================================================================
--- brlcad/trunk/src/libfb/if_null.c    2013-03-27 19:43:55 UTC (rev 54921)
+++ brlcad/trunk/src/libfb/if_null.c    2013-03-27 21:17:29 UTC (rev 54922)
@@ -67,21 +67,21 @@
 }
 
 
-HIDDEN int
+HIDDEN ssize_t
 null_read(FBIO *ifp, int UNUSED(x), int UNUSED(y), unsigned char 
*UNUSED(pixelp), size_t count)
 {
     FB_CK_FBIO(ifp);
 
-    return (int)count;
+    return count;
 }
 
 
-HIDDEN int
+HIDDEN ssize_t
 null_write(FBIO *ifp, int UNUSED(x), int UNUSED(y), const unsigned char 
*UNUSED(pixelp), size_t count)
 {
     FB_CK_FBIO(ifp);
 
-    return (int)count;
+    return count;
 }
 
 

Modified: brlcad/trunk/src/libfb/if_ogl.c
===================================================================
--- brlcad/trunk/src/libfb/if_ogl.c     2013-03-27 19:43:55 UTC (rev 54921)
+++ brlcad/trunk/src/libfb/if_ogl.c     2013-03-27 21:17:29 UTC (rev 54922)
@@ -1860,13 +1860,13 @@
 
 
 /* read count pixels into pixelp starting at x, y */
-HIDDEN int
+HIDDEN ssize_t
 ogl_read(FBIO *ifp, int x, int y, unsigned char *pixelp, size_t count)
 {
     size_t n;
     size_t scan_count; /* # pix on this scanline */
     register unsigned char *cp;
-    int ret;
+    ssize_t ret;
     register struct ogl_pixel *oglp;
 
     if (CJDEBUG) printf("entering ogl_read\n");
@@ -1899,7 +1899,7 @@
            cp += 3;
            n--;
        }
-       ret += (int)scan_count;
+       ret += scan_count;
        count -= scan_count;
        x = 0;
        /* Advance upwards */
@@ -1911,12 +1911,12 @@
 
 
 /* write count pixels from pixelp starting at xstart, ystart */
-HIDDEN int
+HIDDEN ssize_t
 ogl_write(FBIO *ifp, int xstart, int ystart, const unsigned char *pixelp, 
size_t count)
 {
     size_t scan_count; /* # pix on this scanline */
     register unsigned char *cp;
-    int ret;
+    ssize_t ret;
     int ybase;
     size_t pix_count;  /* # pixels to send */
     register int x;

Modified: brlcad/trunk/src/libfb/if_remote.c
===================================================================
--- brlcad/trunk/src/libfb/if_remote.c  2013-03-27 19:43:55 UTC (rev 54921)
+++ brlcad/trunk/src/libfb/if_remote.c  2013-03-27 21:17:29 UTC (rev 54922)
@@ -349,10 +349,10 @@
 /*
  * Send as longs:  x, y, num
  */
-HIDDEN int
+HIDDEN ssize_t
 rem_read(register FBIO *ifp, int x, int y, unsigned char *pixelp, size_t num)
 {
-    int ret;
+    ssize_t ret;
     unsigned char buf[3*NET_LONG_LEN+1];
 
     if (num == 0)
@@ -367,8 +367,8 @@
     /* Get response;  0 len means failure */
     ret = pkg_waitfor(MSG_RETURN, (char *)pixelp, num*sizeof(RGBpixel), 
PCP(ifp));
     if (ret <= 0) {
-       fb_log("rem_read: read %ld at <%d, %d> failed, ret=%d.\n",
-              (long)num, x, y, ret);
+       fb_log("rem_read: read %lu at <%d, %d> failed, ret=%ld.\n",
+              num, x, y, ret);
        return -3;
     }
     return ret/sizeof(RGBpixel);
@@ -378,10 +378,10 @@
 /*
  * As longs, x, y, num
  */
-HIDDEN int
+HIDDEN ssize_t
 rem_write(register FBIO *ifp, int x, int y, const unsigned char *pixelp, 
size_t num)
 {
-    int ret;
+    ssize_t ret;
     unsigned char buf[3*NET_LONG_LEN+1];
 
     if (num <= 0) return num;

Modified: brlcad/trunk/src/libfb/if_stack.c
===================================================================
--- brlcad/trunk/src/libfb/if_stack.c   2013-03-27 19:43:55 UTC (rev 54921)
+++ brlcad/trunk/src/libfb/if_stack.c   2013-03-27 21:17:29 UTC (rev 54922)
@@ -140,7 +140,7 @@
 }
 
 
-HIDDEN int
+HIDDEN ssize_t
 stk_read(FBIO *ifp, int x, int y, unsigned char *pixelp, size_t count)
 {
     register FBIO **ip = SI(ifp)->if_list;
@@ -149,11 +149,11 @@
        fb_read((*ip), x, y, pixelp, count);
     }
 
-    return (int)count;
+    return count;
 }
 
 
-HIDDEN int
+HIDDEN ssize_t
 stk_write(FBIO *ifp, int x, int y, const unsigned char *pixelp, size_t count)
 {
     register FBIO **ip = SI(ifp)->if_list;
@@ -163,7 +163,7 @@
        ip++;
     }
 
-    return (int)count;
+    return count;
 }
 
 

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Own the Future-Intel&reg; Level Up Game Demo Contest 2013
Rise to greatness in Intel's independent game demo contest.
Compete for recognition, cash, and the chance to get your game 
on Steam. $5K grand prize plus 10 genre and skill prizes. 
Submit your demo by 6/6/13. http://p.sf.net/sfu/intel_levelupd2d
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to