Skip to content

Commit b361888

Browse files
committed
thread-utils.h: simplify the inclusion
All files that include this header file use the same four line incantation: #ifndef NO_PTHREADS #include <pthread.h> #include "thread-utils.h" #endif Move the responsibility for that gymnastics to the header file from the files that include it. This approach makes it easier to later declare new services that are related to threading in thread-utils.h and have them available to all the threading code. Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent e4117b1 commit b361888

4 files changed

Lines changed: 4 additions & 12 deletions

File tree

builtin/grep.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@
1717
#include "grep.h"
1818
#include "quote.h"
1919
#include "dir.h"
20-
21-
#ifndef NO_PTHREADS
22-
#include <pthread.h>
2320
#include "thread-utils.h"
24-
#endif
2521

2622
static char const * const grep_usage[] = {
2723
"git grep [options] [-e] <pattern> [<rev>...] [[--] <path>...]",

builtin/pack-objects.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,7 @@
1616
#include "list-objects.h"
1717
#include "progress.h"
1818
#include "refs.h"
19-
20-
#ifndef NO_PTHREADS
21-
#include <pthread.h>
2219
#include "thread-utils.h"
23-
#endif
2420

2521
static const char pack_usage[] =
2622
"git pack-objects [ -q | --progress | --all-progress ]\n"

thread-utils.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
#ifndef THREAD_COMPAT_H
22
#define THREAD_COMPAT_H
33

4+
#ifndef NO_PTHREADS
5+
#include <pthread.h>
6+
47
extern int online_cpus(void);
58
extern int init_recursive_mutex(pthread_mutex_t*);
69

10+
#endif
711
#endif /* THREAD_COMPAT_H */

transport-helper.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@
88
#include "quote.h"
99
#include "remote.h"
1010
#include "string-list.h"
11-
12-
#ifndef NO_PTHREADS
13-
#include <pthread.h>
1411
#include "thread-utils.h"
15-
#endif
1612

1713
static int debug;
1814

0 commit comments

Comments
 (0)