Apache GraphAr C++ Library
The C++ Library for Apache GraphAr
macros.h
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 
20 #pragma once
21 
22 #include <cstdint>
23 
24 // namespace config
25 
26 #define GAR_EXPAND(x) x
27 #define GAR_STRINGIFY(x) #x
28 #define GAR_CONCAT(x, y) x##y
29 
30 //
31 // GCC can be told that a certain branch is not likely to be taken (for
32 // instance, a CHECK failure), and use that information in static analysis.
33 // Giving it this information can help it optimize for the common case in
34 // the absence of better information (ie. -fprofile-arcs).
35 //
36 #if defined(__GNUC__)
37 #define GAR_PREDICT_FALSE(x) (__builtin_expect(!!(x), 0))
38 #define GAR_PREDICT_TRUE(x) (__builtin_expect(!!(x), 1))
39 #elif defined(_MSC_VER)
40 #define GAR_PREDICT_FALSE(x) (x)
41 #define GAR_PREDICT_TRUE(x) (x)
42 #else
43 #define GAR_PREDICT_FALSE(x) (x)
44 #define GAR_PREDICT_TRUE(x) (x)
45 #endif