Skip to content

Commit 1adb841

Browse files
authored
Merge pull request libgit2#5719 from libgit2/ethomson/nothreads
Thread-free implementation
2 parents 87e4597 + 8f30532 commit 1adb841

File tree

6 files changed

+34
-24
lines changed

6 files changed

+34
-24
lines changed

.github/workflows/nightly.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ jobs:
5151
CMAKE_OPTIONS: -DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
5252
CMAKE_GENERATOR: Ninja
5353
os: ubuntu-latest
54+
- # Xenial, GCC, thread-free
55+
container:
56+
name: xenial
57+
env:
58+
CC: gcc
59+
CMAKE_OPTIONS: -DTHREADSAFE=OFF -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
60+
CMAKE_GENERATOR: Ninja
61+
os: ubuntu-latest
5462
- # Focal, Clang 10, mbedTLS, MemorySanitizer
5563
container:
5664
name: focal

src/pack-objects.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ struct walk_object {
5050
#ifdef GIT_THREADS
5151
# define GIT_PACKBUILDER__MUTEX_OP(pb, mtx, op) git_mutex_##op(&(pb)->mtx)
5252
#else
53-
# define GIT_PACKBUILDER__MUTEX_OP(pb, mtx, op) GIT_UNUSED(pb)
53+
# define GIT_PACKBUILDER__MUTEX_OP(pb, mtx, op) git__noop()
5454
#endif
5555

5656
#define git_packbuilder__cache_lock(pb) GIT_PACKBUILDER__MUTEX_OP(pb, cache_mutex, lock)

src/runtime.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ GIT_INLINE(int) init_unlock(void)
103103
# error unknown threading model
104104
#else
105105

106-
# define init_lock() git___noop()
107-
# define init_unlock() git___noop()
106+
# define init_lock() git__noop()
107+
# define init_unlock() git__noop()
108108

109109
#endif
110110

src/thread-utils.h

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -235,38 +235,36 @@ GIT_INLINE(int64_t) git_atomic64_get(git_atomic64 *a)
235235

236236
#else
237237

238-
GIT_INLINE(int) git___noop(void) { return 0; }
239-
240-
#define git_threads_global_init git___noop
238+
#define git_threads_global_init git__noop
241239

242240
#define git_thread unsigned int
243-
#define git_thread_create(thread, start_routine, arg) git___noop()
244-
#define git_thread_join(id, status) git___noop()
241+
#define git_thread_create(thread, start_routine, arg) git__noop()
242+
#define git_thread_join(id, status) git__noop()
245243

246244
/* Pthreads Mutex */
247245
#define git_mutex unsigned int
248-
#define git_mutex_init(a) git___noop()
249-
#define git_mutex_init(a) git___noop()
250-
#define git_mutex_lock(a) git___noop()
251-
#define git_mutex_unlock(a) git___noop()
252-
#define git_mutex_free(a) git___noop()
246+
#define git_mutex_init(a) git__noop()
247+
#define git_mutex_init(a) git__noop()
248+
#define git_mutex_lock(a) git__noop()
249+
#define git_mutex_unlock(a) git__noop()
250+
#define git_mutex_free(a) git__noop()
253251

254252
/* Pthreads condition vars */
255253
#define git_cond unsigned int
256-
#define git_cond_init(c) git___noop()
257-
#define git_cond_free(c) git___noop()
258-
#define git_cond_wait(c, l) git___noop()
259-
#define git_cond_signal(c) git___noop()
260-
#define git_cond_broadcast(c) git___noop()
254+
#define git_cond_init(c) git__noop()
255+
#define git_cond_free(c) git__noop()
256+
#define git_cond_wait(c, l) git__noop()
257+
#define git_cond_signal(c) git__noop()
258+
#define git_cond_broadcast(c) git__noop()
261259

262260
/* Pthreads rwlock */
263261
#define git_rwlock unsigned int
264-
#define git_rwlock_init(a) git___noop()
265-
#define git_rwlock_rdlock(a) git___noop()
266-
#define git_rwlock_rdunlock(a) git___noop()
267-
#define git_rwlock_wrlock(a) git___noop()
268-
#define git_rwlock_wrunlock(a) git___noop()
269-
#define git_rwlock_free(a) git___noop()
262+
#define git_rwlock_init(a) git__noop()
263+
#define git_rwlock_rdlock(a) git__noop()
264+
#define git_rwlock_rdunlock(a) git__noop()
265+
#define git_rwlock_wrlock(a) git__noop()
266+
#define git_rwlock_wrunlock(a) git__noop()
267+
#define git_rwlock_free(a) git__noop()
270268
#define GIT_RWLOCK_STATIC_INIT 0
271269

272270

src/util.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,8 @@ GIT_INLINE(double) git__timer(void)
414414

415415
extern int git__getenv(git_buf *out, const char *name);
416416

417+
GIT_INLINE(int) git__noop(void) { return 0; }
418+
417419
#include "alloc.h"
418420

419421
#endif

tests/pack/threadsafety.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ void test_pack_threadsafety__cleanup(void)
2020
cl_git_pass(git_libgit2_opts(GIT_OPT_SET_MWINDOW_FILE_LIMIT, original_mwindow_file_limit));
2121
}
2222

23+
#ifdef GIT_THREADS
2324
static void *get_status(void *arg)
2425
{
2526
const char *repo_path = (const char *)arg;
@@ -33,6 +34,7 @@ static void *get_status(void *arg)
3334

3435
return NULL;
3536
}
37+
#endif
3638

3739
void test_pack_threadsafety__open_repo_in_multiple_threads(void)
3840
{

0 commit comments

Comments
 (0)