rugged 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -0
- data/README.md +1 -1
- data/ext/rugged/rugged.c +7 -4
- data/ext/rugged/rugged_object.c +1 -1
- data/ext/rugged/rugged_repo.c +3 -3
- data/lib/rugged/repository.rb +2 -2
- data/lib/rugged/version.rb +1 -1
- data/vendor/libgit2/CMakeLists.txt +11 -6
- data/vendor/libgit2/COPYING +109 -1
- data/vendor/libgit2/cmake/Findfutimens.cmake +14 -0
- data/vendor/libgit2/cmake/SelectHTTPSBackend.cmake +4 -0
- data/vendor/libgit2/cmake/SelectHashes.cmake +1 -0
- data/vendor/libgit2/deps/chromium-zlib/CMakeLists.txt +101 -0
- data/vendor/libgit2/deps/ntlmclient/CMakeLists.txt +17 -5
- data/vendor/libgit2/deps/ntlmclient/crypt.h +14 -9
- data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.c +20 -20
- data/vendor/libgit2/deps/ntlmclient/crypt_commoncrypto.h +3 -3
- data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.c +37 -36
- data/vendor/libgit2/deps/ntlmclient/crypt_mbedtls.h +4 -3
- data/vendor/libgit2/deps/ntlmclient/crypt_openssl.c +178 -51
- data/vendor/libgit2/deps/ntlmclient/crypt_openssl.h +74 -5
- data/vendor/libgit2/deps/ntlmclient/ntlm.c +150 -118
- data/vendor/libgit2/deps/ntlmclient/ntlm.h +13 -9
- data/vendor/libgit2/deps/ntlmclient/ntlmclient.h +16 -3
- data/vendor/libgit2/deps/ntlmclient/unicode.h +10 -4
- data/vendor/libgit2/deps/ntlmclient/unicode_builtin.c +16 -27
- data/vendor/libgit2/deps/ntlmclient/unicode_builtin.h +20 -0
- data/vendor/libgit2/deps/ntlmclient/unicode_iconv.c +28 -52
- data/vendor/libgit2/deps/ntlmclient/unicode_iconv.h +22 -0
- data/vendor/libgit2/include/git2/attr.h +89 -0
- data/vendor/libgit2/include/git2/blame.h +93 -42
- data/vendor/libgit2/include/git2/blob.h +14 -2
- data/vendor/libgit2/include/git2/branch.h +25 -0
- data/vendor/libgit2/include/git2/cert.h +42 -5
- data/vendor/libgit2/include/git2/checkout.h +28 -12
- data/vendor/libgit2/include/git2/commit.h +35 -19
- data/vendor/libgit2/include/git2/common.h +14 -4
- data/vendor/libgit2/include/git2/deprecated.h +206 -6
- data/vendor/libgit2/include/git2/diff.h +34 -19
- data/vendor/libgit2/include/git2/errors.h +6 -6
- data/vendor/libgit2/include/git2/filter.h +57 -17
- data/vendor/libgit2/include/git2/graph.h +20 -2
- data/vendor/libgit2/include/git2/index.h +2 -2
- data/vendor/libgit2/include/git2/odb.h +29 -0
- data/vendor/libgit2/include/git2/patch.h +8 -0
- data/vendor/libgit2/include/git2/rebase.h +25 -1
- data/vendor/libgit2/include/git2/refs.h +6 -2
- data/vendor/libgit2/include/git2/remote.h +59 -6
- data/vendor/libgit2/include/git2/revparse.h +5 -5
- data/vendor/libgit2/include/git2/status.h +115 -59
- data/vendor/libgit2/include/git2/submodule.h +9 -0
- data/vendor/libgit2/include/git2/sys/commit_graph.h +174 -0
- data/vendor/libgit2/include/git2/sys/filter.h +49 -28
- data/vendor/libgit2/include/git2/sys/midx.h +74 -0
- data/vendor/libgit2/include/git2/sys/odb_backend.h +7 -0
- data/vendor/libgit2/include/git2/sys/transport.h +1 -0
- data/vendor/libgit2/include/git2/tag.h +12 -0
- data/vendor/libgit2/include/git2/tree.h +0 -14
- data/vendor/libgit2/include/git2/types.h +9 -0
- data/vendor/libgit2/include/git2/version.h +4 -4
- data/vendor/libgit2/include/git2/worktree.h +1 -0
- data/vendor/libgit2/src/CMakeLists.txt +25 -4
- data/vendor/libgit2/src/alloc.c +21 -8
- data/vendor/libgit2/src/allocators/failalloc.c +92 -0
- data/vendor/libgit2/src/allocators/failalloc.h +23 -0
- data/vendor/libgit2/src/allocators/stdalloc.c +41 -10
- data/vendor/libgit2/src/allocators/win32_leakcheck.c +118 -0
- data/vendor/libgit2/src/allocators/{win32_crtdbg.h → win32_leakcheck.h} +3 -3
- data/vendor/libgit2/src/annotated_commit.c +21 -9
- data/vendor/libgit2/src/apply.c +16 -7
- data/vendor/libgit2/src/array.h +11 -11
- data/vendor/libgit2/src/attr.c +181 -74
- data/vendor/libgit2/src/attr_file.c +84 -39
- data/vendor/libgit2/src/attr_file.h +32 -11
- data/vendor/libgit2/src/attrcache.c +42 -37
- data/vendor/libgit2/src/attrcache.h +4 -5
- data/vendor/libgit2/src/blame.c +11 -5
- data/vendor/libgit2/src/blob.c +35 -24
- data/vendor/libgit2/src/branch.c +69 -17
- data/vendor/libgit2/src/buffer.c +334 -25
- data/vendor/libgit2/src/buffer.h +153 -2
- data/vendor/libgit2/src/cache.c +2 -2
- data/vendor/libgit2/src/cache.h +7 -7
- data/vendor/libgit2/src/cc-compat.h +10 -2
- data/vendor/libgit2/src/checkout.c +48 -26
- data/vendor/libgit2/src/cherrypick.c +6 -2
- data/vendor/libgit2/src/clone.c +41 -47
- data/vendor/libgit2/src/commit.c +41 -28
- data/vendor/libgit2/src/commit_graph.c +1209 -0
- data/vendor/libgit2/src/commit_graph.h +162 -0
- data/vendor/libgit2/src/commit_list.c +46 -0
- data/vendor/libgit2/src/commit_list.h +2 -0
- data/vendor/libgit2/src/common.h +25 -2
- data/vendor/libgit2/src/config.c +37 -15
- data/vendor/libgit2/src/config_cache.c +5 -3
- data/vendor/libgit2/src/config_file.c +16 -8
- data/vendor/libgit2/src/config_parse.c +4 -6
- data/vendor/libgit2/src/crlf.c +16 -6
- data/vendor/libgit2/src/date.c +4 -3
- data/vendor/libgit2/src/delta.c +1 -1
- data/vendor/libgit2/src/describe.c +6 -3
- data/vendor/libgit2/src/diff.c +11 -8
- data/vendor/libgit2/src/diff_driver.c +21 -17
- data/vendor/libgit2/src/diff_file.c +2 -6
- data/vendor/libgit2/src/diff_generate.c +46 -17
- data/vendor/libgit2/src/diff_print.c +19 -6
- data/vendor/libgit2/src/diff_stats.c +7 -5
- data/vendor/libgit2/src/diff_tform.c +9 -8
- data/vendor/libgit2/src/diff_xdiff.c +4 -2
- data/vendor/libgit2/src/diff_xdiff.h +1 -1
- data/vendor/libgit2/src/errors.c +24 -19
- data/vendor/libgit2/src/features.h.in +5 -1
- data/vendor/libgit2/src/fetch.c +5 -2
- data/vendor/libgit2/src/fetchhead.c +8 -4
- data/vendor/libgit2/src/filebuf.c +9 -7
- data/vendor/libgit2/src/filter.c +206 -110
- data/vendor/libgit2/src/filter.h +24 -5
- data/vendor/libgit2/src/futils.c +5 -5
- data/vendor/libgit2/src/futils.h +1 -1
- data/vendor/libgit2/src/graph.c +64 -9
- data/vendor/libgit2/src/hash/sha1/collisiondetect.c +3 -3
- data/vendor/libgit2/src/hash/sha1/common_crypto.c +3 -3
- data/vendor/libgit2/src/hash/sha1/generic.h +1 -1
- data/vendor/libgit2/src/hash/sha1/mbedtls.c +12 -12
- data/vendor/libgit2/src/hash/sha1/openssl.c +3 -3
- data/vendor/libgit2/src/hash/sha1/sha1dc/sha1.c +0 -2
- data/vendor/libgit2/src/hash/sha1/win32.c +15 -11
- data/vendor/libgit2/src/hash.c +16 -13
- data/vendor/libgit2/src/hash.h +1 -1
- data/vendor/libgit2/src/hashsig.c +23 -10
- data/vendor/libgit2/src/ident.c +13 -3
- data/vendor/libgit2/src/ignore.c +35 -19
- data/vendor/libgit2/src/index.c +106 -70
- data/vendor/libgit2/src/index.h +1 -1
- data/vendor/libgit2/src/indexer.c +31 -29
- data/vendor/libgit2/src/integer.h +64 -2
- data/vendor/libgit2/src/iterator.c +36 -24
- data/vendor/libgit2/src/iterator.h +1 -1
- data/vendor/libgit2/src/khash.h +2 -11
- data/vendor/libgit2/src/{settings.c → libgit2.c} +117 -50
- data/vendor/libgit2/src/libgit2.h +15 -0
- data/vendor/libgit2/src/mailmap.c +23 -10
- data/vendor/libgit2/src/map.h +3 -3
- data/vendor/libgit2/src/merge.c +70 -30
- data/vendor/libgit2/src/merge.h +2 -1
- data/vendor/libgit2/src/merge_driver.c +19 -13
- data/vendor/libgit2/src/merge_file.c +11 -3
- data/vendor/libgit2/src/message.c +3 -1
- data/vendor/libgit2/src/midx.c +471 -10
- data/vendor/libgit2/src/midx.h +28 -1
- data/vendor/libgit2/src/mwindow.c +103 -59
- data/vendor/libgit2/src/mwindow.h +3 -3
- data/vendor/libgit2/src/net.c +127 -3
- data/vendor/libgit2/src/net.h +16 -2
- data/vendor/libgit2/src/netops.c +6 -4
- data/vendor/libgit2/src/netops.h +2 -2
- data/vendor/libgit2/src/notes.c +10 -10
- data/vendor/libgit2/src/object.c +22 -14
- data/vendor/libgit2/src/odb.c +285 -48
- data/vendor/libgit2/src/odb.h +16 -2
- data/vendor/libgit2/src/odb_loose.c +28 -18
- data/vendor/libgit2/src/odb_mempack.c +1 -1
- data/vendor/libgit2/src/odb_pack.c +391 -114
- data/vendor/libgit2/src/oid.c +5 -4
- data/vendor/libgit2/src/pack-objects.c +54 -48
- data/vendor/libgit2/src/pack.c +329 -119
- data/vendor/libgit2/src/pack.h +25 -7
- data/vendor/libgit2/src/patch.c +14 -7
- data/vendor/libgit2/src/patch_generate.c +2 -2
- data/vendor/libgit2/src/patch_parse.c +2 -1
- data/vendor/libgit2/src/path.c +98 -53
- data/vendor/libgit2/src/path.h +79 -6
- data/vendor/libgit2/src/pathspec.c +8 -8
- data/vendor/libgit2/src/pool.c +13 -7
- data/vendor/libgit2/src/posix.c +11 -3
- data/vendor/libgit2/src/reader.c +10 -6
- data/vendor/libgit2/src/rebase.c +93 -49
- data/vendor/libgit2/src/refdb.c +30 -13
- data/vendor/libgit2/src/refdb_fs.c +121 -69
- data/vendor/libgit2/src/reflog.c +19 -14
- data/vendor/libgit2/src/refs.c +76 -41
- data/vendor/libgit2/src/refspec.c +32 -12
- data/vendor/libgit2/src/remote.c +272 -102
- data/vendor/libgit2/src/remote.h +2 -1
- data/vendor/libgit2/src/repository.c +176 -103
- data/vendor/libgit2/src/repository.h +12 -1
- data/vendor/libgit2/src/reset.c +7 -6
- data/vendor/libgit2/src/revert.c +6 -2
- data/vendor/libgit2/src/revparse.c +14 -9
- data/vendor/libgit2/src/revwalk.c +32 -15
- data/vendor/libgit2/src/runtime.c +162 -0
- data/vendor/libgit2/src/runtime.h +62 -0
- data/vendor/libgit2/src/settings.h +11 -0
- data/vendor/libgit2/src/signature.c +6 -5
- data/vendor/libgit2/src/sortedcache.h +10 -8
- data/vendor/libgit2/src/stash.c +3 -1
- data/vendor/libgit2/src/status.c +7 -4
- data/vendor/libgit2/src/strarray.c +2 -1
- data/vendor/libgit2/src/streams/mbedtls.c +14 -17
- data/vendor/libgit2/src/streams/mbedtls.h +1 -1
- data/vendor/libgit2/src/streams/openssl.c +101 -201
- data/vendor/libgit2/src/streams/openssl.h +9 -1
- data/vendor/libgit2/src/streams/openssl_dynamic.c +309 -0
- data/vendor/libgit2/src/streams/openssl_dynamic.h +348 -0
- data/vendor/libgit2/src/streams/openssl_legacy.c +203 -0
- data/vendor/libgit2/src/streams/openssl_legacy.h +63 -0
- data/vendor/libgit2/src/streams/registry.c +5 -6
- data/vendor/libgit2/src/streams/socket.c +6 -2
- data/vendor/libgit2/src/streams/stransport.c +6 -3
- data/vendor/libgit2/src/streams/tls.c +5 -3
- data/vendor/libgit2/src/submodule.c +128 -62
- data/vendor/libgit2/src/submodule.h +9 -9
- data/vendor/libgit2/src/sysdir.c +4 -6
- data/vendor/libgit2/src/tag.c +47 -11
- data/vendor/libgit2/src/thread.c +140 -0
- data/vendor/libgit2/src/thread.h +479 -0
- data/vendor/libgit2/src/threadstate.c +83 -0
- data/vendor/libgit2/src/threadstate.h +24 -0
- data/vendor/libgit2/src/trace.c +2 -2
- data/vendor/libgit2/src/trace.h +17 -13
- data/vendor/libgit2/src/transaction.c +19 -8
- data/vendor/libgit2/src/transport.c +3 -3
- data/vendor/libgit2/src/transports/auth.c +1 -1
- data/vendor/libgit2/src/transports/auth_negotiate.c +11 -4
- data/vendor/libgit2/src/transports/auth_ntlm.c +10 -6
- data/vendor/libgit2/src/transports/credential.c +15 -7
- data/vendor/libgit2/src/transports/git.c +1 -3
- data/vendor/libgit2/src/transports/http.c +19 -17
- data/vendor/libgit2/src/transports/http.h +1 -0
- data/vendor/libgit2/src/transports/httpclient.c +53 -26
- data/vendor/libgit2/src/transports/httpclient.h +1 -1
- data/vendor/libgit2/src/transports/local.c +3 -3
- data/vendor/libgit2/src/transports/smart.c +12 -7
- data/vendor/libgit2/src/transports/smart.h +1 -1
- data/vendor/libgit2/src/transports/smart_protocol.c +11 -5
- data/vendor/libgit2/src/transports/ssh.c +51 -17
- data/vendor/libgit2/src/transports/winhttp.c +41 -31
- data/vendor/libgit2/src/tree.c +100 -77
- data/vendor/libgit2/src/tree.h +1 -0
- data/vendor/libgit2/src/tsort.c +0 -2
- data/vendor/libgit2/src/unix/map.c +3 -1
- data/vendor/libgit2/src/unix/pthread.h +2 -1
- data/vendor/libgit2/src/utf8.c +150 -0
- data/vendor/libgit2/src/utf8.h +52 -0
- data/vendor/libgit2/src/util.c +53 -129
- data/vendor/libgit2/src/util.h +33 -39
- data/vendor/libgit2/src/vector.c +23 -19
- data/vendor/libgit2/src/vector.h +4 -2
- data/vendor/libgit2/src/win32/findfile.c +4 -2
- data/vendor/libgit2/src/win32/map.c +1 -1
- data/vendor/libgit2/src/win32/msvc-compat.h +9 -1
- data/vendor/libgit2/src/win32/path_w32.c +22 -24
- data/vendor/libgit2/src/win32/path_w32.h +0 -1
- data/vendor/libgit2/src/win32/posix_w32.c +7 -1
- data/vendor/libgit2/src/win32/precompiled.h +0 -1
- data/vendor/libgit2/src/win32/reparse.h +4 -4
- data/vendor/libgit2/src/win32/thread.c +24 -15
- data/vendor/libgit2/src/win32/thread.h +1 -1
- data/vendor/libgit2/src/win32/w32_buffer.c +3 -3
- data/vendor/libgit2/src/win32/w32_common.h +18 -9
- data/vendor/libgit2/src/win32/{w32_crtdbg_stacktrace.c → w32_leakcheck.c} +269 -33
- data/vendor/libgit2/src/win32/w32_leakcheck.h +222 -0
- data/vendor/libgit2/src/win32/w32_util.h +6 -6
- data/vendor/libgit2/src/worktree.c +27 -16
- data/vendor/libgit2/src/zstream.c +1 -1
- metadata +32 -16
- data/vendor/libgit2/src/allocators/win32_crtdbg.c +0 -118
- data/vendor/libgit2/src/buf_text.c +0 -316
- data/vendor/libgit2/src/buf_text.h +0 -122
- data/vendor/libgit2/src/global.c +0 -363
- data/vendor/libgit2/src/global.h +0 -41
- data/vendor/libgit2/src/thread-utils.c +0 -58
- data/vendor/libgit2/src/thread-utils.h +0 -369
- data/vendor/libgit2/src/win32/w32_crtdbg_stacktrace.h +0 -127
- data/vendor/libgit2/src/win32/w32_stack.c +0 -188
- data/vendor/libgit2/src/win32/w32_stack.h +0 -140
@@ -1,369 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Copyright (C) the libgit2 contributors. All rights reserved.
|
3
|
-
*
|
4
|
-
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
5
|
-
* a Linking Exception. For full terms see the included COPYING file.
|
6
|
-
*/
|
7
|
-
#ifndef INCLUDE_thread_utils_h__
|
8
|
-
#define INCLUDE_thread_utils_h__
|
9
|
-
|
10
|
-
#if defined(GIT_THREADS)
|
11
|
-
|
12
|
-
#if defined(__clang__)
|
13
|
-
|
14
|
-
# if (__clang_major__ < 3 || (__clang_major__ == 3 && __clang_minor__ < 1))
|
15
|
-
# error Atomic primitives do not exist on this version of clang; configure libgit2 with -DTHREADSAFE=OFF
|
16
|
-
# else
|
17
|
-
# define GIT_BUILTIN_ATOMIC
|
18
|
-
# endif
|
19
|
-
|
20
|
-
#elif defined(__GNUC__)
|
21
|
-
|
22
|
-
# if (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 1))
|
23
|
-
# error Atomic primitives do not exist on this version of gcc; configure libgit2 with -DTHREADSAFE=OFF
|
24
|
-
# elif (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7))
|
25
|
-
# define GIT_BUILTIN_ATOMIC
|
26
|
-
# else
|
27
|
-
# define GIT_BUILTIN_SYNC
|
28
|
-
# endif
|
29
|
-
|
30
|
-
#endif
|
31
|
-
|
32
|
-
#endif /* GIT_THREADS */
|
33
|
-
|
34
|
-
/* Common operations even if threading has been disabled */
|
35
|
-
typedef struct {
|
36
|
-
#if defined(GIT_WIN32)
|
37
|
-
volatile long val;
|
38
|
-
#else
|
39
|
-
volatile int val;
|
40
|
-
#endif
|
41
|
-
} git_atomic;
|
42
|
-
|
43
|
-
#ifdef GIT_ARCH_64
|
44
|
-
|
45
|
-
typedef struct {
|
46
|
-
#if defined(GIT_WIN32)
|
47
|
-
volatile __int64 val;
|
48
|
-
#else
|
49
|
-
volatile int64_t val;
|
50
|
-
#endif
|
51
|
-
} git_atomic64;
|
52
|
-
|
53
|
-
typedef git_atomic64 git_atomic_ssize;
|
54
|
-
|
55
|
-
#define git_atomic_ssize_set git_atomic64_set
|
56
|
-
#define git_atomic_ssize_add git_atomic64_add
|
57
|
-
#define git_atomic_ssize_get git_atomic64_get
|
58
|
-
|
59
|
-
#else
|
60
|
-
|
61
|
-
typedef git_atomic git_atomic_ssize;
|
62
|
-
|
63
|
-
#define git_atomic_ssize_set git_atomic_set
|
64
|
-
#define git_atomic_ssize_add git_atomic_add
|
65
|
-
#define git_atomic_ssize_get git_atomic_get
|
66
|
-
|
67
|
-
#endif
|
68
|
-
|
69
|
-
#ifdef GIT_THREADS
|
70
|
-
|
71
|
-
#ifdef GIT_WIN32
|
72
|
-
# include "win32/thread.h"
|
73
|
-
#else
|
74
|
-
# include "unix/pthread.h"
|
75
|
-
#endif
|
76
|
-
|
77
|
-
GIT_INLINE(void) git_atomic_set(git_atomic *a, int val)
|
78
|
-
{
|
79
|
-
#if defined(GIT_WIN32)
|
80
|
-
InterlockedExchange(&a->val, (LONG)val);
|
81
|
-
#elif defined(GIT_BUILTIN_ATOMIC)
|
82
|
-
__atomic_store_n(&a->val, val, __ATOMIC_SEQ_CST);
|
83
|
-
#elif defined(GIT_BUILTIN_SYNC)
|
84
|
-
__sync_lock_test_and_set(&a->val, val);
|
85
|
-
#else
|
86
|
-
# error "Unsupported architecture for atomic operations"
|
87
|
-
#endif
|
88
|
-
}
|
89
|
-
|
90
|
-
GIT_INLINE(int) git_atomic_inc(git_atomic *a)
|
91
|
-
{
|
92
|
-
#if defined(GIT_WIN32)
|
93
|
-
return InterlockedIncrement(&a->val);
|
94
|
-
#elif defined(GIT_BUILTIN_ATOMIC)
|
95
|
-
return __atomic_add_fetch(&a->val, 1, __ATOMIC_SEQ_CST);
|
96
|
-
#elif defined(GIT_BUILTIN_SYNC)
|
97
|
-
return __sync_add_and_fetch(&a->val, 1);
|
98
|
-
#else
|
99
|
-
# error "Unsupported architecture for atomic operations"
|
100
|
-
#endif
|
101
|
-
}
|
102
|
-
|
103
|
-
GIT_INLINE(int) git_atomic_add(git_atomic *a, int32_t addend)
|
104
|
-
{
|
105
|
-
#if defined(GIT_WIN32)
|
106
|
-
return InterlockedExchangeAdd(&a->val, addend);
|
107
|
-
#elif defined(GIT_BUILTIN_ATOMIC)
|
108
|
-
return __atomic_add_fetch(&a->val, addend, __ATOMIC_SEQ_CST);
|
109
|
-
#elif defined(GIT_BUILTIN_SYNC)
|
110
|
-
return __sync_add_and_fetch(&a->val, addend);
|
111
|
-
#else
|
112
|
-
# error "Unsupported architecture for atomic operations"
|
113
|
-
#endif
|
114
|
-
}
|
115
|
-
|
116
|
-
GIT_INLINE(int) git_atomic_dec(git_atomic *a)
|
117
|
-
{
|
118
|
-
#if defined(GIT_WIN32)
|
119
|
-
return InterlockedDecrement(&a->val);
|
120
|
-
#elif defined(GIT_BUILTIN_ATOMIC)
|
121
|
-
return __atomic_sub_fetch(&a->val, 1, __ATOMIC_SEQ_CST);
|
122
|
-
#elif defined(GIT_BUILTIN_SYNC)
|
123
|
-
return __sync_sub_and_fetch(&a->val, 1);
|
124
|
-
#else
|
125
|
-
# error "Unsupported architecture for atomic operations"
|
126
|
-
#endif
|
127
|
-
}
|
128
|
-
|
129
|
-
GIT_INLINE(int) git_atomic_get(git_atomic *a)
|
130
|
-
{
|
131
|
-
#if defined(GIT_WIN32)
|
132
|
-
return (int)InterlockedCompareExchange(&a->val, 0, 0);
|
133
|
-
#elif defined(GIT_BUILTIN_ATOMIC)
|
134
|
-
return __atomic_load_n(&a->val, __ATOMIC_SEQ_CST);
|
135
|
-
#elif defined(GIT_BUILTIN_SYNC)
|
136
|
-
return __sync_val_compare_and_swap(&a->val, 0, 0);
|
137
|
-
#else
|
138
|
-
# error "Unsupported architecture for atomic operations"
|
139
|
-
#endif
|
140
|
-
}
|
141
|
-
|
142
|
-
GIT_INLINE(void *) git___compare_and_swap(
|
143
|
-
void * volatile *ptr, void *oldval, void *newval)
|
144
|
-
{
|
145
|
-
#if defined(GIT_WIN32)
|
146
|
-
volatile void *foundval;
|
147
|
-
foundval = InterlockedCompareExchangePointer((volatile PVOID *)ptr, newval, oldval);
|
148
|
-
return (foundval == oldval) ? oldval : newval;
|
149
|
-
#elif defined(GIT_BUILTIN_ATOMIC)
|
150
|
-
bool success = __atomic_compare_exchange(ptr, &oldval, &newval, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
|
151
|
-
return success ? oldval : newval;
|
152
|
-
#elif defined(GIT_BUILTIN_SYNC)
|
153
|
-
volatile void *foundval;
|
154
|
-
foundval = __sync_val_compare_and_swap(ptr, oldval, newval);
|
155
|
-
return (foundval == oldval) ? oldval : newval;
|
156
|
-
#else
|
157
|
-
# error "Unsupported architecture for atomic operations"
|
158
|
-
#endif
|
159
|
-
}
|
160
|
-
|
161
|
-
GIT_INLINE(volatile void *) git___swap(
|
162
|
-
void * volatile *ptr, void *newval)
|
163
|
-
{
|
164
|
-
#if defined(GIT_WIN32)
|
165
|
-
return InterlockedExchangePointer(ptr, newval);
|
166
|
-
#elif defined(GIT_BUILTIN_ATOMIC)
|
167
|
-
void * volatile foundval;
|
168
|
-
__atomic_exchange(ptr, &newval, &foundval, __ATOMIC_SEQ_CST);
|
169
|
-
return foundval;
|
170
|
-
#elif defined(GIT_BUILTIN_SYNC)
|
171
|
-
return __sync_lock_test_and_set(ptr, newval);
|
172
|
-
#else
|
173
|
-
# error "Unsupported architecture for atomic operations"
|
174
|
-
#endif
|
175
|
-
}
|
176
|
-
|
177
|
-
GIT_INLINE(volatile void *) git___load(void * volatile *ptr)
|
178
|
-
{
|
179
|
-
#if defined(GIT_WIN32)
|
180
|
-
void *newval = NULL, *oldval = NULL;
|
181
|
-
volatile void *foundval = NULL;
|
182
|
-
foundval = InterlockedCompareExchangePointer((volatile PVOID *)ptr, newval, oldval);
|
183
|
-
return foundval;
|
184
|
-
#elif defined(GIT_BUILTIN_ATOMIC)
|
185
|
-
return (volatile void *)__atomic_load_n(ptr, __ATOMIC_SEQ_CST);
|
186
|
-
#elif defined(GIT_BUILTIN_SYNC)
|
187
|
-
return (volatile void *)__sync_val_compare_and_swap(ptr, 0, 0);
|
188
|
-
#else
|
189
|
-
# error "Unsupported architecture for atomic operations"
|
190
|
-
#endif
|
191
|
-
}
|
192
|
-
|
193
|
-
#ifdef GIT_ARCH_64
|
194
|
-
|
195
|
-
GIT_INLINE(int64_t) git_atomic64_add(git_atomic64 *a, int64_t addend)
|
196
|
-
{
|
197
|
-
#if defined(GIT_WIN32)
|
198
|
-
return InterlockedExchangeAdd64(&a->val, addend);
|
199
|
-
#elif defined(GIT_BUILTIN_ATOMIC)
|
200
|
-
return __atomic_add_fetch(&a->val, addend, __ATOMIC_SEQ_CST);
|
201
|
-
#elif defined(GIT_BUILTIN_SYNC)
|
202
|
-
return __sync_add_and_fetch(&a->val, addend);
|
203
|
-
#else
|
204
|
-
# error "Unsupported architecture for atomic operations"
|
205
|
-
#endif
|
206
|
-
}
|
207
|
-
|
208
|
-
GIT_INLINE(void) git_atomic64_set(git_atomic64 *a, int64_t val)
|
209
|
-
{
|
210
|
-
#if defined(GIT_WIN32)
|
211
|
-
InterlockedExchange64(&a->val, val);
|
212
|
-
#elif defined(GIT_BUILTIN_ATOMIC)
|
213
|
-
__atomic_store_n(&a->val, val, __ATOMIC_SEQ_CST);
|
214
|
-
#elif defined(GIT_BUILTIN_SYNC)
|
215
|
-
__sync_lock_test_and_set(&a->val, val);
|
216
|
-
#else
|
217
|
-
# error "Unsupported architecture for atomic operations"
|
218
|
-
#endif
|
219
|
-
}
|
220
|
-
|
221
|
-
GIT_INLINE(int64_t) git_atomic64_get(git_atomic64 *a)
|
222
|
-
{
|
223
|
-
#if defined(GIT_WIN32)
|
224
|
-
return (int64_t)InterlockedCompareExchange64(&a->val, 0, 0);
|
225
|
-
#elif defined(GIT_BUILTIN_ATOMIC)
|
226
|
-
return __atomic_load_n(&a->val, __ATOMIC_SEQ_CST);
|
227
|
-
#elif defined(GIT_BUILTIN_SYNC)
|
228
|
-
return __sync_val_compare_and_swap(&a->val, 0, 0);
|
229
|
-
#else
|
230
|
-
# error "Unsupported architecture for atomic operations"
|
231
|
-
#endif
|
232
|
-
}
|
233
|
-
|
234
|
-
#endif
|
235
|
-
|
236
|
-
#else
|
237
|
-
|
238
|
-
GIT_INLINE(int) git___noop(void) { return 0; }
|
239
|
-
|
240
|
-
#define git_thread unsigned int
|
241
|
-
#define git_thread_create(thread, start_routine, arg) git___noop()
|
242
|
-
#define git_thread_join(id, status) git___noop()
|
243
|
-
|
244
|
-
/* Pthreads Mutex */
|
245
|
-
#define git_mutex unsigned int
|
246
|
-
#define git_mutex_init(a) git___noop()
|
247
|
-
#define git_mutex_lock(a) git___noop()
|
248
|
-
#define git_mutex_unlock(a) git___noop()
|
249
|
-
#define git_mutex_free(a) git___noop()
|
250
|
-
|
251
|
-
/* Pthreads condition vars */
|
252
|
-
#define git_cond unsigned int
|
253
|
-
#define git_cond_init(c, a) git___noop()
|
254
|
-
#define git_cond_free(c) git___noop()
|
255
|
-
#define git_cond_wait(c, l) git___noop()
|
256
|
-
#define git_cond_signal(c) git___noop()
|
257
|
-
#define git_cond_broadcast(c) git___noop()
|
258
|
-
|
259
|
-
/* Pthreads rwlock */
|
260
|
-
#define git_rwlock unsigned int
|
261
|
-
#define git_rwlock_init(a) git___noop()
|
262
|
-
#define git_rwlock_rdlock(a) git___noop()
|
263
|
-
#define git_rwlock_rdunlock(a) git___noop()
|
264
|
-
#define git_rwlock_wrlock(a) git___noop()
|
265
|
-
#define git_rwlock_wrunlock(a) git___noop()
|
266
|
-
#define git_rwlock_free(a) git___noop()
|
267
|
-
#define GIT_RWLOCK_STATIC_INIT 0
|
268
|
-
|
269
|
-
|
270
|
-
GIT_INLINE(void) git_atomic_set(git_atomic *a, int val)
|
271
|
-
{
|
272
|
-
a->val = val;
|
273
|
-
}
|
274
|
-
|
275
|
-
GIT_INLINE(int) git_atomic_inc(git_atomic *a)
|
276
|
-
{
|
277
|
-
return ++a->val;
|
278
|
-
}
|
279
|
-
|
280
|
-
GIT_INLINE(int) git_atomic_add(git_atomic *a, int32_t addend)
|
281
|
-
{
|
282
|
-
a->val += addend;
|
283
|
-
return a->val;
|
284
|
-
}
|
285
|
-
|
286
|
-
GIT_INLINE(int) git_atomic_dec(git_atomic *a)
|
287
|
-
{
|
288
|
-
return --a->val;
|
289
|
-
}
|
290
|
-
|
291
|
-
GIT_INLINE(int) git_atomic_get(git_atomic *a)
|
292
|
-
{
|
293
|
-
return (int)a->val;
|
294
|
-
}
|
295
|
-
|
296
|
-
GIT_INLINE(void *) git___compare_and_swap(
|
297
|
-
void * volatile *ptr, void *oldval, void *newval)
|
298
|
-
{
|
299
|
-
if (*ptr == oldval)
|
300
|
-
*ptr = newval;
|
301
|
-
else
|
302
|
-
oldval = newval;
|
303
|
-
return oldval;
|
304
|
-
}
|
305
|
-
|
306
|
-
GIT_INLINE(volatile void *) git___swap(
|
307
|
-
void * volatile *ptr, void *newval)
|
308
|
-
{
|
309
|
-
volatile void *old = *ptr;
|
310
|
-
*ptr = newval;
|
311
|
-
return old;
|
312
|
-
}
|
313
|
-
|
314
|
-
GIT_INLINE(volatile void *) git___load(void * volatile *ptr)
|
315
|
-
{
|
316
|
-
return *ptr;
|
317
|
-
}
|
318
|
-
|
319
|
-
#ifdef GIT_ARCH_64
|
320
|
-
|
321
|
-
GIT_INLINE(int64_t) git_atomic64_add(git_atomic64 *a, int64_t addend)
|
322
|
-
{
|
323
|
-
a->val += addend;
|
324
|
-
return a->val;
|
325
|
-
}
|
326
|
-
|
327
|
-
GIT_INLINE(void) git_atomic64_set(git_atomic64 *a, int64_t val)
|
328
|
-
{
|
329
|
-
a->val = val;
|
330
|
-
}
|
331
|
-
|
332
|
-
GIT_INLINE(int64_t) git_atomic64_get(git_atomic64 *a)
|
333
|
-
{
|
334
|
-
return (int64_t)a->val;
|
335
|
-
}
|
336
|
-
|
337
|
-
#endif
|
338
|
-
|
339
|
-
#endif
|
340
|
-
|
341
|
-
/* Atomically replace oldval with newval
|
342
|
-
* @return oldval if it was replaced or newval if it was not
|
343
|
-
*/
|
344
|
-
#define git__compare_and_swap(P,O,N) \
|
345
|
-
git___compare_and_swap((void * volatile *)P, O, N)
|
346
|
-
|
347
|
-
#define git__swap(ptr, val) (void *)git___swap((void * volatile *)&ptr, val)
|
348
|
-
|
349
|
-
#define git__load(ptr) (void *)git___load((void * volatile *)&ptr)
|
350
|
-
|
351
|
-
extern int git_online_cpus(void);
|
352
|
-
|
353
|
-
#if defined(GIT_THREADS)
|
354
|
-
|
355
|
-
# if defined(GIT_WIN32)
|
356
|
-
# define GIT_MEMORY_BARRIER MemoryBarrier()
|
357
|
-
# elif defined(GIT_BUILTIN_ATOMIC)
|
358
|
-
# define GIT_MEMORY_BARRIER __atomic_thread_fence(__ATOMIC_SEQ_CST)
|
359
|
-
# elif defined(GIT_BUILTIN_SYNC)
|
360
|
-
# define GIT_MEMORY_BARRIER __sync_synchronize()
|
361
|
-
# endif
|
362
|
-
|
363
|
-
#else
|
364
|
-
|
365
|
-
# define GIT_MEMORY_BARRIER /* noop */
|
366
|
-
|
367
|
-
#endif
|
368
|
-
|
369
|
-
#endif
|
@@ -1,127 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Copyright (C) the libgit2 contributors. All rights reserved.
|
3
|
-
*
|
4
|
-
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
5
|
-
* a Linking Exception. For full terms see the included COPYING file.
|
6
|
-
*/
|
7
|
-
#ifndef INCLUDE_win32_w32_crtdbg_stacktrace_h__
|
8
|
-
#define INCLUDE_win32_w32_crtdbg_stacktrace_h__
|
9
|
-
|
10
|
-
#include "common.h"
|
11
|
-
|
12
|
-
#if defined(GIT_MSVC_CRTDBG)
|
13
|
-
|
14
|
-
#include <stdlib.h>
|
15
|
-
#include <crtdbg.h>
|
16
|
-
|
17
|
-
#include "git2/errors.h"
|
18
|
-
#include "strnlen.h"
|
19
|
-
|
20
|
-
/* MSVC CRTDBG memory leak reporting.
|
21
|
-
*
|
22
|
-
* We DO NOT use the "_CRTDBG_MAP_ALLOC" macro described in the MSVC
|
23
|
-
* documentation because all allocs/frees in libgit2 already go through
|
24
|
-
* the "git__" routines defined in this file. Simply using the normal
|
25
|
-
* reporting mechanism causes all leaks to be attributed to a routine
|
26
|
-
* here in util.h (ie, the actual call to calloc()) rather than the
|
27
|
-
* caller of git__calloc().
|
28
|
-
*
|
29
|
-
* Therefore, we declare a set of "git__crtdbg__" routines to replace
|
30
|
-
* the corresponding "git__" routines and re-define the "git__" symbols
|
31
|
-
* as macros. This allows us to get and report the file:line info of
|
32
|
-
* the real caller.
|
33
|
-
*
|
34
|
-
* We DO NOT replace the "git__free" routine because it needs to remain
|
35
|
-
* a function pointer because it is used as a function argument when
|
36
|
-
* setting up various structure "destructors".
|
37
|
-
*
|
38
|
-
* We also DO NOT use the "_CRTDBG_MAP_ALLOC" macro because it causes
|
39
|
-
* "free" to be remapped to "_free_dbg" and this causes problems for
|
40
|
-
* structures which define a field named "free".
|
41
|
-
*
|
42
|
-
* Finally, CRTDBG must be explicitly enabled and configured at program
|
43
|
-
* startup. See tests/main.c for an example.
|
44
|
-
*/
|
45
|
-
|
46
|
-
/**
|
47
|
-
* Initialize our memory leak tracking and de-dup data structures.
|
48
|
-
* This should ONLY be called by git_libgit2_init().
|
49
|
-
*/
|
50
|
-
void git_win32__crtdbg_stacktrace_init(void);
|
51
|
-
|
52
|
-
/**
|
53
|
-
* Shutdown our memory leak tracking and dump summary data.
|
54
|
-
* This should ONLY be called by git_libgit2_shutdown().
|
55
|
-
*
|
56
|
-
* We explicitly call _CrtDumpMemoryLeaks() during here so
|
57
|
-
* that we can compute summary data for the leaks. We print
|
58
|
-
* the stacktrace of each unique leak.
|
59
|
-
*
|
60
|
-
* This cleanup does not happen if the app calls exit()
|
61
|
-
* without calling the libgit2 shutdown code.
|
62
|
-
*
|
63
|
-
* This info we print here is independent of any automatic
|
64
|
-
* reporting during exit() caused by _CRTDBG_LEAK_CHECK_DF.
|
65
|
-
* Set it in your app if you also want traditional reporting.
|
66
|
-
*/
|
67
|
-
void git_win32__crtdbg_stacktrace_cleanup(void);
|
68
|
-
|
69
|
-
/**
|
70
|
-
* Checkpoint options.
|
71
|
-
*/
|
72
|
-
typedef enum git_win32__crtdbg_stacktrace_options {
|
73
|
-
/**
|
74
|
-
* Set checkpoint marker.
|
75
|
-
*/
|
76
|
-
GIT_WIN32__CRTDBG_STACKTRACE__SET_MARK = (1 << 0),
|
77
|
-
|
78
|
-
/**
|
79
|
-
* Dump leaks since last checkpoint marker.
|
80
|
-
* May not be combined with __LEAKS_TOTAL.
|
81
|
-
*
|
82
|
-
* Note that this may generate false positives for global TLS
|
83
|
-
* error state and other global caches that aren't cleaned up
|
84
|
-
* until the thread/process terminates. So when using this
|
85
|
-
* around a region of interest, also check the final (at exit)
|
86
|
-
* dump before digging into leaks reported here.
|
87
|
-
*/
|
88
|
-
GIT_WIN32__CRTDBG_STACKTRACE__LEAKS_SINCE_MARK = (1 << 1),
|
89
|
-
|
90
|
-
/**
|
91
|
-
* Dump leaks since init. May not be combined
|
92
|
-
* with __LEAKS_SINCE_MARK.
|
93
|
-
*/
|
94
|
-
GIT_WIN32__CRTDBG_STACKTRACE__LEAKS_TOTAL = (1 << 2),
|
95
|
-
|
96
|
-
/**
|
97
|
-
* Suppress printing during dumps.
|
98
|
-
* Just return leak count.
|
99
|
-
*/
|
100
|
-
GIT_WIN32__CRTDBG_STACKTRACE__QUIET = (1 << 3),
|
101
|
-
|
102
|
-
} git_win32__crtdbg_stacktrace_options;
|
103
|
-
|
104
|
-
/**
|
105
|
-
* Checkpoint memory state and/or dump unique stack traces of
|
106
|
-
* current memory leaks.
|
107
|
-
*
|
108
|
-
* @return number of unique leaks (relative to requested starting
|
109
|
-
* point) or error.
|
110
|
-
*/
|
111
|
-
GIT_EXTERN(int) git_win32__crtdbg_stacktrace__dump(
|
112
|
-
git_win32__crtdbg_stacktrace_options opt,
|
113
|
-
const char *label);
|
114
|
-
|
115
|
-
/**
|
116
|
-
* Construct stacktrace and append it to the global buffer.
|
117
|
-
* Return pointer to start of this string. On any error or
|
118
|
-
* lack of buffer space, just return the given file buffer
|
119
|
-
* so it will behave as usual.
|
120
|
-
*
|
121
|
-
* This should ONLY be called by our internal memory allocations
|
122
|
-
* routines.
|
123
|
-
*/
|
124
|
-
const char *git_win32__crtdbg_stacktrace(int skip, const char *file);
|
125
|
-
|
126
|
-
#endif
|
127
|
-
#endif
|