- Implement MSVC versions of call_copy_ctor, call_dtor, continue_after_catch, __CxxFrameHandler
- Fix amd64 versions of _control87 and _statusfp
- Fix MSVC and amd64 warnings

svn path=/trunk/; revision=53713
This commit is contained in:
Timo Kreuzer 2011-09-15 17:11:53 +00:00
parent 2fca6b111a
commit 3e2fddbe19
53 changed files with 309 additions and 211 deletions

View file

@ -74,6 +74,11 @@ typedef struct _WINE_EXCEPTION_REGISTRATION_RECORD
#define siglongjmp(buf,val) longjmp(buf,val) #define siglongjmp(buf,val) longjmp(buf,val)
#endif #endif
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable:4733)
#endif
static inline EXCEPTION_REGISTRATION_RECORD *__wine_push_frame( EXCEPTION_REGISTRATION_RECORD *frame ) static inline EXCEPTION_REGISTRATION_RECORD *__wine_push_frame( EXCEPTION_REGISTRATION_RECORD *frame )
{ {
#ifdef __i386__ #ifdef __i386__
@ -101,6 +106,10 @@ static inline EXCEPTION_REGISTRATION_RECORD *__wine_pop_frame( EXCEPTION_REGISTR
#endif #endif
} }
#ifdef _MSC_VER
#pragma warning(pop)
#endif
extern void __wine_enter_vm86( CONTEXT *context ); extern void __wine_enter_vm86( CONTEXT *context );
#ifdef __cplusplus #ifdef __cplusplus

View file

@ -26,7 +26,7 @@ int _cputs(const char *_str)
UNLOCK_CONSOLE; UNLOCK_CONSOLE;
return retval; return retval;
#else #else
int len = strlen(_str); int len = (int)strlen(_str);
DWORD written = 0; DWORD written = 0;
if (!WriteFile( fdesc[stdout->_file].hFile ,_str,len,&written,NULL)) if (!WriteFile( fdesc[stdout->_file].hFile ,_str,len,&written,NULL))
return -1; return -1;

View file

@ -379,6 +379,7 @@ elseif(ARCH MATCHES amd64)
except/amd64/seh.s except/amd64/seh.s
except/amd64/ehandler.c except/amd64/ehandler.c
float/amd64/clearfp.S float/amd64/clearfp.S
float/amd64/getsetfpcw.S
float/i386/cntrlfp.c float/i386/cntrlfp.c
float/amd64/fpreset.S float/amd64/fpreset.S
float/amd64/logb.S float/amd64/logb.S

View file

@ -132,7 +132,7 @@ static void WINAPI EXCEPTION_ctor(exception *_this, const char** name)
_this->vtable = &MSVCRT_exception_vtable; _this->vtable = &MSVCRT_exception_vtable;
if (*name) if (*name)
{ {
unsigned int name_len = strlen(*name) + 1; size_t name_len = strlen(*name) + 1;
_this->name = MSVCRT_malloc(name_len); _this->name = MSVCRT_malloc(name_len);
memcpy(_this->name, *name, name_len); memcpy(_this->name, *name, name_len);
_this->do_free = TRUE; _this->do_free = TRUE;
@ -608,7 +608,7 @@ const char * __stdcall MSVCRT_type_info_name(type_info * _this)
if (name) if (name)
{ {
unsigned int len = strlen(name); size_t len = strlen(name);
/* It seems _unDName may leave blanks at the end of the demangled name */ /* It seems _unDName may leave blanks at the end of the demangled name */
while (len && name[--len] == ' ') while (len && name[--len] == ' ')

View file

@ -81,7 +81,25 @@ static inline void call_copy_ctor( void *func, void *this, void *src, int has_vb
{ {
TRACE( "calling copy ctor %p object %p src %p\n", func, this, src ); TRACE( "calling copy ctor %p object %p src %p\n", func, this, src );
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma message ("call_copy_ctor is unimplemented for MSC") if (has_vbase)
{
__asm
{
mov ecx, this
push 1
push src
call func
}
}
else
{
__asm
{
mov ecx, this
push src
call func
}
}
#else #else
if (has_vbase) if (has_vbase)
/* in that case copy ctor takes an extra bool indicating whether to copy the base class */ /* in that case copy ctor takes an extra bool indicating whether to copy the base class */
@ -97,23 +115,42 @@ static inline void call_copy_ctor( void *func, void *this, void *src, int has_vb
static inline void call_dtor( void *func, void *object ) static inline void call_dtor( void *func, void *object )
{ {
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma message ("call_dtor is unimplemented for MSC") __asm
{
mov ecx, object
call func
}
#else #else
__asm__ __volatile__("call *%0" : : "r" (func), "c" (object) : "eax", "edx", "memory" ); __asm__ __volatile__("call *%0" : : "r" (func), "c" (object) : "eax", "edx", "memory" );
#endif #endif
} }
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable:4731)
/* continue execution to the specified address after exception is caught */
__forceinline void DECLSPEC_NORETURN continue_after_catch( cxx_exception_frame* frame, void *addr )
{
__asm
{
mov eax, addr
mov edx, frame
mov esp, [edx-4]
lea ebp, [edx+12]
jmp eax
}
for (;;) ; /* unreached */
}
#pragma warning(pop)
#else
/* continue execution to the specified address after exception is caught */ /* continue execution to the specified address after exception is caught */
static inline void DECLSPEC_NORETURN continue_after_catch( cxx_exception_frame* frame, void *addr ) static inline void DECLSPEC_NORETURN continue_after_catch( cxx_exception_frame* frame, void *addr )
{ {
#ifdef _MSC_VER
#pragma message ("continue_after_catch is unimplemented for MSC")
#else
__asm__ __volatile__("movl -4(%0),%%esp; leal 12(%0),%%ebp; jmp *%1" __asm__ __volatile__("movl -4(%0),%%esp; leal 12(%0),%%ebp; jmp *%1"
: : "r" (frame), "a" (addr) ); : : "r" (frame), "a" (addr) );
#endif
for (;;) ; /* unreached */ for (;;) ; /* unreached */
} }
#endif
static inline void dump_type( const cxx_type_info *type ) static inline void dump_type( const cxx_type_info *type )
{ {
@ -235,7 +272,7 @@ static void cxx_local_unwind( cxx_exception_frame* frame, const cxx_function_des
while (trylevel != last_level) while (trylevel != last_level)
{ {
if (trylevel < 0 || trylevel >= descr->unwind_count) if (trylevel < 0 || (unsigned)trylevel >= descr->unwind_count)
{ {
ERR( "invalid trylevel %d\n", trylevel ); ERR( "invalid trylevel %d\n", trylevel );
MSVCRT_terminate(); MSVCRT_terminate();
@ -448,11 +485,22 @@ DWORD CDECL cxx_frame_handler( PEXCEPTION_RECORD rec, cxx_exception_frame* frame
extern DWORD CDECL __CxxFrameHandler( PEXCEPTION_RECORD rec, EXCEPTION_REGISTRATION_RECORD* frame, extern DWORD CDECL __CxxFrameHandler( PEXCEPTION_RECORD rec, EXCEPTION_REGISTRATION_RECORD* frame,
PCONTEXT context, EXCEPTION_REGISTRATION_RECORD** dispatch ); PCONTEXT context, EXCEPTION_REGISTRATION_RECORD** dispatch );
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma message ("__CxxFrameHandler is unimplemented for MSC") DWORD _declspec(naked) __CxxFrameHandler( PEXCEPTION_RECORD rec, EXCEPTION_REGISTRATION_RECORD* frame,
DWORD CDECL __CxxFrameHandler( PEXCEPTION_RECORD rec, EXCEPTION_REGISTRATION_RECORD* frame,
PCONTEXT context, EXCEPTION_REGISTRATION_RECORD** dispatch ) PCONTEXT context, EXCEPTION_REGISTRATION_RECORD** dispatch )
{ {
return 0; __asm
{
push 0
push 0
push eax
push [esp + 28]
push [esp + 28]
push [esp + 28]
push [esp + 28]
call cxx_frame_handler
add esp, 28
ret
}
} }
#else #else
__ASM_GLOBAL_FUNC( __CxxFrameHandler, __ASM_GLOBAL_FUNC( __CxxFrameHandler,

View file

@ -0,0 +1,24 @@
#include <asm.inc>
.code64
PUBLIC __getfpcw87
FUNC __getfpcw87
sub rsp, 8
.ENDPROLOG
stmxcsr [rsp]
mov rax, [rsp]
add rsp, 8
ret
ENDFUNC __getfpcw87
PUBLIC __setfpcw87
FUNC __setfpcw87
mov qword ptr [rsp + 8], rcx
.ENDPROLOG
ldmxcsr [rsp + 8]
ret
ENDFUNC __setfpcw87
END

View file

@ -23,6 +23,11 @@
#define X87_CW_IC (1<<12) /* infinity control flag */ #define X87_CW_IC (1<<12) /* infinity control flag */
#ifdef _M_AMD64
unsigned int __getfpcw87(void);
void __setfpcw87(unsigned int);
#endif
/* /*
* @implemented * @implemented
*/ */
@ -43,12 +48,12 @@ unsigned int CDECL _control87(unsigned int newval, unsigned int mask)
TRACE("(%08x, %08x): Called\n", newval, mask); TRACE("(%08x, %08x): Called\n", newval, mask);
/* Get fp control word */ /* Get fp control word */
#if defined(__GNUC__) #ifdef _M_AMD64
fpword = __getfpcw87();
#elif defined(__GNUC__)
__asm__ __volatile__( "fstcw %0" : "=m" (fpword) : ); __asm__ __volatile__( "fstcw %0" : "=m" (fpword) : );
#elif defined(_M_IX86)
__asm fstcw [fpword];
#else #else
#pragma message("FIXME: _control87 is halfplemented") __asm fstcw [fpword];
#endif #endif
TRACE("Control word before : %08x\n", fpword); TRACE("Control word before : %08x\n", fpword);
@ -98,12 +103,12 @@ unsigned int CDECL _control87(unsigned int newval, unsigned int mask)
TRACE("Control word after : %08x\n", fpword); TRACE("Control word after : %08x\n", fpword);
/* Put fp control word */ /* Put fp control word */
#if defined(__GNUC__) #ifdef _M_AMD64
__setfpcw87(fpword);
#elif defined(__GNUC__)
__asm__ __volatile__( "fldcw %0" : : "m" (fpword) ); __asm__ __volatile__( "fldcw %0" : : "m" (fpword) );
#elif defined(_M_IX86)
__asm fldcw [fpword];
#else #else
#pragma message("FIXME: _control87 is halfplemented") __asm fldcw [fpword];
#endif #endif
return flags; return flags;

View file

@ -26,12 +26,13 @@ unsigned int CDECL _statusfp(void)
{ {
unsigned int retVal = 0; unsigned int retVal = 0;
unsigned int fpword; unsigned int fpword;
#if defined(__GNUC__)
#ifdef _M_AMD64
fpword = _mm_getcsr();
#elif defined(__GNUC__)
__asm__ __volatile__( "fstsw %0" : "=m" (fpword) : ); __asm__ __volatile__( "fstsw %0" : "=m" (fpword) : );
#elif defined(_M_IX86) #else // _MSC_VER
__asm fstsw [fpword]; __asm fstsw [fpword];
#else
#pragma message("FIXME: _statusfp is halfplemented")
#endif #endif
if (fpword & 0x1) retVal |= _SW_INVALID; if (fpword & 0x1) retVal |= _SW_INVALID;
if (fpword & 0x2) retVal |= _SW_DENORMAL; if (fpword & 0x2) retVal |= _SW_DENORMAL;

View file

@ -10,17 +10,17 @@
#define LEAPDAY 59 #define LEAPDAY 59
static __inline static __inline
time_t __time64_t
FileTimeToUnixTime(const FILETIME *FileTime, USHORT *millitm) FileTimeToUnixTime(const FILETIME *FileTime, USHORT *millitm)
{ {
ULARGE_INTEGER ULargeInt; ULARGE_INTEGER ULargeInt;
time_t time; __time64_t time;
ULargeInt.LowPart = FileTime->dwLowDateTime; ULargeInt.LowPart = FileTime->dwLowDateTime;
ULargeInt.HighPart = FileTime->dwHighDateTime; ULargeInt.HighPart = FileTime->dwHighDateTime;
ULargeInt.QuadPart -= DIFFTIME; ULargeInt.QuadPart -= DIFFTIME;
time = (time_t)(ULargeInt.QuadPart / 10000000); time = ULargeInt.QuadPart / 10000000;
if (millitm) if (millitm)
*millitm = (USHORT)((ULargeInt.QuadPart % 10000000) / 10000); *millitm = (USHORT)((ULargeInt.QuadPart % 10000000) / 10000);

View file

@ -19,7 +19,7 @@ cos(double x)
double x2, result; double x2, result;
/* Calculate the quadrant */ /* Calculate the quadrant */
quadrant = x * (2./M_PI); quadrant = (int)(x * (2./M_PI));
/* Get offset inside quadrant */ /* Get offset inside quadrant */
x = x - quadrant * (M_PI/2.); x = x - quadrant * (M_PI/2.);
@ -33,7 +33,7 @@ cos(double x)
/* Calculate the negative of the square of x */ /* Calculate the negative of the square of x */
x2 = - (x * x); x2 = - (x * x);
/* This is an unrolled taylor series using <PRECISION> iterations /* This is an unrolled taylor series using <PRECISION> iterations
* Example with 4 iterations: * Example with 4 iterations:
* result = 1 - x^2/2! + x^4/4! - x^6/6! + x^8/8! * result = 1 - x^2/2! + x^4/4! - x^6/6! + x^8/8!
* To save multiplications and to keep the precision high, it's performed * To save multiplications and to keep the precision high, it's performed

View file

@ -19,7 +19,7 @@ sin(double x)
double x2, result; double x2, result;
/* Calculate the quadrant */ /* Calculate the quadrant */
quadrant = x * (2./M_PI); quadrant = (int)(x * (2./M_PI));
/* Get offset inside quadrant */ /* Get offset inside quadrant */
x = x - quadrant * (M_PI/2.); x = x - quadrant * (M_PI/2.);
@ -33,7 +33,7 @@ sin(double x)
/* Calculate the negative of the square of x */ /* Calculate the negative of the square of x */
x2 = - (x * x); x2 = - (x * x);
/* This is an unrolled taylor series using <PRECISION> iterations /* This is an unrolled taylor series using <PRECISION> iterations
* Example with 4 iterations: * Example with 4 iterations:
* result = 1 - x^2/2! + x^4/4! - x^6/6! + x^8/8! * result = 1 - x^2/2! + x^4/4! - x^6/6! + x^8/8!
* To save multiplications and to keep the precision high, it's performed * To save multiplications and to keep the precision high, it's performed

View file

@ -6,7 +6,7 @@
*/ */
unsigned char *_mbsstr(const unsigned char *src1,const unsigned char *src2) unsigned char *_mbsstr(const unsigned char *src1,const unsigned char *src2)
{ {
int len; size_t len;
if (src2 ==NULL || *src2 == 0) if (src2 ==NULL || *src2 == 0)
return (unsigned char *)src1; return (unsigned char *)src1;

View file

@ -5,7 +5,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <signal.h> #include <signal.h>
static const char formatstr[] = static const char formatstr[] =
"Assertion failed!\n\n" "Assertion failed!\n\n"
"Program: %s\n" "Program: %s\n"
"File: %s\n" "File: %s\n"
@ -23,7 +23,7 @@ void _assert(const char *exp, const char *file, unsigned line)
HMODULE hmodUser32; HMODULE hmodUser32;
char achProgram[40]; char achProgram[40];
char *pszBuffer; char *pszBuffer;
int len; size_t len;
int iResult; int iResult;
/* Assertion failed at foo.c line 45: x<y */ /* Assertion failed at foo.c line 45: x<y */
@ -40,7 +40,7 @@ void _assert(const char *exp, const char *file, unsigned line)
/* Get the file name of the module */ /* Get the file name of the module */
len = GetModuleFileNameA(NULL, achProgram, 40); len = GetModuleFileNameA(NULL, achProgram, 40);
/* Calculate full length of the message */ /* Calculate full length of the message */
len += sizeof(formatstr) + len + strlen(exp) + strlen(file); len += sizeof(formatstr) + len + strlen(exp) + strlen(file);
@ -51,8 +51,8 @@ void _assert(const char *exp, const char *file, unsigned line)
_snprintf(pszBuffer, len, formatstr, achProgram, file, line, exp); _snprintf(pszBuffer, len, formatstr, achProgram, file, line, exp);
/* Display a message box */ /* Display a message box */
iResult = pMessageBoxA(NULL, iResult = pMessageBoxA(NULL,
pszBuffer, pszBuffer,
"ReactOS C Runtime Library", "ReactOS C Runtime Library",
MB_ABORTRETRYIGNORE | MB_ICONERROR); MB_ABORTRETRYIGNORE | MB_ICONERROR);

View file

@ -40,7 +40,8 @@ int BlockEnvToEnvironA(void)
{ {
char *ptr, *environment_strings; char *ptr, *environment_strings;
char **envptr; char **envptr;
int count = 1, len; int count = 1;
size_t len;
TRACE("BlockEnvToEnvironA()\n"); TRACE("BlockEnvToEnvironA()\n");
@ -91,7 +92,8 @@ int BlockEnvToEnvironW(void)
{ {
wchar_t *ptr, *environment_strings; wchar_t *ptr, *environment_strings;
wchar_t **envptr; wchar_t **envptr;
int count = 1, len; int count = 1;
size_t len;
TRACE("BlockEnvToEnvironW()\n"); TRACE("BlockEnvToEnvironW()\n");

View file

@ -71,7 +71,7 @@ int wexpand(wchar_t* name, int expand_wildcards)
HANDLE hFile; HANDLE hFile;
BOOLEAN first = TRUE; BOOLEAN first = TRUE;
wchar_t buffer[256]; wchar_t buffer[256];
int pos; uintptr_t pos;
if (expand_wildcards && (s = wcspbrk(name, L"*?"))) if (expand_wildcards && (s = wcspbrk(name, L"*?")))
{ {
@ -136,7 +136,7 @@ int aexpand(char* name, int expand_wildcards)
HANDLE hFile; HANDLE hFile;
BOOLEAN first = TRUE; BOOLEAN first = TRUE;
char buffer[256]; char buffer[256];
int pos; uintptr_t pos;
if (expand_wildcards && (s = strpbrk(name, "*?"))) if (expand_wildcards && (s = strpbrk(name, "*?")))
{ {
@ -181,7 +181,8 @@ int aexpand(char* name, int expand_wildcards)
*/ */
void __getmainargs(int* argc, char*** argv, char*** env, int expand_wildcards, int* new_mode) void __getmainargs(int* argc, char*** argv, char*** env, int expand_wildcards, int* new_mode)
{ {
int i, afterlastspace, ignorespace, len, doexpand; int i, afterlastspace, ignorespace, doexpand;
size_t len;
/* missing threading init */ /* missing threading init */
@ -262,7 +263,8 @@ void __getmainargs(int* argc, char*** argv, char*** env, int expand_wildcards, i
void __wgetmainargs(int* argc, wchar_t*** wargv, wchar_t*** wenv, void __wgetmainargs(int* argc, wchar_t*** wargv, wchar_t*** wenv,
int expand_wildcards, int* new_mode) int expand_wildcards, int* new_mode)
{ {
int i, afterlastspace, ignorespace, len, doexpand; int i, afterlastspace, ignorespace, doexpand;
size_t len;
/* missing threading init */ /* missing threading init */

View file

@ -59,7 +59,7 @@ int CDECL MSVCRT_I10_OUTPUT(long double ld, int prec, int flag, struct _I10_OUTP
} }
if(flag&1) { if(flag&1) {
int exp = 1+floor(log10(d)); int exp = (int)(1+floor(log10(d)));
prec += exp; prec += exp;
if(exp < 0) if(exp < 0)
@ -83,7 +83,7 @@ int CDECL MSVCRT_I10_OUTPUT(long double ld, int prec, int flag, struct _I10_OUTP
data->pos++; data->pos++;
for(p = buf+prec+1; p>buf+1 && *p=='0'; p--); for(p = buf+prec+1; p>buf+1 && *p=='0'; p--);
data->len = p-buf; data->len = (BYTE)(p - buf);
memcpy(data->str, buf+1, data->len); memcpy(data->str, buf+1, data->len);
data->str[data->len] = '\0'; data->str[data->len] = '\0';

View file

@ -47,7 +47,7 @@ _sxprintf(
stream._ptr = stream._base; stream._ptr = stream._base;
stream._charbuf = 0; stream._charbuf = 0;
#if USE_COUNT #if USE_COUNT
stream._cnt = count * sizeof(TCHAR); stream._cnt = (int)(count * sizeof(TCHAR));
#else #else
stream._cnt = INT_MAX; stream._cnt = INT_MAX;
#endif #endif

View file

@ -67,7 +67,7 @@ enum
(flags & FLAG_LONGDOUBLE) ? va_arg(argptr, long double) : \ (flags & FLAG_LONGDOUBLE) ? va_arg(argptr, long double) : \
va_arg(argptr, double) va_arg(argptr, double)
#define get_exp(f) floor(f == 0 ? 0 : (f >= 0 ? log10(f) : log10(-f))) #define get_exp(f) (int)floor(f == 0 ? 0 : (f >= 0 ? log10(f) : log10(-f)))
#define round(x) floor((x) + 0.5) #define round(x) floor((x) + 0.5)
#ifndef _USER32_WSPRINTF #ifndef _USER32_WSPRINTF
@ -244,7 +244,7 @@ streamout_char(FILE *stream, int chr)
static static
int int
streamout_astring(FILE *stream, const char *string, int count) streamout_astring(FILE *stream, const char *string, size_t count)
{ {
TCHAR chr; TCHAR chr;
int written = 0; int written = 0;
@ -267,7 +267,7 @@ streamout_astring(FILE *stream, const char *string, int count)
static static
int int
streamout_wstring(FILE *stream, const wchar_t *string, int count) streamout_wstring(FILE *stream, const wchar_t *string, size_t count)
{ {
wchar_t chr; wchar_t chr;
int written = 0; int written = 0;
@ -317,7 +317,8 @@ streamout(FILE *stream, const TCHAR *format, va_list argptr)
TCHAR chr, *string; TCHAR chr, *string;
STRING *nt_string; STRING *nt_string;
const TCHAR *digits, *prefix; const TCHAR *digits, *prefix;
int base, len, prefixlen, fieldwidth, precision, padding; int base, fieldwidth, precision, padding;
size_t prefixlen, len;
int written = 1, written_all = 0; int written = 1, written_all = 0;
unsigned int flags; unsigned int flags;
unsigned __int64 val64; unsigned __int64 val64;
@ -510,7 +511,7 @@ streamout(FILE *stream, const TCHAR *format, va_list argptr)
len = wcslen((wchar_t*)string); len = wcslen((wchar_t*)string);
else else
len = strlen((char*)string); len = strlen((char*)string);
if (precision >= 0 && len > precision) len = precision; if (precision >= 0 && len > (unsigned)precision) len = precision;
precision = 0; precision = 0;
break; break;
@ -611,7 +612,7 @@ streamout(FILE *stream, const TCHAR *format, va_list argptr)
/* Calculate padding */ /* Calculate padding */
prefixlen = prefix ? _tcslen(prefix) : 0; prefixlen = prefix ? _tcslen(prefix) : 0;
if (precision < 0) precision = 0; if (precision < 0) precision = 0;
padding = fieldwidth - len - prefixlen - precision; padding = (int)(fieldwidth - len - prefixlen - precision);
if (padding < 0) padding = 0; if (padding < 0) padding = 0;
/* Optional left space padding */ /* Optional left space padding */

View file

@ -117,7 +117,8 @@ const _TCHAR* find_execT(const _TCHAR* path, _TCHAR* rpath)
static _TCHAR* static _TCHAR*
argvtosT(const _TCHAR* const* argv, _TCHAR delim) argvtosT(const _TCHAR* const* argv, _TCHAR delim)
{ {
int i, len; int i;
size_t len;
_TCHAR *ptr, *str; _TCHAR *ptr, *str;
if (argv == NULL) if (argv == NULL)
@ -149,7 +150,7 @@ valisttosT(const _TCHAR* arg0, va_list alist, _TCHAR delim)
{ {
va_list alist2 = alist; va_list alist2 = alist;
_TCHAR *ptr, *str; _TCHAR *ptr, *str;
int len; size_t len;
if (arg0 == NULL) if (arg0 == NULL)
return NULL; return NULL;
@ -327,7 +328,7 @@ intptr_t _tspawnl(int mode, const _TCHAR *cmdname, const _TCHAR* arg0, ...)
{ {
va_list argp; va_list argp;
_TCHAR* args; _TCHAR* args;
int ret = -1; intptr_t ret = -1;
TRACE(MK_STR(_tspawnl)"('%"sT"')\n", cmdname); TRACE(MK_STR(_tspawnl)"('%"sT"')\n", cmdname);
@ -348,7 +349,7 @@ intptr_t _tspawnl(int mode, const _TCHAR *cmdname, const _TCHAR* arg0, ...)
intptr_t _tspawnv(int mode, const _TCHAR *cmdname, const _TCHAR* const* argv) intptr_t _tspawnv(int mode, const _TCHAR *cmdname, const _TCHAR* const* argv)
{ {
_TCHAR* args; _TCHAR* args;
int ret = -1; intptr_t ret = -1;
TRACE(MK_STR(_tspawnv)"('%"sT"')\n", cmdname); TRACE(MK_STR(_tspawnv)"('%"sT"')\n", cmdname);
@ -371,7 +372,7 @@ intptr_t _tspawnle(int mode, const _TCHAR *cmdname, const _TCHAR* arg0, ... /*,
_TCHAR* args; _TCHAR* args;
_TCHAR* envs; _TCHAR* envs;
_TCHAR const * const* ptr; _TCHAR const * const* ptr;
int ret = -1; intptr_t ret = -1;
TRACE(MK_STR(_tspawnle)"('%"sT"')\n", cmdname); TRACE(MK_STR(_tspawnle)"('%"sT"')\n", cmdname);
@ -404,7 +405,7 @@ intptr_t _tspawnve(int mode, const _TCHAR *cmdname, const _TCHAR* const* argv, c
{ {
_TCHAR *args; _TCHAR *args;
_TCHAR *envs; _TCHAR *envs;
int ret = -1; intptr_t ret = -1;
TRACE(MK_STR(_tspawnve)"('%"sT"')\n", cmdname); TRACE(MK_STR(_tspawnve)"('%"sT"')\n", cmdname);
@ -442,7 +443,7 @@ intptr_t _tspawnlp(int mode, const _TCHAR* cmdname, const _TCHAR* arg0, .../*, N
{ {
va_list argp; va_list argp;
_TCHAR* args; _TCHAR* args;
int ret = -1; intptr_t ret = -1;
_TCHAR pathname[FILENAME_MAX]; _TCHAR pathname[FILENAME_MAX];
TRACE(MK_STR(_tspawnlp)"('%"sT"')\n", cmdname); TRACE(MK_STR(_tspawnlp)"('%"sT"')\n", cmdname);
@ -467,7 +468,7 @@ intptr_t _tspawnlpe(int mode, const _TCHAR* cmdname, const _TCHAR* arg0, .../*,
_TCHAR* args; _TCHAR* args;
_TCHAR* envs; _TCHAR* envs;
_TCHAR const* const * ptr; _TCHAR const* const * ptr;
int ret = -1; intptr_t ret = -1;
_TCHAR pathname[FILENAME_MAX]; _TCHAR pathname[FILENAME_MAX];
TRACE(MK_STR(_tspawnlpe)"('%"sT"')\n", cmdname); TRACE(MK_STR(_tspawnlpe)"('%"sT"')\n", cmdname);
@ -512,7 +513,7 @@ intptr_t _texecl(const _TCHAR* cmdname, const _TCHAR* arg0, ...)
{ {
_TCHAR* args; _TCHAR* args;
va_list argp; va_list argp;
int ret = -1; intptr_t ret = -1;
TRACE(MK_STR(_texecl)"('%"sT"')\n", cmdname); TRACE(MK_STR(_texecl)"('%"sT"')\n", cmdname);
@ -545,7 +546,7 @@ intptr_t _texecle(const _TCHAR* cmdname, const _TCHAR* arg0, ... /*, NULL, char*
_TCHAR* args; _TCHAR* args;
_TCHAR* envs; _TCHAR* envs;
_TCHAR const* const* ptr; _TCHAR const* const* ptr;
int ret = -1; intptr_t ret = -1;
TRACE(MK_STR(_texecle)"('%"sT"')\n", cmdname); TRACE(MK_STR(_texecle)"('%"sT"')\n", cmdname);
@ -586,7 +587,7 @@ intptr_t _texeclp(const _TCHAR* cmdname, const _TCHAR* arg0, ...)
{ {
_TCHAR* args; _TCHAR* args;
va_list argp; va_list argp;
int ret = -1; intptr_t ret = -1;
_TCHAR pathname[FILENAME_MAX]; _TCHAR pathname[FILENAME_MAX];
TRACE(MK_STR(_texeclp)"('%"sT"')\n", cmdname); TRACE(MK_STR(_texeclp)"('%"sT"')\n", cmdname);
@ -620,7 +621,7 @@ intptr_t _texeclpe(const _TCHAR* cmdname, const _TCHAR* arg0, ... /*, NULL, char
_TCHAR* args; _TCHAR* args;
_TCHAR* envs; _TCHAR* envs;
_TCHAR const* const* ptr; _TCHAR const* const* ptr;
int ret = -1; intptr_t ret = -1;
_TCHAR pathname[FILENAME_MAX]; _TCHAR pathname[FILENAME_MAX];
TRACE(MK_STR(_texeclpe)"('%"sT"')\n", cmdname); TRACE(MK_STR(_texeclpe)"('%"sT"')\n", cmdname);

View file

@ -9,7 +9,8 @@ bsearch(const void *key, const void *base0, size_t nelem,
size_t size, int (__cdecl *cmp)(const void *ck, const void *ce)) size_t size, int (__cdecl *cmp)(const void *ck, const void *ce))
{ {
char *base = (char *)base0; char *base = (char *)base0;
int lim, cmpval; size_t lim;
int cmpval;
void *p; void *p;
for (lim = nelem; lim != 0; lim >>= 1) for (lim = nelem; lim != 0; lim >>= 1)

View file

@ -56,7 +56,7 @@ _flsbuf(int ch, FILE *stream)
if (stream->_base && !(stream->_flag & _IONBF)) if (stream->_base && !(stream->_flag & _IONBF))
{ {
/* We can, check if there is something to write */ /* We can, check if there is something to write */
count = stream->_ptr - stream->_base; count = (int)(stream->_ptr - stream->_base);
if (count > 0) if (count > 0)
written = _write(stream->_file, stream->_base, count); written = _write(stream->_file, stream->_base, count);
else else

View file

@ -267,7 +267,7 @@ unsigned create_io_inherit_block(WORD *size, BYTE **block)
char* wxflag_ptr; char* wxflag_ptr;
HANDLE* handle_ptr; HANDLE* handle_ptr;
*size = sizeof(unsigned) + (sizeof(char) + sizeof(HANDLE)) * fdend; *size = (WORD)(sizeof(unsigned) + (sizeof(char) + sizeof(HANDLE)) * fdend);
*block = calloc(*size, 1); *block = calloc(*size, 1);
if (!*block) if (!*block)
{ {
@ -302,7 +302,7 @@ unsigned create_io_inherit_block(WORD *size, BYTE **block)
void msvcrt_init_io(void) void msvcrt_init_io(void)
{ {
STARTUPINFOA si; STARTUPINFOA si;
int i; unsigned int i;
InitializeCriticalSection(&FILE_cs); InitializeCriticalSection(&FILE_cs);
FILE_cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": FILE_cs"); FILE_cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": FILE_cs");
@ -397,7 +397,7 @@ void msvcrt_init_io(void)
static int flush_buffer(FILE* file) static int flush_buffer(FILE* file)
{ {
if(file->_bufsiz) { if(file->_bufsiz) {
int cnt=file->_ptr-file->_base; int cnt = (int)(file->_ptr - file->_base);
if(cnt>0 && _write(file->_file, file->_base, cnt) != cnt) { if(cnt>0 && _write(file->_file, file->_base, cnt) != cnt) {
file->_flag |= _IOERR; file->_flag |= _IOERR;
return EOF; return EOF;
@ -839,7 +839,7 @@ __int64 CDECL _lseeki64(int fd, __int64 offset, int whence)
*/ */
LONG CDECL _lseek(int fd, LONG offset, int whence) LONG CDECL _lseek(int fd, LONG offset, int whence)
{ {
return _lseeki64(fd, offset, whence); return (LONG)_lseeki64(fd, offset, whence);
} }
/********************************************************************* /*********************************************************************
@ -1056,7 +1056,7 @@ FILE* CDECL _fdopen(int fd, const char *mode)
*/ */
FILE* CDECL _wfdopen(int fd, const wchar_t *mode) FILE* CDECL _wfdopen(int fd, const wchar_t *mode)
{ {
unsigned mlen = strlenW(mode); unsigned mlen = (unsigned)strlenW(mode);
char *modea = calloc(mlen + 1, 1); char *modea = calloc(mlen + 1, 1);
FILE* file = NULL; FILE* file = NULL;
int open_flags, stream_flags; int open_flags, stream_flags;
@ -1409,7 +1409,7 @@ int CDECL _sopen( const char *path, int oflags, int shflags, ... )
*/ */
int CDECL _wsopen( const wchar_t* path, int oflags, int shflags, ... ) int CDECL _wsopen( const wchar_t* path, int oflags, int shflags, ... )
{ {
const unsigned int len = strlenW(path); const unsigned int len = (unsigned)strlenW(path);
char *patha = calloc(len + 1,1); char *patha = calloc(len + 1,1);
va_list ap; va_list ap;
int pmode; int pmode;
@ -1453,7 +1453,7 @@ int CDECL _open( const char *path, int flags, ... )
*/ */
int CDECL _wopen(const wchar_t *path,int flags,...) int CDECL _wopen(const wchar_t *path,int flags,...)
{ {
const unsigned int len = strlenW(path); const unsigned int len = (unsigned)strlenW(path);
char *patha = calloc(len + 1,1); char *patha = calloc(len + 1,1);
va_list ap; va_list ap;
int pmode; int pmode;
@ -1793,7 +1793,7 @@ int CDECL _write(int fd, const void* buf, unsigned int count)
*_errno() = ENOSPC; *_errno() = ENOSPC;
if(nr_lf) if(nr_lf)
free(p); free(p);
return s - buf_start; return (int)(s - buf_start);
} }
else else
{ {
@ -2071,7 +2071,7 @@ wchar_t * CDECL fgetws(wchar_t *s, int size, FILE* file)
*/ */
size_t CDECL fwrite(const void *ptr, size_t size, size_t nmemb, FILE* file) size_t CDECL fwrite(const void *ptr, size_t size, size_t nmemb, FILE* file)
{ {
size_t wrcnt=size * nmemb; int wrcnt=(int)(size * nmemb);
int written = 0; int written = 0;
if (size == 0) if (size == 0)
return 0; return 0;
@ -2184,7 +2184,7 @@ FILE * CDECL _fsopen(const char *path, const char *mode, int share)
*/ */
FILE * CDECL _wfsopen(const wchar_t *path, const wchar_t *mode, int share) FILE * CDECL _wfsopen(const wchar_t *path, const wchar_t *mode, int share)
{ {
const unsigned int plen = strlenW(path), mlen = strlenW(mode); const unsigned int plen = (unsigned)strlenW(path), mlen = (unsigned)strlenW(mode);
char *patha = calloc(plen + 1, 1); char *patha = calloc(plen + 1, 1);
char *modea = calloc(mlen + 1, 1); char *modea = calloc(mlen + 1, 1);
@ -2256,7 +2256,7 @@ int CDECL _fputchar(int c)
* fread (MSVCRT.@) * fread (MSVCRT.@)
*/ */
size_t CDECL fread(void *ptr, size_t size, size_t nmemb, FILE* file) size_t CDECL fread(void *ptr, size_t size, size_t nmemb, FILE* file)
{ size_t rcnt=size * nmemb; { int rcnt=(int)(size * nmemb);
size_t read=0; size_t read=0;
int pread=0; int pread=0;
@ -2431,7 +2431,7 @@ LONG CDECL ftell(FILE* file)
if(pos == -1) return -1; if(pos == -1) return -1;
if(file->_bufsiz) { if(file->_bufsiz) {
if( file->_flag & _IOWRT ) { if( file->_flag & _IOWRT ) {
off = file->_ptr - file->_base; off = (int)(file->_ptr - file->_base);
} else { } else {
off = -file->_cnt; off = -file->_cnt;
if (fdesc[file->_file].wxflag & WX_TEXT) { if (fdesc[file->_file].wxflag & WX_TEXT) {
@ -2457,7 +2457,7 @@ int CDECL fgetpos(FILE* file, fpos_t *pos)
if(*pos == -1) return -1; if(*pos == -1) return -1;
if(file->_bufsiz) { if(file->_bufsiz) {
if( file->_flag & _IOWRT ) { if( file->_flag & _IOWRT ) {
off = file->_ptr - file->_base; off = (int)(file->_ptr - file->_base);
} else { } else {
off = -file->_cnt; off = -file->_cnt;
if (fdesc[file->_file].wxflag & WX_TEXT) { if (fdesc[file->_file].wxflag & WX_TEXT) {
@ -2664,7 +2664,7 @@ int CDECL setvbuf(FILE* file, char *buf, int mode, size_t size)
file->_flag &= ~_IONBF; file->_flag &= ~_IONBF;
file->_base = file->_ptr = buf; file->_base = file->_ptr = buf;
if(buf) { if(buf) {
file->_bufsiz = size; file->_bufsiz = (int)size;
} }
} else { } else {
file->_flag |= _IONBF; file->_flag |= _IONBF;

View file

@ -14,9 +14,9 @@ intptr_t _tfindfirst(const _TCHAR* _name, struct _tfinddata_t* result)
} }
result->attrib = FindFileData.dwFileAttributes; result->attrib = FindFileData.dwFileAttributes;
result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL); result->time_create = (time_t)FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL);
result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL); result->time_access = (time_t)FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL);
result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL); result->time_write = (time_t)FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL);
result->size = (((__int64)FindFileData.nFileSizeHigh)<<32) + FindFileData.nFileSizeLow; result->size = (((__int64)FindFileData.nFileSizeHigh)<<32) + FindFileData.nFileSizeLow;
_tcsncpy(result->name,FindFileData.cFileName,MAX_PATH); _tcsncpy(result->name,FindFileData.cFileName,MAX_PATH);
@ -36,9 +36,9 @@ int _tfindnext(intptr_t handle, struct _tfinddata_t* result)
} }
result->attrib = FindFileData.dwFileAttributes; result->attrib = FindFileData.dwFileAttributes;
result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL); result->time_create = (time_t)FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL);
result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL); result->time_access = (time_t)FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL);
result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL); result->time_write = (time_t)FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL);
result->size = (((__int64)FindFileData.nFileSizeHigh)<<32) + FindFileData.nFileSizeLow; result->size = (((__int64)FindFileData.nFileSizeHigh)<<32) + FindFileData.nFileSizeLow;
_tcsncpy(result->name,FindFileData.cFileName, MAX_PATH); _tcsncpy(result->name,FindFileData.cFileName, MAX_PATH);

View file

@ -9,10 +9,10 @@
buf->st_uid = (buf64)->st_uid; \ buf->st_uid = (buf64)->st_uid; \
buf->st_gid = (buf64)->st_gid; \ buf->st_gid = (buf64)->st_gid; \
buf->st_rdev = (buf64)->st_rdev; \ buf->st_rdev = (buf64)->st_rdev; \
buf->st_size = (buf64)->st_size; \ buf->st_size = (_off_t)(buf64)->st_size; \
buf->st_atime = (buf64)->st_atime; \ buf->st_atime = (time_t)(buf64)->st_atime; \
buf->st_mtime = (buf64)->st_mtime; \ buf->st_mtime = (time_t)(buf64)->st_mtime; \
buf->st_ctime = (buf64)->st_ctime; \ buf->st_ctime = (time_t)(buf64)->st_ctime; \
int CDECL _tstat(const _TCHAR* path, struct _stat * buf) int CDECL _tstat(const _TCHAR* path, struct _stat * buf)
{ {

View file

@ -2,7 +2,7 @@
#include <tchar.h> #include <tchar.h>
#include <direct.h> #include <direct.h>
HANDLE fdtoh(int fd); HANDLE fdtoh(int fd);
#define ALL_S_IREAD (_S_IREAD | (_S_IREAD >> 3) | (_S_IREAD >> 6)) #define ALL_S_IREAD (_S_IREAD | (_S_IREAD >> 3) | (_S_IREAD >> 6))
#define ALL_S_IWRITE (_S_IWRITE | (_S_IWRITE >> 3) | (_S_IWRITE >> 6)) #define ALL_S_IWRITE (_S_IWRITE | (_S_IWRITE >> 3) | (_S_IWRITE >> 6))
@ -27,7 +27,7 @@ int CDECL _tstat64(const _TCHAR *path, struct __stat64 *buf)
DWORD dw; DWORD dw;
WIN32_FILE_ATTRIBUTE_DATA hfi; WIN32_FILE_ATTRIBUTE_DATA hfi;
unsigned short mode = ALL_S_IREAD; unsigned short mode = ALL_S_IREAD;
int plen; size_t plen;
TRACE(":file (%s) buf(%p)\n",path,buf); TRACE(":file (%s) buf(%p)\n",path,buf);
@ -136,7 +136,7 @@ int CDECL _fstat64(int fd, struct __stat64* buf)
buf->st_atime = dw; buf->st_atime = dw;
RtlTimeToSecondsSince1970((LARGE_INTEGER *)&hfi.ftLastWriteTime, &dw); RtlTimeToSecondsSince1970((LARGE_INTEGER *)&hfi.ftLastWriteTime, &dw);
buf->st_mtime = buf->st_ctime = dw; buf->st_mtime = buf->st_ctime = dw;
buf->st_nlink = hfi.nNumberOfLinks; buf->st_nlink = (short)hfi.nNumberOfLinks;
} }
TRACE(":dwFileAttributes = 0x%x, mode set to 0x%x\n",hfi.dwFileAttributes, TRACE(":dwFileAttributes = 0x%x, mode set to 0x%x\n",hfi.dwFileAttributes,
buf->st_mode); buf->st_mode);

View file

@ -23,7 +23,7 @@ void _atexit_cleanup(void)
_onexit_t __dllonexit(_onexit_t func, _onexit_t **start, _onexit_t **end) _onexit_t __dllonexit(_onexit_t func, _onexit_t **start, _onexit_t **end)
{ {
_onexit_t *tmp; _onexit_t *tmp;
int len; size_t len;
if (!start || !*start || !end || !*end) if (!start || !*start || !end || !*end)
return NULL; return NULL;

View file

@ -25,7 +25,7 @@ _TCHAR* _tfullpath(_TCHAR* absPath, const _TCHAR* relPath, size_t maxLength)
absPath = malloc(maxLength); absPath = malloc(maxLength);
} }
copied = GetFullPathName(relPath,maxLength,absPath,&lpFilePart); copied = GetFullPathName(relPath,(DWORD)maxLength,absPath,&lpFilePart);
if (copied == 0 || copied > maxLength) if (copied == 0 || copied > maxLength)
return NULL; return NULL;

View file

@ -17,7 +17,7 @@
char *getenv(const char *name) char *getenv(const char *name)
{ {
char **environ; char **environ;
unsigned int length = strlen(name); size_t length = strlen(name);
for (environ = *__p__environ(); *environ; environ++) for (environ = *__p__environ(); *environ; environ++)
{ {
@ -35,7 +35,7 @@ char *getenv(const char *name)
wchar_t *_wgetenv(const wchar_t *name) wchar_t *_wgetenv(const wchar_t *name)
{ {
wchar_t **environ; wchar_t **environ;
unsigned int length = wcslen(name); size_t length = wcslen(name);
for (environ = *__p__wenviron(); *environ; environ++) for (environ = *__p__wenviron(); *environ; environ++)
{ {

View file

@ -34,7 +34,7 @@ void _makepath(char* path, const char* drive, const char* dir, const char* fname
} }
if (dir && dir[0]) if (dir && dir[0])
{ {
unsigned int len = strlen(dir); size_t len = strlen(dir);
memmove(p, dir, len); memmove(p, dir, len);
p += len; p += len;
if (p[-1] != '/' && p[-1] != '\\') if (p[-1] != '/' && p[-1] != '\\')
@ -42,7 +42,7 @@ void _makepath(char* path, const char* drive, const char* dir, const char* fname
} }
if (fname && fname[0]) if (fname && fname[0])
{ {
unsigned int len = strlen(fname); size_t len = strlen(fname);
memmove(p, fname, len); memmove(p, fname, len);
p += len; p += len;
} }

View file

@ -44,9 +44,9 @@ int CDECL _makepath_s(char *path, size_t size, const char *drive,
if (directory && directory[0]) if (directory && directory[0])
{ {
unsigned int len = strlen(directory); size_t len = strlen(directory);
unsigned int needs_separator = directory[len - 1] != '/' && directory[len - 1] != '\\'; unsigned int needs_separator = directory[len - 1] != '/' && directory[len - 1] != '\\';
unsigned int copylen = min(size - 1, len); size_t copylen = min(size - 1, len);
if (size < 2) if (size < 2)
goto range; goto range;
@ -71,8 +71,8 @@ int CDECL _makepath_s(char *path, size_t size, const char *drive,
if (filename && filename[0]) if (filename && filename[0])
{ {
unsigned int len = strlen(filename); size_t len = strlen(filename);
unsigned int copylen = min(size - 1, len); size_t copylen = min(size - 1, len);
if (size < 2) if (size < 2)
goto range; goto range;
@ -88,9 +88,9 @@ int CDECL _makepath_s(char *path, size_t size, const char *drive,
if (extension && extension[0]) if (extension && extension[0])
{ {
unsigned int len = strlen(extension); size_t len = strlen(extension);
unsigned int needs_period = extension[0] != '.'; unsigned int needs_period = extension[0] != '.';
unsigned int copylen; size_t copylen;
if (size < 2) if (size < 2)
goto range; goto range;

View file

@ -53,9 +53,9 @@ static void
qst(size_t size, int (__cdecl *compar)(const void*, const void*), char *base, char *max) qst(size_t size, int (__cdecl *compar)(const void*, const void*), char *base, char *max)
{ {
char c, *i, *j, *jj; char c, *i, *j, *jj;
int ii; size_t ii;
char *mid, *tmp; char *mid, *tmp;
int lo, hi; size_t lo, hi;
size_t thresh; size_t thresh;
size_t mthresh; size_t mthresh;

View file

@ -32,7 +32,7 @@ void _wmakepath(wchar_t* path, const wchar_t* drive, const wchar_t* dir, const w
} }
if (dir && dir[0]) if (dir && dir[0])
{ {
unsigned int len = strlenW(dir); size_t len = strlenW(dir);
memmove(p, dir, len * sizeof(wchar_t)); memmove(p, dir, len * sizeof(wchar_t));
p += len; p += len;
if (p[-1] != '/' && p[-1] != '\\') if (p[-1] != '/' && p[-1] != '\\')
@ -40,7 +40,7 @@ void _wmakepath(wchar_t* path, const wchar_t* drive, const wchar_t* dir, const w
} }
if (fname && fname[0]) if (fname && fname[0])
{ {
unsigned int len = strlenW(fname); size_t len = strlenW(fname);
memmove(p, fname, len * sizeof(wchar_t)); memmove(p, fname, len * sizeof(wchar_t));
p += len; p += len;
} }

View file

@ -44,9 +44,9 @@ int CDECL _wmakepath_s(wchar_t *path, size_t size, const wchar_t *drive,
if (directory && directory[0]) if (directory && directory[0])
{ {
unsigned int len = strlenW(directory); size_t len = strlenW(directory);
unsigned int needs_separator = directory[len - 1] != '/' && directory[len - 1] != '\\'; unsigned int needs_separator = directory[len - 1] != '/' && directory[len - 1] != '\\';
unsigned int copylen = min(size - 1, len); size_t copylen = min(size - 1, len);
if (size < 2) if (size < 2)
goto range; goto range;
@ -71,8 +71,8 @@ int CDECL _wmakepath_s(wchar_t *path, size_t size, const wchar_t *drive,
if (filename && filename[0]) if (filename && filename[0])
{ {
unsigned int len = strlenW(filename); size_t len = strlenW(filename);
unsigned int copylen = min(size - 1, len); size_t copylen = min(size - 1, len);
if (size < 2) if (size < 2)
goto range; goto range;
@ -88,9 +88,9 @@ int CDECL _wmakepath_s(wchar_t *path, size_t size, const wchar_t *drive,
if (extension && extension[0]) if (extension && extension[0])
{ {
unsigned int len = strlenW(extension); size_t len = strlenW(extension);
unsigned int needs_period = extension[0] != '.'; unsigned int needs_period = extension[0] != '.';
unsigned int copylen; size_t copylen;
if (size < 2) if (size < 2)
goto range; goto range;

View file

@ -34,7 +34,7 @@ _i64tow(__int64 value, wchar_t *string, int radix)
*pos = '\0'; *pos = '\0';
do { do {
digit = val % radix; digit = (WCHAR)(val % radix);
val = val / radix; val = val / radix;
if (digit < 10) { if (digit < 10) {
*--pos = '0' + digit; *--pos = '0' + digit;
@ -68,7 +68,7 @@ _ui64tow(unsigned __int64 value, wchar_t *string, int radix)
*pos = '\0'; *pos = '\0';
do { do {
digit = value % radix; digit = (WCHAR)(value % radix);
value = value / radix; value = value / radix;
if (digit < 10) { if (digit < 10) {
*--pos = '0' + digit; *--pos = '0' + digit;
@ -120,7 +120,7 @@ _ltow(long value, wchar_t *string, int radix)
*pos = '\0'; *pos = '\0';
do { do {
digit = val % radix; digit = (WCHAR)(val % radix);
val = val / radix; val = val / radix;
if (digit < 10) { if (digit < 10) {
*--pos = '0' + digit; *--pos = '0' + digit;
@ -155,7 +155,7 @@ _ultow(unsigned long value, wchar_t *string, int radix)
*pos = '\0'; *pos = '\0';
do { do {
digit = value % radix; digit = (WCHAR)(value % radix);
value = value / radix; value = value / radix;
if (digit < 10) { if (digit < 10) {
*--pos = '0' + digit; *--pos = '0' + digit;

View file

@ -32,7 +32,7 @@ int mbtowc (wchar_t *wchar, const char *mbchar, size_t count)
*wchar = wc; *wchar = wc;
return mbs - mbarr; return (int)(mbs - mbarr);
} }
/* /*
@ -44,7 +44,7 @@ size_t mbstowcs (wchar_t *wcstr, const char *mbstr, size_t count)
ULONG Size; ULONG Size;
ULONG Length; ULONG Length;
Length = strlen (mbstr); Length = (ULONG)strlen (mbstr);
if (wcstr == NULL) if (wcstr == NULL)
{ {
@ -56,7 +56,7 @@ size_t mbstowcs (wchar_t *wcstr, const char *mbstr, size_t count)
} }
Status = RtlMultiByteToUnicodeN (wcstr, Status = RtlMultiByteToUnicodeN (wcstr,
count * sizeof(WCHAR), (ULONG)count * sizeof(WCHAR),
&Size, &Size,
mbstr, mbstr,
Length); Length);

View file

@ -170,7 +170,7 @@ _FUNCTION_ {
base = 0; base = 0;
number: { number: {
/* read an integer */ /* read an integer */
ULONGLONG cur = 0; __int64 cur = 0;
int negative = 0; int negative = 0;
int seendigit=0; int seendigit=0;
/* skip initial whitespace */ /* skip initial whitespace */
@ -224,7 +224,7 @@ _FUNCTION_ {
if (!seendigit) break; /* not a valid number */ if (!seendigit) break; /* not a valid number */
st = 1; st = 1;
if (!suppress) { if (!suppress) {
#define _SET_NUMBER_(type) *va_arg(ap, type*) = negative ? -cur : cur #define _SET_NUMBER_(type) *va_arg(ap, type*) = (type)(negative ? -cur : cur)
if (I64_prefix) _SET_NUMBER_(LONGLONG); if (I64_prefix) _SET_NUMBER_(LONGLONG);
else if (l_prefix) _SET_NUMBER_(LONG); else if (l_prefix) _SET_NUMBER_(LONG);
else if (h_prefix) _SET_NUMBER_(short int); else if (h_prefix) _SET_NUMBER_(short int);
@ -296,7 +296,7 @@ _FUNCTION_ {
if (width>0) width--; if (width>0) width--;
} }
/* update 'cur' with this exponent. */ /* update 'cur' with this exponent. */
expcnt = negexp ? .1 : 10; expcnt = negexp ? 0.1f : 10.0f;
while (exponent!=0) { while (exponent!=0) {
if (exponent&1) if (exponent&1)
cur*=expcnt; cur*=expcnt;

View file

@ -54,7 +54,7 @@ strtol(const char *nptr, char **endptr, int base)
* Set any if any `digits' consumed; make it negative to indicate * Set any if any `digits' consumed; make it negative to indicate
* overflow. * overflow.
*/ */
cutoff = neg ? -(unsigned long)LONG_MIN : LONG_MAX; cutoff = neg ? ((unsigned long)LONG_MAX+1) : LONG_MAX;
cutlim = cutoff % (unsigned long)base; cutlim = cutoff % (unsigned long)base;
cutoff /= (unsigned long)base; cutoff /= (unsigned long)base;
for (acc = 0, any = 0;; c = *s++) for (acc = 0, any = 0;; c = *s++)
@ -84,7 +84,7 @@ strtol(const char *nptr, char **endptr, int base)
#endif #endif
} }
else if (neg) else if (neg)
acc = -acc; acc = 0-acc;
if (endptr != 0) if (endptr != 0)
*endptr = any ? (char *)((size_t)(s - 1)) : (char *)((size_t)nptr); *endptr = any ? (char *)((size_t)(s - 1)) : (char *)((size_t)nptr);
return acc; return acc;

View file

@ -68,7 +68,7 @@ strtoul(const char *nptr, char **endptr, int base)
#endif #endif
} }
else if (neg) else if (neg)
acc = -acc; acc = 0-acc;
if (endptr != 0) if (endptr != 0)
*endptr = any ? (char *)((size_t)(s - 1)) : (char *)((size_t)nptr); *endptr = any ? (char *)((size_t)(s - 1)) : (char *)((size_t)nptr);
return acc; return acc;

View file

@ -59,7 +59,7 @@ strtoull(const char *nptr, char **endptr, int base)
#endif #endif
} }
else if (neg) else if (neg)
acc = -acc; acc = 0-acc;
if (endptr != 0) if (endptr != 0)
*endptr = any ? (char *)((size_t)(s - 1)) : (char *)((size_t)nptr); *endptr = any ? (char *)((size_t)(s - 1)) : (char *)((size_t)nptr);
return acc; return acc;

View file

@ -60,7 +60,7 @@ wchar_t* CDECL _wcsdup( const wchar_t* str )
wchar_t* ret = NULL; wchar_t* ret = NULL;
if (str) if (str)
{ {
int size = (strlenW(str) + 1) * sizeof(wchar_t); size_t size = (strlenW(str) + 1) * sizeof(wchar_t);
ret = malloc( size ); ret = malloc( size );
if (ret) memcpy( ret, str, size ); if (ret) memcpy( ret, str, size );
} }
@ -386,7 +386,7 @@ size_t CDECL wcstombs(char *mbstr, const wchar_t *wcstr, size_t count)
*/ */
INT CDECL wcscpy_s( wchar_t* wcDest, size_t numElement, const wchar_t *wcSrc) INT CDECL wcscpy_s( wchar_t* wcDest, size_t numElement, const wchar_t *wcSrc)
{ {
INT size = 0; size_t size = 0;
if(!wcDest || !numElement) if(!wcDest || !numElement)
return EINVAL; return EINVAL;

View file

@ -63,7 +63,7 @@ wcstol(const wchar_t *nptr, wchar_t **endptr, int base)
* Set any if any `digits' consumed; make it negative to indicate * Set any if any `digits' consumed; make it negative to indicate
* overflow. * overflow.
*/ */
cutoff = neg ? -(unsigned long)LONG_MIN : LONG_MAX; cutoff = neg ? ((unsigned long)LONG_MAX+1) : LONG_MAX;
cutlim = cutoff % (unsigned long)base; cutlim = cutoff % (unsigned long)base;
cutoff /= (unsigned long)base; cutoff /= (unsigned long)base;
for (acc = 0, any = 0;; c = *s++) for (acc = 0, any = 0;; c = *s++)
@ -90,7 +90,7 @@ wcstol(const wchar_t *nptr, wchar_t **endptr, int base)
acc = neg ? LONG_MIN : LONG_MAX; acc = neg ? LONG_MIN : LONG_MAX;
} }
else if (neg) else if (neg)
acc = -acc; acc = 0-acc;
if (endptr != 0) if (endptr != 0)
*endptr = any ? (wchar_t *)((size_t)(s - 1)) : (wchar_t *)((size_t)nptr); *endptr = any ? (wchar_t *)((size_t)(s - 1)) : (wchar_t *)((size_t)nptr);
return acc; return acc;

View file

@ -34,7 +34,7 @@ size_t wcstombs (char *mbstr, const wchar_t *wcstr, size_t count)
ULONG Size; ULONG Size;
ULONG Length; ULONG Length;
Length = wcslen (wcstr); Length = (ULONG)wcslen (wcstr);
if (mbstr == NULL) if (mbstr == NULL)
{ {
@ -46,7 +46,7 @@ size_t wcstombs (char *mbstr, const wchar_t *wcstr, size_t count)
} }
Status = RtlUnicodeToMultiByteN (mbstr, Status = RtlUnicodeToMultiByteN (mbstr,
count, (ULONG)count,
&Size, &Size,
(wchar_t*)((size_t)wcstr), (wchar_t*)((size_t)wcstr),
Length * sizeof(WCHAR)); Length * sizeof(WCHAR));

View file

@ -65,7 +65,7 @@ wcstoul(const wchar_t *nptr, wchar_t **endptr, int base)
acc = ULONG_MAX; acc = ULONG_MAX;
} }
else if (neg) else if (neg)
acc = -acc; acc = 0-acc;
if (endptr != 0) if (endptr != 0)
*endptr = any ? (wchar_t *)((size_t)(s - 1)) : (wchar_t *)((size_t)nptr); *endptr = any ? (wchar_t *)((size_t)(s - 1)) : (wchar_t *)((size_t)nptr);
return acc; return acc;

View file

@ -32,7 +32,7 @@ _wtol(const wchar_t *str)
str++; str++;
} /* while */ } /* while */
return bMinus ? -RunningTotal : RunningTotal; return bMinus ? 0-RunningTotal : RunningTotal;
} }

View file

@ -26,5 +26,5 @@ clock(void)
GetSystemTimeAsFileTime((FILETIME*)&Time); GetSystemTimeAsFileTime((FILETIME*)&Time);
Time.QuadPart -= g_StartupTime.QuadPart; Time.QuadPart -= g_StartupTime.QuadPart;
return FileTimeToUnixTime((FILETIME*)&Time, NULL); return (clock_t)FileTimeToUnixTime((FILETIME*)&Time, NULL);
}; };

View file

@ -13,7 +13,7 @@
/****************************************************************************** /******************************************************************************
* \name _ftime_s * \name _ftime_s
* \brief Get the current time. * \brief Get the current time.
* \param [out] ptimeb Pointer to a structure of type struct _timeb that * \param [out] ptimeb Pointer to a structure of type struct _timeb that
* recieves the current time. * recieves the current time.
* \sa http://msdn.microsoft.com/en-us/library/95e68951.aspx * \sa http://msdn.microsoft.com/en-us/library/95e68951.aspx
*/ */
@ -39,10 +39,10 @@ _ftime_s(struct _timeb *ptimeb)
ret = GetTimeZoneInformation(&TimeZoneInformation); ret = GetTimeZoneInformation(&TimeZoneInformation);
ptimeb->dstflag = (ret == TIME_ZONE_ID_DAYLIGHT) ? 1 : 0; ptimeb->dstflag = (ret == TIME_ZONE_ID_DAYLIGHT) ? 1 : 0;
ptimeb->timezone = TimeZoneInformation.Bias; ptimeb->timezone = (short)TimeZoneInformation.Bias;
GetSystemTimeAsFileTime(&SystemTime); GetSystemTimeAsFileTime(&SystemTime);
ptimeb->time = FileTimeToUnixTime(&SystemTime, &ptimeb->millitm); ptimeb->time = (time_t)FileTimeToUnixTime(&SystemTime, &ptimeb->millitm);
return 0; return 0;
} }
@ -50,9 +50,9 @@ _ftime_s(struct _timeb *ptimeb)
/****************************************************************************** /******************************************************************************
* \name _ftime * \name _ftime
* \brief Get the current time. * \brief Get the current time.
* \param [out] ptimeb Pointer to a structure of type struct _timeb that * \param [out] ptimeb Pointer to a structure of type struct _timeb that
* recieves the current time. * recieves the current time.
* \note This function is for compatability and simply calls the secure * \note This function is for compatability and simply calls the secure
* version _ftime_s(). * version _ftime_s().
* \sa http://msdn.microsoft.com/en-us/library/z54t9z5f.aspx * \sa http://msdn.microsoft.com/en-us/library/z54t9z5f.aspx
*/ */

View file

@ -44,7 +44,7 @@ HANDLE fdtoh(int fd);
/****************************************************************************** /******************************************************************************
* \name _futime * \name _futime
* \brief Set a files modification time. * \brief Set a file's modification time.
* \param [out] ptimeb Pointer to a structure of type struct _timeb that * \param [out] ptimeb Pointer to a structure of type struct _timeb that
* recieves the current time. * recieves the current time.
* \sa http://msdn.microsoft.com/en-us/library/95e68951.aspx * \sa http://msdn.microsoft.com/en-us/library/95e68951.aspx
@ -65,19 +65,22 @@ _futime(int fd, struct _utimbuf *filetime)
{ {
time_t currTime; time_t currTime;
_time(&currTime); _time(&currTime);
RtlSecondsSince1970ToTime(currTime, (LARGE_INTEGER *)&at); RtlSecondsSince1970ToTime((ULONG)currTime,
(LARGE_INTEGER *)&at);
wt = at; wt = at;
} }
else else
{ {
RtlSecondsSince1970ToTime(filetime->actime, (LARGE_INTEGER *)&at); RtlSecondsSince1970ToTime((ULONG)filetime->actime,
(LARGE_INTEGER *)&at);
if (filetime->actime == filetime->modtime) if (filetime->actime == filetime->modtime)
{ {
wt = at; wt = at;
} }
else else
{ {
RtlSecondsSince1970ToTime(filetime->modtime, (LARGE_INTEGER *)&wt); RtlSecondsSince1970ToTime((ULONG)filetime->modtime,
(LARGE_INTEGER *)&wt);
} }
} }

View file

@ -23,7 +23,7 @@ _gmtime_worker(struct tm *ptm, __time64_t time, int do_dst)
} }
/* Divide into date and time */ /* Divide into date and time */
days = time / SECONDSPERDAY; days = (unsigned int)(time / SECONDSPERDAY);
secondinday = time % SECONDSPERDAY; secondinday = time % SECONDSPERDAY;
/* Shift to days from 1.1.1601 */ /* Shift to days from 1.1.1601 */
@ -61,11 +61,11 @@ _gmtime_worker(struct tm *ptm, __time64_t time, int do_dst)
ptm->tm_isdst = 0; ptm->tm_isdst = 0;
if (do_dst) if (do_dst)
{ {
unsigned int yeartime = dayinyear * SECONDSPERDAY + secondinday ; int yeartime = dayinyear * SECONDSPERDAY + secondinday ;
if (yeartime >= dst_begin && yeartime <= dst_end) // FIXME! DST in winter if (yeartime >= dst_begin && yeartime <= dst_end) // FIXME! DST in winter
{ {
time -= _dstbias; time -= _dstbias;
days = time / SECONDSPERDAY + DIFFDAYS; days = (unsigned int)(time / SECONDSPERDAY + DIFFDAYS);
dayinyear = days - daystoyear; dayinyear = days - daystoyear;
ptm->tm_isdst = 1; ptm->tm_isdst = 1;
} }
@ -97,7 +97,7 @@ _gmtime_worker(struct tm *ptm, __time64_t time, int do_dst)
/****************************************************************************** /******************************************************************************
* \name _gmtime64 * \name _gmtime64
* \brief * \brief
* \param ptime Pointer to a variable of type __time64_t containing the time. * \param ptime Pointer to a variable of type __time64_t containing the time.
*/ */
struct tm * struct tm *
@ -123,7 +123,7 @@ _gmtime64(const __time64_t * ptime)
/****************************************************************************** /******************************************************************************
* \name _gmtime32 * \name _gmtime32
* \brief * \brief
* \param ptime Pointer to a variable of type __time32_t containing the time. * \param ptime Pointer to a variable of type __time32_t containing the time.
*/ */
struct tm * struct tm *
@ -135,7 +135,7 @@ _gmtime32(const __time32_t * ptime)
/****************************************************************************** /******************************************************************************
* \name gmtime * \name gmtime
* \brief * \brief
* \param ptime Pointer to a variable of type time_t containing the time. * \param ptime Pointer to a variable of type time_t containing the time.
*/ */
struct tm * struct tm *

View file

@ -106,36 +106,36 @@ mktime_worker(struct tm * ptm, int utc)
int tm_isdst; int tm_isdst;
*/ */
/** /**
* \name _mkgmtime * \name _mkgmtime
* *
*/ */
time_t time_t
_mkgmtime(struct tm *ptm) _mkgmtime(struct tm *ptm)
{ {
time_t time = mktime_worker(ptm, 1); __time64_t time = mktime_worker(ptm, 1);
return (time > MAX_32BIT_TIME) ? -1 : time; return (time_t)((time > MAX_32BIT_TIME) ? -1 : time);
} }
time_t time_t
mktime(struct tm *ptm) mktime(struct tm *ptm)
{ {
time_t time = mktime_worker(ptm, 0); __time64_t time = mktime_worker(ptm, 0);
return (time > MAX_32BIT_TIME) ? -1 : time; return (time_t)((time > MAX_32BIT_TIME) ? -1 : time);
} }
__time32_t __time32_t
_mkgmtime32(struct tm *ptm) _mkgmtime32(struct tm *ptm)
{ {
time_t time = mktime_worker(ptm, 1); __time64_t time = mktime_worker(ptm, 1);
return (time > MAX_32BIT_TIME) ? -1 : time; return (__time32_t)((time > MAX_32BIT_TIME) ? -1 : time);
} }
__time32_t __time32_t
_mktime32(struct tm *ptm) _mktime32(struct tm *ptm)
{ {
time_t time = mktime_worker(ptm, 0); __time64_t time = mktime_worker(ptm, 0);
return (time > MAX_32BIT_TIME) ? -1 : time; return (__time32_t)((time > MAX_32BIT_TIME) ? -1 : time);
} }
__time64_t __time64_t

View file

@ -15,7 +15,7 @@ time_t _time(time_t* ptime)
time_t time = 0; time_t time = 0;
GetSystemTimeAsFileTime(&SystemTime); GetSystemTimeAsFileTime(&SystemTime);
time = FileTimeToUnixTime(&SystemTime, NULL); time = (time_t)FileTimeToUnixTime(&SystemTime, NULL);
if (ptime) if (ptime)
{ {

View file

@ -65,7 +65,7 @@ long _dstbias = 0;
* \name __p__dstbias * \name __p__dstbias
* \brief Returns a pointer to the _dstbias variable; * \brief Returns a pointer to the _dstbias variable;
*/ */
long * long *
__p__dstbias(void) __p__dstbias(void)
{ {
return &_dstbias; return &_dstbias;
@ -103,7 +103,7 @@ _tzset(void)
if (str && str[0] != 0) if (str && str[0] != 0)
{ {
long hour = 0, min = 0, sec = 0; long hour = 0, min = 0, sec = 0;
int len = strnlen(str, 16); size_t len = strnlen(str, 16);
int sign = 1; int sign = 1;
dst_begin = 0; dst_begin = 0;
@ -143,7 +143,7 @@ _tzset(void)
/* Copy DST name */ /* Copy DST name */
strncpy(tz_dst_name, str, 3); strncpy(tz_dst_name, str, 3);
// FIXME: set dst_begin etc // FIXME: set dst_begin etc
/* We are finished */ /* We are finished */
@ -151,7 +151,7 @@ _tzset(void)
} }
_timezone = sign * (((hour * 60) + min) * 60 + sec); _timezone = sign * (((hour * 60) + min) * 60 + sec);
} }
else else
{ {
@ -163,7 +163,7 @@ _tzset(void)
{ {
return; return;
} }
ret = WideCharToMultiByte(CP_ACP, ret = WideCharToMultiByte(CP_ACP,
0, 0,
tzi.StandardName, tzi.StandardName,
@ -196,13 +196,13 @@ _tzset(void)
_tm.tm_hour = tzi.DaylightDate.wHour; _tm.tm_hour = tzi.DaylightDate.wHour;
_tm.tm_min = tzi.DaylightDate.wMinute; _tm.tm_min = tzi.DaylightDate.wMinute;
_tm.tm_sec = tzi.DaylightDate.wSecond; _tm.tm_sec = tzi.DaylightDate.wSecond;
dst_begin = _mkgmtime(&_tm); dst_begin = (long)_mkgmtime(&_tm);
_tm.tm_mon = tzi.StandardDate.wMonth - 1; _tm.tm_mon = tzi.StandardDate.wMonth - 1;
_tm.tm_mday = tzi.StandardDate.wDay; _tm.tm_mday = tzi.StandardDate.wDay;
_tm.tm_hour = tzi.StandardDate.wHour; _tm.tm_hour = tzi.StandardDate.wHour;
_tm.tm_min = tzi.StandardDate.wMinute; _tm.tm_min = tzi.StandardDate.wMinute;
_tm.tm_sec = tzi.StandardDate.wSecond; _tm.tm_sec = tzi.StandardDate.wSecond;
dst_end = _mkgmtime(&_tm); dst_end = (long)_mkgmtime(&_tm);
} }
else else
{ {

View file

@ -40,7 +40,7 @@ typedef void (*MSVCRT_new_handler_func)(size_t size);
static MSVCRT_new_handler_func MSVCRT_new_handler; static MSVCRT_new_handler_func MSVCRT_new_handler;
static int MSVCRT_new_mode; static int MSVCRT_new_mode;
/* FIXME - According to documentation it should be 8*1024, at runtime it returns 16 */ /* FIXME - According to documentation it should be 8*1024, at runtime it returns 16 */
static unsigned int MSVCRT_amblksiz = 16; static unsigned int MSVCRT_amblksiz = 16;
/* FIXME - According to documentation it should be 480 bytes, at runtime default is 0 */ /* FIXME - According to documentation it should be 480 bytes, at runtime default is 0 */
static size_t MSVCRT_sbh_threshold = 0; static size_t MSVCRT_sbh_threshold = 0;
@ -148,7 +148,7 @@ int CDECL _callnewh(size_t size)
*/ */
void* CDECL _expand(void* mem, size_t size) void* CDECL _expand(void* mem, size_t size)
{ {
return HeapReAlloc(GetProcessHeap(), HEAP_REALLOC_IN_PLACE_ONLY, mem, size); return HeapReAlloc(GetProcessHeap(), HEAP_REALLOC_IN_PLACE_ONLY, mem, (DWORD)size);
} }
/********************************************************************* /*********************************************************************
@ -187,7 +187,7 @@ int CDECL _heapwalk(_HEAPINFO* next)
LOCK_HEAP; LOCK_HEAP;
phe.lpData = next->_pentry; phe.lpData = next->_pentry;
phe.cbData = next->_size; phe.cbData = (DWORD)next->_size;
phe.wFlags = next->_useflag == _USEDENTRY ? PROCESS_HEAP_ENTRY_BUSY : 0; phe.wFlags = next->_useflag == _USEDENTRY ? PROCESS_HEAP_ENTRY_BUSY : 0;
if (phe.lpData && phe.wFlags & PROCESS_HEAP_ENTRY_BUSY && if (phe.lpData && phe.wFlags & PROCESS_HEAP_ENTRY_BUSY &&
@ -303,7 +303,7 @@ void* CDECL malloc(size_t size)
void* CDECL realloc(void* ptr, size_t size) void* CDECL realloc(void* ptr, size_t size)
{ {
if (!ptr) return malloc(size); if (!ptr) return malloc(size);
if (size) return HeapReAlloc(GetProcessHeap(), 0, ptr, size); if (size) return HeapReAlloc(GetProcessHeap(), 0, ptr, (DWORD)size);
free(ptr); free(ptr);
return NULL; return NULL;
} }

View file

@ -53,7 +53,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
#define UNDNAME_NO_COMPLEX_TYPE (0x8000) #define UNDNAME_NO_COMPLEX_TYPE (0x8000)
/* How data types modifiers are stored: /* How data types modifiers are stored:
* M (in the following definitions) is defined for * M (in the following definitions) is defined for
* 'A', 'B', 'C' and 'D' as follows * 'A', 'B', 'C' and 'D' as follows
* {<A>}: "" * {<A>}: ""
* {<B>}: "const " * {<B>}: "const "
@ -67,7 +67,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
* in data fields: * in data fields:
* same as for arguments and also the following * same as for arguments and also the following
* ?<M>x {<M>}x * ?<M>x {<M>}x
* *
*/ */
struct array struct array
@ -127,7 +127,7 @@ static void* und_alloc(struct parsed_symbol* sym, unsigned int len)
sym->avail_in_first = 0; sym->avail_in_first = 0;
ptr = (char*)sym->alloc_list + sizeof(void*); ptr = (char*)sym->alloc_list + sizeof(void*);
} }
else else
{ {
if (len > sym->avail_in_first) if (len > sym->avail_in_first)
{ {
@ -201,14 +201,14 @@ static BOOL str_array_push(struct parsed_symbol* sym, const char* ptr, int len,
a->alloc *= 2; a->alloc *= 2;
a->elts = new; a->elts = new;
} }
if (len == -1) len = strlen(ptr); if (len == -1) len = (int)strlen(ptr);
a->elts[a->num] = und_alloc(sym, len + 1); a->elts[a->num] = und_alloc(sym, len + 1);
assert(a->elts[a->num]); assert(a->elts[a->num]);
memcpy(a->elts[a->num], ptr, len); memcpy(a->elts[a->num], ptr, len);
a->elts[a->num][len] = '\0'; a->elts[a->num][len] = '\0';
if (++a->num >= a->max) a->max = a->num; if (++a->num >= a->max) a->max = a->num;
{ {
int i; unsigned int i;
char c; char c;
for (i = a->max - 1; i >= 0; i--) for (i = a->max - 1; i >= 0; i--)
@ -234,18 +234,18 @@ static char* str_array_get_ref(struct array* cref, unsigned idx)
assert(cref); assert(cref);
if (cref->start + idx >= cref->max) if (cref->start + idx >= cref->max)
{ {
WARN("Out of bounds: %p %d + %d >= %d\n", WARN("Out of bounds: %p %d + %d >= %d\n",
cref, cref->start, idx, cref->max); cref, cref->start, idx, cref->max);
return NULL; return NULL;
} }
TRACE("Returning %p[%d] => %s\n", TRACE("Returning %p[%d] => %s\n",
cref, idx, cref->elts[cref->start + idx]); cref, idx, cref->elts[cref->start + idx]);
return cref->elts[cref->start + idx]; return cref->elts[cref->start + idx];
} }
/****************************************************************** /******************************************************************
* str_printf * str_printf
* Helper for printf type of command (only %s and %c are implemented) * Helper for printf type of command (only %s and %c are implemented)
* while dynamically allocating the buffer * while dynamically allocating the buffer
*/ */
static char* str_printf(struct parsed_symbol* sym, const char* format, ...) static char* str_printf(struct parsed_symbol* sym, const char* format, ...)
@ -263,7 +263,7 @@ static char* str_printf(struct parsed_symbol* sym, const char* format, ...)
{ {
switch (format[++i]) switch (format[++i])
{ {
case 's': t = va_arg(args, char*); if (t) len += strlen(t); break; case 's': t = va_arg(args, char*); if (t) len += (int)strlen(t); break;
case 'c': (void)va_arg(args, int); len++; break; case 'c': (void)va_arg(args, int); len++; break;
default: i--; /* fall thru */ default: i--; /* fall thru */
case '%': len++; break; case '%': len++; break;
@ -284,7 +284,7 @@ static char* str_printf(struct parsed_symbol* sym, const char* format, ...)
t = va_arg(args, char*); t = va_arg(args, char*);
if (t) if (t)
{ {
sz = strlen(t); sz = (int)strlen(t);
memcpy(p, t, sz); memcpy(p, t, sz);
p += sz; p += sz;
} }
@ -358,7 +358,7 @@ static const char* get_number(struct parsed_symbol* sym)
* Parses a list of function/method arguments, creates a string corresponding * Parses a list of function/method arguments, creates a string corresponding
* to the arguments' list. * to the arguments' list.
*/ */
static char* get_args(struct parsed_symbol* sym, struct array* pmt_ref, BOOL z_term, static char* get_args(struct parsed_symbol* sym, struct array* pmt_ref, BOOL z_term,
char open_char, char close_char) char open_char, char close_char)
{ {
@ -393,8 +393,8 @@ static char* get_args(struct parsed_symbol* sym, struct array* pmt_ref, BOOL z_t
*/ */
if (z_term && *sym->current++ != 'Z') return NULL; if (z_term && *sym->current++ != 'Z') return NULL;
if (arg_collect.num == 0 || if (arg_collect.num == 0 ||
(arg_collect.num == 1 && !strcmp(arg_collect.elts[0], "void"))) (arg_collect.num == 1 && !strcmp(arg_collect.elts[0], "void")))
return str_printf(sym, "%cvoid%c", open_char, close_char); return str_printf(sym, "%cvoid%c", open_char, close_char);
for (i = 1; i < arg_collect.num; i++) for (i = 1; i < arg_collect.num; i++)
{ {
@ -403,12 +403,12 @@ static char* get_args(struct parsed_symbol* sym, struct array* pmt_ref, BOOL z_t
last = args_str ? args_str : arg_collect.elts[0]; last = args_str ? args_str : arg_collect.elts[0];
if (close_char == '>' && last[strlen(last) - 1] == '>') if (close_char == '>' && last[strlen(last) - 1] == '>')
args_str = str_printf(sym, "%c%s%s %c", args_str = str_printf(sym, "%c%s%s %c",
open_char, arg_collect.elts[0], args_str, close_char); open_char, arg_collect.elts[0], args_str, close_char);
else else
args_str = str_printf(sym, "%c%s%s%c", args_str = str_printf(sym, "%c%s%s%c",
open_char, arg_collect.elts[0], args_str, close_char); open_char, arg_collect.elts[0], args_str, close_char);
return args_str; return args_str;
} }
@ -516,7 +516,7 @@ static char* get_literal_string(struct parsed_symbol* sym)
} }
} while (*++sym->current != '@'); } while (*++sym->current != '@');
sym->current++; sym->current++;
if (!str_array_push(sym, ptr, sym->current - 1 - ptr, &sym->names)) if (!str_array_push(sym, ptr, (int)(sym->current - 1 - ptr), &sym->names))
return NULL; return NULL;
return str_array_get_ref(&sym->names, sym->names.num - sym->names.start - 1); return str_array_get_ref(&sym->names, sym->names.num - sym->names.start - 1);
@ -582,7 +582,7 @@ static BOOL get_class(struct parsed_symbol* sym)
name = str_array_get_ref(&sym->names, *sym->current++ - '0'); name = str_array_get_ref(&sym->names, *sym->current++ - '0');
break; break;
case '?': case '?':
if (*++sym->current == '$') if (*++sym->current == '$')
{ {
sym->current++; sym->current++;
if ((name = get_template_name(sym)) && if ((name = get_template_name(sym)) &&
@ -613,15 +613,15 @@ static char* get_class_string(struct parsed_symbol* sym, int start)
char* ret; char* ret;
struct array *a = &sym->stack; struct array *a = &sym->stack;
for (len = 0, i = start; i < a->num; i++) for (len = 0, i = start; i < (int)a->num; i++)
{ {
assert(a->elts[i]); assert(a->elts[i]);
len += 2 + strlen(a->elts[i]); len += 2 + (int)strlen(a->elts[i]);
} }
if (!(ret = und_alloc(sym, len - 1))) return NULL; if (!(ret = und_alloc(sym, len - 1))) return NULL;
for (len = 0, i = a->num - 1; i >= start; i--) for (len = 0, i = a->num - 1; i >= start; i--)
{ {
sz = strlen(a->elts[i]); sz = (int)strlen(a->elts[i]);
memcpy(ret + len, a->elts[i], sz); memcpy(ret + len, a->elts[i], sz);
len += sz; len += sz;
if (i > start) if (i > start)
@ -702,7 +702,7 @@ static BOOL get_calling_convention(char ch, const char** call_conv,
static const char* get_simple_type(char c) static const char* get_simple_type(char c)
{ {
const char* type_string; const char* type_string;
switch (c) switch (c)
{ {
case 'C': type_string = "signed char"; break; case 'C': type_string = "signed char"; break;
@ -731,7 +731,7 @@ static const char* get_simple_type(char c)
static const char* get_extended_type(char c) static const char* get_extended_type(char c)
{ {
const char* type_string; const char* type_string;
switch (c) switch (c)
{ {
case 'D': type_string = "__int8"; break; case 'D': type_string = "__int8"; break;
@ -766,7 +766,7 @@ static BOOL demangle_datatype(struct parsed_symbol* sym, struct datatype_t* ct,
assert(ct); assert(ct);
ct->left = ct->right = NULL; ct->left = ct->right = NULL;
switch (dt = *sym->current++) switch (dt = *sym->current++)
{ {
case '_': case '_':
@ -791,7 +791,7 @@ static BOOL demangle_datatype(struct parsed_symbol* sym, struct datatype_t* ct,
if (!(struct_name = get_class_name(sym))) if (!(struct_name = get_class_name(sym)))
goto done; goto done;
if (!(sym->flags & UNDNAME_NO_COMPLEX_TYPE)) if (!(sym->flags & UNDNAME_NO_COMPLEX_TYPE))
{ {
switch (dt) switch (dt)
{ {
@ -839,7 +839,7 @@ static BOOL demangle_datatype(struct parsed_symbol* sym, struct datatype_t* ct,
unsigned mark = sym->stack.num; unsigned mark = sym->stack.num;
if (!get_calling_convention(*sym->current++, if (!get_calling_convention(*sym->current++,
&call_conv, &exported, &call_conv, &exported,
sym->flags & ~UNDNAME_NO_ALLOCATION_LANGUAGE) || sym->flags & ~UNDNAME_NO_ALLOCATION_LANGUAGE) ||
!demangle_datatype(sym, &sub_ct, pmt_ref, FALSE)) !demangle_datatype(sym, &sub_ct, pmt_ref, FALSE))
goto done; goto done;
@ -848,7 +848,7 @@ static BOOL demangle_datatype(struct parsed_symbol* sym, struct datatype_t* ct,
if (!args) goto done; if (!args) goto done;
sym->stack.num = mark; sym->stack.num = mark;
ct->left = str_printf(sym, "%s%s (%s*", ct->left = str_printf(sym, "%s%s (%s*",
sub_ct.left, sub_ct.right, call_conv); sub_ct.left, sub_ct.right, call_conv);
ct->right = str_printf(sym, ")%s", args); ct->right = str_printf(sym, ")%s", args);
} }
@ -944,7 +944,7 @@ static BOOL demangle_datatype(struct parsed_symbol* sym, struct datatype_t* ct,
return FALSE; return FALSE;
} }
done: done:
return ct->left != NULL; return ct->left != NULL;
} }
@ -980,7 +980,7 @@ static BOOL handle_data(struct parsed_symbol* sym)
case '0': access = "private: "; break; case '0': access = "private: "; break;
case '1': access = "protected: "; break; case '1': access = "protected: "; break;
case '2': access = "public: "; break; case '2': access = "public: "; break;
} }
} }
if (!(sym->flags & UNDNAME_NO_MEMBER_TYPE)) if (!(sym->flags & UNDNAME_NO_MEMBER_TYPE))
@ -1028,8 +1028,8 @@ static BOOL handle_data(struct parsed_symbol* sym)
if (sym->flags & UNDNAME_NAME_ONLY) ct.left = ct.right = modifier = NULL; if (sym->flags & UNDNAME_NAME_ONLY) ct.left = ct.right = modifier = NULL;
sym->result = str_printf(sym, "%s%s%s%s%s%s%s%s", access, sym->result = str_printf(sym, "%s%s%s%s%s%s%s%s", access,
member_type, ct.left, member_type, ct.left,
modifier && ct.left ? " " : NULL, modifier, modifier && ct.left ? " " : NULL, modifier,
modifier || ct.left ? " " : NULL, name, ct.right); modifier || ct.left ? " " : NULL, name, ct.right);
ret = TRUE; ret = TRUE;
done: done:
@ -1163,10 +1163,10 @@ static BOOL handle_method(struct parsed_symbol* sym, BOOL cast_op)
* Yet!!! FIXME * Yet!!! FIXME
*/ */
sym->result = str_printf(sym, "%s%s%s%s%s%s%s%s%s%s%s%s", sym->result = str_printf(sym, "%s%s%s%s%s%s%s%s%s%s%s%s",
access, member_type, ct_ret.left, access, member_type, ct_ret.left,
(ct_ret.left && !ct_ret.right) ? " " : NULL, (ct_ret.left && !ct_ret.right) ? " " : NULL,
call_conv, call_conv ? " " : NULL, exported, call_conv, call_conv ? " " : NULL, exported,
name, args_str, modifier, name, args_str, modifier,
modifier ? " " : NULL, ct_ret.right); modifier ? " " : NULL, ct_ret.right);
ret = TRUE; ret = TRUE;
done: done:
@ -1446,7 +1446,7 @@ char* CDECL __unDNameEx(char* buffer, const char* mangled, int buflen,
TRACE("(%p,%s,%d,%p,%p,%p,%x)\n", TRACE("(%p,%s,%d,%p,%p,%p,%x)\n",
buffer, mangled, buflen, memget, memfree, unknown, flags); buffer, mangled, buflen, memget, memfree, unknown, flags);
/* The flags details is not documented by MS. However, it looks exactly /* The flags details is not documented by MS. However, it looks exactly
* like the UNDNAME_ manifest constants from imagehlp.h and dbghelp.h * like the UNDNAME_ manifest constants from imagehlp.h and dbghelp.h
* So, we copied those (on top of the file) * So, we copied those (on top of the file)