diff --git a/reactos/ChangeLog b/reactos/ChangeLog index 43a60fb5f00..a73d428f5e0 100644 --- a/reactos/ChangeLog +++ b/reactos/ChangeLog @@ -1,3 +1,10 @@ +2003-07-15 Royce Mitchell III + + * fixed references to errno in MSVCRT to use __set_errno() and + _errno() respectively. + * Fixed warning (args 3 & 6 in call to CreateThread) in + lib/msvcrt/process/threadx.c + 2003-07-15 Royce Mitchell III * modified crtdll to forward most of it's CTYPE, STRING diff --git a/reactos/lib/msvcrt/io/lseeki64.c b/reactos/lib/msvcrt/io/lseeki64.c index 801b7dd6e38..83c45e72029 100644 --- a/reactos/lib/msvcrt/io/lseeki64.c +++ b/reactos/lib/msvcrt/io/lseeki64.c @@ -16,12 +16,12 @@ __int64 _lseeki64(int _fildes, __int64 _offset, int _whence) offset.QuadPart = _offset; // if (invalid_filehnd(_fildes)) { -// errno = EBADF; +// __set_errno ( EBADF ); // return -1L; // } if (SetFilePointerEx((HANDLE)filehnd(_fildes), offset, &new_pos, _whence)) { } else { - //errno = EINVAL; + //__set_errno ( EINVAL ); return -1L; } return new_pos.QuadPart; diff --git a/reactos/lib/msvcrt/misc/assert.c b/reactos/lib/msvcrt/misc/assert.c index 8adbbdac739..0e416a894c7 100644 --- a/reactos/lib/msvcrt/misc/assert.c +++ b/reactos/lib/msvcrt/misc/assert.c @@ -13,4 +13,5 @@ void _assert(const char *msg, const char *file, int line) /* Assertion failed at foo.c line 45: x #include #include @@ -176,18 +176,18 @@ do_spawn(int mode, const char* cmdname, const char* args, const char* envp) if (mode != _P_NOWAIT && mode != _P_NOWAITO && mode != _P_WAIT && mode != _P_DETACH && mode != _P_OVERLAY) { - errno = EINVAL; + __set_errno ( EINVAL ); return -1; } if (0 != _access(cmdname, F_OK)) { - errno = ENOENT; + __set_errno ( ENOENT ); return -1; } if (0 == _access(cmdname, D_OK)) { - errno = EISDIR; + __set_errno ( EISDIR ); return -1; } @@ -208,7 +208,7 @@ do_spawn(int mode, const char* cmdname, const char* args, const char* envp) StartupInfo.lpReserved2 = malloc(StartupInfo.cbReserved2); if (StartupInfo.lpReserved2 == NULL) { - errno = ENOMEM; + __set_errno ( ENOMEM ); return -1; } diff --git a/reactos/lib/msvcrt/process/thread.c b/reactos/lib/msvcrt/process/thread.c index 9884a9610d3..f23aaefed66 100644 --- a/reactos/lib/msvcrt/process/thread.c +++ b/reactos/lib/msvcrt/process/thread.c @@ -1,4 +1,4 @@ -/* $Id: thread.c,v 1.6 2003/07/11 21:58:09 royce Exp $ +/* $Id: thread.c,v 1.7 2003/07/16 02:45:24 royce Exp $ * */ #include @@ -14,7 +14,7 @@ unsigned long _beginthread( unsigned stack_size, void* arglist) { - errno = ENOSYS; + __set_errno ( ENOSYS ); return (unsigned long)-1; } diff --git a/reactos/lib/msvcrt/process/threadx.c b/reactos/lib/msvcrt/process/threadx.c index cc287cdabe5..01b3bc2f085 100644 --- a/reactos/lib/msvcrt/process/threadx.c +++ b/reactos/lib/msvcrt/process/threadx.c @@ -1,4 +1,4 @@ -/* $Id: threadx.c,v 1.3 2003/07/11 21:58:09 royce Exp $ +/* $Id: threadx.c,v 1.4 2003/07/16 02:45:24 royce Exp $ * */ #include @@ -23,11 +23,13 @@ unsigned long _beginthreadex( * Just call the API function. Any CRT specific processing is done in * DllMain DLL_THREAD_ATTACH */ - NewThread = CreateThread(security, stack_size, start_address, arglist, initflag, thrdaddr); + NewThread = CreateThread ( security, stack_size, + (LPTHREAD_START_ROUTINE)start_address, + arglist, initflag, (PULONG)thrdaddr ); if (NULL == NewThread) { /* FIXME map GetLastError() to errno */ - errno = ENOSYS; + __set_errno ( ENOSYS ); } return (unsigned long) NewThread; diff --git a/reactos/lib/msvcrt/stdio/fflush.c b/reactos/lib/msvcrt/stdio/fflush.c index 7bceaa07153..7680626c8d8 100644 --- a/reactos/lib/msvcrt/stdio/fflush.c +++ b/reactos/lib/msvcrt/stdio/fflush.c @@ -32,11 +32,11 @@ int fflush(FILE *f) if (f == NULL) { - int e = errno; + int e = *_errno(); __set_errno(0); _fwalk((void (*)(FILE *))fflush); - if (errno) + if (*_errno()) return EOF; __set_errno(e); return 0; diff --git a/reactos/lib/msvcrt/stdio/fgetpos.c b/reactos/lib/msvcrt/stdio/fgetpos.c index a216e7db3d7..b4b61247e98 100644 --- a/reactos/lib/msvcrt/stdio/fgetpos.c +++ b/reactos/lib/msvcrt/stdio/fgetpos.c @@ -12,6 +12,6 @@ int fgetpos(FILE *stream, fpos_t *pos) *pos = (fpos_t)ftell(stream); return 0; } - //errno = EFAULT; + //__set_errno ( EFAULT ); return 1; } diff --git a/reactos/lib/msvcrt/stdio/filbuf.c b/reactos/lib/msvcrt/stdio/filbuf.c index 1df9fb0a5c3..306c8bd976c 100644 --- a/reactos/lib/msvcrt/stdio/filbuf.c +++ b/reactos/lib/msvcrt/stdio/filbuf.c @@ -86,7 +86,7 @@ int _filbuf(FILE* f) f->_flag |= _IOERR; f->_cnt = 0; -// should set errno +// FIXME should set errno return EOF; } diff --git a/reactos/lib/msvcrt/stdio/tmpfile.c b/reactos/lib/msvcrt/stdio/tmpfile.c index bfa621ed0b0..b188dece4a3 100644 --- a/reactos/lib/msvcrt/stdio/tmpfile.c +++ b/reactos/lib/msvcrt/stdio/tmpfile.c @@ -38,9 +38,9 @@ tmpfile(void) retries the call to `tmpnam' until we actually succeed to create the file which didn't exist before. */ do { - // errno = 0; + // __set_errno ( 0 ); temp_fd = _open(temp_name, 0, SH_DENYRW); - // if ( errno == ENOENT ) + // if ( *_errno() == ENOENT ) // break; } while (temp_fd == -1 && (temp_name = tmpnam(0)) != 0); diff --git a/reactos/lib/msvcrt/stdio/vfscanf.c b/reactos/lib/msvcrt/stdio/vfscanf.c index 349aabae345..b0ddad64c54 100644 --- a/reactos/lib/msvcrt/stdio/vfscanf.c +++ b/reactos/lib/msvcrt/stdio/vfscanf.c @@ -229,7 +229,7 @@ int __vfscanf (FILE *s, const char *format, va_list argptr) if (skip_space) { while (isspace (c)) - if (inchar () == EOF && errno == EINTR) + if (inchar () == EOF && *_errno() == EINTR) conv_error (); skip_space = 0; } @@ -344,7 +344,7 @@ int __vfscanf (FILE *s, const char *format, va_list argptr) conv_error (); /* We must take care for EINTR errors. */ - if (c == EOF && errno == EINTR) + if (c == EOF && *_errno() == EINTR) input_error (); /* Find the conversion specifier. */ @@ -353,7 +353,7 @@ int __vfscanf (FILE *s, const char *format, va_list argptr) { /* Eat whitespace. */ do - if (inchar () == EOF && errno == EINTR) + if (inchar () == EOF && *_errno() == EINTR) input_error (); while (isspace (c)); ungetc (c, s); diff --git a/reactos/lib/msvcrt/stdlib/strtoll.c b/reactos/lib/msvcrt/stdlib/strtoll.c index b609e79d233..6115580be3a 100644 --- a/reactos/lib/msvcrt/stdlib/strtoll.c +++ b/reactos/lib/msvcrt/stdlib/strtoll.c @@ -74,7 +74,7 @@ strtoll(const char *nptr, char **endptr, int base) if (any < 0) { acc = neg ? LLONG_MIN : LLONG_MAX; - errno = ERANGE; + __set_errno ( ERANGE ); } else if (neg) acc *= -1; diff --git a/reactos/lib/msvcrt/stdlib/strtoull.c b/reactos/lib/msvcrt/stdlib/strtoull.c index ec9f852525f..031b9103a57 100644 --- a/reactos/lib/msvcrt/stdlib/strtoull.c +++ b/reactos/lib/msvcrt/stdlib/strtoull.c @@ -66,7 +66,7 @@ strtoull(const char *nptr, char **endptr, int base) if (any < 0) { acc = ULONG_MAX; - errno = ERANGE; + __set_errno ( ERANGE ); } else if (neg) acc = -acc; diff --git a/reactos/lib/msvcrt/string/strerror.c b/reactos/lib/msvcrt/string/strerror.c index cd2df30d4f7..fa8d9d0083b 100644 --- a/reactos/lib/msvcrt/string/strerror.c +++ b/reactos/lib/msvcrt/string/strerror.c @@ -108,7 +108,7 @@ char *strerror(int errnum) char *_strerror(const char *s) { if ( s == NULL ) - return strerror(errno); + return strerror(*_errno()); return strerror(atoi(s)); }