Skip to contentSkip to conversation

diffs for OpenBSD, and a problem ..

Qemu-devel Todd T. Fries 1 participant 1 message Feb 27, 2005 Kbuild

lore
Share & tools
lore
#0 lore raw

Current cvs no longer builds on OpenBSD. I'm trying to track this down. Here is what ends up happening for me:

for d in i386-softmmu ppc-softmmu sparc-softmmu x86_64-softmmu; do \
gmake -C $d all || exit 1 ; \
done
gmake[1]: Entering directory `/usr/obj/ports/qemu-20050227/qemu-20050227/i386-so ftmmu'
gcc -O2 -pipe -fomit-frame-pointer -I. -I/usr/obj/ports/qemu-20050227/qemu-20050 227/target-i386 -I/usr/obj/ports/qemu-20050227/qemu-20050227 -D_GNU_SOURCE -D_FI LE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -I/usr/obj/ports/qemu-20050227/qemu-200502 27/slirp -c -o translate-all.o /usr/obj/ports/qemu-20050227/qemu-20050227/transl ate-all.c
In file included from /usr/obj/ports/qemu-20050227/qemu-20050227/translate-all.c :41:
op.h: In function `dyngen_code':
op.h:6997: error: syntax error before ')' token
op.h:7074: error: syntax error before ')' token
op.h:7105: error: syntax error before ')' token
op.h:7124: error: syntax error before ')' token
op.h:7155: error: syntax error before ')' token
op.h:7174: error: syntax error before ')' token
op.h:7808: error: syntax error before ')' token
op.h:7830: error: syntax error before ')' token
op.h:7851: error: syntax error before ')' token
op.h:7872: error: syntax error before ')' token
op.h:7896: error: syntax error before ')' token
op.h:8611: error: syntax error before ')' token
op.h:8629: error: syntax error before ')' token
op.h:8646: error: syntax error before ')' token
op.h:8664: error: syntax error before ')' token
op.h:9257: error: syntax error before ')' token
op.h:9276: error: syntax error before ')' token
op.h:9295: error: syntax error before ')' token
op.h:9314: error: syntax error before ')' token
op.h:9333: error: syntax error before ')' token
op.h:9352: error: syntax error before ')' token
op.h:9372: error: syntax error before ')' token
op.h:9391: error: syntax error before ')' token
op.h:9410: error: syntax error before ')' token
op.h:9429: error: syntax error before ')' token
op.h:9449: error: syntax error before ')' token
gmake[1]: *** [translate-all.o] Error 1
gmake[1]: Leaving directory `/usr/obj/ports/qemu-20050227/qemu-20050227/i386-sof tmmu'
gmake: *** [all] Error 1
*** Error code 2

Stop in /tmp_mnt/10.0.0.66/ccd0/OpenBSD/wip/testing-ports/mystuff/emulators/qemu -snap (line 1716 of /usr/ports/infrastructure/mk/bsd.port.mk).
*** Error code 1

Stop in /tmp_mnt/10.0.0.66/ccd0/OpenBSD/wip/testing-ports/mystuff/emulators/qemu -snap (line 1517 of /usr/ports/infrastructure/mk/bsd.port.mk). todd@eclipse/p0 21$

Here are the diffs that are presently necessary, adapted from 0.6.1, I expect to be necessary to build qemu on OpenBSD/i386 and OpenBSD/macppc, that I have in my tree as well, incase you think any of them might be a culprit.

Index: Makefile
===================================================================
RCS file: /cvsroot/qemu/qemu/Makefile,v
retrieving revision 1.82

Makefile +10 -12
diff -u -r1.82 Makefile
@@ -1,10 +1,10 @@
 -include config-host.mak
 
-CFLAGS=-Wall -O2 -g -fno-strict-aliasing 
+#CFLAGS=-Wall -O2 -g -fno-strict-aliasing 
 ifdef CONFIG_DARWIN
 CFLAGS+= -mdynamic-no-pic
 endif
-LDFLAGS=-g
+#LDFLAGS=-g
 LIBS=
 DEFINES+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
 TOOLS=qemu-img$(EXESUF)
@@ -50,21 +50,19 @@
 common  de-ch  es     fo  fr-ca  hu     ja  mk  nl-be      pt  sl     tr
 
 install: all 
-	mkdir -p "$(bindir)"
-	install -m 755 -s $(TOOLS) "$(bindir)"
-	mkdir -p "$(datadir)"
+	mkdir -p $(PREFIX)/share/qemu
+	install -m 755 -s $(TOOLS) $(PREFIX)/bin
 	install -m 644 pc-bios/bios.bin pc-bios/vgabios.bin \
                        pc-bios/vgabios-cirrus.bin \
                        pc-bios/ppc_rom.bin \
                        pc-bios/proll.elf \
-                       pc-bios/linux_boot.bin "$(datadir)"
-	mkdir -p "$(docdir)"
-	install -m 644 qemu-doc.html  qemu-tech.html "$(docdir)"
+                       pc-bios/linux_boot.bin $(PREFIX)/share/qemu
+	mkdir -p $(PREFIX)/share/doc/qemu
+	install -m 644 qemu-doc.html  qemu-tech.html $(PREFIX)/share/doc/qemu
 ifndef CONFIG_WIN32
-	mkdir -p "$(mandir)/man1"
-	install qemu.1 qemu-img.1 "$(mandir)/man1"
-	mkdir -p "$(datadir)/keymaps"
-	install -m 644 $(addprefix keymaps/,$(KEYMAPS)) "$(datadir)/keymaps"
+	install qemu.1 qemu-img.1 $(PREFIX)/man/man1
+	mkdir -p $(PREFIX)/share/qemu/keymaps
+	install -m 644 $(addprefix keymaps/,$(KEYMAPS)) $(PREFIX)/share/qemu/keymaps
 endif
 	for d in $(TARGET_DIRS); do \
 	$(MAKE) -C $$d $@ || exit 1 ; \

Index: Makefile.target
===================================================================
RCS file: /cvsroot/qemu/qemu/Makefile.target,v
retrieving revision 1.58

Makefile.target +5 -2
diff -u -r1.58 Makefile.target
@@ -14,7 +14,7 @@
 VPATH+=:$(SRC_PATH)/linux-user
 DEFINES+=-I$(SRC_PATH)/linux-user -I$(SRC_PATH)/linux-user/$(TARGET_ARCH)
 endif
-CFLAGS=-Wall -O2 -g -fno-strict-aliasing
+#CFLAGS=-Wall -O2 -g -fno-strict-aliasing
 #CFLAGS+=-Werror
 LDFLAGS=-g
 LIBS=
@@ -312,6 +312,9 @@
 endif
 ifdef CONFIG_OSS
 AUDIODRV += ossaudio.o
+ifdef CONFIG_OSS_LIBRARY
+LIBS += -lossaudio
+endif
 endif
 
 pc.o: DEFINES := -DUSE_SB16 $(DEFINES)
@@ -439,7 +442,7 @@
 
 install: all 
 ifneq ($(PROGS),)
-	install -m 755 -s $(PROGS) "$(bindir)"
+	install -m 755 -s $(PROGS) $(PREFIX)/bin/
 endif
 
 ifneq ($(wildcard .depend),)

Index: configure
===================================================================
RCS file: /cvsroot/qemu/qemu/configure,v
retrieving revision 1.56

configure +15 -2
diff -u -r1.56 configure
@@ -41,7 +41,7 @@
   alpha)
     cpu="alpha"
   ;;
-  "Power Macintosh"|ppc|ppc64)
+  "Power Macintosh"|macppc|ppc|ppc64)
     cpu="powerpc"
   ;;
   mips)
@@ -100,6 +100,7 @@
 ;;
 OpenBSD)
 bsd="yes"
+openbsd="yes"
 oss="yes"
 ;;
 Darwin)
@@ -341,7 +342,7 @@
 if test -z "$prefix" ; then
     prefix="/usr/local"
 fi
-mandir="$prefix/share/man"
+mandir="$prefix/man"
 datadir="$prefix/share/qemu"
 docdir="$prefix/share/doc/qemu"
 bindir="$prefix/bin"
@@ -533,6 +534,9 @@
 if test "$oss" = "yes" ; then
   echo "CONFIG_OSS=yes" >> $config_mak
   echo "#define CONFIG_OSS 1" >> $config_h
+  if test "$openbsd"="yes" ; then
+    echo "CONFIG_OSS_LIBRARY=yes" >> $config_mak
+  fi
 fi
 if test "$fmod" = "yes" ; then
   echo "CONFIG_FMOD=yes" >> $config_mak
@@ -564,6 +568,15 @@
   echo "#define _BSD 1" >> $config_h
 fi
 
+if [ "$openbsd" = "yes" ] ; then
+  echo "#define ENOTSUP 4096" >> $config_h
+  echo "#define PRIx64 \"llX\"" >> $config_h
+  echo "#define qemu_siginfo siginfo_t" >> $config_h
+else
+  echo "#define qemu_siginfo struct siginfo" >> $config_h
+fi     
+
+
 for target in $target_list; do 
 
 target_dir="$target"

Index: dis-asm.h
===================================================================
RCS file: /cvsroot/qemu/qemu/dis-asm.h,v
retrieving revision 1.7

dis-asm.h +1 -0
diff -u -r1.7 dis-asm.h
@@ -13,6 +13,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <inttypes.h>
+#include "config.h"
 
 #define PARAMS(x) x
 typedef void *PTR;

Index: dyngen-exec.h
===================================================================
RCS file: /cvsroot/qemu/qemu/dyngen-exec.h,v
retrieving revision 1.20

dyngen-exec.h +11 -1
diff -u -r1.20 dyngen-exec.h
@@ -20,11 +20,15 @@
 #if !defined(__DYNGEN_EXEC_H__)
 #define __DYNGEN_EXEC_H__
 
+#include "config.h"
+
 /* NOTE: standard headers should be used with special care at this
    point because host CPU registers are used as global variables. Some
    host headers do not allow that. */
 #include <stddef.h>
-
+#ifdef __OpenBSD__
+#include <sys/types.h>
+#else
 typedef unsigned char uint8_t;
 typedef unsigned short uint16_t;
 typedef unsigned int uint32_t;
@@ -43,6 +47,7 @@
 #else
 typedef signed long long int64_t;
 #endif
+#endif
 
 #define INT8_MIN		(-128)
 #define INT16_MIN		(-32767-1)
@@ -57,11 +62,15 @@
 #define UINT32_MAX		(4294967295U)
 #define UINT64_MAX		((uint64_t)(18446744073709551615))
 
+#ifdef __OpenBSD__
+typedef struct __sFILE FILE;
+#else
 typedef struct FILE FILE;
 extern int fprintf(FILE *, const char *, ...);
 extern int printf(const char *, ...);
 #undef NULL
 #define NULL 0
+#endif
 #if defined(_BSD) && !defined(__APPLE__)
 #include <ieeefp.h>
 
@@ -70,6 +79,7 @@
 #define FE_UPWARD      FP_RP
 #define FE_TOWARDZERO  FP_RZ
 #define fesetround(x)  fpsetround(x)
+#define fegetround()   fpgetround()
 #else
 #include <fenv.h>
 #endif

Index: osdep.h
===================================================================
RCS file: /cvsroot/qemu/qemu/osdep.h,v
retrieving revision 1.5

osdep.h +5 -1
diff -u -r1.5 osdep.h
@@ -2,6 +2,10 @@
 #define QEMU_OSDEP_H
 
 #include <stdarg.h>
+#ifdef __OpenBSD__
+#include <sys/types.h>
+#include <sys/signal.h>
+#endif
 
 int qemu_vsnprintf(char *buf, int buflen, const char *fmt, va_list args);
 void qemu_vprintf(const char *fmt, va_list ap);
@@ -31,7 +35,7 @@
 struct qemu_sigaction {
     union {
         void (*_sa_handler)(int);
-        void (*_sa_sigaction)(int, struct siginfo *, void *);
+        void (*_sa_sigaction)(int, qemu_siginfo *, void *);
     } _u;
     unsigned long sa_flags;
     void (*sa_restorer)(void);

Index: vl.c
===================================================================
RCS file: /cvsroot/qemu/qemu/vl.c,v
retrieving revision 1.120

vl.c +22 -1
diff -u -r1.120 vl.c
@@ -42,7 +42,7 @@
 #include <dirent.h>
 #ifdef _BSD
 #include <sys/stat.h>
-#ifndef __APPLE__
+#if !defined(__APPLE__) && !defined(__OpenBSD__)
 #include <libutil.h>
 #endif
 #else
@@ -1574,11 +1574,32 @@
     char *dev;
     struct stat s;
 
+#ifdef __OpenBSD__
+    int i = 0, enoentcount = 0, err = 0;
+    char dname[100];
+
+    for (; i < 10; i++) {
+	snprintf(dname, sizeof dname, "%s%d", "/dev/tun", i);
+	fd = open(dname, O_RDWR);
+	if (fd >= 0)
+	    break;
+	else if (errno != ENOENT || ++enoentcount > 3) {
+	    err = errno;
+	    break;
+	} else
+	    err = errno;
+    }
+    if (fd < 0) {
+        fprintf(stderr, "warning: could not open %s (%s): no virtual network emulation\n", dname, strerror(err));
+        return -1;
+    }
+#else
     fd = open("/dev/tap", O_RDWR);
     if (fd < 0) {
         fprintf(stderr, "warning: could not open /dev/tap: no virtual network emulation\n");
         return -1;
     }
+#endif
 
     fstat(fd, &s);
     dev = devname(s.st_rdev, S_IFCHR);

Index: audio/audio.c
===================================================================
RCS file: /cvsroot/qemu/qemu/audio/audio.c,v
retrieving revision 1.5

audio.c +4 -0
diff -u -r1.5 audio.c
@@ -35,6 +35,10 @@
 #define ldebug(...)
 #endif
 
+#ifdef __OpenBSD__
+#define INT16_MAX		(32767)
+#endif
+
 #define QC_AUDIO_DRV    "QEMU_AUDIO_DRV"
 #define QC_VOICES       "QEMU_VOICES"
 #define QC_FIXED_FORMAT "QEMU_FIXED_FORMAT"

Index: audio/ossaudio.c
===================================================================
RCS file: /cvsroot/qemu/qemu/audio/ossaudio.c,v
retrieving revision 1.4

ossaudio.c +6 -1
diff -u -r1.4 ossaudio.c
@@ -21,10 +21,15 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#ifdef __OpenBSD__
+#include <stdlib.h>
+#include <soundcard.h>
+#else
+#include <sys/soundcard.h>
+#endif
 #include <sys/mman.h>
 #include <sys/types.h>
 #include <sys/ioctl.h>
-#include <sys/soundcard.h>
 #include <assert.h>
 #include "vl.h"
 

Index: slirp/slirp_config.h
===================================================================
RCS file: /cvsroot/qemu/qemu/slirp/slirp_config.h,v retrieving revision 1.3

slirp_config.h +4 -4
diff -u -r1.3 slirp_config.h
@@ -92,7 +92,7 @@
 #undef BAD_SPRINTF
 
 /* Define if you have readv */
-#undef HAVE_READV
+#define HAVE_READV
 
 /* Define if iovec needs to be declared */
 #undef DECLARE_IOVEC
@@ -104,7 +104,7 @@
 #undef DECLARE_SPRINTF
 
 /* Define if you have a POSIX.1 sys/wait.h */
-#undef HAVE_SYS_WAIT_H
+#define HAVE_SYS_WAIT_H
 
 /* Define if you have sys/select.h */
 #undef HAVE_SYS_SELECT_H
@@ -122,7 +122,7 @@
 #endif
 
 /* Define if you have sys/signal.h */
-#undef HAVE_SYS_SIGNAL_H
+#define HAVE_SYS_SIGNAL_H
 
 /* Define if you have sys/stropts.h */
 #undef HAVE_SYS_STROPTS_H
@@ -198,7 +198,7 @@
 #undef HAVE_GRANTPT
 
 /* Define if you have fchmod */
-#undef HAVE_FCHMOD
+#define HAVE_FCHMOD
 
 /* Define if you have <sys/type32.h> */
 #undef HAVE_SYS_TYPES32_H

Index: target-arm/cpu.h
===================================================================
RCS file: /cvsroot/qemu/qemu/target-arm/cpu.h,v
retrieving revision 1.7

cpu.h +1 -1
diff -u -r1.7 cpu.h
@@ -97,7 +97,7 @@
    signal handlers to inform the virtual CPU of exceptions. non zero
    is returned if the signal was handled by the virtual CPU.  */
 struct siginfo;
-int cpu_arm_signal_handler(int host_signum, struct siginfo *info, 
+int cpu_arm_signal_handler(int host_signum, qemu_siginfo *info, 
                            void *puc);
 
 #define TARGET_PAGE_BITS 12

Index: target-i386/cpu.h
===================================================================
RCS file: /cvsroot/qemu/qemu/target-i386/cpu.h,v
retrieving revision 1.27

cpu.h +1 -2
diff -u -r1.27 cpu.h
@@ -609,8 +609,7 @@
 /* you can call this signal handler from your SIGBUS and SIGSEGV
    signal handlers to inform the virtual CPU of exceptions. non zero
    is returned if the signal was handled by the virtual CPU.  */
-struct siginfo;
-int cpu_x86_signal_handler(int host_signum, struct siginfo *info, 
+int cpu_x86_signal_handler(int host_signum, qemu_siginfo *info, 
                            void *puc);
 void cpu_x86_set_a20(CPUX86State *env, int a20_state);
 

Index: target-ppc/cpu.h
===================================================================
RCS file: /cvsroot/qemu/qemu/target-ppc/cpu.h,v
retrieving revision 1.15

cpu.h +1 -2
diff -u -r1.15 cpu.h
@@ -163,8 +163,7 @@
 /* you can call this signal handler from your SIGBUS and SIGSEGV
    signal handlers to inform the virtual CPU of exceptions. non zero
    is returned if the signal was handled by the virtual CPU.  */
-struct siginfo;
-int cpu_ppc_signal_handler(int host_signum, struct siginfo *info, 
+int cpu_ppc_signal_handler(int host_signum, qemu_siginfo *info, 
                            void *puc);
 
 void do_interrupt (CPUPPCState *env);

Index: target-ppc/op_helper.c
===================================================================
RCS file: /cvsroot/qemu/qemu/target-ppc/op_helper.c,v retrieving revision 1.11

op_helper.c +22 -0
diff -u -r1.11 op_helper.c
@@ -226,6 +226,18 @@
     /* Set rounding mode */
     switch (env->fpscr[0] & 0x3) {
     case 0:
+#ifdef _BSD
+	fpsetround(FP_RN);
+	break;
+    case 1:
+	fpsetround(FP_RZ);
+	break;
+    case 2:
+	fpsetround(FP_RP);
+	break;
+    case 3:
+	fpsetround(FP_RM);
+#else
         /* Best approximation (round to nearest) */
         fesetround(FE_TONEAREST);
         break;
@@ -240,6 +252,7 @@
     case 3:
         /* Round toward -infinite */
         fesetround(FE_DOWNWARD);
+#endif
         break;
     }
 }
@@ -267,9 +280,14 @@
         double d;
         uint64_t i;
     } *p = (void *)&FT1;
+#ifdef _BSD
+    int cround = fpgetround();
+    fpsetround(FP_RZ);
+#else
     int cround = fegetround();
 
     fesetround(FE_TOWARDZERO);
+#endif
     if (FT0 > (double)0x7FFFFFFF)
         p->i = 0x7FFFFFFFULL << 32;
     else if (FT0 < -(double)0x80000000)
@@ -278,7 +296,11 @@
         p->i = 0;
     p->i |= (uint32_t)FT0;
     FT0 = p->d;
+#ifdef _BSD
+    fpsetround(cround);
+#else
     fesetround(cround);
+#endif
 }
 
 void do_fnmadd (void)

Index: target-sparc/cpu.h
===================================================================
RCS file: /cvsroot/qemu/qemu/target-sparc/cpu.h,v
retrieving revision 1.15

cpu.h +1 -2
diff -u -r1.15 cpu.h
@@ -189,8 +189,7 @@
 	cpu_set_cwp(env, _tmp & PSR_CWP & (NWINDOWS - 1));		\
     } while (0)
 
-struct siginfo;
-int cpu_sparc_signal_handler(int hostsignum, struct siginfo *info, void *puc);
+int cpu_sparc_signal_handler(int hostsignum, qemu_siginfo *info, void *puc);
 
 #define TARGET_PAGE_BITS 12 /* 4k */
 #include "cpu-all.h"

Index: target-sparc/op_helper.c
===================================================================
RCS file: /cvsroot/qemu/qemu/target-sparc/op_helper.c,v retrieving revision 1.9

op_helper.c +2 -0
diff -u -r1.9 op_helper.c
@@ -1,5 +1,7 @@
 #include <math.h>
+#ifndef _BSD
 #include <fenv.h>
+#endif
 #include "exec.h"
 
 //#define DEBUG_MMU
Signature · 12 lines
Todd Fries .. [email protected]

 _____________________________________________
|                                             \  1.636.410.0632 (voice)
| Free Daemon Consulting, LLC                 \  1.405.227.9094 (voice)
| http://FreeDaemonConsulting.com             \  1.866.792.3418 (FAX)
| "..in support of free software solutions."  \  1.700.227.9094 (IAXTEL)
|                                             \          250797 (FWD)
 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
                                                 
              37E7 D3EB 74D0 8D66 A68D  B866 0326 204E 3F42 004A
                        http://todd.fries.net/pgp.txt