Module Name:    src
Committed By:   jruoho
Date:           Sun Dec 19 08:10:09 UTC 2010

Modified Files:
        src/distrib/sets/lists/comp: mi
        src/share/man/man3: Makefile attribute.3 offsetof.3 typeof.3
Added Files:
        src/share/man/man3: __alignof__.3

Log Message:
Document the __alignof__ GNU extension.


To generate a diff of this commit:
cvs rdiff -u -r1.1554 -r1.1555 src/distrib/sets/lists/comp/mi
cvs rdiff -u -r1.64 -r1.65 src/share/man/man3/Makefile
cvs rdiff -u -r0 -r1.1 src/share/man/man3/__alignof__.3
cvs rdiff -u -r1.8 -r1.9 src/share/man/man3/attribute.3
cvs rdiff -u -r1.2 -r1.3 src/share/man/man3/offsetof.3
cvs rdiff -u -r1.1 -r1.2 src/share/man/man3/typeof.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.1554 src/distrib/sets/lists/comp/mi:1.1555
--- src/distrib/sets/lists/comp/mi:1.1554	Fri Dec 17 12:14:03 2010
+++ src/distrib/sets/lists/comp/mi	Sun Dec 19 08:10:07 2010
@@ -1,4 +1,4 @@
-#	$NetBSD: mi,v 1.1554 2010/12/17 12:14:03 jruoho Exp $
+#	$NetBSD: mi,v 1.1555 2010/12/19 08:10:07 jruoho Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -4906,6 +4906,7 @@
 ./usr/share/man/cat3/__UNCONST.0		comp-c-catman		.cat
 ./usr/share/man/cat3/__UNVOLATILE.0		comp-c-catman		.cat
 ./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_object_size.0	comp-c-catman		.cat
 ./usr/share/man/cat3/__cacheline_aligned.0	comp-c-catman		.cat
@@ -10994,6 +10995,7 @@
 ./usr/share/man/html3/__UNCONST.html		comp-c-htmlman		html
 ./usr/share/man/html3/__UNVOLATILE.html		comp-c-htmlman		html
 ./usr/share/man/html3/__aligned.html		comp-c-htmlman		html
+./usr/share/man/html3/__alignof__.html		comp-c-htmlman		html
 ./usr/share/man/html3/__arraycount.html		comp-c-htmlman		html
 ./usr/share/man/html3/__builtin_object_size.html	comp-c-htmlman		html
 ./usr/share/man/html3/__cacheline_aligned.html	comp-c-htmlman		html
@@ -16882,6 +16884,7 @@
 ./usr/share/man/man3/__UNCONST.3		comp-c-man		.man
 ./usr/share/man/man3/__UNVOLATILE.3		comp-c-man		.man
 ./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_object_size.3	comp-c-man		.man
 ./usr/share/man/man3/__cacheline_aligned.3	comp-c-man		.man

Index: src/share/man/man3/Makefile
diff -u src/share/man/man3/Makefile:1.64 src/share/man/man3/Makefile:1.65
--- src/share/man/man3/Makefile:1.64	Fri Dec 17 12:14:04 2010
+++ src/share/man/man3/Makefile	Sun Dec 19 08:10:08 2010
@@ -1,8 +1,8 @@
-#	$NetBSD: Makefile,v 1.64 2010/12/17 12:14:04 jruoho Exp $
+#	$NetBSD: Makefile,v 1.65 2010/12/19 08:10:08 jruoho Exp $
 #	@(#)Makefile	8.2 (Berkeley) 12/13/93
 
 MAN=	_DIAGASSERT.3 __CONCAT.3 __UNCONST.3 CMSG_DATA.3 \
-	__arraycount.3 __insn_barrier.3 \
+	__alignof__.3 __arraycount.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 \

Index: src/share/man/man3/attribute.3
diff -u src/share/man/man3/attribute.3:1.8 src/share/man/man3/attribute.3:1.9
--- src/share/man/man3/attribute.3:1.8	Fri Dec 17 08:23:04 2010
+++ src/share/man/man3/attribute.3	Sun Dec 19 08:10:09 2010
@@ -1,4 +1,4 @@
-.\" $NetBSD: attribute.3,v 1.8 2010/12/17 08:23:04 jruoho Exp $
+.\" $NetBSD: attribute.3,v 1.9 2010/12/19 08:10:09 jruoho Exp $
 .\"
 .\" Copyright (c) 2010 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd December 16, 2010
+.Dd December 19, 2010
 .Dt ATTRIBUTE 3
 .Os
 .Sh NAME
@@ -208,6 +208,9 @@
 The effectiveness of
 .Fn __aligned
 is largely dependent on the linker.
+The
+.Xr __alignof__ 3
+operator can be used to examine the alignment.
 .It Fn __section "section"
 The
 .Fn __section

