Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Document the __builtin_types_compatible_p() GNU/GCC extension.
details: https://anonhg.NetBSD.org/src/rev/189697514ef8
branches: trunk
changeset: 759944:189697514ef8
user: jruoho <jruoho%NetBSD.org@localhost>
date: Tue Dec 21 15:05:02 2010 +0000
description:
Document the __builtin_types_compatible_p() GNU/GCC extension.
diffstat:
distrib/sets/lists/comp/mi | 21 ++--
share/man/man3/Makefile | 5 +-
share/man/man3/__builtin_types_compatible_p.3 | 105 ++++++++++++++++++++++++++
3 files changed, 120 insertions(+), 11 deletions(-)
diffs (174 lines):
diff -r deb77471fa6f -r 189697514ef8 distrib/sets/lists/comp/mi
--- a/distrib/sets/lists/comp/mi Tue Dec 21 14:26:17 2010 +0000
+++ b/distrib/sets/lists/comp/mi Tue Dec 21 15:05:02 2010 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1558 2010/12/19 22:53:19 pgoyette Exp $
+# $NetBSD: mi,v 1.1559 2010/12/21 15:05:02 jruoho Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -4909,10 +4909,11 @@
./usr/share/man/cat3/__aligned.0 comp-c-catman .cat
./usr/share/man/cat3/__alignof__.0 comp-c-catman .cat
./usr/share/man/cat3/__arraycount.0 comp-c-catman .cat
-./usr/share/man/cat3/__builtin_constant_p.0 comp-c-catman .cat
-./usr/share/man/cat3/__builtin_frame_address.0 comp-c-catman .cat
-./usr/share/man/cat3/__builtin_object_size.0 comp-c-catman .cat
-./usr/share/man/cat3/__builtin_return_address.0 comp-c-catman .cat
+./usr/share/man/cat3/__builtin_constant_p.0 comp-c-catman .cat
+./usr/share/man/cat3/__builtin_frame_address.0 comp-c-catman .cat
+./usr/share/man/cat3/__builtin_object_size.0 comp-c-catman .cat
+./usr/share/man/cat3/__builtin_return_address.0 comp-c-catman .cat
+./usr/share/man/cat3/__builtin_types_compatible_p.0 comp-c-catman .cat
./usr/share/man/cat3/__cacheline_aligned.0 comp-c-catman .cat
./usr/share/man/cat3/__constfunc.0 comp-c-catman .cat
./usr/share/man/cat3/__dead.0 comp-c-catman .cat
@@ -11005,6 +11006,7 @@
./usr/share/man/html3/__builtin_frame_address.html comp-c-htmlman html
./usr/share/man/html3/__builtin_object_size.html comp-c-htmlman html
./usr/share/man/html3/__builtin_return_address.html comp-c-htmlman html
+./usr/share/man/html3/__builtin_types_compatible_p.html comp-c-htmlman html
./usr/share/man/html3/__cacheline_aligned.html comp-c-htmlman html
./usr/share/man/html3/__constfunc.html comp-c-htmlman html
./usr/share/man/html3/__dead.html comp-c-htmlman html
@@ -16893,10 +16895,11 @@
./usr/share/man/man3/__aligned.3 comp-c-man .man
./usr/share/man/man3/__alignof__.3 comp-c-man .man
./usr/share/man/man3/__arraycount.3 comp-c-man .man
-./usr/share/man/man3/__builtin_constant_p.3 comp-c-man .man
-./usr/share/man/man3/__builtin_frame_address.3 comp-c-man .man
-./usr/share/man/man3/__builtin_object_size.3 comp-c-man .man
-./usr/share/man/man3/__builtin_return_address.3 comp-c-man .man
+./usr/share/man/man3/__builtin_constant_p.3 comp-c-man .man
+./usr/share/man/man3/__builtin_frame_address.3 comp-c-man .man
+./usr/share/man/man3/__builtin_object_size.3 comp-c-man .man
+./usr/share/man/man3/__builtin_return_address.3 comp-c-man .man
+./usr/share/man/man3/__builtin_types_compatible_p.3 comp-c-man .man
./usr/share/man/man3/__cacheline_aligned.3 comp-c-man .man
./usr/share/man/man3/__constfunc.3 comp-c-man .man
./usr/share/man/man3/__dead.3 comp-c-man .man
diff -r deb77471fa6f -r 189697514ef8 share/man/man3/Makefile
--- a/share/man/man3/Makefile Tue Dec 21 14:26:17 2010 +0000
+++ b/share/man/man3/Makefile Tue Dec 21 15:05:02 2010 +0000
@@ -1,9 +1,10 @@
-# $NetBSD: Makefile,v 1.67 2010/12/19 10:07:24 jruoho Exp $
+# $NetBSD: Makefile,v 1.68 2010/12/21 15:05:02 jruoho Exp $
# @(#)Makefile 8.2 (Berkeley) 12/13/93
MAN= _DIAGASSERT.3 __CONCAT.3 __UNCONST.3 CMSG_DATA.3 \
__alignof__.3 __arraycount.3 \
- __builtin_constant_p.3 __builtin_return_address.3 __insn_barrier.3 \
+ __builtin_constant_p.3 __builtin_return_address.3 \
+ __builtin_types_compatible_p.3 __insn_barrier.3 \
assert.3 attribute.3 bits.3 bitstring.3 \
cdefs.3 dirent.3 dlfcn.3 dl_iterate_phdr.3 end.3 \
fast_divide32.3 ffs32.3 gcq.3 \
diff -r deb77471fa6f -r 189697514ef8 share/man/man3/__builtin_types_compatible_p.3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/share/man/man3/__builtin_types_compatible_p.3 Tue Dec 21 15:05:02 2010 +0000
@@ -0,0 +1,105 @@
+.\" $NetBSD: __builtin_types_compatible_p.3,v 1.1 2010/12/21 15:05:02 jruoho Exp $
+.\"
+.\" Copyright (c) 2010 Jukka Ruohonen <jruohonen%iki.fi@localhost>
+.\" All rights reserved.
+.\"
+.\" 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 December 21, 2010
+.Dt __BUILTIN_TYPES_COMPATIBLE_P 3
+.Os
+.Sh NAME
+.Nm __builtin_types_compatible_p
+.Nd GNU extension to check equivalent types
+.Sh SYNOPSIS
+.Ft int
+.Fn __builtin_types_compatible_p "type_a" "type_b"
+.Sh DESCRIPTION
+The
+.Fn __builtin_types_compatible_p
+is a
+.Tn GNU
+extension for determining whether two types are equivalent.
+If
+.Fa type_a
+is equivalent to
+.Fa type_b ,
+a value 1 is returned.
+Otherwise
+.Fn __builtin_types_compatible_p
+returns 0.
+.Pp
+The following remarks should be taken into account.
+.Bl -enum -offset indent
+.It
+The architecture-specific size of the two types
+does not have an impact on the result.
+For example,
+.Fn sizeof "char *"
+and
+.Fn sizeof "int"
+result the same value on i386, but the types naturally are not equivalent.
+.It
+Type qualifiers are ignored.
+The function returns the same value for
+.Vt long
+and
+.Vt const long .
+.It
+The amount of pointer indirection affects the result.
+For example,
+.Vt double *
+is not equivalent to
+.Vt double ** .
+.It
+Two types defined with
+.Em typedef
+are equivalent if and only if their underlying types are equivalent.
+.It
+The
+.Em enum
+type is a special case in that two
+.Em enum
+types are not considered equivalent.
+.El
+.Sh EXAMPLES
+The following example combines
+.Fn __builtin_types_compatible_p
+and the
+.Xr typeof 3
+construct:
+.Bd -literal -offset indent
+#define __COMPARE_TYPES(v, t) \\
+ __builtin_types_compatible_p(__typeof__(v), t)
+
+\&...
+
+if (__COMPARE_TYPES(p, double) != 0)
+ err(EX_DATAERR, "invalid type");
+.Ed
+.Pp
+.Sh SEE ALSO
+.Xr gcc 1 ,
+.Xr __builtin_constant_p 3 ,
+.Xr typeof 3
+.Sh CAVEATS
+This is a non-standard, compiler-specific extension.
Home |
Main Index |
Thread Index |
Old Index