about summary refs log tree commit homepage
path: root/util.h
diff options
context:
space:
mode:
Diffstat (limited to 'util.h')
-rw-r--r--util.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/util.h b/util.h
index 072f429..82f737e 100644
--- a/util.h
+++ b/util.h
@@ -52,6 +52,20 @@ static inline void mog_cancel_disable(void)
         assert(old == PTHREAD_CANCEL_ENABLE && "redundant cancel disable");
 }
 
+static inline void mog_testcancel(void)
+{
+        int old;
+
+        mog_cancel_enable();
+
+        /* make sure we are already using the async cancel type */
+        assert(0 == pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &old)
+               && old == PTHREAD_CANCEL_ASYNCHRONOUS
+               && "asynchronous cancel not previously enabled");
+
+        mog_cancel_disable();
+}
+
 /* compiler should optimize this away */
 __attribute__((const)) static inline off_t off_t_max(void)
 {