Skip to content

Commit

Permalink
format c
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszcz committed May 15, 2024
1 parent 2c5f337 commit 330153f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
14 changes: 9 additions & 5 deletions runtime/c/src/juvix/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@
DECL_TAIL_APPLY_3; \
juvix_program_start:

#define JUVIX_EPILOGUE \
juvix_program_end : STACK_POPT; \
IO_INTERPRET; \
#define JUVIX_EPILOGUE \
juvix_program_end: \
STACK_POPT; \
IO_INTERPRET; \
io_print_toplevel(juvix_result);

// Temporary / local vars
Expand All @@ -44,7 +45,9 @@

// Begin a function definition. `max_stack` is the maximum stack allocation in
// the function.
#define JUVIX_FUNCTION(label, max_stack) label : STACK_ENTER((max_stack))
#define JUVIX_FUNCTION(label, max_stack) \
label: \
STACK_ENTER((max_stack))

/*
Macro sequence for function definition:
Expand All @@ -64,7 +67,8 @@
*/

// Begin a function with no stack allocation.
#define JUVIX_FUNCTION_NS(label) label:
#define JUVIX_FUNCTION_NS(label) \
label:

#define JUVIX_INT_ADD(var0, var1, var2) (var0 = smallint_add(var1, var2))
#define JUVIX_INT_SUB(var0, var1, var2) (var0 = smallint_sub(var1, var2))
Expand Down
2 changes: 1 addition & 1 deletion runtime/c/src/juvix/object/closure.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ EXTEND_CLOSURE(dest, src, n, {
#define DECL_ZEROARG_CLOSURE(name, fuid, largs) \
word_t juvix_zeroarg_closure_data_##name[1 + CLOSURE_SKIP]; \
word_t juvix_zeroarg_closure_##name = \
(word_t) & juvix_zeroarg_closure_data_##name; \
(word_t)&juvix_zeroarg_closure_data_##name; \
INIT_CLOSURE(juvix_zeroarg_closure_##name, fuid, \
LABEL_ADDR(juvix_closure_##name), 0, largs);

Expand Down
12 changes: 6 additions & 6 deletions runtime/c/src/juvix/object/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@

// The least significant two bits encode object kind
#define KIND_MASK 3
#define GET_KIND(x) ((word_t)(x) & KIND_MASK)
#define GET_KIND(x) ((word_t)(x)&KIND_MASK)

#define KIND_PTR 0
#define KIND_UNBOXED0 1
#define KIND_UNBOXED1 3
#define KIND_HEADER 2

#define KIND3_MASK 7
#define GET_KIND3(x) ((word_t)(x) & KIND3_MASK)
#define GET_KIND3(x) ((word_t)(x)&KIND3_MASK)

static inline bool is_unboxed(word_t x) { return x & 1; }
static inline bool is_ptr(word_t x) { return GET_KIND(x) == KIND_PTR; }
Expand Down Expand Up @@ -60,7 +60,7 @@ static inline word_t clear_mark(word_t x) { return x & ~MARK_MASK; }

#define UID_MASK ((word_t)0x00FFFFF0)
#define UID_SHIFT 4U
#define GET_UID(x) (((word_t)(x) & UID_MASK) >> UID_SHIFT)
#define GET_UID(x) (((word_t)(x)&UID_MASK) >> UID_SHIFT)

#define NFIELDS_MASK 0xFF000000
#define NFIELDS_SHIFT 24U
Expand Down Expand Up @@ -105,16 +105,16 @@ static inline bool is_special_header(word_t x) {

#define SUID_MASK ((word_t)0x30)
#define SUID_SHIFT 4U
#define GET_SUID(x) (((word_t)(x) & SUID_MASK) >> SUID_SHIFT)
#define GET_SUID(x) (((word_t)(x)&SUID_MASK) >> SUID_SHIFT)

#define SKIP_MASK ((word_t)0xC0)
#define SKIP_SHIFT 6U
#define GET_SKIP(x) (((word_t)(x) & SKIP_MASK) >> SKIP_SHIFT)
#define GET_SKIP(x) (((word_t)(x)&SKIP_MASK) >> SKIP_SHIFT)
#define SKIP_ALL 3U

#define RESERVED_MASK 0x00FFFF00
#define RESERVED_SHIFT 8U
#define GET_RESERVED(x) (((word_t)(x) & RESERVED_MASK) >> RESERVED_SHIFT)
#define GET_RESERVED(x) (((word_t)(x)&RESERVED_MASK) >> RESERVED_SHIFT)

static inline word_t make_special_header(word_t suid, word_t nfields,
word_t skip, word_t reserved) {
Expand Down

0 comments on commit 330153f

Please sign in to comment.