Skip to content

Commit

Permalink
Merge pull request #364 from lf-lang/windows-c11
Browse files Browse the repository at this point in the history
No use of C11 threads on Windows/Mac
  • Loading branch information
lhstrh authored Feb 23, 2024
2 parents aaa38d8 + 7b3ce0d commit b67cdad
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 17 deletions.
8 changes: 4 additions & 4 deletions .github/scripts/check-diff.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ changes() {
git diff --name-only HEAD $(git merge-base HEAD origin/main)
}

if changes | grep "$2" | grep -q -v "^.*md\|txt$"; then
echo "changed_$3=1" >> $GITHUB_OUTPUT
if changes | grep "$1" | grep -q -v "^.*md\|txt$"; then
echo "changed_$2=1" >> $GITHUB_OUTPUT
else
echo "changed_$3=0" >> $GITHUB_OUTPUT
fi
echo "changed_$2=0" >> $GITHUB_OUTPUT
fi
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
with:
runtime-ref: ${{ github.ref }}
compiler-ref: ${{ needs.fetch-lf.outputs.ref }}
all-platforms: ${{ needs.check-diff.outputs.run_macos == 'true' || needs.check-diff.outputs.run_macos == 'true' }}
all-platforms: ${{ needs.check-diff.outputs.run_macos == 'true' || needs.check-diff.outputs.run_windows == 'true' }}

lf-python:
needs: [fetch-lf, check-diff]
Expand All @@ -72,7 +72,7 @@ jobs:
runtime-ref: ${{ github.ref }}
compiler-ref: ${{ needs.fetch-lf.outputs.ref }}
scheduler: GEDF_NP
all-platforms: ${{ needs.check-diff.outputs.run_macos == 'true' || needs.check-diff.outputs.run_macos == 'true' }}
all-platforms: ${{ needs.check-diff.outputs.run_macos == 'true' || needs.check-diff.outputs.run_windows == 'true' }}

lf-adaptive:
needs: [fetch-lf, check-diff]
Expand All @@ -81,4 +81,4 @@ jobs:
runtime-ref: ${{ github.ref }}
compiler-ref: ${{ needs.fetch-lf.outputs.ref }}
scheduler: ADAPTIVE
all-platforms: ${{ needs.check-diff.outputs.run_macos == 'true' || needs.check-diff.outputs.run_macos == 'true' }}
all-platforms: ${{ needs.check-diff.outputs.run_macos == 'true' || needs.check-diff.outputs.run_windows == 'true' }}
1 change: 1 addition & 0 deletions core/modal_models/modes.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "modes.h"
#include "reactor.h"
#include "reactor_common.h"
#include "api/schedule.h"

// Bit masks for the internally used flags on modes
#define _LF_MODE_FLAG_MASK_ACTIVE (1 << 0)
Expand Down
5 changes: 0 additions & 5 deletions core/platform/lf_windows_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,6 @@ int lf_available_cores() {
return sysinfo.dwNumberOfProcessors;
}

#if __STDC_VERSION__ < 201112L || defined (__STDC_NO_THREADS__) // (Not C++11 or later) or no threads support

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 Expand Up @@ -297,9 +295,6 @@ int _lf_cond_timedwait(lf_cond_t* cond, instant_t wakeup_time) {
// Success
return 0;
}
#else // If there is C11 support
#include "lf_C11_threads_support.c"
#endif
#endif


Expand Down
4 changes: 0 additions & 4 deletions include/core/platform/lf_windows_support.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <windows.h>

#if !defined LF_SINGLE_THREADED
#if __STDC_VERSION__ < 201112L || defined (__STDC_NO_THREADS__)
/**
* On Windows, one could use both a mutex or
* a critical section for the same purpose. However,
Expand All @@ -62,9 +61,6 @@ THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
CONDITION_VARIABLE condition;
} lf_cond_t;
typedef HANDLE lf_thread_t;
#else
#include "lf_C11_threads_support.h"
#endif
#endif

// Use 64-bit times and 32-bit unsigned microsteps
Expand Down
2 changes: 1 addition & 1 deletion lingua-franca-ref.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
further-cleanup
windows-c11

0 comments on commit b67cdad

Please sign in to comment.