diff --git a/library/GNUmakefile.68k b/library/GNUmakefile.68k index f5992c8..fa9dda2 100644 --- a/library/GNUmakefile.68k +++ b/library/GNUmakefile.68k @@ -1,5 +1,5 @@ # -# $Id: GNUmakefile.68k,v 1.23 2005-01-29 18:05:13 obarthel Exp $ +# $Id: GNUmakefile.68k,v 1.24 2005-02-03 16:56:15 obarthel Exp $ # # :ts=8 # @@ -272,6 +272,7 @@ C_LIB = \ stdlib_dosbase.o \ stdlib_exit.o \ stdlib_free.o \ + stdlib_get_errno.o \ stdlib_getdefstacksize.o \ stdlib_getenv.o \ stdlib_getsp.o \ @@ -298,6 +299,7 @@ C_LIB = \ stdlib_realloc.o \ stdlib_red_black.o \ stdlib_setenv.o \ + stdlib_set_errno.o \ stdlib_setjmp.o \ stdlib_set_process_window.o \ stdlib_shell_escape.o \ @@ -475,6 +477,7 @@ MATH_LIB = \ math_floor.o \ math_fmod.o \ math_frexp.o \ + math_huge_val.o \ math_hypot.o \ math_init_exit.o \ math_isinf.o \ diff --git a/library/GNUmakefile.os4 b/library/GNUmakefile.os4 index 2f18233..26277b0 100644 --- a/library/GNUmakefile.os4 +++ b/library/GNUmakefile.os4 @@ -1,5 +1,5 @@ # -# $Id: GNUmakefile.os4,v 1.23 2005-01-29 18:05:13 obarthel Exp $ +# $Id: GNUmakefile.os4,v 1.24 2005-02-03 16:56:15 obarthel Exp $ # # :ts=8 # @@ -275,6 +275,7 @@ C_LIB = \ stdlib_exit.o \ stdlib_free.o \ stdlib_getdefstacksize.o \ + stdlib_get_errno.o \ stdlib_getenv.o \ stdlib_getsp.o \ stdlib_init_exit.o \ @@ -299,6 +300,7 @@ C_LIB = \ stdlib_rand.o \ stdlib_realloc.o \ stdlib_red_black.o \ + stdlib_set_errno.o \ stdlib_setenv.o \ stdlib_setjmp.o \ stdlib_set_process_window.o \ @@ -479,6 +481,7 @@ MATH_LIB = \ math_floor.o \ math_fmod.o \ math_frexp.o \ + math_huge_val.o \ math_hypot.o \ math_init_exit.o \ math_isnan.o \ diff --git a/library/changes b/library/changes index 57aa3a9..0428c05 100644 --- a/library/changes +++ b/library/changes @@ -22,6 +22,17 @@ functions which is not required unless the code is built for Unix compatibility mode. +- Lost the __not_a_number and __infinity variables, including the + code which initialized them. + +- Reading/changing the errno variable is no longer done directly, but + involves accessor functions. + +- References to the HUGE_VAL quantity now involve an accessor function, too. + +- Changed the manner in which the __huge_val constant is initialized by + the __math_init() function. + c.lib 1.187 (29.1.2005) diff --git a/library/dirent_closedir.c b/library/dirent_closedir.c index 02fc063..31f47c4 100644 --- a/library/dirent_closedir.c +++ b/library/dirent_closedir.c @@ -1,5 +1,5 @@ /* - * $Id: dirent_closedir.c,v 1.4 2005-02-03 12:14:55 obarthel Exp $ + * $Id: dirent_closedir.c,v 1.5 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -63,7 +63,7 @@ closedir(DIR * directory_pointer) if(directory_pointer == NULL) { - errno = EBADF; + __set_errno(EBADF); goto out; } @@ -84,7 +84,7 @@ closedir(DIR * directory_pointer) if(NOT directory_pointer_is_valid) { - errno = EBADF; + __set_errno(EBADF); goto out; } } diff --git a/library/dirent_headers.h b/library/dirent_headers.h index e2a5014..df7abe2 100644 --- a/library/dirent_headers.h +++ b/library/dirent_headers.h @@ -1,5 +1,5 @@ /* - * $Id: dirent_headers.h,v 1.4 2005-02-03 12:14:55 obarthel Exp $ + * $Id: dirent_headers.h,v 1.5 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -42,6 +42,12 @@ /****************************************************************************/ +#ifndef _STDLIB_HEADERS_H +#include "stdlib_headers.h" +#endif /* _STDLIB_HEADERS_H */ + +/****************************************************************************/ + #ifndef _MACROS_H #include "macros.h" #endif /* _MACROS_H */ diff --git a/library/dirent_opendir.c b/library/dirent_opendir.c index 63bdeea..ca4bd74 100644 --- a/library/dirent_opendir.c +++ b/library/dirent_opendir.c @@ -1,5 +1,5 @@ /* - * $Id: dirent_opendir.c,v 1.4 2005-02-03 12:14:55 obarthel Exp $ + * $Id: dirent_opendir.c,v 1.5 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -106,7 +106,7 @@ opendir(const char * path_name) { SHOWMSG("invalid parameter"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -159,7 +159,7 @@ opendir(const char * path_name) { UnLockDosList(LDF_VOLUMES|LDF_READ); - errno = ENOMEM; + __set_errno(ENOMEM); goto out; } @@ -189,7 +189,7 @@ opendir(const char * path_name) /* Bail out if we cannot present anything. */ if(IsListEmpty((struct List *)&dh->dh_VolumeList)) { - errno = ENOMEM; + __set_errno(ENOMEM); goto out; } } @@ -212,7 +212,7 @@ opendir(const char * path_name) { SHOWMSG("couldn't get a lock on it"); - __translate_access_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_access_io_error_to_errno(IoErr())); goto out; } @@ -226,7 +226,7 @@ opendir(const char * path_name) { SHOWMSG("couldn't examine it"); - __translate_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_io_error_to_errno(IoErr())); goto out; } @@ -234,7 +234,7 @@ opendir(const char * path_name) { SHOWMSG("this isn't a directory"); - errno = ENOTDIR; + __set_errno(ENOTDIR); goto out; } } diff --git a/library/dirent_readdir.c b/library/dirent_readdir.c index 53924b0..9ed2bf9 100644 --- a/library/dirent_readdir.c +++ b/library/dirent_readdir.c @@ -1,5 +1,5 @@ /* - * $Id: dirent_readdir.c,v 1.6 2005-02-03 12:14:55 obarthel Exp $ + * $Id: dirent_readdir.c,v 1.7 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -61,7 +61,7 @@ readdir(DIR * directory_pointer) { SHOWMSG("ouch. invalid parameter"); - errno = EBADF; + __set_errno(EBADF); goto out; } @@ -164,7 +164,7 @@ readdir(DIR * directory_pointer) { if(CANNOT Examine(parent_directory,fib)) { - __translate_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_io_error_to_errno(IoErr())); goto out; } } @@ -206,7 +206,7 @@ readdir(DIR * directory_pointer) { SHOWMSG("error scanning directory"); - __translate_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_io_error_to_errno(IoErr())); goto out; } diff --git a/library/dirent_rewinddir.c b/library/dirent_rewinddir.c index ad5d3bd..b734506 100644 --- a/library/dirent_rewinddir.c +++ b/library/dirent_rewinddir.c @@ -1,5 +1,5 @@ /* - * $Id: dirent_rewinddir.c,v 1.3 2005-01-02 09:07:07 obarthel Exp $ + * $Id: dirent_rewinddir.c,v 1.4 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -76,7 +76,7 @@ rewinddir(DIR * directory_pointer) if(CANNOT Examine(dh->dh_DirLock,&dh->dh_FileInfo)) { SHOWMSG("ouch. that didn't work"); - __translate_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_io_error_to_errno(IoErr())); } } } diff --git a/library/fcntl_close.c b/library/fcntl_close.c index 6dfeff1..255b8ba 100644 --- a/library/fcntl_close.c +++ b/library/fcntl_close.c @@ -1,5 +1,5 @@ /* - * $Id: fcntl_close.c,v 1.6 2005-01-14 08:36:54 obarthel Exp $ + * $Id: fcntl_close.c,v 1.7 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -178,10 +178,12 @@ int close(int file_descriptor) { int result; + int error; ENTER(); - result = __close(file_descriptor,&errno); + result = __close(file_descriptor,&error); + __set_errno(error); RETURN(result); return(result); diff --git a/library/fcntl_creat.c b/library/fcntl_creat.c index fa5c375..1d18713 100644 --- a/library/fcntl_creat.c +++ b/library/fcntl_creat.c @@ -1,5 +1,5 @@ /* - * $Id: fcntl_creat.c,v 1.3 2005-01-02 09:07:07 obarthel Exp $ + * $Id: fcntl_creat.c,v 1.4 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -66,7 +66,7 @@ creat(const char * path_name, mode_t mode) { if(path_name == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/fcntl_fcntl.c b/library/fcntl_fcntl.c index 4a92947..1b65261 100644 --- a/library/fcntl_fcntl.c +++ b/library/fcntl_fcntl.c @@ -1,5 +1,5 @@ /* - * $Id: fcntl_fcntl.c,v 1.5 2005-01-02 09:07:07 obarthel Exp $ + * $Id: fcntl_fcntl.c,v 1.6 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -71,7 +71,7 @@ fcntl(int file_descriptor, int cmd, ... /* int arg */ ) fd = __get_file_descriptor(file_descriptor); if(fd == NULL) { - errno = EBADF; + __set_errno(EBADF); goto out; } @@ -94,7 +94,7 @@ fcntl(int file_descriptor, int cmd, ... /* int arg */ ) SHOWMSG("invalid flock type"); va_end(arg); - errno = EINVAL; + __set_errno(EINVAL); break; } @@ -103,7 +103,7 @@ fcntl(int file_descriptor, int cmd, ... /* int arg */ ) SHOWMSG("invalid flock offset"); va_end(arg); - errno = EINVAL; + __set_errno(EINVAL); break; } @@ -116,7 +116,7 @@ fcntl(int file_descriptor, int cmd, ... /* int arg */ ) CallHookPkt(fd->fd_Hook,fd,&message); result = message.result; - errno = message.error; + __set_errno(message.error); va_end(arg); @@ -159,7 +159,7 @@ fcntl(int file_descriptor, int cmd, ... /* int arg */ ) result = message.result; if(result < 0) { - errno = message.error; + __set_errno(message.error); va_end(arg); goto out; @@ -184,7 +184,7 @@ fcntl(int file_descriptor, int cmd, ... /* int arg */ ) result = message.result; if(result < 0) { - errno = message.error; + __set_errno(message.error); va_end(arg); goto out; @@ -210,7 +210,7 @@ fcntl(int file_descriptor, int cmd, ... /* int arg */ ) if(fdbase < 0) { - errno = EINVAL; + __set_errno(EINVAL); goto out; } @@ -257,14 +257,14 @@ fcntl(int file_descriptor, int cmd, ... /* int arg */ ) goto out; } - errno = EMFILE; + __set_errno(EMFILE); break; default: SHOWMSG("something else"); - errno = ENOSYS; + __set_errno(ENOSYS); break; } diff --git a/library/fcntl_get_default_file.c b/library/fcntl_get_default_file.c index f61e85d..2dd5378 100644 --- a/library/fcntl_get_default_file.c +++ b/library/fcntl_get_default_file.c @@ -1,5 +1,5 @@ /* - * $Id: fcntl_get_default_file.c,v 1.2 2005-01-02 09:07:07 obarthel Exp $ + * $Id: fcntl_get_default_file.c,v 1.3 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -55,7 +55,7 @@ __get_default_file(int file_descriptor,long * file_ptr) fd = __get_file_descriptor(file_descriptor); if(fd == NULL) { - errno = EBADF; + __set_errno(EBADF); goto out; } diff --git a/library/fcntl_headers.h b/library/fcntl_headers.h index a50798d..de10fcd 100644 --- a/library/fcntl_headers.h +++ b/library/fcntl_headers.h @@ -1,5 +1,5 @@ /* - * $Id: fcntl_headers.h,v 1.2 2005-01-02 09:07:07 obarthel Exp $ + * $Id: fcntl_headers.h,v 1.3 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -42,4 +42,10 @@ /****************************************************************************/ +#ifndef _STDLIB_HEADERS_H +#include "stdlib_headers.h" +#endif /* _STDLIB_HEADERS_H */ + +/****************************************************************************/ + #endif /* _FCNTL_HEADERS_H */ diff --git a/library/fcntl_lseek.c b/library/fcntl_lseek.c index d0b1784..6093548 100644 --- a/library/fcntl_lseek.c +++ b/library/fcntl_lseek.c @@ -1,5 +1,5 @@ /* - * $Id: fcntl_lseek.c,v 1.3 2005-01-02 09:07:07 obarthel Exp $ + * $Id: fcntl_lseek.c,v 1.4 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -115,10 +115,12 @@ off_t lseek(int file_descriptor, off_t offset, int mode) { off_t result; + int error; ENTER(); - result = __lseek(file_descriptor,offset,mode,&errno); + result = __lseek(file_descriptor,offset,mode,&error); + __set_errno(error); RETURN(result); return(result); diff --git a/library/fcntl_open.c b/library/fcntl_open.c index 5fe950e..f5f820b 100644 --- a/library/fcntl_open.c +++ b/library/fcntl_open.c @@ -1,5 +1,5 @@ /* - * $Id: fcntl_open.c,v 1.7 2005-01-09 16:07:27 obarthel Exp $ + * $Id: fcntl_open.c,v 1.8 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -123,7 +123,7 @@ open(const char *path_name, int open_flag, ... /* mode_t mode */ ) { SHOWMSG("path name is invalid"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -134,7 +134,7 @@ open(const char *path_name, int open_flag, ... /* mode_t mode */ ) { SHOWMSG("access mode is invalid"); - errno = EINVAL; + __set_errno(EINVAL); goto out; } @@ -160,7 +160,7 @@ open(const char *path_name, int open_flag, ... /* mode_t mode */ ) if(path_name_nti.is_root) { - errno = EACCES; + __set_errno(EACCES); goto out; } } @@ -187,7 +187,7 @@ open(const char *path_name, int open_flag, ... /* mode_t mode */ ) { SHOWMSG("the file already exists"); - errno = EEXIST; + __set_errno(EEXIST); goto out; } @@ -197,14 +197,14 @@ open(const char *path_name, int open_flag, ... /* mode_t mode */ ) { SHOWMSG("there's something not a directory on the path"); - errno = ENOTDIR; + __set_errno(ENOTDIR); goto out; } else if (error != ERROR_OBJECT_NOT_FOUND && error != ERROR_ACTION_NOT_KNOWN) { SHOWMSG("error accessing the object"); - __translate_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_io_error_to_errno(IoErr())); goto out; } @@ -233,7 +233,7 @@ open(const char *path_name, int open_flag, ... /* mode_t mode */ ) { SHOWMSG("could not examine the object"); - __translate_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_io_error_to_errno(IoErr())); goto out; } @@ -242,7 +242,7 @@ open(const char *path_name, int open_flag, ... /* mode_t mode */ ) { SHOWMSG("can't open a directory"); - errno = EISDIR; + __set_errno(EISDIR); goto out; } @@ -251,7 +251,7 @@ open(const char *path_name, int open_flag, ... /* mode_t mode */ ) { SHOWMSG("this object is not write enabled"); - errno = EACCES; + __set_errno(EACCES); goto out; } @@ -274,14 +274,14 @@ open(const char *path_name, int open_flag, ... /* mode_t mode */ ) { SHOWMSG("there's something not a directory on the path"); - errno = ENOTDIR; + __set_errno(ENOTDIR); goto out; } else if (error != ERROR_OBJECT_NOT_FOUND && error != ERROR_ACTION_NOT_KNOWN) { SHOWMSG("error accessing the object"); - __translate_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_io_error_to_errno(IoErr())); goto out; } } @@ -305,7 +305,7 @@ open(const char *path_name, int open_flag, ... /* mode_t mode */ ) LONG io_err = IoErr(); D(("the file '%s' didn't open in mode %ld",path_name,open_mode)); - __translate_access_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_access_io_error_to_errno(io_err)); /* Check if ended up trying to open a directory as if it were a plain file. */ @@ -317,7 +317,7 @@ open(const char *path_name, int open_flag, ... /* mode_t mode */ ) if(lock != ZERO) { if(Examine(lock,fib) && fib->fib_DirEntryType >= 0) - errno = EISDIR; + __set_errno(EISDIR); } PROFILE_ON(); diff --git a/library/fcntl_read.c b/library/fcntl_read.c index ce99f20..4576eec 100644 --- a/library/fcntl_read.c +++ b/library/fcntl_read.c @@ -1,5 +1,5 @@ /* - * $Id: fcntl_read.c,v 1.3 2005-01-02 09:07:07 obarthel Exp $ + * $Id: fcntl_read.c,v 1.4 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -136,10 +136,12 @@ ssize_t read(int file_descriptor, void * buffer, size_t num_bytes) { ssize_t result; + int error; ENTER(); - result = __read(file_descriptor,buffer,num_bytes,&errno); + result = __read(file_descriptor,buffer,num_bytes,&error); + __set_errno(error); RETURN(result); return(result); diff --git a/library/fcntl_write.c b/library/fcntl_write.c index cb4fb80..c6d1dd6 100644 --- a/library/fcntl_write.c +++ b/library/fcntl_write.c @@ -1,5 +1,5 @@ /* - * $Id: fcntl_write.c,v 1.3 2005-01-02 09:07:07 obarthel Exp $ + * $Id: fcntl_write.c,v 1.4 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -136,10 +136,12 @@ ssize_t write(int file_descriptor, const void * buffer, size_t num_bytes) { ssize_t result; + int error; ENTER(); - result = __write(file_descriptor,buffer,num_bytes,&errno); + result = __write(file_descriptor,buffer,num_bytes,&error); + __set_errno(error); RETURN(result); return(result); diff --git a/library/include/dos.h b/library/include/dos.h index 3f41d6e..d41891a 100644 --- a/library/include/dos.h +++ b/library/include/dos.h @@ -1,5 +1,5 @@ /* - * $Id: dos.h,v 1.5 2005-01-02 09:07:21 obarthel Exp $ + * $Id: dos.h,v 1.6 2005-02-03 16:56:20 obarthel Exp $ * * :ts=4 * @@ -278,7 +278,7 @@ extern int __translate_relative_path_name(char const ** name_ptr,char *replace,s extern void __restore_path_name(char const ** name_ptr,struct name_translation_info * nti); extern int __translate_amiga_to_unix_path_name(char const ** name_ptr,struct name_translation_info * nti); extern int __translate_unix_to_amiga_path_name(char const ** name_ptr,struct name_translation_info * nti); -extern void __translate_io_error_to_errno(LONG io_error,int * errno_ptr); +extern int __translate_io_error_to_errno(LONG io_error); /****************************************************************************/ diff --git a/library/locale_headers.h b/library/locale_headers.h index 3f2db74..e82e665 100644 --- a/library/locale_headers.h +++ b/library/locale_headers.h @@ -1,5 +1,5 @@ /* - * $Id: locale_headers.h,v 1.3 2005-01-02 09:07:07 obarthel Exp $ + * $Id: locale_headers.h,v 1.4 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -53,9 +53,9 @@ /****************************************************************************/ -#ifndef _STDLIB_LOCALE_UTILITY_H -#include "stdlib_locale_utility.h" -#endif /* _STDLIB_LOCALE_UTILITY_H */ +#ifndef _STDLIB_HEADERS_H +#include "stdlib_headers.h" +#endif /* _STDLIB_HEADERS_H */ /****************************************************************************/ diff --git a/library/locale_setlocale.c b/library/locale_setlocale.c index d2c7594..755a698 100644 --- a/library/locale_setlocale.c +++ b/library/locale_setlocale.c @@ -1,5 +1,5 @@ /* - * $Id: locale_setlocale.c,v 1.2 2005-01-02 09:07:07 obarthel Exp $ + * $Id: locale_setlocale.c,v 1.3 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -56,7 +56,7 @@ setlocale(int category, const char *locale) { SHOWMSG("invalid category"); - errno = EINVAL; + __set_errno(EINVAL); goto out; } @@ -75,7 +75,7 @@ setlocale(int category, const char *locale) { SHOWMSG("locale name is too long"); - errno = ENAMETOOLONG; + __set_errno(ENAMETOOLONG); goto out; } @@ -103,7 +103,7 @@ setlocale(int category, const char *locale) { SHOWMSG("couldn't open the locale"); - errno = ENOENT; + __set_errno(ENOENT); goto out; } } diff --git a/library/math_acos.c b/library/math_acos.c index 41e7b72..3378a27 100644 --- a/library/math_acos.c +++ b/library/math_acos.c @@ -1,5 +1,5 @@ /* - * $Id: math_acos.c,v 1.3 2005-01-02 09:07:07 obarthel Exp $ + * $Id: math_acos.c,v 1.4 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -227,7 +227,7 @@ acos(double x) else { result = 0; - errno = EDOM; + __set_errno(EDOM); } return(result); diff --git a/library/math_asin.c b/library/math_asin.c index 2cb4e0a..b3b7e1f 100644 --- a/library/math_asin.c +++ b/library/math_asin.c @@ -1,5 +1,5 @@ /* - * $Id: math_asin.c,v 1.3 2005-01-02 09:07:07 obarthel Exp $ + * $Id: math_asin.c,v 1.4 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -238,7 +238,7 @@ asin(double x) else { result = 0; - errno = EDOM; + __set_errno(EDOM); } return(result); diff --git a/library/math_atan2.c b/library/math_atan2.c index 77a23d5..145aaee 100644 --- a/library/math_atan2.c +++ b/library/math_atan2.c @@ -1,5 +1,5 @@ /* - * $Id: math_atan2.c,v 1.4 2005-01-02 09:07:07 obarthel Exp $ + * $Id: math_atan2.c,v 1.5 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -108,7 +108,7 @@ __atan2(double y,double x) else { result = 0; - errno = EDOM; + __set_errno(EDOM); } } } @@ -187,7 +187,7 @@ __atan2(double y,double x) else { result = 0; - errno = EDOM; + __set_errno(EDOM); } } } diff --git a/library/math_data.c b/library/math_data.c index b47abf6..d11c79d 100644 --- a/library/math_data.c +++ b/library/math_data.c @@ -1,5 +1,5 @@ /* - * $Id: math_data.c,v 1.3 2005-01-02 09:07:07 obarthel Exp $ + * $Id: math_data.c,v 1.4 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -48,5 +48,3 @@ struct Library * MathIeeeDoubTransBase; /****************************************************************************/ double __huge_val; -double __not_a_number; -double __infinity; diff --git a/library/math_fmod.c b/library/math_fmod.c index dcdd062..a310cd0 100644 --- a/library/math_fmod.c +++ b/library/math_fmod.c @@ -1,5 +1,5 @@ /* - * $Id: math_fmod.c,v 1.3 2005-01-02 09:07:07 obarthel Exp $ + * $Id: math_fmod.c,v 1.4 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -285,7 +285,7 @@ fmod(double x,double y) else { result = x; - errno = EDOM; + __set_errno(EDOM); } return(result); diff --git a/library/math_frexp.c b/library/math_frexp.c index 5983d1d..8f3e2a9 100644 --- a/library/math_frexp.c +++ b/library/math_frexp.c @@ -1,5 +1,5 @@ /* - * $Id: math_frexp.c,v 1.2 2005-01-02 09:07:07 obarthel Exp $ + * $Id: math_frexp.c,v 1.3 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -189,8 +189,9 @@ frexp(double x,int *nptr) { if(nptr == NULL) { - result = HUGE_VAL; - errno = EFAULT; + __set_errno(EFAULT); + + result = __get_huge_val(); goto out; } } diff --git a/library/math_headers.h b/library/math_headers.h index 6e34ec4..2f016bc 100644 --- a/library/math_headers.h +++ b/library/math_headers.h @@ -1,5 +1,5 @@ /* - * $Id: math_headers.h,v 1.5 2005-01-02 09:07:07 obarthel Exp $ + * $Id: math_headers.h,v 1.6 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -192,8 +192,14 @@ extern double __scalbn(double x, int n); /****************************************************************************/ -extern double __not_a_number; -extern double __infinity; +#ifndef _STDLIB_HEADERS_H +#include "stdlib_headers.h" +#endif /* _STDLIB_HEADERS_H */ + +/****************************************************************************/ + +/* math_huge_val.c */ +double __get_huge_val(void); /****************************************************************************/ diff --git a/library/math_huge_val.c b/library/math_huge_val.c new file mode 100644 index 0000000..a1dde11 --- /dev/null +++ b/library/math_huge_val.c @@ -0,0 +1,44 @@ +/* + * $Id: math_huge_val.c,v 1.1 2005-02-03 16:56:15 obarthel Exp $ + * + * :ts=4 + * + * Portable ISO 'C' (1994) runtime library for the Amiga computer + * Copyright (c) 2002-2005 by Olaf Barthel + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Neither the name of Olaf Barthel nor the names of contributors + * may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _MATH_HEADERS_H +#include "math_headers.h" +#endif /* _MATH_HEADERS_H */ + +/****************************************************************************/ + +double +__get_huge_val(void) +{ + return(__huge_val); +} diff --git a/library/math_init_exit.c b/library/math_init_exit.c index 5f37091..2df3397 100644 --- a/library/math_init_exit.c +++ b/library/math_init_exit.c @@ -1,5 +1,5 @@ /* - * $Id: math_init_exit.c,v 1.6 2005-01-02 09:07:07 obarthel Exp $ + * $Id: math_init_exit.c,v 1.7 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -127,82 +127,28 @@ __math_init(void) the largest representable floating point value. */ if(sizeof(__huge_val) == 4) /* single precision */ { - static const unsigned long largest_fp_value[1] = - { - /* Exponent = +126, Mantissa = 8,388,607 */ - 0x7f7fffff - }; + union ieee_single * x = (union ieee_single *)&__huge_val; - static const unsigned long not_a_number[1] = - { - /* Exponent = 255 and fraction != 0.0 */ - 0x7fffffff - }; - - static const unsigned long infinity[1] = - { - /* Exponent = 255 and fraction = 0.0 */ - 0x7f800000 - }; - - assert( sizeof(largest_fp_value) == sizeof(__huge_val) ); - - memmove((void *)&__huge_val,largest_fp_value,sizeof(largest_fp_value)); - memmove((void *)&__not_a_number,not_a_number,sizeof(not_a_number)); - memmove((void *)&__infinity,infinity,sizeof(infinity)); + /* Exponent = +126, Mantissa = 8,388,607 */ + x->raw[0] = 0x7f7fffff; } else if (sizeof(__huge_val) == 8) /* double precision */ { - static const unsigned long largest_fp_value[2] = - { - /* Exponent = +1022, Mantissa = 4,503,599,627,370,495 */ - 0x7fefffff,0xffffffff - }; + union ieee_double * x = (union ieee_double *)&__huge_val; - static const unsigned long not_a_number[2] = - { - /* Exponent = 2047 and fraction != 0.0 */ - 0x7fffffff,0xffffffff - }; - - static const unsigned long infinity[2] = - { - /* Exponent = 2047 and fraction = 0.0 */ - 0x7ff00000,0x00000000 - }; - - assert( sizeof(largest_fp_value) == sizeof(__huge_val) ); - - memmove((void *)&__huge_val,largest_fp_value,sizeof(largest_fp_value)); - memmove((void *)&__not_a_number,not_a_number,sizeof(not_a_number)); - memmove((void *)&__infinity,infinity,sizeof(infinity)); + /* Exponent = +1022, Mantissa = 4,503,599,627,370,495 */ + x->raw[0] = 0x7fefffff; + x->raw[1] = 0xffffffff; } #if defined(USE_LONG_DOUBLE) else if (sizeof(__huge_val) == 12) /* extended precision */ { - static const unsigned long largest_fp_value[3] = - { - /* Exponent = +32766, Mantissa = 18,446,744,073,709,551,615 */ - 0x7ffe0000,0xffffffff,0xffffffff - }; + union ieee_long_double * x = (union ieee_long_double *)&__huge_val; - static const unsigned long not_a_number[3] = - { - /* Exponent = 32767 and fraction != 0.0 */ - 0x7fff0000,0xffffffff,0xffffffff - }; - - static const unsigned long infinity[3] = - { - /* Exponent = 32767 and fraction = 0.0 */ - 0x7fff0000,0x00000000,0x00000000 - }; - - assert( sizeof(largest_fp_value) == sizeof(__huge_val) ); - - memmove((void *)&__huge_val,largest_fp_value,sizeof(largest_fp_value)); - memmove((void *)&__not_a_number,not_a_number,sizeof(not_a_number)); - memmove((void *)&__infinity,infinity,sizeof(infinity)); + /* Exponent = +32766, Mantissa = 18,446,744,073,709,551,615 */ + x->raw[0] = 0x7ffe0000; + x->raw[1] = 0xffffffff; + x->raw[2] = 0xffffffff; } #endif /* USE_LONG_DOUBLE */ diff --git a/library/math_log.c b/library/math_log.c index 98d633c..91680d4 100644 --- a/library/math_log.c +++ b/library/math_log.c @@ -1,5 +1,5 @@ /* - * $Id: math_log.c,v 1.4 2005-01-18 20:00:08 obarthel Exp $ + * $Id: math_log.c,v 1.5 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -244,18 +244,16 @@ log(double x) { double result; - /* When do we consider 'x' to be invalid? If it's close - * enough to zero or negative. - */ if(x > DBL_EPSILON) { result = __log(x); } else { - /* ZZZ this should be minus infinity */ - result = -HUGE_VAL; - errno = ERANGE; + __set_errno(ERANGE); + + /* This should really be minus infinity. */ + result = (-__get_huge_val()); } return(result); diff --git a/library/math_log10.c b/library/math_log10.c index 532db47..c8073bc 100644 --- a/library/math_log10.c +++ b/library/math_log10.c @@ -1,5 +1,5 @@ /* - * $Id: math_log10.c,v 1.3 2005-01-18 20:00:08 obarthel Exp $ + * $Id: math_log10.c,v 1.4 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -186,18 +186,16 @@ log10(double x) { double result; - /* When do we consider 'x' to be invalid? If it's close - * enough to zero or negative. - */ if(x > DBL_EPSILON) { result = __log10(x); } else { - /* ZZZ this should be minus infinity */ - result = -HUGE_VAL; - errno = ERANGE; + __set_errno(ERANGE); + + /* This should really be minus infinity. */ + result = (-__get_huge_val()); } return(result); diff --git a/library/math_logb.c b/library/math_logb.c index 4cb55ef..dfce008 100644 --- a/library/math_logb.c +++ b/library/math_logb.c @@ -1,5 +1,5 @@ /* - * $Id: math_logb.c,v 1.3 2005-01-02 09:07:07 obarthel Exp $ + * $Id: math_logb.c,v 1.4 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -103,7 +103,7 @@ logb(double x) if(x == 0.0) { - result = -HUGE_VAL; + result = -__get_huge_val(); goto out; } diff --git a/library/math_modf.c b/library/math_modf.c index 4ee7432..f3ab21c 100644 --- a/library/math_modf.c +++ b/library/math_modf.c @@ -1,5 +1,5 @@ /* - * $Id: math_modf.c,v 1.3 2005-01-02 09:07:07 obarthel Exp $ + * $Id: math_modf.c,v 1.4 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -150,8 +150,9 @@ modf(double x,double *nptr) { if(nptr == NULL) { - errno = EFAULT; - result = HUGE_VAL; + __set_errno(EFAULT); + + result = __get_huge_val(); goto out; } } diff --git a/library/math_pow.c b/library/math_pow.c index 360e655..57f08c8 100644 --- a/library/math_pow.c +++ b/library/math_pow.c @@ -1,5 +1,5 @@ /* - * $Id: math_pow.c,v 1.4 2005-01-02 09:07:07 obarthel Exp $ + * $Id: math_pow.c,v 1.5 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -424,8 +424,9 @@ pow(double x,double y) if(x == 0.0 && y < 0.0) { - result = HUGE_VAL; - errno = EDOM; + __set_errno(EDOM); + + result = __get_huge_val(); goto out; } @@ -436,8 +437,9 @@ pow(double x,double y) abs_y = fabs(y); if(floor(abs_y) != abs_y) { - result = HUGE_VAL; - errno = EDOM; + __set_errno(EDOM); + + result = __get_huge_val(); goto out; } } diff --git a/library/math_sqrt.c b/library/math_sqrt.c index ff7d8e9..f1edd14 100644 --- a/library/math_sqrt.c +++ b/library/math_sqrt.c @@ -1,5 +1,5 @@ /* - * $Id: math_sqrt.c,v 1.4 2005-01-02 09:07:07 obarthel Exp $ + * $Id: math_sqrt.c,v 1.5 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -252,7 +252,7 @@ sqrt(double x) else { result = 0; - errno = EDOM; + __set_errno(EDOM); } return(result); diff --git a/library/mount_fstatfs.c b/library/mount_fstatfs.c index a5311d9..12cf9f1 100644 --- a/library/mount_fstatfs.c +++ b/library/mount_fstatfs.c @@ -1,5 +1,5 @@ /* - * $Id: mount_fstatfs.c,v 1.3 2005-01-02 09:07:07 obarthel Exp $ + * $Id: mount_fstatfs.c,v 1.4 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -70,7 +70,7 @@ fstatfs(int file_descriptor, struct statfs *buf) { SHOWMSG("invalid buffer parameter"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -86,7 +86,7 @@ fstatfs(int file_descriptor, struct statfs *buf) fd = __get_file_descriptor(file_descriptor); if(fd == NULL) { - errno = EBADF; + __set_errno(EBADF); goto out; } @@ -102,7 +102,7 @@ fstatfs(int file_descriptor, struct statfs *buf) result = message.result; if(result != 0) { - errno = message.error; + __set_errno(message.error); goto out; } diff --git a/library/mount_headers.h b/library/mount_headers.h index ee176b7..007a6b0 100644 --- a/library/mount_headers.h +++ b/library/mount_headers.h @@ -1,5 +1,5 @@ /* - * $Id: mount_headers.h,v 1.2 2005-01-02 09:07:07 obarthel Exp $ + * $Id: mount_headers.h,v 1.3 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -42,6 +42,12 @@ /****************************************************************************/ +#ifndef _STDLIB_HEADERS_H +#include "stdlib_headers.h" +#endif /* _STDLIB_HEADERS_H */ + +/****************************************************************************/ + #include /****************************************************************************/ diff --git a/library/mount_statfs.c b/library/mount_statfs.c index c7266c4..dde138c 100644 --- a/library/mount_statfs.c +++ b/library/mount_statfs.c @@ -1,5 +1,5 @@ /* - * $Id: mount_statfs.c,v 1.3 2005-01-02 09:07:07 obarthel Exp $ + * $Id: mount_statfs.c,v 1.4 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -74,7 +74,7 @@ statfs(const char *path, struct statfs *buf) { SHOWMSG("invalid parameters"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -123,7 +123,7 @@ statfs(const char *path, struct statfs *buf) { SHOWMSG("that didn't work"); - __translate_access_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_access_io_error_to_errno(IoErr())); goto out; } @@ -135,7 +135,7 @@ statfs(const char *path, struct statfs *buf) { SHOWMSG("didn't get the info"); - __translate_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_io_error_to_errno(IoErr())); goto out; } diff --git a/library/signal_kill.c b/library/signal_kill.c index 6c17fab..2e62e2a 100644 --- a/library/signal_kill.c +++ b/library/signal_kill.c @@ -1,5 +1,5 @@ /* - * $Id: signal_kill.c,v 1.3 2005-01-02 09:07:07 obarthel Exp $ + * $Id: signal_kill.c,v 1.4 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -64,7 +64,7 @@ kill(pid_t pid, int signal_number) { SHOWMSG("didn't find the process"); - errno = ESRCH; + __set_errno(ESRCH); goto out; } @@ -95,7 +95,7 @@ kill(pid_t pid, int signal_number) { SHOWMSG("didn't find the process"); - errno = ESRCH; + __set_errno(ESRCH); goto out; } diff --git a/library/signal_raise.c b/library/signal_raise.c index 58b14b6..79ac9b8 100644 --- a/library/signal_raise.c +++ b/library/signal_raise.c @@ -1,5 +1,5 @@ /* - * $Id: signal_raise.c,v 1.3 2005-01-02 09:07:07 obarthel Exp $ + * $Id: signal_raise.c,v 1.4 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -52,7 +52,7 @@ raise(int sig) { SHOWMSG("unknown signal number"); - errno = EINVAL; + __set_errno(EINVAL); goto out; } diff --git a/library/signal_sigaddset.c b/library/signal_sigaddset.c index c5f8cf6..33c2955 100644 --- a/library/signal_sigaddset.c +++ b/library/signal_sigaddset.c @@ -1,5 +1,5 @@ /* - * $Id: signal_sigaddset.c,v 1.3 2005-01-02 09:07:07 obarthel Exp $ + * $Id: signal_sigaddset.c,v 1.4 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -60,7 +60,7 @@ sigaddset(sigset_t * set,int sig) { if(set == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/signal_sigemptyset.c b/library/signal_sigemptyset.c index 4fbb629..94b5ffb 100644 --- a/library/signal_sigemptyset.c +++ b/library/signal_sigemptyset.c @@ -1,5 +1,5 @@ /* - * $Id: signal_sigemptyset.c,v 1.3 2005-01-02 09:07:07 obarthel Exp $ + * $Id: signal_sigemptyset.c,v 1.4 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -60,7 +60,7 @@ sigemptyset(sigset_t * set) { if(set == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/signal_signal.c b/library/signal_signal.c index 6352e17..c1d9649 100644 --- a/library/signal_signal.c +++ b/library/signal_signal.c @@ -1,5 +1,5 @@ /* - * $Id: signal_signal.c,v 1.2 2005-01-02 09:07:07 obarthel Exp $ + * $Id: signal_signal.c,v 1.3 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -51,7 +51,7 @@ void (*signal(int sig, void (* handler)(int)))(int) { SHOWMSG("unsupported signal"); - errno = EINVAL; + __set_errno(EINVAL); goto out; } diff --git a/library/signal_sigprocmask.c b/library/signal_sigprocmask.c index 4de8418..7258593 100644 --- a/library/signal_sigprocmask.c +++ b/library/signal_sigprocmask.c @@ -1,5 +1,5 @@ /* - * $Id: signal_sigprocmask.c,v 1.3 2005-01-02 09:07:07 obarthel Exp $ + * $Id: signal_sigprocmask.c,v 1.4 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -56,7 +56,7 @@ sigprocmask(int how, const sigset_t *set, sigset_t *oset) { SHOWMSG("invalid operating mode"); - errno = EINVAL; + __set_errno(EINVAL); goto out; } diff --git a/library/smakefile b/library/smakefile index 7f81881..21d248a 100644 --- a/library/smakefile +++ b/library/smakefile @@ -1,5 +1,5 @@ # -# $Id: smakefile,v 1.18 2005-01-29 18:05:14 obarthel Exp $ +# $Id: smakefile,v 1.19 2005-02-03 16:56:15 obarthel Exp $ # # :ts=8 # @@ -190,6 +190,7 @@ MATH_OBJ = \ math_floor.o \ math_fmod.o \ math_frexp.o \ + math_huge_val.o \ math_hypot.o \ math_init_exit.o \ math_isinf.o \ @@ -375,6 +376,8 @@ STDLIB_OBJ = \ stdlib_destructor.o \ stdlib_detach.o \ stdlib_dosbase.o \ + stdlib_get_errno.o \ + stdlib_set_errno.o \ stdlib_sysbase.o \ stdlib_termination_message.o \ stdlib_threshold.o \ diff --git a/library/socket_accept.c b/library/socket_accept.c index ff773e7..f4ad1b7 100644 --- a/library/socket_accept.c +++ b/library/socket_accept.c @@ -1,5 +1,5 @@ /* - * $Id: socket_accept.c,v 1.2 2005-01-02 09:07:07 obarthel Exp $ + * $Id: socket_accept.c,v 1.3 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -71,7 +71,7 @@ accept(int sockfd,struct sockaddr *cliaddr,int *addrlen) { SHOWMSG("invalid parameters"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/socket_bind.c b/library/socket_bind.c index 06ea588..e6e1225 100644 --- a/library/socket_bind.c +++ b/library/socket_bind.c @@ -1,5 +1,5 @@ /* - * $Id: socket_bind.c,v 1.2 2005-01-02 09:07:07 obarthel Exp $ + * $Id: socket_bind.c,v 1.3 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -68,7 +68,7 @@ bind(int sockfd,struct sockaddr *name,int namelen) { SHOWMSG("invalid name parameter"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/socket_connect.c b/library/socket_connect.c index 85b7290..a98e267 100644 --- a/library/socket_connect.c +++ b/library/socket_connect.c @@ -1,5 +1,5 @@ /* - * $Id: socket_connect.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: socket_connect.c,v 1.3 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -68,7 +68,7 @@ connect(int sockfd,struct sockaddr *name,int namelen) { SHOWMSG("invalid name parameter"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/socket_get_descriptor.c b/library/socket_get_descriptor.c index 1706aeb..54a7913 100644 --- a/library/socket_get_descriptor.c +++ b/library/socket_get_descriptor.c @@ -1,5 +1,5 @@ /* - * $Id: socket_get_descriptor.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: socket_get_descriptor.c,v 1.3 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -50,13 +50,13 @@ __get_socket_descriptor(int socket_descriptor) fd = __get_file_descriptor(socket_descriptor); if(fd == NULL) { - errno = EBADF; + __set_errno(EBADF); goto out; } if(FLAG_IS_CLEAR(fd->fd_Flags,FDF_IS_SOCKET)) { - errno = ENOTSOCK; + __set_errno(ENOTSOCK); goto out; } diff --git a/library/socket_gethostbyaddr.c b/library/socket_gethostbyaddr.c index 2963344..e20c4b7 100644 --- a/library/socket_gethostbyaddr.c +++ b/library/socket_gethostbyaddr.c @@ -1,5 +1,5 @@ /* - * $Id: socket_gethostbyaddr.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: socket_gethostbyaddr.c,v 1.3 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -67,7 +67,7 @@ gethostbyaddr(const char *addr, int len, int type) { SHOWMSG("invalid addr parameter"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/socket_gethostbyname.c b/library/socket_gethostbyname.c index f88a088..bfda3d5 100644 --- a/library/socket_gethostbyname.c +++ b/library/socket_gethostbyname.c @@ -1,5 +1,5 @@ /* - * $Id: socket_gethostbyname.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: socket_gethostbyname.c,v 1.3 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -65,7 +65,7 @@ gethostbyname(const char *name) { SHOWMSG("invalid name parameter"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/socket_gethostname.c b/library/socket_gethostname.c index a8fde3c..434538c 100644 --- a/library/socket_gethostname.c +++ b/library/socket_gethostname.c @@ -1,5 +1,5 @@ /* - * $Id: socket_gethostname.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: socket_gethostname.c,v 1.3 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -66,7 +66,7 @@ gethostname(const char *hostname,int size) { SHOWMSG("invalid host name parameter"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/socket_getnetbyname.c b/library/socket_getnetbyname.c index b351133..9a90e89 100644 --- a/library/socket_getnetbyname.c +++ b/library/socket_getnetbyname.c @@ -1,5 +1,5 @@ /* - * $Id: socket_getnetbyname.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: socket_getnetbyname.c,v 1.3 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -65,7 +65,7 @@ getnetbyname(const char *name) { SHOWMSG("invalid name parameter"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/socket_getpeername.c b/library/socket_getpeername.c index f8456e5..6249471 100644 --- a/library/socket_getpeername.c +++ b/library/socket_getpeername.c @@ -1,5 +1,5 @@ /* - * $Id: socket_getpeername.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: socket_getpeername.c,v 1.3 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -68,7 +68,7 @@ getpeername(int sockfd,struct sockaddr *name,int *namelen) { SHOWMSG("invalid parameters"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/socket_getprotobyname.c b/library/socket_getprotobyname.c index 2ae5286..2452ad8 100644 --- a/library/socket_getprotobyname.c +++ b/library/socket_getprotobyname.c @@ -1,5 +1,5 @@ /* - * $Id: socket_getprotobyname.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: socket_getprotobyname.c,v 1.3 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -63,7 +63,7 @@ getprotobyname(const char *name) { SHOWMSG("invalid parameters"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/socket_getservbyname.c b/library/socket_getservbyname.c index fc660b3..5710d24 100644 --- a/library/socket_getservbyname.c +++ b/library/socket_getservbyname.c @@ -1,5 +1,5 @@ /* - * $Id: socket_getservbyname.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: socket_getservbyname.c,v 1.3 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -63,7 +63,7 @@ getservbyname(const char *name, const char *proto) { SHOWMSG("invalid parameters"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/socket_getservbyport.c b/library/socket_getservbyport.c index 56d4283..1dc9966 100644 --- a/library/socket_getservbyport.c +++ b/library/socket_getservbyport.c @@ -1,5 +1,5 @@ /* - * $Id: socket_getservbyport.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: socket_getservbyport.c,v 1.3 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -63,7 +63,7 @@ getservbyport(int port, const char *proto) { SHOWMSG("invalid parameters"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/socket_getsockname.c b/library/socket_getsockname.c index 5ec35f1..659235d 100644 --- a/library/socket_getsockname.c +++ b/library/socket_getsockname.c @@ -1,5 +1,5 @@ /* - * $Id: socket_getsockname.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: socket_getsockname.c,v 1.3 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -68,7 +68,7 @@ getsockname(int sockfd,struct sockaddr *name,int *namelen) { SHOWMSG("invalid parameters"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/socket_getsockopt.c b/library/socket_getsockopt.c index e4af34a..27ac3a5 100644 --- a/library/socket_getsockopt.c +++ b/library/socket_getsockopt.c @@ -1,5 +1,5 @@ /* - * $Id: socket_getsockopt.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: socket_getsockopt.c,v 1.3 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -70,7 +70,7 @@ getsockopt(int sockfd,int level,int optname,void *optval,int *optlen) { SHOWMSG("invalid parameters"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/socket_headers.h b/library/socket_headers.h index 77c9f5a..0132aec 100644 --- a/library/socket_headers.h +++ b/library/socket_headers.h @@ -1,5 +1,5 @@ /* - * $Id: socket_headers.h,v 1.4 2005-01-02 09:07:08 obarthel Exp $ + * $Id: socket_headers.h,v 1.5 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -48,6 +48,12 @@ /****************************************************************************/ +#ifndef _STDLIB_HEADERS_H +#include "stdlib_headers.h" +#endif /* _STDLIB_HEADERS_H */ + +/****************************************************************************/ + extern struct Library * NOCOMMON __SocketBase; /****************************************************************************/ diff --git a/library/socket_hook_entry.c b/library/socket_hook_entry.c index 9504b78..d1588f4 100644 --- a/library/socket_hook_entry.c +++ b/library/socket_hook_entry.c @@ -1,5 +1,5 @@ /* - * $Id: socket_hook_entry.c,v 1.4 2005-01-02 09:07:08 obarthel Exp $ + * $Id: socket_hook_entry.c,v 1.5 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -73,7 +73,7 @@ __socket_hook_entry( PROFILE_OFF(); result = __recv((LONG)fd->fd_DefaultFile,message->data,message->size,0); - error = errno; + error = __get_errno(); PROFILE_ON(); @@ -92,7 +92,7 @@ __socket_hook_entry( PROFILE_OFF(); result = __send((LONG)fd->fd_DefaultFile,message->data,message->size,0); - error = errno; + error = __get_errno(); PROFILE_ON(); @@ -141,7 +141,7 @@ __socket_hook_entry( param = (int)(message->arg == 0); result = __IoctlSocket(fd->fd_DefaultFile,FIONBIO,¶m); - error = errno; + error = __get_errno(); break; @@ -152,7 +152,7 @@ __socket_hook_entry( param = (int)(message->arg != 0); result = __IoctlSocket(fd->fd_DefaultFile,FIOASYNC,¶m); - error = errno; + error = __get_errno(); break; diff --git a/library/socket_inet_addr.c b/library/socket_inet_addr.c index bbb341b..a5f6640 100644 --- a/library/socket_inet_addr.c +++ b/library/socket_inet_addr.c @@ -1,5 +1,5 @@ /* - * $Id: socket_inet_addr.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: socket_inet_addr.c,v 1.3 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -65,7 +65,7 @@ inet_addr(const char *addr) { SHOWMSG("invalid parameter"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/socket_inet_aton.c b/library/socket_inet_aton.c index 6f7ff6b..6d7b8db 100644 --- a/library/socket_inet_aton.c +++ b/library/socket_inet_aton.c @@ -1,5 +1,5 @@ /* - * $Id: socket_inet_aton.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: socket_inet_aton.c,v 1.3 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -108,7 +108,7 @@ inet_aton(const char *cp, struct in_addr *addr) { SHOWMSG("invalid parameters"); - errno = EFAULT; + __set_errno(EFAULT); return(0); } } diff --git a/library/socket_inet_network.c b/library/socket_inet_network.c index 1536297..4991bf0 100644 --- a/library/socket_inet_network.c +++ b/library/socket_inet_network.c @@ -1,5 +1,5 @@ /* - * $Id: socket_inet_network.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: socket_inet_network.c,v 1.3 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -63,7 +63,7 @@ inet_network(const char *cp) { SHOWMSG("invalid cp parameter"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/socket_recv.c b/library/socket_recv.c index b6119a7..e4a483e 100644 --- a/library/socket_recv.c +++ b/library/socket_recv.c @@ -1,5 +1,5 @@ /* - * $Id: socket_recv.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: socket_recv.c,v 1.3 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -70,7 +70,7 @@ recv(int sockfd,void *buff,size_t nbytes,int flags) { SHOWMSG("invalid buffer parameter"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/socket_recvfrom.c b/library/socket_recvfrom.c index 536c6c9..3950ea7 100644 --- a/library/socket_recvfrom.c +++ b/library/socket_recvfrom.c @@ -1,5 +1,5 @@ /* - * $Id: socket_recvfrom.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: socket_recvfrom.c,v 1.3 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -71,7 +71,7 @@ recvfrom(int sockfd,void *buff,int len,int flags,struct sockaddr *from,int *from { SHOWMSG("invalid parameters"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/socket_recvmsg.c b/library/socket_recvmsg.c index d611aac..3c7c6c1 100644 --- a/library/socket_recvmsg.c +++ b/library/socket_recvmsg.c @@ -1,5 +1,5 @@ /* - * $Id: socket_recvmsg.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: socket_recvmsg.c,v 1.3 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -68,7 +68,7 @@ recvmsg(int sockfd,struct msghdr *msg,int flags) { SHOWMSG("invalid msg parameter"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/socket_select.c b/library/socket_select.c index 43e2c93..9cc89e3 100644 --- a/library/socket_select.c +++ b/library/socket_select.c @@ -1,5 +1,5 @@ /* - * $Id: socket_select.c,v 1.3 2005-01-02 09:07:08 obarthel Exp $ + * $Id: socket_select.c,v 1.4 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -726,7 +726,7 @@ select(int num_fds,fd_set *read_fds,fd_set *write_fds,fd_set *except_fds,struct PROFILE_ON(); /* Stop if a break signal arrives. */ - if((result < 0 && errno == EINTR) || FLAG_IS_SET(break_mask,SIGBREAKF_CTRL_C)) + if((result < 0 && __get_errno() == EINTR) || FLAG_IS_SET(break_mask,SIGBREAKF_CTRL_C)) { SetSignal(SIGBREAKF_CTRL_C,SIGBREAKF_CTRL_C); __check_abort(); @@ -837,7 +837,7 @@ select(int num_fds,fd_set *read_fds,fd_set *write_fds,fd_set *except_fds,struct result = __WaitSelect(total_socket_fd,socket_read_fds,socket_write_fds,socket_except_fds,timeout,&break_mask); PROFILE_ON(); - if((result < 0 && errno == EINTR) || FLAG_IS_SET(break_mask,SIGBREAKF_CTRL_C)) + if((result < 0 && __get_errno() == EINTR) || FLAG_IS_SET(break_mask,SIGBREAKF_CTRL_C)) { SetSignal(SIGBREAKF_CTRL_C,SIGBREAKF_CTRL_C); __check_abort(); diff --git a/library/socket_send.c b/library/socket_send.c index 80d2a61..8dcb0dc 100644 --- a/library/socket_send.c +++ b/library/socket_send.c @@ -1,5 +1,5 @@ /* - * $Id: socket_send.c,v 1.3 2005-01-02 09:07:08 obarthel Exp $ + * $Id: socket_send.c,v 1.4 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -70,7 +70,7 @@ send(int sockfd,const void *buff,size_t nbytes,int flags) { SHOWMSG("invalid buffer parameter"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/socket_sendmsg.c b/library/socket_sendmsg.c index 1a024cf..1f378cc 100644 --- a/library/socket_sendmsg.c +++ b/library/socket_sendmsg.c @@ -1,5 +1,5 @@ /* - * $Id: socket_sendmsg.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: socket_sendmsg.c,v 1.3 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -68,7 +68,7 @@ sendmsg(int sockfd,struct msghdr *msg,int flags) { SHOWMSG("invalid msg parameter"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/socket_sendto.c b/library/socket_sendto.c index 20e37f5..98b983e 100644 --- a/library/socket_sendto.c +++ b/library/socket_sendto.c @@ -1,5 +1,5 @@ /* - * $Id: socket_sendto.c,v 1.3 2005-01-02 09:07:08 obarthel Exp $ + * $Id: socket_sendto.c,v 1.4 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -71,7 +71,7 @@ sendto(int sockfd,const void *buff,int len,int flags,struct sockaddr *to,int tol { SHOWMSG("invalid parameters"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/socket_setsockopt.c b/library/socket_setsockopt.c index eeaf444..66a5afe 100644 --- a/library/socket_setsockopt.c +++ b/library/socket_setsockopt.c @@ -1,5 +1,5 @@ /* - * $Id: socket_setsockopt.c,v 1.3 2005-01-02 09:07:08 obarthel Exp $ + * $Id: socket_setsockopt.c,v 1.4 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -70,7 +70,7 @@ setsockopt(int sockfd,int level,int optname,const void *optval,int optlen) { SHOWMSG("invalid optval parameter"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/stat_chmod.c b/library/stat_chmod.c index 49552a5..a124a03 100644 --- a/library/stat_chmod.c +++ b/library/stat_chmod.c @@ -1,5 +1,5 @@ /* - * $Id: stat_chmod.c,v 1.3 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stat_chmod.c,v 1.4 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -70,7 +70,7 @@ chmod(const char * path_name, mode_t mode) { SHOWMSG("invalid path parameter"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -88,7 +88,7 @@ chmod(const char * path_name, mode_t mode) if(path_name_nti.is_root) { - errno = EACCES; + __set_errno(EACCES); goto out; } } @@ -142,7 +142,7 @@ chmod(const char * path_name, mode_t mode) if(status == DOSFALSE) { - __translate_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_io_error_to_errno(IoErr())); goto out; } diff --git a/library/stat_fchmod.c b/library/stat_fchmod.c index 369bae6..ff86e6a 100644 --- a/library/stat_fchmod.c +++ b/library/stat_fchmod.c @@ -1,5 +1,5 @@ /* - * $Id: stat_fchmod.c,v 1.3 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stat_fchmod.c,v 1.4 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -67,7 +67,7 @@ fchmod(int file_descriptor, mode_t mode) fd = __get_file_descriptor(file_descriptor); if(fd == NULL) { - errno = EBADF; + __set_errno(EBADF); goto out; } @@ -118,8 +118,9 @@ fchmod(int file_descriptor, mode_t mode) CallHookPkt(fd->fd_Hook,fd,&message); - result = message.result; - errno = message.error; + result = message.result; + + __set_errno(message.error); out: diff --git a/library/stat_fstat.c b/library/stat_fstat.c index 15ab585..0639f88 100644 --- a/library/stat_fstat.c +++ b/library/stat_fstat.c @@ -1,5 +1,5 @@ /* - * $Id: stat_fstat.c,v 1.3 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stat_fstat.c,v 1.4 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -70,7 +70,7 @@ fstat(int file_descriptor, struct stat * buffer) { SHOWMSG("invalid buffer parameter"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -86,7 +86,7 @@ fstat(int file_descriptor, struct stat * buffer) fd = __get_file_descriptor(file_descriptor); if(fd == NULL) { - errno = EBADF; + __set_errno(EBADF); goto out; } @@ -103,7 +103,7 @@ fstat(int file_descriptor, struct stat * buffer) result = message.result; if(result != 0) { - errno = message.error; + __set_errno(message.error); goto out; } diff --git a/library/stat_headers.h b/library/stat_headers.h index 1929291..657c105 100644 --- a/library/stat_headers.h +++ b/library/stat_headers.h @@ -1,5 +1,5 @@ /* - * $Id: stat_headers.h,v 1.3 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stat_headers.h,v 1.4 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -42,6 +42,12 @@ /****************************************************************************/ +#ifndef _STDLIB_HEADERS_H +#include "stdlib_headers.h" +#endif /* _STDLIB_HEADERS_H */ + +/****************************************************************************/ + extern mode_t NOCOMMON __current_umask; /****************************************************************************/ diff --git a/library/stat_lstat.c b/library/stat_lstat.c index 54a1357..d6f4de9 100644 --- a/library/stat_lstat.c +++ b/library/stat_lstat.c @@ -1,5 +1,5 @@ /* - * $Id: stat_lstat.c,v 1.3 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stat_lstat.c,v 1.4 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -65,7 +65,7 @@ lstat(const char * path_name, struct stat * buffer) { SHOWMSG("invalid parameters"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/stat_mkdir.c b/library/stat_mkdir.c index bb9e5f5..98ec8c5 100644 --- a/library/stat_mkdir.c +++ b/library/stat_mkdir.c @@ -1,5 +1,5 @@ /* - * $Id: stat_mkdir.c,v 1.3 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stat_mkdir.c,v 1.4 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -70,7 +70,7 @@ mkdir(const char * path_name, mode_t mode) { SHOWMSG("invalid path name parameter"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -88,7 +88,7 @@ mkdir(const char * path_name, mode_t mode) if(path_name_nti.is_root) { - errno = EACCES; + __set_errno(EACCES); goto out; } } @@ -105,7 +105,7 @@ mkdir(const char * path_name, mode_t mode) { SHOWMSG("that didn't work"); - __translate_access_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_access_io_error_to_errno(IoErr())); goto out; } diff --git a/library/stat_rmdir.c b/library/stat_rmdir.c index 10390d1..676b17e 100644 --- a/library/stat_rmdir.c +++ b/library/stat_rmdir.c @@ -1,5 +1,5 @@ /* - * $Id: stat_rmdir.c,v 1.3 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stat_rmdir.c,v 1.4 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -70,7 +70,7 @@ rmdir(const char * path_name) { SHOWMSG("invalid path name parameter"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -88,7 +88,7 @@ rmdir(const char * path_name) if(path_name_nti.is_root) { - errno = EACCES; + __set_errno(EACCES); goto out; } } @@ -105,7 +105,7 @@ rmdir(const char * path_name) { SHOWMSG("that didn't work"); - __translate_access_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_access_io_error_to_errno(IoErr())); goto out; } @@ -117,7 +117,7 @@ rmdir(const char * path_name) { SHOWMSG("couldn't examine it"); - __translate_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_io_error_to_errno(IoErr())); goto out; } @@ -125,7 +125,7 @@ rmdir(const char * path_name) { SHOWMSG("this is not a directory"); - errno = ENOTDIR; + __set_errno(ENOTDIR); goto out; } @@ -145,7 +145,7 @@ rmdir(const char * path_name) { SHOWMSG("that didn't work"); - __translate_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_io_error_to_errno(IoErr())); goto out; } diff --git a/library/stat_stat.c b/library/stat_stat.c index 4059b84..fedc4de 100644 --- a/library/stat_stat.c +++ b/library/stat_stat.c @@ -1,5 +1,5 @@ /* - * $Id: stat_stat.c,v 1.5 2005-01-30 09:37:59 obarthel Exp $ + * $Id: stat_stat.c,v 1.6 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -80,7 +80,7 @@ stat(const char * path_name, struct stat * st) { SHOWMSG("invalid parameters"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -138,7 +138,7 @@ stat(const char * path_name, struct stat * st) { SHOWMSG("that didn't work"); - __translate_access_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_access_io_error_to_errno(IoErr())); goto out; } @@ -150,7 +150,7 @@ stat(const char * path_name, struct stat * st) { SHOWMSG("couldn't examine it"); - __translate_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_io_error_to_errno(IoErr())); goto out; } diff --git a/library/stdio_asprintf.c b/library/stdio_asprintf.c index 3e3250d..dcfca91 100644 --- a/library/stdio_asprintf.c +++ b/library/stdio_asprintf.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_asprintf.c,v 1.3 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_asprintf.c,v 1.4 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -64,7 +64,7 @@ asprintf(char **ret, const char *format, ...) { if(ret == NULL || format == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/stdio_clearerr.c b/library/stdio_clearerr.c index f6d1482..6ee3ed3 100644 --- a/library/stdio_clearerr.c +++ b/library/stdio_clearerr.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_clearerr.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_clearerr.c,v 1.3 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -62,7 +62,7 @@ clearerr(FILE *stream) { if(stream == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/stdio_dropiobreadbuffer.c b/library/stdio_dropiobreadbuffer.c index 5f514b9..21596db 100644 --- a/library/stdio_dropiobreadbuffer.c +++ b/library/stdio_dropiobreadbuffer.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_dropiobreadbuffer.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_dropiobreadbuffer.c,v 1.3 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -94,8 +94,9 @@ __drop_iob_read_buffer(struct iob * file) SET_FLAG(file->iob_Flags,IOBF_ERROR); - result = -1; - errno = message.error; + result = -1; + + __set_errno(message.error); goto out; } diff --git a/library/stdio_fclose.c b/library/stdio_fclose.c index 9feb965..04f8fa8 100644 --- a/library/stdio_fclose.c +++ b/library/stdio_fclose.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_fclose.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_fclose.c,v 1.3 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -72,7 +72,7 @@ fclose(FILE *stream) result = EOF; - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -91,7 +91,7 @@ fclose(FILE *stream) result = EOF; - errno = EBADF; + __set_errno(EBADF); goto out; } @@ -111,8 +111,9 @@ fclose(FILE *stream) if(result != EOF) { - result = message.result; - errno = message.error; + result = message.result; + + __set_errno(message.error); } /* Now that the file is closed and we are in fact diff --git a/library/stdio_fdhookentry.c b/library/stdio_fdhookentry.c index b5a7cb3..beafc2d 100644 --- a/library/stdio_fdhookentry.c +++ b/library/stdio_fdhookentry.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_fdhookentry.c,v 1.7 2005-01-12 09:15:50 obarthel Exp $ + * $Id: stdio_fdhookentry.c,v 1.8 2005-02-03 16:56:15 obarthel Exp $ * * :ts=4 * @@ -1249,7 +1249,7 @@ handle_record_locking(int cmd,struct flock * l,struct fd * fd,int * error_ptr) { SetIoErr(error); - __translate_io_error_to_errno(IoErr(),error_ptr); + (*error_ptr) = __translate_io_error_to_errno(error); } RETURN(result); @@ -1332,7 +1332,7 @@ grow_file_size(struct fd * fd,int num_bytes,int * error_ptr) { SHOWMSG("could not move to the end of the file"); - __translate_io_error_to_errno(IoErr(),error_ptr); + (*error_ptr) = __translate_io_error_to_errno(IoErr()); goto out; } @@ -1374,7 +1374,7 @@ grow_file_size(struct fd * fd,int num_bytes,int * error_ptr) if(bytes_written != size) { - __translate_io_error_to_errno(IoErr(),error_ptr); + (*error_ptr) = __translate_io_error_to_errno(IoErr()); goto out; } @@ -1439,7 +1439,8 @@ __fd_hook_entry( if(result < 0) { D(("read failed ioerr=%ld",IoErr())); - __translate_io_error_to_errno(IoErr(),&error); + + error = __translate_io_error_to_errno(IoErr()); break; } @@ -1490,7 +1491,7 @@ __fd_hook_entry( { D(("write failed ioerr=%ld",IoErr())); - __translate_io_error_to_errno(IoErr(),&error); + error = __translate_io_error_to_errno(IoErr()); break; } @@ -1600,7 +1601,7 @@ __fd_hook_entry( { D(("seek failed, mode=%ld (%ld), offset=%ld, ioerr=%ld",mode,message->mode,message->position,IoErr())); - __translate_io_error_to_errno(IoErr(),&error); + error = __translate_io_error_to_errno(IoErr()); #if defined(UNIX_PATH_SEMANTICS) { @@ -1665,7 +1666,7 @@ __fd_hook_entry( } if(CANNOT Close(fd->fd_DefaultFile)) - __translate_io_error_to_errno(IoErr(),&error); + error = __translate_io_error_to_errno(IoErr()); PROFILE_ON(); @@ -1913,7 +1914,7 @@ __fd_hook_entry( { SHOWMSG("that didn't work"); - __translate_io_error_to_errno(IoErr(),&error); + error = __translate_io_error_to_errno(IoErr()); } } #else @@ -1930,7 +1931,7 @@ __fd_hook_entry( { SHOWMSG("that didn't work"); - __translate_io_error_to_errno(IoErr(),&error); + error = __translate_io_error_to_errno(IoErr()); } } else @@ -1954,13 +1955,13 @@ __fd_hook_entry( if(DoPkt(dvp->dvp_Port,ACTION_SET_OWNER,dvp->dvp_Lock,MKBADDR(new_name),(LONG)((((ULONG)message->owner) << 16) | message->group),0,0)) result = 0; else - __translate_io_error_to_errno(IoErr(),&error); + error = __translate_io_error_to_errno(IoErr()); FreeDeviceProc(dvp); } else { - __translate_io_error_to_errno(IoErr(),&error); + error = __translate_io_error_to_errno(IoErr()); } } } @@ -1974,14 +1975,14 @@ __fd_hook_entry( { SHOWMSG("couldn't find parent directory"); - __translate_io_error_to_errno(IoErr(),&error); + error = __translate_io_error_to_errno(IoErr()); } } else { SHOWMSG("couldn't examine file handle"); - __translate_io_error_to_errno(IoErr(),&error); + error = __translate_io_error_to_errno(IoErr()); } PROFILE_ON(); @@ -2007,7 +2008,7 @@ __fd_hook_entry( if(CANNOT safe_examine_file_handle(fd->fd_DefaultFile,fib)) { - __translate_io_error_to_errno(IoErr(),&error); + error = __translate_io_error_to_errno(IoErr()); break; } @@ -2025,7 +2026,7 @@ __fd_hook_entry( } else { - __translate_io_error_to_errno(IoErr(),&error); + error = __translate_io_error_to_errno(IoErr()); } } else if (message->size > fib->fib_Size) @@ -2039,7 +2040,7 @@ __fd_hook_entry( } else { - __translate_io_error_to_errno(IoErr(),&error); + error = __translate_io_error_to_errno(IoErr()); } } else @@ -2071,7 +2072,7 @@ __fd_hook_entry( { SHOWMSG("couldn't examine the file"); - __translate_io_error_to_errno(IoErr(),&error); + error = __translate_io_error_to_errno(IoErr()); break; } @@ -2111,7 +2112,7 @@ __fd_hook_entry( { SHOWMSG("couldn't get info on drive"); - __translate_io_error_to_errno(IoErr(),&error); + error = __translate_io_error_to_errno(IoErr()); } UnLock(parent_dir); @@ -2120,7 +2121,7 @@ __fd_hook_entry( { SHOWMSG("couldn't find parent directory"); - __translate_io_error_to_errno(IoErr(),&error); + error = __translate_io_error_to_errno(IoErr()); } PROFILE_ON(); @@ -2163,7 +2164,7 @@ __fd_hook_entry( { SHOWMSG("couldn't change protection bits; oh well, it was worth the effort..."); - __translate_io_error_to_errno(IoErr(),&error); + error = __translate_io_error_to_errno(IoErr()); } CurrentDir(old_current_dir); @@ -2172,7 +2173,7 @@ __fd_hook_entry( { SHOWMSG("couldn't examine file"); - __translate_io_error_to_errno(IoErr(),&error); + error = __translate_io_error_to_errno(IoErr()); } UnLock(parent_dir); @@ -2181,7 +2182,7 @@ __fd_hook_entry( { SHOWMSG("couldn't get a lock on the parent directory"); - __translate_io_error_to_errno(IoErr(),&error); + error = __translate_io_error_to_errno(IoErr()); } PROFILE_ON(); diff --git a/library/stdio_feof.c b/library/stdio_feof.c index 694786f..c85bfa6 100644 --- a/library/stdio_feof.c +++ b/library/stdio_feof.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_feof.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_feof.c,v 1.3 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -65,8 +65,10 @@ feof(FILE *stream) { SHOWMSG("invalid stream parameter"); - errno = EFAULT; + __set_errno(EFAULT); + result = 0; + goto out; } } diff --git a/library/stdio_ferror.c b/library/stdio_ferror.c index e63777e..1b3baac 100644 --- a/library/stdio_ferror.c +++ b/library/stdio_ferror.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_ferror.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_ferror.c,v 1.3 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -65,8 +65,10 @@ ferror(FILE *stream) { SHOWMSG("invalid stream parameter"); - errno = EFAULT; + __set_errno(EFAULT); + result = 0; + goto out; } } diff --git a/library/stdio_fflush.c b/library/stdio_fflush.c index b4ac3f7..0d2aab5 100644 --- a/library/stdio_fflush.c +++ b/library/stdio_fflush.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_fflush.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_fflush.c,v 1.3 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -97,7 +97,7 @@ fflush(FILE *stream) { SHOWMSG("invalid file handle"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/stdio_fgetc.c b/library/stdio_fgetc.c index 5760fd2..03ed732 100644 --- a/library/stdio_fgetc.c +++ b/library/stdio_fgetc.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_fgetc.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_fgetc.c,v 1.3 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -89,7 +89,7 @@ __fgetc_check(FILE * stream) { if(stream == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -107,7 +107,7 @@ __fgetc_check(FILE * stream) SET_FLAG(file->iob_Flags,IOBF_ERROR); - errno = EBADF; + __set_errno(EBADF); goto out; } @@ -115,7 +115,7 @@ __fgetc_check(FILE * stream) { SET_FLAG(file->iob_Flags,IOBF_ERROR); - errno = EBADF; + __set_errno(EBADF); goto out; } @@ -142,7 +142,7 @@ fgetc(FILE *stream) { if(stream == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/stdio_fgetpos.c b/library/stdio_fgetpos.c index 663bc97..c6196a8 100644 --- a/library/stdio_fgetpos.c +++ b/library/stdio_fgetpos.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_fgetpos.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_fgetpos.c,v 1.3 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -62,7 +62,7 @@ fgetpos(FILE *stream, fpos_t *pos) { SHOWMSG("invalid parameters"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/stdio_fgets.c b/library/stdio_fgets.c index 0111d59..eebabb8 100644 --- a/library/stdio_fgets.c +++ b/library/stdio_fgets.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_fgets.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_fgets.c,v 1.3 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -63,7 +63,7 @@ fgets(char *s,int n,FILE *stream) { SHOWMSG("invalid parameters"); - errno = EFAULT; + __set_errno(EFAULT); result = NULL; goto out; } diff --git a/library/stdio_filliobreadbuffer.c b/library/stdio_filliobreadbuffer.c index 9ba56a8..b88d891 100644 --- a/library/stdio_filliobreadbuffer.c +++ b/library/stdio_filliobreadbuffer.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_filliobreadbuffer.c,v 1.3 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_filliobreadbuffer.c,v 1.4 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -92,9 +92,9 @@ __fill_iob_read_buffer(struct iob * file) if(message.result < 0) { - errno = message.error; + __set_errno(message.error); - D(("got error %ld",errno)); + D(("got error %ld",message.error)); SET_FLAG(file->iob_Flags,IOBF_ERROR); goto out; diff --git a/library/stdio_flush.c b/library/stdio_flush.c index 76eac75..803e3c0 100644 --- a/library/stdio_flush.c +++ b/library/stdio_flush.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_flush.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_flush.c,v 1.3 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -68,7 +68,7 @@ __flush(FILE *stream) { SHOWMSG("invalid stream parameter"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/stdio_flushiobwritebuffer.c b/library/stdio_flushiobwritebuffer.c index b317193..99d5739 100644 --- a/library/stdio_flushiobwritebuffer.c +++ b/library/stdio_flushiobwritebuffer.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_flushiobwritebuffer.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_flushiobwritebuffer.c,v 1.3 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -102,9 +102,9 @@ __flush_iob_write_buffer(struct iob * file) SET_FLAG(file->iob_Flags,IOBF_ERROR); - result = -1; - errno = message.error; + __set_errno(message.error); + result = -1; goto out; } diff --git a/library/stdio_fopen.c b/library/stdio_fopen.c index 3fbe22e..d2ceafc 100644 --- a/library/stdio_fopen.c +++ b/library/stdio_fopen.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_fopen.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_fopen.c,v 1.3 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -62,7 +62,7 @@ fopen(const char *filename, const char *mode) { SHOWMSG("invalid parameters"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/stdio_fprintf.c b/library/stdio_fprintf.c index 0ff729b..9d1f7f7 100644 --- a/library/stdio_fprintf.c +++ b/library/stdio_fprintf.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_fprintf.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_fprintf.c,v 1.3 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -60,7 +60,7 @@ fprintf(FILE *stream,const char *format,...) { if(stream == NULL || format == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/stdio_fputc.c b/library/stdio_fputc.c index a122420..cc860ac 100644 --- a/library/stdio_fputc.c +++ b/library/stdio_fputc.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_fputc.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_fputc.c,v 1.3 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -55,7 +55,7 @@ __fputc_check(FILE *stream) { if(stream == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -72,7 +72,7 @@ __fputc_check(FILE *stream) { SHOWMSG("this file is not even in use"); - errno = EBADF; + __set_errno(EBADF); SET_FLAG(file->iob_Flags,IOBF_ERROR); goto out; @@ -82,7 +82,7 @@ __fputc_check(FILE *stream) { SHOWMSG("this stream is not write enabled"); - errno = EBADF; + __set_errno(EBADF); SET_FLAG(file->iob_Flags,IOBF_ERROR); goto out; diff --git a/library/stdio_fputs.c b/library/stdio_fputs.c index 7241f48..a7239d2 100644 --- a/library/stdio_fputs.c +++ b/library/stdio_fputs.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_fputs.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_fputs.c,v 1.3 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -62,7 +62,7 @@ fputs(const char *s, FILE *stream) { if(s == NULL || stream == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/stdio_fread.c b/library/stdio_fread.c index ccf692b..f93f84a 100644 --- a/library/stdio_fread.c +++ b/library/stdio_fread.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_fread.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_fread.c,v 1.3 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -65,7 +65,7 @@ fread(void *ptr,size_t element_size,size_t count,FILE *stream) { SHOWMSG("invalid parameters"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -82,7 +82,7 @@ fread(void *ptr,size_t element_size,size_t count,FILE *stream) { SHOWMSG("this file is not even in use"); - errno = EBADF; + __set_errno(EBADF); SET_FLAG(file->iob_Flags,IOBF_ERROR); goto out; @@ -92,7 +92,7 @@ fread(void *ptr,size_t element_size,size_t count,FILE *stream) { SHOWMSG("this file is not read-enabled"); - errno = EBADF; + __set_errno(EBADF); SET_FLAG(file->iob_Flags,IOBF_ERROR); goto out; diff --git a/library/stdio_freopen.c b/library/stdio_freopen.c index bdefd36..ecb0744 100644 --- a/library/stdio_freopen.c +++ b/library/stdio_freopen.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_freopen.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_freopen.c,v 1.3 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -64,7 +64,7 @@ freopen(const char *filename, const char *mode, FILE *stream) { SHOWMSG("invalid parameters"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/stdio_fscanf.c b/library/stdio_fscanf.c index 9e0b46e..b00c56d 100644 --- a/library/stdio_fscanf.c +++ b/library/stdio_fscanf.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_fscanf.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_fscanf.c,v 1.3 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -62,7 +62,7 @@ fscanf(FILE *stream, const char *format, ...) { SHOWMSG("invalid parameters"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/stdio_fseek.c b/library/stdio_fseek.c index f6419f9..92ca344 100644 --- a/library/stdio_fseek.c +++ b/library/stdio_fseek.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_fseek.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_fseek.c,v 1.3 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -65,7 +65,7 @@ fseek(FILE *stream, long int offset, int wherefrom) { SHOWMSG("invalid stream parameter"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -82,7 +82,7 @@ fseek(FILE *stream, long int offset, int wherefrom) { SHOWMSG("this file is not even in use"); - errno = EBADF; + __set_errno(EBADF); SET_FLAG(file->iob_Flags,IOBF_ERROR); goto out; @@ -92,7 +92,7 @@ fseek(FILE *stream, long int offset, int wherefrom) { SHOWMSG("invalid wherefrom parameter"); - errno = EBADF; + __set_errno(EBADF); SET_FLAG(file->iob_Flags,IOBF_ERROR); goto out; @@ -178,7 +178,7 @@ fseek(FILE *stream, long int offset, int wherefrom) if(message.result < 0) { - errno = message.error; + __set_errno(message.error); SET_FLAG(file->iob_Flags,IOBF_ERROR); goto out; diff --git a/library/stdio_fsetpos.c b/library/stdio_fsetpos.c index 6b0118e..fd13972 100644 --- a/library/stdio_fsetpos.c +++ b/library/stdio_fsetpos.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_fsetpos.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_fsetpos.c,v 1.3 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -61,7 +61,7 @@ fsetpos(FILE *stream, fpos_t *pos) { SHOWMSG("invalid parameters"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/stdio_ftell.c b/library/stdio_ftell.c index 7088aa6..d49d57c 100644 --- a/library/stdio_ftell.c +++ b/library/stdio_ftell.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_ftell.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_ftell.c,v 1.3 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -58,7 +58,7 @@ ftell(FILE *stream) { if(stream == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -75,7 +75,7 @@ ftell(FILE *stream) { SHOWMSG("this file is not even in use"); - errno = EBADF; + __set_errno(EBADF); SET_FLAG(file->iob_Flags,IOBF_ERROR); goto out; @@ -100,7 +100,7 @@ ftell(FILE *stream) result = message.result; if(result < 0) { - errno = message.error; + __set_errno(message.error); SET_FLAG(file->iob_Flags,IOBF_ERROR); diff --git a/library/stdio_fwrite.c b/library/stdio_fwrite.c index 2ef8e52..39ec162 100644 --- a/library/stdio_fwrite.c +++ b/library/stdio_fwrite.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_fwrite.c,v 1.3 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_fwrite.c,v 1.4 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -65,7 +65,7 @@ fwrite(const void *ptr,size_t element_size,size_t count,FILE *stream) { SHOWMSG("invalid parameters"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -82,7 +82,7 @@ fwrite(const void *ptr,size_t element_size,size_t count,FILE *stream) { SHOWMSG("this file is not even in use"); - errno = EBADF; + __set_errno(EBADF); SET_FLAG(file->iob_Flags,IOBF_ERROR); goto out; @@ -92,7 +92,7 @@ fwrite(const void *ptr,size_t element_size,size_t count,FILE *stream) { SHOWMSG("this stream is not write-enabled"); - errno = EBADF; + __set_errno(EBADF); SET_FLAG(file->iob_Flags,IOBF_ERROR); goto out; diff --git a/library/stdio_getc.c b/library/stdio_getc.c index 182e33b..11bddb8 100644 --- a/library/stdio_getc.c +++ b/library/stdio_getc.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_getc.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_getc.c,v 1.3 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -58,7 +58,7 @@ getc(FILE *stream) { if(stream == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/stdio_gets.c b/library/stdio_gets.c index e9f8675..190925f 100644 --- a/library/stdio_gets.c +++ b/library/stdio_gets.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_gets.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_gets.c,v 1.3 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -61,7 +61,8 @@ gets(char *s) { SHOWMSG("invalid parameters"); - errno = EFAULT; + __set_errno(EFAULT); + result = NULL; goto out; } diff --git a/library/stdio_growfdtable.c b/library/stdio_growfdtable.c index 82d049f..343f50a 100644 --- a/library/stdio_growfdtable.c +++ b/library/stdio_growfdtable.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_growfdtable.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_growfdtable.c,v 1.3 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -59,7 +59,7 @@ __grow_fd_table(void) { SHOWMSG("not enough memory for new file descriptor table"); - errno = ENOMEM; + __set_errno(ENOMEM); goto out; } @@ -77,7 +77,7 @@ __grow_fd_table(void) free(new_fd); - errno = ENOMEM; + __set_errno(ENOMEM); goto out; } diff --git a/library/stdio_growiobtable.c b/library/stdio_growiobtable.c index 974d5b3..e93d7e1 100644 --- a/library/stdio_growiobtable.c +++ b/library/stdio_growiobtable.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_growiobtable.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_growiobtable.c,v 1.3 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -59,7 +59,7 @@ __grow_iob_table(void) { SHOWMSG("not enough memory for file table"); - errno = ENOMEM; + __set_errno(ENOMEM); goto out; } @@ -77,7 +77,7 @@ __grow_iob_table(void) free(new_iob); - errno = ENOMEM; + __set_errno(ENOMEM); goto out; } diff --git a/library/stdio_headers.h b/library/stdio_headers.h index 0c49669..58ef1cc 100644 --- a/library/stdio_headers.h +++ b/library/stdio_headers.h @@ -1,5 +1,5 @@ /* - * $Id: stdio_headers.h,v 1.9 2005-01-12 09:15:50 obarthel Exp $ + * $Id: stdio_headers.h,v 1.10 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -81,9 +81,9 @@ /****************************************************************************/ -#ifndef _STDLIB_LOCALE_UTILITY_H -#include "stdlib_locale_utility.h" -#endif /* _STDLIB_LOCALE_UTILITY_H */ +#ifndef _STDLIB_HEADERS_H +#include "stdlib_headers.h" +#endif /* _STDLIB_HEADERS_H */ /****************************************************************************/ diff --git a/library/stdio_openiob.c b/library/stdio_openiob.c index 4637ddb..52df2b3 100644 --- a/library/stdio_openiob.c +++ b/library/stdio_openiob.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_openiob.c,v 1.5 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_openiob.c,v 1.6 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -79,7 +79,7 @@ __open_iob(const char *filename, const char *mode, int file_descriptor, int slot fd = __get_file_descriptor(file_descriptor); if(fd == NULL) { - errno = EBADF; + __set_errno(EBADF); goto out; } } @@ -112,7 +112,7 @@ __open_iob(const char *filename, const char *mode, int file_descriptor, int slot D(("unsupported file open mode '%lc'",mode[0])); - errno = EINVAL; + __set_errno(EINVAL); goto out; } @@ -135,7 +135,7 @@ __open_iob(const char *filename, const char *mode, int file_descriptor, int slot { SHOWMSG("that didn't work"); - errno = ENOBUFS; + __set_errno(ENOBUFS); goto out; } diff --git a/library/stdio_perror.c b/library/stdio_perror.c index 969a1ba..e4b3606 100644 --- a/library/stdio_perror.c +++ b/library/stdio_perror.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_perror.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_perror.c,v 1.3 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -41,7 +41,7 @@ void perror(const char * s) { char * error_message; - int error = errno; + int error = __get_errno(); if(s != NULL) fprintf(stderr,"%s: ",s); diff --git a/library/stdio_popen.c b/library/stdio_popen.c index ac47540..513b247 100644 --- a/library/stdio_popen.c +++ b/library/stdio_popen.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_popen.c,v 1.4 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_popen.c,v 1.5 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -70,7 +70,7 @@ pclose(FILE *stream) { SHOWMSG("invalid stream parameter"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -123,7 +123,7 @@ popen(const char *command, const char *type) { SHOWMSG("invalid parameters"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -149,7 +149,8 @@ popen(const char *command, const char *type) default: D(("unsupported access mode '%lc'",type[0])); - errno = EINVAL; + + __set_errno(EINVAL); goto out; } @@ -158,7 +159,7 @@ popen(const char *command, const char *type) { D(("unsupported access mode '%s'",type)); - errno = EINVAL; + __set_errno(EINVAL); goto out; } @@ -199,7 +200,8 @@ popen(const char *command, const char *type) /* This may be too long for proper translation... */ if(command_len > MAXPATHLEN) { - errno = ENAMETOOLONG; + __set_errno(ENAMETOOLONG); + result = NULL; goto out; } @@ -226,7 +228,8 @@ popen(const char *command, const char *type) command_copy = malloc(1 + strlen(command_name) + 1 + strlen(&command[command_len]) + 1); if(command_copy == NULL) { - errno = ENOMEM; + __set_errno(ENOMEM); + result = NULL; goto out; } @@ -304,7 +307,7 @@ popen(const char *command, const char *type) { SHOWMSG("couldn't open the streams"); - __translate_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_io_error_to_errno(IoErr())); goto out; } @@ -326,7 +329,7 @@ popen(const char *command, const char *type) { SHOWMSG("SystemTagList() failed"); - __translate_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_io_error_to_errno(IoErr())); goto out; } diff --git a/library/stdio_printf.c b/library/stdio_printf.c index 222a992..fda97d0 100644 --- a/library/stdio_printf.c +++ b/library/stdio_printf.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_printf.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_printf.c,v 1.3 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -59,7 +59,7 @@ printf(const char *format, ...) { if(format == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/stdio_protos.h b/library/stdio_protos.h index 8322db5..77d54cd 100644 --- a/library/stdio_protos.h +++ b/library/stdio_protos.h @@ -1,5 +1,5 @@ /* - * $Id: stdio_protos.h,v 1.4 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_protos.h,v 1.5 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -71,8 +71,8 @@ void __close_all_files(void); /****************************************************************************/ /* stdio_translateioerror.c */ -extern void __translate_io_error_to_errno(LONG io_error,int * errno_ptr); -extern void __translate_access_io_error_to_errno(LONG io_error,int * errno_ptr); +extern int __translate_io_error_to_errno(LONG io_error); +extern int __translate_access_io_error_to_errno(LONG io_error); /****************************************************************************/ diff --git a/library/stdio_putc.c b/library/stdio_putc.c index 8909745..668b64d 100644 --- a/library/stdio_putc.c +++ b/library/stdio_putc.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_putc.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_putc.c,v 1.3 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -58,7 +58,7 @@ putc(int c,FILE *stream) { if(stream == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/stdio_puts.c b/library/stdio_puts.c index f24063b..7e17012 100644 --- a/library/stdio_puts.c +++ b/library/stdio_puts.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_puts.c,v 1.3 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_puts.c,v 1.4 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -61,7 +61,7 @@ puts(const char *s) { if(s == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/stdio_remove.c b/library/stdio_remove.c index e561b79..c1dd069 100644 --- a/library/stdio_remove.c +++ b/library/stdio_remove.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_remove.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_remove.c,v 1.3 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -60,7 +60,7 @@ remove(const char *filename) { SHOWMSG("invalid path name"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -85,7 +85,7 @@ remove(const char *filename) if(status == DOSFALSE) { - __translate_access_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_access_io_error_to_errno(IoErr())); goto out; } diff --git a/library/stdio_rename.c b/library/stdio_rename.c index 75695a4..46a8c07 100644 --- a/library/stdio_rename.c +++ b/library/stdio_rename.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_rename.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_rename.c,v 1.3 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -66,7 +66,7 @@ rename(const char *oldname,const char *newname) { SHOWMSG("invalid parameters"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -87,7 +87,7 @@ rename(const char *oldname,const char *newname) if(old_nti.is_root || new_nti.is_root) { - errno = EACCES; + __set_errno(EACCES); goto out; } } @@ -112,7 +112,7 @@ rename(const char *oldname,const char *newname) { SHOWMSG("that was some other error"); - __translate_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_io_error_to_errno(IoErr())); goto out; } @@ -128,13 +128,13 @@ rename(const char *oldname,const char *newname) { SHOWMSG("that didn't work"); - __translate_access_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_access_io_error_to_errno(IoErr())); goto out; } } #else { - __translate_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_io_error_to_errno(IoErr())); goto out; } #endif /* UNIX_PATH_SEMANTICS */ diff --git a/library/stdio_scanf.c b/library/stdio_scanf.c index c28a56b..ee3811c 100644 --- a/library/stdio_scanf.c +++ b/library/stdio_scanf.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_scanf.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_scanf.c,v 1.3 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -61,7 +61,7 @@ scanf(const char *format, ...) { SHOWMSG("invalid format parameter"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/stdio_setbuf.c b/library/stdio_setbuf.c index 23ca4c6..857e383 100644 --- a/library/stdio_setbuf.c +++ b/library/stdio_setbuf.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_setbuf.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_setbuf.c,v 1.3 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -59,7 +59,7 @@ setbuf(FILE *stream,char *buf) { SHOWMSG("invalid stream parameter"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/stdio_setvbuf.c b/library/stdio_setvbuf.c index 8c1bb13..ac8ee90 100644 --- a/library/stdio_setvbuf.c +++ b/library/stdio_setvbuf.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_setvbuf.c,v 1.3 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_setvbuf.c,v 1.4 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -71,7 +71,7 @@ setvbuf(FILE *stream,char *buf,int bufmode,size_t size) { SHOWMSG("invalid stream parameter"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -85,7 +85,7 @@ setvbuf(FILE *stream,char *buf,int bufmode,size_t size) { SHOWMSG("invalid buffer mode"); - errno = EINVAL; + __set_errno(EINVAL); goto out; } @@ -93,7 +93,7 @@ setvbuf(FILE *stream,char *buf,int bufmode,size_t size) { SHOWMSG("invalid buffer size"); - errno = EINVAL; + __set_errno(EINVAL); goto out; } @@ -105,7 +105,7 @@ setvbuf(FILE *stream,char *buf,int bufmode,size_t size) { SHOWMSG("this file is not even in use"); - errno = EBADF; + __set_errno(EBADF); SET_FLAG(file->iob_Flags,IOBF_ERROR); goto out; @@ -123,7 +123,7 @@ setvbuf(FILE *stream,char *buf,int bufmode,size_t size) new_buffer = malloc(size + (CACHE_LINE_SIZE-1)); if(new_buffer == NULL) { - errno = ENOBUFS; + __set_errno(ENOBUFS); goto out; } } diff --git a/library/stdio_snprintf.c b/library/stdio_snprintf.c index 0b072cd..a37d230 100644 --- a/library/stdio_snprintf.c +++ b/library/stdio_snprintf.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_snprintf.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_snprintf.c,v 1.3 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -64,7 +64,7 @@ snprintf(char *s, size_t size, const char *format, ...) { if((size > 0 && s == NULL) || format == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/stdio_sprintf.c b/library/stdio_sprintf.c index 443c4ef..9d761d7 100644 --- a/library/stdio_sprintf.c +++ b/library/stdio_sprintf.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_sprintf.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_sprintf.c,v 1.3 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -60,7 +60,7 @@ sprintf(char *s, const char *format, ...) { if(s == NULL || format == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/stdio_sscanf.c b/library/stdio_sscanf.c index 56a9f02..18531d0 100644 --- a/library/stdio_sscanf.c +++ b/library/stdio_sscanf.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_sscanf.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_sscanf.c,v 1.3 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -64,7 +64,7 @@ sscanf(const char *s,const char *format, ...) { SHOWMSG("invalid parameters"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/stdio_tmpfile.c b/library/stdio_tmpfile.c index 1e9a89c..033e84e 100644 --- a/library/stdio_tmpfile.c +++ b/library/stdio_tmpfile.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_tmpfile.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_tmpfile.c,v 1.3 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -75,7 +75,7 @@ tmpfile(void) { SHOWMSG("couldn't get a temp_file_lock on the current directory"); - __translate_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_io_error_to_errno(IoErr())); goto out; } diff --git a/library/stdio_tmpnam.c b/library/stdio_tmpnam.c index 44dad00..77a741d 100644 --- a/library/stdio_tmpnam.c +++ b/library/stdio_tmpnam.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_tmpnam.c,v 1.3 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_tmpnam.c,v 1.4 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -102,7 +102,7 @@ tmpnam(char *buf) if(IoErr() == ERROR_OBJECT_NOT_FOUND) result = buf; else - __translate_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_io_error_to_errno(IoErr())); break; } diff --git a/library/stdio_translateioerror.c b/library/stdio_translateioerror.c index 42b0db0..e9c5311 100644 --- a/library/stdio_translateioerror.c +++ b/library/stdio_translateioerror.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_translateioerror.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_translateioerror.c,v 1.3 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -37,8 +37,8 @@ /****************************************************************************/ -void -__translate_io_error_to_errno(LONG io_err,int * errno_ptr) +int +__translate_io_error_to_errno(LONG io_err) { static const struct { LONG io_err; LONG errno; } map_table[] = { @@ -84,35 +84,35 @@ __translate_io_error_to_errno(LONG io_err,int * errno_ptr) }; unsigned int i; - int error; + int result; - assert( errno_ptr != NULL ); - - error = EIO; + result = EIO; for(i = 0 ; i < NUM_ENTRIES(map_table) ; i++) { if(map_table[i].io_err == io_err) { - error = map_table[i].errno; + result = map_table[i].errno; break; } } - (*errno_ptr) = error; + return(result); } /****************************************************************************/ /* Same as above, except that we translate ERROR_OBJECT_WRONG_TYPE into ENOTDIR by default. */ -void -__translate_access_io_error_to_errno(LONG io_err,int * errno_ptr) +int +__translate_access_io_error_to_errno(LONG io_err) { - assert( errno_ptr != NULL ); + int result; if(io_err == ERROR_OBJECT_WRONG_TYPE) - (*errno_ptr) = ENOTDIR; + result = ENOTDIR; else - __translate_io_error_to_errno(io_err,errno_ptr); + result = __translate_io_error_to_errno(io_err); + + return(result); } diff --git a/library/stdio_ungetc.c b/library/stdio_ungetc.c index 8611b9d..3db7331 100644 --- a/library/stdio_ungetc.c +++ b/library/stdio_ungetc.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_ungetc.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_ungetc.c,v 1.3 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -57,7 +57,7 @@ ungetc(int c,FILE *stream) { SHOWMSG("null file pointer!"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -74,7 +74,7 @@ ungetc(int c,FILE *stream) { SHOWMSG("this file is not even in use"); - errno = EBADF; + __set_errno(EBADF); SET_FLAG(file->iob_Flags,IOBF_ERROR); goto out; @@ -85,7 +85,7 @@ ungetc(int c,FILE *stream) { SHOWMSG("can't even read from this file"); - errno = EACCES; + __set_errno(EACCES); SET_FLAG(file->iob_Flags,IOBF_ERROR); goto out; @@ -96,7 +96,7 @@ ungetc(int c,FILE *stream) { SHOWMSG("cannot push back an EOF"); - errno = EINVAL; + __set_errno(EINVAL); SET_FLAG(file->iob_Flags,IOBF_ERROR); goto out; @@ -121,7 +121,7 @@ ungetc(int c,FILE *stream) { SHOWMSG("no room to push back"); - errno = ENOBUFS; + __set_errno(ENOBUFS); SET_FLAG(file->iob_Flags,IOBF_ERROR); goto out; diff --git a/library/stdio_vasprintf.c b/library/stdio_vasprintf.c index 2f378ca..2eef88e 100644 --- a/library/stdio_vasprintf.c +++ b/library/stdio_vasprintf.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_vasprintf.c,v 1.5 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_vasprintf.c,v 1.6 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -77,7 +77,7 @@ __vasprintf(const char *file,int line,char **ret,const char *format,va_list arg) { SHOWMSG("invalid parameters"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/stdio_vfprintf.c b/library/stdio_vfprintf.c index 77e8a12..d30a6b3 100644 --- a/library/stdio_vfprintf.c +++ b/library/stdio_vfprintf.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_vfprintf.c,v 1.7 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_vfprintf.c,v 1.8 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -157,7 +157,7 @@ vfprintf(FILE * stream,const char * format, va_list arg) { SHOWMSG("invalid parameters"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -261,7 +261,7 @@ vfprintf(FILE * stream,const char * format, va_list arg) { if(arg == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -342,7 +342,7 @@ vfprintf(FILE * stream,const char * format, va_list arg) { if(arg == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -563,7 +563,7 @@ vfprintf(FILE * stream,const char * format, va_list arg) { if(arg == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -619,7 +619,7 @@ vfprintf(FILE * stream,const char * format, va_list arg) { if(arg == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -1001,7 +1001,7 @@ vfprintf(FILE * stream,const char * format, va_list arg) { if(arg == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -1155,7 +1155,7 @@ vfprintf(FILE * stream,const char * format, va_list arg) { if(arg == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -1210,7 +1210,7 @@ vfprintf(FILE * stream,const char * format, va_list arg) { if(arg == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -1228,7 +1228,7 @@ vfprintf(FILE * stream,const char * format, va_list arg) { if(short_ptr == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -1252,7 +1252,7 @@ vfprintf(FILE * stream,const char * format, va_list arg) { if(int_ptr == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -1272,7 +1272,7 @@ vfprintf(FILE * stream,const char * format, va_list arg) { if(int_ptr == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -1293,7 +1293,7 @@ vfprintf(FILE * stream,const char * format, va_list arg) { if(int_ptr == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/stdio_vfscanf.c b/library/stdio_vfscanf.c index 10ea69f..145fdc7 100644 --- a/library/stdio_vfscanf.c +++ b/library/stdio_vfscanf.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_vfscanf.c,v 1.7 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_vfscanf.c,v 1.8 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -47,6 +47,12 @@ /****************************************************************************/ +#if defined(FLOATING_POINT_SUPPORT) && !defined(_MATH_HEADERS_H) +#include "math_headers.h" +#endif /* FLOATING_POINT_SUPPORT && !_MATH_HEADERS_H */ + +/****************************************************************************/ + /* * Uncomment this to activate '%lld' support and the like. Better still, * define this is in the Makefile! @@ -86,7 +92,7 @@ __vfscanf(FILE *stream, const char *format, va_list arg) { if(stream == NULL || format == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -383,7 +389,7 @@ __vfscanf(FILE *stream, const char *format, va_list arg) { if(arg == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -397,7 +403,7 @@ __vfscanf(FILE *stream, const char *format, va_list arg) { if(c_ptr == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -458,7 +464,7 @@ __vfscanf(FILE *stream, const char *format, va_list arg) { if(arg == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -489,7 +495,7 @@ __vfscanf(FILE *stream, const char *format, va_list arg) { if(next_parameter == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -827,7 +833,7 @@ __vfscanf(FILE *stream, const char *format, va_list arg) if(new_sum >= sum) sum = new_sum; else - sum = HUGE_VAL; + sum = __get_huge_val(); } } } @@ -875,7 +881,7 @@ __vfscanf(FILE *stream, const char *format, va_list arg) { if(arg == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -906,7 +912,7 @@ __vfscanf(FILE *stream, const char *format, va_list arg) { if(next_parameter == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -942,7 +948,7 @@ __vfscanf(FILE *stream, const char *format, va_list arg) { if(arg == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -974,7 +980,7 @@ __vfscanf(FILE *stream, const char *format, va_list arg) { if(next_parameter == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -1234,7 +1240,7 @@ __vfscanf(FILE *stream, const char *format, va_list arg) { if(arg == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -1248,7 +1254,7 @@ __vfscanf(FILE *stream, const char *format, va_list arg) { if(s_ptr == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -1311,7 +1317,7 @@ __vfscanf(FILE *stream, const char *format, va_list arg) { if(arg == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -1329,7 +1335,7 @@ __vfscanf(FILE *stream, const char *format, va_list arg) { if(short_ptr == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -1353,7 +1359,7 @@ __vfscanf(FILE *stream, const char *format, va_list arg) { if(int_ptr == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -1373,7 +1379,7 @@ __vfscanf(FILE *stream, const char *format, va_list arg) { if(int_ptr == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -1394,7 +1400,7 @@ __vfscanf(FILE *stream, const char *format, va_list arg) { if(int_ptr == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -1448,7 +1454,7 @@ __vfscanf(FILE *stream, const char *format, va_list arg) { if(arg == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -1462,7 +1468,7 @@ __vfscanf(FILE *stream, const char *format, va_list arg) { if(s_ptr == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/stdio_vprintf.c b/library/stdio_vprintf.c index 74e3a83..78ae0db 100644 --- a/library/stdio_vprintf.c +++ b/library/stdio_vprintf.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_vprintf.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_vprintf.c,v 1.3 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -59,7 +59,7 @@ vprintf(const char *format,va_list arg) { if(format == NULL || arg == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/stdio_vsnprintf.c b/library/stdio_vsnprintf.c index fae27fb..e0d071f 100644 --- a/library/stdio_vsnprintf.c +++ b/library/stdio_vsnprintf.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_vsnprintf.c,v 1.3 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_vsnprintf.c,v 1.4 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -69,7 +69,7 @@ vsnprintf(char *buffer,size_t size,const char *format,va_list arg) { SHOWMSG("invalid parameters"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/stdio_vsprintf.c b/library/stdio_vsprintf.c index 93dc29a..8c52af6 100644 --- a/library/stdio_vsprintf.c +++ b/library/stdio_vsprintf.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_vsprintf.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdio_vsprintf.c,v 1.3 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -56,7 +56,7 @@ vsprintf(char *s,const char *format,va_list arg) { if(s == NULL || format == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/stdlib_atexit.c b/library/stdlib_atexit.c index f2304fd..7a154e3 100644 --- a/library/stdlib_atexit.c +++ b/library/stdlib_atexit.c @@ -1,5 +1,5 @@ /* - * $Id: stdlib_atexit.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdlib_atexit.c,v 1.3 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -77,7 +77,7 @@ atexit(void (*function)(void)) { if(function == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -85,7 +85,7 @@ atexit(void (*function)(void)) if(atexit_blocked) { - errno = EACCES; + __set_errno(EACCES); goto out; } @@ -102,7 +102,7 @@ atexit(void (*function)(void)) etn = malloc(sizeof(*etn)); if(etn == NULL) { - errno = ENOMEM; + __set_errno(ENOMEM); goto out; } } diff --git a/library/stdlib_atof.c b/library/stdlib_atof.c index e3f2b8c..bd3bb89 100644 --- a/library/stdlib_atof.c +++ b/library/stdlib_atof.c @@ -1,5 +1,5 @@ /* - * $Id: stdlib_atof.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdlib_atof.c,v 1.3 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -58,7 +58,7 @@ atof(const char *str) { if(str == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/stdlib_atoi.c b/library/stdlib_atoi.c index a700108..8690aea 100644 --- a/library/stdlib_atoi.c +++ b/library/stdlib_atoi.c @@ -1,5 +1,5 @@ /* - * $Id: stdlib_atoi.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdlib_atoi.c,v 1.3 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -54,7 +54,7 @@ atoi(const char *str) { if(str == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/stdlib_atol.c b/library/stdlib_atol.c index 2ba9aaa..9d74d6c 100644 --- a/library/stdlib_atol.c +++ b/library/stdlib_atol.c @@ -1,5 +1,5 @@ /* - * $Id: stdlib_atol.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdlib_atol.c,v 1.3 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -54,7 +54,7 @@ atol(const char *str) { if(str == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/stdlib_bsearch.c b/library/stdlib_bsearch.c index a31eaa9..71774cb 100644 --- a/library/stdlib_bsearch.c +++ b/library/stdlib_bsearch.c @@ -1,5 +1,5 @@ /* - * $Id: stdlib_bsearch.c,v 1.2 2005-01-02 09:07:08 obarthel Exp $ + * $Id: stdlib_bsearch.c,v 1.3 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -72,7 +72,7 @@ bsearch(const void *key, const void *base, size_t count, size_t size, int (*comp { SHOWMSG("invalid parameters"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/stdlib_get_errno.c b/library/stdlib_get_errno.c new file mode 100644 index 0000000..2d7b2c0 --- /dev/null +++ b/library/stdlib_get_errno.c @@ -0,0 +1,44 @@ +/* + * $Id: stdlib_get_errno.c,v 1.1 2005-02-03 16:56:16 obarthel Exp $ + * + * :ts=4 + * + * Portable ISO 'C' (1994) runtime library for the Amiga computer + * Copyright (c) 2002-2005 by Olaf Barthel + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Neither the name of Olaf Barthel nor the names of contributors + * may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _STDLIB_HEADERS_H +#include "stdlib_headers.h" +#endif /* _STDLIB_HEADERS_H */ + +/****************************************************************************/ + +int +__get_errno(void) +{ + return(errno); +} diff --git a/library/stdlib_getenv.c b/library/stdlib_getenv.c index 5d12cd0..707577b 100644 --- a/library/stdlib_getenv.c +++ b/library/stdlib_getenv.c @@ -1,5 +1,5 @@ /* - * $Id: stdlib_getenv.c,v 1.2 2005-01-02 09:07:18 obarthel Exp $ + * $Id: stdlib_getenv.c,v 1.3 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -61,7 +61,7 @@ getenv(const char * name) { SHOWMSG("invalid name parameter"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -74,7 +74,7 @@ getenv(const char * name) { SHOWMSG("couldn't get the variable"); - __translate_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_io_error_to_errno(IoErr())); goto out; } diff --git a/library/stdlib_malloc.c b/library/stdlib_malloc.c index ad6ca3f..7c9a409 100644 --- a/library/stdlib_malloc.c +++ b/library/stdlib_malloc.c @@ -1,5 +1,5 @@ /* - * $Id: stdlib_malloc.c,v 1.6 2005-01-09 15:58:02 obarthel Exp $ + * $Id: stdlib_malloc.c,v 1.7 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -100,7 +100,7 @@ __allocate_memory(size_t size,BOOL never_free,const char * UNUSED file,int UNUSE { SHOWMSG("not enough free memory available to safely proceed with allocation"); - errno = ENOMEM; + __set_errno(ENOMEM); goto out; } @@ -130,7 +130,7 @@ __allocate_memory(size_t size,BOOL never_free,const char * UNUSED file,int UNUSE { SHOWMSG("not enough memory"); - errno = ENOMEM; + __set_errno(ENOMEM); goto out; } diff --git a/library/stdlib_mkdtemp.c b/library/stdlib_mkdtemp.c index 73a3ac0..567e204 100644 --- a/library/stdlib_mkdtemp.c +++ b/library/stdlib_mkdtemp.c @@ -1,5 +1,5 @@ /* - * $Id: stdlib_mkdtemp.c,v 1.3 2005-01-02 09:07:18 obarthel Exp $ + * $Id: stdlib_mkdtemp.c,v 1.4 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -68,7 +68,7 @@ mkdtemp(char *name_template) { SHOWMSG("invalid name template"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/stdlib_mkstemp.c b/library/stdlib_mkstemp.c index eab8292..b535bce 100644 --- a/library/stdlib_mkstemp.c +++ b/library/stdlib_mkstemp.c @@ -1,5 +1,5 @@ /* - * $Id: stdlib_mkstemp.c,v 1.3 2005-01-02 09:07:18 obarthel Exp $ + * $Id: stdlib_mkstemp.c,v 1.4 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -68,7 +68,7 @@ mkstemp(char *name_template) { SHOWMSG("invalid name template"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/stdlib_mktemp.c b/library/stdlib_mktemp.c index 22e98ba..4d559e4 100644 --- a/library/stdlib_mktemp.c +++ b/library/stdlib_mktemp.c @@ -1,5 +1,5 @@ /* - * $Id: stdlib_mktemp.c,v 1.5 2005-01-02 09:07:18 obarthel Exp $ + * $Id: stdlib_mktemp.c,v 1.6 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -85,7 +85,7 @@ mktemp(char * name_template) { SHOWMSG("invalid name template"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -102,7 +102,7 @@ mktemp(char * name_template) { SHOWMSG("invalid name template"); - errno = EINVAL; + __set_errno(EINVAL); goto out; } @@ -133,7 +133,7 @@ mktemp(char * name_template) { SHOWMSG("invalid name template"); - errno = EINVAL; + __set_errno(EINVAL); goto out; } @@ -183,7 +183,7 @@ mktemp(char * name_template) if(name_template_nti.is_root) { - errno = EACCES; + __set_errno(EACCES); goto out; } } @@ -213,7 +213,7 @@ mktemp(char * name_template) } /* Looks like a serious error. */ - __translate_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_io_error_to_errno(IoErr())); goto out; } diff --git a/library/stdlib_protos.h b/library/stdlib_protos.h index 00b555f..ace3018 100644 --- a/library/stdlib_protos.h +++ b/library/stdlib_protos.h @@ -1,5 +1,5 @@ /* - * $Id: stdlib_protos.h,v 1.6 2005-01-02 09:07:18 obarthel Exp $ + * $Id: stdlib_protos.h,v 1.7 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -190,4 +190,14 @@ APTR __set_process_window(APTR new_window_pointer); /****************************************************************************/ +/* stdlib_set_errno.c */ +void __set_errno(int new_errno); + +/****************************************************************************/ + +/* stdlib_get_errno.c */ +int __get_errno(void); + +/****************************************************************************/ + #endif /* _STDLIB_PROTOS_H */ diff --git a/library/stdlib_putenv.c b/library/stdlib_putenv.c index d17ce6a..4e0dc8d 100644 --- a/library/stdlib_putenv.c +++ b/library/stdlib_putenv.c @@ -1,5 +1,5 @@ /* - * $Id: stdlib_putenv.c,v 1.3 2005-01-02 09:07:18 obarthel Exp $ + * $Id: stdlib_putenv.c,v 1.4 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -64,7 +64,7 @@ putenv(const char *string) { SHOWMSG("invalid string"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/stdlib_qsort.c b/library/stdlib_qsort.c index e8fc5be..7303b5b 100644 --- a/library/stdlib_qsort.c +++ b/library/stdlib_qsort.c @@ -1,5 +1,5 @@ /* - * $Id: stdlib_qsort.c,v 1.3 2005-01-02 09:07:18 obarthel Exp $ + * $Id: stdlib_qsort.c,v 1.4 2005-02-03 16:56:16 obarthel Exp $ * * :ts=4 * @@ -168,7 +168,7 @@ qsort(void * base, size_t count, size_t size, int (*comp)(const void * element1, { SHOWMSG("invalid parameters"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/stdlib_realloc.c b/library/stdlib_realloc.c index 3209010..3fb0b38 100644 --- a/library/stdlib_realloc.c +++ b/library/stdlib_realloc.c @@ -1,5 +1,5 @@ /* - * $Id: stdlib_realloc.c,v 1.4 2005-01-02 09:07:18 obarthel Exp $ + * $Id: stdlib_realloc.c,v 1.5 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -95,7 +95,7 @@ __realloc(void *ptr,size_t size,const char * file,int line) /* Apparently, the address did not qualify for * reallocation. */ - errno = ENOMEM; + __set_errno(ENOMEM); goto out; } } @@ -109,7 +109,7 @@ __realloc(void *ptr,size_t size,const char * file,int line) { SHOWMSG("cannot free this chunk"); - errno = ENOMEM; + __set_errno(ENOMEM); goto out; } @@ -163,7 +163,7 @@ __realloc(void *ptr,size_t size,const char * file,int line) { SHOWMSG("could not reallocate memory"); - errno = ENOMEM; + __set_errno(ENOMEM); goto out; } diff --git a/library/stdlib_set_errno.c b/library/stdlib_set_errno.c new file mode 100644 index 0000000..9170daa --- /dev/null +++ b/library/stdlib_set_errno.c @@ -0,0 +1,44 @@ +/* + * $Id: stdlib_set_errno.c,v 1.1 2005-02-03 16:56:17 obarthel Exp $ + * + * :ts=4 + * + * Portable ISO 'C' (1994) runtime library for the Amiga computer + * Copyright (c) 2002-2005 by Olaf Barthel + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Neither the name of Olaf Barthel nor the names of contributors + * may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _STDLIB_HEADERS_H +#include "stdlib_headers.h" +#endif /* _STDLIB_HEADERS_H */ + +/****************************************************************************/ + +void +__set_errno(int new_errno) +{ + errno = new_errno; +} diff --git a/library/stdlib_setenv.c b/library/stdlib_setenv.c index 05bceeb..dc3bc61 100644 --- a/library/stdlib_setenv.c +++ b/library/stdlib_setenv.c @@ -1,5 +1,5 @@ /* - * $Id: stdlib_setenv.c,v 1.5 2005-01-09 10:10:41 obarthel Exp $ + * $Id: stdlib_setenv.c,v 1.6 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -112,7 +112,7 @@ setenv(const char *original_name, const char *original_value, int overwrite) { SHOWMSG("invalid parameters"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -170,7 +170,7 @@ setenv(const char *original_name, const char *original_value, int overwrite) { SHOWMSG("invalid name"); - errno = EINVAL; + __set_errno(EINVAL); goto out; } @@ -233,7 +233,7 @@ setenv(const char *original_name, const char *original_value, int overwrite) free(lv); } - __translate_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_io_error_to_errno(IoErr())); goto out; } diff --git a/library/stdlib_strtod.c b/library/stdlib_strtod.c index 8ccb18c..6be4202 100644 --- a/library/stdlib_strtod.c +++ b/library/stdlib_strtod.c @@ -1,5 +1,5 @@ /* - * $Id: stdlib_strtod.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $ + * $Id: stdlib_strtod.c,v 1.3 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -55,6 +55,14 @@ #if defined(FLOATING_POINT_SUPPORT) +/****************************************************************************/ + +#ifndef _MATH_HEADERS_H +#include "math_headers.h" +#endif /* _MATH_HEADERS_H */ + +/****************************************************************************/ + double strtod(const char *str, char ** ptr) { @@ -79,8 +87,9 @@ strtod(const char *str, char ** ptr) { SHOWMSG("invalid str parameter"); - result = HUGE_VAL; - errno = EFAULT; + __set_errno(EFAULT); + + result = __get_huge_val(); goto out; } } @@ -282,9 +291,9 @@ strtod(const char *str, char ** ptr) if(error != 0) { - errno = error; + __set_errno(error); - sum = HUGE_VAL; + sum = __get_huge_val(); } if(is_negative) @@ -304,4 +313,6 @@ strtod(const char *str, char ** ptr) return(result); } +/****************************************************************************/ + #endif /* FLOATING_POINT_SUPPORT */ diff --git a/library/stdlib_strtol.c b/library/stdlib_strtol.c index 985ca4a..e978d51 100644 --- a/library/stdlib_strtol.c +++ b/library/stdlib_strtol.c @@ -1,5 +1,5 @@ /* - * $Id: stdlib_strtol.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $ + * $Id: stdlib_strtol.c,v 1.3 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -66,7 +66,7 @@ strtol(const char *str, char **ptr, int base) { SHOWMSG("invalid str parameter"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -76,7 +76,7 @@ strtol(const char *str, char **ptr, int base) { SHOWMSG("invalid base parameter"); - errno = ERANGE; + __set_errno(ERANGE); goto out; } @@ -160,7 +160,7 @@ strtol(const char *str, char **ptr, int base) new_sum = base * sum + c; if(new_sum < sum) /* overflow? */ { - errno = ERANGE; + __set_errno(ERANGE); if(is_negative) result = LONG_MIN; diff --git a/library/stdlib_strtoll.c b/library/stdlib_strtoll.c index 90caceb..59570a1 100644 --- a/library/stdlib_strtoll.c +++ b/library/stdlib_strtoll.c @@ -1,5 +1,5 @@ /* - * $Id: stdlib_strtoll.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $ + * $Id: stdlib_strtoll.c,v 1.3 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -70,7 +70,7 @@ strtoll(const char *str, char **ptr, int base) { SHOWMSG("invalid str parameter"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -80,7 +80,7 @@ strtoll(const char *str, char **ptr, int base) { SHOWMSG("invalid base parameter"); - errno = ERANGE; + __set_errno(ERANGE); goto out; } @@ -164,7 +164,7 @@ strtoll(const char *str, char **ptr, int base) new_sum = base * sum + c; if(new_sum < sum) /* overflow? */ { - errno = ERANGE; + __set_errno(ERANGE); if(is_negative) result = LONG_MIN; diff --git a/library/stdlib_strtoul.c b/library/stdlib_strtoul.c index 736131d..4f8f596 100644 --- a/library/stdlib_strtoul.c +++ b/library/stdlib_strtoul.c @@ -1,5 +1,5 @@ /* - * $Id: stdlib_strtoul.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $ + * $Id: stdlib_strtoul.c,v 1.3 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -66,7 +66,7 @@ strtoul(const char *str, char **ptr, int base) { SHOWMSG("invalid str parameter"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -76,7 +76,7 @@ strtoul(const char *str, char **ptr, int base) { SHOWMSG("invalid base parameter"); - errno = ERANGE; + __set_errno(ERANGE); goto out; } @@ -160,7 +160,7 @@ strtoul(const char *str, char **ptr, int base) new_sum = base * sum + c; if(new_sum < sum) /* overflow? */ { - errno = ERANGE; + __set_errno(ERANGE); result = ULONG_MAX; diff --git a/library/stdlib_strtoull.c b/library/stdlib_strtoull.c index a501796..c44d2a8 100644 --- a/library/stdlib_strtoull.c +++ b/library/stdlib_strtoull.c @@ -1,5 +1,5 @@ /* - * $Id: stdlib_strtoull.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $ + * $Id: stdlib_strtoull.c,v 1.3 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -70,7 +70,7 @@ strtoull(const char *str, char **ptr, int base) { SHOWMSG("invalid str parameter"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -80,7 +80,7 @@ strtoull(const char *str, char **ptr, int base) { SHOWMSG("invalid base parameter"); - errno = ERANGE; + __set_errno(ERANGE); goto out; } @@ -164,7 +164,7 @@ strtoull(const char *str, char **ptr, int base) new_sum = base * sum + c; if(new_sum < sum) /* overflow? */ { - errno = ERANGE; + __set_errno(ERANGE); result = ULONG_MAX; diff --git a/library/stdlib_system.c b/library/stdlib_system.c index a84d343..478b80e 100644 --- a/library/stdlib_system.c +++ b/library/stdlib_system.c @@ -1,5 +1,5 @@ /* - * $Id: stdlib_system.c,v 1.3 2005-01-09 10:10:41 obarthel Exp $ + * $Id: stdlib_system.c,v 1.4 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -116,7 +116,7 @@ system(const char * command) /* This may be too long for proper translation... */ if(command_len > MAXPATHLEN) { - errno = ENAMETOOLONG; + __set_errno(ENAMETOOLONG); result = -1; goto out; @@ -144,7 +144,8 @@ system(const char * command) command_copy = malloc(1 + strlen(command_name) + 1 + strlen(&command[command_len]) + 1); if(command_copy == NULL) { - errno = ENOMEM; + __set_errno(ENOMEM); + result = -1; goto out; } diff --git a/library/stdlib_unsetenv.c b/library/stdlib_unsetenv.c index 2ceaa5c..05801ff 100644 --- a/library/stdlib_unsetenv.c +++ b/library/stdlib_unsetenv.c @@ -1,5 +1,5 @@ /* - * $Id: stdlib_unsetenv.c,v 1.3 2005-01-02 09:07:19 obarthel Exp $ + * $Id: stdlib_unsetenv.c,v 1.4 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -68,7 +68,7 @@ unsetenv(const char *original_name) { if(name == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/string_memchr.c b/library/string_memchr.c index 8dc98be..8d265d4 100644 --- a/library/string_memchr.c +++ b/library/string_memchr.c @@ -1,5 +1,5 @@ /* - * $Id: string_memchr.c,v 1.3 2005-01-02 09:07:19 obarthel Exp $ + * $Id: string_memchr.c,v 1.4 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -182,7 +182,7 @@ memchr(const void * ptr, int val, size_t len) { if(ptr == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/string_memcmp.c b/library/string_memcmp.c index 943092c..a5b09ed 100644 --- a/library/string_memcmp.c +++ b/library/string_memcmp.c @@ -1,5 +1,5 @@ /* - * $Id: string_memcmp.c,v 1.4 2005-01-02 09:07:19 obarthel Exp $ + * $Id: string_memcmp.c,v 1.5 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -168,7 +168,7 @@ memcmp(const void *ptr1, const void *ptr2, size_t len) { if(ptr1 == NULL || ptr2 == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/string_memcpy.c b/library/string_memcpy.c index 85a5832..d4b205e 100644 --- a/library/string_memcpy.c +++ b/library/string_memcpy.c @@ -1,5 +1,5 @@ /* - * $Id: string_memcpy.c,v 1.4 2005-01-02 09:07:19 obarthel Exp $ + * $Id: string_memcpy.c,v 1.5 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -203,7 +203,7 @@ memcpy(void *dst, const void *src, size_t len) { if(dst == NULL || src == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -343,7 +343,7 @@ memcpy(void *dst, const void *src, size_t len) { if(dst == NULL || src == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/string_memmove.c b/library/string_memmove.c index 9cc5a9d..486fb77 100644 --- a/library/string_memmove.c +++ b/library/string_memmove.c @@ -1,5 +1,5 @@ /* - * $Id: string_memmove.c,v 1.3 2005-01-02 09:07:19 obarthel Exp $ + * $Id: string_memmove.c,v 1.4 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -331,7 +331,7 @@ memmove(void *dest, const void * src, size_t len) { if(dest == NULL || src == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -573,7 +573,7 @@ memmove(void *dest, const void * src, size_t len) { if(dest == NULL || src == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/string_memset.c b/library/string_memset.c index 0f9b950..579ef25 100644 --- a/library/string_memset.c +++ b/library/string_memset.c @@ -1,5 +1,5 @@ /* - * $Id: string_memset.c,v 1.4 2005-01-02 09:07:19 obarthel Exp $ + * $Id: string_memset.c,v 1.5 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -146,7 +146,7 @@ memset(void *ptr, int val, size_t len) { if(ptr == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/string_strcat.c b/library/string_strcat.c index 042b84e..16de5bd 100644 --- a/library/string_strcat.c +++ b/library/string_strcat.c @@ -1,5 +1,5 @@ /* - * $Id: string_strcat.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $ + * $Id: string_strcat.c,v 1.3 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -54,7 +54,7 @@ strcat(char *dest, const char *src) { if(dest == NULL || src == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/string_strchr.c b/library/string_strchr.c index 5a947a2..a90d7df 100644 --- a/library/string_strchr.c +++ b/library/string_strchr.c @@ -1,5 +1,5 @@ /* - * $Id: string_strchr.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $ + * $Id: string_strchr.c,v 1.3 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -57,7 +57,7 @@ strchr(const char *s, int c) { if(us == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/string_strcmp.c b/library/string_strcmp.c index d3edd25..584ad39 100644 --- a/library/string_strcmp.c +++ b/library/string_strcmp.c @@ -1,5 +1,5 @@ /* - * $Id: string_strcmp.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $ + * $Id: string_strcmp.c,v 1.3 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -54,7 +54,7 @@ strcmp(const char *s1, const char * s2) { if(s1 == NULL || s2 == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/string_strcoll.c b/library/string_strcoll.c index 7c35249..018b949 100644 --- a/library/string_strcoll.c +++ b/library/string_strcoll.c @@ -1,5 +1,5 @@ /* - * $Id: string_strcoll.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $ + * $Id: string_strcoll.c,v 1.3 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -59,7 +59,7 @@ strcoll(const char *s1, const char *s2) { if(s1 == NULL || s2 == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/string_strcpy.c b/library/string_strcpy.c index 163c49f..c93b058 100644 --- a/library/string_strcpy.c +++ b/library/string_strcpy.c @@ -1,5 +1,5 @@ /* - * $Id: string_strcpy.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $ + * $Id: string_strcpy.c,v 1.3 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -54,7 +54,7 @@ strcpy(char *dest, const char *src) { if(dest == NULL || src == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/string_strcspn.c b/library/string_strcspn.c index f8b27a6..f868964 100644 --- a/library/string_strcspn.c +++ b/library/string_strcspn.c @@ -1,5 +1,5 @@ /* - * $Id: string_strcspn.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $ + * $Id: string_strcspn.c,v 1.3 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -56,7 +56,7 @@ strcspn(const char *s, const char *set) { if(s == NULL || set == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/string_strdup.c b/library/string_strdup.c index f70d79b..8181a29 100644 --- a/library/string_strdup.c +++ b/library/string_strdup.c @@ -1,5 +1,5 @@ /* - * $Id: string_strdup.c,v 1.5 2005-01-02 09:07:19 obarthel Exp $ + * $Id: string_strdup.c,v 1.6 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -69,7 +69,7 @@ __strdup(const char *s,const char * file,int line) { if(s == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/string_strlcat.c b/library/string_strlcat.c index 34bd5f9..26ffb45 100644 --- a/library/string_strlcat.c +++ b/library/string_strlcat.c @@ -1,5 +1,5 @@ /* - * $Id: string_strlcat.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $ + * $Id: string_strlcat.c,v 1.3 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -96,7 +96,7 @@ strlcat(char *dst, const char *src, size_t siz) { if(src == NULL || (siz != 0 && dst == NULL)) { - errno = EFAULT; + __set_errno(EFAULT); result = 0; goto out; diff --git a/library/string_strlcpy.c b/library/string_strlcpy.c index f9ec0d0..2da4ca3 100644 --- a/library/string_strlcpy.c +++ b/library/string_strlcpy.c @@ -1,5 +1,5 @@ /* - * $Id: string_strlcpy.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $ + * $Id: string_strlcpy.c,v 1.3 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -93,7 +93,7 @@ strlcpy(char *dst, const char *src, size_t siz) { if(siz != 0 && (dst == NULL || src == NULL)) { - errno = EFAULT; + __set_errno(EFAULT); result = 0; goto out; diff --git a/library/string_strlen.c b/library/string_strlen.c index a6ac04b..c62d1f7 100644 --- a/library/string_strlen.c +++ b/library/string_strlen.c @@ -1,5 +1,5 @@ /* - * $Id: string_strlen.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $ + * $Id: string_strlen.c,v 1.3 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -55,7 +55,7 @@ strlen(const char *s) { if(s == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/string_strncat.c b/library/string_strncat.c index ea3a16e..6eb5c20 100644 --- a/library/string_strncat.c +++ b/library/string_strncat.c @@ -1,5 +1,5 @@ /* - * $Id: string_strncat.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $ + * $Id: string_strncat.c,v 1.3 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -55,7 +55,7 @@ strncat(char *dest, const char *src, size_t n) { if(dest == NULL || src == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/string_strncmp.c b/library/string_strncmp.c index 0702124..4a0b4e1 100644 --- a/library/string_strncmp.c +++ b/library/string_strncmp.c @@ -1,5 +1,5 @@ /* - * $Id: string_strncmp.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $ + * $Id: string_strncmp.c,v 1.3 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -55,7 +55,7 @@ strncmp(const char *s1, const char *s2, size_t n) { if(s1 == NULL || s2 == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/string_strncpy.c b/library/string_strncpy.c index a47282b..0a58b3e 100644 --- a/library/string_strncpy.c +++ b/library/string_strncpy.c @@ -1,5 +1,5 @@ /* - * $Id: string_strncpy.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $ + * $Id: string_strncpy.c,v 1.3 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -55,7 +55,7 @@ strncpy(char *dest, const char *src, size_t n) { if(dest == NULL || src == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/string_strpbrk.c b/library/string_strpbrk.c index 8f4a78e..138c723 100644 --- a/library/string_strpbrk.c +++ b/library/string_strpbrk.c @@ -1,5 +1,5 @@ /* - * $Id: string_strpbrk.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $ + * $Id: string_strpbrk.c,v 1.3 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -55,7 +55,7 @@ strpbrk(const char *s, const char *set) { if(s == NULL || set == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/string_strrchr.c b/library/string_strrchr.c index 114665c..8e10d77 100644 --- a/library/string_strrchr.c +++ b/library/string_strrchr.c @@ -1,5 +1,5 @@ /* - * $Id: string_strrchr.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $ + * $Id: string_strrchr.c,v 1.3 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -57,7 +57,7 @@ strrchr(const char *s, int c) { if(us == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/string_strspn.c b/library/string_strspn.c index 9608551..02aa030 100644 --- a/library/string_strspn.c +++ b/library/string_strspn.c @@ -1,5 +1,5 @@ /* - * $Id: string_strspn.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $ + * $Id: string_strspn.c,v 1.3 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -56,7 +56,7 @@ strspn(const char *s, const char *set) { if(s == NULL || set == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/string_strstr.c b/library/string_strstr.c index 517b33d..4b0a9a3 100644 --- a/library/string_strstr.c +++ b/library/string_strstr.c @@ -1,5 +1,5 @@ /* - * $Id: string_strstr.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $ + * $Id: string_strstr.c,v 1.3 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -54,7 +54,7 @@ strstr(const char *src, const char *sub) { if(src == NULL || sub == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/string_strtok_r.c b/library/string_strtok_r.c index 869b4d5..b0918d9 100644 --- a/library/string_strtok_r.c +++ b/library/string_strtok_r.c @@ -1,5 +1,5 @@ /* - * $Id: string_strtok_r.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $ + * $Id: string_strtok_r.c,v 1.3 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -56,7 +56,7 @@ strtok_r(char *str, const char *separator_set,char ** state_ptr) { if(separator_set == NULL || state_ptr == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/string_strxfrm.c b/library/string_strxfrm.c index 8cfe83b..f1d0388 100644 --- a/library/string_strxfrm.c +++ b/library/string_strxfrm.c @@ -1,5 +1,5 @@ /* - * $Id: string_strxfrm.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $ + * $Id: string_strxfrm.c,v 1.3 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -67,7 +67,7 @@ strxfrm(char *dest, const char *src, size_t len) { SHOWMSG("invalid parameters"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/strings_strcasecmp.c b/library/strings_strcasecmp.c index 295bd89..202575b 100644 --- a/library/strings_strcasecmp.c +++ b/library/strings_strcasecmp.c @@ -1,5 +1,5 @@ /* - * $Id: strings_strcasecmp.c,v 1.3 2005-01-02 09:07:19 obarthel Exp $ + * $Id: strings_strcasecmp.c,v 1.4 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -60,7 +60,7 @@ strcasecmp(const char * _s1, const char * _s2) { if(s1 == NULL || s2 == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/strings_strncasecmp.c b/library/strings_strncasecmp.c index 5887ae1..395f0ac 100644 --- a/library/strings_strncasecmp.c +++ b/library/strings_strncasecmp.c @@ -1,5 +1,5 @@ /* - * $Id: strings_strncasecmp.c,v 1.3 2005-01-02 09:07:19 obarthel Exp $ + * $Id: strings_strncasecmp.c,v 1.4 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -62,7 +62,7 @@ strncasecmp(const char * _s1, const char * _s2,size_t n) { if(s1 == NULL || s2 == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/time_asctime_r.c b/library/time_asctime_r.c index 1456f78..e5e0714 100644 --- a/library/time_asctime_r.c +++ b/library/time_asctime_r.c @@ -1,5 +1,5 @@ /* - * $Id: time_asctime_r.c,v 1.5 2005-01-30 09:37:59 obarthel Exp $ + * $Id: time_asctime_r.c,v 1.6 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -85,7 +85,7 @@ __asctime_r(const struct tm *tm,char * buffer,size_t buffer_size) { if(tm == NULL || buffer == NULL ) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/time_ctime.c b/library/time_ctime.c index eed9f71..fcd47fa 100644 --- a/library/time_ctime.c +++ b/library/time_ctime.c @@ -1,5 +1,5 @@ /* - * $Id: time_ctime.c,v 1.4 2005-01-02 09:07:19 obarthel Exp $ + * $Id: time_ctime.c,v 1.5 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -58,7 +58,7 @@ ctime(const time_t *tptr) { SHOWMSG("invalid tptr parameter"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/time_ctime_r.c b/library/time_ctime_r.c index bf4f86a..e0b98a8 100644 --- a/library/time_ctime_r.c +++ b/library/time_ctime_r.c @@ -1,5 +1,5 @@ /* - * $Id: time_ctime_r.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $ + * $Id: time_ctime_r.c,v 1.3 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -57,7 +57,7 @@ ctime_r(const time_t *tptr,char * buffer) { if(tptr == NULL || buffer == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/time_gmtime_r.c b/library/time_gmtime_r.c index 7971950..38ffc28 100644 --- a/library/time_gmtime_r.c +++ b/library/time_gmtime_r.c @@ -1,5 +1,5 @@ /* - * $Id: time_gmtime_r.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $ + * $Id: time_gmtime_r.c,v 1.3 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -56,7 +56,7 @@ gmtime_r(const time_t *t,struct tm * tm_ptr) { if(t == NULL || tm_ptr == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/time_localtime_r.c b/library/time_localtime_r.c index 79fc55e..5358220 100644 --- a/library/time_localtime_r.c +++ b/library/time_localtime_r.c @@ -1,5 +1,5 @@ /* - * $Id: time_localtime_r.c,v 1.3 2005-01-25 11:21:00 obarthel Exp $ + * $Id: time_localtime_r.c,v 1.4 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -61,7 +61,7 @@ localtime_r(const time_t *t,struct tm * tm_ptr) { if(t == NULL || tm_ptr == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/time_mktime.c b/library/time_mktime.c index 973b53f..3ef79b0 100644 --- a/library/time_mktime.c +++ b/library/time_mktime.c @@ -1,5 +1,5 @@ /* - * $Id: time_mktime.c,v 1.6 2005-01-30 16:10:59 obarthel Exp $ + * $Id: time_mktime.c,v 1.7 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -67,7 +67,7 @@ mktime(struct tm *tm) { SHOWMSG("invalid tm parameter"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/time_strftime.c b/library/time_strftime.c index dacd07e..152ac14 100644 --- a/library/time_strftime.c +++ b/library/time_strftime.c @@ -1,5 +1,5 @@ /* - * $Id: time_strftime.c,v 1.6 2005-01-30 09:37:59 obarthel Exp $ + * $Id: time_strftime.c,v 1.7 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -378,7 +378,7 @@ strftime(char *s, size_t maxsize, const char *format, const struct tm *tm) { SHOWMSG("invalid parameters"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/unistd_access.c b/library/unistd_access.c index e10dfe0..1f101a9 100644 --- a/library/unistd_access.c +++ b/library/unistd_access.c @@ -1,5 +1,5 @@ /* - * $Id: unistd_access.c,v 1.3 2005-01-02 09:07:19 obarthel Exp $ + * $Id: unistd_access.c,v 1.4 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -69,7 +69,7 @@ access(const char * path_name, int mode) { SHOWMSG("invalid path name"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -82,7 +82,7 @@ access(const char * path_name, int mode) { SHOWMSG("invalid mode"); - errno = EINVAL; + __set_errno(EINVAL); goto out; } @@ -106,7 +106,7 @@ access(const char * path_name, int mode) lock = Lock(actual_path_name,SHARED_LOCK); if(lock == ZERO) { - __translate_access_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_access_io_error_to_errno(IoErr())); goto out; } } @@ -121,7 +121,7 @@ access(const char * path_name, int mode) if(lock == ZERO) { - __translate_access_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_access_io_error_to_errno(IoErr())); goto out; } } @@ -155,7 +155,7 @@ access(const char * path_name, int mode) { SHOWMSG("couldn't examine"); - __translate_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_io_error_to_errno(IoErr())); goto out; } } @@ -172,7 +172,7 @@ access(const char * path_name, int mode) { SHOWMSG("couldn't examine"); - __translate_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_io_error_to_errno(IoErr())); goto out; } } @@ -186,7 +186,7 @@ access(const char * path_name, int mode) { SHOWMSG("not readable"); - errno = EACCES; + __set_errno(EACCES); goto out; } } @@ -198,7 +198,7 @@ access(const char * path_name, int mode) { SHOWMSG("not writable"); - errno = EACCES; + __set_errno(EACCES); goto out; } } @@ -212,7 +212,7 @@ access(const char * path_name, int mode) { SHOWMSG("not executable"); - errno = EACCES; + __set_errno(EACCES); goto out; } } diff --git a/library/unistd_chdir.c b/library/unistd_chdir.c index c6f56ba..3260da3 100644 --- a/library/unistd_chdir.c +++ b/library/unistd_chdir.c @@ -1,5 +1,5 @@ /* - * $Id: unistd_chdir.c,v 1.3 2005-01-02 09:07:19 obarthel Exp $ + * $Id: unistd_chdir.c,v 1.4 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -70,7 +70,7 @@ chdir(const char * path_name) { SHOWMSG("invalid path name"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -115,7 +115,7 @@ chdir(const char * path_name) if(dir_lock == ZERO) { - __translate_access_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_access_io_error_to_errno(IoErr())); goto out; } @@ -125,7 +125,7 @@ chdir(const char * path_name) if(status == DOSFALSE) { - __translate_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_io_error_to_errno(IoErr())); goto out; } @@ -133,7 +133,7 @@ chdir(const char * path_name) { SHOWMSG("this is not a directory"); - errno = ENOTDIR; + __set_errno(ENOTDIR); goto out; } diff --git a/library/unistd_chown.c b/library/unistd_chown.c index abb011c..96aa276 100644 --- a/library/unistd_chown.c +++ b/library/unistd_chown.c @@ -1,5 +1,5 @@ /* - * $Id: unistd_chown.c,v 1.4 2005-01-09 15:58:02 obarthel Exp $ + * $Id: unistd_chown.c,v 1.5 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -71,7 +71,7 @@ chown(const char * path_name, uid_t owner, gid_t group) { SHOWMSG("invalid path name"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -84,7 +84,7 @@ chown(const char * path_name, uid_t owner, gid_t group) { SHOWMSG("invalid owner or group"); - errno = EINVAL; + __set_errno(EINVAL); goto out; } @@ -97,7 +97,7 @@ chown(const char * path_name, uid_t owner, gid_t group) if(path_name_nti.is_root) { - errno = EACCES; + __set_errno(EACCES); goto out; } } @@ -128,7 +128,7 @@ chown(const char * path_name, uid_t owner, gid_t group) len = strlen(path_name); if(len >= sizeof(new_name->name)) { - errno = ENAMETOOLONG; + __set_errno(ENAMETOOLONG); goto out; } @@ -138,7 +138,7 @@ chown(const char * path_name, uid_t owner, gid_t group) if(dvp == NULL) { - __translate_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_io_error_to_errno(IoErr())); goto out; } @@ -154,7 +154,7 @@ chown(const char * path_name, uid_t owner, gid_t group) if(status == DOSFALSE) { - __translate_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_io_error_to_errno(IoErr())); goto out; } diff --git a/library/unistd_dup2.c b/library/unistd_dup2.c index f6d1edc..41663c1 100644 --- a/library/unistd_dup2.c +++ b/library/unistd_dup2.c @@ -1,5 +1,5 @@ /* - * $Id: unistd_dup2.c,v 1.3 2005-01-02 09:07:19 obarthel Exp $ + * $Id: unistd_dup2.c,v 1.4 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -65,7 +65,7 @@ dup2(int file_descriptor1, int file_descriptor2) fd1 = __get_file_descriptor(file_descriptor1); if(fd1 == NULL) { - errno = EBADF; + __set_errno(EBADF); goto out; } @@ -135,7 +135,7 @@ dup2(int file_descriptor1, int file_descriptor2) result = message.result; if(result != 0) { - errno = message.error; + __set_errno(message.error); goto out; } } diff --git a/library/unistd_fchown.c b/library/unistd_fchown.c index aecc1a6..a057569 100644 --- a/library/unistd_fchown.c +++ b/library/unistd_fchown.c @@ -1,5 +1,5 @@ /* - * $Id: unistd_fchown.c,v 1.3 2005-01-02 09:07:19 obarthel Exp $ + * $Id: unistd_fchown.c,v 1.4 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -67,7 +67,7 @@ fchown(int file_descriptor, uid_t owner, gid_t group) fd = __get_file_descriptor(file_descriptor); if(fd == NULL) { - errno = EBADF; + __set_errno(EBADF); goto out; } @@ -81,8 +81,9 @@ fchown(int file_descriptor, uid_t owner, gid_t group) CallHookPkt(fd->fd_Hook,fd,&message); - result = message.result; - errno = message.error; + result = message.result; + + __set_errno(message.error); out: diff --git a/library/unistd_fdopen.c b/library/unistd_fdopen.c index 94b6101..a569f4b 100644 --- a/library/unistd_fdopen.c +++ b/library/unistd_fdopen.c @@ -1,5 +1,5 @@ /* - * $Id: unistd_fdopen.c,v 1.3 2005-01-02 09:07:19 obarthel Exp $ + * $Id: unistd_fdopen.c,v 1.4 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -66,7 +66,7 @@ fdopen(int file_descriptor, const char * type) { SHOWMSG("invalid type parameter"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/unistd_fileno.c b/library/unistd_fileno.c index 393d902..7de10f0 100644 --- a/library/unistd_fileno.c +++ b/library/unistd_fileno.c @@ -1,5 +1,5 @@ /* - * $Id: unistd_fileno.c,v 1.3 2005-01-02 09:07:19 obarthel Exp $ + * $Id: unistd_fileno.c,v 1.4 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -65,7 +65,7 @@ fileno(FILE * file) { SHOWMSG("invalid file parameter"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -79,7 +79,7 @@ fileno(FILE * file) if(FLAG_IS_CLEAR(iob->iob_Flags,IOBF_IN_USE)) { - errno = EBADF; + __set_errno(EBADF); goto out; } diff --git a/library/unistd_ftruncate.c b/library/unistd_ftruncate.c index b1f81dd..54d4be7 100644 --- a/library/unistd_ftruncate.c +++ b/library/unistd_ftruncate.c @@ -1,5 +1,5 @@ /* - * $Id: unistd_ftruncate.c,v 1.3 2005-01-02 09:07:19 obarthel Exp $ + * $Id: unistd_ftruncate.c,v 1.4 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -67,7 +67,7 @@ ftruncate(int file_descriptor, off_t length) fd = __get_file_descriptor(file_descriptor); if(fd == NULL) { - errno = EBADF; + __set_errno(EBADF); goto out; } @@ -75,7 +75,7 @@ ftruncate(int file_descriptor, off_t length) { SHOWMSG("invalid length"); - errno = EINVAL; + __set_errno(EINVAL); goto out; } @@ -85,7 +85,7 @@ ftruncate(int file_descriptor, off_t length) { SHOWMSG("file descriptor is not write-enabled"); - errno = EBADF; + __set_errno(EBADF); goto out; } @@ -105,7 +105,7 @@ ftruncate(int file_descriptor, off_t length) if(message.result < 0) { - errno = message.error; + __set_errno(message.error); goto out; } diff --git a/library/unistd_getcwd.c b/library/unistd_getcwd.c index 11fcb72..3a4cd0a 100644 --- a/library/unistd_getcwd.c +++ b/library/unistd_getcwd.c @@ -1,5 +1,5 @@ /* - * $Id: unistd_getcwd.c,v 1.5 2005-01-02 09:07:19 obarthel Exp $ + * $Id: unistd_getcwd.c,v 1.6 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -87,7 +87,7 @@ __getcwd(char * buffer,size_t buffer_size,const char *file,int line) { SHOWMSG("invalid buffer parameter"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -104,7 +104,7 @@ __getcwd(char * buffer,size_t buffer_size,const char *file,int line) { SHOWMSG("could not get a lock on the current directory"); - __translate_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_io_error_to_errno(IoErr())); goto out; } @@ -122,7 +122,7 @@ __getcwd(char * buffer,size_t buffer_size,const char *file,int line) { SHOWMSG("not enough memory for result buffer"); - errno = ENOMEM; + __set_errno(ENOMEM); goto out; } @@ -135,7 +135,7 @@ __getcwd(char * buffer,size_t buffer_size,const char *file,int line) { if(buffer_size == 0) { - errno = ENOMEM; + __set_errno(ENOMEM); goto out; } @@ -163,7 +163,7 @@ __getcwd(char * buffer,size_t buffer_size,const char *file,int line) { SHOWMSG("could not get name from lock"); - __translate_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_io_error_to_errno(IoErr())); goto out; } @@ -176,7 +176,7 @@ __getcwd(char * buffer,size_t buffer_size,const char *file,int line) if(buffer_size == 0) { - errno = ENOMEM; + __set_errno(ENOMEM); goto out; } diff --git a/library/unistd_getopt.c b/library/unistd_getopt.c index df0e0b7..5cc64e4 100644 --- a/library/unistd_getopt.c +++ b/library/unistd_getopt.c @@ -1,5 +1,5 @@ /* - * $Id: unistd_getopt.c,v 1.3 2005-01-02 09:07:19 obarthel Exp $ + * $Id: unistd_getopt.c,v 1.4 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -76,7 +76,7 @@ getopt(int argc, char * argv[], char *opts) { SHOWMSG("invalid parameters"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/unistd_headers.h b/library/unistd_headers.h index a69d19f..41b1c3c 100644 --- a/library/unistd_headers.h +++ b/library/unistd_headers.h @@ -1,5 +1,5 @@ /* - * $Id: unistd_headers.h,v 1.5 2005-01-02 09:07:19 obarthel Exp $ + * $Id: unistd_headers.h,v 1.6 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -42,6 +42,12 @@ /****************************************************************************/ +#ifndef _STDLIB_HEADERS_H +#include "stdlib_headers.h" +#endif /* _STDLIB_HEADERS_H */ + +/****************************************************************************/ + extern char NOCOMMON __current_path_name[MAXPATHLEN]; /****************************************************************************/ diff --git a/library/unistd_isatty.c b/library/unistd_isatty.c index 80b9d80..b75885b 100644 --- a/library/unistd_isatty.c +++ b/library/unistd_isatty.c @@ -1,5 +1,5 @@ /* - * $Id: unistd_isatty.c,v 1.4 2005-01-02 09:07:19 obarthel Exp $ + * $Id: unistd_isatty.c,v 1.5 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -61,7 +61,7 @@ isatty(int file_descriptor) fd = __get_file_descriptor(file_descriptor); if(fd == NULL) { - errno = EBADF; + __set_errno(EBADF); goto out; } diff --git a/library/unistd_lchown.c b/library/unistd_lchown.c index d3d791e..f0a22c6 100644 --- a/library/unistd_lchown.c +++ b/library/unistd_lchown.c @@ -1,5 +1,5 @@ /* - * $Id: unistd_lchown.c,v 1.3 2005-01-02 09:07:19 obarthel Exp $ + * $Id: unistd_lchown.c,v 1.4 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -66,7 +66,7 @@ lchown(const char * path_name, uid_t owner, gid_t group) { SHOWMSG("invalid path name"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/unistd_link.c b/library/unistd_link.c index 3e4f346..7f35d23 100644 --- a/library/unistd_link.c +++ b/library/unistd_link.c @@ -1,5 +1,5 @@ /* - * $Id: unistd_link.c,v 1.3 2005-01-02 09:07:19 obarthel Exp $ + * $Id: unistd_link.c,v 1.4 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -71,7 +71,7 @@ link(const char * existing_path,const char * new_path) { SHOWMSG("invalid parameters"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -92,7 +92,7 @@ link(const char * existing_path,const char * new_path) if(existing_path_name_nti.is_root || new_path_name_nti.is_root) { - errno = EACCES; + __set_errno(EACCES); goto out; } } @@ -109,7 +109,7 @@ link(const char * existing_path,const char * new_path) { SHOWMSG("that didn't work"); - __translate_access_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_access_io_error_to_errno(IoErr())); goto out; } @@ -123,7 +123,7 @@ link(const char * existing_path,const char * new_path) { SHOWMSG("that didn't work"); - __translate_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_io_error_to_errno(IoErr())); goto out; } diff --git a/library/unistd_readlink.c b/library/unistd_readlink.c index 99fd4aa..b785a09 100644 --- a/library/unistd_readlink.c +++ b/library/unistd_readlink.c @@ -1,5 +1,5 @@ /* - * $Id: unistd_readlink.c,v 1.3 2005-01-02 09:07:19 obarthel Exp $ + * $Id: unistd_readlink.c,v 1.4 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -72,7 +72,7 @@ readlink(const char * path_name, char * buffer, int buffer_size) { SHOWSTRING("invalid parameters"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -108,7 +108,7 @@ readlink(const char * path_name, char * buffer, int buffer_size) { SHOWMSG("that didn't work"); - __translate_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_io_error_to_errno(IoErr())); goto out; } } @@ -124,7 +124,7 @@ readlink(const char * path_name, char * buffer, int buffer_size) { SHOWMSG("didn't get deviceproc"); - __translate_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_io_error_to_errno(IoErr())); goto out; } @@ -136,14 +136,14 @@ readlink(const char * path_name, char * buffer, int buffer_size) { SHOWMSG("couldn't read the link"); - __translate_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_io_error_to_errno(IoErr())); goto out; } else if (read_link_result == -2) { SHOWMSG("buffer was too short"); - errno = ENOBUFS; + __set_errno(ENOBUFS); goto out; } } diff --git a/library/unistd_realpath.c b/library/unistd_realpath.c index 8e0e6d8..befd871 100644 --- a/library/unistd_realpath.c +++ b/library/unistd_realpath.c @@ -1,5 +1,5 @@ /* - * $Id: unistd_realpath.c,v 1.3 2005-01-02 09:07:19 obarthel Exp $ + * $Id: unistd_realpath.c,v 1.4 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -71,7 +71,7 @@ realpath(const char * path_name, char * buffer) { SHOWSTRING("invalid parameters"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -107,7 +107,7 @@ realpath(const char * path_name, char * buffer) { SHOWMSG("that didn't work"); - __translate_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_io_error_to_errno(IoErr())); goto out; } } @@ -115,7 +115,7 @@ realpath(const char * path_name, char * buffer) { SHOWMSG("couldn't get a lock"); - __translate_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_io_error_to_errno(IoErr())); goto out; } diff --git a/library/unistd_setcurrentpath.c b/library/unistd_setcurrentpath.c index 121b6c6..a46ec45 100644 --- a/library/unistd_setcurrentpath.c +++ b/library/unistd_setcurrentpath.c @@ -1,5 +1,5 @@ /* - * $Id: unistd_setcurrentpath.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $ + * $Id: unistd_setcurrentpath.c,v 1.3 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -52,7 +52,7 @@ __set_current_path(const char * path_name) { SHOWMSG("path is too long"); - errno = ENAMETOOLONG; + __set_errno(ENAMETOOLONG); goto out; } diff --git a/library/unistd_symlink.c b/library/unistd_symlink.c index 573e1fa..387868e 100644 --- a/library/unistd_symlink.c +++ b/library/unistd_symlink.c @@ -1,5 +1,5 @@ /* - * $Id: unistd_symlink.c,v 1.3 2005-01-02 09:07:19 obarthel Exp $ + * $Id: unistd_symlink.c,v 1.4 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -69,7 +69,7 @@ symlink(const char * actual_path, const char * symbolic_path) { SHOWMSG("invalid parameters"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -88,7 +88,7 @@ symlink(const char * actual_path, const char * symbolic_path) { SHOWMSG("that didn't work"); - __translate_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_io_error_to_errno(IoErr())); goto out; } diff --git a/library/unistd_translatea2u.c b/library/unistd_translatea2u.c index 3c9082e..248bb90 100644 --- a/library/unistd_translatea2u.c +++ b/library/unistd_translatea2u.c @@ -1,5 +1,5 @@ /* - * $Id: unistd_translatea2u.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $ + * $Id: unistd_translatea2u.c,v 1.3 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -60,7 +60,7 @@ __translate_amiga_to_unix_path_name(char const ** name_ptr,struct name_translati { D(("path name '%s' is too long (%ld characters total; maximum is %ld)!",name,len,sizeof(nti->substitute)-1)); - errno = ENAMETOOLONG; + __set_errno(ENAMETOOLONG); goto out; } @@ -83,7 +83,7 @@ __translate_amiga_to_unix_path_name(char const ** name_ptr,struct name_translati /* We will need to make a copy of the name. Make sure that it fits. */ if(len > max_unix_len) { - errno = ENAMETOOLONG; + __set_errno(ENAMETOOLONG); goto out; } @@ -136,7 +136,7 @@ __translate_amiga_to_unix_path_name(char const ** name_ptr,struct name_translati { if(replace_len + 3 > max_unix_len) { - errno = ENAMETOOLONG; + __set_errno(ENAMETOOLONG); goto out; } @@ -159,7 +159,7 @@ __translate_amiga_to_unix_path_name(char const ** name_ptr,struct name_translati { if(replace_len + 3 > max_unix_len) { - errno = ENAMETOOLONG; + __set_errno(ENAMETOOLONG); goto out; } @@ -170,7 +170,7 @@ __translate_amiga_to_unix_path_name(char const ** name_ptr,struct name_translati { if(replace_len + 1 > max_unix_len) { - errno = ENAMETOOLONG; + __set_errno(ENAMETOOLONG); goto out; } @@ -189,7 +189,7 @@ __translate_amiga_to_unix_path_name(char const ** name_ptr,struct name_translati case scenario. */ if(1 + volume_name_len + 1 + replace_len > max_unix_len) { - errno = ENAMETOOLONG; + __set_errno(ENAMETOOLONG); goto out; } @@ -239,7 +239,7 @@ __translate_amiga_to_unix_path_name(char const ** name_ptr,struct name_translati { if(path_prefix_len + 1 + replace_len > max_unix_len) { - errno = ENAMETOOLONG; + __set_errno(ENAMETOOLONG); goto out; } diff --git a/library/unistd_translaterel.c b/library/unistd_translaterel.c index 07eaddd..99d6fbc 100644 --- a/library/unistd_translaterel.c +++ b/library/unistd_translaterel.c @@ -1,5 +1,5 @@ /* - * $Id: unistd_translaterel.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $ + * $Id: unistd_translaterel.c,v 1.3 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -78,7 +78,7 @@ __translate_relative_path_name(char const ** name_ptr,char *replacement_buffer,s /* Check if the complete string will fit, including the terminating NUL byte. */ if(total_len+1 > replacement_buffer_size) { - errno = ENAMETOOLONG; + __set_errno(ENAMETOOLONG); goto out; } diff --git a/library/unistd_translateu2a.c b/library/unistd_translateu2a.c index 9f41520..38ecc18 100644 --- a/library/unistd_translateu2a.c +++ b/library/unistd_translateu2a.c @@ -1,5 +1,5 @@ /* - * $Id: unistd_translateu2a.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $ + * $Id: unistd_translateu2a.c,v 1.3 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -67,7 +67,7 @@ __translate_unix_to_amiga_path_name(char const ** name_ptr,struct name_translati { D(("path name '%s' is too long (%ld characters total; maximum is %ld)!",name,len,sizeof(nti->substitute)-1)); - errno = ENAMETOOLONG; + __set_errno(ENAMETOOLONG); goto out; } @@ -325,7 +325,7 @@ __translate_unix_to_amiga_path_name(char const ** name_ptr,struct name_translati { D(("name '%s' still contains colon characters",name)); - errno = EINVAL; /* invalid name */ + __set_errno(EINVAL); /* invalid name */ goto out; } } @@ -352,7 +352,7 @@ __translate_unix_to_amiga_path_name(char const ** name_ptr,struct name_translati { D(("name '%s' still contains colon characters",name)); - errno = EINVAL; /* invalid name */ + __set_errno(EINVAL); /* invalid name */ goto out; } } diff --git a/library/unistd_truncate.c b/library/unistd_truncate.c index 51b7872..c81bd82 100644 --- a/library/unistd_truncate.c +++ b/library/unistd_truncate.c @@ -1,5 +1,5 @@ /* - * $Id: unistd_truncate.c,v 1.3 2005-01-02 09:07:19 obarthel Exp $ + * $Id: unistd_truncate.c,v 1.4 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -66,7 +66,7 @@ truncate(const char * path_name, off_t length) { SHOWMSG("invalid path name"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -79,7 +79,7 @@ truncate(const char * path_name, off_t length) { SHOWMSG("invalid length"); - errno = EINVAL; + __set_errno(EINVAL); goto out; } diff --git a/library/unistd_unlink.c b/library/unistd_unlink.c index b7b67c8..2752eb3 100644 --- a/library/unistd_unlink.c +++ b/library/unistd_unlink.c @@ -1,5 +1,5 @@ /* - * $Id: unistd_unlink.c,v 1.3 2005-01-02 09:07:19 obarthel Exp $ + * $Id: unistd_unlink.c,v 1.4 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -76,7 +76,7 @@ unlink(const char * path_name) { SHOWMSG("invalid path name"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -94,7 +94,7 @@ unlink(const char * path_name) if(path_name_nti.is_root) { - errno = EACCES; + __set_errno(EACCES); goto out; } } @@ -119,7 +119,7 @@ unlink(const char * path_name) if(IoErr() != ERROR_OBJECT_IN_USE) { - __translate_access_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_access_io_error_to_errno(IoErr())); goto out; } @@ -134,7 +134,7 @@ unlink(const char * path_name) if(current_dir == ZERO) { - __translate_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_io_error_to_errno(IoErr())); goto out; } @@ -172,7 +172,7 @@ unlink(const char * path_name) } #else { - __translate_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_io_error_to_errno(IoErr())); goto out; } #endif /* UNIX_PATH_SEMANTICS */ diff --git a/library/unistd_wildcard_expand.c b/library/unistd_wildcard_expand.c index b3d37f7..8627d84 100644 --- a/library/unistd_wildcard_expand.c +++ b/library/unistd_wildcard_expand.c @@ -1,5 +1,5 @@ /* - * $Id: unistd_wildcard_expand.c,v 1.5 2005-02-03 12:14:55 obarthel Exp $ + * $Id: unistd_wildcard_expand.c,v 1.6 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -390,7 +390,7 @@ __wildcard_expand_init(void) if(error != OK) { - errno = error; + __set_errno(error); perror(__argv[0]); abort(); diff --git a/library/usergroup_crypt.c b/library/usergroup_crypt.c index 2b9ea3c..52b0d73 100644 --- a/library/usergroup_crypt.c +++ b/library/usergroup_crypt.c @@ -1,5 +1,5 @@ /* - * $Id: usergroup_crypt.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $ + * $Id: usergroup_crypt.c,v 1.3 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -71,7 +71,8 @@ crypt(const char *key,const char *salt) if(key == NULL || salt == NULL) { SHOWMSG("invalid parameters"); - errno = EFAULT; + + __set_errno(EFAULT); goto out; } } diff --git a/library/usergroup_getgrnam.c b/library/usergroup_getgrnam.c index d89d183..07e5289 100644 --- a/library/usergroup_getgrnam.c +++ b/library/usergroup_getgrnam.c @@ -1,5 +1,5 @@ /* - * $Id: usergroup_getgrnam.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $ + * $Id: usergroup_getgrnam.c,v 1.3 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -65,7 +65,7 @@ getgrnam(const char * name) { SHOWMSG("invalid name parameter"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/usergroup_getgroups.c b/library/usergroup_getgroups.c index 20e368d..730d152 100644 --- a/library/usergroup_getgroups.c +++ b/library/usergroup_getgroups.c @@ -1,5 +1,5 @@ /* - * $Id: usergroup_getgroups.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $ + * $Id: usergroup_getgroups.c,v 1.3 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -66,7 +66,7 @@ getgroups(int ngroups, gid_t *groups) { SHOWMSG("invalid groups parameter"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/usergroup_getpass.c b/library/usergroup_getpass.c index 09e2b28..00fbcb8 100644 --- a/library/usergroup_getpass.c +++ b/library/usergroup_getpass.c @@ -1,5 +1,5 @@ /* - * $Id: usergroup_getpass.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $ + * $Id: usergroup_getpass.c,v 1.3 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -65,7 +65,7 @@ getpass(const char *prompt) { SHOWMSG("invalid prompt"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/usergroup_getpwnam.c b/library/usergroup_getpwnam.c index 5b820c3..c2e5dde 100644 --- a/library/usergroup_getpwnam.c +++ b/library/usergroup_getpwnam.c @@ -1,5 +1,5 @@ /* - * $Id: usergroup_getpwnam.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $ + * $Id: usergroup_getpwnam.c,v 1.3 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -65,7 +65,7 @@ getpwnam(const char *name) { SHOWMSG("invalid name"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/usergroup_initgroups.c b/library/usergroup_initgroups.c index 9e028dc..229e39a 100644 --- a/library/usergroup_initgroups.c +++ b/library/usergroup_initgroups.c @@ -1,5 +1,5 @@ /* - * $Id: usergroup_initgroups.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $ + * $Id: usergroup_initgroups.c,v 1.3 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -66,7 +66,7 @@ initgroups(const char *name, gid_t basegroup) { SHOWMSG("invalid name"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/usergroup_setgroups.c b/library/usergroup_setgroups.c index 47cb11b..8ce596c 100644 --- a/library/usergroup_setgroups.c +++ b/library/usergroup_setgroups.c @@ -1,5 +1,5 @@ /* - * $Id: usergroup_setgroups.c,v 1.2 2005-01-02 09:07:19 obarthel Exp $ + * $Id: usergroup_setgroups.c,v 1.3 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -66,7 +66,7 @@ setgroups(int ngroups,const gid_t *groups) { SHOWMSG("invalid groups parameter"); - errno = EFAULT; + __set_errno(EFAULT); goto out; } } diff --git a/library/utime_utime.c b/library/utime_utime.c index 13ccb1b..d488dec 100644 --- a/library/utime_utime.c +++ b/library/utime_utime.c @@ -1,5 +1,5 @@ /* - * $Id: utime_utime.c,v 1.5 2005-01-29 18:05:14 obarthel Exp $ + * $Id: utime_utime.c,v 1.6 2005-02-03 16:56:17 obarthel Exp $ * * :ts=4 * @@ -71,7 +71,7 @@ utime(const char * path_name,const struct utimbuf * times) { if(path_name == NULL) { - errno = EFAULT; + __set_errno(EFAULT); goto out; } } @@ -86,7 +86,7 @@ utime(const char * path_name,const struct utimbuf * times) { if(CANNOT __convert_time_to_datestamp(times->modtime,&ds)) { - errno = EINVAL; + __set_errno(EINVAL); goto out; } } @@ -106,7 +106,7 @@ utime(const char * path_name,const struct utimbuf * times) if(path_name_nti.is_root) { - errno = EACCES; + __set_errno(EACCES); goto out; } } @@ -119,7 +119,7 @@ utime(const char * path_name,const struct utimbuf * times) if(status == DOSFALSE) { - __translate_io_error_to_errno(IoErr(),&errno); + __set_errno(__translate_io_error_to_errno(IoErr())); goto out; }