detached 2d5afc8

Clarify Example section and Dl* windows equivalents (#274)

commit
2d5afc8a4b0c49b48c2b6c37dad1512cb24c28a4
author
TotallyGamerJet · · 2024-08-25 13:00 UTC
committer
GitHub · · 2024-08-25 13:00 UTC
parent
5905af5
signature
GPG UnverifiedB5690EEEBB952194 The key is unknown
3 files · +14 -1
M README.md +2 -1
@@ -35,7 +35,8 @@ except for float arguments and return values.
3535
3636 ## Example
3737
38-This example only works on macOS and Linux. For a complete example look at [libc](https://github.com/ebitengine/purego/tree/main/examples/libc) which supports Windows and FreeBSD.
38+The example below only showcases purego use for macOS and Linux. The other platforms require special handling which can
39+be seen in the complete example at [examples/libc](https://github.com/ebitengine/purego/tree/main/examples/libc) which supports Windows and FreeBSD.
3940
4041 ```go
4142 package main
@@ -35,7 +35,8 @@ except for float arguments and return values.
35 35
36 ## Example36 ## Example
37 37
38-This example only works on macOS and Linux. For a complete example look at [libc](https://github.com/ebitengine/purego/tree/main/examples/libc) which supports Windows and FreeBSD.38+The example below only showcases purego use for macOS and Linux. The other platforms require special handling which can
39+be seen in the complete example at [examples/libc](https://github.com/ebitengine/purego/tree/main/examples/libc) which supports Windows and FreeBSD.
39 40
40 ```go41 ```go
41 package main42 package main
M dlerror.go +2 -0
@@ -6,6 +6,8 @@
66 package purego
77
88 // Dlerror represents an error value returned from Dlopen, Dlsym, or Dlclose.
9+//
10+// This type is not available on Windows as there is no counterpart to it on Windows.
911 type Dlerror struct {
1012 s string
1113 }
@@ -6,6 +6,8 @@
6 package purego6 package purego
7 7
8 // Dlerror represents an error value returned from Dlopen, Dlsym, or Dlclose.8 // Dlerror represents an error value returned from Dlopen, Dlsym, or Dlclose.
9+//
10+// This type is not available on Windows as there is no counterpart to it on Windows.
9 type Dlerror struct {11 type Dlerror struct {
10 s string12 s string
11 }13 }
M dlfcn.go +10 -0
@@ -33,6 +33,10 @@ func init() {
3333 // A second call to Dlopen with the same path will return the same handle, but the internal
3434 // reference count for the handle will be incremented. Therefore, all
3535 // Dlopen calls should be balanced with a Dlclose call.
36+//
37+// This function is not available on Windows.
38+// Use [golang.org/x/sys/windows.LoadLibrary], [golang.org/x/sys/windows.NewLazyDLL], or
39+// [golang.org/x/sys/windows.NewLazySystemDLL] for Windows instead.
3640 func Dlopen(path string, mode int) (uintptr, error) {
3741 u := fnDlopen(path, mode)
3842 if u == 0 {
@@ -45,6 +49,9 @@ func Dlopen(path string, mode int) (uintptr, error) {
4549 // It returns the address where that symbol is loaded into memory. If the symbol is not found,
4650 // in the specified library or any of the libraries that were automatically loaded by Dlopen
4751 // when that library was loaded, Dlsym returns zero.
52+//
53+// This function is not available on Windows.
54+// Use [golang.org/x/sys/windows.GetProcAddress] for Windows instead.
4855 func Dlsym(handle uintptr, name string) (uintptr, error) {
4956 u := fnDlsym(handle, name)
5057 if u == 0 {
@@ -56,6 +63,9 @@ func Dlsym(handle uintptr, name string) (uintptr, error) {
5663 // Dlclose decrements the reference count on the dynamic library handle.
5764 // If the reference count drops to zero and no other loaded libraries
5865 // use symbols in it, then the dynamic library is unloaded.
66+//
67+// This function is not available on Windows.
68+// Use [golang.org/x/sys/windows.FreeLibrary] for Windows instead.
5969 func Dlclose(handle uintptr) error {
6070 if fnDlclose(handle) {
6171 return Dlerror{fnDlerror()}
@@ -33,6 +33,10 @@ func init() {
33 // A second call to Dlopen with the same path will return the same handle, but the internal33 // A second call to Dlopen with the same path will return the same handle, but the internal
34 // reference count for the handle will be incremented. Therefore, all34 // reference count for the handle will be incremented. Therefore, all
35 // Dlopen calls should be balanced with a Dlclose call.35 // Dlopen calls should be balanced with a Dlclose call.
36+//
37+// This function is not available on Windows.
38+// Use [golang.org/x/sys/windows.LoadLibrary], [golang.org/x/sys/windows.NewLazyDLL], or
39+// [golang.org/x/sys/windows.NewLazySystemDLL] for Windows instead.
36 func Dlopen(path string, mode int) (uintptr, error) {40 func Dlopen(path string, mode int) (uintptr, error) {
37 u := fnDlopen(path, mode)41 u := fnDlopen(path, mode)
38 if u == 0 {42 if u == 0 {
@@ -45,6 +49,9 @@ func Dlopen(path string, mode int) (uintptr, error) {
45 // It returns the address where that symbol is loaded into memory. If the symbol is not found,49 // It returns the address where that symbol is loaded into memory. If the symbol is not found,
46 // in the specified library or any of the libraries that were automatically loaded by Dlopen50 // in the specified library or any of the libraries that were automatically loaded by Dlopen
47 // when that library was loaded, Dlsym returns zero.51 // when that library was loaded, Dlsym returns zero.
52+//
53+// This function is not available on Windows.
54+// Use [golang.org/x/sys/windows.GetProcAddress] for Windows instead.
48 func Dlsym(handle uintptr, name string) (uintptr, error) {55 func Dlsym(handle uintptr, name string) (uintptr, error) {
49 u := fnDlsym(handle, name)56 u := fnDlsym(handle, name)
50 if u == 0 {57 if u == 0 {
@@ -56,6 +63,9 @@ func Dlsym(handle uintptr, name string) (uintptr, error) {
56 // Dlclose decrements the reference count on the dynamic library handle.63 // Dlclose decrements the reference count on the dynamic library handle.
57 // If the reference count drops to zero and no other loaded libraries64 // If the reference count drops to zero and no other loaded libraries
58 // use symbols in it, then the dynamic library is unloaded.65 // use symbols in it, then the dynamic library is unloaded.
66+//
67+// This function is not available on Windows.
68+// Use [golang.org/x/sys/windows.FreeLibrary] for Windows instead.
59 func Dlclose(handle uintptr) error {69 func Dlclose(handle uintptr) error {
60 if fnDlclose(handle) {70 if fnDlclose(handle) {
61 return Dlerror{fnDlerror()}71 return Dlerror{fnDlerror()}

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