From bb17f83689bc78ab01d57c9ea0d8fd7ad9ca0fc7 Mon Sep 17 00:00:00 2001 From: verhaegs Date: Fri, 24 Feb 2012 17:51:38 +0000 Subject: [PATCH] compiler/clib: Do not call __arosc_get_ctype() for each call to a ctype.h macro. Global variables are now used in the macros that are initialized at program startup or module init. git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@44231 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- compiler/clib/__ctype.c | 31 ++++++++++++------------------- compiler/clib/__ctype_linklib.c | 24 ++++++++++++++++++++++++ compiler/clib/include/ctype.h | 6 +++--- compiler/clib/mmakefile.src | 3 ++- 4 files changed, 41 insertions(+), 23 deletions(-) create mode 100644 compiler/clib/__ctype_linklib.c diff --git a/compiler/clib/__ctype.c b/compiler/clib/__ctype.c index 37bc4e79f5..974b85c238 100644 --- a/compiler/clib/__ctype.c +++ b/compiler/clib/__ctype.c @@ -1,5 +1,5 @@ /* - Copyright © 1995-2011, The AROS Development Team. All rights reserved. + Copyright © 1995-2012, The AROS Development Team. All rights reserved. $Id$ */ @@ -506,6 +506,11 @@ const int __ctype_tolower_array[384] = }; #ifdef AROSC_SHARED +const struct arosc_ctype *__get_arosc_ctype(void) +{ + return &__get_arosc_userdata()->acud_ctype; +} + static int __ctype_init(void) { struct arosc_userdata *acud = __get_arosc_userdata(); @@ -520,24 +525,12 @@ static int __ctype_init(void) ADD2INIT(__ctype_init, 20); #endif -/* Provide local arosc ctypes for the static version of arosc */ -#ifdef AROSC_STATIC -const struct arosc_ctype __arosc_ctype = { - .b = &__ctype_b_array[128], - .toupper = &__ctype_toupper_array[128], - .tolower = &__ctype_tolower_array[128], -}; -const struct arosc_ctype *__get_arosc_ctype(void) -{ - return &__arosc_ctype; -} -#else -const struct arosc_ctype *__get_arosc_ctype(void) -{ - return &__get_arosc_userdata()->acud_ctype; -} -#endif - +/* Pointers have to be available both when in static linklib and + internally to arosc.library also +*/ +const unsigned short int * const __ctype_b = &__ctype_b_array[128]; +const int * const __ctype_toupper = &__ctype_toupper_array[128]; +const int * const __ctype_tolower = &__ctype_tolower_array[128]; /***************************************************************************** diff --git a/compiler/clib/__ctype_linklib.c b/compiler/clib/__ctype_linklib.c new file mode 100644 index 0000000000..82706658d6 --- /dev/null +++ b/compiler/clib/__ctype_linklib.c @@ -0,0 +1,24 @@ +/* + Copyright © 2012, The AROS Development Team. All rights reserved. + $Id$ +*/ + +#include +#include + +const unsigned short int *__ctype_b; +const int *__ctype_toupper; +const int *__ctype_tolower; + +static int __ctype_init(void) +{ + const struct arosc_ctype *ctype = __get_arosc_ctype(); + + __ctype_b = ctype->b; + __ctype_toupper = ctype->toupper; + __ctype_tolower = ctype->tolower; + + return 1; +} + +ADD2INIT(__ctype_init, 20); diff --git a/compiler/clib/include/ctype.h b/compiler/clib/include/ctype.h index a1bbcd8213..ee1df50d34 100644 --- a/compiler/clib/include/ctype.h +++ b/compiler/clib/include/ctype.h @@ -25,9 +25,9 @@ #define _ISpunct 0x0400 /* .,:;!? */ #define _ISalnum (_ISalpha | _ISdigit) -#define __ctype_b (__get_arosc_ctype()->b) -#define __ctype_toupper (__get_arosc_ctype()->toupper) -#define __ctype_tolower (__get_arosc_ctype()->tolower) +extern const unsigned short int * const __ctype_b; +extern const int * const __ctype_toupper; +extern const int * const __ctype_tolower; #define _istype(c,type) \ (__ctype_b[(int) (c)] & (unsigned short int) (type)) diff --git a/compiler/clib/mmakefile.src b/compiler/clib/mmakefile.src index 0f4ad56bab..1fc3a537f1 100644 --- a/compiler/clib/mmakefile.src +++ b/compiler/clib/mmakefile.src @@ -382,7 +382,8 @@ SHARED_ARCH := \ vfork_longjmp SHARED_LINKLIB := \ - arosc_environ + arosc_environ \ + __ctype_linklib # Note: These files are compiled differently # depending on whether -DAROSC_ROM is used -- 2.11.4.GIT