ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/SheepShaver/src/Unix/sysdeps.h
Revision 1.59 - (view) (annotate) - [select for diffs]
2009-08-17T20:44:30Z (15 years, 3 months ago) by asvitkine
Branch: MAIN
CVS Tags: HEAD
Changes since 1.58: +9 -0 lines
Diff to previous 1.58
[Charles Srstka]
Attached is a set of patches to port the precise timer that is currently used in the Linux and BeOS builds of SheepShaver to Mac OS X (and any other Mach-based operating systems).

Currently, the Linux build uses the clock_gettime() function to get nanosecond-precision time, and falls back on gettimeofday() if it is not present. Unfortunately, Mac OS X does not currently support clock_gettime(), and gettimeofday() has only microsecond granularity. The Mach kernel, however, has a clock_get_time() function that does very nearly the same thing as clock_gettime(). The patches to BasiliskII cause the timing functions such as timer_current_time() to use clock_get_time() instead of gettimeofday() on Mach-based systems that do not support clock_gettime().

The changes to SheepShaver involve the precise timer. The existing code for Linux uses pthreads and real-time signals to handle the timing. Mac OS X unfortunately does not seem to support real-time signals, so Mach calls are again used to suspend and resume the timer thread in order to attempt to duplicate the Linux and BeOS versions of the timer. The code is somewhat ugly right now, as I decided to leave alone the pre-existing style of the source file, which unfortunately involves #ifdefs scattered throughout the file and some duplication of code. A future patch may want to clean this up to separate out the OS-specific code and put it all together at the top of the file. However, for the time being, this seems to work.

This has not been extensively tested, because I have not been able to get my hands on a good test-case app for the classic Mac OS that would run inside the emulator and try out the timer. However, performance does seem to be better than with the pre-existing code, and nothing seems to have blown up as far as I can tell. I did find a game via a Google search -  Cap'n Magneto - that is known to have problems with Basilisk/SheepShaver's legacy 60 Hz timer, and the opening fade-to-color for this game appears to run much more smoothly with the precise timer code in place.

Revision 1.58 - (view) (annotate) - [select for diffs]
2008-06-20T00:50:33Z (16 years, 5 months ago) by asvitkine
Branch: MAIN
Changes since 1.57: +1 -1 lines
Diff to previous 1.57
Don't profile by default - as this is no use to non-developers.

Revision 1.57 - (view) (annotate) - [select for diffs]
2008-01-01T09:47:39Z (16 years, 11 months ago) by gbeauche
Branch: MAIN
Changes since 1.56: +1 -1 lines
Diff to previous 1.56
Happy New Year!

Revision 1.56 - (view) (annotate) - [select for diffs]
2007-02-17T09:01:30Z (17 years, 9 months ago) by gbeauche
Branch: MAIN
Changes since 1.55: +1 -0 lines
Diff to previous 1.55
merge PPC_PROFILE_REGS_USE fixes from KPX branch

Revision 1.55 - (view) (annotate) - [select for diffs]
2007-01-17T07:05:19Z (17 years, 10 months ago) by gbeauche
Branch: MAIN
Changes since 1.54: +1 -1 lines
Diff to previous 1.54
Rearrange powerpc_registers struct and nuke fp_result register which is
only needed for JIT (and to be handled differently in the future).

Revision 1.54 - (view) (annotate) - [select for diffs]
2006-07-06T00:01:04Z (18 years, 4 months ago) by gbeauche
Branch: MAIN
Changes since 1.53: +1 -1 lines
Diff to previous 1.53
Add more micro asm optimisations to x86{,-64} (mulhw, mulhwu, slw, srw, cntlzw
and subf* series). Also now enable the optimzations on x86_64 by default.

Revision 1.53 - (view) (annotate) - [select for diffs]
2006-05-07T16:54:58Z (18 years, 6 months ago) by gbeauche
Branch: MAIN
Changes since 1.52: +6 -0 lines
Diff to previous 1.52
Define UNALIGNED_PROFITABLE on x86 platforms

