Add support for GNU/kFreeBSD

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
This commit is contained in:
Aurelien Jarno 2009-11-29 18:00:41 +01:00
parent 3098b9fde9
commit a167ba5085
11 changed files with 39 additions and 42 deletions

View File

@ -51,7 +51,7 @@
#include <linux/cdrom.h> #include <linux/cdrom.h>
#include <linux/fd.h> #include <linux/fd.h>
#endif #endif
#ifdef __FreeBSD__ #if defined (__FreeBSD__) || defined(__FreeBSD_kernel__)
#include <signal.h> #include <signal.h>
#include <sys/disk.h> #include <sys/disk.h>
#include <sys/cdio.h> #include <sys/cdio.h>
@ -124,7 +124,7 @@ typedef struct BDRVRawState {
static int fd_open(BlockDriverState *bs); static int fd_open(BlockDriverState *bs);
static int64_t raw_getlength(BlockDriverState *bs); static int64_t raw_getlength(BlockDriverState *bs);
#if defined(__FreeBSD__) #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
static int cdrom_reopen(BlockDriverState *bs); static int cdrom_reopen(BlockDriverState *bs);
#endif #endif
@ -636,7 +636,7 @@ static int64_t raw_getlength(BlockDriverState *bs)
int64_t size; int64_t size;
#ifdef CONFIG_BSD #ifdef CONFIG_BSD
struct stat sb; struct stat sb;
#ifdef __FreeBSD__ #if defined (__FreeBSD__) || defined(__FreeBSD_kernel__)
int reopened = 0; int reopened = 0;
#endif #endif
#endif #endif
@ -651,7 +651,7 @@ static int64_t raw_getlength(BlockDriverState *bs)
return ret; return ret;
#ifdef CONFIG_BSD #ifdef CONFIG_BSD
#ifdef __FreeBSD__ #if defined (__FreeBSD__) || defined(__FreeBSD_kernel__)
again: again:
#endif #endif
if (!fstat(fd, &sb) && (S_IFCHR & sb.st_mode)) { if (!fstat(fd, &sb) && (S_IFCHR & sb.st_mode)) {
@ -672,7 +672,7 @@ again:
#else #else
size = lseek(fd, 0LL, SEEK_END); size = lseek(fd, 0LL, SEEK_END);
#endif #endif
#ifdef __FreeBSD__ #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
switch(s->type) { switch(s->type) {
case FTYPE_CD: case FTYPE_CD:
/* XXX FreeBSD acd returns UINT_MAX sectors for an empty drive */ /* XXX FreeBSD acd returns UINT_MAX sectors for an empty drive */
@ -957,7 +957,7 @@ static BlockDriverAIOCB *hdev_aio_ioctl(BlockDriverState *bs,
return paio_ioctl(bs, s->fd, req, buf, cb, opaque); return paio_ioctl(bs, s->fd, req, buf, cb, opaque);
} }
#elif defined(__FreeBSD__) #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
static int fd_open(BlockDriverState *bs) static int fd_open(BlockDriverState *bs)
{ {
BDRVRawState *s = bs->opaque; BDRVRawState *s = bs->opaque;
@ -1213,7 +1213,7 @@ static BlockDriver bdrv_host_cdrom = {
}; };
#endif /* __linux__ */ #endif /* __linux__ */
#ifdef __FreeBSD__ #if defined (__FreeBSD__) || defined(__FreeBSD_kernel__)
static int cdrom_open(BlockDriverState *bs, const char *filename, int flags) static int cdrom_open(BlockDriverState *bs, const char *filename, int flags)
{ {
BDRVRawState *s = bs->opaque; BDRVRawState *s = bs->opaque;
@ -1342,7 +1342,7 @@ static void bdrv_raw_init(void)
bdrv_register(&bdrv_host_floppy); bdrv_register(&bdrv_host_floppy);
bdrv_register(&bdrv_host_cdrom); bdrv_register(&bdrv_host_cdrom);
#endif #endif
#ifdef __FreeBSD__ #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
bdrv_register(&bdrv_host_cdrom); bdrv_register(&bdrv_host_cdrom);
#endif #endif
} }

6
configure vendored
View File

@ -255,27 +255,32 @@ MINGW32*)
audio_drv_list="winwave" audio_drv_list="winwave"
;; ;;
GNU/kFreeBSD) GNU/kFreeBSD)
bsd="yes"
audio_drv_list="oss" audio_drv_list="oss"
audio_possible_drivers="oss sdl esd pa" audio_possible_drivers="oss sdl esd pa"
;; ;;
FreeBSD) FreeBSD)
bsd="yes" bsd="yes"
make="gmake"
audio_drv_list="oss" audio_drv_list="oss"
audio_possible_drivers="oss sdl esd pa" audio_possible_drivers="oss sdl esd pa"
;; ;;
DragonFly) DragonFly)
bsd="yes" bsd="yes"
make="gmake"
audio_drv_list="oss" audio_drv_list="oss"
audio_possible_drivers="oss sdl esd pa" audio_possible_drivers="oss sdl esd pa"
;; ;;
NetBSD) NetBSD)
bsd="yes" bsd="yes"
make="gmake"
audio_drv_list="oss" audio_drv_list="oss"
audio_possible_drivers="oss sdl esd" audio_possible_drivers="oss sdl esd"
oss_lib="-lossaudio" oss_lib="-lossaudio"
;; ;;
OpenBSD) OpenBSD)
bsd="yes" bsd="yes"
make="gmake"
audio_drv_list="oss" audio_drv_list="oss"
audio_possible_drivers="oss sdl esd" audio_possible_drivers="oss sdl esd"
oss_lib="-lossaudio" oss_lib="-lossaudio"
@ -360,7 +365,6 @@ esac
if [ "$bsd" = "yes" ] ; then if [ "$bsd" = "yes" ] ; then
if [ "$darwin" != "yes" ] ; then if [ "$darwin" != "yes" ] ; then
make="gmake"
usb="bsd" usb="bsd"
fi fi
bsd_user="yes" bsd_user="yes"

