How to disable per-local string functions?

Philip Munts phil@munts.net
Mon Mar 20 12:33:00 GMT 2017


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



More information about the Newlib mailing list