racket/racket/collects/racket/fixnum.rkt
Matthew Flatt 128892c996 add fx{+,-,*,lshift}/wraparound
Expose machine-level operations that stay within the fixnum range,
which can be useful for things like hash-code computations where it's
ok to just lose bits. Operations like `unsafe-fx+` turn out to do that
already in the current implementation, but with no guarantee (and with
no checking of arguments).

For Racket BC, before this commit, JIT-inlined `fxlshift` incorrectly
handled a negative second argument like `arithmetic-shift` instead of
erroring.
2020-11-18 17:39:18 -07:00

36 lines
987 B
Racket

#lang racket/base
(require '#%flfxnum
"private/vector-wraps.rkt"
"private/fixnum.rkt"
"unsafe/ops.rkt"
(for-syntax racket/base))
(provide fx->fl fl->fx
fxabs
fx+ fx- fx*
fx+/wraparound fx-/wraparound fx*/wraparound
fxquotient fxremainder fxmodulo
fxand fxior fxxor
fxnot fxrshift fxlshift fxlshift/wraparound
fx>= fx> fx= fx< fx<=
fxmin fxmax
fixnum-for-every-system?
fxvector? fxvector make-fxvector
shared-fxvector make-shared-fxvector
fxvector-length fxvector-ref fxvector-set!
fxvector-copy
in-fxvector for/fxvector for*/fxvector)
(define-vector-wraps "fxvector"
"fixnum?" fixnum?
fxvector? fxvector-length fxvector-ref fxvector-set! make-fxvector
unsafe-fxvector-ref unsafe-fxvector-set! unsafe-fxvector-length
in-fxvector*
in-fxvector
for/fxvector
for*/fxvector
fxvector-copy
0
check-fxvector)