Date: Tue, 4 Mar 2008 10:30:39 +0200 From: Giorgos Keramidas <keramida@ceid.upatras.gr> To: "M. Warner Losh" <imp@bsdimp.com> Cc: hackers@freebsd.org Subject: Re: Comments on pmake diffs for building on Linux Message-ID: <20080304083038.GB90914@kobe.laptop> Resent-Message-ID: <20080304114950.GB1983@kobe.laptop> In-Reply-To: <20080303.224256.635730757.imp@bsdimp.com> References: <20080303.224256.635730757.imp@bsdimp.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On 2008-03-03 22:42, "M. Warner Losh" <imp@bsdimp.com> wrote: > Greetings, > > here's a set of diffs that will allow FreeBSD's usr.bin/make to build > on Linux. I'm sure they are gross, and I don't plan to commit them > (at least not all of them), but I thought I'd post them here to see > what people think. > > I think that the extra config.h includes, the errc -> errx patches and > the Makefile.dist patches may be good for the tree. The rest may not > meet FreeBSD's source tree policies. > > Comments? > > Warner > > diff -ur pmake.orig/config.h pmake/config.h > --- pmake.orig/config.h 2005-02-01 03:50:35.000000000 -0700 > +++ pmake/config.h 2008-03-03 22:24:16.745493000 -0700 > @@ -108,4 +108,27 @@ > # endif > #endif > > +#ifndef TAILQ_HEAD_INITIALIZER > +#define TAILQ_HEAD_INITIALIZER(head) { NULL, &(head).tqh_first } > +#endif > + > +#ifndef TAILQ_FOREACH > +#define TAILQ_FOREACH(var, head, field) \ > + for ((var) = TAILQ_FIRST((head)); \ > + (var); \ > + (var) = TAILQ_NEXT((var), field)) > +#endif > + > +#ifndef TAILQ_FIRST > +#define TAILQ_FIRST(head) ((head)->tqh_first) > +#endif > + > +#ifndef TAILQ_NEXT > +#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) > +#endif > + > +#ifndef TAILQ_EMPTY > +#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL) > +#endif > + > #endif /* config_h_efe0765e */ In a Solaris-based project I'm involved with, I used our own "queue.h" pretty much verbatim. Only STAILQ_LAST() seems to use __offsetof(), which may be a bit tricky to 'port over'. That's not to say that I don't like the above change, but I am just `thinking aloud' about the possibility of importing sys/queue.h into `http://hg.hellug.gr/bmake' to avoid the need for the #ifdef trick. The TAILQ_*() macros are pretty simple, so it's fairly easy to copy them verbatim. In the long run, they may get `stale' though, so a full import of sys/queue.h looks like a `safe' thing. It also stands a chance of working on Solaris, which doesn't have a sys/queue.h header at all. > --- pmake.orig/main.c 2007-12-18 15:58:14.000000000 -0700 > +++ pmake/main.c 2008-03-03 22:25:47.543349000 -0700 > @@ -660,11 +664,9 @@ > int level = (value == NULL) ? 0 : atoi(value); > > if (level < 0) { > - errc(2, EAGAIN, "Invalid value for recursion level (%d).", > - level); > + errx(2, "Invalid value for recursion level (%d).", level); > } else if (level > MKLVL_MAXVAL) { > - errc(2, EAGAIN, "Max recursion level (%d) exceeded.", > - MKLVL_MAXVAL); > + errx(2, "Max recursion level (%d) exceeded.", MKLVL_MAXVAL); > } else { > char new_value[32]; > sprintf(new_value, "%d", level + 1); Hohoho! I didn't realize errx() was already available on Linux. Last night, when I ran `man errx' there was no manpage, but I forgot that glibc prefers Info manuals :) Nice...
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080304083038.GB90914>