diff options
author | Benny Prijono <bennylp@teluu.com> | 2005-11-21 16:57:02 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2005-11-21 16:57:02 +0000 |
commit | 5d8ed312c380f76e442ca170f0f791273c914bfa (patch) | |
tree | 552b3ccb4a8bb0b9144fac237822a147c6d48a24 /pjlib/src | |
parent | 54349030a3b401a96f1dc24dd351fe19110ddbb9 (diff) |
Changed syntax to support Windows SEH
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@68 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjlib/src')
-rw-r--r-- | pjlib/src/pj/except.c | 2 | ||||
-rw-r--r-- | pjlib/src/pjlib-samples/except.c | 6 | ||||
-rw-r--r-- | pjlib/src/pjlib-test/exception.c | 52 |
3 files changed, 30 insertions, 30 deletions
diff --git a/pjlib/src/pj/except.c b/pjlib/src/pj/except.c index ceaaad16..0a9f32ab 100644 --- a/pjlib/src/pj/except.c +++ b/pjlib/src/pj/except.c @@ -35,6 +35,7 @@ static long thread_local_id = -1; #endif /* PJ_HAS_EXCEPTION_NAMES */ +#if !defined(PJ_EXCEPTION_USE_WIN32_SEH) || PJ_EXCEPTION_USE_WIN32_SEH==0 PJ_DEF(void) pj_throw_exception_(int exception_id) { struct pj_exception_state_t *handler; @@ -69,6 +70,7 @@ PJ_DEF(void) pj_pop_exception_handler_(void) pj_assert(handler != NULL); pj_thread_local_set(thread_local_id, handler->prev); } +#endif #if defined(PJ_HAS_EXCEPTION_NAMES) && PJ_HAS_EXCEPTION_NAMES != 0 PJ_DEF(pj_status_t) pj_exception_id_alloc( const char *name, diff --git a/pjlib/src/pjlib-samples/except.c b/pjlib/src/pjlib-samples/except.c index 3bbfa544..5a319403 100644 --- a/pjlib/src/pjlib-samples/except.c +++ b/pjlib/src/pjlib-samples/except.c @@ -54,11 +54,7 @@ static int test_exception() free(data); randomly_throw_exception(); } - PJ_CATCH( NO_MEMORY ) { - puts("Can't allocate memory"); - return 0; - } - PJ_DEFAULT { + PJ_CATCH_ANY { pj_exception_id_t x_id; x_id = PJ_GET_EXCEPTION(); diff --git a/pjlib/src/pjlib-test/exception.c b/pjlib/src/pjlib-test/exception.c index ef4bf4a2..5e9ef2b6 100644 --- a/pjlib/src/pjlib-test/exception.c +++ b/pjlib/src/pjlib-test/exception.c @@ -65,8 +65,8 @@ static int throw_id_2(void) static int test(void) { - PJ_USE_EXCEPTION; int rc = 0; + PJ_USE_EXCEPTION; /* * No exception situation. @@ -74,10 +74,7 @@ static int test(void) PJ_TRY { rc = rc; } - PJ_CATCH( ID_1 ) { - rc = -2; - } - PJ_DEFAULT { + PJ_CATCH_ANY { rc = -3; } PJ_END; @@ -95,14 +92,13 @@ static int test(void) // should not reach here. rc = -10; } - PJ_CATCH( ID_1 ) { - if (!rc) rc = 0; - } - PJ_DEFAULT { + PJ_CATCH_ANY { int id = PJ_GET_EXCEPTION(); - PJ_LOG(3,("", "...error: got unexpected exception %d (%s)", - id, pj_exception_id_name(id))); - if (!rc) rc = -20; + if (id != ID_1) { + PJ_LOG(3,("", "...error: got unexpected exception %d (%s)", + id, pj_exception_id_name(id))); + if (!rc) rc = -20; + } } PJ_END; @@ -117,14 +113,16 @@ static int test(void) // should not reach here. rc = -25; } - PJ_CATCH( ID_1 ) { - if (!rc) rc = -30; - } - PJ_CATCH( ID_2 ) { - if (!rc) rc = 0; - } - PJ_DEFAULT { - if (!rc) rc = -40; + PJ_CATCH_ANY { + switch (PJ_GET_EXCEPTION()) { + case ID_1: + if (!rc) rc = -30; break; + case ID_2: + if (!rc) rc = 0; break; + default: + if (!rc) rc = -40; + break; + } } PJ_END; @@ -139,11 +137,15 @@ static int test(void) // should not reach here rc = -50; } - PJ_CATCH( ID_2 ) { - if (!rc) rc = -60; - } - PJ_DEFAULT { - if (!rc) rc = 0; + PJ_CATCH_ANY { + switch (PJ_GET_EXCEPTION()) { + case ID_1: + if (!rc) rc = 0; + break; + default: + if (!rc) rc = -60; + break; + } } PJ_END; |