Author: tkreuzer
Date: Mon Aug 25 13:47:44 2008
New Revision: 35636
URL: 
http://svn.reactos.org/svn/reactos?rev=35636&view=rev
Log:
Merge 34703, 34704, 34705, 34706, 34707, 34708, 34709 and 34710 from ros-amd64-bringup
branch:
- Fix inline versions of integer <-> pointer conversion functions.
- Implement _InterlockedAnd64, _InterlockedOr64, _interlockedbittestandreset64,
_interlockedbittestandset64 and gs-segment-adressing functions
- As amd64 shares most of the intrinsics of x86, implement them in intrin_x86.h
- Fix IMAGE_FIRST_SECTION macro
- Implement GetCurrentFiber(), NtCurrentTeb() and YieldProcessor()
- Fix ENUMRESLANGPROC, ENUMRESNAMEPROC and ENUMRESTYPEPROC
- Add Interlocked functions for pointers
- Add InterlockedCompareExchangePointer and InterlockedExchangePointer
- Add intrinsic port and register access functions
fix LIST_ENTRY() macro for 64 bits
add size_t definition to _mingw.h (ported from mingw)
- Update some loader structs ULONG -> ULONG_PTR / SIZE_T
Modified:
    trunk/reactos/include/crt/_mingw.h
    trunk/reactos/include/ddk/winddk.h
    trunk/reactos/include/psdk/basetsd.h
    trunk/reactos/include/psdk/intrin.h
    trunk/reactos/include/psdk/intrin_x86.h
    trunk/reactos/include/psdk/winbase.h
    trunk/reactos/include/psdk/winnt.h
    trunk/reactos/include/reactos/rosldr.h
    trunk/reactos/include/reactos/wine/list.h
Modified: trunk/reactos/include/crt/_mingw.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/crt/_mingw.h?rev=3…
==============================================================================
--- trunk/reactos/include/crt/_mingw.h [iso-8859-1] (original)
+++ trunk/reactos/include/crt/_mingw.h [iso-8859-1] Mon Aug 25 13:47:44 2008
@@ -178,6 +178,20 @@
 # define __MSVCRT_VERSION__ 0x0600
 #endif
+#ifndef _SIZE_T_DEFINED
+#define _SIZE_T_DEFINED
+#undef size_t
+#ifdef _WIN64
+#if defined(__GNUC__) && defined(__STRICT_ANSI__)
+  typedef unsigned int size_t __attribute__ ((mode (DI)));
+#else
+  typedef unsigned __int64 size_t;
+#endif
+#else
+  typedef unsigned int size_t;
+#endif
+#endif
+
 #define __MINGW32_VERSION 3.13
 #define __MINGW32_MAJOR_VERSION 3
 #define __MINGW32_MINOR_VERSION 13
Modified: trunk/reactos/include/ddk/winddk.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/ddk/winddk.h?rev=3…
==============================================================================
--- trunk/reactos/include/ddk/winddk.h [iso-8859-1] (original)
+++ trunk/reactos/include/ddk/winddk.h [iso-8859-1] Mon Aug 25 13:47:44 2008
@@ -228,7 +228,7 @@
 #define ZwCurrentProcess() NtCurrentProcess()
 #define NtCurrentThread() ( (HANDLE)(LONG_PTR) -2 )
 #define ZwCurrentThread() NtCurrentThread()
-
+
 #if (_M_IX86)
 #define KIP0PCRADDRESS                      0xffdff000
 #endif
@@ -5404,7 +5404,7 @@
 */
 #define PCR_MINOR_VERSION 1
 #define PCR_MAJOR_VERSION 1
-
+
 #ifdef _X86_
 typedef ULONG PFN_NUMBER, *PPFN_NUMBER;
@@ -5493,19 +5493,19 @@
 #error Unknown compiler
 #endif
 }
-
+
 NTHALAPI
 KIRQL
 DDKAPI
 KeGetCurrentIrql(
     VOID);
-
+
 NTKERNELAPI
 PRKTHREAD
 NTAPI
 KeGetCurrentThread(
     VOID);
-
+
 #define KI_USER_SHARED_DATA               0xffdf0000
 #elif defined(__x86_64__)
@@ -5586,7 +5586,7 @@
 #elif defined(_MIPS_)
 #error MIPS Headers are totally incorrect
-
+
 typedef ULONG PFN_NUMBER, *PPFN_NUMBER;
 #define PASSIVE_LEVEL                      0
@@ -5620,16 +5620,16 @@
 // NT-ARM is not documented, need DDK-ARM
 //
 #include <armddk.h>
-
+
 #else
 #error Unknown architecture
 #endif
