From owner-svn-src-all@FreeBSD.ORG Thu Feb 9 16:55:20 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D6314106564A; Thu, 9 Feb 2012 16:55:20 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BFBC78FC13; Thu, 9 Feb 2012 16:55:20 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q19GtKlH010434; Thu, 9 Feb 2012 16:55:20 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q19GtK7H010429; Thu, 9 Feb 2012 16:55:20 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <201202091655.q19GtK7H010429@svn.freebsd.org> From: Ed Schouten Date: Thu, 9 Feb 2012 16:55:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r231289 - in stable/9/contrib/gcclibs/libcpp: . include X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Feb 2012 16:55:21 -0000 Author: ed Date: Thu Feb 9 16:55:20 2012 New Revision: 231289 URL: http://svn.freebsd.org/changeset/base/231289 Log: MFC r228474: Add support for __COUNTER__. __COUNTER__ allows one to obtain incrementing (read: unique) numbers from the C preprocesor. This is useful when implementing things like a robust implementation of CTASSERT(), which currently fails when using it more than once on a single line of code. Probably not likely to cause any breakage, but still. __COUNTER__ was also added to GCC 4.3, but since that implementation is GPLv3 licensed, I took the liberty of implementing it without looking at any upstream sources. Therefore, this version is licensed under the same license as the rest of the code; GPLv2. Modified: stable/9/contrib/gcclibs/libcpp/include/cpplib.h stable/9/contrib/gcclibs/libcpp/init.c stable/9/contrib/gcclibs/libcpp/internal.h stable/9/contrib/gcclibs/libcpp/macro.c Directory Properties: stable/9/contrib/gcclibs/ (props changed) Modified: stable/9/contrib/gcclibs/libcpp/include/cpplib.h ============================================================================== --- stable/9/contrib/gcclibs/libcpp/include/cpplib.h Thu Feb 9 16:54:06 2012 (r231288) +++ stable/9/contrib/gcclibs/libcpp/include/cpplib.h Thu Feb 9 16:55:20 2012 (r231289) @@ -555,7 +555,8 @@ enum builtin_type BT_TIME, /* `__TIME__' */ BT_STDC, /* `__STDC__' */ BT_PRAGMA, /* `_Pragma' operator */ - BT_TIMESTAMP /* `__TIMESTAMP__' */ + BT_TIMESTAMP, /* `__TIMESTAMP__' */ + BT_COUNTER /* `__COUNTER__' */ }; #define CPP_HASHNODE(HNODE) ((cpp_hashnode *) (HNODE)) Modified: stable/9/contrib/gcclibs/libcpp/init.c ============================================================================== --- stable/9/contrib/gcclibs/libcpp/init.c Thu Feb 9 16:54:06 2012 (r231288) +++ stable/9/contrib/gcclibs/libcpp/init.c Thu Feb 9 16:55:20 2012 (r231289) @@ -308,6 +308,7 @@ static const struct builtin builtin_arra B("__BASE_FILE__", BT_BASE_FILE), B("__LINE__", BT_SPECLINE), B("__INCLUDE_LEVEL__", BT_INCLUDE_LEVEL), + B("__COUNTER__", BT_COUNTER), /* Keep builtins not used for -traditional-cpp at the end, and update init_builtins() if any more are added. */ B("_Pragma", BT_PRAGMA), Modified: stable/9/contrib/gcclibs/libcpp/internal.h ============================================================================== --- stable/9/contrib/gcclibs/libcpp/internal.h Thu Feb 9 16:54:06 2012 (r231288) +++ stable/9/contrib/gcclibs/libcpp/internal.h Thu Feb 9 16:55:20 2012 (r231289) @@ -448,6 +448,8 @@ struct cpp_reader /* A saved list of the defined macros, for dependency checking of precompiled headers. */ struct cpp_savedstate *savedstate; + + unsigned int nextcounter; }; /* Character classes. Based on the more primitive macros in safe-ctype.h. Modified: stable/9/contrib/gcclibs/libcpp/macro.c ============================================================================== --- stable/9/contrib/gcclibs/libcpp/macro.c Thu Feb 9 16:54:06 2012 (r231288) +++ stable/9/contrib/gcclibs/libcpp/macro.c Thu Feb 9 16:55:20 2012 (r231289) @@ -262,6 +262,10 @@ _cpp_builtin_macro_text (cpp_reader *pfi else result = pfile->time; break; + + case BT_COUNTER: + number = pfile->nextcounter++; + break; } if (result == NULL)