Deleted Added
full compact
thr_clean.c (13546) thr_clean.c (22315)
1/*
2 * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 23 unchanged lines hidden (view full) ---

32 */
33#include <signal.h>
34#include <errno.h>
35#include <stdlib.h>
36#ifdef _THREAD_SAFE
37#include <pthread.h>
38#include "pthread_private.h"
39
1/*
2 * Copyright (c) 1995 John Birrell <jb@cimlogic.com.au>.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 23 unchanged lines hidden (view full) ---

32 */
33#include <signal.h>
34#include <errno.h>
35#include <stdlib.h>
36#ifdef _THREAD_SAFE
37#include <pthread.h>
38#include "pthread_private.h"
39
40int
41_thread_cleanup_push(void (*routine) (void *), void *routine_arg)
40void
41pthread_cleanup_push(void (*routine) (void *), void *routine_arg)
42{
43 struct pthread_cleanup *new;
42{
43 struct pthread_cleanup *new;
44 int ret;
45
46 if ((new = (struct pthread_cleanup *) malloc(sizeof(struct pthread_cleanup))) != NULL) {
47 new->routine = routine;
48 new->routine_arg = routine_arg;
49 new->next = _thread_run->cleanup;
50
51 _thread_run->cleanup = new;
44
45 if ((new = (struct pthread_cleanup *) malloc(sizeof(struct pthread_cleanup))) != NULL) {
46 new->routine = routine;
47 new->routine_arg = routine_arg;
48 new->next = _thread_run->cleanup;
49
50 _thread_run->cleanup = new;
52 ret = 0;
53 } else {
54 ret = ENOMEM;
55 }
51 }
56 return (ret);
57}
58
59void
52}
53
54void
60_thread_cleanup_pop(int execute)
55pthread_cleanup_pop(int execute)
61{
62 struct pthread_cleanup *old;
63
64 if ((old = _thread_run->cleanup) != NULL) {
65 _thread_run->cleanup = old->next;
66 if (execute) {
67 old->routine(old->routine_arg);
68 }
69 free(old);
70 }
71}
72
73#endif
56{
57 struct pthread_cleanup *old;
58
59 if ((old = _thread_run->cleanup) != NULL) {
60 _thread_run->cleanup = old->next;
61 if (execute) {
62 old->routine(old->routine_arg);
63 }
64 free(old);
65 }
66}
67
68#endif