mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-09-03 04:13:31 +00:00
Commit WIP. Part 3 of ??
- Update crt to conform - add some amd64 stubs svn path=/branches/ros-amd64-bringup/; revision=35810
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
|
||||
<module name="crt" type="staticlibrary">
|
||||
<module name="crt" type="staticlibrary" allowwarnings="true">
|
||||
<include base="crt">.</include>
|
||||
<include base="crt">include</include>
|
||||
<define name="_DISABLE_TIDENTS" />
|
||||
@@ -56,6 +56,12 @@
|
||||
<file>chkstk_asm.s</file>
|
||||
</directory>
|
||||
</if>
|
||||
<if property="ARCH" value="amd64">
|
||||
<directory name="amd64">
|
||||
<file>seh.s</file>
|
||||
<file>chkstk_asm.s</file>
|
||||
</directory>
|
||||
</if>
|
||||
<file>xcptfil.c</file>
|
||||
</directory>
|
||||
<directory name="float">
|
||||
@@ -75,6 +81,14 @@
|
||||
<file>statfp.c</file>
|
||||
</directory>
|
||||
</if>
|
||||
<if property="ARCH" value="amd64">
|
||||
<directory name="i386">
|
||||
<file>clearfp.c</file>
|
||||
<file>cntrlfp.c</file>
|
||||
<file>logb.c</file>
|
||||
<file>statfp.c</file>
|
||||
</directory>
|
||||
</if>
|
||||
</directory>
|
||||
<directory name="locale">
|
||||
<file>locale.c</file>
|
||||
@@ -112,8 +126,15 @@
|
||||
<file>log10_asm.s</file>
|
||||
</directory>
|
||||
</if>
|
||||
<ifnot property="ARCH" value="i386">
|
||||
</ifnot>
|
||||
<if property="ARCH" value="amd64">
|
||||
<directory name="i386">
|
||||
<file>atan2.c</file>
|
||||
<file>exp.c</file>
|
||||
<file>fmod.c</file>
|
||||
<file>ldexp.c</file>
|
||||
</directory>
|
||||
</if>
|
||||
|
||||
</directory>
|
||||
|
||||
<directory name="mbstring">
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* PURPOSE: Stack checker
|
||||
* FILE: lib/ntdll/rtl/i386/chkstk.s
|
||||
* PROGRAMER:
|
||||
*/
|
||||
|
||||
.globl _chkstk
|
||||
.globl _alloca_probe
|
||||
|
||||
/*
|
||||
_chkstk() is called by all stack allocations of more than 4 KB. It grows the
|
||||
stack in areas of 4 KB each, trying to access each area. This ensures that the
|
||||
guard page for the stack is hit, and the stack growing triggered
|
||||
*/
|
||||
_chkstk:
|
||||
_alloca_probe:
|
||||
/* return */
|
||||
ret
|
||||
|
||||
/* EOF */
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS CRT
|
||||
* FILE: lib/crt/misc/i386/seh.S
|
||||
* PURPOSE: SEH Support for the CRT
|
||||
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <ndk/asm.h>
|
||||
.intel_syntax noprefix
|
||||
|
||||
#define DISPOSITION_DISMISS 0
|
||||
#define DISPOSITION_CONTINUE_SEARCH 1
|
||||
#define DISPOSITION_COLLIDED_UNWIND 3
|
||||
|
||||
/* GLOBALS *******************************************************************/
|
||||
|
||||
.globl __global_unwind2
|
||||
.globl __local_unwind2
|
||||
.globl __abnormal_termination
|
||||
.globl __except_handler2
|
||||
.globl __except_handler3
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
.func unwind_handler
|
||||
_unwind_handler:
|
||||
ret
|
||||
.endfunc
|
||||
|
||||
.func _global_unwind2
|
||||
__global_unwind2:
|
||||
ret
|
||||
.endfunc
|
||||
|
||||
.func _abnormal_termination
|
||||
__abnormal_termination:
|
||||
ret
|
||||
.endfunc
|
||||
|
||||
.func _local_unwind2
|
||||
__local_unwind2:
|
||||
ret
|
||||
.endfunc
|
||||
|
||||
.func _except_handler2
|
||||
__except_handler2:
|
||||
ret
|
||||
.endfunc
|
||||
|
||||
.func _except_handler3
|
||||
__except_handler3:
|
||||
ret
|
||||
.endfunc
|
||||
|
||||
//
|
||||
//
|
||||
// REMOVE ME REMOVE ME REMOVE ME REMOVE ME REMOVE ME REMOVE ME REMOVE ME
|
||||
//
|
||||
//
|
||||
.func RtlpGetStackLimits@8
|
||||
.globl _RtlpGetStackLimits@8
|
||||
_RtlpGetStackLimits@8:
|
||||
|
||||
/* Get the current thread */
|
||||
mov eax, [fs:KPCR_CURRENT_THREAD]
|
||||
|
||||
/* Get the stack limits */
|
||||
mov ecx, [eax+KTHREAD_STACK_LIMIT]
|
||||
mov edx, [eax+KTHREAD_INITIAL_STACK]
|
||||
sub edx, SIZEOF_FX_SAVE_AREA
|
||||
|
||||
/* Return them */
|
||||
mov eax, [esp+4]
|
||||
mov [eax], ecx
|
||||
|
||||
mov eax, [esp+8]
|
||||
mov [eax], edx
|
||||
|
||||
/* return */
|
||||
ret 8
|
||||
.endfunc
|
||||
@@ -323,7 +323,7 @@ do_spawnT(int mode, const _TCHAR* cmdname, const _TCHAR* args, const _TCHAR* env
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int _tspawnl(int mode, const _TCHAR *cmdname, const _TCHAR* arg0, ...)
|
||||
intptr_t _tspawnl(int mode, const _TCHAR *cmdname, const _TCHAR* arg0, ...)
|
||||
{
|
||||
va_list argp;
|
||||
_TCHAR* args;
|
||||
@@ -345,7 +345,7 @@ int _tspawnl(int mode, const _TCHAR *cmdname, const _TCHAR* arg0, ...)
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int _tspawnv(int mode, const _TCHAR *cmdname, const _TCHAR* const* argv)
|
||||
intptr_t _tspawnv(int mode, const _TCHAR *cmdname, const _TCHAR* const* argv)
|
||||
{
|
||||
_TCHAR* args;
|
||||
int ret = -1;
|
||||
@@ -365,7 +365,7 @@ int _tspawnv(int mode, const _TCHAR *cmdname, const _TCHAR* const* argv)
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int _tspawnle(int mode, const _TCHAR *cmdname, const _TCHAR* arg0, ... /*, NULL, const char* const* envp*/)
|
||||
intptr_t _tspawnle(int mode, const _TCHAR *cmdname, const _TCHAR* arg0, ... /*, NULL, const char* const* envp*/)
|
||||
{
|
||||
va_list argp;
|
||||
_TCHAR* args;
|
||||
@@ -400,7 +400,7 @@ int _tspawnle(int mode, const _TCHAR *cmdname, const _TCHAR* arg0, ... /*, NULL,
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int _tspawnve(int mode, const _TCHAR *cmdname, const _TCHAR* const* argv, const _TCHAR* const* envp)
|
||||
intptr_t _tspawnve(int mode, const _TCHAR *cmdname, const _TCHAR* const* argv, const _TCHAR* const* envp)
|
||||
{
|
||||
_TCHAR *args;
|
||||
_TCHAR *envs;
|
||||
@@ -426,7 +426,7 @@ int _tspawnve(int mode, const _TCHAR *cmdname, const _TCHAR* const* argv, const
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int _tspawnvp(int mode, const _TCHAR* cmdname, const _TCHAR* const* argv)
|
||||
intptr_t _tspawnvp(int mode, const _TCHAR* cmdname, const _TCHAR* const* argv)
|
||||
{
|
||||
_TCHAR pathname[FILENAME_MAX];
|
||||
|
||||
@@ -438,7 +438,7 @@ int _tspawnvp(int mode, const _TCHAR* cmdname, const _TCHAR* const* argv)
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int _tspawnlp(int mode, const _TCHAR* cmdname, const _TCHAR* arg0, .../*, NULL*/)
|
||||
intptr_t _tspawnlp(int mode, const _TCHAR* cmdname, const _TCHAR* arg0, .../*, NULL*/)
|
||||
{
|
||||
va_list argp;
|
||||
_TCHAR* args;
|
||||
@@ -461,7 +461,7 @@ int _tspawnlp(int mode, const _TCHAR* cmdname, const _TCHAR* arg0, .../*, NULL*/
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int _tspawnlpe(int mode, const _TCHAR* cmdname, const _TCHAR* arg0, .../*, NULL, const char* const* envp*/)
|
||||
intptr_t _tspawnlpe(int mode, const _TCHAR* cmdname, const _TCHAR* arg0, .../*, NULL, const char* const* envp*/)
|
||||
{
|
||||
va_list argp;
|
||||
_TCHAR* args;
|
||||
@@ -496,7 +496,7 @@ int _tspawnlpe(int mode, const _TCHAR* cmdname, const _TCHAR* arg0, .../*, NULL,
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int _tspawnvpe(int mode, const _TCHAR* cmdname, const _TCHAR* const* argv, const _TCHAR* const* envp)
|
||||
intptr_t _tspawnvpe(int mode, const _TCHAR* cmdname, const _TCHAR* const* argv, const _TCHAR* const* envp)
|
||||
{
|
||||
_TCHAR pathname[FILENAME_MAX];
|
||||
|
||||
@@ -508,7 +508,7 @@ int _tspawnvpe(int mode, const _TCHAR* cmdname, const _TCHAR* const* argv, const
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int _texecl(const _TCHAR* cmdname, const _TCHAR* arg0, ...)
|
||||
intptr_t _texecl(const _TCHAR* cmdname, const _TCHAR* arg0, ...)
|
||||
{
|
||||
_TCHAR* args;
|
||||
va_list argp;
|
||||
@@ -530,7 +530,7 @@ int _texecl(const _TCHAR* cmdname, const _TCHAR* arg0, ...)
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int _texecv(const _TCHAR* cmdname, const _TCHAR* const* argv)
|
||||
intptr_t _texecv(const _TCHAR* cmdname, const _TCHAR* const* argv)
|
||||
{
|
||||
TRACE(MK_STR(_texecv)"('%"sT"')\n", cmdname);
|
||||
return _tspawnv(P_OVERLAY, cmdname, argv);
|
||||
@@ -539,7 +539,7 @@ int _texecv(const _TCHAR* cmdname, const _TCHAR* const* argv)
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int _texecle(const _TCHAR* cmdname, const _TCHAR* arg0, ... /*, NULL, char* const* envp */)
|
||||
intptr_t _texecle(const _TCHAR* cmdname, const _TCHAR* arg0, ... /*, NULL, char* const* envp */)
|
||||
{
|
||||
va_list argp;
|
||||
_TCHAR* args;
|
||||
@@ -573,7 +573,7 @@ int _texecle(const _TCHAR* cmdname, const _TCHAR* arg0, ... /*, NULL, char* cons
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int _texecve(const _TCHAR* cmdname, const _TCHAR* const* argv, const _TCHAR* const* envp)
|
||||
intptr_t _texecve(const _TCHAR* cmdname, const _TCHAR* const* argv, const _TCHAR* const* envp)
|
||||
{
|
||||
TRACE(MK_STR(_texecve)"('%"sT"')\n", cmdname);
|
||||
return _tspawnve(P_OVERLAY, cmdname, argv, envp);
|
||||
@@ -582,7 +582,7 @@ int _texecve(const _TCHAR* cmdname, const _TCHAR* const* argv, const _TCHAR* con
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int _texeclp(const _TCHAR* cmdname, const _TCHAR* arg0, ...)
|
||||
intptr_t _texeclp(const _TCHAR* cmdname, const _TCHAR* arg0, ...)
|
||||
{
|
||||
_TCHAR* args;
|
||||
va_list argp;
|
||||
@@ -605,7 +605,7 @@ int _texeclp(const _TCHAR* cmdname, const _TCHAR* arg0, ...)
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int _texecvp(const _TCHAR* cmdname, const _TCHAR* const* argv)
|
||||
intptr_t _texecvp(const _TCHAR* cmdname, const _TCHAR* const* argv)
|
||||
{
|
||||
TRACE(MK_STR(_texecvp)"('%"sT"')\n", cmdname);
|
||||
return _tspawnvp(P_OVERLAY, cmdname, argv);
|
||||
@@ -614,7 +614,7 @@ int _texecvp(const _TCHAR* cmdname, const _TCHAR* const* argv)
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int _texeclpe(const _TCHAR* cmdname, const _TCHAR* arg0, ... /*, NULL, char* const* envp */)
|
||||
intptr_t _texeclpe(const _TCHAR* cmdname, const _TCHAR* arg0, ... /*, NULL, char* const* envp */)
|
||||
{
|
||||
va_list argp;
|
||||
_TCHAR* args;
|
||||
@@ -649,7 +649,7 @@ int _texeclpe(const _TCHAR* cmdname, const _TCHAR* arg0, ... /*, NULL, char* con
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int _texecvpe(const _TCHAR* cmdname, const _TCHAR* const* argv, const _TCHAR* const* envp)
|
||||
intptr_t _texecvpe(const _TCHAR* cmdname, const _TCHAR* const* argv, const _TCHAR* const* envp)
|
||||
{
|
||||
TRACE(MK_STR(_texecvpe)"('%"sT"')\n", cmdname);
|
||||
return _tspawnvpe(P_OVERLAY, cmdname, argv, envp);
|
||||
|
||||
@@ -132,21 +132,7 @@ static CRITICAL_SECTION FILE_cs;
|
||||
#define LOCK_FILES() do { EnterCriticalSection(&FILE_cs); } while (0)
|
||||
#define UNLOCK_FILES() do { LeaveCriticalSection(&FILE_cs); } while (0)
|
||||
|
||||
static void stat64_to_stat(const struct __stat64 *buf64, struct _stat *buf)
|
||||
{
|
||||
buf->st_dev = buf64->st_dev;
|
||||
buf->st_ino = buf64->st_ino;
|
||||
buf->st_mode = buf64->st_mode;
|
||||
buf->st_nlink = buf64->st_nlink;
|
||||
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;
|
||||
}
|
||||
|
||||
#ifndef _WIN64
|
||||
static void stat64_to_stati64(const struct __stat64 *buf64, struct _stati64 *buf)
|
||||
{
|
||||
buf->st_dev = buf64->st_dev;
|
||||
@@ -161,6 +147,7 @@ static void stat64_to_stati64(const struct __stat64 *buf64, struct _stati64 *buf
|
||||
buf->st_mtime = buf64->st_mtime;
|
||||
buf->st_ctime = buf64->st_ctime;
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline BOOL is_valid_fd(int fd)
|
||||
{
|
||||
@@ -494,7 +481,7 @@ static void int_to_base32(int num, char *str)
|
||||
*/
|
||||
FILE * CDECL __p__iob(void)
|
||||
{
|
||||
return &_iob[0];
|
||||
return _iob;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
@@ -1165,7 +1152,7 @@ int CDECL _fileno(FILE* file)
|
||||
/*********************************************************************
|
||||
* _fstat64 (MSVCRT.@)
|
||||
*/
|
||||
int CDECL _fstat64(int fd, struct __stat64* buf)
|
||||
int CDECL _fstat64(int fd, struct _stat64* buf)
|
||||
{
|
||||
DWORD dw;
|
||||
DWORD type;
|
||||
@@ -1238,14 +1225,60 @@ int CDECL _fstati64(int fd, struct _stati64* buf)
|
||||
/*********************************************************************
|
||||
* _fstat (MSVCRT.@)
|
||||
*/
|
||||
int CDECL _fstat(int fd, struct _stat* buf)
|
||||
{ int ret;
|
||||
struct __stat64 buf64;
|
||||
int CDECL _fstat(int fd, struct _stat32* buf)
|
||||
{
|
||||
DWORD dw;
|
||||
DWORD type;
|
||||
BY_HANDLE_FILE_INFORMATION hfi;
|
||||
HANDLE hand = fdtoh(fd);
|
||||
|
||||
ret = _fstat64(fd, &buf64);
|
||||
if (!ret)
|
||||
stat64_to_stat(&buf64, buf);
|
||||
return ret;
|
||||
TRACE(":fd (%d) stat (%p)\n",fd,buf);
|
||||
if (hand == INVALID_HANDLE_VALUE)
|
||||
return -1;
|
||||
|
||||
if (!buf)
|
||||
{
|
||||
WARN(":failed-NULL buf\n");
|
||||
__set_errno(ERROR_INVALID_PARAMETER);
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset(&hfi, 0, sizeof(hfi));
|
||||
memset(buf, 0, sizeof(struct _stat32));
|
||||
type = GetFileType(hand);
|
||||
if (type == FILE_TYPE_PIPE)
|
||||
{
|
||||
buf->st_dev = buf->st_rdev = fd;
|
||||
buf->st_mode = S_IFIFO;
|
||||
buf->st_nlink = 1;
|
||||
}
|
||||
else if (type == FILE_TYPE_CHAR)
|
||||
{
|
||||
buf->st_dev = buf->st_rdev = fd;
|
||||
buf->st_mode = S_IFCHR;
|
||||
buf->st_nlink = 1;
|
||||
}
|
||||
else /* FILE_TYPE_DISK etc. */
|
||||
{
|
||||
if (!GetFileInformationByHandle(hand, &hfi))
|
||||
{
|
||||
WARN(":failed-last error (%d)\n",GetLastError());
|
||||
__set_errno(ERROR_INVALID_PARAMETER);
|
||||
return -1;
|
||||
}
|
||||
buf->st_mode = S_IFREG | S_IREAD;
|
||||
if (!(hfi.dwFileAttributes & FILE_ATTRIBUTE_READONLY))
|
||||
buf->st_mode |= S_IWRITE;
|
||||
buf->st_size = ((__int32)hfi.nFileSizeHigh << 16) + hfi.nFileSizeLow;
|
||||
RtlTimeToSecondsSince1970((LARGE_INTEGER *)&hfi.ftLastAccessTime, &dw);
|
||||
buf->st_atime = dw;
|
||||
RtlTimeToSecondsSince1970((LARGE_INTEGER *)&hfi.ftLastWriteTime, &dw);
|
||||
buf->st_mtime = buf->st_ctime = dw;
|
||||
buf->st_nlink = hfi.nNumberOfLinks;
|
||||
}
|
||||
TRACE(":dwFileAttributes = 0x%x, mode set to 0x%x\n",hfi.dwFileAttributes,
|
||||
buf->st_mode);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
@@ -1286,7 +1319,7 @@ int CDECL _futime(int fd, struct _utimbuf *t)
|
||||
/*********************************************************************
|
||||
* _get_osfhandle (MSVCRT.@)
|
||||
*/
|
||||
long CDECL _get_osfhandle(int fd)
|
||||
intptr_t CDECL _get_osfhandle(int fd)
|
||||
{
|
||||
HANDLE hand = fdtoh(fd);
|
||||
TRACE(":fd (%d) handle (%p)\n",fd,hand);
|
||||
@@ -1641,7 +1674,7 @@ int CDECL _wcreat(const wchar_t *path, int flags)
|
||||
/*********************************************************************
|
||||
* _open_osfhandle (MSVCRT.@)
|
||||
*/
|
||||
int CDECL _open_osfhandle(long handle, int oflags)
|
||||
int CDECL _open_osfhandle(intptr_t handle, int oflags)
|
||||
{
|
||||
int fd;
|
||||
|
||||
@@ -1879,14 +1912,67 @@ int CDECL _stati64(const char* path, struct _stati64 * buf)
|
||||
/*********************************************************************
|
||||
* _stat (MSVCRT.@)
|
||||
*/
|
||||
int CDECL _stat(const char* path, struct _stat * buf)
|
||||
{ int ret;
|
||||
struct __stat64 buf64;
|
||||
int CDECL _stat32(const char* path, struct _stat32 * buf)
|
||||
{
|
||||
DWORD dw;
|
||||
WIN32_FILE_ATTRIBUTE_DATA hfi;
|
||||
unsigned short mode = ALL_S_IREAD;
|
||||
int plen;
|
||||
|
||||
ret = _stat64( path, &buf64);
|
||||
if (!ret)
|
||||
stat64_to_stat(&buf64, buf);
|
||||
return ret;
|
||||
TRACE(":file (%s) buf(%p)\n",path,buf);
|
||||
|
||||
if (!GetFileAttributesExA(path, GetFileExInfoStandard, &hfi))
|
||||
{
|
||||
TRACE("failed (%d)\n",GetLastError());
|
||||
__set_errno(ERROR_FILE_NOT_FOUND);
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset(buf,0,sizeof(struct _stat32));
|
||||
|
||||
/* FIXME: rdev isn't drive num, despite what the docs say-what is it?
|
||||
Bon 011120: This FIXME seems incorrect
|
||||
Also a letter as first char isn't enough to be classified
|
||||
as a drive letter
|
||||
*/
|
||||
if (isalpha(*path)&& (*(path+1)==':'))
|
||||
buf->st_dev = buf->st_rdev = toupper(*path) - 'A'; /* drive num */
|
||||
else
|
||||
buf->st_dev = buf->st_rdev = _getdrive() - 1;
|
||||
|
||||
plen = strlen(path);
|
||||
|
||||
/* Dir, or regular file? */
|
||||
if ((hfi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ||
|
||||
(path[plen-1] == '\\'))
|
||||
mode |= (_S_IFDIR | ALL_S_IEXEC);
|
||||
else
|
||||
{
|
||||
mode |= _S_IFREG;
|
||||
/* executable? */
|
||||
if (plen > 6 && path[plen-4] == '.') /* shortest exe: "\x.exe" */
|
||||
{
|
||||
unsigned int ext = tolower(path[plen-1]) | (tolower(path[plen-2]) << 8) |
|
||||
(tolower(path[plen-3]) << 16);
|
||||
if (ext == EXE || ext == BAT || ext == CMD || ext == COM)
|
||||
mode |= ALL_S_IEXEC;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(hfi.dwFileAttributes & FILE_ATTRIBUTE_READONLY))
|
||||
mode |= ALL_S_IWRITE;
|
||||
|
||||
buf->st_mode = mode;
|
||||
buf->st_nlink = 1;
|
||||
buf->st_size = ((__int32)hfi.nFileSizeHigh << 16) + hfi.nFileSizeLow;
|
||||
RtlTimeToSecondsSince1970((LARGE_INTEGER *)&hfi.ftLastAccessTime, &dw);
|
||||
buf->st_atime = dw;
|
||||
RtlTimeToSecondsSince1970((LARGE_INTEGER *)&hfi.ftLastWriteTime, &dw);
|
||||
buf->st_mtime = buf->st_ctime = dw;
|
||||
TRACE("%d %d 0x%08lx%08lx %ld %ld %ld\n", buf->st_mode,buf->st_nlink,
|
||||
(long)(buf->st_size >> 16),(long)buf->st_size,
|
||||
(long)buf->st_atime,(long)buf->st_mtime,(long)buf->st_ctime);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
@@ -1968,14 +2054,63 @@ int CDECL _wstati64(const wchar_t* path, struct _stati64 * buf)
|
||||
/*********************************************************************
|
||||
* _wstat (MSVCRT.@)
|
||||
*/
|
||||
int CDECL _wstat(const wchar_t* path, struct _stat * buf)
|
||||
int CDECL _wstat32(const wchar_t* path, struct _stat32 * buf)
|
||||
{
|
||||
int ret;
|
||||
struct __stat64 buf64;
|
||||
DWORD dw;
|
||||
WIN32_FILE_ATTRIBUTE_DATA hfi;
|
||||
unsigned short mode = ALL_S_IREAD;
|
||||
int plen;
|
||||
|
||||
ret = _wstat64( path, &buf64 );
|
||||
if (!ret) stat64_to_stat(&buf64, buf);
|
||||
return ret;
|
||||
TRACE(":file (%s) buf(%p)\n",debugstr_w(path),buf);
|
||||
|
||||
if (!GetFileAttributesExW(path, GetFileExInfoStandard, &hfi))
|
||||
{
|
||||
TRACE("failed (%d)\n",GetLastError());
|
||||
__set_errno(ERROR_FILE_NOT_FOUND);
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset(buf,0,sizeof(struct _stat32));
|
||||
|
||||
/* FIXME: rdev isn't drive num, despite what the docs says-what is it? */
|
||||
if (iswalpha(*path))
|
||||
buf->st_dev = buf->st_rdev = toupperW(*path - 'A'); /* drive num */
|
||||
else
|
||||
buf->st_dev = buf->st_rdev = _getdrive() - 1;
|
||||
|
||||
plen = strlenW(path);
|
||||
|
||||
/* Dir, or regular file? */
|
||||
if ((hfi.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ||
|
||||
(path[plen-1] == '\\'))
|
||||
mode |= (_S_IFDIR | ALL_S_IEXEC);
|
||||
else
|
||||
{
|
||||
mode |= _S_IFREG;
|
||||
/* executable? */
|
||||
if (plen > 6 && path[plen-4] == '.') /* shortest exe: "\x.exe" */
|
||||
{
|
||||
ULONGLONG ext = tolowerW(path[plen-1]) | (tolowerW(path[plen-2]) << 16) |
|
||||
((ULONGLONG)tolowerW(path[plen-3]) << 32);
|
||||
if (ext == WCEXE || ext == WCBAT || ext == WCCMD || ext == WCCOM)
|
||||
mode |= ALL_S_IEXEC;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(hfi.dwFileAttributes & FILE_ATTRIBUTE_READONLY))
|
||||
mode |= ALL_S_IWRITE;
|
||||
|
||||
buf->st_mode = mode;
|
||||
buf->st_nlink = 1;
|
||||
buf->st_size = ((__int32)hfi.nFileSizeHigh << 16) + hfi.nFileSizeLow;
|
||||
RtlTimeToSecondsSince1970((LARGE_INTEGER *)&hfi.ftLastAccessTime, &dw);
|
||||
buf->st_atime = dw;
|
||||
RtlTimeToSecondsSince1970((LARGE_INTEGER *)&hfi.ftLastWriteTime, &dw);
|
||||
buf->st_mtime = buf->st_ctime = dw;
|
||||
TRACE("%d %d 0x%08lx%08lx %ld %ld %ld\n", buf->st_mode,buf->st_nlink,
|
||||
(long)(buf->st_size >> 16),(long)buf->st_size,
|
||||
(long)buf->st_atime,(long)buf->st_mtime,(long)buf->st_ctime);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <precomp.h>
|
||||
#include <tchar.h>
|
||||
|
||||
#include <io.h>
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
int* __doserrno(void)
|
||||
unsigned long* __doserrno(void)
|
||||
{
|
||||
return (int*)(&GetThreadData()->tdoserrno);
|
||||
return (unsigned long*)(&GetThreadData()->tdoserrno);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
*/
|
||||
|
||||
#include <precomp.h>
|
||||
#undef environ
|
||||
//#undef environ
|
||||
|
||||
/*
|
||||
* @implemented
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
unsigned int _rotr( unsigned int value, int shift );
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
|
||||
@@ -15,8 +15,7 @@
|
||||
*
|
||||
* copy this swab from wine cvs 2006-05-24
|
||||
*/
|
||||
void _swab (const char * src, char * dst, size_t sizeToCopy
|
||||
)
|
||||
void _swab (char * src, char * dst, int sizeToCopy)
|
||||
|
||||
{
|
||||
if (sizeToCopy > 1)
|
||||
|
||||
@@ -11,9 +11,9 @@ _ttol(const _TCHAR *str)
|
||||
return (long)_ttoi64(str);
|
||||
}
|
||||
|
||||
int _atoldbl(long double *value, const char *str)
|
||||
int _atoldbl(_LDOUBLE *value, char *str)
|
||||
{
|
||||
/* FIXME needs error checking for huge/small values */
|
||||
//*value = strtold(str,0);
|
||||
return 0;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <ctype.h>
|
||||
|
||||
#undef _pctype
|
||||
#undef _pwctype
|
||||
|
||||
/* MS's CRT header defines all that, and we actually implement that */
|
||||
#undef iswalnum
|
||||
@@ -22,11 +23,13 @@
|
||||
#undef iswspace
|
||||
#undef iswxdigit
|
||||
#undef __toascii
|
||||
#undef _tolower
|
||||
#undef _toupper
|
||||
|
||||
#define upalpha ('A' - 'a')
|
||||
|
||||
|
||||
unsigned short _ctype[] = {
|
||||
const unsigned short _ctype[] = {
|
||||
0, /* <EOF>, 0xFFFF */
|
||||
_CONTROL, /* CTRL+@, 0x00 */
|
||||
_CONTROL, /* CTRL+A, 0x01 */
|
||||
@@ -545,7 +548,7 @@ int iswxdigit(wint_t c)
|
||||
*/
|
||||
int __toascii(int c)
|
||||
{
|
||||
return((unsigned)(c) & 0x7f);
|
||||
return((unsigned int)(c) & 0x7f);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -24,8 +24,6 @@
|
||||
*/
|
||||
|
||||
#include <precomp.h>
|
||||
|
||||
#include <wchar.h>
|
||||
#include <ctype.h>
|
||||
|
||||
// HACK for LIBCNT
|
||||
@@ -183,7 +181,7 @@ int swscanf(const wchar_t *str, const wchar_t *format, ...)
|
||||
/*********************************************************************
|
||||
* _cscanf (MSVCRT.@)
|
||||
*/
|
||||
int _cscanf(/*const*/ char *format, ...)
|
||||
int _cscanf(const char *format, ...)
|
||||
{
|
||||
va_list valist;
|
||||
int res;
|
||||
|
||||
@@ -1450,12 +1450,12 @@ __p__tzname(void)
|
||||
/*********************************************************************
|
||||
* _dstbias (MSVCRT.@)
|
||||
*/
|
||||
int _dstbias = 0;
|
||||
long _dstbias = 0;
|
||||
|
||||
/*********************************************************************
|
||||
* __p_dstbias (MSVCRT.@)
|
||||
*/
|
||||
int * __p__dstbias(void)
|
||||
long * __p__dstbias(void)
|
||||
{
|
||||
return &_dstbias;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* @implemented
|
||||
*/
|
||||
double
|
||||
difftime(time_t time1, time_t time0)
|
||||
difftime(time_t time1, time_t time2)
|
||||
{
|
||||
return time1-time0;
|
||||
return (double)(time1 - time2);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user