Fix NETBSD/amd64 compilation
PATCH 1/1 Fix NETBSD/amd64 compilation
Hi,
the following patch fixes compilation of qemu on NetBSD/amd64. Some of the chunks are from the pkgsrc tree.
From: Christoph Egger <[email protected]>
Signed-off-by Christoph Egger <[email protected]>
Regards,
Andre.
--
Andre Przywara
AMD-Operating System Research Center (OSRC), Dresden, Germany
Tel: +49 351 277-84917
----to satisfy European Law for business letters:
AMD Saxony Limited Liability Company & Co. KG, Wilschdorfer Landstr. 101, 01109 Dresden, Germany Register Court Dresden: HRA 4896, General Partner authorized to represent: AMD Saxony LLC (Wilmington, Delaware, US) General Manager of AMD Saxony LLC: Dr. Hans-R. Deppe, Thomas McCoy
Makefile.target +4 -0
@@ -92,6 +92,10 @@ OP_CFLAGS+=$(call cc-option, -fno-align-functions, $(call cc-option, -malign-functions=0, "")) OP_CFLAGS+=$(call cc-option, -fno-section-anchors, "") +ifdef STACK_PROTECTOR_PRESENT +OP_CFLAGS += -fno-stack-protector +endif + HELPER_CFLAGS= ifeq ($(ARCH),i386)
block-vvfat.c +1 -1
@@ -1052,7 +1052,7 @@ i =strrchr (dirname,':' ) - dirname;assert (i >=3 ); -if (dirname[i-2 ] ==':' &&isalpha (dirname[i-1 ])) +if (dirname[i-2 ] ==':' &&isalpha ((uint8_t )dirname[i-1 ]))/* workaround for DOS drive names */ dirname += i-1 ;else
vl.c +13 -5
@@ -54,16 +54,26 @@#include <sys/poll.h> #include <sys/mman.h> #include <sys/ioctl.h> +#include <sys/resource.h> #include <sys/socket.h> #include <netinet/in.h> +#include <net/if.h> +#if defined(__NetBSD__) +#include <net/if_tap.h> +#endif +#if defined(__linux__) || defined(__Linux__) +#include <linux/if_tun.h> +#endif +#include <arpa/inet.h> #include <dirent.h> #include <netdb.h> #include <sys/select.h> -#include <arpa/inet.h> #ifdef _BSD#include <sys/stat.h> -#if !defined(__APPLE__) && !defined(__OpenBSD__) +#if !defined(__APPLE__) && !defined(__OpenBSD__) && !defined(__NetBSD__)#include <libutil.h> +#else +#include <util.h> #endif #ifdef __OpenBSD__#include <net/if.h>
@@ -72,8 +82,6 @@#include <freebsd/stdlib.h> #else #ifdef __linux__ -#include <linux/if.h> -#include <linux/if_tun.h> #include <pty.h> #include <malloc.h> #include <linux/rtc.h>
@@ -3990,7 +3998,7 @@if (buf[0 ] =='\0' ) { saddr->sin_addr.s_addr =0 ; }else { -if (isdigit (buf[0 ])) { +if (isdigit ((uint8_t )buf[0 ])) {if (!inet_aton (buf, &saddr->sin_addr))return -1 ; }else {
translate_init.c +1 -1
@@ -9458,7 +9458,7 @@ p = name; check_pvr:for (i =0 ; i <8 ; i++) { -if (!isxdigit (*p++)) +if (!isxdigit ((uint8_t )*p++))break ; }if (i ==8 )
audio.c +2 -2
@@ -215,7 +215,7 @@pstrcat (r, len +sizeof (qemu_prefix), s);for (i =0 ; i < len; ++i) { - u[i] =toupper (u[i]); + u[i] =toupper ((uint8_t )u[i]); } }return r;
@@ -470,7 +470,7 @@/* copy while upper-casing, including trailing zero */ for (i =0 ; i <= preflen; ++i) { - optname[i +sizeof (qemu_prefix) -1 ] =toupper (prefix[i]); + optname[i +sizeof (qemu_prefix) -1 ] =toupper ((uint8_t )prefix[i]); }pstrcat (optname, optlen,"_" );pstrcat (optname, optlen, opt->name);
mixeng.c +56 -48
164 lines not on this page · raw message
bswap.h +8 -0
@@ -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);
dyngen.c +1 -0
@@ -1651,6 +1651,7 @@if (!sym_name)continue ;if (*sym_name && + !strstart (sym_name,"bswap64" ,NULL ) &&/* HF hack */ !strstart (sym_name,"__op_param" ,NULL ) && !strstart (sym_name,"__op_jmp" ,NULL ) && !strstart (sym_name,"__op_gen_label" ,NULL )) {
monitor.c +19 -19
@@ -1907,7 +1907,7 @@ {if (pch !='\0' ) { pch++; -while (isspace (*pch)) +while (isspace ((uint8_t )*pch)) pch++; } }
@@ -1966,7 +1966,7 @@ *q++ = *pch; pch++; } -while (isspace (*pch)) +while (isspace ((uint8_t )*pch)) pch++; *q =0 ; ret =get_monitor_def (®, buf);
@@ -1991,7 +1991,7 @@expr_error ("invalid char in expression" ); } pch = p; -while (isspace (*pch)) +while (isspace ((uint8_t )*pch)) pch++;break ; }
@@ -2085,7 +2085,7 @@ *pp = pch;return -1 ; } -while (isspace (*pch)) +while (isspace ((uint8_t )*pch)) pch++; *pval =expr_sum (); *pp = pch;
@@ -2100,7 +2100,7 @@ q = buf; p = *pp; -while (isspace (*p)) +while (isspace ((uint8_t )*p)) p++;if (*p =='\0' ) { fail:
@@ -2145,7 +2145,7 @@ } p++; }else { -while (*p !='\0' && !isspace (*p)) { +while (*p !='\0' && !isspace ((uint8_t )*p)) {if ((q - buf) < buf_size -1 ) { *q++ = *p; }
@@ -2191,12 +2191,12 @@/* extract the command name */ p = cmdline; q = cmdname; -while (isspace (*p)) +while (isspace ((uint8_t )*p)) p++;if (*p =='\0' )return ; pstart = p; -while (*p !='\0' && *p !='/' && !isspace (*p)) +while (*p !='\0' && *p !='/' && !isspace ((uint8_t )*p)) p++; len = p - pstart;if (len >sizeof (cmdname) -1 )
@@ -2232,7 +2232,7 @@int ret;char *str; -while (isspace (*p)) +while (isspace ((uint8_t )*p)) p++;if (*typestr =='?' ) { typestr++;
@@ -2273,15 +2273,15 @@ {int count, format, size; -while (isspace (*p)) +while (isspace ((uint8_t )*p)) p++;if (*p =='/' ) {/* format found */ p++; count =1 ; -if (isdigit (*p)) { +if (isdigit ((uint8_t )*p)) { count =0 ; -while (isdigit (*p)) { +while (isdigit ((uint8_t )*p)) { count = count *10 + (*p -'0' ); p++; }
@@ -2320,7 +2320,7 @@ } } next: -if (*p !='\0' && !isspace (*p)) { +if (*p !='\0' && !isspace ((uint8_t )*p)) {term_printf ("invalid char in format: '%c'\n" , *p); goto fail; }
@@ -2354,7 +2354,7 @@ {int64_t val; -while (isspace (*p)) +while (isspace ((uint8_t )*p)) p++;if (*typestr =='?' || *typestr =='.' ) {if (*typestr =='?' ) {
@@ -2365,7 +2365,7 @@ }else {if (*p =='.' ) { p++; -while (isspace (*p)) +while (isspace ((uint8_t )*p)) p++; has_arg =1 ; }else {
@@ -2410,7 +2410,7 @@ c = *typestr++;if (c =='\0' ) goto bad_type; -while (isspace (*p)) +while (isspace ((uint8_t )*p)) p++; has_option =0 ;if (*p =='-' ) {
@@ -2435,7 +2435,7 @@ } }/* check that all arguments were parsed */ -while (isspace (*p)) +while (isspace ((uint8_t )*p)) p++;if (*p !='\0' ) { term_printf("%s: extraneous characters at the end of line\n",
@@ -2583,7 +2583,7 @@ p = cmdline; nb_args =0 ;for (;;) { -while (isspace (*p)) +while (isspace ((uint8_t )*p)) p++;if (*p =='\0' )break ;
@@ -2617,7 +2617,7 @@/* if the line ends with a space, it means we want to complete the next arg */ len =strlen (cmdline); -if (len >0 &&isspace (cmdline[len -1 ])) { +if (len >0 &&isspace ((uint8_t )cmdline[len -1 ])) {if (nb_args >=MAX_ARGS )return ; args[nb_args++] =qemu_strdup ("" );
block.c +2 -0
@@ -30,8 +30,10 @@#include <sys/stat.h> #include <sys/ioctl.h> #include <sys/queue.h> +#if defined(__FreeBSD__)#include <sys/disk.h> #endif +#endif #define SECTOR_BITS 9#define SECTOR_SIZE (1 << SECTOR_BITS)
configure +26 -2
@@ -68,7 +68,7 @@ mips64) cpu="mips64" ;; - "Power Macintosh"|ppc|ppc64) + "Power Macintosh"|ppc|ppc64|powerpc) cpu="powerpc" ;; s390*)
@@ -151,6 +151,7 @@ bsd="yes" audio_drv_list="oss" audio_possible_drivers="oss sdl esd" +oss_lib="-lossaudio" ;; OpenBSD) bsd="yes"
@@ -497,7 +498,7 @@ if [ "$darwin" = "yes" -o "$mingw32" = "yes" ] ; then AIOLIBS= elif [ "$bsd" = "yes" ]; then - AIOLIBS="-lpthread" + AIOLIBS="-lrt -lpthread" else # Some Linux architectures (e.g. s390) don't imply -lpthread automatically. AIOLIBS="-lrt -lpthread"
@@ -537,6 +538,16 @@ fi fi +# Check for stack protector +cat > $TMPC <<EOF +extern int foo; +EOF +if "$cc" -o $TMPE $TMPC -fno-stack-protector 2> /dev/null ; then + stack_protector_present="yes" +else + stack_protector_present="no" +fi + if test ! -x "$(which cgcc 2>/dev/null)"; then sparse="no" fi
@@ -1139,6 +1150,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
@@ -1276,6 +1296,10 @@ echo "#define _BSD 1" >> $config_h fi +if [ "$stack_protector_present" = "yes" ] ; then + echo "STACK_PROTECTOR_PRESENT=yes" >> $config_mak +fi + echo "#define CONFIG_UNAME_RELEASE \"$uname_release\"" >> $config_h tools=
softfloat-native.h +20 -2
@@ -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)))