[Openmcl-cvs-notifications] r8561 - in /trunk/source/lisp-kernel: gc-common.c lisp-debug.c pmcl-kernel.c win64/Makefile.nmake x86-asmutils64.s x86-constants64.s
andreas at clozure.com
andreas at clozure.com
Fri Feb 22 11:04:06 EST 2008
Author: andreas
Date: Fri Feb 22 11:04:06 2008
New Revision: 8561
Log:
* no pid_t on native Windows
* not gettimeofday either
* C calling conventions are different: short documentation, and one implem=
entation
Modified:
trunk/source/lisp-kernel/gc-common.c
trunk/source/lisp-kernel/lisp-debug.c
trunk/source/lisp-kernel/pmcl-kernel.c
trunk/source/lisp-kernel/win64/Makefile.nmake
trunk/source/lisp-kernel/x86-asmutils64.s
trunk/source/lisp-kernel/x86-constants64.s
Modified: trunk/source/lisp-kernel/gc-common.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/source/lisp-kernel/gc-common.c (original)
+++ trunk/source/lisp-kernel/gc-common.c Fri Feb 22 11:04:06 2008
@@ -23,7 +23,10 @@
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
+
+#ifndef WINDOWS
#include <sys/time.h>
+#endif
=
#ifndef timeradd
# define timeradd(a, b, result) \
@@ -273,7 +276,7 @@
void
ncircle_mark_weak_htabv(LispObj htabv)
{
- int i, skip =3D hash_table_vector_header_count;;
+ int i, skip =3D hash_table_vector_header_count;
hash_table_vector_header *hashp =3D (hash_table_vector_header *)(untag(h=
tabv));
natural
dnode,
@@ -983,9 +986,11 @@
the exception occurred.)
*/
=
-
+#ifdef WINDOWS
+#define get_time(when) /* FIXME */
+#else
#define get_time(when) gettimeofday(&when, NULL)
-
+#endif
=
=
#ifdef FORCE_DWS_MARK
Modified: trunk/source/lisp-kernel/lisp-debug.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/source/lisp-kernel/lisp-debug.c (original)
+++ trunk/source/lisp-kernel/lisp-debug.c Fri Feb 22 11:04:06 2008
@@ -868,7 +868,9 @@
#endif
}
=
+#ifndef WINDOWS
extern pid_t main_thread_pid;
+#endif
=
OSStatus
lisp_Debugger(ExceptionInformation *xp, =
@@ -904,7 +906,11 @@
}
fprintf(stderr, "? for help\n");
while (state =3D=3D debug_continue) {
+#ifdef WINDOWS
+ fprintf(stderr, "[%d] OpenMCL kernel debugger: ", 23 /* FIXME */);
+#else
fprintf(stderr, "[%d] OpenMCL kernel debugger: ", main_thread_pid);
+#endif
state =3D apply_debug_command(xp, readc(), info, why);
}
switch (state) {
Modified: trunk/source/lisp-kernel/pmcl-kernel.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/source/lisp-kernel/pmcl-kernel.c (original)
+++ trunk/source/lisp-kernel/pmcl-kernel.c Fri Feb 22 11:04:06 2008
@@ -1224,14 +1224,14 @@
}
}
=
+#ifdef WINDOWS
+void
+terminate_lisp()
+{
+}
+#else
pid_t main_thread_pid =3D (pid_t)0;
=
-#ifdef WINDOWS
-void
-terminate_lisp()
-{
-}
-#else
void
terminate_lisp()
{
@@ -1521,7 +1521,9 @@
}
#endif
=
+#ifndef WINDOWS
main_thread_pid =3D getpid();
+#endif
tcr_area_lock =3D (void *)new_recursive_lock();
=
program_name =3D argv[0];
Modified: trunk/source/lisp-kernel/win64/Makefile.nmake
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/source/lisp-kernel/win64/Makefile.nmake (original)
+++ trunk/source/lisp-kernel/win64/Makefile.nmake Fri Feb 22 11:04:06 2008
@@ -26,7 +26,7 @@
ASFLAGS =3D -f win64 -g cv8 -p gas
AS =3D yasm
M4FLAGS =3D -DWIN64 -DWINDOWS -DX86 -DX8664 -DHAVE_TLS -DEMUTLS
-CDEFINES =3D /I.. /DWIN64 /DWINDOWS /D_REENTRANT /DX86 /DX8664 /D_GNU_SOUR=
CE /DHAVE_TLS /DEMUTLS #-DDISABLE_EGC
+CDEFINES =3D /I.. /DWIN64 /DWINDOWS /D_REENTRANT /DX86 /DX8664 /D_GNU_SOUR=
CE /DHAVE_TLS /DEMUTLS /DVC #-DDISABLE_EGC
CDEBUG =3D /Zi
COPT =3D
LDFLAGS =3D
@@ -65,6 +65,7 @@
..\wx86cl64: $(KSPOBJ) $(KERNELOBJ) $(DEBUGOBJ) Makefile =
$(LD) $(LDFLAGS) /out:$@ $(KSPOBJ) $(KERNELOBJ) $(DEBUGOBJ) $(OSLIBS)
=
+cobjs: $(COBJ)
=
$(SPOBJ): $(SPINC)
$(ASMOBJ): $(SPINC)
Modified: trunk/source/lisp-kernel/x86-asmutils64.s
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/source/lisp-kernel/x86-asmutils64.s (original)
+++ trunk/source/lisp-kernel/x86-asmutils64.s Fri Feb 22 11:04:06 2008
@@ -132,12 +132,22 @@
__endif =
=
/* int cpuid (int code, int *pebx, int *pecx, int *pedx) */
-/* %rdi, %rsi, %rdx, %rcx */
+/* UNIX %rdi, %rsi, %rdx, %rcx */
+/* WIN %ecx, %rdx, %r8, %r9 */ =
_exportfn(C(cpuid))
+ __ifdef([WINDOWS])
+ __(pushq %r8) /* pecx */
+ __(pushq %r9) /* pedx */
+ __(movq %rdx, %rsi) /* pebx */
+ __(pushq %rbx) /* %rbx is non-volatile */
+ __(xorq %rax, %rax)
+ __(movl %ecx,%eax)
+ __else
__(pushq %rdx) /* pecx */
__(pushq %rcx) /* pedx */
__(pushq %rbx) /* %rbx is non-volatile */
__(movq %rdi,%rax)
+ __endif
__(xorl %ecx,%ecx)
__(cpuid)
__(movl %ebx,(%rsi))
Modified: trunk/source/lisp-kernel/x86-constants64.s
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- trunk/source/lisp-kernel/x86-constants64.s (original)
+++ trunk/source/lisp-kernel/x86-constants64.s Fri Feb 22 11:04:06 2008
@@ -19,6 +19,71 @@
/* do some unboxed arithmetic. */
=
=
+/*
+
+ Register usage in C calling conventions differ between
+ Darwin/Linux/FreeBSD (which use the AMD-defined ABI) and
+ Windows64 (which uses something else). The good news is that
+ Win64 did away with the cdecl/stdcall/fastcall madness, there
+ is only one ABI left. Here's a rundown.
+
+ AMD64^Wx86-64 ABI:
+ * Integer and pointer function arguments passed (from left to
+ right) in RDI, RSI, RDX, RCX, R8 and R9
+ * FP arguments are passed in XMM0..XMM7
+ * rest is passed on stack
+ * return value in RAX
+ * Callee must preserve RBP, RBX, R12..R15, MXCSR control bits
+ * On function entry, x87 mode and DF clear is assumed
+ * [RSP]..[RSP-128] must not be touched by signal handlers
+
+ Win64 ABI:
+ * Integer and pointers passed in RCX, RDX, R8, R9
+ * FP passed in XMM0..XMM3
+ * rest is passed on stack
+ * Return value in RAX or XMM0
+ * Caller (!) responsible for creating and cleaning stack space for
+ spilling integer registers
+ * Callee must preserve RBP, RBX, RSI, RDI, R12..R15, XMM6..XMM15
+
+ Both want their stack pointers to be 16 byte aligned on call,
+ equivalent to 8 byte offset after call due to pushed return address.
+ =
+ http://msdn2.microsoft.com/en-us/library/zthk2dkh(VS.80).aspx
+ http://www.tortall.net/projects/yasm/manual/html/objfmt-win64-exception.h=
tml
+ http://www.x86-64.org/documentation/abi.pdf
+
+
+ Lisp register usage:
+
+ Clozure CL renames the physical registers, giving them names
+ based on their usage. An overview:
+
+ imm0..imm2
+ temp0..temp2
+ save0..save3
+ arg_x, arg_y, arg_z
+ fn
+
+ On top of that, further mappings are defined:
+
+ fname, next_method_context: temp0
+ nargs: imm2
+ ra0: temp2
+ xfn: temp1
+ allocptr: temp0
+ stack_temp: mm7 =
+ =
+ x86-64 ABI mapping:
+ =
+ imm0..imm2: RAX, RDX, RCX
+ temp0..temp2: RBX, R9, R10
+ save0..save3: R15, R14, R12, R11
+ arg_x, arg_y, arg_z: R8, RDI, RSI
+ fn: R13 =
+ =
+*/
+ =
=
/* Redefining these standard register names - with the same _l, _w, _b suf=
fixes */
/* used in lispy symbolic names - allows us to play Stupid M4 Tricks in m=
acros */
More information about the Openmcl-cvs-notifications
mailing list