1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: ghs.h 4 5 Copyright (C) 2009-2011 Nintendo. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 13 $Rev: 27772 $ 14 *---------------------------------------------------------------------------*/ 15 16 /*! 17 @file 18 :include nn/config.h 19 20 */ 21 22 #ifndef NN_CONFIG_COMPILER_GHS_H_ 23 #define NN_CONFIG_COMPILER_GHS_H_ 24 25 26 //! @addtogroup nn_config Environment Macros 27 //! @brief These macros represent environment information. They are used to change the implementation depending on the environment. 28 //! @{ 29 30 //--------------------------------------------------------------------------- 31 //! @brief Specifies the current source filename. 32 //! 33 //! Unlike <tt>__FILE__</tt>, this consists only of a filename. 34 //! No directory path is included. 35 //--------------------------------------------------------------------------- 36 #define NN_FILE_NAME __FILE__ 37 38 //--------------------------------------------------------------------------- 39 //! @brief Specifies the current function name. 40 //! 41 //! Represents a more detailed function name than <tt>_FUNCTION_</tt>. 42 //--------------------------------------------------------------------------- 43 #define NN_FUNCTION __PRETTY_FUNCTION__ 44 45 46 //--------------------------------------------------------------------------- 47 //! @param[in] n Specifies the alignment. 48 //! 49 //! @brief Used to align the boundaries of object addresses. 50 //! 51 //! Ensures that the start addresses of global objects are aligned on <span class="argument">n</span>-byte boundaries by padding the ends of the objects. 52 //! 53 //--------------------------------------------------------------------------- 54 #define NN_ATTRIBUTE_ALIGN(n) __attribute__ ((aligned(n))) 55 56 57 58 //--------------------------------------------------------------------------- 59 //! @param[in] var Specifies the variable. 60 //! 61 //! @brief Declares that a variable is not used. 62 //! 63 //! If a variable is declared in the code but not referenced, it generates a compiler warning. This macro eliminates this warning by declaring the variable as unused. 64 //! 65 //! 66 //! Such variables are primarily used as temporary function parameters. 67 //--------------------------------------------------------------------------- 68 #define NN_UNUSED_VAR(var) ((void)&var); 69 70 //! @} 71 72 73 74 //--------------------------------------------------------------------------- 75 // @brief Explicitly creates a reference to a symbol. 76 // 77 // Put this macro in front of a variable or function declaration to ensure that a symbol reference is always generated. 78 // 79 //--------------------------------------------------------------------------- 80 #define NN_DLL_IMPORT __declspec(dllimport) 81 82 //--------------------------------------------------------------------------- 83 // @brief Explicitly exports a symbol. 84 // 85 // Put this macro in front of a variable or function definition to ensure the symbol is exported, even if it has no references. 86 // 87 //--------------------------------------------------------------------------- 88 #define NN_DLL_EXPORT __declspec(dllexport) 89 90 91 92 93 #define NN_IS_UNUSED_VAR __attribute__((unused)) 94 #define NN_IS_UNUSED_FUNC __attribute__((unused)) 95 96 #define NN_WEAK_SYMBOL //__weak 97 #define NN_ASM __asm 98 #define NN_PACKED __packed 99 100 #define NN_FORCE_INLINE __forceinline 101 #define NN_ATTRIBUTE_PACK __attribute__ ((packed)) 102 #define NN_ATTRIBUTE_DEPRECATED __attribute__ ((deprecated)) 103 #define NN_ATTRIBUTE_FORMAT(type, m, n) \ 104 __attribute__ ((format(type,m,n))) 105 #define NN_ATTRIBUTE_NORETURN __attribute__ ((noreturn)) 106 107 #define NN_LSYM( no ) no 108 #define NN_BSYM( no ) %b##no 109 #define NN_FSYM( no ) %f##no 110 111 // NOTE: Note that the same symbol is defined in <tt>nn/middleware.h</tt>. 112 // This header must be organized if it is to be released to the public. 113 #define NN_DEFINE_MODULE_ID_STRING(name, value) \ 114 static const char name[] __attribute__((section(".module_id"))) = (value) 115 116 #define NN_DEFINE_STATIC_INIT_ARRAY(array, symbol) \ 117 static void (*const array[])() __attribute__((used, section(".static_init"))) = { &symbol } 118 119 120 #define NN_ATTR_PRIVATE_SECTION_2(a, b) \ 121 __attribute__((section(#a "." #b))) 122 123 #define NN_ATTR_PRIVATE_SECTION_1(a, b) \ 124 NN_ATTR_PRIVATE_SECTION_2(a, b) 125 126 #define NN_ATTR_PRIVATE_SECTION \ 127 NN_ATTR_PRIVATE_SECTION_1(NN_FILE_NAME, __LINE__) 128 129 #define NN_FUNC_ATTR_PRIVATE_SECTION NN_ATTR_PRIVATE_SECTION 130 131 // TORIAEZU: Strange for it to be here because there is no compiler dependency. 132 #define NN_PADDING1 int : 8 133 #define NN_PADDING2 int : 16 134 #define NN_PADDING3 int : 24 135 #define NN_PADDING4 int : 32 136 137 138 139 /* NN_CONFIG_COMPILER_GHS_H_ */ 140 #endif 141