This repository has been archived by the owner on Jan 24, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes errno to work on single-threaded targets, adds CI
- Loading branch information
Felix "xq" Queißner
committed
Jan 5, 2024
1 parent
3e7253b
commit 4c159fa
Showing
3 changed files
with
41 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Continuous Integration | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
build: | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, windows-latest, macos-latest] | ||
single_thread: [true, false] | ||
|
||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Zig | ||
uses: goto-bus-stop/setup-zig@v2 | ||
with: | ||
version: 0.11.0 | ||
|
||
- name: Generate and validate packages | ||
run: | | ||
zig build -Dsingle-threaded=${{ matrix.single_thread }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
//! implementation of `errno.h` | ||
|
||
const std = @import("std"); | ||
const builtin = @import("builtin"); | ||
|
||
threadlocal var errno: c_int = 0; | ||
const storage = if (builtin.single_threaded) | ||
struct { | ||
var errno: c_int = 0; // regular variable on single-threaded systems | ||
} | ||
else | ||
struct { | ||
threadlocal var errno: c_int = 0; // thread-local variable on multi-threaded systems | ||
}; | ||
|
||
export fn __get_errno() *c_int { | ||
return &errno; | ||
return &storage.errno; | ||
} |