index-pack: Disable threading on cygwin
The Cygwin implementation of pread() is not thread-safe since, just like the emulation provided by compat/pread.c, it uses a sequence of seek-read-seek calls. In order to avoid failues due to thread-safety issues, commit b038a61 disables threading when NO_PREAD is defined. (ie when using the emulation code in compat/pread.c). We introduce a new build variable, NO_THREAD_SAFE_PREAD, which allows use to disable the threaded index-pack code on cygwin, in addition to the above NO_PREAD case. Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Jun 26, 2012 at 19:19 UTC
c0f86547c522906da7538c0d2b7b0de608499c23
2 files changed
+10
-2
Makefile
+8
@@ -158,6 +158,9 @@ all::
158
# Define NO_PREAD if you have a problem with pread() system call (e.g.
159
# cygwin1.dll before v1.5.22).
160
#
161
+# Define NO_THREAD_SAFE_PREAD if your pread() implementation is not
162
+# thread-safe. (e.g. compat/pread.c or cygwin)
163
+#
164
# Define NO_FAST_WORKING_DIRECTORY if accessing objects in pack files is
165
# generally faster on your platform than accessing the working directory.
166
#
@@ -1051,6 +1054,7 @@ ifeq ($(uname_O),Cygwin)
1054
NO_IPV6 = YesPlease
1055
OLD_ICONV = UnfortunatelyYes
1056
endif
1057
+ NO_THREAD_SAFE_PREAD = YesPlease
1058
NEEDS_LIBICONV = YesPlease
1059
NO_FAST_WORKING_DIRECTORY = UnfortunatelyYes
1060
NO_TRUSTABLE_FILEMODE = UnfortunatelyYes
@@ -1659,6 +1663,10 @@ endif
1663
ifdef NO_PREAD
1664
COMPAT_CFLAGS += -DNO_PREAD
1665
COMPAT_OBJS += compat/pread.o
1666
+ NO_THREAD_SAFE_PREAD = YesPlease
1667
+endif
1668
+ifdef NO_THREAD_SAFE_PREAD
1669
+ BASIC_CFLAGS += -DNO_THREAD_SAFE_PREAD
1670
endif
1671
ifdef NO_FAST_WORKING_DIRECTORY
1672
BASIC_CFLAGS += -DNO_FAST_WORKING_DIRECTORY
builtin/index-pack.c
+2
-2
@@ -39,8 +39,8 @@ struct base_data {
39
int ofs_first, ofs_last;
40
};
41
42
-#if !defined(NO_PTHREADS) && defined(NO_PREAD)
43
-/* NO_PREAD uses compat/pread.c, which is not thread-safe. Disable threading. */
42
+#if !defined(NO_PTHREADS) && defined(NO_THREAD_SAFE_PREAD)
43
+/* pread() emulation is not thread-safe. Disable threading. */
44
#define NO_PTHREADS
45
#endif
46