From owner-freebsd-arch@FreeBSD.ORG Tue May 28 02:21:21 2013 Return-Path: Delivered-To: freebsd-arch@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id E451F8DA; Tue, 28 May 2013 02:21:21 +0000 (UTC) (envelope-from yaneurabeya@gmail.com) Received: from mail-ve0-x236.google.com (mail-ve0-x236.google.com [IPv6:2607:f8b0:400c:c01::236]) by mx1.freebsd.org (Postfix) with ESMTP id 9824CEA6; Tue, 28 May 2013 02:21:21 +0000 (UTC) Received: by mail-ve0-f182.google.com with SMTP id ox1so1104654veb.41 for ; Mon, 27 May 2013 19:21:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:cc:content-type; bh=Sw4zRuoJGdC/P1xhnRDfZ9OcrkiQ6KElhsQilIoaQgc=; b=U8qd0Y0ZI3QHcXDQKpAPKhJMvq4TMec4XlwzqSLJIuUk2DevcAirdGciwiT1kk5BBp 9UYlAMG+WNw+Ok2YRvPNf8TznKFTeR4XzGV2f+roDdhXChy3yjVWy9qBAlbBvtwKbjG9 JsxLH2ob4uSXFmiwCeBZrkgtoKhuH758xUGeOyk1vTRlA/Ny02pUCe+IKBr/FkGNNXX8 9uvJKRntScUkjqOLa7g9bxN7x2MoaRlpMgou00+o8htTkKIGPeTrSTyQDNTxqIRFHYdQ 8+X1nmRkPQmH3pCX6HuBWMfcuSfcebB8AfftSO25tIhxkbLdBNd5jyDShcHght//aGgk Vm3g== MIME-Version: 1.0 X-Received: by 10.220.101.69 with SMTP id b5mr16776993vco.55.1369707680107; Mon, 27 May 2013 19:21:20 -0700 (PDT) Received: by 10.220.217.198 with HTTP; Mon, 27 May 2013 19:21:20 -0700 (PDT) Date: Mon, 27 May 2013 19:21:20 -0700 Message-ID: Subject: [RFC] add NetBSD compat macros to sys/cdefs.h From: Garrett Cooper To: freebsd-arch@FreeBSD.org Content-Type: text/plain; charset=ISO-8859-1 Cc: Brooks Davis 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 02:21:22 -0000 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? Thanks! -Garrett