Copyright (c) 1994 Sun Microsystems, Inc. - All Rights Reserved.
The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
#include <note.h> NOTE(NoteInfo);
or #include <sys/note.h> _NOTE(NoteInfo);
Annotations should, in general, provide documentation useful to the human reader. If information is of no use to a human trying to understand the code but is necessary for proper operation of a tool, use another mechanism for conveying that information to the tool (one which does not involve adding to the source code), so as not to detract from the readability of the source. The following is an example of an annotation which provides information of use to a tool and to the human reader (in this case, which data are protected by a particular lock, an annotation defined by the static lock analysis tool lock_lint).
NOTE(MUTEX_PROTECTS_DATA(foo_lock, foo_list Foo))
Such annotations do not represent executable code; they are neither statements nor declarations. They should not be followed by a semicolon. If a compiler or tool that analyzes C source does not understand this annotation scheme, then the tool will ignore the annotations. (For such tools, NOTE(x) expands to nothing.)
Annotations may only be placed at particular places in the source. These places are where the following C constructs would be allowed:
a top-level declaration (that is, a declaration not within a function or other construct)
a declaration or statement within a block (including the block which defines a function)
a member of a struct or union.
Annotations are not allowed in any other place. For example, the following are illegal:
x = y + NOTE(...) z ; typedef NOTE(...) unsigned int uint ;
While NOTE and _NOTE may be used in the places described above, a particular type of annotation may only be allowed in a subset of those places. For example, a particular annotation may not be allowed inside a struct or union definition.
#ifndef _FOO_H #define _FOO_H #define FOO _NOTE #include <sys/note.h> #endif
Public header files which span projects should use _NOTE rather than NOTE, since NOTE may already be used by a program which needs to include such a header file.
NoteInfo must have one of the following forms:
NoteName NoteName(Args)
where NoteName is simply an identifier which indicates the type of annotation, and Args is something defined by the tool that specifies the particular NoteName. The general restrictions on Args are that it be compatible with an ANSI C tokenizer and that unquoted parentheses be balanced (so that the end of the annotation can be determined without intimate knowledge of any particular annotation).
ATTRIBUTE TYPE ATTRIBUTE VALUE |
MT-Level Safe |