-
+
 #define PAGE_SIZE                         0x1000
 #define PAGE_SHIFT                        12L
 #define SharedUserData                    ((KUSER_SHARED_DATA * CONST)
KI_USER_SHARED_DATA)
-
+
 extern NTKERNELAPI PVOID MmHighestUserAddress;
 extern NTKERNELAPI PVOID MmSystemRangeStart;
 extern NTKERNELAPI ULONG_PTR MmUserProbeAddress;
@@ -5744,8 +5744,12 @@
  *   IN OUT PVOID VOLATILE  *Target,
  *   IN PVOID  Value)
  */
+#if defined (_M_AMD64)
+#define InterlockedExchangePointer _InterlockedExchangePointer
+#else
 #define InterlockedExchangePointer(Target, Value) \
   ((PVOID) InterlockedExchange((PLONG) Target, (LONG) Value))
+#endif
 /*
  * PVOID
@@ -5754,8 +5758,12 @@
  *   IN PVOID  Exchange,
  *   IN PVOID  Comparand)
  */
+#if defined (_M_AMD64)
+#define InterlockedCompareExchangePointer _InterlockedCompareExchangePointer
+#else
 #define InterlockedCompareExchangePointer(Destination, Exchange, Comparand) \
   ((PVOID) InterlockedCompareExchange((PLONG) Destination, (LONG) Exchange, (LONG)
Comparand))
+#endif
 #define InterlockedExchangeAddSizeT(a, b) InterlockedExchangeAdd((LONG *)a, b)
 #define InterlockedIncrementSizeT(a) InterlockedIncrement((LONG *)a)
@@ -7569,6 +7577,9 @@
     IN PVOID Context
 );
+/** Io access routines **/
+
+#if !defined(_M_AMD64)
 NTHALAPI
 VOID
 NTAPI
@@ -7742,6 +7753,244 @@
 WRITE_REGISTER_USHORT(
   IN PUSHORT  Register,
   IN USHORT  Value);
