LLP64: change UNSIGNED-LONG to UNSIGNED
authorDavid Lichteblau <david@lichteblau.com>
Fri, 9 Nov 2012 13:25:42 +0000 (14:25 +0100)
committerDavid Lichteblau <david@lichteblau.com>
Tue, 20 Nov 2012 14:02:05 +0000 (15:02 +0100)
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
src/code/foreign-load.lisp
src/code/interr.lisp
src/code/room.lisp
src/code/target-allocate.lisp
src/code/target-thread.lisp
src/code/unix.lisp
src/code/x86-64-vm.lisp
src/compiler/generic/target-core.lisp

index 24cc07b..a39421c 100644 (file)
@@ -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))
 
index bbf99c1..185d958 100644 (file)
@@ -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*)
index 3e0e9ae..82cc549 100644 (file)
   (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 ()
index e38ce5e..8331d71 100644 (file)
 (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.
               (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
index 702fe5e..40c6b0f 100644 (file)
@@ -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))
index 773fe9c..8948d3d 100644 (file)
@@ -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))
index 23c1c8d..9572a22 100644 (file)
@@ -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
index 337e787..2706a42 100644 (file)
@@ -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 *'.)
 (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
 (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
index fddd407..55808d8 100644 (file)
@@ -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))