1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-01 04:10:18 +02:00
guile/qt/md/i386.asm
Stefan Jahn 8f99e3f38b 2001-11-04 Stefan Jahn <stefan@lkcc.org>
* NEWS: Corrected remarks about SCM_API.

        * configure.in: Defining USE_DLL_IMPORT definition to indicate
        usage of DLL import macros in `libguile/__scm.h'.
        (LIBOBJS): Removed `fileblocks.o' from the list of object files.
        Somehow Jim Blandy's patch from 1997 did not survive.

2001-11-04  Stefan Jahn  <stefan@lkcc.org>

        * configure.in (EXTRA_DEFS): Follow-up patch.  Using SCM_IMPORT
        instead of __SCM_IMPORT__.

        * readline.c (scm_readline_init_ports): Disable input/output
        stream redirection for Win32.  The readline package for Win32
        does not support this.  The guile-readline library works fine
        for command line editing.

        * readline.h (SCM_RL_API): Renamed __FOO__ macros into FOO.

2001-11-04  Stefan Jahn  <stefan@lkcc.org>

        * Makefile.am (libguile_la_LIBADD): Added $(THREAD_LIBS_LOCAL)
        here (was at guile_LDADD) which describes the dependency
        correctly and allows a clean build on Win32.

        * __scm.h (SCM_API): Follow-up patch.  Renamed __FOO__ macros
        into FOO.

        * __scm.h: USE_DLL_IMPORT indicates the usage of the DLL
        import macros for external libraries (libcrypt, libqthreads,
        libreadline and libregex).

        * coop-defs.h: Include <winsock2.h> for `struct timeval'.

        * posix.c (flock): Added support for flock() in M$-Windows.

        * guile.c (SCM_IMPORT): Follow-up patch.  Use SCM_IMPORT instead
        of __SCM_IMPORT__.

        * fports.c (getflags): Differentiate reading and writing pipes
        descriptors.

        * filesys.c (S_IS*): Redefine all of the S_IS*() macros for
        M$-Windows.

        * coop.c (coop_condition_variable_timed_wait_mutex): Use
        conditionalized error code if `ETIMEDOUT' is not available.
        (scm_thread_usleep): Remove bogus declaration of `struct timeval
        timeout'.

        * numbers.c (PTRDIFF_MIN): Moved this definition where it actually
        belongs.  That is because NO_PREPRO_MAGIC gets undefined after
        each inclusion of `num2integral.i.c'.
        (SIZE_MAX): Define NO_PREPRO_MAGIC if SIZE_MAX is undefined.

2001-11-04  Stefan Jahn  <stefan@lkcc.org>

        * md/Makefile.am (EXTRA_DIST): Added `i386.asm'.

        * md/i386.asm: New file.  Contains the Intel syntax version for
        nasm/tasm/masm of the file `i386.s'.

        * qt.h.in: Definition of QT_API, QT_IMPORT and QT_EXPORT.
        Prefixed each symbols which is meant to go into a DLL.

        * Makefile.am (libqthreads_la_LDFLAGS):  Put `-no-undefined'
        into LDFLAGS to support linkers which do not allow unresolved
        symbols inside shared libraries.
        (EXTRA_DIST): Add `libqthreads.def', which is an export file
        definition for M$-Windows.  It defines exported symbols.  This is
        necessary because the M$VC linker does not know how to export
        assembler symbols into a DLL.

2001-11-04  Stefan Jahn  <stefan@lkcc.org>

        * srfi-13.h, srfi-14.h, srfi-4.h: Follow-up patch.  Renamed
        __FOO__ macros into FOO.

2001-11-04  Stefan Jahn  <stefan@lkcc.org>

        * tests/ports.test: Run (close-port) before (delete-file) if
        necessary/advisory.
2001-11-04 15:52:30 +00:00

112 lines
3.2 KiB
NASM

;; i386.asm -- assembly support.
;;
;; QuickThreads -- Threads-building toolkit.
;; Copyright (c) 2001 Free Software Foundation, Inc.
;;
;; Permission to use, copy, modify and distribute this software and
;; its documentation for any purpose and without fee is hereby
;; granted, provided that the above copyright notice and this notice
;; appear in all copies. This software is provided as a
;; proof-of-concept and for demonstration purposes; there is no
;; representation about the suitability of this software for any
;; purpose.
;; NOTE: double-labeled `_name' and `name' for System V compatability.
;; NOTE: Comment lines start like this one, or with '//' ONLY. Sorry!
;; Callee-save: %esi, %edi, %ebx, %ebp
;; Caller-save: %eax, %ecx
;; Can't tell: %edx (seems to work w/o saving it.)
;;
;; Assignment:
;;
;; See ``i386.h'' for the somewhat unconventional stack layout.
.386p
.model flat
.code
public _qt_abort
public qt_abort
public _qt_block
public qt_block
public _qt_blocki
public qt_blocki
;; These all have the type signature
;;
;; void *blocking (helper, arg0, arg1, new)
;;
;; On procedure entry, the helper is at 4(sp), args at 8(sp) and
;; 12(sp) and the new thread's sp at 16(sp). It *appears* that the
;; calling convention for the 8X86 requires the caller to save all
;; floating-point registers, this makes our life easy.
;; Halt the currently-running thread. Save it's callee-save regs on
;; to the stack, 32 bytes. Switch to the new stack (next == 16+32(sp))
;; and call the user function (f == 4+32(sp) with arguments: old sp
;; arg1 (8+32(sp)) and arg2 (12+32(sp)). When the user function is
;; done, restore the new thread's state and return.
;;
;; `qt_abort' is (currently) an alias for `qt_block' because most of
;; the work is shared. We could save the insns up to `qt_common' by
;; replicating, but w/o replicating we need an inital subtract (to
;; offset the stack as if it had been a qt_block) and then a jump
;; to qt_common. For the cost of a jump, we might as well just do
;; all the work.
;;
;; The helper function (4(sp)) can return a void* that is returned
;; by the call to `qt_blockk{,i}'. Since we don't touch %eax in
;; between, we get that ``for free''.
_qt_abort:
qt_abort:
_qt_block:
qt_block:
_qt_blocki:
qt_blocki:
push ebp ; Save callee-save, sp-=4.
push esi ; Save callee-save, sp-=4.
push edi ; Save callee-save, sp-=4.
push ebx ; Save callee-save, sp-=4.
mov eax, esp ; Remember old stack pointer.
qt_common:
mov esp, [esp+32] ; Move to new thread.
push [eax+28] ; Push arg 2.
push [eax+24] ; Push arg 1.
push eax ; Push arg 0.
mov ebx, [eax+20] ; Get function to call.
call ebx ; Call f.
add esp, 12 ; Pop args.
pop ebx ; Restore callee-save, sp+=4.
pop edi ; Restore callee-save, sp+=4.
pop esi ; Restore callee-save, sp+=4.
pop ebp ; Restore callee-save, sp+=4.
ret ; Resume the stopped function.
hlt
;; Start a varargs thread.
public _qt_vstart
public qt_vstart
_qt_vstart:
qt_vstart:
push edi ; Push `pt' arg to `startup'.
call ebp ; Call `startup'.
pop eax ; Clean up the stack.
call ebx ; Call the user's function.
push eax ; Push return from user's.
push edi ; Push `pt' arg to `cleanup'.
call esi ; Call `cleanup'.
hlt ; `cleanup' never returns.
end