1// Copyright 2009 The RE2 Authors. All Rights Reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5#ifndef UTIL_UTIL_H_
6#define UTIL_UTIL_H_
7
8#define arraysize(array) (int)(sizeof(array)/sizeof((array)[0]))
9
10#ifndef ATTRIBUTE_NORETURN
11#if defined(__GNUC__)
12#define ATTRIBUTE_NORETURN __attribute__((noreturn))
13#elif defined(_MSC_VER)
14#define ATTRIBUTE_NORETURN __declspec(noreturn)
15#else
16#define ATTRIBUTE_NORETURN
17#endif
18#endif
19
20#ifndef FALLTHROUGH_INTENDED
21#if defined(__clang__)
22#define FALLTHROUGH_INTENDED [[clang::fallthrough]]
23#elif defined(__GNUC__) && __GNUC__ >= 7
24#define FALLTHROUGH_INTENDED [[gnu::fallthrough]]
25#else
26#define FALLTHROUGH_INTENDED do {} while (0)
27#endif
28#endif
29
30#ifndef NO_THREAD_SAFETY_ANALYSIS
31#define NO_THREAD_SAFETY_ANALYSIS
32#endif
33
34#endif // UTIL_UTIL_H_
35