From 492c73cf1f1b3e35b394aec991d1201726ec606d Mon Sep 17 00:00:00 2001 From: rpj Date: Tue, 21 Jul 1998 17:04:38 +0000 Subject: Wed Jul 22 00:16:22 1998 Ross Johnson * cleanup.c (_pthread_cleanup_push): Implement. (_pthread_cleanup_pop): Implement. (_pthread_do_cancellation): Implement. These are private to the implementation. The real cleanup functions are macros. See below. * pthread.h (pthread_cleanup_push): Implement as a macro. (pthread_cleanup_pop): Implement as a macro. Because these are macros which start and end a block, the POSIX scoping requirement is observed. See the comment in the file. * exit.c (pthread_exit): Refine the code. * create.c (pthread_create): Code cleanup. * implement.h (RND_SIZEOF): Add RND_SIZEOF(T) to round sizeof(T) up to multiple of DWORD. Add function prototypes. * private.c (_pthread_getthreadindex): "*thread" should have been "thread". Detect empty slot fail condition. --- pthread.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'pthread.h') diff --git a/pthread.h b/pthread.h index 974a163..bf9ff7b 100644 --- a/pthread.h +++ b/pthread.h @@ -170,6 +170,26 @@ int pthread_key_delete(pthread_key_t key); } #endif /* __cplusplus */ +/* The following #defines implement POSIX cleanup handlers. + The standard requires that these functions be used as statements and + be used pairwise in the same scope. The standard suggests that, in C, they + may be implemented as macros starting and ending the same block. + */ +#ifdef pthread_cleanup_push +#undef pthread_cleanup_push +#endif +#define pthread_cleanup_push(routine, arg) \ +{ \ + _pthread_cleanup_push(routine, arg); + +#ifdef pthread_cleanup_pop +#undef pthread_cleanup_pop +#endif +#define pthread_cleanup_pop(execute) \ + _pthread_cleanup_pop(execute);\ +} + + /* Below here goes all internal definitions required by this implementation of pthreads for Win32. */ -- cgit v1.2.3