From: Philippe Proulx Date: Wed, 10 Jul 2019 06:15:51 +0000 (-0400) Subject: lib: put __BT_UPCAST() and __BT_UPCAST_CONST() in `babeltrace.h` X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=06b2c29428b48f3c12564b5c26590d11f7482a97 lib: put __BT_UPCAST() and __BT_UPCAST_CONST() in `babeltrace.h` This makes it possible to clear those macros at the end of `babeltrace.h`. This is safe because each public header is guaranteed to be included from `babeltrace.h`. Signed-off-by: Philippe Proulx Change-Id: Ib030f70869b48e76bd78a91be55e581aeb3f3435 Reviewed-on: https://review.lttng.org/c/babeltrace/+/1676 Tested-by: jenkins --- diff --git a/include/babeltrace2/babeltrace.h b/include/babeltrace2/babeltrace.h index 739e76b3..b9ce9847 100644 --- a/include/babeltrace2/babeltrace.h +++ b/include/babeltrace2/babeltrace.h @@ -32,9 +32,18 @@ # define __BT_IN_BABELTRACE_H #endif -/* Need by some of the following included headers */ +/* Internal: needed by some of the following included headers */ #include +/* Internal: needed by some of the following included headers */ +#ifdef __cplusplus +# define __BT_UPCAST(_type, _p) static_cast<_type *>(static_cast(_p)) +# define __BT_UPCAST_CONST(_type, _p) static_cast(static_cast(_p)) +#else +# define __BT_UPCAST(_type, _p) ((_type *) (_p)) +# define __BT_UPCAST_CONST(_type, _p) ((const _type *) (_p)) +#endif + /* Core API */ #include #include @@ -157,5 +166,7 @@ #undef __BT_FUNC_STATUS_UNSUPPORTED #undef __BT_FUNC_STATUS_CANCELED #undef __BT_IN_BABELTRACE_H +#undef __BT_UPCAST +#undef __BT_UPCAST_CONST #endif /* BABELTRACE2_BABELTRACE_H */ diff --git a/include/babeltrace2/types.h b/include/babeltrace2/types.h index 9808ec1d..99d9f1bf 100644 --- a/include/babeltrace2/types.h +++ b/include/babeltrace2/types.h @@ -29,15 +29,6 @@ #include -/* Internal use */ -#ifdef __cplusplus -# define __BT_UPCAST(_type, _p) static_cast<_type *>(static_cast(_p)) -# define __BT_UPCAST_CONST(_type, _p) static_cast(static_cast(_p)) -#else -# define __BT_UPCAST(_type, _p) ((_type *) (_p)) -# define __BT_UPCAST_CONST(_type, _p) ((const _type *) (_p)) -#endif - #ifdef __cplusplus extern "C" { #endif