Skip to content

Commit 91b26cc

Browse files
committed
fsm-listen-win32: stub in backend for Windows
Stub in empty filesystem listener backend for fsmonitor--daemon on Windows. Signed-off-by: Jeff Hostetler <[email protected]>
1 parent 4e81f9b commit 91b26cc

File tree

6 files changed

+91
-0
lines changed

6 files changed

+91
-0
lines changed

Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,11 @@ all::
467467
# directory, and the JSON compilation database 'compile_commands.json' will be
468468
# created at the root of the repository.
469469
#
470+
# If your platform supports a built-in fsmonitor backend, set
471+
# FSMONITOR_DAEMON_BACKEND to the "<name>" of the corresponding
472+
# `compat/fsmonitor/fsm-listen-<name>.c` that implements the
473+
# `fsm_listen__*()` routines.
474+
#
470475
# Define DEVELOPER to enable more compiler warnings. Compiler version
471476
# and family are auto detected, but could be overridden by defining
472477
# COMPILER_FEATURES (see config.mak.dev). You can still set
@@ -1930,6 +1935,11 @@ ifdef NEED_ACCESS_ROOT_HANDLER
19301935
COMPAT_OBJS += compat/access.o
19311936
endif
19321937

1938+
ifdef FSMONITOR_DAEMON_BACKEND
1939+
COMPAT_CFLAGS += -DHAVE_FSMONITOR_DAEMON_BACKEND
1940+
COMPAT_OBJS += compat/fsmonitor/fsm-listen-$(FSMONITOR_DAEMON_BACKEND).o
1941+
endif
1942+
19331943
ifeq ($(TCLTK_PATH),)
19341944
NO_TCLTK = NoThanks
19351945
endif
@@ -2794,6 +2804,9 @@ GIT-BUILD-OPTIONS: FORCE
27942804
@echo PAGER_ENV=\''$(subst ','\'',$(subst ','\'',$(PAGER_ENV)))'\' >>$@+
27952805
@echo DC_SHA1=\''$(subst ','\'',$(subst ','\'',$(DC_SHA1)))'\' >>$@+
27962806
@echo X=\'$(X)\' >>$@+
2807+
ifdef FSMONITOR_DAEMON_BACKEND
2808+
@echo FSMONITOR_DAEMON_BACKEND=\''$(subst ','\'',$(subst ','\'',$(FSMONITOR_DAEMON_BACKEND)))'\' >>$@+
2809+
endif
27972810
ifdef TEST_OUTPUT_DIRECTORY
27982811
@echo TEST_OUTPUT_DIRECTORY=\''$(subst ','\'',$(subst ','\'',$(TEST_OUTPUT_DIRECTORY)))'\' >>$@+
27992812
endif

compat/fsmonitor/fsm-listen-win32.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include "cache.h"
2+
#include "config.h"
3+
#include "fsmonitor.h"
4+
#include "fsm-listen.h"
5+
6+
void fsm_listen__stop_async(struct fsmonitor_daemon_state *state)
7+
{
8+
}
9+
10+
void fsm_listen__loop(struct fsmonitor_daemon_state *state)
11+
{
12+
}
13+
14+
int fsm_listen__ctor(struct fsmonitor_daemon_state *state)
15+
{
16+
return -1;
17+
}
18+
19+
void fsm_listen__dtor(struct fsmonitor_daemon_state *state)
20+
{
21+
}

compat/fsmonitor/fsm-listen.h

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#ifndef FSM_LISTEN_H
2+
#define FSM_LISTEN_H
3+
4+
/* This needs to be implemented by each backend */
5+
6+
#ifdef HAVE_FSMONITOR_DAEMON_BACKEND
7+
8+
struct fsmonitor_daemon_state;
9+
10+
/*
11+
* Initialize platform-specific data for the fsmonitor listener thread.
12+
* This will be called from the main thread PRIOR to staring the
13+
* fsmonitor_fs_listener thread.
14+
*
15+
* Returns 0 if successful.
16+
* Returns -1 otherwise.
17+
*/
18+
int fsm_listen__ctor(struct fsmonitor_daemon_state *state);
19+
20+
/*
21+
* Cleanup platform-specific data for the fsmonitor listener thread.
22+
* This will be called from the main thread AFTER joining the listener.
23+
*/
24+
void fsm_listen__dtor(struct fsmonitor_daemon_state *state);
25+
26+
/*
27+
* The main body of the platform-specific event loop to watch for
28+
* filesystem events. This will run in the fsmonitor_fs_listen thread.
29+
*
30+
* It should call `ipc_server_stop_async()` if the listener thread
31+
* prematurely terminates (because of a filesystem error or if it
32+
* detects that the .git directory has been deleted). (It should NOT
33+
* do so if the listener thread receives a normal shutdown signal from
34+
* the IPC layer.)
35+
*
36+
* It should set `state->error_code` to -1 if the daemon should exit
37+
* with an error.
38+
*/
39+
void fsm_listen__loop(struct fsmonitor_daemon_state *state);
40+
41+
/*
42+
* Gently request that the fsmonitor listener thread shutdown.
43+
* It does not wait for it to stop. The caller should do a JOIN
44+
* to wait for it.
45+
*/
46+
void fsm_listen__stop_async(struct fsmonitor_daemon_state *state);
47+
48+
#endif /* HAVE_FSMONITOR_DAEMON_BACKEND */
49+
#endif /* FSM_LISTEN_H */

config.mak.uname

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ ifeq ($(uname_S),Windows)
420420
# so we don't need this:
421421
#
422422
# SNPRINTF_RETURNS_BOGUS = YesPlease
423+
FSMONITOR_DAEMON_BACKEND = win32
423424
NO_SVN_TESTS = YesPlease
424425
RUNTIME_PREFIX = YesPlease
425426
HAVE_WPGMPTR = YesWeDo
@@ -598,6 +599,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))
598599
NO_STRTOUMAX = YesPlease
599600
NO_MKDTEMP = YesPlease
600601
NO_SVN_TESTS = YesPlease
602+
FSMONITOR_DAEMON_BACKEND = win32
601603
RUNTIME_PREFIX = YesPlease
602604
HAVE_WPGMPTR = YesWeDo
603605
NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease

contrib/buildsystems/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,11 @@ else()
263263
endif()
264264
endif()
265265

266+
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
267+
add_compile_definitions(HAVE_FSMONITOR_DAEMON_BACKEND)
268+
list(APPEND compat_SOURCES compat/fsmonitor/fsm-listen-win32.c)
269+
endif()
270+
266271
set(EXE_EXTENSION ${CMAKE_EXECUTABLE_SUFFIX})
267272

268273
#header checks

repo-settings.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "config.h"
33
#include "repository.h"
44
#include "midx.h"
5+
#include "compat/fsmonitor/fsm-listen.h"
56

67
#define UPDATE_DEFAULT_BOOL(s,v) do { if (s == -1) { s = v; } } while(0)
78

0 commit comments

Comments
 (0)