diff options
author | Drew DeVault <sir@cmpwn.com> | 2023-01-31 19:33:47 +0100 |
---|---|---|
committer | Michael Forney <mforney@mforney.org> | 2024-04-19 20:30:01 -0700 |
commit | 0c1f837141457574bd71ef0d761613ba6a941380 (patch) | |
tree | 78877e94444d1e26d4c4d9e9448e4c1508db0697 /test | |
parent | d345c729b2418f5f536e7fc401047a9a473bdf01 (diff) |
implement _Thread_local storage class
Implements: https://todo.sr.ht/~mcf/cproc/8
Diffstat (limited to 'test')
-rw-r--r-- | test/thread-local.c | 10 | ||||
-rw-r--r-- | test/thread-local.qbe | 23 |
2 files changed, 33 insertions, 0 deletions
diff --git a/test/thread-local.c b/test/thread-local.c new file mode 100644 index 0000000..3086699 --- /dev/null +++ b/test/thread-local.c @@ -0,0 +1,10 @@ +thread_local int a = 1; +static thread_local int b = 2; +extern thread_local int c = 3; +thread_local int d; +static thread_local int e; +extern thread_local int f; +int main(void) { + static thread_local int x = 6; + return a + b + c + d + e - x; +} diff --git a/test/thread-local.qbe b/test/thread-local.qbe new file mode 100644 index 0000000..0e9ba83 --- /dev/null +++ b/test/thread-local.qbe @@ -0,0 +1,23 @@ +thread export data $a = align 4 { w 1, } +thread data $b = align 4 { w 2, } +thread export data $c = align 4 { w 3, } +thread export data $d = align 4 { z 4 } +thread data $e = align 4 { z 4 } +thread data $.Lx.2 = align 4 { w 6, } +export +function w $main() { +@start.1 +@body.2 + %.1 =w loadw thread $a + %.2 =w loadw thread $b + %.3 =w add %.1, %.2 + %.4 =w loadw thread $c + %.5 =w add %.3, %.4 + %.6 =w loadw thread $d + %.7 =w add %.5, %.6 + %.8 =w loadw thread $e + %.9 =w add %.7, %.8 + %.10 =w loadw thread $.Lx.2 + %.11 =w sub %.9, %.10 + ret %.11 +} |