Skip to content

Commit 6b285f1

Browse files
committed
dlopennote: update documentation and internal variable names
1 parent 98944ec commit 6b285f1

File tree

1 file changed

+23
-41
lines changed

1 file changed

+23
-41
lines changed

include/SDL3/SDL_dlopennote.h

Lines changed: 23 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -28,26 +28,7 @@
2828
* dynamic shared library dependencies.
2929
*
3030
* If you determine that your toolchain doesn't support dlopen notes, you can
31-
* disable this feature by defining `SDL_DISABLE_DLOPEN_NOTES`. You can use
32-
* this CMake snippet to check for support:
33-
*
34-
* ```cmake
35-
* set(CHECK_ELF_DLNOTES_SRC [==[
36-
* #ifndef __ELF__
37-
* ELF DL notes is only supported on ELF platforms
38-
* #endif
39-
* __attribute__ ((used,aligned(4),section(".note.dlopen"))) static const struct {
40-
* struct { int a; int b; int c; } hdr; char name[4]; __attribute__((aligned(4))) char json[24];
41-
* } dlnote = { { 4, 0x407c0c0aU, 16 }, "FDO", "[\\"a\\":{\\"a\\":\\"1\\",\\"b\\":\\"2\\"}]" };
42-
* int main(int argc, char *argv[]) {
43-
* return argc + dlnote.hdr.a;
44-
* }
45-
* ]==])
46-
* check_c_source_compiles("${CHECK_ELF_DLNOTES_SRC}" COMPILER_SUPPORTS_ELFNOTES)
47-
* if(NOT COMPILER_SUPPORTS_ELFNOTES)
48-
* set(SDL_DISABLE_DLOPEN_NOTES TRUE)
49-
* endif()
50-
* ```
31+
* disable this feature by defining `SDL_DISABLE_DLOPEN_NOTES`.
5132
*/
5233

5334
#ifndef SDL_dlopennote_h
@@ -141,29 +122,30 @@
141122
#define SDL_ELF_NOTE_INTERNAL(json, variable_name) \
142123
SDL_ELF_NOTE_INTERNAL2(json, variable_name)
143124

