Kudu C++ client API
int128.h
1 // Licensed to the Apache Software Foundation (ASF) under one
2 // or more contributor license agreements. See the NOTICE file
3 // distributed with this work for additional information
4 // regarding copyright ownership. The ASF licenses this file
5 // to you under the Apache License, Version 2.0 (the
6 // "License"); you may not use this file except in compliance
7 // with the License. You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing,
12 // software distributed under the License is distributed on an
13 // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 // KIND, either express or implied. See the License for the
15 // specific language governing permissions and limitations
16 // under the License.
17 
18 // This file is the central location for defining the int128 type
19 // used by Kudu. Though this file is small it ensures flexibility
20 // as choices and standards around int128 change.
21 #pragma once
22 
23 // __int128 is not supported before gcc 4.6
24 #if defined(__clang__) || \
25  (defined(__GNUC__) && \
26  (__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= 40600)
27 #define KUDU_INT128_SUPPORTED 1
28 #else
29 #define KUDU_INT128_SUPPORTED 0
30 #endif
31 
32 #if KUDU_INT128_SUPPORTED
33 namespace kudu {
34 
35 typedef unsigned __int128 uint128_t;
36 typedef signed __int128 int128_t;
37 
38 // Note: We don't use numeric_limits because it can give incorrect
39 // values for __int128 and unsigned __int128.
40 static const uint128_t UINT128_MIN = (uint128_t) 0;
41 static const uint128_t UINT128_MAX = ((uint128_t) -1);
42 static const int128_t INT128_MAX = ((int128_t)(UINT128_MAX >> 1));
43 static const int128_t INT128_MIN = (-INT128_MAX - 1);
44 
45 } // namespace kudu
46 #endif
Definition: callbacks.h:28