+
+#else
+
+FORCEINLINE
+VOID
+READ_PORT_BUFFER_UCHAR(
+  IN PUCHAR  Port,
+  IN PUCHAR  Buffer,
+  IN ULONG  Count)
+{
+    __inbytestring((USHORT)(ULONG_PTR)Port, Buffer, Count);
+}
+
+FORCEINLINE
+VOID
+READ_PORT_BUFFER_ULONG(
+  IN PULONG  Port,
+  IN PULONG  Buffer,
+  IN ULONG  Count)
+{
+    __indwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count);
+}
+
+FORCEINLINE
+VOID
+READ_PORT_BUFFER_USHORT(
+  IN PUSHORT  Port,
+  IN PUSHORT  Buffer,
+  IN ULONG  Count)
+{
+    __inwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count);
+}
+
+FORCEINLINE
+UCHAR
+READ_PORT_UCHAR(
+  IN PUCHAR  Port)
+{
+    return __inbyte((USHORT)(ULONG_PTR)Port);
+}
+
+FORCEINLINE
+ULONG
+READ_PORT_ULONG(
+  IN PULONG  Port)
+{
+    return __indword((USHORT)(ULONG_PTR)Port);
+}
+
+FORCEINLINE
+USHORT
+READ_PORT_USHORT(
+  IN PUSHORT  Port)
+{
+    return __inword((USHORT)(ULONG_PTR)Port);
+}
+
+FORCEINLINE
+VOID
+READ_REGISTER_BUFFER_UCHAR(
+  IN PUCHAR  Register,
+  IN PUCHAR  Buffer,
+  IN ULONG  Count)
+{
+    __movsb(Register, Buffer, Count);
+}
+
+FORCEINLINE
+VOID
+READ_REGISTER_BUFFER_ULONG(
+  IN PULONG  Register,
+  IN PULONG  Buffer,
+  IN ULONG  Count)
+{
+    __movsd(Register, Buffer, Count);
+}
+
+FORCEINLINE
+VOID
+READ_REGISTER_BUFFER_USHORT(
+  IN PUSHORT  Register,
+  IN PUSHORT  Buffer,
+  IN ULONG  Count)
+{
+    __movsw(Register, Buffer, Count);
+}
+
+FORCEINLINE
+UCHAR
+READ_REGISTER_UCHAR(
+  IN PUCHAR Register)
+{
+    return *Register;
+}
+
+FORCEINLINE
+ULONG
+READ_REGISTER_ULONG(
+  IN PULONG Register)
+{
+    return *Register;
+}
+
+FORCEINLINE
+USHORT
+READ_REGISTER_USHORT(
+  IN PUSHORT Register)
+{
+    return *Register;
+}
+
+FORCEINLINE
+VOID
+WRITE_PORT_BUFFER_UCHAR(
+  IN PUCHAR  Port,
+  IN PUCHAR  Buffer,
+  IN ULONG  Count)
+{
+    __outbytestring((USHORT)(ULONG_PTR)Port, Buffer, Count);
+}
+
+FORCEINLINE
+VOID
+WRITE_PORT_BUFFER_ULONG(
+  IN PULONG  Port,
+  IN PULONG  Buffer,
+  IN ULONG  Count)
+{
+    __outdwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count);
+}
+
+FORCEINLINE
+VOID
+WRITE_PORT_BUFFER_USHORT(
+  IN PUSHORT  Port,
+  IN PUSHORT  Buffer,
+  IN ULONG  Count)
+{
+    __outwordstring((USHORT)(ULONG_PTR)Port, Buffer, Count);
+}
+
+FORCEINLINE
+VOID
+WRITE_PORT_UCHAR(
+  IN PUCHAR  Port,
+  IN UCHAR  Value)
+{
+    __outbyte((USHORT)(ULONG_PTR)Port, Value);
+}
+
+FORCEINLINE
+VOID
+WRITE_PORT_ULONG(
+  IN PULONG  Port,
+  IN ULONG  Value)
+{
+    __outdword((USHORT)(ULONG_PTR)Port, Value);
+}
+
+FORCEINLINE
+VOID
+WRITE_PORT_USHORT(
+  IN PUSHORT  Port,
+  IN USHORT  Value)
+{
+    __outword((USHORT)(ULONG_PTR)Port, Value);
+}
+
+FORCEINLINE
+VOID
+WRITE_REGISTER_BUFFER_UCHAR(
+  IN PUCHAR  Register,
+  IN PUCHAR  Buffer,
+  IN ULONG  Count)
+{
+    LONG Synch;
+    __movsb(Register, Buffer, Count);
+    InterlockedOr(&Synch, 1);
+}
+
+FORCEINLINE
+VOID
+WRITE_REGISTER_BUFFER_ULONG(
+  IN PULONG  Register,
+  IN PULONG  Buffer,
+  IN ULONG  Count)
+{
+    LONG Synch;
+    __movsd(Register, Buffer, Count);
+    InterlockedOr(&Synch, 1);
+}
+
+FORCEINLINE
+VOID
+WRITE_REGISTER_BUFFER_USHORT(
+  IN PUSHORT  Register,
+  IN PUSHORT  Buffer,
+  IN ULONG  Count)
+{
+    LONG Synch;
+    __movsw(Register, Buffer, Count);
+    InterlockedOr(&Synch, 1);
+}
+
+FORCEINLINE
+VOID
+WRITE_REGISTER_UCHAR(
+  IN PUCHAR  Register,
+  IN UCHAR  Value)
+{
+    LONG Synch;
+    *Register = Value;
+    InterlockedOr(&Synch, 1);
+}
+
+FORCEINLINE
+VOID
+WRITE_REGISTER_ULONG(
+  IN PULONG  Register,
+  IN ULONG  Value)
+{
+    LONG Synch;
+    *Register = Value;
+    InterlockedOr(&Synch, 1);
+}
+
+FORCEINLINE
+VOID
+WRITE_REGISTER_USHORT(
+  IN PUSHORT  Register,
+  IN USHORT  Value)
+{
+       LONG Sync;
+       *Register = Value;
+       InterlockedOr(&Sync, 1);
+}
+
+#endif
 /** I/O manager routines **/
@@ -9599,9 +9848,9 @@
 DDKAPI
 KeRaiseIrqlToSynchLevel(
     VOID);
-
+
 #elif defined(_M_ARM)
-
+
 #include <armddk.h>
 #else
Modified: trunk/reactos/include/psdk/basetsd.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/basetsd.h?rev…
==============================================================================
--- trunk/reactos/include/psdk/basetsd.h [iso-8859-1] (original)
+++ trunk/reactos/include/psdk/basetsd.h [iso-8859-1] Mon Aug 25 13:47:44 2008
@@ -65,37 +65,36 @@
 typedef unsigned int UHALF_PTR, *PUHALF_PTR;
 typedef int HALF_PTR, *PHALF_PTR;
-#if 0 /* TODO when WIN64 is here */
-inline unsigned long HandleToUlong(const void* h )
-    { return((unsigned long) h ); }
-inline long HandleToLong( const void* h )
-    { return((long) h ); }
-inline void* ULongToHandle( const long h )
+#if !defined(__midl) && !defined(__WIDL__)
+static inline unsigned long HandleToUlong(const void* h )
+    { return((unsigned long)(ULONG_PTR) h ); }
+static inline long HandleToLong( const void* h )
+    { return((long)(LONG_PTR) h ); }
+static inline void* ULongToHandle( const long h )
     { return((void*) (UINT_PTR) h ); }
