Makefile: introduce NO_PTHREADS
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: Mike Ralphson <mike@abacus.co.uk> Tested-by: Johannes Sixt <j6t@kdbg.org> (AIX 4.3.x) Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Nov 15, 2008 at 04:08 UTC
46059cc63259f7a3d408fc1e52e8da9d37dc49ff
4 files changed
+31
-1
Makefile
+16
-1
@@ -90,6 +90,8 @@ all::
90
#
91
# Define NO_MMAP if you want to avoid mmap.
92
#
93
+# Define NO_PTHREADS if you do not have or do not want to use Pthreads.
94
+#
95
# Define NO_PREAD if you have a problem with pread() system call (e.g.
96
# cygwin.dll before v1.5.22).
97
#
@@ -164,6 +166,7 @@ uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
166
uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
167
uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
168
uname_P := $(shell sh -c 'uname -p 2>/dev/null || echo not')
169
+uname_V := $(shell sh -c 'uname -v 2>/dev/null || echo not')
170
171
# CFLAGS and LDFLAGS are for the users to override from the command line.
172
@@ -722,6 +725,11 @@ ifeq ($(uname_S),AIX)
725
INTERNAL_QSORT = UnfortunatelyYes
726
NEEDS_LIBICONV=YesPlease
727
BASIC_CFLAGS += -D_LARGE_FILES
728
+ ifneq ($(shell expr "$(uname_V)" : '[1234]'),1)
729
+ THREADED_DELTA_SEARCH = YesPlease
730
+ else
731
+ NO_PTHREADS = YesPlease
732
+ endif
733
endif
734
ifeq ($(uname_S),GNU)
735
# GNU/Hurd
@@ -766,6 +774,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))
774
NO_STRCASESTR = YesPlease
775
NO_STRLCPY = YesPlease
776
NO_MEMMEM = YesPlease
777
+ NO_PTHREADS = YesPlease
778
NEEDS_LIBICONV = YesPlease
779
OLD_ICONV = YesPlease
780
NO_C99_FORMAT = YesPlease
@@ -1017,9 +1026,15 @@ ifdef INTERNAL_QSORT
1026
COMPAT_OBJS += compat/qsort.o
1027
endif
1028
1029
+ifdef NO_PTHREADS
1030
+ THREADED_DELTA_SEARCH =
1031
+ BASIC_CFLAGS += -DNO_PTHREADS
1032
+else
1033
+ EXTLIBS += $(PTHREAD_LIBS)
1034
+endif
1035
+
1036
ifdef THREADED_DELTA_SEARCH
1037
BASIC_CFLAGS += -DTHREADED_DELTA_SEARCH
1022
- EXTLIBS += $(PTHREAD_LIBS)
1038
LIB_OBJS += thread-utils.o
1039
endif
1040
ifdef DIR_HAS_BSD_GROUP_SEMANTICS
config.mak.in
+1
@@ -51,4 +51,5 @@ OLD_ICONV=@OLD_ICONV@
51
NO_DEFLATE_BOUND=@NO_DEFLATE_BOUND@
52
FREAD_READS_DIRECTORIES=@FREAD_READS_DIRECTORIES@
53
SNPRINTF_RETURNS_BOGUS=@SNPRINTF_RETURNS_BOGUS@
54
+NO_PTHREADS=@NO_PTHREADS@
55
PTHREAD_LIBS=@PTHREAD_LIBS@
configure.ac
+5
@@ -490,6 +490,8 @@ AC_SUBST(NO_MKDTEMP)
490
# Define NO_SYMLINK_HEAD if you never want .git/HEAD to be a symbolic link.
491
# Enable it on Windows. By default, symrefs are still used.
492
#
493
+# Define NO_PTHREADS if we do not have pthreads
494
+#
495
# Define PTHREAD_LIBS to the linker flag used for Pthread support.
496
AC_LANG_CONFTEST([AC_LANG_PROGRAM(
497
[[#include <pthread.h>]],
@@ -502,9 +504,12 @@ else
504
${CC} -lpthread conftest.c -o conftest.o > /dev/null 2>&1
505
if test $? -eq 0;then
506
PTHREAD_LIBS="-lpthread"
507
+ else
508
+ NO_PTHREADS=UnfortunatelyYes
509
fi
510
fi
511
AC_SUBST(PTHREAD_LIBS)
512
+AC_SUBST(NO_PTHREADS)
513
514
## Site configuration (override autodetection)
515
## --with-PACKAGE[=ARG] and --without-PACKAGE
preload-index.c
+9
@@ -2,6 +2,14 @@
2
* Copyright (C) 2008 Linus Torvalds
3
*/
4
#include "cache.h"
5
+
6
+#ifdef NO_PTHREADS
7
+static void preload_index(struct index_state *index, const char **pathspec)
8
+{
9
+ ; /* nothing */
10
+}
11
+#else
12
+
13
#include <pthread.h>
14
15
/*
@@ -81,6 +89,7 @@ static void preload_index(struct index_state *index, const char **pathspec)
89
die("unable to join threaded lstat");
90
}
91
}
92
+#endif
93
94
int read_index_preload(struct index_state *index, const char **pathspec)
95
{