headers/bsd: Add sys/queue.h.
[haiku.git] / src / system / libroot / posix / pthread / pthread_cleanup.cpp
blobc3c0e69cbc13cf7d32a8d22b342f4dbb7c871d27
1 /*
2 * Copyright 2008, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 */
7 #include "pthread_private.h"
10 void
11 __pthread_cleanup_push_handler(__pthread_cleanup_handler* handler)
13 pthread_thread* thread = pthread_self();
14 if (thread == NULL)
15 return;
17 handler->previous = thread->cleanup_handlers;
18 thread->cleanup_handlers = handler;
22 __pthread_cleanup_handler*
23 __pthread_cleanup_pop_handler(void)
25 pthread_thread* thread = pthread_self();
26 if (thread == NULL)
27 return NULL;
29 __pthread_cleanup_handler* handler = thread->cleanup_handlers;
30 if (handler == NULL)
31 return NULL;
33 thread->cleanup_handlers = handler->previous;
34 return handler;