Does CFFI contain a Lisp type which represents the machine's word size?
I guess it could be defined as
(deftype word-size () `(unsigned-byte ,(* 8 (foreign-type-size :long))))
Are there any caveats? E.g. what about a 32bit Lisp implementation on a 64bit architecture?
Perhaps the type should rather be defined in each backend.
-T.
In article tcr-C05AC2.17212025102010@news.gmane.org, Tobias C Rittweiler tcr@freebits.de wrote:
Does CFFI contain a Lisp type which represents the machine's word size?
I guess it could be defined as
(deftype word-size () `(unsigned-byte ,(* 8 (foreign-type-size :long))))
Are there any caveats? E.g. what about a 32bit Lisp implementation on a 64bit architecture?
Perhaps the type should rather be defined in each backend.
Clarification:
I'm concerned about the 32bit Lisp on 64bit architecture issue, because for my purposes I'd like
(make-pointer (the word-size X))
never signal a type error.
-T.
Are there any caveats?
:long may be not of a mahine word size on windows, for example. CFFI, unfortunatly, does not have a :size-t or similiar type at the moment.
But, using trivial-features library(which is already used by cffi), on x86[-64] platform you could define it like this: (defctype :size-t #+x86-64 :uint64 #+x86 :uint32) have no idea about other platforms, however
On Mon, 25 Oct 2010 17:21:20 +0200, Tobias C Rittweiler said:
Does CFFI contain a Lisp type which represents the machine's word size?
I guess it could be defined as
(deftype word-size () `(unsigned-byte ,(* 8 (foreign-type-size :long))))
Using :pointer instead of :long would be better (long is 32-bit on 64-bit Windows).
Are there any caveats? E.g. what about a 32bit Lisp implementation on a 64bit architecture?
That should be OK in general, because almost all 64-bit OSes run 32-bit programs in a 32-bit address space (i.e. as if the OS is 32-bit).
__Martin