1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
// BSD 3-Clause License; see https://github.com/scikit-hep/awkward/blob/main/LICENSE
#ifndef AWKWARD_COMMON_H_
#define AWKWARD_COMMON_H_
#include <cstddef>
#include <cstdint>
#ifdef _MSC_VER
#define EXPORT_SYMBOL __declspec(dllexport)
#define ERROR Error
using ssize_t = std::ptrdiff_t;
#else
#define EXPORT_SYMBOL __attribute__((visibility("default")))
#define ERROR struct Error
#endif
#define QUOTE(x) #x
#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 ")"
#define FILENAME_FOR_EXCEPTIONS(filename, line) std::string(FILENAME_FOR_EXCEPTIONS_C(filename, line))
#ifdef __GNUC__
// Silence a gcc warning: type attributes ignored after type is already defined
#define EXPORT_TEMPLATE_INST
#else
#define EXPORT_TEMPLATE_INST EXPORT_SYMBOL
#endif
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <mutex>
#include <memory>
#include <cstring>
extern "C" {
struct EXPORT_SYMBOL Error {
const char* str;
const char* filename;
int64_t identity;
int64_t attempt;
};
const int8_t kMaxInt8 = 127; // 2**7 - 1
const uint8_t kMaxUInt8 = 255; // 2**8 - 1
const int32_t kMaxInt32 = 2147483647; // 2**31 - 1
const uint32_t kMaxUInt32 = 4294967295; // 2**32 - 1
const int64_t kMaxInt64 = 9223372036854775806; // 2**63 - 2: see below
const int64_t kSliceNone = kMaxInt64 + 1; // for Slice::none()
const int64_t kMaxLevels = 48;
inline struct Error
success() {
struct Error out;
out.str = nullptr;
out.filename = nullptr;
out.identity = kSliceNone;
out.attempt = kSliceNone;
return out;
};
inline struct Error
failure(
const char* str,
int64_t identity,
int64_t attempt,
const char* filename) {
struct Error out;
out.str = str;
out.filename = filename;
out.identity = identity;
out.attempt = attempt;
return out;
};
}
#endif // AWKWARD_COMMON_H_
|