提交 46059cc6 编写于 作者: J Junio C Hamano

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: NJunio C Hamano <gitster@pobox.com>
Signed-off-by: NMike Ralphson <mike@abacus.co.uk>
Tested-by: Johannes Sixt <j6t@kdbg.org> (AIX 4.3.x)
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 5413812f
...@@ -90,6 +90,8 @@ all:: ...@@ -90,6 +90,8 @@ all::
# #
# Define NO_MMAP if you want to avoid mmap. # 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. # Define NO_PREAD if you have a problem with pread() system call (e.g.
# cygwin.dll before v1.5.22). # cygwin.dll before v1.5.22).
# #
...@@ -164,6 +166,7 @@ uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not') ...@@ -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_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
uname_R := $(shell sh -c 'uname -r 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_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. # CFLAGS and LDFLAGS are for the users to override from the command line.
...@@ -722,6 +725,11 @@ ifeq ($(uname_S),AIX) ...@@ -722,6 +725,11 @@ ifeq ($(uname_S),AIX)
INTERNAL_QSORT = UnfortunatelyYes INTERNAL_QSORT = UnfortunatelyYes
NEEDS_LIBICONV=YesPlease NEEDS_LIBICONV=YesPlease
BASIC_CFLAGS += -D_LARGE_FILES BASIC_CFLAGS += -D_LARGE_FILES
ifneq ($(shell expr "$(uname_V)" : '[1234]'),1)
THREADED_DELTA_SEARCH = YesPlease
else
NO_PTHREADS = YesPlease
endif
endif endif
ifeq ($(uname_S),GNU) ifeq ($(uname_S),GNU)
# GNU/Hurd # GNU/Hurd
...@@ -766,6 +774,7 @@ ifneq (,$(findstring MINGW,$(uname_S))) ...@@ -766,6 +774,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))
NO_STRCASESTR = YesPlease NO_STRCASESTR = YesPlease
NO_STRLCPY = YesPlease NO_STRLCPY = YesPlease
NO_MEMMEM = YesPlease NO_MEMMEM = YesPlease
NO_PTHREADS = YesPlease
NEEDS_LIBICONV = YesPlease NEEDS_LIBICONV = YesPlease
OLD_ICONV = YesPlease OLD_ICONV = YesPlease
NO_C99_FORMAT = YesPlease NO_C99_FORMAT = YesPlease
...@@ -1017,9 +1026,15 @@ ifdef INTERNAL_QSORT ...@@ -1017,9 +1026,15 @@ ifdef INTERNAL_QSORT
COMPAT_OBJS += compat/qsort.o COMPAT_OBJS += compat/qsort.o
endif endif
ifdef NO_PTHREADS
THREADED_DELTA_SEARCH =
BASIC_CFLAGS += -DNO_PTHREADS
else
EXTLIBS += $(PTHREAD_LIBS)
endif
ifdef THREADED_DELTA_SEARCH ifdef THREADED_DELTA_SEARCH
BASIC_CFLAGS += -DTHREADED_DELTA_SEARCH BASIC_CFLAGS += -DTHREADED_DELTA_SEARCH
EXTLIBS += $(PTHREAD_LIBS)
LIB_OBJS += thread-utils.o LIB_OBJS += thread-utils.o
endif endif
ifdef DIR_HAS_BSD_GROUP_SEMANTICS ifdef DIR_HAS_BSD_GROUP_SEMANTICS
......
...@@ -51,4 +51,5 @@ OLD_ICONV=@OLD_ICONV@ ...@@ -51,4 +51,5 @@ OLD_ICONV=@OLD_ICONV@
NO_DEFLATE_BOUND=@NO_DEFLATE_BOUND@ NO_DEFLATE_BOUND=@NO_DEFLATE_BOUND@
FREAD_READS_DIRECTORIES=@FREAD_READS_DIRECTORIES@ FREAD_READS_DIRECTORIES=@FREAD_READS_DIRECTORIES@
SNPRINTF_RETURNS_BOGUS=@SNPRINTF_RETURNS_BOGUS@ SNPRINTF_RETURNS_BOGUS=@SNPRINTF_RETURNS_BOGUS@
NO_PTHREADS=@NO_PTHREADS@
PTHREAD_LIBS=@PTHREAD_LIBS@ PTHREAD_LIBS=@PTHREAD_LIBS@
...@@ -490,6 +490,8 @@ AC_SUBST(NO_MKDTEMP) ...@@ -490,6 +490,8 @@ AC_SUBST(NO_MKDTEMP)
# Define NO_SYMLINK_HEAD if you never want .git/HEAD to be a symbolic link. # 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. # 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. # Define PTHREAD_LIBS to the linker flag used for Pthread support.
AC_LANG_CONFTEST([AC_LANG_PROGRAM( AC_LANG_CONFTEST([AC_LANG_PROGRAM(
[[#include <pthread.h>]], [[#include <pthread.h>]],
...@@ -502,9 +504,12 @@ else ...@@ -502,9 +504,12 @@ else
${CC} -lpthread conftest.c -o conftest.o > /dev/null 2>&1 ${CC} -lpthread conftest.c -o conftest.o > /dev/null 2>&1
if test $? -eq 0;then if test $? -eq 0;then
PTHREAD_LIBS="-lpthread" PTHREAD_LIBS="-lpthread"
else
NO_PTHREADS=UnfortunatelyYes
fi fi
fi fi
AC_SUBST(PTHREAD_LIBS) AC_SUBST(PTHREAD_LIBS)
AC_SUBST(NO_PTHREADS)
## Site configuration (override autodetection) ## Site configuration (override autodetection)
## --with-PACKAGE[=ARG] and --without-PACKAGE ## --with-PACKAGE[=ARG] and --without-PACKAGE
......
...@@ -2,6 +2,14 @@ ...@@ -2,6 +2,14 @@
* Copyright (C) 2008 Linus Torvalds * Copyright (C) 2008 Linus Torvalds
*/ */
#include "cache.h" #include "cache.h"
#ifdef NO_PTHREADS
static void preload_index(struct index_state *index, const char **pathspec)
{
; /* nothing */
}
#else
#include <pthread.h> #include <pthread.h>
/* /*
...@@ -81,6 +89,7 @@ static void preload_index(struct index_state *index, const char **pathspec) ...@@ -81,6 +89,7 @@ static void preload_index(struct index_state *index, const char **pathspec)
die("unable to join threaded lstat"); die("unable to join threaded lstat");
} }
} }
#endif
int read_index_preload(struct index_state *index, const char **pathspec) int read_index_preload(struct index_state *index, const char **pathspec)
{ {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册