Skip to content

Commit

Permalink
thread-utils.h: simplify the inclusion
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
gitster committed Dec 10, 2010
1 parent e4117b1 commit b361888
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 12 deletions.
4 changes: 0 additions & 4 deletions builtin/grep.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@
#include "grep.h"
#include "quote.h"
#include "dir.h"

#ifndef NO_PTHREADS
#include <pthread.h>
#include "thread-utils.h"
#endif

static char const * const grep_usage[] = {
"git grep [options] [-e] <pattern> [<rev>...] [[--] <path>...]",
Expand Down
4 changes: 0 additions & 4 deletions builtin/pack-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@
#include "list-objects.h"
#include "progress.h"
#include "refs.h"

#ifndef NO_PTHREADS
#include <pthread.h>
#include "thread-utils.h"
#endif

static const char pack_usage[] =
"git pack-objects [ -q | --progress | --all-progress ]\n"
Expand Down
4 changes: 4 additions & 0 deletions thread-utils.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#ifndef THREAD_COMPAT_H
#define THREAD_COMPAT_H

#ifndef NO_PTHREADS
#include <pthread.h>

extern int online_cpus(void);
extern int init_recursive_mutex(pthread_mutex_t*);

#endif
#endif /* THREAD_COMPAT_H */
4 changes: 0 additions & 4 deletions transport-helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@
#include "quote.h"
#include "remote.h"
#include "string-list.h"

#ifndef NO_PTHREADS
#include <pthread.h>
#include "thread-utils.h"
#endif

static int debug;

Expand Down

0 comments on commit b361888

Please sign in to comment.