8#ifndef PXR_ARCH_ATTRIBUTES_H 
    9#define PXR_ARCH_ATTRIBUTES_H 
   17#include "pxr/arch/pxr.h" 
   20ARCH_NAMESPACE_OPEN_SCOPE
 
   35#   define ARCH_PRINTF_FUNCTION(_fmt, _firstArg) 
   49#   define ARCH_SCANF_FUNCTION(_fmt, _firstArg) 
   73#   define ARCH_UNUSED_ARG 
   88#   define ARCH_UNUSED_FUNCTION 
  108#   define ARCH_USED_FUNCTION 
  123#   define ARCH_CONSTRUCTOR(_name, _priority) 
  138#   define ARCH_DESTRUCTOR(_name, _priority) 
  146#   define ARCH_EMPTY_BASES 
  148#elif defined(ARCH_COMPILER_GCC) || defined(ARCH_COMPILER_CLANG) 
  150#   define ARCH_PRINTF_FUNCTION(_fmt, _firstArg) \ 
  151        __attribute__((format(printf, _fmt, _firstArg))) 
  152#   define ARCH_SCANF_FUNCTION(_fmt, _firstArg) \ 
  153        __attribute__((format(scanf, _fmt, _firstArg))) 
  154#   define ARCH_NOINLINE __attribute__((noinline)) 
  155#   define ARCH_ALWAYS_INLINE __attribute__((always_inline)) 
  156#   define ARCH_UNUSED_ARG   __attribute__ ((unused)) 
  157#   define ARCH_UNUSED_FUNCTION __attribute__((unused)) 
  158#   define ARCH_USED_FUNCTION __attribute__((used)) 
  159#   define ARCH_EMPTY_BASES 
  161#elif defined(ARCH_COMPILER_MSVC) 
  163#   define ARCH_PRINTF_FUNCTION(_fmt, _firstArg) 
  164#   define ARCH_SCANF_FUNCTION(_fmt, _firstArg) 
  165#   define ARCH_NOINLINE  
  166#   define ARCH_ALWAYS_INLINE 
  167#   define ARCH_UNUSED_ARG 
  168#   define ARCH_UNUSED_FUNCTION 
  169#   define ARCH_USED_FUNCTION 
  170#   define ARCH_EMPTY_BASES __declspec(empty_bases) 
  194template <
class StaticInit>
 
  199    static StaticInit 
init;
 
 
  201template <
class StaticInit>
 
  202StaticInit Arch_PerLibInit<StaticInit>::init;
 
  204#define _ARCH_CAT_NOEXPAND(a, b) a ## b 
  205#define _ARCH_CAT(a, b) _ARCH_CAT_NOEXPAND(a, b) 
  206#define _ARCH_ENSURE_PER_LIB_INIT(T, prefix) \ 
  207    static ARCH_NS::Arch_PerLibInit<T> _ARCH_CAT(prefix, __COUNTER__) 
 
  213#elif defined(ARCH_OS_DARWIN) 
  216struct Arch_ConstructorEntry {
 
  217    typedef void (*Type)(void);
 
  219    unsigned int version:24;    
 
  220    unsigned int priority:8;    
 
  224#   define ARCH_CONSTRUCTOR(_name, _priority)                                         \ 
  225    static void _name();                                                              \ 
  226    static const ARCH_NS::Arch_ConstructorEntry _ARCH_CAT_NOEXPAND(arch_ctor_, _name) \ 
  227        __attribute__((used, section("__DATA,pxrctor"))) = {                          \ 
  228        reinterpret_cast<ARCH_NS::Arch_ConstructorEntry::Type>(&_name),               \ 
  229        static_cast<unsigned>(ARCH_VERSION),                                          \ 
  235#   define ARCH_DESTRUCTOR(_name, _priority)                                          \ 
  236    static void _name();                                                              \ 
  237    static const ARCH_NS::Arch_ConstructorEntry _ARCH_CAT_NOEXPAND(arch_dtor_, _name) \ 
  238        __attribute__((used, section("__DATA,pxrdtor"))) = {                          \ 
  239        reinterpret_cast<ARCH_NS::Arch_ConstructorEntry::Type>(&_name),               \ 
  240        static_cast<unsigned>(ARCH_VERSION),                                          \ 
  245#elif defined(ARCH_COMPILER_GCC) || defined(ARCH_COMPILER_CLANG) 
  249#   define ARCH_CONSTRUCTOR(_name, _priority) \ 
  250        __attribute__((used, section(".pxrctor"), constructor((_priority) + 100))) \ 
  252#   define ARCH_DESTRUCTOR(_name, _priority) \ 
  253        __attribute__((used, section(".pxrdtor"), destructor((_priority) + 100))) \ 
  256#elif defined(ARCH_OS_WINDOWS) 
  261    __declspec(align(16))
 
  262    struct Arch_ConstructorEntry {
 
  263        typedef void (__cdecl *Type)(void);
 
  265        unsigned int version:24;    
 
  266        unsigned int priority:8;    
 
  270#   pragma section(".pxrctor", read) 
  271#   pragma section(".pxrdtor", read) 
  276struct Arch_ConstructorInit {
 
  277    ARCH_API Arch_ConstructorInit();
 
  278    ARCH_API ~Arch_ConstructorInit();
 
  285#   define ARCH_CONSTRUCTOR(_name, _priority)                                  \ 
  286    static void _name();                                                       \ 
  288    __declspec(allocate(".pxrctor"))                                           \ 
  289    extern const ARCH_NS::Arch_ConstructorEntry                                \ 
  290    _ARCH_CAT_NOEXPAND(arch_ctor_, _name) = {                                  \ 
  291        reinterpret_cast<ARCH_NS::Arch_ConstructorEntry::Type>(&_name),        \ 
  292        static_cast<unsigned>(ARCH_VERSION),                                   \ 
  296    _ARCH_ENSURE_PER_LIB_INIT(ARCH_NS::Arch_ConstructorInit, _archCtorInit);   \ 
  300#   define ARCH_DESTRUCTOR(_name, _priority)                                   \ 
  301    static void _name();                                                       \ 
  303    __declspec(allocate(".pxrdtor"))                                           \ 
  304    extern const ARCH_NS::Arch_ConstructorEntry                                \ 
  305    _ARCH_CAT_NOEXPAND(arch_dtor_, _name) = {                                  \ 
  306        reinterpret_cast<ARCH_NS::Arch_ConstructorEntry::Type>(&_name),        \ 
  307        static_cast<unsigned>(ARCH_VERSION),                                   \ 
  311    _ARCH_ENSURE_PER_LIB_INIT(ARCH_NS::Arch_ConstructorInit, _archCtorInit);   \ 
  321ARCH_NAMESPACE_CLOSE_SCOPE
 
Defines symbol visibility macros.
#define ARCH_HIDDEN
Definition export.h:166
StaticInit Arch_PerLibInit< StaticInit >::init
Definition attributes.h:202
Arch_PerLibInit()
Definition attributes.h:196