xref: /netbsd-src/external/gpl3/gdb/dist/include/symcat.h (revision e663ba6e3a60083e70de702e9d54bf486a57b6a7)
198b9484cSchristos /* Symbol concatenation utilities.
298b9484cSchristos 
3*e663ba6eSchristos    Copyright (C) 1998-2024 Free Software Foundation, Inc.
498b9484cSchristos 
598b9484cSchristos    This program is free software; you can redistribute it and/or modify
698b9484cSchristos    it under the terms of the GNU General Public License as published by
798b9484cSchristos    the Free Software Foundation; either version 2 of the License, or
898b9484cSchristos    (at your option) any later version.
998b9484cSchristos 
1098b9484cSchristos    This program is distributed in the hope that it will be useful,
1198b9484cSchristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
1298b9484cSchristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1398b9484cSchristos    GNU General Public License for more details.
1498b9484cSchristos 
1598b9484cSchristos    You should have received a copy of the GNU General Public License along
1698b9484cSchristos    with this program; if not, write to the Free Software Foundation, Inc.,
1798b9484cSchristos    51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
1898b9484cSchristos 
1998b9484cSchristos #ifndef SYM_CAT_H
2098b9484cSchristos #define SYM_CAT_H
2198b9484cSchristos 
2298b9484cSchristos #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
2398b9484cSchristos #define CONCAT2(a,b)	 a##b
2498b9484cSchristos #define CONCAT3(a,b,c)	 a##b##c
2598b9484cSchristos #define CONCAT4(a,b,c,d) a##b##c##d
2698b9484cSchristos #define CONCAT5(a,b,c,d,e) a##b##c##d##e
2798b9484cSchristos #define CONCAT6(a,b,c,d,e,f) a##b##c##d##e##f
2898b9484cSchristos #define STRINGX(s) #s
2998b9484cSchristos #else
3098b9484cSchristos /* Note one should never pass extra whitespace to the CONCATn macros,
3198b9484cSchristos    e.g. CONCAT2(foo, bar) because traditonal C will keep the space between
3298b9484cSchristos    the two labels instead of concatenating them.  Instead, make sure to
3398b9484cSchristos    write CONCAT2(foo,bar).  */
3498b9484cSchristos #define CONCAT2(a,b)	 a/**/b
3598b9484cSchristos #define CONCAT3(a,b,c)	 a/**/b/**/c
3698b9484cSchristos #define CONCAT4(a,b,c,d) a/**/b/**/c/**/d
3798b9484cSchristos #define CONCAT5(a,b,c,d,e) a/**/b/**/c/**/d/**/e
3898b9484cSchristos #define CONCAT6(a,b,c,d,e,f) a/**/b/**/c/**/d/**/e/**/f
3998b9484cSchristos #define STRINGX(s) "s"
4098b9484cSchristos #endif
4198b9484cSchristos 
4298b9484cSchristos #define XCONCAT2(a,b)     CONCAT2(a,b)
4398b9484cSchristos #define XCONCAT3(a,b,c)   CONCAT3(a,b,c)
4498b9484cSchristos #define XCONCAT4(a,b,c,d) CONCAT4(a,b,c,d)
4598b9484cSchristos #define XCONCAT5(a,b,c,d,e) CONCAT5(a,b,c,d,e)
4698b9484cSchristos #define XCONCAT6(a,b,c,d,e,f) CONCAT6(a,b,c,d,e,f)
4798b9484cSchristos 
4898b9484cSchristos /* Note the layer of indirection here is typically used to allow
4998b9484cSchristos    stringification of the expansion of macros.  I.e. "#define foo
5098b9484cSchristos    bar", "XSTRING(foo)", to yield "bar".  Be aware that this only
5198b9484cSchristos    works for __STDC__, not for traditional C which will still resolve
5298b9484cSchristos    to "foo".  */
5398b9484cSchristos #define XSTRING(s) STRINGX(s)
5498b9484cSchristos 
5598b9484cSchristos #endif /* SYM_CAT_H */
56