c macro pair

成对使用的macro, 不过也有机会用错, 死都不知道怎么死的, 这宏...

#define pthread_cleanup_push(func, val) \
   { \
         struct __darwin_pthread_handler_rec __handler; \
         pthread_t __self = pthread_self(); \
         __handler.__routine = func; \
         __handler.__arg = val; \
         __handler.__next = __self->__cleanup_stack; \
         __self->__cleanup_stack = &__handler;

#define pthread_cleanup_pop(execute) \
         /* Note: 'handler' must be in this same lexical context! */ \
         __self->__cleanup_stack = __handler.__next; \
         if (execute) (__handler.__routine)(__handler.__arg); \
   }

 

posted @ 2014-06-03 16:42  summernight  阅读(127)  评论(0编辑  收藏  举报