Skip to content

Commit

Permalink
tests/rtdl: Add a regression test for #960
Browse files Browse the repository at this point in the history
  • Loading branch information
qookei committed Dec 21, 2023
1 parent b78244e commit c643fd3
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/rtdl/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ rtdl_test_cases = [
'scope3',
'scope4',
'scope5',
'tls_align',
]

foreach test_name : rtdl_test_cases
Expand Down
1 change: 1 addition & 0 deletions tests/rtdl/tls_align/libbar.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_Thread_local __attribute__((aligned(8))) char bar_thread_local[8] = "Hello!";
1 change: 1 addition & 0 deletions tests/rtdl/tls_align/libfoo.c
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_Thread_local __attribute__((aligned(16))) char foo_thread_local[8] = "Hello!";
7 changes: 7 additions & 0 deletions tests/rtdl/tls_align/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
libfoo = shared_library('foo', 'libfoo.c')
libbar = shared_library('bar', 'libbar.c')
test_link_with = [libfoo, libbar]

libfoo_native = shared_library('native-foo', 'libfoo.c', native: true)
libbar_native = shared_library('native-bar', 'libbar.c', native: true)
test_native_link_with = [libfoo_native, libbar_native]
10 changes: 10 additions & 0 deletions tests/rtdl/tls_align/test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <assert.h>
#include <stdint.h>

extern _Thread_local char foo_thread_local[];
extern _Thread_local char bar_thread_local[];

int main() {
assert(!((uintptr_t)foo_thread_local & (16 - 1)));
assert(!((uintptr_t)bar_thread_local & (8 - 1)));
}

0 comments on commit c643fd3

Please sign in to comment.