catboost 1.25.1 → 1.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DEPLOYMENT.md +22 -15
- package/README.md +37 -27
- package/binding.gyp +5 -7
- package/build_scripts/bootstrap.js +2 -1
- package/build_scripts/out/build.js +46 -68
- package/build_scripts/out/build_model.js +1 -1
- package/build_scripts/out/{build_ya.js → build_native.js} +1 -1
- package/build_scripts/out/ci.js +5 -5
- package/build_scripts/out/config.js +32 -18
- package/build_scripts/out/install.js +5 -3
- package/build_scripts/out/package_prepublish.js +1 -1
- package/build_scripts/out/packaging.js +1 -19
- package/build_scripts/out/run_tests.js +1 -1
- package/build_scripts/out/test.js +8 -3
- package/config.json +18 -11
- package/inc/catboost/libs/model_interface/c_api.h +349 -3
- package/lib/catboost.d.ts +65 -21
- package/package.json +4 -4
- package/src/api_helpers.cpp +100 -24
- package/src/api_helpers.h +8 -7
- package/src/api_module.cpp +1 -2
- package/src/model.cpp +483 -83
- package/src/model.h +24 -9
- package/inc/contrib/libs/cxxsupp/system_stl/include/stlfwd +0 -14
- package/inc/util/charset/recode_result.h +0 -9
- package/inc/util/charset/unicode_table.h +0 -123
- package/inc/util/charset/unidata.h +0 -421
- package/inc/util/charset/utf8.h +0 -384
- package/inc/util/charset/wide.h +0 -843
- package/inc/util/charset/wide_specific.h +0 -22
- package/inc/util/datetime/base.h +0 -669
- package/inc/util/datetime/constants.h +0 -7
- package/inc/util/datetime/cputimer.h +0 -124
- package/inc/util/datetime/parser.h +0 -292
- package/inc/util/datetime/systime.h +0 -47
- package/inc/util/datetime/uptime.h +0 -8
- package/inc/util/digest/city.h +0 -88
- package/inc/util/digest/fnv.h +0 -73
- package/inc/util/digest/multi.h +0 -14
- package/inc/util/digest/murmur.h +0 -57
- package/inc/util/digest/numeric.h +0 -86
- package/inc/util/digest/sequence.h +0 -48
- package/inc/util/draft/date.h +0 -129
- package/inc/util/draft/datetime.h +0 -184
- package/inc/util/draft/enum.h +0 -136
- package/inc/util/draft/holder_vector.h +0 -102
- package/inc/util/draft/ip.h +0 -131
- package/inc/util/draft/matrix.h +0 -108
- package/inc/util/draft/memory.h +0 -40
- package/inc/util/folder/dirent_win.h +0 -46
- package/inc/util/folder/dirut.h +0 -121
- package/inc/util/folder/filelist.h +0 -81
- package/inc/util/folder/fts.h +0 -108
- package/inc/util/folder/iterator.h +0 -109
- package/inc/util/folder/lstat_win.h +0 -20
- package/inc/util/folder/path.h +0 -225
- package/inc/util/folder/pathsplit.h +0 -113
- package/inc/util/folder/tempdir.h +0 -42
- package/inc/util/generic/adaptor.h +0 -134
- package/inc/util/generic/algorithm.h +0 -765
- package/inc/util/generic/array_ref.h +0 -282
- package/inc/util/generic/array_size.h +0 -24
- package/inc/util/generic/benchmark/vector_count_ctor/f.h +0 -9
- package/inc/util/generic/bitmap.h +0 -1115
- package/inc/util/generic/bitops.h +0 -459
- package/inc/util/generic/bt_exception.h +0 -24
- package/inc/util/generic/buffer.h +0 -232
- package/inc/util/generic/cast.h +0 -176
- package/inc/util/generic/deque.h +0 -24
- package/inc/util/generic/explicit_type.h +0 -42
- package/inc/util/generic/fastqueue.h +0 -55
- package/inc/util/generic/flags.h +0 -244
- package/inc/util/generic/function.h +0 -103
- package/inc/util/generic/fwd.h +0 -171
- package/inc/util/generic/guid.h +0 -61
- package/inc/util/generic/hash.h +0 -2032
- package/inc/util/generic/hash_primes.h +0 -140
- package/inc/util/generic/hash_set.h +0 -490
- package/inc/util/generic/hide_ptr.h +0 -3
- package/inc/util/generic/intrlist.h +0 -876
- package/inc/util/generic/is_in.h +0 -53
- package/inc/util/generic/iterator.h +0 -137
- package/inc/util/generic/iterator_range.h +0 -105
- package/inc/util/generic/lazy_value.h +0 -66
- package/inc/util/generic/list.h +0 -22
- package/inc/util/generic/map.h +0 -44
- package/inc/util/generic/mapfindptr.h +0 -60
- package/inc/util/generic/maybe.h +0 -713
- package/inc/util/generic/maybe_traits.h +0 -164
- package/inc/util/generic/mem_copy.h +0 -55
- package/inc/util/generic/noncopyable.h +0 -38
- package/inc/util/generic/object_counter.h +0 -53
- package/inc/util/generic/ptr.h +0 -1113
- package/inc/util/generic/queue.h +0 -57
- package/inc/util/generic/refcount.h +0 -162
- package/inc/util/generic/reserve.h +0 -11
- package/inc/util/generic/scope.h +0 -65
- package/inc/util/generic/serialized_enum.h +0 -406
- package/inc/util/generic/set.h +0 -42
- package/inc/util/generic/singleton.h +0 -136
- package/inc/util/generic/size_literals.h +0 -65
- package/inc/util/generic/stack.h +0 -18
- package/inc/util/generic/store_policy.h +0 -120
- package/inc/util/generic/strbase.h +0 -612
- package/inc/util/generic/strbuf.h +0 -552
- package/inc/util/generic/strfcpy.h +0 -17
- package/inc/util/generic/string.h +0 -1572
- package/inc/util/generic/string_hash.h +0 -21
- package/inc/util/generic/string_ut.h +0 -1175
- package/inc/util/generic/type_name.h +0 -34
- package/inc/util/generic/typelist.h +0 -114
- package/inc/util/generic/typetraits.h +0 -325
- package/inc/util/generic/utility.h +0 -132
- package/inc/util/generic/va_args.h +0 -400
- package/inc/util/generic/variant.h +0 -631
- package/inc/util/generic/variant_traits.h +0 -171
- package/inc/util/generic/vector.h +0 -119
- package/inc/util/generic/xrange.h +0 -258
- package/inc/util/generic/yexception.h +0 -212
- package/inc/util/generic/yexception_ut.h +0 -14
- package/inc/util/generic/ylimits.h +0 -92
- package/inc/util/generic/ymath.h +0 -206
- package/inc/util/memory/addstorage.h +0 -93
- package/inc/util/memory/alloc.h +0 -27
- package/inc/util/memory/blob.h +0 -296
- package/inc/util/memory/mmapalloc.h +0 -8
- package/inc/util/memory/pool.h +0 -432
- package/inc/util/memory/segmented_string_pool.h +0 -194
- package/inc/util/memory/segpool_alloc.h +0 -118
- package/inc/util/memory/smallobj.h +0 -141
- package/inc/util/memory/tempbuf.h +0 -111
- package/inc/util/network/address.h +0 -136
- package/inc/util/network/endpoint.h +0 -61
- package/inc/util/network/hostip.h +0 -16
- package/inc/util/network/init.h +0 -60
- package/inc/util/network/interface.h +0 -17
- package/inc/util/network/iovec.h +0 -65
- package/inc/util/network/ip.h +0 -116
- package/inc/util/network/nonblock.h +0 -8
- package/inc/util/network/pair.h +0 -9
- package/inc/util/network/poller.h +0 -58
- package/inc/util/network/pollerimpl.h +0 -707
- package/inc/util/network/sock.h +0 -608
- package/inc/util/network/socket.h +0 -421
- package/inc/util/random/common_ops.h +0 -130
- package/inc/util/random/easy.h +0 -47
- package/inc/util/random/entropy.h +0 -21
- package/inc/util/random/fast.h +0 -101
- package/inc/util/random/init_atfork.h +0 -3
- package/inc/util/random/lcg_engine.h +0 -66
- package/inc/util/random/mersenne.h +0 -46
- package/inc/util/random/mersenne32.h +0 -50
- package/inc/util/random/mersenne64.h +0 -50
- package/inc/util/random/normal.h +0 -38
- package/inc/util/random/random.h +0 -30
- package/inc/util/random/shuffle.h +0 -39
- package/inc/util/str_stl.h +0 -266
- package/inc/util/stream/aligned.h +0 -99
- package/inc/util/stream/buffer.h +0 -119
- package/inc/util/stream/buffered.h +0 -225
- package/inc/util/stream/debug.h +0 -53
- package/inc/util/stream/direct_io.h +0 -43
- package/inc/util/stream/file.h +0 -108
- package/inc/util/stream/format.h +0 -444
- package/inc/util/stream/fwd.h +0 -100
- package/inc/util/stream/hex.h +0 -8
- package/inc/util/stream/holder.h +0 -44
- package/inc/util/stream/input.h +0 -273
- package/inc/util/stream/labeled.h +0 -19
- package/inc/util/stream/length.h +0 -100
- package/inc/util/stream/mem.h +0 -255
- package/inc/util/stream/multi.h +0 -32
- package/inc/util/stream/null.h +0 -61
- package/inc/util/stream/output.h +0 -304
- package/inc/util/stream/pipe.h +0 -112
- package/inc/util/stream/printf.h +0 -25
- package/inc/util/stream/str.h +0 -207
- package/inc/util/stream/tee.h +0 -28
- package/inc/util/stream/tempbuf.h +0 -21
- package/inc/util/stream/tokenizer.h +0 -214
- package/inc/util/stream/trace.h +0 -60
- package/inc/util/stream/walk.h +0 -35
- package/inc/util/stream/zerocopy.h +0 -91
- package/inc/util/stream/zerocopy_output.h +0 -57
- package/inc/util/stream/zlib.h +0 -173
- package/inc/util/string/ascii.h +0 -236
- package/inc/util/string/builder.h +0 -39
- package/inc/util/string/cast.h +0 -347
- package/inc/util/string/cstriter.h +0 -14
- package/inc/util/string/escape.h +0 -70
- package/inc/util/string/hex.h +0 -59
- package/inc/util/string/join.h +0 -194
- package/inc/util/string/printf.h +0 -13
- package/inc/util/string/reverse.h +0 -16
- package/inc/util/string/split.h +0 -1080
- package/inc/util/string/strip.h +0 -257
- package/inc/util/string/strspn.h +0 -65
- package/inc/util/string/subst.h +0 -56
- package/inc/util/string/type.h +0 -50
- package/inc/util/string/util.h +0 -195
- package/inc/util/string/vector.h +0 -132
- package/inc/util/system/align.h +0 -50
- package/inc/util/system/atexit.h +0 -22
- package/inc/util/system/atomic.h +0 -51
- package/inc/util/system/atomic_gcc.h +0 -90
- package/inc/util/system/atomic_ops.h +0 -189
- package/inc/util/system/atomic_win.h +0 -114
- package/inc/util/system/backtrace.h +0 -39
- package/inc/util/system/byteorder.h +0 -186
- package/inc/util/system/compat.h +0 -84
- package/inc/util/system/compiler.h +0 -620
- package/inc/util/system/condvar.h +0 -71
- package/inc/util/system/context.h +0 -181
- package/inc/util/system/context_aarch64.h +0 -8
- package/inc/util/system/context_i686.h +0 -9
- package/inc/util/system/context_x86.h +0 -12
- package/inc/util/system/context_x86_64.h +0 -7
- package/inc/util/system/cpu_id.h +0 -159
- package/inc/util/system/daemon.h +0 -28
- package/inc/util/system/datetime.h +0 -98
- package/inc/util/system/defaults.h +0 -149
- package/inc/util/system/demangle.h +0 -5
- package/inc/util/system/demangle_impl.h +0 -23
- package/inc/util/system/direct_io.h +0 -71
- package/inc/util/system/dynlib.h +0 -119
- package/inc/util/system/env.h +0 -32
- package/inc/util/system/error.h +0 -95
- package/inc/util/system/event.h +0 -122
- package/inc/util/system/execpath.h +0 -17
- package/inc/util/system/fasttime.h +0 -6
- package/inc/util/system/fhandle.h +0 -27
- package/inc/util/system/file.h +0 -210
- package/inc/util/system/file_lock.h +0 -34
- package/inc/util/system/filemap.h +0 -383
- package/inc/util/system/flock.h +0 -35
- package/inc/util/system/fs.h +0 -156
- package/inc/util/system/fs_win.h +0 -29
- package/inc/util/system/fstat.h +0 -46
- package/inc/util/system/getpid.h +0 -12
- package/inc/util/system/guard.h +0 -179
- package/inc/util/system/hi_lo.h +0 -139
- package/inc/util/system/hostname.h +0 -10
- package/inc/util/system/hp_timer.h +0 -36
- package/inc/util/system/info.h +0 -12
- package/inc/util/system/interrupt_signals.h +0 -22
- package/inc/util/system/madvise.h +0 -30
- package/inc/util/system/maxlen.h +0 -32
- package/inc/util/system/mem_info.h +0 -18
- package/inc/util/system/mincore.h +0 -38
- package/inc/util/system/mktemp.h +0 -11
- package/inc/util/system/mlock.h +0 -43
- package/inc/util/system/mutex.h +0 -67
- package/inc/util/system/nice.h +0 -3
- package/inc/util/system/pipe.h +0 -90
- package/inc/util/system/platform.h +0 -246
- package/inc/util/system/progname.h +0 -13
- package/inc/util/system/protect.h +0 -25
- package/inc/util/system/rusage.h +0 -26
- package/inc/util/system/rwlock.h +0 -78
- package/inc/util/system/sanitizers.h +0 -122
- package/inc/util/system/sem.h +0 -41
- package/inc/util/system/shellcommand.h +0 -472
- package/inc/util/system/shmat.h +0 -32
- package/inc/util/system/sigset.h +0 -78
- package/inc/util/system/spin_wait.h +0 -10
- package/inc/util/system/spinlock.h +0 -121
- package/inc/util/system/src_location.h +0 -25
- package/inc/util/system/src_root.h +0 -68
- package/inc/util/system/sys_alloc.h +0 -43
- package/inc/util/system/sysstat.h +0 -52
- package/inc/util/system/tempfile.h +0 -34
- package/inc/util/system/thread.h +0 -167
- package/inc/util/system/tls.h +0 -307
- package/inc/util/system/types.h +0 -119
- package/inc/util/system/unaligned_mem.h +0 -67
- package/inc/util/system/user.h +0 -5
- package/inc/util/system/utime.h +0 -6
- package/inc/util/system/valgrind.h +0 -48
- package/inc/util/system/winint.h +0 -43
- package/inc/util/system/yassert.h +0 -121
- package/inc/util/system/yield.h +0 -4
- package/inc/util/thread/factory.h +0 -65
- package/inc/util/thread/fwd.h +0 -30
- package/inc/util/thread/lfqueue.h +0 -406
- package/inc/util/thread/lfstack.h +0 -188
- package/inc/util/thread/pool.h +0 -388
- package/inc/util/thread/singleton.h +0 -42
- package/inc/util/ysafeptr.h +0 -427
- package/inc/util/ysaveload.h +0 -700
package/inc/util/string/vector.h
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include "cast.h"
|
|
4
|
-
#include "split.h"
|
|
5
|
-
|
|
6
|
-
#include <util/generic/map.h>
|
|
7
|
-
#include <util/generic/strbuf.h>
|
|
8
|
-
#include <util/generic/string.h>
|
|
9
|
-
#include <util/generic/vector.h>
|
|
10
|
-
#include <util/string/cast.h>
|
|
11
|
-
#include <util/system/yassert.h>
|
|
12
|
-
|
|
13
|
-
#define KEEP_EMPTY_TOKENS 0x01
|
|
14
|
-
|
|
15
|
-
//
|
|
16
|
-
// NOTE: Check StringSplitter below to get more convenient split string interface.
|
|
17
|
-
|
|
18
|
-
namespace NPrivate {
|
|
19
|
-
|
|
20
|
-
void SplitStringImpl(TVector<TString>* res, const char* ptr,
|
|
21
|
-
const char* delimiter, size_t maxFields, int options);
|
|
22
|
-
void SplitStringImpl(TVector<TString>* res, const char* ptr, size_t len,
|
|
23
|
-
const char* delimiter, size_t maxFields, int options);
|
|
24
|
-
|
|
25
|
-
void SplitStringImpl(TVector<TUtf16String>* res, const wchar16* ptr,
|
|
26
|
-
const wchar16* delimiter, size_t maxFields, int options);
|
|
27
|
-
void SplitStringImpl(TVector<TUtf16String>* res, const wchar16* ptr, size_t len,
|
|
28
|
-
const wchar16* delimiter, size_t maxFields, int options);
|
|
29
|
-
|
|
30
|
-
template <typename C>
|
|
31
|
-
struct TStringDeducer;
|
|
32
|
-
|
|
33
|
-
template <>
|
|
34
|
-
struct TStringDeducer<char> {
|
|
35
|
-
using type = TString;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
template <>
|
|
39
|
-
struct TStringDeducer<wchar16> {
|
|
40
|
-
using type = TUtf16String;
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
template <typename C>
|
|
45
|
-
TVector<typename ::NPrivate::TStringDeducer<C>::type>
|
|
46
|
-
SplitString(const C* ptr, const C* delimiter,
|
|
47
|
-
size_t maxFields = 0, int options = 0) {
|
|
48
|
-
TVector<typename ::NPrivate::TStringDeducer<C>::type> res;
|
|
49
|
-
::NPrivate::SplitStringImpl(&res, ptr, delimiter, maxFields, options);
|
|
50
|
-
return res;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
template <typename C>
|
|
54
|
-
TVector<typename ::NPrivate::TStringDeducer<C>::type>
|
|
55
|
-
SplitString(const C* ptr, size_t len, const C* delimiter,
|
|
56
|
-
size_t maxFields = 0, int options = 0) {
|
|
57
|
-
TVector<typename ::NPrivate::TStringDeducer<C>::type> res;
|
|
58
|
-
::NPrivate::SplitStringImpl(&res, ptr, len, delimiter, maxFields, options);
|
|
59
|
-
return res;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
template <typename C>
|
|
63
|
-
TVector<typename ::NPrivate::TStringDeducer<C>::type>
|
|
64
|
-
SplitString(const typename ::NPrivate::TStringDeducer<C>::type& str, const C* delimiter,
|
|
65
|
-
size_t maxFields = 0, int options = 0) {
|
|
66
|
-
return SplitString(str.data(), str.size(), delimiter, maxFields, options);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
template <class TIter>
|
|
70
|
-
inline TString JoinStrings(TIter begin, TIter end, const TStringBuf delim) {
|
|
71
|
-
if (begin == end)
|
|
72
|
-
return TString();
|
|
73
|
-
|
|
74
|
-
TString result = ToString(*begin);
|
|
75
|
-
|
|
76
|
-
for (++begin; begin != end; ++begin) {
|
|
77
|
-
result.append(delim);
|
|
78
|
-
result.append(ToString(*begin));
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return result;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
template <class TIter>
|
|
85
|
-
inline TUtf16String JoinStrings(TIter begin, TIter end, const TWtringBuf delim) {
|
|
86
|
-
if (begin == end)
|
|
87
|
-
return TUtf16String();
|
|
88
|
-
|
|
89
|
-
TUtf16String result = ToWtring(*begin);
|
|
90
|
-
|
|
91
|
-
for (++begin; begin != end; ++begin) {
|
|
92
|
-
result.append(delim);
|
|
93
|
-
result.append(ToWtring(*begin));
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return result;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/// Concatenates elements of given TVector<TString>.
|
|
100
|
-
inline TString JoinStrings(const TVector<TString>& v, const TStringBuf delim) {
|
|
101
|
-
return JoinStrings(v.begin(), v.end(), delim);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
inline TString JoinStrings(const TVector<TString>& v, size_t index, size_t count, const TStringBuf delim) {
|
|
105
|
-
Y_ASSERT(index + count <= v.size() && "JoinStrings(): index or count out of range");
|
|
106
|
-
return JoinStrings(v.begin() + index, v.begin() + index + count, delim);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
template <typename T>
|
|
110
|
-
inline TString JoinVectorIntoString(const TVector<T>& v, const TStringBuf delim) {
|
|
111
|
-
return JoinStrings(v.begin(), v.end(), delim);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
template <typename T>
|
|
115
|
-
inline TString JoinVectorIntoString(const TVector<T>& v, size_t index, size_t count, const TStringBuf delim) {
|
|
116
|
-
Y_ASSERT(index + count <= v.size() && "JoinVectorIntoString(): index or count out of range");
|
|
117
|
-
return JoinStrings(v.begin() + index, v.begin() + index + count, delim);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
TUtf16String JoinStrings(const TVector<TUtf16String>& v, const TWtringBuf delim);
|
|
121
|
-
TUtf16String JoinStrings(const TVector<TUtf16String>& v, size_t index, size_t count, const TWtringBuf delim);
|
|
122
|
-
|
|
123
|
-
//! Converts vector of strings to vector of type T variables
|
|
124
|
-
template <typename T, typename TStringType>
|
|
125
|
-
TVector<T> Scan(const TVector<TStringType>& input) {
|
|
126
|
-
TVector<T> output;
|
|
127
|
-
output.reserve(input.size());
|
|
128
|
-
for (int i = 0; i < input.ysize(); ++i) {
|
|
129
|
-
output.push_back(FromString<T>(input[i]));
|
|
130
|
-
}
|
|
131
|
-
return output;
|
|
132
|
-
}
|
package/inc/util/system/align.h
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include "yassert.h"
|
|
4
|
-
#include "defaults.h"
|
|
5
|
-
#include <util/generic/bitops.h>
|
|
6
|
-
|
|
7
|
-
template <class T>
|
|
8
|
-
static inline T AlignDown(T len, T align) noexcept {
|
|
9
|
-
Y_ASSERT(IsPowerOf2(align)); // align should be power of 2
|
|
10
|
-
return len & ~(align - 1);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
template <class T>
|
|
14
|
-
static inline T AlignUp(T len, T align) noexcept {
|
|
15
|
-
const T alignedResult = AlignDown(len + (align - 1), align);
|
|
16
|
-
Y_ASSERT(alignedResult >= len); // check for overflow
|
|
17
|
-
return alignedResult;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
template <class T>
|
|
21
|
-
static inline T AlignUpSpace(T len, T align) noexcept {
|
|
22
|
-
Y_ASSERT(IsPowerOf2(align)); // align should be power of 2
|
|
23
|
-
return ((T)0 - len) & (align - 1); // AlignUp(len, align) - len;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
template <class T>
|
|
27
|
-
static inline T* AlignUp(T* ptr, size_t align) noexcept {
|
|
28
|
-
return (T*)AlignUp((uintptr_t)ptr, align);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
template <class T>
|
|
32
|
-
static inline T* AlignDown(T* ptr, size_t align) noexcept {
|
|
33
|
-
return (T*)AlignDown((uintptr_t)ptr, align);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
template <class T>
|
|
37
|
-
static inline T AlignUp(T t) noexcept {
|
|
38
|
-
return AlignUp(t, (size_t)PLATFORM_DATA_ALIGN);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
template <class T>
|
|
42
|
-
static inline T AlignDown(T t) noexcept {
|
|
43
|
-
return AlignDown(t, (size_t)PLATFORM_DATA_ALIGN);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
template <class T>
|
|
47
|
-
static inline T Align(T t) noexcept {
|
|
48
|
-
return AlignUp(t);
|
|
49
|
-
}
|
|
50
|
-
|
package/inc/util/system/atexit.h
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include "defaults.h"
|
|
4
|
-
|
|
5
|
-
using TAtExitFunc = void (*)(void*);
|
|
6
|
-
using TTraditionalAtExitFunc = void (*)();
|
|
7
|
-
|
|
8
|
-
void AtExit(TAtExitFunc func, void* ctx);
|
|
9
|
-
void AtExit(TAtExitFunc func, void* ctx, size_t priority);
|
|
10
|
-
|
|
11
|
-
void AtExit(TTraditionalAtExitFunc func);
|
|
12
|
-
void AtExit(TTraditionalAtExitFunc func, size_t priority);
|
|
13
|
-
|
|
14
|
-
bool ExitStarted();
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Generally it's a bad idea to call this method except for some rare cases,
|
|
18
|
-
* like graceful python DLL module unload.
|
|
19
|
-
* This function is not threadsafe.
|
|
20
|
-
* Calls in the moment when application is not terminating - bad idea.
|
|
21
|
-
*/
|
|
22
|
-
void ManualRunAtExitFinalizers();
|
package/inc/util/system/atomic.h
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include "defaults.h"
|
|
4
|
-
|
|
5
|
-
using TAtomicBase = intptr_t;
|
|
6
|
-
using TAtomic = volatile TAtomicBase;
|
|
7
|
-
|
|
8
|
-
#if defined(__GNUC__)
|
|
9
|
-
#include "atomic_gcc.h"
|
|
10
|
-
#elif defined(_MSC_VER)
|
|
11
|
-
#include "atomic_win.h"
|
|
12
|
-
#else
|
|
13
|
-
#error unsupported platform
|
|
14
|
-
#endif
|
|
15
|
-
|
|
16
|
-
#if !defined(ATOMIC_COMPILER_BARRIER)
|
|
17
|
-
#define ATOMIC_COMPILER_BARRIER()
|
|
18
|
-
#endif
|
|
19
|
-
|
|
20
|
-
static inline TAtomicBase AtomicSub(TAtomic& a, TAtomicBase v) {
|
|
21
|
-
return AtomicAdd(a, -v);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
static inline TAtomicBase AtomicGetAndSub(TAtomic& a, TAtomicBase v) {
|
|
25
|
-
return AtomicGetAndAdd(a, -v);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
#if defined(USE_GENERIC_SETGET)
|
|
29
|
-
static inline TAtomicBase AtomicGet(const TAtomic& a) {
|
|
30
|
-
return a;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
static inline void AtomicSet(TAtomic& a, TAtomicBase v) {
|
|
34
|
-
a = v;
|
|
35
|
-
}
|
|
36
|
-
#endif
|
|
37
|
-
|
|
38
|
-
static inline bool AtomicTryLock(TAtomic* a) {
|
|
39
|
-
return AtomicCas(a, 1, 0);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
static inline bool AtomicTryAndTryLock(TAtomic* a) {
|
|
43
|
-
return (AtomicGet(*a) == 0) && AtomicTryLock(a);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
static inline void AtomicUnlock(TAtomic* a) {
|
|
47
|
-
ATOMIC_COMPILER_BARRIER();
|
|
48
|
-
AtomicSet(*a, 0);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
#include "atomic_ops.h"
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#define ATOMIC_COMPILER_BARRIER() __asm__ __volatile__("" \
|
|
4
|
-
: \
|
|
5
|
-
: \
|
|
6
|
-
: "memory")
|
|
7
|
-
|
|
8
|
-
static inline TAtomicBase AtomicGet(const TAtomic& a) {
|
|
9
|
-
TAtomicBase tmp;
|
|
10
|
-
#if defined(_arm64_)
|
|
11
|
-
__asm__ __volatile__(
|
|
12
|
-
"ldar %x[value], %[ptr] \n\t"
|
|
13
|
-
: [value] "=r"(tmp)
|
|
14
|
-
: [ptr] "Q"(a)
|
|
15
|
-
: "memory");
|
|
16
|
-
#else
|
|
17
|
-
__atomic_load(&a, &tmp, __ATOMIC_ACQUIRE);
|
|
18
|
-
#endif
|
|
19
|
-
return tmp;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
static inline void AtomicSet(TAtomic& a, TAtomicBase v) {
|
|
23
|
-
#if defined(_arm64_)
|
|
24
|
-
__asm__ __volatile__(
|
|
25
|
-
"stlr %x[value], %[ptr] \n\t"
|
|
26
|
-
: [ptr] "=Q"(a)
|
|
27
|
-
: [value] "r"(v)
|
|
28
|
-
: "memory");
|
|
29
|
-
#else
|
|
30
|
-
__atomic_store(&a, &v, __ATOMIC_RELEASE);
|
|
31
|
-
#endif
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
static inline intptr_t AtomicIncrement(TAtomic& p) {
|
|
35
|
-
return __atomic_add_fetch(&p, 1, __ATOMIC_SEQ_CST);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
static inline intptr_t AtomicGetAndIncrement(TAtomic& p) {
|
|
39
|
-
return __atomic_fetch_add(&p, 1, __ATOMIC_SEQ_CST);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
static inline intptr_t AtomicDecrement(TAtomic& p) {
|
|
43
|
-
return __atomic_sub_fetch(&p, 1, __ATOMIC_SEQ_CST);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
static inline intptr_t AtomicGetAndDecrement(TAtomic& p) {
|
|
47
|
-
return __atomic_fetch_sub(&p, 1, __ATOMIC_SEQ_CST);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
static inline intptr_t AtomicAdd(TAtomic& p, intptr_t v) {
|
|
51
|
-
return __atomic_add_fetch(&p, v, __ATOMIC_SEQ_CST);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
static inline intptr_t AtomicGetAndAdd(TAtomic& p, intptr_t v) {
|
|
55
|
-
return __atomic_fetch_add(&p, v, __ATOMIC_SEQ_CST);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
static inline intptr_t AtomicSwap(TAtomic* p, intptr_t v) {
|
|
59
|
-
(void)p; // disable strange 'parameter set but not used' warning on gcc
|
|
60
|
-
intptr_t ret;
|
|
61
|
-
__atomic_exchange(p, &v, &ret, __ATOMIC_SEQ_CST);
|
|
62
|
-
return ret;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
static inline bool AtomicCas(TAtomic* a, intptr_t exchange, intptr_t compare) {
|
|
66
|
-
(void)a; // disable strange 'parameter set but not used' warning on gcc
|
|
67
|
-
return __atomic_compare_exchange(a, &compare, &exchange, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
static inline intptr_t AtomicGetAndCas(TAtomic* a, intptr_t exchange, intptr_t compare) {
|
|
71
|
-
(void)a; // disable strange 'parameter set but not used' warning on gcc
|
|
72
|
-
__atomic_compare_exchange(a, &compare, &exchange, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
|
|
73
|
-
return compare;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
static inline intptr_t AtomicOr(TAtomic& a, intptr_t b) {
|
|
77
|
-
return __atomic_or_fetch(&a, b, __ATOMIC_SEQ_CST);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
static inline intptr_t AtomicXor(TAtomic& a, intptr_t b) {
|
|
81
|
-
return __atomic_xor_fetch(&a, b, __ATOMIC_SEQ_CST);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
static inline intptr_t AtomicAnd(TAtomic& a, intptr_t b) {
|
|
85
|
-
return __atomic_and_fetch(&a, b, __ATOMIC_SEQ_CST);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
static inline void AtomicBarrier() {
|
|
89
|
-
__sync_synchronize();
|
|
90
|
-
}
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include <util/generic/typetraits.h>
|
|
4
|
-
|
|
5
|
-
template <typename T>
|
|
6
|
-
inline TAtomic* AsAtomicPtr(T volatile* target) {
|
|
7
|
-
return reinterpret_cast<TAtomic*>(target);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
template <typename T>
|
|
11
|
-
inline const TAtomic* AsAtomicPtr(T const volatile* target) {
|
|
12
|
-
return reinterpret_cast<const TAtomic*>(target);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// integral types
|
|
16
|
-
|
|
17
|
-
template <typename T>
|
|
18
|
-
struct TAtomicTraits {
|
|
19
|
-
enum {
|
|
20
|
-
Castable = std::is_integral<T>::value && sizeof(T) == sizeof(TAtomicBase) && !std::is_const<T>::value,
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
template <typename T, typename TT>
|
|
25
|
-
using TEnableIfCastable = std::enable_if_t<TAtomicTraits<T>::Castable, TT>;
|
|
26
|
-
|
|
27
|
-
template <typename T>
|
|
28
|
-
inline TEnableIfCastable<T, T> AtomicGet(T const volatile& target) {
|
|
29
|
-
return static_cast<T>(AtomicGet(*AsAtomicPtr(&target)));
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
template <typename T>
|
|
33
|
-
inline TEnableIfCastable<T, void> AtomicSet(T volatile& target, TAtomicBase value) {
|
|
34
|
-
AtomicSet(*AsAtomicPtr(&target), value);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
template <typename T>
|
|
38
|
-
inline TEnableIfCastable<T, T> AtomicIncrement(T volatile& target) {
|
|
39
|
-
return static_cast<T>(AtomicIncrement(*AsAtomicPtr(&target)));
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
template <typename T>
|
|
43
|
-
inline TEnableIfCastable<T, T> AtomicGetAndIncrement(T volatile& target) {
|
|
44
|
-
return static_cast<T>(AtomicGetAndIncrement(*AsAtomicPtr(&target)));
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
template <typename T>
|
|
48
|
-
inline TEnableIfCastable<T, T> AtomicDecrement(T volatile& target) {
|
|
49
|
-
return static_cast<T>(AtomicDecrement(*AsAtomicPtr(&target)));
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
template <typename T>
|
|
53
|
-
inline TEnableIfCastable<T, T> AtomicGetAndDecrement(T volatile& target) {
|
|
54
|
-
return static_cast<T>(AtomicGetAndDecrement(*AsAtomicPtr(&target)));
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
template <typename T>
|
|
58
|
-
inline TEnableIfCastable<T, T> AtomicAdd(T volatile& target, TAtomicBase value) {
|
|
59
|
-
return static_cast<T>(AtomicAdd(*AsAtomicPtr(&target), value));
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
template <typename T>
|
|
63
|
-
inline TEnableIfCastable<T, T> AtomicGetAndAdd(T volatile& target, TAtomicBase value) {
|
|
64
|
-
return static_cast<T>(AtomicGetAndAdd(*AsAtomicPtr(&target), value));
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
template <typename T>
|
|
68
|
-
inline TEnableIfCastable<T, T> AtomicSub(T volatile& target, TAtomicBase value) {
|
|
69
|
-
return static_cast<T>(AtomicSub(*AsAtomicPtr(&target), value));
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
template <typename T>
|
|
73
|
-
inline TEnableIfCastable<T, T> AtomicGetAndSub(T volatile& target, TAtomicBase value) {
|
|
74
|
-
return static_cast<T>(AtomicGetAndSub(*AsAtomicPtr(&target), value));
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
template <typename T>
|
|
78
|
-
inline TEnableIfCastable<T, T> AtomicSwap(T volatile* target, TAtomicBase exchange) {
|
|
79
|
-
return static_cast<T>(AtomicSwap(AsAtomicPtr(target), exchange));
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
template <typename T>
|
|
83
|
-
inline TEnableIfCastable<T, bool> AtomicCas(T volatile* target, TAtomicBase exchange, TAtomicBase compare) {
|
|
84
|
-
return AtomicCas(AsAtomicPtr(target), exchange, compare);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
template <typename T>
|
|
88
|
-
inline TEnableIfCastable<T, T> AtomicGetAndCas(T volatile* target, TAtomicBase exchange, TAtomicBase compare) {
|
|
89
|
-
return static_cast<T>(AtomicGetAndCas(AsAtomicPtr(target), exchange, compare));
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
template <typename T>
|
|
93
|
-
inline TEnableIfCastable<T, bool> AtomicTryLock(T volatile* target) {
|
|
94
|
-
return AtomicTryLock(AsAtomicPtr(target));
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
template <typename T>
|
|
98
|
-
inline TEnableIfCastable<T, bool> AtomicTryAndTryLock(T volatile* target) {
|
|
99
|
-
return AtomicTryAndTryLock(AsAtomicPtr(target));
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
template <typename T>
|
|
103
|
-
inline TEnableIfCastable<T, void> AtomicUnlock(T volatile* target) {
|
|
104
|
-
AtomicUnlock(AsAtomicPtr(target));
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
template <typename T>
|
|
108
|
-
inline TEnableIfCastable<T, T> AtomicOr(T volatile& target, TAtomicBase value) {
|
|
109
|
-
return static_cast<T>(AtomicOr(*AsAtomicPtr(&target), value));
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
template <typename T>
|
|
113
|
-
inline TEnableIfCastable<T, T> AtomicAnd(T volatile& target, TAtomicBase value) {
|
|
114
|
-
return static_cast<T>(AtomicAnd(*AsAtomicPtr(&target), value));
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
template <typename T>
|
|
118
|
-
inline TEnableIfCastable<T, T> AtomicXor(T volatile& target, TAtomicBase value) {
|
|
119
|
-
return static_cast<T>(AtomicXor(*AsAtomicPtr(&target), value));
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// pointer types
|
|
123
|
-
|
|
124
|
-
template <typename T>
|
|
125
|
-
inline T* AtomicGet(T* const volatile& target) {
|
|
126
|
-
return reinterpret_cast<T*>(AtomicGet(*AsAtomicPtr(&target)));
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
template <typename T>
|
|
130
|
-
inline void AtomicSet(T* volatile& target, T* value) {
|
|
131
|
-
AtomicSet(*AsAtomicPtr(&target), reinterpret_cast<TAtomicBase>(value));
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
using TNullPtr = decltype(nullptr);
|
|
135
|
-
|
|
136
|
-
template <typename T>
|
|
137
|
-
inline void AtomicSet(T* volatile& target, TNullPtr) {
|
|
138
|
-
AtomicSet(*AsAtomicPtr(&target), 0);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
template <typename T>
|
|
142
|
-
inline T* AtomicSwap(T* volatile* target, T* exchange) {
|
|
143
|
-
return reinterpret_cast<T*>(AtomicSwap(AsAtomicPtr(target), reinterpret_cast<TAtomicBase>(exchange)));
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
template <typename T>
|
|
147
|
-
inline T* AtomicSwap(T* volatile* target, TNullPtr) {
|
|
148
|
-
return reinterpret_cast<T*>(AtomicSwap(AsAtomicPtr(target), 0));
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
template <typename T>
|
|
152
|
-
inline bool AtomicCas(T* volatile* target, T* exchange, T* compare) {
|
|
153
|
-
return AtomicCas(AsAtomicPtr(target), reinterpret_cast<TAtomicBase>(exchange), reinterpret_cast<TAtomicBase>(compare));
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
template <typename T>
|
|
157
|
-
inline T* AtomicGetAndCas(T* volatile* target, T* exchange, T* compare) {
|
|
158
|
-
return reinterpret_cast<T*>(AtomicGetAndCas(AsAtomicPtr(target), reinterpret_cast<TAtomicBase>(exchange), reinterpret_cast<TAtomicBase>(compare)));
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
template <typename T>
|
|
162
|
-
inline bool AtomicCas(T* volatile* target, T* exchange, TNullPtr) {
|
|
163
|
-
return AtomicCas(AsAtomicPtr(target), reinterpret_cast<TAtomicBase>(exchange), 0);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
template <typename T>
|
|
167
|
-
inline T* AtomicGetAndCas(T* volatile* target, T* exchange, TNullPtr) {
|
|
168
|
-
return reinterpret_cast<T*>(AtomicGetAndCas(AsAtomicPtr(target), reinterpret_cast<TAtomicBase>(exchange), 0));
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
template <typename T>
|
|
172
|
-
inline bool AtomicCas(T* volatile* target, TNullPtr, T* compare) {
|
|
173
|
-
return AtomicCas(AsAtomicPtr(target), 0, reinterpret_cast<TAtomicBase>(compare));
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
template <typename T>
|
|
177
|
-
inline T* AtomicGetAndCas(T* volatile* target, TNullPtr, T* compare) {
|
|
178
|
-
return reinterpret_cast<T*>(AtomicGetAndCas(AsAtomicPtr(target), 0, reinterpret_cast<TAtomicBase>(compare)));
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
template <typename T>
|
|
182
|
-
inline bool AtomicCas(T* volatile* target, TNullPtr, TNullPtr) {
|
|
183
|
-
return AtomicCas(AsAtomicPtr(target), 0, 0);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
template <typename T>
|
|
187
|
-
inline T* AtomicGetAndCas(T* volatile* target, TNullPtr, TNullPtr) {
|
|
188
|
-
return reinterpret_cast<T*>(AtomicGetAndCas(AsAtomicPtr(target), 0, 0));
|
|
189
|
-
}
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include <intrin.h>
|
|
4
|
-
|
|
5
|
-
#define USE_GENERIC_SETGET
|
|
6
|
-
|
|
7
|
-
#if defined(_i386_)
|
|
8
|
-
|
|
9
|
-
#pragma intrinsic(_InterlockedIncrement)
|
|
10
|
-
#pragma intrinsic(_InterlockedDecrement)
|
|
11
|
-
#pragma intrinsic(_InterlockedExchangeAdd)
|
|
12
|
-
#pragma intrinsic(_InterlockedExchange)
|
|
13
|
-
#pragma intrinsic(_InterlockedCompareExchange)
|
|
14
|
-
|
|
15
|
-
static inline intptr_t AtomicIncrement(TAtomic& a) {
|
|
16
|
-
return _InterlockedIncrement((volatile long*)&a);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
static inline intptr_t AtomicGetAndIncrement(TAtomic& a) {
|
|
20
|
-
return _InterlockedIncrement((volatile long*)&a) - 1;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
static inline intptr_t AtomicDecrement(TAtomic& a) {
|
|
24
|
-
return _InterlockedDecrement((volatile long*)&a);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
static inline intptr_t AtomicGetAndDecrement(TAtomic& a) {
|
|
28
|
-
return _InterlockedDecrement((volatile long*)&a) + 1;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
static inline intptr_t AtomicAdd(TAtomic& a, intptr_t b) {
|
|
32
|
-
return _InterlockedExchangeAdd((volatile long*)&a, b) + b;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
static inline intptr_t AtomicGetAndAdd(TAtomic& a, intptr_t b) {
|
|
36
|
-
return _InterlockedExchangeAdd((volatile long*)&a, b);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
static inline intptr_t AtomicSwap(TAtomic* a, intptr_t b) {
|
|
40
|
-
return _InterlockedExchange((volatile long*)a, b);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
static inline bool AtomicCas(TAtomic* a, intptr_t exchange, intptr_t compare) {
|
|
44
|
-
return _InterlockedCompareExchange((volatile long*)a, exchange, compare) == compare;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
static inline intptr_t AtomicGetAndCas(TAtomic* a, intptr_t exchange, intptr_t compare) {
|
|
48
|
-
return _InterlockedCompareExchange((volatile long*)a, exchange, compare);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
#else // _x86_64_
|
|
52
|
-
|
|
53
|
-
#pragma intrinsic(_InterlockedIncrement64)
|
|
54
|
-
#pragma intrinsic(_InterlockedDecrement64)
|
|
55
|
-
#pragma intrinsic(_InterlockedExchangeAdd64)
|
|
56
|
-
#pragma intrinsic(_InterlockedExchange64)
|
|
57
|
-
#pragma intrinsic(_InterlockedCompareExchange64)
|
|
58
|
-
|
|
59
|
-
static inline intptr_t AtomicIncrement(TAtomic& a) {
|
|
60
|
-
return _InterlockedIncrement64((volatile __int64*)&a);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
static inline intptr_t AtomicGetAndIncrement(TAtomic& a) {
|
|
64
|
-
return _InterlockedIncrement64((volatile __int64*)&a) - 1;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
static inline intptr_t AtomicDecrement(TAtomic& a) {
|
|
68
|
-
return _InterlockedDecrement64((volatile __int64*)&a);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
static inline intptr_t AtomicGetAndDecrement(TAtomic& a) {
|
|
72
|
-
return _InterlockedDecrement64((volatile __int64*)&a) + 1;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
static inline intptr_t AtomicAdd(TAtomic& a, intptr_t b) {
|
|
76
|
-
return _InterlockedExchangeAdd64((volatile __int64*)&a, b) + b;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
static inline intptr_t AtomicGetAndAdd(TAtomic& a, intptr_t b) {
|
|
80
|
-
return _InterlockedExchangeAdd64((volatile __int64*)&a, b);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
static inline intptr_t AtomicSwap(TAtomic* a, intptr_t b) {
|
|
84
|
-
return _InterlockedExchange64((volatile __int64*)a, b);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
static inline bool AtomicCas(TAtomic* a, intptr_t exchange, intptr_t compare) {
|
|
88
|
-
return _InterlockedCompareExchange64((volatile __int64*)a, exchange, compare) == compare;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
static inline intptr_t AtomicGetAndCas(TAtomic* a, intptr_t exchange, intptr_t compare) {
|
|
92
|
-
return _InterlockedCompareExchange64((volatile __int64*)a, exchange, compare);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
static inline intptr_t AtomicOr(TAtomic& a, intptr_t b) {
|
|
96
|
-
return _InterlockedOr64(&a, b) | b;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
static inline intptr_t AtomicAnd(TAtomic& a, intptr_t b) {
|
|
100
|
-
return _InterlockedAnd64(&a, b) & b;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
static inline intptr_t AtomicXor(TAtomic& a, intptr_t b) {
|
|
104
|
-
return _InterlockedXor64(&a, b) ^ b;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
#endif // _x86_
|
|
108
|
-
|
|
109
|
-
//TODO
|
|
110
|
-
static inline void AtomicBarrier() {
|
|
111
|
-
TAtomic val = 0;
|
|
112
|
-
|
|
113
|
-
AtomicSwap(&val, 0);
|
|
114
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
|
|
3
|
-
#include <util/generic/fwd.h>
|
|
4
|
-
#include <util/system/defaults.h>
|
|
5
|
-
|
|
6
|
-
class IOutputStream;
|
|
7
|
-
|
|
8
|
-
size_t BackTrace(void** p, size_t len);
|
|
9
|
-
|
|
10
|
-
struct TResolvedSymbol {
|
|
11
|
-
const char* Name;
|
|
12
|
-
void* NearestSymbol;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
TResolvedSymbol ResolveSymbol(void* sym, char* buf, size_t len);
|
|
16
|
-
|
|
17
|
-
void FormatBackTrace(IOutputStream* out, void* const* backtrace, size_t backtraceSize);
|
|
18
|
-
void FormatBackTrace(IOutputStream* out);
|
|
19
|
-
void PrintBackTrace();
|
|
20
|
-
|
|
21
|
-
using TFormatBackTraceFn = void (*)(IOutputStream*, void* const* backtrace, size_t backtraceSize);
|
|
22
|
-
|
|
23
|
-
TFormatBackTraceFn SetFormatBackTraceFn(TFormatBackTraceFn f);
|
|
24
|
-
TFormatBackTraceFn GetFormatBackTraceFn();
|
|
25
|
-
|
|
26
|
-
class TBackTrace {
|
|
27
|
-
private:
|
|
28
|
-
static constexpr size_t CAPACITY = 300;
|
|
29
|
-
void* Data[CAPACITY];
|
|
30
|
-
size_t Size;
|
|
31
|
-
|
|
32
|
-
public:
|
|
33
|
-
TBackTrace();
|
|
34
|
-
void Capture();
|
|
35
|
-
void PrintTo(IOutputStream&) const;
|
|
36
|
-
TString PrintToString() const;
|
|
37
|
-
|
|
38
|
-
static TBackTrace FromCurrentException();
|
|
39
|
-
};
|