Skip to contentSkip to conversation

fix compile & linking errors on NetBSD

PATCH In review Christoph Egger 3 participants 5 messages Nov 17, 2008 – Nov 24, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix compile & linking errors on NetBSD

Hi,

Attached patch fixes some compile and linking issues on NetBSD.

- change configure and bswap.h to get the bswap* functions
- adapt configure to link against -lrt to fix aio linking errors
- adapt configure to link against -lossaudio to fix oss linking errors
- add native softfloat fpu functions

Signature · 12 lines
AMD Saxony, Dresden, Germany
Operating System Research Center

Legal Information:
AMD Saxony Limited Liability Company & Co. KG
Sitz (Geschäftsanschrift):
   Wilschdorfer Landstr. 101, 01109 Dresden, Deutschland
Registergericht Dresden: HRA 4896
vertretungsberechtigter Komplementär:
   AMD Saxony LLC (Sitz Wilmington, Delaware, USA)
Geschäftsführer der AMD Saxony LLC:
   Dr. Hans-R. Deppe, Thomas McCoy
qemu-sockets.c +3 -2
Index: qemu-sockets.c
===================================================================
@@ -20,6 +20,7 @@
 #include <unistd.h>
 
 #include "qemu_socket.h"
+#include "qemu-common.h" /* for qemu_isdigit */
 
 #ifndef AI_ADDRCONFIG
 # define AI_ADDRCONFIG 0
@@ -120,7 +121,7 @@
             return -1;
         }
         ai.ai_family = PF_INET6;
-    } else if (isdigit(str[0])) {
+    } else if (qemu_isdigit(str[0])) {
         /* IPv4 addr */
         if (2 != sscanf(str,"%64[0-9.]:%32[^,]%n",addr,port,&pos)) {
             fprintf(stderr, "%s: ipv4 parse error (%s)\n",
@@ -244,7 +245,7 @@
             return -1;
         }
         ai.ai_family = PF_INET6;
-    } else if (isdigit(str[0])) {
+    } else if (qemu_isdigit(str[0])) {
         /* IPv4 addr */
         if (2 != sscanf(str,"%64[0-9.]:%32[^,]",addr,port)) {
             fprintf(stderr, "%s: ipv4 parse error (%s)\n",
bswap.h +8 -0
Index: bswap.h
===================================================================
@@ -5,6 +5,12 @@
 
 #include <inttypes.h>
 
+#ifdef HAVE_MACHINE_BSWAP_H
+#include <sys/endian.h>
+#include <sys/types.h>
+#include <machine/bswap.h>
+#else
+
 #ifdef HAVE_BYTESWAP_H
 #include <byteswap.h>
 #else
@@ -58,6 +64,8 @@
     return bswap_64(x);
 }
 
+#endif /* ! HAVE_MACHINE_BSWAP_H */
+
 static inline void bswap16s(uint16_t *s)
 {
     *s = bswap16(*s);
configure +15 -1
Index: configure
===================================================================
@@ -147,6 +147,7 @@
 bsd="yes"
 audio_drv_list="oss"
 audio_possible_drivers="oss sdl esd pa"
+aiolib="-lpthread"
 if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then
     kqemu="yes"
 fi
@@ -155,6 +156,8 @@
 bsd="yes"
 audio_drv_list="oss"
 audio_possible_drivers="oss sdl esd"
+oss_lib="-lossaudio"
+aio_lib="-lrt -lpthread"
 ;;
 OpenBSD)
 bsd="yes"
@@ -162,6 +165,7 @@
 audio_drv_list="oss"
 audio_possible_drivers="oss sdl esd"
 oss_lib="-lossaudio"
+aio_lib="-lpthread"
 ;;
 Darwin)
 bsd="yes"
@@ -172,6 +176,7 @@
 audio_possible_drivers="coreaudio sdl fmod"
 OS_CFLAGS="-mdynamic-no-pic"
 OS_LDFLAGS="-framework CoreFoundation -framework IOKit"
+aio_lib="-lpthread"
 ;;
 SunOS)
     solaris="yes"
@@ -517,7 +522,7 @@
 if [ "$darwin" = "yes" -o "$mingw32" = "yes" ] ; then
     AIOLIBS=
 elif [ "$bsd" = "yes" ]; then
-    AIOLIBS="-lpthread"
+    AIOLIBS="$aio_lib"
 else
     # Some Linux architectures (e.g. s390) don't imply -lpthread automatically.
     AIOLIBS="-lrt -lpthread"
@@ -1210,6 +1225,15 @@
   if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
     echo "#define HAVE_BYTESWAP_H 1" >> $config_h
   fi
+  cat > $TMPC << EOF
+#include <sys/endian.h>
+#include <sys/types.h>
+#include <machine/bswap.h>
+int main(void) { return bswap32(0); }
+EOF
+  if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
+    echo "#define HAVE_MACHINE_BSWAP_H 1" >> $config_h
+  fi
 fi
 
 if [ "$openbsd" = "yes" ] ; then
softfloat-native.h +20 -2
Index: fpu/softfloat-native.h
===================================================================
@@ -8,8 +8,7 @@
 #include <fenv.h>
 #endif
 
-#ifdef __OpenBSD__
-/* Get OpenBSD version number */
+#if defined(__OpenBSD__) || defined(__NetBSD__)
 #include <sys/param.h>
 #endif
 
@@ -35,6 +34,25 @@
 #define unordered(x, y) (isnan(x) || isnan(y))
 #endif
 
+#ifdef __NetBSD__
+#ifndef isgreater
+#define isgreater(x, y)		__builtin_isgreater(x, y)
+#endif
+#ifndef isgreaterequal
+#define isgreaterequal(x, y)	__builtin_isgreaterequal(x, y)
+#endif
+#ifndef isless
+#define isless(x, y)		__builtin_isless(x, y)
+#endif
+#ifndef islessequal
+#define islessequal(x, y)	__builtin_islessequal(x, y)
+#endif
+#ifndef isunordered
+#define isunordered(x, y)	__builtin_isunordered(x, y)
+#endif
+#endif
+
+
 #define isnormal(x)             (fpclass(x) >= FP_NZERO)
 #define isgreater(x, y)         ((!unordered(x, y)) && ((x) > (y)))
 #define isgreaterequal(x, y)    ((!unordered(x, y)) && ((x) >= (y)))
#1 lore raw
Quoted 6 lines · Christoph Egger

Hi,

Attached patch fixes some compile and linking issues on NetBSD.

- change configure and bswap.h to get the bswap* functions

I didn't apply this, I think the bswap functions are fully optimized by the compiler.

Quoted 3 lines

- adapt configure to link against -lrt to fix aio linking errors
- adapt configure to link against -lossaudio to fix oss linking errors
- add native softfloat fpu functions

These are applied as r5774, r5775 and r5776. Thanks.

#2 lore raw
Quoted 9 lines · On Saturday 22 November 2008 21:28:56 Blue Swirl wrote:
Quoted 5 lines · Christoph Egger

Hi,

Attached patch fixes some compile and linking issues on NetBSD.

- change configure and bswap.h to get the bswap* functions

I didn't apply this, I think the bswap functions are fully optimized by the compiler.

The bswap part is needed on NetBSD. W/o it, I get this build error:

bswap.h:46: error: expected declaration specifiers or '...' before '(' token bswap.h:46: error: expected ')' before '?' token
bswap.h:51: error: expected declaration specifiers or '...' before '(' token bswap.h:51: error: expected ')' before '?' token
bswap.h:56: error: expected declaration specifiers or '...' before '(' token bswap.h:56: error: expected ')' before '?' token

Attached patch re-adds this.

Quoted 6 lines
Quoted 4 lines

- adapt configure to link against -lrt to fix aio linking errors
- adapt configure to link against -lossaudio to fix oss linking errors
- add native softfloat fpu functions

These are applied as r5774, r5775 and r5776. Thanks.

Thanks for applying it and fixing the typo.

Christoph

Signature · 12 lines
AMD Saxony, Dresden, Germany
Operating System Research Center

Legal Information:
AMD Saxony Limited Liability Company & Co. KG
Sitz (Geschäftsanschrift):
   Wilschdorfer Landstr. 101, 01109 Dresden, Deutschland
Registergericht Dresden: HRA 4896
vertretungsberechtigter Komplementär:
   AMD Saxony LLC (Sitz Wilmington, Delaware, USA)
Geschäftsführer der AMD Saxony LLC:
   Dr. Hans-R. Deppe, Thomas McCoy
bswap.h +8 -0
Index: bswap.h
===================================================================
@@ -5,6 +5,12 @@
 
 #include <inttypes.h>
 
+#ifdef HAVE_MACHINE_BSWAP_H
+#include <sys/endian.h>
+#include <sys/types.h>
+#include <machine/bswap.h>
+#else
+
 #ifdef HAVE_BYTESWAP_H
 #include <byteswap.h>
 #else
@@ -58,6 +64,8 @@
     return bswap_64(x);
 }
 
