hash.c and _stat variants

Corinna Vinschen vinschen@redhat.com
Wed Jan 23 08:47:00 GMT 2013

On Jan 22 15:38, Joel Sherrill wrote:
> Hi Corinna,
> I was going through my newlib patches and found where
> I had undone your change and used the version without
> the _.
> 2012-08-08  Corinna Vinschen <...>
>        * libc/search/hash.c:  Throughout use underscored variants of
> the stat
>         function family.
> RTEMS doesn't have _stat, _fstat, _stat64, _fstat64 or _mkdir. We do have
> the version without _.  Looking in sys/stat.h, it appears that these
> are part of the libgloss support but we didn't notice needing them
> until you made this change.
> RTEMS provides its own mkdir() so we can ignore _mkdir().
> But to use hash.c, we need to address the four stat calls.
> I see two possibilities:
> + Define _stat -> stat, etc.  This would be a conditional
>    in newlib's sys/stat.h.
> + Implement simple _XXX wrappers for RTEMS.
> Which would be better in your opinion?

I don't have a strong opinion.  Maybe you could simply utilize the
MISSING_SYSCALL_NAMES define, see libc/include/_syslist.h.  You could
also add an RTEMS-specific snippet to that file.

Alternatively, and IMHO most elegant, what about adding alias
definitions to your source files, along the lines of

  int stat() { ... }
  int _stat() __attribute__ ((weak, alias ("stat")));


Corinna Vinschen
Cygwin Project Co-Leader
Red Hat

More information about the Newlib mailing list