144-
#define SDL_SONAME_ARRAY1(N1) "[\"" N1 "\"]"
145-
#define SDL_SONAME_ARRAY2(N1,N2) "[\"" N1 "\",\"" N2 "\"]"
146-
#define SDL_SONAME_ARRAY3(N1,N2,N3) "[\"" N1 "\",\"" N2 "\",\"" N3 "\"]"
147-
#define SDL_SONAME_ARRAY4(N1,N2,N3,N4) "[\"" N1 "\",\"" N2 "\",\"" N3 "\",\"" N4 "\"]"
148-
#define SDL_SONAME_ARRAY5(N1,N2,N3,N4,N5) "[\"" N1 "\",\"" N2 "\",\"" N3 "\",\"" N4 "\",\"" N5 "\"]"
149-
#define SDL_SONAME_ARRAY6(N1,N2,N3,N4,N5,N6) "[\"" N1 "\",\"" N2 "\",\"" N3 "\",\"" N4 "\",\"" N5 "\",\"" N6 "\"]"
150-
#define SDL_SONAME_ARRAY7(N1,N2,N3,N4,N5,N6,N7) "[\"" N1 "\",\"" N2 "\",\"" N3 "\",\"" N4 "\",\"" N5 "\",\"" N6 "\",\"" N7 "\"]"
151-
#define SDL_SONAME_ARRAY8(N1,N2,N3,N4,N5,N6,N7,N8) "[\"" N1 "\",\"" N2 "\",\"" N3 "\",\"" N4 "\",\"" N5 "\",\"" N6 "\",\"" N7 "\",\"" N8 "\"]"
152-
#define SDL_SONAME_ARRAY_GET(N1,N2,N3,N4,N5,N6,N7,N8,NAME,...) NAME
153-
#define SDL_SONAME_ARRAY(...) \
154-
SDL_SONAME_ARRAY_GET(__VA_ARGS__, \
155-
SDL_SONAME_ARRAY8, \
156-
SDL_SONAME_ARRAY7, \
157-
SDL_SONAME_ARRAY6, \
158-
SDL_SONAME_ARRAY5, \
159-
SDL_SONAME_ARRAY4, \
160-
SDL_SONAME_ARRAY3, \
161-
SDL_SONAME_ARRAY2, \
162-
SDL_SONAME_ARRAY1 \
125+
#define SDL_ELF_JSON_ARRAY1(N1) "[\"" N1 "\"]"
126+
#define SDL_ELF_JSON_ARRAY2(N1,N2) "[\"" N1 "\",\"" N2 "\"]"
127+
#define SDL_ELF_JSON_ARRAY3(N1,N2,N3) "[\"" N1 "\",\"" N2 "\",\"" N3 "\"]"
128+
#define SDL_ELF_JSON_ARRAY4(N1,N2,N3,N4) "[\"" N1 "\",\"" N2 "\",\"" N3 "\",\"" N4 "\"]"
129+
#define SDL_ELF_JSON_ARRAY5(N1,N2,N3,N4,N5) "[\"" N1 "\",\"" N2 "\",\"" N3 "\",\"" N4 "\",\"" N5 "\"]"
130+
#define SDL_ELF_JSON_ARRAY6(N1,N2,N3,N4,N5,N6) "[\"" N1 "\",\"" N2 "\",\"" N3 "\",\"" N4 "\",\"" N5 "\",\"" N6 "\"]"
131+
#define SDL_ELF_JSON_ARRAY7(N1,N2,N3,N4,N5,N6,N7) "[\"" N1 "\",\"" N2 "\",\"" N3 "\",\"" N4 "\",\"" N5 "\",\"" N6 "\",\"" N7 "\"]"
132+
#define SDL_ELF_JSON_ARRAY8(N1,N2,N3,N4,N5,N6,N7,N8) "[\"" N1 "\",\"" N2 "\",\"" N3 "\",\"" N4 "\",\"" N5 "\",\"" N6 "\",\"" N7 "\",\"" N8 "\"]"
133+
#define SDL_ELF_JSON_ARRAY_GET(N1,N2,N3,N4,N5,N6,N7,N8,NAME,...) NAME
134+
#define SDL_ELF_JSON_ARRAY(...) \
135+
SDL_ELF_JSON_ARRAY_GET( \
136+
__VA_ARGS__, \
137+
SDL_ELF_JSON_ARRAY8, \
138+
SDL_ELF_JSON_ARRAY7, \
139+
SDL_ELF_JSON_ARRAY6, \
140+
SDL_ELF_JSON_ARRAY5, \
141+
SDL_ELF_JSON_ARRAY4, \
142+
SDL_ELF_JSON_ARRAY3, \
143+
SDL_ELF_JSON_ARRAY2, \
144+
SDL_ELF_JSON_ARRAY1 \
163145
)(__VA_ARGS__)
164146

165147
/* Create "unique" variable name using __LINE__,
166-
* so creating elf notes on the same line is not supported
148+
* so creating multiple elf notes on the same line is not supported
167149
*/
168150
#define SDL_ELF_NOTE_JOIN2(A,B) A##B
169151
#define SDL_ELF_NOTE_JOIN(A,B) SDL_ELF_NOTE_JOIN2(A,B)
@@ -206,7 +188,7 @@
206188
"[{\"feature\":\"" feature \
207189
"\",\"description\":\"" description \
208190
"\",\"priority\":\"" priority \
209-
"\",\"soname\":" SDL_SONAME_ARRAY(__VA_ARGS__) "}]", \
191+
"\",\"soname\":" SDL_ELF_JSON_ARRAY(__VA_ARGS__) "}]", \
210192
SDL_ELF_NOTE_UNIQUE_NAME)
211193

212194
#elif defined(__GNUC__) && __GNUC__ < 3

0 commit comments

Comments
 (0)