Sat Aug 6 00:39:29 2011

Asterisk developer's documentation


inline_api.h

Go to the documentation of this file.
00001 /*
00002  * Asterisk -- An open source telephony toolkit.
00003  *
00004  * Copyright (C) 1999 - 2005, Digium, Inc.
00005  *
00006  * Kevin P. Fleming <kpfleming@digium.com>
00007  *
00008  * See http://www.asterisk.org for more information about
00009  * the Asterisk project. Please do not directly contact
00010  * any of the maintainers of this project for assistance;
00011  * the project provides a web site, mailing lists and IRC
00012  * channels for your use.
00013  *
00014  * This program is free software, distributed under the terms of
00015  * the GNU General Public License Version 2. See the LICENSE file
00016  * at the top of the source tree.
00017  */
00018 
00019 #ifndef __ASTERISK_INLINEAPI_H
00020 #define __ASTERISK_INLINEAPI_H
00021 
00022 /*! \file
00023  * \brief Inlinable API function macro
00024 
00025   Small API functions that are candidates for inlining need to be specially
00026   declared and defined, to ensure that the 'right thing' always happens.
00027   For example:
00028    - there must _always_ be a non-inlined version of the function
00029    available for modules compiled out of the tree to link to
00030    - references to a function that cannot be inlined (for any
00031    reason that the compiler deems proper) must devolve into an
00032    'extern' reference, instead of 'static', so that multiple
00033    copies of the function body are not built in different modules
00034    - when LOW_MEMORY is defined, inlining should be disabled
00035    completely, even if the compiler is configured to support it
00036 
00037   The AST_INLINE_API macro allows this to happen automatically, when
00038   used to define your function. Proper usage is as follows:
00039   - define your function one place, in a header file, using the macro
00040   to wrap the function (see strings.h or time.h for examples)
00041   - choose a module to 'host' the function body for non-inline
00042   usages, and in that module _only_, define AST_API_MODULE before
00043   including the header file
00044  */
00045 
00046 #if !defined(LOW_MEMORY)
00047 
00048 #if !defined(AST_API_MODULE)
00049 #define AST_INLINE_API(hdr, body) hdr; extern inline hdr body
00050 #else
00051 #define AST_INLINE_API(hdr, body) hdr; hdr body
00052 #endif
00053 
00054 #else /* defined(LOW_MEMORY) */
00055 
00056 #if !defined(AST_API_MODULE)
00057 #define AST_INLINE_API(hdr, body) hdr;
00058 #else
00059 #define AST_INLINE_API(hdr, body) hdr; hdr body
00060 #endif
00061 
00062 #endif
00063 
00064 #undef AST_API_MODULE
00065 
00066 #endif /* __ASTERISK_INLINEAPI_H */

Generated on Sat Aug 6 00:39:29 2011 for Asterisk - the Open Source PBX by  doxygen 1.4.7