All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
common.h
Go to the documentation of this file.
1// BSD 3-Clause License; see https://github.com/scikit-hep/awkward-1.0/blob/main/LICENSE
2
3#ifndef AWKWARD_COMMON_H_
4#define AWKWARD_COMMON_H_
5
6#ifdef _MSC_VER
7 #define EXPORT_SYMBOL __declspec(dllexport)
8 #ifdef _WIN64
9 typedef signed __int64 ssize_t;
10 typedef unsigned __int64 size_t;
11 #else
12 typedef signed int ssize_t;
13 typedef unsigned int size_t;
14 #endif
15 typedef unsigned char uint8_t;
16 typedef signed char int8_t;
17 typedef unsigned short uint16_t;
18 typedef signed short int16_t;
19 typedef unsigned int uint32_t;
20 typedef signed int int32_t;
21 typedef unsigned __int64 uint64_t;
22 typedef signed __int64 int64_t;
23 #define ERROR Error
24#else
25 #define EXPORT_SYMBOL __attribute__((visibility("default")))
26 #include <cstddef>
27 #include <cstdint>
28 #define ERROR struct Error
29#endif
30
31#define QUOTE(x) #x
32
33#define FILENAME_FOR_EXCEPTIONS_C(filename, line) "\n\n(https://github.com/scikit-hep/awkward/blob/awkward-cpp-" VERSION_INFO "/awkward-cpp/" filename "#L" #line ")"
34#define FILENAME_FOR_EXCEPTIONS(filename, line) std::string(FILENAME_FOR_EXCEPTIONS_C(filename, line))
35
36#ifdef __GNUC__
37// Silence a gcc warning: type attributes ignored after type is already defined
38 #define EXPORT_TEMPLATE_INST
39#else
40 #define EXPORT_TEMPLATE_INST EXPORT_SYMBOL
41#endif
42
43#ifndef LIBAWKWARD_EXPORT_SYMBOL
44 #define LIBAWKWARD_EXPORT_SYMBOL
45#endif
46
47#include <iostream>
48#include <algorithm>
49#include <map>
50#include <vector>
51#include <mutex>
52#include <memory>
53#include <cstring>
54
55extern "C" {
57 const char* str;
58 const char* filename;
59 int64_t identity;
60 int64_t attempt;
62 };
63
64 const int8_t kMaxInt8 = 127; // 2**7 - 1
65 const uint8_t kMaxUInt8 = 255; // 2**8 - 1
66 const int32_t kMaxInt32 = 2147483647; // 2**31 - 1
67 const uint32_t kMaxUInt32 = 4294967295; // 2**32 - 1
68 const int64_t kMaxInt64 = 9223372036854775806; // 2**63 - 2: see below
69 const int64_t kSliceNone = kMaxInt64 + 1; // for Slice::none()
70 const int64_t kMaxLevels = 48;
71
72 inline struct Error
74 struct Error out;
75 out.str = nullptr;
76 out.filename = nullptr;
77 out.identity = kSliceNone;
78 out.attempt = kSliceNone;
79 out.pass_through = false;
80 return out;
81 };
82
83 inline struct Error
85 const char* str,
86 int64_t identity,
87 int64_t attempt,
88 const char* filename) {
89 struct Error out;
90 out.str = str;
91 out.filename = filename;
92 out.identity = identity;
93 out.attempt = attempt;
94 out.pass_through = false;
95 return out;
96 };
97
98 inline struct Error
100 const char* str,
101 int64_t identity,
102 int64_t attempt,
103 const char* filename) {
104 struct Error out;
105 out.str = str;
106 out.filename = filename;
107 out.identity = identity;
108 out.attempt = attempt;
109 out.pass_through = true;
110 return out;
111 };
112}
113
114#endif // AWKWARD_COMMON_H_
const uint32_t kMaxUInt32
Definition: common.h:67
const int64_t kMaxLevels
Definition: common.h:70
const int64_t kSliceNone
Definition: common.h:69
#define LIBAWKWARD_EXPORT_SYMBOL
Definition: common.h:44
const int64_t kMaxInt64
Definition: common.h:68
const uint8_t kMaxUInt8
Definition: common.h:65
const int32_t kMaxInt32
Definition: common.h:66
struct Error failure_pass_through(const char *str, int64_t identity, int64_t attempt, const char *filename)
Definition: common.h:99
struct Error success()
Definition: common.h:73
struct Error failure(const char *str, int64_t identity, int64_t attempt, const char *filename)
Definition: common.h:84
const int8_t kMaxInt8
Definition: common.h:64
Definition: common.h:56
bool pass_through
Definition: common.h:61
int64_t attempt
Definition: common.h:60
int64_t identity
Definition: common.h:59
const char * filename
Definition: common.h:58
const char * str
Definition: common.h:57