From 23c7a28e39b67f70ebf98aefaa112a74922a3900 Mon Sep 17 00:00:00 2001 From: maartenbrock Date: Thu, 17 Mar 2005 10:00:37 +0000 Subject: [PATCH] * device/include/stdint.h: added * device/lib/abs.c: added * device/lib/labs.c: added * device/include/stdlib.h: added abs() and labs() prototypes * device/lib/libsdcc.lib: added abs and labs * device/include/float.h, * device/lib/_fsmul.c, * device/lib/printf_fast.c, * device/lib/printf_tiny.c: updated comments git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3700 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 12 +++ device/include/float.h | 2 +- device/include/stdint.h | 157 +++++++++++++++++++++++++++++++++++++++ device/include/stdlib.h | 3 + device/lib/_fsmul.c | 6 +- device/lib/abs.c | 27 +++++++ device/lib/labs.c | 27 +++++++ device/lib/libsdcc.lib | 2 + device/lib/printf_fast.c | 8 +- device/lib/printf_tiny.c | 2 +- 10 files changed, 238 insertions(+), 8 deletions(-) create mode 100644 device/include/stdint.h create mode 100644 device/lib/abs.c create mode 100644 device/lib/labs.c diff --git a/ChangeLog b/ChangeLog index 46309454..bcc73684 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2005-03-17 Maarten Brock + + * device/include/stdint.h: added + * device/lib/abs.c: added + * device/lib/labs.c: added + * device/include/stdlib.h: added abs() and labs() prototypes + * device/lib/libsdcc.lib: added abs and labs + * device/include/float.h, + * device/lib/_fsmul.c, + * device/lib/printf_fast.c, + * device/lib/printf_tiny.c: updated comments + 2005-03-16 Erik Petrich * src/SDCCicode.c (geniCodeSwitch, geniCodeJumpTable): fixed diff --git a/device/include/float.h b/device/include/float.h index 3eea235a..3d3bb4c0 100644 --- a/device/include/float.h +++ b/device/include/float.h @@ -82,7 +82,7 @@ char __fsqt (float, float); // This adds about 66 bytes to the code size and // significantly speeds up shift operations more // than 8 bits (common when subtracting numbers -// of siginifantly different magnitude and scaling +// of significantly different magnitude and scaling // to fixed point) #define FLOAT_SHIFT_SPEEDUP diff --git a/device/include/stdint.h b/device/include/stdint.h new file mode 100644 index 00000000..12b26d5b --- /dev/null +++ b/device/include/stdint.h @@ -0,0 +1,157 @@ +/*------------------------------------------------------------------------- + stdint.h - ISO C99 7.18 Integer types + + Written By - Maarten Brock, sourceforge.brock@dse.nl (2005) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +-------------------------------------------------------------------------*/ + +#ifndef _STDINT_H +#define _STDINT_H 1 + +/* Exact integral types. */ + +/* Signed. */ + +typedef signed char int8_t; +typedef short int int16_t; +typedef long int int32_t; + +/* Unsigned. */ +typedef unsigned char uint8_t; +typedef unsigned short int uint16_t; +typedef unsigned long int uint32_t; + + +/* Small types. */ + +/* Signed. */ +typedef signed char int_least8_t; +typedef short int int_least16_t; +typedef long int int_least32_t; + +/* Unsigned. */ +typedef unsigned char uint_least8_t; +typedef unsigned short int uint_least16_t; +typedef unsigned long int uint_least32_t; + + +/* Fast types. */ + +/* Signed. */ +typedef signed char int_fast8_t; +typedef int int_fast16_t; +typedef long int int_fast32_t; + +/* Unsigned. */ +typedef unsigned char uint_fast8_t; +typedef unsigned int uint_fast16_t; +typedef unsigned long int uint_fast32_t; + + +/* Types for `void *' pointers. */ +typedef long int intptr_t; +typedef unsigned long int uintptr_t; + + +/* Largest integral types. */ +typedef long int intmax_t; +typedef unsigned long int uintmax_t; + + +/* Limits of integral types. */ + +/* Minimum of signed integral types. */ +# define INT8_MIN (-128) +# define INT16_MIN (-32767-1) +# define INT32_MIN (-2147483647L-1) +/* Maximum of signed integral types. */ +# define INT8_MAX (127) +# define INT16_MAX (32767) +# define INT32_MAX (2147483647L) + +/* Maximum of unsigned integral types. */ +# define UINT8_MAX (255) +# define UINT16_MAX (65535) +# define UINT32_MAX (4294967295UL) + +/* Minimum of signed integral types having a minimum size. */ +# define INT_LEAST8_MIN (-128) +# define INT_LEAST16_MIN (-32767-1) +# define INT_LEAST32_MIN (-2147483647L-1) +/* Maximum of signed integral types having a minimum size. */ +# define INT_LEAST8_MAX (127) +# define INT_LEAST16_MAX (32767) +# define INT_LEAST32_MAX (2147483647L) + +/* Maximum of unsigned integral types having a minimum size. */ +# define UINT_LEAST8_MAX (255) +# define UINT_LEAST16_MAX (65535) +# define UINT_LEAST32_MAX (4294967295UL) + +/* Minimum of fast signed integral types having a minimum size. */ +# define INT_FAST8_MIN (-128) +# define INT_FAST16_MIN (-32767-1) +# define INT_FAST32_MIN (-2147483647L-1) + +/* Maximum of fast signed integral types having a minimum size. */ +# define INT_FAST8_MAX (127) +# define INT_FAST16_MAX (32767) +# define INT_FAST32_MAX (2147483647L) + +/* Maximum of fast unsigned integral types having a minimum size. */ +# define UINT_FAST8_MAX (255) +# define UINT_FAST16_MAX (65535) +# define UINT_FAST32_MAX (4294967295UL) + +/* Values to test for integral types holding `void *' pointer. */ +# define INTPTR_MIN (-2147483647L-1) +# define INTPTR_MAX (2147483647L) +# define UINTPTR_MAX (4294967295UL) + +/* Minimum for largest signed integral type. */ +# define INTMAX_MIN (-__INT32_C(-2147483647L)-1) +/* Maximum for largest signed integral type. */ +# define INTMAX_MAX (__INT32_C(2147483647L)) + +/* Maximum for largest unsigned integral type. */ +# define UINTMAX_MAX (__UINT32_C(4294967295UL)) + + +/* Limits of other integer types. */ + +/* Limits of `ptrdiff_t' type. */ +# define PTRDIFF_MIN (-2147483647L-1) +# define PTRDIFF_MAX (2147483647L) + +/* Limit of `size_t' type. */ +# define SIZE_MAX (65535) + +/* Signed. */ +# define INT8_C(c) c +# define INT16_C(c) c +# define INT32_C(c) c ## L + +/* Unsigned. */ +# define UINT8_C(c) c ## U +# define UINT16_C(c) c ## U +# define UINT32_C(c) c ## UL + +/* Maximal type. */ +# define INTMAX_C(c) c ## L +# define UINTMAX_C(c) c ## UL + + +#endif /* stdint.h */ diff --git a/device/include/stdlib.h b/device/include/stdlib.h index 550a67aa..27328370 100644 --- a/device/include/stdlib.h +++ b/device/include/stdlib.h @@ -31,6 +31,9 @@ #include +int abs(int j); +long int labs(long int j); + extern float atof (char *); extern int atoi (char *); extern long atol (char *); diff --git a/device/lib/_fsmul.c b/device/lib/_fsmul.c index 95c12f11..96be13d9 100644 --- a/device/lib/_fsmul.c +++ b/device/lib/_fsmul.c @@ -30,8 +30,8 @@ static void dummy(void) _naked .globl ___fsmul ___fsmul: // extract the two inputs, placing them into: - // sign exponent mantiassa - // ---- -------- --------- + // sign exponent mantissa + // ---- -------- -------- // a: sign_a exp_a r4/r3/r2 // b: sign_b exp_b r7/r6/r5 @@ -67,7 +67,7 @@ ___fsmul: // r4 * r7 << 32 // // This adds quite a bit of code, but it is a LOT faster - // that three calls to __mululong... + // than three calls to __mululong... // output goes into r4/r3/r2/r1/r0/xx diff --git a/device/lib/abs.c b/device/lib/abs.c new file mode 100644 index 00000000..a19a9b05 --- /dev/null +++ b/device/lib/abs.c @@ -0,0 +1,27 @@ +/*------------------------------------------------------------------------- + abs.c: computes absolute value of an integer. + + Copyright (C) 2004 - Maarten Brock, sourceforge.brock@dse.nl + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +-------------------------------------------------------------------------*/ + +#include + +int abs(int j) +{ + return (j >= 0) ? j : -j; +} +//END OF MODULE diff --git a/device/lib/labs.c b/device/lib/labs.c new file mode 100644 index 00000000..3b64c078 --- /dev/null +++ b/device/lib/labs.c @@ -0,0 +1,27 @@ +/*------------------------------------------------------------------------- + abs.c: computes absolute value of an integer. + + Copyright (C) 2004 - Maarten Brock, sourceforge.brock@dse.nl + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +-------------------------------------------------------------------------*/ + +#include + +long int labs(long int j) +{ + return (j >= 0) ? j : -j; +} +//END OF MODULE diff --git a/device/lib/libsdcc.lib b/device/lib/libsdcc.lib index 0e3ae982..88bf7b03 100644 --- a/device/lib/libsdcc.lib +++ b/device/lib/libsdcc.lib @@ -33,6 +33,8 @@ _gptrput _decdptr _bp _spx +abs +labs _atoi _atol calloc diff --git a/device/lib/printf_fast.c b/device/lib/printf_fast.c index 4382d643..952b9547 100644 --- a/device/lib/printf_fast.c +++ b/device/lib/printf_fast.c @@ -19,13 +19,13 @@ /******************************************************************/ /** **/ /** Major features. These determine what capabilities your **/ -/** comiled printf_fast will have. **/ +/** compiled printf_fast will have. **/ /** **/ /******************************************************************/ // Include support for 32 bit base 10 integers (%ld and %lu). Without // this, you won't be able to print 32 bit integers as base 10. They -// will appear in hexidecimal. +// will appear in hexadecimal. #define LONG // Include support for floating point numbers (%f). Don't forget to @@ -88,6 +88,8 @@ /* extern void putchar(char ); */ +// Warning: using static/global variables makes these functions NON-reentrant! +// reentrant keyword is only used for parameter passing method static bit long_flag, short_flag, print_zero_flag, negative_flag; @@ -134,7 +136,7 @@ static data unsigned int i2bcd_tmp; // slow 32 int conversion needs temp space void PRINTF_FAST(code char *fmt, ...) reentrant { - fmt; /* supress unreferenced variable warning */ + fmt; /* suppress unreferenced variable warning */ _asm diff --git a/device/lib/printf_tiny.c b/device/lib/printf_tiny.c index 4db9fe4f..4d70072d 100644 --- a/device/lib/printf_tiny.c +++ b/device/lib/printf_tiny.c @@ -68,7 +68,7 @@ void printf_tiny(code char *fmt, ...) reentrant { - fmt; /* supress unreferenced variable warning */ + fmt; /* suppress unreferenced variable warning */ _asm -- 2.30.2