2
exec.c
View File

@ -463,7 +463,7 @@ static void code_gen_alloc(unsigned long tb_size)
exit(1); exit(1);
} }
} }
#elif defined(__FreeBSD__) || defined(__DragonFly__) #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
{ {
int flags; int flags;
void *addr = NULL; void *addr = NULL;

View File

@ -9,7 +9,7 @@
void set_float_rounding_mode(int val STATUS_PARAM) void set_float_rounding_mode(int val STATUS_PARAM)
{ {
STATUS(float_rounding_mode) = val; STATUS(float_rounding_mode) = val;
#if defined(CONFIG_BSD) && !defined(__APPLE__) || \ #if (defined(CONFIG_BSD) && !defined(__APPLE__) && !defined(__GLIBC__)) || \
(defined(CONFIG_SOLARIS) && CONFIG_SOLARIS_VERSION < 10) (defined(CONFIG_SOLARIS) && CONFIG_SOLARIS_VERSION < 10)
fpsetround(val); fpsetround(val);
#elif defined(__arm__) #elif defined(__arm__)

View File

@ -1,7 +1,8 @@
/* Native implementation of soft float functions */ /* Native implementation of soft float functions */
#include <math.h> #include <math.h>
#if (defined(CONFIG_BSD) && !defined(__APPLE__)) || defined(CONFIG_SOLARIS) #if (defined(CONFIG_BSD) && !defined(__APPLE__) && !defined(__GLIBC__)) \
|| defined(CONFIG_SOLARIS)
#include <ieeefp.h> #include <ieeefp.h>
#define fabsf(f) ((float)fabs(f)) #define fabsf(f) ((float)fabs(f))
#else #else
@ -112,7 +113,8 @@ typedef union {
/*---------------------------------------------------------------------------- /*----------------------------------------------------------------------------
| Software IEC/IEEE floating-point rounding mode. | Software IEC/IEEE floating-point rounding mode.
*----------------------------------------------------------------------------*/ *----------------------------------------------------------------------------*/
#if (defined(CONFIG_BSD) && !defined(__APPLE__)) || defined(CONFIG_SOLARIS) #if (defined(CONFIG_BSD) && !defined(__APPLE__) && !defined(__GLIBC__)) \
|| defined(CONFIG_SOLARIS)
#if defined(__OpenBSD__) #if defined(__OpenBSD__)
#define FE_RM FP_RM #define FE_RM FP_RM
#define FE_RP FP_RP #define FE_RP FP_RP

5
net.c
View File

@ -48,14 +48,11 @@
#include <sys/select.h> #include <sys/select.h>
#ifdef CONFIG_BSD #ifdef CONFIG_BSD
#include <sys/stat.h> #include <sys/stat.h>
#if defined(__FreeBSD__) || defined(__DragonFly__) #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
#include <libutil.h> #include <libutil.h>
#else #else
#include <util.h> #include <util.h>
#endif #endif
#elif defined (__GLIBC__) && defined (__FreeBSD_kernel__)
#include <freebsd/stdlib.h>
#else
#ifdef __linux__ #ifdef __linux__
#include <pty.h> #include <pty.h>
#include <malloc.h> #include <malloc.h>

View File

@ -30,14 +30,11 @@
#include <net/if_tap.h> #include <net/if_tap.h>
#endif #endif
#if defined(__FreeBSD__) || defined(__DragonFly__) #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
#include <libutil.h> #include <libutil.h>
#else #else
#include <util.h> #include <util.h>
#endif #endif
#if defined (__GLIBC__) && defined (__FreeBSD_kernel__)
#include <freebsd/stdlib.h>
#endif
#if defined(__OpenBSD__) #if defined(__OpenBSD__)
#include <util.h> #include <util.h>
@ -49,7 +46,7 @@ int tap_open(char *ifname, int ifname_size, int *vnet_hdr, int vnet_hdr_required
char *dev; char *dev;
struct stat s; struct stat s;
#ifdef __FreeBSD__ #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
/* if no ifname is given, always start the search from tap0. */ /* if no ifname is given, always start the search from tap0. */
int i; int i;
char dname[100]; char dname[100];

View File

@ -57,10 +57,13 @@
#include <sys/select.h> #include <sys/select.h>
#ifdef CONFIG_BSD #ifdef CONFIG_BSD
#include <sys/stat.h> #include <sys/stat.h>
#ifdef __FreeBSD__ #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#include <libutil.h> #include <libutil.h>
#include <dev/ppbus/ppi.h> #include <dev/ppbus/ppi.h>
#include <dev/ppbus/ppbconf.h> #include <dev/ppbus/ppbconf.h>
#if defined(__GLIBC__)
#include <pty.h>
#endif
#elif defined(__DragonFly__) #elif defined(__DragonFly__)
#include <libutil.h> #include <libutil.h>
#include <dev/misc/ppi/ppi.h> #include <dev/misc/ppi/ppi.h>
@ -68,9 +71,6 @@
#else #else
#include <util.h> #include <util.h>
#endif #endif
#elif defined (__GLIBC__) && defined (__FreeBSD_kernel__)
#include <freebsd/stdlib.h>
#else
#ifdef __linux__ #ifdef __linux__
#include <pty.h> #include <pty.h>
@ -820,7 +820,8 @@ static void cfmakeraw (struct termios *termios_p)
#endif #endif
#if defined(__linux__) || defined(__sun__) || defined(__FreeBSD__) \ #if defined(__linux__) || defined(__sun__) || defined(__FreeBSD__) \
|| defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) \
|| defined(__GLIBC__)
typedef struct { typedef struct {
int fd; int fd;
@ -1336,7 +1337,7 @@ static CharDriverState *qemu_chr_open_pp(QemuOpts *opts)
} }
#endif /* __linux__ */ #endif /* __linux__ */
#if defined(__FreeBSD__) || defined(__DragonFly__) #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
static int pp_ioctl(CharDriverState *chr, int cmd, void *arg) static int pp_ioctl(CharDriverState *chr, int cmd, void *arg)
{ {
int fd = (int)chr->opaque; int fd = (int)chr->opaque;
@ -2380,10 +2381,12 @@ static const struct {
{ .name = "braille", .open = chr_baum_init }, { .name = "braille", .open = chr_baum_init },
#endif #endif
#if defined(__linux__) || defined(__sun__) || defined(__FreeBSD__) \ #if defined(__linux__) || defined(__sun__) || defined(__FreeBSD__) \
|| defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) \
|| defined(__FreeBSD_kernel__)
{ .name = "tty", .open = qemu_chr_open_tty }, { .name = "tty", .open = qemu_chr_open_tty },
#endif #endif
#if defined(__linux__) || defined(__FreeBSD__) || defined(__DragonFly__) #if defined(__linux__) || defined(__FreeBSD__) || defined(__DragonFly__) \
|| defined(__FreeBSD_kernel__)
{ .name = "parport", .open = qemu_chr_open_pp }, { .name = "parport", .open = qemu_chr_open_pp },
#endif #endif
}; };

View File

@ -48,14 +48,11 @@
#include <sys/select.h> #include <sys/select.h>
#ifdef CONFIG_BSD #ifdef CONFIG_BSD
#include <sys/stat.h> #include <sys/stat.h>
#if defined(__FreeBSD__) || defined(__DragonFly__) #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
#include <libutil.h> #include <libutil.h>
#else #else
#include <util.h> #include <util.h>
#endif #endif
#elif defined (__GLIBC__) && defined (__FreeBSD_kernel__)
#include <freebsd/stdlib.h>
#else
#ifdef __linux__ #ifdef __linux__
#include <pty.h> #include <pty.h>
#include <malloc.h> #include <malloc.h>

View File

@ -335,7 +335,7 @@ USBDevice *usb_host_device_open(const char *devname)
return NULL; return NULL;
} }
#if defined(__FreeBSD__) || defined(__DragonFly__) #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
snprintf(ctlpath, PATH_MAX, "/dev/%s", bus_info.udi_devnames[0]); snprintf(ctlpath, PATH_MAX, "/dev/%s", bus_info.udi_devnames[0]);
#else #else
snprintf(ctlpath, PATH_MAX, "/dev/%s.00", bus_info.udi_devnames[0]); snprintf(ctlpath, PATH_MAX, "/dev/%s.00", bus_info.udi_devnames[0]);
@ -437,7 +437,7 @@ static int usb_host_scan(void *opaque, USBScanFunc *func)
if (strncmp(bus_info.udi_devnames[0], "ugen", 4) != 0) if (strncmp(bus_info.udi_devnames[0], "ugen", 4) != 0)
continue; continue;
#if defined(__FreeBSD__) || defined(__DragonFly__) #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
snprintf(devbuf, sizeof(devbuf) - 1, "/dev/%s", bus_info.udi_devnames[0]); snprintf(devbuf, sizeof(devbuf) - 1, "/dev/%s", bus_info.udi_devnames[0]);
#else #else
snprintf(devbuf, sizeof(devbuf) - 1, "/dev/%s.00", bus_info.udi_devnames[0]); snprintf(devbuf, sizeof(devbuf) - 1, "/dev/%s.00", bus_info.udi_devnames[0]);

9
vl.c
View File

@ -50,14 +50,11 @@
#include <sys/select.h> #include <sys/select.h>
#ifdef CONFIG_BSD #ifdef CONFIG_BSD
#include <sys/stat.h> #include <sys/stat.h>
#if defined(__FreeBSD__) || defined(__DragonFly__) #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
#include <libutil.h> #include <libutil.h>
#else #else
#include <util.h> #include <util.h>
#endif #endif
#elif defined (__GLIBC__) && defined (__FreeBSD_kernel__)
#include <freebsd/stdlib.h>
#else
#ifdef __linux__ #ifdef __linux__
#include <pty.h> #include <pty.h>
#include <malloc.h> #include <malloc.h>
@ -569,7 +566,7 @@ static void init_get_clock(void)
{ {
use_rt_clock = 0; use_rt_clock = 0;
#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >= 500000) \ #if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >= 500000) \
|| defined(__DragonFly__) || defined(__DragonFly__) || defined(__FreeBSD_kernel__)
{ {
struct timespec ts; struct timespec ts;
if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) { if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) {
@ -582,7 +579,7 @@ static void init_get_clock(void)
static int64_t get_clock(void) static int64_t get_clock(void)
{ {
#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >= 500000) \ #if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >= 500000) \
|| defined(__DragonFly__) || defined(__DragonFly__) || defined(__FreeBSD_kernel__)
if (use_rt_clock) { if (use_rt_clock) {
struct timespec ts; struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts); clock_gettime(CLOCK_MONOTONIC, &ts);