diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2020-12-05 22:47:24 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-05 22:47:24 +0000 |
commit | 1adb84107f406a00178296257289663860d277ae (patch) | |
tree | 1e1c82b5d446ed8e32be2b83724f129d66493b08 | |
parent | 87e4597caa1a26b8fdd97213ee2d4041e67f5f0c (diff) | |
parent | 8f3053269e6d518ccf06549aed82dddbfe0c4823 (diff) | |
download | libgit2-1adb84107f406a00178296257289663860d277ae.tar.gz |
Merge pull request #5719 from libgit2/ethomson/nothreads
Thread-free implementation
-rw-r--r-- | .github/workflows/nightly.yml | 8 | ||||
-rw-r--r-- | src/pack-objects.c | 2 | ||||
-rw-r--r-- | src/runtime.c | 4 | ||||
-rw-r--r-- | src/thread-utils.h | 40 | ||||
-rw-r--r-- | src/util.h | 2 | ||||
-rw-r--r-- | tests/pack/threadsafety.c | 2 |
6 files changed, 34 insertions, 24 deletions
diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 11b184ee2..8e35726d7 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -51,6 +51,14 @@ jobs: CMAKE_OPTIONS: -DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON CMAKE_GENERATOR: Ninja os: ubuntu-latest + - # Xenial, GCC, thread-free + container: + name: xenial + env: + CC: gcc + CMAKE_OPTIONS: -DTHREADSAFE=OFF -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON + CMAKE_GENERATOR: Ninja + os: ubuntu-latest - # Focal, Clang 10, mbedTLS, MemorySanitizer container: name: focal diff --git a/src/pack-objects.c b/src/pack-objects.c index 8ebb8cf43..03d05b7e7 100644 --- a/src/pack-objects.c +++ b/src/pack-objects.c @@ -50,7 +50,7 @@ struct walk_object { #ifdef GIT_THREADS # define GIT_PACKBUILDER__MUTEX_OP(pb, mtx, op) git_mutex_##op(&(pb)->mtx) #else -# define GIT_PACKBUILDER__MUTEX_OP(pb, mtx, op) GIT_UNUSED(pb) +# define GIT_PACKBUILDER__MUTEX_OP(pb, mtx, op) git__noop() #endif #define git_packbuilder__cache_lock(pb) GIT_PACKBUILDER__MUTEX_OP(pb, cache_mutex, lock) diff --git a/src/runtime.c b/src/runtime.c index f8e3e3b27..a214b435e 100644 --- a/src/runtime.c +++ b/src/runtime.c @@ -103,8 +103,8 @@ GIT_INLINE(int) init_unlock(void) # error unknown threading model #else -# define init_lock() git___noop() -# define init_unlock() git___noop() +# define init_lock() git__noop() +# define init_unlock() git__noop() #endif diff --git a/src/thread-utils.h b/src/thread-utils.h index e577a9b0b..d71fabe10 100644 --- a/src/thread-utils.h +++ b/src/thread-utils.h @@ -235,38 +235,36 @@ GIT_INLINE(int64_t) git_atomic64_get(git_atomic64 *a) #else -GIT_INLINE(int) git___noop(void) { return 0; } - -#define git_threads_global_init git___noop +#define git_threads_global_init git__noop #define git_thread unsigned int -#define git_thread_create(thread, start_routine, arg) git___noop() -#define git_thread_join(id, status) git___noop() +#define git_thread_create(thread, start_routine, arg) git__noop() +#define git_thread_join(id, status) git__noop() /* Pthreads Mutex */ #define git_mutex unsigned int -#define git_mutex_init(a) git___noop() -#define git_mutex_init(a) git___noop() -#define git_mutex_lock(a) git___noop() -#define git_mutex_unlock(a) git___noop() -#define git_mutex_free(a) git___noop() +#define git_mutex_init(a) git__noop() +#define git_mutex_init(a) git__noop() +#define git_mutex_lock(a) git__noop() +#define git_mutex_unlock(a) git__noop() +#define git_mutex_free(a) git__noop() /* Pthreads condition vars */ #define git_cond unsigned int -#define git_cond_init(c) git___noop() -#define git_cond_free(c) git___noop() -#define git_cond_wait(c, l) git___noop() -#define git_cond_signal(c) git___noop() -#define git_cond_broadcast(c) git___noop() +#define git_cond_init(c) git__noop() +#define git_cond_free(c) git__noop() +#define git_cond_wait(c, l) git__noop() +#define git_cond_signal(c) git__noop() +#define git_cond_broadcast(c) git__noop() /* Pthreads rwlock */ #define git_rwlock unsigned int -#define git_rwlock_init(a) git___noop() -#define git_rwlock_rdlock(a) git___noop() -#define git_rwlock_rdunlock(a) git___noop() -#define git_rwlock_wrlock(a) git___noop() -#define git_rwlock_wrunlock(a) git___noop() -#define git_rwlock_free(a) git___noop() +#define git_rwlock_init(a) git__noop() +#define git_rwlock_rdlock(a) git__noop() +#define git_rwlock_rdunlock(a) git__noop() +#define git_rwlock_wrlock(a) git__noop() +#define git_rwlock_wrunlock(a) git__noop() +#define git_rwlock_free(a) git__noop() #define GIT_RWLOCK_STATIC_INIT 0 diff --git a/src/util.h b/src/util.h index f49989f7e..185a1b129 100644 --- a/src/util.h +++ b/src/util.h @@ -414,6 +414,8 @@ GIT_INLINE(double) git__timer(void) extern int git__getenv(git_buf *out, const char *name); +GIT_INLINE(int) git__noop(void) { return 0; } + #include "alloc.h" #endif diff --git a/tests/pack/threadsafety.c b/tests/pack/threadsafety.c index 0b479788f..fd6a61fbd 100644 --- a/tests/pack/threadsafety.c +++ b/tests/pack/threadsafety.c @@ -20,6 +20,7 @@ void test_pack_threadsafety__cleanup(void) cl_git_pass(git_libgit2_opts(GIT_OPT_SET_MWINDOW_FILE_LIMIT, original_mwindow_file_limit)); } +#ifdef GIT_THREADS static void *get_status(void *arg) { const char *repo_path = (const char *)arg; @@ -33,6 +34,7 @@ static void *get_status(void *arg) return NULL; } +#endif void test_pack_threadsafety__open_repo_in_multiple_threads(void) { |