At one point jacek suggested that intrin-mac.h should be merged into intrin-impl.h. Intrin-impl is the only place intrin-mac is used. Since I had just created intrin-mac a few days before, I wasn't ready to delete it quite that fast.

However, time has shown that jacek was right and I have finally done this. Apparently patch files don't show deletions, so the attached patch only shows the merged content in intrin-impl.h.

dw
Index: mingw-w64-headers/include/psdk_inc/intrin-impl.h
===================================================================
--- mingw-w64-headers/include/psdk_inc/intrin-impl.h	(revision 5973)
+++ mingw-w64-headers/include/psdk_inc/intrin-impl.h	(working copy)
@@ -61,8 +61,125 @@
 
 #ifdef __MINGW_INTRIN_INLINE
 
-#include <psdk_inc/intrin-mac.h>
+/* These macros are used by the routines below.  While this file may be included 
+   multiple times, these macros only need to be defined once. */
+#ifndef _INTRIN_MAC_
+#define _INTRIN_MAC_
 
+/* This macro is used by __stosb, __stosw, __stosd, __stosq */
+
+/* Parameters: (FunctionName, DataType, Operator)
+   FunctionName: Any valid function name
+   DataType: BYTE, WORD, DWORD or DWORD64 */
+
+/* While we don't need the output values for Dest or Count, we
+   must still inform the compiler the asm changes them. */
+#define __buildstos(x, y) void x(y *Dest, y Data, size_t Count) \
+{ \
+   __asm__ __volatile__ ("rep stos%z[Data]" \
+      : "+D" (Dest), "+c" (Count) \
+      : [Data] "a" (Data) \
+      : "memory"); \
+}
+
+/* This macro is used by InterlockedAnd, InterlockedOr, InterlockedXor, InterlockedAnd64, InterlockedOr64, InterlockedXor64 */
+
+/* Parameters: (FunctionName, DataType, Operator)
+   FunctionName: Any valid function name
+   DataType: __LONG32 or LONG64
+   Operator: One of xor, or, and */
+#define __buildlogicali(x, y, o) y x(volatile y *Destination, y Value) \
+{ \
+    return __sync_fetch_and_ ## o(Destination, Value); \
+}
+
+/* This macro is used by InterlockedBitTestAndSet, InterlockedBitTestAndReset, InterlockedBitTestAndComplement,
+   InterlockedBitTestAndSet64, InterlockedBitTestAndReset64, InterlockedBitTestAndComplement64
+   _interlockedbittestandset, _interlockedbittestandreset, _interlockedbittestandcomplement
+   _interlockedbittestandset64, _interlockedbittestandreset64, _interlockedbittestandcomplement64 */
+
+/* Parameters: (FunctionName, DataType, AsmCode, OffsetConstraint, Volatile)
+   FunctionName: Any valid function name
+   DataType: __LONG32 or LONG64
+   OffsetConstraint: either "I" for 32bit data types or "J" for 64.
+   Volatile: either volatile or blank. */
+#define __buildbittesti(x, y, z, a, b) unsigned char x(b y *Base, y Offset) \
+{ \
+   unsigned char old; \
+   __asm__ __volatile__ (z "%z[Base] {%[Offset],%[Base] | %[Base],%[Offset]} ; setc %[old]" \
+      : [old] "=qm" (old), [Base] "+m" (*Base) \
+      : [Offset] a "r" (Offset) \
+      : "memory", "cc"); \
+   return old; \
+}
+
+/* This macro is used by YieldProcessor when compiling x86 w/o SSE2.
+It generates the same opcodes as _mm_pause.  */
+#define __buildpause() __asm__ __volatile__("rep nop")
+
+/* This macro is used by DbgRaiseAssertionFailure and __int2c
+
+Parameters: (IntNum)
+IntNum: Interrupt number in hex */
+#define __buildint(a) __asm__ __volatile__("int {$}" #a :)
+
+/* This macro is used by MemoryBarrier when compiling x86 w/o SSE2. 
+Note that on i386, xchg performs an implicit lock. */
+#define __buildmemorybarrier() \
+{ \
+unsigned char Barrier; \
+__asm__ __volatile__("xchg{b %%| }al, %0" :"=m" (Barrier) : /* no inputs */ : "eax", "memory"); \
+}
+
+/* This macro is used by __readfsbyte, __readfsword, __readfsdword
+                         __readgsbyte, __readgsword, __readgsdword, __readgsqword
+
+Parameters: (FunctionName, DataType, Segment)
+   FunctionName: Any valid function name
+   DataType: char, short, __LONG32 or __int64
+   Segment: fs or gs */
+
+#define __buildreadseg(x, y, z) y x(unsigned __LONG32 Offset) { \
+    y ret; \
+    __asm__ ("mov{%z[ret] %%" z ":%[offset], %[ret] | %[ret], %%" z ":%[offset]}" \
+        : [ret] "=r" (ret) \
+        : [offset] "m" ((*(y *) (size_t) Offset))); \
+    return ret; \
+}
+
+/* This macro is used by __writefsbyte, __writefsword, __writefsdword
+                         __writegsbyte, __writegsword, __writegsdword, __writegsqword
+
+Parameters: (FunctionName, DataType, Segment)
+   FunctionName: Any valid function name
+   DataType: char, short, __LONG32 or __int64
+   Segment: fs or gs */
+
+#define __buildwriteseg(x, y, z) void x(unsigned __LONG32 Offset, y Data) { \
+    __asm__ ("mov{%z[offset] %[Data], %%" z ":%[offset] | %%" z ":%[offset], %[Data]}" \
+        : [offset] "=m" ((*(y *) (size_t) Offset)) \
+        : [Data] "ri" (Data)); \
+}
+
+/* This macro is used by _BitScanForward, _BitScanForward64, _BitScanReverse _BitScanReverse64
+
+   FunctionName: Any valid function name
+   DataType: unsigned __LONG32 or unsigned __int64
+   Segment: BSF or BSR */
+
+#define __buildbitscan(x, y, z) unsigned char x(unsigned __LONG32 *Index, y Mask) \
+{ \
+   y n; \
+   __asm__ (z "{%z[Mask] %[Mask],%[Index] | %[Index],%[Mask]}" \
+      : [Index] "=r" (n) \
+      : [Mask] "r" (Mask) \
+      : "cc"); \
+   *Index = n; \
+   return Mask!=0; \
+}
+
+#endif /* _INTRIN_MAC_ */
+
 /* The Barrier functions can never be in the library.  Since gcc only
 supports ReadWriteBarrier, map all 3 to do the same. */
 #ifndef _ReadWriteBarrier
------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to