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;
61 };
62
63 const int8_t kMaxInt8 = 127; // 2**7 - 1
64 const uint8_t kMaxUInt8 = 255; // 2**8 - 1
65 const int32_t kMaxInt32 = 2147483647; // 2**31 - 1
66 const uint32_t kMaxUInt32 = 4294967295; // 2**32 - 1
67 const int64_t kMaxInt64 = 9223372036854775806; // 2**63 - 2: see below
68 const int64_t kSliceNone = kMaxInt64 + 1; // for Slice::none()
69 const int64_t kMaxLevels = 48;
70
71 inline struct Error
73 struct Error out;
74 out.str = nullptr;
75 out.filename = nullptr;
76 out.identity = kSliceNone;
77 out.attempt = kSliceNone;
78 return out;
79 };
80
81 inline struct Error
83 const char* str,
84 int64_t identity,
85 int64_t attempt,
86 const char* filename) {
87 struct Error out;
88 out.str = str;
89 out.filename = filename;
90 out.identity = identity;
91 out.attempt = attempt;
92 return out;
93 };
94}
95
96#endif // AWKWARD_COMMON_H_
const uint32_t kMaxUInt32
Definition common.h:66
const int64_t kMaxLevels
Definition common.h:69
const int64_t kSliceNone
Definition common.h:68
#define LIBAWKWARD_EXPORT_SYMBOL
Definition common.h:44
const int64_t kMaxInt64
Definition common.h:67
const uint8_t kMaxUInt8
Definition common.h:64
const int32_t kMaxInt32
Definition common.h:65
struct Error success()
Definition common.h:72
struct Error failure(const char *str, int64_t identity, int64_t attempt, const char *filename)
Definition common.h:82
const int8_t kMaxInt8
Definition common.h:63
Definition common.h:56
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