mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Isaac Dunham <idunham@lavabit.com>
To: musl@lists.openwall.com
Subject: Re: _BSD_SOURCE support for musl ready
Date: Mon, 21 May 2012 10:19:26 -0700	[thread overview]
Message-ID: <20120521101926.52f4aab2@newbook> (raw)
In-Reply-To: <20120521133629.GA9215@brightrain.aerifal.cx>

On Mon, 21 May 2012 09:36:29 -0400
Rich Felker <dalias@aerifal.cx> wrote:

> On Sun, May 20, 2012 at 11:26:51PM -0700, Isaac Dunham wrote:
> > I think the _BSD_SOURCE support is ready to merge now.
> 
> Great. Quick review; not sure I caught all the issues...
> 
> > diff --git a/include/fcntl.h b/include/fcntl.h
> > index 63f1beb..b776d38 100644
> > --- a/include/fcntl.h
> > +++ b/include/fcntl.h
> > [...]
> > +
> > +#ifndef _UNISTD_H
> > +#define F_OK 0
> > +#define R_OK 4
> > [...]
> 
> All _XXX_H macros should be considered entirely internal to the header
> they're used to protect. Aside from that, this sort of mechanism makes
> the logic in unistd.h very ugly (since it would have to check if
> fcntl.h was already included with _GNU_SOURCE or _BSD_SOURCE defined).
> 
> Since the definitions are exactly the same, multiple #defines are
> legal in C. If they work in C++ too, and if the compiler does not
> issue ugly warnings, I would just leave it be. Otherwise you could
> #undef them all first, or use #ifdef F_OK.
Will use #ifdef F_OK, I think. 
> > diff --git a/include/netdb.h b/include/netdb.h
> > index 33b7a0a..d1fe9a8 100644
> > --- a/include/netdb.h
> > +++ b/include/netdb.h
> > @@ -5,7 +5,7 @@
> > [...]
> > +
> > +int innetgr(const char *, const char *, const char *, const char
> > *);
> 
> This should be a separate patch, and should add stubs for the rest of
> the netgr functions at the same time (weak aliases in ent.c). Of
> course innetgr needs to be in its own file since it's not a weak alias
> and would pollute the standard namespace if put in ent.c.
OK.
I've put innetgr in its own file under src/stubs/
This probably means I'd need to change logwtmp, also (I had it in
stubs/utmpx.c)
> > diff --git a/include/signal.h b/include/signal.h
> > [...]
> > -#ifdef _GNU_SOURCE
> > +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
> >  typedef void (*sighandler_t)(int);
> > +typedef sighandler_t sig_t;
> >  void (*bsd_signal(int, void (*)(int)))(int);
> > +#endif
> 
> I think sig_t should be BSD-only. That's how it is in glibc, and since
> it's so illogically named and short, I'd rather keep it out of the
> namespace even with _GNU_SOURCE.
> 
> In glibc, sighandler_t is GNU-only (not in BSD). So it might make
> sense to just have these be separate #ifdefs.

Maybe.

> > diff --git a/include/string.h b/include/string.h
> > index 8cf0ee9..9715713 100644
> > --- a/include/string.h
> > +++ b/include/string.h
> > [...]
> >  
> > +#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
> > +int bcmp (const void *, const void *, size_t);
> > +void bcopy (const void *, void *, size_t);
> > +void bzero (void *, size_t);
> > +int strcasecmp (const char *, const char *);
> > +int strncasecmp (const char *, const char *, size_t);
> > +char *index (const char *, int);
> > +char *rindex (const char *, int);
> > +int ffs (int);
> > +#endif
> 
> Wasn't all of this already coming from strings.h?

I think I did that before _GNU_SOURCE included strings.h ...

By the way, I noticed that strings.h seems to be specified (without
bzero & co.) in X/Open 2008. I'm inclined to test like so:

#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE) \
 || !defined(_XOPEN_SOURCE)

That way, the X/Open namespace is respected, but -D_BSD_SOURCE
-D_XOPEN_SOURCE will get everything.

> That was just from a quick glance, so there might be some other issues
> remaining, but overall it looks good. Thanks!
Whitespace, I think.

Iswaac Dunham



  reply	other threads:[~2012-05-21 17:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-21  6:26 Isaac Dunham
2012-05-21 12:42 ` Isaac Dunham
2012-05-21 13:36 ` Rich Felker
2012-05-21 17:19   ` Isaac Dunham [this message]
2012-05-21 17:43     ` Rich Felker
2012-05-21 18:31   ` [PATCH]_BSD_SOURCE for musl, take 2 Isaac Dunham
2012-05-22 15:22     ` Rich Felker
2012-05-22 23:19       ` Isaac Dunham

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120521101926.52f4aab2@newbook \
    --to=idunham@lavabit.com \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).