Add _intptr etc; closes PR11311.

This commit is contained in:
Eli Barzilay 2010-10-12 15:56:49 -04:00
parent b3cfbe77c9
commit 615d8f1329
2 changed files with 29 additions and 25 deletions

View File

@ -45,42 +45,40 @@
(define* _uword _uint16)
(define* _sword _int16)
;; _short etc is a convenient name for whatever is the compiler's `short'
;; (_short is signed)
(provide _short _ushort _sshort)
(define-values (_short _ushort _sshort)
(case (compiler-sizeof 'short)
[(2) (values _int16 _uint16 _int16)]
[(4) (values _int32 _uint32 _int32)]
[else (error 'foreign "internal error: bad compiler size for `short'")]))
;; _int etc is a convenient name for whatever is the compiler's `int'
;; (_int is signed)
(provide _int _uint _sint)
(define-values (_int _uint _sint)
;; utility for the next few definitions
(define (sizeof->3ints c-type)
(case (compiler-sizeof 'int)
[(2) (values _int16 _uint16 _int16)]
[(4) (values _int32 _uint32 _int32)]
[(8) (values _int64 _uint64 _int64)]
[else (error 'foreign "internal error: bad compiler size for `int'")]))
[else (error 'foreign "internal error: bad compiler size for `~s'"
c-type)]))
;; _short etc is a convenient name for whatever is the compiler's `short'
;; (_short is signed)
(provide _short _ushort _sshort)
(define-values (_short _ushort _sshort) (sizeof->3ints 'short))
;; _int etc is a convenient name for whatever is the compiler's `int'
;; (_int is signed)
(provide _int _uint _sint)
(define-values (_int _uint _sint) (sizeof->3ints 'int))
;; _long etc is a convenient name for whatever is the compiler's `long'
;; (_long is signed)
(provide _long _ulong _slong)
(define-values (_long _ulong _slong)
(case (compiler-sizeof 'long)
[(4) (values _int32 _uint32 _int32)]
[(8) (values _int64 _uint64 _int64)]
[else (error 'foreign "internal error: bad compiler size for `long'")]))
(define-values (_long _ulong _slong) (sizeof->3ints 'long))
;; _llong etc is a convenient name for whatever is the compiler's `long long'
;; (_llong is signed)
(provide _llong _ullong _sllong)
(define-values (_llong _ullong _sllong)
(case (compiler-sizeof '(long long))
[(4) (values _int32 _uint32 _int32)]
[(8) (values _int64 _uint64 _int64)]
[else (error 'foreign "internal error: bad compiler size for `llong'")]))
(define-values (_llong _ullong _sllong) (sizeof->3ints '(long long)))
;; _intptr etc is a convenient name for whatever is the integer
;; equivalent of the compiler's pointer (see `intptr_t') (_intptr is
;; signed)
(provide _intptr _uintptr _sintptr)
(define-values (_intptr _uintptr _sintptr) (sizeof->3ints '(void *)))
;; ----------------------------------------------------------------------------
;; Getting and setting library objects

View File

@ -104,7 +104,13 @@ respectively; the ones with no prefix are signed.}
[_uword ctype?]
[_long ctype?]
[_slong ctype?]
[_ulong ctype?])]{
[_ulong ctype?]
[_llong ctype?]
[_sllong ctype?]
[_ullong ctype?]
[_intptr ctype?]
[_sintptr ctype?]
[_uintptr ctype?])]{
Aliases for basic integer types. The @scheme[_byte] aliases correspond
to @scheme[_int8]. The @scheme[_short] and @scheme[_word] aliases