xref: /netbsd-src/external/gpl3/gcc.old/dist/libphobos/libdruntime/__entrypoint.di (revision 4c3eb207d36f67d31994830c0a694161fc1ca39b)
1627f7eb2Smrg/* GDC -- D front-end for GCC
2*4c3eb207Smrg   Copyright (C) 2013-2020 Free Software Foundation, Inc.
3627f7eb2Smrg
4627f7eb2Smrg   GCC is free software; you can redistribute it and/or modify it under
5627f7eb2Smrg   the terms of the GNU General Public License as published by the Free
6627f7eb2Smrg   Software Foundation; either version 3, or (at your option) any later
7627f7eb2Smrg   version.
8627f7eb2Smrg
9627f7eb2Smrg   GCC is distributed in the hope that it will be useful, but WITHOUT ANY
10627f7eb2Smrg   WARRANTY; without even the implied warranty of MERCHANTABILITY or
11627f7eb2Smrg   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12627f7eb2Smrg   for more details.
13627f7eb2Smrg
14627f7eb2Smrg   You should have received a copy of the GNU General Public License
15627f7eb2Smrg   along with GCC; see the file COPYING3.  If not see
16627f7eb2Smrg   <http://www.gnu.org/licenses/>.
17627f7eb2Smrg*/
18627f7eb2Smrg
19627f7eb2Smrg/* This module provides the C main() function supplied by the user's program.  */
20627f7eb2Smrg
21627f7eb2Smrgmodule __entrypoint;
22627f7eb2Smrg
23627f7eb2Smrgextern(C):
24627f7eb2Smrg
25627f7eb2Smrg/* The D main() function supplied by the user's program
26627f7eb2Smrg
27627f7eb2Smrg   It always has `_Dmain` symbol name and uses C calling convention.
28627f7eb2Smrg   But D frontend returns its type as `extern(D)` because of Issue 9028.
29627f7eb2Smrg   As we need to deal with actual calling convention we have to mark it
30627f7eb2Smrg   as `extern(C)` and use its symbol name.
31627f7eb2Smrg*/
32627f7eb2Smrg
33627f7eb2Smrgint _Dmain(char[][] args);
34627f7eb2Smrgint _d_run_main(int argc, char **argv, void* mainFunc);
35627f7eb2Smrg
36627f7eb2Smrg/* Substitutes for the C main() function.  Just calls into d_run_main with
37627f7eb2Smrg   the default main function.  Applications are free to implement their own
38627f7eb2Smrg   main function and call the _d_run_main function themselves with any main
39627f7eb2Smrg   function.
40627f7eb2Smrg*/
41627f7eb2Smrg
42627f7eb2Smrgint main(int argc, char **argv)
43627f7eb2Smrg{
44627f7eb2Smrg    return _d_run_main(argc, argv, &_Dmain);
45627f7eb2Smrg}
46627f7eb2Smrg
47627f7eb2Smrg/* This is apparently needed on Solaris because the C tool chain seems to
48627f7eb2Smrg   expect the main function to be called _main.  It needs both not just one!
49627f7eb2Smrg*/
50627f7eb2Smrg
51627f7eb2Smrgversion (Solaris)
52627f7eb2Smrgint _main(int argc, char** argv)
53627f7eb2Smrg{
54627f7eb2Smrg    return main(argc, argv);
55627f7eb2Smrg}
56627f7eb2Smrg
57