Home | History | Annotate | Download | only in cups
      1 /*
      2  * API versioning definitions for CUPS.
      3  *
      4  * Copyright 2007-2017 by Apple Inc.
      5  *
      6  * These coded instructions, statements, and computer programs are the
      7  * property of Apple Inc. and are protected by Federal copyright
      8  * law.  Distribution and use rights are outlined in the file "LICENSE.txt"
      9  * which should have been included with this file.  If this file is
     10  * missing or damaged, see the license at "http://www.cups.org/".
     11  *
     12  * This file is subject to the Apple OS-Developed Software exception.
     13  */
     14 
     15 #ifndef _CUPS_VERSIONING_H_
     16 #  define _CUPS_VERSIONING_H_
     17 
     18 /*
     19  * This header defines several constants - _CUPS_DEPRECATED,
     20  * _CUPS_DEPRECATED_MSG, _CUPS_INTERNAL_MSG, _CUPS_API_major_minor, and
     21  * _CUPS_API_major_minor_patch - which add compiler-specific attributes that
     22  * flag functions that are deprecated, added in particular releases, or internal
     23  * to CUPS.
     24  *
     25  * On macOS, the _CUPS_API_* constants are defined based on the values of
     26  * the MAC_OS_X_VERSION_MIN_ALLOWED and MAC_OS_X_VERSION_MAX_ALLOWED constants
     27  * provided by the compiler.
     28  */
     29 
     30 #  if defined(__APPLE__) && !defined(_CUPS_SOURCE) && !TARGET_OS_IOS
     31 #    include <AvailabilityMacros.h>
     32 #    ifndef AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER
     33 #      define AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER __attribute__((unavailable))
     34 #    endif /* !AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER */
     35 #    ifndef AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER
     36 #      define AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER __attribute__((unavailable))
     37 #    endif /* !AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER */
     38 #    ifndef AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
     39 #      define AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER __attribute__((unavailable))
     40 #    endif /* !AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER */
     41 #    ifndef AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
     42 #      define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER __attribute__((unavailable))
     43 #    endif /* !AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER */
     44 #    ifndef AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
     45 #      define AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER __attribute__((unavailable))
     46 #    endif /* !AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER */
     47 #    ifndef AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER
     48 #      define AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER __attribute__((unavailable))
     49 #    endif /* !AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER */
     50 #    ifndef AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER
     51 #      define AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER __attribute__((unavailable))
     52 #    endif /* !AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER */
     53 #    ifndef AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER
     54 #      define AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER __attribute__((unavailable))
     55 #    endif /* !AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER */
     56 #    ifndef AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER
     57 #      define AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER __attribute__((unavailable))
     58 #    endif /* !AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER */
     59 #    ifndef AVAILABLE_MAC_OS_X_VERSION_10_13_AND_LATER
     60 #      define AVAILABLE_MAC_OS_X_VERSION_10_13_AND_LATER __attribute__((unavailable))
     61 #    endif /* !AVAILABLE_MAC_OS_X_VERSION_10_13_AND_LATER */
     62 #    define _CUPS_API_1_1_19 AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER
     63 #    define _CUPS_API_1_1_20 AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER
     64 #    define _CUPS_API_1_1_21 AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER
     65 #    define _CUPS_API_1_2 AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
     66 #    define _CUPS_API_1_3 AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER
     67 #    define _CUPS_API_1_4 AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
     68 #    define _CUPS_API_1_5 AVAILABLE_MAC_OS_X_VERSION_10_7_AND_LATER
     69 #    define _CUPS_API_1_6 AVAILABLE_MAC_OS_X_VERSION_10_8_AND_LATER
     70 #    define _CUPS_API_1_7 AVAILABLE_MAC_OS_X_VERSION_10_9_AND_LATER
     71 #    define _CUPS_API_2_0 AVAILABLE_MAC_OS_X_VERSION_10_10_AND_LATER
     72 #    define _CUPS_API_2_2 AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER
     73 #    define _CUPS_API_2_2_4 AVAILABLE_MAC_OS_X_VERSION_10_13_AND_LATER
     74 #  else
     75 #    define _CUPS_API_1_1_19
     76 #    define _CUPS_API_1_1_20
     77 #    define _CUPS_API_1_1_21
     78 #    define _CUPS_API_1_2
     79 #    define _CUPS_API_1_3
     80 #    define _CUPS_API_1_4
     81 #    define _CUPS_API_1_5
     82 #    define _CUPS_API_1_6
     83 #    define _CUPS_API_1_7
     84 #    define _CUPS_API_2_0
     85 #    define _CUPS_API_2_2
     86 #    define _CUPS_API_2_2_4
     87 #  endif /* __APPLE__ && !_CUPS_SOURCE */
     88 
     89 /*
     90  * With GCC and Clang we can mark old APIs as "deprecated" or "unavailable" with
     91  * messages so you get warnings/errors are compile-time...
     92  */
     93 
     94 #  ifdef __has_extension		/* Clang */
     95 #    define _CUPS_HAS_DEPRECATED
     96 #    if __has_extension(attribute_deprecated_with_message)
     97 #      define _CUPS_HAS_DEPRECATED_WITH_MESSAGE
     98 #    endif
     99 #    if __has_extension(attribute_unavailable_with_message)
    100 #      define _CUPS_HAS_UNAVAILABLE_WITH_MESSAGE
    101 #    endif
    102 #  elif defined(__GNUC__)		/* GCC and compatible */
    103 #    if __GNUC__ >= 3			/* GCC 3.0 or higher */
    104 #      define _CUPS_HAS_DEPRECATED
    105 #    endif /* __GNUC__ >= 3 */
    106 #    if __GNUC__ >= 5			/* GCC 5.x */
    107 #      define _CUPS_HAS_DEPRECATED_WITH_MESSAGE
    108 #    elif __GNUC__ == 4 && __GNUC_MINOR__ >= 5
    109 					/* GCC 4.5 or higher */
    110 #      define _CUPS_HAS_DEPRECATED_WITH_MESSAGE
    111 #    endif /* __GNUC__ >= 5 */
    112 #  endif /* __has_extension */
    113 
    114 #  if !defined(_CUPS_HAS_DEPRECATED) || (defined(_CUPS_SOURCE) && !defined(_CUPS_NO_DEPRECATED))
    115     /*
    116      * Don't mark functions deprecated if the compiler doesn't support it
    117      * or we are building CUPS source that doesn't care.
    118      */
    119 #    define _CUPS_DEPRECATED
    120 #    define _CUPS_DEPRECATED_MSG(m)
    121 #    define _CUPS_DEPRECATED_1_6_MSG(m)
    122 #    define _CUPS_DEPRECATED_1_7_MSG(m)
    123 #    define _CUPS_INTERNAL_MSG(m)
    124 #  elif defined(_CUPS_HAS_UNAVAILABLE_WITH_MESSAGE) && defined(_CUPS_NO_DEPRECATED)
    125     /*
    126      * Compiler supports the unavailable attribute, so use it when the code
    127      * wants to exclude the use of deprecated API.
    128      */
    129 #    define _CUPS_DEPRECATED __attribute__ ((unavailable))
    130 #    define _CUPS_DEPRECATED_MSG(m) __attribute__ ((unavailable(m)))
    131 #    define _CUPS_DEPRECATED_1_6_MSG(m) __attribute__ ((unavailable(m)))
    132 #    define _CUPS_DEPRECATED_1_7_MSG(m) __attribute__ ((unavailable(m)))
    133 #    define _CUPS_INTERNAL_MSG(m) __attribute__ ((unavailable(m)))
    134 #  else
    135     /*
    136      * Compiler supports the deprecated attribute, so use it.
    137      */
    138 #    define _CUPS_DEPRECATED __attribute__ ((deprecated))
    139 #    ifdef _CUPS_HAS_DEPRECATED_WITH_MESSAGE
    140 #      define _CUPS_DEPRECATED_MSG(m) __attribute__ ((deprecated(m)))
    141 #    else
    142 #      define _CUPS_DEPRECATED_MSG(m) __attribute__ ((deprecated))
    143 #    endif /* _CUPS_HAS_DEPRECATED_WITH_MESSAGE */
    144 #    if defined(MAC_OS_X_VERSION_10_8) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_8
    145 #      define _CUPS_DEPRECATED_1_6_MSG(m) _CUPS_DEPRECATED_MSG(m)
    146 #    else
    147 #      define _CUPS_DEPRECATED_1_6_MSG(m)
    148 #    endif /* MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_8 */
    149 #    if defined(MAC_OS_X_VERSION_10_9) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_9
    150 #      define _CUPS_DEPRECATED_1_7_MSG(m) _CUPS_DEPRECATED_MSG(m)
    151 #    else
    152 #      define _CUPS_DEPRECATED_1_7_MSG(m)
    153 #    endif /* MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_9 */
    154 #    ifdef _CUPS_SOURCE
    155 #      define _CUPS_INTERNAL_MSG(m)
    156 #    elif defined(_CUPS_HAS_UNAVAILABLE_WITH_MESSAGE)
    157 #      define _CUPS_INTERNAL_MSG(m) __attribute__ ((unavailable(m)))
    158 #    elif defined(_CUPS_HAS_DEPRECATED_WITH_MESSAGE)
    159 #      define _CUPS_INTERNAL_MSG(m) __attribute__ ((deprecated(m)))
    160 #    else
    161 #      define _CUPS_INTERNAL_MSG(m) __attribute__ ((deprecated))
    162 #    endif /* _CUPS_SOURCE */
    163 #  endif /* !_CUPS_HAS_DEPRECATED || (_CUPS_SOURCE && !_CUPS_NO_DEPRECATED) */
    164 
    165 #  ifndef __GNUC__
    166 #    define __attribute__(x)
    167 #  endif /* !__GNUC__ */
    168 
    169 #endif /* !_CUPS_VERSIONING_H_ */
    170