From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KU47M-0000DZ-UI for qemu-devel@nongnu.org; Fri, 15 Aug 2008 14:33:44 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KU47M-0000DJ-IT for qemu-devel@nongnu.org; Fri, 15 Aug 2008 14:33:44 -0400 Received: from [199.232.76.173] (port=43593 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KU47M-0000DB-6p for qemu-devel@nongnu.org; Fri, 15 Aug 2008 14:33:44 -0400 Received: from savannah.gnu.org ([199.232.41.3]:58904 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1KU47L-0008LZ-LP for qemu-devel@nongnu.org; Fri, 15 Aug 2008 14:33:43 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1KU47K-0008FN-W3 for qemu-devel@nongnu.org; Fri, 15 Aug 2008 18:33:43 +0000 Received: from blueswir1 by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1KU47K-0008FJ-Ir for qemu-devel@nongnu.org; Fri, 15 Aug 2008 18:33:42 +0000 MIME-Version: 1.0 Errors-To: blueswir1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Blue Swirl Message-Id: Date: Fri, 15 Aug 2008 18:33:42 +0000 Subject: [Qemu-devel] [5012] Preliminary OpenBSD host support (based on OpenBSD patches by Todd T . Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 5012 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5012 Author: blueswir1 Date: 2008-08-15 18:33:42 +0000 (Fri, 15 Aug 2008) Log Message: ----------- Preliminary OpenBSD host support (based on OpenBSD patches by Todd T. Fries) Modified Paths: -------------- trunk/block-raw-posix.c trunk/configure trunk/curses.c trunk/dyngen-exec.h trunk/fpu/softfloat-native.h trunk/osdep.c trunk/osdep.h trunk/vl.c Modified: trunk/block-raw-posix.c =================================================================== --- trunk/block-raw-posix.c 2008-08-15 18:21:58 UTC (rev 5011) +++ trunk/block-raw-posix.c 2008-08-15 18:33:42 UTC (rev 5012) @@ -58,6 +58,12 @@ #include #endif +#ifdef __OpenBSD__ +#include +#include +#include +#endif + //#define DEBUG_FLOPPY //#define DEBUG_BLOCK @@ -745,6 +751,26 @@ return 0; } +#ifdef __OpenBSD__ +static int64_t raw_getlength(BlockDriverState *bs) +{ + BDRVRawState *s = bs->opaque; + int fd = s->fd; + struct stat st; + + if (fstat(fd, &st)) + return -1; + if (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode)) { + struct disklabel dl; + + if (ioctl(fd, DIOCGDINFO, &dl)) + return -1; + return (uint64_t)dl.d_secsize * + dl.d_partitions[DISKPART(st.st_rdev)].p_size; + } else + return st.st_size; +} +#else /* !__OpenBSD__ */ static int64_t raw_getlength(BlockDriverState *bs) { BDRVRawState *s = bs->opaque; @@ -791,6 +817,7 @@ } return size; } +#endif static int raw_create(const char *filename, int64_t total_size, const char *backing_file, int flags) Modified: trunk/configure =================================================================== --- trunk/configure 2008-08-15 18:21:58 UTC (rev 5011) +++ trunk/configure 2008-08-15 18:33:42 UTC (rev 5012) @@ -150,6 +150,7 @@ ;; OpenBSD) bsd="yes" +openbsd="yes" audio_drv_list="oss" audio_possible_drivers="oss sdl esd" ;; @@ -1086,6 +1087,11 @@ echo "#define HAVE_BYTESWAP_H 1" >> $config_h fi fi + +if [ "$openbsd" = "yes" ] ; then + echo "#define ENOTSUP 4096" >> $config_h +fi + if test "$darwin" = "yes" ; then echo "CONFIG_DARWIN=yes" >> $config_mak echo "#define CONFIG_DARWIN 1" >> $config_h Modified: trunk/curses.c =================================================================== --- trunk/curses.c 2008-08-15 18:21:58 UTC (rev 5011) +++ trunk/curses.c 2008-08-15 18:33:42 UTC (rev 5012) @@ -34,6 +34,10 @@ #include #endif +#ifdef __OpenBSD__ +#define resize_term resizeterm +#endif + #define FONT_HEIGHT 16 #define FONT_WIDTH 8 Modified: trunk/dyngen-exec.h =================================================================== --- trunk/dyngen-exec.h 2008-08-15 18:21:58 UTC (rev 5011) +++ trunk/dyngen-exec.h 2008-08-15 18:33:42 UTC (rev 5012) @@ -32,6 +32,9 @@ host headers do not allow that. */ #include +#ifdef __OpenBSD__ +#include +#else typedef unsigned char uint8_t; typedef unsigned short uint16_t; typedef unsigned int uint32_t; @@ -61,6 +64,7 @@ typedef signed long long int64_t; #endif #endif +#endif /* XXX: This may be wrong for 64-bit ILP32 hosts. */ typedef void * host_reg_t; Modified: trunk/fpu/softfloat-native.h =================================================================== --- trunk/fpu/softfloat-native.h 2008-08-15 18:21:58 UTC (rev 5011) +++ trunk/fpu/softfloat-native.h 2008-08-15 18:33:42 UTC (rev 5012) @@ -15,7 +15,9 @@ * Solaris 10 with GCC4 does not need these macros as they * are defined in with a compiler directive */ -#if defined(HOST_SOLARIS) && (( HOST_SOLARIS <= 9 ) || ((HOST_SOLARIS >= 10) && (__GNUC__ <= 4))) +#if defined(HOST_SOLARIS) && (( HOST_SOLARIS <= 9 ) || ((HOST_SOLARIS >= 10) \ + && (__GNUC__ <= 4))) \ + || defined(__OpenBSD__) /* * C99 7.12.3 classification macros * and @@ -24,6 +26,9 @@ * ... do not work on Solaris 10 using GNU CC 3.4.x. * Try to workaround the missing / broken C99 math macros. */ +#if defined(__OpenBSD__) +#define unordered(x, y) (isnan(x) || isnan(y)) +#endif #define isnormal(x) (fpclass(x) >= FP_NZERO) #define isgreater(x, y) ((!unordered(x, y)) && ((x) > (y))) @@ -84,6 +89,11 @@ | Software IEC/IEEE floating-point rounding mode. *----------------------------------------------------------------------------*/ #if (defined(_BSD) && !defined(__APPLE__)) || defined(HOST_SOLARIS) +#if defined(__OpenBSD__) +#define FE_RM FP_RM +#define FE_RP FP_RP +#define FE_RZ FP_RZ +#endif enum { float_round_nearest_even = FP_RN, float_round_down = FP_RM, Modified: trunk/osdep.c =================================================================== --- trunk/osdep.c 2008-08-15 18:21:58 UTC (rev 5011) +++ trunk/osdep.c 2008-08-15 18:33:42 UTC (rev 5012) @@ -68,7 +68,14 @@ #if defined(USE_KQEMU) +#ifdef __OpenBSD__ +#include +#include +#include +#else #include +#endif + #include #include @@ -76,9 +83,14 @@ { static int phys_ram_fd = -1; static int phys_ram_size = 0; + void *ptr; + +#ifdef __OpenBSD__ /* no need (?) for a dummy file on OpenBSD */ + int map_anon = MAP_ANON; +#else + int map_anon = 0; const char *tmpdir; char phys_ram_file[1024]; - void *ptr; #ifdef HOST_SOLARIS struct statvfs stfs; #else @@ -140,9 +152,10 @@ } size = (size + 4095) & ~4095; ftruncate(phys_ram_fd, phys_ram_size + size); +#endif /* !__OpenBSD__ */ ptr = mmap(NULL, size, - PROT_WRITE | PROT_READ, MAP_SHARED, + PROT_WRITE | PROT_READ, map_anon | MAP_SHARED, phys_ram_fd, phys_ram_size); if (ptr == MAP_FAILED) { fprintf(stderr, "Could not map physical memory\n"); Modified: trunk/osdep.h =================================================================== --- trunk/osdep.h 2008-08-15 18:21:58 UTC (rev 5011) +++ trunk/osdep.h 2008-08-15 18:33:42 UTC (rev 5012) @@ -2,6 +2,10 @@ #define QEMU_OSDEP_H #include +#ifdef __OpenBSD__ +#include +#include +#endif #ifndef glue #define xglue(x, y) x ## y Modified: trunk/vl.c =================================================================== --- trunk/vl.c 2008-08-15 18:21:58 UTC (rev 5011) +++ trunk/vl.c 2008-08-15 18:33:42 UTC (rev 5012) @@ -61,9 +61,12 @@ #include #ifdef _BSD #include -#ifndef __APPLE__ +#if !defined(__APPLE__) && !defined(__OpenBSD__) #include #endif +#ifdef __OpenBSD__ +#include +#endif #elif defined (__GLIBC__) && defined (__FreeBSD_kernel__) #include #else