Yuri Dario wrote:
Hi Stephan,


I looked at new main.h code, and I propose to change it as follows:

#ifdef SAL_OS2

int SAL_CALL osl_setExceptionHook( void);
int SAL_CALL osl_unsetExceptionHook( void);
#define SET_EXCEPTION_HOOK      if (osl_setExceptionHook()==0) {
#define UNSET_EXCEPTION_HOOK    } osl_unsetExceptionHook()

#else

#define SET_EXCEPTION_HOOK
#define UNSET_EXCEPTION_HOOK

#endif

#define SAL_MAIN_WITH_ARGS_IMPL \
int SAL_CALL main(int argc, char ** argv) \
{ \
        int rc; \
        SET_EXCEPTION_HOOK; \
        osl_setCommandArgs(argc, argv); \
        rc = sal_main_with_args(argc, argv); \
        UNSET_EXCEPTION_HOOK; \
        return rc; \
}

#define SAL_MAIN_IMPL \
int SAL_CALL main(int argc, char ** argv) \
{ \
        int rc; \
        SET_EXCEPTION_HOOK; \
        osl_setCommandArgs(argc, argv); \
        rc = sal_main(); \
        UNSET_EXCEPTION_HOOK; \
        return rc; \
}


the new macros are used to install the OS/2 exception handler, so I can
wrap program execution and dump stack frames at crash.

If you know a better way to put it in common code, please let me know.

On CWS sb71, we faced a similar problem (needing initialization and deinitialization around sal_main on Windows) and changed SAL_MAIN_WITH_ARGS_IMPL (and correspondingly SAL_MAIN_IMPL) to

#define SAL_MAIN_WITH_ARGS_IMPL \
int SAL_CALL main(int argc, char ** argv) \
{ \
        int ret; \
        sal_detail_initialize(argc, argv);   \
        ret = sal_main_with_args(argc, argv); \
        sal_detail_deinitialize(); \
        return ret; \
}

(see sal/rtl/sal/main.h:1.7.68.2 l. 50--58). CWS sb71 is not yet integrated, but planned to be ready for integration on October 5. So I would suggest you move your OS/2-specific osl_[un]setExceptionHook functionality into sal_detail_[de]initialize once CWS sb71 is integrated. (Also, it is probably not a good idea anyway to silently not execute rc=sal_main() when osl_setExceptionHook fails and return a random uninitialized rc; abort is probably what you want.) You also no longer need the changes in sal/util/makefile.mk:1.44.4.1 then.

-Stephan

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to