From acc795df55ea395a22a676a296caba02c604ece8 Mon Sep 17 00:00:00 2001 From: Olaf Barthel Date: Mon, 13 Nov 2006 09:51:53 +0000 Subject: [PATCH] - The math kernel code no longer uses its own private scalbn() function. - Added a function prototype for the _exit() function. Note that _exit() is not an ISO 'C' function. - Corrected the getopt() function prototype, as prompted by Henning Nielsen Lund. git-svn-id: file:///Users/olsen/Code/migration-svn-zu-git/logical-line-staging/clib2/trunk@15164 87f5fb63-7c3d-0410-a384-fd976d0f7a62 --- library/changes | 7 +++ library/include/stdlib.h | 3 +- library/include/unistd.h | 4 +- library/libm.gmk | 3 +- library/math_headers.h | 3 +- library/math_kernel_rem_pio2.c | 12 ++--- library/math_kernel_scalbn.c | 88 ---------------------------------- library/unistd_getopt.c | 4 +- 8 files changed, 21 insertions(+), 103 deletions(-) delete mode 100644 library/math_kernel_scalbn.c diff --git a/library/changes b/library/changes index ebd3d62..f7b23d1 100644 --- a/library/changes +++ b/library/changes @@ -1,3 +1,10 @@ +- The math kernel code no longer uses its own private scalbn() function. + +- Added a function prototype for the _exit() function. Note that _exit() is + not an ISO 'C' function. + +- Corrected the getopt() function prototype, as prompted by Henning Nielsen Lund. + - The printf() family no longer adds a 0 or 0x prefix if the alternate conversion modifier is present for the %o and %x conversions and the value to be converted is 0 already. Put another way, printf("%#x %#o",0,0); diff --git a/library/include/stdlib.h b/library/include/stdlib.h index 096e4d4..37a57b1 100644 --- a/library/include/stdlib.h +++ b/library/include/stdlib.h @@ -1,5 +1,5 @@ /* - * $Id: stdlib.h,v 1.17 2006-01-08 12:06:14 obarthel Exp $ + * $Id: stdlib.h,v 1.18 2006-11-13 09:51:53 obarthel Exp $ * * :ts=4 * @@ -156,6 +156,7 @@ extern long atol(const char *str); /****************************************************************************/ +extern void _exit(int status); extern int rand_r(unsigned int * seed); /****************************************************************************/ diff --git a/library/include/unistd.h b/library/include/unistd.h index 4021e73..46b1bd1 100644 --- a/library/include/unistd.h +++ b/library/include/unistd.h @@ -1,5 +1,5 @@ /* - * $Id: unistd.h,v 1.21 2006-08-02 06:49:47 obarthel Exp $ + * $Id: unistd.h,v 1.22 2006-11-13 09:51:53 obarthel Exp $ * * :ts=4 * @@ -114,7 +114,7 @@ extern int chdir(const char * path_name); extern int lockf(int file_descriptor, int function, off_t size); extern unsigned int sleep(unsigned int seconds); extern void usleep(unsigned long microseconds); -extern int getopt(int argc, char * argv[], char *opts); +extern int getopt(int argc, char * const argv[], const char *opts); extern pid_t getpid(void); extern char *realpath(const char *file_name, char *resolved_name); extern int fsync(int file_descriptor); diff --git a/library/libm.gmk b/library/libm.gmk index 0d0b856..a06da9b 100755 --- a/library/libm.gmk +++ b/library/libm.gmk @@ -1,5 +1,5 @@ # -# $Id: libm.gmk,v 1.1 2006-09-17 17:37:27 obarthel Exp $ +# $Id: libm.gmk,v 1.2 2006-11-13 09:51:53 obarthel Exp $ # # :ts=8 # @@ -109,7 +109,6 @@ MATH_LIB := \ math_kernel_cosf.o \ math_kernel_expm1.o \ math_kernel_rem_pio2.o \ - math_kernel_scalbn.o \ math_kernel_sin.o \ math_kernel_sinf.o \ math_kernel_tan.o \ diff --git a/library/math_headers.h b/library/math_headers.h index ea148e3..77e483a 100644 --- a/library/math_headers.h +++ b/library/math_headers.h @@ -1,5 +1,5 @@ /* - * $Id: math_headers.h,v 1.14 2006-01-08 12:04:23 obarthel Exp $ + * $Id: math_headers.h,v 1.15 2006-11-13 09:51:53 obarthel Exp $ * * :ts=4 * @@ -216,7 +216,6 @@ extern double __kernel_sin(double x, double y, int iy); extern int __rem_pio2(double x, double *y); extern double __kernel_tan(double x, double y, int iy); extern double __expm1(double x); -extern double __scalbn(double x, int n); extern float __kernel_cosf(float x, float y); extern float __kernel_sinf(float x, float y, int iy); extern LONG __rem_pio2f(float x, float *y); diff --git a/library/math_kernel_rem_pio2.c b/library/math_kernel_rem_pio2.c index 5df175e..258c5f6 100644 --- a/library/math_kernel_rem_pio2.c +++ b/library/math_kernel_rem_pio2.c @@ -1,5 +1,5 @@ /* - * $Id: math_kernel_rem_pio2.c,v 1.6 2006-11-13 09:25:28 obarthel Exp $ + * $Id: math_kernel_rem_pio2.c,v 1.7 2006-11-13 09:51:53 obarthel Exp $ * * :ts=4 * @@ -102,7 +102,7 @@ recompute: } /* compute n */ - z = __scalbn(z,(int)q0); /* actual value of z */ + z = scalbn(z,(int)q0); /* actual value of z */ z -= 8.0*floor(z*0.125); /* trim off integer >= 8 */ n = (int) z; z -= (double)n; @@ -135,7 +135,7 @@ recompute: } if(ih==2) { z = one - z; - if(carry!=0) z -= __scalbn(one,(int)q0); + if(carry!=0) z -= scalbn(one,(int)q0); } } @@ -161,7 +161,7 @@ recompute: jz -= 1; q0 -= 24; while(iq[jz]==0) { jz--; q0-=24;} } else { /* break z into 24-bit if necessary */ - z = __scalbn(z,-(int)q0); + z = scalbn(z,-(int)q0); if(z>=two24) { fw = (double)((int)(twon24*z)); iq[jz] = (int)(z-two24*fw); @@ -171,7 +171,7 @@ recompute: } /* convert integer "bit" chunk to floating-point value */ - fw = __scalbn(one,(int)q0); + fw = scalbn(one,(int)q0); for(i=jz;i>=0;i--) { q[i] = fw*(double)iq[i]; fw*=twon24; } @@ -331,7 +331,7 @@ int __rem_pio2(double x, double *y) } /* keep the compiler happy */ z = 0; - /* set z = __scalbn(|x|,ilogb(x)-23) */ + /* set z = scalbn(|x|,ilogb(x)-23) */ GET_LOW_WORD(low,x); SET_LOW_WORD(z,low); e0 = (int)((ix>>20)-1046); /* e0 = ilogb(z)-23; */ diff --git a/library/math_kernel_scalbn.c b/library/math_kernel_scalbn.c deleted file mode 100644 index 72cd9dd..0000000 --- a/library/math_kernel_scalbn.c +++ /dev/null @@ -1,88 +0,0 @@ -/* - * $Id: math_kernel_scalbn.c,v 1.5 2006-01-08 12:04:23 obarthel Exp $ - * - * :ts=4 - * - * Portable ISO 'C' (1994) runtime library for the Amiga computer - * Copyright (c) 2002-2006 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. - * - * - * PowerPC math library based in part on work by Sun Microsystems - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - */ - -#ifndef _MATH_HEADERS_H -#include "math_headers.h" -#endif /* _MATH_HEADERS_H */ - -/****************************************************************************/ - -#if defined(FLOATING_POINT_SUPPORT) && defined(PPC_FLOATING_POINT_SUPPORT) - -/****************************************************************************/ - -static const double -huge = 1.0e+300, -tiny = 1.0e-300, -two54 = 1.80143985094819840000e+16, /* 0x43500000, 0x00000000 */ -twom54 = 5.55111512312578270212e-17; /* 0x3C900000, 0x00000000 */ - -double __scalbn (double x, int n) -{ - int k,hx,lx; - EXTRACT_WORDS(hx,lx,x); - k = (hx&0x7ff00000)>>20; /* extract exponent */ - if (k==0) { /* 0 or subnormal x */ - if ((lx|(hx&0x7fffffff))==0) return x; /* +-0 */ - x *= two54; - GET_HIGH_WORD(hx,x); - k = ((hx&0x7ff00000)>>20) - 54; - if (n< -50000) return tiny*x; /*underflow*/ - } - if (k==0x7ff) return x+x; /* NaN or Inf */ - k = k+n; - if (k > 0x7fe) return huge*copysign(huge,x); /* overflow */ - if (k > 0) /* normal result */ - {SET_HIGH_WORD(x,(hx&0x800fffff)|(k<<20)); return x;} - if (k <= -54) { - if (n > 50000) /* in case integer overflow in n+k */ - return huge*copysign(huge,x); /*overflow*/ - else return tiny*copysign(tiny,x); /*underflow*/ - } - k += 54; /* subnormal result */ - SET_HIGH_WORD(x,(hx&0x800fffff)|(k<<20)); - return x*twom54; -} - -/****************************************************************************/ - -#endif /* FLOATING_POINT_SUPPORT && PPC_FLOATING_POINT_SUPPORT */ diff --git a/library/unistd_getopt.c b/library/unistd_getopt.c index 84eb58d..a44b948 100644 --- a/library/unistd_getopt.c +++ b/library/unistd_getopt.c @@ -1,5 +1,5 @@ /* - * $Id: unistd_getopt.c,v 1.6 2006-01-08 12:04:27 obarthel Exp $ + * $Id: unistd_getopt.c,v 1.7 2006-11-13 09:51:53 obarthel Exp $ * * :ts=4 * @@ -55,7 +55,7 @@ char * optarg; /****************************************************************************/ int -getopt(int argc, char * argv[], char *opts) +getopt(int argc, char * const argv[], const char *opts) { static int sp = 1; int result = EOF;