Revision 1.52 - (view) (annotate) - [select for diffs]
2006-05-02T19:33:10Z (18 years, 7 months ago) by gbeauche
Branch: MAIN
Changes since 1.51: +0 -15 lines
Diff to previous 1.51
Move likely() definitions to dyngen-exec.h, they are only used in the CPU
core where it's most useful (give a stronger hint to gcc4)

Revision 1.51 - (view) (annotate) - [select for diffs]
2006-04-01T21:41:18Z (18 years, 8 months ago) by gbeauche
Branch: MAIN
Changes since 1.50: +15 -0 lines
Diff to previous 1.50
Helper macros to annotate likely branch directions. Colateral effect: this
also fixes build with GCC 4.1 (ppc-dyngen-ops.cpp) since the branches are
re-ordered in a way there is now only one exit-point in op_jump_next_A0().

Revision 1.50 - (view) (annotate) - [select for diffs]
2005-11-30T07:24:53Z (19 years ago) by gbeauche
Branch: MAIN
Changes since 1.49: +0 -2 lines
Diff to previous 1.49
Always use the complete non-stubs Ethernet driver (XXX probably do that
only in Emulated PPC mode for performance reasons?)

Revision 1.49 - (view) (annotate) - [select for diffs]
2005-11-27T16:20:17Z (19 years ago) by gbeauche
Branch: MAIN
Changes since 1.48: +0 -2 lines
Diff to previous 1.48
Do use predecode cache in case the JIT is disabled by the user ("jit" option)

Revision 1.48 - (view) (annotate) - [select for diffs]
2005-07-03T22:02:01Z (19 years, 5 months ago) by gbeauche
Branch: MAIN
Changes since 1.47: +5 -0 lines
Diff to previous 1.47
Minor tweaks to support compilation of ether.cpp within MacOS. i.e. mostly
migrate the Ethernet driver to the MacOS side. This is enabled for
DIRECT_ADDRESSING cases. I didn't want to alter much of ether.cpp (as it
would have required to support that mode). Of course, in REAL_ADDRESSING
mode (the default) and for debugging purposes, the old driver is still
available.

Revision 1.47 - (view) (annotate) - [select for diffs]
2005-07-03T13:39:06Z (19 years, 5 months ago) by gbeauche
Branch: MAIN
Changes since 1.46: +0 -14 lines
Diff to previous 1.46
Remove obsolete and broken Cygwin/X11 hacks. Forbid builds of the Windows
version from within the Unix/ directory.

Revision 1.46 - (view) (annotate) - [select for diffs]
2005-07-01T23:15:11Z (19 years, 5 months ago) by gbeauche
Branch: MAIN
Changes since 1.45: +1 -1 lines
Diff to previous 1.45
Hopefully fix the remaining issue in the High Resolution Timing support
code and re-enable it on Linux platforms (they have clock_nanosleep). Why
did I trigger an interrupt inside a held lock? Hmmm, we should probably
add an _ack semaphore like we do e.g. for ethernet.

Revision 1.45 - (view) (annotate) - [select for diffs]
2005-06-30T13:29:43Z (19 years, 5 months ago) by gbeauche
Branch: MAIN
Changes since 1.44: +1 -2 lines
Diff to previous 1.44
Re-enable spinlocks on {i386,x86_64} since they are now used only for really
small atomic operations (add/sub). This implementation should be enough for
that purpose.

Revision 1.44 - (view) (annotate) - [select for diffs]
2005-06-25T11:39:47Z (19 years, 5 months ago) by gbeauche
Branch: MAIN
Changes since 1.43: +8 -7 lines
Diff to previous 1.43
Use fast spinlocks only for small enough atomic operations. Otherwise, you
run into some performance problems in e.g. video graphics experience because
of busywaits in the current spin_lock() implementation.

