From 9d09d138082b61e001fdca1b547a70aab36a25ed Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Fri, 22 May 1998 11:03:03 +0000 Subject: Added main() which did not require C++ support. A different main is used based on whether C++ is enabled or disabled. --- c/src/lib/libbsp/unix/posix/startup/Makefile.in | 14 ++++++- c/src/lib/libbsp/unix/posix/startup/main.c | 54 +++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 c/src/lib/libbsp/unix/posix/startup/main.c (limited to 'c/src/lib/libbsp') diff --git a/c/src/lib/libbsp/unix/posix/startup/Makefile.in b/c/src/lib/libbsp/unix/posix/startup/Makefile.in index ce2a77744c..d09765cd19 100644 --- a/c/src/lib/libbsp/unix/posix/startup/Makefile.in +++ b/c/src/lib/libbsp/unix/posix/startup/Makefile.in @@ -12,11 +12,11 @@ PGM=${ARCH}/startup.rel NO_CTOR_LIB=${ARCH}/libno-ctor.a # C source names, if any, go here -- minus the .c -C_PIECES=bspclean bsplibc bspstart setvec +C_PIECES=bspclean bsplibc bspstart setvec $(C_MAIN) C_FILES=$(C_PIECES:%=%.c) C_O_FILES=$(C_PIECES:%=${ARCH}/%.o) -CC_PIECES=rtems-ctor +CC_PIECES=$(CXX_MAIN) CC_FILES=$(CC_PIECES:%=%.cc) CC_O_FILES=$(CC_PIECES:%=${ARCH}/%.o) @@ -32,6 +32,16 @@ INSTALLED_O_FILES=$(ARCH)/rtems-ctor.o include $(RTEMS_ROOT)/make/custom/$(RTEMS_BSP).cfg include $(RTEMS_ROOT)/make/leaf.cfg +ifeq ($(RTEMS_HAS_CPLUSPLUS),yes) +NO_CTOR_LIB=${ARCH}/libno-ctor.a +INSTALLED_O_FILES=$(ARCH)/rtems-ctor.o +CXX_MAIN=rtems-ctor +C_MAIN= +else +CXX_MAIN= +C_MAIN=main +endif + # # (OPTIONAL) Add local stuff here using += # diff --git a/c/src/lib/libbsp/unix/posix/startup/main.c b/c/src/lib/libbsp/unix/posix/startup/main.c new file mode 100644 index 0000000000..520cd36b04 --- /dev/null +++ b/c/src/lib/libbsp/unix/posix/startup/main.c @@ -0,0 +1,54 @@ +/* + * Description: + * This file exists solely to (try to) ensure RTEMS is initialized. + * It is not to be used in systems which want C++ support. + * + * $Id$ + */ + +#include +#include +#include + +/* + * RTEMS program name + * Probably not used by anyone, but it is nice to have it. + * Actually the UNIX version of CPU_INVOKE_DEBUGGER will probably + * need to use it + */ + +char *rtems_progname; + +int main( + int argc, + char **argv +) +{ + rtems_argc = argc; + rtems_argv = argv; + + bsp_start(); + + if ((argc > 0) && argv && argv[0]) + rtems_progname = argv[0]; + else + rtems_progname = "RTEMS"; + + /* + * Start multitasking + */ + + rtems_initialize_executive_late( bsp_isr_level ); + + /* + * Returns when multitasking is stopped + * This allows our destructors to get run normally + */ + + fflush( stdout ); + fflush( stderr ); + + bsp_cleanup(); + + return 0; +} -- cgit v1.2.3