mailing list of musl libc
 help / color / mirror / code / Atom feed
* [PATCH] add _DIRENT_HAVE_D_* constants to dirent.h
@ 2016-01-13 18:09 Felix Janda
  2016-01-14 22:44 ` Rich Felker
  0 siblings, 1 reply; 4+ messages in thread
From: Felix Janda @ 2016-01-13 18:09 UTC (permalink / raw)
  To: musl

they can be used for checking existence of non-standard fields of
struct dirent, are used by various programs to avoid configure
checks and are at least present on glibc, uclibc, dietlibc and
newlib.
---
The motivation for this patch is

http://oss.sgi.com/archives/xfs/2016-01/msg00388.html
---
 include/dirent.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/dirent.h b/include/dirent.h
index 5aa8510..b2ffe8a 100644
--- a/include/dirent.h
+++ b/include/dirent.h
@@ -57,6 +57,9 @@ int getdents(int, struct dirent *, size_t);
 #endif
 
 #ifdef _GNU_SOURCE
+#define _DIRENT_HAVE_D_OFF
+#define _DIRENT_HAVE_D_RECLEN
+#define _DIRENT_HAVE_D_TYPE
 int versionsort(const struct dirent **, const struct dirent **);
 #endif
 
-- 
2.4.10


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] add _DIRENT_HAVE_D_* constants to dirent.h
  2016-01-13 18:09 [PATCH] add _DIRENT_HAVE_D_* constants to dirent.h Felix Janda
@ 2016-01-14 22:44 ` Rich Felker
  2016-01-15  2:27   ` Rich Felker
  0 siblings, 1 reply; 4+ messages in thread
From: Rich Felker @ 2016-01-14 22:44 UTC (permalink / raw)
  To: musl

On Wed, Jan 13, 2016 at 07:09:19PM +0100, Felix Janda wrote:
> they can be used for checking existence of non-standard fields of
> struct dirent, are used by various programs to avoid configure
> checks and are at least present on glibc, uclibc, dietlibc and
> newlib.
> ---
> The motivation for this patch is
> 
> http://oss.sgi.com/archives/xfs/2016-01/msg00388.html
> ---
>  include/dirent.h | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/include/dirent.h b/include/dirent.h
> index 5aa8510..b2ffe8a 100644
> --- a/include/dirent.h
> +++ b/include/dirent.h
> @@ -57,6 +57,9 @@ int getdents(int, struct dirent *, size_t);
>  #endif
>  
>  #ifdef _GNU_SOURCE
> +#define _DIRENT_HAVE_D_OFF
> +#define _DIRENT_HAVE_D_RECLEN
> +#define _DIRENT_HAVE_D_TYPE
>  int versionsort(const struct dirent **, const struct dirent **);
>  #endif

I like the concept of defining macros to publish the availability of
extensions like this, but I don't think they should be dependent on
_GNU_SOURCE. At the very least they should also be available under
_DEFAULT_SOURCE (_BSD_SOURCE), but since they're in the reserved
namespace (underscore followed by capital) I'd prefer to have them
exposed unconditionally.

I'm also skeptical of whether d_off and d_reclen should be promoted as
public APIs. They don't seem to be useful (unlike d_type which is
highly useful) and may lock down some assumptions about
implementation.

Rich


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] add _DIRENT_HAVE_D_* constants to dirent.h
  2016-01-14 22:44 ` Rich Felker
@ 2016-01-15  2:27   ` Rich Felker
  2016-01-15 16:20     ` Felix Janda
  0 siblings, 1 reply; 4+ messages in thread
From: Rich Felker @ 2016-01-15  2:27 UTC (permalink / raw)
  To: musl

On Thu, Jan 14, 2016 at 05:44:49PM -0500, Rich Felker wrote:
> On Wed, Jan 13, 2016 at 07:09:19PM +0100, Felix Janda wrote:
> > they can be used for checking existence of non-standard fields of
> > struct dirent, are used by various programs to avoid configure
> > checks and are at least present on glibc, uclibc, dietlibc and
> > newlib.
> > ---
> > The motivation for this patch is
> > 
> > http://oss.sgi.com/archives/xfs/2016-01/msg00388.html
> > ---
> >  include/dirent.h | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/include/dirent.h b/include/dirent.h
> > index 5aa8510..b2ffe8a 100644
> > --- a/include/dirent.h
> > +++ b/include/dirent.h
> > @@ -57,6 +57,9 @@ int getdents(int, struct dirent *, size_t);
> >  #endif
> >  
> >  #ifdef _GNU_SOURCE
> > +#define _DIRENT_HAVE_D_OFF
> > +#define _DIRENT_HAVE_D_RECLEN
> > +#define _DIRENT_HAVE_D_TYPE
> >  int versionsort(const struct dirent **, const struct dirent **);
> >  #endif
> 
> I like the concept of defining macros to publish the availability of
> extensions like this, but I don't think they should be dependent on
> _GNU_SOURCE. At the very least they should also be available under
> _DEFAULT_SOURCE (_BSD_SOURCE), but since they're in the reserved
> namespace (underscore followed by capital) I'd prefer to have them
> exposed unconditionally.
> 
> I'm also skeptical of whether d_off and d_reclen should be promoted as
> public APIs. They don't seem to be useful (unlike d_type which is
> highly useful) and may lock down some assumptions about
> implementation.

