crtdll: Share source with msvcrt.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2019-03-29 14:06:05 +01:00
parent 610d48ba77
commit 1f7489d493
7 changed files with 620 additions and 720 deletions

View File

@ -1,5 +1,34 @@
EXTRADEFS = -D_MT -D_MSVCR_VER=0 -D_CRTDLL
MODULE = crtdll.dll
IMPORTS = msvcrt
PARENTSRC = ../msvcrt
DELAYIMPORTS = advapi32 user32
C_SRCS = \
crtdll_main.c
cpp.c \
console.c \
ctype.c \
data.c \
dir.c \
environ.c \
locale.c \
errno.c \
exit.c \
except.c \
except_arm.c \
except_arm64.c \
except_i386.c \
except_x86_64.c \
lock.c \
file.c \
heap.c \
math.c \
mbcs.c \
misc.c \
process.c \
main.c \
string.c \
scanf.c \
time.c \
undname.c \
thread.c \
wcs.c

File diff suppressed because it is too large Load Diff

View File

@ -1,199 +0,0 @@
/*
* Old C RunTime DLL - All functionality is provided by msvcrt.
*
* Copyright 2000 Jon Griffiths
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include <stdarg.h>
#ifdef HAVE_SYS_STAT_H
# include <sys/stat.h>
#endif
#include "windef.h"
#include "winbase.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(crtdll);
/* from msvcrt */
extern void CDECL __getmainargs( int *argc, char ***argv, char ***envp,
int expand_wildcards, int *new_mode );
/* The following data items are not exported from msvcrt */
unsigned int CRTDLL__basemajor_dll = 0;
unsigned int CRTDLL__baseminor_dll = 0;
unsigned int CRTDLL__baseversion_dll = 0;
unsigned int CRTDLL__cpumode_dll = 0;
unsigned int CRTDLL__osmajor_dll = 0;
unsigned int CRTDLL__osminor_dll = 0;
unsigned int CRTDLL__osmode_dll = 0;
unsigned int CRTDLL__osversion_dll = 0;
/* dev_t is a short in crtdll but an unsigned int in msvcrt */
typedef short crtdll_dev_t;
struct crtdll_stat
{
crtdll_dev_t st_dev;
_ino_t st_ino;
unsigned short st_mode;
short st_nlink;
short st_uid;
short st_gid;
crtdll_dev_t st_rdev;
_off_t st_size;
time_t st_atime;
time_t st_mtime;
time_t st_ctime;
};
/* convert struct _stat from crtdll format to msvcrt format */
static void convert_struct_stat( struct crtdll_stat *dst, const struct _stat *src )
{
dst->st_dev = src->st_dev;
dst->st_ino = src->st_ino;
dst->st_mode = src->st_mode;
dst->st_nlink = src->st_nlink;
dst->st_uid = src->st_uid;
dst->st_gid = src->st_gid;
dst->st_rdev = src->st_rdev;
dst->st_size = src->st_size;
dst->st_atime = src->st_atime;
dst->st_mtime = src->st_mtime;
dst->st_ctime = src->st_ctime;
}
/*********************************************************************
* DllMain (CRTDLL.init)
*/
BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved)
{
TRACE("(%p,%d,%p)\n",hinstDLL,fdwReason,lpvReserved);
if (fdwReason == DLL_PROCESS_ATTACH)
{
DWORD version = GetVersion();
DisableThreadLibraryCalls(hinstDLL);
CRTDLL__basemajor_dll = (version >> 24) & 0xFF;
CRTDLL__baseminor_dll = (version >> 16) & 0xFF;
CRTDLL__baseversion_dll = (version >> 16);
CRTDLL__cpumode_dll = 1; /* FIXME */
CRTDLL__osmajor_dll = (version>>8) & 0xFF;
CRTDLL__osminor_dll = (version & 0xFF);
CRTDLL__osmode_dll = 1; /* FIXME */
CRTDLL__osversion_dll = (version & 0xFFFF);
}
return TRUE;
}
/*********************************************************************
* __GetMainArgs (CRTDLL.@)
*/
void CDECL __GetMainArgs( int *argc, char ***argv, char ***envp, int expand_wildcards )
{
int new_mode = 0;
__getmainargs( argc, argv, envp, expand_wildcards, &new_mode );
}
/*********************************************************************
* _fstat (CRTDLL.@)
*/
int CDECL CRTDLL__fstat(int fd, struct crtdll_stat* buf)
{
struct _stat st;
int ret;
if (!(ret = _fstat( fd, &st ))) convert_struct_stat( buf, &st );
return ret;
}
/*********************************************************************
* _stat (CRTDLL.@)
*/
int CDECL CRTDLL__stat(const char* path, struct crtdll_stat * buf)
{
struct _stat st;
int ret;
if (!(ret = _stat( path, &st ))) convert_struct_stat( buf, &st );
return ret;
}
/*********************************************************************
* _strdec (CRTDLL.@)
*/
char * CDECL _strdec(const char *str1, const char *str2)
{
return (char *)(str2 - 1);
}
/*********************************************************************
* _strinc (CRTDLL.@)
*/
char * CDECL _strinc(const char *str)
{
return (char *)(str + 1);
}
/*********************************************************************
* _strncnt (CRTDLL.@)
*/
size_t CDECL _strncnt(const char *str, size_t maxlen)
{
size_t len = strlen(str);
return (len > maxlen) ? maxlen : len;
}
/*********************************************************************
* _strnextc (CRTDLL.@)
*/
unsigned int CDECL _strnextc(const char *str)
{
return (unsigned char)str[0];
}
/*********************************************************************
* _strninc (CRTDLL.@)
*/
char * CDECL _strninc(const char *str, size_t len)
{
return (char *)(str + len);
}
/*********************************************************************
* _strspnp (CRTDLL.@)
*/
char * CDECL _strspnp( const char *str1, const char *str2)
{
str1 += strspn( str1, str2 );
return *str1 ? (char*)str1 : NULL;
}

