From 9b8afa0f83f2fc576723a0262ee17f32055b25d2 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Sun, 17 May 2020 11:09:30 +0200 Subject: [PATCH] ntdll: Move the Wine version functions to the Unix library. Signed-off-by: Alexandre Julliard --- dlls/ntdll/Makefile.in | 8 +++++++ dlls/ntdll/misc.c | 24 +++----------------- dlls/ntdll/unix/loader.c | 48 ++++++++++++++++++++++++++++++++++++++++ dlls/ntdll/unixlib.h | 5 +++++ tools/makedep.c | 5 ++++- 5 files changed, 68 insertions(+), 22 deletions(-) diff --git a/dlls/ntdll/Makefile.in b/dlls/ntdll/Makefile.in index f1ecb395e31..ebf607e9d43 100644 --- a/dlls/ntdll/Makefile.in +++ b/dlls/ntdll/Makefile.in @@ -59,9 +59,17 @@ C_SRCS = \ RC_SRCS = version.rc +EXTRA_OBJS = unix/version.o + server_EXTRADEFS = \ -DBINDIR=\"${bindir}\" \ -DDLLDIR=\"${dlldir}\" \ -DBIN_TO_DLLDIR=\"`$(MAKEDEP) -R ${bindir} ${dlldir}`\" \ -DDLL_TO_BINDIR=\"`$(MAKEDEP) -R ${dlldir} ${bindir}`\" \ -DBIN_TO_DATADIR=\"`$(MAKEDEP) -R ${bindir} ${datadir}/wine`\" + +unix/version.c: dummy + version=`(GIT_DIR=$(top_srcdir)/.git git describe HEAD 2>/dev/null || echo "wine-$(PACKAGE_VERSION)") | sed -n -e '$$s/\(.*\)/const char wine_build[] = "\1";/p'` && (echo $$version | cmp -s - $@) || echo $$version >$@ || (rm -f $@ && exit 1) + +dummy: +.PHONY: dummy diff --git a/dlls/ntdll/misc.c b/dlls/ntdll/misc.c index c29a1c26c26..fd9ba491135 100644 --- a/dlls/ntdll/misc.c +++ b/dlls/ntdll/misc.c @@ -23,13 +23,9 @@ #include #include -#ifdef HAVE_SYS_UTSNAME_H -#include -#endif #include "ntstatus.h" #define WIN32_NO_STATUS -#include "wine/library.h" #include "wine/debug.h" #include "ntdll_misc.h" #include "wmistr.h" @@ -57,7 +53,7 @@ LPCSTR debugstr_us( const UNICODE_STRING *us ) */ const char * CDECL NTDLL_wine_get_version(void) { - return wine_get_version(); + return unix_funcs->get_version(); } /********************************************************************* @@ -65,7 +61,7 @@ const char * CDECL NTDLL_wine_get_version(void) */ const char * CDECL NTDLL_wine_get_build_id(void) { - return wine_get_build_id(); + return unix_funcs->get_build_id(); } /********************************************************************* @@ -73,21 +69,7 @@ const char * CDECL NTDLL_wine_get_build_id(void) */ void CDECL NTDLL_wine_get_host_version( const char **sysname, const char **release ) { -#ifdef HAVE_SYS_UTSNAME_H - static struct utsname buf; - static BOOL init_done; - - if (!init_done) - { - uname( &buf ); - init_done = TRUE; - } - if (sysname) *sysname = buf.sysname; - if (release) *release = buf.release; -#else - if (sysname) *sysname = ""; - if (release) *release = ""; -#endif + return unix_funcs->get_host_version( sysname, release ); } /********************************************************************* diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c index fdcca55bebb..a8e7530c0ca 100644 --- a/dlls/ntdll/unix/loader.c +++ b/dlls/ntdll/unix/loader.c @@ -31,6 +31,9 @@ #ifdef HAVE_SYS_MMAN_H # include #endif +#ifdef HAVE_SYS_UTSNAME_H +#include +#endif #ifdef __APPLE__ # include # define LoadResource MacLoadResource @@ -101,6 +104,48 @@ static void fixup_so_resources( IMAGE_RESOURCE_DIRECTORY *dir, BYTE *root, int d } +/********************************************************************* + * get_version + */ +const char * CDECL get_version(void) +{ + return PACKAGE_VERSION; +} + + +/********************************************************************* + * get_build_id + */ +const char * CDECL get_build_id(void) +{ + extern const char wine_build[]; + return wine_build; +} + + +/********************************************************************* + * get_host_version + */ +void CDECL get_host_version( const char **sysname, const char **release ) +{ +#ifdef HAVE_SYS_UTSNAME_H + static struct utsname buf; + static BOOL init_done; + + if (!init_done) + { + uname( &buf ); + init_done = TRUE; + } + if (sysname) *sysname = buf.sysname; + if (release) *release = buf.release; +#else + if (sysname) *sysname = ""; + if (release) *release = ""; +#endif +} + + /************************************************************************* * map_so_dll * @@ -379,6 +424,9 @@ static HMODULE load_ntdll(void) */ static struct unix_funcs unix_funcs = { + get_version, + get_build_id, + get_host_version, map_so_dll, mmap_add_reserved_area, mmap_remove_reserved_area, diff --git a/dlls/ntdll/unixlib.h b/dlls/ntdll/unixlib.h index 753dea6accf..62ba2615ba2 100644 --- a/dlls/ntdll/unixlib.h +++ b/dlls/ntdll/unixlib.h @@ -28,6 +28,11 @@ struct unix_funcs { + /* environment functions */ + const char * (CDECL *get_version)(void); + const char * (CDECL *get_build_id)(void); + void (CDECL *get_host_version)( const char **sysname, const char **release ); + /* virtual memory functions */ NTSTATUS (CDECL *map_so_dll)( const IMAGE_NT_HEADERS *nt_descr, HMODULE module ); void (CDECL *mmap_add_reserved_area)( void *addr, SIZE_T size ); diff --git a/tools/makedep.c b/tools/makedep.c index 193de2d4d87..cde07f669c8 100644 --- a/tools/makedep.c +++ b/tools/makedep.c @@ -1969,7 +1969,10 @@ static void add_generated_sources( struct makefile *make ) { /* default to .c for unknown extra object files */ if (strendswith( objs.str[i], ".o" )) - add_generated_source( make, objs.str[i], replace_extension( objs.str[i], ".o", ".c" )); + { + file = add_generated_source( make, objs.str[i], replace_extension( objs.str[i], ".o", ".c" )); + if (make->module || make->staticlib) file->file->flags |= FLAG_C_UNIX; + } else if (strendswith( objs.str[i], ".res" )) add_generated_source( make, replace_extension( objs.str[i], ".res", ".rc" ), NULL ); else