xref: /netbsd-src/external/gpl3/binutils/dist/include/symcat.h (revision cb63e24e8d6aae7ddac1859a9015f48b1d8bd90e)
12a6b7db3Sskrll /* Symbol concatenation utilities.
22a6b7db3Sskrll 
3*cb63e24eSchristos    Copyright (C) 1998-2024 Free Software Foundation, Inc.
42a6b7db3Sskrll 
52a6b7db3Sskrll    This program is free software; you can redistribute it and/or modify
62a6b7db3Sskrll    it under the terms of the GNU General Public License as published by
72a6b7db3Sskrll    the Free Software Foundation; either version 2 of the License, or
82a6b7db3Sskrll    (at your option) any later version.
92a6b7db3Sskrll 
102a6b7db3Sskrll    This program is distributed in the hope that it will be useful,
112a6b7db3Sskrll    but WITHOUT ANY WARRANTY; without even the implied warranty of
122a6b7db3Sskrll    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
132a6b7db3Sskrll    GNU General Public License for more details.
142a6b7db3Sskrll 
152a6b7db3Sskrll    You should have received a copy of the GNU General Public License along
162a6b7db3Sskrll    with this program; if not, write to the Free Software Foundation, Inc.,
172a6b7db3Sskrll    51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
182a6b7db3Sskrll 
192a6b7db3Sskrll #ifndef SYM_CAT_H
202a6b7db3Sskrll #define SYM_CAT_H
212a6b7db3Sskrll 
222a6b7db3Sskrll #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
232a6b7db3Sskrll #define CONCAT2(a,b)	 a##b
242a6b7db3Sskrll #define CONCAT3(a,b,c)	 a##b##c
252a6b7db3Sskrll #define CONCAT4(a,b,c,d) a##b##c##d
2645548106Schristos #define CONCAT5(a,b,c,d,e) a##b##c##d##e
2745548106Schristos #define CONCAT6(a,b,c,d,e,f) a##b##c##d##e##f
282a6b7db3Sskrll #define STRINGX(s) #s
292a6b7db3Sskrll #else
302a6b7db3Sskrll /* Note one should never pass extra whitespace to the CONCATn macros,
312a6b7db3Sskrll    e.g. CONCAT2(foo, bar) because traditonal C will keep the space between
322a6b7db3Sskrll    the two labels instead of concatenating them.  Instead, make sure to
332a6b7db3Sskrll    write CONCAT2(foo,bar).  */
342a6b7db3Sskrll #define CONCAT2(a,b)	 a/**/b
352a6b7db3Sskrll #define CONCAT3(a,b,c)	 a/**/b/**/c
362a6b7db3Sskrll #define CONCAT4(a,b,c,d) a/**/b/**/c/**/d
3745548106Schristos #define CONCAT5(a,b,c,d,e) a/**/b/**/c/**/d/**/e
3845548106Schristos #define CONCAT6(a,b,c,d,e,f) a/**/b/**/c/**/d/**/e/**/f
392a6b7db3Sskrll #define STRINGX(s) "s"
402a6b7db3Sskrll #endif
412a6b7db3Sskrll 
422a6b7db3Sskrll #define XCONCAT2(a,b)     CONCAT2(a,b)
432a6b7db3Sskrll #define XCONCAT3(a,b,c)   CONCAT3(a,b,c)
442a6b7db3Sskrll #define XCONCAT4(a,b,c,d) CONCAT4(a,b,c,d)
4545548106Schristos #define XCONCAT5(a,b,c,d,e) CONCAT5(a,b,c,d,e)
4645548106Schristos #define XCONCAT6(a,b,c,d,e,f) CONCAT6(a,b,c,d,e,f)
472a6b7db3Sskrll 
482a6b7db3Sskrll /* Note the layer of indirection here is typically used to allow
492a6b7db3Sskrll    stringification of the expansion of macros.  I.e. "#define foo
502a6b7db3Sskrll    bar", "XSTRING(foo)", to yield "bar".  Be aware that this only
512a6b7db3Sskrll    works for __STDC__, not for traditional C which will still resolve
522a6b7db3Sskrll    to "foo".  */
532a6b7db3Sskrll #define XSTRING(s) STRINGX(s)
542a6b7db3Sskrll 
552a6b7db3Sskrll #endif /* SYM_CAT_H */
56