summaryrefslogtreecommitdiff
path: root/builtin/grep.c
diff options
context:
space:
mode:
Diffstat (limited to 'builtin/grep.c')
-rw-r--r--builtin/grep.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/builtin/grep.c b/builtin/grep.c
index 3ffb5b4..b109536 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -73,14 +73,14 @@ static pthread_mutex_t grep_mutex;
static inline void grep_lock(void)
{
- if (num_threads)
- pthread_mutex_lock(&grep_mutex);
+ assert(num_threads);
+ pthread_mutex_lock(&grep_mutex);
}
static inline void grep_unlock(void)
{
- if (num_threads)
- pthread_mutex_unlock(&grep_mutex);
+ assert(num_threads);
+ pthread_mutex_unlock(&grep_mutex);
}
/* Signalled when a new work_item is added to todo. */
@@ -289,6 +289,17 @@ static int grep_cmd_config(const char *var, const char *value, void *cb)
if (num_threads < 0)
die(_("invalid number of threads specified (%d) for %s"),
num_threads, var);
+#ifdef NO_PTHREADS
+ else if (num_threads && num_threads != 1) {
+ /*
+ * TRANSLATORS: %s is the configuration
+ * variable for tweaking threads, currently
+ * grep.threads
+ */
+ warning(_("no threads support, ignoring %s"), var);
+ num_threads = 0;
+ }
+#endif
}
return st;
@@ -495,6 +506,8 @@ static void compile_submodule_options(const struct grep_opt *opt,
break;
case GREP_PATTERN_TYPE_UNSPECIFIED:
break;
+ default:
+ die("BUG: Added a new grep pattern type without updating switch statement");
}
for (pattern = opt->pattern_list; pattern != NULL;
@@ -1227,6 +1240,8 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
else if (num_threads < 0)
die(_("invalid number of threads specified (%d)"), num_threads);
#else
+ if (num_threads)
+ warning(_("no threads support, ignoring --threads"));
num_threads = 0;
#endif