* How to disable per-local string functions? @ 2017-03-19 7:25 Philip Munts 2017-03-20 10:58 ` Corinna Vinschen 0 siblings, 1 reply; 4+ messages in thread From: Philip Munts @ 2017-03-19 7:25 UTC (permalink / raw) To: newlib I have a resource constrained Cortex-M0 application that fails with newlib 2.5.0. The strncasecmp() function is now pulling in a lot of locale handling code, which I presume results from commit c1b7d9d93dc8e88693162c0d984a114371919fdd, "Implement per-locale string functions". How can I either build newlib, or build my application to use the original string functions instead of the new *_l locale handling string functions? Phil ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How to disable per-local string functions? 2017-03-19 7:25 How to disable per-local string functions? Philip Munts @ 2017-03-20 10:58 ` Corinna Vinschen 2017-03-20 12:33 ` Philip Munts 0 siblings, 1 reply; 4+ messages in thread From: Corinna Vinschen @ 2017-03-20 10:58 UTC (permalink / raw) To: newlib; +Cc: Philip Munts [-- Attachment #1: Type: text/plain, Size: 1262 bytes --] On Mar 19 08:24, Philip Munts wrote: > I have a resource constrained Cortex-M0 application that fails with > newlib 2.5.0. The strncasecmp() function is now pulling in a lot of > locale handling code, which I presume results from commit > c1b7d9d93dc8e88693162c0d984a114371919fdd, "Implement per-locale string > functions". > > How can I either build newlib, or build my application to use the > original string functions instead of the new *_l locale handling > string functions? strncasecmp does not use strncasecmp_l. It just calls tolower, which calls isupper, which in turn calls a function accessing the __global_locale struct. I *think* the problem is that this pulls in all of libc/locale/locale.c, so the problem could perhaps alleviated by moving __locale_ctype_ptr() and the __global_locale struct to separate files...? When I implemented this functionality I asked specificially for input from users of small targets. I tried to keep the footprint as small as possible, but there's very likely room for further improvement. So, here's my request again: If somebody has problems with the size of the code due to the locale stuff, please provide patches. Corinna -- Corinna Vinschen Cygwin Maintainer Red Hat [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 819 bytes --] ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How to disable per-local string functions? 2017-03-20 10:58 ` Corinna Vinschen @ 2017-03-20 12:33 ` Philip Munts 2017-03-21 0:12 ` Hans-Bernhard Bröker 0 siblings, 1 reply; 4+ messages in thread From: Philip Munts @ 2017-03-20 12:33 UTC (permalink / raw) To: newlib On 03/20/2017 11:58 AM, Corinna Vinschen wrote: > On Mar 19 08:24, Philip Munts wrote: >> I have a resource constrained Cortex-M0 application that fails with >> newlib 2.5.0. The strncasecmp() function is now pulling in a lot of >> locale handling code, which I presume results from commit >> c1b7d9d93dc8e88693162c0d984a114371919fdd, "Implement per-locale string >> functions". >> >> How can I either build newlib, or build my application to use the >> original string functions instead of the new *_l locale handling >> string functions? > > strncasecmp does not use strncasecmp_l. It just calls tolower, which > calls isupper, which in turn calls a function accessing the > __global_locale struct. I *think* the problem is that this pulls in all > of libc/locale/locale.c, so the problem could perhaps alleviated by > moving __locale_ctype_ptr() and the __global_locale struct to separate > files...? > > When I implemented this functionality I asked specificially for input > from users of small targets. I tried to keep the footprint as small as > possible, but there's very likely room for further improvement. > > So, here's my request again: If somebody has problems with the size > of the code due to the locale stuff, please provide patches. > > Corinna tolower() and isupper() both must be getting inlined. Here is the fragment of disassembly code that made me think I was getting strncasecmp_l() instead of strncasecmp: 00004808 <strncasecmp>: 4808: b5f0 push {r4, r5, r6, r7, lr} 480a: 464f mov r7, r9 480c: 46d6 mov lr, sl 480e: 4646 mov r6, r8 4810: 4682 mov sl, r0 4812: b5c0 push {r6, r7, lr} 4814: 4689 mov r9, r1 4816: 4690 mov r8, r2 4818: 2500 movs r5, #0 481a: 2703 movs r7, #3 481c: 2a00 cmp r2, #0 481e: d110 bne.n 4842 <strncasecmp+0x3a> 4820: e023 b.n 486a <strncasecmp+0x62> 4822: 464b mov r3, r9 4824: 5d5e ldrb r6, [r3, r5] 4826: f000 fc8b bl 5140 <__locale_ctype_ptr> 482a: 1980 adds r0, r0, r6 482c: 7843 ldrb r3, [r0, #1] tolower() and isupper() as functions are nowhere to be found in my assembly code. For now I'll just use a private implementation of strncasecmp() that calls _tolower(). Phil ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How to disable per-local string functions? 2017-03-20 12:33 ` Philip Munts @ 2017-03-21 0:12 ` Hans-Bernhard Bröker 0 siblings, 0 replies; 4+ messages in thread From: Hans-Bernhard Bröker @ 2017-03-21 0:12 UTC (permalink / raw) To: newlib Am 20.03.2017 um 13:33 schrieb Philip Munts: > On 03/20/2017 11:58 AM, Corinna Vinschen wrote: >> On Mar 19 08:24, Philip Munts wrote: > tolower() and isupper() both must be getting inlined. Close, but not quite. Like most of <ctype.h>'s public interfaces typically are, they're macros. So they generate in-line code by definition, not by inlining or optimization. They do however refer to locale-specific tables to find properties of given characters. Those tables are managed by the <locale.h> machinery. That's the __locale_ctype_ptr you see in your assembly listing. And yes, that will drag in a large part, if not all, of the locale implementation without anyone having much of a choice about it. By definition of Standard C the <ctype.h> functions are locale-sensitive, after all. The only way to avoid all the memory consumption that goes with this would be to build the library with support for the 'C' locale only. I don't think there's a configure-time option for that. ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-03-21 0:12 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2017-03-19 7:25 How to disable per-local string functions? Philip Munts 2017-03-20 10:58 ` Corinna Vinschen 2017-03-20 12:33 ` Philip Munts 2017-03-21 0:12 ` Hans-Bernhard Bröker
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).