-inline void* LongToHandle( const long h )
+static inline void* LongToHandle( const long h )
     { return((void*) (INT_PTR) h ); }
-inline unsigned long PtrToUlong( const void* p)
-    { return((unsigned long) p ); }
-inline unsigned int PtrToUint( const void* p )
-    { return((unsigned int) p ); }
-inline unsigned short PtrToUshort( const void* p )
-    { return((unsigned short) p ); }
-inline long PtrToLong( const void* p )
-    { return((long) p ); }
-inline int PtrToInt( const void* p )
-    { return((int) p ); }
-inline short PtrToShort( const void* p )
-    { return((short) p ); }
-inline void* IntToPtr( const int i )
+static inline unsigned long PtrToUlong( const void* p)
+    { return((unsigned long)(ULONG_PTR) p ); }
+static inline unsigned int PtrToUint( const void* p )
+    { return((unsigned int)(UINT_PTR) p ); }
+static inline unsigned short PtrToUshort( const void* p )
+    { return((unsigned short)(ULONG_PTR) p ); }
+static inline long PtrToLong( const void* p )
+    { return((long)(LONG_PTR) p ); }
+static inline int PtrToInt( const void* p )
+    { return((int)(INT_PTR) p ); }
+static inline short PtrToShort( const void* p )
+    { return((short)(INT_PTR) p ); }
+static inline void* IntToPtr( const int i )
     { return( (void*)(INT_PTR)i ); }
-inline void* UIntToPtr(const unsigned int ui)
+static inline void* UIntToPtr(const unsigned int ui)
     { return( (void*)(UINT_PTR)ui ); }
-inline void* LongToPtr( const long l )
+static inline void* LongToPtr( const long l )
     { return( (void*)(LONG_PTR)l ); }
-inline void* ULongToPtr( const unsigned long ul )
+static inline void* ULongToPtr( const unsigned long ul )
     { return( (void*)(ULONG_PTR)ul ); }
-#endif /* 0_ */
-
+#endif /* !__midl */
 #else /*  !_WIN64 */
 typedef int INT_PTR, *PINT_PTR;
 typedef unsigned int UINT_PTR, *PUINT_PTR;
Modified: trunk/reactos/include/psdk/intrin.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/intrin.h?rev=…
==============================================================================
--- trunk/reactos/include/psdk/intrin.h [iso-8859-1] (original)
+++ trunk/reactos/include/psdk/intrin.h [iso-8859-1] Mon Aug 25 13:47:44 2008
@@ -79,7 +79,7 @@
 #include "intrin_arm.h"
 #elif defined(__x86_64__)
 /* TODO: the x64 architecture shares most of the i386 intrinsics. It should be easy to
support */
-#include "intrin_x86_64.h"
+#include "intrin_x86.h"
 #else
 #error Unsupported architecture
 #endif
Modified: trunk/reactos/include/psdk/intrin_x86.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/intrin_x86.h?…
==============================================================================
--- trunk/reactos/include/psdk/intrin_x86.h [iso-8859-1] (original)
+++ trunk/reactos/include/psdk/intrin_x86.h [iso-8859-1] Mon Aug 25 13:47:44 2008
@@ -153,6 +153,13 @@
        return __sync_fetch_and_and(value, mask);
 }
+#if defined(_M_AMD64)
+static __inline__ __attribute__((always_inline)) long _InterlockedAnd64(volatile long
long * const value, const long long mask)
+{
+       return __sync_fetch_and_and(value, mask);
+}
+#endif
+
 static __inline__ __attribute__((always_inline)) char _InterlockedOr8(volatile char *
const value, const char mask)
 {
        return __sync_fetch_and_or(value, mask);
@@ -167,6 +174,13 @@
 {
        return __sync_fetch_and_or(value, mask);
 }
+
+#if defined(_M_AMD64)
+static __inline__ __attribute__((always_inline)) long _InterlockedOr64(volatile long long
* const value, const long long mask)
+{
+       return __sync_fetch_and_or(value, mask);
+}
+#endif
 static __inline__ __attribute__((always_inline)) char _InterlockedXor8(volatile char *
const value, const char mask)
 {
@@ -455,6 +469,15 @@
        return retval;
 }
+#if defined(_M_AMD64)
+static __inline__ __attribute__((always_inline)) unsigned char
_interlockedbittestandreset64(volatile long long * a, const long long b)
+{
+       unsigned char retval;
+       __asm__("lock; btrq %[b], %[a]; setb %b[retval]" : [retval]
"=r" (retval), [a] "=m" (a) : [b] "Ir" (b) :
"memory");
+       return retval;
+}
+#endif
+
 static __inline__ __attribute__((always_inline)) unsigned char
_interlockedbittestandset(volatile long * a, const long b)
 {
        unsigned char retval;
@@ -462,6 +485,14 @@
        return retval;
 }
+#if defined(_M_AMD64)
+static __inline__ __attribute__((always_inline)) unsigned char
_interlockedbittestandset64(volatile long long * a, const long long b)
+{
+       unsigned char retval;
+       __asm__("lock; btsq %[b], %[a]; setc %b[retval]" : [retval]
"=r" (retval), [a] "=m" (a) : [b] "Ir" (b) :
"memory");
+       return retval;
+}
+#endif
 /*** String operations ***/
 /* NOTE: we don't set a memory clobber in the __stosX functions because Visual C++
doesn't */
@@ -525,7 +556,98 @@
        );
 }
