public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: Philip Munts <phil@munts.net>
To: newlib@sourceware.org
Subject: Re: How to disable per-local string functions?
Date: Mon, 20 Mar 2017 12:33:00 -0000	[thread overview]
Message-ID: <d97f2673-fdc4-64b1-2a8b-aa958cba72af@munts.net> (raw)
In-Reply-To: <20170320105804.GI16777@calimero.vinschen.de>

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

  reply	other threads:[~2017-03-20 12:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-19  7:25 Philip Munts
2017-03-20 10:58 ` Corinna Vinschen
2017-03-20 12:33   ` Philip Munts [this message]
2017-03-21  0:12     ` Hans-Bernhard Bröker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d97f2673-fdc4-64b1-2a8b-aa958cba72af@munts.net \
    --to=phil@munts.net \
    --cc=newlib@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).