EmbDev.net

Forum: ARM programming with GCC/GNU tools What is _impure_ptr?


Author: jrmymllr jrmymllr (jrmymllr)
Posted on:

Rate this post
0 useful
not useful
I'm using Codesourcery, and noticed that something called

...arm-none-eabi/lib/thumb2\libc.a(lib_a-impure.o)

is using 0xF4 bytes of RAM.  I have no idea what this is, why it's using
RAM, and haven't found anything with web searches either.  Does anyone
know what this is, and if I can get rid of it, how?  I could put that
memory to better use if I can free it.

Author: Clifford Slocombe (clifford)
Posted on:

Rate this post
0 useful
not useful
Jerry Milner wrote:
> I'm using Codesourcery, and noticed that something called
>
> ...arm-none-eabi/lib/thumb2\libc.a(lib_a-impure.o)
>
> is using 0xF4 bytes of RAM.  I have no idea what this is, why it's using
> RAM, and haven't found anything with web searches either.  Does anyone
> know what this is, and if I can get rid of it, how?  I could put that
> memory to better use if I can free it.

It is part of libc.a (the Newlib C library). Newlib is open source, so
you could see for yourself. This is the content of impure.c (from which
impure.o is compiled).
-----------------------------
#include <reent.h>

/* Note that there is a copy of this in sys/reent.h.  */
#ifndef _ATTRIBUTE_IMPURE_PTR_
#define _ATTRIBUTE_IMPURE_PTR_
#endif

#ifndef _ATTRIBUTE_IMPURE_DATA_
#define _ATTRIBUTE_IMPURE_DATA_
#endif

static struct reent __ATTRIBUTE_IMPURE_DATA_ impure_data = _REENT_INIT
(impure_data);
struct _reent *__ATTRIBUTE_IMPURE_PTR__ _impure_ptr = &impure_data;
-----------------------------

As you can see it comprises a structure and a pointer to that structure.
The structure itself is large and defined in reent.h. I would suggest
that you mess with it at your peril, but if you do you will have to
rebuild the library in any case.

The question of how to remove reentrancy support from Newlib was asked
here:
http://www.codesourcery.com/archives/coldfire-gnu-...,
the answer was that it could not be done (easily).

Clifford

Author: jrmymllr jrmymllr (jrmymllr)
Posted on:

Rate this post
0 useful
not useful
Clifford Slocombe wrote:
>
> It is part of libc.a (the Newlib C library). Newlib is open source, so
> you could see for yourself. This is the content of impure.c (from which
> impure.o is compiled).

> -----------------------------
>
> As you can see it comprises a structure and a pointer to that structure.
> The structure itself is large and defined in reent.h. I would suggest
> that you mess with it at your peril, but if you do you will have to
> rebuild the library in any case.
>
> The question of how to remove reentrancy support from Newlib was asked
> here:
> http://www.codesourcery.com/archives/coldfire-gnu-...,
> the answer was that it could not be done (easily).
>
> Clifford

I tried commenting out my one use of atoi() and I got back 0xF8 bytes
RAM!  I had intended on commenting out that, in addition to memcpy,
strcmp, memset, etc, but atoi was the first one I tried.

Author: Clifford Slocombe (clifford)
Posted on:

Rate this post
0 useful
not useful
> I tried commenting out my one use of atoi() and I got back 0xF8 bytes
> RAM!  I had intended on commenting out that, in addition to memcpy,
> strcmp, memset, etc, but atoi was the first one I tried.

atoi() is not defined as setting errno, but neither is it guaranteed
that it does not. It is likely that it is defined in terms of strtol() -
as it is equivalent to (int)strtol(s, 0, 10) - because strtol()
explicitly sets errno, then so may atoi().

You will loose that 0xF8 bytes as soon as you use anything that uses
errno directly or indirectly.

Clifford

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.