From 62250cf5d75cb500bbc445b2e110e2ed3efbd216 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Mon, 20 Jan 2025 18:54:18 -0800 Subject: [PATCH] Run formatting job --- gc.c | 20 +++++++------ include/cyclone/bignum.h | 11 ++++--- runtime.c | 62 +++++++++++++++++++++------------------- 3 files changed, 49 insertions(+), 44 deletions(-) diff --git a/gc.c b/gc.c index 0c1aad9b..3372e227 100644 --- a/gc.c +++ b/gc.c @@ -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", - heap_type, hdest, hsrc, hsrc->size); - fflush(stderr); + 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]))); } diff --git a/include/cyclone/bignum.h b/include/cyclone/bignum.h index 4f29952d..30d3313c 100644 --- a/include/cyclone/bignum.h +++ b/include/cyclone/bignum.h @@ -256,7 +256,7 @@ extern "C" { /* callback for mp_prime_random, should fill dst with random bytes and return how many read [upto len] */ typedef int private_mp_prime_callback(unsigned char *dst, int len, void *dat); typedef private_mp_prime_callback MP_DEPRECATED(mp_rand_source) - ltm_prime_callback; + ltm_prime_callback; /* error code to char* string */ const char *mp_error_to_string(mp_err code) MP_WUR; @@ -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,15 +766,14 @@ 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; MP_DEPRECATED(mp_to_ubin) mp_err mp_to_unsigned_bin_n(const mp_int * a, unsigned char *b, unsigned long *outlen) - MP_WUR; + MP_WUR; MP_DEPRECATED(mp_sbin_size) int mp_signed_bin_size(const mp_int * a) MP_WUR; MP_DEPRECATED(mp_from_sbin) mp_err mp_read_signed_bin(mp_int * a, @@ -785,7 +784,7 @@ extern "C" { MP_DEPRECATED(mp_to_sbin) mp_err mp_to_signed_bin_n(const mp_int * a, unsigned char *b, unsigned long *outlen) - MP_WUR; + MP_WUR; size_t mp_ubin_size(const mp_int * a) MP_WUR; mp_err mp_from_ubin(mp_int * a, const unsigned char *buf, size_t size) MP_WUR; diff --git a/runtime.c b/runtime.c index 016b4574..29523dba 100644 --- a/runtime.c +++ b/runtime.c @@ -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,9 +6609,8 @@ 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, - heap_grown); + object hp = gc_alloc(heap, gc_allocated_bytes(obj, NULL, NULL), obj, thd, + heap_grown); return_closcall1(data, k, hp); } // Objs w/children force minor GC to guarantee everything is relocated: @@ -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,13 +7573,11 @@ 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') - && (tok[0] == '-' || tok[0] == '+')) || - ((len > 1) && tok[0] == '.' && isdigit(tok[1])) || - ((len > 1) && (tok[1] == '.' || isdigit(tok[1])) - && (tok[0] == '-' || tok[0] == '+')))); + 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])) + && (tok[0] == '-' || tok[0] == '+')))); } /** @@ -8534,32 +8536,32 @@ static const uint8_t utf8d[] = { // The first part of the table maps bytes to character classes that // to reduce the size of the transition table and create bitmasks. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9, 9, 9, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 8, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 10, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 3, 11, 6, 6, 6, 5, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, // The second part is a transition table that maps a combination // of a state of the automaton and a character class to a state. 0, 12, 24, 36, 60, 96, 84, 12, 12, 12, 48, 72, 12, 12, 12, 12, 12, 12, 12, 12, - 12, 12, 12, 12, + 12, 12, 12, 12, 12, 0, 12, 12, 12, 12, 12, 0, 12, 0, 12, 12, 12, 24, 12, 12, 12, 12, 12, 24, - 12, 24, 12, 12, + 12, 24, 12, 12, 12, 12, 12, 12, 12, 12, 12, 24, 12, 12, 12, 12, 12, 24, 12, 12, 12, 12, 12, - 12, 12, 24, 12, 12, + 12, 12, 24, 12, 12, 12, 12, 12, 12, 12, 12, 12, 36, 12, 36, 12, 12, 12, 36, 12, 12, 12, 12, 12, - 36, 12, 36, 12, 12, + 36, 12, 36, 12, 12, 12, 36, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, }; @@ -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); } /**