bsd port (Markus Niemisto)

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@800 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
bellard 2004-05-12 19:32:15 +00:00
parent fd872598d8
commit 7d3505c55a
9 changed files with 111 additions and 16 deletions

View File

@ -16,7 +16,7 @@ endif
all: dyngen$(EXESUF) $(TOOLS) qemu-doc.html qemu-tech.html qemu.1
for d in $(TARGET_DIRS); do \
make -C $$d $@ || exit 1 ; \
$(MAKE) -C $$d $@ || exit 1 ; \
done
qemu-mkcow: qemu-mkcow.c
@ -29,9 +29,9 @@ clean:
# avoid old build problems by removing potentially incorrect old files
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
rm -f *.o *.a $(TOOLS) dyngen$(EXESUF) TAGS qemu.pod
make -C tests clean
$(MAKE) -C tests clean
for d in $(TARGET_DIRS); do \
make -C $$d $@ || exit 1 ; \
$(MAKE) -C $$d $@ || exit 1 ; \
done
distclean: clean
@ -55,12 +55,12 @@ ifndef CONFIG_WIN32
install qemu.1 qemu-mkcow.1 "$(mandir)/man1"
endif
for d in $(TARGET_DIRS); do \
make -C $$d $@ || exit 1 ; \
$(MAKE) -C $$d $@ || exit 1 ; \
done
# various test targets
test speed test2: all
make -C tests $@
$(MAKE) -C tests $@
TAGS:
etags *.[ch] tests/*.[ch]

20
configure vendored
View File

@ -79,9 +79,23 @@ case $targetos in
MINGW32*)
mingw32="yes"
;;
FreeBSD)
bsd="yes"
;;
NetBSD)
bsd="yes"
;;
OpenBSD)
bsd="yes"
;;
*) ;;
esac
if [ "$bsd" = "yes" ] ; then
make="gmake"
target_list="i386-softmmu"
fi
# find source path
# XXX: we assume an absolute path is given when launching configure,
# except in './configure' case.
@ -373,7 +387,7 @@ fi
if test "$mingw32" = "yes" ; then
echo "CONFIG_WIN32=yes" >> $config_mak
echo "#define CONFIG_WIN32 1" >> $config_h
else
elif test -f "/usr/include/byteswap.h" ; then
echo "#define HAVE_BYTESWAP_H 1" >> $config_h
fi
if test "$gdbstub" = "yes" ; then
@ -402,6 +416,10 @@ echo "\"" >> $config_h
echo "SRC_PATH=$source_path" >> $config_mak
echo "TARGET_DIRS=$target_list" >> $config_mak
if [ "$bsd" = "yes" ] ; then
echo "#define _BSD 1" >> $config_h
fi
for target in $target_list; do
target_dir="$target"

View File

@ -59,7 +59,11 @@ extern int fprintf(FILE *, const char *, ...);
extern int printf(const char *, ...);
#undef NULL
#define NULL 0
#ifdef _BSD
#include <ieeefp.h>
#else
#include <fenv.h>
#endif
#ifdef __i386__
#define AREG0 "ebp"

View File

@ -532,7 +532,7 @@ static void gdb_accept(void *opaque, const uint8_t *buf, int size)
/* set short latency */
val = 1;
setsockopt(fd, SOL_TCP, TCP_NODELAY, &val, sizeof(val));
setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val));
s = qemu_mallocz(sizeof(GDBState));
if (!s) {

View File

@ -259,7 +259,7 @@ enum {
CC_OP_NB,
};
#if defined(__i386__) || defined(__x86_64__)
#if (defined(__i386__) || defined(__x86_64__)) && !defined(_BSD)
#define USE_X86LDOUBLE
#endif

View File

@ -17,6 +17,7 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#include "dyngen-exec.h"
/* at least 4 register variables are defines */
@ -307,8 +308,13 @@ static inline void stfl(void *ptr, float v)
#define rint rintl
#endif
#if !defined(_BSD)
extern int lrint(CPU86_LDouble x);
extern int64_t llrint(CPU86_LDouble x);
#else
#define lrint(d) ((int)rint(d))
#define llrint(d) ((int)rint(d))
#endif
extern CPU86_LDouble fabs(CPU86_LDouble x);
extern CPU86_LDouble sin(CPU86_LDouble x);
extern CPU86_LDouble cos(CPU86_LDouble x);

View File

@ -1938,6 +1938,24 @@ void OPPROTO op_fldcw_A0(void)
int rnd_type;
env->fpuc = lduw((void *)A0);
/* set rounding mode */
#ifdef _BSD
switch(env->fpuc & RC_MASK) {
default:
case RC_NEAR:
rnd_type = FP_RN;
break;
case RC_DOWN:
rnd_type = FP_RM;
break;
case RC_UP:
rnd_type = FP_RP;
break;
case RC_CHOP:
rnd_type = FP_RZ;
break;
}
fpsetround(rnd_type);
#else
switch(env->fpuc & RC_MASK) {
default:
case RC_NEAR:
@ -1954,6 +1972,7 @@ void OPPROTO op_fldcw_A0(void)
break;
}
fesetround(rnd_type);
#endif
}
void OPPROTO op_fclex(void)