Revision 1.43 - (view) (annotate) - [select for diffs]
2005-06-25T11:06:24Z (19 years, 5 months ago) by gbeauche
Branch: MAIN
Changes since 1.42: +1 -1 lines
Diff to previous 1.42
We HAVE_PTHREADS even if we use our own pthreads implementation, this also
induces availability of locking primitives. I will merge the !HAVE_PTHREADS
case (a la Basilisk II) for EMULATED_PPC when I get back to home.

Revision 1.42 - (view) (annotate) - [select for diffs]
2005-06-22T12:32:32Z (19 years, 5 months ago) by gbeauche
Branch: MAIN
Changes since 1.41: +8 -0 lines
Diff to previous 1.41
Extend internal math library from GNU libc to accomodate older systems
with glibc 2.2.X or simply no C99 capable C library. Fix vrfiz instruction
to really truncate on float values.

Revision 1.41 - (view) (annotate) - [select for diffs]
2005-03-27T13:41:46Z (19 years, 8 months ago) by gbeauche
Branch: MAIN
Changes since 1.40: +1 -1 lines
Diff to previous 1.40
Disable high-res timings as it could still hang. The advantage is that we
now can use special mutexes to debug deadlocks

Revision 1.40 - (view) (annotate) - [select for diffs]
2005-03-05T19:07:35Z (19 years, 8 months ago) by gbeauche
Branch: MAIN
Changes since 1.39: +6 -0 lines
Diff to previous 1.39
Enable high precision timings on POSIX systems supporting clock_nanosleep().
Since pthread_suspend_np() is not available to Linux (but NetBSD 2.0), thread
suspend is implemented likewise to boehm-gc.

Revision 1.39 - (view) (annotate) - [select for diffs]
2005-02-27T21:52:06Z (19 years, 9 months ago) by gbeauche
Branch: MAIN
Changes since 1.38: +1 -0 lines
Diff to previous 1.38
Fix native Linux/ppc with recent enough glibc that supports TLS; r2 is used
in that case. Tell me if I broke other arches, e.g. r13 is no longer saved
in Video and Ethernet stubs, though it seems to be OK.

Colateral feature: SheepShaver should now run on Linux/ppc64 with relevant
32-bit runtime. Native Linux/ppc64 support is harder as low mem globals are
32-bit in mind and e.g. the TLS register there is %r13, %r2 is the TOC
(PowerOpen/AIX ABI)

Revision 1.38 - (view) (annotate) - [select for diffs]
2005-02-20T18:08:50Z (19 years, 9 months ago) by gbeauche
Branch: MAIN
Changes since 1.37: +1 -1 lines
Diff to previous 1.37
Initial support for NetBSD/ppc in native mode (some crashes occur but I
could boot MacOS 9.0.4)

Revision 1.37 - (view) (annotate) - [select for diffs]
2005-02-13T18:18:59Z (19 years, 9 months ago) by gbeauche
Branch: MAIN
Changes since 1.36: +12 -0 lines
Diff to previous 1.36
Support FreeBSD 5.3:
- fix implementation of offsetof() with GCC >= 3.4 and C++ code

Revision 1.36 - (view) (annotate) - [select for diffs]
2005-01-30T21:48:20Z (19 years, 10 months ago) by gbeauche
Branch: MAIN
Changes since 1.35: +1 -1 lines
Diff to previous 1.35
Happy New Year 2005!

Revision 1.35 - (view) (annotate) - [select for diffs]
2004-11-22T22:40:26Z (20 years ago) by gbeauche
Branch: MAIN
Changes since 1.34: +18 -2 lines
Diff to previous 1.34
Cygwin Direct Addressing hack.

Revision 1.34 - (view) (annotate) - [select for diffs]
2004-11-13T14:09:16Z (20 years ago) by gbeauche
Branch: MAIN
Changes since 1.33: +14 -9 lines
Diff to previous 1.33
Implement Direct Addressing mode similarly to Basilisk II. This is to get
SheepShaver working on OSes that don't support maipping of Low Memory globals
at 0x00000000, e.g. Windows.

