diff options
author | dhinton <dhinton@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-11-07 21:11:00 +0000 |
---|---|---|
committer | dhinton <dhinton@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2003-11-07 21:11:00 +0000 |
commit | 4cd070f36a6d311a58507836b91099a928d07664 (patch) | |
tree | ccf999976dcc0546e732acef65cfe3840b93a7c8 /ace/OS_main.h | |
parent | b868c47847846dcd617e969d1ed9c32fe1b44547 (diff) | |
download | ATCD-4cd070f36a6d311a58507836b91099a928d07664.tar.gz |
ChangeLogTag:Fri Nov 7 21:09:01 UTC 2003 Don Hinton <dhinton@dresystems.com>
Diffstat (limited to 'ace/OS_main.h')
-rw-r--r-- | ace/OS_main.h | 138 |
1 files changed, 35 insertions, 103 deletions
diff --git a/ace/OS_main.h b/ace/OS_main.h index 6263408b02b..50b18a0dc61 100644 --- a/ace/OS_main.h +++ b/ace/OS_main.h @@ -14,13 +14,13 @@ */ //============================================================================= +#include "ace/config-all.h" + #ifndef ACE_OS_MAIN_H # define ACE_OS_MAIN_H # include /**/ "ace/pre.h" -# include "ace/config-all.h" - # if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once # endif /* ACE_LACKS_PRAGMA_ONCE */ @@ -45,68 +45,48 @@ # endif /* ACE_HAS_NONSTATIC_OBJECT_MANAGER */ # endif /* ACE_DOESNT_INSTANTIATE_NONSTATIC_OBJECT_MANAGER */ -# if defined (ACE_HAS_NONSTATIC_OBJECT_MANAGER) && !defined (ACE_DOESNT_INSTANTIATE_NONSTATIC_OBJECT_MANAGER) - -# if !defined (ACE_HAS_MINIMAL_ACE_OS) -# include "ace/Object_Manager.h" -# endif /* ! ACE_HAS_MINIMAL_ACE_OS */ +# if defined (ACE_HAS_NONSTATIC_OBJECT_MANAGER) \ + && !defined (ACE_DOESNT_INSTANTIATE_NONSTATIC_OBJECT_MANAGER) // Rename "main ()" on platforms that don't allow it to be called "main ()". -// Also, create ACE_Object_Manager static instance(s) in "main ()". -// ACE_MAIN_OBJECT_MANAGER defines the ACE_Object_Manager(s) that will -// be instantiated on the stack of main (). Note that it is only used -// when compiling main (): its value does not affect the contents of -// ace/OS.o. -# if !defined (ACE_MAIN_OBJECT_MANAGER) -# define ACE_MAIN_OBJECT_MANAGER \ - ACE_OS_Object_Manager ace_os_object_manager; \ - ACE_Object_Manager ace_object_manager; -# endif /* ! ACE_MAIN_OBJECT_MANAGER */ - -# if defined (ACE_PSOSIM) -// PSOSIM root lacks the standard argc, argv command line parameters, -// create dummy argc and argv in the "real" main and pass to "user" main. -// NOTE: ACE_MAIN must be defined to give the return type as well as the -// name of the entry point. +# if defined (ACE_PSOSIM) + || (defined (ACE_PSOS) && defined (ACE_PSOS_LACKS_ARGC_ARGV)) + # define main \ -ace_main_i (int, char *[]); /* forward declaration */ \ +ace_os_main_i (int, char *[]); \ ACE_MAIN () /* user's entry point, e.g., "main" w/out argc, argv */ \ { \ - int argc = 1; /* dummy arg count */ \ - char *argv[] = {"psosim"}; /* dummy arg list */ \ - ACE_MAIN_OBJECT_MANAGER \ - int ret_val = -1; /* assume the worst */ \ - if (ACE_PSOS_Time_t::init_simulator_time ()) /* init simulator time */ \ - { \ - ACE_ERROR((LM_ERROR, "init_simulator_time failed\n")); /* report */ \ - } \ - else \ - { \ - ret_val = ace_main_i (argc, argv); /* call user main, save result */ \ - } \ - ACE_OS::exit (ret_val); /* pass code to simulator exit */ \ + ace_os_main_i (argc, argv); /* what the user calls "main" */ \ } \ int \ ace_main_i -# elif defined (ACE_PSOS) && defined (ACE_PSOS_LACKS_ARGC_ARGV) -// PSOS root lacks the standard argc, argv command line parameters, -// create dummy argc and argv in the "real" main and pass to "user" main. -// Ignore return value from user main as well. NOTE: ACE_MAIN must be -// defined to give the return type as well as the name of the entry point + +# elif !defined (ACE_WINCE) + # define main \ -ace_main_i (int, char *[]); /* forward declaration */ \ -ACE_MAIN () /* user's entry point, e.g., "main" w/out argc, argv */ \ +ace_os_main_i (int, char *[]); \ +int \ +ACE_MAIN (int argc, char *argv[]) /* user's entry point, e.g., main */ \ +{ \ + return ace_os_main_i (argc, argv); /* what the user calls "main" */ \ +} \ +int \ +ace_main_i + +# if defined (ACE_WIN32) +# define wmain \ +ace_os_wmain_i (int, ACE_TCHAR *[]); +int \ +ACE_WMAIN (int argc, ACE_TCHAR *argv[]) /* user's entry point, e.g., wmain */ \ { \ - int argc = 1; /* dummy arg count */ \ - char *argv[] = {"root"}; /* dummy arg list */ \ - ACE_MAIN_OBJECT_MANAGER \ - ace_main_i (argc, argv); /* call user main, ignore result */ \ + return ace_os_wmain_i (argc, argv); /* what the user calls "main" */ \ } \ int \ ace_main_i +# endif /* ACE_WIN32 */ -# elif defined (ACE_HAS_WINCE) +# else /* ACE_HAS_WINCE */ # if defined (ACE_TMAIN) // Use WinMain on CE; others give warning/error. # undef ACE_TMAIN @@ -120,36 +100,20 @@ ace_main_i // CE had CommandLineToArgvW()... but it's only on NT3.5 and up. # define ACE_TMAIN \ -ace_main_i (int, ACE_TCHAR *[]); /* forward declaration */ \ +ace_os_wintmain_i (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow); /* forward declaration */ \ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow) \ { \ - ACE_TCHAR cmdline[1024]; \ - ACE_OS::strcpy (cmdline, ACE_LIB_TEXT ("program ")); \ - ACE_OS::strcat (cmdline, lpCmdLine); \ - ACE_ARGV ce_argv (cmdline); \ - ACE::init (); \ - ACE_MAIN_OBJECT_MANAGER \ - int i = ace_main_i (ce_argv.argc (), ce_argv.argv ()); \ - ACE::fini (); \ - return i; \ + return ace_os_wintmain_i (hInstance, hPrevInstance, lpCmdLine, nCmdShow); \ } \ int ace_main_i // Support for wchar_t but still can't fit to CE because of the command // line parameters. # define wmain \ -ace_main_i (int, ACE_TCHAR *[]); /* forward declaration */ \ +ace_os_winwmain_i (int, ACE_TCHAR *[]); /* forward declaration */ \ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow) \ { \ - ACE_TCHAR cmdline[1024]; \ - ACE_OS::strcpy (cmdline, ACE_LIB_TEXT ("program ")); \ - ACE_OS::strcat (cmdline, lpCmdLine); \ - ACE_ARGV ce_argv (cmdline); \ - ACE::init (); \ - ACE_MAIN_OBJECT_MANAGER \ - int i = ace_main_i (ce_argv.argc (), ce_argv.argv ()); \ - ACE::fini (); \ - return i; \ + return ace_os_winwmain_i (hInstance, hPrevInstance, lpCmdLine, nCmdShow); \ } \ int ace_main_i @@ -158,45 +122,13 @@ int ace_main_i // expansion, so it needs to go out here. # include "ace/Argv_Type_Converter.h" # define main \ -ace_main_i (int, char *[]); /* forward declaration */ \ +ace_os_winmain_i (int, char *[]); /* forward declaration */ \ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow) \ { \ - ACE_TCHAR cmdline[1024]; \ - ACE_OS::strcpy (cmdline, ACE_LIB_TEXT ("program ")); \ - ACE_OS::strcat (cmdline, lpCmdLine); \ - ACE_ARGV ce_argv (cmdline); \ - ACE::init (); \ - ACE_MAIN_OBJECT_MANAGER \ - ACE_Argv_Type_Converter command_line (ce_argv.argc (), ce_argv.argv ()); \ - int i = ace_main_i (command_line.get_argc(), command_line.get_ASCII_argv());\ - ACE::fini (); \ - return i; \ + return ace_os_winmain_i (hInstance, hPrevInstance, lpCmdLine, nCmdShow); \ } \ int ace_main_i -# else -# define main \ -ace_main_i (int, char *[]); /* forward declaration */ \ -int \ -ACE_MAIN (int argc, char *argv[]) /* user's entry point, e.g., main */ \ -{ \ - ACE_MAIN_OBJECT_MANAGER \ - return ace_main_i (argc, argv); /* what the user calls "main" */ \ -} \ -int \ -ace_main_i -# if defined (ACE_WIN32) -# define wmain \ -ace_main_i (int, ACE_TCHAR *[]); /* forward declaration */ \ -int \ -ACE_WMAIN (int argc, ACE_TCHAR *argv[]) /* user's entry point, e.g., main */ \ -{ \ - ACE_MAIN_OBJECT_MANAGER \ - return ace_main_i (argc, argv); /* what the user calls "main" */ \ -} \ -int \ -ace_main_i -# endif /* ACE_WIN32 && UNICODE */ # endif /* ACE_PSOSIM */ # endif /* ACE_HAS_NONSTATIC_OBJECT_MANAGER && !ACE_HAS_WINCE && !ACE_DOESNT_INSTANTIATE_NONSTATIC_OBJECT_MANAGER */ |