[argyllcms] [FreeBSD, patch] spectro/usbio.c

  • From: Boris Samorodov <bsam@xxxxxxxxx>
  • To: argyllcms@xxxxxxxxxxxxx
  • Date: Fri, 22 Feb 2013 16:22:47 +0400

Hello All,

while building argyllcms at FreeBSD some errors occur. Errors are
the same at 9-i386 and 10-amd64. Compiles tested (clang is base
compiler at 10.x):
-----
% clang --version
FreeBSD clang version 3.2 (tags/RELEASE_32/final 170710) 20121221
Target: x86_64-unknown-freebsd10.0
Thread model: posix

% gcc --version
gcc (GCC) 4.2.1 20070831 patched [FreeBSD]
Copyright (C) 2007 Free Software Foundation, Inc.
-----

The first error is:
[...]
Cc_ spectro/spotread.o
Link_ spectro/illumread
spectro/libinst.a(usbio.o): In function `usb_get_paths':
spectro/usbio.c:(.text+0x1a): undefined reference to `usb_argyll_patched'
cc: error: linker command failed with exit code 1 (use -v to see invocation)

        cc -o spectro/illumread  spectro/illumread.o  -L/usr/local/lib
-g -lrt -lX11 -lXext -lXxf86vm -lXinerama -lXrandr -lXau -lXdmcp -lXss
-lusb -ltiff -ltiff spectro/libinst.a spect
ro/libconv.a xicc/libxcolorants.a xicc/libxicc.a gamut/libgamut.a
rspl/librspl.a cgats/libcgats.a icc/libicc.a plot/libplot.a
plot/libvrml.a numlib/libnum.a ucmm/libucmm.a jcnf/libjcnf.
a jcnf/yajl/libyajl.a libusb/libusb.a  -lm -lpthread

...failed Link_ spectro/illumread ...
[...]

And the second one is (clang):
[...]
spectro/usbio.c:742:17: error: use of undeclared identifier 'dev'; did
you mean 'div'?
                        descriptor = dev->descriptor;   /* Copy */
                                     ^~~
                                     div
/usr/include/stdlib.h:91:8: note: 'div' declared here
div_t    div(int, int) __pure2;
         ^
spectro/usbio.c:742:20: error: member reference base type 'div_t (int,
int)' is not a structure or union
                        descriptor = dev->descriptor;   /* Copy */
                                     ~~~^ ~~~~~~~~~~
4 warnings and 2 errors generated.

        cc -c -o spectro/usbio.o -DUNIX -D_THREAD_SAFE -pipe -O2
-DARGYLLCMS -Ispectro -Ih -Inumlib -Iicc -Icgats -Irspl -Ixicc -Igamut
-Ispectro -Iplot -Ilibusb -Iucmm -I/usr/local/inc
lude spectro/usbio.c

...failed Cc_ spectro/usbio.o ...
[...]

The second one with gcc:
[...]
spectro/usbio.c: In function 'usb_open_port':
spectro/usbio.c:742: error: 'dev' undeclared (first use in this function)
spectro/usbio.c:742: error: (Each undeclared identifier is reported only
once
spectro/usbio.c:742: error: for each function it appears in.)
spectro/usbio.c: In function 'icoms_usb_cancel_io':
spectro/usbio.c:1486: warning: cast from pointer to integer of different
size

        gcc -c -o spectro/usbio.o -DUNIX -D_THREAD_SAFE -pipe -O2
-DARGYLLCMS -Ispectro -Ih -Inumlib -Iicc -Icgats -Irspl -Ixicc -Igamut
-Ispectro -Iplot -Ilibusb -Iucmm -I/usr/local/in
clude spectro/usbio.c

...failed Cc_ spectro/usbio.o ...
[...]

The attached patch makes the build proceed.

The first hunk just disables the test for argyll patched usb at
FreeBSD. The second one is more questionable for me. Seems like
dev is a global variable but not seen by FreeBSD compilers...
The resulting code works for me though. At least spotread uses
my device: "usb:/bus0/dev13 (GretagMacbeth i1 Pro)" and do measures.

HTH
-- 
WBR, Boris Samorodov (bsam)
FreeBSD Committer, http://www.FreeBSD.org The Power To Serve
--- spectro/usbio.c.orig        2012-04-19 11:50:54.000000000 +0400
+++ spectro/usbio.c     2013-02-22 15:43:23.739460332 +0400
@@ -204,9 +204,10 @@ struct _icoms *p 
        struct usb_bus *bus;
 
        /* Check that we've got an up to date version of libusb */
+#ifndef __FreeBSD__
        if (usb_argyll_patched() < 2)
                error("usblib isn't up to date to work with this version of 
Argyll");
-
+#endif /* __FreeBSD__ */
        if (p->debug > 8)
                usb_set_debug(p->debug);
 
@@ -654,6 +655,7 @@ icomuflags usbflags,/* Any special handl
 int retries,           /* > 0 if we should retry set_configuration (100msec) 
*/ 
 char **pnames          /* List of process names to try and kill before opening 
*/
 ) {
+       struct usb_device *dev;
        int tries = 0;
        if (p->debug) fprintf(stderr,"icoms: About to open the USB port, tries 
%d\n",retries);
 

Other related posts:

  • » [argyllcms] [FreeBSD, patch] spectro/usbio.c - Boris Samorodov