-
+#if defined(_M_AMD64)
+/*** GS segment addressing ***/
+
+static __inline__ __attribute__((always_inline)) void __writegsbyte(const unsigned long
Offset, const unsigned char Data)
+{
+       __asm__("movb %b[Data], %%gs:%a[Offset]" : : [Offset] "ir"
(Offset), [Data] "iq" (Data));
+}
+
+static __inline__ __attribute__((always_inline)) void __writegsword(const unsigned long
Offset, const unsigned short Data)
+{
+       __asm__("movw %w[Data], %%gs:%a[Offset]" : : [Offset] "ir"
(Offset), [Data] "iq" (Data));
+}
+
+static __inline__ __attribute__((always_inline)) void __writegsdword(const unsigned long
Offset, const unsigned long Data)
+{
+       __asm__("movl %k[Data], %%gs:%a[Offset]" : : [Offset] "ir"
(Offset), [Data] "iq" (Data));
+}
+
+static __inline__ __attribute__((always_inline)) void __writegsqword(const unsigned long
Offset, const unsigned __int64 Data)
+{
+       __asm__("movq %q[Data], %%gs:%a[Offset]" : : [Offset] "ir"
(Offset), [Data] "iq" (Data));
+}
+
+static __inline__ __attribute__((always_inline)) unsigned char __readgsbyte(const
unsigned long Offset)
+{
+       unsigned char value;
+       __asm__("movb %%gs:%a[Offset], %b[value]" : [value] "=q"
(value) : [Offset] "irm" (Offset));
+       return value;
+}
+
+static __inline__ __attribute__((always_inline)) unsigned short __readgsword(const
unsigned long Offset)
+{
+       unsigned short value;
+       __asm__("movw %%gs:%a[Offset], %w[value]" : [value] "=q"
(value) : [Offset] "irm" (Offset));
+       return value;
+}
+
+static __inline__ __attribute__((always_inline)) unsigned long __readgsdword(const
unsigned long Offset)
+{
+       unsigned long value;
+       __asm__("movl %%gs:%a[Offset], %k[value]" : [value] "=q"
(value) : [Offset] "irm" (Offset));
+       return value;
+}
+
+static __inline__ __attribute__((always_inline)) unsigned __int64 __readgsqword(const
unsigned long Offset)
+{
+       unsigned long value;
+       __asm__("movq %%gs:%a[Offset], %q[value]" : [value] "=q"
(value) : [Offset] "irm" (Offset));
+       return value;
+}
+
+static __inline__ __attribute__((always_inline)) void __incgsbyte(const unsigned long
Offset)
+{
+       __asm__("incb %%gs:%a[Offset]" : : [Offset] "ir" (Offset));
+}
+
+static __inline__ __attribute__((always_inline)) void __incgsword(const unsigned long
Offset)
+{
+       __asm__("incw %%gs:%a[Offset]" : : [Offset] "ir" (Offset));
+}
+
+static __inline__ __attribute__((always_inline)) void __incgsdword(const unsigned long
Offset)
+{
+       __asm__("incl %%gs:%a[Offset]" : : [Offset] "ir" (Offset));
+}
+
+/* NOTE: the bizarre implementation of __addgsxxx mimics the broken Visual C++ behavior
*/
+static __inline__ __attribute__((always_inline)) void __addgsbyte(const unsigned long
Offset, const unsigned char Data)
+{
+       if(!__builtin_constant_p(Offset))
+               __asm__("addb %k[Offset], %%gs:%a[Offset]" : : [Offset]
"r" (Offset));
+       else
+               __asm__("addb %b[Data], %%gs:%a[Offset]" : : [Offset]
"ir" (Offset), [Data] "iq" (Data));
+}
+
+static __inline__ __attribute__((always_inline)) void __addgsword(const unsigned long
Offset, const unsigned short Data)
+{
+       if(!__builtin_constant_p(Offset))
+               __asm__("addw %k[Offset], %%gs:%a[Offset]" : : [Offset]
"r" (Offset));
+       else
+               __asm__("addw %w[Data], %%gs:%a[Offset]" : : [Offset]
"ir" (Offset), [Data] "iq" (Data));
+}
+
+static __inline__ __attribute__((always_inline)) void __addgsdword(const unsigned long
Offset, const unsigned int Data)
+{
+       if(!__builtin_constant_p(Offset))
+               __asm__("addl %k[Offset], %%gs:%a[Offset]" : : [Offset]
"r" (Offset));
+       else
+               __asm__("addl %k[Data], %%gs:%a[Offset]" : : [Offset]
"ir" (Offset), [Data] "iq" (Data));
+}
+
+#else
 /*** FS segment addressing ***/
 static __inline__ __attribute__((always_inline)) void __writefsbyte(const unsigned long
Offset, const unsigned char Data)
 {
@@ -602,6 +724,7 @@
        else
                __asm__("addl %k[Data], %%fs:%a[Offset]" : : [Offset]
"ir" (Offset), [Data] "iq" (Data));
 }
