summaryrefslogtreecommitdiff
path: root/include/asterisk/compiler.h
AgeCommit message (Collapse)Author
2016-07-19Add conditional support for noreturn functions.Corey Farrell
This adds support for tagging functions with the noreturn attribute. If DO_CRASH is enabled then ast_do_crash never returns. If AST_DEVMODE and DO_CRASH are enabled then failed assertions never return. This can resolve a large number of false positives with static analyzers. ASTERISK-26220 #close Change-Id: Icfb61e5fe54574eced4c3e88b317244f467ec753
2013-08-30optional_api: Fix linking problems between modules that export global symbolsDavid M. Lee
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
2010-09-07Merged revisions 285336 via svnmerge from Tilghman Lesher
https://origsvn.digium.com/svn/asterisk/branches/1.8 ........ r285336 | tilghman | 2010-09-07 14:38:12 -0500 (Tue, 07 Sep 2010) | 2 lines Fix build on FreeBSD 8.0, take 2. ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@285337 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-06-15Redesigned 'optional API' support.Kevin P. Fleming
This patch provides a new implementation of the optional API support defined in asterisk/optional_api.h; this new version provides solves compatibility issues with the use of linker version scripts for suppressing global symbols. In addition, there is now a functional (and tested!) implementation for Mac OS/X, so module writers no longer need to use special tests before calling optional API functions. All future implementations must provide these same semantics, so that module writers can rely on them. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@200519 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-02-031. Make OS X compile cleanly with app_stack.Tilghman Lesher
2. Use curl to download sound files, as curl is installed natively on OS X, whereas wget and fetch are not. (closes issue #14332) Reported by: oej Tested by: Corydon76 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@173130 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-11-02instead of trying to forcibly load res_agi when app_stack is loaded (even if ↵Kevin P. Fleming
the administrator didn't want it loaded), use GCC weak symbols to determine whether it was loaded already or not; if it was loaded, then use it. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@153709 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-06-19Older versions of GNU gcc do not allow 'NULL' as sentinel.Michiel van Baak
They want (char *)NULL as sentinel. An example is OpenBSD (confirmed on 4.3) that ships with gcc 3.3.4 This commit introduces a contstant SENTINEL which is declared as: #define SENTINEL ((char *)NULL) All places I could test compile on my openbsd system are converted. Update CODING-GUIDELINES to tell about this constant. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@124127 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-06-19Detect if the installed gcc version supports the warn_unused_result attribute.Tilghman Lesher
Reported by mvanbaak via IRC -dev. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@123988 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-05-04Merged revisions 115279 via svnmerge from Joshua Colp
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r115279 | file | 2008-05-03 22:50:59 -0300 (Sat, 03 May 2008) | 2 lines For my next trick I will make these work with what our autoconf header file gives us. ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@115280 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2008-05-02Okay, maybe FreeBSD will like this better.Tilghman Lesher
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@115159 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-09-28Merged revisions 43861-43862 via svnmerge from Paul Cadach
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r43861 | pcadach | 2006-09-28 18:47:23 +0600 (Чтв, 28 Сен 2006) | 1 line Put attribute tag at correct place ........ r43862 | pcadach | 2006-09-28 18:58:22 +0600 (Чтв, 28 Сен 2006) | 1 line Force remote side to start media on outgoing PROGRESS message ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@43863 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-08-21merge new_loader_completion branch, including (at least):Kevin P. Fleming
- restructured build tree and makefiles to eliminate recursion problems - support for embedded modules - support for static builds - simpler cross-compilation support - simpler module/loader interface (no exported symbols) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@40722 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-08-08Merge team/russell/ast_verbose_threadstorageRussell Bryant
- 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-07-28the pure attribute was not implemented before gcc 2.96. Since we have thisRussell Bryant
version check here anwyay, define attribute_pure to be empty if it's an earlier version. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@38464 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2006-07-28add macros for the pure and const attributes to compiler.h, in case they everRussell Bryant
need to be handled differently for a specific compiler git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@38454 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2005-11-29remove extraneous svn:executable propertiesKevin P. Fleming
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@7221 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2005-11-04old compiler compatibility (again...)Kevin P. Fleming
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6960 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2005-11-01add new GCC-specific macro and force inlining of certain functions where ↵Kevin P. Fleming
speed is paramount, even when optimization is disabled git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6929 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2005-10-24Doxygen documentation update from oej (issue #5505)Russell Bryant
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6847 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2005-08-30major header file cleanup: license, copyrights, descriptions, markers, etc.Kevin P. Fleming
remove deprecated config_old.c/config_old.h remove unused cvsid.h git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6454 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2005-06-24add new header filesKevin P. Fleming
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6009 65c4cc65-6c06-0410-ace0-fbb531ad65f3