Fix bug in __stosb Patch by David Wohlferd limegreensocks@yahoo.com 1) The __buildstos macro has been removed from winnt.h 2) __buildstos has been put in the new file mingw-w64-headers/include/psdk_inc/intrin-mac.h 3) mingw-w64-crt/intrincs/__stosb.c (and stosw.c, stosd.c, stosq.c) now use the macro from intrin-mac.h As a result, not only do the stos*.c files get the new code, but this inline assembler now only exists in one place, making future maintenance easier. git-svn-id: svn+ssh://svn.code.sf.net/p/mingw-w64/code/trunk@5872 4407c894-4637-0410-b4f5-ada5f102cad1
diff --git a/mingw-w64-crt/intrincs/__stosb.c b/mingw-w64-crt/intrincs/__stosb.c index d55bbc0..3a590b9 100644 --- a/mingw-w64-crt/intrincs/__stosb.c +++ b/mingw-w64-crt/intrincs/__stosb.c
@@ -1,12 +1,4 @@ #include <intrin.h> +#include <psdk_inc/intrin-mac.h> -void __stosb(unsigned char *Dest, unsigned char Data, size_t Count) -{ - __asm__ __volatile__ - ( - "rep; stosb" : - [Dest] "=D" (Dest), [Count] "=c" (Count) : - "[Dest]" (Dest), "a" (Data), "[Count]" (Count) - ); -} - +__buildstos(__stosb, unsigned char)
diff --git a/mingw-w64-crt/intrincs/__stosd.c b/mingw-w64-crt/intrincs/__stosd.c index b5399ab..cbde654 100644 --- a/mingw-w64-crt/intrincs/__stosd.c +++ b/mingw-w64-crt/intrincs/__stosd.c
@@ -1,12 +1,4 @@ #include <intrin.h> +#include <psdk_inc/intrin-mac.h> -void __stosd(unsigned __LONG32 *Dest, unsigned __LONG32 Data, size_t Count) -{ - __asm__ __volatile__ - ( - "rep; stosl" : - [Dest] "=D" (Dest), [Count] "=c" (Count) : - "[Dest]" (Dest), "a" (Data), "[Count]" (Count) - ); -} - +__buildstos(__stosd, unsigned __LONG32)
diff --git a/mingw-w64-crt/intrincs/__stosq.c b/mingw-w64-crt/intrincs/__stosq.c index 269baf8..606128a 100644 --- a/mingw-w64-crt/intrincs/__stosq.c +++ b/mingw-w64-crt/intrincs/__stosq.c
@@ -1,12 +1,4 @@ #include <intrin.h> +#include <psdk_inc/intrin-mac.h> -void __stosq(unsigned __int64 *Dest, unsigned __int64 Data, size_t Count) -{ - __asm__ __volatile__ - ( - "rep; stosq" : - [Dest] "=D" (Dest), [Count] "=c" (Count) : - "[Dest]" (Dest), "a" (Data), "[Count]" (Count) - ); -} - +__buildstos(__stosq, unsigned __int64)
diff --git a/mingw-w64-crt/intrincs/__stosw.c b/mingw-w64-crt/intrincs/__stosw.c index befa4ec..4c1b0d4 100644 --- a/mingw-w64-crt/intrincs/__stosw.c +++ b/mingw-w64-crt/intrincs/__stosw.c
@@ -1,12 +1,4 @@ #include <intrin.h> +#include <psdk_inc/intrin-mac.h> -void __stosw(unsigned short *Dest, unsigned short Data, size_t Count) -{ - __asm__ __volatile__ - ( - "rep; stosw" : - [Dest] "=D" (Dest), [Count] "=c" (Count) : - "[Dest]" (Dest), "a" (Data), "[Count]" (Count) - ); -} - +__buildstos(__stosw, unsigned short)
diff --git a/mingw-w64-headers/include/psdk_inc/intrin-mac.h b/mingw-w64-headers/include/psdk_inc/intrin-mac.h new file mode 100644 index 0000000..93b2b59 --- /dev/null +++ b/mingw-w64-headers/include/psdk_inc/intrin-mac.h
@@ -0,0 +1,21 @@ +/** + * This file has no copyright assigned and is placed in the Public Domain. + * This file is part of the mingw-w64 runtime package. + * No warranty is given; refer to the file DISCLAIMER.PD within this package. + */ + +// The macros in this file are included in multiple places + +#ifndef _INTRIN-MAC_ +#define _INTRIN-MAC_ + +// This macro is used by __stosb, __stosw, __stosd, __stosq +#define __buildstos(x, y) void x(y *Dest, y Data, size_t Count) \ +{ \ + __asm__ __volatile__ ("rep stos%z[Data]" \ + : /* no outputs */ \ + : "D" (Dest), "c" (Count), [Data] "a" (Data) \ + : "memory"); \ +} + +#endif /* _INTRIN-MAC_ */
diff --git a/mingw-w64-headers/include/winnt.h b/mingw-w64-headers/include/winnt.h index bd5b0a5..23ffafb 100644 --- a/mingw-w64-headers/include/winnt.h +++ b/mingw-w64-headers/include/winnt.h
@@ -18,6 +18,7 @@ #define ANYSIZE_ARRAY 1 #include <specstrings.h> +#include <psdk_inc/intrin-mac.h> #if defined(__x86_64) && \ !(defined(_X86_) || defined(__i386__) || defined(_IA64_)) @@ -1580,18 +1581,10 @@ VOID __stosq(PDWORD64 Destination,DWORD64 Value,SIZE_T Count); #ifndef __CRT__NO_INLINE -#define __buildstos(x, y) __CRT_INLINE VOID x(y *Dest, y Data, SIZE_T Count) \ -{ \ - __asm__ __volatile__ ("rep stos%z2" \ - : /* no outputs */ \ - : "D" (Dest), "c" (Count), "a" (Data) \ - : "memory"); \ -} - -__buildstos(__stosb, BYTE) -__buildstos(__stosw, WORD) -__buildstos(__stosd, DWORD) -__buildstos(__stosq, DWORD64) +__CRT_INLINE __buildstos(__stosb, BYTE) +__CRT_INLINE __buildstos(__stosw, WORD) +__CRT_INLINE __buildstos(__stosd, DWORD) +__CRT_INLINE __buildstos(__stosq, DWORD64) #endif /* __CRT__NO_INLINE */ #define MultiplyHigh __mulh