odd bits in the tree

Werner Almesberger almesber@lrc.epfl.ch
Tue Aug 22 15:22:00 GMT 2000

When browsing through the newlib tree, I noticed two things that strike
me as a little odd:
 - there are plenty of "standard" prototypes that are declared
   several times in libc/sys/*/sys (e.g. dirent.h), and sometimes also
   in libc/include/sys/*.h (e.g. stat.h)
 - libc/machine/i386 contains lots of functions that belong to libm

One side-effect of the latter is that libc needs symbols from libm
(e.g. powf, infinity), which fails my shared library build. I can work
around this, but I wonder if it wouldn't be cleaner to move them into
some yet to be created libm/machine instead ?

For the standard prototypes, let's examine dirent.h:
 - cygwin, decstation, go32, rtems, sparc64, sun4, and sysvi386 all
   declare opendir, readdir, rewinddir, and closedir conforming to 1003.1
 - cygwin declares telldir, seekdir, scandir, and alphasort unless
   _POSIX_SOURCE is defined, which is good
 - go32 and rtems declare telldir and seekdir unconditionally, which is
   probably not so good

Wouldn't it be better to have a single file, say sys/std_dirent.h, with
the cygwin prototypes, which could then be included by the others ?
(The simpler solution of declaring the prototypes in include/dirent.h
would break the include_next mechanism in the default include/sys/dirent.h,
so this does't seem to be an option.)

Also, opendir is always declared with  DIR *opendir (const char *);
Shouldn't that be _CONST ?

sys/errno.h, sys/stat.h, and sys/utmp.h have issues similar to

I can make patches if there's interest in changing some of these things.

- Werner

 / Werner Almesberger, ICA, EPFL, CH       werner.almesberger@ica.epfl.ch /

More information about the Newlib mailing list