Skip to content

Commit f9fc402

Browse files
committed
clang-format using: IndentPPDirectives: AfterHash
Apply new rule for improved macro readability. Signed-off-by: Davide Bettio <[email protected]>
1 parent cf17831 commit f9fc402

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+785
-785
lines changed

src/libAtomVM/atom_table.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@
3131
#include "utils.h"
3232

3333
#ifndef AVM_NO_SMP
34-
#define SMP_RDLOCK(htable) smp_rwlock_rdlock(htable->lock)
35-
#define SMP_WRLOCK(htable) smp_rwlock_wrlock(htable->lock)
36-
#define SMP_UNLOCK(htable) smp_rwlock_unlock(htable->lock)
34+
# define SMP_RDLOCK(htable) smp_rwlock_rdlock(htable->lock)
35+
# define SMP_WRLOCK(htable) smp_rwlock_wrlock(htable->lock)
36+
# define SMP_UNLOCK(htable) smp_rwlock_unlock(htable->lock)
3737
#else
38-
#define SMP_RDLOCK(htable) UNUSED(htable)
39-
#define SMP_WRLOCK(htable) UNUSED(htable)
40-
#define SMP_UNLOCK(htable) UNUSED(htable)
38+
# define SMP_RDLOCK(htable) UNUSED(htable)
39+
# define SMP_WRLOCK(htable) UNUSED(htable)
40+
# define SMP_UNLOCK(htable) UNUSED(htable)
4141
#endif
4242

4343
#define DEFAULT_SIZE 8

src/libAtomVM/bif.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@
7272
* do not use `(avm_float_t) INT64_MIN` or `(avm_float_t) INT64_MAX`.
7373
*/
7474
#ifdef AVM_USE_SINGLE_PRECISION
75-
#define INT64_MIN_AS_AVM_FLOAT -9223372586610590720.0 // 0xDF000000 = -2^63
76-
#define INT64_MAX_AS_AVM_FLOAT 9223371761976868863.0 // 0x5F000000 = 2^63
75+
# define INT64_MIN_AS_AVM_FLOAT -9223372586610590720.0 // 0xDF000000 = -2^63
76+
# define INT64_MAX_AS_AVM_FLOAT 9223371761976868863.0 // 0x5F000000 = 2^63
7777
#else
78-
#define INT64_MIN_AS_AVM_FLOAT -9223372036854776832.0 // 0xC3E0000000000000 = -2^63
79-
#define INT64_MAX_AS_AVM_FLOAT 9223372036854775295.0 // 0x43DFFFFFFFFFFFFF = 2^62 * 1.1...1b
78+
# define INT64_MIN_AS_AVM_FLOAT -9223372036854776832.0 // 0xC3E0000000000000 = -2^63
79+
# define INT64_MAX_AS_AVM_FLOAT 9223372036854775295.0 // 0x43DFFFFFFFFFFFFF = 2^62 * 1.1...1b
8080
#endif
8181

8282
const struct ExportedFunction *bif_registry_get_handler(const char *mfa)
@@ -645,7 +645,7 @@ static term add_boxed_helper(Context *ctx, uint32_t fail_label, uint32_t live, t
645645
#elif BOXED_TERMS_REQUIRED_FOR_INT64 == 1
646646
return add_int64_to_bigint(ctx, fail_label, live, val1, val2);
647647
#else
648-
#error "Unsupported configuration."
648+
# error "Unsupported configuration."
649649
#endif
650650
}
651651

@@ -784,7 +784,7 @@ static term sub_boxed_helper(Context *ctx, uint32_t fail_label, uint32_t live, t
784784
#elif BOXED_TERMS_REQUIRED_FOR_INT64 == 1
785785
return sub_int64_to_bigint(ctx, fail_label, live, val1, val2);
786786
#else
787-
#error "Unsupported configuration."
787+
# error "Unsupported configuration."
788788
#endif
789789
}
790790

@@ -927,7 +927,7 @@ static term mul_boxed_helper(Context *ctx, uint32_t fail_label, uint32_t live, t
927927
#elif BOXED_TERMS_REQUIRED_FOR_INT64 == 1
928928
return mul_int64_to_bigint(ctx, fail_label, live, val1, val2);
929929
#else
930-
#error "Unsupported configuration."
930+
# error "Unsupported configuration."
931931
#endif
932932
}
933933

