X-Git-Url: https://git.liburcu.org/?p=urcu.git;a=blobdiff_plain;f=urcu%2Fwfcqueue.h;h=ec86032dd4e091155c64b8d80a0525874d90269a;hp=83ec21949bbf5c7a27e012be5aa675bb06883dfc;hb=4d0d7cbccec1c35f544f6fee24b762e398a2f0b9;hpb=5135c0fd2284e6365bc9d0c53f060b7e946a412f diff --git a/urcu/wfcqueue.h b/urcu/wfcqueue.h index 83ec219..ec86032 100644 --- a/urcu/wfcqueue.h +++ b/urcu/wfcqueue.h @@ -43,7 +43,7 @@ extern "C" { * McKenney. */ -#define CDS_WFCQ_WOULDBLOCK ((void *) -1UL) +#define CDS_WFCQ_WOULDBLOCK ((struct cds_wfcq_node *) -1UL) enum cds_wfcq_ret { CDS_WFCQ_RET_WOULDBLOCK = -1, @@ -74,6 +74,7 @@ struct cds_wfcq_head { pthread_mutex_t lock; }; +#ifndef __cplusplus /* * The transparent union allows calling functions that work on both * struct cds_wfcq_head and struct __cds_wfcq_head on any of those two @@ -84,6 +85,45 @@ typedef union { struct cds_wfcq_head *h; } __attribute__((__transparent_union__)) cds_wfcq_head_ptr_t; +/* + * This static inline is only present for compatibility with C++. It is + * effect-less in C. + */ +static inline struct __cds_wfcq_head *__cds_wfcq_head_cast(struct __cds_wfcq_head *head) +{ + return head; +} + +/* + * This static inline is only present for compatibility with C++. It is + * effect-less in C. + */ +static inline struct cds_wfcq_head *cds_wfcq_head_cast(struct cds_wfcq_head *head) +{ + return head; +} +#else /* #ifndef __cplusplus */ + +/* C++ ignores transparent union. */ +typedef union { + struct __cds_wfcq_head *_h; + struct cds_wfcq_head *h; +} cds_wfcq_head_ptr_t; + +/* C++ ignores transparent union. Requires an explicit conversion. */ +static inline cds_wfcq_head_ptr_t __cds_wfcq_head_cast(struct __cds_wfcq_head *head) +{ + cds_wfcq_head_ptr_t ret = { ._h = head }; + return ret; +} +/* C++ ignores transparent union. Requires an explicit conversion. */ +static inline cds_wfcq_head_ptr_t cds_wfcq_head_cast(struct cds_wfcq_head *head) +{ + cds_wfcq_head_ptr_t ret = { .h = head }; + return ret; +} +#endif /* #else #ifndef __cplusplus */ + struct cds_wfcq_tail { struct cds_wfcq_node *p; };