Index: src/share/man/man3/offsetof.3
diff -u src/share/man/man3/offsetof.3:1.2 src/share/man/man3/offsetof.3:1.3
--- src/share/man/man3/offsetof.3:1.2	Sun Mar 21 12:36:21 2010
+++ src/share/man/man3/offsetof.3	Sun Dec 19 08:10:09 2010
@@ -1,4 +1,4 @@
-.\"	$NetBSD: offsetof.3,v 1.2 2010/03/21 12:36:21 jruoho Exp $
+.\"	$NetBSD: offsetof.3,v 1.3 2010/12/19 08:10:09 jruoho Exp $
 .\"
 .\"	$OpenBSD: offsetof.3,v 1.2 2010/02/18 18:30:19 jmc Exp $
 .\"
@@ -17,7 +17,7 @@
 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 .\"
 .\"
-.Dd February 18, 2010
+.Dd December 19, 2010
 .Dt OFFSETOF 3
 .Os
 .Sh NAME
@@ -42,7 +42,9 @@
 .Ar member
 is not aligned to a byte boundary (i.e. it is a bit-field).
 .Sh SEE ALSO
-.Xr stddef 3
+.Xr __alignof__ 3 ,
+.Xr stddef 3 ,
+.Xr typeof 3
 .Sh STANDARDS
 The
 .Fn offsetof

Index: src/share/man/man3/typeof.3
diff -u src/share/man/man3/typeof.3:1.1 src/share/man/man3/typeof.3:1.2
--- src/share/man/man3/typeof.3:1.1	Fri Dec 17 12:14:04 2010
+++ src/share/man/man3/typeof.3	Sun Dec 19 08:10:09 2010
@@ -1,4 +1,4 @@
-.\" $NetBSD: typeof.3,v 1.1 2010/12/17 12:14:04 jruoho Exp $
+.\" $NetBSD: typeof.3,v 1.2 2010/12/19 08:10:09 jruoho Exp $
 .\"
 .\" Copyright (c) 2010 Jukka Ruohonen <[email protected]>
 .\" All rights reserved.
@@ -24,7 +24,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd December 17, 2010
+.Dd December 19, 2010
 .Dt TYPEOF 3
 .Os
 .Sh NAME
@@ -54,6 +54,7 @@
 .Ed
 .Sh SEE ALSO
 .Xr gcc 1 ,
+.Xr __alignof__ 3 ,
 .Xr attribute 3 ,
 .Xr offsetof 3
 .Sh CAVEATS

Added files:

Index: src/share/man/man3/__alignof__.3
diff -u /dev/null src/share/man/man3/__alignof__.3:1.1
--- /dev/null	Sun Dec 19 08:10:09 2010
+++ src/share/man/man3/__alignof__.3	Sun Dec 19 08:10:09 2010
@@ -0,0 +1,84 @@
+.\" $NetBSD: __alignof__.3,v 1.1 2010/12/19 08:10:09 jruoho Exp $
+.\"
+.\" Copyright (c) 2010 Jukka Ruohonen <[email protected]>
+.\" 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 19, 2010
+.Dt __alignof__ 3
+.Os
+.Sh NAME
+.Nm __alignof__
+.Nd GNU extension for alignment of an object
+.Sh SYNOPSIS
+.Ft int
+.Fn __alignof__ "void type"
+.Sh DESCRIPTION
+The
+.Fn __alignof__
+operator returns the alignment of its operand.
+The operand can be a type or an expression.
+If the operand is a
+.Sq lvalue ,
+the return value represents the required alignment of the underlying type,
+not the actual alignment of the specified
+.Sq lvalue .
+.Pp
+The returned value is specific to the architecture and the
+.Tn ABI .
+If the architecture does not impose strict alignment requirements,
+.Fn __alignof__
+returns the minimum required alignment.
+If
+.Xr __aligned 3
+is used to increase the alignment,
+.Fn __alignof__
+returns the specified alignment.
+.Sh EXAMPLES
+The syntax is comparable to the
+.Fn sizeof
+operator.
+If the architecture aligns integers along 32-bit address boundaries,
+the following should print the value 4.
+.Bd -literal -offset indent
+(void)printf(\*[q]%d\\n\*[q], __alignof__(int));
+.Ed
+.Pp
+On the other hand, the following example probably prints the value 1,
+even though this is unlikely to be the actual alignment of the
+structure member.
+.Bd -literal -offset indent
+struct align {
+	int  x;
+	char y;
+} a;
+
+(void)printf(\*[q]%d\\n\*[q], __alignof__(a.y));
+.Ed
+.Sh SEE ALSO
+.Xr gcc 1 ,
+.Xr attribute 3 ,
+.Xr offsetof 3 ,
+.Xr typeof 3
+.Sh CAVEATS
+This is a non-standard, compiler-specific extension.

Reply via email to