Skip to content
This repository has been archived by the owner on May 18, 2024. It is now read-only.

Commit

Permalink
__atomic_load_n
Browse files Browse the repository at this point in the history
  • Loading branch information
xushiwei committed Apr 12, 2022
1 parent 37bc26b commit 0c1e70e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
5 changes: 4 additions & 1 deletion cl/codebuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ const builtin_decls = `{
"__builtin___memcpy_chk": "void* (void*, void*, uint, uint)",
"__builtin_object_size": "uint (void*, int32)",
"__atomic_store_n_i32": "void (int32*, int, int32)",
"__atomic_store_n_i64": "void (int64*, int, int64)"
"__atomic_store_n_i64": "void (int64*, int, int64)",
"__atomic_load_n_i32": "int32 (int32*, int)",
"__atomic_load_n_i64": "int64 (int64*, int)"
}`

type overloadFn struct {
Expand All @@ -38,6 +40,7 @@ type overloadFn struct {
var (
builtin_overloads = []overloadFn{
{name: "__atomic_store_n", overloads: []string{"__atomic_store_n_i32", "__atomic_store_n_i64"}},
{name: "__atomic_load_n", overloads: []string{"__atomic_load_n_i32", "__atomic_load_n_i64"}},
}
)

Expand Down
2 changes: 1 addition & 1 deletion testdata/atomic/atomic.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ int main() {
__atomic_store_n(&a, 100, 0);
printf("atomic: %lld\n", a);
__atomic_store_n(&b, a!=0, 0);
printf("atomic: %d\n", b);
printf("atomic: %d\n", __atomic_load_n(&b, 0));
return 0;
}
8 changes: 8 additions & 0 deletions testdata/atomic/libc.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ func __atomic_store_n_i64(p *int64, memorder int32, v int64) {
*p = v
}

func __atomic_load_n_i32(p *int32, memorder int32) int32 {
return *p
}

func __atomic_load_n_i64(p *int64, memorder int32) int64 {
return *p
}

func __swbuf(_c int32, _p *FILE) int32 {
return _c
}
Expand Down

0 comments on commit 0c1e70e

Please sign in to comment.