Module Name: src Committed By: jruoho Date: Wed Apr 21 18:04:38 UTC 2010
Modified Files: src/distrib/sets/lists/comp: mi src/share/man/man3: Makefile Added Files: src/share/man/man3: __CONCAT.3 Log Message: Document __STRING(x) and __CONCAT(x, y) from <sys/cdefs.h>. To generate a diff of this commit: cvs rdiff -u -r1.1433 -r1.1434 src/distrib/sets/lists/comp/mi cvs rdiff -u -r1.47 -r1.48 src/share/man/man3/Makefile cvs rdiff -u -r0 -r1.1 src/share/man/man3/__CONCAT.3 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/distrib/sets/lists/comp/mi diff -u src/distrib/sets/lists/comp/mi:1.1433 src/distrib/sets/lists/comp/mi:1.1434 --- src/distrib/sets/lists/comp/mi:1.1433 Fri Apr 16 20:08:51 2010 +++ src/distrib/sets/lists/comp/mi Wed Apr 21 18:04:38 2010 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1433 2010/04/16 20:08:51 dyoung Exp $ +# $NetBSD: mi,v 1.1434 2010/04/21 18:04:38 jruoho Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -4764,9 +4764,11 @@ ./usr/share/man/cat3/_DIAGASSERT.0 comp-c-catman .cat ./usr/share/man/cat3/__BIT.0 comp-c-catman .cat ./usr/share/man/cat3/__BITS.0 comp-c-catman .cat +./usr/share/man/cat3/__CONCAT.0 comp-c-catman .cat ./usr/share/man/cat3/__SHIFTIN.0 comp-c-catman .cat ./usr/share/man/cat3/__SHIFTOUT.0 comp-c-catman .cat ./usr/share/man/cat3/__SHIFTOUT_MASK.0 comp-c-catman .cat +./usr/share/man/cat3/__STRING.0 comp-c-catman .cat ./usr/share/man/cat3/__UNCONST.0 comp-c-catman .cat ./usr/share/man/cat3/__UNVOLATILE.0 comp-c-catman .cat ./usr/share/man/cat3/__arraycount.0 comp-c-catman .cat @@ -10626,9 +10628,11 @@ ./usr/share/man/html3/_DIAGASSERT.html comp-c-htmlman html ./usr/share/man/html3/__BIT.html comp-c-htmlman html ./usr/share/man/html3/__BITS.html comp-c-htmlman html +./usr/share/man/html3/__CONCAT.html comp-c-htmlman html ./usr/share/man/html3/__SHIFTIN.html comp-c-htmlman html ./usr/share/man/html3/__SHIFTOUT.html comp-c-htmlman html ./usr/share/man/html3/__SHIFTOUT_MASK.html comp-c-htmlman html +./usr/share/man/html3/__STRING.html comp-c-htmlman html ./usr/share/man/html3/__UNCONST.html comp-c-htmlman html ./usr/share/man/html3/__UNVOLATILE.html comp-c-htmlman html ./usr/share/man/html3/__arraycount.html comp-c-htmlman html @@ -16288,9 +16292,11 @@ ./usr/share/man/man3/_DIAGASSERT.3 comp-c-man .man ./usr/share/man/man3/__BIT.3 comp-c-man .man ./usr/share/man/man3/__BITS.3 comp-c-man .man +./usr/share/man/man3/__CONCAT.3 comp-c-man .man ./usr/share/man/man3/__SHIFTIN.3 comp-c-man .man ./usr/share/man/man3/__SHIFTOUT.3 comp-c-man .man ./usr/share/man/man3/__SHIFTOUT_MASK.3 comp-c-man .man +./usr/share/man/man3/__STRING.3 comp-c-man .man ./usr/share/man/man3/__UNCONST.3 comp-c-man .man ./usr/share/man/man3/__UNVOLATILE.3 comp-c-man .man ./usr/share/man/man3/__arraycount.3 comp-c-man .man Index: src/share/man/man3/Makefile diff -u src/share/man/man3/Makefile:1.47 src/share/man/man3/Makefile:1.48 --- src/share/man/man3/Makefile:1.47 Tue Apr 13 10:46:10 2010 +++ src/share/man/man3/Makefile Wed Apr 21 18:04:38 2010 @@ -1,7 +1,7 @@ -# $NetBSD: Makefile,v 1.47 2010/04/13 10:46:10 jruoho Exp $ +# $NetBSD: Makefile,v 1.48 2010/04/21 18:04:38 jruoho Exp $ # @(#)Makefile 8.2 (Berkeley) 12/13/93 -MAN= _DIAGASSERT.3 __UNCONST.3 CMSG_DATA.3 \ +MAN= _DIAGASSERT.3 __CONCAT.3 __UNCONST.3 CMSG_DATA.3 \ __arraycount.3 assert.3 bits.3 bitstring.3 dlfcn.3 end.3 \ fast_divide32.3 gcq.3 intro.3 inttypes.3 iso646.3 offsetof.3 queue.3 \ rb.3 stdarg.3 stdbool.3 stddef.3 stdint.3 stdlib.3 sysexits.3 \ @@ -9,6 +9,7 @@ USETBL= # used by queue.3 +MLINKS+=__CONCAT.3 __STRING.3 MLINKS+=__UNCONST.3 __UNVOLATILE.3 MLINKS+=bitstring.3 bit_alloc.3 \ bitstring.3 bit_clear.3 \ Added files: Index: src/share/man/man3/__CONCAT.3 diff -u /dev/null src/share/man/man3/__CONCAT.3:1.1 --- /dev/null Wed Apr 21 18:04:38 2010 +++ src/share/man/man3/__CONCAT.3 Wed Apr 21 18:04:38 2010 @@ -0,0 +1,102 @@ +.\" $NetBSD: __CONCAT.3,v 1.1 2010/04/21 18:04:38 jruoho Exp $ $ +.\" +.\" Copyright (c) 2010 The NetBSD Foundation, Inc. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to The NetBSD Foundation +.\" by Jukka Ruohonen. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS +.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS +.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +.\" POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd April 17, 2010 +.Os +.Dt __CONCAT 3 +.Sh NAME +.Nm __CONCAT , +.Nm __STRING +.Nd argument substitution +.Sh SYNOPSIS +.In sys/cdefs.h +.Ft xy +.Fn __CONCAT "x" "y" +.Ft const char * +.Fn __STRING "x" +.Sh DESCRIPTION +The +.Nm +macro makes use of the +.Xr cpp 3 +preprocessor to concatenate two tokens. +When the macro is expanded, +.Fa x +and +.Fa y +are combined into a single token, provided that the result forms a valid token; +two tokens that do not together form a valid token can not be concatenated. +This is known as +.Dq token concatenation +or +.Dq token pasting . +.Pp +The +.Fn __STRING +macro uses the conventional +.Sq # +preprocessing operator to replace the argument +.Fa x +with a string literal. +This is also known as +.Dq stringification . +.Sh EXAMPLES +The following two +.Xr printf 3 +calls produce the same output: +.Bd -literal -offset indent +#define Net 0x01 +#define BSD 0x02 + +#define NetBSD "NetBSD" + +(void)printf("%s\\n", __CONCAT(Net, BSD)); +(void)printf("%s%s\\n", __STRING(Net), __STRING(BSD)); +.Ed +.Sh SEE ALSO +.Xr cpp 1 +.Sh HISTORY +The +.Fn __CONCAT +and +.Fn __STRING +macros first appeared in +.Nx 1.3. +.Sh CAVEATS +Many small details direct the proper use of the macros. +For example, while all leading and trailing whitespace is ignored when +.Fn __STRING +is used, it is undefined whether +.Xr cpp 1 +puts white space between the tokens when +.Fn __CONCAT +is used. +It can be also noted that the C preprocessor converts all +comments to whitespace before any macros are even considered. +The use of either macro is discouraged in complex constructs.