static sexp sexp_make_pollfds (sexp ctx) { sexp res = sexp_alloc_tagged(ctx, sexp_sizeof_pollfds, sexp_unbox_fixnum(sexp_global(ctx, SEXP_G_THREADS_POLLFDS_ID))); sexp_pollfds_fds(res) = malloc(SEXP_INIT_POLLFDS_MAX_FDS * sizeof(struct pollfd)); sexp_pollfds_num_fds(res) = 0; sexp_pollfds_max_fds(res) = SEXP_INIT_POLLFDS_MAX_FDS; return res; }
sexp sexp_make_bignum (sexp ctx, sexp_uint_t len) { sexp_uint_t size = sexp_sizeof(bignum) + len*sizeof(sexp_uint_t); sexp res = sexp_alloc_tagged(ctx, size, SEXP_BIGNUM); sexp_bignum_length(res) = len; sexp_bignum_sign(res) = 1; return res; }
static sexp sexp_make_pollfds (sexp ctx) { sexp res = sexp_alloc_tagged(ctx, sexp_sizeof_pollfds, sexp_pollfds_id); sexp_pollfds_fds(res) = malloc(SEXP_INIT_POLLFDS_MAX_FDS * sizeof(struct pollfd)); sexp_pollfds_num_fds(res) = 0; sexp_pollfds_max_fds(res) = SEXP_INIT_POLLFDS_MAX_FDS; return res; }
static sexp sexp_make_random_source (sexp ctx, sexp self, sexp_sint_t n) { sexp res; sexp_gc_var1(state); sexp_gc_preserve1(ctx, state); state = sexp_make_string(ctx, STATE_SIZE, SEXP_UNDEF); res = sexp_alloc_tagged(ctx, sexp_sizeof_random, rs_type_id); if (sexp_exceptionp(res)) return res; sexp_random_state(res) = state; sexp_random_init(res, 1); sexp_gc_release1(ctx); return res; }
static sexp sexp_make_timeval_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg0, sexp arg1) { struct timeval* r; sexp_gc_var1(res); sexp_gc_preserve1(ctx, res); res = sexp_alloc_tagged(ctx, sexp_sizeof(cpointer), sexp_unbox_fixnum(sexp_opcode_return_type(self))); sexp_cpointer_value(res) = calloc(1, sizeof(struct timeval)); r = (struct timeval*) sexp_cpointer_value(res); memset(r, 0, sizeof(struct timeval)); sexp_freep(res) = 1; r->tv_sec = sexp_unshift_epoch(sexp_uint_value(arg0)); r->tv_usec = sexp_sint_value(arg1); sexp_gc_release1(ctx); return res; }
sexp sexp_copy_bignum (sexp ctx, sexp dst, sexp a, sexp_uint_t len0) { sexp_uint_t len = (len0 > 0) ? len0 : sexp_bignum_length(a), size; size = sexp_sizeof(bignum) + len*sizeof(sexp_uint_t); if (! dst || sexp_bignum_length(dst) < len) { dst = sexp_alloc_tagged(ctx, size, SEXP_BIGNUM); memmove(dst, a, size); sexp_bignum_length(dst) = len; } else { memset(dst->value.bignum.data, 0, sexp_bignum_length(dst)*sizeof(sexp_uint_t)); memmove(dst->value.bignum.data, a->value.bignum.data, sexp_bignum_length(a)*sizeof(sexp_uint_t)); } return dst; }
static sexp sexp_make_tm_stub (sexp ctx, sexp self, sexp_sint_t n, sexp arg0, sexp arg1, sexp arg2, sexp arg3, sexp arg4, sexp arg5, sexp arg6) { struct tm* r; sexp_gc_var1(res); sexp_gc_preserve1(ctx, res); res = sexp_alloc_tagged(ctx, sexp_sizeof(cpointer), sexp_unbox_fixnum(sexp_opcode_return_type(self))); sexp_cpointer_value(res) = calloc(1, sizeof(struct tm)); r = (struct tm*) sexp_cpointer_value(res); memset(r, 0, sizeof(struct tm)); sexp_freep(res) = 1; r->tm_sec = sexp_sint_value(arg0); r->tm_min = sexp_sint_value(arg1); r->tm_hour = sexp_sint_value(arg2); r->tm_mday = sexp_sint_value(arg3); r->tm_mon = sexp_sint_value(arg4); r->tm_year = sexp_sint_value(arg5); r->tm_isdst = sexp_sint_value(arg6); sexp_gc_release1(ctx); return res; }
static sexp sexp_make_random_source (sexp ctx, sexp self, sexp_sint_t n) { sexp res; res = sexp_alloc_tagged(ctx, sexp_sizeof_random, rs_type_id); *sexp_random_data(res) = 1; return res; }