qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Antony T Curtis <antony.t.curtis@ntlworld.com>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] Running QEMU on FreeBSD
Date: Sun, 30 May 2004 04:53:20 +0100	[thread overview]
Message-ID: <1085889200.93476.22.camel@pcgem.rdg.cyberkinetica.com> (raw)
In-Reply-To: <1085872155.93476.18.camel@pcgem.rdg.cyberkinetica.com>

[-- Attachment #1: Type: text/plain, Size: 1065 bytes --]

On Sun, 2004-05-30 at 00:09, Antony T Curtis wrote:
> On Sat, 2004-05-29 at 23:24, Bartosz Fabianowski wrote:
> > > I pulled in some code from Linux for the missing long double
> > > functions... So in theory, the binary I have does have long double
> > > support ;)
> > 
> > Nice one. As far as I can tell from various mailing lists and bug 
> > reports, somebody is working on adding the long double rounding 
> > functions to FreeBSD's libc. Of course, they won't be able to use code 
> > from Linux due to licensing issues. So until that work is finished, 
> > maybe you could submit your patches so somebody could commit it to QEMU? 
> > I'd love to have long doubles in QEMU and don't want to duplicate your work.
> 
> Sure... I'll generate some diffs soon...

I have checked out te code from CVS and I am integrating my changes.

Attached is my FreeBSD diffs... (includes your diff) 

More to come soon - including my diffs to enable using device nodes
directly instead of files for hard drives and cdroms.
-- 
Antony T Curtis <antony.t.curtis@ntlworld.com>

[-- Attachment #2: qemu-freebsd.patch --]
[-- Type: text/x-patch, Size: 9662 bytes --]

diff -BcNpPr --exclude=CVS /home/antony/cvs/qemu/Makefile qemu-0.5.5/Makefile
*** /home/antony/cvs/qemu/Makefile	Mon May 17 21:06:42 2004
--- qemu-0.5.5/Makefile	Sun May 30 05:26:19 2004
*************** TAGS: 
*** 70,76 ****
  
  # documentation
  %.html: %.texi
! 	texi2html -monolithic -number $<
  
  qemu.1: qemu-doc.texi
  	./texi2pod.pl $< qemu.pod
--- 70,76 ----
  
  # documentation
  %.html: %.texi
! 	-texi2html -monolithic -number $<
  
  qemu.1: qemu-doc.texi
  	./texi2pod.pl $< qemu.pod
diff -BcNpPr --exclude=CVS /home/antony/cvs/qemu/configure qemu-0.5.5/configure
*** /home/antony/cvs/qemu/configure	Thu May 20 14:23:39 2004
--- qemu-0.5.5/configure	Sun May 30 05:42:05 2004
*************** echo "TARGET_DIRS=$target_list" >> $conf
*** 419,427 ****
--- 419,429 ----
  if [ "$bsd" = "yes" ] ; then
    echo "#define O_LARGEFILE 0" >> $config_h
    echo "#define lseek64 lseek" >> $config_h
+   echo "#define mkstemp64 mkstemp" >> $config_h
    echo "#define ftruncate64 ftruncate" >> $config_h
    echo "#define MAP_ANONYMOUS MAP_ANON" >> $config_h
    echo "#define _BSD 1" >> $config_h
+   echo "#define off64_t off_t" >> $config_h
  fi
  
  for target in $target_list; do 
diff -BcNpPr --exclude=CVS /home/antony/cvs/qemu/target-i386/cpu.h qemu-0.5.5/target-i386/cpu.h
*** /home/antony/cvs/qemu/target-i386/cpu.h	Thu May 20 15:01:56 2004
--- qemu-0.5.5/target-i386/cpu.h	Sun May 30 05:16:10 2004
*************** enum {
*** 259,265 ****
      CC_OP_NB,
  };
  
! #if (defined(__i386__) || defined(__x86_64__)) && !defined(_BSD)
  #define USE_X86LDOUBLE
  #endif
  
--- 259,265 ----
      CC_OP_NB,
  };
  
! #if defined(__i386__) || defined(__x86_64__)
  #define USE_X86LDOUBLE
  #endif
  
