diff --git a/reactos/include/msvcrt/internal/rterror.h b/reactos/include/msvcrt/internal/rterror.h new file mode 100644 index 00000000000..6979abedb0c --- /dev/null +++ b/reactos/include/msvcrt/internal/rterror.h @@ -0,0 +1,29 @@ +/* rterror.h */ + +#ifndef __MSVCRT_INTERNAL_RTERROR_H +#define __MSVCRT_INTERNAL_RTERROR_H + +#define _RT_STACK 0 /* stack overflow */ +#define _RT_NULLPTR 1 /* null pointer assignment */ +#define _RT_FLOAT 2 /* floating point not loaded */ +#define _RT_INTDIV 3 /* integer divide by 0 */ +#define _RT_SPACEARG 4 /* not enough space for arguments */ +#define _RT_SPACEENV 5 /* not enough space for environment */ +#define _RT_ABORT 6 /* abnormal program termination */ +#define _RT_THREAD 7 /* not enough space for thread data */ +#define _RT_LOCK 8 /* unexpected multi-thread lock error */ +#define _RT_HEAP 9 /* unexpected heap error */ +#define _RT_OPENCON 10 /* unable to open console device */ +#define _RT_NONCONT 11 /* non-continuable exception */ +#define _RT_INVALDISP 12 /* invalid disposition of exception */ +#define _RT_ONEXIT 13 /* insufficient heap to allocate + * initial table of function pointers + * used by _onexit()/atexit(). */ +#define _RT_PUREVIRT 14 /* pure virtual function call attempted + * (C++ error) */ +#define _RT_STDIOINIT 15 /* not enough space for stdio initialization */ +#define _RT_LOWIOINIT 16 /* not enough space for lowio initialization */ + +void _amsg_exit (int errnum); + +#endif /* __MSVCRT_INTERNAL_RTERROR_H */ diff --git a/reactos/lib/msvcrt/Makefile b/reactos/lib/msvcrt/Makefile index 8c4e850b172..77e6905395e 100644 --- a/reactos/lib/msvcrt/Makefile +++ b/reactos/lib/msvcrt/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.7 2000/12/28 11:43:07 jean Exp $ +# $Id: Makefile,v 1.8 2001/01/06 15:49:25 ekohl Exp $ # # ReactOS Operating System # @@ -7,7 +7,7 @@ PATH_TO_TOP = ../.. TARGET_NAME=msvcrt TARGET_DLL=$(TARGET_NAME).dll -BASE_CFLAGS = -I../../include +CFLAGS = -I../../include -D__MSVCRT__ all: $(TARGET_DLL) @@ -42,7 +42,8 @@ OBJECTS_DIRECT = \ direct/rmdir.o OBJECTS_FLOAT = \ - float/isnan.o \ + float/fpreset.o \ + float/isnan.o OBJECTS_IO = \ io/close.o \ @@ -52,6 +53,7 @@ OBJECTS_IO = \ io/open.o \ io/read.o \ io/setmode.o \ + io/unlink.o \ io/write.o OBJECTS_MATH = \ @@ -59,11 +61,16 @@ OBJECTS_MATH = \ math/pow.o \ OBJECTS_MISC = \ + misc/amsg.o \ misc/dllmain.o \ + misc/purecall.o \ misc/tls.o OBJECTS_PROCESS = \ - process/thread.o + process/dll.o \ + process/procid.o \ + process/thread.o \ + process/threadid.o OBJECTS_SIGNAL = \ signal/signal.o \ @@ -118,6 +125,7 @@ OBJECTS_STDLIB = \ stdlib/ldiv.o \ stdlib/makepath.o \ stdlib/malloc.o \ + stdlib/obsol.o \ stdlib/putenv.o \ stdlib/qsort.o \ stdlib/rand.o \ @@ -127,6 +135,7 @@ OBJECTS_STDLIB = \ stdlib/strtod.o \ stdlib/strtol.o \ stdlib/strtoul.o \ + stdlib/swab.o \ stdlib/wcstod.o \ stdlib/wcstol.o \ stdlib/wcstoul.o \ @@ -259,12 +268,13 @@ $(TARGET_NAME).dll: $(DLLMAIN) $(OBJECTS) $(TARGET_NAME).def --def $(TARGET_NAME).def \ --output-lib $(TARGET_NAME).a $(CC) \ - -specs=misc/$(TARGET_NAME)_specs \ + -nostartfiles -nostdlib \ -mdll \ -o junk.tmp \ -Wl,--base-file,base.tmp \ + -Wl,--entry=_DllMain@12 \ $(TARGET_NAME).o \ - ../kernel32/kernel32.a + ../kernel32/kernel32.a -lgcc - $(RM) junk.tmp $(DLLTOOL) \ --dllname $(TARGET_NAME).dll \ @@ -273,15 +283,16 @@ $(TARGET_NAME).dll: $(DLLMAIN) $(OBJECTS) $(TARGET_NAME).def --def $(TARGET_NAME).def - $(RM) base.tmp $(CC) \ - -specs=misc/$(TARGET_NAME)_specs \ + -nostartfiles -nostdlib \ -mdll \ -o $(TARGET_NAME).dll \ $(TARGET_NAME).o \ - ../kernel32/kernel32.a \ + ../kernel32/kernel32.a -lgcc \ -Wl,--image-base,0x78000000 \ -Wl,--file-alignment,0x1000 \ -Wl,--section-alignment,0x1000 \ - -Wl,temp.exp + -Wl,temp.exp \ + -Wl,--entry=_DllMain@12 - $(RM) temp.exp $(NM) --numeric-sort $(TARGET_NAME).dll > $(TARGET_NAME).sym diff --git a/reactos/lib/msvcrt/float/fpreset.c b/reactos/lib/msvcrt/float/fpreset.c new file mode 100644 index 00000000000..6e8dd3d24ca --- /dev/null +++ b/reactos/lib/msvcrt/float/fpreset.c @@ -0,0 +1,8 @@ +#include + +void _fpreset (void) +{ + /* FIXME: This causes an exception */ +// __asm__ __volatile__("fninit\n\t"); + return; +} diff --git a/reactos/lib/msvcrt/io/open.c b/reactos/lib/msvcrt/io/open.c index c3a8a6b2289..5228201068c 100644 --- a/reactos/lib/msvcrt/io/open.c +++ b/reactos/lib/msvcrt/io/open.c @@ -41,8 +41,6 @@ char __is_text_file(FILE *p) } - - int __fileno_alloc(HANDLE hFile, int mode); @@ -53,7 +51,7 @@ int _open(const char *_path, int _oflag,...) DWORD dwShareMode = 0; DWORD dwCreationDistribution = 0; DWORD dwFlagsAndAttributes = 0; - + if (( _oflag & S_IREAD ) == S_IREAD) dwShareMode = FILE_SHARE_READ; else if ( ( _oflag & S_IWRITE) == S_IWRITE ) { @@ -64,7 +62,8 @@ int _open(const char *_path, int _oflag,...) * * _O_BINARY Opens file in binary (untranslated) mode. (See fopen for a description of binary mode.) * _O_TEXT Opens file in text (translated) mode. (For more information, see Text and Binary Mode File I/O and fopen.) - * + * + * _O_APPEND Moves file pointer to end of file before every write operation. */ if (( _oflag & _O_RDWR ) == _O_RDWR ) dwDesiredAccess |= GENERIC_WRITE|GENERIC_READ | FILE_READ_DATA | @@ -120,18 +119,90 @@ int _open(const char *_path, int _oflag,...) if (hFile == (HANDLE)-1) return -1; return __fileno_alloc(hFile,_oflag); - -// _O_APPEND Moves file pointer to end of file before every write operation. - } +int _wopen(const wchar_t *_path, int _oflag,...) +{ + HANDLE hFile; + DWORD dwDesiredAccess = 0; + DWORD dwShareMode = 0; + DWORD dwCreationDistribution = 0; + DWORD dwFlagsAndAttributes = 0; + + if (( _oflag & S_IREAD ) == S_IREAD) + dwShareMode = FILE_SHARE_READ; + else if ( ( _oflag & S_IWRITE) == S_IWRITE ) { + dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE; + } + + /* + * + * _O_BINARY Opens file in binary (untranslated) mode. (See fopen for a description of binary mode.) + * _O_TEXT Opens file in text (translated) mode. (For more information, see Text and Binary Mode File I/O and fopen.) + * + * _O_APPEND Moves file pointer to end of file before every write operation. + */ + if (( _oflag & _O_RDWR ) == _O_RDWR ) + dwDesiredAccess |= GENERIC_WRITE|GENERIC_READ | FILE_READ_DATA | + FILE_WRITE_DATA | FILE_READ_ATTRIBUTES | + FILE_WRITE_ATTRIBUTES; + else if (( _oflag & O_RDONLY ) == O_RDONLY ) + dwDesiredAccess |= GENERIC_READ | FILE_READ_DATA | FILE_READ_ATTRIBUTES + | FILE_WRITE_ATTRIBUTES; + else if (( _oflag & _O_WRONLY ) == _O_WRONLY ) + dwDesiredAccess |= GENERIC_WRITE | FILE_WRITE_DATA | + FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES; + + if (( _oflag & S_IREAD ) == S_IREAD ) + dwShareMode |= FILE_SHARE_READ; + + if (( _oflag & S_IWRITE ) == S_IWRITE ) + dwShareMode |= FILE_SHARE_WRITE; + + if (( _oflag & (_O_CREAT | _O_EXCL ) ) == (_O_CREAT | _O_EXCL) ) + dwCreationDistribution |= CREATE_NEW; + + else if (( _oflag & O_TRUNC ) == O_TRUNC ) { + if (( _oflag & O_CREAT ) == O_CREAT ) + dwCreationDistribution |= CREATE_ALWAYS; + else if (( _oflag & O_RDONLY ) != O_RDONLY ) + dwCreationDistribution |= TRUNCATE_EXISTING; + } + else if (( _oflag & _O_APPEND ) == _O_APPEND ) + dwCreationDistribution |= OPEN_EXISTING; + else if (( _oflag & _O_CREAT ) == _O_CREAT ) + dwCreationDistribution |= OPEN_ALWAYS; + else + dwCreationDistribution |= OPEN_EXISTING; + + if (( _oflag & _O_RANDOM ) == _O_RANDOM ) + dwFlagsAndAttributes |= FILE_FLAG_RANDOM_ACCESS; + if (( _oflag & _O_SEQUENTIAL ) == _O_SEQUENTIAL ) + dwFlagsAndAttributes |= FILE_FLAG_SEQUENTIAL_SCAN; + + if (( _oflag & _O_TEMPORARY ) == _O_TEMPORARY ) + dwFlagsAndAttributes |= FILE_FLAG_DELETE_ON_CLOSE; + + if (( _oflag & _O_SHORT_LIVED ) == _O_SHORT_LIVED ) + dwFlagsAndAttributes |= FILE_FLAG_DELETE_ON_CLOSE; + + hFile = CreateFileW(_path, + dwDesiredAccess, + dwShareMode, + NULL, + dwCreationDistribution, + dwFlagsAndAttributes, + NULL); + if (hFile == (HANDLE)-1) + return -1; + return __fileno_alloc(hFile,_oflag); +} int __fileno_alloc(HANDLE hFile, int mode) { - int i; /* Check for bogus values */ if (hFile < 0) @@ -146,7 +217,6 @@ __fileno_alloc(HANDLE hFile, int mode) } } - /* See if we need to expand the tables. Check this BEFORE it might fail, so that when we hit the count'th request, we've already up'd it. */ if ( i == maxfno) @@ -159,7 +229,6 @@ __fileno_alloc(HANDLE hFile, int mode) memcpy(fileno_modes, old_fileno_modes, oldcount * sizeof(fileno_modes_type)); memset(fileno_modes + oldcount, 0, (maxfno-oldcount)*sizeof(fileno_modes)); free ( old_fileno_modes ); - } /* Fill in the value */ @@ -171,9 +240,6 @@ __fileno_alloc(HANDLE hFile, int mode) void *filehnd(int fileno) { - - - if ( fileno < 0 ) return (void *)-1; #define STD_AUX_HANDLE 3 @@ -194,7 +260,7 @@ void *filehnd(int fileno) default: break; } - + if ( fileno >= maxfno ) return (void *)-1; @@ -217,8 +283,7 @@ int __fileno_dup2( int handle1, int handle2 ) return -1; memcpy(&fileno_modes[handle1],&fileno_modes[handle2],sizeof(fileno_modes)); - - + return handle1; } @@ -229,7 +294,7 @@ int __fileno_setmode(int _fd, int _newmode) return -1; if ( _fd >= maxfno ) - return -1; + return -1; m = fileno_modes[_fd].mode; fileno_modes[_fd].mode = _newmode; @@ -242,32 +307,32 @@ int __fileno_getmode(int _fd) return -1; if ( _fd >= maxfno ) - return -1; + return -1; return fileno_modes[_fd].mode; } -int __fileno_close(int _fd) +int __fileno_close(int _fd) { if ( _fd < 0 ) return -1; if ( _fd >= maxfno ) - return -1; + return -1; fileno_modes[_fd].fd = -1; fileno_modes[_fd].hFile = (HANDLE)-1; - return 0; + return 0; } int _open_osfhandle (void *osfhandle, int flags ) { return __fileno_alloc((HANDLE)osfhandle, flags); -} +} void *_get_osfhandle( int fileno ) { - return filehnd(fileno); + return filehnd(fileno); } diff --git a/reactos/lib/msvcrt/io/unlink.c b/reactos/lib/msvcrt/io/unlink.c new file mode 100644 index 00000000000..9e11757b913 --- /dev/null +++ b/reactos/lib/msvcrt/io/unlink.c @@ -0,0 +1,20 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS system libraries + * FILE: lib/msvcrt/io/unlink.c + * PURPOSE: Deletes a file + * PROGRAMER: Boudewijn Dekker + * UPDATE HISTORY: + * 28/12/98: Created + */ +#include +#include + + + +int _unlink( const char *filename ) +{ + if ( !DeleteFileA(filename) ) + return -1; + return 0; +} diff --git a/reactos/lib/msvcrt/misc/amsg.c b/reactos/lib/msvcrt/misc/amsg.c new file mode 100644 index 00000000000..37b72ec8ab4 --- /dev/null +++ b/reactos/lib/msvcrt/misc/amsg.c @@ -0,0 +1,47 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS system libraries + * FILE: lib/msvcrt/misc/amsg.c + * PURPOSE: Print runtime error messages + * PROGRAMER: Boudewijn Dekker + * UPDATE HISTORY: + * 28/12/98: Created + */ + +#include + + +static char *__rt_err_msg[] = +{ + "stack overflow", /* _RT_STACK */ + "null pointer assignment", /* _RT_NULLPTR */ + "floating point not loaded", /* _RT_FLOAT */ + "integer divide by 0", /* _RT_INTDIV */ + "not enough space for arguments", /* _RT_SPACEARG */ + "not enough space for environment", /* _RT_SPACEENV */ + "abnormal program termination", /* _RT_ABORT */ + "not enough space for thread data", /* _RT_THREAD */ + "unexpected multithread lock error", /* _RT_LOCK */ + "unexpected heap error", /* _RT_HEAP */ + "unable to open console device", /* _RT_OPENCON */ + "non-continuable exception", /* _RT_NONCONT */ + "invalid exception disposition", /* _RT_INVALDISP */ + "not enough space for _onexit/atexit table", /* _RT_ONEXIT */ + "pure virtual function call", /* _RT_PUREVIRT */ + "not enough space for stdio initialization", /* _RT_STDIOINIT */ + "not enough space for lowio initialization", /* _RT_LOWIOINIT */ +}; + + +int _aexit_rtn(int exitcode) +{ + _exit(exitcode); +} + +void _amsg_exit (int errnum) +{ + fprintf(stderr, "runtime error - %s\n", __rt_err_msg[errnum]); + _aexit_rtn(-1); +} + +/* EOF */ diff --git a/reactos/lib/msvcrt/misc/msvcrt_specs b/reactos/lib/msvcrt/misc/msvcrt_specs deleted file mode 100644 index 81539eee5ca..00000000000 --- a/reactos/lib/msvcrt/misc/msvcrt_specs +++ /dev/null @@ -1,78 +0,0 @@ -*asm: - - -*asm_final: - - -*cpp: --remap %(cpp_cpu) %{posix:-D_POSIX_SOURCE} - -*cc1: -%(cc1_spec) - -*cc1plus: - - -*endfile: - - -*link: -%{mwindows:--subsystem windows} %{mdll:--dll -e _DllMain@12} - -*lib: - - -*libgcc: --lgcc - -*startfile: - - -*switches_need_spaces: - - -*signed_char: -%{funsigned-char:-D__CHAR_UNSIGNED__} - -*predefines: --Di386 -D_WIN32 -DWIN32 -D__WIN32__ -D__MINGW32__ -DWINNT -D_X86_=1 -D__STDC__=1 -D__stdcall=__attribute__((__stdcall__)) _D_stdcall=__attribute__((__stdcall__)) -D__cdecl=__attribute__((__cdecl__)) -D__declspec(x)=__attribute__((x)) -Asystem(winnt) -Acpu(i386) -Amachine(i386) - -*cross_compile: -0 - -*version: -egcs-2.8.2 - -*multilib: -. ; - -*multilib_defaults: - - -*multilib_extra: - - -*multilib_matches: - - -*linker: -collect2 - -*cpp_486: -%{!ansi:-Di486} -D__i486 -D__i486__ - -*cpp_586: -%{!ansi:-Di586 -Dpentium} -D__i586 -D__i586__ -D__pentium -D__pentium__ - -*cpp_686: -%{!ansi:-Di686 -Dpentiumpro} -D__i686 -D__i686__ -D__pentiumpro -D__pentiumpro__ - -*cpp_cpu_default: -%(cpp_586) - -*cpp_cpu: --Acpu(i386) -Amachine(i386) %{!ansi:-Di386} -D__i386 -D__i386__ %{mcpu=i486:%(cpp_486)} %{m486:%(cpp_486)} %{mpentium:%(cpp_586)} %{mcpu=pentium:%(cpp_586)} %{mpentiumpro:%(cpp_686)} %{mcpu=pentiumpro:%(cpp_686)} %{!mcpu*:%{!m486:%{!mpentium*:%(cpp_cpu_default)}}} - -*cc1_cpu: -%{!mcpu*: %{m386:-mcpu=i386 -march=i386} %{mno-486:-mcpu=i386 -march=i386} %{m486:-mcpu=i486 -march=i486} %{mno-386:-mcpu=i486 -march=i486} %{mno-pentium:-mcpu=i486 -march=i486} %{mpentium:-mcpu=pentium} %{mno-pentiumpro:-mcpu=pentium} %{mpentiumpro:-mcpu=pentiumpro}} - diff --git a/reactos/lib/msvcrt/misc/purecall.c b/reactos/lib/msvcrt/misc/purecall.c new file mode 100644 index 00000000000..fea7d5ef2b5 --- /dev/null +++ b/reactos/lib/msvcrt/misc/purecall.c @@ -0,0 +1,7 @@ + +#include + +void _purecall(void) +{ + _amsg_exit(_RT_PUREVIRT); +} diff --git a/reactos/lib/msvcrt/misc/tls.c b/reactos/lib/msvcrt/misc/tls.c index f4acf3fdffe..624c0ee847b 100644 --- a/reactos/lib/msvcrt/misc/tls.c +++ b/reactos/lib/msvcrt/misc/tls.c @@ -2,6 +2,7 @@ #include #include +#include static unsigned long TlsIndex = (unsigned long)-1; @@ -85,7 +86,7 @@ PTHREADDATA GetThreadData(void) } else { -// _amsg_exit(_RT_THREAD); /* write message and die */ + _amsg_exit(_RT_THREAD); /* write message and die */ } } diff --git a/reactos/lib/msvcrt/msvcrt.def b/reactos/lib/msvcrt/msvcrt.def index a35a7819b62..9877158e68f 100644 --- a/reactos/lib/msvcrt/msvcrt.def +++ b/reactos/lib/msvcrt/msvcrt.def @@ -1,4 +1,4 @@ -; $Id: msvcrt.def,v 1.2 2000/12/28 11:43:07 jean Exp $ +; $Id: msvcrt.def,v 1.3 2001/01/06 15:49:25 ekohl Exp $ ; ; ReactOS MSVCRT Compatibility Library ; @@ -142,8 +142,8 @@ __p__pwctype DATA ; __set_app_type ; __setlc_active ; __setusermatherr -; __threadhandle -; __threadid +__threadhandle +__threadid __toascii ; __unDName ; __unDNameEx @@ -168,19 +168,19 @@ __toascii ; _adj_fprem1 ; _adj_fptan ; _adjust_fdiv -; _aexit_rtn -; _amsg_exit +_aexit_rtn +_amsg_exit ; _assert ; _atodbl ; _atoi64 ; _atoldbl -; _beep +_beep _beginthread _beginthreadex -; _c_exit +_c_exit ; _cabs ; _callnewh -; _cexit +_cexit ; _cgets _chdir _chdrive @@ -210,7 +210,7 @@ _endthread _endthreadex ; _environ ; _eof -; _errno +_errno ; _except_handler2 ; _except_handler3 ; _execl @@ -221,7 +221,7 @@ _endthreadex ; _execve ; _execvp ; _execvpe -; _exit +_exit ; _expand _fcloseall ; _fcvt @@ -244,7 +244,7 @@ _flushall _fmode ; _fpclass ; _fpieee_flt -; _fpreset +_fpreset ; _fputchar ; _fputwchar ; _fsopen @@ -262,12 +262,12 @@ _get_osfhandle _getcwd _getdcwd _getdiskfree -; _getdllprocaddr +_getdllprocaddr _getdrive _getdrives ; _getmaxstdio ; _getmbcp -; _getpid +_getpid ; _getsystime ; _getw ; _getws @@ -325,7 +325,7 @@ _itow ; _jn ; _kbhit ; _lfind -; _loaddll +_loaddll ; _local_unwind2 ; _lock ; _locking @@ -412,7 +412,7 @@ _osver DATA ; _pgmptr ; _pipe ; _popen -; _purecall +_purecall ; _putch _putenv ; _putw @@ -432,14 +432,14 @@ _searchenv ; _seh_longjmp_unwind ; _set_error_mode ; _set_sbh_threshold -; _seterrormode +_seterrormode ; _setjmp ; _setjmp3 ; _setmaxstdio ; _setmbcp _setmode ; _setsystime -; _sleep +_sleep _snprintf _snwprintf ; _sopen @@ -470,9 +470,9 @@ _strrev _strset ; _strtime _strupr -; _swab -; _sys_errlist -; _sys_nerr +_swab +_sys_errlist DATA +_sys_nerr DATA ; _tell ; _telli64 ; _tempnam @@ -487,8 +487,8 @@ _ultoa _ultow ; _umask ; _ungetch -; _unlink -; _unloaddll +_unlink +_unloaddll ; _unlock ; _utime _vsnprintf @@ -538,12 +538,12 @@ _winver DATA _wmakepath _wmkdir ; _wmktemp -; _wopen +_wopen ; _wperror ; _wpgmptr ; _wpopen _wputenv -; _wremove +_wremove ; _wrename _write _wrmdir diff --git a/reactos/lib/msvcrt/process/dll.c b/reactos/lib/msvcrt/process/dll.c new file mode 100644 index 00000000000..2e8bc205e69 --- /dev/null +++ b/reactos/lib/msvcrt/process/dll.c @@ -0,0 +1,31 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS system libraries + * FILE: lib/msvcrt/process/dll.c + * PURPOSE: Dll support routines + * PROGRAMER: Boudewijn Dekker + * UPDATE HISTORY: + * 04/03/99: Created + */ + +#include +#include + +void *_loaddll (char *name) +{ + return LoadLibraryA(name); +} + +int _unloaddll(void *handle) +{ + return FreeLibrary(handle); +} + +FARPROC _getdllprocaddr(void *hModule,char * lpProcName, int iOrdinal) +{ + if ( lpProcName != NULL ) + return GetProcAddress(hModule, lpProcName); + else + return GetProcAddress(hModule, (LPSTR)iOrdinal); + return (NULL); +} diff --git a/reactos/lib/msvcrt/process/procid.c b/reactos/lib/msvcrt/process/procid.c new file mode 100644 index 00000000000..5213b0d504a --- /dev/null +++ b/reactos/lib/msvcrt/process/procid.c @@ -0,0 +1,8 @@ +#include +#include + +int _getpid (void) +{ + return (int)GetCurrentProcessId(); +} + diff --git a/reactos/lib/msvcrt/process/threadid.c b/reactos/lib/msvcrt/process/threadid.c new file mode 100644 index 00000000000..858c1692ce2 --- /dev/null +++ b/reactos/lib/msvcrt/process/threadid.c @@ -0,0 +1,12 @@ +#include +#include + +unsigned long __threadid (void) +{ + return GetCurrentThreadId(); +} + +void *__threadhandle(void) +{ + return GetCurrentThread(); +} \ No newline at end of file diff --git a/reactos/lib/msvcrt/stdio/fileno.c b/reactos/lib/msvcrt/stdio/fileno.c new file mode 100644 index 00000000000..f895187bafb --- /dev/null +++ b/reactos/lib/msvcrt/stdio/fileno.c @@ -0,0 +1,13 @@ +#include + +#undef fileno +int fileno(FILE *f) +{ + return f->_file; +} + + +int _fileno(FILE *f) +{ + return f->_file; +} diff --git a/reactos/lib/msvcrt/stdio/remove.c b/reactos/lib/msvcrt/stdio/remove.c index 8fc77bdbda7..8f3131375b5 100644 --- a/reactos/lib/msvcrt/stdio/remove.c +++ b/reactos/lib/msvcrt/stdio/remove.c @@ -1,4 +1,5 @@ #include +#include int remove(const char *fn) { @@ -6,4 +7,10 @@ int remove(const char *fn) return -1; return 0; } - + +int _wremove(const wchar_t *fn) +{ + if (!DeleteFileW(fn)) + return -1; + return 0; +} diff --git a/reactos/lib/msvcrt/string/strerror.c b/reactos/lib/msvcrt/string/strerror.c index 777e0cae55d..048b6e751a1 100644 --- a/reactos/lib/msvcrt/string/strerror.c +++ b/reactos/lib/msvcrt/string/strerror.c @@ -57,7 +57,7 @@ __syserr35, __syserr36, __syserr37, __syserr38 int __sys_nerr = sizeof(_sys_errlist) / sizeof(_sys_errlist[0]); -int* _sys_nerr_dll = &__sys_nerr; +int* _sys_nerr = &__sys_nerr; char *strerror(int errnum) {