Delete redundant broken offsetof definitions (dotnet/coreclr#18947)
authorJan Kotas <jkotas@microsoft.com>
Tue, 17 Jul 2018 08:51:57 +0000 (01:51 -0700)
committerGitHub <noreply@github.com>
Tue, 17 Jul 2018 08:51:57 +0000 (01:51 -0700)
Fixes build breaks with latest Visual Studio Preview.

Fixes dotnet/coreclr#18338

Commit migrated from https://github.com/dotnet/coreclr/commit/cc3e7d05c9248c0951beef289c48909066d27345

src/coreclr/src/debug/daccess/stdafx.h
src/coreclr/src/gc/env/volatile.h
src/coreclr/src/inc/corinfo.h
src/coreclr/src/inc/corpriv.h
src/coreclr/src/inc/gcinfotypes.h
src/coreclr/src/inc/slist.h
src/coreclr/src/inc/volatile.h
src/coreclr/src/pal/src/map/map.cpp
src/coreclr/src/vm/common.h
src/coreclr/src/zap/common.h

index 1c19ebf..93a5d23 100644 (file)
@@ -21,6 +21,7 @@
 
 #define USE_COM_CONTEXT_DEF
 
+#include <stddef.h>
 #include <stdint.h>
 #include <windows.h>
 
index 782b6ef..311e126 100644 (file)
@@ -448,32 +448,6 @@ public:
     }
 };
 
-
-//
-// Warning: workaround
-// 
-// At the bottom of this file, we are going to #define the "volatile" keyword such that it is illegal
-// to use it.  Unfortunately, VC++ uses the volatile keyword in stddef.h, in the definition of "offsetof".
-// GCC does not use volatile in its definition.
-// 
-// To get around this, we include stddef.h here (even if we're on GCC, for consistency).  We then need
-// to redefine offsetof such that it does not use volatile, if we're building with VC++.
-//
-#include <stddef.h>
-#ifdef _MSC_VER
-#undef offsetof
-#ifdef  _WIN64
-#define offsetof(s,m)   (size_t)( (ptrdiff_t)&reinterpret_cast<const char&>((((s *)0)->m)) )
-#else
-#define offsetof(s,m)   (size_t)&reinterpret_cast<const char&>((((s *)0)->m))
-#endif //_WIN64
-
-// These also use volatile, so we'll include them here.
-//#include <intrin.h>
-//#include <memory>
-
-#endif //_MSC_VER
-
 #define VOLATILE(T) Volatile<T>
 
 #endif //_VOLATILE_H_
index 2270d32..89cd95f 100644 (file)
@@ -1963,9 +1963,6 @@ struct DelegateCtorArgs
 
 // use offsetof to get the offset of the fields above
 #include <stddef.h> // offsetof
-#ifndef offsetof
-#define offsetof(s,m)   ((size_t)&(((s *)0)->m))
-#endif
 
 // Guard-stack cookie for preventing against stack buffer overruns
 typedef SIZE_T GSCookie;
index edd55e9..9641b05 100644 (file)
@@ -309,9 +309,6 @@ typedef enum CorOpenFlagsInternal
 #endif
 
 // %%Classes: ----------------------------------------------------------------
-#ifndef offsetof
-#define offsetof(s,f)   ((ULONG)(&((s*)0)->f))
-#endif
 #ifndef lengthof
 #define lengthof(rg)    (sizeof(rg)/sizeof(rg[0]))
 #endif
index c802d97..ac82dfb 100644 (file)
@@ -331,9 +331,6 @@ inline const char *ReturnKindToString(ReturnKind returnKind)
 
 // we use offsetof to get the offset of a field
 #include <stddef.h> // offsetof
-#ifndef offsetof
-#define offsetof(s,m)   ((size_t)&(((s *)0)->m))
-#endif
 
 enum infoHdrAdjustConstants {
     // Constants
index 2b81f9b..9a75e1d 100644 (file)
@@ -136,14 +136,14 @@ protected:
         }
         else
         {
-#ifdef __GNUC__
-            // GCC defines offsetof to be __builtin_offsetof, which doesn't use the
+#if 1
+            // Newer compilers define offsetof to be __builtin_offsetof, which doesn't use the
             // old-school memory model trick to determine offset.
             const UINT_PTR offset = (((UINT_PTR)&(((T *)0x1000)->*LinkPtr))-0x1000);
             return (T*)__PTR(dac_cast<TADDR>(pLink) - offset);
 #else
-            return (T*)__PTR(dac_cast<TADDR>(pLink) - offsetof(T, *LinkPtr));         
-#endif // __GNUC__
+            return (T*)__PTR(dac_cast<TADDR>(pLink) - offsetof(T, *LinkPtr));
+#endif
         }
     }
 
index ecf9ffe..fa756ef 100644 (file)
@@ -474,32 +474,6 @@ public:
     }
 };
 
-
-//
-// Warning: workaround
-// 
-// At the bottom of this file, we are going to #define the "volatile" keyword such that it is illegal
-// to use it.  Unfortunately, VC++ uses the volatile keyword in stddef.h, in the definition of "offsetof".
-// GCC does not use volatile in its definition.
-// 
-// To get around this, we include stddef.h here (even if we're on GCC, for consistency).  We then need
-// to redefine offsetof such that it does not use volatile, if we're building with VC++.
-//
-#include <stddef.h>
-#ifdef _MSC_VER
-#undef offsetof
-#ifdef  _WIN64
-#define offsetof(s,m)   (size_t)( (ptrdiff_t)&reinterpret_cast<const char&>((((s *)0)->m)) )
-#else
-#define offsetof(s,m)   (size_t)&reinterpret_cast<const char&>((((s *)0)->m))
-#endif //_WIN64
-
-// These also use volatile, so we'll include them here.
-//#include <intrin.h>
-//#include <memory>
-
-#endif //_MSC_VER
-
 //
 // From here on out, we ban the use of the "volatile" keyword.  If you found this while trying to define
 // a volatile variable, go to the top of this file and start reading.
index 7f389ab..7e6c89b 100644 (file)
@@ -31,6 +31,7 @@ Abstract:
 #include "pal/file.hpp"
 #include "pal/malloc.hpp"
 
+#include <stddef.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <sys/mman.h>
index 044ebb0..29311db 100644 (file)
@@ -66,6 +66,7 @@
 
 
 #include <stdint.h>
+#include <stddef.h>
 #include <winwrap.h>
 
 
index c4397c2..df5beac 100644 (file)
 #define __COMMON_H__
 
 #include <stdint.h>
+#include <stddef.h>
 #include <winwrap.h>
 #include <windows.h>
 #include <stdlib.h>
 #include <objbase.h>
-#include <stddef.h>
 #include <float.h>
 #include <limits.h>