Re: [PATCH v3 2/3] grep: enable threading with -p and -W using lazy attribute lookup
- From
Johannes Sixt <j.sixt@viscovery.net>
- Date
- Dec 16, 2011, 08:22 UTC
- Message-ID
- <4EEAFFAF.8030003@viscovery.net>
- In-Reply-To
- <138b930c0c96029f2fb9a816e73e70a4d5bce1de.1323723759.git.trast@student.ethz.ch>
Am 12/12/2011 22:16, schrieb Thomas Rast:
Show 23 quoted lines
> diff --git a/grep.h b/grep.h
> index a652800..15d227c 100644
> --- a/grep.h
> +++ b/grep.h
> @@ -115,6 +115,7 @@ struct grep_opt {
> int show_hunk_mark;
> int file_break;
> int heading;
> + int use_threads;
> void *priv;
>
> void (*output)(struct grep_opt *opt, const void *data, size_t size);
> @@ -131,4 +132,10 @@ struct grep_opt {
> extern struct grep_opt *grep_opt_dup(const struct grep_opt *opt);
> extern int grep_threads_ok(const struct grep_opt *opt);
>
> +#ifndef NO_PTHREADS
> +/* Mutex used around access to the attributes machinery if
> + * opt->use_threads. Must be initialized/destroyed by callers! */
> +extern pthread_mutex_t grep_attr_mutex;
> +#endif
> +
> #endifThis is the first time we use pthread_mutex_t in a header file. We need at least the following squashed in. An alternative would be to include "thread-utils.h", but thread-utils is really more about implementation helpers functions, not about types, and therefore does not look right to be #included in a header.
--- grep.h | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/grep.h b/grep.h index 15d227c..754b270 100644 --- a/grep.h +++ b/grep.h @@ -133,6 +133,7 @@ extern struct grep_opt *grep_opt_dup(const struct grep_opt *opt); extern int grep_threads_ok(const struct grep_opt *opt); #ifndef NO_PTHREADS +#include <pthread.h> /* Mutex used around access to the attributes machinery if * opt->use_threads. Must be initialized/destroyed by callers! */ extern pthread_mutex_t grep_attr_mutex;
-- 1.7.8.1436.gb3021