View File

@ -39,6 +39,13 @@ unsigned int MSVCRT__osplatform = 0;
unsigned int MSVCRT__winmajor = 0;
unsigned int MSVCRT__winminor = 0;
unsigned int MSVCRT__winver = 0;
#ifdef _CRTDLL
unsigned int CRTDLL__basemajor_dll = 0;
unsigned int CRTDLL__baseminor_dll = 0;
unsigned int CRTDLL__baseversion_dll = 0;
unsigned int CRTDLL__cpumode_dll = 1;
unsigned int CRTDLL__osmode_dll = 1;
#endif
unsigned int MSVCRT___setlc_active = 0;
unsigned int MSVCRT___unguarded_readlc_active = 0;
double MSVCRT__HUGE = 0;
@ -337,6 +344,11 @@ void msvcrt_init_args(void)
MSVCRT__osplatform = osvi.dwPlatformId;
TRACE( "winver %08x winmajor %08x winminor %08x osver %08x\n",
MSVCRT__winver, MSVCRT__winmajor, MSVCRT__winminor, MSVCRT__osver);
#ifdef _CRTDLL
CRTDLL__baseversion_dll = (GetVersion() >> 16);
CRTDLL__basemajor_dll = CRTDLL__baseversion_dll >> 8;
CRTDLL__baseminor_dll = CRTDLL__baseversion_dll & 0xff;
#endif
MSVCRT__HUGE = HUGE_VAL;
MSVCRT___setlc_active = 0;
@ -478,6 +490,17 @@ int CDECL __getmainargs(int *argc, char** *argv, char** *envp,
return 0;
}
#ifdef _CRTDLL
/*********************************************************************
* __GetMainArgs (CRTDLL.@)
*/
void CDECL __GetMainArgs( int *argc, char ***argv, char ***envp, int expand_wildcards )
{
int new_mode = 0;
__getmainargs( argc, argv, envp, expand_wildcards, &new_mode );
}
#endif
static int build_expanded_wargv(int *argc, MSVCRT_wchar_t **argv)
{
int i, size=0, args_no=0, path_len;

View File

@ -79,7 +79,11 @@ typedef unsigned long MSVCRT_size_t;
typedef long MSVCRT_intptr_t;
typedef unsigned long MSVCRT_uintptr_t;
#endif
#ifdef _CRTDLL
typedef short MSVCRT__dev_t;
#else
typedef unsigned int MSVCRT__dev_t;
#endif
typedef int MSVCRT__off_t;
typedef int MSVCRT_clock_t;
typedef int MSVCRT___time32_t;

View File

@ -2076,3 +2076,47 @@ MSVCRT_size_t __cdecl MSVCRT___strncnt(const char *str, MSVCRT_size_t size)
return ret;
}
#ifdef _CRTDLL
/*********************************************************************
* _strdec (CRTDLL.@)
*/
char * CDECL _strdec(const char *str1, const char *str2)
{
return (char *)(str2 - 1);
}
/*********************************************************************
* _strinc (CRTDLL.@)
*/
char * CDECL _strinc(const char *str)
{
return (char *)(str + 1);
}
/*********************************************************************
* _strnextc (CRTDLL.@)
*/
unsigned int CDECL _strnextc(const char *str)
{
return (unsigned char)str[0];
}
/*********************************************************************
* _strninc (CRTDLL.@)
*/
char * CDECL _strninc(const char *str, size_t len)
{
return (char *)(str + len);
}
/*********************************************************************
* _strspnp (CRTDLL.@)
*/
char * CDECL _strspnp( const char *str1, const char *str2)
{
str1 += strspn( str1, str2 );
return *str1 ? (char*)str1 : NULL;
}
#endif

View File

@ -31,7 +31,6 @@ my @dll_groups =
"msvcirt",
"msvcrt40",
"msvcrt20",
"crtdll",
],
[
"msvcrt",