|
44 | 44 | #define Z_MIN_WINDOWBITS 8
|
45 | 45 | #define Z_MAX_WINDOWBITS 15
|
46 | 46 | #define Z_DEFAULT_WINDOWBITS 15
|
47 |
| -// Fewer than 64 bytes per chunk is not recommended. |
48 |
| -// Technically it could work with as few as 8, but even 64 bytes |
49 |
| -// is low. Usually a MB or more is best. |
50 |
| -#define Z_MIN_CHUNK 64 |
51 |
| -#define Z_MAX_CHUNK std::numeric_limits<double>::infinity() |
52 |
| -#define Z_DEFAULT_CHUNK (16 * 1024) |
53 |
| -#define Z_MIN_MEMLEVEL 1 |
54 |
| -#define Z_MAX_MEMLEVEL 9 |
55 |
| -#define Z_DEFAULT_MEMLEVEL 8 |
56 |
| -#define Z_MIN_LEVEL -1 |
57 |
| -#define Z_MAX_LEVEL 9 |
58 |
| -#define Z_DEFAULT_LEVEL Z_DEFAULT_COMPRESSION |
59 | 47 |
|
60 | 48 | struct sockaddr;
|
61 | 49 |
|
62 |
| -// Variation on NODE_DEFINE_CONSTANT that sets a String value. |
63 |
| -#define NODE_DEFINE_STRING_CONSTANT(target, name, constant) \ |
64 |
| - do { \ |
65 |
| - v8::Isolate* isolate = target->GetIsolate(); \ |
66 |
| - v8::Local<v8::String> constant_name = \ |
67 |
| - v8::String::NewFromUtf8(isolate, name, v8::NewStringType::kNormal) \ |
68 |
| - .ToLocalChecked(); \ |
69 |
| - v8::Local<v8::String> constant_value = \ |
70 |
| - v8::String::NewFromUtf8(isolate, constant, v8::NewStringType::kNormal)\ |
71 |
| - .ToLocalChecked(); \ |
72 |
| - v8::PropertyAttribute constant_attributes = \ |
73 |
| - static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete); \ |
74 |
| - target->DefineOwnProperty(isolate->GetCurrentContext(), \ |
75 |
| - constant_name, \ |
76 |
| - constant_value, \ |
77 |
| - constant_attributes).FromJust(); \ |
78 |
| - } while (0) |
79 |
| - |
80 | 50 | namespace node {
|
81 | 51 |
|
82 | 52 | namespace native_module {
|
@@ -126,80 +96,10 @@ void RegisterSignalHandler(int signal,
|
126 | 96 | std::string GetHumanReadableProcessName();
|
127 | 97 | void GetHumanReadableProcessName(char (*name)[1024]);
|
128 | 98 |
|
129 |
| -template <typename T, size_t N> |
130 |
| -constexpr size_t arraysize(const T(&)[N]) { return N; } |
131 |
| - |
132 |
| -#ifndef ROUND_UP |
133 |
| -# define ROUND_UP(a, b) ((a) % (b) ? ((a) + (b)) - ((a) % (b)) : (a)) |
134 |
| -#endif |
135 |
| - |
136 |
| -#ifdef __GNUC__ |
137 |
| -# define MUST_USE_RESULT __attribute__((warn_unused_result)) |
138 |
| -#else |
139 |
| -# define MUST_USE_RESULT |
140 |
| -#endif |
141 |
| - |
142 |
| -class SlicedArguments { |
143 |
| - public: |
144 |
| - inline explicit SlicedArguments( |
145 |
| - const v8::FunctionCallbackInfo<v8::Value>& args, |
146 |
| - size_t start = 0); |
147 |
| - inline size_t size() const { return size_; } |
148 |
| - inline v8::Local<v8::Value>* data() { return data_; } |
149 |
| - |
150 |
| - private: |
151 |
| - size_t size_; |
152 |
| - v8::Local<v8::Value>* data_; |
153 |
| - v8::Local<v8::Value> fixed_[64]; |
154 |
| - std::vector<v8::Local<v8::Value>> dynamic_; |
155 |
| -}; |
156 |
| - |
157 |
| -SlicedArguments::SlicedArguments( |
158 |
| - const v8::FunctionCallbackInfo<v8::Value>& args, |
159 |
| - size_t start) : size_(0), data_(fixed_) { |
160 |
| - const size_t length = static_cast<size_t>(args.Length()); |
161 |
| - if (start >= length) return; |
162 |
| - const size_t size = length - start; |
163 |
| - |
164 |
| - if (size > arraysize(fixed_)) { |
165 |
| - dynamic_.resize(size); |
166 |
| - data_ = dynamic_.data(); |
167 |
| - } |
168 |
| - |
169 |
| - for (size_t i = 0; i < size; ++i) |
170 |
| - data_[i] = args[i + start]; |
171 |
| - |
172 |
| - size_ = size; |
173 |
| -} |
174 |
| - |
175 | 99 | namespace task_queue {
|
176 | 100 | void PromiseRejectCallback(v8::PromiseRejectMessage message);
|
177 | 101 | } // namespace task_queue
|
178 | 102 |
|
179 |
| -enum Endianness { |
180 |
| - kLittleEndian, // _Not_ LITTLE_ENDIAN, clashes with endian.h. |
181 |
| - kBigEndian |
182 |
| -}; |
183 |
| - |
184 |
| -inline enum Endianness GetEndianness() { |
185 |
| - // Constant-folded by the compiler. |
186 |
| - const union { |
187 |
| - uint8_t u8[2]; |
188 |
| - uint16_t u16; |
189 |
| - } u = { |
190 |
| - { 1, 0 } |
191 |
| - }; |
192 |
| - return u.u16 == 1 ? kLittleEndian : kBigEndian; |
193 |
| -} |
194 |
| - |
195 |
| -inline bool IsLittleEndian() { |
196 |
| - return GetEndianness() == kLittleEndian; |
197 |
| -} |
198 |
| - |
199 |
| -inline bool IsBigEndian() { |
200 |
| - return GetEndianness() == kBigEndian; |
201 |
| -} |
202 |
| - |
203 | 103 | class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
|
204 | 104 | public:
|
205 | 105 | inline uint32_t* zero_fill_field() { return &zero_fill_field_; }
|
|
0 commit comments