[sane-devel] Compilation errors with snapscan and Irix

Henning Meier-Geinitz henning@meier-geinitz.de
Sun, 27 Jan 2002 14:58:55 +0100


--d6Gm4EdcadzBjdND
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hi,

On Sun, Jan 27, 2002 at 12:57:46PM +0100, Oliver Schwartz wrote:
> I'm neither an expert on Irix nor on FreeBSD. The "#if defined" code was 
> taken directly from the manpage of semctl(2) on Linux. Maybe the manpage of 
> semctl for Irix or FreeBSD offers help. If anyone knows a fix I'll be happy 
> to integrate it.

And I'm nor an expert on semaphores :-)

From the Irix man page:
Status: O

SYNOPSIS
     #include <sys/types.h>
     #include <sys/ipc.h>
     #include <sys/sem.h>

     union semun {
          int val;
          struct semid_ds *buf;
          ushort *array;
     };

     int semctl(int semid, int semnum, int cmd, ... /* union semun arg */);

So it looks like semun must be defined manually.

However, looking at /usr/include/sys/sem.h on Irix:

#if _NO_XOPEN4
union semun {
        int val;
        struct semid_ds *buf;
        ushort_t *array;
};
#endif  /* _NO_XOPEN4 */
			
So something seems to define _NO_XOPEN4.

What about a configure test for "union semun"?

The attached dif is only tested for Linux/i386 and Irix but seems to
work. Its necessary to run autoconf before running configure.

What do you think about it?

Bye,
  Henning

--d6Gm4EdcadzBjdND
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="snapscan.dif"

Index: configure.in
===================================================================
RCS file: /cvsroot/external/sane/sane-backends/configure.in,v
retrieving revision 1.51
diff -u -u -r1.51 configure.in
--- configure.in	2002/01/17 03:17:23	1.51
+++ configure.in	2002/01/27 13:57:04
@@ -122,7 +122,7 @@
 AC_EGREP_HEADER([struct flock], fcntl.h, [AC_MSG_RESULT(yes) ;
                 AC_DEFINE(HAVE_STRUCT_FLOCK, 1,
                 [Define if struct flock is available.])], AC_MSG_RESULT(no))
- 
+
 if test "$ac_cv_header_sys_scsiio_h" = "yes" \
      -a "$ac_cv_header_scsi_h" = "yes";
 then
@@ -140,6 +140,14 @@
 ],[socklen_t len],AC_MSG_RESULT(yes),
 [AC_MSG_RESULT(no); AC_DEFINE(socklen_t,int,
 [Define socklen_t as \`int\' if necessary.])])
+
+AC_MSG_CHECKING([for union semun in <sys/sem.h>])
+AC_TRY_COMPILE([
+#include <sys/sem.h>
+],[union semun test_semun],[AC_MSG_RESULT(yes);
+AC_DEFINE(HAVE_UNION_SEMUN,1,[Define if union semun is available.])],
+AC_MSG_RESULT(no))
+
 
 SANE_V4L_VERSION
 
Index: include/sane/config.h.in
===================================================================
RCS file: /cvsroot/external/sane/sane-backends/include/sane/config.h.in,v
retrieving revision 1.17
diff -u -u -r1.17 config.h.in
--- config.h.in	2002/01/06 22:21:17	1.17
+++ config.h.in	2002/01/27 13:57:04
@@ -100,6 +100,9 @@
 /* Define if struct flock is available */
 #undef HAVE_STRUCT_FLOCK
 
+/* Define if union semun is available */
+#undef HAVE_UNION_SEMUN
+
 /* Define if you have the ANSI C header files.  */
 #undef STDC_HEADERS
 
Index: backend/snapscan-usb.c
===================================================================
RCS file: /cvsroot/external/sane/sane-backends/backend/snapscan-usb.c,v
retrieving revision 1.6
diff -u -u -r1.6 snapscan-usb.c
--- snapscan-usb.c	2002/01/15 20:16:55	1.6
+++ snapscan-usb.c	2002/01/27 13:57:05
@@ -55,8 +55,8 @@
 
 #include "snapscan-usb.h"
 
-/* the following code is taken from the manpage of semctl(2) */
-#if defined(__GNU_LIBRARY__) && !defined(_SEM_SEMUN_UNDEFINED)
+/* check for union semun */
+#if defined(HAVE_UNION_SEMUN)
 /* union semun is defined by including <sys/sem.h> */
 #else
 /* according to X/OPEN we have to define it ourselves */

--d6Gm4EdcadzBjdND--