xref: /aosp_15_r20/external/regex-re2/util/util.h (revision ccdc9c3e24c519bfa4832a66aa2e83a52c19f295)
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 // TODO(junyer): Get rid of this.
9 #include <string>
10 using std::string;
11 
12 #define arraysize(array) (int)(sizeof(array)/sizeof((array)[0]))
13 
14 #ifndef ATTRIBUTE_NORETURN
15 #if defined(__GNUC__)
16 #define ATTRIBUTE_NORETURN __attribute__((noreturn))
17 #elif defined(_MSC_VER)
18 #define ATTRIBUTE_NORETURN __declspec(noreturn)
19 #else
20 #define ATTRIBUTE_NORETURN
21 #endif
22 #endif
23 
24 #ifndef FALLTHROUGH_INTENDED
25 #if defined(__clang__)
26 #define FALLTHROUGH_INTENDED [[clang::fallthrough]]
27 #elif defined(__GNUC__) && __GNUC__ >= 7
28 #define FALLTHROUGH_INTENDED [[gnu::fallthrough]]
29 #else
30 #define FALLTHROUGH_INTENDED do {} while (0)
31 #endif
32 #endif
33 
34 #ifndef NO_THREAD_SAFETY_ANALYSIS
35 #define NO_THREAD_SAFETY_ANALYSIS
36 #endif
37 
38 #endif  // UTIL_UTIL_H_
39