Revision 1.33 - (view) (annotate) - [select for diffs]
2004-06-15T21:37:22Z (20 years, 5 months ago) by gbeauche
Branch: MAIN
Changes since 1.32: +5 -0 lines
Diff to previous 1.32
Don't bother with predecode cache when using JIT.

Revision 1.32 - (view) (annotate) - [select for diffs]
2004-06-02T16:11:49Z (20 years, 6 months ago) by gbeauche
Branch: MAIN
Changes since 1.31: +17 -3 lines
Diff to previous 1.31
Disable testandset() locks, use pthread's as SheepShaver occasionnally hangs
with spinlocks. Weird as those are derived from x86 linuxthreads.

Revision 1.31 - (view) (annotate) - [select for diffs]
2004-05-20T17:46:49Z (20 years, 6 months ago) by gbeauche
Branch: MAIN
Changes since 1.30: +4 -5 lines
Diff to previous 1.30
add and fix testandset for x86_64

Revision 1.30 - (view) (annotate) - [select for diffs]
2004-05-20T12:33:57Z (20 years, 6 months ago) by gbeauche
Branch: MAIN
Changes since 1.29: +1 -3 lines
Diff to previous 1.29
Get rid of old (and broken) ASYNC_IRQ / MUTICORE code

Revision 1.29 - (view) (annotate) - [select for diffs]
2004-05-19T21:23:15Z (20 years, 6 months ago) by gbeauche
Branch: MAIN
Changes since 1.28: +1 -0 lines
Diff to previous 1.28
Make NativeOp() handler a sheepshaver_cpu handler, thus getting rid of ugly
GPR macro definition.

Make the JIT engine somewhat reentrant. This brings a massive performance
boost for applications that cause many Execute68k(). e.g. audio in PlayerPRO.

Revision 1.28 - (view) (annotate) - [select for diffs]
2004-05-14T08:25:30Z (20 years, 6 months ago) by gbeauche
Branch: MAIN
Changes since 1.27: +3 -0 lines
Diff to previous 1.27
Use assembly optimizations on x86 for adde/addo/etc. emulation

Revision 1.27 - (view) (annotate) - [select for diffs]
2004-05-12T11:38:16Z (20 years, 6 months ago) by gbeauche
Branch: MAIN
Changes since 1.26: +0 -4 lines
Diff to previous 1.26
Direct block chaining works on all supported platforms, enabled by default

Revision 1.26 - (view) (annotate) - [select for diffs]
2004-05-11T20:53:23Z (20 years, 6 months ago) by gbeauche
Branch: MAIN
Changes since 1.25: +4 -0 lines
Diff to previous 1.25
direct block chaining, aka faster block dispatcher

Revision 1.25 - (view) (annotate) - [select for diffs]
2004-02-25T22:02:59Z (20 years, 9 months ago) by gbeauche
Branch: MAIN
Changes since 1.24: +1 -1 lines
Diff to previous 1.24
fix for SheepThreads (native mode)

Revision 1.24 - (view) (annotate) - [select for diffs]
2004-02-24T23:09:39Z (20 years, 9 months ago) by gbeauche
Branch: MAIN
Changes since 1.23: +6 -0 lines
Diff to previous 1.23
Portability fixes: declare Set_pthread_attr() only if HAVE_PTHREADS. Merge
add_{serial,ether}_names() from B2 prefs editor for FreeBSD/IRIX.

Revision 1.23 - (view) (annotate) - [select for diffs]
2004-01-26T13:52:31Z (20 years, 10 months ago) by gbeauche
Branch: MAIN
Changes since 1.22: +9 -1 lines
Diff to previous 1.22
Use bswap instruction on IA-32 too. Optimize bswap_64 on little-endian
(x86 for now) systems.

Revision 1.22 - (view) (annotate) - [select for diffs]
2004-01-18T22:05:28Z (20 years, 10 months ago) by gbeauche
Branch: MAIN
Changes since 1.21: +6 -6 lines
Diff to previous 1.21
Add spinlocks for Darwin/PPC

