diff options
| author | apb <apb@NetBSD.org> | 2012-11-24 09:07:44 +0000 |
|---|---|---|
| committer | apb <apb@NetBSD.org> | 2012-11-24 09:07:44 +0000 |
| commit | edd45c4f725efefe883e67070de81e0091bcaf55 (patch) | |
| tree | c0a0652e3a400a2a2be9f0f502defff805072891 /gnu | |
| parent | 84d501111b538db76b23a1dee6cdeb7f9b90683d (diff) | |
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.
Diffstat (limited to 'gnu')
| -rw-r--r-- | gnu/dist/gcc4/libcpp/include/cpplib.h | 1 | ||||
| -rw-r--r-- | gnu/dist/gcc4/libcpp/init.c | 1 | ||||
| -rw-r--r-- | gnu/dist/gcc4/libcpp/macro.c | 8 |
3 files changed, 10 insertions, 0 deletions
diff --git a/gnu/dist/gcc4/libcpp/include/cpplib.h b/gnu/dist/gcc4/libcpp/include/cpplib.h index bb207b5acda..ddad5b25249 100644 --- a/gnu/dist/gcc4/libcpp/include/cpplib.h +++ b/gnu/dist/gcc4/libcpp/include/cpplib.h @@ -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 */ }; diff --git a/gnu/dist/gcc4/libcpp/init.c b/gnu/dist/gcc4/libcpp/init.c index 2e245b7e083..e6273c60dc4 100644 --- a/gnu/dist/gcc4/libcpp/init.c +++ b/gnu/dist/gcc4/libcpp/init.c @@ -309,6 +309,7 @@ static const struct builtin builtin_array[] = 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), diff --git a/gnu/dist/gcc4/libcpp/macro.c b/gnu/dist/gcc4/libcpp/macro.c index 8c3d9fcd608..008440bc054 100644 --- a/gnu/dist/gcc4/libcpp/macro.c +++ b/gnu/dist/gcc4/libcpp/macro.c @@ -284,6 +284,14 @@ _cpp_builtin_macro_text (cpp_reader *pfile, cpp_hashnode *node) else result = pfile->time; break; + + case BT_COUNTER: + { + static unsigned int counter = 0; + + number = counter++; + } + break; } if (result == NULL) |
