Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit 6f5a0a9

Browse files
committed
Add module for the crt_externs.h header for Darwin platforms
1 parent 6f27f55 commit 6f5a0a9

File tree

8 files changed

+146
-1
lines changed

8 files changed

+146
-1
lines changed

changelog/crt_externs.dd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Add D header file $(REF_ALTTEXT `core.sys.darwin.crt_externs`, crt_externs, core, sys, darwin) for $(LINK2 https://opensource.apple.com/source/Libc/Libc-1244.30.3/include/crt_externs.h.auto.html, libc/crt_externs.h) on Darwin.
2+
3+
Add D header file $(REF_ALTTEXT `core.sys.darwin.crt_externs`, crt_externs, core, sys, darwin) for $(LINK2 https://opensource.apple.com/source/Libc/Libc-1244.30.3/include/crt_externs.h.auto.html, libc/crt_externs.h) on Darwin.

mak/COPY

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ COPY=\
5454
$(IMPDIR)\core\stdcpp\typeinfo.d \
5555
$(IMPDIR)\core\stdcpp\xutility.d \
5656
\
57+
$(IMPDIR)\core\sys\darwin\crt_externs.d \
58+
$(IMPDIR)\core\sys\darwin\dlfcn.d \
5759
$(IMPDIR)\core\sys\darwin\execinfo.d \
5860
$(IMPDIR)\core\sys\darwin\pthread.d \
5961
\

mak/DOCS

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,19 @@ DOCS=\
5151
$(DOCDIR)\core_sync_rwmutex.html \
5252
$(DOCDIR)\core_sync_semaphore.html \
5353
\
54+
$(DOCDIR)\core_sys_darwin_crt_externs.html \
55+
$(DOCDIR)\core_sys_darwin_dlfcn.html \
56+
$(DOCDIR)\core_sys_darwin_execinfo.html \
57+
$(DOCDIR)\core_sys_darwin_pthread.html \
58+
$(DOCDIR)\core_sys_darwin_mach_dyld.html \
59+
$(DOCDIR)\core_sys_darwin_mach_getsect.html \
60+
$(DOCDIR)\core_sys_darwin_mach_kern_return.html \
61+
$(DOCDIR)\core_sys_darwin_mach_loader.html \
62+
$(DOCDIR)\core_sys_darwin_mach_port.html \
63+
$(DOCDIR)\core_sys_darwin_mach_semaphore.html \
64+
$(DOCDIR)\core_sys_darwin_mach_thread_act.html \
65+
$(DOCDIR)\core_sys_darwin_netinet_in_.html \
66+
\
5467
$(DOCDIR)\rt_aaA.html \
5568
$(DOCDIR)\rt_aApply.html \
5669
$(DOCDIR)\rt_aApplyR.html \

mak/SRCS

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,17 @@ SRCS=\
5858
src\core\sync\rwmutex.d \
5959
src\core\sync\semaphore.d \
6060
\
61+
src\core\sys\darwin\crt_externs.d \
62+
src\core\sys\darwin\dlfcn.d \
63+
src\core\sys\darwin\execinfo.d \
64+
src\core\sys\darwin\pthread.d \
65+
src\core\sys\darwin\mach\dyld.d \
66+
src\core\sys\darwin\mach\getsect.d \
67+
src\core\sys\darwin\mach\kern_return.d \
68+
src\core\sys\darwin\mach\loader.d \
69+
src\core\sys\darwin\mach\port.d \
70+
src\core\sys\darwin\mach\semaphore.d \
71+
src\core\sys\darwin\mach\thread_act.d \
6172
src\core\sys\darwin\netinet\in_.d \
6273
\
6374
src\core\sys\freebsd\dlfcn.d \

mak/WINDOWS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,12 @@ $(IMPDIR)\core\stdcpp\typeinfo.d : src\core\stdcpp\typeinfo.d
198198
$(IMPDIR)\core\stdcpp\xutility.d : src\core\stdcpp\xutility.d
199199
copy $** $@
200200

201+
$(IMPDIR)\core\sys\darwin\crt_externs.d : src\core\sys\darwin\crt_externs.d
202+
copy $** $@
203+
204+
$(IMPDIR)\core\sys\darwin\dlfcn.d : src\core\sys\darwin\dlfcn.d
205+
copy $** $@
206+
201207
$(IMPDIR)\core\sys\darwin\execinfo.d : src\core\sys\darwin\execinfo.d
202208
copy $** $@
203209

posix.mak

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,15 @@ $(DOCDIR)/core_stdcpp_%.html : src/core/stdcpp/%.d $(DMD)
161161
$(DOCDIR)/core_sync_%.html : src/core/sync/%.d $(DMD)
162162
$(DMD) $(DDOCFLAGS) -Df$@ project.ddoc $(DOCFMT) $<
163163

164+
$(DOCDIR)/core_sys_darwin_%.html : src/core/sys/darwin/%.d $(DMD)
165+
$(DMD) $(DDOCFLAGS) -Df$@ project.ddoc $(DOCFMT) $<
166+
167+
$(DOCDIR)/core_sys_darwin_mach_%.html : src/core/sys/darwin/mach/%.d $(DMD)
168+
$(DMD) $(DDOCFLAGS) -Df$@ project.ddoc $(DOCFMT) $<
169+
170+
$(DOCDIR)/core_sys_darwin_netinet_%.html : src/core/sys/darwin/netinet/%.d $(DMD)
171+
$(DMD) $(DDOCFLAGS) -Df$@ project.ddoc $(DOCFMT) $<
172+
164173
$(DOCDIR)/rt_%.html : src/rt/%.d $(DMD)
165174
$(DMD) $(DDOCFLAGS) -Df$@ project.ddoc $(DOCFMT) $<
166175

src/core/sys/darwin/crt_externs.d

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
/**
2+
* D header file for $(LINK2 https://opensource.apple.com/source/Libc/Libc-1244.30.3/include/crt_externs.h.auto.html, libc/crt_externs.h).
3+
*
4+
* Copyright: Copyright (c) 2018 D Language Foundation
5+
* License: $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
6+
* Authors: Jacob Carlborg
7+
* Source: $(DRUNTIMESRC core/sys/darwin/_crt_externs.d)
8+
*/
9+
module core.sys.darwin.crt_externs;
10+
11+
version (CoreDoc)
12+
{
13+
/**
14+
* In reality this will be $(REF mach_header, core, sys, darwin, mach, loader)
15+
* on 32-bit platforms and $(REF mach_header_64, core, sys, darwin, mach, loader)
16+
* 64-bit platforms.
17+
*/
18+
struct MachHeader;
19+
20+
/**
21+
* Returns the program arguments.
22+
*
23+
* These are the same arguments passed to the C main function:
24+
*
25+
* ___
26+
* extern (C) void main (char** argv, int argc, char** envp) {}
27+
* ___
28+
*
29+
* Same as the above `argv`.
30+
*
31+
* Return: the program arguments as a pointer to an array of null terminated C
32+
* strings
33+
*/
34+
char*** _NSGetArgv();
35+
36+
/**
37+
* Returns the number of program arguments.
38+
*
39+
* These are the same arguments passed to the C main function:
40+
*
41+
* ___
42+
* extern (C) void main (char** argv, int argc, char** envp) {}
43+
* ___
44+
*
45+
* Same as the above `argc`.
46+
*
47+
* Return: a pointer to the number of program arguments
48+
*/
49+
int* _NSGetArgc();
50+
51+
/**
52+
* Returns the program environment variables.
53+
*
54+
* These are the same arguments passed as an array to the C main function:
55+
*
56+
* ___
57+
* extern (C) void main (char** argv, int argc, char** envp) {}
58+
* ___
59+
*
60+
* Same as the above `envp`.
61+
*
62+
* Return: the program environment variables as a pointer to an array of null
63+
* terminated C strings
64+
*/
65+
char*** _NSGetEnviron();
66+
67+
/**
68+
* Returns the full path to the current executable as a pointer to a null
69+
* terminated C string.
70+
*/
71+
char** _NSGetProgname();
72+
73+
/// Returns the Mach-O header of the current executable.
74+
MachHeader* _NSGetMachExecuteHeader();
75+
}
76+
77+
else version (OSX)
78+
version = Darwin;
79+
else version (iOS)
80+
version = Darwin;
81+
else version (TVOS)
82+
version = Darwin;
83+
else version (WatchOS)
84+
version = Darwin;
85+
86+
version (Darwin):
87+
extern(C):
88+
nothrow:
89+
@nogc:
90+
91+
import core.sys.darwin.mach.loader : mach_header, mach_header_64;
92+
93+
char*** _NSGetArgv();
94+
int* _NSGetArgc();
95+
char*** _NSGetEnviron();
96+
char** _NSGetProgname();
97+
98+
version (D_LP64)
99+
mach_header_64* _NSGetMachExecuteHeader();
100+
else
101+
mach_header* _NSGetMachExecuteHeader();

src/core/sys/darwin/mach/getsect.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ version (CoreDdoc)
320320
* Params:
321321
* mhp = the mach header to get the section from
322322
* segname = the name of the segment
323-
* sectname = the name of the section
323+
* section = the name of the section
324324
* fSwap = ?
325325
*
326326
* Returns: a pointer to the section structure or `null` if it doesn't exist

0 commit comments

Comments
 (0)