ntdll: Move the Wine version functions to the Unix library.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
feature/deterministic
Alexandre Julliard 2020-05-17 11:09:30 +02:00
parent 2424742d07
commit 9b8afa0f83
5 changed files with 68 additions and 22 deletions

View File

@ -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

View File

@ -23,13 +23,9 @@
#include <time.h>
#include <math.h>
#ifdef HAVE_SYS_UTSNAME_H
#include <sys/utsname.h>
#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 );
}
/*********************************************************************

View File

@ -31,6 +31,9 @@
#ifdef HAVE_SYS_MMAN_H
# include <sys/mman.h>
#endif
#ifdef HAVE_SYS_UTSNAME_H
#include <sys/utsname.h>
#endif
#ifdef __APPLE__
# include <CoreFoundation/CoreFoundation.h>
# 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,

View File

@ -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 );

View File

@ -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