xref: /dflybsd-src/contrib/gdb-7/include/symcat.h (revision 86d7f5d305c6adaa56ff4582ece9859d73106103)
1*86d7f5d3SJohn Marino /* Symbol concatenation utilities.
2*86d7f5d3SJohn Marino 
3*86d7f5d3SJohn Marino    Copyright (C) 1998, 2000, 2010 Free Software Foundation, Inc.
4*86d7f5d3SJohn Marino 
5*86d7f5d3SJohn Marino    This program is free software; you can redistribute it and/or modify
6*86d7f5d3SJohn Marino    it under the terms of the GNU General Public License as published by
7*86d7f5d3SJohn Marino    the Free Software Foundation; either version 2 of the License, or
8*86d7f5d3SJohn Marino    (at your option) any later version.
9*86d7f5d3SJohn Marino 
10*86d7f5d3SJohn Marino    This program is distributed in the hope that it will be useful,
11*86d7f5d3SJohn Marino    but WITHOUT ANY WARRANTY; without even the implied warranty of
12*86d7f5d3SJohn Marino    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13*86d7f5d3SJohn Marino    GNU General Public License for more details.
14*86d7f5d3SJohn Marino 
15*86d7f5d3SJohn Marino    You should have received a copy of the GNU General Public License along
16*86d7f5d3SJohn Marino    with this program; if not, write to the Free Software Foundation, Inc.,
17*86d7f5d3SJohn Marino    51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
18*86d7f5d3SJohn Marino 
19*86d7f5d3SJohn Marino #ifndef SYM_CAT_H
20*86d7f5d3SJohn Marino #define SYM_CAT_H
21*86d7f5d3SJohn Marino 
22*86d7f5d3SJohn Marino #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
23*86d7f5d3SJohn Marino #define CONCAT2(a,b)	 a##b
24*86d7f5d3SJohn Marino #define CONCAT3(a,b,c)	 a##b##c
25*86d7f5d3SJohn Marino #define CONCAT4(a,b,c,d) a##b##c##d
26*86d7f5d3SJohn Marino #define CONCAT5(a,b,c,d,e) a##b##c##d##e
27*86d7f5d3SJohn Marino #define CONCAT6(a,b,c,d,e,f) a##b##c##d##e##f
28*86d7f5d3SJohn Marino #define STRINGX(s) #s
29*86d7f5d3SJohn Marino #else
30*86d7f5d3SJohn Marino /* Note one should never pass extra whitespace to the CONCATn macros,
31*86d7f5d3SJohn Marino    e.g. CONCAT2(foo, bar) because traditonal C will keep the space between
32*86d7f5d3SJohn Marino    the two labels instead of concatenating them.  Instead, make sure to
33*86d7f5d3SJohn Marino    write CONCAT2(foo,bar).  */
34*86d7f5d3SJohn Marino #define CONCAT2(a,b)	 a/**/b
35*86d7f5d3SJohn Marino #define CONCAT3(a,b,c)	 a/**/b/**/c
36*86d7f5d3SJohn Marino #define CONCAT4(a,b,c,d) a/**/b/**/c/**/d
37*86d7f5d3SJohn Marino #define CONCAT5(a,b,c,d,e) a/**/b/**/c/**/d/**/e
38*86d7f5d3SJohn Marino #define CONCAT6(a,b,c,d,e,f) a/**/b/**/c/**/d/**/e/**/f
39*86d7f5d3SJohn Marino #define STRINGX(s) "s"
40*86d7f5d3SJohn Marino #endif
41*86d7f5d3SJohn Marino 
42*86d7f5d3SJohn Marino #define XCONCAT2(a,b)     CONCAT2(a,b)
43*86d7f5d3SJohn Marino #define XCONCAT3(a,b,c)   CONCAT3(a,b,c)
44*86d7f5d3SJohn Marino #define XCONCAT4(a,b,c,d) CONCAT4(a,b,c,d)
45*86d7f5d3SJohn Marino #define XCONCAT5(a,b,c,d,e) CONCAT5(a,b,c,d,e)
46*86d7f5d3SJohn Marino #define XCONCAT6(a,b,c,d,e,f) CONCAT6(a,b,c,d,e,f)
47*86d7f5d3SJohn Marino 
48*86d7f5d3SJohn Marino /* Note the layer of indirection here is typically used to allow
49*86d7f5d3SJohn Marino    stringification of the expansion of macros.  I.e. "#define foo
50*86d7f5d3SJohn Marino    bar", "XSTRING(foo)", to yield "bar".  Be aware that this only
51*86d7f5d3SJohn Marino    works for __STDC__, not for traditional C which will still resolve
52*86d7f5d3SJohn Marino    to "foo".  */
53*86d7f5d3SJohn Marino #define XSTRING(s) STRINGX(s)
54*86d7f5d3SJohn Marino 
55*86d7f5d3SJohn Marino #endif /* SYM_CAT_H */
56