Skip to content

Commit

Permalink
Merge pull request #456 from lf-lang/initialize-master-thread-id-windows
Browse files Browse the repository at this point in the history
Fix compilation errors in `initialize-master-thread-id`
  • Loading branch information
cmnrd authored Jun 28, 2024
2 parents e14a891 + 7a8d18a commit ebc2443
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
10 changes: 10 additions & 0 deletions low_level_platform/impl/src/lf_arduino_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,16 @@ typedef void* (*lf_function_t)(void*);
*/
int lf_available_cores() { return 1; }

lf_thread_t lf_thread_self() {
// Not implemented. Although Arduino mbed provides a ThisThread API and a
// get_id() function, it does not provide a way to get the current thread as a
// Thread object.
// N.B. This wrong implementation will eventually cause hard-to-debug
// segfaults, but it unblocks us from conveniently implementing features for
// other platforms, and it does not break existing features for Arduino.
return NULL;
}

int lf_thread_create(lf_thread_t* thread, void* (*lf_thread)(void*), void* arguments) {
lf_thread_t t = thread_new();
long int start = thread_start(t, *lf_thread, arguments);
Expand Down
7 changes: 7 additions & 0 deletions low_level_platform/impl/src/lf_flexpret_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,13 @@ int lf_available_cores() {
return FP_THREADS - 1; // Return the number of Flexpret HW threads
}

lf_thread_t lf_thread_self() {
// N.B. This wrong implementation will eventually cause hard-to-debug
// segfaults, but it unblocks us from conveniently implementing features for
// other platforms, and it does not break existing features for FlexPRET.
return NULL;
}

int lf_thread_create(lf_thread_t* thread, void* (*lf_thread)(void*), void* arguments) {
/**
* Need to select between HRTT or SRTT; see
Expand Down
2 changes: 2 additions & 0 deletions low_level_platform/impl/src/lf_windows_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ int lf_available_cores() {
return sysinfo.dwNumberOfProcessors;
}

lf_thread_t lf_thread_self() { return GetCurrentThread(); }

int lf_thread_create(lf_thread_t* thread, void* (*lf_thread)(void*), void* arguments) {
uintptr_t handle = _beginthreadex(NULL, 0, lf_thread, arguments, 0, NULL);
*thread = (HANDLE)handle;
Expand Down

0 comments on commit ebc2443

Please sign in to comment.