From fb6f41008e8e7d22008d4b97d9aea364d688d2ae Mon Sep 17 00:00:00 2001 From: David Lichteblau Date: Fri, 9 Nov 2012 14:25:42 +0100 Subject: [PATCH] LLP64: change UNSIGNED-LONG to UNSIGNED Adjust references to alien types within Lisp code for LLP64 platforms, replacing UNSIGNED-LONG with UNSIGNED. UNSIGNED-LONG is currently used when pointer-size values are desirable, but does not have that meaning on LLP64 platforms. Note: UNSIGNED does not in general refer to C's `unsigned'; rather it means (UNSIGNED N-WORD-BITS). UNSIGNED-LONG actually means `unsigned long'. The implication is that 32 <= sizeof(UNSIGNED-LONG) <= sizeof(UNSIGNED) <= 64 and not, as one might have expected, the other way around. Existing platforms were assuming these two types to be the same. Thanks to Anton Kovalenko. --- src/code/debug-int.lisp | 4 ++-- src/code/foreign-load.lisp | 2 +- src/code/interr.lisp | 2 +- src/code/room.lisp | 4 ++-- src/code/target-allocate.lisp | 4 ++-- src/code/target-thread.lisp | 18 +++++++++--------- src/code/unix.lisp | 2 +- src/code/x86-64-vm.lisp | 10 +++++----- src/compiler/generic/target-core.lisp | 2 +- 9 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/code/debug-int.lisp b/src/code/debug-int.lisp index 24cc07b..a39421c 100644 --- a/src/code/debug-int.lisp +++ b/src/code/debug-int.lisp @@ -3018,14 +3018,14 @@ register." ;;; which GC is disabled, so that Lisp doesn't move objects around ;;; that C is pointing to. (sb!alien:define-alien-routine "breakpoint_install" sb!alien:unsigned-int - (code-obj sb!alien:unsigned-long) + (code-obj sb!alien:unsigned) (pc-offset sb!alien:int)) ;;; This removes the break instruction and replaces the original ;;; instruction. You must call this in a context in which GC is disabled ;;; so Lisp doesn't move objects around that C is pointing to. (sb!alien:define-alien-routine "breakpoint_remove" sb!alien:void - (code-obj sb!alien:unsigned-long) + (code-obj sb!alien:unsigned) (pc-offset sb!alien:int) (old-inst sb!alien:unsigned-int)) diff --git a/src/code/foreign-load.lisp b/src/code/foreign-load.lisp index bbf99c1..185d958 100644 --- a/src/code/foreign-load.lisp +++ b/src/code/foreign-load.lisp @@ -26,7 +26,7 @@ (load-1-foreign)) (progn - (define-alien-variable undefined-alien-address unsigned-long) + (define-alien-variable undefined-alien-address unsigned) (defvar *runtime-dlhandle*)) (defvar *shared-objects*) diff --git a/src/code/interr.lisp b/src/code/interr.lisp index 3e0e9ae..82cc549 100644 --- a/src/code/interr.lisp +++ b/src/code/interr.lisp @@ -514,7 +514,7 @@ (error 'undefined-alien-function-error)) #!-win32 -(define-alien-variable current-memory-fault-address unsigned-long) +(define-alien-variable current-memory-fault-address unsigned) #!-win32 (defun memory-fault-error () diff --git a/src/code/room.lisp b/src/code/room.lisp index e38ce5e..8331d71 100644 --- a/src/code/room.lisp +++ b/src/code/room.lisp @@ -192,7 +192,7 @@ (progn (define-alien-type (struct page) (struct page - (start long) + (start signed) ;; On platforms with small enough GC pages, this field ;; will be a short. On platforms with larger ones, it'll ;; be an int. @@ -204,7 +204,7 @@ (flags (unsigned 8)) (gen (signed 8)))) (declaim (inline find-page-index)) - (define-alien-routine "find_page_index" long (index long)) + (define-alien-routine "find_page_index" long (index signed)) (define-alien-variable "page_table" (* (struct page)))) ;;; Iterate over all the objects allocated in SPACE, calling FUN with diff --git a/src/code/target-allocate.lisp b/src/code/target-allocate.lisp index 702fe5e..40c6b0f 100644 --- a/src/code/target-allocate.lisp +++ b/src/code/target-allocate.lisp @@ -13,9 +13,9 @@ (sb!alien:define-alien-routine ("os_allocate" allocate-system-memory) system-area-pointer - (bytes sb!alien:unsigned-long)) + (bytes sb!alien:unsigned)) (sb!alien:define-alien-routine ("os_deallocate" deallocate-system-memory) sb!alien:void (addr system-area-pointer) - (bytes sb!alien:unsigned-long)) + (bytes sb!alien:unsigned)) diff --git a/src/code/target-thread.lisp b/src/code/target-thread.lisp index 773fe9c..8948d3d 100644 --- a/src/code/target-thread.lisp +++ b/src/code/target-thread.lisp @@ -347,12 +347,12 @@ See also: RETURN-FROM-THREAD and SB-EXT:EXIT." (define-alien-routine "kill_safely" integer - (os-thread #!-alpha unsigned-long #!+alpha unsigned-int) + (os-thread #!-alpha unsigned #!+alpha unsigned-int) (signal int)) (define-alien-routine "wake_thread" integer - (os-thread #!-alpha unsigned-long #!+alpha unsigned-int)) + (os-thread unsigned)) #!+sb-thread (progn @@ -361,13 +361,13 @@ See also: RETURN-FROM-THREAD and SB-EXT:EXIT." ;; that on Linux it's a pid, but it might not be on posix thread ;; implementations. (define-alien-routine ("create_thread" %create-thread) - unsigned-long (lisp-fun-address unsigned-long)) + unsigned (lisp-fun-address unsigned)) (declaim (inline %block-deferrable-signals)) (define-alien-routine ("block_deferrable_signals" %block-deferrable-signals) void - (where sb!alien:unsigned-long) - (old sb!alien:unsigned-long)) + (where unsigned) + (old unsigned)) (defun block-deferrable-signals () (%block-deferrable-signals 0 0)) @@ -376,16 +376,16 @@ See also: RETURN-FROM-THREAD and SB-EXT:EXIT." (progn (declaim (inline futex-wait %futex-wait futex-wake)) - (define-alien-routine ("futex_wait" %futex-wait) - int (word unsigned-long) (old-value unsigned-long) - (to-sec long) (to-usec unsigned-long)) + (define-alien-routine ("futex_wait" %futex-wait) int + (word unsigned) (old-value unsigned) + (to-sec long) (to-usec unsigned-long)) (defun futex-wait (word old to-sec to-usec) (with-interrupts (%futex-wait word old to-sec to-usec))) (define-alien-routine "futex_wake" - int (word unsigned-long) (n unsigned-long)))) + int (word unsigned) (n unsigned-long)))) ;;; used by debug-int.lisp to access interrupt contexts #!-(or sb-fluid sb-thread) (declaim (inline sb!vm::current-thread-offset-sap)) diff --git a/src/code/unix.lisp b/src/code/unix.lisp index 23c1c8d..9572a22 100644 --- a/src/code/unix.lisp +++ b/src/code/unix.lisp @@ -136,7 +136,7 @@ corresponds to NAME, or NIL if there is none." ;;; is not extreme enough, since it doesn't need to be blindingly ;;; fast: we can just implement those functions in C as a wrapper ;;; layer. -(define-alien-type fd-mask unsigned-long) +(define-alien-type fd-mask unsigned) (define-alien-type nil (struct fd-set diff --git a/src/code/x86-64-vm.lisp b/src/code/x86-64-vm.lisp index 337e787..2706a42 100644 --- a/src/code/x86-64-vm.lisp +++ b/src/code/x86-64-vm.lisp @@ -89,7 +89,7 @@ ;;;; negligible. (declaim (inline context-pc-addr)) -(define-alien-routine ("os_context_pc_addr" context-pc-addr) (* unsigned-long) +(define-alien-routine ("os_context_pc_addr" context-pc-addr) (* unsigned) ;; (Note: Just as in CONTEXT-REGISTER-ADDR, we intentionally use an ;; 'unsigned *' interpretation for the 32-bit word passed to us by ;; the C code, even though the C code may think it's an 'int *'.) @@ -99,12 +99,12 @@ (defun context-pc (context) (declare (type (alien (* os-context-t)) context)) (let ((addr (context-pc-addr context))) - (declare (type (alien (* unsigned-long)) addr)) + (declare (type (alien (* unsigned)) addr)) (int-sap (deref addr)))) (declaim (inline context-register-addr)) (define-alien-routine ("os_context_register_addr" context-register-addr) - (* unsigned-long) + (* unsigned) ;; (Note the mismatch here between the 'int *' value that the C code ;; may think it's giving us and the 'unsigned *' value that we ;; receive. It's intentional: the C header files may think of @@ -118,13 +118,13 @@ (defun context-register (context index) (declare (type (alien (* os-context-t)) context)) (let ((addr (context-register-addr context index))) - (declare (type (alien (* unsigned-long)) addr)) + (declare (type (alien (* unsigned)) addr)) (deref addr))) (defun %set-context-register (context index new) (declare (type (alien (* os-context-t)) context)) (let ((addr (context-register-addr context index))) - (declare (type (alien (* unsigned-long)) addr)) + (declare (type (alien (* unsigned)) addr)) (setf (deref addr) new))) ;;; This is like CONTEXT-REGISTER, but returns the value of a float diff --git a/src/compiler/generic/target-core.lisp b/src/compiler/generic/target-core.lisp index fddd407..55808d8 100644 --- a/src/compiler/generic/target-core.lisp +++ b/src/compiler/generic/target-core.lisp @@ -22,7 +22,7 @@ #!+gencgc (without-gcing (%make-lisp-obj - (alien-funcall (extern-alien "alloc_code_object" (function unsigned-long unsigned unsigned)) + (alien-funcall (extern-alien "alloc_code_object" (function unsigned unsigned unsigned)) boxed unboxed))) #!-gencgc (%primitive allocate-code-object boxed unboxed)) -- 1.7.10.4