+#endif /* ! HAVE_MACHINE_BSWAP_H */
+
 static inline void bswap16s(uint16_t *s)
 {
     *s = bswap16(*s);
configure +9 -0
Index: configure
===================================================================
@@ -1222,6 +1233,15 @@
   if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
     echo "#define HAVE_BYTESWAP_H 1" >> $config_h
   fi
+  cat > $TMPC << EOF
+#include <sys/endian.h>
+#include <sys/types.h>
+#include <machine/bswap.h>
+int main(void) { return bswap32(0); }
+EOF
+  if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null ; then
+    echo "#define HAVE_MACHINE_BSWAP_H 1" >> $config_h
+  fi
 fi
 
 if [ "$openbsd" = "yes" ] ; then
#3 lore raw
In reply to Christoph Egger

Christoph Egger wrote:
[snip]

configure line 150

Quoted 9 lines

Index: configure
===================================================================

configure +1 -0
@@ -147,6 +147,7 @@
 bsd="yes"
 audio_drv_list="oss"
 audio_possible_drivers="oss sdl esd pa"
+aiolib="-lpthread"

Apparently this wasn't tested with FreeBSD. (It is aio_lib, not aiolib.)

Thiemo

#4 lore raw
Quoted 13 lines · Thiemo Seufer

Christoph Egger wrote:
[snip]

configure (working copy) line 150

Quoted 9 lines

Index: configure
===================================================================

configure (working copy) renamed from configure (revision 5728) +1 -0
@@ -147,6 +147,7 @@
 bsd="yes"
 audio_drv_list="oss"
 audio_possible_drivers="oss sdl esd pa"
+aiolib="-lpthread"

Apparently this wasn't tested with FreeBSD. (It is aio_lib, not aiolib.)

Thanks, fixed in r5782.