Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 27 May 2013 21:24:22 -0700
From:      Alfred Perlstein <bright@mu.org>
To:        Garrett Cooper <yaneurabeya@gmail.com>
Cc:        Brooks Davis <brooks@freebsd.org>, freebsd-arch@FreeBSD.org
Subject:   Re: [RFC] add NetBSD compat macros to sys/cdefs.h
Message-ID:  <51A43176.9060100@mu.org>
In-Reply-To: <CAGHfRMCHbrBXPVfuH0bX0OZFn7KNuebswi_UrS1FoZv_zh4sgA@mail.gmail.com>
References:  <CAGHfRMCHbrBXPVfuH0bX0OZFn7KNuebswi_UrS1FoZv_zh4sgA@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?51A43176.9060100>