Path: blob/master/thirdparty/linuxbsd_headers/X11/Xfuncproto.h
9898 views
/*1*2Copyright 1989, 1991, 1998 The Open Group34Permission to use, copy, modify, distribute, and sell this software and its5documentation for any purpose is hereby granted without fee, provided that6the above copyright notice appear in all copies and that both that7copyright notice and this permission notice appear in supporting8documentation.910The above copyright notice and this permission notice shall be included in11all copies or substantial portions of the Software.1213THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR14IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,15FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE16OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN17AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN18CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.1920Except as contained in this notice, the name of The Open Group shall not be21used in advertising or otherwise to promote the sale, use or other dealings22in this Software without prior written authorization from The Open Group.23*24*/2526/* Definitions to make function prototypes manageable */2728#ifndef _XFUNCPROTO_H_29#define _XFUNCPROTO_H_3031#ifndef NeedFunctionPrototypes32#define NeedFunctionPrototypes 133#endif /* NeedFunctionPrototypes */3435#ifndef NeedVarargsPrototypes36#define NeedVarargsPrototypes 137#endif /* NeedVarargsPrototypes */3839#if NeedFunctionPrototypes4041#ifndef NeedNestedPrototypes42#define NeedNestedPrototypes 143#endif /* NeedNestedPrototypes */4445#ifndef _Xconst46#define _Xconst const47#endif /* _Xconst */4849/* Function prototype configuration (see configure for more info) */50#if !defined(NARROWPROTO) && \51(defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__))52#define NARROWPROTO53#endif54#ifndef FUNCPROTO55#define FUNCPROTO 1556#endif5758#ifndef NeedWidePrototypes59#ifdef NARROWPROTO60#define NeedWidePrototypes 061#else62#define NeedWidePrototypes 1 /* default to make interropt. easier */63#endif64#endif /* NeedWidePrototypes */6566#endif /* NeedFunctionPrototypes */6768#ifndef _XFUNCPROTOBEGIN69#if defined(__cplusplus) || defined(c_plusplus) /* for C++ V2.0 */70#define _XFUNCPROTOBEGIN extern "C" { /* do not leave open across includes */71#define _XFUNCPROTOEND }72#else73#define _XFUNCPROTOBEGIN74#define _XFUNCPROTOEND75#endif76#endif /* _XFUNCPROTOBEGIN */7778/* http://clang.llvm.org/docs/LanguageExtensions.html#has-attribute */79#ifndef __has_attribute80# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */81#endif82#ifndef __has_feature83# define __has_feature(x) 0 /* Compatibility with non-clang compilers. */84#endif85#ifndef __has_extension86# define __has_extension(x) 0 /* Compatibility with non-clang compilers. */87#endif8889/* Added in X11R6.9, so available in any version of modular xproto */90#if __has_attribute(__sentinel__) || (defined(__GNUC__) && (__GNUC__ >= 4))91# define _X_SENTINEL(x) __attribute__ ((__sentinel__(x)))92#else93# define _X_SENTINEL(x)94#endif /* GNUC >= 4 */9596/* Added in X11R6.9, so available in any version of modular xproto */97#if (__has_attribute(visibility) || (defined(__GNUC__) && (__GNUC__ >= 4))) \98&& !defined(__CYGWIN__) && !defined(__MINGW32__)99# define _X_EXPORT __attribute__((visibility("default")))100# define _X_HIDDEN __attribute__((visibility("hidden")))101# define _X_INTERNAL __attribute__((visibility("internal")))102#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)103# define _X_EXPORT __global104# define _X_HIDDEN __hidden105# define _X_INTERNAL __hidden106#else /* not gcc >= 4 and not Sun Studio >= 8 */107# define _X_EXPORT108# define _X_HIDDEN109# define _X_INTERNAL110#endif /* GNUC >= 4 */111112/* Branch prediction hints for individual conditionals */113/* requires xproto >= 7.0.9 */114#if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 303)115# define _X_LIKELY(x) __builtin_expect(!!(x), 1)116# define _X_UNLIKELY(x) __builtin_expect(!!(x), 0)117#else /* not gcc >= 3.3 */118# define _X_LIKELY(x) (x)119# define _X_UNLIKELY(x) (x)120#endif121122/* Bulk branch prediction hints via marking error path functions as "cold" */123/* requires xproto >= 7.0.25 */124#if __has_attribute(__cold__) || \125(defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 403)) /* 4.3+ */126# define _X_COLD __attribute__((__cold__))127#else128# define _X_COLD /* nothing */129#endif130131/* Added in X11R6.9, so available in any version of modular xproto */132#if __has_attribute(deprecated) \133|| (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 301)) \134|| (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x5130))135# define _X_DEPRECATED __attribute__((deprecated))136#else /* not gcc >= 3.1 */137# define _X_DEPRECATED138#endif139140/* requires xproto >= 7.0.30 */141#if __has_extension(attribute_deprecated_with_message) || \142(defined(__GNUC__) && ((__GNUC__ >= 5) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 5))))143# define _X_DEPRECATED_MSG(_msg) __attribute__((deprecated(_msg)))144#else145# define _X_DEPRECATED_MSG(_msg) _X_DEPRECATED146#endif147148/* requires xproto >= 7.0.17 */149#if __has_attribute(noreturn) \150|| (defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 205)) \151|| (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))152# define _X_NORETURN __attribute((noreturn))153#else154# define _X_NORETURN155#endif /* GNUC */156157/* Added in X11R6.9, so available in any version of modular xproto */158#if __has_attribute(__format__) \159|| defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 203)160# define _X_ATTRIBUTE_PRINTF(x,y) __attribute__((__format__(__printf__,x,y)))161#else /* not gcc >= 2.3 */162# define _X_ATTRIBUTE_PRINTF(x,y)163#endif164165/* requires xproto >= 7.0.22 - since this uses either gcc or C99 variable166argument macros, must be only used inside #ifdef _X_NONNULL guards, as167many legacy X clients are compiled in C89 mode still. */168#if __has_attribute(nonnull) \169&& defined(__STDC_VERSION__) && (__STDC_VERSION__ - 0 >= 199901L) /* C99 */170#define _X_NONNULL(...) __attribute__((nonnull(__VA_ARGS__)))171#elif __has_attribute(nonnull) \172|| defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 303)173#define _X_NONNULL(args...) __attribute__((nonnull(args)))174#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ - 0 >= 199901L) /* C99 */175#define _X_NONNULL(...) /* */176#endif177178/* requires xproto >= 7.0.22 */179#if __has_attribute(__unused__) \180|| defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 205)181#define _X_UNUSED __attribute__((__unused__))182#else183#define _X_UNUSED /* */184#endif185186/* C99 keyword "inline" or equivalent extensions in pre-C99 compilers */187/* requires xproto >= 7.0.9188(introduced in 7.0.8 but didn't support all compilers until 7.0.9) */189#if defined(inline) /* assume autoconf set it correctly */ || \190(defined(__STDC_VERSION__) && (__STDC_VERSION__ - 0 >= 199901L)) /* C99 */ || \191(defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550))192# define _X_INLINE inline193#elif defined(__GNUC__) && !defined(__STRICT_ANSI__) /* gcc w/C89+extensions */194# define _X_INLINE __inline__195#else196# define _X_INLINE197#endif198199/* C99 keyword "restrict" or equivalent extensions in pre-C99 compilers */200/* requires xproto >= 7.0.21 */201#ifndef _X_RESTRICT_KYWD202# if defined(restrict) /* assume autoconf set it correctly */ || \203(defined(__STDC_VERSION__) && (__STDC_VERSION__ - 0 >= 199901L) /* C99 */ \204&& !defined(__cplusplus)) /* Workaround g++ issue on Solaris */205# define _X_RESTRICT_KYWD restrict206# elif defined(__GNUC__) && !defined(__STRICT_ANSI__) /* gcc w/C89+extensions */207# define _X_RESTRICT_KYWD __restrict__208# else209# define _X_RESTRICT_KYWD210# endif211#endif212213/* requires xproto >= 7.0.30 */214#if __has_attribute(no_sanitize_thread)215# define _X_NOTSAN __attribute__((no_sanitize_thread))216#else217# define _X_NOTSAN218#endif219220/* Mark a char array/pointer as not containing a NUL-terminated string */221/* requires xproto >= 7.0.33 */222#if __has_attribute(nonstring)223# define _X_NONSTRING __attribute__((nonstring))224#else225# define _X_NONSTRING226#endif227228#endif /* _XFUNCPROTO_H_ */229230231