From 8555296691960caefef441784737ccd80320c0f5 Mon Sep 17 00:00:00 2001 From: Olaf Barthel Date: Wed, 29 Sep 2004 14:17:46 +0000 Subject: [PATCH] c.lib 1.177 (29.9.2004) - Moved the locale initialization/cleanup code into constructors and destructors. - The socket cleanup function is now a destructor. - The math cleanup function is now a destructor. - The wildcard cleanup function is now a destructor. - The stdio cleanup function is now a destructor. - The stack extension cleanup function is now a destructor. - The code that cleans up after the program's current directory was changed is now a destructor function. - Moved the initialization/cleanup code for unlink() into constructors and destructors. - Moved the initialization/cleanup code for usergroup.library into constructors and destructors. - Added usleep(), and created wrapper code that both sleep() and usleep() can use. - Added strtoll() and strtoull(), with further changes to and . git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@14737 87f5fb63-7c3d-0410-a384-fd976d0f7a62 --- library/GNUmakefile.68k | 10 ++-- library/GNUmakefile.os4 | 10 ++-- library/amiga.lib_rev.h | 10 ++-- library/amiga.lib_rev.rev | 2 +- library/c.lib_rev.h | 10 ++-- library/c.lib_rev.rev | 2 +- library/changes | 24 +++++++++ library/debug.lib_rev.h | 10 ++-- library/debug.lib_rev.rev | 2 +- library/include/unistd.h | 33 ++++++++---- library/locale_data.c | 45 ---------------- library/locale_init_exit.c | 30 ++++++++--- library/m.lib_rev.h | 10 ++-- library/m.lib_rev.rev | 2 +- library/m881.lib_rev.h | 10 ++-- library/m881.lib_rev.rev | 2 +- library/math_fabs.c | 13 +---- library/math_init_exit.c | 5 +- library/net.lib_rev.h | 10 ++-- library/net.lib_rev.rev | 2 +- library/smakefile | 6 +-- library/socket_init_exit.c | 11 ++-- library/stack.lib_rev.h | 10 ++-- library/stack.lib_rev.rev | 2 +- library/stdio_init_exit.c | 19 +++++-- library/stdio_protos.h | 7 ++- library/stdlib_data.c | 8 +-- library/stdlib_main.c | 14 +---- library/stdlib_math.c | 9 +--- library/stdlib_protos.h | 32 +----------- library/stdlib_socket.c | 9 +--- library/stdlib_stackcheck.c | 7 +-- library/stdlib_stackextension.c | 5 +- library/stdlib_startup.c | 5 +- library/stdlib_usergroup.c | 51 ------------------- library/stdlib_wildcard_expand.c | 10 +--- .../{unistd_data.c => unistd_chdir_exit.c} | 36 ++++++++++--- library/unistd_init_exit.c | 36 +++++-------- library/unistd_time_delay.c | 6 ++- library/unistd_wildcard_expand.c | 5 +- library/unix.lib_rev.h | 10 ++-- library/unix.lib_rev.rev | 2 +- library/usergroup_data.c | 14 +---- library/usergroup_init_exit.c | 24 ++++++--- 44 files changed, 239 insertions(+), 341 deletions(-) delete mode 100644 library/locale_data.c delete mode 100644 library/stdlib_usergroup.c rename library/{unistd_data.c => unistd_chdir_exit.c} (82%) diff --git a/library/GNUmakefile.68k b/library/GNUmakefile.68k index 9d093f5..21c3fe4 100644 --- a/library/GNUmakefile.68k +++ b/library/GNUmakefile.68k @@ -1,5 +1,5 @@ # -# $Id: GNUmakefile.68k,v 1.9 2004-09-20 17:16:06 obarthel Exp $ +# $Id: GNUmakefile.68k,v 1.10 2004-09-29 14:17:44 obarthel Exp $ # # :ts=8 # @@ -147,7 +147,6 @@ C_LIB = \ fcntl_get_default_file.o \ libgen_basename.o \ libgen_dirname.o \ - locale_data.o \ locale_init_exit.o \ locale_localeconv.o \ locale_setlocale.o \ @@ -318,7 +317,6 @@ C_LIB = \ stdlib_udivsi4.o \ stdlib_umodsi3.o \ stdlib_unsetenv.o \ - stdlib_usergroup.o \ stdlib_wildcard_expand.o \ strings_strcasecmp.o \ strings_strncasecmp.o \ @@ -364,9 +362,9 @@ C_LIB = \ time_time.o \ unistd_access.o \ unistd_chdir.o \ + unistd_chdir_exit.o \ unistd_chown.o \ unistd_currentpathname.o \ - unistd_data.o \ unistd_dup.o \ unistd_dup2.o \ unistd_fchown.o \ @@ -384,8 +382,11 @@ C_LIB = \ unistd_realpath.o \ unistd_sleep.o \ unistd_symlink.o \ + unistd_timer.o \ + unistd_time_delay.o \ unistd_truncate.o \ unistd_unlink.o \ + unistd_usleep.o \ utime_utime.o UNIX_LIB = \ @@ -424,6 +425,7 @@ UNIX_LIB = \ stdlib_system.o \ unistd_access.o \ unistd_chdir.o \ + unistd_chdir_exit.o \ unistd_chown.o \ unistd_getcwd.o \ unistd_lchown.o \ diff --git a/library/GNUmakefile.os4 b/library/GNUmakefile.os4 index ad801a7..ffe1b91 100644 --- a/library/GNUmakefile.os4 +++ b/library/GNUmakefile.os4 @@ -1,5 +1,5 @@ # -# $Id: GNUmakefile.os4,v 1.8 2004-09-27 15:04:51 tfrieden Exp $ +# $Id: GNUmakefile.os4,v 1.9 2004-09-29 14:17:44 obarthel Exp $ # # :ts=8 # @@ -145,7 +145,6 @@ C_LIB = \ fcntl_get_default_file.o \ libgen_basename.o \ libgen_dirname.o \ - locale_data.o \ locale_init_exit.o \ locale_localeconv.o \ locale_setlocale.o \ @@ -313,7 +312,6 @@ C_LIB = \ stdlib_termination_message.o \ stdlib_threshold.o \ stdlib_unsetenv.o \ - stdlib_usergroup.o \ stdlib_wildcard_expand.o \ strings_strcasecmp.o \ strings_strncasecmp.o \ @@ -359,9 +357,9 @@ C_LIB = \ time_time.o \ unistd_access.o \ unistd_chdir.o \ + unistd_chdir_exit.o \ unistd_chown.o \ unistd_currentpathname.o \ - unistd_data.o \ unistd_dup.o \ unistd_dup2.o \ unistd_fchown.o \ @@ -379,8 +377,11 @@ C_LIB = \ unistd_realpath.o \ unistd_sleep.o \ unistd_symlink.o \ + unistd_time_delay.o \ + unistd_timer.o \ unistd_truncate.o \ unistd_unlink.o \ + unistd_usleep.o \ utime_utime.o @@ -420,6 +421,7 @@ UNIX_LIB = \ stdlib_system.o \ unistd_access.o \ unistd_chdir.o \ + unistd_chdir_exit.o \ unistd_chown.o \ unistd_getcwd.o \ unistd_lchown.o \ diff --git a/library/amiga.lib_rev.h b/library/amiga.lib_rev.h index 5e754cb..d209bc6 100644 --- a/library/amiga.lib_rev.h +++ b/library/amiga.lib_rev.h @@ -1,6 +1,6 @@ #define VERSION 1 -#define REVISION 176 -#define DATE "27.9.2004" -#define VERS "amiga.lib 1.176" -#define VSTRING "amiga.lib 1.176 (27.9.2004)\r\n" -#define VERSTAG "\0$VER: amiga.lib 1.176 (27.9.2004)" +#define REVISION 177 +#define DATE "29.9.2004" +#define VERS "amiga.lib 1.177" +#define VSTRING "amiga.lib 1.177 (29.9.2004)\r\n" +#define VERSTAG "\0$VER: amiga.lib 1.177 (29.9.2004)" diff --git a/library/amiga.lib_rev.rev b/library/amiga.lib_rev.rev index 1057e9a..eec4941 100644 --- a/library/amiga.lib_rev.rev +++ b/library/amiga.lib_rev.rev @@ -1 +1 @@ -176 +177 diff --git a/library/c.lib_rev.h b/library/c.lib_rev.h index 917412b..dbb7f7a 100644 --- a/library/c.lib_rev.h +++ b/library/c.lib_rev.h @@ -1,6 +1,6 @@ #define VERSION 1 -#define REVISION 176 -#define DATE "27.9.2004" -#define VERS "c.lib 1.176" -#define VSTRING "c.lib 1.176 (27.9.2004)\r\n" -#define VERSTAG "\0$VER: c.lib 1.176 (27.9.2004)" +#define REVISION 177 +#define DATE "29.9.2004" +#define VERS "c.lib 1.177" +#define VSTRING "c.lib 1.177 (29.9.2004)\r\n" +#define VERSTAG "\0$VER: c.lib 1.177 (29.9.2004)" diff --git a/library/c.lib_rev.rev b/library/c.lib_rev.rev index 1057e9a..eec4941 100644 --- a/library/c.lib_rev.rev +++ b/library/c.lib_rev.rev @@ -1 +1 @@ -176 +177 diff --git a/library/changes b/library/changes index 7c42506..d9daf04 100644 --- a/library/changes +++ b/library/changes @@ -1,3 +1,27 @@ +c.lib 1.177 (29.9.2004) + +- Moved the locale initialization/cleanup code into constructors + and destructors. + +- The socket cleanup function is now a destructor. + +- The math cleanup function is now a destructor. + +- The wildcard cleanup function is now a destructor. + +- The stdio cleanup function is now a destructor. + +- The stack extension cleanup function is now a destructor. + +- The code that cleans up after the program's current directory + was changed is now a destructor function. + +- Moved the initialization/cleanup code for unlink() into constructors + and destructors. + +- Moved the initialization/cleanup code for usergroup.library into + constructors and destructors. + - Added usleep(), and created wrapper code that both sleep() and usleep() can use. diff --git a/library/debug.lib_rev.h b/library/debug.lib_rev.h index aca074d..1171057 100644 --- a/library/debug.lib_rev.h +++ b/library/debug.lib_rev.h @@ -1,6 +1,6 @@ #define VERSION 1 -#define REVISION 176 -#define DATE "27.9.2004" -#define VERS "debug.lib 1.176" -#define VSTRING "debug.lib 1.176 (27.9.2004)\r\n" -#define VERSTAG "\0$VER: debug.lib 1.176 (27.9.2004)" +#define REVISION 177 +#define DATE "29.9.2004" +#define VERS "debug.lib 1.177" +#define VSTRING "debug.lib 1.177 (29.9.2004)\r\n" +#define VERSTAG "\0$VER: debug.lib 1.177 (29.9.2004)" diff --git a/library/debug.lib_rev.rev b/library/debug.lib_rev.rev index 1057e9a..eec4941 100644 --- a/library/debug.lib_rev.rev +++ b/library/debug.lib_rev.rev @@ -1 +1 @@ -176 +177 diff --git a/library/include/unistd.h b/library/include/unistd.h index 5ffc4e5..0febd8d 100644 --- a/library/include/unistd.h +++ b/library/include/unistd.h @@ -1,5 +1,5 @@ /* - * $Id: unistd.h,v 1.5 2004-09-29 12:10:35 obarthel Exp $ + * $Id: unistd.h,v 1.6 2004-09-29 14:17:46 obarthel Exp $ * * :ts=4 * @@ -52,6 +52,13 @@ extern "C" { /****************************************************************************/ +/* Endianness: we assume a big endian memory layout (for 68k and PowerPC). */ +#define LITTLE_ENDIAN 1234 +#define BIG_ENDIAN 4321 +#define BYTE_ORDER BIG_ENDIAN + +/****************************************************************************/ + #define STDIN_FILENO 0 #define STDOUT_FILENO 1 #define STDERR_FILENO 2 @@ -201,28 +208,32 @@ extern int h_errno; /****************************************************************************/ -extern int accept(int sockfd,struct sockaddr *cliaddr,int *addrlen); +typedef int socklen_t; + +/****************************************************************************/ + +extern int accept(int sockfd,struct sockaddr *cliaddr,socklen_t *addrlen); extern int bind(int sockfd,struct sockaddr *name,int namelen); -extern int connect(int sockfd,struct sockaddr *name,int namelen); -extern struct hostent * gethostbyaddr(const char *addr, int len, int type); +extern int connect(int sockfd,struct sockaddr *name,socklen_t namelen); +extern struct hostent * gethostbyaddr(const char *addr, socklen_t len, int type); extern struct hostent * gethostbyname(const char *name); extern int gethostname(const char *name, int namelen); extern struct netent * getnetbyname(const char *name); -extern int getpeername(int sockfd,struct sockaddr *name,int *namelen); -extern int getsockname(int sockfd,struct sockaddr *name,int *namelen); -extern int getsockopt(int sockfd,int level,int optname,void *optval,int *optlen); +extern int getpeername(int sockfd,struct sockaddr *name,socklen_t *namelen); +extern int getsockname(int sockfd,struct sockaddr *name,socklen_t *namelen); +extern int getsockopt(int sockfd,int level,int optname,void *optval,socklen_t *optlen); extern unsigned long inet_addr(const char *addr); extern char * inet_ntoa(struct in_addr in); extern int ioctl(int fd,unsigned long request, ... /* char *arg */); extern int listen(int sockfd,int backlog); extern int recv(int fd,void *buff,size_t nbytes,int flags); -extern int recvfrom(int sockfd,void *buff,int len,int flags,struct sockaddr *from,int *fromlen); +extern int recvfrom(int sockfd,void *buff,int len,int flags,struct sockaddr *from,socklen_t *fromlen); extern int recvmsg(int socket,struct msghdr *msg,int flags); extern int select(int num_fds,fd_set *read_fds,fd_set *write_fds,fd_set *except_fds,struct timeval *timeout); -extern int send(int fd,void *buff,size_t nbytes,int flags); +extern int send(int fd,const void *buff,size_t nbytes,int flags); extern int sendmsg(int socket,struct msghdr *msg,int flags); -extern int sendto(int sockfd,void *buff,int len,int flags,struct sockaddr *to,int tolen); -extern int setsockopt(int sockfd,int level,int optname,void *optval,int optlen); +extern int sendto(int sockfd,const void *buff,int len,int flags,struct sockaddr *to,socklen_t tolen); +extern int setsockopt(int sockfd,int level,int optname,const void *optval,socklen_t optlen); extern int shutdown(int socket, int how); extern int socket(int domain,int type,int protocol); extern long gethostid(void); diff --git a/library/locale_data.c b/library/locale_data.c deleted file mode 100644 index d77ddc6..0000000 --- a/library/locale_data.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * $Id: locale_data.c,v 1.1.1.1 2004-07-26 16:30:35 obarthel Exp $ - * - * :ts=4 - * - * Portable ISO 'C' (1994) runtime library for the Amiga computer - * Copyright (c) 2002-2004 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 _LOCALE_HEADERS_H -#include "locale_headers.h" -#endif /* _LOCALE_HEADERS_H */ - -/****************************************************************************/ - -struct Locale * __default_locale; -struct Locale * __locale_table[NUM_LOCALES]; - -/****************************************************************************/ - -char __locale_name_table[NUM_LOCALES][MAX_LOCALE_NAME_LEN]; diff --git a/library/locale_init_exit.c b/library/locale_init_exit.c index 8d3139b..48eab7e 100644 --- a/library/locale_init_exit.c +++ b/library/locale_init_exit.c @@ -1,5 +1,5 @@ /* - * $Id: locale_init_exit.c,v 1.1.1.1 2004-07-26 16:30:35 obarthel Exp $ + * $Id: locale_init_exit.c,v 1.2 2004-09-29 14:17:44 obarthel Exp $ * * :ts=4 * @@ -41,6 +41,25 @@ /****************************************************************************/ +struct Library * __LocaleBase; + +/****************************************************************************/ + +#if defined(__amigaos4__) +struct LocaleIFace * __ILocale; +#endif /* __amigaos4__ */ + +/****************************************************************************/ + +struct Locale * __default_locale; +struct Locale * __locale_table[NUM_LOCALES]; + +/****************************************************************************/ + +char __locale_name_table[NUM_LOCALES][MAX_LOCALE_NAME_LEN]; + +/****************************************************************************/ + void __close_all_locales(void) { @@ -71,8 +90,7 @@ __close_all_locales(void) /****************************************************************************/ -void -__locale_exit(void) +CLIB_DESTRUCTOR(__locale_exit) { ENTER(); @@ -107,8 +125,7 @@ __locale_exit(void) /****************************************************************************/ -int -__locale_init(void) +CLIB_CONSTRUCTOR(__locale_init) { int i; @@ -145,5 +162,6 @@ __locale_init(void) PROFILE_ON(); RETURN(OK); - return(OK); + + CONSTRUCTOR_SUCCEED(); } diff --git a/library/m.lib_rev.h b/library/m.lib_rev.h index 5fc3f4a..a3db4c8 100644 --- a/library/m.lib_rev.h +++ b/library/m.lib_rev.h @@ -1,6 +1,6 @@ #define VERSION 1 -#define REVISION 176 -#define DATE "27.9.2004" -#define VERS "m.lib 1.176" -#define VSTRING "m.lib 1.176 (27.9.2004)\r\n" -#define VERSTAG "\0$VER: m.lib 1.176 (27.9.2004)" +#define REVISION 177 +#define DATE "29.9.2004" +#define VERS "m.lib 1.177" +#define VSTRING "m.lib 1.177 (29.9.2004)\r\n" +#define VERSTAG "\0$VER: m.lib 1.177 (29.9.2004)" diff --git a/library/m.lib_rev.rev b/library/m.lib_rev.rev index 1057e9a..eec4941 100644 --- a/library/m.lib_rev.rev +++ b/library/m.lib_rev.rev @@ -1 +1 @@ -176 +177 diff --git a/library/m881.lib_rev.h b/library/m881.lib_rev.h index e28f38a..abe2ea0 100644 --- a/library/m881.lib_rev.h +++ b/library/m881.lib_rev.h @@ -1,6 +1,6 @@ #define VERSION 1 -#define REVISION 176 -#define DATE "27.9.2004" -#define VERS "m881.lib 1.176" -#define VSTRING "m881.lib 1.176 (27.9.2004)\r\n" -#define VERSTAG "\0$VER: m881.lib 1.176 (27.9.2004)" +#define REVISION 177 +#define DATE "29.9.2004" +#define VERS "m881.lib 1.177" +#define VSTRING "m881.lib 1.177 (29.9.2004)\r\n" +#define VERSTAG "\0$VER: m881.lib 1.177 (29.9.2004)" diff --git a/library/m881.lib_rev.rev b/library/m881.lib_rev.rev index 1057e9a..eec4941 100644 --- a/library/m881.lib_rev.rev +++ b/library/m881.lib_rev.rev @@ -1 +1 @@ -176 +177 diff --git a/library/math_fabs.c b/library/math_fabs.c index c73bedc..d929781 100644 --- a/library/math_fabs.c +++ b/library/math_fabs.c @@ -1,5 +1,5 @@ /* - * $Id: math_fabs.c,v 1.2 2004-09-27 15:06:16 tfrieden Exp $ + * $Id: math_fabs.c,v 1.3 2004-09-29 14:17:44 obarthel Exp $ * * :ts=4 * @@ -141,17 +141,6 @@ __fabs(double x) } -#else - -INLINE static const double -__fabs(double x) -{ - if (x > 0) - return x; - else - return -x; -} - #endif /* PPC_FLOATING_POINT_SUPPORT */ /****************************************************************************/ diff --git a/library/math_init_exit.c b/library/math_init_exit.c index 19ec455..ec2ced7 100644 --- a/library/math_init_exit.c +++ b/library/math_init_exit.c @@ -1,5 +1,5 @@ /* - * $Id: math_init_exit.c,v 1.3 2004-08-21 18:57:40 obarthel Exp $ + * $Id: math_init_exit.c,v 1.4 2004-09-29 14:17:44 obarthel Exp $ * * :ts=4 * @@ -53,8 +53,7 @@ /****************************************************************************/ -void -__math_exit(void) +CLIB_DESTRUCTOR(__math_exit) { #if defined(IEEE_FLOATING_POINT_SUPPORT) { diff --git a/library/net.lib_rev.h b/library/net.lib_rev.h index d57abfc..dbe3c04 100644 --- a/library/net.lib_rev.h +++ b/library/net.lib_rev.h @@ -1,6 +1,6 @@ #define VERSION 1 -#define REVISION 176 -#define DATE "27.9.2004" -#define VERS "net.lib 1.176" -#define VSTRING "net.lib 1.176 (27.9.2004)\r\n" -#define VERSTAG "\0$VER: net.lib 1.176 (27.9.2004)" +#define REVISION 177 +#define DATE "29.9.2004" +#define VERS "net.lib 1.177" +#define VSTRING "net.lib 1.177 (29.9.2004)\r\n" +#define VERSTAG "\0$VER: net.lib 1.177 (29.9.2004)" diff --git a/library/net.lib_rev.rev b/library/net.lib_rev.rev index 1057e9a..eec4941 100644 --- a/library/net.lib_rev.rev +++ b/library/net.lib_rev.rev @@ -1 +1 @@ -176 +177 diff --git a/library/smakefile b/library/smakefile index c18b821..6fe5667 100644 --- a/library/smakefile +++ b/library/smakefile @@ -1,5 +1,5 @@ # -# $Id: smakefile,v 1.9 2004-09-29 12:10:29 obarthel Exp $ +# $Id: smakefile,v 1.10 2004-09-29 14:17:44 obarthel Exp $ # # :ts=8 # @@ -171,7 +171,6 @@ LIBGEN_OBJ = \ libgen_dirname.o LOCALE_OBJ = \ - locale_data.o \ locale_init_exit.o \ locale_localeconv.o \ locale_setlocale.o @@ -474,9 +473,9 @@ TIME_OBJ = \ UNISTD_OBJ = \ unistd_access.o \ unistd_chdir.o \ + unistd_chdir_exit.o \ unistd_chown.o \ unistd_currentpathname.o \ - unistd_data.o \ unistd_dup.o \ unistd_dup2.o \ unistd_fchown.o \ @@ -498,6 +497,7 @@ UNISTD_OBJ = \ unistd_strip_double_slash.o \ unistd_symlink.o \ unistd_time_delay.o \ + unistd_timer.o \ unistd_translatea2u.o \ unistd_translaterel.o \ unistd_translateu2a.o \ diff --git a/library/socket_init_exit.c b/library/socket_init_exit.c index 23e8202..c4deb9c 100644 --- a/library/socket_init_exit.c +++ b/library/socket_init_exit.c @@ -1,5 +1,5 @@ /* - * $Id: socket_init_exit.c,v 1.2 2004-07-28 15:50:45 obarthel Exp $ + * $Id: socket_init_exit.c,v 1.3 2004-09-29 14:17:44 obarthel Exp $ * * :ts=4 * @@ -84,16 +84,11 @@ extern BOOL __is_daemon; /****************************************************************************/ -extern void __show_error(const char * message); - -/****************************************************************************/ - extern void __socket_hook_entry(struct Hook * hook,struct fd * fd,struct file_hook_message * message); /****************************************************************************/ -void -__socket_exit(void) +CLIB_DESTRUCTOR(__socket_exit) { ENTER(); @@ -116,7 +111,7 @@ __socket_exit(void) * does not happen, the stdio cleanup function will * crash (with bells on). */ - if(__fd != NULL) + if(__fd != NULL && __num_fd > 0) { int i; diff --git a/library/stack.lib_rev.h b/library/stack.lib_rev.h index d60171a..c91e74f 100644 --- a/library/stack.lib_rev.h +++ b/library/stack.lib_rev.h @@ -1,6 +1,6 @@ #define VERSION 1 -#define REVISION 176 -#define DATE "27.9.2004" -#define VERS "stack.lib 1.176" -#define VSTRING "stack.lib 1.176 (27.9.2004)\r\n" -#define VERSTAG "\0$VER: stack.lib 1.176 (27.9.2004)" +#define REVISION 177 +#define DATE "29.9.2004" +#define VERS "stack.lib 1.177" +#define VSTRING "stack.lib 1.177 (29.9.2004)\r\n" +#define VERSTAG "\0$VER: stack.lib 1.177 (29.9.2004)" diff --git a/library/stack.lib_rev.rev b/library/stack.lib_rev.rev index 1057e9a..eec4941 100644 --- a/library/stack.lib_rev.rev +++ b/library/stack.lib_rev.rev @@ -1 +1 @@ -176 +177 diff --git a/library/stdio_init_exit.c b/library/stdio_init_exit.c index cb90b13..a725877 100644 --- a/library/stdio_init_exit.c +++ b/library/stdio_init_exit.c @@ -1,5 +1,5 @@ /* - * $Id: stdio_init_exit.c,v 1.1.1.1 2004-07-26 16:31:36 obarthel Exp $ + * $Id: stdio_init_exit.c,v 1.2 2004-09-29 14:17:44 obarthel Exp $ * * :ts=4 * @@ -52,7 +52,7 @@ /****************************************************************************/ void -__stdio_exit(void) +__close_all_files(void) { int i; @@ -60,7 +60,7 @@ __stdio_exit(void) __check_abort_enabled = FALSE; - if(__iob != NULL) + if(__iob != NULL && __num_iob > 0) { for(i = 0 ; i < __num_iob ; i++) { @@ -72,7 +72,7 @@ __stdio_exit(void) __iob = NULL; } - if(__fd != NULL) + if(__fd != NULL && __num_fd > 0) { for(i = 0 ; i < __num_fd ; i++) { @@ -89,6 +89,17 @@ __stdio_exit(void) /****************************************************************************/ +CLIB_DESTRUCTOR(__stdio_exit) +{ + ENTER(); + + __close_all_files(); + + LEAVE(); +} + +/****************************************************************************/ + int __stdio_init(void) { diff --git a/library/stdio_protos.h b/library/stdio_protos.h index 798ce92..30f40df 100644 --- a/library/stdio_protos.h +++ b/library/stdio_protos.h @@ -1,5 +1,5 @@ /* - * $Id: stdio_protos.h,v 1.2 2004-08-08 10:55:57 obarthel Exp $ + * $Id: stdio_protos.h,v 1.3 2004-09-29 14:17:44 obarthel Exp $ * * :ts=4 * @@ -65,6 +65,11 @@ struct fd; /****************************************************************************/ +/* stdio_init_exit.c */ +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); diff --git a/library/stdlib_data.c b/library/stdlib_data.c index 41ddf3c..8dd4d0e 100644 --- a/library/stdlib_data.c +++ b/library/stdlib_data.c @@ -1,5 +1,5 @@ /* - * $Id: stdlib_data.c,v 1.1.1.1 2004-07-26 16:31:53 obarthel Exp $ + * $Id: stdlib_data.c,v 1.2 2004-09-29 14:17:44 obarthel Exp $ * * :ts=4 * @@ -85,15 +85,11 @@ ULONG __stk_extensions; /****************************************************************************/ struct Library * __UtilityBase; -struct Library * __LocaleBase; /****************************************************************************/ #if defined(__amigaos4__) - -struct UtilityIFace * __IUtility; -struct LocaleIFace * __ILocale; - +struct UtilityIFace * __IUtility; #endif /* __amigaos4__ */ /****************************************************************************/ diff --git a/library/stdlib_main.c b/library/stdlib_main.c index 4cec734..03578d7 100644 --- a/library/stdlib_main.c +++ b/library/stdlib_main.c @@ -1,5 +1,5 @@ /* - * $Id: stdlib_main.c,v 1.2 2004-09-18 09:03:30 obarthel Exp $ + * $Id: stdlib_main.c,v 1.3 2004-09-29 14:17:44 obarthel Exp $ * * :ts=4 * @@ -122,10 +122,7 @@ call_main(void) __stdio_init, __machine_test, __math_init, - __locale_init, - __unistd_init, __socket_init, - __usergroup_init, __wildcard_expand_init, NULL @@ -138,15 +135,6 @@ call_main(void) */ static exit_func_ptr exit_functions[] = { - __wildcard_expand_exit, - __usergroup_exit, - __socket_exit, - __unistd_exit, - __locale_exit, - __math_exit, - __stdio_exit, - __startup_exit, - __stk_exit, __stdlib_exit, NULL diff --git a/library/stdlib_math.c b/library/stdlib_math.c index 699e696..1808fca 100644 --- a/library/stdlib_math.c +++ b/library/stdlib_math.c @@ -1,5 +1,5 @@ /* - * $Id: stdlib_math.c,v 1.1.1.1 2004-07-26 16:31:59 obarthel Exp $ + * $Id: stdlib_math.c,v 1.2 2004-09-29 14:17:44 obarthel Exp $ * * :ts=4 * @@ -41,13 +41,6 @@ /****************************************************************************/ -void -__math_exit(void) -{ -} - -/****************************************************************************/ - int __math_init(void) { diff --git a/library/stdlib_protos.h b/library/stdlib_protos.h index c44bad7..865c014 100644 --- a/library/stdlib_protos.h +++ b/library/stdlib_protos.h @@ -1,5 +1,5 @@ /* - * $Id: stdlib_protos.h,v 1.1.1.1 2004-07-26 16:32:02 obarthel Exp $ + * $Id: stdlib_protos.h,v 1.2 2004-09-29 14:17:44 obarthel Exp $ * * :ts=4 * @@ -60,7 +60,6 @@ struct MemoryTree; /* math_init_exit.c */ extern int __math_init(void); -extern void __math_exit(void); /****************************************************************************/ @@ -69,15 +68,8 @@ extern int __machine_test(void); /****************************************************************************/ -/* locale_init_exit.c */ -extern int __locale_init(void); -extern void __locale_exit(void); - -/****************************************************************************/ - /* stdio_init_exit.c */ extern int __stdio_init(void); -extern void __stdio_exit(void); /****************************************************************************/ @@ -87,18 +79,6 @@ extern void __stdlib_exit(void); /****************************************************************************/ -/* unistd_init_exit.c */ -extern int __unistd_init(void); -extern void __unistd_exit(void); - -/****************************************************************************/ - -/* dirent_init_exit.c */ -extern int __dirent_init(void); -extern void __dirent_exit(void); - -/****************************************************************************/ - /* stdlib_atexit.c */ extern void __exit_trap_trigger(void); @@ -106,13 +86,6 @@ extern void __exit_trap_trigger(void); /* socket_init_exit.c */ extern int __socket_init(void); -extern void __socket_exit(void); - -/****************************************************************************/ - -/* usergroup_init_exit.c */ -extern int __usergroup_init(void); -extern void __usergroup_exit(void); /****************************************************************************/ @@ -134,13 +107,11 @@ extern unsigned long __get_sp(void); /* stdlib_wildcard_expand.c */ extern UBYTE * __allocate_quote_vector(int num_parameters); extern int __wildcard_expand_init(void); -extern void __wildcard_expand_exit(void); /****************************************************************************/ /* stdlib_stackextension.c */ extern int __stk_init(void); -extern void __stk_exit(void); /****************************************************************************/ @@ -163,7 +134,6 @@ void _fini(void); /* stdlib_startup.c */ extern int __startup_init(void); -extern void __startup_exit(void); /****************************************************************************/ diff --git a/library/stdlib_socket.c b/library/stdlib_socket.c index 4fddc09..fab1cd4 100644 --- a/library/stdlib_socket.c +++ b/library/stdlib_socket.c @@ -1,5 +1,5 @@ /* - * $Id: stdlib_socket.c,v 1.1.1.1 2004-07-26 16:32:06 obarthel Exp $ + * $Id: stdlib_socket.c,v 1.2 2004-09-29 14:17:44 obarthel Exp $ * * :ts=4 * @@ -37,13 +37,6 @@ /****************************************************************************/ -void -__socket_exit(void) -{ -} - -/****************************************************************************/ - int __socket_init(void) { diff --git a/library/stdlib_stackcheck.c b/library/stdlib_stackcheck.c index a3b3ddf..a5020aa 100644 --- a/library/stdlib_stackcheck.c +++ b/library/stdlib_stackcheck.c @@ -1,5 +1,5 @@ /* - * $Id: stdlib_stackcheck.c,v 1.1.1.1 2004-07-26 16:32:07 obarthel Exp $ + * $Id: stdlib_stackcheck.c,v 1.2 2004-09-29 14:17:44 obarthel Exp $ * * :ts=4 * @@ -123,8 +123,3 @@ __stk_init(void) return(OK); } - -void -__stk_exit(void) -{ -} diff --git a/library/stdlib_stackextension.c b/library/stdlib_stackextension.c index 97c401b..d41d2fa 100644 --- a/library/stdlib_stackextension.c +++ b/library/stdlib_stackextension.c @@ -1,5 +1,5 @@ /* - * $Id: stdlib_stackextension.c,v 1.1.1.1 2004-07-26 16:32:08 obarthel Exp $ + * $Id: stdlib_stackextension.c,v 1.2 2004-09-29 14:17:44 obarthel Exp $ * * :ts=4 * @@ -294,8 +294,7 @@ __stk_init(void) /****************************************************************************/ /* Free all spare stackframes */ -void -__stk_exit(void) +CLIB_DESTRUCTOR(__stk_exit) { ENTER(); diff --git a/library/stdlib_startup.c b/library/stdlib_startup.c index 27e59a4..0d2ab6b 100644 --- a/library/stdlib_startup.c +++ b/library/stdlib_startup.c @@ -1,5 +1,5 @@ /* - * $Id: stdlib_startup.c,v 1.1.1.1 2004-07-26 16:32:10 obarthel Exp $ + * $Id: stdlib_startup.c,v 1.2 2004-09-29 14:17:44 obarthel Exp $ * * :ts=4 * @@ -421,8 +421,7 @@ __startup_init(void) /****************************************************************************/ -void -__startup_exit(void) +CLIB_DESTRUCTOR(__startup_exit) { PROFILE_OFF(); diff --git a/library/stdlib_usergroup.c b/library/stdlib_usergroup.c deleted file mode 100644 index 67f307e..0000000 --- a/library/stdlib_usergroup.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - * $Id: stdlib_usergroup.c,v 1.1.1.1 2004-07-26 16:32:13 obarthel Exp $ - * - * :ts=4 - * - * Portable ISO 'C' (1994) runtime library for the Amiga computer - * Copyright (c) 2002-2004 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 -__usergroup_exit(void) -{ -} - -/****************************************************************************/ - -int -__usergroup_init(void) -{ - return(OK); -} diff --git a/library/stdlib_wildcard_expand.c b/library/stdlib_wildcard_expand.c index 2b1a5fe..d227be8 100644 --- a/library/stdlib_wildcard_expand.c +++ b/library/stdlib_wildcard_expand.c @@ -1,5 +1,5 @@ /* - * $Id: stdlib_wildcard_expand.c,v 1.1.1.1 2004-07-26 16:32:13 obarthel Exp $ + * $Id: stdlib_wildcard_expand.c,v 1.2 2004-09-29 14:17:44 obarthel Exp $ * * :ts=4 * @@ -39,7 +39,6 @@ UBYTE * WEAK __allocate_quote_vector(int num_parameters UNUSED); int WEAK __wildcard_expand_init(void); -void WEAK __wildcard_expand_exit(void); /****************************************************************************/ @@ -56,10 +55,3 @@ __wildcard_expand_init(void) { return(0); } - -/****************************************************************************/ - -void -__wildcard_expand_exit(void) -{ -} diff --git a/library/unistd_data.c b/library/unistd_chdir_exit.c similarity index 82% rename from library/unistd_data.c rename to library/unistd_chdir_exit.c index 6ee4cf2..668e146 100644 --- a/library/unistd_data.c +++ b/library/unistd_chdir_exit.c @@ -1,5 +1,5 @@ /* - * $Id: unistd_data.c,v 1.3 2004-09-29 12:10:29 obarthel Exp $ + * $Id: unistd_chdir_exit.c,v 1.1 2004-09-29 14:17:44 obarthel Exp $ * * :ts=4 * @@ -41,14 +41,34 @@ /****************************************************************************/ -/* Names of files and directories to delete when shutting down. */ -struct MinList __unlink_list; - -/****************************************************************************/ - /* If the program's current directory was changed, here is where - * we find out about it. - */ + we find out about it. */ BPTR __original_current_directory; BOOL __current_directory_changed; BOOL __unlock_current_directory; + +/****************************************************************************/ + +CLIB_DESTRUCTOR(__chdir_exit) +{ + ENTER(); + + if(__current_directory_changed) + { + BPTR old_dir; + + old_dir = CurrentDir(__original_current_directory); + __original_current_directory = ZERO; + + if(__unlock_current_directory) + { + UnLock(old_dir); + + __unlock_current_directory = FALSE; + } + + __current_directory_changed = FALSE; + } + + LEAVE(); +} diff --git a/library/unistd_init_exit.c b/library/unistd_init_exit.c index bb03b21..13ca7d3 100644 --- a/library/unistd_init_exit.c +++ b/library/unistd_init_exit.c @@ -1,5 +1,5 @@ /* - * $Id: unistd_init_exit.c,v 1.4 2004-09-29 12:10:29 obarthel Exp $ + * $Id: unistd_init_exit.c,v 1.5 2004-09-29 14:17:44 obarthel Exp $ * * :ts=4 * @@ -41,21 +41,25 @@ /****************************************************************************/ -int -__unistd_init(void) +/* Names of files and directories to delete when shutting down. */ +struct MinList __unlink_list; + +/****************************************************************************/ + +CLIB_CONSTRUCTOR(__unistd_init) { ENTER(); NewList((struct List *)&__unlink_list); RETURN(OK); - return(OK); + + CONSTRUCTOR_SUCCEED(); } /****************************************************************************/ -void -__unistd_exit(void) +CLIB_DESTRUCTOR(__unistd_exit) { ENTER(); @@ -66,6 +70,9 @@ __unistd_exit(void) struct UnlinkNode * uln; BPTR old_dir; + /* Close all the files that still might be open. */ + __close_all_files(); + while((uln = (struct UnlinkNode *)RemHead((struct List *)&__unlink_list))) { old_dir = CurrentDir(uln->uln_Lock); @@ -80,23 +87,6 @@ __unistd_exit(void) } } - if(__current_directory_changed) - { - BPTR old_dir; - - old_dir = CurrentDir(__original_current_directory); - __original_current_directory = ZERO; - - if(__unlock_current_directory) - { - UnLock(old_dir); - - __unlock_current_directory = FALSE; - } - - __current_directory_changed = FALSE; - } - PROFILE_ON(); LEAVE(); diff --git a/library/unistd_time_delay.c b/library/unistd_time_delay.c index a03df61..0ae794f 100644 --- a/library/unistd_time_delay.c +++ b/library/unistd_time_delay.c @@ -1,5 +1,5 @@ /* - * $Id: unistd_time_delay.c,v 1.1 2004-09-29 12:10:29 obarthel Exp $ + * $Id: unistd_time_delay.c,v 1.2 2004-09-29 14:17:44 obarthel Exp $ * * :ts=4 * @@ -37,6 +37,10 @@ /****************************************************************************/ +#include + +/****************************************************************************/ + /* The following is not part of the ISO 'C' (1994) standard. */ /****************************************************************************/ diff --git a/library/unistd_wildcard_expand.c b/library/unistd_wildcard_expand.c index c7a8907..dc48d57 100644 --- a/library/unistd_wildcard_expand.c +++ b/library/unistd_wildcard_expand.c @@ -1,5 +1,5 @@ /* - * $Id: unistd_wildcard_expand.c,v 1.1.1.1 2004-07-26 16:32:33 obarthel Exp $ + * $Id: unistd_wildcard_expand.c,v 1.2 2004-09-29 14:17:44 obarthel Exp $ * * :ts=4 * @@ -74,8 +74,7 @@ static struct AnchorPath * anchor; /****************************************************************************/ -void -__wildcard_expand_exit(void) +CLIB_DESTRUCTOR(__wildcard_expand_exit) { if(anchor != NULL) { diff --git a/library/unix.lib_rev.h b/library/unix.lib_rev.h index db3dc7d..43d07f2 100644 --- a/library/unix.lib_rev.h +++ b/library/unix.lib_rev.h @@ -1,6 +1,6 @@ #define VERSION 1 -#define REVISION 176 -#define DATE "27.9.2004" -#define VERS "unix.lib 1.176" -#define VSTRING "unix.lib 1.176 (27.9.2004)\r\n" -#define VERSTAG "\0$VER: unix.lib 1.176 (27.9.2004)" +#define REVISION 177 +#define DATE "29.9.2004" +#define VERS "unix.lib 1.177" +#define VSTRING "unix.lib 1.177 (29.9.2004)\r\n" +#define VERSTAG "\0$VER: unix.lib 1.177 (29.9.2004)" diff --git a/library/unix.lib_rev.rev b/library/unix.lib_rev.rev index 1057e9a..eec4941 100644 --- a/library/unix.lib_rev.rev +++ b/library/unix.lib_rev.rev @@ -1 +1 @@ -176 +177 diff --git a/library/usergroup_data.c b/library/usergroup_data.c index 8b262a7..903cb92 100644 --- a/library/usergroup_data.c +++ b/library/usergroup_data.c @@ -1,5 +1,5 @@ /* - * $Id: usergroup_data.c,v 1.1.1.1 2004-07-26 16:32:34 obarthel Exp $ + * $Id: usergroup_data.c,v 1.2 2004-09-29 14:17:44 obarthel Exp $ * * :ts=4 * @@ -41,18 +41,6 @@ /****************************************************************************/ -struct Library * __UserGroupBase; - -/****************************************************************************/ - -#if defined(__amigaos4__) - -struct UserGroupIFace *__IUserGroup; - -#endif /* __amigaos4__ */ - -/****************************************************************************/ - int __root_uid; int __root_gid; int __root_euid; diff --git a/library/usergroup_init_exit.c b/library/usergroup_init_exit.c index 513e278..cad4d62 100644 --- a/library/usergroup_init_exit.c +++ b/library/usergroup_init_exit.c @@ -1,5 +1,5 @@ /* - * $Id: usergroup_init_exit.c,v 1.1.1.1 2004-07-26 16:32:38 obarthel Exp $ + * $Id: usergroup_init_exit.c,v 1.2 2004-09-29 14:17:44 obarthel Exp $ * * :ts=4 * @@ -58,8 +58,17 @@ extern void __show_error(const char * message); /****************************************************************************/ -void -__usergroup_exit(void) +struct Library * __UserGroupBase; + +/****************************************************************************/ + +#if defined(__amigaos4__) +struct UserGroupIFace * __IUserGroup; +#endif /* __amigaos4__ */ + +/****************************************************************************/ + +CLIB_DESTRUCTOR(__usergroup_exit) { ENTER(); @@ -84,8 +93,7 @@ __usergroup_exit(void) /****************************************************************************/ -int -__usergroup_init(void) +CLIB_CONSTRUCTOR(__usergroup_init) { struct TagItem tags[2]; int result = ERROR; @@ -139,7 +147,11 @@ __usergroup_init(void) PROFILE_ON(); RETURN(result); - return(result); + + if(result == OK) + CONSTRUCTOR_SUCCEED(); + else + CONSTRUCTOR_FAIL(); } /****************************************************************************/