mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-07-05 09:10:18 +02:00
Convert scm_gc_malloc* calls to scm_allocate*
* libguile/arrays.c: * libguile/bitvectors.c: * libguile/bytevectors.c: * libguile/chooks.c: * libguile/continuations.c: * libguile/control.c: * libguile/dynstack.c: * libguile/ephemerons.c: * libguile/filesys.c: * libguile/foreign.c: * libguile/fports.c: * libguile/frames.c: * libguile/gsubr.c: * libguile/hashtab.c: * libguile/i18n.c: * libguile/integers.c: * libguile/intrinsics.c: * libguile/load.c: * libguile/loader.c: * libguile/macros.c: * libguile/numbers.c: * libguile/options.c: * libguile/ports.c: * libguile/programs.h: * libguile/random.c: * libguile/read.c: * libguile/regex-posix.c: * libguile/smob.c: * libguile/srfi-14.c: * libguile/strings.c: * libguile/struct.c: * libguile/threads.c: * libguile/threads.h: * libguile/values.c: * libguile/vm.c: Convert all calls to scm_gc_malloc_pointerless to scm_allocate_pointerless. Convert scm_gc_malloc to either scm_allocate_tagged or scm_allocate_sloppy, depending on whether the value can be precisely traced or not.
This commit is contained in:
parent
290a57b1b0
commit
f2ad6525e6
35 changed files with 126 additions and 102 deletions
|
@ -486,9 +486,10 @@ SCM_DEFINE (scm_shared_array_increments, "shared-array-increments", 1, 0, 0,
|
||||||
struct scm_array *
|
struct scm_array *
|
||||||
scm_i_make_array (SCM v, size_t base, int ndim)
|
scm_i_make_array (SCM v, size_t base, int ndim)
|
||||||
{
|
{
|
||||||
struct scm_array *array = scm_gc_malloc (sizeof (struct scm_array)
|
struct scm_array *array =
|
||||||
+ ndim * sizeof (scm_t_array_dim),
|
scm_allocate_tagged (SCM_I_CURRENT_THREAD,
|
||||||
"array");
|
sizeof (struct scm_array)
|
||||||
|
+ ndim * sizeof (scm_t_array_dim));
|
||||||
/* FIXME: Shift ndim by something more reasonable instead. */
|
/* FIXME: Shift ndim by something more reasonable instead. */
|
||||||
array->tag_and_ndims = scm_tc7_array | (ndim << 16);
|
array->tag_and_ndims = scm_tc7_array | (ndim << 16);
|
||||||
array->vector = v;
|
array->vector = v;
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
#include "pairs.h"
|
#include "pairs.h"
|
||||||
#include "ports.h"
|
#include "ports.h"
|
||||||
#include "srfi-4.h"
|
#include "srfi-4.h"
|
||||||
|
#include "threads.h"
|
||||||
|
|
||||||
#include "bitvectors.h"
|
#include "bitvectors.h"
|
||||||
|
|
||||||
|
@ -199,9 +200,9 @@ make_bitvector (size_t len, int fill)
|
||||||
size_t word_len = bit_count_to_word_count (len);
|
size_t word_len = bit_count_to_word_count (len);
|
||||||
struct scm_bitvector *bv;
|
struct scm_bitvector *bv;
|
||||||
|
|
||||||
bv = scm_gc_malloc_pointerless (sizeof (struct scm_bitvector)
|
bv = scm_allocate_pointerless (SCM_I_CURRENT_THREAD,
|
||||||
+ sizeof (scm_t_bits) * word_len,
|
sizeof (struct scm_bitvector)
|
||||||
"bitvector");
|
+ sizeof (scm_t_bits) * word_len);
|
||||||
|
|
||||||
bv->tag_and_flags = scm_tc7_bitvector;
|
bv->tag_and_flags = scm_tc7_bitvector;
|
||||||
bv->length = len;
|
bv->length = len;
|
||||||
|
|
|
@ -56,6 +56,7 @@
|
||||||
#include "srfi-4.h"
|
#include "srfi-4.h"
|
||||||
#include "strings.h"
|
#include "strings.h"
|
||||||
#include "symbols.h"
|
#include "symbols.h"
|
||||||
|
#include "threads.h"
|
||||||
#include "uniform.h"
|
#include "uniform.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
|
@ -232,8 +233,8 @@ make_bytevector (size_t len, scm_t_array_element_type element_type)
|
||||||
|
|
||||||
size_t c_len = len * bytes_per_elt;
|
size_t c_len = len * bytes_per_elt;
|
||||||
struct scm_bytevector *bv =
|
struct scm_bytevector *bv =
|
||||||
scm_gc_malloc_pointerless (sizeof (struct scm_bytevector) + c_len,
|
scm_allocate_pointerless (SCM_I_CURRENT_THREAD,
|
||||||
"bytevector");
|
sizeof (struct scm_bytevector) + c_len);
|
||||||
|
|
||||||
scm_t_bits flags = SCM_F_BYTEVECTOR_CONTIGUOUS;
|
scm_t_bits flags = SCM_F_BYTEVECTOR_CONTIGUOUS;
|
||||||
bv->tag_flags_and_element_type = make_bytevector_tag (flags, element_type);
|
bv->tag_flags_and_element_type = make_bytevector_tag (flags, element_type);
|
||||||
|
@ -258,7 +259,8 @@ make_bytevector_from_buffer (size_t len, void *contents,
|
||||||
size_t bytes_per_elt = scm_i_array_element_type_sizes[element_type]/8;
|
size_t bytes_per_elt = scm_i_array_element_type_sizes[element_type]/8;
|
||||||
size_t c_len = len * bytes_per_elt;
|
size_t c_len = len * bytes_per_elt;
|
||||||
struct scm_bytevector *bv =
|
struct scm_bytevector *bv =
|
||||||
scm_gc_malloc (sizeof (struct scm_bytevector), "bytevector");
|
scm_allocate_tagged (SCM_I_CURRENT_THREAD,
|
||||||
|
sizeof (struct scm_bytevector));
|
||||||
|
|
||||||
scm_t_bits flags = is_immutable ? SCM_F_BYTEVECTOR_IMMUTABLE : 0;
|
scm_t_bits flags = is_immutable ? SCM_F_BYTEVECTOR_IMMUTABLE : 0;
|
||||||
bv->tag_flags_and_element_type = make_bytevector_tag (flags, element_type);
|
bv->tag_flags_and_element_type = make_bytevector_tag (flags, element_type);
|
||||||
|
@ -286,11 +288,12 @@ scm_i_make_typed_bytevector (size_t len, scm_t_array_element_type element_type)
|
||||||
|
|
||||||
/* Return a bytevector of size LEN made up of CONTENTS. The area
|
/* Return a bytevector of size LEN made up of CONTENTS. The area
|
||||||
pointed to by CONTENTS must be protected from GC somehow: either
|
pointed to by CONTENTS must be protected from GC somehow: either
|
||||||
because it was allocated using `scm_gc_malloc ()', or because it is
|
because it is itself GC-managed, or because it is part of PARENT. */
|
||||||
part of PARENT. */
|
|
||||||
SCM
|
SCM
|
||||||
scm_c_take_gc_bytevector (signed char *contents, size_t len, SCM parent)
|
scm_c_take_gc_bytevector (signed char *contents, size_t len, SCM parent)
|
||||||
{
|
{
|
||||||
|
/* FIXME: If contents is an interior pointer to a GC-managed object,
|
||||||
|
we should gc_pin_object() on that parent object! */
|
||||||
return scm_from_bytevector
|
return scm_from_bytevector
|
||||||
(make_bytevector_from_buffer (len, contents, SCM_ARRAY_ELEMENT_TYPE_VU8,
|
(make_bytevector_from_buffer (len, contents, SCM_ARRAY_ELEMENT_TYPE_VU8,
|
||||||
parent, 0));
|
parent, 0));
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright 1995-1996,1998-2001,2003,2006,2008-2009,2011,2018
|
/* Copyright 1995-1996,1998-2001,2003,2006,2008-2009,2011,2018,2025
|
||||||
Free Software Foundation, Inc.
|
Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of Guile.
|
This file is part of Guile.
|
||||||
|
@ -28,6 +28,7 @@
|
||||||
#include "gc.h"
|
#include "gc.h"
|
||||||
|
|
||||||
#include "chooks.h"
|
#include "chooks.h"
|
||||||
|
#include "threads.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,9 +36,6 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Hint for `scm_gc_malloc ()' and friends. */
|
|
||||||
static const char hook_entry_gc_hint[] = "hook entry";
|
|
||||||
|
|
||||||
void
|
void
|
||||||
scm_c_hook_init (scm_t_c_hook *hook, void *hook_data, scm_t_c_hook_type type)
|
scm_c_hook_init (scm_t_c_hook *hook, void *hook_data, scm_t_c_hook_type type)
|
||||||
{
|
{
|
||||||
|
@ -55,7 +53,8 @@ scm_c_hook_add (scm_t_c_hook *hook,
|
||||||
scm_t_c_hook_entry *entry;
|
scm_t_c_hook_entry *entry;
|
||||||
scm_t_c_hook_entry **loc = &hook->first;
|
scm_t_c_hook_entry **loc = &hook->first;
|
||||||
|
|
||||||
entry = scm_gc_malloc (sizeof (scm_t_c_hook_entry), hook_entry_gc_hint);
|
entry = scm_allocate_sloppy (SCM_I_CURRENT_THREAD,
|
||||||
|
sizeof (scm_t_c_hook_entry));
|
||||||
if (appendp)
|
if (appendp)
|
||||||
while (*loc)
|
while (*loc)
|
||||||
loc = &(*loc)->next;
|
loc = &(*loc)->next;
|
||||||
|
|
|
@ -91,8 +91,8 @@ make_continuation_trampoline (struct scm_continuation *cont)
|
||||||
scm_t_bits tag = scm_tc7_program | (nfree << 16) | flags;
|
scm_t_bits tag = scm_tc7_program | (nfree << 16) | flags;
|
||||||
|
|
||||||
struct scm_program *ret =
|
struct scm_program *ret =
|
||||||
scm_gc_malloc (sizeof (struct scm_program) + nfree * sizeof(SCM),
|
scm_allocate_tagged (SCM_I_CURRENT_THREAD,
|
||||||
"foreign procedure");
|
sizeof (struct scm_program) + nfree * sizeof(SCM));
|
||||||
ret->tag_flags_and_free_variable_count = tag;
|
ret->tag_flags_and_free_variable_count = tag;
|
||||||
ret->code = goto_continuation_code.code;
|
ret->code = goto_continuation_code.code;
|
||||||
ret->free_variables[0] = scm_from_continuation (cont);
|
ret->free_variables[0] = scm_from_continuation (cont);
|
||||||
|
@ -173,8 +173,8 @@ capture_auxiliary_stack (scm_thread *thread, struct scm_continuation *continuati
|
||||||
continuation->auxiliary_stack_size =
|
continuation->auxiliary_stack_size =
|
||||||
top - (char *) thread->auxiliary_stack_base;
|
top - (char *) thread->auxiliary_stack_base;
|
||||||
continuation->auxiliary_stack =
|
continuation->auxiliary_stack =
|
||||||
scm_gc_malloc (continuation->auxiliary_stack_size,
|
scm_allocate_sloppy (SCM_I_CURRENT_THREAD,
|
||||||
"continuation auxiliary stack");
|
continuation->auxiliary_stack_size);
|
||||||
memcpy (continuation->auxiliary_stack, thread->auxiliary_stack_base,
|
memcpy (continuation->auxiliary_stack, thread->auxiliary_stack_base,
|
||||||
continuation->auxiliary_stack_size);
|
continuation->auxiliary_stack_size);
|
||||||
|
|
||||||
|
@ -199,9 +199,9 @@ scm_i_make_continuation (scm_thread *thread, struct scm_vm_cont *vm_cont)
|
||||||
SCM_FLUSH_REGISTER_WINDOWS;
|
SCM_FLUSH_REGISTER_WINDOWS;
|
||||||
long stack_size = scm_stack_size (thread->continuation_base);
|
long stack_size = scm_stack_size (thread->continuation_base);
|
||||||
struct scm_continuation *continuation =
|
struct scm_continuation *continuation =
|
||||||
scm_gc_malloc (sizeof (struct scm_continuation)
|
scm_allocate_tagged (SCM_I_CURRENT_THREAD,
|
||||||
+ stack_size * sizeof (SCM_STACKITEM),
|
sizeof (struct scm_continuation)
|
||||||
"continuation");
|
+ stack_size * sizeof (SCM_STACKITEM));
|
||||||
continuation->tag = scm_tc16_continuation;
|
continuation->tag = scm_tc16_continuation;
|
||||||
memcpy (continuation->jmpbuf, thread->vm.registers, sizeof (jmp_buf));
|
memcpy (continuation->jmpbuf, thread->vm.registers, sizeof (jmp_buf));
|
||||||
pin_conservative_roots (thread, continuation->jmpbuf, sizeof (jmp_buf));
|
pin_conservative_roots (thread, continuation->jmpbuf, sizeof (jmp_buf));
|
||||||
|
|
|
@ -98,8 +98,8 @@ scm_i_make_composable_continuation (SCM vmcont)
|
||||||
scm_t_bits tag = scm_tc7_program | (nfree << 16) | flags;
|
scm_t_bits tag = scm_tc7_program | (nfree << 16) | flags;
|
||||||
|
|
||||||
struct scm_program *ret =
|
struct scm_program *ret =
|
||||||
scm_gc_malloc (sizeof (struct scm_program) + nfree * sizeof(SCM),
|
scm_allocate_tagged (SCM_I_CURRENT_THREAD,
|
||||||
"foreign procedure");
|
sizeof (struct scm_program) + nfree * sizeof(SCM));
|
||||||
ret->tag_flags_and_free_variable_count = tag;
|
ret->tag_flags_and_free_variable_count = tag;
|
||||||
ret->code = compose_continuation_code.code;
|
ret->code = compose_continuation_code.code;
|
||||||
ret->free_variables[0] = vmcont;
|
ret->free_variables[0] = vmcont;
|
||||||
|
|
|
@ -384,7 +384,8 @@ scm_dynstack_capture (scm_t_dynstack *dynstack, scm_t_bits *item)
|
||||||
assert (item <= dynstack->top);
|
assert (item <= dynstack->top);
|
||||||
|
|
||||||
len = dynstack->top - item + SCM_DYNSTACK_HEADER_LEN;
|
len = dynstack->top - item + SCM_DYNSTACK_HEADER_LEN;
|
||||||
ret = scm_gc_malloc (sizeof (*ret) + len * sizeof(scm_t_bits), "dynstack");
|
ret = scm_allocate_tagged (SCM_I_CURRENT_THREAD,
|
||||||
|
sizeof (*ret) + len * sizeof(scm_t_bits));
|
||||||
ret->tag = scm_tc16_dynstack_slice;
|
ret->tag = scm_tc16_dynstack_slice;
|
||||||
ret->base = ret->inline_storage;
|
ret->base = ret->inline_storage;
|
||||||
ret->limit = ret->base + len;
|
ret->limit = ret->base + len;
|
||||||
|
|
|
@ -257,7 +257,8 @@ scm_c_make_ephemeron_table (size_t size)
|
||||||
{
|
{
|
||||||
size_t byte_size = sizeof (struct scm_ephemeron_table);
|
size_t byte_size = sizeof (struct scm_ephemeron_table);
|
||||||
byte_size += sizeof (struct gc_ephemeron*) * size;
|
byte_size += sizeof (struct gc_ephemeron*) * size;
|
||||||
struct scm_ephemeron_table *table = scm_gc_malloc (byte_size, NULL);
|
struct scm_ephemeron_table *table = scm_allocate_tagged (SCM_I_CURRENT_THREAD,
|
||||||
|
byte_size);
|
||||||
table->tag = scm_tc7_ephemeron_table;
|
table->tag = scm_tc7_ephemeron_table;
|
||||||
table->size = size;
|
table->size = size;
|
||||||
return table;
|
return table;
|
||||||
|
|
|
@ -2236,7 +2236,8 @@ SCM_DEFINE (scm_opendir, "opendir", 1, 0, 0,
|
||||||
"stream.")
|
"stream.")
|
||||||
#define FUNC_NAME s_scm_opendir
|
#define FUNC_NAME s_scm_opendir
|
||||||
{
|
{
|
||||||
struct scm_directory *d = scm_gc_malloc (sizeof (*d), "directory stream");
|
struct scm_directory *d = scm_allocate_tagged (SCM_I_CURRENT_THREAD,
|
||||||
|
sizeof (*d));
|
||||||
d->tag_and_flags = scm_tc16_directory | SCM_DIR_FLAG_OPEN;
|
d->tag_and_flags = scm_tc16_directory | SCM_DIR_FLAG_OPEN;
|
||||||
|
|
||||||
STRING_SYSCALL (dirname, c_dirname, d->ds = opendir (c_dirname));
|
STRING_SYSCALL (dirname, c_dirname, d->ds = opendir (c_dirname));
|
||||||
|
|
|
@ -820,7 +820,7 @@ make_cif (SCM return_type, SCM arg_types, const char *caller)
|
||||||
cif_len = (ROUND_UP (cif_len, alignof_type (ffi_type))
|
cif_len = (ROUND_UP (cif_len, alignof_type (ffi_type))
|
||||||
+ (nargs + n_struct_elts + 1)*sizeof(ffi_type));
|
+ (nargs + n_struct_elts + 1)*sizeof(ffi_type));
|
||||||
|
|
||||||
mem = scm_gc_malloc_pointerless (cif_len, "foreign");
|
mem = scm_allocate_pointerless (SCM_I_CURRENT_THREAD, cif_len);
|
||||||
/* ensure all the memory is initialized, even the holes */
|
/* ensure all the memory is initialized, even the holes */
|
||||||
memset (mem, 0, cif_len);
|
memset (mem, 0, cif_len);
|
||||||
cif = (ffi_cif *) mem;
|
cif = (ffi_cif *) mem;
|
||||||
|
@ -952,8 +952,8 @@ cif_to_procedure (SCM cif, SCM func_ptr, int with_errno)
|
||||||
c_cif = (ffi_cif *) SCM_POINTER_VALUE (cif);
|
c_cif = (ffi_cif *) SCM_POINTER_VALUE (cif);
|
||||||
|
|
||||||
struct scm_program *ret =
|
struct scm_program *ret =
|
||||||
scm_gc_malloc (sizeof (struct scm_program) + nfree * sizeof(SCM),
|
scm_allocate_tagged (SCM_I_CURRENT_THREAD,
|
||||||
"foreign procedure");
|
sizeof (struct scm_program) + nfree * sizeof(SCM));
|
||||||
ret->tag_flags_and_free_variable_count = tag;
|
ret->tag_flags_and_free_variable_count = tag;
|
||||||
ret->code = get_foreign_stub_code (c_cif->nargs, with_errno);
|
ret->code = get_foreign_stub_code (c_cif->nargs, with_errno);
|
||||||
ret->free_variables[0] = cif;
|
ret->free_variables[0] = cif;
|
||||||
|
@ -1136,7 +1136,7 @@ pack (const ffi_type * type, const void *loc, int return_value_p)
|
||||||
|
|
||||||
case FFI_TYPE_STRUCT:
|
case FFI_TYPE_STRUCT:
|
||||||
{
|
{
|
||||||
void *mem = scm_gc_malloc_pointerless (type->size, "foreign");
|
void *mem = scm_allocate_pointerless (SCM_I_CURRENT_THREAD, type->size);
|
||||||
memcpy (mem, loc, type->size);
|
memcpy (mem, loc, type->size);
|
||||||
return scm_from_pointer (mem, NULL);
|
return scm_from_pointer (mem, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -454,8 +454,8 @@ scm_i_fdes_to_port (int fdes, long mode_bits, SCM name, unsigned options)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fp = (scm_t_fport *) scm_gc_malloc_pointerless (sizeof (scm_t_fport),
|
fp = (scm_t_fport *) scm_allocate_pointerless (SCM_I_CURRENT_THREAD,
|
||||||
"file port");
|
sizeof (scm_t_fport));
|
||||||
fp->fdes = fdes;
|
fp->fdes = fdes;
|
||||||
fp->options = options;
|
fp->options = options;
|
||||||
fp->revealed = 0;
|
fp->revealed = 0;
|
||||||
|
|
|
@ -46,8 +46,8 @@
|
||||||
SCM
|
SCM
|
||||||
scm_c_make_frame (enum scm_vm_frame_kind kind, const struct scm_frame *frame)
|
scm_c_make_frame (enum scm_vm_frame_kind kind, const struct scm_frame *frame)
|
||||||
{
|
{
|
||||||
struct scm_vm_frame *p = scm_gc_malloc (sizeof (struct scm_vm_frame),
|
struct scm_vm_frame *p = scm_allocate_tagged (SCM_I_CURRENT_THREAD,
|
||||||
"vmframe");
|
sizeof (struct scm_vm_frame));
|
||||||
p->tag_and_flags = scm_tc7_frame | (kind << 8);
|
p->tag_and_flags = scm_tc7_frame | (kind << 8);
|
||||||
p->frame.stack_holder = frame->stack_holder;
|
p->frame.stack_holder = frame->stack_holder;
|
||||||
p->frame.fp_offset = frame->fp_offset;
|
p->frame.fp_offset = frame->fp_offset;
|
||||||
|
|
|
@ -344,7 +344,7 @@ scm_make_subr_from_code (struct scm_thread *thread, const uint32_t *code,
|
||||||
scm_t_bits program_flags, size_t nfree)
|
scm_t_bits program_flags, size_t nfree)
|
||||||
{
|
{
|
||||||
size_t bytes = sizeof(struct scm_program) + nfree * sizeof (SCM);
|
size_t bytes = sizeof(struct scm_program) + nfree * sizeof (SCM);
|
||||||
struct scm_program *proc = scm_inline_gc_malloc (thread, bytes);
|
struct scm_program *proc = scm_allocate_tagged (thread, bytes);
|
||||||
proc->tag_flags_and_free_variable_count =
|
proc->tag_flags_and_free_variable_count =
|
||||||
scm_tc7_program | program_flags | (nfree << 16);
|
scm_tc7_program | program_flags | (nfree << 16);
|
||||||
proc->code = code;
|
proc->code = code;
|
||||||
|
|
|
@ -507,7 +507,7 @@ make_hash_table (unsigned long k, const char *func_name)
|
||||||
|
|
||||||
vector = scm_c_make_vector (n, SCM_EOL);
|
vector = scm_c_make_vector (n, SCM_EOL);
|
||||||
|
|
||||||
t = scm_gc_malloc_pointerless (sizeof (*t), s_hashtable);
|
t = scm_allocate_pointerless (SCM_I_CURRENT_THREAD, sizeof (*t));
|
||||||
t->min_size_index = t->size_index = i;
|
t->min_size_index = t->size_index = i;
|
||||||
t->n_items = 0;
|
t->n_items = 0;
|
||||||
t->lower = 0;
|
t->lower = 0;
|
||||||
|
|
|
@ -339,7 +339,8 @@ SCM_DEFINE (scm_make_locale, "make-locale", 2, 1, 0,
|
||||||
scm_locale_error (FUNC_NAME, errno);
|
scm_locale_error (FUNC_NAME, errno);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct scm_locale *locale = scm_gc_malloc (sizeof (*locale), "locale");
|
struct scm_locale *locale = scm_allocate_tagged (SCM_I_CURRENT_THREAD,
|
||||||
|
sizeof (*locale));
|
||||||
locale->tag = scm_tc16_locale;
|
locale->tag = scm_tc16_locale;
|
||||||
locale->locale = c_locale;
|
locale->locale = c_locale;
|
||||||
scm_i_add_locale_finalizer (SCM_I_CURRENT_THREAD, scm_from_locale (locale));
|
scm_i_add_locale_finalizer (SCM_I_CURRENT_THREAD, scm_from_locale (locale));
|
||||||
|
@ -1479,7 +1480,8 @@ scm_init_i18n ()
|
||||||
/* XXX: We don't define it as `LC_GLOBAL_LOCALE' because of bugs as of
|
/* XXX: We don't define it as `LC_GLOBAL_LOCALE' because of bugs as of
|
||||||
glibc <= 2.11 not (yet) worked around by Gnulib. See
|
glibc <= 2.11 not (yet) worked around by Gnulib. See
|
||||||
http://sourceware.org/bugzilla/show_bug.cgi?id=11009 for details. */
|
http://sourceware.org/bugzilla/show_bug.cgi?id=11009 for details. */
|
||||||
struct scm_locale *locale = scm_gc_malloc (sizeof (*locale), "locale");
|
struct scm_locale *locale = scm_allocate_tagged (SCM_I_CURRENT_THREAD,
|
||||||
|
sizeof (*locale));
|
||||||
locale->tag = scm_tc16_locale;
|
locale->tag = scm_tc16_locale;
|
||||||
locale->locale = NULL;
|
locale->locale = NULL;
|
||||||
SCM_VARIABLE_SET (scm_global_locale, scm_from_locale (locale));
|
SCM_VARIABLE_SET (scm_global_locale, scm_from_locale (locale));
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include "boolean.h"
|
#include "boolean.h"
|
||||||
#include "numbers.h"
|
#include "numbers.h"
|
||||||
#include "strings.h"
|
#include "strings.h"
|
||||||
|
#include "threads.h"
|
||||||
|
|
||||||
#include "integers.h"
|
#include "integers.h"
|
||||||
|
|
||||||
|
@ -138,7 +139,7 @@ allocate_bignum (size_t nlimbs)
|
||||||
ASSERT (nlimbs <= NLIMBS_MAX);
|
ASSERT (nlimbs <= NLIMBS_MAX);
|
||||||
|
|
||||||
size_t size = sizeof (struct scm_bignum) + nlimbs * sizeof(mp_limb_t);
|
size_t size = sizeof (struct scm_bignum) + nlimbs * sizeof(mp_limb_t);
|
||||||
struct scm_bignum *z = scm_gc_malloc_pointerless (size, "bignum");
|
struct scm_bignum *z = scm_allocate_pointerless (SCM_I_CURRENT_THREAD, size);
|
||||||
|
|
||||||
z->tag = scm_tc16_big;
|
z->tag = scm_tc16_big;
|
||||||
z->size = nlimbs;
|
z->size = nlimbs;
|
||||||
|
|
|
@ -463,13 +463,14 @@ error_wrong_number_of_values (uint32_t expected)
|
||||||
static SCM
|
static SCM
|
||||||
allocate_words (scm_thread *thread, size_t n)
|
allocate_words (scm_thread *thread, size_t n)
|
||||||
{
|
{
|
||||||
return SCM_PACK_POINTER (scm_inline_gc_malloc_words (thread, n));
|
return SCM_PACK_POINTER (scm_inline_allocate_tagged (thread, n * sizeof(SCM)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static SCM
|
static SCM
|
||||||
allocate_pointerless_words (scm_thread *thread, size_t n)
|
allocate_pointerless_words (scm_thread *thread, size_t n)
|
||||||
{
|
{
|
||||||
return SCM_PACK_POINTER (scm_inline_gc_malloc_pointerless_words (thread, n));
|
return SCM_PACK_POINTER (scm_inline_allocate_pointerless (thread,
|
||||||
|
n * sizeof (SCM)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static SCM
|
static SCM
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright 1995-1996,1998-2001,2004,2006,2008-2019,2022
|
/* Copyright 1995-1996,1998-2001,2004,2006,2008-2019,2022,2025
|
||||||
Free Software Foundation, Inc.
|
Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of Guile.
|
This file is part of Guile.
|
||||||
|
@ -58,6 +58,7 @@
|
||||||
#include "strings.h"
|
#include "strings.h"
|
||||||
#include "strports.h"
|
#include "strports.h"
|
||||||
#include "symbols.h"
|
#include "symbols.h"
|
||||||
|
#include "threads.h"
|
||||||
#include "throw.h"
|
#include "throw.h"
|
||||||
#include "variable.h"
|
#include "variable.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
@ -429,7 +430,8 @@ stringbuf_grow (struct stringbuf *buf)
|
||||||
ptroff = buf->ptr - buf->buf;
|
ptroff = buf->ptr - buf->buf;
|
||||||
|
|
||||||
buf->buf_len *= 2;
|
buf->buf_len *= 2;
|
||||||
buf->buf = scm_gc_malloc_pointerless (buf->buf_len, "search-path");
|
buf->buf = scm_allocate_pointerless (SCM_I_CURRENT_THREAD,
|
||||||
|
buf->buf_len);
|
||||||
memcpy (buf->buf, prev_buf, prev_len);
|
memcpy (buf->buf, prev_buf, prev_len);
|
||||||
buf->ptr = buf->buf + ptroff;
|
buf->ptr = buf->buf + ptroff;
|
||||||
}
|
}
|
||||||
|
|
|
@ -698,9 +698,9 @@ register_elf (char *data, size_t len, char *frame_maps)
|
||||||
|
|
||||||
prev = mapped_elf_images;
|
prev = mapped_elf_images;
|
||||||
mapped_elf_images =
|
mapped_elf_images =
|
||||||
scm_gc_malloc_pointerless (sizeof (*mapped_elf_images)
|
scm_allocate_pointerless (SCM_I_CURRENT_THREAD,
|
||||||
* mapped_elf_images_allocated,
|
sizeof (*mapped_elf_images)
|
||||||
"mapped elf images");
|
* mapped_elf_images_allocated);
|
||||||
|
|
||||||
for (n = 0; n < mapped_elf_images_count; n++)
|
for (n = 0; n < mapped_elf_images_count; n++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include "procs.h"
|
#include "procs.h"
|
||||||
#include "random.h"
|
#include "random.h"
|
||||||
#include "symbols.h"
|
#include "symbols.h"
|
||||||
|
#include "threads.h"
|
||||||
#include "variable.h"
|
#include "variable.h"
|
||||||
|
|
||||||
#include "macros.h"
|
#include "macros.h"
|
||||||
|
@ -92,8 +93,8 @@ SCM
|
||||||
scm_i_make_primitive_syntax_transformer (const char *name,
|
scm_i_make_primitive_syntax_transformer (const char *name,
|
||||||
scm_t_macro_primitive fn)
|
scm_t_macro_primitive fn)
|
||||||
{
|
{
|
||||||
struct scm_syntax_transformer *tx = scm_gc_malloc (sizeof (*tx),
|
struct scm_syntax_transformer *tx =
|
||||||
"syntax transformer");
|
scm_allocate_tagged (SCM_I_CURRENT_THREAD, sizeof (*tx));
|
||||||
tx->tag = scm_tc16_syntax_transformer;
|
tx->tag = scm_tc16_syntax_transformer;
|
||||||
tx->primitive = fn;
|
tx->primitive = fn;
|
||||||
tx->name = scm_from_utf8_symbol (name);
|
tx->name = scm_from_utf8_symbol (name);
|
||||||
|
@ -122,8 +123,8 @@ SCM_DEFINE (scm_make_syntax_transformer, "make-syntax-transformer", 3, 0, 0,
|
||||||
|
|
||||||
SCM_VALIDATE_SYMBOL (2, type);
|
SCM_VALIDATE_SYMBOL (2, type);
|
||||||
|
|
||||||
struct scm_syntax_transformer *tx = scm_gc_malloc (sizeof (*tx),
|
struct scm_syntax_transformer *tx = scm_allocate_tagged (SCM_I_CURRENT_THREAD,
|
||||||
"syntax transformer");
|
sizeof (*tx));
|
||||||
tx->tag = scm_tc16_syntax_transformer;
|
tx->tag = scm_tc16_syntax_transformer;
|
||||||
tx->primitive = NULL;
|
tx->primitive = NULL;
|
||||||
tx->name = name;
|
tx->name = name;
|
||||||
|
|
|
@ -71,6 +71,7 @@
|
||||||
#include "ports.h"
|
#include "ports.h"
|
||||||
#include "simpos.h"
|
#include "simpos.h"
|
||||||
#include "strings.h"
|
#include "strings.h"
|
||||||
|
#include "threads.h"
|
||||||
#include "values.h"
|
#include "values.h"
|
||||||
|
|
||||||
#include "numbers.h"
|
#include "numbers.h"
|
||||||
|
@ -420,7 +421,8 @@ scm_i_from_double (double val)
|
||||||
{
|
{
|
||||||
SCM z;
|
SCM z;
|
||||||
|
|
||||||
z = SCM_PACK_POINTER (scm_gc_malloc_pointerless (sizeof (scm_t_double), "real"));
|
z = SCM_PACK_POINTER
|
||||||
|
(scm_allocate_pointerless (SCM_I_CURRENT_THREAD, sizeof (scm_t_double)));
|
||||||
|
|
||||||
SCM_SET_CELL_TYPE (z, scm_tc16_real);
|
SCM_SET_CELL_TYPE (z, scm_tc16_real);
|
||||||
SCM_REAL_VALUE (z) = val;
|
SCM_REAL_VALUE (z) = val;
|
||||||
|
@ -6072,8 +6074,8 @@ scm_c_make_rectangular (double re, double im)
|
||||||
{
|
{
|
||||||
SCM z;
|
SCM z;
|
||||||
|
|
||||||
z = SCM_PACK_POINTER (scm_gc_malloc_pointerless (sizeof (scm_t_complex),
|
z = SCM_PACK_POINTER
|
||||||
"complex"));
|
(scm_allocate_pointerless (SCM_I_CURRENT_THREAD, sizeof (scm_t_complex)));
|
||||||
SCM_SET_CELL_TYPE (z, scm_tc16_complex);
|
SCM_SET_CELL_TYPE (z, scm_tc16_complex);
|
||||||
SCM_COMPLEX_REAL (z) = re;
|
SCM_COMPLEX_REAL (z) = re;
|
||||||
SCM_COMPLEX_IMAG (z) = im;
|
SCM_COMPLEX_IMAG (z) = im;
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include "pairs.h"
|
#include "pairs.h"
|
||||||
#include "strings.h"
|
#include "strings.h"
|
||||||
#include "symbols.h"
|
#include "symbols.h"
|
||||||
|
#include "threads.h"
|
||||||
|
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
|
|
||||||
|
@ -183,8 +184,8 @@ change_option_setting (SCM args, scm_t_option options[], const char *s,
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
scm_t_bits *new_vals;
|
scm_t_bits *new_vals;
|
||||||
|
|
||||||
new_vals = scm_gc_malloc (options_length (options) * sizeof (scm_t_bits),
|
new_vals = scm_allocate_sloppy (SCM_I_CURRENT_THREAD,
|
||||||
"new-options");
|
options_length (options) * sizeof (scm_t_bits));
|
||||||
|
|
||||||
for (i = 0; options[i].name; ++i)
|
for (i = 0; options[i].name; ++i)
|
||||||
{
|
{
|
||||||
|
|
|
@ -249,7 +249,7 @@ scm_make_port_type (char *name,
|
||||||
{
|
{
|
||||||
scm_t_port_type *desc;
|
scm_t_port_type *desc;
|
||||||
|
|
||||||
desc = scm_gc_malloc_pointerless (sizeof (*desc), "port-type");
|
desc = scm_allocate_pointerless (SCM_I_CURRENT_THREAD, sizeof (*desc));
|
||||||
memset (desc, 0, sizeof (*desc));
|
memset (desc, 0, sizeof (*desc));
|
||||||
|
|
||||||
desc->name = name;
|
desc->name = name;
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#define _SCM_PROGRAMS_H_
|
#define _SCM_PROGRAMS_H_
|
||||||
|
|
||||||
#include <libguile/gc.h>
|
#include <libguile/gc.h>
|
||||||
|
#include <libguile/threads.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Programs
|
* Programs
|
||||||
|
@ -122,11 +123,14 @@ scm_program_free_variable_set_x (struct scm_program *program, size_t idx, SCM v)
|
||||||
program->free_variables[idx] = v;
|
program->free_variables[idx] = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include "threads.h"
|
||||||
|
|
||||||
static inline SCM
|
static inline SCM
|
||||||
scm_i_make_program (const uint32_t *code)
|
scm_i_make_program (const uint32_t *code)
|
||||||
{
|
{
|
||||||
struct scm_program *ret =
|
struct scm_program *ret =
|
||||||
scm_gc_malloc_pointerless (sizeof (struct scm_program), "program");
|
scm_allocate_pointerless (SCM_I_CURRENT_THREAD,
|
||||||
|
sizeof (struct scm_program));
|
||||||
ret->tag_flags_and_free_variable_count = scm_tc7_program;
|
ret->tag_flags_and_free_variable_count = scm_tc7_program;
|
||||||
ret->code = code;
|
ret->code = code;
|
||||||
return scm_from_program (ret);
|
return scm_from_program (ret);
|
||||||
|
|
|
@ -50,6 +50,7 @@
|
||||||
#include "stime.h"
|
#include "stime.h"
|
||||||
#include "strings.h"
|
#include "strings.h"
|
||||||
#include "symbols.h"
|
#include "symbols.h"
|
||||||
|
#include "threads.h"
|
||||||
#include "variable.h"
|
#include "variable.h"
|
||||||
#include "vectors.h"
|
#include "vectors.h"
|
||||||
|
|
||||||
|
@ -136,8 +137,8 @@ scm_i_copy_rstate (scm_t_rstate *state)
|
||||||
{
|
{
|
||||||
scm_t_rstate *new_state;
|
scm_t_rstate *new_state;
|
||||||
|
|
||||||
new_state = scm_gc_malloc_pointerless (state->rng->rstate_size,
|
new_state = scm_allocate_pointerless (SCM_I_CURRENT_THREAD,
|
||||||
"random-state");
|
state->rng->rstate_size);
|
||||||
return memcpy (new_state, state, state->rng->rstate_size);
|
return memcpy (new_state, state, state->rng->rstate_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,8 +183,8 @@ scm_c_make_rstate (const char *seed, int n)
|
||||||
{
|
{
|
||||||
scm_t_rstate *state;
|
scm_t_rstate *state;
|
||||||
|
|
||||||
state = scm_gc_malloc_pointerless (scm_the_rng.rstate_size,
|
state = scm_allocate_pointerless (SCM_I_CURRENT_THREAD,
|
||||||
"random-state");
|
scm_the_rng.rstate_size);
|
||||||
state->tag = scm_tc16_random_state;
|
state->tag = scm_tc16_random_state;
|
||||||
state->rng = &scm_the_rng;
|
state->rng = &scm_the_rng;
|
||||||
state->normal_next = 0.0;
|
state->normal_next = 0.0;
|
||||||
|
@ -196,8 +197,8 @@ scm_c_rstate_from_datum (SCM datum)
|
||||||
{
|
{
|
||||||
scm_t_rstate *state;
|
scm_t_rstate *state;
|
||||||
|
|
||||||
state = scm_gc_malloc_pointerless (scm_the_rng.rstate_size,
|
state = scm_allocate_pointerless (SCM_I_CURRENT_THREAD,
|
||||||
"random-state");
|
scm_the_rng.rstate_size);
|
||||||
state->tag = scm_tc16_random_state;
|
state->tag = scm_tc16_random_state;
|
||||||
state->rng = &scm_the_rng;
|
state->rng = &scm_the_rng;
|
||||||
state->normal_next = 0.0;
|
state->normal_next = 0.0;
|
||||||
|
|
|
@ -59,6 +59,7 @@
|
||||||
#include "strings.h"
|
#include "strings.h"
|
||||||
#include "strports.h"
|
#include "strports.h"
|
||||||
#include "symbols.h"
|
#include "symbols.h"
|
||||||
|
#include "threads.h"
|
||||||
#include "variable.h"
|
#include "variable.h"
|
||||||
#include "vectors.h"
|
#include "vectors.h"
|
||||||
|
|
||||||
|
@ -233,14 +234,16 @@ read_complete_token (SCM port, char *buffer, size_t buffer_size, size_t *read)
|
||||||
{
|
{
|
||||||
if (overflow_size == 0)
|
if (overflow_size == 0)
|
||||||
{
|
{
|
||||||
overflow_buffer = scm_gc_malloc_pointerless (bytes_read, "read");
|
overflow_buffer = scm_allocate_pointerless (SCM_I_CURRENT_THREAD,
|
||||||
|
bytes_read);
|
||||||
memcpy (overflow_buffer, buffer, bytes_read);
|
memcpy (overflow_buffer, buffer, bytes_read);
|
||||||
overflow_size = bytes_read;
|
overflow_size = bytes_read;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char *new_buf =
|
char *new_buf =
|
||||||
scm_gc_malloc_pointerless (overflow_size + bytes_read, "read");
|
scm_allocate_pointerless (SCM_I_CURRENT_THREAD,
|
||||||
|
overflow_size + bytes_read);
|
||||||
|
|
||||||
memcpy (new_buf, overflow_buffer, overflow_size);
|
memcpy (new_buf, overflow_buffer, overflow_size);
|
||||||
memcpy (new_buf + overflow_size, buffer, bytes_read);
|
memcpy (new_buf + overflow_size, buffer, bytes_read);
|
||||||
|
@ -1677,8 +1680,8 @@ is_encoding_char (char c)
|
||||||
|
|
||||||
|
|
||||||
/* Search the SCM_ENCODING_SEARCH_SIZE bytes of a file for an Emacs-like
|
/* Search the SCM_ENCODING_SEARCH_SIZE bytes of a file for an Emacs-like
|
||||||
coding declaration. Returns either NULL or a string whose storage
|
coding declaration. Returns the encoding as a GC-managed pointer, or
|
||||||
has been allocated with `scm_gc_malloc'. */
|
NULL. */
|
||||||
char *
|
char *
|
||||||
scm_i_scan_for_encoding (SCM port)
|
scm_i_scan_for_encoding (SCM port)
|
||||||
{
|
{
|
||||||
|
|
|
@ -182,7 +182,8 @@ SCM_DEFINE_STATIC (make_regexp, "make-regexp", 1, 0, 1,
|
||||||
flag = SCM_CDR (flag);
|
flag = SCM_CDR (flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
rx = scm_gc_malloc_pointerless (sizeof (*rx), "regex");
|
rx = scm_allocate_pointerless (SCM_I_CURRENT_THREAD,
|
||||||
|
sizeof (*rx));
|
||||||
rx->tag = scm_tc16_regexp;
|
rx->tag = scm_tc16_regexp;
|
||||||
c_pat = scm_to_locale_string (pat);
|
c_pat = scm_to_locale_string (pat);
|
||||||
status = regcomp (&rx->regex, c_pat,
|
status = regcomp (&rx->regex, c_pat,
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
#include "numbers.h"
|
#include "numbers.h"
|
||||||
#include "ports.h"
|
#include "ports.h"
|
||||||
#include "programs.h"
|
#include "programs.h"
|
||||||
|
#include "threads.h"
|
||||||
|
|
||||||
#include "smob.h"
|
#include "smob.h"
|
||||||
|
|
||||||
|
@ -244,7 +245,8 @@ scm_make_smob (scm_t_bits tc)
|
||||||
scm_t_bits n = SCM_TC2SMOBNUM (tc);
|
scm_t_bits n = SCM_TC2SMOBNUM (tc);
|
||||||
size_t size = scm_smobs[n].size;
|
size_t size = scm_smobs[n].size;
|
||||||
scm_t_bits data = (size > 0
|
scm_t_bits data = (size > 0
|
||||||
? (scm_t_bits) scm_gc_malloc (size, SCM_SMOBNAME (n))
|
? (scm_t_bits) scm_allocate_sloppy (SCM_I_CURRENT_THREAD,
|
||||||
|
size)
|
||||||
: 0);
|
: 0);
|
||||||
|
|
||||||
SCM_RETURN_NEWSMOB (tc, data);
|
SCM_RETURN_NEWSMOB (tc, data);
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#include "procs.h"
|
#include "procs.h"
|
||||||
#include "strings.h"
|
#include "strings.h"
|
||||||
#include "symbols.h"
|
#include "symbols.h"
|
||||||
|
#include "threads.h"
|
||||||
#include "values.h"
|
#include "values.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
|
@ -164,8 +165,8 @@ static struct scm_bytevector *empty_charset_ranges;
|
||||||
static struct scm_charset *
|
static struct scm_charset *
|
||||||
make_charset (struct scm_bytevector *ranges)
|
make_charset (struct scm_bytevector *ranges)
|
||||||
{
|
{
|
||||||
struct scm_charset *p = scm_gc_malloc (sizeof (struct scm_charset),
|
struct scm_charset *p = scm_allocate_tagged (SCM_I_CURRENT_THREAD,
|
||||||
"charset");
|
sizeof (struct scm_charset));
|
||||||
p->tag_and_flags = scm_tc16_charset;
|
p->tag_and_flags = scm_tc16_charset;
|
||||||
p->ranges = ranges;
|
p->ranges = ranges;
|
||||||
return p;
|
return p;
|
||||||
|
|
|
@ -137,8 +137,9 @@ make_stringbuf (size_t len)
|
||||||
if (INT_ADD_OVERFLOW (len, STRINGBUF_HEADER_BYTES + 32))
|
if (INT_ADD_OVERFLOW (len, STRINGBUF_HEADER_BYTES + 32))
|
||||||
scm_num_overflow ("make_stringbuf");
|
scm_num_overflow ("make_stringbuf");
|
||||||
|
|
||||||
buf = SCM_PACK_POINTER (scm_gc_malloc_pointerless (STRINGBUF_HEADER_BYTES + len + 1,
|
buf = SCM_PACK_POINTER
|
||||||
"string"));
|
(scm_allocate_pointerless (SCM_I_CURRENT_THREAD,
|
||||||
|
STRINGBUF_HEADER_BYTES + len + 1));
|
||||||
|
|
||||||
SCM_SET_CELL_TYPE (buf, STRINGBUF_TAG);
|
SCM_SET_CELL_TYPE (buf, STRINGBUF_TAG);
|
||||||
SCM_SET_CELL_WORD_1 (buf, (scm_t_bits) len);
|
SCM_SET_CELL_WORD_1 (buf, (scm_t_bits) len);
|
||||||
|
@ -171,8 +172,9 @@ make_wide_stringbuf (size_t len)
|
||||||
scm_num_overflow ("make_wide_stringbuf");
|
scm_num_overflow ("make_wide_stringbuf");
|
||||||
|
|
||||||
raw_len = (len + 1) * sizeof (scm_t_wchar);
|
raw_len = (len + 1) * sizeof (scm_t_wchar);
|
||||||
buf = SCM_PACK_POINTER (scm_gc_malloc_pointerless (STRINGBUF_HEADER_BYTES + raw_len,
|
buf = SCM_PACK_POINTER
|
||||||
"string"));
|
(scm_allocate_pointerless (SCM_I_CURRENT_THREAD,
|
||||||
|
STRINGBUF_HEADER_BYTES + raw_len));
|
||||||
|
|
||||||
SCM_SET_CELL_TYPE (buf, STRINGBUF_TAG | STRINGBUF_F_WIDE);
|
SCM_SET_CELL_TYPE (buf, STRINGBUF_TAG | STRINGBUF_F_WIDE);
|
||||||
SCM_SET_CELL_WORD_1 (buf, (scm_t_bits) len);
|
SCM_SET_CELL_WORD_1 (buf, (scm_t_bits) len);
|
||||||
|
@ -1499,7 +1501,7 @@ decoding_error (const char *func_name, int errno_save,
|
||||||
SCM bv;
|
SCM bv;
|
||||||
signed char *buf;
|
signed char *buf;
|
||||||
|
|
||||||
buf = scm_gc_malloc_pointerless (len, "bytevector");
|
buf = scm_allocate_pointerless (SCM_I_CURRENT_THREAD, len);
|
||||||
memcpy (buf, str, len);
|
memcpy (buf, str, len);
|
||||||
bv = scm_c_take_gc_bytevector (buf, len, SCM_BOOL_F);
|
bv = scm_c_take_gc_bytevector (buf, len, SCM_BOOL_F);
|
||||||
|
|
||||||
|
|
|
@ -141,8 +141,8 @@ set_vtable_access_fields (SCM vtable)
|
||||||
{
|
{
|
||||||
size_t bitmask_size = (nfields + 31U) / 32U;
|
size_t bitmask_size = (nfields + 31U) / 32U;
|
||||||
unboxed_fields =
|
unboxed_fields =
|
||||||
scm_gc_malloc_pointerless (bitmask_size * sizeof (*unboxed_fields),
|
scm_allocate_pointerless (SCM_I_CURRENT_THREAD,
|
||||||
"unboxed fields");
|
bitmask_size * sizeof (*unboxed_fields));
|
||||||
memset (unboxed_fields, 0, bitmask_size * sizeof (*unboxed_fields));
|
memset (unboxed_fields, 0, bitmask_size * sizeof (*unboxed_fields));
|
||||||
for (size_t field = 0; field < nfields; field++)
|
for (size_t field = 0; field < nfields; field++)
|
||||||
if (c_layout[field*2] == 'u')
|
if (c_layout[field*2] == 'u')
|
||||||
|
|
|
@ -1017,7 +1017,7 @@ SCM_DEFINE (scm_make_mutex_with_kind, "make-mutex", 0, 1, 0,
|
||||||
SCM_MISC_ERROR ("unsupported mutex kind: ~a", scm_list_1 (kind));
|
SCM_MISC_ERROR ("unsupported mutex kind: ~a", scm_list_1 (kind));
|
||||||
}
|
}
|
||||||
|
|
||||||
m = scm_gc_malloc (sizeof (struct scm_mutex), "mutex");
|
m = scm_allocate_tagged (SCM_I_CURRENT_THREAD, sizeof (struct scm_mutex));
|
||||||
m->tag_and_flags = scm_tc16_mutex | (mkind << 16);
|
m->tag_and_flags = scm_tc16_mutex | (mkind << 16);
|
||||||
m->owner = SCM_BOOL_F;
|
m->owner = SCM_BOOL_F;
|
||||||
m->waiting = make_queue ();
|
m->waiting = make_queue ();
|
||||||
|
@ -1353,7 +1353,7 @@ SCM_DEFINE (scm_make_condition_variable, "make-condition-variable", 0, 0, 0,
|
||||||
#define FUNC_NAME s_scm_make_condition_variable
|
#define FUNC_NAME s_scm_make_condition_variable
|
||||||
{
|
{
|
||||||
struct scm_cond *c =
|
struct scm_cond *c =
|
||||||
scm_gc_malloc (sizeof (struct scm_cond), "condition variable");
|
scm_allocate_tagged (SCM_I_CURRENT_THREAD, sizeof (struct scm_cond));
|
||||||
c->tag = scm_tc16_condition_variable;
|
c->tag = scm_tc16_condition_variable;
|
||||||
c->waiting = make_queue ();
|
c->waiting = make_queue ();
|
||||||
return scm_from_condvar (c);
|
return scm_from_condvar (c);
|
||||||
|
|
|
@ -38,19 +38,6 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define SCM_INLINE_GC_GRANULE_WORDS 2
|
|
||||||
#define SCM_INLINE_GC_GRANULE_BYTES \
|
|
||||||
(sizeof(void *) * SCM_INLINE_GC_GRANULE_WORDS)
|
|
||||||
|
|
||||||
/* A freelist set contains SCM_INLINE_GC_FREELIST_COUNT pointers to
|
|
||||||
singly linked lists of objects of different sizes, the ith one
|
|
||||||
containing objects i + 1 granules in size. This setting of
|
|
||||||
SCM_INLINE_GC_FREELIST_COUNT will hold freelists for allocations of
|
|
||||||
up to 256 bytes. */
|
|
||||||
#define SCM_INLINE_GC_FREELIST_COUNT (256U / SCM_INLINE_GC_GRANULE_BYTES)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct scm_thread_wake_data;
|
struct scm_thread_wake_data;
|
||||||
struct gc_mutator;
|
struct gc_mutator;
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
#include "numbers.h"
|
#include "numbers.h"
|
||||||
#include "pairs.h"
|
#include "pairs.h"
|
||||||
|
#include "threads.h"
|
||||||
|
|
||||||
#include "values.h"
|
#include "values.h"
|
||||||
|
|
||||||
|
@ -101,7 +102,8 @@ SCM_DEFINE (scm_values, "values", 0, 0, 1,
|
||||||
SCM_EOL, SCM_EOL);
|
SCM_EOL, SCM_EOL);
|
||||||
|
|
||||||
struct scm_values *values =
|
struct scm_values *values =
|
||||||
scm_gc_malloc (sizeof (struct scm_values) + n * sizeof (SCM), "values");
|
scm_allocate_tagged (SCM_I_CURRENT_THREAD,
|
||||||
|
sizeof (struct scm_values) + n * sizeof (SCM));
|
||||||
values->tag_and_count = scm_tc7_values | (n << 8);
|
values->tag_and_count = scm_tc7_values | (n << 8);
|
||||||
for (i = 0; i < n; i++, args = SCM_CDR (args))
|
for (i = 0; i < n; i++, args = SCM_CDR (args))
|
||||||
values->values[i] = SCM_CAR (args);
|
values->values[i] = SCM_CAR (args);
|
||||||
|
@ -123,7 +125,8 @@ scm_c_values (SCM *base, size_t nvalues)
|
||||||
SCM_EOL, SCM_EOL);
|
SCM_EOL, SCM_EOL);
|
||||||
|
|
||||||
struct scm_values *values =
|
struct scm_values *values =
|
||||||
scm_gc_malloc (sizeof (struct scm_values) + nvalues * sizeof (SCM), "values");
|
scm_allocate_tagged (SCM_I_CURRENT_THREAD,
|
||||||
|
sizeof (struct scm_values) + nvalues * sizeof (SCM));
|
||||||
|
|
||||||
values->tag_and_count = scm_tc7_values | (nvalues << 8);
|
values->tag_and_count = scm_tc7_values | (nvalues << 8);
|
||||||
|
|
||||||
|
@ -137,7 +140,8 @@ SCM
|
||||||
scm_values_2 (SCM a, SCM b)
|
scm_values_2 (SCM a, SCM b)
|
||||||
{
|
{
|
||||||
struct scm_values *values =
|
struct scm_values *values =
|
||||||
scm_gc_malloc (sizeof (struct scm_values) + 2 * sizeof (SCM), "values");
|
scm_allocate_tagged (SCM_I_CURRENT_THREAD,
|
||||||
|
sizeof (struct scm_values) + 2 * sizeof (SCM));
|
||||||
|
|
||||||
values->tag_and_count = scm_tc7_values | (2 << 8);
|
values->tag_and_count = scm_tc7_values | (2 << 8);
|
||||||
values->values[0] = a;
|
values->values[0] = a;
|
||||||
|
@ -150,7 +154,8 @@ SCM
|
||||||
scm_values_3 (SCM a, SCM b, SCM c)
|
scm_values_3 (SCM a, SCM b, SCM c)
|
||||||
{
|
{
|
||||||
struct scm_values *values =
|
struct scm_values *values =
|
||||||
scm_gc_malloc (sizeof (struct scm_values) + 3 * sizeof (SCM), "values");
|
scm_allocate_tagged (SCM_I_CURRENT_THREAD,
|
||||||
|
sizeof (struct scm_values) + 3 * sizeof (SCM));
|
||||||
|
|
||||||
values->tag_and_count = scm_tc7_values | (3 << 8);
|
values->tag_and_count = scm_tc7_values | (3 << 8);
|
||||||
values->values[0] = a;
|
values->values[0] = a;
|
||||||
|
|
|
@ -171,8 +171,8 @@ capture_stack (scm_thread *thread,
|
||||||
|
|
||||||
stack_size = stack_top - sp;
|
stack_size = stack_top - sp;
|
||||||
|
|
||||||
p = scm_gc_malloc (sizeof (*p) + stack_size * sizeof (p->stack_slice[0]),
|
p = scm_allocate_tagged (SCM_I_CURRENT_THREAD,
|
||||||
"capture_vm_cont");
|
sizeof (*p) + stack_size * sizeof (p->stack_slice[0]));
|
||||||
p->tag_and_flags = scm_tc7_vm_cont | flags;
|
p->tag_and_flags = scm_tc7_vm_cont | flags;
|
||||||
p->dynstack = dynstack;
|
p->dynstack = dynstack;
|
||||||
p->vra = vra;
|
p->vra = vra;
|
||||||
|
@ -480,12 +480,13 @@ define_vm_builtins (void)
|
||||||
SCM_PACK_OP_24 (return_from_interrupt, 0)
|
SCM_PACK_OP_24 (return_from_interrupt, 0)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct scm_thread *thr = SCM_I_CURRENT_THREAD;
|
||||||
#define DEFINE_BUILTIN(builtin, BUILTIN, req, opt, rest) \
|
#define DEFINE_BUILTIN(builtin, BUILTIN, req, opt, rest) \
|
||||||
{ \
|
{ \
|
||||||
size_t sz = sizeof (builtin##_code); \
|
size_t sz = sizeof (builtin##_code); \
|
||||||
vm_builtin_##builtin##_code = instrumented_code (builtin##_code, sz); \
|
vm_builtin_##builtin##_code = instrumented_code (builtin##_code, sz); \
|
||||||
struct scm_program *p = \
|
struct scm_program *p = \
|
||||||
scm_gc_malloc_pointerless (sizeof (struct scm_program), "builtin"); \
|
scm_allocate_pointerless (thr, sizeof (struct scm_program)); \
|
||||||
scm_t_bits tag = scm_tc7_program | SCM_F_PROGRAM_IS_PRIMITIVE; \
|
scm_t_bits tag = scm_tc7_program | SCM_F_PROGRAM_IS_PRIMITIVE; \
|
||||||
p->tag_flags_and_free_variable_count = tag; \
|
p->tag_flags_and_free_variable_count = tag; \
|
||||||
p->code = vm_builtin_##builtin##_code; \
|
p->code = vm_builtin_##builtin##_code; \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue