From patchwork Sat Oct 27 07:09:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10658255 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3041C13BF for ; Sat, 27 Oct 2018 07:10:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 15DC92BE94 for ; Sat, 27 Oct 2018 07:10:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0849D2BEA7; Sat, 27 Oct 2018 07:10:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7A0C52BE94 for ; Sat, 27 Oct 2018 07:10:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728022AbeJ0PuN (ORCPT ); Sat, 27 Oct 2018 11:50:13 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:40163 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727844AbeJ0PuN (ORCPT ); Sat, 27 Oct 2018 11:50:13 -0400 Received: by mail-lj1-f196.google.com with SMTP id t22-v6so3165631lji.7 for ; Sat, 27 Oct 2018 00:10:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=R7+bNRaeDS9nwR8IL/WmShtlYTjnFbyiaS1BiIVwpLQ=; b=F7+0Dsqc117rNELyLSxioYiQ8IU1Vjah7Z13ZjMLkcVWZtufZ5P5HXh5UidC/gDqu2 anDgr263KUBFjsqYom3YdVLFcUGuMrGDM6mjXR/vYbxd4q8TqW49gcmK2qcmXB7YuWhK zOZ8HPpzJhvsP8+7Dj/FENX9grWwF5sWlaLO/t50dE9jeuvdamISdRoJCt+IijqHJTDG /cQL647QJWB9hSrT+qqK9EpmxNXmjWsU494qMPHxgzEX3PjFze9PjKKSbDNztqIIM0bC 2UjImyvZo44R35PvjIkzQAs0GTYtjMRs5EFlzotxXQ4/BME5R+wyHPMPJth8JuZ+0h8d vAuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=R7+bNRaeDS9nwR8IL/WmShtlYTjnFbyiaS1BiIVwpLQ=; b=mUfi/TzcUbbdIYLmAnLM+XigwGZacaghd1FNVMbGBvDnMzRI3FikRWKyg2kFIcOnX/ qZUHXEOWgnlg8ucaTOw4dD3/uNu99KjxdRhvXbMvHdyh51L8EE46JQKPmv8gZaylPDyE YG4wXJZ7xkGGxDIGgToBzesB3ZfgsA6FQ8taRKuWX7GnFXH09jDHgRZlrqX22bFXFcBo VHeC3MRzTaicW3uSKyKtQuHYAJm8e2MBHvnBDC3veTetab6+RdGGEFn6EpdSoRm1mlmV FMv+B5vADLyf0hiGv0z9DUyacOhMicK61st3gmDDZJMosHnhbgGzLGCcLWaQIGOdv7XA W/xw== X-Gm-Message-State: AGRZ1gLH+WrnYAPmT6QhtPNMjpptiSk5Cg7bIcmLJy2yUBOjuD7Xx0AN Kxu7INruMJoYzlaBDO+/tyDSmZ9W X-Google-Smtp-Source: AJdET5f5o+kZKbrURtTYTOEE8yvYWjSg75NImk3tBnj6qKUggFtsZLIcgyAgQV3f7ZrUMCX/XuRmfw== X-Received: by 2002:a2e:6a13:: with SMTP id f19-v6mr1899446ljc.41.1540624210910; Sat, 27 Oct 2018 00:10:10 -0700 (PDT) Received: from localhost.localdomain (c80-216-12-205.bredband.comhem.se. [80.216.12.205]) by smtp.gmail.com with ESMTPSA id r7-v6sm1534899ljr.21.2018.10.27.00.10.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 27 Oct 2018 00:10:10 -0700 (PDT) From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Ben Peart , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1?= =?utf-8?b?eQ==?= Subject: [PATCH 01/10] thread-utils: macros to unconditionally compile pthreads API Date: Sat, 27 Oct 2018 09:09:54 +0200 Message-Id: <20181027071003.1347-2-pclouds@gmail.com> X-Mailer: git-send-email 2.19.1.647.g708186aaf9 In-Reply-To: <20181027071003.1347-1-pclouds@gmail.com> References: <20181027071003.1347-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When built with NO_PTHREADS, the macros are used make the code build even though pthreads header and library may be missing. The code can still have different code paths for no threads support with HAVE_THREADS variable. There are of course impacts on no-pthreads builds: - data structure may get slightly bigger because all the mutexes and pthread_t are present (as an int) - code execution is not impacted much. Locking (in hot path) is no-op. Other wrapper function calls really should not matter much. - the binary size grows bigger because of threaded code. But at least on Linux this does not matter, if some code is not executed, it's not mapped in memory. This is a preparation step to remove "#ifdef NO_PTHREADS" in the code mostly because of maintainability. As Jeff put it > it's probably OK to stop thinking of it as "non-threaded platforms > are the default and must pay zero cost" and more as "threaded > platforms are the default, and non-threaded ones are OK to pay a > small cost as long as they still work". Signed-off-by: Nguyễn Thái Ngọc Duy --- Makefile | 2 +- thread-utils.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ thread-utils.h | 47 ++++++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 93 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index b08d5ea258..321540a736 100644 --- a/Makefile +++ b/Makefile @@ -991,6 +991,7 @@ LIB_OBJS += sub-process.o LIB_OBJS += symlinks.o LIB_OBJS += tag.o LIB_OBJS += tempfile.o +LIB_OBJS += thread-utils.o LIB_OBJS += tmp-objdir.o LIB_OBJS += trace.o LIB_OBJS += trailer.o @@ -1674,7 +1675,6 @@ ifdef NO_PTHREADS else BASIC_CFLAGS += $(PTHREAD_CFLAGS) EXTLIBS += $(PTHREAD_LIBS) - LIB_OBJS += thread-utils.o endif ifdef HAVE_PATHS_H diff --git a/thread-utils.c b/thread-utils.c index a2135e0743..5329845691 100644 --- a/thread-utils.c +++ b/thread-utils.c @@ -20,6 +20,9 @@ int online_cpus(void) { +#ifdef NO_PTHREADS + return 1; +#else #ifdef _SC_NPROCESSORS_ONLN long ncpus; #endif @@ -59,10 +62,12 @@ int online_cpus(void) #endif return 1; +#endif } int init_recursive_mutex(pthread_mutex_t *m) { +#ifndef NO_PTHREADS pthread_mutexattr_t a; int ret; @@ -74,4 +79,47 @@ int init_recursive_mutex(pthread_mutex_t *m) pthread_mutexattr_destroy(&a); } return ret; +#else + return 0; +#endif +} + +#ifdef NO_PTHREADS +int dummy_pthread_create(pthread_t *pthread, const void *attr, + void *(*fn)(void *), void *data) +{ + /* + * Do nothing. + * + * The main purpose of this function is to break compiler's + * flow analysis and avoid -Wunused-variable false warnings. + */ + return ENOSYS; +} + +int dummy_pthread_init(void *data) +{ + /* + * Do nothing. + * + * The main purpose of this function is to break compiler's + * flow analysis or it may realize that functions like + * pthread_mutex_init() is no-op, which means the (static) + * variable is not used/initialized at all and trigger + * -Wunused-variable + */ + return ENOSYS; } + +int dummy_pthread_join(pthread_t pthread, void **retval) +{ + /* + * Do nothing. + * + * The main purpose of this function is to break compiler's + * flow analysis and avoid -Wunused-variable false warnings. + */ + return ENOSYS; +} + +#endif diff --git a/thread-utils.h b/thread-utils.h index d9a769d190..a12850e747 100644 --- a/thread-utils.h +++ b/thread-utils.h @@ -4,12 +4,53 @@ #ifndef NO_PTHREADS #include -extern int online_cpus(void); -extern int init_recursive_mutex(pthread_mutex_t*); +#define HAVE_THREADS 1 #else -#define online_cpus() 1 +#define HAVE_THREADS 0 + +/* + * macros instead of typedefs because pthread definitions may have + * been pulled in by some system dependencies even though the user + * wants to disable pthread. + */ +#define pthread_t int +#define pthread_mutex_t int +#define pthread_cond_t int + +#define pthread_mutex_init(mutex, attr) dummy_pthread_init(mutex) +#define pthread_mutex_lock(mutex) +#define pthread_mutex_unlock(mutex) +#define pthread_mutex_destroy(mutex) + +#define pthread_cond_init(cond, attr) dummy_pthread_init(cond) +#define pthread_cond_wait(cond, mutex) +#define pthread_cond_signal(cond) +#define pthread_cond_broadcast(cond) +#define pthread_cond_destroy(cond) + +#define pthread_key_create(key, attr) dummy_pthread_init(key) +#define pthread_key_delete(key) + +#define pthread_create(thread, attr, fn, data) \ + dummy_pthread_create(thread, attr, fn, data) +#define pthread_join(thread, retval) \ + dummy_pthread_join(thread, retval) + +#define pthread_setspecific(key, data) +#define pthread_getspecific(key) NULL + +int dummy_pthread_create(pthread_t *pthread, const void *attr, + void *(*fn)(void *), void *data); +int dummy_pthread_join(pthread_t pthread, void **retval); + +int dummy_pthread_init(void *); #endif + +int online_cpus(void); +int init_recursive_mutex(pthread_mutex_t*); + + #endif /* THREAD_COMPAT_H */ From patchwork Sat Oct 27 07:09:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10658263 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F09091815 for ; Sat, 27 Oct 2018 07:10:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D6DBF2BE48 for ; Sat, 27 Oct 2018 07:10:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CB1E12BEAB; Sat, 27 Oct 2018 07:10:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BB61E2BEA0 for ; Sat, 27 Oct 2018 07:10:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728147AbeJ0PuO (ORCPT ); Sat, 27 Oct 2018 11:50:14 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:43525 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726610AbeJ0PuO (ORCPT ); Sat, 27 Oct 2018 11:50:14 -0400 Received: by mail-lj1-f196.google.com with SMTP id g26-v6so1902991lja.10 for ; Sat, 27 Oct 2018 00:10:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6xDyapWfwoqfEqSfPJe6Xohq4fxEOPqfhDua9vHp/Eg=; b=JM1P3AUyCeK50kGFYyToOmzsgbvOzFJHbNsckPghaIOVc6lKB752n0vanBPrr4N1Lo kM9XDq1YKCRuFls6pAUxCAYQLqBEB3k7WocyoJFMciitbo0czzBxzJshGGh8bLgn5VL+ L7bQfyoen5EJP7M7zA8cO0Dkipsj5qoIK3wKfJa5hkEAJyQwL794wSbPzmyeMKRa/3jT 8b3k6uOvGPCbvZHFdBbYzkjlIIkaLBiIhrYtC8eaQ+q+ShWNzjCLgg61kl/OtFND9msl Ygyu3CsZuEbGda5OegbFR8z2Aq9XYsLhF17hIJtZHBOhUWz2M1lPxIyWEowwEKeLWRwL KizQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6xDyapWfwoqfEqSfPJe6Xohq4fxEOPqfhDua9vHp/Eg=; b=IPHThW+KOCs+osxv50zz/af0I/J5kD4zare7ZfyW8T9+bsN9SYCm6i3PqAIumV/zqu pUc9qLHXaMDQN82AvYNs4f3H2w4UZE3+9tPngt1TfDCxDOMEynbcDbQS8K9K1q+IUpql KVuq2TFAVRtrBV3Lh6RTXYMS8u16vfoUdZYlnmoDo8ruPwk9rSdj/LEz2/3GdnJ5ZoLS 4izVDw9CsNmbSQTpgCflhLqZJRkLeIZLvqHGQ3M2wScj32ceeviIi+GE9wuYAL0kMk7s p+jIhf+CEwDueg4c4/R3qCGFuZ5TqvLm5OcTF7FBMNtTESI0YHPQhWSHoXUzr2SFt8JR F92A== X-Gm-Message-State: AGRZ1gIE7Z9661bHN7kcz9IQA97/H7h/FnEi5yRTYFJq9sbMUog65gXK I5p4WfUm9lC0EhFSR4eibK89NQ5X X-Google-Smtp-Source: AJdET5fNIZB5Aophabj5fGNBE4qHWrs29yTox4l5ya9GcWFSBwtgvAQBL8OtnQjxzmTCwFtzJaVAIA== X-Received: by 2002:a2e:719:: with SMTP id 25-v6mr4347477ljh.128.1540624211935; Sat, 27 Oct 2018 00:10:11 -0700 (PDT) Received: from localhost.localdomain (c80-216-12-205.bredband.comhem.se. [80.216.12.205]) by smtp.gmail.com with ESMTPSA id r7-v6sm1534899ljr.21.2018.10.27.00.10.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 27 Oct 2018 00:10:11 -0700 (PDT) From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Ben Peart , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1?= =?utf-8?b?eQ==?= Subject: [PATCH 02/10] index-pack: remove #ifdef NO_PTHREADS Date: Sat, 27 Oct 2018 09:09:55 +0200 Message-Id: <20181027071003.1347-3-pclouds@gmail.com> X-Mailer: git-send-email 2.19.1.647.g708186aaf9 In-Reply-To: <20181027071003.1347-1-pclouds@gmail.com> References: <20181027071003.1347-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Nguyễn Thái Ngọc Duy --- builtin/index-pack.c | 68 ++++++++++++-------------------------------- 1 file changed, 18 insertions(+), 50 deletions(-) diff --git a/builtin/index-pack.c b/builtin/index-pack.c index 2004e25da2..bbd66ca025 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -42,9 +42,7 @@ struct base_data { }; struct thread_local { -#ifndef NO_PTHREADS pthread_t thread; -#endif struct base_data *base_cache; size_t base_cache_used; int pack_fd; @@ -98,8 +96,6 @@ static uint32_t input_crc32; static int input_fd, output_fd; static const char *curr_pack; -#ifndef NO_PTHREADS - static struct thread_local *thread_data; static int nr_dispatched; static int threads_active; @@ -179,26 +175,6 @@ static void cleanup_thread(void) free(thread_data); } -#else - -#define read_lock() -#define read_unlock() - -#define counter_lock() -#define counter_unlock() - -#define work_lock() -#define work_unlock() - -#define deepest_delta_lock() -#define deepest_delta_unlock() - -#define type_cas_lock() -#define type_cas_unlock() - -#endif - - static int mark_link(struct object *obj, int type, void *data, struct fsck_options *options) { if (!obj) @@ -364,22 +340,20 @@ static NORETURN void bad_object(off_t offset, const char *format, ...) static inline struct thread_local *get_thread_data(void) { -#ifndef NO_PTHREADS - if (threads_active) - return pthread_getspecific(key); - assert(!threads_active && - "This should only be reached when all threads are gone"); -#endif + if (HAVE_THREADS) { + if (threads_active) + return pthread_getspecific(key); + assert(!threads_active && + "This should only be reached when all threads are gone"); + } return ¬hread_data; } -#ifndef NO_PTHREADS static void set_thread_data(struct thread_local *data) { if (threads_active) pthread_setspecific(key, data); } -#endif static struct base_data *alloc_base_data(void) { @@ -1092,7 +1066,6 @@ static void resolve_base(struct object_entry *obj) find_unresolved_deltas(base_obj); } -#ifndef NO_PTHREADS static void *threaded_second_pass(void *data) { set_thread_data(data); @@ -1116,7 +1089,6 @@ static void *threaded_second_pass(void *data) } return NULL; } -#endif /* * First pass: @@ -1213,7 +1185,6 @@ static void resolve_deltas(void) progress = start_progress(_("Resolving deltas"), nr_ref_deltas + nr_ofs_deltas); -#ifndef NO_PTHREADS nr_dispatched = 0; if (nr_threads > 1 || getenv("GIT_FORCE_THREADS")) { init_thread(); @@ -1229,7 +1200,6 @@ static void resolve_deltas(void) cleanup_thread(); return; } -#endif for (i = 0; i < nr_objects; i++) { struct object_entry *obj = &objects[i]; @@ -1531,11 +1501,11 @@ static int git_index_pack_config(const char *k, const char *v, void *cb) if (nr_threads < 0) die(_("invalid number of threads specified (%d)"), nr_threads); -#ifdef NO_PTHREADS - if (nr_threads != 1) - warning(_("no threads support, ignoring %s"), k); - nr_threads = 1; -#endif + if (!HAVE_THREADS) { + if (nr_threads != 1) + warning(_("no threads support, ignoring %s"), k); + nr_threads = 1; + } return 0; } return git_default_config(k, v, cb); @@ -1723,12 +1693,12 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix) nr_threads = strtoul(arg+10, &end, 0); if (!arg[10] || *end || nr_threads < 0) usage(index_pack_usage); -#ifdef NO_PTHREADS - if (nr_threads != 1) - warning(_("no threads support, " - "ignoring %s"), arg); - nr_threads = 1; -#endif + if (!HAVE_THREADS) { + if (nr_threads != 1) + warning(_("no threads support, " + "ignoring %s"), arg); + nr_threads = 1; + } } else if (starts_with(arg, "--pack_header=")) { struct pack_header *hdr; char *c; @@ -1791,14 +1761,12 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix) if (strict) opts.flags |= WRITE_IDX_STRICT; -#ifndef NO_PTHREADS - if (!nr_threads) { + if (HAVE_THREADS && !nr_threads) { nr_threads = online_cpus(); /* An experiment showed that more threads does not mean faster */ if (nr_threads > 3) nr_threads = 3; } -#endif curr_pack = open_pack_file(pack_name); parse_pack_header(); From patchwork Sat Oct 27 07:09:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10658265 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 536C613BF for ; Sat, 27 Oct 2018 07:10:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 396582BE48 for ; Sat, 27 Oct 2018 07:10:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2DBCE2BEA0; Sat, 27 Oct 2018 07:10:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B0582BE9B for ; Sat, 27 Oct 2018 07:10:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728184AbeJ0PuO (ORCPT ); Sat, 27 Oct 2018 11:50:14 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:43534 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728013AbeJ0PuO (ORCPT ); Sat, 27 Oct 2018 11:50:14 -0400 Received: by mail-lf1-f66.google.com with SMTP id u18so2517021lff.10 for ; Sat, 27 Oct 2018 00:10:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ElWD/L0AMYKRyntyrlVCHl2EzE6d7g0uBaIj7GWAy84=; b=HD7yKadnutXGrUUEP/9dIchJvjQrufbpCAzPEvvyrFN5jWvCfKqi/7S4TDa0vtx9gj BfOKu+bjiofjUZH4dDmFoKdgDsnLW70h8rCHSCLYdBIo0oYLJDJcu0tmAVe/8pFeOYfu V+vn3e9Rct+Sq4OYdC7WGSdxcKll8qorAJgj/qzPnxHwPDXWll37y9DmtLLefnN51bUt cehbOX0UQZZGR3sD4+lhAetSc46SO6dxjwoRbCXSmL9DcgDWkewrUTNbYEiEQg7aCpHI CyELpJcLgdXJjalTI57KD53B5c1DfK8Q2/bxB78sLSvAjP3DlQ9eP3XuKOs+cjJVO3+t zF5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ElWD/L0AMYKRyntyrlVCHl2EzE6d7g0uBaIj7GWAy84=; b=IkCO0Rm8XpL8C45CwHg1lgGAAXlpXb0qO8YlMw7eCv2hcEs0YtFR2VWAUne+3eei4+ RYdjPCQ4UBToQyuFftUPsqn+gr2kORdpiMhp4+0hDw01LKYS+sO8gddBfEuJlzsHfQIA 0uKFHY9GZV5vQaofPud3JQG4L7rVxrxNjDBNFHFXE///tKRdj+H44QHkUgLjQbNt46gN A2RuzzPFieQAPpKbyzdS3sj9WNGwrYFfwa9AZSD1j7gwEvsBsXV24C/vLmNegzOF/ZOk 0IMpFfX0PDi3R3jFRsjjluBiNlN8fOAul8DK0WRrVRZj8AbUZ+6x1mDsAiykt7NVObDx cDXQ== X-Gm-Message-State: AGRZ1gJJ9IFfR3mNE1g+JlDUGOZLW84tRpXTPcUyuFKEJf/T8h6TeniB 947aVqW2tu1qpTdKeBwC2l5xFnwh X-Google-Smtp-Source: AJdET5cD9tm4ejVjSmG9WmoICP9b6jJkUxEn7Y52i6Qph6uflT2gSrvJMe74kGt0KSz5lr+toSXzpQ== X-Received: by 2002:a19:d58e:: with SMTP id m136mr4238219lfg.70.1540624213051; Sat, 27 Oct 2018 00:10:13 -0700 (PDT) Received: from localhost.localdomain (c80-216-12-205.bredband.comhem.se. [80.216.12.205]) by smtp.gmail.com with ESMTPSA id r7-v6sm1534899ljr.21.2018.10.27.00.10.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 27 Oct 2018 00:10:12 -0700 (PDT) From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Ben Peart , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1?= =?utf-8?b?eQ==?= Subject: [PATCH 03/10] name-hash.c: remove #ifdef NO_PTHREADS Date: Sat, 27 Oct 2018 09:09:56 +0200 Message-Id: <20181027071003.1347-4-pclouds@gmail.com> X-Mailer: git-send-email 2.19.1.647.g708186aaf9 In-Reply-To: <20181027071003.1347-1-pclouds@gmail.com> References: <20181027071003.1347-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Nguyễn Thái Ngọc Duy --- name-hash.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/name-hash.c b/name-hash.c index 1fcda73cb3..b3c9ac791d 100644 --- a/name-hash.c +++ b/name-hash.c @@ -7,6 +7,7 @@ */ #define NO_THE_INDEX_COMPATIBILITY_MACROS #include "cache.h" +#include "thread-utils.h" struct dir_entry { struct hashmap_entry ent; @@ -131,22 +132,6 @@ static int cache_entry_cmp(const void *unused_cmp_data, static int lazy_try_threaded = 1; static int lazy_nr_dir_threads; -#ifdef NO_PTHREADS - -static inline int lookup_lazy_params(struct index_state *istate) -{ - return 0; -} - -static inline void threaded_lazy_init_name_hash( - struct index_state *istate) -{ -} - -#else - -#include "thread-utils.h" - /* * Set a minimum number of cache_entries that we will handle per * thread and use that to decide how many threads to run (upto @@ -516,6 +501,9 @@ static void threaded_lazy_init_name_hash( struct lazy_dir_thread_data *td_dir; struct lazy_name_thread_data *td_name; + if (!HAVE_THREADS) + return; + k_start = 0; nr_each = DIV_ROUND_UP(istate->cache_nr, lazy_nr_dir_threads); @@ -574,8 +562,6 @@ static void threaded_lazy_init_name_hash( free(lazy_entries); } -#endif - static void lazy_init_name_hash(struct index_state *istate) { From patchwork Sat Oct 27 07:09:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10658257 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 64CF614E2 for ; Sat, 27 Oct 2018 07:10:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4AE772BE94 for ; Sat, 27 Oct 2018 07:10:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3FD242BEB5; Sat, 27 Oct 2018 07:10:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DCE282BEAB for ; Sat, 27 Oct 2018 07:10:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728197AbeJ0PuQ (ORCPT ); Sat, 27 Oct 2018 11:50:16 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:33079 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727844AbeJ0PuP (ORCPT ); Sat, 27 Oct 2018 11:50:15 -0400 Received: by mail-lj1-f194.google.com with SMTP id z21-v6so3185259ljz.0 for ; Sat, 27 Oct 2018 00:10:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mAfV2Nz5oHseiWQnq7IrtXDy2ffEDSwSfXwchHyglKQ=; b=bQNW+lBMjWP/Kc4xeLCCn+aFRnLXiCOs0UTAx5iZVzhrXfduFnN+zdfIVi0W44qJYD PBjydnyPB/VFfC3vmwGfTI0LJ/KN5ilVZCsONfx03vuQKQ06UGBdcOF/eIBZhscvI+sY TOz+PtCcD8x4BPKY9vtKdCnJ8IVXfKwxrLiaEZtWNUvmcnuAs5/fsYfW/jB6mF2wcZjz W477N8AUG1EV/O70T09ADZTsFo3M544KtLnLGH1A73xzJ3viOmZWrYJ4v5mFKulZGGbZ oqyUWUSXWTH1SDDCy66L8yDQRLE1dJagpgmz/Apmb0rfbfYITgvfdYobkIkdde/PjZak 7ihw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mAfV2Nz5oHseiWQnq7IrtXDy2ffEDSwSfXwchHyglKQ=; b=kRYbl9cfAzedC7p4K5QlvRJSOe7lhomg/N4rX08CFvWG3H3Ra0kxmzgt68TkoodA1E b1AGBclNVt6kcaXIAqNgQ4UMI8paeAjBLlLsV2ILuQPSACd1K+2DIhaV6vnKA0tEwCCW yeUiNKlm7ykyQCjCHofIynLvse8c0lc0syNAe0ol1BVHCidp0058NAQ2BDpDGx3X/3Xa lB/7oELww37P5v6wVHo2LDfnQ+C+0fE6s4mpklwLUl8qbWww6MHw6TNCsEJZCNHNV04O 8KLLDgpvvpThpOYYsai5vHNQIltCEeHCutSS5hT3U1fDF9mt7VWB6h0T75QmisxgMesF Bidw== X-Gm-Message-State: AGRZ1gLGuhyU2NOLBbRTuZXYXsCWdyN5EfmgoI3/phIDCL/JjbizA8gH KuyheHt3z2UsUi1EtiJtx/b2CMMj X-Google-Smtp-Source: AJdET5ecLC+5Q7AVdNeb9N90hRs0SKwTwsncpnGOXir6zUp58PWA2bRU1nqSuG7c5juWNZ2/959fvQ== X-Received: by 2002:a2e:1bc5:: with SMTP id c66-v6mr4209435ljf.96.1540624214181; Sat, 27 Oct 2018 00:10:14 -0700 (PDT) Received: from localhost.localdomain (c80-216-12-205.bredband.comhem.se. [80.216.12.205]) by smtp.gmail.com with ESMTPSA id r7-v6sm1534899ljr.21.2018.10.27.00.10.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 27 Oct 2018 00:10:13 -0700 (PDT) From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Ben Peart , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1?= =?utf-8?b?eQ==?= Subject: [PATCH 04/10] attr.c: remove #ifdef NO_PTHREADS Date: Sat, 27 Oct 2018 09:09:57 +0200 Message-Id: <20181027071003.1347-5-pclouds@gmail.com> X-Mailer: git-send-email 2.19.1.647.g708186aaf9 In-Reply-To: <20181027071003.1347-1-pclouds@gmail.com> References: <20181027071003.1347-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Nguyễn Thái Ngọc Duy --- attr.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/attr.c b/attr.c index 60d284796d..eaece6658d 100644 --- a/attr.c +++ b/attr.c @@ -41,23 +41,17 @@ const char *git_attr_name(const struct git_attr *attr) struct attr_hashmap { struct hashmap map; -#ifndef NO_PTHREADS pthread_mutex_t mutex; -#endif }; static inline void hashmap_lock(struct attr_hashmap *map) { -#ifndef NO_PTHREADS pthread_mutex_lock(&map->mutex); -#endif } static inline void hashmap_unlock(struct attr_hashmap *map) { -#ifndef NO_PTHREADS pthread_mutex_unlock(&map->mutex); -#endif } /* @@ -498,23 +492,17 @@ static struct check_vector { size_t nr; size_t alloc; struct attr_check **checks; -#ifndef NO_PTHREADS pthread_mutex_t mutex; -#endif } check_vector; static inline void vector_lock(void) { -#ifndef NO_PTHREADS pthread_mutex_lock(&check_vector.mutex); -#endif } static inline void vector_unlock(void) { -#ifndef NO_PTHREADS pthread_mutex_unlock(&check_vector.mutex); -#endif } static void check_vector_add(struct attr_check *c) @@ -1181,8 +1169,6 @@ void git_all_attrs(const struct index_state *istate, void attr_start(void) { -#ifndef NO_PTHREADS pthread_mutex_init(&g_attr_hashmap.mutex, NULL); pthread_mutex_init(&check_vector.mutex, NULL); -#endif } From patchwork Sat Oct 27 07:09:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10658259 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 907691869 for ; Sat, 27 Oct 2018 07:10:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7694C2BE48 for ; Sat, 27 Oct 2018 07:10:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6B3ED2BEAB; Sat, 27 Oct 2018 07:10:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D55A2BE48 for ; Sat, 27 Oct 2018 07:10:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728207AbeJ0PuQ (ORCPT ); Sat, 27 Oct 2018 11:50:16 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:36446 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728013AbeJ0PuQ (ORCPT ); Sat, 27 Oct 2018 11:50:16 -0400 Received: by mail-lf1-f66.google.com with SMTP id h192so2542149lfg.3 for ; Sat, 27 Oct 2018 00:10:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=NICg9Cu7JUzj1kC1SFqvl9rQPtNHtmIhcjE7o2czEAc=; b=rYzKwq+YGop/KctT7cSOoGgvR93Vc/ovd65+aJUBqr19BWLaK9ZO9lJ4V1pD4SziHg UZ5FtDH00I3kTR1aguHPq9p9bb06E71X5XZL9AI5zpsoXksMpIriYcNUIxYHGPwAMXhI xjGmTzyTB33DA6DzeJ57SUO6kAZwXWP5NUochYXiieOngnxAlAbWB09HMwxBM9q450f+ q9bbNS+CYzIXVDSaj5sTpvLfUYy5ziXTF2icoEWLcVKCHdgy2+Aqf5MNHGoJ4ZqUZ9kb UXuqT/Djayxr8Fo+wHaHaxYK2kVmubVphbDeSW/xhMlROn4M9NB5XcuKXbbqY8CSyZ+J A7EQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NICg9Cu7JUzj1kC1SFqvl9rQPtNHtmIhcjE7o2czEAc=; b=qT9Pe22h+UjPB7JfPYURSjU+VVLKYcuwS0oy+XeGJTNFNuOpZ3DileX04q50Tbfabx jfNrX5WigUvdCEDzYYNRwPvkll38CKo+4JAumgtBbMd+JWiO/oqb+jz72WUeWWCk+E5Q boMQ0kYMf5oIjDHFuWg4aKxTtrVkGR75uQf/U0RC8pu0ju4lloNoyG+HXiiSTP8Xx3WE eCdP4yNok1er2gViaEMmG3skYe7Fu56CnZ7RMe0ot4JpQPMgyEaSqNv1i2gapWXkJNCx ZaA46JrhMqdywB0X0woosRpqNL3HIVk68u28+nMf0yirqzgHB6vFyYVXMZO3tl+kFZBp zseA== X-Gm-Message-State: AGRZ1gJ044A10p0IPAyefXJQjwWE1W1GObXdnTqCWOrf+jzsLnDLSvnJ teDlE1gte6ycM2iRNI8gZyyvPutL X-Google-Smtp-Source: AJdET5cWKX4/Wms8+MgNBPSUTO6civ3N/CigTY2fv1hqubEEGfsqtVSHyYpctswp1WTtBHwOOJBznQ== X-Received: by 2002:a19:4345:: with SMTP id m5mr3872355lfj.142.1540624215314; Sat, 27 Oct 2018 00:10:15 -0700 (PDT) Received: from localhost.localdomain (c80-216-12-205.bredband.comhem.se. [80.216.12.205]) by smtp.gmail.com with ESMTPSA id r7-v6sm1534899ljr.21.2018.10.27.00.10.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 27 Oct 2018 00:10:14 -0700 (PDT) From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Ben Peart , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1?= =?utf-8?b?eQ==?= Subject: [PATCH 05/10] send-pack.c: remove #ifdef NO_PTHREADS Date: Sat, 27 Oct 2018 09:09:58 +0200 Message-Id: <20181027071003.1347-6-pclouds@gmail.com> X-Mailer: git-send-email 2.19.1.647.g708186aaf9 In-Reply-To: <20181027071003.1347-1-pclouds@gmail.com> References: <20181027071003.1347-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP While at there correct "#include cache.h" position. It must be one of the first includes. Signed-off-by: Nguyễn Thái Ngọc Duy --- send-pack.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/send-pack.c b/send-pack.c index e920ca57df..fa7dc44b36 100644 --- a/send-pack.c +++ b/send-pack.c @@ -1,4 +1,5 @@ #include "builtin.h" +#include "cache.h" #include "config.h" #include "commit.h" #include "refs.h" @@ -14,7 +15,7 @@ #include "version.h" #include "sha1-array.h" #include "gpg-interface.h" -#include "cache.h" +#include "thread-utils.h" int option_parse_push_signed(const struct option *opt, const char *arg, int unset) @@ -203,9 +204,8 @@ static int receive_status(int in, struct ref *refs) static int sideband_demux(int in, int out, void *data) { int *fd = data, ret; -#ifdef NO_PTHREADS - close(fd[1]); -#endif + if (!HAVE_THREADS) + close(fd[1]); ret = recv_sideband("send-pack", fd[0], out); close(out); return ret; From patchwork Sat Oct 27 07:09:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10658267 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 54FFB13BF for ; Sat, 27 Oct 2018 07:10:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B4F82BE48 for ; Sat, 27 Oct 2018 07:10:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2F78F2BE94; Sat, 27 Oct 2018 07:10:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E72E2BEA7 for ; Sat, 27 Oct 2018 07:10:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728211AbeJ0PuS (ORCPT ); Sat, 27 Oct 2018 11:50:18 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:33087 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727844AbeJ0PuS (ORCPT ); Sat, 27 Oct 2018 11:50:18 -0400 Received: by mail-lf1-f66.google.com with SMTP id w16-v6so2547605lfc.0 for ; Sat, 27 Oct 2018 00:10:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JMdBbkG8MyBAK38GN4xKX/1Er6iknpslCmJoKDCEZbc=; b=i8fCV4uoyKwWyXVj0I59Wcz07YGZRRabnoEgq9clAyJQX79xmL7bHXZGxN9PGWoCvE X9pt5D+I5bKxRlxWRAZMlojz4u2oyHu2jIMixELfhFW4wOcH+r8FGEFSxpRafI9MqVAF tu3U9VU6VPFirvsLU2iCmfgeCvP8YXyU72FQyMfuQ9aCOs3GoCvx4jU3HlO80zFVHY2H IxEw5wniDyPEXRzKsYpEBNmhqeCFiag0pueyEUHGgZC2dfnf0uRosk5uztuM4p1Ayvzz gnjssYZnctB0tu2SfziU1tST9+oXtjIZJlNQQfR1y21pYRe92RDuMkriV/7hQTG7Plkm xOHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JMdBbkG8MyBAK38GN4xKX/1Er6iknpslCmJoKDCEZbc=; b=UEechPwGcXwhLbA/nkTz5jC7HBXQRp2qcyS4qjDvrT6QKxpigWGWgnFg2mKPfG8TMK dS05rGlRrCX4C75E3z7F4FaDmJh1xak1jpzkBNn+4EtKkijvq/yxXsKCDdoajSxyqG++ l04OeaTVdz44QYbonoqYKer9wmgKL+Y2e1H6MMgbx1NusuyQKdbjOCHkRO0Qz8SHpClP HOacCRdQ43Fe/kaATzgVywFfZt3/gY/LsoEC6nG8GZbHNdkJFCiS7lzM1peyPw6eWYgH aeXDrBA0VfyiwxSg5ClCEFdhd7dbUG5OPKYIyYCXRK8etoKGL0LBCY18hhU4n2I7PC/6 VMaw== X-Gm-Message-State: AGRZ1gInH6FqSuY0blkEP65pzdnD3agBfBXRcokTcml1YNej4QoW6CT0 1aFaG08l6taLpOcP4FLABkrxZQuZ X-Google-Smtp-Source: AJdET5e+uSOyHNmMJqcDw+RxpurWaWmGyY3lxHDXJEh3l7NnkRS9f5Xz68sV9ZE5LTVPQ5YE2j8LSQ== X-Received: by 2002:a19:1019:: with SMTP id f25mr3820894lfi.54.1540624216412; Sat, 27 Oct 2018 00:10:16 -0700 (PDT) Received: from localhost.localdomain (c80-216-12-205.bredband.comhem.se. [80.216.12.205]) by smtp.gmail.com with ESMTPSA id r7-v6sm1534899ljr.21.2018.10.27.00.10.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 27 Oct 2018 00:10:15 -0700 (PDT) From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Ben Peart , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1?= =?utf-8?b?eQ==?= Subject: [PATCH 06/10] grep: remove #ifdef NO_PTHREADS Date: Sat, 27 Oct 2018 09:09:59 +0200 Message-Id: <20181027071003.1347-7-pclouds@gmail.com> X-Mailer: git-send-email 2.19.1.647.g708186aaf9 In-Reply-To: <20181027071003.1347-1-pclouds@gmail.com> References: <20181027071003.1347-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Nguyễn Thái Ngọc Duy --- builtin/grep.c | 58 +++++++++++++++++--------------------------------- grep.c | 6 ------ grep.h | 6 ------ 3 files changed, 20 insertions(+), 50 deletions(-) diff --git a/builtin/grep.c b/builtin/grep.c index d8508ddf79..29221e1003 100644 --- a/builtin/grep.c +++ b/builtin/grep.c @@ -34,7 +34,6 @@ static int recurse_submodules; #define GREP_NUM_THREADS_DEFAULT 8 static int num_threads; -#ifndef NO_PTHREADS static pthread_t *threads; /* We use one producer thread and THREADS consumer @@ -265,13 +264,6 @@ static int wait_all(void) return hit; } -#else /* !NO_PTHREADS */ - -static int wait_all(void) -{ - return 0; -} -#endif static int grep_cmd_config(const char *var, const char *value, void *cb) { @@ -284,8 +276,7 @@ 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) { + else if (!HAVE_THREADS && num_threads && num_threads != 1) { /* * TRANSLATORS: %s is the configuration * variable for tweaking threads, currently @@ -294,7 +285,6 @@ static int grep_cmd_config(const char *var, const char *value, void *cb) warning(_("no threads support, ignoring %s"), var); num_threads = 0; } -#endif } if (!strcmp(var, "submodule.recurse")) @@ -330,17 +320,14 @@ static int grep_oid(struct grep_opt *opt, const struct object_id *oid, grep_source_init(&gs, GREP_SOURCE_OID, pathbuf.buf, path, oid); strbuf_release(&pathbuf); -#ifndef NO_PTHREADS - if (num_threads) { + if (HAVE_THREADS && num_threads) { /* * add_work() copies gs and thus assumes ownership of * its fields, so do not call grep_source_clear() */ add_work(opt, &gs); return 0; - } else -#endif - { + } else { int hit; hit = grep_source(opt, &gs); @@ -363,17 +350,14 @@ static int grep_file(struct grep_opt *opt, const char *filename) grep_source_init(&gs, GREP_SOURCE_FILE, buf.buf, filename, filename); strbuf_release(&buf); -#ifndef NO_PTHREADS - if (num_threads) { + if (HAVE_THREADS && num_threads) { /* * add_work() copies gs and thus assumes ownership of * its fields, so do not call grep_source_clear() */ add_work(opt, &gs); return 0; - } else -#endif - { + } else { int hit; hit = grep_source(opt, &gs); @@ -1038,20 +1022,20 @@ int cmd_grep(int argc, const char **argv, const char *prefix) pathspec.recursive = 1; pathspec.recurse_submodules = !!recurse_submodules; -#ifndef NO_PTHREADS - if (list.nr || cached || show_in_pager) - num_threads = 0; - else if (num_threads == 0) - num_threads = GREP_NUM_THREADS_DEFAULT; - else if (num_threads < 0) - die(_("invalid number of threads specified (%d)"), num_threads); - if (num_threads == 1) + if (HAVE_THREADS) { + if (list.nr || cached || show_in_pager) + num_threads = 0; + else if (num_threads == 0) + num_threads = GREP_NUM_THREADS_DEFAULT; + else if (num_threads < 0) + die(_("invalid number of threads specified (%d)"), num_threads); + if (num_threads == 1) + num_threads = 0; + } else { + if (num_threads) + warning(_("no threads support, ignoring --threads")); num_threads = 0; -#else - if (num_threads) - warning(_("no threads support, ignoring --threads")); - num_threads = 0; -#endif + } if (!num_threads) /* @@ -1062,15 +1046,13 @@ int cmd_grep(int argc, const char **argv, const char *prefix) */ compile_grep_patterns(&opt); -#ifndef NO_PTHREADS - if (num_threads) { + if (HAVE_THREADS && num_threads) { if (!(opt.name_only || opt.unmatch_name_only || opt.count) && (opt.pre_context || opt.post_context || opt.file_break || opt.funcbody)) skip_first_line = 1; start_threads(&opt); } -#endif if (show_in_pager && (cached || list.nr)) die(_("--open-files-in-pager only works on the worktree")); @@ -1121,7 +1103,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix) hit = grep_objects(&opt, &pathspec, &list); } - if (num_threads) + if (HAVE_THREADS && num_threads) hit |= wait_all(); if (hit && show_in_pager) run_pager(&opt, prefix); diff --git a/grep.c b/grep.c index f6bd89e40b..4db1510d16 100644 --- a/grep.c +++ b/grep.c @@ -1513,7 +1513,6 @@ static void show_line(struct grep_opt *opt, char *bol, char *eol, } } -#ifndef NO_PTHREADS int grep_use_locks; /* @@ -1539,11 +1538,6 @@ static inline void grep_attr_unlock(void) */ pthread_mutex_t grep_read_mutex; -#else -#define grep_attr_lock() -#define grep_attr_unlock() -#endif - static int match_funcname(struct grep_opt *opt, struct grep_source *gs, char *bol, char *eol) { xdemitconf_t *xecfg = opt->priv; diff --git a/grep.h b/grep.h index 1a57d12b90..fb04893721 100644 --- a/grep.h +++ b/grep.h @@ -229,7 +229,6 @@ int grep_source(struct grep_opt *opt, struct grep_source *gs); 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! @@ -250,9 +249,4 @@ static inline void grep_read_unlock(void) pthread_mutex_unlock(&grep_read_mutex); } -#else -#define grep_read_lock() -#define grep_read_unlock() -#endif - #endif From patchwork Sat Oct 27 07:10:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10658261 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CE44C180E for ; Sat, 27 Oct 2018 07:10:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B3F0D2BE48 for ; Sat, 27 Oct 2018 07:10:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A83B72BEAB; Sat, 27 Oct 2018 07:10:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F9BD2BEBF for ; Sat, 27 Oct 2018 07:10:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728214AbeJ0PuT (ORCPT ); Sat, 27 Oct 2018 11:50:19 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:42672 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728013AbeJ0PuT (ORCPT ); Sat, 27 Oct 2018 11:50:19 -0400 Received: by mail-lj1-f195.google.com with SMTP id f3-v6so3165380ljk.9 for ; Sat, 27 Oct 2018 00:10:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=34AlMYInjUJvKBJ83Ba7wlLqRcceLi+ycsU6IviV8ho=; b=rgfgzMCZJLmM/Cp/LqUuJ5PgDmYBXj4bD4jTIh4+2DVkFmTaNpQYahiyfI99vHf92L +PIjSZHYXh1/OIOOfhSVJ4fZabipj9C9d3DpXHoAzdFm23Qdb6LYVPC0Zq5kyoShrNt+ pUnGuXm+r7Gm5fH3ef3WwqV8tFAi9izvRAwjFYAt1SzQcn9tSpBINHJPG2unfsEw0WxT biizS3VReKTLErYHd8VxfAlFH9x3h67h41XLOKTC0eYnchZreq79/lfi+gJ9/VXjMnSM XFL2k1kBHgvoS9miDVvWEPZfQm+EXNodspgc+FOrpVRoeqnlFrQPT8UCJZ8iOaKpo+Nk NQUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=34AlMYInjUJvKBJ83Ba7wlLqRcceLi+ycsU6IviV8ho=; b=N/KqHa4accu7yi/X1hQO+EZpQfjEvB9GAN1sevJyRX4G1nxcOUrQyaF9N2JkT20ejY eYjkSvv43K0tnnCRLNGwdYoR06U9f+XjQ/naTKyj3ObWiEjyXKqsJKicDP3CoDd1JxSz EGNQzFitdJseKZq0BEfQ+Jc4ZsEkae4zRN70OfJBCrXW7iltO8QtWLDd/JGCWF+4l0za UCZ1TKOK03kfVyX14ebJjGIPHDK/B+qSvJgy8QY1pG26sWxAsdAlVXuxXOv276GZ0Q05 JwxjNEKJj+55Otn73IgCxkc84GvUjUwnRJy0DlvK2amUQ8rA/WCx2bPXoZTcEil8yy6m Gv/w== X-Gm-Message-State: AGRZ1gLFOH5DwrwaD3Yo9FFI+GUtWA1pGTHExObX96r8+v4+H1oie3Fz 8r+9M7ri+rKwyGe0prEvbdaqIVyp X-Google-Smtp-Source: AJdET5dB+laE+wme4gPJcZjsOZnEB1gOn/7sk0YoH+3S+kU/G0iXWSUw10EHEQhlPuRvclIQgqqy8g== X-Received: by 2002:a2e:6503:: with SMTP id z3-v6mr3321555ljb.153.1540624217396; Sat, 27 Oct 2018 00:10:17 -0700 (PDT) Received: from localhost.localdomain (c80-216-12-205.bredband.comhem.se. [80.216.12.205]) by smtp.gmail.com with ESMTPSA id r7-v6sm1534899ljr.21.2018.10.27.00.10.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 27 Oct 2018 00:10:16 -0700 (PDT) From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Ben Peart , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1?= =?utf-8?b?eQ==?= Subject: [PATCH 07/10] preload-index.c: remove #ifdef NO_PTHREADS Date: Sat, 27 Oct 2018 09:10:00 +0200 Message-Id: <20181027071003.1347-8-pclouds@gmail.com> X-Mailer: git-send-email 2.19.1.647.g708186aaf9 In-Reply-To: <20181027071003.1347-1-pclouds@gmail.com> References: <20181027071003.1347-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Nguyễn Thái Ngọc Duy --- preload-index.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/preload-index.c b/preload-index.c index 9e7152ab14..0e24886aca 100644 --- a/preload-index.c +++ b/preload-index.c @@ -7,17 +7,7 @@ #include "fsmonitor.h" #include "config.h" #include "progress.h" - -#ifdef NO_PTHREADS -static void preload_index(struct index_state *index, - const struct pathspec *pathspec, - unsigned int refresh_flags) -{ - ; /* nothing */ -} -#else - -#include +#include "thread-utils.h" /* * Mostly randomly chosen maximum thread counts: we @@ -108,7 +98,7 @@ static void preload_index(struct index_state *index, struct thread_data data[MAX_PARALLEL]; struct progress_data pd; - if (!core_preload_index) + if (!HAVE_THREADS || !core_preload_index) return; threads = index->cache_nr / THREAD_COST; @@ -151,7 +141,6 @@ static void preload_index(struct index_state *index, trace_performance_leave("preload index"); } -#endif int read_index_preload(struct index_state *index, const struct pathspec *pathspec, From patchwork Sat Oct 27 07:10:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10658269 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BA67B14E2 for ; Sat, 27 Oct 2018 07:10:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A0A682BE48 for ; Sat, 27 Oct 2018 07:10:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 94D152BEA0; Sat, 27 Oct 2018 07:10:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 263E32BE48 for ; Sat, 27 Oct 2018 07:10:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728223AbeJ0PuV (ORCPT ); Sat, 27 Oct 2018 11:50:21 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:37879 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727844AbeJ0PuU (ORCPT ); Sat, 27 Oct 2018 11:50:20 -0400 Received: by mail-lf1-f65.google.com with SMTP id a82-v6so2523341lfa.4 for ; Sat, 27 Oct 2018 00:10:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SF0N9DVdrmmyoJxDZIeToLkpdB5o/uj/ao+EU7EKPtg=; b=SgvVDmMCwOWhNaE4AB4siPe17ulBLXRHXIsBEN0kqkt/rn5A0L+U/3vb+O09zFxcZ0 Ft+WUU28NHJUCUsqYA8MxgW2dCeW/h+2cPZgA2eTjisOXWaooAxwx/C8DLZbY1C5qgek fbxvwArWdN71Aex4ueuxndQMyfER9jJKer8KKc0UfewGKWtl8u/3sl/QipE+o+7NDDLl g5ZX9+P/NDpKZP6hIW3qa0np4f2Mz7xWvcFTcmXvkw4i9GMAqzGYsiNB543BDK+HoQvh IzPnL9iZlcjfaC6UyLP5Sou743m+VXD+0jmK/ERZRvgfjR5+ibxb8PyCVwSctdZBYivl Xwiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SF0N9DVdrmmyoJxDZIeToLkpdB5o/uj/ao+EU7EKPtg=; b=o9LpPJj6FGeKozKiSl25oUgr0hh8aPN86rxuyFkD3IBel9OIcijTCHUYV65KHjGnI+ tKxauKrP354Bfx0Z8KVYb1ok9z2jk9L5EJ/WUMdPyopxpyXVKEzzK69fhZMJULgBJ0c6 bUJ4EBpwt3+N6S+vlh7nnbF4Ix8Sgw2ZWn7hEEHb3QpE33qNuWmZ8Ec7dY/E8SQMpvWk M2CPWzy2DdfP4saVyKAfRobUOueLemxaOQhyBnCPi/as22D5RA9h6qoB0OS1r0DGHv2W jC7UFcOa8Dewnv7hsUCbcYBI0lsTcG7C3xwWojYMgk4+JZ7HRPxr1qECkro6To4t86Ij yVdA== X-Gm-Message-State: AGRZ1gK9yf9cVU9+G12R7fzz/Rtupidqn7OVb0XfmxHJwRKhh61PnuEo A+M794mSnN3zq4gQ71mzdVoJdPV8 X-Google-Smtp-Source: AJdET5ffhGOEW1riHtgtCV4Q16l+9+VKmyO4Vp9fHwKc6KuDKftgp6JCSbmelCUJzCUHorXjIa5FPw== X-Received: by 2002:a19:54d7:: with SMTP id b84mr767770lfl.131.1540624218597; Sat, 27 Oct 2018 00:10:18 -0700 (PDT) Received: from localhost.localdomain (c80-216-12-205.bredband.comhem.se. [80.216.12.205]) by smtp.gmail.com with ESMTPSA id r7-v6sm1534899ljr.21.2018.10.27.00.10.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 27 Oct 2018 00:10:17 -0700 (PDT) From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Ben Peart , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1?= =?utf-8?b?eQ==?= Subject: [PATCH 08/10] pack-objects: remove #ifdef NO_PTHREADS Date: Sat, 27 Oct 2018 09:10:01 +0200 Message-Id: <20181027071003.1347-9-pclouds@gmail.com> X-Mailer: git-send-email 2.19.1.647.g708186aaf9 In-Reply-To: <20181027071003.1347-1-pclouds@gmail.com> References: <20181027071003.1347-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Nguyễn Thái Ngọc Duy --- builtin/pack-objects.c | 26 ++------------------------ pack-objects.h | 6 ------ 2 files changed, 2 insertions(+), 30 deletions(-) diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index b059b86aee..12edd6da16 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -1953,8 +1953,6 @@ static int delta_cacheable(unsigned long src_size, unsigned long trg_size, return 0; } -#ifndef NO_PTHREADS - /* Protect access to object database */ static pthread_mutex_t read_mutex; #define read_lock() pthread_mutex_lock(&read_mutex) @@ -1979,16 +1977,6 @@ static pthread_mutex_t progress_mutex; * ahead in the list because they can be stolen and would need * progress_mutex for protection. */ -#else - -#define read_lock() (void)0 -#define read_unlock() (void)0 -#define cache_lock() (void)0 -#define cache_unlock() (void)0 -#define progress_lock() (void)0 -#define progress_unlock() (void)0 - -#endif /* * Return the size of the object without doing any delta @@ -2347,8 +2335,6 @@ static void find_deltas(struct object_entry **list, unsigned *list_size, free(array); } -#ifndef NO_PTHREADS - static void try_to_free_from_threads(size_t size) { read_lock(); @@ -2578,10 +2564,6 @@ static void ll_find_deltas(struct object_entry **list, unsigned list_size, free(p); } -#else -#define ll_find_deltas(l, s, w, d, p) find_deltas(l, &s, w, d, p) -#endif - static void add_tag_chain(const struct object_id *oid) { struct tag *tag; @@ -2734,12 +2716,10 @@ static int git_pack_config(const char *k, const char *v, void *cb) if (delta_search_threads < 0) die(_("invalid number of threads specified (%d)"), delta_search_threads); -#ifdef NO_PTHREADS - if (delta_search_threads != 1) { + if (!HAVE_THREADS && delta_search_threads != 1) { warning(_("no threads support, ignoring %s"), k); delta_search_threads = 0; } -#endif return 0; } if (!strcmp(k, "pack.indexversion")) { @@ -3402,10 +3382,8 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix) if (!delta_search_threads) /* --threads=0 means autodetect */ delta_search_threads = online_cpus(); -#ifdef NO_PTHREADS - if (delta_search_threads != 1) + if (!HAVE_THREADS && delta_search_threads != 1) warning(_("no threads support, ignoring --threads")); -#endif if (!pack_to_stdout && !pack_size_limit) pack_size_limit = pack_size_limit_cfg; if (pack_to_stdout && pack_size_limit) diff --git a/pack-objects.h b/pack-objects.h index 2ca39cfcfe..3a42727c7d 100644 --- a/pack-objects.h +++ b/pack-objects.h @@ -145,9 +145,7 @@ struct packing_data { struct packed_git **in_pack_by_idx; struct packed_git **in_pack; -#ifndef NO_PTHREADS pthread_mutex_t lock; -#endif /* * This list contains entries for bases which we know the other side @@ -169,15 +167,11 @@ void prepare_packing_data(struct packing_data *pdata); static inline void packing_data_lock(struct packing_data *pdata) { -#ifndef NO_PTHREADS pthread_mutex_lock(&pdata->lock); -#endif } static inline void packing_data_unlock(struct packing_data *pdata) { -#ifndef NO_PTHREADS pthread_mutex_unlock(&pdata->lock); -#endif } struct object_entry *packlist_alloc(struct packing_data *pdata, From patchwork Sat Oct 27 07:10:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10658271 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 456F9180E for ; Sat, 27 Oct 2018 07:10:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 273532BE94 for ; Sat, 27 Oct 2018 07:10:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1BA482BEA3; Sat, 27 Oct 2018 07:10:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8BD232BE9B for ; Sat, 27 Oct 2018 07:10:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728233AbeJ0PuV (ORCPT ); Sat, 27 Oct 2018 11:50:21 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:34508 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728013AbeJ0PuV (ORCPT ); Sat, 27 Oct 2018 11:50:21 -0400 Received: by mail-lj1-f196.google.com with SMTP id g8-v6so274245ljk.1 for ; Sat, 27 Oct 2018 00:10:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xLCcqTzF++H24RbkSBiziTtVjx4je/Bxw9RWY3pqi9k=; b=L7sQ5hvAJUa6h1AGH5UQGZLw3GpZj8f3TTuio2uDvpZoWXVs7zNE8n7aRKbkX7OtOa su5BwLg2ICUI9CKaJ/NWZkCNmT4fnEK7f90RdZ1clCgTTih1KKca5XY75k08pgESxcEZ 19FR5Yb+XL5RJ3ozdMlCMkB4wO9YniJfTPolytZBmrjOK67ZfL4EDBtq99rF7cFRadZ2 tCuQWzCm9JbCRcNljfbixaehn5gPgy04GbQapshzT8diLG9vo2Bor65uhVV8Ha7tnLGJ PQj5SH+hdMnehUQLPZrLUoTHfJcy7GJAfYEEpU4IY3fHhlI87sD5LqoxHd4sN5m/Kq1E w39w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xLCcqTzF++H24RbkSBiziTtVjx4je/Bxw9RWY3pqi9k=; b=DhBYCDsvX6Q2JivTVQQ3Rm4XVNyq5dJi9ukc8LWbRawioM5OXCeIyxTDFdGGbD1hmI 2+2hp+x07Qo3fhcCFELjDPg6X4wjbrNHSuUaMJOQFQTtWSZ2uU7LOUN4kXTFD9Tosy2S 3bB10MRa42BwN0W9Czw3MATiCwFqsuBkTeXrQdxZpwB2c+sBbRzCUZhbpYZcA6wPIZVT pJztTuT0XvfzVnrcvJCSnCpRG1wegEvoeQ9EbwGEM9JFk1vajebSN27A7kA1Zr3992uM eaVAapPLmR9d0aSpaJTUjvfLedKL2KyRUj+vs+SuXx9hRJjh/5aaviaT9Fyq9Xv6UpDx xFcg== X-Gm-Message-State: AGRZ1gJt8lu84+qU7wHbuZ+RsoB0YucQ6Mysa7uaYZ6pvC01AHDKszbS uy3kayLfwBadXnG+1SsYsOde9VSJ X-Google-Smtp-Source: AJdET5ch1+YlXHJ91Z36StEwDOgOXPLxKeituMM8MkjfFxCUOUQRBI4Uosz73oRC9YIbTO5HPKxfsw== X-Received: by 2002:a2e:5816:: with SMTP id m22-v6mr1356315ljb.177.1540624219611; Sat, 27 Oct 2018 00:10:19 -0700 (PDT) Received: from localhost.localdomain (c80-216-12-205.bredband.comhem.se. [80.216.12.205]) by smtp.gmail.com with ESMTPSA id r7-v6sm1534899ljr.21.2018.10.27.00.10.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 27 Oct 2018 00:10:18 -0700 (PDT) From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Ben Peart , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1?= =?utf-8?b?eQ==?= Subject: [PATCH 09/10] read-cache.c: remove #ifdef NO_PTHREADS Date: Sat, 27 Oct 2018 09:10:02 +0200 Message-Id: <20181027071003.1347-10-pclouds@gmail.com> X-Mailer: git-send-email 2.19.1.647.g708186aaf9 In-Reply-To: <20181027071003.1347-1-pclouds@gmail.com> References: <20181027071003.1347-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Nguyễn Thái Ngọc Duy --- read-cache.c | 49 ++++++++++++++++++------------------------------- 1 file changed, 18 insertions(+), 31 deletions(-) diff --git a/read-cache.c b/read-cache.c index d57958233e..ba870bc3fd 100644 --- a/read-cache.c +++ b/read-cache.c @@ -1920,19 +1920,15 @@ struct index_entry_offset_table struct index_entry_offset entries[FLEX_ARRAY]; }; -#ifndef NO_PTHREADS static struct index_entry_offset_table *read_ieot_extension(const char *mmap, size_t mmap_size, size_t offset); static void write_ieot_extension(struct strbuf *sb, struct index_entry_offset_table *ieot); -#endif static size_t read_eoie_extension(const char *mmap, size_t mmap_size); static void write_eoie_extension(struct strbuf *sb, git_hash_ctx *eoie_context, size_t offset); struct load_index_extensions { -#ifndef NO_PTHREADS pthread_t pthread; -#endif struct index_state *istate; const char *mmap; size_t mmap_size; @@ -2010,8 +2006,6 @@ static unsigned long load_all_cache_entries(struct index_state *istate, return consumed; } -#ifndef NO_PTHREADS - /* * Mostly randomly chosen maximum thread counts: we * cap the parallelism to online_cpus() threads, and we want @@ -2122,7 +2116,6 @@ static unsigned long load_cache_entries_threaded(struct index_state *istate, con return consumed; } -#endif /* remember to discard_cache() before reading a different cache! */ int do_read_index(struct index_state *istate, const char *path, int must_exist) @@ -2135,10 +2128,8 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist) size_t mmap_size; struct load_index_extensions p; size_t extension_offset = 0; -#ifndef NO_PTHREADS int nr_threads, cpus; struct index_entry_offset_table *ieot = NULL; -#endif if (istate->initialized) return istate->cache_nr; @@ -2181,15 +2172,18 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist) src_offset = sizeof(*hdr); -#ifndef NO_PTHREADS - nr_threads = git_config_get_index_threads(); + if (HAVE_THREADS) { + nr_threads = git_config_get_index_threads(); - /* TODO: does creating more threads than cores help? */ - if (!nr_threads) { - nr_threads = istate->cache_nr / THREAD_COST; - cpus = online_cpus(); - if (nr_threads > cpus) - nr_threads = cpus; + /* TODO: does creating more threads than cores help? */ + if (!nr_threads) { + nr_threads = istate->cache_nr / THREAD_COST; + cpus = online_cpus(); + if (nr_threads > cpus) + nr_threads = cpus; + } + } else { + nr_threads = 1; } if (nr_threads > 1) { @@ -2219,21 +2213,16 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist) } else { src_offset += load_all_cache_entries(istate, mmap, mmap_size, src_offset); } -#else - src_offset += load_all_cache_entries(istate, mmap, mmap_size, src_offset); -#endif istate->timestamp.sec = st.st_mtime; istate->timestamp.nsec = ST_MTIME_NSEC(st); /* if we created a thread, join it otherwise load the extensions on the primary thread */ -#ifndef NO_PTHREADS - if (extension_offset) { + if (HAVE_THREADS && extension_offset) { int ret = pthread_join(p.pthread, NULL); if (ret) die(_("unable to join load_index_extensions thread: %s"), strerror(ret)); } -#endif if (!extension_offset) { p.src_offset = src_offset; load_index_extensions(&p); @@ -2756,8 +2745,11 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile, if (ce_write(&c, newfd, &hdr, sizeof(hdr)) < 0) return -1; -#ifndef NO_PTHREADS - nr_threads = git_config_get_index_threads(); + if (HAVE_THREADS) + nr_threads = git_config_get_index_threads(); + else + nr_threads = 1; + if (nr_threads != 1) { int ieot_blocks, cpus; @@ -2787,7 +2779,6 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile, ieot_entries = DIV_ROUND_UP(entries, ieot_blocks); } } -#endif offset = lseek(newfd, 0, SEEK_CUR); if (offset < 0) { @@ -2871,8 +2862,7 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile, * strip_extensions parameter as we need it when loading the shared * index. */ -#ifndef NO_PTHREADS - if (ieot) { + if (HAVE_THREADS && ieot) { struct strbuf sb = STRBUF_INIT; write_ieot_extension(&sb, ieot); @@ -2883,7 +2873,6 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile, if (err) return -1; } -#endif if (!strip_extensions && istate->split_index) { struct strbuf sb = STRBUF_INIT; @@ -3469,7 +3458,6 @@ static void write_eoie_extension(struct strbuf *sb, git_hash_ctx *eoie_context, strbuf_add(sb, hash, the_hash_algo->rawsz); } -#ifndef NO_PTHREADS #define IEOT_VERSION (1) static struct index_entry_offset_table *read_ieot_extension(const char *mmap, size_t mmap_size, size_t offset) @@ -3542,4 +3530,3 @@ static void write_ieot_extension(struct strbuf *sb, struct index_entry_offset_ta strbuf_add(sb, &buffer, sizeof(uint32_t)); } } -#endif From patchwork Sat Oct 27 07:10:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10658273 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5B4A613BF for ; Sat, 27 Oct 2018 07:10:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 417272BE48 for ; Sat, 27 Oct 2018 07:10:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2B4AF2BEA0; Sat, 27 Oct 2018 07:10:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B69A52BE48 for ; Sat, 27 Oct 2018 07:10:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728237AbeJ0PuX (ORCPT ); Sat, 27 Oct 2018 11:50:23 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:33091 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727844AbeJ0PuW (ORCPT ); Sat, 27 Oct 2018 11:50:22 -0400 Received: by mail-lf1-f67.google.com with SMTP id w16-v6so2547660lfc.0 for ; Sat, 27 Oct 2018 00:10:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6Qk+6dxMRf1uSVCWaRLkgpXbfUTW045jwm0hjrNlab0=; b=KNwGxpWP+j+Uy89vTmi2OfXLFJ9iK/BhZ3AGZ2GwMi1BzqFG6LrwOj9PTWC5DUaCkq CKnDSYiNfWkMMG30OoRpUQGNqVJ0Qw0EZrjsI6G3gf2qsSHF2KvFqmgrdzpTK1U4fjTx SCqZN+S69bzqaMsuPsB/NLM/3NIwAmtRJSdFs9HAAwbGNxg9x6Fuz0l0uUOEiJ9EwOWP m/ZOyL8w6ztdht52wAe9TXCGpPXJ5hh0lqBJC6ERcrc0kY0ow8aYSeLzYuWRLB+HlIIL s7IquuuSxsYPMR3ga9W3jILWnYi4lNLSBHRc4wbumlnb8kUPKCaQW1aIYdId027LmTEN 48kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6Qk+6dxMRf1uSVCWaRLkgpXbfUTW045jwm0hjrNlab0=; b=NA6TJWDhtLksCP7at+CrANCHxZhlwgfzZp/piCLFy+nAxTLkUAo8g5oEQTWT4kL187 hv1e4TZDYkByAvWjIYLK32ausE11f/t7hfoh/Q9YtZZnoU7MtSJJ6DAG12+LDPkIPY2j OD7UF3ZkW8RQJVQnGEXteqvWxfJ9mKX6YlN5PJEZJ7khBuG+3j/JWfWjmXGMzYIVPP22 OL0BxOUtC8OgdRViU+0mt3+KuMt4iRzJxdU/S/+jBYp+N+PWYTW+XjE3sjNBIhIhdNAd Q4K9lmvvBY7nUG7CLx2EDzIqii6fxqqa9oBokmceTr4AW7VOu5W6ODjb9JfsiLyLSlFu FpLA== X-Gm-Message-State: AGRZ1gJD+To4Yg769c6c4u9yKAdwvYZr9Tjlk42p7EfseBAr6VtOyvBw +1OJYdddUuY7bweyEJcrOi6tVZJn X-Google-Smtp-Source: AJdET5dfzCRyvJNylybm+mSiVIR7HIu2+z/ynbnd/aCR00aII380WWOEBg14Hm7pZudGGDdspPCuiw== X-Received: by 2002:a19:5154:: with SMTP id f81mr4093331lfb.96.1540624220686; Sat, 27 Oct 2018 00:10:20 -0700 (PDT) Received: from localhost.localdomain (c80-216-12-205.bredband.comhem.se. [80.216.12.205]) by smtp.gmail.com with ESMTPSA id r7-v6sm1534899ljr.21.2018.10.27.00.10.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 27 Oct 2018 00:10:19 -0700 (PDT) From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , Ben Peart , =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1?= =?utf-8?b?eQ==?= Subject: [PATCH 10/10] Clean up pthread_create() error handling Date: Sat, 27 Oct 2018 09:10:03 +0200 Message-Id: <20181027071003.1347-11-pclouds@gmail.com> X-Mailer: git-send-email 2.19.1.647.g708186aaf9 In-Reply-To: <20181027071003.1347-1-pclouds@gmail.com> References: <20181027071003.1347-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Normally pthread_create() rarely fails and sometimes error handling can be neglected. But with new pthreads wrapper, pthread_create() will return ENOSYS on a system without thread support. Threaded code _is_ protected by HAVE_THREADS and pthread_create() should never run in the first place. But the situation could change in the future and bugs may sneak in. Make sure that all pthread_create() checks and handles the result. While at there, mark these strings for translation if they aren't. Signed-off-by: Nguyễn Thái Ngọc Duy --- name-hash.c | 16 ++++++++++------ preload-index.c | 8 ++++++-- run-command.c | 2 +- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/name-hash.c b/name-hash.c index b3c9ac791d..623ca6923a 100644 --- a/name-hash.c +++ b/name-hash.c @@ -494,6 +494,7 @@ static inline void lazy_update_dir_ref_counts( static void threaded_lazy_init_name_hash( struct index_state *istate) { + int err; int nr_each; int k_start; int t; @@ -526,8 +527,9 @@ static void threaded_lazy_init_name_hash( if (k_start > istate->cache_nr) k_start = istate->cache_nr; td_dir_t->k_end = k_start; - if (pthread_create(&td_dir_t->pthread, NULL, lazy_dir_thread_proc, td_dir_t)) - die("unable to create lazy_dir_thread"); + err = pthread_create(&td_dir_t->pthread, NULL, lazy_dir_thread_proc, td_dir_t); + if (err) + die(_("unable to create lazy_dir thread: %s"), strerror(err)); } for (t = 0; t < lazy_nr_dir_threads; t++) { struct lazy_dir_thread_data *td_dir_t = td_dir + t; @@ -547,13 +549,15 @@ static void threaded_lazy_init_name_hash( */ td_name->istate = istate; td_name->lazy_entries = lazy_entries; - if (pthread_create(&td_name->pthread, NULL, lazy_name_thread_proc, td_name)) - die("unable to create lazy_name_thread"); + err = pthread_create(&td_name->pthread, NULL, lazy_name_thread_proc, td_name); + if (err) + die(_("unable to create lazy_name thread: %s"), strerror(err)); lazy_update_dir_ref_counts(istate, lazy_entries); - if (pthread_join(td_name->pthread, NULL)) - die("unable to join lazy_name_thread"); + err = pthread_join(td_name->pthread, NULL); + if (err) + die(_("unable to join lazy_name thread: %s"), strerror(err)); cleanup_dir_mutex(); diff --git a/preload-index.c b/preload-index.c index 0e24886aca..ddca1c216e 100644 --- a/preload-index.c +++ b/preload-index.c @@ -121,6 +121,8 @@ static void preload_index(struct index_state *index, for (i = 0; i < threads; i++) { struct thread_data *p = data+i; + int err; + p->index = index; if (pathspec) copy_pathspec(&p->pathspec, pathspec); @@ -129,8 +131,10 @@ static void preload_index(struct index_state *index, if (pd.progress) p->progress = &pd; offset += work; - if (pthread_create(&p->pthread, NULL, preload_thread, p)) - die("unable to create threaded lstat"); + err = pthread_create(&p->pthread, NULL, preload_thread, p); + + if (err) + die(_("unable to create threaded lstat: %s"), strerror(err)); } for (i = 0; i < threads; i++) { struct thread_data *p = data+i; diff --git a/run-command.c b/run-command.c index 84b883c213..26154ba257 100644 --- a/run-command.c +++ b/run-command.c @@ -1213,7 +1213,7 @@ int start_async(struct async *async) { int err = pthread_create(&async->tid, NULL, run_thread, async); if (err) { - error_errno("cannot create thread"); + error(_("cannot create async thread: %s"), strerror(err)); goto error; } }