Run formatting job

This commit is contained in:
Justin Ethier 2025-01-20 18:54:18 -08:00
parent 1f942dcb04
commit 62250cf5d7
3 changed files with 49 additions and 44 deletions

16
gc.c
View file

@ -1902,14 +1902,15 @@ void gc_mut_update(gc_thread_data * thd, object old_obj, object value)
}
}
static void gc_sweep_primordial_thread_heap() {
static void gc_sweep_primordial_thread_heap()
{
int heap_type, must_free;
gc_heap *h, *prev, *next, *sweep;
pthread_mutex_lock(&(primordial_thread->lock));
for (heap_type = 0; heap_type < NUM_HEAP_TYPES; heap_type++) {
prev = primordial_thread->heap->heap[heap_type];
h = prev->next;
while(h != NULL) {
while (h != NULL) {
next = h->next;
must_free = 0;
if (h->is_unswept) {
@ -1954,7 +1955,8 @@ void gc_mut_cooperate(gc_thread_data * thd, int buf_len)
// the heep keeps growing. Perform a sweep here if necessary.
stage = ck_pr_load_int(&gc_stage);
merged = ck_pr_load_int(&gc_threads_merged);
if ((thd == primordial_thread) && (merged == 1) && ((stage == STAGE_SWEEPING) || (stage == STAGE_RESTING))) {
if ((thd == primordial_thread) && (merged == 1)
&& ((stage == STAGE_SWEEPING) || (stage == STAGE_RESTING))) {
gc_sweep_primordial_thread_heap();
ck_pr_cas_int(&gc_threads_merged, 1, 0);
}
@ -2824,7 +2826,7 @@ void gc_merge_all_heaps(gc_thread_data * dest, gc_thread_data * src)
// be stored on the primordial thread's heap. Make this explicit by
// including it in the thread object.
if (src->gc_num_args > 0) {
for (i=src->gc_num_args-1; i>=0; --i) {
for (i = src->gc_num_args - 1; i >= 0; --i) {
context = gc_alloc_pair(dest, (src->gc_args)[i], context);
}
}
@ -2847,14 +2849,16 @@ void gc_merge_all_heaps(gc_thread_data * dest, gc_thread_data * src)
hdest = dest->heap->heap[heap_type];
hsrc = src->heap->heap[heap_type];
if (!hdest) {
fprintf(stderr, "WARNING !!!!! merging heap type %d does not happen: hdest = %p hsrc = %p size = %d\n",
fprintf(stderr,
"WARNING !!!!! merging heap type %d does not happen: hdest = %p hsrc = %p size = %d\n",
heap_type, hdest, hsrc, hsrc->size);
fflush(stderr);
}
if (hdest && hsrc) {
freed = gc_heap_merge(hdest, hsrc);
ck_pr_add_ptr(&(dest->cached_heap_total_sizes[heap_type]),
ck_pr_load_ptr(&(src->cached_heap_total_sizes[heap_type]))-freed);
ck_pr_load_ptr(&(src->cached_heap_total_sizes[heap_type])) -
freed);
ck_pr_add_ptr(&(dest->cached_heap_free_sizes[heap_type]),
ck_pr_load_ptr(&(src->cached_heap_free_sizes[heap_type])));
}

View file

@ -443,7 +443,7 @@ extern "C" {
* It is compatible with `rng_get_bytes()` from libtomcrypt so you could
* provide that one and then set `ltm_rng = rng_get_bytes;` */
extern unsigned long (*ltm_rng)(unsigned char *out, unsigned long outlen,
void(*callback)(void));
void (*callback)(void));
extern void (*ltm_rng_callback)(void);
#endif
@ -766,8 +766,7 @@ extern "C" {
MP_DEPRECATED(mp_ubin_size) int mp_unsigned_bin_size(const mp_int *
a) MP_WUR;
MP_DEPRECATED(mp_from_ubin) mp_err mp_read_unsigned_bin(mp_int * a,
const unsigned char
MP_DEPRECATED(mp_from_ubin) mp_err mp_read_unsigned_bin(mp_int * a, const unsigned char
*b, int c) MP_WUR;
MP_DEPRECATED(mp_to_ubin) mp_err mp_to_unsigned_bin(const mp_int * a,
unsigned char *b) MP_WUR;

View file

@ -6427,7 +6427,6 @@ int gc_minor(void *data, object low_limit, object high_limit, closure cont,
((gc_thread_data *) data)->gc_args[i] = args[i];
}
}
// Transport exception stack
gc_move2heap(((gc_thread_data *) data)->exception_handler_stack);
gc_move2heap(((gc_thread_data *) data)->param_objs);
@ -6610,8 +6609,7 @@ void Cyc_make_shared_object(void *data, object k, object obj)
case port_tag:
case c_opaque_tag:
case complex_num_tag:{
object hp =
gc_alloc(heap, gc_allocated_bytes(obj, NULL, NULL), obj, thd,
object hp = gc_alloc(heap, gc_allocated_bytes(obj, NULL, NULL), obj, thd,
heap_grown);
return_closcall1(data, k, hp);
}
@ -6797,7 +6795,8 @@ static primitive_type Cyc_91installation_91dir_primitive =
{ {0}, primitive_tag, &_Cyc_91installation_91dir, "Cyc-installation-dir" };
static primitive_type Cyc_91compilation_91environment_primitive =
{ {0}, primitive_tag, &_Cyc_91compilation_91environment,
"Cyc-compilation-environment" };
"Cyc-compilation-environment"
};
static primitive_type command_91line_91arguments_primitive =
{ {0}, primitive_tag, &_command_91line_91arguments, "command-line-arguments"
};
@ -6878,10 +6877,12 @@ static primitive_type open_91output_91file_primitive =
{ {0}, primitive_tag, &_open_91output_91file, "open-output-file" };
static primitive_type open_91binary_91input_91file_primitive =
{ {0}, primitive_tag, &_open_91binary_91input_91file,
"open-binary-input-file" };
"open-binary-input-file"
};
static primitive_type open_91binary_91output_91file_primitive =
{ {0}, primitive_tag, &_open_91binary_91output_91file,
"open-binary-output-file" };
"open-binary-output-file"
};
static primitive_type close_91port_primitive =
{ {0}, primitive_tag, &_close_91port, "close-port" };
static primitive_type close_91input_91port_primitive =
@ -6890,7 +6891,8 @@ static primitive_type close_91output_91port_primitive =
{ {0}, primitive_tag, &_close_91output_91port, "close-output-port" };
static primitive_type Cyc_91flush_91output_91port_primitive =
{ {0}, primitive_tag, &_Cyc_91flush_91output_91port,
"Cyc-flush-output-port" };
"Cyc-flush-output-port"
};
static primitive_type file_91exists_127_primitive =
{ {0}, primitive_tag, &_file_91exists_127, "file-exists?" };
static primitive_type delete_91file_primitive =
@ -7138,7 +7140,9 @@ void *Cyc_init_thread(object thread_and_thunk, int argc, object * args)
ck_pr_cas_int((int *)&(thd->thread_state), CYC_THREAD_STATE_NEW,
CYC_THREAD_STATE_RUNNABLE);
if (ck_pr_cas_int(&cyclone_thread_key_create, 1, 0)) {
int r = pthread_key_create(&cyclone_thread_key, (void (*)(void *))Cyc_cancel_thread);
int r =
pthread_key_create(&cyclone_thread_key,
(void (*)(void *))Cyc_cancel_thread);
assert(r == 0);
}
pthread_setspecific(cyclone_thread_key, thd);
@ -7209,7 +7213,7 @@ static void Cyc_cancel_thread(gc_thread_data * thd)
{
// do a minor GC without a continuation, so that we return
// here without performing a longjmp
GC(thd, (closure)NULL, (object *)NULL, 0);
GC(thd, (closure) NULL, (object *) NULL, 0);
if (gc_is_mutator_active(thd)) {
gc_remove_mutator(thd);
}
@ -7569,9 +7573,7 @@ static void _read_add_to_tok_buf(port_type * p, char c)
*/
static int _read_is_numeric(const char *tok, int len)
{
return (len &&
((isdigit(tok[0])) ||
(((len == 2) && tok[1] == 'i')
return (len && ((isdigit(tok[0])) || (((len == 2) && tok[1] == 'i')
&& (tok[0] == '-' || tok[0] == '+')) ||
((len > 1) && tok[0] == '.' && isdigit(tok[1])) ||
((len > 1) && (tok[1] == '.' || isdigit(tok[1]))
@ -8799,7 +8801,7 @@ int num2ratio(double x, double *numerator, double *denominator)
double round_to_nearest_even(double x)
{
return x-remainder(x,1.0);
return x - remainder(x, 1.0);
}
/**