Commit 7d3505c55aae54c9610e8be1ff476ec8849c98e6
1 parent
fd872598
bsd port (Markus Niemisto)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@800 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
9 changed files
with
111 additions
and
16 deletions
Makefile
... | ... | @@ -16,7 +16,7 @@ endif |
16 | 16 | |
17 | 17 | all: dyngen$(EXESUF) $(TOOLS) qemu-doc.html qemu-tech.html qemu.1 |
18 | 18 | for d in $(TARGET_DIRS); do \ |
19 | - make -C $$d $@ || exit 1 ; \ | |
19 | + $(MAKE) -C $$d $@ || exit 1 ; \ | |
20 | 20 | done |
21 | 21 | |
22 | 22 | qemu-mkcow: qemu-mkcow.c |
... | ... | @@ -29,9 +29,9 @@ clean: |
29 | 29 | # avoid old build problems by removing potentially incorrect old files |
30 | 30 | rm -f config.mak config.h op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h gen-op-arm.h |
31 | 31 | rm -f *.o *.a $(TOOLS) dyngen$(EXESUF) TAGS qemu.pod |
32 | - make -C tests clean | |
32 | + $(MAKE) -C tests clean | |
33 | 33 | for d in $(TARGET_DIRS); do \ |
34 | - make -C $$d $@ || exit 1 ; \ | |
34 | + $(MAKE) -C $$d $@ || exit 1 ; \ | |
35 | 35 | done |
36 | 36 | |
37 | 37 | distclean: clean |
... | ... | @@ -55,12 +55,12 @@ ifndef CONFIG_WIN32 |
55 | 55 | install qemu.1 qemu-mkcow.1 "$(mandir)/man1" |
56 | 56 | endif |
57 | 57 | for d in $(TARGET_DIRS); do \ |
58 | - make -C $$d $@ || exit 1 ; \ | |
58 | + $(MAKE) -C $$d $@ || exit 1 ; \ | |
59 | 59 | done |
60 | 60 | |
61 | 61 | # various test targets |
62 | 62 | test speed test2: all |
63 | - make -C tests $@ | |
63 | + $(MAKE) -C tests $@ | |
64 | 64 | |
65 | 65 | TAGS: |
66 | 66 | etags *.[ch] tests/*.[ch] | ... | ... |
configure
... | ... | @@ -79,9 +79,23 @@ case $targetos in |
79 | 79 | MINGW32*) |
80 | 80 | mingw32="yes" |
81 | 81 | ;; |
82 | +FreeBSD) | |
83 | +bsd="yes" | |
84 | +;; | |
85 | +NetBSD) | |
86 | +bsd="yes" | |
87 | +;; | |
88 | +OpenBSD) | |
89 | +bsd="yes" | |
90 | +;; | |
82 | 91 | *) ;; |
83 | 92 | esac |
84 | 93 | |
94 | +if [ "$bsd" = "yes" ] ; then | |
95 | + make="gmake" | |
96 | + target_list="i386-softmmu" | |
97 | +fi | |
98 | + | |
85 | 99 | # find source path |
86 | 100 | # XXX: we assume an absolute path is given when launching configure, |
87 | 101 | # except in './configure' case. |
... | ... | @@ -373,7 +387,7 @@ fi |
373 | 387 | if test "$mingw32" = "yes" ; then |
374 | 388 | echo "CONFIG_WIN32=yes" >> $config_mak |
375 | 389 | echo "#define CONFIG_WIN32 1" >> $config_h |
376 | -else | |
390 | +elif test -f "/usr/include/byteswap.h" ; then | |
377 | 391 | echo "#define HAVE_BYTESWAP_H 1" >> $config_h |
378 | 392 | fi |
379 | 393 | if test "$gdbstub" = "yes" ; then |
... | ... | @@ -402,6 +416,10 @@ echo "\"" >> $config_h |
402 | 416 | echo "SRC_PATH=$source_path" >> $config_mak |
403 | 417 | echo "TARGET_DIRS=$target_list" >> $config_mak |
404 | 418 | |
419 | +if [ "$bsd" = "yes" ] ; then | |
420 | + echo "#define _BSD 1" >> $config_h | |
421 | +fi | |
422 | + | |
405 | 423 | for target in $target_list; do |
406 | 424 | |
407 | 425 | target_dir="$target" | ... | ... |
dyngen-exec.h
... | ... | @@ -59,7 +59,11 @@ extern int fprintf(FILE *, const char *, ...); |
59 | 59 | extern int printf(const char *, ...); |
60 | 60 | #undef NULL |
61 | 61 | #define NULL 0 |
62 | +#ifdef _BSD | |
63 | +#include <ieeefp.h> | |
64 | +#else | |
62 | 65 | #include <fenv.h> |
66 | +#endif | |
63 | 67 | |
64 | 68 | #ifdef __i386__ |
65 | 69 | #define AREG0 "ebp" | ... | ... |
gdbstub.c
... | ... | @@ -532,7 +532,7 @@ static void gdb_accept(void *opaque, const uint8_t *buf, int size) |
532 | 532 | |
533 | 533 | /* set short latency */ |
534 | 534 | val = 1; |
535 | - setsockopt(fd, SOL_TCP, TCP_NODELAY, &val, sizeof(val)); | |
535 | + setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val)); | |
536 | 536 | |
537 | 537 | s = qemu_mallocz(sizeof(GDBState)); |
538 | 538 | if (!s) { | ... | ... |
target-i386/cpu.h
target-i386/exec.h
... | ... | @@ -17,6 +17,7 @@ |
17 | 17 | * License along with this library; if not, write to the Free Software |
18 | 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 | 19 | */ |
20 | +#include "config.h" | |
20 | 21 | #include "dyngen-exec.h" |
21 | 22 | |
22 | 23 | /* at least 4 register variables are defines */ |
... | ... | @@ -307,8 +308,13 @@ static inline void stfl(void *ptr, float v) |
307 | 308 | #define rint rintl |
308 | 309 | #endif |
309 | 310 | |
311 | +#if !defined(_BSD) | |
310 | 312 | extern int lrint(CPU86_LDouble x); |
311 | 313 | extern int64_t llrint(CPU86_LDouble x); |
314 | +#else | |
315 | +#define lrint(d) ((int)rint(d)) | |
316 | +#define llrint(d) ((int)rint(d)) | |
317 | +#endif | |
312 | 318 | extern CPU86_LDouble fabs(CPU86_LDouble x); |
313 | 319 | extern CPU86_LDouble sin(CPU86_LDouble x); |
314 | 320 | extern CPU86_LDouble cos(CPU86_LDouble x); | ... | ... |
target-i386/op.c
... | ... | @@ -1938,6 +1938,24 @@ void OPPROTO op_fldcw_A0(void) |
1938 | 1938 | int rnd_type; |
1939 | 1939 | env->fpuc = lduw((void *)A0); |
1940 | 1940 | /* set rounding mode */ |
1941 | +#ifdef _BSD | |
1942 | + switch(env->fpuc & RC_MASK) { | |
1943 | + default: | |
1944 | + case RC_NEAR: | |
1945 | + rnd_type = FP_RN; | |
1946 | + break; | |
1947 | + case RC_DOWN: | |
1948 | + rnd_type = FP_RM; | |
1949 | + break; | |
1950 | + case RC_UP: | |
1951 | + rnd_type = FP_RP; | |
1952 | + break; | |
1953 | + case RC_CHOP: | |
1954 | + rnd_type = FP_RZ; | |
1955 | + break; | |
1956 | + } | |
1957 | + fpsetround(rnd_type); | |
1958 | +#else | |
1941 | 1959 | switch(env->fpuc & RC_MASK) { |
1942 | 1960 | default: |
1943 | 1961 | case RC_NEAR: |
... | ... | @@ -1954,6 +1972,7 @@ void OPPROTO op_fldcw_A0(void) |
1954 | 1972 | break; |
1955 | 1973 | } |
1956 | 1974 | fesetround(rnd_type); |
1975 | +#endif | |
1957 | 1976 | } |
1958 | 1977 | |
1959 | 1978 | void OPPROTO op_fclex(void) | ... | ... |
vl.c
... | ... | @@ -28,29 +28,35 @@ |
28 | 28 | #include <fcntl.h> |
29 | 29 | #include <signal.h> |
30 | 30 | #include <time.h> |
31 | -#include <malloc.h> | |
32 | 31 | #include <errno.h> |
33 | 32 | #include <sys/time.h> |
34 | 33 | |
35 | 34 | #ifndef _WIN32 |
36 | 35 | #include <sys/times.h> |
37 | 36 | #include <sys/wait.h> |
38 | -#include <pty.h> | |
39 | 37 | #include <termios.h> |
40 | 38 | #include <sys/poll.h> |
41 | 39 | #include <sys/mman.h> |
42 | 40 | #include <sys/ioctl.h> |
43 | 41 | #include <sys/socket.h> |
42 | +#ifdef _BSD | |
43 | +#include <sys/stat.h> | |
44 | +#include <libutil.h> | |
45 | +#else | |
44 | 46 | #include <linux/if.h> |
45 | 47 | #include <linux/if_tun.h> |
48 | +#include <pty.h> | |
49 | +#include <malloc.h> | |
46 | 50 | #include <linux/rtc.h> |
47 | 51 | #endif |
52 | +#endif | |
48 | 53 | |
49 | 54 | #if defined(CONFIG_SLIRP) |
50 | 55 | #include "libslirp.h" |
51 | 56 | #endif |
52 | 57 | |
53 | 58 | #ifdef _WIN32 |
59 | +#include <malloc.h> | |
54 | 60 | #include <sys/timeb.h> |
55 | 61 | #include <windows.h> |
56 | 62 | #define getopt_long_only getopt_long |
... | ... | @@ -58,15 +64,17 @@ |
58 | 64 | #endif |
59 | 65 | |
60 | 66 | #ifdef CONFIG_SDL |
67 | +#if defined(__linux__) | |
61 | 68 | /* SDL use the pthreads and they modify sigaction. We don't |
62 | 69 | want that. */ |
63 | -#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) | |
70 | +#if (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)) | |
64 | 71 | extern void __libc_sigaction(); |
65 | 72 | #define sigaction(sig, act, oact) __libc_sigaction(sig, act, oact) |
66 | 73 | #else |
67 | 74 | extern void __sigaction(); |
68 | 75 | #define sigaction(sig, act, oact) __sigaction(sig, act, oact) |
69 | 76 | #endif |
77 | +#endif /* __linux__ */ | |
70 | 78 | #endif /* CONFIG_SDL */ |
71 | 79 | |
72 | 80 | #include "disas.h" |
... | ... | @@ -637,11 +645,17 @@ int64_t qemu_get_clock(QEMUClock *clock) |
637 | 645 | #ifdef _WIN32 |
638 | 646 | return GetTickCount(); |
639 | 647 | #else |
640 | - /* XXX: portability among Linux hosts */ | |
641 | - if (timer_freq == 100) { | |
642 | - return times(NULL) * 10; | |
643 | - } else { | |
644 | - return ((int64_t)times(NULL) * 1000) / timer_freq; | |
648 | + { | |
649 | + struct tms tp; | |
650 | + | |
651 | + /* Note that using gettimeofday() is not a good solution | |
652 | + for timers because its value change when the date is | |
653 | + modified. */ | |
654 | + if (timer_freq == 100) { | |
655 | + return times(&tp) * 10; | |
656 | + } else { | |
657 | + return ((int64_t)times(&tp) * 1000) / timer_freq; | |
658 | + } | |
645 | 659 | } |
646 | 660 | #endif |
647 | 661 | default: |
... | ... | @@ -964,7 +978,27 @@ static int net_slirp_init(NetDriverState *nd) |
964 | 978 | #endif /* CONFIG_SLIRP */ |
965 | 979 | |
966 | 980 | #if !defined(_WIN32) |
981 | +#ifdef _BSD | |
982 | +static int tun_open(char *ifname, int ifname_size) | |
983 | +{ | |
984 | + int fd; | |
985 | + char *dev; | |
986 | + struct stat s; | |
967 | 987 | |
988 | + fd = open("/dev/tap", O_RDWR); | |
989 | + if (fd < 0) { | |
990 | + fprintf(stderr, "warning: could not open /dev/tap: no virtual network emulation\n"); | |
991 | + return -1; | |
992 | + } | |
993 | + | |
994 | + fstat(fd, &s); | |
995 | + dev = devname(s.st_rdev, S_IFCHR); | |
996 | + pstrcpy(ifname, ifname_size, dev); | |
997 | + | |
998 | + fcntl(fd, F_SETFL, O_NONBLOCK); | |
999 | + return fd; | |
1000 | +} | |
1001 | +#else | |
968 | 1002 | static int tun_open(char *ifname, int ifname_size) |
969 | 1003 | { |
970 | 1004 | struct ifreq ifr; |
... | ... | @@ -989,6 +1023,7 @@ static int tun_open(char *ifname, int ifname_size) |
989 | 1023 | fcntl(fd, F_SETFL, O_NONBLOCK); |
990 | 1024 | return fd; |
991 | 1025 | } |
1026 | +#endif | |
992 | 1027 | |
993 | 1028 | static void tun_send_packet(NetDriverState *nd, const uint8_t *buf, int size) |
994 | 1029 | { |
... | ... | @@ -2248,7 +2283,12 @@ int main(int argc, char **argv) |
2248 | 2283 | phys_ram_size = ram_size + vga_ram_size; |
2249 | 2284 | |
2250 | 2285 | #ifdef CONFIG_SOFTMMU |
2286 | +#ifdef _BSD | |
2287 | + /* mallocs are always aligned on BSD. */ | |
2288 | + phys_ram_base = malloc(phys_ram_size); | |
2289 | +#else | |
2251 | 2290 | phys_ram_base = memalign(TARGET_PAGE_SIZE, phys_ram_size); |
2291 | +#endif | |
2252 | 2292 | if (!phys_ram_base) { |
2253 | 2293 | fprintf(stderr, "Could not allocate physical memory\n"); |
2254 | 2294 | exit(1); | ... | ... |
vl.h
... | ... | @@ -35,6 +35,7 @@ |
35 | 35 | #include <errno.h> |
36 | 36 | #include <unistd.h> |
37 | 37 | #include <fcntl.h> |
38 | +#include <sys/stat.h> | |
38 | 39 | |
39 | 40 | #ifndef O_LARGEFILE |
40 | 41 | #define O_LARGEFILE 0 |
... | ... | @@ -49,6 +50,13 @@ |
49 | 50 | |
50 | 51 | #include "cpu.h" |
51 | 52 | |
53 | +#ifdef _BSD | |
54 | +#define lseek64 lseek | |
55 | +#define ftruncate64 ftruncate | |
56 | +#define mkstemp64 mkstemp | |
57 | +#define MAP_ANONYMOUS MAP_ANON | |
58 | +#endif | |
59 | + | |
52 | 60 | #ifndef glue |
53 | 61 | #define xglue(x, y) x ## y |
54 | 62 | #define glue(x, y) xglue(x, y) | ... | ... |