summaryrefslogtreecommitdiff
path: root/cleanup.c
diff options
context:
space:
mode:
authorrpj <rpj>1999-01-04 23:22:35 +0000
committerrpj <rpj>1999-01-04 23:22:35 +0000
commit5f3c7322e8f3f35cb0f8c250f337596c83961b25 (patch)
tree1b76bab6fb83344eff3d731a8cfb340e03b25e24 /cleanup.c
parent36f0ed4155fdab7b12c5c5ddf4252170fac0a77e (diff)
Parts of this package are going to have to be C++ in the GNU world because we
now use exception handling to implement thread cancellation. The MSC compiler appears to know about __try/__except blocks, but gcc (ie. the GNU ANSI C compiler) doesn't know about the equivalent C++ try/catch blocks. This should not be a problem since gcc and g++ are nearly always available together. Some file names may need to change in the CVS repository however. Tue Jan 5 16:33:04 1999 Ross Johnson <rpj@swan.canberra.edu.au> * cleanup.c (_pthread_pop_cleanup): Add C++ version of __try/__except block. Move trailing "}" out of #ifdef _WIN32 block left there by (my) mistake. * private.c: Remove #include <errno.h> which is included by pthread.h.
Diffstat (limited to 'cleanup.c')
-rw-r--r--cleanup.c65
1 files changed, 44 insertions, 21 deletions
diff --git a/cleanup.c b/cleanup.c
index 12ce282..883c8ca 100644
--- a/cleanup.c
+++ b/cleanup.c
@@ -54,31 +54,54 @@ _pthread_pop_cleanup (int execute)
#ifdef _WIN32
__try
- {
- /*
- * Run the caller's cleanup routine.
- */
- (*cleanup->routine) (cleanup->arg);
- }
+ {
+ /*
+ * Run the caller's cleanup routine.
+ */
+ (*cleanup->routine) (cleanup->arg);
+ }
__except (EXCEPTION_EXECUTE_HANDLER)
- {
- /*
- * A system unexpected exception had occurred
- * running the user's cleanup routine.
- * We get control back within this block.
- */
- }
- }
-
-#else
-
- /*
- * Run the caller's cleanup routine.
- */
- (*cleanup->routine) (cleanup->arg);
+ {
+ /*
+ * A system unexpected exception had occurred
+ * running the user's cleanup routine.
+ * We get control back within this block.
+ */
+ }
+
+#else /* _WIN32 */
+
+#ifdef _cplusplus
+
+ try
+ {
+ /*
+ * Run the caller's cleanup routine.
+ */
+ (*cleanup->routine) (cleanup->arg);
+ }
+ catch(...)
+ {
+ /*
+ * A system unexpected exception had occurred
+ * running the user's cleanup routine.
+ * We get control back within this block.
+ */
+ }
+
+#else /* _cplusplus */
+
+ /*
+ * Run the caller's cleanup routine and FIXME: hope for the best.
+ */
+ (*cleanup->routine) (cleanup->arg);
+
+#endif /* _cplusplus */
#endif /* _WIN32 */
+ }
+
pthread_setspecific (_pthread_cleanupKey, cleanup->prev);
}