xref: /netbsd-src/external/gpl3/binutils.old/dist/include/symcat.h (revision e992f068c547fd6e84b3f104dc2340adcc955732)
175fd0b74Schristos /* Symbol concatenation utilities.
275fd0b74Schristos 
3*e992f068Schristos    Copyright (C) 1998-2022 Free Software Foundation, Inc.
475fd0b74Schristos 
575fd0b74Schristos    This program is free software; you can redistribute it and/or modify
675fd0b74Schristos    it under the terms of the GNU General Public License as published by
775fd0b74Schristos    the Free Software Foundation; either version 2 of the License, or
875fd0b74Schristos    (at your option) any later version.
975fd0b74Schristos 
1075fd0b74Schristos    This program is distributed in the hope that it will be useful,
1175fd0b74Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
1275fd0b74Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1375fd0b74Schristos    GNU General Public License for more details.
1475fd0b74Schristos 
1575fd0b74Schristos    You should have received a copy of the GNU General Public License along
1675fd0b74Schristos    with this program; if not, write to the Free Software Foundation, Inc.,
1775fd0b74Schristos    51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
1875fd0b74Schristos 
1975fd0b74Schristos #ifndef SYM_CAT_H
2075fd0b74Schristos #define SYM_CAT_H
2175fd0b74Schristos 
2275fd0b74Schristos #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
2375fd0b74Schristos #define CONCAT2(a,b)	 a##b
2475fd0b74Schristos #define CONCAT3(a,b,c)	 a##b##c
2575fd0b74Schristos #define CONCAT4(a,b,c,d) a##b##c##d
2675fd0b74Schristos #define CONCAT5(a,b,c,d,e) a##b##c##d##e
2775fd0b74Schristos #define CONCAT6(a,b,c,d,e,f) a##b##c##d##e##f
2875fd0b74Schristos #define STRINGX(s) #s
2975fd0b74Schristos #else
3075fd0b74Schristos /* Note one should never pass extra whitespace to the CONCATn macros,
3175fd0b74Schristos    e.g. CONCAT2(foo, bar) because traditonal C will keep the space between
3275fd0b74Schristos    the two labels instead of concatenating them.  Instead, make sure to
3375fd0b74Schristos    write CONCAT2(foo,bar).  */
3475fd0b74Schristos #define CONCAT2(a,b)	 a/**/b
3575fd0b74Schristos #define CONCAT3(a,b,c)	 a/**/b/**/c
3675fd0b74Schristos #define CONCAT4(a,b,c,d) a/**/b/**/c/**/d
3775fd0b74Schristos #define CONCAT5(a,b,c,d,e) a/**/b/**/c/**/d/**/e
3875fd0b74Schristos #define CONCAT6(a,b,c,d,e,f) a/**/b/**/c/**/d/**/e/**/f
3975fd0b74Schristos #define STRINGX(s) "s"
4075fd0b74Schristos #endif
4175fd0b74Schristos 
4275fd0b74Schristos #define XCONCAT2(a,b)     CONCAT2(a,b)
4375fd0b74Schristos #define XCONCAT3(a,b,c)   CONCAT3(a,b,c)
4475fd0b74Schristos #define XCONCAT4(a,b,c,d) CONCAT4(a,b,c,d)
4575fd0b74Schristos #define XCONCAT5(a,b,c,d,e) CONCAT5(a,b,c,d,e)
4675fd0b74Schristos #define XCONCAT6(a,b,c,d,e,f) CONCAT6(a,b,c,d,e,f)
4775fd0b74Schristos 
4875fd0b74Schristos /* Note the layer of indirection here is typically used to allow
4975fd0b74Schristos    stringification of the expansion of macros.  I.e. "#define foo
5075fd0b74Schristos    bar", "XSTRING(foo)", to yield "bar".  Be aware that this only
5175fd0b74Schristos    works for __STDC__, not for traditional C which will still resolve
5275fd0b74Schristos    to "foo".  */
5375fd0b74Schristos #define XSTRING(s) STRINGX(s)
5475fd0b74Schristos 
5575fd0b74Schristos #endif /* SYM_CAT_H */
56