Quantcast

[PATCH] Port to OS X

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH] Port to OS X

Yurii Kolesnykov
Quick fixes for error I have encountered during compilation.
make check reports problem:
>**** File generated for html-backends-split mode is different from reference

I have no clue wath this error is about. Is this the real error?

Yurii Kolesnykov (1):
  Port to OS X

 backend/pieusb_buffer.c      | 6 ++++++
 include/sane/sane.h          | 5 +++++
 include/sane/sanei_backend.h | 2 ++
 sanei/sanei_ir.c             | 6 ++++++
 4 files changed, 19 insertions(+)

--
2.6.0


--
sane-devel mailing list: [hidden email]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject "unsubscribe your_password"
             to [hidden email]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH] Port to OS X

Yurii Kolesnykov

 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
+
 
 /* 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
+
 /*
  * 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
 # 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>
 
 #define BACKEND_NAME sanei_ir /* name of this module for debugging */
--
2.6.0


--
sane-devel mailing list: [hidden email]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject "unsubscribe your_password"
             to [hidden email]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [PATCH] Port to OS X

Olaf Meeuwissen-4
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


--
sane-devel mailing list: [hidden email]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject "unsubscribe your_password"
             to [hidden email]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [PATCH] Port to OS X

Yurii Kolesnykov
Hi Olaf, thanks for your feedback.
Sorry, I forgot to include this comment in previous email.

