From owner-freebsd-arch@FreeBSD.ORG Tue May 28 04:24:31 2013 Return-Path: Delivered-To: freebsd-arch@FreeBSD.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id D70169FC; Tue, 28 May 2013 04:24:31 +0000 (UTC) (envelope-from bright@mu.org) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.freebsd.org (Postfix) with ESMTP id C7E7A6BB; Tue, 28 May 2013 04:24:31 +0000 (UTC) Received: from Alfreds-MacBook-Pro-9.local (c-67-180-208-218.hsd1.ca.comcast.net [67.180.208.218]) by elvis.mu.org (Postfix) with ESMTPSA id E4EDA1A3C19; Mon, 27 May 2013 21:24:27 -0700 (PDT) Message-ID: <51A43176.9060100@mu.org> Date: Mon, 27 May 2013 21:24:22 -0700 From: Alfred Perlstein User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:17.0) Gecko/20130509 Thunderbird/17.0.6 MIME-Version: 1.0 To: Garrett Cooper Subject: Re: [RFC] add NetBSD compat macros to sys/cdefs.h References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Brooks Davis , freebsd-arch@FreeBSD.org X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 May 2013 04:24:31 -0000 On 5/27/13 7:21 PM, Garrett Cooper wrote: > Hi, > One of the things that I've done in order to reduce unnecessary > divergence when porting NetBSD testcases to FreeBSD is I've pushed a > few macros into my sys/cdefs.h in order to facilitate compatibility > with NetBSD: > > /* NetBSD compat */ > /* > * The following macro is used to remove const cast-away warnings > * from gcc -Wcast-qual; it should be used with caution because it > * can hide valid errors; in particular most valid uses are in > * situations where the API requires it, not to cast away string > * constants. We don't use *intptr_t on purpose here and we are > * explicit about unsigned long so that we don't have additional > * dependencies. > */ > #define __UNCONST(a) ((void *)(unsigned long)(const void *)(a)) > > #define ___STRING(x) __STRING(x) > #define __arraycount(__x) (sizeof(__x) / sizeof(__x[0])) > /* End NetBSD compat */ > > To clarify... > - I know __UNCONST is basically like __DECONST on steroids as > __UNCONST doesn't have the typecasting like __DECONST does. > - I'm working at removing the need for ___STRING with upstream. > - I know that __arraycount is equivalent to nitems. > > The reason why I'm doing this is to reduce divergence and get > things going ASAP with the testing effort as I have a couple thousand > testcases ported from NetBSD which will be hooked into release images > (really soon) and will result in automated testing (not too far away, > potentially a couple months), versus the zero coverage we currently > have in FreeBSD. If _anyone_ has a better idea and is willing to pony > up the patch to make things more sane, please by all means do. > I would prefer not to use libnetbsd as it just introduces > unnecessary churn in Makefiles and dependencies on a compat library > strictly for a couple of C macros. > Thoughts? Under COMPAT_NETBSD? -Alfred