This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: _REENT


Raphael Derosso Pereira wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I'm working with FreeRTOS and want to use _REENT, but I don't know how
to setup this in a multithread environment. Is there any function that
can be used to specify the current _REENT structure on context switch?

All that is needed is to set the global variable: _impure_ptr to a new reentrancy structure you have previously
initialized via the _REENT_INIT() macro. See libc/reent/impure.c You can do this manually in your
thread switching logic or you can do the following:


If you set the flag __DYNAMIC_REENT__ for your platform, newlib functions
requiring reentrancy will call __getreent() to get the reentrancy structure for the current thread automatically. You need to supply this function and how it is implemented is up to you. One way would be using thread-specific storage if you support it. Another way would be to use a global hash table or array indexed by thread-id. It's up to you. You would register a new reentrancy structure on thread creation. Typically you set
the __DYNAMIC_REENT__ flag in libc/include/sys/config.h.


If you don't use __DYNAMIC_REENT__, then you either have to set _impure_ptr manually or else you can use the reentrant versions of the newlib functions and call with the appropriate reentrancy structure as a parameter.

-- Jeff J.
- --
Raphael Derosso Pereira
Engenheiro de Computação
icq: 4517421
msn: rderossopereira@hotmail.com
Skype: rderossopereira

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: http://getfiregpg.org

iD8DBQFIf2EJYcVjciDA62QRAnQKAKDwulaD/g08Hc+HEvtPN/443kSQ6gCfUgYM
hadVmX/my9M45A50/FMPUr8=
=K8iu
-----END PGP SIGNATURE-----


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]