summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: cdf0553)
raw | patch | inline | side by side (parent: cdf0553)
author | Junio C Hamano <gitster@pobox.com> | |
Wed, 26 Oct 2011 18:45:15 +0000 (11:45 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 26 Oct 2011 20:09:04 +0000 (13:09 -0700) |
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/grep.c | patch | blob | history |
diff --git a/builtin/grep.c b/builtin/grep.c
index 88b0c8013716367cddc064ac9b24575c3c9360bd..3ddfae4e79b5092a211608f25b6ded9b522d9f99 100644 (file)
--- a/builtin/grep.c
+++ b/builtin/grep.c
/* This lock protects all the variables above. */
static pthread_mutex_t grep_mutex;
+static inline void grep_lock(void)
+{
+ if (use_threads)
+ pthread_mutex_lock(&grep_mutex);
+}
+
+static inline void grep_unlock(void)
+{
+ if (use_threads)
+ pthread_mutex_unlock(&grep_mutex);
+}
+
/* Used to serialize calls to read_sha1_file. */
static pthread_mutex_t read_sha1_mutex;
-#define WHEN_THREADED(x) do { if (use_threads) (x); } while (0)
-#define grep_lock() WHEN_THREADED(pthread_mutex_lock(&grep_mutex))
-#define grep_unlock() WHEN_THREADED(pthread_mutex_unlock(&grep_mutex))
-#define read_sha1_lock() WHEN_THREADED(pthread_mutex_lock(&read_sha1_mutex))
-#define read_sha1_unlock() WHEN_THREADED(pthread_mutex_unlock(&read_sha1_mutex))
+static inline void read_sha1_lock(void)
+{
+ if (use_threads)
+ pthread_mutex_lock(&read_sha1_mutex);
+}
+
+static inline void read_sha1_unlock(void)
+{
+ if (use_threads)
+ pthread_mutex_unlock(&read_sha1_mutex);
+}
/* Signalled when a new work_item is added to todo. */
static pthread_cond_t cond_add;