This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc 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: musl - and menchmarking libc


On Thu, Sep 06, 2012 at 01:17:27AM -0400, Mike Frysinger wrote:
> On Wed, Sep 5, 2012 at 10:32 PM, Rich Felker wrote:
> > On Thu, Sep 06, 2012 at 12:46:46AM +0000, Joseph S. Myers wrote:
> >> > Step 2 is necessary to support conforming applications which declare
> >> > LFS64-affected functions themselves rather than including the
> >> > associated header (which, per ISO C and POSIX, is completely valid to
> >> > do).
> >>
> >> The LFS functions are not part of POSIX, and ISO C and POSIX only allow
> >> declaring the functions yourself if the function prototype purely involves
> >> built-in C types rather than typedefs from standard headers, which also
> >> excludes most but not all of these functions.
> >
> > I'm talking about -D_FILE_OFFSET_BITS=64, not -D_LARGEFILE64_SOURCE.
> > The former is advertised by glibc as one of the POSIX compilation
> > environments, one that provides _POSIX_V6_ILP32_OFFBIG, and it's the
> > only compilation environment provided that any modern application
> > should be using on a 32-bit machine. However, it's not actually a
> > POSIX conforming environment since you can't reliably use these
> > interfaces without including the headers that do the redirection
> > (you'll instead call the 32-bit versions with the wrong prototypes,
> > thus invoking UB), and since even when you do include the headers, you
> > will pull in external symbol name pollution in the namespace reserved
> > for the application.
> 
> on the first point (not including the header file), pretty sure POSIX
> makes no such stipulation.  if you want the POSIX API, you must
> include the appropriate header.  requiring implicit decls (or even
> people copying & pasting the prototypes from the spec and putting
> "extern" before it) to "work" is bunk.

It's explicitly permitted by the standard. See XBD 2.1.1 item 4:

  "Provided that a function can be declared without reference to any
  type defined in a header, it is also permissible to declare the
  function explicitly and use it without including its associated
  header."

One could nit-pick about whether the "a header" condition disallows
this practice due to off_t, but my understanding of the intended
meaning is that, as long as you do not need the same header that
declares the function to get the type, you're free to declare it
yourself as long as the types are defined (either by being non-typedef
types or by being defined through the inclusion of a different
header).

In any case, the worst historical "offender" in this area is GNU
software...

Rich


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