On this page:
list->cblock
vector->cblock
vector->cpointer
flvector->cpointer
saved-errno
lookup-errno
cast
cblock->list
cblock->vector

6 Miscellaneous Support

procedure

(list->cblock lst type)  any

  lst : list?
  type : ctype?
Allocates a memory block of an appropriate size, and initializes it using values from lst and the given type. The lst must hold values that can all be converted to C values according to the given type.

procedure

(vector->cblock vec type)  any

  vec : vector?
  type : type?
Like list->cblock, but for Racket vectors.

procedure

(vector->cpointer vec)  cpointer?

  vec : vector?
Returns a pointer to an array of _scheme values, which is the internal representation of vec.

procedure

(flvector->cpointer flvec)  cpointer?

  flvec : flvector?
Returns a pointer to an array of _double values, which is the internal representation of flvec.

procedure

(saved-errno)  exact-integer?

Returns the value most recently saved (in the current thread) after a foreign call with a non-#f #:save-errno option (see _fun and _cprocedure).

procedure

(lookup-errno sym)  exact-integer?

  sym : (or/c 'EINTR 'EEXIST 'EAGAIN)
Returns a platform-specific value corresponding to a Posix errno symbol. The set of supported symbols is likely to expand in the future.

procedure

(cast v from-type to-type)  any/c

  v : any/c
  from-type : ctype?
  to-type : ctype?
Converts v from a value matching from-type to a value matching to-type, where (ctype-sizeof from-type) matches (ctype-sizeof to-type).

The conversion is equivalent to

(let ([p (malloc from-type)])
  (ptr-set! p from-type v)
  (ptr-ref p to-type))

Beware of potential pitfalls with cast:

procedure

(cblock->list cblock type length)  list?

  cblock : any/c
  type : ctype?
  length : exact-nonnegative-integer?
Converts C cblock, which is a vector of types, to a Racket list. The arguments are the same as in the list->cblock. The length must be specified because there is no way to know where the block ends.

procedure

(cblock->vector cblock type length)  vector?

  cblock : any/c
  type : ctype?
  length : exact-nonnegative-integer?
Like cblock->vector, but for Racket vectors.