diff -BcNpPr --exclude=CVS /home/antony/cvs/qemu/target-i386/exec.h qemu-0.5.5/target-i386/exec.h
*** /home/antony/cvs/qemu/target-i386/exec.h	Sat May 29 12:08:52 2004
--- qemu-0.5.5/target-i386/exec.h	Sun May 30 05:19:43 2004
*************** static inline void stfl(void *ptr, float
*** 293,298 ****
--- 293,314 ----
  
  #endif /* !defined(CONFIG_USER_ONLY) */
  
+ #if defined(_BSD) && defined(USE_X86LDOUBLE)
+ #include <math.h>
+ /*int rintl(long double __x);
+ long int lrintl(long double __x);
+ long long int llrintl(long double __x);
+ long double powl(long double __x, long double __y);
+ long double logl(long double __x);
+ long double tanl(long double __x);
+ long double atan2l(long double __y, long double __x);
+ long double ceill(long double __x);
+ long double floorl(long double __x);
+ long double sqrtl(long double __x);
+ long double sinl(long double __x);
+ long double cosl(long double __x);*/
+ #endif
+ 
  #ifdef USE_X86LDOUBLE
  /* use long double functions */
  #define lrint lrintl
*************** static inline void stfl(void *ptr, float
*** 310,316 ****
  #define rint rintl
  #endif
  
! #if !defined(_BSD)
  extern int lrint(CPU86_LDouble x);
  extern int64_t llrint(CPU86_LDouble x);
  #else
--- 326,332 ----
  #define rint rintl
  #endif
  
! #if !defined(_BSD) || defined(USE_X86LDOUBLE)
  extern int lrint(CPU86_LDouble x);
  extern int64_t llrint(CPU86_LDouble x);
  #else
diff -BcNpPr --exclude=CVS /home/antony/cvs/qemu/target-i386/op.c qemu-0.5.5/target-i386/op.c
*** /home/antony/cvs/qemu/target-i386/op.c	Sat May 29 12:08:52 2004
--- qemu-0.5.5/target-i386/op.c	Sun May 30 05:40:54 2004
*************** CCTable cc_table[CC_OP_NB] = {
*** 1304,1309 ****
--- 1304,1452 ----
     functions comes from the LGPL'ed x86 emulator found in the Willows
     TWIN windows emulator. */
  
+ #if defined(_BSD) && defined(USE_X86LDOUBLE)
+ 
+ CPU86_LDouble rintl(CPU86_LDouble __x) {
+   CPU86_LDouble __rintres;
+   __asm__ __volatile__
+     ("fistp %0"
+      : "=m" (__rintres) : "t" (__x) : "st");
+   return __rintres;
+ }
+ 
+ int lrintl(CPU86_LDouble __x) {
+   int __lrintres;
+   __asm__ __volatile__
+     ("fistpl %0"
+      : "=m" (__lrintres) : "t" (__x) : "st");
+   return __lrintres;
+ }
+ 
+ 
+ int64_t llrintl(CPU86_LDouble __x) {
+   int64_t __llrintres;
+   __asm__ __volatile__
+     ("fistpll %0"
+      : "=m" (__llrintres) : "t" (__x) : "st");
+   return __llrintres;
+ }
+ 
+ CPU86_LDouble powl(CPU86_LDouble __x, CPU86_LDouble __y) {
+   register CPU86_LDouble __value;
+   register long double __exponent;
+   __extension__ long long int __p = (long long int) __y;
+   if (__x == 0.0)
+     {
+        if (__y > 0.0)
+          return __y == (double) __p && (__p & 1) != 0 ? __x : 0.0;
+        else if (__y < 0.0)
+          return (__y == (double) __p && (-__p & 1) != 0
+                  ? 1.0 / __x : 1.0 / fabs (__x));
+     }
+   if (__y == (double) __p)
+     {
+       long double __r = 1.0;
+       if (__p == 0)
+         return 1.0;
+       if (__p < 0)
+         {
+           __p = -__p;
+           __x = 1.0 / __x;
+         }
+       while (1)
+         {
+           if (__p & 1)
+             __r *= __x;
+           __p >>= 1;
+           if (__p == 0)
+             return __r;
+           __x *= __x;
+         }
+       /* NOTREACHED */
+     }
+   __asm __volatile__
+     ("fyl2x" : "=t" (__value) : "0" (__x), "u" (1.0) : "st(1)");
+   __asm __volatile__
+     ("fmul      %%st(1)         # y * log2(x)\n\t"
+      "fst       %%st(1)\n\t"
+      "frndint                   # int(y * log2(x))\n\t"
+      "fxch\n\t"
+      "fsub      %%st(1)         # fract(y * log2(x))\n\t"
+      "f2xm1                     # 2^(fract(y * log2(x))) - 1\n\t"
+      : "=t" (__value), "=u" (__exponent) : "0" (__y), "1" (__value));
+   __value += 1.0;
+   __asm __volatile__
+     ("fscale"
+      : "=t" (__value) : "0" (__value), "u" (__exponent));
+   return __value;
+ }
+ 
+ CPU86_LDouble logl(CPU86_LDouble __x) {
+   register CPU86_LDouble __result;
+   __asm __volatile__ ("fldln2; fxch; fyl2x" : "=t" (__result) : "0" (__x) : "st(1)");
+   return __result;
+ }
+ 
+ CPU86_LDouble tanl(CPU86_LDouble __x) {
+   register CPU86_LDouble __value;
+   register CPU86_LDouble __value2 __attribute__ ((__unused__));
+   __asm __volatile__
+     ("fptan"
+      : "=t" (__value2), "=u" (__value) : "0" (__x));
+   return __value;
+ }
+ 
+ CPU86_LDouble atan2l(CPU86_LDouble __y, CPU86_LDouble __x) {
+   register CPU86_LDouble __value;
+   __asm __volatile__
+     ("fpatan"
+      : "=t" (__value) : "0" (__x), "u" (__y) : "st(1)");
+   return __value;
+ }
+ 
+ CPU86_LDouble ceill(CPU86_LDouble __x) {
+   register CPU86_LDouble __value;
+   __volatile unsigned short int __cw;
+   __volatile unsigned short int __cwtmp;
+   __asm __volatile ("fnstcw %0" : "=m" (__cw));
+   __cwtmp = (__cw & 0xf3ff) | 0x0800; /* rounding up */
+   __asm __volatile ("fldcw %0" : : "m" (__cwtmp));
+   __asm __volatile ("frndint" : "=t" (__value) : "0" (__x));
+   __asm __volatile ("fldcw %0" : : "m" (__cw));
+   return __value;
+ }
+ 
+ CPU86_LDouble floorl(CPU86_LDouble __x) {
+   register CPU86_LDouble __value;
+   __volatile unsigned short int __cw;
+   __volatile unsigned short int __cwtmp;
+   __asm __volatile ("fnstcw %0" : "=m" (__cw));
+   __cwtmp = (__cw & 0xf3ff) | 0x0400; /* rounding down */
+   __asm __volatile ("fldcw %0" : : "m" (__cwtmp));
+   __asm __volatile ("frndint" : "=t" (__value) : "0" (__x));
+   __asm __volatile ("fldcw %0" : : "m" (__cw));
+   return __value;
+ }
+ 
+ CPU86_LDouble sqrtl(CPU86_LDouble __x) {
+   register CPU86_LDouble __result;
+   __asm __volatile__ ("fsqrt" : "=t" (__result) : "0" (__x));
+   return __result;
+ }
+ 
+ CPU86_LDouble sinl(CPU86_LDouble __x) {
+   register CPU86_LDouble __result;
+   __asm __volatile__ ("fsin" : "=t" (__result) : "0" (__x));
+   return __result;
+ }
+ 
+ CPU86_LDouble cosl(CPU86_LDouble __x) {
+   register CPU86_LDouble __result;
+   __asm __volatile__ ("fcos" : "=t" (__result) : "0" (__x));
+   return __result;
+ }
+ #endif
+ 
  #if defined(__powerpc__)
  extern CPU86_LDouble copysign(CPU86_LDouble, CPU86_LDouble);
  
diff -BcNpPr --exclude=CVS /home/antony/cvs/qemu/vl.c qemu-0.5.5/vl.c
*** /home/antony/cvs/qemu/vl.c	Wed May 26 23:12:06 2004
--- qemu-0.5.5/vl.c	Sun May 30 05:30:56 2004
*************** int64_t qemu_get_clock(QEMUClock *clock)
*** 662,667 ****
--- 662,675 ----
      case QEMU_TIMER_REALTIME:
  #ifdef _WIN32
          return GetTickCount();
+ #elif defined(_BSD)
+         {
+             struct timeval r;
+             if (!gettimeofday(&r, NULL)) {
+                 return ((CLK_TCK * 1000LL) * (int64_t)r.tv_sec 
+                       + ((int64_t)r.tv_usec * CLK_TCK) / 1000) / timer_freq;
+             }
+         }        
  #else
          {
              struct tms tp;
*************** static void init_timers(void)
*** 828,833 ****
--- 836,842 ----
             the emulated kernel requested a too high timer frequency */
          getitimer(ITIMER_REAL, &itv);
  
+ #if defined(__linux__)
          if (itv.it_interval.tv_usec > 1000) {
              /* try to use /dev/rtc to have a faster timer */
              if (start_rtc_timer() < 0)
*************** static void init_timers(void)
*** 843,849 ****
              sigaction(SIGIO, &act, NULL);
              fcntl(rtc_fd, F_SETFL, O_ASYNC);
              fcntl(rtc_fd, F_SETOWN, getpid());
!         } else {
          use_itimer:
              pit_min_timer_count = ((uint64_t)itv.it_interval.tv_usec * 
                                     PIT_FREQ) / 1000000;
--- 852,860 ----
              sigaction(SIGIO, &act, NULL);
              fcntl(rtc_fd, F_SETFL, O_ASYNC);
              fcntl(rtc_fd, F_SETOWN, getpid());
!         } else 
! #endif
!         {
          use_itimer:
              pit_min_timer_count = ((uint64_t)itv.it_interval.tv_usec * 
                                     PIT_FREQ) / 1000000;

  reply	other threads:[~2004-05-30  3:54 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-29 21:25 [Qemu-devel] Running QEMU on FreeBSD Antony T Curtis
2004-05-29 21:39 ` Bartosz Fabianowski
2004-05-29 21:50   ` Antony T Curtis
2004-05-29 21:58     ` Bartosz Fabianowski
2004-05-29 22:09       ` Antony T Curtis
2004-05-29 22:24         ` Bartosz Fabianowski
2004-05-29 23:09           ` Antony T Curtis
2004-05-30  3:53             ` Antony T Curtis [this message]
2004-05-30  7:25             ` Markus Niemistö
2004-05-30  9:50               ` Antony T Curtis
2004-05-30 14:41                 ` Bartosz Fabianowski
2004-05-30 17:27                   ` Antony T Curtis
2004-05-30 18:57                     ` Bartosz Fabianowski
2004-05-30 20:09                       ` Antony T Curtis
2004-05-31  0:36                         ` Bartosz Fabianowski
2004-05-31  1:24                           ` Antony T Curtis
2004-05-31  1:42                             ` Bartosz Fabianowski
2004-05-31  1:59                               ` Kyle Hayes
2004-05-31 12:15                                 ` Bartosz Fabianowski
2004-05-31 13:22                                   ` Antony T Curtis
2004-05-31  9:38                               ` Antony T Curtis
2004-05-31 20:36                                 ` Bartosz Fabianowski
2004-05-31 13:54                               ` Antony T Curtis
2004-05-31 20:31                                 ` Bartosz Fabianowski
2004-05-31 22:15                                   ` Antony T Curtis
2004-05-31 22:56                               ` Brion Vibber
2004-05-31 23:01                                 ` Bartosz Fabianowski
2004-06-02 23:18                             ` qemu port (was: Re: [Qemu-devel] Running QEMU on FreeBSD) Juergen Lock
2004-06-02 23:54                               ` [Qemu-devel] Re: qemu port Bartosz Fabianowski
2004-06-03 17:10                                 ` Gianni Tedesco
2004-06-04 18:44                                 ` Juergen Lock
2004-06-05 21:04                               ` [Qemu-devel] FreeSBIE timer (was: Re: qemu port) Juergen Lock

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1085889200.93476.22.camel@pcgem.rdg.cyberkinetica.com \
    --to=antony.t.curtis@ntlworld.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).