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>
Junio C Hamano committed
Dec 10, 2010 at 10:32 UTC
b361888dd5a26c4f1eb6268392e89e2d546accf6
4 files changed
+4
-12
builtin/grep.c
-4
@@ -17,11 +17,7 @@
17
#include "grep.h"
18
#include "quote.h"
19
#include "dir.h"
20
-
21
-#ifndef NO_PTHREADS
22
-#include <pthread.h>
20
#include "thread-utils.h"
24
-#endif
21
22
static char const * const grep_usage[] = {
23
"git grep [options] [-e] <pattern> [<rev>...] [[--] <path>...]",
builtin/pack-objects.c
-4
@@ -16,11 +16,7 @@
16
#include "list-objects.h"
17
#include "progress.h"
18
#include "refs.h"
19
-
20
-#ifndef NO_PTHREADS
21
-#include <pthread.h>
19
#include "thread-utils.h"
23
-#endif
20
21
static const char pack_usage[] =
22
"git pack-objects [ -q | --progress | --all-progress ]\n"
thread-utils.h
+4
@@ -1,7 +1,11 @@
1
#ifndef THREAD_COMPAT_H
2
#define THREAD_COMPAT_H
3
4
+#ifndef NO_PTHREADS
5
+#include <pthread.h>
6
+
7
extern int online_cpus(void);
8
extern int init_recursive_mutex(pthread_mutex_t*);
9
10
+#endif
11
#endif /* THREAD_COMPAT_H */
transport-helper.c
-4
@@ -8,11 +8,7 @@
8
#include "quote.h"
9
#include "remote.h"
10
#include "string-list.h"
11
-
12
-#ifndef NO_PTHREADS
13
-#include <pthread.h>
11
#include "thread-utils.h"
15
-#endif
12
13
static int debug;
14