diff options
author | Guy Harris <guy@alum.mit.edu> | 2017-03-19 11:18:43 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2017-03-19 11:18:43 -0700 |
commit | c4b0e2bd57a234f474b061db5b96950bf5a81a5d (patch) | |
tree | 584ae5d187d616fd77c61f140e260b744ceb86d9 /gencode.h | |
parent | 4b144f965200f15d93bc673365ffb676b0b06369 (diff) | |
download | libpcap-c4b0e2bd57a234f474b061db5b96950bf5a81a5d.tar.gz |
Use compiler #defines to determine how to handle some function attributes.
Take the set of tests in the test programs that check compiler and
version to decide how to mark functions as printflike or as not
returning, and put them into a header. Use that throughout the libpcap
code, rather than doing configuration-time tests that have to be
replicated in the autoconf script and CMake files.
That obviates the need to put those tests into CMakeLists.txt and means
that, if we ever make functions with those attributes available by code
outside libpcap (for example, if we ever introduce a plugin mechanism
for libpcap, to allow third-party pcap modules to be maintained
separately from libpcap), we can use those declarations (making a public
header file dependent on the results of a configure script usually
doesn't work well, for a variety of reasons).
Diffstat (limited to 'gencode.h')
-rw-r--r-- | gencode.h | 14 |
1 files changed, 4 insertions, 10 deletions
@@ -19,6 +19,8 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ +#include "funcattrs.h" + /* * ATM support: * @@ -53,10 +55,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#ifndef HAVE___ATTRIBUTE__ -#define __attribute__(x) -#endif /* HAVE___ATTRIBUTE__ */ - /* Address qualifiers. */ #define Q_HOST 1 @@ -367,12 +365,8 @@ struct icode { void bpf_optimize(compiler_state_t *, struct icode *ic); void bpf_syntax_error(compiler_state_t *, const char *); -void bpf_error(compiler_state_t *, const char *, ...) - __attribute__((noreturn)) -#ifdef __ATTRIBUTE___FORMAT_OK - __attribute__((format (printf, 2, 3))) -#endif /* __ATTRIBUTE___FORMAT_OK */ - ; +void bpf_error(compiler_state_t *, const char *, ...) PCAP_NORETURN + PCAP_PRINTFLIKE(2, 3); void finish_parse(compiler_state_t *, struct block *); char *sdup(compiler_state_t *, const char *); |