Solaris host patch for QEMU
Hi,
With this patch, I can build and run qemu on Solaris x86. Note that it requires GNU make to build. The patch is available at
http://digitaleric.net/solaris.patch (in case my webmail mangles the whitespace).
--Eric
--- patch against qemu CVS as of last night ---
configure +12 -2
@@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # qemu configure script (c) 2003 Fabrice Bellard #
@@ -88,10 +88,13 @@ OpenBSD) bsd="yes" ;; +SunOS) +solaris="yes" +;; *) ;; esac -if [ "$bsd" = "yes" ] ; then +if [ "$bsd" = "yes" -o "$solaris" = "yes" ] ; then make="gmake" target_list="i386-softmmu" fi
@@ -391,6 +394,9 @@ elif test -f "/usr/include/byteswap.h" ; then echo "#define HAVE_BYTESWAP_H 1" >> $config_h fi +if test "$solaris" = "yes" ; then + echo "CONFIG_SOLARIS=yes" >> $config_mak +fi if test "$gdbstub" = "yes" ; then echo "CONFIG_GDBSTUB=yes" >> $config_mak echo "#define CONFIG_GDBSTUB 1" >> $config_h
@@ -424,6 +430,10 @@ echo "#define MAP_ANONYMOUS MAP_ANON" >> $config_h echo "#define _BSD 1" >> $config_h fi +if [ "$solaris" = "yes" ] ; then + echo "#define MAP_ANONYMOUS MAP_ANON" >> $config_h + echo "#define _SOLARIS 1" >> $config_h +fi for target in $target_list; do
dyngen-exec.h +8 -2
@@ -22,6 +22,7 @@#include <stddef.h> +#ifndef _SOLARIStypedef unsigned char uint8_t ;typedef unsigned short uint16_t ;typedef unsigned int uint32_t ;
@@ -40,6 +41,7 @@#else typedef signed long long int64_t ;#endif +#endif // ! _SOLARIS #define INT8_MIN (-128)#define INT16_MIN (-32767-1)
@@ -54,16 +56,20 @@#define UINT32_MAX (4294967295U)#define UINT64_MAX ((uint64_t)(18446744073709551615)) +#ifdef _SOLARIS +typedef struct __FILE FILE ; +#else typedef struct FILE FILE ; +#endif // _SOLARIS +extern int fprintf (FILE *,const char *, ...);extern int printf (const char *, ...);#undef NULL#define NULL 0#ifdef _BSD#include <ieeefp.h> -#else -#include <fenv.h> #endif +#include <fenv.h> #ifdef __i386__#define AREG0 "ebp"
Makefile.target +7 -0
@@ -159,6 +159,11 @@ ifdef CONFIG_WIN32 LIBS+=-lwinmm endif +ifdef CONFIG_SOLARIS +LIBS+=-lsocket +LIBS+=-lnsl +LIBS+=-lresolv +endif # profiling code ifdef TARGET_GPROF
@@ -271,8 +276,10 @@ VL_LDFLAGS+=-Wl,-T,$(SRC_PATH)/i386-vl.ld endif ifndef CONFIG_WIN32 +ifndef CONFIG_SOLARIS VL_LIBS=-lutil endif +endif $(QEMU_SYSTEM): $(VL_OBJS) libqemu.a $(CC) $(VL_LDFLAGS) -o $@ $^ $(LIBS) $(SDL_LIBS) $(VL_LIBS)
oss.c +10 -2
@@ -23,7 +23,15 @@*/ #include "vl.h" -#ifndef _WIN32 +#ifdef _WIN32 +#define NO_OSS +#endif +#ifdef _SOLARIS +#define NO_OSS +#endif + + +#ifndef NO_OSS #include <ctype.h> #include <fcntl.h> #include <errno.h>
@@ -556,7 +564,7 @@ conf.fragsize = lsbindex (fsp); } -#else +#else // NO_OSS void AUD_run (void ) {
qemu-mkcow.c +6 -1
@@ -25,7 +25,6 @@#include <stdio.h> #include <stdarg.h> #include <string.h> -#include <getopt.h> #include <inttypes.h> #include <unistd.h> #include <fcntl.h>
@@ -36,6 +35,12 @@#include <sys/stat.h> #include <netinet/in.h> +#include "config-host.h" + +#ifndef _SOLARIS +#include <getopt.h> +#endif +#include "cow.h" #include "bswap.h"
slirp/slirp.h +7 -2
@@ -5,10 +5,15 @@#define DEBUG 1 +#include "config.h" #ifndef CONFIG_QEMU #include "version.h" -#endif -#include "config.h" +#else +#ifdef _SOLARIS +#include "types.h" +#include <sys/filio.h> // for FIONREAD +#endif // _SOLARIS +#endif // CONFIG_QEMU #include "slirp_config.h" #include <sys/types.h>
diff -b -B -r -u qemu-cvs/target-i386/exec.hqemu-cvs+solaris/target-i386/exec.h
target-i386/exec.h +2 -0
@@ -17,6 +17,8 @@* License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#include <sys/types.h> #include "config.h" #include "dyngen-exec.h"
vl.c +7 -1
@@ -41,7 +41,9 @@#ifdef _BSD#include <sys/stat.h> #include <libutil.h> -#else +#elif _SOLARIS +#include <sys/stat.h> +#else // assume Linux #include <linux/if.h> #include <linux/if_tun.h> #include <pty.h>
@@ -865,6 +867,7 @@the emulated kernel requested a too high timer frequency */ getitimer (ITIMER_REAL , &itv); +#ifndef _SOLARISif (itv.it_interval.tv_usec >1000 ) {/* try to use /dev/rtc to have a faster timer */ if (start_rtc_timer () <0 )
@@ -885,6 +888,10 @@ pit_min_timer_count = ((uint64_t )itv.it_interval.tv_usec *PIT_FREQ ) /1000000 ; } +#else + + pit_min_timer_count = ((uint64_t)itv.it_interval.tv_usec * PIT_FREQ) /
1000000;
+#endif // ! _SOLARIS
}
#endif
}
@@ -1069,7 +1076,12 @@
fcntl(fd, F_SETFL, O_NONBLOCK);
return fd; }
-#else
+#elif _SOLARIS
+static int tun_open(char *ifname, int ifname_size) +{
+ return -1;
+}
+#else // assume Linux
static int tun_open(char *ifname, int ifname_size)
{
struct ifreq ifr;dyngen-exec.h line 72
Quoted 6 lines · On Fri, 11 Jun 2004 19:23:09 -0400 "EricNorthup" <[email protected]>…
#ifdef
_BSD
#include <ieeefp.h>dyngen-exec.h +1
-2-#else -#include <fenv.h> #endif +#include <fenv.h>
This will break BSD build. With this change fenv.h would always be included. You should change it to something like:
#if defined(_BSD) && !defined(_SOLARIS)
#include <ieeefp.h>
#else
#include <fenv.h>
#endif
vl.c line 895
Quoted 13 lines
vl.c +5
-0+#ifndef _SOLARISif (itv.it_interval.tv_usec >1000 ) {/* try to use /dev/rtc to have a faster timer */ if (start_rtc_timer () <0 )@@ -885,6 +888,10 @@ pit_min_timer_count = ((uint64_t )itv.it_interval.tv_usec * PIT_FREQ) / 1000000; } +#else + + pit_min_timer_count = ((uint64_t )itv.it_interval.tv_usec *PIT_FREQ ) /1000000 ; +#endif // ! _SOLARIS
I think it should be #ifndef _BSD. The patch that makes it work on BSD is not it the tree yet.
Regards,
Markus
On Sat, Jun 12, 2004 at 01:38:46 EDT, Markus Niemistö scribbled these curious markings:
Quoted 8 lines
Quoted 8 lines
vl.c +1
-0+#ifndef _SOLARISif (itv.it_interval.tv_usec >1000 ) {/* try to use /dev/rtc to have a faster timer */ if (start_rtc_timer () <0 )@@ -885,6 +888,10 @@ pit_min_timer_count = ((uint64_t )itv.it_interval.tv_usec *PIT_FREQ ) /1000000 ; }
Quoted 8 lines
Review line 895
Quoted 5 lines
(quoted diff) +4
-0+#else + + pit_min_timer_count = ((uint64_t)itv.it_interval.tv_usec * PIT_FREQ) / 1000000; +#endif // ! _SOLARISI think it should be #ifndef
_BSD. The patch that makes it work on BSD is not it the tree yet.
/me perks. What's this? A patch to make networking function on BSD? :) Please do elucidate this tired wannabe C programmer. =)
Signature · 4 lines
I abhor a system designed for the "user", if that word is a coded pejorative meaning "stupid and unsophisticated". -- Ken Thompson - Unix is user friendly. However, it isn't idiot friendly.
Quoted 5 lines · On Sat, 12 Jun 2004 03:23:23 -0400 Christopher Nehren <[email protected]>…
Quoted 2 lines
I think it should be #ifndef
_BSD. The patch that makes it work on BSD is not it the tree yet./me perks. What's this? A patch to make networking function on BSD? :) Please do elucidate this tired wannabe C programmer. =)
Actually I was referring to the grand unified BSD patch by Antony T. Curtis (sent to the list 30.5.). I am just trying to keep the BSD port working.
Markus