;;;; object-uword-ref.scm ;;;; Kon Lovett, Mar '20 (cond-expand (64bit (define-constant WORD-SIZE (/ 64 8)) ) (else (define-constant WORD-SIZE (/ 32 8)) ) ) (: blob-word-ref (blob fixnum --> integer)) ;; ;NOTE datum allocation on "word" boundary (at least) ; ;NOTE `byts' type is "weaker" here than the Scheme type, `blob' only, mainly due to ;ease of implementation. ; (cond-expand (64bit (define blob-word-ref (foreign-lambda* unsigned-integer64 (((nonnull-scheme-pointer unsigned-byte) byts) (unsigned-integer64 off)) " return( *(uint64_t *)(&byts[off]) );")) ) (else (define blob-word-ref (foreign-lambda* unsigned-integer32 (((nonnull-scheme-pointer unsigned-byte) byts) (unsigned-integer32 off)) " return( *(uint32_t *)(&byts[off]) );")) ) ) (define-constant C_WORD_SIZE WORD-SIZE) (define-inline (object-uword-ref proc #!optional (idx 0)) ;skip over C_WORD header (blob-word-ref (object->pointer proc) (* C_WORD_SIZE (add1 idx))) )