git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mike Ralphson <mike@abacus.co.uk>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Mike Ralphson <mike.ralphson@gmail.com>,
	j.sixt@viscovery.net
Subject: [PATCH] Makefile: introduce NO_PTHREADS
Date: Mon,  1 Dec 2008 16:13:25 +0000	[thread overview]
Message-ID: <1228148005-9404-1-git-send-email-mike@abacus.co.uk> (raw)
In-Reply-To: <4933A058.3050101@viscovery.net>

From: Junio C Hamano <gitster@pobox.com>

 This introduces make variable NO_PTHREADS for platforms that lack the
 support for pthreads library or people who do not want to use it for
 whatever reason.  When defined, it makes the multi-threaded index
 preloading into a no-op, and also disables threaded delta searching by
 pack-objects.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Mike Ralphson <mike@abacus.co.uk>
---

* I notice a handful platforms do not define THREADED_DELTA_SEARCH, and
 on them Linus's preload-index.c is the first source file that includes
 <pthreads.h>, which may result in breakages.

 Made the default for AIX <5 and Mingw

 With correct commit message. Sorry for the previous attempt.

 Makefile        |   17 ++++++++++++++++-
 config.mak.in   |    1 +
 configure.ac    |    5 +++++
 preload-index.c |    9 +++++++++
 4 files changed, 31 insertions(+), 1 deletions(-)

diff --git a/Makefile b/Makefile
index d1e2116..5a69a41 100644
--- a/Makefile
+++ b/Makefile
@@ -90,6 +90,8 @@ all::
 #
 # Define NO_MMAP if you want to avoid mmap.
 #
+# Define NO_PTHREADS if you do not have or do not want to use Pthreads.
+#
 # Define NO_PREAD if you have a problem with pread() system call (e.g.
 # cygwin.dll before v1.5.22).
 #
@@ -164,6 +166,7 @@ uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
 uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
 uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
 uname_P := $(shell sh -c 'uname -p 2>/dev/null || echo not')
+uname_V := $(shell sh -c 'uname -v 2>/dev/null || echo not')
 
 # CFLAGS and LDFLAGS are for the users to override from the command line.
 
@@ -722,6 +725,11 @@ ifeq ($(uname_S),AIX)
 	INTERNAL_QSORT = UnfortunatelyYes
 	NEEDS_LIBICONV=YesPlease
 	BASIC_CFLAGS += -D_LARGE_FILES
+	ifneq ($(shell expr "$(uname_V)" : '[1234]'),1)
+		THREADED_DELTA_SEARCH = YesPlease
+	else
+		NO_PTHREADS = YesPlease
+	endif
 endif
 ifeq ($(uname_S),GNU)
 	# GNU/Hurd
@@ -766,6 +774,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))
 	NO_STRCASESTR = YesPlease
 	NO_STRLCPY = YesPlease
 	NO_MEMMEM = YesPlease
+	NO_PTHREADS = YesPlease
 	NEEDS_LIBICONV = YesPlease
 	OLD_ICONV = YesPlease
 	NO_C99_FORMAT = YesPlease
@@ -1017,9 +1026,15 @@ ifdef INTERNAL_QSORT
 	COMPAT_OBJS += compat/qsort.o
 endif
 
+ifdef NO_PTHREADS
+	THREADED_DELTA_SEARCH =
+	BASIC_CFLAGS += -DNO_PTHREADS
+else
+	EXTLIBS += $(PTHREAD_LIBS)
+endif
+
 ifdef THREADED_DELTA_SEARCH
 	BASIC_CFLAGS += -DTHREADED_DELTA_SEARCH
-	EXTLIBS += $(PTHREAD_LIBS)
 	LIB_OBJS += thread-utils.o
 endif
 ifdef DIR_HAS_BSD_GROUP_SEMANTICS
diff --git a/config.mak.in b/config.mak.in
index ea7705c..14dfb21 100644
--- a/config.mak.in
+++ b/config.mak.in
@@ -51,4 +51,5 @@ OLD_ICONV=@OLD_ICONV@
 NO_DEFLATE_BOUND=@NO_DEFLATE_BOUND@
 FREAD_READS_DIRECTORIES=@FREAD_READS_DIRECTORIES@
 SNPRINTF_RETURNS_BOGUS=@SNPRINTF_RETURNS_BOGUS@
+NO_PTHREADS=@NO_PTHREADS@
 PTHREAD_LIBS=@PTHREAD_LIBS@
