Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / ace / OS_main.h
blob873e4e0ecb424c5188c22d89a0dc71bbaed83042
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file OS_main.h
7 * @author Douglas C. Schmidt <d.schmidt@vanderbilt.edu>
8 * @author Jesper S. M|ller<stophph@diku.dk>
9 * @author and a cast of thousands...
11 //=============================================================================
13 #include /**/ "ace/ACE_export.h"
15 #ifndef ACE_OS_MAIN_H
16 # define ACE_OS_MAIN_H
18 # include /**/ "ace/pre.h"
20 # if !defined (ACE_LACKS_PRAGMA_ONCE)
21 # pragma once
22 # endif /* ACE_LACKS_PRAGMA_ONCE */
24 #if defined (ACE_MQX)
25 # include "ace/MQX_Filesystem.h"
26 #endif
28 # if !defined (ACE_DOESNT_DEFINE_MAIN)
30 #if defined (ACE_VXWORKS) && (ACE_VXWORKS <= 0x640) && defined (__RTP__)
31 # include <resolvLib.h>
32 #endif
34 # if !defined (ACE_MAIN)
35 # define ACE_MAIN main
36 # endif /* ! ACE_MAIN */
38 # if !defined (ACE_WMAIN)
39 # define ACE_WMAIN wmain
40 # endif /* ! ACE_WMAIN */
42 # if defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
43 # define ACE_TMAIN wmain
44 # else
45 # if defined (ACE_USES_WCHAR) /* Not Win32, but uses wchar */
46 // Replace main() with a version that converts the char** argv to
47 // ACE_TCHAR and calls the ACE_TMAIN entrypoint.
48 # include "ace/Argv_Type_Converter.h"
49 # define ACE_TMAIN \
50 ace_main_i (int, ACE_TCHAR *[]); /* forward declaration */ \
51 int main (int argc, char *argv[]) { \
52 ACE_Argv_Type_Converter wide_argv (argc, argv); \
53 return ace_main_i (argc, wide_argv.get_TCHAR_argv ()); \
54 } \
55 int ace_main_i
56 # elif !defined (ACE_MQX)
57 # define ACE_TMAIN main
58 # endif /* ACE_USES_WCHAR */
59 # endif
61 # if defined (ACE_DOESNT_INSTANTIATE_NONSTATIC_OBJECT_MANAGER)
62 # if !defined (ACE_HAS_NONSTATIC_OBJECT_MANAGER)
63 # define ACE_HAS_NONSTATIC_OBJECT_MANAGER
64 # endif /* ACE_HAS_NONSTATIC_OBJECT_MANAGER */
65 # endif /* ACE_DOESNT_INSTANTIATE_NONSTATIC_OBJECT_MANAGER */
67 # if defined (ACE_HAS_NONSTATIC_OBJECT_MANAGER) \
68 && !defined (ACE_DOESNT_INSTANTIATE_NONSTATIC_OBJECT_MANAGER)
70 // Rename "main ()" on platforms that don't allow it to be called "main ()".
72 # if defined (ACE_VXWORKS) && !defined (__RTP__)
74 typedef int (*ace_main_proc_ptr)(int, char *[]);
76 extern ace_main_proc_ptr vx_ace_main_i_ptr;
78 // Declare ACE_MAIN as extern C so that it can be retrieved
79 // using symFindByName
80 extern "C"
82 int ACE_MAIN (int, char* []);
85 # define main \
86 ACE_MAIN (int, char *[]); /* forward decl to gobble up the 'int' if there is one */ \
87 ACE_BEGIN_VERSIONED_NAMESPACE_DECL \
88 int ace_os_main_i (int, char *[]); \
89 ACE_END_VERSIONED_NAMESPACE_DECL \
90 int ace_main_i(int, char *[]); \
91 int \
92 ACE_MAIN (int argc, char *argv[]) /* user's entry point, e.g., main */ \
93 { \
94 vx_ace_main_i_ptr = ace_main_i; \
95 return ace_os_main_i (argc, argv); /* what the user calls "main" */ \
96 } \
97 int \
98 ace_main_i
100 # elif defined (ACE_VXWORKS) && (ACE_VXWORKS <= 0x640) && defined (__RTP__)
102 # define main \
103 ACE_MAIN (int, char *[]); /* forward decl to gobble up the 'int' if there is one */ \
104 ACE_BEGIN_VERSIONED_NAMESPACE_DECL \
105 int ace_os_main_i (int, char *[]); \
106 ACE_END_VERSIONED_NAMESPACE_DECL \
107 int \
108 ACE_MAIN (int argc, char *argv[]) /* user's entry point, e.g., main */ \
110 resolvInit(); \
111 return ace_os_main_i (argc, argv); /* what the user calls "main" */ \
113 int \
114 ace_main_i
116 # elif !defined (ACE_WIN32)
118 # define main \
119 ACE_MAIN (int, char *[]); /* forward decl to gobble up the 'int' if there is one */ \
120 ACE_BEGIN_VERSIONED_NAMESPACE_DECL \
121 ACE_Export int ace_os_main_i (int, char *[]); \
122 ACE_END_VERSIONED_NAMESPACE_DECL \
123 int \
124 ACE_MAIN (int argc, char *argv[]) /* user's entry point, e.g., main */ \
126 return ace_os_main_i (argc, argv); /* what the user calls "main" */ \
128 ACE_Proper_Export_Flag int \
129 ace_main_i
131 # else
133 # if defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
135 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
137 class ACE_Export ACE_Main_Base
139 public:
140 int run (int, ACE_TCHAR *[]);
141 virtual int run_i (int, ACE_TCHAR *[]) = 0;
144 ACE_END_VERSIONED_NAMESPACE_DECL
146 # define wmain \
147 ace_wmain_i (int, ACE_TCHAR *[]); \
148 ACE_BEGIN_VERSIONED_NAMESPACE_DECL \
149 ACE_Export int ace_os_wmain_i (ACE_Main_Base&, int, ACE_TCHAR *[]); \
150 class ACE_Main : public ACE_Main_Base {int run_i (int, ACE_TCHAR *[]);}; \
151 ACE_END_VERSIONED_NAMESPACE_DECL \
152 inline int ACE_Main::run_i (int argc, ACE_TCHAR *argv[]) \
154 return ace_wmain_i (argc, argv); \
156 int \
157 ACE_WMAIN (int argc, ACE_TCHAR *argv[]) /* user's entry point, e.g., wmain */ \
159 ACE_Main m; \
160 return ace_os_wmain_i (m, argc, argv); /* what the user calls "main" */ \
162 int \
163 ace_wmain_i
165 # else /* ! (ACE_WIN32 && ACE_USES_WCHAR) */
167 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
169 class ACE_Export ACE_Main_Base
171 public:
172 ACE_Main_Base ();
173 virtual ~ACE_Main_Base ();
174 int run (int, char *[]);
175 virtual int run_i (int, char *[]) = 0;
178 ACE_END_VERSIONED_NAMESPACE_DECL
181 ** LabVIEW RT cannot directly use an executable. Need to build the program
182 ** as a DLL and call it from something else. The ACE test framework knows this
183 ** trick and uses a LabVIEW RT target-resident control program to load a
184 ** DLL, look up it's main() entrypoint, and call it.
186 # if defined (ACE_BUILD_LABVIEW_EXE_AS_DLL)
187 extern "C" __declspec (dllexport) int main (int, char *[]);
188 # endif /* ACE_BUILD_LABVIEW_EXE_AS_DLL) */
190 # define main \
191 ace_main_i (int, char *[]); \
192 ACE_BEGIN_VERSIONED_NAMESPACE_DECL \
193 ACE_Export int ace_os_main_i (ACE_Main_Base&, int, char *[]); \
194 class ACE_Main : public ACE_Main_Base {int run_i (int, char *[]);}; \
195 inline int ACE_Main::run_i (int argc, char *argv[]) \
197 return ace_main_i (argc, argv); \
199 ACE_END_VERSIONED_NAMESPACE_DECL \
200 int \
201 ACE_MAIN (int argc, char *argv[]) /* user's entry point, e.g., wmain */ \
203 ACE_Main m; \
204 return m.run (argc, argv); /*ace_os_main_i (m, argc, argv); what the user calls "main" */ \
206 int \
207 ace_main_i
209 # endif /* ACE_WIN32 && ACE_USES_WCHAR */
210 # endif
211 # endif /* ACE_HAS_NONSTATIC_OBJECT_MANAGER && !ACE_DOESNT_INSTANTIATE_NONSTATIC_OBJECT_MANAGER */
213 # ifdef ACE_MQX
214 # include <iar_dynamic_init.h>
215 # include "ace/MQX_Filesystem.h"
216 # define ACE_TMAIN \
217 ace_main_i(int argc, ACE_TCHAR *argv[]); \
218 static void main_task(uint32_t param) { \
219 __iar_dynamic_initialization(); \
220 RTCS_create(); \
221 MQX_Filesystem::inst ().complete_initialization (); \
222 ace_main_i(0, 0); \
224 static TASK_TEMPLATE_STRUCT MQX_template_list[] = { \
225 {1, main_task, 25000, 9, "Main", MQX_AUTO_START_TASK, 0, 0 }, { 0 } \
226 }; \
227 static const MQX_INITIALIZATION_STRUCT MQX_init_struct = { \
228 BSP_DEFAULT_PROCESSOR_NUMBER, BSP_DEFAULT_START_OF_KERNEL_MEMORY, \
229 BSP_DEFAULT_END_OF_KERNEL_MEMORY, BSP_DEFAULT_INTERRUPT_STACK_SIZE, \
230 MQX_template_list, BSP_DEFAULT_MQX_HARDWARE_INTERRUPT_LEVEL_MAX, \
231 BSP_DEFAULT_MAX_MSGPOOLS, BSP_DEFAULT_MAX_MSGQS, \
232 BSP_DEFAULT_IO_CHANNEL, (char const*)BSP_DEFAULT_IO_OPEN_MODE, 0, 0 \
233 }; \
234 int main() { return _mqx( (MQX_INITIALIZATION_STRUCT_PTR) &MQX_init_struct ); } \
235 int ace_main_i
236 # endif /* ACE_MQX */
238 #endif /* ACE_DOESNT_DEFINE_MAIN */
240 # include /**/ "ace/post.h"
242 #endif /* ACE_OS_MAIN_H */