summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0ea1c89)
raw | patch | inline | side by side (parent: 0ea1c89)
author | Johannes Sixt <j6t@kdbg.org> | |
Tue, 9 Mar 2010 20:00:36 +0000 (21:00 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 10 Mar 2010 22:26:54 +0000 (14:26 -0800) |
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/technical/api-run-command.txt | patch | blob | history | |
Makefile | patch | blob | history | |
run-command.c | patch | blob | history | |
run-command.h | patch | blob | history |
diff --git a/Documentation/technical/api-run-command.txt b/Documentation/technical/api-run-command.txt
index 44876fa703578f4952d6e928993e15ddec70439c..f18b4f4817448530a5adbe2c8835bb7791add42a 100644 (file)
There are serious restrictions on what the asynchronous function can do
-because this facility is implemented by a pipe to a forked process on
-UNIX, but by a thread in the same address space on Windows:
+because this facility is implemented by a thread in the same address
+space on most platforms (when pthreads is available), but by a pipe to
+a forked process otherwise:
. It cannot change the program's state (global variables, environment,
etc.) in a way that the caller notices; in other words, .in and .out
diff --git a/Makefile b/Makefile
index 2fe52f8163e67fc593ca6ffc75d584bf230c3667..52f2cc040ba82696b199537d3155a095939dac68 100644 (file)
--- a/Makefile
+++ b/Makefile
NO_CURL = YesPlease
NO_PYTHON = YesPlease
BLK_SHA1 = YesPlease
- ASYNC_AS_THREAD = YesPlease
CC = compat/vcbuild/scripts/clink.pl
AR = compat/vcbuild/scripts/lib.pl
NO_REGEX = YesPlease
NO_PYTHON = YesPlease
BLK_SHA1 = YesPlease
- ASYNC_AS_THREAD = YesPlease
COMPAT_CFLAGS += -D__USE_MINGW_ACCESS -DNOGDI -Icompat -Icompat/fnmatch -Icompat/win32
COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"
COMPAT_OBJS += compat/mingw.o compat/fnmatch/fnmatch.o compat/winansi.o \
else
EXTLIBS += $(PTHREAD_LIBS)
LIB_OBJS += thread-utils.o
-ifdef ASYNC_AS_THREAD
- BASIC_CFLAGS += -DASYNC_AS_THREAD
-endif
endif
ifdef DIR_HAS_BSD_GROUP_SEMANTICS
diff --git a/run-command.c b/run-command.c
index 66cc4bfa57b0fa8378a5d1f8562462db1d3c2078..61b153987b0efb9d9c5c53e2a4aa6893a9362f01 100644 (file)
--- a/run-command.c
+++ b/run-command.c
return run_command(&cmd);
}
-#ifdef ASYNC_AS_THREAD
+#ifndef NO_PTHREADS
static pthread_t main_thread;
static int main_thread_set;
static pthread_key_t async_key;
static void *run_thread(void *data)
{
struct async *async = data;
+ intptr_t ret;
pthread_setspecific(async_key, async);
-
- intptr_t ret = async->proc(async->proc_in, async->proc_out, async->data);
+ ret = async->proc(async->proc_in, async->proc_out, async->data);
return (void *)ret;
}
else
proc_out = -1;
-#ifndef ASYNC_AS_THREAD
+#ifdef NO_PTHREADS
/* Flush stdio before fork() to avoid cloning buffers */
fflush(NULL);
int finish_async(struct async *async)
{
-#ifndef ASYNC_AS_THREAD
+#ifdef NO_PTHREADS
return wait_or_whine(async->pid, "child process", 0);
#else
void *ret = (void *)(intptr_t)(-1);
diff --git a/run-command.h b/run-command.h
index 40db39cec0d4dcaac4de6e34d8734be14270552a..56491b9f2344541c02bd0da2928a535f11193bd8 100644 (file)
--- a/run-command.h
+++ b/run-command.h
#ifndef RUN_COMMAND_H
#define RUN_COMMAND_H
-#ifdef ASYNC_AS_THREAD
+#ifndef NO_PTHREADS
#include <pthread.h>
#endif
void *data;
int in; /* caller writes here and closes it */
int out; /* caller reads from here and closes it */
-#ifndef ASYNC_AS_THREAD
+#ifdef NO_PTHREADS
pid_t pid;
#else
pthread_t tid;