> > /*
> > * 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.

I had this error:

In file included from epsonds-jpeg.c:18:
In file included from ./epsonds.h:43:
In file included from ../include/sane/sanei_usb.h:69:
In file included from /usr/include/stdlib.h:65:
In file included from /usr/include/sys/wait.h:109:
In file included from /usr/include/sys/signal.h:154:
/usr/include/sys/_types/_sigset_t.h:30:28: error: cannot combine with previous 'type-name' declaration specifier
typedef __darwin_sigset_t               sigset_t;
                                        ^
../include/sane/sanei_backend.h:99:33: note: expanded from macro 'sigset_t'
# define sigset_t               int
                                ^
1 error generated.



--
sane-devel mailing list: [hidden email]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject "unsubscribe your_password"
             to [hidden email]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [PATCH] Port to OS X

Olaf Meeuwissen-4
Hi Yurii,

Sorry for the late follow-up.

Yurii Kolesnykov writes:

> Hi Olaf, thanks for your feedback.
> Sorry, I forgot to include this comment in previous email.
>
>> > /*
>> > * 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.
>
> I had this error:
>
> In file included from epsonds-jpeg.c:18:
> In file included from ./epsonds.h:43:
> In file included from ../include/sane/sanei_usb.h:69:
> In file included from /usr/include/stdlib.h:65:
> In file included from /usr/include/sys/wait.h:109:
> In file included from /usr/include/sys/signal.h:154:
> /usr/include/sys/_types/_sigset_t.h:30:28: error: cannot combine with previous 'type-name' declaration specifier
> typedef __darwin_sigset_t        sigset_t;
>                     ^
> ../include/sane/sanei_backend.h:99:33: note: expanded from macro 'sigset_t'
> # define sigset_t        int
>                 ^
> 1 error generated.

Ok, so sigset_t wasn't a define.

I've dug up some[1] info[2] on __darwin_sigset_t and it seems to just be
a typedef for a 32 bit unsigned integer.  In that case, the other signal
related defines in sanei_backend.h won't break.

 [1] http://fxr.watson.org/fxr/ident?v=xnu-792;i=__darwin_sigset_t
 [2] https://www.opensource.apple.com/source/xnu/xnu-792.6.56/bsd/sys/_types.h

However, I don't think that your fix is the right way to go about fixing
this.  It is really something that configure should check for.

Feel free to keep using this patch yourself but I will not commit it to
Alioth's master.

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

--
sane-devel mailing list: [hidden email]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject "unsubscribe your_password"
             to [hidden email]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [PATCH] Port to OS X

Luiz Angelo Daros de Luca

Olaf and Yurii,

The sys/type.h problem is the same I face while compiling with musl instead of glibc.
There are just some files that miss it. I have a patch for them but it still misses the ifdef around it.
Check the other patches that might easy your port.

https://github.com/openwrt/packages/blob/master/utils/sane-backends/patches/

Regards,


Em sáb, 17 de out de 2015 01:36, Olaf Meeuwissen <[hidden email]> escreveu:
Hi Yurii,

Sorry for the late follow-up.

Yurii Kolesnykov writes:

> Hi Olaf, thanks for your feedback.
> Sorry, I forgot to include this comment in previous email.
>
>> > /*
>> > * 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.
>
> I had this error:
>
> In file included from epsonds-jpeg.c:18:
> In file included from ./epsonds.h:43:
> In file included from ../include/sane/sanei_usb.h:69:
> In file included from /usr/include/stdlib.h:65:
> In file included from /usr/include/sys/wait.h:109:
> In file included from /usr/include/sys/signal.h:154:
> /usr/include/sys/_types/_sigset_t.h:30:28: error: cannot combine with previous 'type-name' declaration specifier
> typedef __darwin_sigset_t        sigset_t;
>                     ^
> ../include/sane/sanei_backend.h:99:33: note: expanded from macro 'sigset_t'
> # define sigset_t        int
>                 ^
> 1 error generated.

Ok, so sigset_t wasn't a define.

I've dug up some[1] info[2] on __darwin_sigset_t and it seems to just be
a typedef for a 32 bit unsigned integer.  In that case, the other signal
related defines in sanei_backend.h won't break.

 [1] http://fxr.watson.org/fxr/ident?v=xnu-792;i=__darwin_sigset_t
 [2] https://www.opensource.apple.com/source/xnu/xnu-792.6.56/bsd/sys/_types.h

However, I don't think that your fix is the right way to go about fixing
this.  It is really something that configure should check for.

Feel free to keep using this patch yourself but I will not commit it to
Alioth's master.

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

--
sane-devel mailing list: [hidden email]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject "unsubscribe your_password"
             to [hidden email]
--

Luiz Angelo Daros de Luca


--
sane-devel mailing list: [hidden email]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject "unsubscribe your_password"
             to [hidden email]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Replacing u_char and friends (was Re: [PATCH] Port to OS X)

Olaf Meeuwissen-4
Hi Luiz, Devs,

Luiz Angelo Daros de Luca writes:

> Olaf and Yurii,
>
> The sys/type.h problem is the same I face while compiling with musl
> instead of glibc.  There are just some files that miss it. I have a
> patch for them but it still misses the ifdef around it.  Check the
> other patches that might easy your port.
>
> https://github.com/openwrt/packages/blob/master/utils/sane-backends/patches/

I looked at the 030-musl.patch and except maybe for the backend/hp*.c
files, all fixes seem to involve u_char and friends.  Now, ./configure
checks for their presence.  If they are absent, they will be defined
automatically for you in include/sane/config.h.  If they are present,
these defines are not provided and whoever uses them will need to add an
#include for a header that does, normally sys/types.h.  However, that
header may be absent itself, so ...

Somehow, I get the impression that ./configure is only doing half of
this job.  On the other hand, (blindly?) including sys/types.h in the
config.h file seems pretty heavy handed too.  Moreover, that file may
not be there.

Now, if the issue is just u_char and friends, can't we just simply avoid
the whole issue and replace them with "unsigned char" and the like?  For
all I know that ought to work everywhere.
A similar suggestion was made (way back) on StackOverflow[1].

 [1] http://stackoverflow.com/questions/1918934/is-u-char-a-standard

Grepping for the ones that ./configure checks for (SANE_CHECK_U_TYPES in
acinclude.m4) with:

  $ git grep -wE 'u_(char|short|int|long)' master | wc -l
  2084

that would be quite a monster patch though.  Would such a patch be
acceptable?

# There are false positives in the above, e.g. the ones in acinclude.m4
# and in include/sane/config.h and its template.

I realize that this is not Yurii's sigset_t problem but thought I would
mention it anyway.

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


--
sane-devel mailing list: [hidden email]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject "unsubscribe your_password"
             to [hidden email]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Replacing u_char and friends (was Re: [PATCH] Port to OS X)

Olaf Meeuwissen-4
Hi Devs,

Olaf Meeuwissen writes:

> Hi Luiz, Devs,
>
> Luiz Angelo Daros de Luca writes:
>
>> Olaf and Yurii,
>>
>> The sys/type.h problem is the same I face while compiling with musl
>> instead of glibc.  There are just some files that miss it. I have a
>> patch for them but it still misses the ifdef around it.  Check the
>> other patches that might easy your port.
>>
>> https://github.com/openwrt/packages/blob/master/utils/sane-backends/patches/
>
> I looked at the 030-musl.patch and except maybe for the backend/hp*.c
> files, all fixes seem to involve u_char and friends.  Now, ./configure
> checks for their presence.  If they are absent, they will be defined
> automatically for you in include/sane/config.h.  If they are present,
> these defines are not provided and whoever uses them will need to add an
> #include for a header that does, normally sys/types.h.  However, that
> header may be absent itself, so ...
>
> Somehow, I get the impression that ./configure is only doing half of
> this job.  On the other hand, (blindly?) including sys/types.h in the
> config.h file seems pretty heavy handed too.  Moreover, that file may
> not be there.
>
> Now, if the issue is just u_char and friends, can't we just simply avoid
> the whole issue and replace them with "unsigned char" and the like?  For
> all I know that ought to work everywhere.
> A similar suggestion was made (way back) on StackOverflow[1].
>
>  [1] http://stackoverflow.com/questions/1918934/is-u-char-a-standard
>
> Grepping for the ones that ./configure checks for (SANE_CHECK_U_TYPES in
> acinclude.m4) with:
>
>   $ git grep -wE 'u_(char|short|int|long)' master | wc -l
>   2084
>
> that would be quite a monster patch though.  Would such a patch be
> acceptable?

Following private communication with Luiz, I've decided to use his
030-musl.patch rather than replace u_TYPE with unsigned TYPE in all of
the sources.

When C libraries change their includes or someone tries to build with a
previously unused C library we will probably get to fix up another few
files that are getting a "free ride" through an implicitly included
<sys/types.h> somewhere.  We'll just keep playing whack-a-mole.  :-|

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

--
sane-devel mailing list: [hidden email]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject "unsubscribe your_password"
             to [hidden email]
Loading...