diff --git a/configure.ac b/configure.ac
index 4256742..8821b50 100644
--- a/configure.ac
+++ b/configure.ac
@@ -490,6 +490,8 @@ AC_SUBST(NO_MKDTEMP)
 # Define NO_SYMLINK_HEAD if you never want .git/HEAD to be a symbolic link.
 # Enable it on Windows.  By default, symrefs are still used.
 #
+# Define NO_PTHREADS if we do not have pthreads
+#
 # Define PTHREAD_LIBS to the linker flag used for Pthread support.
 AC_LANG_CONFTEST([AC_LANG_PROGRAM(
   [[#include <pthread.h>]],
@@ -502,9 +504,12 @@ else
  ${CC} -lpthread conftest.c -o conftest.o > /dev/null 2>&1
  if test $? -eq 0;then
   PTHREAD_LIBS="-lpthread"
+ else
+  NO_PTHREADS=UnfortunatelyYes
  fi
 fi
 AC_SUBST(PTHREAD_LIBS)
+AC_SUBST(NO_PTHREADS)
 
 ## Site configuration (override autodetection)
 ## --with-PACKAGE[=ARG] and --without-PACKAGE
diff --git a/preload-index.c b/preload-index.c
index a685583..88edc5f 100644
--- a/preload-index.c
+++ b/preload-index.c
@@ -2,6 +2,14 @@
  * Copyright (C) 2008 Linus Torvalds
  */
 #include "cache.h"
+
+#ifdef NO_PTHREADS
+static void preload_index(struct index_state *index, const char **pathspec)
+{
+	; /* nothing */
+}
+#else
+
 #include <pthread.h>
 
 /*
@@ -81,6 +89,7 @@ static void preload_index(struct index_state *index, const char **pathspec)
 			die("unable to join threaded lstat");
 	}
 }
+#endif
 
 int read_index_preload(struct index_state *index, const char **pathspec)
 {
-- 
1.6.0.2.229.g1293c.dirty

  parent reply	other threads:[~2008-12-01 16:31 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-12  9:29 hosting git on a nfs Thomas Koch
2008-11-12 10:10 ` Julian Phillips
2008-11-12 20:31   ` Brandon Casey
2008-11-12 17:36 ` David Brown
2008-11-12 18:14   ` Linus Torvalds
2008-11-13 18:18     ` J. Bruce Fields
2008-11-13 18:32     ` James Pickens
2008-11-13 20:18       ` Linus Torvalds
2008-11-13 21:05         ` Linus Torvalds
2008-11-13 23:23           ` James Pickens
2008-11-13 23:48             ` Linus Torvalds
2008-11-13 23:23           ` Julian Phillips
2008-11-13 23:42           ` Linus Torvalds
2008-11-14  0:04             ` Julian Phillips
2008-11-14  0:14             ` Brandon Casey
2008-11-14  0:38               ` Linus Torvalds
2008-11-14  0:59                 ` Pieter de Bie
2008-11-14  1:15                 ` Linus Torvalds
2008-11-14  3:33                   ` James Pickens
2008-11-14  5:01                     ` Linus Torvalds
2008-11-14 13:01                   ` Michael J Gruber
2008-11-14 14:31                   ` Kyle Moffett
2008-11-14 18:32                   ` Brandon Casey
2008-11-14 19:23                     ` Linus Torvalds
2008-11-14 20:14                       ` Junio C Hamano
2008-11-14 23:10                         ` Linus Torvalds
2008-11-15 12:08                       ` [PATCH] Makefile: introduce NO_PTHREADS Junio C Hamano
2008-11-15 17:15                         ` Linus Torvalds
2008-11-17 10:03                           ` Mike Ralphson
2008-11-17 10:18                             ` Junio C Hamano
2008-11-17 10:34                             ` Johannes Sixt
2008-11-17 10:45                               ` Mike Ralphson
2008-11-17 11:25                                 ` Johannes Sixt
2008-12-01  8:29                                   ` Johannes Sixt
2008-12-01  8:48                                     ` dhruva
2008-12-01  9:57                                     ` Mike Ralphson
2008-12-01 16:09                                     ` Mike Ralphson
2008-12-01 16:13                                     ` Mike Ralphson [this message]
2008-12-02  7:41                                       ` Johannes Sixt
2008-12-03  2:18                                         ` Junio C Hamano
2008-11-17 16:38                           ` Junio C Hamano
2008-11-17 16:47                             ` Linus Torvalds
2008-11-17 17:01                               ` Fix index preloading for racy dirty case Linus Torvalds
2008-11-17 16:41                           ` [PATCH] Makefile: introduce NO_PTHREADS Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1228148005-9404-1-git-send-email-mike@abacus.co.uk \
    --to=mike@abacus.co.uk \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=j.sixt@viscovery.net \
    --cc=mike.ralphson@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).