From owner-freebsd-hackers@FreeBSD.ORG Tue Mar 4 15:47:29 2008 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A3E551065671; Tue, 4 Mar 2008 15:47:29 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from igloo.linux.gr (igloo.linux.gr [62.1.205.36]) by mx1.freebsd.org (Postfix) with ESMTP id 17B438FC15; Tue, 4 Mar 2008 15:47:28 +0000 (UTC) (envelope-from keramida@ceid.upatras.gr) Received: from kobe.laptop (vader.bytemobile-rio.ondsl.gr [83.235.57.37]) (authenticated bits=128) by igloo.linux.gr (8.14.1/8.14.1/Debian-9) with ESMTP id m24FjnAK000870 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 4 Mar 2008 17:46:06 +0200 Received: from kobe.laptop (kobe.laptop [127.0.0.1]) by kobe.laptop (8.14.2/8.14.2) with ESMTP id m24FjhBd088498; Tue, 4 Mar 2008 17:45:43 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Received: (from keramida@localhost) by kobe.laptop (8.14.2/8.14.2/Submit) id m24Fjh30088497; Tue, 4 Mar 2008 17:45:43 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Date: Tue, 4 Mar 2008 17:45:43 +0200 From: Giorgos Keramidas To: Robert Watson Message-ID: <20080304154542.GC61036@kobe.laptop> References: <20080303.224256.635730757.imp@bsdimp.com> <20080304151326.J41184@fledge.watson.org> <20080304.083350.1661915009.imp@bsdimp.com> <20080304153651.I41184@fledge.watson.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20080304153651.I41184@fledge.watson.org> X-Hellug-MailScanner: Found to be clean X-Hellug-MailScanner-SpamCheck: not spam, SpamAssassin (not cached, score=-3.976, required 5, autolearn=not spam, ALL_TRUSTED -1.80, AWL 0.42, BAYES_00 -2.60) X-Hellug-MailScanner-From: keramida@ceid.upatras.gr X-Spam-Status: No Cc: hackers@freebsd.org Subject: Re: Comments on pmake diffs for building on Linux X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Mar 2008 15:47:29 -0000 On 2008-03-04 15:38, Robert Watson wrote: > On Tue, 4 Mar 2008, M. Warner Losh wrote: > >> : In most ports of FreeBSD parts to Linux that I've seen, the preferred solution >> : has to been to bring the entire FreeBSD queue.h with you rather than relying >> : on the native Linux queue.h. This is what we do for OpenBSM, for example; >> : this also helps out when you get to Mac OS X, Solaris, etc, where all the >> : queue.h's continue to vary in subtle ways. This depends a fair amount on a >> : lack of header pollution in the OS's own include files, of course... >> >> I was rather hoping for something that could be used without any of that >> nonsense... > > Sadly, nonsense seems to be the name of the game in software portability. > Here's the broken autoconf garbage I use to pick out adequate queue.h's > from inadequate ones: > > # sys/queue.h exists on most systems, but its capabilities vary a great deal. > # test for LIST_FIRST and TAILQ_FOREACH_SAFE, which appears to not exist in > # all of them, and are necessary for OpenBSM. > AC_TRY_LINK([ > #include > ], [ > > #ifndef LIST_FIRST > #error LIST_FIRST missing > #endif > #ifndef TAILQ_FOREACH_SAFE > #error TAILQ_FOREACH_SAFE > #endif > ], [ > AC_DEFINE(HAVE_FULL_QUEUE_H,, Define if queue.h includes LIST_FIRST) > ]) > > Note that there are at least a couple of mostly stylistic bugs there (could > use compile rather than link, definition description is poor, errors are > inconsistent). :-) I found that on both Linux and Mac OS X, the queue.h's > didn't have everything I wanted. Nice! Thank you Robert. Can I copy parts of this and add them to the autoconf glue I'm adding now? To test just cpp(1) stuff, autoconf supports AC_PREPROC_IFELSE() too, which I used when I tried writing a check for __FBSDID(): AC_PREPROC_IFELSE( [AC_LANG_PROGRAM([[#include #ifndef __FBSDID #error No __FBSDID definition. #endif]])], [AC_DEFINE([HAVE_FBSDID_MACRO], [1], [Define to 1 if you have the __FBSDID macro.])]) I can probably improve a bit the queue.h check using what you wrote above and AC_PREPROC_IFELSE().