Build fixes for BSD
PATCH 1/1 Build fixes for BSD
Hi,
Attached patch fixes ioemu build for NetBSD.
All changes (apart from hw/battery_mgmt.h) are from qemu upstream.
Signed-off-by Christoph Egger <[email protected]>
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
audio/audio.c +2 -2
@@ -215,7 +215,7 @@ static char *audio_alloc_prefix (const char *s)pstrcat (r, len +sizeof (qemu_prefix), s);for (i =0 ; i < len; ++i) { - u[i] =CTYPE (toupper, u[i]); + u[i] =qemu_toupper (u[i]); } }return r;
@@ -470,7 +470,7 @@ static void audio_process_options (const char *prefix,/* copy while upper-casing, including trailing zero */ for (i =0 ; i <= preflen; ++i) { - optname[i +sizeof (qemu_prefix) -1 ] =CTYPE (toupper, prefix[i]); + optname[i +sizeof (qemu_prefix) -1 ] =qemu_toupper (prefix[i]); }pstrcat (optname, optlen,"_" );pstrcat (optname, optlen, opt->name);
block-vvfat.c +3 -3
@@ -1052,7 +1052,7 @@ DLOG(if (stderr == NULL) { i =strrchr (dirname,':' ) - dirname;assert (i >=3 ); -if (dirname[i-2 ] ==':' &&CTYPE (isalpha,dirname[i-1 ])) +if (dirname[i-2 ] ==':' &&qemu_isalpha (dirname[i-1 ]))/* workaround for DOS drive names */ dirname += i-1 ;else
@@ -1479,7 +1479,7 @@ static int parse_short_name(BDRVVVFATState* s,if (direntry->name[i] <=' ' || direntry->name[i] >0x7f )return -1 ;else if (s->downcase_short_names) - lfn->name[i] =CTYPE (tolower,direntry->name[i]); + lfn->name[i] =qemu_tolower (direntry->name[i]);else lfn->name[i] = direntry->name[i]; }
@@ -1492,7 +1492,7 @@ static int parse_short_name(BDRVVVFATState* s,if (direntry->extension[j] <=' ' || direntry->extension[j] >0x7f )return -2 ;else if (s->downcase_short_names) - lfn->name[i + j] =CTYPE (tolower,direntry->extension[j]); + lfn->name[i + j] =qemu_tolower (direntry->extension[j]);else lfn->name[i + j] = direntry->extension[j]; }
block.c +6 -0
@@ -21,6 +21,12 @@* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +#include "config-host.h" +#ifdef _BSD +/* include native header before sys-queue.h */ +#include <sys/queue.h> +#endif +#include "qemu-common.h" #include "console.h" #include "block_int.h"
configure +7 -4
@@ -143,14 +143,15 @@ FreeBSD) bsd="yes" audio_drv_list="oss" audio_possible_drivers="oss sdl esd pa" -if [ "$cpu" = "i386" -o "$cpu" = "x86_64" ] ; then - kqemu="yes" -fi +oss_lib="-lossaudio" +aio_lib="-lpthread" ;; NetBSD) bsd="yes" audio_drv_list="oss" audio_possible_drivers="oss sdl esd" +oss_lib="-lossaudio" +aio_lib="-lrt -lpthread" ;; OpenBSD) bsd="yes"
@@ -158,6 +159,7 @@ openbsd="yes" audio_drv_list="oss" audio_possible_drivers="oss sdl esd" oss_lib="-lossaudio" +aio_lib="-lpthread" ;; Darwin) bsd="yes"
@@ -168,6 +170,7 @@ audio_drv_list="coreaudio" audio_possible_drivers="coreaudio sdl fmod" OS_CFLAGS="-mdynamic-no-pic" OS_LDFLAGS="-framework CoreFoundation -framework IOKit" +aio_lib="-lpthread" ;; SunOS) solaris="yes"
@@ -500,7 +503,7 @@ fi 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"
cutils.c +1 -1
@@ -72,7 +72,7 @@ int stristart(const char *str, const char *val, const char **ptr) p = str; q = val;while (*q !='\0' ) { -if (CTYPE (toupper,*p) !=CTYPE (toupper,*q)) +if (qemu_toupper (*p) !=qemu_toupper (*q))return 0 ; p++; q++;
hw/battery_mgmt.h +3 -0
@@ -25,6 +25,9 @@#ifdef CONFIG_STUBDOM #define CONFIG_NO_BATTERY_MGMT #endif +#ifdef _BSD/* There's no ioperm(), outb(), inb() */ +#define CONFIG_NO_BATTERY_MGMT +#endif enum POWER_MGMT_MODE {PM_MODE_NONE =0 ,PM_MODE_PT ,PM_MODE_NON_PT };enum BATTERY_INFO_TYPE {BATT_NONE ,BIF ,BST };
monitor.c +19 -19
@@ -1923,7 +1923,7 @@ static void next(void) {if (pch !='\0' ) { pch++; -while (CTYPE (isspace,*pch)) +while (qemu_isspace (*pch)) pch++; } }
@@ -1982,7 +1982,7 @@ static int64_t expr_unary(void) *q++ = *pch; pch++; } -while (CTYPE (isspace,*pch)) +while (qemu_isspace (*pch)) pch++; *q =0 ; ret =get_monitor_def (®, buf);
@@ -2007,7 +2007,7 @@ static int64_t expr_unary(void)expr_error ("invalid char in expression" ); } pch = p; -while (CTYPE (isspace,*pch)) +while (qemu_isspace (*pch)) pch++;break ; }
@@ -2101,7 +2101,7 @@ static int get_expr(int64_t *pval, const char **pp) *pp = pch;return -1 ; } -while (CTYPE (isspace,*pch)) +while (qemu_isspace (*pch)) pch++; *pval =expr_sum (); *pp = pch;
@@ -2116,7 +2116,7 @@ static int get_str(char *buf, int buf_size, const char **pp) q = buf; p = *pp; -while (CTYPE (isspace,*p)) +while (qemu_isspace (*p)) p++;if (*p =='\0' ) { fail:
@@ -2161,7 +2161,7 @@ static int get_str(char *buf, int buf_size, const char **pp) } p++; }else { -while (*p !='\0' && !CTYPE (isspace,*p)) { +while (*p !='\0' && !qemu_isspace (*p)) {if ((q - buf) < buf_size -1 ) { *q++ = *p; }
@@ -2207,12 +2207,12 @@ static void monitor_handle_command(const char *cmdline)/* extract the command name */ p = cmdline; q = cmdname; -while (CTYPE (isspace,*p)) +while (qemu_isspace (*p)) p++;if (*p =='\0' )return ; pstart = p; -while (*p !='\0' && *p !='/' && !CTYPE (isspace,*p)) +while (*p !='\0' && *p !='/' && !qemu_isspace (*p)) p++; len = p - pstart;if (len >sizeof (cmdname) -1 )
@@ -2248,7 +2248,7 @@ static void monitor_handle_command(const char *cmdline)int ret;char *str; -while (CTYPE (isspace,*p)) +while (qemu_isspace (*p)) p++;if (*typestr =='?' ) { typestr++;
@@ -2289,15 +2289,15 @@ static void monitor_handle_command(const char *cmdline) {int count, format, size; -while (CTYPE (isspace,*p)) +while (qemu_isspace (*p)) p++;if (*p =='/' ) {/* format found */ p++; count =1 ; -if (isdigit (*p)) { +if (qemu_isdigit (*p)) { count =0 ; -while (isdigit (*p)) { +while (qemu_isdigit (*p)) { count = count *10 + (*p -'0' ); p++; }
@@ -2336,7 +2336,7 @@ static void monitor_handle_command(const char *cmdline) } } next: -if (*p !='\0' && !CTYPE (isspace,*p)) { +if (*p !='\0' && !qemu_isspace (*p)) {term_printf ("invalid char in format: '%c'\n" , *p); goto fail; }
@@ -2370,7 +2370,7 @@ static void monitor_handle_command(const char *cmdline) {int64_t val; -while (CTYPE (isspace,*p)) +while (qemu_isspace (*p)) p++;if (*typestr =='?' || *typestr =='.' ) {if (*typestr =='?' ) {
@@ -2381,7 +2381,7 @@ static void monitor_handle_command(const char *cmdline) }else {if (*p =='.' ) { p++; -while (CTYPE (isspace,*p)) +while (qemu_isspace (*p)) p++; has_arg =1 ; }else {
@@ -2426,7 +2426,7 @@ static void monitor_handle_command(const char *cmdline) c = *typestr++;if (c =='\0' ) goto bad_type; -while (CTYPE (isspace,*p)) +while (qemu_isspace (*p)) p++; has_option =0 ;if (*p =='-' ) {
@@ -2451,7 +2451,7 @@ static void monitor_handle_command(const char *cmdline) } }/* check that all arguments were parsed */ -while (CTYPE (isspace,*p)) +while (qemu_isspace (*p)) p++;if (*p !='\0' ) { term_printf("%s: extraneous characters at the end of line\n",
@@ -2599,7 +2599,7 @@ static void parse_cmdline(const char *cmdline, p = cmdline; nb_args =0 ;for (;;) { -while (CTYPE (isspace,*p)) +while (qemu_isspace (*p)) p++;if (*p =='\0' )break ;
@@ -2633,7 +2633,7 @@ void readline_find_completion(const char *cmdline)/* if the line ends with a space, it means we want to complete the next arg */ len =strlen (cmdline); -if (len >0 &&CTYPE (isspace,cmdline[len -1 ])) { +if (len >0 &&qemu_isspace (cmdline[len -1 ])) {if (nb_args >=MAX_ARGS )return ; args[nb_args++] =qemu_strdup ("" );
qemu-common.h +15 -10
@@ -86,16 +86,21 @@ int strstart(const char *str, const char *val, const char **ptr);int stristart (const char *str,const char *val,const char **ptr);time_t mktimegm (struct tm *tm); -#define CTYPE (isfoobar,argumentchar) (isfoobar((unsigned char)(argumentchar))) -/* One must not pass a plain `char' to isupper, toupper, et al. If -* it has the top bit set (ie, is negative if your chars are -* signed), undefined behaviour results. The <ctype.h> functions -* are defined to take the value of an unsigned char, as an int. -* So use this macro. You may pass toupper et al for isfoobar. -* Do not pass EOF as a character to this macro. If you might have -* EOF then you ought to have it in an int representing an unsigned -* char, which is safe for the ctype macros directly. Or test separately. -* Obviously don't use this for floating point things like isnan! */ +#define qemu_isalnum (c) isalnum((unsigned char)(c)) +#define qemu_isalpha (c) isalpha((unsigned char)(c)) +#define qemu_iscntrl (c) iscntrl((unsigned char)(c)) +#define qemu_isdigit (c) isdigit((unsigned char)(c)) +#define qemu_isgraph (c) isgraph((unsigned char)(c)) +#define qemu_islower (c) islower((unsigned char)(c)) +#define qemu_isprint (c) isprint((unsigned char)(c)) +#define qemu_ispunct (c) ispunct((unsigned char)(c)) +#define qemu_isspace (c) isspace((unsigned char)(c)) +#define qemu_isupper (c) isupper((unsigned char)(c)) +#define qemu_isxdigit (c) isxdigit((unsigned char)(c)) +#define qemu_tolower (c) tolower((unsigned char)(c)) +#define qemu_toupper (c) toupper((unsigned char)(c)) +#define qemu_isascii (c) isascii((unsigned char)(c)) +#define qemu_toascii (c) toascii((unsigned char)(c))void *qemu_malloc (size_t size);void *qemu_realloc (void *ptr,size_t size);
readline.c +2 -2
@@ -169,7 +169,7 @@ static void term_backword(void)/* find first word (backwards) */ while (start >0 ) { -if (!CTYPE (isspace,term_cmd_buf[start])) { +if (!qemu_isspace (term_cmd_buf[start])) {break ; }
@@ -178,7 +178,7 @@ static void term_backword(void)/* find first space (backwards) */ while (start >0 ) { -if (CTYPE (isspace,term_cmd_buf[start])) { +if (qemu_isspace (term_cmd_buf[start])) { ++start;break ; }
target-ppc/translate_init.c +1 -1
@@ -9459,7 +9459,7 @@ const ppc_def_t *cpu_ppc_find_by_name (const char *name) p = name; check_pvr:for (i =0 ; i <8 ; i++) { -if (!CTYPE (isxdigit,*p++)) +if (!qemu_isxdigit (*p++))break ; }if (i ==8 )
usb-linux.c +1 -1
@@ -1048,7 +1048,7 @@ static int get_tag_value(char *buf, int buf_size,if (!p)return -1 ; p +=strlen (tag); -while (CTYPE (isspace,*p)) +while (qemu_isspace (*p)) p++; q = buf;while (*p !='\0' && !strchr (stopchars, *p)) {
vl.c +17 -9
@@ -57,26 +57,31 @@#include <termios.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 +#ifdef __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__) +#ifdef __FreeBSD__#include <libutil.h> -#endif -#ifdef __OpenBSD__ -#include <net/if.h> +#else +#include <util.h> #endif #elif defined (__GLIBC__) && defined (__FreeBSD_kernel__)#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>
@@ -4035,7 +4040,7 @@ int parse_host_port(struct sockaddr_in *saddr, const char *str)if (buf[0 ] =='\0' ) { saddr->sin_addr.s_addr =0 ; }else { -if (CTYPE (isdigit,buf[0 ])) { +if (qemu_isdigit (buf[0 ])) {if (!inet_aton (buf, &saddr->sin_addr))return -1 ; }else {
@@ -4415,10 +4420,13 @@ static int tap_open(char *ifname, int ifname_size)#ifndef TAPGIFNAME char *dev;struct stat s; +#else +struct ifreq ifr;#endif TFR (fd =open ("/dev/tap" ,O_RDWR ));if (fd <0 ) { +fprintf (stderr,"warning: could not open /dev/tap: no virtual network emulation %s\n" ,strerror (errno));return -1 ; }
@@ -4461,7 +4469,7 @@ int tap_alloc(char *dev, size_t dev_size)if ( *dev ){ ptr = dev; -while ( *ptr && !CTYPE (isdigit,(int )*ptr) ) ptr++; +while ( *ptr && !qemu_isdigit ((int )*ptr) ) ptr++; ppa =atoi (ptr); }
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Christoph Egger writes ("[Xen-devel] [PATCH][IOEMU] Build fixes for BSD"):
Quoted 2 lines
Attached patch fixes ioemu build for NetBSD.
All changes (apart fromhw/battery_mgmt.h) are from qemu upstream.
Thanks. I'll apply the battery_mgmt.h fix in my tree. The rest I'll leave, if it's OK with you, until I merge from upstream again. That'll save on conflicts in my merges.
If you need me to cherry pick it let me know.
Ian.