--- ex.pod 2002/03/07 21:30:10 1.21
+++ ex.pod 2002/03/30 18:15:49 1.22
@@ -410,98 +410,98 @@
=item F<pthread_ex.h>
-#ifndef __PTHREAD_EX_H__
-#define __PTHREAD_EX_H__
+ #ifndef __PTHREAD_EX_H__
+ #define __PTHREAD_EX_H__
-#include <pthread.h>
+ #include <pthread.h>
-int pthread_init_ex (void);
-int pthread_create_ex (pthread_t *, const pthread_attr_t *, void *(*)(void *), void *);
+ int pthread_init_ex (void);
+ int pthread_create_ex (pthread_t *, const pthread_attr_t *, void *(*)(void *), void *);
-#ifndef PTHREAD_EX_INTERNAL
-#define pthread_init pthread_init_ex
-#define pthread_create pthread_create_ex
-#endif
+ #ifndef PTHREAD_EX_INTERNAL
+ #define pthread_init pthread_init_ex
+ #define pthread_create pthread_create_ex
+ #endif
-#endif /* __PTHREAD_EX_H__ */
+ #endif /* __PTHREAD_EX_H__ */
=item F<pthread_ex.c>
-#include <stdlib.h>
-#include <pthread.h>
+ #include <stdlib.h>
+ #include <pthread.h>
+
+ #define PTHREAD_EX_INTERNAL
+ #include "pthread_ex.h"
+ #include "ex.h"
+
+ /* context storage key */
+ static pthread_key_t pthread_ex_ctx_key;
-#define PTHREAD_EX_INTERNAL
-#include "pthread_ex.h"
-#include "ex.h"
-
-/* context storage key */
-static pthread_key_t pthread_ex_ctx_key;
-
-/* context destructor */
-static void pthread_ex_ctx_destroy(void *data)
-{
- if (data != NULL)
- free(data);
- return;
-}
-
-/* callback: context fetching */
-static ex_ctx_t *pthread_ex_ctx(void)
-{
- return (ex_ctx_t *)pthread_getspecific(pthread_ex_ctx_key);
-}
-
-/* callback: termination */
-static void pthread_ex_terminate(ex_t *e)
-{
- pthread_exit(e->ex_value);
-}
-
-/* pthread init */
-int pthread_init_ex(void)
-{
- int rc;
-
- /* additionally create thread data key and override OSSP ex callbacks */
- pthread_key_create(&pthread_ex_ctx_key, pthread_ex_ctx_destroy);
- __ex_ctx = pthread_ex_ctx;
- __ex_terminate = pthread_ex_terminate;
-
- return rc;
-}
-
-/* internal thread entry wrapper information */
-typedef struct {
- void *(*entry)(void *);
- void *arg;
-} pthread_create_ex_t;
-
-/* internal thread entry wrapper */
-static void *pthread_create_wrapper(void *arg)
-{
- pthread_create_ex_t *wrapper;
- ex_ctx_t *ex_ctx;
-
- /* create per-thread exception context */
- wrapper = (pthread_create_ex_t *)arg;
- ex_ctx = (ex_ctx_t *)malloc(sizeof(ex_ctx_t));
- EX_CTX_INITIALIZE(ex_ctx);
- pthread_setspecific(pthread_ex_ctx_key, ex_ctx);
-
- /* perform original operation */
- return wrapper->entry(wrapper->arg);
-}
-
-/* pthread_create() wrapper */
-int pthread_create_ex(pthread_t *thread, const pthread_attr_t *attr, void *(*entry)(void *), void *arg)
-{
- pthread_create_ex_t wrapper;
-
- /* spawn thread but execute start function through wrapper */
- wrapper.entry = entry;
- wrapper.arg = arg;
- return pthread_create(thread, attr, pthread_create_wrapper, &wrapper);
-}
+ /* context destructor */
+ static void pthread_ex_ctx_destroy(void *data)
+ {
+ if (data != NULL)
+ free(data);
+ return;
+ }
+
+ /* callback: context fetching */
+ static ex_ctx_t *pthread_ex_ctx(void)
+ {
+ return (ex_ctx_t *)pthread_getspecific(pthread_ex_ctx_key);
+ }
+
+ /* callback: termination */
+ static void pthread_ex_terminate(ex_t *e)
+ {
+ pthread_exit(e->ex_value);
+ }
+
+ /* pthread init */
+ int pthread_init_ex(void)
+ {
+ int rc;
+
+ /* additionally create thread data key and override OSSP ex callbacks */
+ pthread_key_create(&pthread_ex_ctx_key, pthread_ex_ctx_destroy);
+ __ex_ctx = pthread_ex_ctx;
+ __ex_terminate = pthread_ex_terminate;
+
+ return rc;
+ }
+
+ /* internal thread entry wrapper information */
+ typedef struct {
+ void *(*entry)(void *);
+ void *arg;
+ } pthread_create_ex_t;
+
+ /* internal thread entry wrapper */
+ static void *pthread_create_wrapper(void *arg)
+ {
+ pthread_create_ex_t *wrapper;
+ ex_ctx_t *ex_ctx;
+
+ /* create per-thread exception context */
+ wrapper = (pthread_create_ex_t *)arg;
+ ex_ctx = (ex_ctx_t *)malloc(sizeof(ex_ctx_t));
+ EX_CTX_INITIALIZE(ex_ctx);
+ pthread_setspecific(pthread_ex_ctx_key, ex_ctx);
+
+ /* perform original operation */
+ return wrapper->entry(wrapper->arg);
+ }
+
+ /* pthread_create() wrapper */
+ int pthread_create_ex(pthread_t *thread, const pthread_attr_t *attr, void *(*entry)(void *), void *arg)
+ {
+ pthread_create_ex_t wrapper;
+
+ /* spawn thread but execute start function through wrapper */
+ wrapper.entry = entry;
+ wrapper.arg = arg;
+ return pthread_create(thread, attr, pthread_create_wrapper, &wrapper);
+ }
=back
@@ -665,27 +665,33 @@
=head1 SEE ALSO
-B<ISO-C++> C<try>/C<catch>/C<throw>;
-B<Java> C<try>/C<catch>/C<finally>/C<throw>;
-B<ISO-C> jmp_buf(3)/setjmp(3)/longjmp(3);
-B<POSIX.1> sigjmp_buf(3)/sigsetjmp(3)/siglongjump(3);
-B<POSIX.1> ucontext(3)/setcontext(3)/getcontext(3).
+B<ISO-C++> C<try>, C<catch>, C<throw>.
+
+B<Java> C<try>, C<catch>, C<finally>, C<throw>.
+
+B<ISO-C> jmp_buf(3), setjmp(3), longjmp(3).
+
+B<POSIX.1> sigjmp_buf(3), sigsetjmp(3), siglongjump(3).
+
+B<POSIX.1> ucontext(3), setcontext(3), getcontext(3).
=head1 HISTORY
B<OSSP ex> was invented in January 2002 by Ralf S. Engelschall
-E<lt>rse@engelschall.comE<gt> for use inside the B<OSSP> project.
-Its creation was prompted by the requirement to reduce the error
-handling inside B<OSSP lmtp2nntp>. The core B<try>/B<catch> clause
-was inspired by B<ISO-C++> and the implementation was partly
-derived from B<cexcept> 2.0.0, a similar library written 2000 by
-Adam M. Costello E<lt>amc@cs.berkeley.eduE<gt> and Cosmin Truta
-E<lt>cosmin@cs.toronto.eduE<gt>. The B<cleanup> clause was inspired by
-the B<Java> C<finally> clause. The B<shield> feature was inspired by an
-C<errno> shielding facility used in the B<GNU pth> implementation. The
-B<defer> feature was invented to simplify an application's cleanup
-handling if multiple independent resources are allocated and have to be
-freed on error.
+E<lt>rse@engelschall.comE<gt> for use inside the B<OSSP> project. Its
+creation was prompted by the requirement to reduce the error handling
+inside B<OSSP lmtp2nntp>.
+
+The core B<try>/B<catch> clause was inspired by B<ISO-C++> and the
+implementation was partly derived from B<cexcept> 2.0.0, a similar
+library written 2000 by Adam M. Costello E<lt>amc@cs.berkeley.eduE<gt>
+and Cosmin Truta E<lt>cosmin@cs.toronto.eduE<gt>.
+
+The B<cleanup> clause was inspired by the B<Java> C<finally> clause.
+The B<shield> feature was inspired by an C<errno> shielding facility
+used in the B<GNU pth> implementation. The B<defer> feature was invented
+to simplify an application's cleanup handling if multiple independent
+resources are allocated and have to be freed on error.
=head1 AUTHORS
|