From 95c5d0b0457e2ead4fe8bae3fe28f29c4a181875 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Thu, 7 Sep 2023 20:03:07 +0100 Subject: [PATCH] Cleanup Windows build Fix make depend errors in slapi --- servers/slapd/slapi/Makefile.in | 12 ++++++------ servers/slapd/slapi/printmsg.c | 20 ++++++++++++++++++++ servers/slapd/slapi/slapi_utils.c | 6 ++++++ 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/servers/slapd/slapi/Makefile.in b/servers/slapd/slapi/Makefile.in index 0e46f78641..32ade0cc26 100644 --- a/servers/slapd/slapi/Makefile.in +++ b/servers/slapd/slapi/Makefile.in @@ -19,9 +19,6 @@ LIBRARY = libslapi.la #all-common: $(LIBRARY) $(PROGRAMS) # @touch plugin.c slapi_pblock.c slapi_utils.c slapi_ops.c slapi_ext.c -NT_SRCS = nt_err.c -NT_OBJS = nt_err.lo - LIB_DEFS = -DSLAPI_LIBRARY SRCS= plugin.c slapi_pblock.c slapi_utils.c printmsg.c slapi_ops.c slapi_dn.c slapi_ext.c slapi_overlay.c \ @@ -31,12 +28,15 @@ OBJS= plugin.lo slapi_pblock.lo slapi_utils.lo printmsg.lo slapi_ops.lo slapi_d XSRCS= version.c -LDAP_INCDIR= ../../../include -I.. -I. -LDAP_LIBDIR= ../../../libraries +LDAP_INCDIR= ../../../include -I.. -I. +LDAP_LIBDIR= ../../../libraries + +shared_LDAP_LIBS = $(LDAP_LIBLDAP_LA) $(LDAP_LIBLBER_LA) XLIBS = $(LIBRARY) XXLIBS = -NT_LINK_LIBS = $(AC_LIBS) +MOD_LIBS = $(MODULES_LIBS) +NT_LINK_LIBS = $(AC_LIBS) -L.. -lslapd $(@BUILD_LIBS_DYNAMIC@_LDAP_LIBS) XINCPATH = -I$(srcdir)/.. -I$(srcdir) XDEFS = $(MODULES_CPPFLAGS) diff --git a/servers/slapd/slapi/printmsg.c b/servers/slapd/slapi/printmsg.c index 15b60045ed..5251846f21 100644 --- a/servers/slapd/slapi/printmsg.c +++ b/servers/slapd/slapi/printmsg.c @@ -32,6 +32,10 @@ #include #include +#ifdef _WIN32 +#include +#endif + #include /* Single threads access to routine */ @@ -60,18 +64,30 @@ slapi_int_log_error( /* for now, we log all severities */ if ( level <= slapi_log_level ) { +#ifdef _WIN32 + intptr_t fhandle; +#endif fp = fopen( slapi_log_file, "a" ); if ( fp == NULL) { rc = -1; goto done; } +#ifdef _WIN32 + fhandle = _get_osfhandle( fileno( fp )); +#endif /* * FIXME: could block */ +#ifdef _WIN32 + while ( LockFile( fhandle, 0, 0, UINT_MAX, UINT_MAX ) == 0 ) { + /* DO NOTHING */ ; + } +#else while ( lockf( fileno( fp ), F_LOCK, 0 ) != 0 ) { /* DO NOTHING */ ; } +#endif time( ¤tTime ); ltm = localtime( ¤tTime ); @@ -85,7 +101,11 @@ slapi_int_log_error( } fflush( fp ); +#ifdef _WIN32 + UnlockFile( fhandle, 0, 0, UINT_MAX, UINT_MAX ); +#else lockf( fileno( fp ), F_ULOCK, 0 ); +#endif fclose( fp ); diff --git a/servers/slapd/slapi/slapi_utils.c b/servers/slapd/slapi/slapi_utils.c index 6c1cecfc27..c45912213f 100644 --- a/servers/slapd/slapi/slapi_utils.c +++ b/servers/slapd/slapi/slapi_utils.c @@ -31,7 +31,11 @@ #include #include +#ifdef _WIN32 +#include +#else #include +#endif #ifdef LDAP_SLAPI @@ -1971,6 +1975,8 @@ slapi_timer_current_time( void ) */ #else /* _WIN32 */ LARGE_INTEGER now; + static LARGE_INTEGER base_time, performance_freq; + static int performance_counter_present; if ( first_time ) { first_time = 0;