+ /* Flags determining processing of cancellation. */
+ int cancelhandling;
+ /* Bit set if cancellation is disabled. */
+#define CANCELSTATE_BIT 0
+#define CANCELSTATE_BITMASK 0x01
+ /* Bit set if asynchronous cancellation mode is selected. */
+#define CANCELTYPE_BIT 1
+#define CANCELTYPE_BITMASK 0x02
+ /* Bit set if canceling has been initiated. */
+#define CANCELING_BIT 2
+#define CANCELING_BITMASK 0x04
+ /* Bit set if canceled. */
+#define CANCELED_BIT 3
+#define CANCELED_BITMASK 0x08
+ /* Bit set if thread is exiting. */
+#define EXITING_BIT 4
+#define EXITING_BITMASK 0x10
+ /* Bit set if thread terminated and TCB is freed. */
+#define TERMINATED_BIT 5
+#define TERMINATED_BITMASK 0x20
+ /* Mask for the rest. Helps the compiler to optimize. */
+#define CANCEL_RESTMASK 0xffffffc0
+
+#define CANCEL_ENABLED_AND_CANCELED(value) \
+ (((value) & (CANCELSTATE_BITMASK | CANCELED_BITMASK | EXITING_BITMASK \
+ | CANCEL_RESTMASK | TERMINATED_BITMASK)) == CANCELED_BITMASK)
+#define CANCEL_ENABLED_AND_CANCELED_AND_ASYNCHRONOUS(value) \
+ (((value) & (CANCELSTATE_BITMASK | CANCELTYPE_BITMASK | CANCELED_BITMASK \
+ | EXITING_BITMASK | CANCEL_RESTMASK | TERMINATED_BITMASK)) \
+ == (CANCELTYPE_BITMASK | CANCELED_BITMASK))