- 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
#define siglongjmp(buf,val) longjmp(buf,val)
#endif
+#ifdef _MSC_VER
+#pragma warning(push)
+#pragma warning(disable:4733)
+#endif
+
static inline EXCEPTION_REGISTRATION_RECORD *__wine_push_frame( EXCEPTION_REGISTRATION_RECORD *frame )
{
#ifdef __i386__
#endif
}
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif
+
extern void __wine_enter_vm86( CONTEXT *context );
#ifdef __cplusplus
UNLOCK_CONSOLE;
return retval;
#else
- int len = strlen(_str);
+ int len = (int)strlen(_str);
DWORD written = 0;
if (!WriteFile( fdesc[stdout->_file].hFile ,_str,len,&written,NULL))
return -1;
except/amd64/seh.s
except/amd64/ehandler.c
float/amd64/clearfp.S
+ float/amd64/getsetfpcw.S
float/i386/cntrlfp.c
float/amd64/fpreset.S
float/amd64/logb.S
_this->vtable = &MSVCRT_exception_vtable;
if (*name)
{
- unsigned int name_len = strlen(*name) + 1;
+ size_t name_len = strlen(*name) + 1;
_this->name = MSVCRT_malloc(name_len);
memcpy(_this->name, *name, name_len);
_this->do_free = TRUE;
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 */
while (len && name[--len] == ' ')
{
TRACE( "calling copy ctor %p object %p src %p\n", func, this, src );
#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
if (has_vbase)
/* in that case copy ctor takes an extra bool indicating whether to copy the base class */
static inline void call_dtor( void *func, void *object )
{
#ifdef _MSC_VER
-#pragma message ("call_dtor is unimplemented for MSC")
+ __asm
+ {
+ mov ecx, object
+ call func
+ }
#else
__asm__ __volatile__("call *%0" : : "r" (func), "c" (object) : "eax", "edx", "memory" );
#endif
}
+#ifdef _MSC_VER
+#pragma warning(push)
+#pragma warning(disable:4731)
/* continue execution to the specified address after exception is caught */
-static inline void DECLSPEC_NORETURN continue_after_catch( cxx_exception_frame* frame, void *addr )
+__forceinline void DECLSPEC_NORETURN continue_after_catch( cxx_exception_frame* frame, void *addr )
{
-#ifdef _MSC_VER
-#pragma message ("continue_after_catch is unimplemented for MSC")
+ __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 */
+static inline void DECLSPEC_NORETURN continue_after_catch( cxx_exception_frame* frame, void *addr )
+{
__asm__ __volatile__("movl -4(%0),%%esp; leal 12(%0),%%ebp; jmp *%1"
: : "r" (frame), "a" (addr) );
-#endif
for (;;) ; /* unreached */
}
+#endif
static inline void dump_type( const cxx_type_info *type )
{
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 );
MSVCRT_terminate();
extern DWORD CDECL __CxxFrameHandler( PEXCEPTION_RECORD rec, EXCEPTION_REGISTRATION_RECORD* frame,
PCONTEXT context, EXCEPTION_REGISTRATION_RECORD** dispatch );
#ifdef _MSC_VER
-#pragma message ("__CxxFrameHandler is unimplemented for MSC")
-DWORD CDECL __CxxFrameHandler( PEXCEPTION_RECORD rec, EXCEPTION_REGISTRATION_RECORD* frame,
+DWORD _declspec(naked) __CxxFrameHandler( PEXCEPTION_RECORD rec, EXCEPTION_REGISTRATION_RECORD* frame,
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
__ASM_GLOBAL_FUNC( __CxxFrameHandler,
--- /dev/null
+
+#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
#define X87_CW_IC (1<<12) /* infinity control flag */
+#ifdef _M_AMD64
+unsigned int __getfpcw87(void);
+void __setfpcw87(unsigned int);
+#endif
+
/*
* @implemented
*/
TRACE("(%08x, %08x): Called\n", newval, mask);
/* Get fp control word */
-#if defined(__GNUC__)
+#ifdef _M_AMD64
+ fpword = __getfpcw87();
+#elif defined(__GNUC__)
__asm__ __volatile__( "fstcw %0" : "=m" (fpword) : );
-#elif defined(_M_IX86)
- __asm fstcw [fpword];
#else
- #pragma message("FIXME: _control87 is halfplemented")
+ __asm fstcw [fpword];
#endif
TRACE("Control word before : %08x\n", fpword);
TRACE("Control word after : %08x\n", fpword);
/* Put fp control word */
-#if defined(__GNUC__)
+#ifdef _M_AMD64
+ __setfpcw87(fpword);
+#elif defined(__GNUC__)
__asm__ __volatile__( "fldcw %0" : : "m" (fpword) );
-#elif defined(_M_IX86)
- __asm fldcw [fpword];
#else
- #pragma message("FIXME: _control87 is halfplemented")
+ __asm fldcw [fpword];
#endif
return flags;
{
unsigned int retVal = 0;
unsigned int fpword;
-#if defined(__GNUC__)
+
+#ifdef _M_AMD64
+ fpword = _mm_getcsr();
+#elif defined(__GNUC__)
__asm__ __volatile__( "fstsw %0" : "=m" (fpword) : );
-#elif defined(_M_IX86)
+#else // _MSC_VER
__asm fstsw [fpword];
-#else
- #pragma message("FIXME: _statusfp is halfplemented")
#endif
if (fpword & 0x1) retVal |= _SW_INVALID;
if (fpword & 0x2) retVal |= _SW_DENORMAL;
#define LEAPDAY 59
static __inline
-time_t
+__time64_t
FileTimeToUnixTime(const FILETIME *FileTime, USHORT *millitm)
{
ULARGE_INTEGER ULargeInt;
- time_t time;
+ __time64_t time;
ULargeInt.LowPart = FileTime->dwLowDateTime;
ULargeInt.HighPart = FileTime->dwHighDateTime;
ULargeInt.QuadPart -= DIFFTIME;
- time = (time_t)(ULargeInt.QuadPart / 10000000);
+ time = ULargeInt.QuadPart / 10000000;
if (millitm)
*millitm = (USHORT)((ULargeInt.QuadPart % 10000000) / 10000);
double x2, result;
/* Calculate the quadrant */
- quadrant = x * (2./M_PI);
+ quadrant = (int)(x * (2./M_PI));
/* Get offset inside quadrant */
x = x - quadrant * (M_PI/2.);
/* Calculate the negative of the square of 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:
* 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
double x2, result;
/* Calculate the quadrant */
- quadrant = x * (2./M_PI);
+ quadrant = (int)(x * (2./M_PI));
/* Get offset inside quadrant */
x = x - quadrant * (M_PI/2.);
/* Calculate the negative of the square of 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:
* 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
*/
unsigned char *_mbsstr(const unsigned char *src1,const unsigned char *src2)
{
- int len;
+ size_t len;
if (src2 ==NULL || *src2 == 0)
return (unsigned char *)src1;
#include <stdlib.h>
#include <signal.h>
-static const char formatstr[] =
+static const char formatstr[] =
"Assertion failed!\n\n"
"Program: %s\n"
"File: %s\n"
HMODULE hmodUser32;
char achProgram[40];
char *pszBuffer;
- int len;
+ size_t len;
int iResult;
/* Assertion failed at foo.c line 45: x<y */
/* Get the file name of the module */
len = GetModuleFileNameA(NULL, achProgram, 40);
-
+
/* Calculate full length of the message */
len += sizeof(formatstr) + len + strlen(exp) + strlen(file);
_snprintf(pszBuffer, len, formatstr, achProgram, file, line, exp);
/* Display a message box */
- iResult = pMessageBoxA(NULL,
- pszBuffer,
+ iResult = pMessageBoxA(NULL,
+ pszBuffer,
"ReactOS C Runtime Library",
MB_ABORTRETRYIGNORE | MB_ICONERROR);
{
char *ptr, *environment_strings;
char **envptr;
- int count = 1, len;
+ int count = 1;
+ size_t len;
TRACE("BlockEnvToEnvironA()\n");
{
wchar_t *ptr, *environment_strings;
wchar_t **envptr;
- int count = 1, len;
+ int count = 1;
+ size_t len;
TRACE("BlockEnvToEnvironW()\n");
HANDLE hFile;
BOOLEAN first = TRUE;
wchar_t buffer[256];
- int pos;
+ uintptr_t pos;
if (expand_wildcards && (s = wcspbrk(name, L"*?")))
{
HANDLE hFile;
BOOLEAN first = TRUE;
char buffer[256];
- int pos;
+ uintptr_t pos;
if (expand_wildcards && (s = strpbrk(name, "*?")))
{
*/
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 */
void __wgetmainargs(int* argc, wchar_t*** wargv, wchar_t*** wenv,
int expand_wildcards, int* new_mode)
{
- int i, afterlastspace, ignorespace, len, doexpand;
+ int i, afterlastspace, ignorespace, doexpand;
+ size_t len;
/* missing threading init */
}
if(flag&1) {
- int exp = 1+floor(log10(d));
+ int exp = (int)(1+floor(log10(d)));
prec += exp;
if(exp < 0)
data->pos++;
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);
data->str[data->len] = '\0';
stream._ptr = stream._base;
stream._charbuf = 0;
#if USE_COUNT
- stream._cnt = count * sizeof(TCHAR);
+ stream._cnt = (int)(count * sizeof(TCHAR));
#else
stream._cnt = INT_MAX;
#endif
(flags & FLAG_LONGDOUBLE) ? va_arg(argptr, long 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)
#ifndef _USER32_WSPRINTF
static
int
-streamout_astring(FILE *stream, const char *string, int count)
+streamout_astring(FILE *stream, const char *string, size_t count)
{
TCHAR chr;
int written = 0;
static
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;
int written = 0;
TCHAR chr, *string;
STRING *nt_string;
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;
unsigned int flags;
unsigned __int64 val64;
len = wcslen((wchar_t*)string);
else
len = strlen((char*)string);
- if (precision >= 0 && len > precision) len = precision;
+ if (precision >= 0 && len > (unsigned)precision) len = precision;
precision = 0;
break;
/* Calculate padding */
prefixlen = prefix ? _tcslen(prefix) : 0;
if (precision < 0) precision = 0;
- padding = fieldwidth - len - prefixlen - precision;
+ padding = (int)(fieldwidth - len - prefixlen - precision);
if (padding < 0) padding = 0;
/* Optional left space padding */
static _TCHAR*
argvtosT(const _TCHAR* const* argv, _TCHAR delim)
{
- int i, len;
+ int i;
+ size_t len;
_TCHAR *ptr, *str;
if (argv == NULL)
{
va_list alist2 = alist;
_TCHAR *ptr, *str;
- int len;
+ size_t len;
if (arg0 == NULL)
return NULL;
{
va_list argp;
_TCHAR* args;
- int ret = -1;
+ intptr_t ret = -1;
TRACE(MK_STR(_tspawnl)"('%"sT"')\n", cmdname);
intptr_t _tspawnv(int mode, const _TCHAR *cmdname, const _TCHAR* const* argv)
{
_TCHAR* args;
- int ret = -1;
+ intptr_t ret = -1;
TRACE(MK_STR(_tspawnv)"('%"sT"')\n", cmdname);
_TCHAR* args;
_TCHAR* envs;
_TCHAR const * const* ptr;
- int ret = -1;
+ intptr_t ret = -1;
TRACE(MK_STR(_tspawnle)"('%"sT"')\n", cmdname);
{
_TCHAR *args;
_TCHAR *envs;
- int ret = -1;
+ intptr_t ret = -1;
TRACE(MK_STR(_tspawnve)"('%"sT"')\n", cmdname);
{
va_list argp;
_TCHAR* args;
- int ret = -1;
+ intptr_t ret = -1;
_TCHAR pathname[FILENAME_MAX];
TRACE(MK_STR(_tspawnlp)"('%"sT"')\n", cmdname);
_TCHAR* args;
_TCHAR* envs;
_TCHAR const* const * ptr;
- int ret = -1;
+ intptr_t ret = -1;
_TCHAR pathname[FILENAME_MAX];
TRACE(MK_STR(_tspawnlpe)"('%"sT"')\n", cmdname);
{
_TCHAR* args;
va_list argp;
- int ret = -1;
+ intptr_t ret = -1;
TRACE(MK_STR(_texecl)"('%"sT"')\n", cmdname);
_TCHAR* args;
_TCHAR* envs;
_TCHAR const* const* ptr;
- int ret = -1;
+ intptr_t ret = -1;
TRACE(MK_STR(_texecle)"('%"sT"')\n", cmdname);
{
_TCHAR* args;
va_list argp;
- int ret = -1;
+ intptr_t ret = -1;
_TCHAR pathname[FILENAME_MAX];
TRACE(MK_STR(_texeclp)"('%"sT"')\n", cmdname);
_TCHAR* args;
_TCHAR* envs;
_TCHAR const* const* ptr;
- int ret = -1;
+ intptr_t ret = -1;
_TCHAR pathname[FILENAME_MAX];
TRACE(MK_STR(_texeclpe)"('%"sT"')\n", cmdname);
size_t size, int (__cdecl *cmp)(const void *ck, const void *ce))
{
char *base = (char *)base0;
- int lim, cmpval;
+ size_t lim;
+ int cmpval;
void *p;
for (lim = nelem; lim != 0; lim >>= 1)
if (stream->_base && !(stream->_flag & _IONBF))
{
/* We can, check if there is something to write */
- count = stream->_ptr - stream->_base;
+ count = (int)(stream->_ptr - stream->_base);
if (count > 0)
written = _write(stream->_file, stream->_base, count);
else
char* wxflag_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);
if (!*block)
{
void msvcrt_init_io(void)
{
STARTUPINFOA si;
- int i;
+ unsigned int i;
InitializeCriticalSection(&FILE_cs);
FILE_cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": FILE_cs");
static int flush_buffer(FILE* file)
{
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) {
file->_flag |= _IOERR;
return EOF;
*/
LONG CDECL _lseek(int fd, LONG offset, int whence)
{
- return _lseeki64(fd, offset, whence);
+ return (LONG)_lseeki64(fd, offset, whence);
}
/*********************************************************************
*/
FILE* CDECL _wfdopen(int fd, const wchar_t *mode)
{
- unsigned mlen = strlenW(mode);
+ unsigned mlen = (unsigned)strlenW(mode);
char *modea = calloc(mlen + 1, 1);
FILE* file = NULL;
int open_flags, stream_flags;
*/
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);
va_list ap;
int pmode;
*/
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);
va_list ap;
int pmode;
*_errno() = ENOSPC;
if(nr_lf)
free(p);
- return s - buf_start;
+ return (int)(s - buf_start);
}
else
{
*/
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;
if (size == 0)
return 0;
*/
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 *modea = calloc(mlen + 1, 1);
* fread (MSVCRT.@)
*/
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;
int pread=0;
if(pos == -1) return -1;
if(file->_bufsiz) {
if( file->_flag & _IOWRT ) {
- off = file->_ptr - file->_base;
+ off = (int)(file->_ptr - file->_base);
} else {
off = -file->_cnt;
if (fdesc[file->_file].wxflag & WX_TEXT) {
if(*pos == -1) return -1;
if(file->_bufsiz) {
if( file->_flag & _IOWRT ) {
- off = file->_ptr - file->_base;
+ off = (int)(file->_ptr - file->_base);
} else {
off = -file->_cnt;
if (fdesc[file->_file].wxflag & WX_TEXT) {
file->_flag &= ~_IONBF;
file->_base = file->_ptr = buf;
if(buf) {
- file->_bufsiz = size;
+ file->_bufsiz = (int)size;
}
} else {
file->_flag |= _IONBF;
}
result->attrib = FindFileData.dwFileAttributes;
- result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL);
- result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL);
- result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL);
+ result->time_create = (time_t)FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL);
+ result->time_access = (time_t)FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL);
+ result->time_write = (time_t)FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL);
result->size = (((__int64)FindFileData.nFileSizeHigh)<<32) + FindFileData.nFileSizeLow;
_tcsncpy(result->name,FindFileData.cFileName,MAX_PATH);
}
result->attrib = FindFileData.dwFileAttributes;
- result->time_create = FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL);
- result->time_access = FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL);
- result->time_write = FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL);
+ result->time_create = (time_t)FileTimeToUnixTime(&FindFileData.ftCreationTime,NULL);
+ result->time_access = (time_t)FileTimeToUnixTime(&FindFileData.ftLastAccessTime,NULL);
+ result->time_write = (time_t)FileTimeToUnixTime(&FindFileData.ftLastWriteTime,NULL);
result->size = (((__int64)FindFileData.nFileSizeHigh)<<32) + FindFileData.nFileSizeLow;
_tcsncpy(result->name,FindFileData.cFileName, MAX_PATH);
buf->st_uid = (buf64)->st_uid; \
buf->st_gid = (buf64)->st_gid; \
buf->st_rdev = (buf64)->st_rdev; \
- buf->st_size = (buf64)->st_size; \
- buf->st_atime = (buf64)->st_atime; \
- buf->st_mtime = (buf64)->st_mtime; \
- buf->st_ctime = (buf64)->st_ctime; \
+ buf->st_size = (_off_t)(buf64)->st_size; \
+ buf->st_atime = (time_t)(buf64)->st_atime; \
+ buf->st_mtime = (time_t)(buf64)->st_mtime; \
+ buf->st_ctime = (time_t)(buf64)->st_ctime; \
int CDECL _tstat(const _TCHAR* path, struct _stat * buf)
{
#include <tchar.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_IWRITE (_S_IWRITE | (_S_IWRITE >> 3) | (_S_IWRITE >> 6))
DWORD dw;
WIN32_FILE_ATTRIBUTE_DATA hfi;
unsigned short mode = ALL_S_IREAD;
- int plen;
+ size_t plen;
TRACE(":file (%s) buf(%p)\n",path,buf);
buf->st_atime = dw;
RtlTimeToSecondsSince1970((LARGE_INTEGER *)&hfi.ftLastWriteTime, &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,
buf->st_mode);
_onexit_t __dllonexit(_onexit_t func, _onexit_t **start, _onexit_t **end)
{
_onexit_t *tmp;
- int len;
+ size_t len;
if (!start || !*start || !end || !*end)
return NULL;
absPath = malloc(maxLength);
}
- copied = GetFullPathName(relPath,maxLength,absPath,&lpFilePart);
+ copied = GetFullPathName(relPath,(DWORD)maxLength,absPath,&lpFilePart);
if (copied == 0 || copied > maxLength)
return NULL;
char *getenv(const char *name)
{
char **environ;
- unsigned int length = strlen(name);
+ size_t length = strlen(name);
for (environ = *__p__environ(); *environ; environ++)
{
wchar_t *_wgetenv(const wchar_t *name)
{
wchar_t **environ;
- unsigned int length = wcslen(name);
+ size_t length = wcslen(name);
for (environ = *__p__wenviron(); *environ; environ++)
{
}
if (dir && dir[0])
{
- unsigned int len = strlen(dir);
+ size_t len = strlen(dir);
memmove(p, dir, len);
p += len;
if (p[-1] != '/' && p[-1] != '\\')
}
if (fname && fname[0])
{
- unsigned int len = strlen(fname);
+ size_t len = strlen(fname);
memmove(p, fname, len);
p += len;
}
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 copylen = min(size - 1, len);
+ size_t copylen = min(size - 1, len);
if (size < 2)
goto range;
if (filename && filename[0])
{
- unsigned int len = strlen(filename);
- unsigned int copylen = min(size - 1, len);
+ size_t len = strlen(filename);
+ size_t copylen = min(size - 1, len);
if (size < 2)
goto range;
if (extension && extension[0])
{
- unsigned int len = strlen(extension);
+ size_t len = strlen(extension);
unsigned int needs_period = extension[0] != '.';
- unsigned int copylen;
+ size_t copylen;
if (size < 2)
goto range;
qst(size_t size, int (__cdecl *compar)(const void*, const void*), char *base, char *max)
{
char c, *i, *j, *jj;
- int ii;
+ size_t ii;
char *mid, *tmp;
- int lo, hi;
+ size_t lo, hi;
size_t thresh;
size_t mthresh;
}
if (dir && dir[0])
{
- unsigned int len = strlenW(dir);
+ size_t len = strlenW(dir);
memmove(p, dir, len * sizeof(wchar_t));
p += len;
if (p[-1] != '/' && p[-1] != '\\')
}
if (fname && fname[0])
{
- unsigned int len = strlenW(fname);
+ size_t len = strlenW(fname);
memmove(p, fname, len * sizeof(wchar_t));
p += len;
}
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 copylen = min(size - 1, len);
+ size_t copylen = min(size - 1, len);
if (size < 2)
goto range;
if (filename && filename[0])
{
- unsigned int len = strlenW(filename);
- unsigned int copylen = min(size - 1, len);
+ size_t len = strlenW(filename);
+ size_t copylen = min(size - 1, len);
if (size < 2)
goto range;
if (extension && extension[0])
{
- unsigned int len = strlenW(extension);
+ size_t len = strlenW(extension);
unsigned int needs_period = extension[0] != '.';
- unsigned int copylen;
+ size_t copylen;
if (size < 2)
goto range;
*pos = '\0';
do {
- digit = val % radix;
+ digit = (WCHAR)(val % radix);
val = val / radix;
if (digit < 10) {
*--pos = '0' + digit;
*pos = '\0';
do {
- digit = value % radix;
+ digit = (WCHAR)(value % radix);
value = value / radix;
if (digit < 10) {
*--pos = '0' + digit;
*pos = '\0';
do {
- digit = val % radix;
+ digit = (WCHAR)(val % radix);
val = val / radix;
if (digit < 10) {
*--pos = '0' + digit;
*pos = '\0';
do {
- digit = value % radix;
+ digit = (WCHAR)(value % radix);
value = value / radix;
if (digit < 10) {
*--pos = '0' + digit;
*wchar = wc;
- return mbs - mbarr;
+ return (int)(mbs - mbarr);
}
/*
ULONG Size;
ULONG Length;
- Length = strlen (mbstr);
+ Length = (ULONG)strlen (mbstr);
if (wcstr == NULL)
{
}
Status = RtlMultiByteToUnicodeN (wcstr,
- count * sizeof(WCHAR),
+ (ULONG)count * sizeof(WCHAR),
&Size,
mbstr,
Length);
base = 0;
number: {
/* read an integer */
- ULONGLONG cur = 0;
+ __int64 cur = 0;
int negative = 0;
int seendigit=0;
/* skip initial whitespace */
if (!seendigit) break; /* not a valid number */
st = 1;
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);
else if (l_prefix) _SET_NUMBER_(LONG);
else if (h_prefix) _SET_NUMBER_(short int);
if (width>0) width--;
}
/* update 'cur' with this exponent. */
- expcnt = negexp ? .1 : 10;
+ expcnt = negexp ? 0.1f : 10.0f;
while (exponent!=0) {
if (exponent&1)
cur*=expcnt;
* Set any if any `digits' consumed; make it negative to indicate
* overflow.
*/
- cutoff = neg ? -(unsigned long)LONG_MIN : LONG_MAX;
+ cutoff = neg ? ((unsigned long)LONG_MAX+1) : LONG_MAX;
cutlim = cutoff % (unsigned long)base;
cutoff /= (unsigned long)base;
for (acc = 0, any = 0;; c = *s++)
#endif
}
else if (neg)
- acc = -acc;
+ acc = 0-acc;
if (endptr != 0)
*endptr = any ? (char *)((size_t)(s - 1)) : (char *)((size_t)nptr);
return acc;
#endif
}
else if (neg)
- acc = -acc;
+ acc = 0-acc;
if (endptr != 0)
*endptr = any ? (char *)((size_t)(s - 1)) : (char *)((size_t)nptr);
return acc;
#endif
}
else if (neg)
- acc = -acc;
+ acc = 0-acc;
if (endptr != 0)
*endptr = any ? (char *)((size_t)(s - 1)) : (char *)((size_t)nptr);
return acc;
wchar_t* ret = NULL;
if (str)
{
- int size = (strlenW(str) + 1) * sizeof(wchar_t);
+ size_t size = (strlenW(str) + 1) * sizeof(wchar_t);
ret = malloc( size );
if (ret) memcpy( ret, str, size );
}
*/
INT CDECL wcscpy_s( wchar_t* wcDest, size_t numElement, const wchar_t *wcSrc)
{
- INT size = 0;
+ size_t size = 0;
if(!wcDest || !numElement)
return EINVAL;
* Set any if any `digits' consumed; make it negative to indicate
* overflow.
*/
- cutoff = neg ? -(unsigned long)LONG_MIN : LONG_MAX;
+ cutoff = neg ? ((unsigned long)LONG_MAX+1) : LONG_MAX;
cutlim = cutoff % (unsigned long)base;
cutoff /= (unsigned long)base;
for (acc = 0, any = 0;; c = *s++)
acc = neg ? LONG_MIN : LONG_MAX;
}
else if (neg)
- acc = -acc;
+ acc = 0-acc;
if (endptr != 0)
*endptr = any ? (wchar_t *)((size_t)(s - 1)) : (wchar_t *)((size_t)nptr);
return acc;
ULONG Size;
ULONG Length;
- Length = wcslen (wcstr);
+ Length = (ULONG)wcslen (wcstr);
if (mbstr == NULL)
{
}
Status = RtlUnicodeToMultiByteN (mbstr,
- count,
+ (ULONG)count,
&Size,
(wchar_t*)((size_t)wcstr),
Length * sizeof(WCHAR));
acc = ULONG_MAX;
}
else if (neg)
- acc = -acc;
+ acc = 0-acc;
if (endptr != 0)
*endptr = any ? (wchar_t *)((size_t)(s - 1)) : (wchar_t *)((size_t)nptr);
return acc;
str++;
} /* while */
- return bMinus ? -RunningTotal : RunningTotal;
+ return bMinus ? 0-RunningTotal : RunningTotal;
}
GetSystemTimeAsFileTime((FILETIME*)&Time);
Time.QuadPart -= g_StartupTime.QuadPart;
- return FileTimeToUnixTime((FILETIME*)&Time, NULL);
+ return (clock_t)FileTimeToUnixTime((FILETIME*)&Time, NULL);
};
/******************************************************************************
* \name _ftime_s
* \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.
* \sa http://msdn.microsoft.com/en-us/library/95e68951.aspx
*/
ret = GetTimeZoneInformation(&TimeZoneInformation);
ptimeb->dstflag = (ret == TIME_ZONE_ID_DAYLIGHT) ? 1 : 0;
- ptimeb->timezone = TimeZoneInformation.Bias;
+ ptimeb->timezone = (short)TimeZoneInformation.Bias;
GetSystemTimeAsFileTime(&SystemTime);
- ptimeb->time = FileTimeToUnixTime(&SystemTime, &ptimeb->millitm);
+ ptimeb->time = (time_t)FileTimeToUnixTime(&SystemTime, &ptimeb->millitm);
return 0;
}
/******************************************************************************
* \name _ftime
* \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.
- * \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().
* \sa http://msdn.microsoft.com/en-us/library/z54t9z5f.aspx
*/
/******************************************************************************
* \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
* recieves the current time.
* \sa http://msdn.microsoft.com/en-us/library/95e68951.aspx
{
time_t currTime;
_time(&currTime);
- RtlSecondsSince1970ToTime(currTime, (LARGE_INTEGER *)&at);
+ RtlSecondsSince1970ToTime((ULONG)currTime,
+ (LARGE_INTEGER *)&at);
wt = at;
}
else
{
- RtlSecondsSince1970ToTime(filetime->actime, (LARGE_INTEGER *)&at);
+ RtlSecondsSince1970ToTime((ULONG)filetime->actime,
+ (LARGE_INTEGER *)&at);
if (filetime->actime == filetime->modtime)
{
wt = at;
}
else
{
- RtlSecondsSince1970ToTime(filetime->modtime, (LARGE_INTEGER *)&wt);
+ RtlSecondsSince1970ToTime((ULONG)filetime->modtime,
+ (LARGE_INTEGER *)&wt);
}
}
}
/* Divide into date and time */
- days = time / SECONDSPERDAY;
+ days = (unsigned int)(time / SECONDSPERDAY);
secondinday = time % SECONDSPERDAY;
/* Shift to days from 1.1.1601 */
ptm->tm_isdst = 0;
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
{
time -= _dstbias;
- days = time / SECONDSPERDAY + DIFFDAYS;
+ days = (unsigned int)(time / SECONDSPERDAY + DIFFDAYS);
dayinyear = days - daystoyear;
ptm->tm_isdst = 1;
}
/******************************************************************************
* \name _gmtime64
- * \brief
+ * \brief
* \param ptime Pointer to a variable of type __time64_t containing the time.
*/
struct tm *
/******************************************************************************
* \name _gmtime32
- * \brief
+ * \brief
* \param ptime Pointer to a variable of type __time32_t containing the time.
*/
struct tm *
/******************************************************************************
* \name gmtime
- * \brief
+ * \brief
* \param ptime Pointer to a variable of type time_t containing the time.
*/
struct tm *
int tm_isdst;
*/
-/**
+/**
* \name _mkgmtime
- *
+ *
*/
time_t
_mkgmtime(struct tm *ptm)
{
- time_t time = mktime_worker(ptm, 1);
- return (time > MAX_32BIT_TIME) ? -1 : time;
+ __time64_t time = mktime_worker(ptm, 1);
+ return (time_t)((time > MAX_32BIT_TIME) ? -1 : time);
}
time_t
mktime(struct tm *ptm)
{
- time_t time = mktime_worker(ptm, 0);
- return (time > MAX_32BIT_TIME) ? -1 : time;
+ __time64_t time = mktime_worker(ptm, 0);
+ return (time_t)((time > MAX_32BIT_TIME) ? -1 : time);
}
__time32_t
_mkgmtime32(struct tm *ptm)
{
- time_t time = mktime_worker(ptm, 1);
- return (time > MAX_32BIT_TIME) ? -1 : time;
+ __time64_t time = mktime_worker(ptm, 1);
+ return (__time32_t)((time > MAX_32BIT_TIME) ? -1 : time);
}
__time32_t
_mktime32(struct tm *ptm)
{
- time_t time = mktime_worker(ptm, 0);
- return (time > MAX_32BIT_TIME) ? -1 : time;
+ __time64_t time = mktime_worker(ptm, 0);
+ return (__time32_t)((time > MAX_32BIT_TIME) ? -1 : time);
}
__time64_t
time_t time = 0;
GetSystemTimeAsFileTime(&SystemTime);
- time = FileTimeToUnixTime(&SystemTime, NULL);
+ time = (time_t)FileTimeToUnixTime(&SystemTime, NULL);
if (ptime)
{
* \name __p__dstbias
* \brief Returns a pointer to the _dstbias variable;
*/
-long *
+long *
__p__dstbias(void)
{
return &_dstbias;
if (str && str[0] != 0)
{
long hour = 0, min = 0, sec = 0;
- int len = strnlen(str, 16);
+ size_t len = strnlen(str, 16);
int sign = 1;
dst_begin = 0;
/* Copy DST name */
strncpy(tz_dst_name, str, 3);
-
+
// FIXME: set dst_begin etc
/* We are finished */
}
_timezone = sign * (((hour * 60) + min) * 60 + sec);
-
+
}
else
{
{
return;
}
-
+
ret = WideCharToMultiByte(CP_ACP,
0,
tzi.StandardName,
_tm.tm_hour = tzi.DaylightDate.wHour;
_tm.tm_min = tzi.DaylightDate.wMinute;
_tm.tm_sec = tzi.DaylightDate.wSecond;
- dst_begin = _mkgmtime(&_tm);
+ dst_begin = (long)_mkgmtime(&_tm);
_tm.tm_mon = tzi.StandardDate.wMonth - 1;
_tm.tm_mday = tzi.StandardDate.wDay;
_tm.tm_hour = tzi.StandardDate.wHour;
_tm.tm_min = tzi.StandardDate.wMinute;
_tm.tm_sec = tzi.StandardDate.wSecond;
- dst_end = _mkgmtime(&_tm);
+ dst_end = (long)_mkgmtime(&_tm);
}
else
{
static MSVCRT_new_handler_func MSVCRT_new_handler;
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;
/* FIXME - According to documentation it should be 480 bytes, at runtime default is 0 */
static size_t MSVCRT_sbh_threshold = 0;
*/
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);
}
/*********************************************************************
LOCK_HEAP;
phe.lpData = next->_pentry;
- phe.cbData = next->_size;
+ phe.cbData = (DWORD)next->_size;
phe.wFlags = next->_useflag == _USEDENTRY ? PROCESS_HEAP_ENTRY_BUSY : 0;
if (phe.lpData && phe.wFlags & PROCESS_HEAP_ENTRY_BUSY &&
void* CDECL realloc(void* ptr, size_t 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);
return NULL;
}
#define UNDNAME_NO_COMPLEX_TYPE (0x8000)
/* 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>}: "const "
* in data fields:
* same as for arguments and also the following
* ?<M>x {<M>}x
- *
+ *
*/
struct array
sym->avail_in_first = 0;
ptr = (char*)sym->alloc_list + sizeof(void*);
}
- else
+ else
{
if (len > sym->avail_in_first)
{
a->alloc *= 2;
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);
assert(a->elts[a->num]);
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;
{
- int i;
+ unsigned int i;
char c;
for (i = a->max - 1; i >= 0; i--)
assert(cref);
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);
return NULL;
}
- TRACE("Returning %p[%d] => %s\n",
+ TRACE("Returning %p[%d] => %s\n",
cref, idx, cref->elts[cref->start + idx]);
return cref->elts[cref->start + idx];
}
/******************************************************************
* 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
*/
static char* str_printf(struct parsed_symbol* sym, const char* format, ...)
{
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;
default: i--; /* fall thru */
case '%': len++; break;
t = va_arg(args, char*);
if (t)
{
- sz = strlen(t);
+ sz = (int)strlen(t);
memcpy(p, t, sz);
p += sz;
}
* Parses a list of function/method arguments, creates a string corresponding
* 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)
{
*/
if (z_term && *sym->current++ != 'Z') return NULL;
- if (arg_collect.num == 0 ||
- (arg_collect.num == 1 && !strcmp(arg_collect.elts[0], "void")))
+ if (arg_collect.num == 0 ||
+ (arg_collect.num == 1 && !strcmp(arg_collect.elts[0], "void")))
return str_printf(sym, "%cvoid%c", open_char, close_char);
for (i = 1; i < arg_collect.num; i++)
{
last = args_str ? args_str : arg_collect.elts[0];
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);
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);
-
+
return args_str;
}
}
} while (*++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 str_array_get_ref(&sym->names, sym->names.num - sym->names.start - 1);
name = str_array_get_ref(&sym->names, *sym->current++ - '0');
break;
case '?':
- if (*++sym->current == '$')
+ if (*++sym->current == '$')
{
sym->current++;
if ((name = get_template_name(sym)) &&
char* ret;
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]);
- len += 2 + strlen(a->elts[i]);
+ len += 2 + (int)strlen(a->elts[i]);
}
if (!(ret = und_alloc(sym, len - 1))) return NULL;
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);
len += sz;
if (i > start)
static const char* get_simple_type(char c)
{
const char* type_string;
-
+
switch (c)
{
case 'C': type_string = "signed char"; break;
static const char* get_extended_type(char c)
{
const char* type_string;
-
+
switch (c)
{
case 'D': type_string = "__int8"; break;
assert(ct);
ct->left = ct->right = NULL;
-
+
switch (dt = *sym->current++)
{
case '_':
if (!(struct_name = get_class_name(sym)))
goto done;
- if (!(sym->flags & UNDNAME_NO_COMPLEX_TYPE))
+ if (!(sym->flags & UNDNAME_NO_COMPLEX_TYPE))
{
switch (dt)
{
unsigned mark = sym->stack.num;
if (!get_calling_convention(*sym->current++,
- &call_conv, &exported,
+ &call_conv, &exported,
sym->flags & ~UNDNAME_NO_ALLOCATION_LANGUAGE) ||
!demangle_datatype(sym, &sub_ct, pmt_ref, FALSE))
goto done;
if (!args) goto done;
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);
ct->right = str_printf(sym, ")%s", args);
}
return FALSE;
}
done:
-
+
return ct->left != NULL;
}
case '0': access = "private: "; break;
case '1': access = "protected: "; break;
case '2': access = "public: "; break;
- }
+ }
}
if (!(sym->flags & UNDNAME_NO_MEMBER_TYPE))
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,
- member_type, ct.left,
- modifier && ct.left ? " " : NULL, modifier,
+ member_type, ct.left,
+ modifier && ct.left ? " " : NULL, modifier,
modifier || ct.left ? " " : NULL, name, ct.right);
ret = TRUE;
done:
* Yet!!! FIXME
*/
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,
call_conv, call_conv ? " " : NULL, exported,
- name, args_str, modifier,
+ name, args_str, modifier,
modifier ? " " : NULL, ct_ret.right);
ret = TRUE;
done:
TRACE("(%p,%s,%d,%p,%p,%p,%x)\n",
buffer, mangled, buflen, memget, memfree, unknown, flags);
-
+
/* The flags details is not documented by MS. However, it looks exactly
* like the UNDNAME_ manifest constants from imagehlp.h and dbghelp.h
* So, we copied those (on top of the file)