Perhaps to make a discussion of this more concrete: is there other
software that's using the d_reclen or d_off fields conditionally on
having the above macros defined? What is is using them for?

I read the above-linked mailing list discussion and I think the
autoconf test is a better approach than depending on the macros (since
they're not present on older musl or on other non-glibc libcs/systems)
but we should probably add at least _DIRENT_HAVE_D_TYPE and perhaps
the others too.

Rich


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] add _DIRENT_HAVE_D_* constants to dirent.h
  2016-01-15  2:27   ` Rich Felker
@ 2016-01-15 16:20     ` Felix Janda
  0 siblings, 0 replies; 4+ messages in thread
From: Felix Janda @ 2016-01-15 16:20 UTC (permalink / raw)
  To: musl

Rich Felker wrote:
> On Thu, Jan 14, 2016 at 05:44:49PM -0500, Rich Felker wrote:
> > On Wed, Jan 13, 2016 at 07:09:19PM +0100, Felix Janda wrote:
> > > they can be used for checking existence of non-standard fields of
> > > struct dirent, are used by various programs to avoid configure
> > > checks and are at least present on glibc, uclibc, dietlibc and
> > > newlib.
> > > ---
> > > The motivation for this patch is
> > > 
> > > http://oss.sgi.com/archives/xfs/2016-01/msg00388.html
> > > ---
> > >  include/dirent.h | 3 +++
> > >  1 file changed, 3 insertions(+)
> > > 
> > > diff --git a/include/dirent.h b/include/dirent.h
> > > index 5aa8510..b2ffe8a 100644
> > > --- a/include/dirent.h
> > > +++ b/include/dirent.h
> > > @@ -57,6 +57,9 @@ int getdents(int, struct dirent *, size_t);
> > >  #endif
> > >  
> > >  #ifdef _GNU_SOURCE
> > > +#define _DIRENT_HAVE_D_OFF
> > > +#define _DIRENT_HAVE_D_RECLEN
> > > +#define _DIRENT_HAVE_D_TYPE
> > >  int versionsort(const struct dirent **, const struct dirent **);
> > >  #endif
> > 
> > I like the concept of defining macros to publish the availability of
> > extensions like this, but I don't think they should be dependent on
> > _GNU_SOURCE. At the very least they should also be available under
> > _DEFAULT_SOURCE (_BSD_SOURCE), but since they're in the reserved
> > namespace (underscore followed by capital) I'd prefer to have them
> > exposed unconditionally.

I see.

> > I'm also skeptical of whether d_off and d_reclen should be promoted as
> > public APIs. They don't seem to be useful (unlike d_type which is
> > highly useful) and may lock down some assumptions about
> > implementation.
> 
> Perhaps to make a discussion of this more concrete: is there other
> software that's using the d_reclen or d_off fields conditionally on
> having the above macros defined? What is is using them for?

I had not checked specifically how much each macro is used. (I'm using
debian codesearch.) _DIRENT_HAVE_D_TYPE seems to be used the most
often. The only other (apart from xfsprogs) use of the others is in
glusterfs:

http://sources.debian.net/src/glusterfs/3.7.6-1/api/src/glfs-fops.c

It seems to be used in the glfs_readdir* functions to convert the
internal gf_dirent structure to the usual dirent. Likely few people
rely on the d_reclen or d_off from a dirent received via
glfs_readdir*...

> I read the above-linked mailing list discussion and I think the
> autoconf test is a better approach than depending on the macros (since
> they're not present on older musl or on other non-glibc libcs/systems)

They seem to be present on most libcs on linux.

> but we should probably add at least _DIRENT_HAVE_D_TYPE and perhaps
> the others too.

Thanks,
Felix


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-01-15 16:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-13 18:09 [PATCH] add _DIRENT_HAVE_D_* constants to dirent.h Felix Janda
2016-01-14 22:44 ` Rich Felker
2016-01-15  2:27   ` Rich Felker
2016-01-15 16:20     ` Felix Janda

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).