Ok, I get it now. As everyone was trying to tell me (including myself),
the problem was in SIZE_T/size_t. I just couldn't get my head around
the fact that these two lines are different:
typedef unsigned long int size_t;
typedef unsigned long long SIZE_T;
Under CygWin64, they are both 8 bytes long, unsigned integers, but the
compiler still treats them as different types (thanks to jon_y for
finally pounding this home).
So, the question now is, which one should we be using for __stos*? Even
before I began my work on the asm stuff, winnt.h was using SIZE_T and
the files in the instrincs folder were using size_t (for example check
out __movsw.c which still does this). As ktietz says, we should keep
signatures compatible. So let's pick one and use it in all 3 places
(winnt.h, intrin-mac.h & intrinsics\*.c).
I believe that the most correct definition for __stosb is the one from
MS
<http://msdn.microsoft.com/en-us/library/ywwcatsa%28v=vs.100%29.aspx>,
which looks like this:
void __stosb(unsigned char* Dest, unsigned char Data, size_t Count);
As it happens, this is what intrin-mac.h and intrinsics\__stos*.c are
already using. The only thing I think needs changing is winnt.h. My
proposed patch is attached.
*Note that I am fudging a bit on __stosd, which MS declares as "unsigned
long." I'm pretty sure this isn't what we want in gcc, so I've changed
this to unsigned int.
dw
Index: mingw-w64-crt/intrincs/__stosd.c
===================================================================
--- mingw-w64-crt/intrincs/__stosd.c (revision 5877)
+++ mingw-w64-crt/intrincs/__stosd.c (working copy)
@@ -1,4 +1,4 @@
#include <intrin.h>
#include <psdk_inc/intrin-mac.h>
-__buildstos(__stosd, unsigned __LONG32)
+__buildstos(__stosd, unsigned int)
Index: mingw-w64-headers/crt/intrin.h
===================================================================
--- mingw-w64-headers/crt/intrin.h (revision 5877)
+++ mingw-w64-headers/crt/intrin.h (working copy)
@@ -1031,7 +1031,7 @@
__MACHINEX64(__MINGW_EXTENSION void _mm_stream_si64x(__int64 *,__int64))
__MACHINEI(void __stosb(unsigned char *,unsigned char,size_t))
__MACHINEI(void __stosw(unsigned short *,unsigned short,size_t))
- __MACHINEI(void __stosd(unsigned __LONG32 *,unsigned __LONG32,size_t))
+ __MACHINEI(void __stosd(unsigned int *,unsigned int,size_t))
__MACHINEX64(__MINGW_EXTENSION void __stosq(unsigned __int64 *,unsigned
__int64,size_t))
__MACHINEIW64(unsigned char _bittest(__LONG32 const *a,__LONG32 b))
__MACHINEIW64(unsigned char _bittestandset(__LONG32 *a,__LONG32 b))
Index: mingw-w64-headers/include/winnt.h
===================================================================
--- mingw-w64-headers/include/winnt.h (revision 5877)
+++ mingw-w64-headers/include/winnt.h (working copy)
@@ -1536,16 +1536,16 @@
VOID __movsw(PWORD Destination,WORD const *Source,SIZE_T Count);
VOID __movsd(PDWORD Destination,DWORD const *Source,SIZE_T Count);
VOID __movsq(PDWORD64 Destination,DWORD64 const *Source,SIZE_T Count);
- VOID __stosb(PBYTE Destination,BYTE Value,SIZE_T Count);
- VOID __stosw(PWORD Destination,WORD Value,SIZE_T Count);
- VOID __stosd(PDWORD Destination,DWORD Value,SIZE_T Count);
- VOID __stosq(PDWORD64 Destination,DWORD64 Value,SIZE_T Count);
+ void __stosb(unsigned char *Destination, unsigned char Value, size_t
Count);
+ void __stosw(unsigned short *Destination, unsigned short Value, size_t
Count);
+ void __stosd(unsigned int *Destination, unsigned int Value, size_t Count);
+ void __stosq(unsigned __int64 *Destination, unsigned __int64 Value, size_t
Count);
#ifndef __CRT__NO_INLINE
-__CRT_INLINE __buildstos(__stosb, BYTE)
-__CRT_INLINE __buildstos(__stosw, WORD)
-__CRT_INLINE __buildstos(__stosd, DWORD)
-__CRT_INLINE __buildstos(__stosq, DWORD64)
+__CRT_INLINE __buildstos(__stosb, unsigned char)
+__CRT_INLINE __buildstos(__stosw, unsigned short)
+__CRT_INLINE __buildstos(__stosd, unsigned int)
+__CRT_INLINE __buildstos(__stosq, unsigned __int64)
#endif /* __CRT__NO_INLINE */
#define MultiplyHigh __mulh
------------------------------------------------------------------------------
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public