+#endif
 /*** Bit manipulation ***/
Modified: trunk/reactos/include/psdk/winbase.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/winbase.h?rev…
==============================================================================
--- trunk/reactos/include/psdk/winbase.h [iso-8859-1] (original)
+++ trunk/reactos/include/psdk/winbase.h [iso-8859-1] Mon Aug 25 13:47:44 2008
@@ -23,7 +23,7 @@
 #define FILE_SYSTEM_NOT_SUPPORT  6
 #define FILE_USER_DISALLOWED     7
 #define FILE_READ_ONLY           8
-#define FILE_DIR_DISALOWED       9
+#define FILE_DIR_DISALOWED       9
 #define COMMPROP_INITIALIZED 0xE73CF52E
 #define SP_SERIALCOMM 1
@@ -1081,12 +1081,12 @@
 typedef DWORD(WINAPI
*LPPROGRESS_ROUTINE)(LARGE_INTEGER,LARGE_INTEGER,LARGE_INTEGER,LARGE_INTEGER,DWORD,DWORD,HANDLE,HANDLE,LPVOID);
 typedef void(WINAPI *LPFIBER_START_ROUTINE)(PVOID);
 typedef VOID (WINAPI *PFLS_CALLBACK_FUNCTION)(PVOID);
-typedef BOOL(CALLBACK *ENUMRESLANGPROCA)(HMODULE,LPCSTR,LPCSTR,WORD,LONG);
-typedef BOOL(CALLBACK *ENUMRESLANGPROCW)(HMODULE,LPCWSTR,LPCWSTR,WORD,LONG);
-typedef BOOL(CALLBACK *ENUMRESNAMEPROCA)(HMODULE,LPCSTR,LPSTR,LONG);
-typedef BOOL(CALLBACK *ENUMRESNAMEPROCW)(HMODULE,LPCWSTR,LPWSTR,LONG);
-typedef BOOL(CALLBACK *ENUMRESTYPEPROCA)(HMODULE,LPSTR,LONG);
-typedef BOOL(CALLBACK *ENUMRESTYPEPROCW)(HMODULE,LPWSTR,LONG);
+typedef BOOL(CALLBACK *ENUMRESLANGPROCA)(HMODULE,LPCSTR,LPCSTR,WORD,LONG_PTR);
+typedef BOOL(CALLBACK *ENUMRESLANGPROCW)(HMODULE,LPCWSTR,LPCWSTR,WORD,LONG_PTR);
+typedef BOOL(CALLBACK *ENUMRESNAMEPROCA)(HMODULE,LPCSTR,LPSTR,LONG_PTR);
+typedef BOOL(CALLBACK *ENUMRESNAMEPROCW)(HMODULE,LPCWSTR,LPWSTR,LONG_PTR);
+typedef BOOL(CALLBACK *ENUMRESTYPEPROCA)(HMODULE,LPSTR,LONG_PTR);
+typedef BOOL(CALLBACK *ENUMRESTYPEPROCW)(HMODULE,LPWSTR,LONG_PTR);
 typedef void(CALLBACK *LPOVERLAPPED_COMPLETION_ROUTINE)(DWORD,DWORD,LPOVERLAPPED);
 typedef LONG(CALLBACK *PTOP_LEVEL_EXCEPTION_FILTER)(LPEXCEPTION_POINTERS);
 typedef PTOP_LEVEL_EXCEPTION_FILTER LPTOP_LEVEL_EXCEPTION_FILTER;
