Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Document __dead, __pure, __constfunc, __noinline, __unused, ...
details: https://anonhg.NetBSD.org/src/rev/47462482fb7c
branches: trunk
changeset: 759787:47462482fb7c
user: jruoho <jruoho%NetBSD.org@localhost>
date: Thu Dec 16 17:47:53 2010 +0000
description:
Document __dead, __pure, __constfunc, __noinline, __unused, and __used.
diffstat:
distrib/sets/lists/comp/mi | 20 ++++++++-
share/man/man3/Makefile | 10 +++-
share/man/man3/attribute.3 | 101 +++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 125 insertions(+), 6 deletions(-)
diffs (207 lines):
diff -r 57eaafbbe97f -r 47462482fb7c distrib/sets/lists/comp/mi
--- a/distrib/sets/lists/comp/mi Thu Dec 16 17:42:25 2010 +0000
+++ b/distrib/sets/lists/comp/mi Thu Dec 16 17:47:53 2010 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1547 2010/12/16 10:19:13 jruoho Exp $
+# $NetBSD: mi,v 1.1548 2010/12/16 17:47:53 jruoho Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -4908,9 +4908,15 @@
./usr/share/man/cat3/__aligned.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/__constfunc.0 comp-c-catman .cat
+./usr/share/man/cat3/__dead.0 comp-c-catman .cat
+./usr/share/man/cat3/__noinline.0 comp-c-catman .cat
./usr/share/man/cat3/__packed.0 comp-c-catman .cat
+./usr/share/man/cat3/__pure.0 comp-c-catman .cat
./usr/share/man/cat3/__section.0 comp-c-catman .cat
./usr/share/man/cat3/__svc_getcallercreds.0 comp-c-catman .cat
+./usr/share/man/cat3/__unused.0 comp-c-catman .cat
+./usr/share/man/cat3/__used.0 comp-c-catman .cat
./usr/share/man/cat3/_longjmp.0 comp-c-catman .cat
./usr/share/man/cat3/_lwp_makecontext.0 comp-c-catman .cat
./usr/share/man/cat3/_setjmp.0 comp-c-catman .cat
@@ -10975,9 +10981,15 @@
./usr/share/man/html3/__aligned.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/__constfunc.html comp-c-htmlman html
+./usr/share/man/html3/__dead.html comp-c-htmlman html
+./usr/share/man/html3/__noinline.html comp-c-htmlman html
./usr/share/man/html3/__packed.html comp-c-htmlman html
+./usr/share/man/html3/__pure.html comp-c-htmlman html
./usr/share/man/html3/__section.html comp-c-htmlman html
./usr/share/man/html3/__svc_getcallercreds.html comp-c-htmlman html
+./usr/share/man/html3/__unused.html comp-c-htmlman html
+./usr/share/man/html3/__used.html comp-c-htmlman html
./usr/share/man/html3/_longjmp.html comp-c-htmlman html
./usr/share/man/html3/_lwp_makecontext.html comp-c-htmlman html
./usr/share/man/html3/_setjmp.html comp-c-htmlman html
@@ -16842,9 +16854,15 @@
./usr/share/man/man3/__aligned.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/__constfunc.3 comp-c-man .man
+./usr/share/man/man3/__dead.3 comp-c-man .man
+./usr/share/man/man3/__noinline.3 comp-c-man .man
./usr/share/man/man3/__packed.3 comp-c-man .man
+./usr/share/man/man3/__pure.3 comp-c-man .man
./usr/share/man/man3/__section.3 comp-c-man .man
./usr/share/man/man3/__svc_getcallercreds.3 comp-c-man .man
+./usr/share/man/man3/__unused.3 comp-c-man .man
+./usr/share/man/man3/__used.3 comp-c-man .man
./usr/share/man/man3/_longjmp.3 comp-c-man .man
./usr/share/man/man3/_lwp_makecontext.3 comp-c-man .man
./usr/share/man/man3/_setjmp.3 comp-c-man .man
diff -r 57eaafbbe97f -r 47462482fb7c share/man/man3/Makefile
--- a/share/man/man3/Makefile Thu Dec 16 17:42:25 2010 +0000
+++ b/share/man/man3/Makefile Thu Dec 16 17:47:53 2010 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.60 2010/12/16 10:19:14 jruoho Exp $
+# $NetBSD: Makefile,v 1.61 2010/12/16 17:47:54 jruoho Exp $
# @(#)Makefile 8.2 (Berkeley) 12/13/93
MAN= _DIAGASSERT.3 __CONCAT.3 __UNCONST.3 CMSG_DATA.3 \
@@ -14,7 +14,13 @@
MLINKS+=__CONCAT.3 __STRING.3
MLINKS+=__UNCONST.3 __UNVOLATILE.3
-MLINKS+=attribute.3 __packed.3 \
+MLINKS+=attribute.3 __dead.3 \
+ attribute.3 __pure.3 \
+ attribute.3 __constfunc.3 \
+ attribute.3 __noinline.3 \
+ attribute.3 __unused.3 \
+ attribute.3 __used.3 \
+ attribute.3 __packed.3 \
attribute.3 __aligned.3 \
attribute.3 __section.3
MLINKS+=bitstring.3 bit_alloc.3 \
diff -r 57eaafbbe97f -r 47462482fb7c share/man/man3/attribute.3
--- a/share/man/man3/attribute.3 Thu Dec 16 17:42:25 2010 +0000
+++ b/share/man/man3/attribute.3 Thu Dec 16 17:47:53 2010 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: attribute.3,v 1.4 2010/12/16 15:55:41 jruoho Exp $
+.\" $NetBSD: attribute.3,v 1.5 2010/12/16 17:47:54 jruoho Exp $
.\"
.\" Copyright (c) 2010 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -32,10 +32,22 @@
.Os
.Sh NAME
.Nm attribute
-.Nd non-standard GCC extensions
+.Nd non-standard GCC attribute extensions
.Sh SYNOPSIS
.In sys/cdefs.h
.Pp
+.Ic __dead
+.Pp
+.Ic __pure
+.Pp
+.Ic __constfunc
+.Pp
+.Ic __noinline
+.Pp
+.Ic __unused
+.Pp
+.Ic __used
+.Pp
.Ic __packed
.Pp
.Fn __aligned "x"
@@ -54,8 +66,91 @@
.Tn GCC's
.Em __attribute__
extension directly.
-.Sh FUNCTIONS
+.Sh ATTRIBUTES
.Bl -tag -width abc
+.It Ic __dead
+The
+.Xr gcc 1
+compiler knows that certain functions such as
+.Xr abort 3
+and
+.Xr exit 3
+can never return any value.
+When such a function is equipped with
+.Ic __dead ,
+certain optimizations are possible.
+Obviously a
+.Ic __dead
+function can never have return type other than
+.Vt void .
+.It Ic __pure
+A
+.Ic __pure
+function is defined to be one that has no effects except
+the return value, which is assumed to depend only on the
+function parameters and/or global variables.
+Any access to parameters and/or global variables must also be read-only.
+A function that depends on volatile memory, or other comparable
+system resource that can change between two consecutive calls,
+can never be
+.Ic __pure .
+Many
+.Xr math 3
+functions satisfy the definition of a
+.Ic __pure
+function, at least in theory.
+Other examples include
+.Xr strlen 3
+and
+.Xr strcmp 3 .
+.It Ic __constfunc
+A
+.Dq const function
+is a stricter variant of
+.Dq pure functions .
+In addition to the restrictions of pure functions, a function declared with
+.Ic __constfunc
+can never access global variables nor take pointers as parameters.
+The return value of these functions must depend
+only on the passed-by-value parameters.
+Note also that a function that calls non-const functions can not be
+.Ic __constfunc .
+The canonical example of a const function would be
+.Xr abs 3 .
+As with pure functions,
+certain micro-optimizations are possible for functions declared with
+.Ic __constfunc .
+.It Ic __noinline
+.Tn GCC
+is known for aggressive function inlining.
+Sometimes it is known that inlining is undesirable or that
+a function will perform incorrectly when inlined.
+The
+.Ic __noinline
+macro expands to a function attribute that prevents
+.Tn GCC
+for inlining the function, irrespective
+whether the function was declared with the
+.Em inline
+keyword.
+The attribute takes precedence over all
+other compiler options related to inlining.
+.It Ic __unused
+In most
+.Tn GCC
+versions the common
+.Fl Wall
+flag enables warnings produced by functions that are defined but unused.
+Marking an unused function with the
+.Ic __unused
+macro inhibits these warnings.
+.It Ic __used
+The
+.Ic __used
+macro expands to an attribute that informs
+.Tn GCC
+that a static variable or function is to be always retained
+in the object file even if it is unreferenced.
.It Ic __packed
The
.Ic __packed
Home |
Main Index |
Thread Index |
Old Index