3 //=============================================================================
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"
16 # define ACE_OS_MAIN_H
18 # include /**/ "ace/pre.h"
20 # if !defined (ACE_LACKS_PRAGMA_ONCE)
22 # endif /* ACE_LACKS_PRAGMA_ONCE */
25 # include "ace/MQX_Filesystem.h"
28 # if !defined (ACE_DOESNT_DEFINE_MAIN)
30 #if defined (ACE_VXWORKS) && (ACE_VXWORKS <= 0x640) && defined (__RTP__)
31 # include <resolvLib.h>
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
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"
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 ()); \
56 # elif !defined (ACE_MQX)
57 # define ACE_TMAIN main
58 # endif /* ACE_USES_WCHAR */
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
82 int ACE_MAIN (int, char* []);
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 *[]); \
92 ACE_MAIN (int argc, char *argv[]) /* user's entry point, e.g., main */ \
94 vx_ace_main_i_ptr = ace_main_i; \
95 return ace_os_main_i (argc, argv); /* what the user calls "main" */ \
100 # elif defined (ACE_VXWORKS) && (ACE_VXWORKS <= 0x640) && defined (__RTP__)
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 \
108 ACE_MAIN (int argc, char *argv[]) /* user's entry point, e.g., main */ \
111 return ace_os_main_i (argc, argv); /* what the user calls "main" */ \
116 # elif !defined (ACE_WIN32)
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 \
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 \
133 # if defined (ACE_WIN32) && defined (ACE_USES_WCHAR)
135 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
137 class ACE_Export ACE_Main_Base
140 int run (int, ACE_TCHAR
*[]);
141 virtual int run_i (int, ACE_TCHAR
*[]) = 0;
144 ACE_END_VERSIONED_NAMESPACE_DECL
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); \
157 ACE_WMAIN (int argc, ACE_TCHAR *argv[]) /* user's entry point, e.g., wmain */ \
160 return ace_os_wmain_i (m, argc, argv); /* what the user calls "main" */ \
165 # else /* ! (ACE_WIN32 && ACE_USES_WCHAR) */
167 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
169 class ACE_Export 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) */
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 \
201 ACE_MAIN (int argc, char *argv[]) /* user's entry point, e.g., wmain */ \
204 return m.run (argc, argv); /*ace_os_main_i (m, argc, argv); what the user calls "main" */ \
209 # endif /* ACE_WIN32 && ACE_USES_WCHAR */
211 # endif /* ACE_HAS_NONSTATIC_OBJECT_MANAGER && !ACE_DOESNT_INSTANTIATE_NONSTATIC_OBJECT_MANAGER */
214 # include <iar_dynamic_init.h>
215 # include "ace/MQX_Filesystem.h"
217 ace_main_i(int argc, ACE_TCHAR *argv[]); \
218 static void main_task(uint32_t param) { \
219 __iar_dynamic_initialization(); \
221 MQX_Filesystem::inst ().complete_initialization (); \
224 static TASK_TEMPLATE_STRUCT MQX_template_list[] = { \
225 {1, main_task, 25000, 9, "Main", MQX_AUTO_START_TASK, 0, 0 }, { 0 } \
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 \
234 int main() { return _mqx( (MQX_INITIALIZATION_STRUCT_PTR) &MQX_init_struct ); } \
236 # endif /* ACE_MQX */
238 #endif /* ACE_DOESNT_DEFINE_MAIN */
240 # include /**/ "ace/post.h"
242 #endif /* ACE_OS_MAIN_H */