1 /* ------------------------------------------------------------------ 2 * Copyright (C) 1998-2009 PacketVideo 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 13 * express or implied. 14 * See the License for the specific language governing permissions 15 * and limitations under the License. 16 * ------------------------------------------------------------------- 17 */ 18 // -*- c++ -*- 19 // = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 20 21 // O S C L B A S E _ M A C R O S 22 23 // = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 24 25 /*! \addtogroup osclbase OSCL Base 26 * 27 * @{ 28 */ 29 30 31 /*! \file oscl_base_macros.h 32 \brief This file defines common macros and constants for basic compilation support. 33 */ 34 35 #ifndef OSCL_BASE_MACROS_H_INCLUDED 36 #define OSCL_BASE_MACROS_H_INCLUDED 37 38 // Pick up any platform-specific definitions for the common 39 // macros. 40 #include "osclconfig.h" 41 42 // Define default values for the common macros 43 #ifndef OSCL_EXPORT_REF 44 #define OSCL_EXPORT_REF 45 #endif 46 47 #ifndef OSCL_IMPORT_REF 48 #define OSCL_IMPORT_REF 49 #endif 50 51 //! The NULL_TERM_CHAR is used to terminate c-style strings. 52 //static const char NULL_TERM_CHAR = '\0'; 53 #ifndef NULL_TERM_CHAR 54 #define NULL_TERM_CHAR '\0' 55 #endif 56 57 //! if the NULL macro isn't already defined, then define it as zero. 58 #ifndef NULL 59 #define NULL (0) 60 #endif 61 62 #if (OSCL_DISABLE_INLINES) 63 #define OSCL_INLINE 64 #define OSCL_COND_EXPORT_REF OSCL_EXPORT_REF 65 #define OSCL_COND_IMPORT_REF OSCL_IMPORT_REF 66 #else 67 #define OSCL_INLINE inline 68 #define OSCL_COND_EXPORT_REF 69 #define OSCL_COND_IMPORT_REF 70 #endif 71 72 //this macro may not be defined in all configurations 73 //so a default is defined here. 74 75 //! Type casting macros 76 /*! 77 \param type Destination type of cast 78 \param exp Expression to cast 79 */ 80 81 #define OSCL_CONST_CAST(type,exp) ((type)(exp)) 82 #define OSCL_STATIC_CAST(type,exp) ((type)(exp)) 83 #define OSCL_REINTERPRET_CAST(type,exp) ((type)(exp)) 84 #define OSCL_DYNAMIC_CAST(type, exp) ((type)(exp)) 85 86 87 /** 88 * The following two macros are used to avoid compiler warnings. 89 * 90 * OSCL_UNUSED_ARG(vbl) is used to "reference" an otherwise unused 91 * parameter or variable, often one which is used only in an 92 * OSCL_ASSERT and thus unreferenced in release mode 93 * OSCL_UNUSED_RETURN(val) provides a "return" of a value, in places 94 * which will not actually be executed, such as after an 95 * OSCL_LEAVE or Thread::exit or abort. The value needs to 96 * be of an appropriate type for the current function, though 97 * zero will usually suffice. Note that OSCL_UNUSED_RETURN 98 * will not be necessary for 'void' functions, as there is no 99 * requirement for a value-return operation. 100 */ 101 #define OSCL_UNUSED_ARG(vbl) (void)(vbl) 102 #define OSCL_UNUSED_RETURN(value) return value 103 104 /* The __TFS__ macro is used to optionally expand to "<>" depending on the 105 * compiler. Some compilers require it to indicate that the friend function 106 * is a template function as specified in the standard, but others don't 107 * like it so it will handled with a macro expansion that depends on the 108 * compiler. 109 */ 110 #ifndef __TFS__ 111 #define __TFS__ 112 #endif 113 114 #define OSCL_MIN(a,b) ((a) < (b) ? (a) : (b)) 115 #define OSCL_MAX(a,b) ((a) > (b) ? (a) : (b)) 116 #define OSCL_ABS(a) ((a) > (0) ? (a) : -(a)) 117 118 // the syntax for explicitly calling the destructor varies on some platforms 119 // below is the default syntax as defined in the C++ standard 120 #ifndef OSCL_TEMPLATED_DESTRUCTOR_CALL 121 #define OSCL_TEMPLATED_DESTRUCTOR_CALL(type,simple_type) type :: ~simple_type () 122 #endif 123 124 125 /* 126 * The OSCL_UNSIGNED_CONST macro is used to optionally add a suffix to the 127 * end of integer constants to identify them as unsigned constants. It is 128 * usually only necessary to do that for very large constants that are too 129 * big to fit within the range of a signed integer. Some compilers will issue 130 * warnings for that. The default behavior will be to add no suffix. 131 */ 132 133 #ifndef OSCL_UNSIGNED_CONST 134 #define OSCL_UNSIGNED_CONST(x) x 135 #endif 136 137 /* 138 * These macros are used by MTP to avoid byte aligning structures. 139 */ 140 #ifndef OSCL_PACKED_VAR 141 #define OSCL_PACKED_VAR "error" 142 #endif 143 144 #ifndef OSCL_BEGIN_PACKED 145 #define OSCL_BEGIN_PACKED "error" 146 #endif 147 148 #ifndef OSCL_END_PACKED 149 #define OSCL_END_PACKED "error" 150 #endif 151 152 /*! @} */ 153 154 #endif // OSCL_BASE_MACROS_H_INCLUDED 155