2005-06-24 22:50:07 +00:00
|
|
|
/*
|
2005-08-30 18:32:10 +00:00
|
|
|
* Asterisk -- An open source telephony toolkit.
|
2005-06-24 22:50:07 +00:00
|
|
|
*
|
2005-08-30 18:32:10 +00:00
|
|
|
* Copyright (C) 1999 - 2005, Digium, Inc.
|
|
|
|
*
|
|
|
|
* Mark Spencer <markster@digium.com>
|
2005-06-24 22:50:07 +00:00
|
|
|
*
|
2005-08-30 18:32:10 +00:00
|
|
|
* See http://www.asterisk.org for more information about
|
|
|
|
* the Asterisk project. Please do not directly contact
|
|
|
|
* any of the maintainers of this project for assistance;
|
|
|
|
* the project provides a web site, mailing lists and IRC
|
|
|
|
* channels for your use.
|
2005-06-24 22:50:07 +00:00
|
|
|
*
|
|
|
|
* This program is free software, distributed under the terms of
|
2005-08-30 18:32:10 +00:00
|
|
|
* the GNU General Public License Version 2. See the LICENSE file
|
|
|
|
* at the top of the source tree.
|
|
|
|
*/
|
|
|
|
|
2005-10-24 20:12:06 +00:00
|
|
|
/*! \file
|
|
|
|
* \brief Compiler-specific macros and other items
|
2005-06-24 22:50:07 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _ASTERISK_COMPILER_H
|
|
|
|
#define _ASTERISK_COMPILER_H
|
|
|
|
|
2008-05-04 01:52:00 +00:00
|
|
|
#ifdef HAVE_ATTRIBUTE_always_inline
|
2006-09-28 13:02:30 +00:00
|
|
|
#define force_inline __attribute__((always_inline)) inline
|
2006-08-21 02:11:39 +00:00
|
|
|
#else
|
|
|
|
#define force_inline inline
|
|
|
|
#endif
|
|
|
|
|
2008-05-04 01:52:00 +00:00
|
|
|
#ifdef HAVE_ATTRIBUTE_pure
|
2006-07-28 22:50:54 +00:00
|
|
|
#define attribute_pure __attribute__((pure))
|
2006-08-21 02:11:39 +00:00
|
|
|
#else
|
|
|
|
#define attribute_pure
|
2006-07-28 23:30:18 +00:00
|
|
|
#endif
|
2006-07-28 22:50:54 +00:00
|
|
|
|
2008-05-04 01:52:00 +00:00
|
|
|
#ifdef HAVE_ATTRIBUTE_const
|
2006-07-28 22:50:54 +00:00
|
|
|
#define attribute_const __attribute__((const))
|
2006-08-21 02:11:39 +00:00
|
|
|
#else
|
|
|
|
#define attribute_const
|
|
|
|
#endif
|
|
|
|
|
2010-09-07 19:38:55 +00:00
|
|
|
#ifdef HAVE_ATTRIBUTE_deprecated
|
|
|
|
#define attribute_deprecated __attribute__((deprecated))
|
|
|
|
#else
|
|
|
|
#define attribute_deprecated
|
|
|
|
#endif
|
|
|
|
|
2008-05-04 01:52:00 +00:00
|
|
|
#ifdef HAVE_ATTRIBUTE_unused
|
Merge team/russell/ast_verbose_threadstorage
- instead of defining a free() wrapper in a bunch of files, define it as
ast_free() in utils.h and remove the copies from all the files.
- centralize and abstract the code used for doing thread storage. The code
lives in threadstorage.h, with one function being implemented in utils.c.
This new API includes generic thread storage as well as special functions
for handling thread local dynamic length string buffers.
- update ast_inet_ntoa() to use the new threadstorage API
- update ast_state2str() to use the new threadstorage API
- update ast_cli() to use the new threadstorage API
- Modify manager_event() to use thread storage. Instead of using a buffer of
4096 characters as the workspace for building the manager event, use a thread
local dynamic string. Now there is no length limitation on the length of the
body of a manager event.
- Significantly simplify the handling of ast_verbose() ...
- Instead of using a static char buffer and a lock to make sure only one
thread can be using ast_verbose() at a time, use a thread local dynamic
string as the workspace for preparing the verbose message. Instead of
locking around the entire function, the only locking done now is when the
message has been built and is being deliviered to the list of registered
verbose message handlers.
- This function was doing a strdup() on every message passed to it and
keeping a queue of the last 200 messages in memory. This has been
completely removed. The only place this was used was that if there were
any messages in the verbose queue when a verbose handler was registered,
all of the messages in the queue would be fed to it. So, I just made sure
that the console verbose handler and the network verbose handler (for
remote asterisk consoles) were registered before any verbose messages.
pbx_gtkconsole and pbx_kdeconsole will now lose a few verbose messages at
startup, but I didn't feel the performance hit of this message queue was
worth saving the initial verbose output for these very rarely used modules.
- I have removed the last three arguments to the verbose handlers, leaving
only the string itself because they aren't needed anymore. For example,
ast_verbose had some logic for telling the verbose handler to add
a newline if the buffer was completely full. Now that the buffer can grow
as needed, this doesn't matter anymore.
- remove unused function, ast_verbose_dmesg() which was to dispatch the
message queue
- Convert the list of verbose handlers to use the linked list macros.
- add missing newline characters to a few ast_verbose() calls
- convert the list of log channels to use the linked list macros in logger.c
- fix close_logger() to close all of the files it opened for logging
- update ast_log() to use a thread local dynamic string for its workspace
for preparing log messages instead of a buffer of size BUFSIZ (8kB on my
system) allocated on the stack. The dynamic string in this case is limited
to only growing to a maximum size of BUFSIZ.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@39272 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-08-08 06:32:04 +00:00
|
|
|
#define attribute_unused __attribute__((unused))
|
2006-08-21 02:11:39 +00:00
|
|
|
#else
|
|
|
|
#define attribute_unused
|
|
|
|
#endif
|
|
|
|
|
2008-05-04 01:52:00 +00:00
|
|
|
#ifdef HAVE_ATTRIBUTE_malloc
|
2006-08-21 02:11:39 +00:00
|
|
|
#define attribute_malloc __attribute__((malloc))
|
|
|
|
#else
|
|
|
|
#define attribute_malloc
|
|
|
|
#endif
|
2006-07-28 22:50:54 +00:00
|
|
|
|
2008-05-04 01:52:00 +00:00
|
|
|
#ifdef HAVE_ATTRIBUTE_sentinel
|
2008-05-02 02:56:39 +00:00
|
|
|
#define attribute_sentinel __attribute__((sentinel))
|
|
|
|
#else
|
|
|
|
#define attribute_sentinel
|
|
|
|
#endif
|
|
|
|
|
2008-06-19 17:55:34 +00:00
|
|
|
#ifdef HAVE_ATTRIBUTE_warn_unused_result
|
|
|
|
#define attribute_warn_unused_result __attribute__((warn_unused_result))
|
|
|
|
#else
|
|
|
|
#define attribute_warn_unused_result
|
|
|
|
#endif
|
|
|
|
|
optional_api: Fix linking problems between modules that export global symbols
With the new work in Asterisk 12, there are some uses of the
optional_api that are prone to failure. The details are rather involved,
and captured on [the wiki][1].
This patch addresses the issue by removing almost all of the magic from
the optional API implementation. Instead of relying on weak symbol
resolution, a new optional_api.c module was added to Asterisk core.
For modules providing an optional API, the pointer to the implementation
function is registered with the core. For modules that use an optional
API, a pointer to a stub function, along with a optional_ref function
pointer are registered with the core. The optional_ref function pointers
is set to the implementation function when it's provided, or the stub
function when it's now.
Since the implementation no longer relies on magic, it is now supported
on all platforms. In the spirit of choice, an OPTIONAL_API flag was
added, so we can disable the optional_api if needed (maybe it's buggy on
some bizarre platform I haven't tested on)
The AST_OPTIONAL_API*() macros themselves remained unchanged, so
existing code could remain unchanged. But to help with debugging the
optional_api, the patch limits the #include of optional API's to just
the modules using the API. This also reduces resource waste maintaining
optional_ref pointers that aren't used.
Other changes made as a part of this patch:
* The stubs for http_websocket that wrap system calls set errno to
ENOSYS.
* res_http_websocket now properly increments module use count.
* In loader.c, the while() wrappers around dlclose() were removed. The
while(!dlclose()) is actually an anti-pattern, which can lead to
infinite loops if the module you're attempting to unload exports a
symbol that was directly linked to.
* The special handling of nonoptreq on systems without weak symbol
support was removed, since we no longer rely on weak symbols for
optional_api.
[1]: https://wiki.asterisk.org/wiki/x/wACUAQ
(closes issue ASTERISK-22296)
Reported by: Matt Jordan
Review: https://reviewboard.asterisk.org/r/2797/
........
Merged revisions 397989 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@397990 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-30 13:40:27 +00:00
|
|
|
#ifdef HAVE_ATTRIBUTE_may_alias
|
|
|
|
#define attribute_may_alias __attribute__((may_alias))
|
|
|
|
#else
|
|
|
|
#define attribute_may_alias
|
|
|
|
#endif
|
|
|
|
|
2016-07-18 23:46:19 -04:00
|
|
|
#ifdef HAVE_ATTRIBUTE_noreturn
|
|
|
|
#define attribute_noreturn __attribute__((noreturn))
|
|
|
|
#else
|
|
|
|
#define attribute_noreturn
|
|
|
|
#endif
|
|
|
|
|
2008-06-19 20:48:33 +00:00
|
|
|
/* Some older version of GNU gcc (3.3.5 on OpenBSD 4.3 for example) dont like 'NULL' as sentinel */
|
|
|
|
#define SENTINEL ((char *)NULL)
|
|
|
|
|
2005-06-24 22:50:07 +00:00
|
|
|
#endif /* _ASTERISK_COMPILER_H */
|