]> git.ipfire.org Git - thirdparty/git.git/commitdiff
tr2: make process info collection platform-generic
authorEmily Shaffer <emilyshaffer@google.com>
Thu, 22 Jul 2021 01:27:06 +0000 (18:27 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 22 Jul 2021 20:35:20 +0000 (13:35 -0700)
To pave the way for non-Windows platforms to define
trace2_collect_process_info(), reorganize the stub-or-definition schema
to something which doesn't directly reference Windows.

Platforms which want to collect parent process information in the
future should:

 1. Add an implementation to compat/ (e.g. compat/somearch/procinfo.c)
 2. Add that object to COMPAT_OBJS to config.mak.uname
    (e.g. COMPAT_OBJS += compat/somearch/procinfo.o)
 3. Define HAVE_PLATFORM_PROCINFO in config.mak.uname

In the Windows case, this definition lives in
compat/win32/trace2_win32_process_info.c, which is already conditionally
added to COMPAT_OBJS; so let's add HAVE_PLATFORM_PROCINFO to hint to the
build that compat/stub/procinfo.c should not be used.

Signed-off-by: Emily Shaffer <emilyshaffer@google.com>
Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Makefile
compat/stub/procinfo.c [new file with mode: 0644]
config.mak.uname
trace2.h

index 79bf9fe6110c6998ca17eab53fad280c51b36ab2..453cad4ee5dc5265d22c1c543f0cc08355125663 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1890,6 +1890,10 @@ ifneq ($(PROCFS_EXECUTABLE_PATH),)
        BASIC_CFLAGS += '-DPROCFS_EXECUTABLE_PATH="$(procfs_executable_path_SQ)"'
 endif
 
+ifndef HAVE_PLATFORM_PROCINFO
+       COMPAT_OBJS += compat/stub/procinfo.o
+endif
+
 ifdef HAVE_NS_GET_EXECUTABLE_PATH
        BASIC_CFLAGS += -DHAVE_NS_GET_EXECUTABLE_PATH
 endif
diff --git a/compat/stub/procinfo.c b/compat/stub/procinfo.c
new file mode 100644 (file)
index 0000000..12c0a23
--- /dev/null
@@ -0,0 +1,11 @@
+#include "git-compat-util.h"
+
+#include "trace2.h"
+
+/*
+ * Stub. See sample implementations in compat/linux/procinfo.c and
+ * compat/win32/trace2_win32_process_info.c.
+ */
+void trace2_collect_process_info(enum trace2_process_info_reason reason)
+{
+}
index cb443b4e023adb9957b17714ed4c72bc21dc8744..185ff79b146aff522234d5b4819a6567e6263908 100644 (file)
@@ -612,6 +612,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))
        ETAGS_TARGET = ETAGS
        NO_POSIX_GOODIES = UnfortunatelyYes
        DEFAULT_HELP_FORMAT = html
+       HAVE_PLATFORM_PROCINFO = YesPlease
        BASIC_LDFLAGS += -municode
        COMPAT_CFLAGS += -DNOGDI -Icompat -Icompat/win32
        COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"
index ede18c2e06373f30679a6c0ecf77b794225edbc5..0d990db8177b390a41f444f3220ebbd4069bf518 100644 (file)
--- a/trace2.h
+++ b/trace2.h
@@ -492,13 +492,7 @@ enum trace2_process_info_reason {
        TRACE2_PROCESS_INFO_EXIT,
 };
 
-#if defined(GIT_WINDOWS_NATIVE)
 void trace2_collect_process_info(enum trace2_process_info_reason reason);
-#else
-#define trace2_collect_process_info(reason) \
-       do {                                \
-       } while (0)
-#endif
 
 const char *trace2_session_id(void);