Module Name: src Committed By: matt Date: Tue Nov 27 22:18:50 UTC 2012
Modified Files: src/gnu/dist/gcc4/libcpp [matt-nb6-plus]: init.c macro.c src/gnu/dist/gcc4/libcpp/include [matt-nb6-plus]: cpplib.h Log Message: Pull from HEAD: Teach gcc4.1's cpp about the magic __COUNTER__ macro, which returns a unique integer each time it is expanded. This code was written without reference to any other implementation of the same feature. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.2.46.1 src/gnu/dist/gcc4/libcpp/init.c cvs rdiff -u -r1.3 -r1.3.10.1 src/gnu/dist/gcc4/libcpp/macro.c cvs rdiff -u -r1.2 -r1.2.10.1 src/gnu/dist/gcc4/libcpp/include/cpplib.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/gnu/dist/gcc4/libcpp/init.c diff -u src/gnu/dist/gcc4/libcpp/init.c:1.2 src/gnu/dist/gcc4/libcpp/init.c:1.2.46.1 --- src/gnu/dist/gcc4/libcpp/init.c:1.2 Fri May 12 00:24:43 2006 +++ src/gnu/dist/gcc4/libcpp/init.c Tue Nov 27 22:18:49 2012 @@ -309,6 +309,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), Index: src/gnu/dist/gcc4/libcpp/macro.c diff -u src/gnu/dist/gcc4/libcpp/macro.c:1.3 src/gnu/dist/gcc4/libcpp/macro.c:1.3.10.1 --- src/gnu/dist/gcc4/libcpp/macro.c:1.3 Wed Nov 11 19:03:52 2009 +++ src/gnu/dist/gcc4/libcpp/macro.c Tue Nov 27 22:18:49 2012 @@ -284,6 +284,14 @@ _cpp_builtin_macro_text (cpp_reader *pfi else result = pfile->time; break; + + case BT_COUNTER: + { + static unsigned int counter = 0; + + number = counter++; + } + break; } if (result == NULL) Index: src/gnu/dist/gcc4/libcpp/include/cpplib.h diff -u src/gnu/dist/gcc4/libcpp/include/cpplib.h:1.2 src/gnu/dist/gcc4/libcpp/include/cpplib.h:1.2.10.1 --- src/gnu/dist/gcc4/libcpp/include/cpplib.h:1.2 Wed Nov 11 19:03:52 2009 +++ src/gnu/dist/gcc4/libcpp/include/cpplib.h Tue Nov 27 22:18:49 2012 @@ -551,6 +551,7 @@ enum builtin_type BT_BASE_FILE, /* `__BASE_FILE__' */ BT_INCLUDE_LEVEL, /* `__INCLUDE_LEVEL__' */ BT_TIME, /* `__TIME__' */ + BT_COUNTER, /* `__COUNTER__' */ BT_STDC, /* `__STDC__' */ BT_PRAGMA /* `_Pragma' operator */ };