Revision 1.21 - (view) (annotate) - [select for diffs]
2004-01-12T15:37:22Z (20 years, 10 months ago) by cebix
Branch: MAIN
Changes since 1.20: +1 -1 lines
Diff to previous 1.20
Happy New Year! :)

Revision 1.20 - (view) (annotate) - [select for diffs]
2004-01-06T15:05:35Z (20 years, 10 months ago) by gbeauche
Branch: MAIN
Changes since 1.19: +12 -12 lines
Diff to previous 1.19
Fix IA-32 testandset(), make spinlock_t volatile int.

Revision 1.19 - (view) (annotate) - [select for diffs]
2003-12-31T18:16:55Z (20 years, 11 months ago) by gbeauche
Branch: MAIN
Changes since 1.18: +19 -0 lines
Diff to previous 1.18
Add fast X11 display locking routines based on spinlocks, or on pthreads
in the worst case. Optimize out GetScrap() case when we already own the
selection. i.e. make it smoother. Use our own XDisplay{Un,}Lock() routines.

Revision 1.18 - (view) (annotate) - [select for diffs]
2003-12-28T17:56:03Z (20 years, 11 months ago) by gbeauche
Branch: MAIN
Changes since 1.17: +4 -0 lines
Diff to previous 1.17
Declare timing functions from timer_unix.cpp

Revision 1.17 - (view) (annotate) - [select for diffs]
2003-12-01T13:51:35Z (21 years ago) by gbeauche
Branch: MAIN
Changes since 1.16: +2 -1 lines
Diff to previous 1.16
Add PPC_PROFILE_GENERIC_CALLS, don't enable PPC_PROFILE_COMPILE_TIME by
default.

Revision 1.16 - (view) (annotate) - [select for diffs]
2003-11-28T22:13:49Z (21 years ago) by gbeauche
Branch: MAIN
Changes since 1.15: +2 -0 lines
Diff to previous 1.15
Gather stats about compile time. Define KPX_MAX_CPUS to 1 for allowing
allocation of translation cache into .data section on PowerPC.

Revision 1.15 - (view) (annotate) - [select for diffs]
2003-11-24T21:20:47Z (21 years ago) by gbeauche
Branch: MAIN
Changes since 1.14: +29 -1 lines
Diff to previous 1.14
Optimized bswap_32() for AMD64

Revision 1.14 - (view) (annotate) - [select for diffs]
2003-11-11T11:32:24Z (21 years ago) by gbeauche
Branch: MAIN
Changes since 1.13: +1 -2 lines
Diff to previous 1.13
Remove obsolete code related to PPC_NO_FPSCR_UPDATE, PPC_LAZY_PC_UPDATE,
PPC_LAZY_CC_UPDATE, PPC_HAVE_SPLIT_CR defines.

Revision 1.13 - (view) (annotate) - [select for diffs]
2003-10-26T14:16:37Z (21 years, 1 month ago) by gbeauche
Branch: MAIN
Changes since 1.12: +1 -1 lines
Diff to previous 1.12
Fix ASYNC_IRQ build but locks may still happen. Note that with a predecode
cache, checking for pending interrupts may not be the bottle neck nowadays.

Revision 1.12 - (view) (annotate) - [select for diffs]
2003-10-26T13:59:02Z (21 years, 1 month ago) by gbeauche
Branch: MAIN
Changes since 1.11: +2 -1 lines
Diff to previous 1.11
Rewrite interrupts handling code so that the emulator can work with a
predecode cache. This implies to run in interpreted mode only while
processing EmulOps or other native (nested) runs.

Note that the FLIGHT_RECORDER with a predecode cache gets slower than
without caching at all.

Revision 1.11 - (view) (annotate) - [select for diffs]
2003-10-12T05:44:14Z (21 years, 1 month ago) by gbeauche
Branch: MAIN
Changes since 1.10: +1 -0 lines
Diff to previous 1.10
- Handle MakeExecutable() replacement
- Disable predecode cache in CVS for now
- Fix flight recorder ordering in predecode cache mode

