Author: sserapion
Date: Sat Aug 30 11:55:35 2008
New Revision: 35810
URL:
http://svn.reactos.org/svn/reactos?rev=35810&view=rev
Log:
Commit WIP. Part 3 of ??
- Update crt to conform
- add some amd64 stubs
Added:
branches/ros-amd64-bringup/reactos/lib/sdk/crt/except/amd64/
branches/ros-amd64-bringup/reactos/lib/sdk/crt/except/amd64/chkstk_asm.s (with
props)
branches/ros-amd64-bringup/reactos/lib/sdk/crt/except/amd64/seh.s (with props)
Modified:
branches/ros-amd64-bringup/reactos/lib/sdk/crt/crt.rbuild
branches/ros-amd64-bringup/reactos/lib/sdk/crt/process/process.c
branches/ros-amd64-bringup/reactos/lib/sdk/crt/stdio/file.c
branches/ros-amd64-bringup/reactos/lib/sdk/crt/stdio/find.c
branches/ros-amd64-bringup/reactos/lib/sdk/crt/stdlib/errno.c
branches/ros-amd64-bringup/reactos/lib/sdk/crt/stdlib/getenv.c
branches/ros-amd64-bringup/reactos/lib/sdk/crt/stdlib/rot.c
branches/ros-amd64-bringup/reactos/lib/sdk/crt/stdlib/swab.c
branches/ros-amd64-bringup/reactos/lib/sdk/crt/string/atol.c
branches/ros-amd64-bringup/reactos/lib/sdk/crt/string/ctype.c
branches/ros-amd64-bringup/reactos/lib/sdk/crt/string/scanf.c
branches/ros-amd64-bringup/reactos/lib/sdk/crt/time/ctime.c
branches/ros-amd64-bringup/reactos/lib/sdk/crt/time/difftime.c
Modified: branches/ros-amd64-bringup/reactos/lib/sdk/crt/crt.rbuild
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/lib/s…
==============================================================================
--- branches/ros-amd64-bringup/reactos/lib/sdk/crt/crt.rbuild [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/lib/sdk/crt/crt.rbuild [iso-8859-1] Sat Aug 30
11:55:35 2008
@@ -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">
@@ -68,6 +74,14 @@
<file>nafter.c</file>
<file>scalb.c</file>
<if property="ARCH" value="i386">
+ <directory name="i386">
+ <file>clearfp.c</file>
+ <file>cntrlfp.c</file>
+ <file>logb.c</file>
+ <file>statfp.c</file>
+ </directory>
+ </if>
+ <if property="ARCH" value="amd64">
<directory name="i386">
<file>clearfp.c</file>
<file>cntrlfp.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">
Added: branches/ros-amd64-bringup/reactos/lib/sdk/crt/except/amd64/chkstk_asm.s
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/lib/s…
==============================================================================
--- branches/ros-amd64-bringup/reactos/lib/sdk/crt/except/amd64/chkstk_asm.s (added)
+++ branches/ros-amd64-bringup/reactos/lib/sdk/crt/except/amd64/chkstk_asm.s [iso-8859-1]
Sat Aug 30 11:55:35 2008
@@ -1,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 */
Propchange: branches/ros-amd64-bringup/reactos/lib/sdk/crt/except/amd64/chkstk_asm.s
------------------------------------------------------------------------------
svn:eol-style = native
Added: branches/ros-amd64-bringup/reactos/lib/sdk/crt/except/amd64/seh.s
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/lib/s…
==============================================================================
--- branches/ros-amd64-bringup/reactos/lib/sdk/crt/except/amd64/seh.s (added)
+++ branches/ros-amd64-bringup/reactos/lib/sdk/crt/except/amd64/seh.s [iso-8859-1] Sat Aug
30 11:55:35 2008
@@ -1,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(a)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
Propchange: branches/ros-amd64-bringup/reactos/lib/sdk/crt/except/amd64/seh.s
------------------------------------------------------------------------------
svn:eol-style = native
Modified: branches/ros-amd64-bringup/reactos/lib/sdk/crt/process/process.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/lib/s…
==============================================================================
--- branches/ros-amd64-bringup/reactos/lib/sdk/crt/process/process.c [iso-8859-1]
(original)
+++ branches/ros-amd64-bringup/reactos/lib/sdk/crt/process/process.c [iso-8859-1] Sat Aug
30 11:55:35 2008
@@ -323,7 +323,7 @@
/*
* @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 @@
/*
* @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 @@
/*
* @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 @@
/*
* @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 @@
/*
* @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 @@
/*
* @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 @@
/*
* @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 @@
/*
* @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 @@
/*
* @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 @@
/*
* @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 @@
/*
* @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 @@
/*
* @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 @@
/*
* @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 @@
/*
* @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 @@
/*
* @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 @@
/*
* @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);
Modified: branches/ros-amd64-bringup/reactos/lib/sdk/crt/stdio/file.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/lib/s…
==============================================================================
--- branches/ros-amd64-bringup/reactos/lib/sdk/crt/stdio/file.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/lib/sdk/crt/stdio/file.c [iso-8859-1] Sat Aug 30
11:55:35 2008
@@ -132,7 +132,8 @@
#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)
+#ifndef _WIN64
+static void stat64_to_stati64(const struct __stat64 *buf64, struct _stati64 *buf)
{
buf->st_dev = buf64->st_dev;
buf->st_ino = buf64->st_ino;
@@ -146,21 +147,7 @@
buf->st_mtime = buf64->st_mtime;
buf->st_ctime = buf64->st_ctime;
}
-
-static void stat64_to_stati64(const struct __stat64 *buf64, struct _stati64 *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;
-}
+#endif
static inline BOOL is_valid_fd(int fd)
{
@@ -494,7 +481,7 @@
*/
FILE * CDECL __p__iob(void)
{
- return &_iob[0];
+ return _iob;
}
/*********************************************************************
@@ -1165,7 +1152,7 @@
/*********************************************************************
* _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 @@
/*********************************************************************
* _fstat (MSVCRT.@)
*/
-int CDECL _fstat(int fd, struct _stat* buf)
-{ int ret;
- struct __stat64 buf64;
-
- ret = _fstat64(fd, &buf64);
- if (!ret)
- stat64_to_stat(&buf64, buf);
- return ret;
+int CDECL _fstat(int fd, struct _stat32* buf)
+{
+ DWORD dw;
+ DWORD type;
+ BY_HANDLE_FILE_INFORMATION hfi;
+ HANDLE hand = fdtoh(fd);
+
+ 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 @@
/*********************************************************************
* _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 @@
/*********************************************************************
* _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 @@
/*********************************************************************
* _stat (MSVCRT.@)
*/
-int CDECL _stat(const char* path, struct _stat * buf)
-{ int ret;
- struct __stat64 buf64;
-
- ret = _stat64( path, &buf64);
- if (!ret)
- stat64_to_stat(&buf64, buf);
- return ret;
+int CDECL _stat32(const char* path, struct _stat32 * buf)
+{
+ DWORD dw;
+ WIN32_FILE_ATTRIBUTE_DATA hfi;
+ unsigned short mode = ALL_S_IREAD;
+ int plen;
+
+ 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 @@
/*********************************************************************
* _wstat (MSVCRT.@)
*/
-int CDECL _wstat(const wchar_t* path, struct _stat * buf)
-{
- int ret;
- struct __stat64 buf64;
-
- ret = _wstat64( path, &buf64 );
- if (!ret) stat64_to_stat(&buf64, buf);
- return ret;
+int CDECL _wstat32(const wchar_t* path, struct _stat32 * buf)
+{
+ DWORD dw;
+ WIN32_FILE_ATTRIBUTE_DATA hfi;
+ unsigned short mode = ALL_S_IREAD;
+ int plen;
+
+ 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;
}
/*********************************************************************
Modified: branches/ros-amd64-bringup/reactos/lib/sdk/crt/stdio/find.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/lib/s…
==============================================================================
--- branches/ros-amd64-bringup/reactos/lib/sdk/crt/stdio/find.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/lib/sdk/crt/stdio/find.c [iso-8859-1] Sat Aug 30
11:55:35 2008
@@ -1,6 +1,6 @@
#include <precomp.h>
#include <tchar.h>
-
+#include <io.h>
/*
* @implemented
*/
Modified: branches/ros-amd64-bringup/reactos/lib/sdk/crt/stdlib/errno.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/lib/s…
==============================================================================
--- branches/ros-amd64-bringup/reactos/lib/sdk/crt/stdlib/errno.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/lib/sdk/crt/stdlib/errno.c [iso-8859-1] Sat Aug 30
11:55:35 2008
@@ -13,9 +13,9 @@
/*
* @implemented
*/
-int* __doserrno(void)
+unsigned long* __doserrno(void)
{
- return (int*)(&GetThreadData()->tdoserrno);
+ return (unsigned long*)(&GetThreadData()->tdoserrno);
}
/*
Modified: branches/ros-amd64-bringup/reactos/lib/sdk/crt/stdlib/getenv.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/lib/s…
==============================================================================
--- branches/ros-amd64-bringup/reactos/lib/sdk/crt/stdlib/getenv.c [iso-8859-1]
(original)
+++ branches/ros-amd64-bringup/reactos/lib/sdk/crt/stdlib/getenv.c [iso-8859-1] Sat Aug 30
11:55:35 2008
@@ -9,7 +9,7 @@
*/
#include <precomp.h>
-#undef environ
+//#undef environ
/*
* @implemented
Modified: branches/ros-amd64-bringup/reactos/lib/sdk/crt/stdlib/rot.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/lib/s…
==============================================================================
--- branches/ros-amd64-bringup/reactos/lib/sdk/crt/stdlib/rot.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/lib/sdk/crt/stdlib/rot.c [iso-8859-1] Sat Aug 30
11:55:35 2008
@@ -10,6 +10,7 @@
#include <stdlib.h>
+unsigned int _rotr( unsigned int value, int shift );
/*
* @implemented
*/
Modified: branches/ros-amd64-bringup/reactos/lib/sdk/crt/stdlib/swab.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/lib/s…
==============================================================================
--- branches/ros-amd64-bringup/reactos/lib/sdk/crt/stdlib/swab.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/lib/sdk/crt/stdlib/swab.c [iso-8859-1] Sat Aug 30
11:55:35 2008
@@ -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)
Modified: branches/ros-amd64-bringup/reactos/lib/sdk/crt/string/atol.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/lib/s…
==============================================================================
--- branches/ros-amd64-bringup/reactos/lib/sdk/crt/string/atol.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/lib/sdk/crt/string/atol.c [iso-8859-1] Sat Aug 30
11:55:35 2008
@@ -11,9 +11,9 @@
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;
}
Modified: branches/ros-amd64-bringup/reactos/lib/sdk/crt/string/ctype.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/lib/s…
==============================================================================
--- branches/ros-amd64-bringup/reactos/lib/sdk/crt/string/ctype.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/lib/sdk/crt/string/ctype.c [iso-8859-1] Sat Aug 30
11:55:35 2008
@@ -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 __toascii(int c)
{
- return((unsigned)(c) & 0x7f);
+ return((unsigned int)(c) & 0x7f);
}
/*
Modified: branches/ros-amd64-bringup/reactos/lib/sdk/crt/string/scanf.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/lib/s…
==============================================================================
--- branches/ros-amd64-bringup/reactos/lib/sdk/crt/string/scanf.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/lib/sdk/crt/string/scanf.c [iso-8859-1] Sat Aug 30
11:55:35 2008
@@ -24,8 +24,6 @@
*/
#include <precomp.h>
-
-#include <wchar.h>
#include <ctype.h>
// HACK for LIBCNT
@@ -183,7 +181,7 @@
/*********************************************************************
* _cscanf (MSVCRT.@)
*/
-int _cscanf(/*const*/ char *format, ...)
+int _cscanf(const char *format, ...)
{
va_list valist;
int res;
Modified: branches/ros-amd64-bringup/reactos/lib/sdk/crt/time/ctime.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/lib/s…
==============================================================================
--- branches/ros-amd64-bringup/reactos/lib/sdk/crt/time/ctime.c [iso-8859-1] (original)
+++ branches/ros-amd64-bringup/reactos/lib/sdk/crt/time/ctime.c [iso-8859-1] Sat Aug 30
11:55:35 2008
@@ -1450,12 +1450,12 @@
/*********************************************************************
* _dstbias (MSVCRT.@)
*/
-int _dstbias = 0;
+long _dstbias = 0;
/*********************************************************************
* __p_dstbias (MSVCRT.@)
*/
-int * __p__dstbias(void)
+long * __p__dstbias(void)
{
return &_dstbias;
}
Modified: branches/ros-amd64-bringup/reactos/lib/sdk/crt/time/difftime.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/lib/s…
==============================================================================
--- branches/ros-amd64-bringup/reactos/lib/sdk/crt/time/difftime.c [iso-8859-1]
(original)
+++ branches/ros-amd64-bringup/reactos/lib/sdk/crt/time/difftime.c [iso-8859-1] Sat Aug 30
11:55:35 2008
@@ -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);
}