[sane-devel] [PATCH] Port to OS X

Olaf Meeuwissen paddy-hack at member.fsf.org
Wed Oct 7 12:10:07 UTC 2015


Hi Yurii,

Thanks for your feedback but there are a few checks done by the
configure script that can/should be used to address the fixes the
suggest.

Yurii Kolesnykov writes:

>  4 files changed, 19 insertions(+)
>
> diff --git a/backend/pieusb_buffer.c b/backend/pieusb_buffer.c
> index 53bd867..23fc645 100644
> --- a/backend/pieusb_buffer.c
> +++ b/backend/pieusb_buffer.c
> @@ -100,7 +100,13 @@
>  #include <stdio.h>
>  #include <fcntl.h>
>  #include <sys/mman.h>
> +
> +#ifdef __APPLE__
> +#include <machine/endian.h>
> +#elif
>  #include <endian.h>
> +#endif

This should probably #include "byteorder.h" instead, independent of any
OS issues.  The byteorder.h file, which is generated by configure below
include/ is meant to take care of those.

> +
>  
>  /* When creating the release backend, make complains about unresolved external
>   * le16toh, although it finds the include <endian.h> */
> diff --git a/include/sane/sane.h b/include/sane/sane.h
> index 5320b4a..736a9cd 100644
> --- a/include/sane/sane.h
> +++ b/include/sane/sane.h
> @@ -20,6 +20,11 @@
>  extern "C" {
>  #endif
>  
> +#ifdef __APPLE__
> +// Fixes u_long missing error
> +#include <sys/types.h>
> +#endif
> +

Unless the SANE C API specification directly references anything that is
in <sys/types.h>, this is a no-no.  That said, the SANE C API should not
reference anthing in <sys/types.h>.

This header file should be directly included in those *.c files that
need it, as follows:

#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif

Of course, any code that depends on <sys/types.h> getting included needs
to be #ifdef'd too.

>  /*
>   * SANE types and defines
>   */
> diff --git a/include/sane/sanei_backend.h b/include/sane/sanei_backend.h
> index 1b5afe2..982dedc 100644
> --- a/include/sane/sanei_backend.h
> +++ b/include/sane/sanei_backend.h
> @@ -96,7 +96,9 @@
>  #  undef SIG_SETMASK
>  # endif
>  
> +# ifndef __APPLE__
>  # define sigset_t               int
> +# endif

Can you explain what this is trying to fix?  The sigset_t macro is
undefined a bit above this.  If sigset_t is still visible to the
compiler, it wasn't a macro and the defines below will quite likely
break things.

>  # define sigemptyset(set)       do { *(set) = 0; } while (0)
>  # define sigfillset(set)        do { *(set) = ~0; } while (0)
>  # define sigaddset(set,signal)  do { *(set) |= sigmask (signal); } while (0)
> diff --git a/sanei/sanei_ir.c b/sanei/sanei_ir.c
> index 42e82ba..0db2c29 100644
> --- a/sanei/sanei_ir.c
> +++ b/sanei/sanei_ir.c
> @@ -29,7 +29,13 @@
>  
>  #include <stdlib.h>
>  #include <string.h>
> +#ifdef __APPLE__ //OSX
> +#include <sys/types.h>
> +#include <limits.h>
> +#include <float.h>
> +#elif // not OSX
>  #include <values.h>
> +#endif
>  #include <math.h>

For <sys/types.h>, see above.  The <values.h> stuff has just been fixed
in master in 2239d2a.

Hope this helps,
-- 
Olaf Meeuwissen, LPIC-2            FSF Associate Member since 2004-01-27
Support Free Software               Support the Free Software Foundation
https://my.fsf.org/donate                        https://my.fsf.org/join
 GnuPG key: F84A2DD9/B3C0 2F47 EA19 64F4 9F13  F43E B8A4 A88A F84A 2DD9




More information about the sane-devel mailing list