@@ -1177,7 +1177,7 @@ static term neg_boxed_helper(Context *ctx, uint32_t fail_label, uint32_t live, t
11771177
return int64_max_plus_one(ctx, fail_label, live);
11781178

11791179
#else
1180-
#error "Unsupported configuration."
1180+
# error "Unsupported configuration."
11811181
#endif
11821182

11831183
default:
@@ -1279,7 +1279,7 @@ static term abs_boxed_helper(Context *ctx, uint32_t fail_label, uint32_t live, t
12791279
return int64_max_plus_one(ctx, fail_label, live);
12801280

12811281
#else
1282-
#error "Unsupported configuration."
1282+
# error "Unsupported configuration."
12831283
#endif
12841284

12851285
} else {

src/libAtomVM/context.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@
3838
#include "utils.h"
3939

4040
#ifdef HAVE_PLATFORM_ATOMIC_H
41-
#include "platform_atomic.h"
41+
# include "platform_atomic.h"
4242
#else
43-
#if defined(HAVE_ATOMIC)
44-
#include <stdatomic.h>
45-
#define ATOMIC_COMPARE_EXCHANGE_WEAK_INT atomic_compare_exchange_weak
46-
#endif
43+
# if defined(HAVE_ATOMIC)
44+
# include <stdatomic.h>
45+
# define ATOMIC_COMPARE_EXCHANGE_WEAK_INT atomic_compare_exchange_weak
46+
# endif
4747
#endif
4848

4949
#define IMPL_EXECUTE_LOOP
@@ -467,15 +467,15 @@ void context_process_code_server_resume_signal(Context *ctx)
467467
// jit_trap_and_load stores the label in saved_function_ptr
468468
uint32_t label = (uint32_t) (uintptr_t) ctx->saved_function_ptr;
469469
Module *module = ctx->saved_module;
470-
#ifndef AVM_NO_EMU
470+
# ifndef AVM_NO_EMU
471471
if (module->native_code) {
472472
ctx->saved_function_ptr = module_get_native_entry_point(module, label);
473473
} else {
474474
ctx->saved_ip = module->labels[label];
475475
}
476-
#else
476+
# else
477477
ctx->saved_function_ptr = module_get_native_entry_point(module, label);
478-
#endif
478+
# endif
479479
// Fix CP to OP_INT_CALL_END
480480
if (ctx->cp == module_address(module->module_index, 0)) {
481481
ctx->cp = module_address(module->module_index, module->end_instruction_ii);

src/libAtomVM/context.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ extern "C" {
4343
struct Module;
4444

4545
#ifndef TYPEDEF_MODULE
46-
#define TYPEDEF_MODULE
46+
# define TYPEDEF_MODULE
4747
typedef struct Module Module;
4848
#endif
4949

@@ -160,7 +160,7 @@ struct Context
160160
};
161161

162162
#ifndef TYPEDEF_CONTEXT
163-
#define TYPEDEF_CONTEXT
163+
# define TYPEDEF_CONTEXT
164164
typedef struct Context Context;
165165
#endif
166166

src/libAtomVM/debug.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ char reg_type_c(int reg_type);
9595
void debug_print_processes_list(struct ListHead *processes);
9696

9797
#ifdef ENABLE_STACK_TRACE
98-
#define DEBUG_DUMP_STACK debug_dump_stack
98+
# define DEBUG_DUMP_STACK debug_dump_stack
9999
#else
100-
#define DEBUG_DUMP_STACK(...)
100+
# define DEBUG_DUMP_STACK(...)
101101
#endif
102102

103103
#ifdef __cplusplus

src/libAtomVM/ets.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,20 @@
3232
#define ETS_ANY_PROCESS -1
3333

3434
#ifndef AVM_NO_SMP
35-
#define SMP_RDLOCK(table) smp_rwlock_rdlock(table->lock)
36-
#define SMP_WRLOCK(table) smp_rwlock_wrlock(table->lock)
37-
#define SMP_UNLOCK(table) smp_rwlock_unlock(table->lock)
35+
# define SMP_RDLOCK(table) smp_rwlock_rdlock(table->lock)
36+
# define SMP_WRLOCK(table) smp_rwlock_wrlock(table->lock)
37+
# define SMP_UNLOCK(table) smp_rwlock_unlock(table->lock)
3838
#else
39-
#define SMP_RDLOCK(table)
40-
#define SMP_WRLOCK(table)
41-
#define SMP_UNLOCK(table)
39+
# define SMP_RDLOCK(table)
40+
# define SMP_WRLOCK(table)
41+
# define SMP_UNLOCK(table)
4242
#endif
4343

4444
#ifndef AVM_NO_SMP
45-
#ifndef TYPEDEF_RWLOCK
46-
#define TYPEDEF_RWLOCK
45+
# ifndef TYPEDEF_RWLOCK
46+
# define TYPEDEF_RWLOCK
4747
typedef struct RWLock RWLock;
48-
#endif
48+
# endif
4949
#endif
5050

5151
struct EtsTable

src/libAtomVM/exportedfunction.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,17 @@
3131
#include "term.h"
3232

3333
#ifndef TYPEDEF_MODULE
34-
#define TYPEDEF_MODULE
34+
# define TYPEDEF_MODULE
3535
typedef struct Module Module;
3636
#endif
3737

3838
#ifndef TYPEDEF_MODULENATIVEINTERFACE
39-
#define TYPEDEF_MODULENATIVEINTERFACE
39+
# define TYPEDEF_MODULENATIVEINTERFACE
4040
typedef struct ModuleNativeInterface ModuleNativeInterface;
4141
#endif
4242

4343
#ifndef TYPEDEF_JITSTATE
44-
#define TYPEDEF_JITSTATE
44+
# define TYPEDEF_JITSTATE
4545
typedef struct JITState JITState;
4646
#endif
4747

src/libAtomVM/externalterm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1157,7 +1157,7 @@ static int calculate_heap_usage(const uint8_t *external_term_buf, size_t remaini
11571157
#elif TERM_BYTES == 8
11581158
int size_in_terms = ((binary_size + 8 - 1) >> 3);
11591159
#else
1160-
#error
1160+
# error
11611161
#endif
11621162

11631163
if (copy && term_binary_size_is_heap_binary(binary_size)) {

src/libAtomVM/globalcontext.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@
4343
#include "valueshashtable.h"
4444

4545
#ifdef HAVE_PLATFORM_ATOMIC_H
46-
#include "platform_atomic.h"
46+
# include "platform_atomic.h"
4747
#else
48-
#if defined(HAVE_ATOMIC)
49-
#include <stdatomic.h>
50-
#define ATOMIC_COMPARE_EXCHANGE_WEAK_PTR atomic_compare_exchange_weak
51-
#endif
48+
# if defined(HAVE_ATOMIC)
49+
# include <stdatomic.h>
50+
# define ATOMIC_COMPARE_EXCHANGE_WEAK_PTR atomic_compare_exchange_weak
51+
# endif
5252
#endif
5353

5454
struct RegisteredProcess
@@ -134,9 +134,9 @@ GlobalContext *globalcontext_new(void)
134134
#if HAVE_OPEN && HAVE_CLOSE
135135
glb->posix_fd_resource_type = enif_init_resource_type(&env, "posix_fd", &posix_fd_resource_type_init, ERL_NIF_RT_CREATE, NULL);
136136
if (IS_NULL_PTR(glb->posix_fd_resource_type)) {
137-
#ifndef AVM_NO_SMP
137+
# ifndef AVM_NO_SMP
138138
smp_rwlock_destroy(glb->modules_lock);
139-
#endif
139+
# endif
140140
free(glb->modules_table);
141141
atom_table_destroy(glb->atom_table);
142142
free(glb);
@@ -149,9 +149,9 @@ GlobalContext *globalcontext_new(void)
149149
erl_nif_env_partial_init_from_globalcontext(&dir_env, glb);
150150
glb->posix_dir_resource_type = enif_init_resource_type(&env, "posix_dir", &posix_dir_resource_type_init, ERL_NIF_RT_CREATE, NULL);
151151
if (IS_NULL_PTR(glb->posix_dir_resource_type)) {
152-
#ifndef AVM_NO_SMP
152+
# ifndef AVM_NO_SMP
153153
smp_rwlock_destroy(glb->modules_lock);
154-
#endif
154+
# endif
155155
free(glb->modules_table);
156156
atom_table_destroy(glb->atom_table);
157157
free(glb);
@@ -164,9 +164,9 @@ GlobalContext *globalcontext_new(void)
164164
#ifndef AVM_NO_SMP
165165
glb->schedulers_mutex = smp_mutex_create();
166166
if (IS_NULL_PTR(glb->schedulers_mutex)) {
167-
#if HAVE_OPEN && HAVE_CLOSE
167+
# if HAVE_OPEN && HAVE_CLOSE
168168
resource_type_destroy(glb->posix_fd_resource_type);
169-
#endif
169+
# endif
170170
smp_rwlock_destroy(glb->modules_lock);
171171
free(glb->modules_table);
172172
atom_table_destroy(glb->atom_table);
@@ -176,9 +176,9 @@ GlobalContext *globalcontext_new(void)
176176
glb->schedulers_cv = smp_condvar_create();
177177
if (IS_NULL_PTR(glb->schedulers_cv)) {
178178
smp_mutex_destroy(glb->schedulers_mutex);
179-
#if HAVE_OPEN && HAVE_CLOSE
179+
# if HAVE_OPEN && HAVE_CLOSE
180180
resource_type_destroy(glb->posix_fd_resource_type);
181-
#endif
181+
# endif
182182
smp_rwlock_destroy(glb->modules_lock);
183183
free(glb->modules_table);
184184
atom_table_destroy(glb->atom_table);
@@ -372,7 +372,7 @@ static inline enum SendMessageResult globalcontext_send_message_from_task_common
372372
{
373373
enum SendMessageResult result = SEND_MESSAGE_PROCESS_NOT_FOUND;
374374
bool postponed = false;
375-
#ifndef AVM_NO_SMP
375+
# ifndef AVM_NO_SMP
376376
Context *p = NULL;
377377
if (globalcontext_get_process_trylock(glb, process_id, &p)) {
378378
if (p) {
@@ -394,10 +394,10 @@ static inline enum SendMessageResult globalcontext_send_message_from_task_common
394394
} else {
395395
postponed = true;
396396
}
397-
#else
397+
# else
398398
// Without SMP, we have no lock, so we must always enqueue.
399399
postponed = true;
400-
#endif
400+
# endif
401401
if (postponed) {
402402
if (message == NULL) {
403403
message = mailbox_message_create_from_term(type, t);

src/libAtomVM/globalcontext.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,29 +51,29 @@ extern "C" {
5151
struct Context;
5252

5353
#ifndef TYPEDEF_CONTEXT
54-
#define TYPEDEF_CONTEXT
54+
# define TYPEDEF_CONTEXT
5555
typedef struct Context Context;
5656
#endif
5757

5858
struct Module;
5959

6060
#ifndef TYPEDEF_MODULE
61-
#define TYPEDEF_MODULE
61+
# define TYPEDEF_MODULE
6262
typedef struct Module Module;
6363
#endif
6464

6565
#ifndef TYPEDEF_GLOBALCONTEXT
66-
#define TYPEDEF_GLOBALCONTEXT
66+
# define TYPEDEF_GLOBALCONTEXT
6767
typedef struct GlobalContext GlobalContext;
6868
#endif
6969

7070
#ifndef TYPEDEF_MAILBOXMESSAGE
71-
#define TYPEDEF_MAILBOXMESSAGE
71+
# define TYPEDEF_MAILBOXMESSAGE
7272
typedef struct MailboxMessage MailboxMessage;
7373
#endif
7474

7575
#ifndef TYPEDEF_MESSAGE
76-
#define TYPEDEF_MESSAGE
76+
# define TYPEDEF_MESSAGE
7777
typedef struct Message Message;
7878
#endif
7979

@@ -144,9 +144,9 @@ struct GlobalContext
144144
unsigned long long ATOMIC ref_ticks;
145145
#else
146146
unsigned long long ref_ticks;
147-
#ifndef AVM_NO_SMP
147+
# ifndef AVM_NO_SMP
148148
SpinLock ref_ticks_spinlock;
149-
#endif
149+
# endif
150150
#endif
151151

152152
#ifndef AVM_NO_SMP
@@ -537,14 +537,14 @@ run_result_t globalcontext_run(GlobalContext *global, Module *start_module, FILE
537537
#ifndef __cplusplus
538538
static inline uint64_t globalcontext_get_ref_ticks(GlobalContext *global)
539539
{
540-
#if defined(AVM_NO_SMP) || ATOMIC_LLONG_LOCK_FREE == 2
540+
# if defined(AVM_NO_SMP) || ATOMIC_LLONG_LOCK_FREE == 2
541541
return ++global->ref_ticks;
542-
#else
542+
# else
543543
smp_spinlock_lock(&global->ref_ticks_spinlock);
544544
unsigned long long value = ++global->ref_ticks;
545545
smp_spinlock_unlock(&global->ref_ticks_spinlock);
546546
return value;
547-
#endif
547+
# endif
548548
}
549549
#endif
550550

0 commit comments

Comments
 (0)