1 /* @(#)ccomdefs.h 1.15 21/04/28 Copyright 2000-2021 J. Schilling */ 2 /* 3 * Various compiler dependant macros. 4 * 5 * Copyright (c) 2000-2021 J. Schilling 6 */ 7 /* 8 * The contents of this file are subject to the terms of the 9 * Common Development and Distribution License, Version 1.0 only 10 * (the "License"). You may not use this file except in compliance 11 * with the License. 12 * 13 * See the file CDDL.Schily.txt in this distribution for details. 14 * A copy of the CDDL is also available via the Internet at 15 * http://www.opensource.org/licenses/cddl1.txt 16 * 17 * When distributing Covered Code, include this CDDL HEADER in each 18 * file and include the License file CDDL.Schily.txt from this distribution. 19 */ 20 21 #ifndef _SCHILY_CCOMDEFS_H 22 #define _SCHILY_CCOMDEFS_H 23 24 #ifndef _SCHILY_MCONFIG_H 25 #include <schily/mconfig.h> 26 #endif 27 28 #ifdef __cplusplus 29 extern "C" { 30 #endif 31 32 /* 33 * Compiler-dependent macros to declare that functions take printf-like 34 * or scanf-like arguments. They are defined to nothing for versions of gcc 35 * that are not known to support the features properly (old versions of gcc-2 36 * didn't permit keeping the keywords out of the application namespace). 37 */ 38 #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) || \ 39 defined(NO_PRINTFLIKE) 40 41 #define __printflike__(fmtarg, firstvararg) 42 #define __printf0like__(fmtarg, firstvararg) 43 #define __scanflike__(fmtarg, firstvararg) 44 45 #else /* We found GCC that supports __attribute__ */ 46 47 #define __printflike__(fmtarg, firstvararg) \ 48 __attribute__((__format__(__printf__, fmtarg, firstvararg))) 49 #define __printf0like__(fmtarg, firstvararg) \ 50 __attribute__((__format__(__printf0__, fmtarg, firstvararg))) 51 52 /* 53 * FreeBSD GCC implements printf0 that allows the format string to 54 * be a NULL pointer. 55 */ 56 #if __FreeBSD_cc_version < 300001 57 #undef __printf0like__ 58 #define __printf0like__ __printflike__ 59 #endif 60 61 #define __scanflike__(fmtarg, firstvararg) \ 62 __attribute__((__format__(__scanf__, fmtarg, firstvararg))) 63 64 #endif /* GNUC */ 65 66 #if __GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 2 67 /* GCC-3.3 or more */ 68 69 /* CSTYLED */ 70 #define UConst __attribute__ ((__used__)) const 71 72 #else /* less than GNUC 3.3 */ 73 74 #define UConst const 75 76 #endif /* less than GNUC 3.3 */ 77 78 #if __GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >= 1 79 /* GCC-3.1 or more */ 80 81 #define __NO_INL__ __attribute__ ((__noinline__)) 82 83 #else /* less than GNUC 3.1 */ 84 #ifdef HAVE_CC_NOINLINE 85 #define __NO_INL__ __attribute__ ((__noinline__)) 86 #else 87 #define __NO_INL__ 88 #endif 89 #endif /* less than GNUC 3.1 */ 90 91 92 #ifdef __PCC__ 93 /* 94 * Hack until pcc supports __attribute__ ((__used__)) 95 */ 96 #ifdef UConst 97 #undef UConst 98 #define UConst const 99 #endif 100 #endif 101 102 #ifdef __cplusplus 103 } 104 #endif 105 106 #endif /* _SCHILY_CCOMDEFS_H */ 107