From owner-freebsd-hackers@FreeBSD.ORG Mon Apr 28 13:22:50 2008 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 61ED1106566C for ; Mon, 28 Apr 2008 13:22:50 +0000 (UTC) (envelope-from sigtrm@gmail.com) Received: from wr-out-0506.google.com (wr-out-0506.google.com [64.233.184.235]) by mx1.freebsd.org (Postfix) with ESMTP id 2303C8FC0A for ; Mon, 28 Apr 2008 13:22:49 +0000 (UTC) (envelope-from sigtrm@gmail.com) Received: by wr-out-0506.google.com with SMTP id 50so2389395wra.13 for ; Mon, 28 Apr 2008 06:22:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type; bh=IvJlJnY70CTQmcpBNuzw5wlNZqyuNWQ0J3s7pqahga4=; b=W8/mCjzXtzWMbXqajrP+0EaVwVDEeqDikkKZdlLPVRVxKWja1DgM9ptkltamHBiBL3Inh0UH1EYnQGFoOeraAEW8M/bsc8RSVhnm9Nq0+/oKAi0s8vdrJHJ/ZjPVABoa2fJxdQ95J0X96loWMNF9Kl0tJp6VcBl3MR1mu8jaxaA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type; b=qBzPibhFSQRwvbf2P/Th7ZoBbkq9K1fJR4ccICMlvP37LgNmXO+WiaoQyt245gvPnR5LxEZTCe7e8rIzZKpJWolQJBGBP30b5bUTdkKsjTSubDrUFKW90z2i6zeWbmSFdwN3Ettgsrxw59dXXkMifqHLSsFum6HZ8UjQarzB1SE= Received: by 10.141.96.21 with SMTP id y21mr3218189rvl.132.1209387210009; Mon, 28 Apr 2008 05:53:30 -0700 (PDT) Received: by 10.141.42.6 with HTTP; Mon, 28 Apr 2008 05:53:29 -0700 (PDT) Message-ID: Date: Mon, 28 Apr 2008 14:53:29 +0200 From: "Lukasz Jaroszewski" To: freebsd-hackers@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: RE: indent(1) support for gcc(1) 0b prefix 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: Mon, 28 Apr 2008 13:22:50 -0000 >On Apr 26, 2008, at 5:01 PM, Max Laier wrote: >>* On Saturday 26 April 2008 23:35:57 Romain Tarti=E8re wrote: *>>>* Hello FreeBSD hackers! *>>>* *>>>* I'm using avr-gcc from the ports and relying on the 0b prefix *>>>* notation *>>>* for binary constants, that is: *>>>* *>>>* =09foo =3D 0b00101010; *>>>* *>>>* Thanks to /usr/ports/devel/avr-gcc/files/patch-0b-constants this is *>>>* possible :-) *>>>* *>>>* But I would like to use indent(1) to reformat contributed code *>>>* automatically. Unfortunately, the 0b notation is not supported by *>>>* that *>>>* program, and the resulting code looks like this: *>>>* *>>>* =09foo =3D 0 b00101010; *>>>* *>>>* ... then compilation fails, bla bla bla... *>>* *>>* I can't think of a case (outside of "0x...." context) where "...0b..." *>>* would be valid C code, let alone better formated as "...0 b...". *>>* Hence I *>>* see no harm in adding your patch to the base indent(1). *>>* *>>* Does anyone have an example where "...0 b..." is valid C code? *> >Well, if b... is a preprocessor define then you can easily >come up with valid C: > >#define b...=09*2 > >then:=09=09...0 b... >becomes:=09...0 *2 > >That's a valid expression in the right context... > >FYI, > >-- >Marcel Moolenaar >xcllnt at mac.com >From c-faq.com( by Bill Finke ): #define Ob(x) ((unsigned)Ob_(0 ## x ## uL)) #define Ob_(x) (x & 1 | x >> 2 & 2 | x >> 4 & 4 | x >> 6 & 8 |=09=09\ =09x >> 8 & 16 | x >> 10 & 32 | x >> 12 & 64 | x >> 14 & 128) --- #define PORT_SYSCTLA 0x092 /* PS2 system control port A */ #define SYSCTLA_DSK Ob(10000000) /* lights the fixed dsk activity led */ #define SYSCTLA_DSK0 Ob(01000000) /* also lights fixed disk actvty led */ #define SYSCTLA_TMOT Ob(00010000) /* watchdog timer has timed-out */ #define SYSCTLA_LOCK Ob(00001000) /* CMOS password area is locked */ #define SYSCTLA_A20 Ob(00000010) /* alternate address line 20 gating */ #define SYSCTLA_RST Ob(00000001) /* alternate hot reset */ regards LJ776-RIPE