The OpenD Programming Language

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();