This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Re: __getreent in libgloss
- From: Jeff Johnston <jjohnstn at redhat dot com>
- To: Stefan Wallentowitz <stefan dot wallentowitz at tum dot de>
- Cc: newlib at sourceware dot org
- Date: Mon, 3 Nov 2014 16:50:38 -0500 (EST)
- Subject: Re: __getreent in libgloss
- Authentication-results: sourceware.org; auth=none
- References: <5457880D dot 9040602 at tum dot de>
----- Original Message -----
> From: "Stefan Wallentowitz" <stefan.wallentowitz@tum.de>
> To: newlib@sourceware.org
> Sent: Monday, November 3, 2014 8:50:05 AM
> Subject: __getreent in libgloss
>
> Dear all,
>
> I am currently porting (baremetal) libgloss/newlib for OpenRISC (or1k).
> I want to use dynamic reentrancy and think I basically understood it.
> Can you please confirm that the following steps are correct and the
> proper way to go:
>
> I specify __DYNAMIC_REENT__ for the machine in
> newlib/libc/include/sys/config.h.
Correct.
> I also set
> newlib_cflags="${newlib_cflags} -DREENTRANT_SYSCALLS_PROVIDED " and
> syscall_dir=syscalls in configure.host for the target.
Sure, this means that you are supplying _r syscalls which is good. I assume
you have read libc/include/reent.h for the various alternatives.
> By default newlib
> takes __getreent() and I can overwrite __getreent to my own function.
> Where should I do this? I set it in config.h (#define __getreent
> or1k_getreent), but then I also need to define the external function
> (extern struct _reent *or1k_getreent(void)), correct?
Actually, overriding is much easier. Newlib is designed to override shared functions with ones
that are found in the libc/machine or libc/sys directories. In your case, if
you have a getreent.c or getreent.S that is found in libc/machine/or1k (or whatever you designate
your machine_dir in configure.host), it will override the object file built in libc/reent.
If you don't actually have multiple threads, you might as well just use the
default one found in libc/reent. There is a sample multithread version in
libc/sys/linux/linuxthreads/getreent.c which uses the thread specific storage
to get the current reentrancy structure for the current thread.
-- Jeff J.
>
> Thanks for your help.
>
> Best regards,
> Stefan
>
>