@@ -1707,14 +1707,23 @@
 #ifndef __INTERLOCKED_DECLARED
 #define __INTERLOCKED_DECLARED
 LONG WINAPI InterlockedCompareExchange(IN OUT LONG volatile *,LONG,LONG);
-/* PVOID WINAPI InterlockedCompareExchangePointer(PVOID*,PVOID,PVOID); */
-#define InterlockedCompareExchangePointer(d,e,c) \
-    (PVOID)InterlockedCompareExchange((LPLONG)(d),(LONG)(e),(LONG)(c))
 LONG WINAPI InterlockedDecrement(IN OUT LONG volatile *);
 LONG WINAPI InterlockedExchange(IN OUT LONG volatile *,LONG);
-/* PVOID WINAPI InterlockedExchangePointer(PVOID*,PVOID); */
-#define InterlockedExchangePointer(t,v) \
+#if defined(_WIN64)
+ /* PVOID WINAPI InterlockedExchangePointer(PVOID*,PVOID); */
+ #define InterlockedExchangePointer(t,v) \
+    (PVOID)InterlockedExchange64((LONGLONG*)(t),(LONGLONG)(v))
+ /* PVOID WINAPI InterlockedCompareExchangePointer(PVOID*,PVOID,PVOID); */
+ #define InterlockedCompareExchangePointer(d,e,c) \
+    (PVOID)InterlockedCompareExchange64((LONGLONG*)(d),(LONGLONG)(e),(LONGLONG)(c))
+#else
+ /* PVOID WINAPI InterlockedExchangePointer(PVOID*,PVOID); */
+ #define InterlockedExchangePointer(t,v) \
     (PVOID)InterlockedExchange((LPLONG)(t),(LONG)(v))
+ /* PVOID WINAPI InterlockedCompareExchangePointer(PVOID*,PVOID,PVOID); */
+ #define InterlockedCompareExchangePointer(d,e,c) \
+    (PVOID)InterlockedCompareExchange((LPLONG)(d),(LONG)(e),(LONG)(c))
+#endif
 LONG WINAPI InterlockedExchangeAdd(IN OUT LONG volatile *,LONG);
 #if (_WIN32_WINNT >= 0x0501)
 PSLIST_ENTRY WINAPI InterlockedFlushSList(PSLIST_HEADER);
Modified: trunk/reactos/include/psdk/winnt.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/winnt.h?rev=3…
==============================================================================
--- trunk/reactos/include/psdk/winnt.h [iso-8859-1] (original)
+++ trunk/reactos/include/psdk/winnt.h [iso-8859-1] Mon Aug 25 13:47:44 2008
@@ -1350,7 +1350,7 @@
 #define IMAGE_DLLCHARACTERISTICS_NO_BIND 0x0800
 #define IMAGE_DLLCHARACTERISTICS_WDM_DRIVER 0x2000
 #define IMAGE_DLLCHARACTERISTICS_TERMINAL_SERVER_AWARE 0x8000
-#define IMAGE_FIRST_SECTION(h) ((PIMAGE_SECTION_HEADER)
((DWORD)h+FIELD_OFFSET(IMAGE_NT_HEADERS,OptionalHeader)+((PIMAGE_NT_HEADERS)(h))->FileHeader.SizeOfOptionalHeader))
+#define IMAGE_FIRST_SECTION(h) ((PIMAGE_SECTION_HEADER)
((DWORD_PTR)h+FIELD_OFFSET(IMAGE_NT_HEADERS,OptionalHeader)+((PIMAGE_NT_HEADERS)(h))->FileHeader.SizeOfOptionalHeader))
 #define IMAGE_DIRECTORY_ENTRY_EXPORT   0
 #define IMAGE_DIRECTORY_ENTRY_IMPORT   1
 #define IMAGE_DIRECTORY_ENTRY_RESOURCE 2
@@ -2902,7 +2902,7 @@
 #endif
 NTSYSAPI
-WORD
+WORD
 NTAPI
 RtlCaptureStackBackTrace(
     IN DWORD FramesToSkip,
@@ -4090,6 +4090,11 @@
     );
     return ret;
 }
+#elif defined (_M_AMD64)
+FORCEINLINE PVOID GetCurrentFiber(VOID)
+{
+    return (PVOID)__readgsqword(FIELD_OFFSET(NT_TIB, FiberData));
+}
 #elif defined (_M_ARM)
     PVOID WINAPI GetCurrentFiber(VOID);
 #else