52
vl.c
View File

@ -28,29 +28,35 @@
#include <fcntl.h>
#include <signal.h>
#include <time.h>
#include <malloc.h>
#include <errno.h>
#include <sys/time.h>
#ifndef _WIN32
#include <sys/times.h>
#include <sys/wait.h>
#include <pty.h>
#include <termios.h>
#include <sys/poll.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#ifdef _BSD
#include <sys/stat.h>
#include <libutil.h>
#else
#include <linux/if.h>
#include <linux/if_tun.h>
#include <pty.h>
#include <malloc.h>
#include <linux/rtc.h>
#endif
#endif
#if defined(CONFIG_SLIRP)
#include "libslirp.h"
#endif
#ifdef _WIN32
#include <malloc.h>
#include <sys/timeb.h>
#include <windows.h>
#define getopt_long_only getopt_long
@ -58,15 +64,17 @@
#endif
#ifdef CONFIG_SDL
#if defined(__linux__)
/* SDL use the pthreads and they modify sigaction. We don't
want that. */
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)
#if (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2))
extern void __libc_sigaction();
#define sigaction(sig, act, oact) __libc_sigaction(sig, act, oact)
#else
extern void __sigaction();
#define sigaction(sig, act, oact) __sigaction(sig, act, oact)
#endif
#endif /* __linux__ */
#endif /* CONFIG_SDL */
#include "disas.h"
@ -637,11 +645,17 @@ int64_t qemu_get_clock(QEMUClock *clock)
#ifdef _WIN32
return GetTickCount();
#else
/* XXX: portability among Linux hosts */
{
struct tms tp;
/* Note that using gettimeofday() is not a good solution
for timers because its value change when the date is
modified. */
if (timer_freq == 100) {
return times(NULL) * 10;
return times(&tp) * 10;
} else {
return ((int64_t)times(NULL) * 1000) / timer_freq;
return ((int64_t)times(&tp) * 1000) / timer_freq;
}
}
#endif
default:
@ -964,7 +978,27 @@ static int net_slirp_init(NetDriverState *nd)
#endif /* CONFIG_SLIRP */
#if !defined(_WIN32)
#ifdef _BSD
static int tun_open(char *ifname, int ifname_size)
{
int fd;
char *dev;
struct stat s;
fd = open("/dev/tap", O_RDWR);
if (fd < 0) {
fprintf(stderr, "warning: could not open /dev/tap: no virtual network emulation\n");
return -1;
}
fstat(fd, &s);
dev = devname(s.st_rdev, S_IFCHR);
pstrcpy(ifname, ifname_size, dev);
fcntl(fd, F_SETFL, O_NONBLOCK);
return fd;
}
#else
static int tun_open(char *ifname, int ifname_size)
{
struct ifreq ifr;
@ -989,6 +1023,7 @@ static int tun_open(char *ifname, int ifname_size)
fcntl(fd, F_SETFL, O_NONBLOCK);
return fd;
}
#endif
static void tun_send_packet(NetDriverState *nd, const uint8_t *buf, int size)
{
@ -2248,7 +2283,12 @@ int main(int argc, char **argv)
phys_ram_size = ram_size + vga_ram_size;
#ifdef CONFIG_SOFTMMU
#ifdef _BSD
/* mallocs are always aligned on BSD. */
phys_ram_base = malloc(phys_ram_size);
#else
phys_ram_base = memalign(TARGET_PAGE_SIZE, phys_ram_size);
#endif
if (!phys_ram_base) {
fprintf(stderr, "Could not allocate physical memory\n");
exit(1);

8
vl.h
View File

@ -35,6 +35,7 @@
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#ifndef O_LARGEFILE
#define O_LARGEFILE 0
@ -49,6 +50,13 @@
#include "cpu.h"
#ifdef _BSD
#define lseek64 lseek
#define ftruncate64 ftruncate
#define mkstemp64 mkstemp
#define MAP_ANONYMOUS MAP_ANON
#endif
#ifndef glue
#define xglue(x, y) x ## y
#define glue(x, y) xglue(x, y)