[PATCH] Add __pure2 to __locale_ctype_ptr
Corinna Vinschen
vinschen@redhat.com
Tue Oct 24 15:19:00 GMT 2017
On Oct 23 17:16, Wilco Dijkstra wrote:
> The newlib ctype functons are extremely inefficient due to repeatedly
> calling __locale_ctype_ptr for every single use of a ctype macro, even
> in a tight loop. Improve this by adding the missing __pure2 attribute so
> the pointer can be cached just like in GLIBC, resulting in > 2x speedup
> in loops.
>
> I haven't looked in detail at the implementation, but in general you don't
> need a function call - a variable, thread-local if required, would be simpler,
> even faster and cache automatically.
>
> ChangeLog:
> 2017-10-22 Wilco Dijkstra <wdijkstr@arm.com>
>
> * newlib/libc/include/ctype.h (__locale_ctype_ptr): Add __pure2.
>
> --
> diff --git a/newlib/libc/include/ctype.h b/newlib/libc/include/ctype.h
> index 06458cbda47abe1294ebe226a16981fc9f38254d..e08120e88841eed77d2953e6a5f2f954f10de1e7 100644
> --- a/newlib/libc/include/ctype.h
> +++ b/newlib/libc/include/ctype.h
> @@ -66,7 +66,7 @@ extern int toascii_l (int __c, locale_t __l);
> #define _X 0100
> #define _B 0200
>
> -const char *__locale_ctype_ptr (void);
> +const char *__locale_ctype_ptr (void) __pure2;
> # define __CTYPE_PTR (__locale_ctype_ptr ())
>
> #ifndef __cplusplus
Same for __locale_ctype_ptr_l() I guess?
Thanks.
Corinna
--
Corinna Vinschen
Cygwin Maintainer
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/newlib/attachments/20171024/53438705/attachment.sig>
More information about the Newlib
mailing list