@@ -4130,13 +4135,18 @@
     return ret;
 }
 #elif _M_ARM
-
+
 //
 // NT-ARM is not documented
 //
 #define KIRQL ULONG // Hack!
 #include <armddk.h>
-
+
+#elif defined (_M_AMD64)
+FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
+{
+    return __readgsqword(FIELD_OFFSET(NT_TIB, Self));
+}
 #else
 static __inline__ struct _TEB * NtCurrentTeb(void)
 {
@@ -4267,6 +4277,8 @@
 #if defined(_M_IX86)
 #define YieldProcessor() __asm__ __volatile__("pause");
+#elif defined (_M_AMD64)
+#define YieldProcessor() __asm__ __volatile__("pause");
 #elif defined(_M_PPC)
 #define YieldProcessor() __asm__ __volatile__("nop");
 #elif defined(_M_MIPS)
@@ -4282,6 +4294,19 @@
 #define InterlockedExchangeAddSizeT(a, b) InterlockedExchangeAdd64((LONG64 *)a, b)
+#define InterlockedAnd _InterlockedAnd
+#define InterlockedExchange _InterlockedExchange
+#define InterlockedOr _InterlockedOr
+
+#define InterlockedAnd64 _InterlockedAnd64
+#define InterlockedOr64 _InterlockedOr64
+
+#define InterlockedBitTestAndSet _interlockedbittestandset
+#define InterlockedBitTestAndSet64 _interlockedbittestandset64
+#define InterlockedBitTestAndReset _interlockedbittestandreset
+#define InterlockedBitTestAndReset64 _interlockedbittestandreset64
+
+
 #endif
 #else
Modified: trunk/reactos/include/reactos/rosldr.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/rosldr.h?r…
==============================================================================
--- trunk/reactos/include/reactos/rosldr.h [iso-8859-1] (original)
+++ trunk/reactos/include/reactos/rosldr.h [iso-8859-1] Mon Aug 25 13:47:44 2008
@@ -17,34 +17,34 @@
 typedef struct _LOADER_MODULE
 {
-    ULONG ModStart;
-    ULONG ModEnd;
-    ULONG String;
-    ULONG Reserved;
+    ULONG_PTR ModStart;
+    ULONG_PTR ModEnd;
+    ULONG_PTR String;
+    ULONG_PTR Reserved;
 } LOADER_MODULE, *PLOADER_MODULE;
 typedef struct _ROS_LOADER_PARAMETER_BLOCK
 {
     ULONG Flags;
-    ULONG MemLower;
-    ULONG MemHigher;
+    ULONG_PTR MemLower;
+    ULONG_PTR MemHigher;
     ULONG BootDevice;
     PCHAR CommandLine;
     ULONG ModsCount;
     PLOADER_MODULE ModsAddr;
     UCHAR Syms[12];
-    ULONG MmapLength;
-    ULONG MmapAddr;
-    ULONG RdLength;
-    ULONG RdAddr;
+    SIZE_T MmapLength;
+    ULONG_PTR MmapAddr;
+    SIZE_T RdLength;
+    ULONG_PTR RdAddr;
     ULONG DrivesCount;
     PARC_DISK_SIGNATURE DrivesAddr;
     ULONG ConfigTable;
     ULONG BootLoaderName;
-    ULONG PageDirectoryStart;
-    ULONG PageDirectoryEnd;
-    ULONG KernelBase;
-    ULONG ArchExtra;
+    ULONG_PTR PageDirectoryStart;
+    ULONG_PTR PageDirectoryEnd;
+    ULONG_PTR KernelBase;
+    ULONG_PTR ArchExtra;
 } ROS_LOADER_PARAMETER_BLOCK, *PROS_LOADER_PARAMETER_BLOCK;
 extern BOOLEAN AcpiTableDetected;
Modified: trunk/reactos/include/reactos/wine/list.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/wine/list.…
==============================================================================
--- trunk/reactos/include/reactos/wine/list.h [iso-8859-1] (original)
+++ trunk/reactos/include/reactos/wine/list.h [iso-8859-1] Mon Aug 25 13:47:44 2008
@@ -224,7 +224,12 @@
 #define LIST_INIT(list)  { &(list), &(list) }
 /* get pointer to object containing list element */
+#ifdef _WIN64
+#define LIST_ENTRY(elem, type, field) \
+    ((type *)((char *)(elem) - (unsigned long long)(&((type *)0)->field)))
+#else
 #define LIST_ENTRY(elem, type, field) \
     ((type *)((char *)(elem) - (unsigned long)(&((type *)0)->field)))
+#endif
 #endif  /* __WINE_SERVER_LIST_H */