Loading...
Searching...
No Matches
common.h
Go to the documentation of this file.
1// BSD 3-Clause License; see https://github.com/scikit-hep/awkward/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#include <iostream>
44#include <algorithm>
45#include <map>
46#include <vector>
47#include <mutex>
48#include <memory>
49#include <cstring>
50
51extern "C" {
53 const char* str;
54 const char* filename;
55 int64_t identity;
56 int64_t attempt;
57 };
58
59 const int8_t kMaxInt8 = 127; // 2**7 - 1
60 const uint8_t kMaxUInt8 = 255; // 2**8 - 1
61 const int32_t kMaxInt32 = 2147483647; // 2**31 - 1
62 const uint32_t kMaxUInt32 = 4294967295; // 2**32 - 1
63 const int64_t kMaxInt64 = 9223372036854775806; // 2**63 - 2: see below
64 const int64_t kSliceNone = kMaxInt64 + 1; // for Slice::none()
65 const int64_t kMaxLevels = 48;
66
67 inline struct Error
69 struct Error out;
70 out.str = nullptr;
71 out.filename = nullptr;
72 out.identity = kSliceNone;
73 out.attempt = kSliceNone;
74 return out;
75 };
76
77 inline struct Error
79 const char* str,
80 int64_t identity,
81 int64_t attempt,
82 const char* filename) {
83 struct Error out;
84 out.str = str;
85 out.filename = filename;
86 out.identity = identity;
87 out.attempt = attempt;
88 return out;
89 };
90}
91
92#endif // AWKWARD_COMMON_H_
const uint32_t kMaxUInt32
Definition common.h:62
const int64_t kMaxLevels
Definition common.h:65
const int64_t kSliceNone
Definition common.h:64
const int64_t kMaxInt64
Definition common.h:63
const uint8_t kMaxUInt8
Definition common.h:60
const int32_t kMaxInt32
Definition common.h:61
struct Error success()
Definition common.h:68
#define EXPORT_SYMBOL
Definition common.h:25
struct Error failure(const char *str, int64_t identity, int64_t attempt, const char *filename)
Definition common.h:78
const int8_t kMaxInt8
Definition common.h:59
Definition common.h:52
int64_t attempt
Definition common.h:56
int64_t identity
Definition common.h:55
const char * filename
Definition common.h:54
const char * str
Definition common.h:53