X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=include%2Flttng%2Fbitfield.h;h=e628af39ca9cdf7d4004769014d52768fb6810e2;hb=c0c0989ab70574e09b2f7e8b48c2da6af664a849;hp=5ed629381ac6ff9508b4e432d8d784660a776d9b;hpb=3f6807bfb5f8e87d09251d3b284d9d586741186b;p=lttng-ust.git diff --git a/include/lttng/bitfield.h b/include/lttng/bitfield.h index 5ed62938..e628af39 100644 --- a/include/lttng/bitfield.h +++ b/include/lttng/bitfield.h @@ -1,28 +1,12 @@ -#ifndef _BABELTRACE_BITFIELD_H -#define _BABELTRACE_BITFIELD_H - /* - * Copyright 2010-2019 - Mathieu Desnoyers + * SPDX-License-Identifier: MIT * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. + * Copyright (C) 2010-2019 Mathieu Desnoyers */ +#ifndef _BABELTRACE_BITFIELD_H +#define _BABELTRACE_BITFIELD_H + #include /* C99 5.2.4.2 Numerical limits */ #include /* C99 5.2.4.2 Numerical limits */ #include /* C99 7.16 bool type */ @@ -70,8 +54,12 @@ * Produce a build-time error if the condition `cond` is non-zero. * Evaluates as a size_t expression. */ +#ifdef __cplusplus +#define _BT_BUILD_ASSERT(cond) ([]{static_assert((cond), "");}, 0) +#else #define _BT_BUILD_ASSERT(cond) \ sizeof(struct { int f:(2 * !!(cond) - 1); }) +#endif /* * Cast value `v` to an unsigned integer of the same size as `v`. @@ -377,7 +365,7 @@ do { \ do { \ __typeof__(*(vptr)) *_vptr = (vptr); \ __typeof__(*_vptr) _v; \ - type *_ptr = (void *) (ptr); \ + type *_ptr = (type *) (ptr); \ unsigned long _start = (start), _length = (length); \ type _mask, _cmask; \ unsigned long _ts = sizeof(type) * CHAR_BIT; /* type size */ \