Skip to content

Commit b7e6a41

Browse files
nasamuffingitster
authored andcommitted
tr2: make process info collection platform-generic
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 <[email protected]> Helped-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 107691c commit b7e6a41

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1890,6 +1890,10 @@ ifneq ($(PROCFS_EXECUTABLE_PATH),)
18901890
BASIC_CFLAGS += '-DPROCFS_EXECUTABLE_PATH="$(procfs_executable_path_SQ)"'
18911891
endif
18921892

1893+
ifndef HAVE_PLATFORM_PROCINFO
1894+
COMPAT_OBJS += compat/stub/procinfo.o
1895+
endif
1896+
18931897
ifdef HAVE_NS_GET_EXECUTABLE_PATH
18941898
BASIC_CFLAGS += -DHAVE_NS_GET_EXECUTABLE_PATH
18951899
endif

compat/stub/procinfo.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include "git-compat-util.h"
2+
3+
#include "trace2.h"
4+
5+
/*
6+
* Stub. See sample implementations in compat/linux/procinfo.c and
7+
* compat/win32/trace2_win32_process_info.c.
8+
*/
9+
void trace2_collect_process_info(enum trace2_process_info_reason reason)
10+
{
11+
}

config.mak.uname

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))
612612
ETAGS_TARGET = ETAGS
613613
NO_POSIX_GOODIES = UnfortunatelyYes
614614
DEFAULT_HELP_FORMAT = html
615+
HAVE_PLATFORM_PROCINFO = YesPlease
615616
BASIC_LDFLAGS += -municode
616617
COMPAT_CFLAGS += -DNOGDI -Icompat -Icompat/win32
617618
COMPAT_CFLAGS += -DSTRIP_EXTENSION=\".exe\"

trace2.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -492,13 +492,7 @@ enum trace2_process_info_reason {
492492
TRACE2_PROCESS_INFO_EXIT,
493493
};
494494

495-
#if defined(GIT_WINDOWS_NATIVE)
496495
void trace2_collect_process_info(enum trace2_process_info_reason reason);
497-
#else
498-
#define trace2_collect_process_info(reason) \
499-
do { \
500-
} while (0)
501-
#endif
502496

503497
const char *trace2_session_id(void);
504498

0 commit comments

Comments
 (0)