Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the C runtime thread-safe #776

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions runtimes/c/runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@
#include <dates_calc.h>
#include "runtime.h"

int catala_persistent_malloc_mode_on = 0;
__thread int catala_persistent_malloc_mode_on = 0;

/* --- Error handling --- */

const catala_code_position catala_empty_position =
__thread const catala_code_position catala_empty_position =
{ NULL, 0, 0, 0, 0 };

struct catala_error catala_error_raised =
__thread struct catala_error catala_error_raised =
{ catala_empty_position, 0 };

jmp_buf catala_error_jump_buffer;
__thread jmp_buf catala_error_jump_buffer;

void catala_error(catala_error_code code,
const catala_code_position * pos)
Expand All @@ -59,7 +59,7 @@ struct catala_heap
struct catala_heap* next;
};

struct catala_heap catala_heap = {NULL, NULL, NULL, NULL};
__thread struct catala_heap catala_heap = {NULL, NULL, NULL, NULL};

#define MALLOC_CHECK(PTR) \
if (PTR == NULL) { \
Expand Down