Revision 1.10 - (view) (annotate) - [select for diffs]
2003-10-11T09:57:49Z (21 years, 1 month ago) by gbeauche
Branch: MAIN
Changes since 1.9: +1 -2 lines
Diff to previous 1.9
- Add support for FLIGHT_RECORDER with predecode cache
- Always enable predecode cache & flight recorder for now

Revision 1.9 - (view) (annotate) - [select for diffs]
2003-10-11T09:34:35Z (21 years, 1 month ago) by gbeauche
Branch: MAIN
Changes since 1.8: +4 -0 lines
Diff to previous 1.8
Move PPC emulator config to here

Revision 1.8 - (view) (annotate) - [select for diffs]
2003-09-29T22:41:50Z (21 years, 2 months ago) by gbeauche
Branch: MAIN
Changes since 1.7: +1 -1 lines
Diff to previous 1.7
Make older & bogus compilers happy. aka. force "static" storage class
for SPIN_LOCK_UNLOCKED constant.

Revision 1.7 - (view) (annotate) - [select for diffs]
2003-09-29T15:46:07Z (21 years, 2 months ago) by gbeauche
Branch: MAIN
Changes since 1.6: +2 -0 lines
Diff to previous 1.6
- Share EmulatorData & KernelData struct definitions
- Introduce new SheepShaver data area for alternate stacks, thunks, etc.
- Experimental asynchronous interrupts handling. This improves performance
  by 30% but some (rare) lockups may occur. To be debugged!

Revision 1.6 - (view) (annotate) - [select for diffs]
2003-09-29T08:27:56Z (21 years, 2 months ago) by gbeauche
Branch: MAIN
Changes since 1.5: +123 -0 lines
Diff to previous 1.5
spinlocks from QEMU

Revision 1.5 - (view) (annotate) - [select for diffs]
2003-09-07T14:19:25Z (21 years, 2 months ago) by gbeauche
Branch: MAIN
Changes since 1.4: +68 -6 lines
Diff to previous 1.4
Add byteswap routines

Revision 1.4 - (view) (annotate) - [select for diffs]
2003-05-22T22:12:05Z (21 years, 6 months ago) by gbeauche
Branch: MAIN
Changes since 1.3: +3 -0 lines
Diff to previous 1.3
Import VOSF from Basilisk II for faster and more accurate video refresh.
There may be some bugs left though. Rework sigsegv_handler() a little to
accomodate VOSF way of life.

TODO: merge video drivers infrastructure from B2.

Revision 1.3 - (view) (annotate) - [select for diffs]
2003-01-04T12:23:39Z (21 years, 10 months ago) by gbeauche
Branch: MAIN
Changes since 1.2: +27 -8 lines
Diff to previous 1.2
Sync with changes from cxmon and B2. I have yet to find out why my old
disk image (8.1 based) no longer boots completely. :-/

Revision 1.2 - (view) (annotate) - [select for diffs]
2002-02-21T15:12:12Z (22 years, 9 months ago) by cebix
Branch: MAIN
Changes since 1.1: +3 -0 lines
Diff to previous 1.1
added dummy Set_pthread_attr()

Revision 1.1.1.1 - (view) (annotate) - [select for diffs] (vendor branch)
2002-02-04T16:58:13Z (22 years, 9 months ago) by cebix
Branch: cebix
CVS Tags: start
Changes since 1.1: +0 -0 lines
Diff to previous 1.1 , to next main 1.59
Imported sources

Revision 1.1 - (view) (annotate) - [select for diffs]
2002-02-04T16:58:13Z (22 years, 9 months ago) by cebix
Branch: MAIN
Branch point for: cebix
Initial revision

Convenience Links

Links to HEAD: (view) (annotate)

Compare Revisions

This form allows you to request diffs between any two revisions of this file. For each of the two "sides" of the diff, select a symbolic revision name using the selection box, or choose 'Use Text Field' and enter a numeric revision.

  Diffs between and
  Type of Diff should be a