Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenintrin.h
Go to the documentation of this file.
00001 /* 00002 Compatibility <intrin.h> header for GCC -- GCC equivalents of intrinsic 00003 Microsoft Visual C++ functions. Originally developed for the ReactOS 00004 (<http://www.reactos.org/>) and TinyKrnl (<http://www.tinykrnl.org/>) 00005 projects. 00006 00007 Copyright (c) 2006 KJK::Hyperion <hackbunny@reactos.com> 00008 00009 Permission is hereby granted, free of charge, to any person obtaining a 00010 copy of this software and associated documentation files (the "Software"), 00011 to deal in the Software without restriction, including without limitation 00012 the rights to use, copy, modify, merge, publish, distribute, sublicense, 00013 and/or sell copies of the Software, and to permit persons to whom the 00014 Software is furnished to do so, subject to the following conditions: 00015 00016 The above copyright notice and this permission notice shall be included in 00017 all copies or substantial portions of the Software. 00018 00019 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00020 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00021 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00022 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00023 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 00024 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 00025 DEALINGS IN THE SOFTWARE. 00026 */ 00027 00028 #ifndef KJK_INTRIN_H_ 00029 #define KJK_INTRIN_H_ 00030 00031 #ifndef RC_INVOKED 00032 00033 #define __INTRIN_INLINE extern __inline__ __attribute__((__always_inline__,__gnu_inline__)) 00034 00035 #ifndef _SIZE_T_DEFINED 00036 #define _SIZE_T_DEFINED 00037 #ifdef _WIN64 00038 typedef unsigned __int64 size_t; 00039 #else 00040 typedef unsigned int size_t; 00041 #endif 00042 #endif 00043 00044 #ifndef _UINTPTR_T_DEFINED 00045 #define _UINTPTR_T_DEFINED 00046 #ifdef _WIN64 00047 typedef unsigned __int64 uintptr_t; 00048 #else 00049 typedef unsigned int uintptr_t; 00050 #endif 00051 #endif 00052 00053 /* 00054 FIXME: review all "memory" clobbers, add/remove to match Visual C++ 00055 behavior: some "obvious" memory barriers are not present in the Visual C++ 00056 implementation - e.g. __stosX; on the other hand, some memory barriers that 00057 *are* present could have been missed 00058 */ 00059 00060 /* 00061 NOTE: this is a *compatibility* header. Some functions may look wrong at 00062 first, but they're only "as wrong" as they would be on Visual C++. Our 00063 priority is compatibility 00064 00065 NOTE: unlike most people who write inline asm for GCC, I didn't pull the 00066 constraints and the uses of __volatile__ out of my... hat. Do not touch 00067 them. I hate cargo cult programming 00068 00069 NOTE: be very careful with declaring "memory" clobbers. Some "obvious" 00070 barriers aren't there in Visual C++ (e.g. __stosX) 00071 00072 NOTE: review all intrinsics with a return value, add/remove __volatile__ 00073 where necessary. If an intrinsic whose value is ignored generates a no-op 00074 under Visual C++, __volatile__ must be omitted; if it always generates code 00075 (for example, if it has side effects), __volatile__ must be specified. GCC 00076 will only optimize out non-volatile asm blocks with outputs, so input-only 00077 blocks are safe. Oddities such as the non-volatile 'rdmsr' are intentional 00078 and follow Visual C++ behavior 00079 00080 NOTE: on GCC 4.1.0, please use the __sync_* built-ins for barriers and 00081 atomic operations. Test the version like this: 00082 00083 #if (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) > 40100 00084 ... 00085 00086 Pay attention to the type of barrier. Make it match with what Visual C++ 00087 would use in the same case 00088 */ 00089 00090 #if defined(__i386__) 00091 #include "intrin_x86.h" 00092 #elif defined(_PPC_) 00093 #include "intrin_ppc.h" 00094 #elif defined(_MIPS_) 00095 #include "intrin_mips.h" 00096 #elif defined(_M_ARM) 00097 #include "intrin_arm.h" 00098 #elif defined(__x86_64__) 00099 /* TODO: the x64 architecture shares most of the i386 intrinsics. It should be easy to support */ 00100 #include "intrin_x86.h" 00101 #else 00102 #error Unsupported architecture 00103 #endif 00104 00105 00106 /*** Miscellaneous ***/ 00107 /* BUGBUG: only good for use in macros. Cannot be taken the address of */ 00108 #define __noop(...) ((void)0) 00109 00110 /* TODO: __assume. GCC only supports the weaker __builtin_expect */ 00111 00112 #endif 00113 00114 #endif 00115 00116 /* EOF */ Generated on Sun May 27 2012 04:29:52 for ReactOS by
1.7.6.1
|