detached ec7a70a

rename libc_* to purego_* (#50)

While porting purego to Linux I discovered that I had missed the cgo_import_dynamic comment for pthread_sigmask. The reason purego was working was because the symbol is normally linked to in the runtime. I decided to make a unique name for the imported symbol so that we aren't relying on runtime behavior that can easily change.
commit
ec7a70a975491a130b940b79c9b41e66bcaba65f
author
TotallyGamerJet · · 2022-10-21 17:39 UTC
committer
GitHub · · 2022-10-21 17:39 UTC
parent
7128aea
signature
GPG Unverified4AEE18F83AFDEB23 The key is unknown
4 files · +34 -33
M dlfcn_darwin.go +4 -4
@@ -3,7 +3,7 @@
33
44 package purego
55
6-//go:cgo_import_dynamic _dlopen dlopen "/usr/lib/libSystem.B.dylib"
7-//go:cgo_import_dynamic _dlsym dlsym "/usr/lib/libSystem.B.dylib"
8-//go:cgo_import_dynamic _dlerror dlerror "/usr/lib/libSystem.B.dylib"
9-//go:cgo_import_dynamic _dlclose dlclose "/usr/lib/libSystem.B.dylib"
6+//go:cgo_import_dynamic purego_dlopen dlopen "/usr/lib/libSystem.B.dylib"
7+//go:cgo_import_dynamic purego_dlsym dlsym "/usr/lib/libSystem.B.dylib"
8+//go:cgo_import_dynamic purego_dlerror dlerror "/usr/lib/libSystem.B.dylib"
9+//go:cgo_import_dynamic purego_dlclose dlclose "/usr/lib/libSystem.B.dylib"
@@ -3,7 +3,7 @@
3 3
4 package purego4 package purego
5 5
6-//go:cgo_import_dynamic _dlopen dlopen "/usr/lib/libSystem.B.dylib"6+//go:cgo_import_dynamic purego_dlopen dlopen "/usr/lib/libSystem.B.dylib"
7-//go:cgo_import_dynamic _dlsym dlsym "/usr/lib/libSystem.B.dylib"7+//go:cgo_import_dynamic purego_dlsym dlsym "/usr/lib/libSystem.B.dylib"
8-//go:cgo_import_dynamic _dlerror dlerror "/usr/lib/libSystem.B.dylib"8+//go:cgo_import_dynamic purego_dlerror dlerror "/usr/lib/libSystem.B.dylib"
9-//go:cgo_import_dynamic _dlclose dlclose "/usr/lib/libSystem.B.dylib"9+//go:cgo_import_dynamic purego_dlclose dlclose "/usr/lib/libSystem.B.dylib"
M dlfcn_stubs.s +4 -4
@@ -8,20 +8,20 @@
88
99 // func dlopen(path *byte, mode int) (ret uintptr)
1010 TEXT dlopen(SB), NOSPLIT, $0-0
11- JMP _dlopen(SB)
11+ JMP purego_dlopen(SB)
1212 RET
1313
1414 // func dlsym(handle uintptr, symbol *byte) (ret uintptr)
1515 TEXT dlsym(SB), NOSPLIT, $0-0
16- JMP _dlsym(SB)
16+ JMP purego_dlsym(SB)
1717 RET
1818
1919 // func dlerror() (ret *byte)
2020 TEXT dlerror(SB), NOSPLIT, $0-0
21- JMP _dlerror(SB)
21+ JMP purego_dlerror(SB)
2222 RET
2323
2424 // func dlclose(handle uintptr) (ret int)
2525 TEXT dlclose(SB), NOSPLIT, $0-0
26- JMP _dlclose(SB)
26+ JMP purego_dlclose(SB)
2727 RET
@@ -8,20 +8,20 @@
8 8
9 // func dlopen(path *byte, mode int) (ret uintptr)9 // func dlopen(path *byte, mode int) (ret uintptr)
10 TEXT dlopen(SB), NOSPLIT, $0-010 TEXT dlopen(SB), NOSPLIT, $0-0
11- JMP _dlopen(SB)11+ JMP purego_dlopen(SB)
12 RET12 RET
13 13
14 // func dlsym(handle uintptr, symbol *byte) (ret uintptr)14 // func dlsym(handle uintptr, symbol *byte) (ret uintptr)
15 TEXT dlsym(SB), NOSPLIT, $0-015 TEXT dlsym(SB), NOSPLIT, $0-0
16- JMP _dlsym(SB)16+ JMP purego_dlsym(SB)
17 RET17 RET
18 18
19 // func dlerror() (ret *byte)19 // func dlerror() (ret *byte)
20 TEXT dlerror(SB), NOSPLIT, $0-020 TEXT dlerror(SB), NOSPLIT, $0-0
21- JMP _dlerror(SB)21+ JMP purego_dlerror(SB)
22 RET22 RET
23 23
24 // func dlclose(handle uintptr) (ret int)24 // func dlclose(handle uintptr) (ret int)
25 TEXT dlclose(SB), NOSPLIT, $0-025 TEXT dlclose(SB), NOSPLIT, $0-0
26- JMP _dlclose(SB)26+ JMP purego_dlclose(SB)
27 RET27 RET
M internal/fakecgo/symbols_darwin.go +13 -12
@@ -3,15 +3,16 @@
33
44 package fakecgo
55
6-//go:cgo_import_dynamic libc_malloc malloc "libSystem.dylib"
7-//go:cgo_import_dynamic libc_free free "libSystem.dylib"
8-//go:cgo_import_dynamic libc_setenv setenv "libSystem.dylib"
9-//go:cgo_import_dynamic libc_unsetenv unsetenv "libSystem.dylib"
10-//go:cgo_import_dynamic libc_pthread_attr_init pthread_attr_init "libSystem.dylib"
11-//go:cgo_import_dynamic libc_pthread_create pthread_create "libSystem.dylib"
12-//go:cgo_import_dynamic libc_pthread_detach pthread_detach "libSystem.dylib"
13-//go:cgo_import_dynamic libc_pthread_attr_destroy pthread_attr_destroy "libSystem.dylib"
14-//go:cgo_import_dynamic libc_pthread_attr_getstacksize pthread_attr_getstacksize "libSystem.dylib"
15-//go:cgo_import_dynamic libc_abort abort "libSystem.dylib"
16-//go:cgo_import_dynamic libc_sigfillset sigfillset "libSystem.dylib"
17-//go:cgo_import_dynamic libc_nanosleep nanosleep "libSystem.dylib"
6+//go:cgo_import_dynamic purego_malloc malloc "libSystem.dylib"
7+//go:cgo_import_dynamic purego_free free "libSystem.dylib"
8+//go:cgo_import_dynamic purego_setenv setenv "libSystem.dylib"
9+//go:cgo_import_dynamic purego_unsetenv unsetenv "libSystem.dylib"
10+//go:cgo_import_dynamic purego_pthread_attr_init pthread_attr_init "libSystem.dylib"
11+//go:cgo_import_dynamic purego_pthread_create pthread_create "libSystem.dylib"
12+//go:cgo_import_dynamic purego_pthread_detach pthread_detach "libSystem.dylib"
13+//go:cgo_import_dynamic purego_pthread_attr_destroy pthread_attr_destroy "libSystem.dylib"
14+//go:cgo_import_dynamic purego_pthread_attr_getstacksize pthread_attr_getstacksize "libSystem.dylib"
15+//go:cgo_import_dynamic purego_pthread_sigmask pthread_sigmask "libSystem.dylib"
16+//go:cgo_import_dynamic purego_abort abort "libSystem.dylib"
17+//go:cgo_import_dynamic purego_sigfillset sigfillset "libSystem.dylib"
18+//go:cgo_import_dynamic purego_nanosleep nanosleep "libSystem.dylib"
@@ -3,15 +3,16 @@
3 3
4 package fakecgo4 package fakecgo
5 5
6-//go:cgo_import_dynamic libc_malloc malloc "libSystem.dylib"6+//go:cgo_import_dynamic purego_malloc malloc "libSystem.dylib"
7-//go:cgo_import_dynamic libc_free free "libSystem.dylib"7+//go:cgo_import_dynamic purego_free free "libSystem.dylib"
8-//go:cgo_import_dynamic libc_setenv setenv "libSystem.dylib"8+//go:cgo_import_dynamic purego_setenv setenv "libSystem.dylib"
9-//go:cgo_import_dynamic libc_unsetenv unsetenv "libSystem.dylib"9+//go:cgo_import_dynamic purego_unsetenv unsetenv "libSystem.dylib"
10-//go:cgo_import_dynamic libc_pthread_attr_init pthread_attr_init "libSystem.dylib"10+//go:cgo_import_dynamic purego_pthread_attr_init pthread_attr_init "libSystem.dylib"
11-//go:cgo_import_dynamic libc_pthread_create pthread_create "libSystem.dylib"11+//go:cgo_import_dynamic purego_pthread_create pthread_create "libSystem.dylib"
12-//go:cgo_import_dynamic libc_pthread_detach pthread_detach "libSystem.dylib"12+//go:cgo_import_dynamic purego_pthread_detach pthread_detach "libSystem.dylib"
13-//go:cgo_import_dynamic libc_pthread_attr_destroy pthread_attr_destroy "libSystem.dylib"13+//go:cgo_import_dynamic purego_pthread_attr_destroy pthread_attr_destroy "libSystem.dylib"
14-//go:cgo_import_dynamic libc_pthread_attr_getstacksize pthread_attr_getstacksize "libSystem.dylib"14+//go:cgo_import_dynamic purego_pthread_attr_getstacksize pthread_attr_getstacksize "libSystem.dylib"
15-//go:cgo_import_dynamic libc_abort abort "libSystem.dylib"15+//go:cgo_import_dynamic purego_pthread_sigmask pthread_sigmask "libSystem.dylib"
16-//go:cgo_import_dynamic libc_sigfillset sigfillset "libSystem.dylib"16+//go:cgo_import_dynamic purego_abort abort "libSystem.dylib"
17-//go:cgo_import_dynamic libc_nanosleep nanosleep "libSystem.dylib"17+//go:cgo_import_dynamic purego_sigfillset sigfillset "libSystem.dylib"
18+//go:cgo_import_dynamic purego_nanosleep nanosleep "libSystem.dylib"
M internal/fakecgo/trampolines_stubs_darwin.s +13 -13
@@ -6,53 +6,53 @@
66 // these stubs are here because it is not possible to go:linkname directly the C functions on darwin arm64
77
88 TEXT _malloc(SB), NOSPLIT, $0-0
9- JMP libc_malloc(SB)
9+ JMP purego_malloc(SB)
1010 RET
1111
1212 TEXT _free(SB), NOSPLIT, $0-0
13- JMP libc_free(SB)
13+ JMP purego_free(SB)
1414 RET
1515
1616 TEXT _setenv(SB), NOSPLIT, $0-0
17- JMP libc_setenv(SB)
17+ JMP purego_setenv(SB)
1818 RET
1919
2020 TEXT _unsetenv(SB), NOSPLIT, $0-0
21- JMP libc_unsetenv(SB)
21+ JMP purego_unsetenv(SB)
2222 RET
2323
2424 TEXT _pthread_attr_init(SB), NOSPLIT, $0-0
25- JMP libc_pthread_attr_init(SB)
25+ JMP purego_pthread_attr_init(SB)
2626 RET
2727
2828 TEXT _pthread_create(SB), NOSPLIT, $0-0
29- JMP libc_pthread_create(SB)
29+ JMP purego_pthread_create(SB)
3030 RET
3131
3232 TEXT _pthread_detach(SB), NOSPLIT, $0-12
33- JMP libc_pthread_detach(SB)
33+ JMP purego_pthread_detach(SB)
3434 RET
3535
3636 TEXT _pthread_sigmask(SB), NOSPLIT, $0-0
37- JMP libc_pthread_sigmask(SB)
37+ JMP purego_pthread_sigmask(SB)
3838 RET
3939
4040 TEXT _pthread_attr_getstacksize(SB), NOSPLIT, $0-0
41- JMP libc_pthread_attr_getstacksize(SB)
41+ JMP purego_pthread_attr_getstacksize(SB)
4242 RET
4343
4444 TEXT _pthread_attr_destroy(SB), NOSPLIT, $0-0
45- JMP libc_pthread_attr_destroy(SB)
45+ JMP purego_pthread_attr_destroy(SB)
4646 RET
4747
4848 TEXT _abort(SB), NOSPLIT, $0-0
49- JMP libc_abort(SB)
49+ JMP purego_abort(SB)
5050 RET
5151
5252 TEXT _nanosleep(SB), NOSPLIT, $0-0
53- JMP libc_nanosleep(SB)
53+ JMP purego_nanosleep(SB)
5454 RET
5555
5656 TEXT _sigfillset(SB), NOSPLIT, $0-12
57- CALL libc_sigfillset(SB)
57+ CALL purego_sigfillset(SB)
5858 RET
@@ -6,53 +6,53 @@
6 // these stubs are here because it is not possible to go:linkname directly the C functions on darwin arm646 // these stubs are here because it is not possible to go:linkname directly the C functions on darwin arm64
7 7
8 TEXT _malloc(SB), NOSPLIT, $0-08 TEXT _malloc(SB), NOSPLIT, $0-0
9- JMP libc_malloc(SB)9+ JMP purego_malloc(SB)
10 RET10 RET
11 11
12 TEXT _free(SB), NOSPLIT, $0-012 TEXT _free(SB), NOSPLIT, $0-0
13- JMP libc_free(SB)13+ JMP purego_free(SB)
14 RET14 RET
15 15
16 TEXT _setenv(SB), NOSPLIT, $0-016 TEXT _setenv(SB), NOSPLIT, $0-0
17- JMP libc_setenv(SB)17+ JMP purego_setenv(SB)
18 RET18 RET
19 19
20 TEXT _unsetenv(SB), NOSPLIT, $0-020 TEXT _unsetenv(SB), NOSPLIT, $0-0
21- JMP libc_unsetenv(SB)21+ JMP purego_unsetenv(SB)
22 RET22 RET
23 23
24 TEXT _pthread_attr_init(SB), NOSPLIT, $0-024 TEXT _pthread_attr_init(SB), NOSPLIT, $0-0
25- JMP libc_pthread_attr_init(SB)25+ JMP purego_pthread_attr_init(SB)
26 RET26 RET
27 27
28 TEXT _pthread_create(SB), NOSPLIT, $0-028 TEXT _pthread_create(SB), NOSPLIT, $0-0
29- JMP libc_pthread_create(SB)29+ JMP purego_pthread_create(SB)
30 RET30 RET
31 31
32 TEXT _pthread_detach(SB), NOSPLIT, $0-1232 TEXT _pthread_detach(SB), NOSPLIT, $0-12
33- JMP libc_pthread_detach(SB)33+ JMP purego_pthread_detach(SB)
34 RET34 RET
35 35
36 TEXT _pthread_sigmask(SB), NOSPLIT, $0-036 TEXT _pthread_sigmask(SB), NOSPLIT, $0-0
37- JMP libc_pthread_sigmask(SB)37+ JMP purego_pthread_sigmask(SB)
38 RET38 RET
39 39
40 TEXT _pthread_attr_getstacksize(SB), NOSPLIT, $0-040 TEXT _pthread_attr_getstacksize(SB), NOSPLIT, $0-0
41- JMP libc_pthread_attr_getstacksize(SB)41+ JMP purego_pthread_attr_getstacksize(SB)
42 RET42 RET
43 43
44 TEXT _pthread_attr_destroy(SB), NOSPLIT, $0-044 TEXT _pthread_attr_destroy(SB), NOSPLIT, $0-0
45- JMP libc_pthread_attr_destroy(SB)45+ JMP purego_pthread_attr_destroy(SB)
46 RET46 RET
47 47
48 TEXT _abort(SB), NOSPLIT, $0-048 TEXT _abort(SB), NOSPLIT, $0-0
49- JMP libc_abort(SB)49+ JMP purego_abort(SB)
50 RET50 RET
51 51
52 TEXT _nanosleep(SB), NOSPLIT, $0-052 TEXT _nanosleep(SB), NOSPLIT, $0-0
53- JMP libc_nanosleep(SB)53+ JMP purego_nanosleep(SB)
54 RET54 RET
55 55
56 TEXT _sigfillset(SB), NOSPLIT, $0-1256 TEXT _sigfillset(SB), NOSPLIT, $0-12
57- CALL libc_sigfillset(SB)57+ CALL purego_sigfillset(SB)
58 RET58 RET

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 102

↑↓ moveenter openesc close