Fix visibility and signed comparison issues for GCC (dotnet/coreclr#22586)
authorAdeel Mujahid <adeelbm@outlook.com>
Sun, 17 Feb 2019 01:50:17 +0000 (03:50 +0200)
committerJan Kotas <jkotas@microsoft.com>
Sun, 17 Feb 2019 01:50:17 +0000 (17:50 -0800)
* Fix visibility and signed comparison issues for GCC

* Fix hidden _CLRDataCreateInstance warned by macOS

* Fix indentation in vswprintf/test1

* Change void* to PVOID in implementation files

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

18 files changed:
src/coreclr/src/debug/daccess/daccess.cpp
src/coreclr/src/pal/inc/pal.h
src/coreclr/src/pal/src/exception/remote-unwind.cpp
src/coreclr/src/pal/src/exception/seh.cpp
src/coreclr/src/pal/src/file/path.cpp
src/coreclr/src/pal/src/loader/module.cpp
src/coreclr/src/pal/src/locale/unicode.cpp
src/coreclr/src/pal/src/locale/unicode_data.cpp
src/coreclr/src/pal/src/map/virtual.cpp
src/coreclr/src/pal/src/misc/environ.cpp
src/coreclr/src/pal/src/misc/miscpalapi.cpp
src/coreclr/src/pal/src/numa/numa.cpp
src/coreclr/src/pal/src/safecrt/tsplitpath_s.inl
src/coreclr/src/pal/src/sharedmemory/sharedmemory.cpp
src/coreclr/src/pal/src/thread/process.cpp
src/coreclr/src/pal/src/thread/thread.cpp
src/coreclr/src/pal/tests/palsuite/c_runtime/vswprintf/test1/test1.cpp
src/coreclr/src/pal/tests/palsuite/pal_specific/pal_entrypoint/test1/palstartup.h

index 2a0f2eb..6fbeea8 100644 (file)
@@ -3,7 +3,7 @@
 // See the LICENSE file in the project root for more information.
 //*****************************************************************************
 // File: daccess.cpp
-// 
+//
 
 //
 // ClrDataAccess implementation.
@@ -24,7 +24,7 @@
 #include "dwreport.h"
 #include "primitives.h"
 #include "dbgutil.h"
-#ifdef FEATURE_PAL            
+#ifdef FEATURE_PAL
 #include <dactablerva.h>
 #endif
 
@@ -53,14 +53,14 @@ EXTERN_C BOOL WINAPI DllMain(HANDLE instance, DWORD reason, LPVOID reserved)
     {
         if (g_procInitialized)
         {
-#ifdef FEATURE_PAL            
-            // Double initialization can happen on Unix 
+#ifdef FEATURE_PAL
+            // Double initialization can happen on Unix
             // in case of manual load of DAC shared lib and calling DllMain
-            // not a big deal, we just ignore it. 
+            // not a big deal, we just ignore it.
             return TRUE;
 #else
-            return FALSE;            
-#endif            
+            return FALSE;
+#endif
         }
 
 #ifdef FEATURE_PAL
@@ -85,7 +85,7 @@ EXTERN_C BOOL WINAPI DllMain(HANDLE instance, DWORD reason, LPVOID reserved)
         {
             DeleteCriticalSection(&g_dacCritSec);
         }
-#ifndef FEATURE_PAL 
+#ifndef FEATURE_PAL
         TLS_FreeMasterSlotIndex();
 #endif
         g_procInitialized = false;
@@ -179,7 +179,7 @@ GetFullClassNameFromMetadata(IMDInternalImport* mdImport,
 {
     HRESULT hr;
     LPCUTF8 baseName, namespaceName;
-    
+
     IfFailRet(mdImport->GetNameOfTypeDef(classToken, &baseName, &namespaceName));
     return ns::MakePath(buffer, bufferChars, namespaceName, baseName) ?
         S_OK : E_OUTOFMEMORY;
@@ -785,7 +785,7 @@ SplitName::SplitString(__in_opt PCWSTR fullName)
     }
     else if (!fullName)
     {
-        return E_INVALIDARG; 
+        return E_INVALIDARG;
     }
 
     return SplitFullName(fullName,
@@ -811,7 +811,7 @@ WCHAR* wcrscan(LPCWSTR beg, LPCWSTR end, WCHAR ch)
 }
 
 // This functions allocates a new UTF8 string that contains the classname
-// lying between the current sepName and the previous sepName.  E.g. for a 
+// lying between the current sepName and the previous sepName.  E.g. for a
 // class name of "Outer+middler+inner" when sepName points to the NULL
 // terminator this function will return "inner" in pResult and will update
 // sepName to point to the second '+' character in the string.  When sepName
@@ -830,7 +830,7 @@ HRESULT NextEnclosingClasName(LPCWSTR fullName, __deref_inout LPWSTR& sepName, _
     {
         sepName = wcrscan(fullName, origInnerName, W('/'));
     }
-    
+
     return AllocUtf8(sepName+1, static_cast<ULONG32>(origInnerName-sepName), pResult);
 }
 
@@ -847,7 +847,7 @@ SplitName::FindType(IMDInternalImport* mdInternal)
         return false;
     }
 
-    if ((m_namespaceName == NULL || m_namespaceName[0] == '\0') 
+    if ((m_namespaceName == NULL || m_namespaceName[0] == '\0')
         && (CompareUtf8(COR_MODULE_CLASS, m_typeName, m_nameFlags)==0))
     {
         m_typeToken = TokenFromRid(1, mdtTypeDef);  // <Module> class always has a RID of 1.
@@ -892,7 +892,7 @@ Retry:
     }
     else if (pHead < wszName)
     {
-        // if we did find a token, *and* the class name given 
+        // if we did find a token, *and* the class name given
         // does not specify any enclosing class, that's it
         return true;
     }
@@ -906,7 +906,7 @@ Retry:
         LPUTF8 utf8Name;
 
         while (
-            !bRetry 
+            !bRetry
             && SUCCEEDED(NextEnclosingClasName(wszName, pHead, &utf8Name))
         )
         {
@@ -919,13 +919,13 @@ Retry:
                 return false;
             }
             bRetry = (CompareUtf8(utf8Name, szName, m_nameFlags) != 0);
-            if (!bRetry) 
+            if (!bRetry)
             {
                 // if this is outermost class we need to compare namespaces too
                 if (tkOuter == mdTypeDefNil)
                 {
                     // is this the outermost in the class name, too?
-                    if (pHead < wszName 
+                    if (pHead < wszName
                         && CompareUtf8(m_namespaceName ? m_namespaceName : "", szNS, m_nameFlags) == 0)
                     {
                         delete[] utf8Name;
@@ -1260,29 +1260,29 @@ SplitName::CdNextField(ClrDataAccess* dac,
                        mdFieldDef* tokenRet)
 {
     HRESULT status;
-    
+
     SplitName* split = FROM_CDENUM(SplitName, *handle);
     if (!split)
     {
         return E_INVALIDARG;
     }
-    
+
     FieldDesc* fieldDesc;
-    
+
     while ((fieldDesc = split->m_fieldEnum.Next()))
     {
         if (split->m_syntax != SPLIT_NO_NAME)
         {
             LPCUTF8 fieldName;
-            if (FAILED(fieldDesc->GetName_NoThrow(&fieldName)) || 
+            if (FAILED(fieldDesc->GetName_NoThrow(&fieldName)) ||
                 (split->Compare(split->m_memberName, fieldName) != 0))
             {
                 continue;
             }
         }
-        
+
         split->m_lastField = fieldDesc;
-        
+
         if (fieldFlags != NULL)
         {
             *fieldFlags =
@@ -1302,11 +1302,11 @@ SplitName::CdNextField(ClrDataAccess* dac,
             {
                 return status;
             }
-            
+
             status = ConvertUtf8(
-                szFieldName, 
-                nameBufRetLen, 
-                nameLenRet, 
+                szFieldName,
+                nameBufRetLen,
+                nameLenRet,
                 nameBufRet);
             if (status != S_OK)
             {
@@ -1565,10 +1565,10 @@ DacInstanceManager::Add(DAC_INSTANCE* inst)
     // Assert that we don't add NULL instances. This allows us to assert that found instances
     // are not NULL in DacInstanceManager::Find
     _ASSERTE(inst != NULL);
-    
+
     DWORD nHash = DAC_INSTANCE_HASH(inst->addr);
     HashInstanceKeyBlock* block = m_hash[nHash];
-    
+
     if (!block || block->firstElement == 0)
     {
 
@@ -1581,9 +1581,9 @@ DacInstanceManager::Add(DAC_INSTANCE* inst)
         {
             // We allocate one big memory chunk that has a block for every index of the hash table to
             // improve data locality and reduce the number of allocs. In most cases, a hash bucket will
-            // use only one block, so improving data locality across blocks (i.e. keeping the buckets of the 
-            // hash table together) should help. 
-            newBlock = (HashInstanceKeyBlock*) 
+            // use only one block, so improving data locality across blocks (i.e. keeping the buckets of the
+            // hash table together) should help.
+            newBlock = (HashInstanceKeyBlock*)
                 ClrVirtualAlloc(NULL, HASH_INSTANCE_BLOCK_ALLOC_SIZE*NumItems(m_hash), MEM_COMMIT, PAGE_READWRITE);
         }
         if (!newBlock)
@@ -1591,7 +1591,7 @@ DacInstanceManager::Add(DAC_INSTANCE* inst)
             return NULL;
         }
         if (block)
-        {  
+        {
             // We add the newest block to the start of the list assuming that most accesses are for
             // recently added elements.
             newBlock->next = block;
@@ -1800,7 +1800,7 @@ DacInstanceManager::ReturnAlloc(DAC_INSTANCE* inst)
 
     // If the block is empty after returning the specified instance, that means this block was newly created
     // when this instance was allocated.  We have seen cases where we are asked to allocate a
-    // large chunk of memory only to fail to read the memory from a dump later on, i.e. when both the target 
+    // large chunk of memory only to fail to read the memory from a dump later on, i.e. when both the target
     // address and the size are invalid.  If we keep the allocation, we'll grow the VM size unnecessarily.
     // Thus, release a block if it's empty and if it's not the default size (to avoid thrashing memory).
     // See Dev10 Dbug 812112 for more information.
@@ -1832,14 +1832,14 @@ DacInstanceManager::Find(TADDR addr)
     g_nFindCalls++;
     nStart = GetCycleCount();
 #endif // #if defined(DAC_MEASURE_PERF)
-    
+
     HashInstanceKeyBlock* block = m_hash[DAC_INSTANCE_HASH(addr)];
 
 #if defined(DAC_MEASURE_PERF)
     nEnd = GetCycleCount();
     g_nFindHashTotalTime += nEnd - nStart;
 #endif // #if defined(DAC_MEASURE_PERF)
-    
+
     while (block)
     {
         DWORD nIndex = block->firstElement;
@@ -1856,14 +1856,14 @@ DacInstanceManager::Find(TADDR addr)
 
                 DAC_INSTANCE* inst = block->instanceKeys[nIndex].instance;
 
-                // inst should not be NULL even if the address was superseded. We search 
-                // the entries in the reverse order they were added. So we should have 
+                // inst should not be NULL even if the address was superseded. We search
+                // the entries in the reverse order they were added. So we should have
                 // found the superseding entry before this one. (Of course, if a NULL instance
-                // has been added, this assert is meaningless. DacInstanceManager::Add 
+                // has been added, this assert is meaningless. DacInstanceManager::Add
                 // asserts that NULL instances aren't added.)
-                
+
                 _ASSERTE(inst != NULL);
-                
+
                 return inst;
             }
         }
@@ -1876,7 +1876,7 @@ DacInstanceManager::Find(TADDR addr)
     g_nFindTotalTime += nEnd - nStart;
     if (g_nStackWalk) g_nFindStackTotalTime += nEnd - nStart;
 #endif // #if defined(DAC_MEASURE_PERF)
-    
+
     return NULL;
 }
 #else //DAC_HASHTABLE
@@ -1923,7 +1923,7 @@ void
 DacInstanceManager::Supersede(DAC_INSTANCE* inst)
 {
     _ASSERTE(inst != NULL);
-                
+
     //
     // This instance has been superseded by a larger
     // one and so must be removed from the hash.  However,
@@ -1998,8 +1998,8 @@ DacInstanceManager::Supersede(DAC_INSTANCE* inst)
 }
 #endif // if defined(DAC_HASHTABLE)
 
-// This is the default Flush() called when the DAC cache is invalidated, 
-// e.g. when we continue the debuggee process.  In this case, we want to 
+// This is the default Flush() called when the DAC cache is invalidated,
+// e.g. when we continue the debuggee process.  In this case, we want to
 // save one block of memory to avoid thrashing.  See the usage of m_unusedBlock
 // for more information.
 void DacInstanceManager::Flush(void)
@@ -2050,7 +2050,7 @@ void DacInstanceManager::Flush(bool fSaveBlock)
         while (block)
         {
             next = block->next;
-            if (next) 
+            if (next)
             {
                 delete [] block;
             }
@@ -2159,7 +2159,7 @@ DacInstanceManager::DumpAllInstances(
             for (j = block->firstElement; j < HASH_INSTANCE_BLOCK_NUM_ELEMENTS; j++)
             {
                 inst = block->instanceKeys[j].instance;
-                
+
                 // Only report those we intended to.
                 // So far, only metadata is excluded!
                 //
@@ -2234,7 +2234,7 @@ DacInstanceManager::DumpAllInstances(
        //
        if (inst->noReport == 0)
        {
-           cbTotal += inst->size;                    
+           cbTotal += inst->size;
            HRESULT hr = pCallBack->EnumMemoryRegion(TO_CDADDR(inst->addr), inst->size);
            if (hr == COR_E_OPERATIONCANCELED)
            {
@@ -2272,7 +2272,7 @@ DacInstanceManager::FindInstanceBlock(DAC_INSTANCE* inst)
     return NULL;
 }
 
-// If fSaveBlock is false, free all blocks of allocated memory.  Otherwise, 
+// If fSaveBlock is false, free all blocks of allocated memory.  Otherwise,
 // free all blocks except the one we save to avoid thrashing memory.
 // Callers very frequently flush repeatedly with little memory needed in DAC
 // so this avoids wasteful repeated allocations/deallocations.
@@ -2320,7 +2320,7 @@ namespace serialization { namespace bin {
 
     //========================================================================
     // Support functions for binary serialization of simple types to a buffer:
-    //   - raw_size() returns the size in bytes of the binary representation 
+    //   - raw_size() returns the size in bytes of the binary representation
     //                of a value.
     //   - raw_serialize() copies the binary representation of a value into a
     //                buffer.
@@ -2347,7 +2347,7 @@ namespace serialization { namespace bin {
     { // determines whether _Ty is blittable
     };
 
-    // allow types to declare themselves blittable by including a static bool 
+    // allow types to declare themselves blittable by including a static bool
     // member "is_blittable".
     template <typename _Ty>
     struct is_blittable<_Ty, typename std::enable_if<_Ty::is_blittable>::type>
@@ -2369,7 +2369,7 @@ namespace serialization { namespace bin {
     class Traits
     {
     public:
-        static FORCEINLINE size_t 
+        static FORCEINLINE size_t
         raw_size(const T & val)
         {
             static_assert(false, "Non-blittable types need explicit specializations");
@@ -2393,19 +2393,19 @@ namespace serialization { namespace bin {
         // raw_size() returns the size in bytes of the binary representation of a
         //                value.
         //
-        static FORCEINLINE size_t 
+        static FORCEINLINE size_t
         raw_size(const T & val)
-        { 
-            return sizeof(T); 
+        {
+            return sizeof(T);
         }
 
         //
-        // raw_serialize() copies the binary representation of a value into a 
+        // raw_serialize() copies the binary representation of a value into a
         //     "dest" buffer that has "destSize" bytes available.
-        // Returns raw_size(val), or ErrOverflow if the buffer does not have  
+        // Returns raw_size(val), or ErrOverflow if the buffer does not have
         //     enough space to accommodate "val".
         //
-        static FORCEINLINE size_t 
+        static FORCEINLINE size_t
         raw_serialize(BYTE* dest, size_t destSize, const T & val)
         {
             size_t cnt = raw_size(val);
@@ -2421,12 +2421,12 @@ namespace serialization { namespace bin {
         }
 
         //
-        // raw_deserialize() generates a value "val" from its binary 
+        // raw_deserialize() generates a value "val" from its binary
         //     representation in a buffer "src".
-        // Returns raw_size(val), or ErrOverflow if the buffer does not have  
+        // Returns raw_size(val), or ErrOverflow if the buffer does not have
         //     enough space to accommodate "val".
         //
-        static FORCEINLINE size_t 
+        static FORCEINLINE size_t
         raw_deserialize(T & val, const BYTE* src, size_t srcSize)
         {
             size_t cnt = raw_size(*(T*)src);
@@ -2450,13 +2450,13 @@ namespace serialization { namespace bin {
     class Traits<LPCUTF8>
     {
     public:
-        static FORCEINLINE size_t 
+        static FORCEINLINE size_t
         raw_size(const LPCUTF8 & val)
         {
             return strlen(val) + 1;
         }
 
-        static FORCEINLINE size_t 
+        static FORCEINLINE size_t
         raw_serialize(BYTE* dest, size_t destSize, const LPCUTF8 & val)
         {
             size_t cnt = raw_size(val);
@@ -2471,7 +2471,7 @@ namespace serialization { namespace bin {
             return cnt;
         }
 
-        static FORCEINLINE size_t 
+        static FORCEINLINE size_t
         raw_deserialize(LPCUTF8 & val, const BYTE* src, size_t srcSize)
         {
             size_t cnt = strnlen((LPCUTF8)src, srcSize) + 1;
@@ -2492,14 +2492,14 @@ namespace serialization { namespace bin {
 
     //
     // Specialization for SString.
-    // SString serialization/deserialization is performed to/from a UTF8 
+    // SString serialization/deserialization is performed to/from a UTF8
     // string.
     //
     template<>
     class Traits<SString>
     {
     public:
-        static FORCEINLINE size_t 
+        static FORCEINLINE size_t
         raw_size(const SString & val)
         {
             StackSString s;
@@ -2508,10 +2508,10 @@ namespace serialization { namespace bin {
             return s.GetCount() + 1;
         }
 
-        static FORCEINLINE size_t 
+        static FORCEINLINE size_t
         raw_serialize(BYTE* dest, size_t destSize, const SString & val)
         {
-            // instead of calling raw_size() we inline it here, so we can reuse 
+            // instead of calling raw_size() we inline it here, so we can reuse
             // the UTF8 string obtained below as an argument to memcpy.
 
             StackSString s;
@@ -2529,7 +2529,7 @@ namespace serialization { namespace bin {
             return cnt;
         }
 
-        static FORCEINLINE size_t 
+        static FORCEINLINE size_t
         raw_deserialize(SString & val, const BYTE* src, size_t srcSize)
         {
             size_t cnt = strnlen((LPCUTF8)src, srcSize) + 1;
@@ -2616,7 +2616,7 @@ namespace serialization { namespace bin {
         }
 
         inline size_t GetPos() const
-        { 
+        {
             return crt;
         }
 
@@ -2626,8 +2626,8 @@ namespace serialization { namespace bin {
         }
 
         inline StreamBuffState State() const
-        { 
-            return sbs; 
+        {
+            return sbs;
         }
 
     private:
@@ -2671,8 +2671,8 @@ namespace serialization { namespace bin {
         }
 
         inline size_t GetPos() const
-        { 
-            return crt; 
+        {
+            return crt;
         }
 
         inline BOOL operator!() const
@@ -2688,7 +2688,7 @@ namespace serialization { namespace bin {
     private:
         size_t          buffsize; // size of buffer
         const BYTE *    buff;     // buffer to read from
-        size_t          crt;      // current offset in buffer      
+        size_t          crt;      // current offset in buffer
         StreamBuffState sbs;      // current state
     };
 
@@ -2707,16 +2707,16 @@ typedef bool (*Reserve_Fnptr)(DWORD size, void * writeState);
 
 //
 // DacEENamesStreamable
-//   Stores EE struct* -> Name mappings and streams them to a 
+//   Stores EE struct* -> Name mappings and streams them to a
 //   streambuf when asked
 //
 class DacEENamesStreamable
 {
 private:
     // the hash map storing the interesting mappings of EE* -> Names
-    MapSHash< TADDR, SString, 
-              NoRemoveSHashTraits < 
-                  NonDacAwareSHashTraits< MapSHashTraits <TADDR, SString> > 
+    MapSHash< TADDR, SString,
+              NoRemoveSHashTraits <
+                  NonDacAwareSHashTraits< MapSHashTraits <TADDR, SString> >
             > > m_hash;
 
     Reserve_Fnptr  m_reserveFn;
@@ -2755,18 +2755,18 @@ public:
         return m_reserveFn(size, m_writeState);
     }
 
-    // Adds a new mapping from an EE struct pointer (e.g. MethodDesc*) to 
+    // Adds a new mapping from an EE struct pointer (e.g. MethodDesc*) to
     // its name
     bool AddEEName(TADDR taEE, const SString & eeName)
     {
         _ASSERTE(m_reserveFn != NULL && m_writeState != NULL);
 
-        // as a micro-optimization convert to Utf8 here as both raw_size and 
-        // raw_serialize are optimized for Utf8... 
+        // as a micro-optimization convert to Utf8 here as both raw_size and
+        // raw_serialize are optimized for Utf8...
         StackSString seeName;
         eeName.ConvertToUTF8(seeName);
 
-        DWORD size = (DWORD)(serialization::bin::raw_size(taEE) + 
+        DWORD size = (DWORD)(serialization::bin::raw_size(taEE) +
                              serialization::bin::raw_size(seeName));
 
         // notify owner of the amount of space needed in the buffer
@@ -2785,7 +2785,7 @@ public:
     // Finds an EE name from a target address of an EE struct (e.g.
     // MethodDesc*)
     bool FindEEName(TADDR taEE, SString & eeName) const
-    { 
+    {
         return m_hash.Lookup(taEE, &eeName) == TRUE;
     }
 
@@ -2843,12 +2843,12 @@ public:
 
 //================================================================================
 // This class enables two scenarios:
-//   1. When debugging a triage/mini-dump the class is initialized with a valid 
-//      buffer in taMiniMetaDataBuff. Afterwards one can call MdCacheGetEEName to 
+//   1. When debugging a triage/mini-dump the class is initialized with a valid
+//      buffer in taMiniMetaDataBuff. Afterwards one can call MdCacheGetEEName to
 //      retrieve the name associated with a MethodDesc*.
 //   2. When generating a dump one must follow this sequence:
-//      a. Initialize the DacStreamManager passing a valid (if the current 
-//         debugging target is a triage/mini-dump) or empty buffer (if the 
+//      a. Initialize the DacStreamManager passing a valid (if the current
+//         debugging target is a triage/mini-dump) or empty buffer (if the
 //         current target is a live processa full or a heap dump)
 //      b. Call PrepareStreamsForWriting() before starting enumerating any memory
 //      c. Call MdCacheAddEEName() anytime we enumerate an EE structure of interest
@@ -2857,11 +2857,11 @@ public:
 class DacStreamManager
 {
 public:
-    enum eReadOrWrite 
-    { 
+    enum eReadOrWrite
+    {
         eNone,    // the stream doesn't exist (target is a live process/full/heap dump)
         eRO,      // the stream exists and we've read it (target is triage/mini-dump)
-        eWO,      // the stream doesn't exist but we're creating it 
+        eWO,      // the stream doesn't exist but we're creating it
                   // (e.g. to save a minidump from the current debugging session)
         eRW       // the stream exists but we're generating another triage/mini-dump
     };
@@ -2908,7 +2908,7 @@ public:
         else // m_rw == eWO
         {
             // this is a second invocation from a possibly live process
-            // clean up the map since the callstacks/exceptions may be different 
+            // clean up the map since the callstacks/exceptions may be different
             m_EENames.Clear();
         }
 
@@ -2983,11 +2983,11 @@ private:
         HRESULT hr = S_OK;
 
         StreamsHeader hdr;
-        DacReadAll(dac_cast<TADDR>(m_MiniMetaDataBuffAddress), 
+        DacReadAll(dac_cast<TADDR>(m_MiniMetaDataBuffAddress),
                    &hdr, sizeof(hdr), true);
 
         // when the DAC looks at a triage dump or minidump generated using
-        // a "minimetadata" enabled DAC, buff will point to a serialized 
+        // a "minimetadata" enabled DAC, buff will point to a serialized
         // representation of a methoddesc->method name hashmap.
         if (hdr.dwSig == sig)
         {
@@ -2996,7 +2996,7 @@ private:
             hr = S_OK;
         }
         else
-        // when the DAC initializes this for the case where the target is 
+        // when the DAC initializes this for the case where the target is
         // (a) a live process, or (b) a full dump, buff will point to a
         // zero initialized memory region (allocated w/ VirtualAlloc)
         if (hdr.dwSig == 0 && hdr.dwTotalSize == 0 && hdr.dwCntStreams == 0)
@@ -3011,7 +3011,7 @@ private:
         }
 
         BYTE * buff = new BYTE[m_MiniMetaDataBuffSizeMax];
-        DacReadAll(dac_cast<TADDR>(m_MiniMetaDataBuffAddress), 
+        DacReadAll(dac_cast<TADDR>(m_MiniMetaDataBuffAddress),
                    buff, m_MiniMetaDataBuffSizeMax, true);
 
         m_rawBuffer = buff;
@@ -3119,17 +3119,17 @@ ClrDataAccess::ClrDataAccess(ICorDebugDataTarget * pTarget, ICLRDataTarget * pLe
 {
     SUPPORTS_DAC_HOST_ONLY;     // ctor does no marshalling - don't check with DacCop
 
-    /* 
+    /*
      *  Stash the various forms of the new ICorDebugDataTarget interface
      */
     m_pTarget = pTarget;
     m_pTarget->AddRef();
-    
+
     HRESULT hr;
 
     hr = m_pTarget->QueryInterface(__uuidof(ICorDebugMutableDataTarget),
                                 (void**)&m_pMutableTarget);
-    
+
     if (hr != S_OK)
     {
         // Create a target which always fails the write requests with CORDBG_E_TARGET_READONLY
@@ -3137,7 +3137,7 @@ ClrDataAccess::ClrDataAccess(ICorDebugDataTarget * pTarget, ICLRDataTarget * pLe
         m_pMutableTarget->AddRef();
     }
 
-    /* 
+    /*
      * If we have a legacy target, it means we're providing compatibility for code that used
      * the old ICLRDataTarget interfaces.  There are still a few things (like metadata location,
      * GetImageBase, and VirtualAlloc) that the implementation may use which we haven't superseded
@@ -3145,7 +3145,7 @@ ClrDataAccess::ClrDataAccess(ICorDebugDataTarget * pTarget, ICLRDataTarget * pLe
      * Any functionality that does exist in ICorDebugDataTarget is accessed from that interface
      * using the DataTargetAdapter on top of the legacy interface (to unify the calling code).
      * Eventually we may expose all functionality we need using ICorDebug (possibly a private
-     * interface for things like VirtualAlloc), at which point we can stop using the legacy interfaces 
+     * interface for things like VirtualAlloc), at which point we can stop using the legacy interfaces
      * completely (except in the DataTargetAdapter).
      */
     m_pLegacyTarget = NULL;
@@ -3156,7 +3156,7 @@ ClrDataAccess::ClrDataAccess(ICorDebugDataTarget * pTarget, ICLRDataTarget * pLe
     if (pLegacyTarget != NULL)
     {
         m_pLegacyTarget = pLegacyTarget;
-        
+
         m_pLegacyTarget->AddRef();
 
         m_pLegacyTarget->QueryInterface(__uuidof(ICLRDataTarget2), (void**)&m_pLegacyTarget2);
@@ -3188,7 +3188,7 @@ ClrDataAccess::ClrDataAccess(ICorDebugDataTarget * pTarget, ICLRDataTarget * pLe
     m_streams = NULL;
 #endif // FEATURE_MINIMETADATA_IN_TRIAGEDUMPS
 
-    // Target consistency checks are disabled by default.  
+    // Target consistency checks are disabled by default.
     // See code:ClrDataAccess::SetTargetConsistencyChecks for details.
     m_fEnableTargetConsistencyAsserts = false;
 
@@ -3199,7 +3199,7 @@ ClrDataAccess::ClrDataAccess(ICorDebugDataTarget * pTarget, ICLRDataTarget * pLe
     }
 
     // Verification asserts are disabled by default because some debuggers (cdb/windbg) probe likely locations
-    // for DAC and having this assert pop up all the time can be annoying.  We let derived classes enable 
+    // for DAC and having this assert pop up all the time can be annoying.  We let derived classes enable
     // this if they want.  It can also be overridden at run-time with COMPlus_DbgDACAssertOnMismatch,
     // see ClrDataAccess::VerifyDlls for details.
     m_fEnableDllVerificationAsserts = false;
@@ -3210,7 +3210,7 @@ ClrDataAccess::ClrDataAccess(ICorDebugDataTarget * pTarget, ICLRDataTarget * pLe
 ClrDataAccess::~ClrDataAccess(void)
 {
     SUPPORTS_DAC_HOST_ONLY;
-    
+
 #ifdef FEATURE_MINIMETADATA_IN_TRIAGEDUMPS
     if (m_streams)
     {
@@ -4494,7 +4494,7 @@ ClrDataAccess::TranslateExceptionRecordToNotification(
             }
             break;
         }
-        
+
         case DACNotify::EXCEPTION_NOTIFICATION:
         {
             TADDR threadPtr;
@@ -5417,7 +5417,7 @@ ClrDataAccess::FollowStub2(
 #pragma warning(push)
 #pragma warning(disable:4297)
 #endif // _MSC_VER
-STDMETHODIMP 
+STDMETHODIMP
 ClrDataAccess::GetGcNotification(GcEvtArgs* gcEvtArgs)
 {
     HRESULT status;
@@ -5465,7 +5465,7 @@ ClrDataAccess::GetGcNotification(GcEvtArgs* gcEvtArgs)
     return status;
 }
 
-STDMETHODIMP 
+STDMETHODIMP
 ClrDataAccess::SetGcNotification(IN GcEvtArgs gcEvtArgs)
 {
     HRESULT status;
@@ -5566,8 +5566,8 @@ ClrDataAccess::Initialize(void)
     }
 
     //
-    // Get the current DLL base for mscorwks globals. 
-    // In case of multiple-CLRs, there may be multiple dlls named "mscorwks". 
+    // Get the current DLL base for mscorwks globals.
+    // In case of multiple-CLRs, there may be multiple dlls named "mscorwks".
     // code:OpenVirtualProcess can take the base address (clrInstanceId) to select exactly
     // which CLR to is being target. If so, m_globalBase will already be set.
     //
@@ -5599,10 +5599,10 @@ ClrDataAccess::Initialize(void)
         s_procInit = true;
     }
 
-    // 
+    //
     // DAC is now setup and ready to use
-    // 
-   
+    //
+
     // Do some validation
     IfFailRet(VerifyDlls());
 
@@ -5618,7 +5618,7 @@ ClrDataAccess::Initialize(void)
     CoreClrCallbacks cccallbacks;
     cccallbacks.m_hmodCoreCLR               = (HINSTANCE)m_globalBase; // Base address of the runtime in the target process
     cccallbacks.m_pfnIEE                    = NULL;
-    cccallbacks.m_pfnGetCORSystemDirectory  = NULL;    
+    cccallbacks.m_pfnGetCORSystemDirectory  = NULL;
     cccallbacks.m_pfnGetCLRFunction         = NULL;
     InitUtilcode(cccallbacks);
 
@@ -5730,7 +5730,7 @@ ClrDataAccess::GetJitHelperName(
 #ifdef FEATURE_PAL
     if (!dynamicHelpersOnly)
 #else
-    if (!dynamicHelpersOnly && g_runtimeLoadedBaseAddress <= address && 
+    if (!dynamicHelpersOnly && g_runtimeLoadedBaseAddress <= address &&
             address < g_runtimeLoadedBaseAddress + g_runtimeVirtualSize)
 #endif // FEATURE_PAL
     {
@@ -5921,8 +5921,8 @@ ClrDataAccess::RawGetMethodName(
         _ASSERTE(wszStubManagerName != NULL);
 
         int result = _snwprintf_s(
-            symbolBuf, 
-            bufLen, 
+            symbolBuf,
+            bufLen,
             _TRUNCATE,
             s_wszFormatNameWithStubManager,
             wszStubManagerName,                                         // Arg 1 = stub name
@@ -5985,7 +5985,7 @@ NameFromMethodDesc:
         static WCHAR s_wszFormatNameAddressOnly[] = W("CLRStub@%I64x");
 
         int result = _snwprintf_s(
-            symbolBuf, 
+            symbolBuf,
             bufLen,
             _TRUNCATE,
             s_wszFormatNameAddressOnly,
@@ -6199,7 +6199,7 @@ ClrDataAccess::GetMethodNativeMap(MethodDesc* methodDesc,
 //       pModule   - pointer to the module for the function
 //       memberRef - metadata token for the function
 // Return Value:
-//       MethodDesc for the function 
+//       MethodDesc for the function
 MethodDesc * ClrDataAccess::FindLoadedMethodRefOrDef(Module* pModule,
     mdToken memberRef)
 {
@@ -6229,13 +6229,13 @@ MethodDesc * ClrDataAccess::FindLoadedMethodRefOrDef(Module* pModule,
 // If you specify that you expect success, any failure will cause ReportMem to
 // return false.  If you do not expect success, true is always returned.
 // This function only throws when all dump collection should be cancelled.
-// 
+//
 // Arguments:
 //     addr - the starting target address for the memory to report
 //     size - the length (in bytes) to report
 //     fExpectSuccess - if true (the default), then we expect that this region of memory
 //                      should be fully readable.  Any read errors indicate a corrupt target.
-//                      
+//
 bool ClrDataAccess::ReportMem(TADDR addr, TSIZE_T size, bool fExpectSuccess /*= true*/)
 {
     SUPPORTS_DAC_HOST_ONLY;
@@ -6243,15 +6243,15 @@ bool ClrDataAccess::ReportMem(TADDR addr, TSIZE_T size, bool fExpectSuccess /*=
     // This block of code is to help debugging blocks that we report
     // to minidump/heapdump. You can set break point here to view the static
     // variable to figure out the size of blocks that we are reporting.
-    // Most useful is set conditional break point to catch large chuck of 
-    // memory. We will leave it here for all builds. 
-    //         
+    // Most useful is set conditional break point to catch large chuck of
+    // memory. We will leave it here for all builds.
+    //
     static TADDR debugAddr;
     static TSIZE_T debugSize;
     debugAddr = addr;
     debugSize = size;
 
-    HRESULT status;        
+    HRESULT status;
     if (!addr || addr == (TADDR)-1 || !size)
     {
         if (fExpectSuccess)
@@ -6262,15 +6262,15 @@ bool ClrDataAccess::ReportMem(TADDR addr, TSIZE_T size, bool fExpectSuccess /*=
 
     //
     // Try and sanity-check the reported region of memory
-    // 
+    //
 #ifdef _DEBUG
     // in debug builds, sanity-check all reports
-    const TSIZE_T k_minSizeToCheck = 1; 
+    const TSIZE_T k_minSizeToCheck = 1;
 #else
     // in retail builds, only sanity-check larger chunks which have the potential to waste a
     // lot of time and/or space.  This avoids the overhead of checking for the majority of
     // memory regions (which are small).
-    const TSIZE_T k_minSizeToCheck = 1024;  
+    const TSIZE_T k_minSizeToCheck = 1024;
 #endif
     if (size >= k_minSizeToCheck)
     {
@@ -6282,7 +6282,7 @@ bool ClrDataAccess::ReportMem(TADDR addr, TSIZE_T size, bool fExpectSuccess /*=
                 // a module image), so just skip this block silently.
                 // Note that the EnumMemoryRegion callback won't necessarily do anything if any part of
                 // the region is unreadable, and so there is no point in calling it.  For cases where we expect
-                // the read might fail, but we want to report any partial blocks, we have to break up the region 
+                // the read might fail, but we want to report any partial blocks, we have to break up the region
                 // into pages and try reporting each page anyway
                 return true;
             }
@@ -6300,12 +6300,12 @@ bool ClrDataAccess::ReportMem(TADDR addr, TSIZE_T size, bool fExpectSuccess /*=
     // Minidumps should never contain data structures that are anywhere near 4MB.  If we see this, it's
     // probably due to memory corruption.  To keep the dump small, we'll truncate the block.  Note that
     // the size to which the block is truncated is pretty unique, so should be good evidence in a dump
-    // that this has happened.  
+    // that this has happened.
     // Note that it's hard to say what a good value would be here, or whether we should dump any of the
     // data structure at all.  Hopefully experience will help guide this going forward.
     // @dbgtodo : Extend dump-gathering API to allow a dump-log to be included.
     const TSIZE_T kMaxMiniDumpRegion = 4*1024*1024 - 3;    // 4MB-3
-    if( size > kMaxMiniDumpRegion 
+    if( size > kMaxMiniDumpRegion
         && (m_enumMemFlags == CLRDATA_ENUM_MEM_MINI
           || m_enumMemFlags == CLRDATA_ENUM_MEM_TRIAGE))
     {
@@ -6313,11 +6313,11 @@ bool ClrDataAccess::ReportMem(TADDR addr, TSIZE_T size, bool fExpectSuccess /*=
         size = kMaxMiniDumpRegion;
     }
 
-    // track the total memory reported. 
+    // track the total memory reported.
     m_cbMemoryReported += size;
-    
+
     // ICLRData APIs take only 32-bit sizes.  In practice this will almost always be sufficient, but
-    // in theory we might have some >4GB ranges on large 64-bit processes doing a heap dump 
+    // in theory we might have some >4GB ranges on large 64-bit processes doing a heap dump
     // (for example, the code:LoaderHeap).  If necessary, break up the reporting into maximum 4GB
     // chunks so we can use the existing API.
     // @dbgtodo : ICorDebugDataTarget should probably use 64-bit sizes
@@ -6345,7 +6345,7 @@ bool ClrDataAccess::ReportMem(TADDR addr, TSIZE_T size, bool fExpectSuccess /*=
         // If the return value of EnumMemoryRegion is COR_E_OPERATIONCANCELED,
         // it means that user has requested that the minidump gathering be canceled.
         // To do this we throw an exception which is caught in EnumMemoryRegionsWrapper.
-        if (status == COR_E_OPERATIONCANCELED) 
+        if (status == COR_E_OPERATIONCANCELED)
         {
             ThrowHR(status);
         }
@@ -6361,23 +6361,23 @@ bool ClrDataAccess::ReportMem(TADDR addr, TSIZE_T size, bool fExpectSuccess /*=
 
 //
 // DacUpdateMemoryRegion - updates/poisons a region of memory of generated dump
-// 
+//
 // Parameters:
 //   addr           - target address of the beginning of the memory region
 //   bufferSize     - number of bytes to update/poison
 //   buffer         - data to be written at given target address
-//                     
+//
 bool ClrDataAccess::DacUpdateMemoryRegion(TADDR addr, TSIZE_T bufferSize, BYTE* buffer)
 {
     SUPPORTS_DAC_HOST_ONLY;
 
-    HRESULT status;        
+    HRESULT status;
     if (!addr || addr == (TADDR)-1 || !bufferSize)
     {
         return false;
     }
 
-    // track the total memory reported. 
+    // track the total memory reported.
     m_cbMemoryReported += bufferSize;
 
     if (m_updateMemCb == NULL)
@@ -6397,13 +6397,13 @@ bool ClrDataAccess::DacUpdateMemoryRegion(TADDR addr, TSIZE_T bufferSize, BYTE*
 
 //
 // Check whether a region of target memory is fully readable.
-// 
+//
 // Arguments:
 //     addr    The base target address of the region
 //     size    The size of the region to analyze
-//     
+//
 // Return value:
-//     True if the entire regions appears to be readable, false otherwise. 
+//     True if the entire regions appears to be readable, false otherwise.
 //
 // Notes:
 //     The motivation here is that reporting large regions of unmapped address space to dbgeng can result in
@@ -6411,9 +6411,9 @@ bool ClrDataAccess::DacUpdateMemoryRegion(TADDR addr, TSIZE_T bufferSize, BYTE*
 //     memory is corrupt, and we enumerate a data structure with a dynamic size.  Ideally we would just spec
 //     the ICLRDataEnumMemoryRegionsCallback API to require the client to fail if it detects an unmapped
 //     memory address in the region.  However, we can't change the existing dbgeng code, so for now we'll
-//     rely on this heuristic here.  
+//     rely on this heuristic here.
 //     @dbgtodo : Try and get the dbg team to change their EnumMemoryRegion behavior.  See DevDiv Bugs 6265
-//     
+//
 bool ClrDataAccess::IsFullyReadable(TADDR taBase, TSIZE_T dwSize)
 {
     // The only way we have to verify that a memory region is readable is to try reading it in it's
@@ -6478,7 +6478,7 @@ ClrDataAccess::GetHostJitNotificationTable()
     return m_jitNotificationTable;
 }
 
-GcNotification*  
+GcNotification*
 ClrDataAccess::GetHostGcNotificationTable()
 {
     if (m_gcNotificationTable == NULL)
@@ -6523,7 +6523,7 @@ ClrDataAccess::GetMetaDataFileInfoFromPEFile(PEFile *pPEFile,
             dwRvaHint = pDir->VirtualAddress;
             dwDataSize = pDir->Size;
         }
-    
+
     }
     if (pDir == NULL || pDir->Size == 0)
     {
@@ -6545,7 +6545,7 @@ ClrDataAccess::GetMetaDataFileInfoFromPEFile(PEFile *pPEFile,
         }
     }
 
-    // Do not fail if path can not be read. Triage dumps don't have paths and we want to fallback 
+    // Do not fail if path can not be read. Triage dumps don't have paths and we want to fallback
     // on searching metadata from IL image.
     mdImage->GetPath().DacGetUnicode(cchFilePath, wszFilePath, &uniPathChars);
 
@@ -6620,14 +6620,14 @@ bool ClrDataAccess::GetILImageNameFromNgenImage( LPCWSTR ilExtension,
     _wcslwr_s(wszFilePath, cchFilePath);
     // Find the "ni.dll" or "ni.winmd" extension (check for PEFile isWinRT something to know when is winmd or not.
     // If none exists use NGEN image name.
-    // 
+    //
     const WCHAR* ngenExtension[] = {W("ni.dll"), W("ni.winmd")};
 
     for (unsigned i = 0; i < COUNTOF(ngenExtension); ++i)
     {
         if (wcslen(ilExtension) > wcslen(ngenExtension[i]))
         {
-            // We should not have IL image name bigger than NGEN image. 
+            // We should not have IL image name bigger than NGEN image.
             // It will not fit inside wszFilePath.
             continue;
         }
@@ -6636,16 +6636,16 @@ bool ClrDataAccess::GetILImageNameFromNgenImage( LPCWSTR ilExtension,
         {
             LPWSTR  wszNextFileExtension = wszFileExtension;
             // Find last occurence
-            do 
+            do
             {
                 wszFileExtension = wszNextFileExtension;
                 wszNextFileExtension = wcsstr(wszFileExtension + 1, ngenExtension[i]);
             } while (wszNextFileExtension != 0);
-        
+
             // Overwrite ni.dll or ni.winmd with ilExtension(.dll, .winmd)
             if (!memcpy_s(wszFileExtension,
-                           wcslen(ngenExtension[i])*sizeof(WCHAR), 
-                           ilExtension, 
+                           wcslen(ngenExtension[i])*sizeof(WCHAR),
+                           ilExtension,
                            wcslen(ilExtension)*sizeof(WCHAR)))
             {
                 wszFileExtension[wcslen(ilExtension)] = '\0';
@@ -6771,7 +6771,7 @@ ClrDataAccess::GetMetaDataFromHost(PEFile* peFile,
         {
             goto ErrExit;
         }
-        
+
 #if defined(FEATURE_CORESYSTEM)
         const WCHAR* ilExtension[] = {W("dll"), W("winmd")};
         WCHAR ngenImageName[MAX_LONGPATH] = {0};
@@ -6983,40 +6983,40 @@ ClrDataAccess::GetMDImport(const PEFile* peFile, const ReflectionModule* reflect
 }
 
 
-// 
+//
 // Set whether inconsistencies in the target should raise asserts.
 // This overrides the default initial setting.
-// 
+//
 // Arguments:
 //     fEnableAsserts - whether ASSERTs in dacized code should be enabled
-// 
+//
 
-void ClrDataAccess::SetTargetConsistencyChecks(bool fEnableAsserts) 
-{ 
+void ClrDataAccess::SetTargetConsistencyChecks(bool fEnableAsserts)
+{
     LIMITED_METHOD_DAC_CONTRACT;
     m_fEnableTargetConsistencyAsserts = fEnableAsserts;
 }
 
 //
 // Get whether inconsistencies in the target should raise asserts.
-// 
+//
 // Return value:
 //     whether ASSERTs in dacized code should be enabled
-//     
+//
 // Notes:
 //     The implementation of ASSERT accesses this via code:DacTargetConsistencyAssertsEnabled
-//     
+//
 //     By default, this is disabled, unless COMPlus_DbgDACEnableAssert is set (see code:ClrDataAccess::ClrDataAccess).
 //     This is necessary for compatibility.  For example, SOS expects to be able to scan for
 //     valid MethodTables etc. (which may cause ASSERTs), and also doesn't want ASSERTs when working
 //     with targets with corrupted memory.
-//     
+//
 //     Calling code:ClrDataAccess::SetTargetConsistencyChecks overrides the default setting.
-//     
+//
 bool ClrDataAccess::TargetConsistencyAssertsEnabled()
-{ 
+{
     LIMITED_METHOD_DAC_CONTRACT;
-    return m_fEnableTargetConsistencyAsserts; 
+    return m_fEnableTargetConsistencyAsserts;
 }
 
 #ifdef FEATURE_CORESYSTEM
@@ -7024,15 +7024,15 @@ bool ClrDataAccess::TargetConsistencyAssertsEnabled()
 #define time_t __time32_t
 #endif
 
-// 
+//
 // VerifyDlls - Validate that the mscorwks in the target matches this version of mscordacwks
 // Only done on Windows and Mac builds at the moment.
 // See code:CordbProcess::CordbProcess#DBIVersionChecking for more information regarding version checking.
-// 
+//
 HRESULT ClrDataAccess::VerifyDlls()
 {
 #ifndef FEATURE_PAL
-    // Provide a knob for disabling this check if we really want to try and proceed anyway with a 
+    // Provide a knob for disabling this check if we really want to try and proceed anyway with a
     // DAC mismatch.  DAC behavior may be arbitrarily bad - globals probably won't be at the same
     // address, data structures may be laid out differently, etc.
     if (CLRConfig::GetConfigValue(CLRConfig::INTERNAL_DbgDACSkipVerifyDlls))
@@ -7052,13 +7052,13 @@ HRESULT ClrDataAccess::VerifyDlls()
     DAC_ENTER();
     EX_TRY
     {
-        // Note that we don't need to worry about ensuring the image memory read by this code 
-        // is saved in a minidump.  Managed minidump debugging already requires that you have 
+        // Note that we don't need to worry about ensuring the image memory read by this code
+        // is saved in a minidump.  Managed minidump debugging already requires that you have
         // the full mscorwks.dll available at debug time (eg. windbg won't even load DAC without it).
         PEDecoder pedecoder(dac_cast<PTR_VOID>(m_globalBase));
 
         // We use the first codeview debug directory entry since this should always refer to the single
-        // PDB for mscorwks.dll.  
+        // PDB for mscorwks.dll.
         const UINT k_maxDebugEntries = 32;  // a reasonable upper limit in case of corruption
         for( UINT i = 0; i < k_maxDebugEntries; i++)
         {
@@ -7068,7 +7068,7 @@ HRESULT ClrDataAccess::VerifyDlls()
             if (pDebugEntry == NULL)
                 break;
 
-            // Ignore non-codeview entries.  Some scenarios (eg. optimized builds), there may be extra 
+            // Ignore non-codeview entries.  Some scenarios (eg. optimized builds), there may be extra
             // debug directory entries at the end of some other type.
             if (pDebugEntry->Type == IMAGE_DEBUG_TYPE_CODEVIEW)
             {
@@ -7106,7 +7106,7 @@ HRESULT ClrDataAccess::VerifyDlls()
 #ifdef _DEBUG
         // Check if verbose asserts are enabled.  The default is up to the specific instantiation of
         // ClrDataAccess, but can be overridden (in either direction) by a COMPlus_ knob.
-        // Note that we check this knob every time because it may be handy to turn it on in 
+        // Note that we check this knob every time because it may be handy to turn it on in
         // the environment mid-flight.
         DWORD dwAssertDefault = m_fEnableDllVerificationAsserts ? 1 : 0;
         if (REGUTIL::GetConfigDWORD_DontUse_(CLRConfig::INTERNAL_DbgDACAssertOnMismatch, dwAssertDefault))
@@ -7114,7 +7114,7 @@ HRESULT ClrDataAccess::VerifyDlls()
             // Output a nice error message that contains the timestamps in string format.
             time_t actualTime = timestamp;
             char szActualTime[30];
-            ctime_s(szActualTime, sizeof(szActualTime), &actualTime);  
+            ctime_s(szActualTime, sizeof(szActualTime), &actualTime);
 
             time_t expectedTime = g_dacTableInfo.dwID0;
             char szExpectedTime[30];
@@ -7307,7 +7307,7 @@ ClrDataAccess::GetDacGlobals()
 
     // Read the header
     struct DacTableHeader header;
-    
+
     // We currently expect the header to be 2 32-bit values and 1 16-byte value,
     // make sure there is no packing going on or anything.
     static_assert_no_msg(sizeof(DacTableHeader) == 2 * 4 + 16);
@@ -7380,9 +7380,9 @@ Exit:
 #undef MAKEINTRESOURCE
 
 //----------------------------------------------------------------------------
-// 
+//
 // IsExceptionFromManagedCode - report if pExceptionRecord points to an exception belonging to the current runtime
-// 
+//
 // Arguments:
 //    pExceptionRecord - the exception record
 //
@@ -7410,15 +7410,15 @@ BOOL ClrDataAccess::IsExceptionFromManagedCode(EXCEPTION_RECORD* pExceptionRecor
 #ifndef FEATURE_PAL
 
 //----------------------------------------------------------------------------
-// 
+//
 // GetWatsonBuckets - retrieve Watson buckets from the specified thread
-// 
+//
 // Arguments:
 //    dwThreadId - the thread ID
 //    pGM - pointer to the space to store retrieved Watson buckets
 //
 // Return Value:
-//    S_OK if the operation is successful.   
+//    S_OK if the operation is successful.
 //    or S_FALSE if Watson buckets cannot be found
 //    else detailed error code.
 //
@@ -7434,7 +7434,7 @@ HRESULT ClrDataAccess::GetWatsonBuckets(DWORD dwThreadId, GenericModeBlock * pGM
     DAC_ENTER();
 
     Thread * pThread = DacGetThread(dwThreadId);
-    _ASSERTE(pThread != NULL);    
+    _ASSERTE(pThread != NULL);
 
     HRESULT hr = E_UNEXPECTED;
 
@@ -7450,9 +7450,9 @@ HRESULT ClrDataAccess::GetWatsonBuckets(DWORD dwThreadId, GenericModeBlock * pGM
 #endif // FEATURE_PAL
 
 //----------------------------------------------------------------------------
-// 
+//
 // CLRDataAccessCreateInstance - create and initialize a ClrDataAccess object
-// 
+//
 // Arguments:
 //    pLegacyTarget - data target object
 //    pClrDataAccess - ClrDataAccess object
@@ -7506,9 +7506,6 @@ STDAPI CLRDataAccessCreateInstance(ICLRDataTarget * pLegacyTarget,
 // This is the legacy entrypoint to DAC, used by dbgeng/dbghelp (windbg, SOS, watson, etc).
 //
 //----------------------------------------------------------------------------
-#ifdef __GNUC__
-__attribute__((used))
-#endif // __GNUC__
 STDAPI
 CLRDataCreateInstance(REFIID iid,
                       ICLRDataTarget * pLegacyTarget,
@@ -7535,9 +7532,9 @@ CLRDataCreateInstance(REFIID iid,
 
 
 //----------------------------------------------------------------------------
-// 
+//
 // OutOfProcessExceptionEventGetProcessIdAndThreadId - get ProcessID and ThreadID
-// 
+//
 // Arguments:
 //    hProcess - process handle
 //    hThread - thread handle
@@ -7574,8 +7571,8 @@ BOOL OutOfProcessExceptionEventGetProcessIdAndThreadId(HANDLE hProcess, HANDLE h
     typedef WINBASEAPI DWORD (WINAPI GET_THREADID)(HANDLE);
     GET_THREADID * pGetThreadId;
 
-    pGetProcessIdOfThread = (GET_PROCESSID_OF_THREAD *)GetProcAddress(hKernel32, "GetProcessIdOfThread"); 
-    pGetThreadId = (GET_THREADID *)GetProcAddress(hKernel32, "GetThreadId"); 
+    pGetProcessIdOfThread = (GET_PROCESSID_OF_THREAD *)GetProcAddress(hKernel32, "GetProcessIdOfThread");
+    pGetThreadId = (GET_THREADID *)GetProcAddress(hKernel32, "GetThreadId");
 
     // OOP callbacks are used on Win7 or later.   We should have having below two APIs available.
     _ASSERTE((pGetProcessIdOfThread != NULL) && (pGetThreadId != NULL));
@@ -7597,7 +7594,7 @@ typedef struct _WER_RUNTIME_EXCEPTION_INFORMATION
     DWORD dwSize;
     HANDLE hProcess;
     HANDLE hThread;
-    EXCEPTION_RECORD exceptionRecord;    
+    EXCEPTION_RECORD exceptionRecord;
     CONTEXT context;
 } WER_RUNTIME_EXCEPTION_INFORMATION, * PWER_RUNTIME_EXCEPTION_INFORMATION;
 #endif // !defined(WER_RUNTIME_EXCEPTION_INFORMATION)
@@ -7606,16 +7603,16 @@ typedef struct _WER_RUNTIME_EXCEPTION_INFORMATION
 #ifndef FEATURE_PAL
 
 //----------------------------------------------------------------------------
-// 
+//
 // OutOfProcessExceptionEventGetWatsonBucket - retrieve Watson buckets if it is a managed exception
-// 
+//
 // Arguments:
 //    pContext - the context passed at helper module registration
 //    pExceptionInformation - structure that contains information about the crash
 //    pGM - pointer to the space to store retrieved Watson buckets
 //
 // Return Value:
-//    S_OK if the operation is successful.   
+//    S_OK if the operation is successful.
 //    or S_FALSE if it is not a managed exception or Watson buckets cannot be found
 //    else detailed error code.
 //
@@ -7661,51 +7658,51 @@ STDAPI OutOfProcessExceptionEventGetWatsonBucket(__in PDWORD pContext,
     {
         return S_FALSE;
     }
-                                     
+
     return pClrDataAccess->GetWatsonBuckets(ThreadId, pGMB);
 }
 
 //----------------------------------------------------------------------------
 //
-// OutOfProcessExceptionEventCallback - claim the ownership of this event if current 
+// OutOfProcessExceptionEventCallback - claim the ownership of this event if current
 //                                      runtime threw the unhandled exception
-// 
+//
 // Arguments:
 //    pContext - the context passed at helper module registration
 //    pExceptionInformation - structure that contains information about the crash
 //    pbOwnershipClaimed - output parameter for claiming the ownership of this event
-//    pwszEventName - name of the event. If this is NULL, pchSize cannot be NULL. 
+//    pwszEventName - name of the event. If this is NULL, pchSize cannot be NULL.
 //                    This parameter is valid only if * pbOwnershipClaimed is TRUE.
 //    pchSize - the size of the buffer pointed by pwszEventName
-//    pdwSignatureCount - the count of signature parameters. Valid values range from 
-//                        0 to 10. If the value returned is greater than 10, only the 
-//                        1st 10 parameters are used for bucketing parameters. This 
+//    pdwSignatureCount - the count of signature parameters. Valid values range from
+//                        0 to 10. If the value returned is greater than 10, only the
+//                        1st 10 parameters are used for bucketing parameters. This
 //                        parameter is valid only if * pbOwnershipClaimed is TRUE.
 //
 // Return Value:
 //    S_OK on success, else detailed error code.
 //
 // Note:
-//    This is the 1st function that is called into by WER. This API through its out 
-//    parameters, tells WER as to whether or not it is claiming the crash. If it does 
-//    claim the crash, WER uses the event name specified in the string pointed to by 
-//    pwszEventName for error reporting. WER then proceed to call the 
-//    OutOfProcessExceptionEventSignatureCallback to get the bucketing parameters from 
+//    This is the 1st function that is called into by WER. This API through its out
+//    parameters, tells WER as to whether or not it is claiming the crash. If it does
+//    claim the crash, WER uses the event name specified in the string pointed to by
+//    pwszEventName for error reporting. WER then proceed to call the
+//    OutOfProcessExceptionEventSignatureCallback to get the bucketing parameters from
 //    the helper dll.
 //
 //    This function follows the multiple call paradigms. WER may call into this function
 //    with *pwszEventName pointer set to NULL. This is to indicate to the function, that
-//    WER wants to know the buffer size needed by the function to populate the string 
-//    into the buffer. The function should return E_INSUFFICIENTBUFFER with the needed 
-//    buffer size in *pchSize. WER shall then allocate a buffer of size *pchSize for 
-//    pwszEventName and then call this function again at which point the function should 
-//    populate the string and return S_OK. 
+//    WER wants to know the buffer size needed by the function to populate the string
+//    into the buffer. The function should return E_INSUFFICIENTBUFFER with the needed
+//    buffer size in *pchSize. WER shall then allocate a buffer of size *pchSize for
+//    pwszEventName and then call this function again at which point the function should
+//    populate the string and return S_OK.
 //
 //    Note that *pdOwnershipClaimed should be set to TRUE everytime this function is called
 //    for the helper dll to claim ownership of bucketing.
 //
-//    The Win7 WER spec is at 
-//    http://windows/windows7/docs/COSD%20Documents/Fundamentals/Feedback%20Services%20and%20Platforms/WER-CLR%20Integration%20Dev%20Spec.docx 
+//    The Win7 WER spec is at
+//    http://windows/windows7/docs/COSD%20Documents/Fundamentals/Feedback%20Services%20and%20Platforms/WER-CLR%20Integration%20Dev%20Spec.docx
 //
 //    !!!READ THIS!!!
 //    Since this is called by external modules it's important that we don't let any exceptions leak out (see Win8 95224).
@@ -7720,11 +7717,11 @@ STDAPI OutOfProcessExceptionEventCallback(__in PDWORD pContext,
 {
     SUPPORTS_DAC_HOST_ONLY;
 
-    if ((pContext == NULL) || 
+    if ((pContext == NULL) ||
         (pExceptionInformation == NULL) ||
         (pExceptionInformation->dwSize < sizeof(WER_RUNTIME_EXCEPTION_INFORMATION)) ||
-        (pbOwnershipClaimed == NULL) || 
-        (pchSize == NULL) || 
+        (pbOwnershipClaimed == NULL) ||
+        (pchSize == NULL) ||
         (pdwSignatureCount == NULL))
     {
         return E_INVALIDARG;
@@ -7772,31 +7769,31 @@ STDAPI OutOfProcessExceptionEventCallback(__in PDWORD pContext,
 //----------------------------------------------------------------------------
 //
 // OutOfProcessExceptionEventCallback - provide custom Watson buckets
-// 
+//
 // Arguments:
 //    pContext - the context passed at helper module registration
 //    pExceptionInformation - structure that contains information about the crash
-//    dwIndex - the index of the bucketing parameter being requested. Valid values are 
+//    dwIndex - the index of the bucketing parameter being requested. Valid values are
 //              from 0 to 9
 //    pwszName - pointer to the name of the bucketing parameter
-//    pchName - pointer to character count of the pwszName buffer. If pwszName points to 
-//              null, *pchName represents the buffer size (represented in number of characters) 
+//    pchName - pointer to character count of the pwszName buffer. If pwszName points to
+//              null, *pchName represents the buffer size (represented in number of characters)
 //              needed to populate the name in pwszName.
 //    pwszValue - pointer to the value of the pwszName bucketing parameter
-//    pchValue - pointer to the character count of the pwszValue buffer. If pwszValue points 
-//               to null, *pchValue represents the buffer size (represented in number of 
+//    pchValue - pointer to the character count of the pwszValue buffer. If pwszValue points
+//               to null, *pchValue represents the buffer size (represented in number of
 //               characters) needed to populate the value in pwszValue.
 //
 // Return Value:
 //    S_OK on success, else detailed error code.
 //
 // Note:
-//    This function is called by WER only if the call to OutOfProcessExceptionEventCallback() 
-//    was successful and the value of *pbOwnershipClaimed was TRUE. This function is called 
-//    pdwSignatureCount times to collect the bucketing parameters from the helper dll. 
+//    This function is called by WER only if the call to OutOfProcessExceptionEventCallback()
+//    was successful and the value of *pbOwnershipClaimed was TRUE. This function is called
+//    pdwSignatureCount times to collect the bucketing parameters from the helper dll.
 //
-//    This function also follows the multiple call paradigm as described for the 
-//    OutOfProcessExceptionEventCallback() function. The buffer sizes needed for 
+//    This function also follows the multiple call paradigm as described for the
+//    OutOfProcessExceptionEventCallback() function. The buffer sizes needed for
 //    this function are of the pwszName and pwszValue buffers.
 //
 //    !!!READ THIS!!!
@@ -7813,11 +7810,11 @@ STDAPI OutOfProcessExceptionEventSignatureCallback(__in PDWORD pContext,
 {
     SUPPORTS_DAC_HOST_ONLY;
 
-    if ((pContext == NULL) || 
+    if ((pContext == NULL) ||
         (pExceptionInformation == NULL) ||
         (pExceptionInformation->dwSize < sizeof(WER_RUNTIME_EXCEPTION_INFORMATION)) ||
         (pchName == NULL) ||
-        (pchValue == NULL)) 
+        (pchValue == NULL))
     {
         return E_INVALIDARG;
     }
@@ -7829,7 +7826,7 @@ STDAPI OutOfProcessExceptionEventSignatureCallback(__in PDWORD pContext,
     }
 
     GenericModeBlock gmb;
-    const PWSTR pwszBucketValues[] = {gmb.wzP1, 
+    const PWSTR pwszBucketValues[] = {gmb.wzP1,
                                       gmb.wzP2,
                                       gmb.wzP3,
                                       gmb.wzP4,
@@ -7859,8 +7856,8 @@ STDAPI OutOfProcessExceptionEventSignatureCallback(__in PDWORD pContext,
     if (hr != S_OK)
     {
         // S_FALSE means either it is not a managed exception or we do not have Watson buckets.
-        // Either case is a logic error becuase this function is called by WER only if the call 
-        // to OutOfProcessExceptionEventCallback() was successful and the value of 
+        // Either case is a logic error becuase this function is called by WER only if the call
+        // to OutOfProcessExceptionEventCallback() was successful and the value of
         // *pbOwnershipClaimed was TRUE.
         if (hr == S_FALSE)
         {
@@ -7869,9 +7866,9 @@ STDAPI OutOfProcessExceptionEventSignatureCallback(__in PDWORD pContext,
 
         return hr;
     }
-    
+
     DWORD paramCount = GetCountBucketParamsForEvent(gmb.wzEventTypeName);
-    
+
     if (dwIndex >= paramCount)
     {
         _ASSERTE(!"dwIndex is out of range");
@@ -7898,36 +7895,36 @@ STDAPI OutOfProcessExceptionEventSignatureCallback(__in PDWORD pContext,
 //----------------------------------------------------------------------------
 //
 // OutOfProcessExceptionEventCallback - provide custom debugger launch string
-// 
+//
 // Arguments:
 //    pContext - the context passed at helper module registration
 //    pExceptionInformation - structure that contains information about the crash
 //    pbCustomDebuggerNeeded - pointer to a BOOL. If this BOOL is set to TRUE, then
-//                             a custom debugger launch option is needed by the 
+//                             a custom debugger launch option is needed by the
 //                             process. In that case, the subsequent parameters will
 //                             be meaningfully used. If this is FALSE, the subsequent
 //                             parameters will be ignored.
 //    pwszDebuggerLaunch - pointer to a string that will be used to launch the debugger,
-//                         if the debugger is launched. The value of this string overrides 
+//                         if the debugger is launched. The value of this string overrides
 //                         the default debugger launch string used by WER.
-//    pchSize - pointer to the character count of the pwszDebuggerLaunch  buffer. If 
-//              pwszDebuggerLaunch points to null, *pchSize represents the buffer size 
-//              (represented in number of characters) needed to populate the debugger 
+//    pchSize - pointer to the character count of the pwszDebuggerLaunch  buffer. If
+//              pwszDebuggerLaunch points to null, *pchSize represents the buffer size
+//              (represented in number of characters) needed to populate the debugger
 //              launch string in pwszDebuggerLaunch.
-//    pbAutoLaunchDebugger - pointer to a BOOL. If this BOOL is set to TRUE, WER will 
-//                           directly launch the debugger. If set to FALSE, WER will show 
+//    pbAutoLaunchDebugger - pointer to a BOOL. If this BOOL is set to TRUE, WER will
+//                           directly launch the debugger. If set to FALSE, WER will show
 //                           the debug option to the user in the WER UI.
 //
 // Return Value:
 //    S_OK on success, else detailed error code.
 //
 // Note:
-//    This function is called into by WER only if the call to OutOfProcessExceptionEventCallback() 
+//    This function is called into by WER only if the call to OutOfProcessExceptionEventCallback()
 //    was successful and the value of *pbOwnershipClaimed was TRUE. This function allows the helper
 //    dll to customize the debugger launch options including the launch string.
 //
-//    This function also follows the multiple call paradigm as described for the 
-//    OutOfProcessExceptionEventCallback() function. The buffer sizes needed for 
+//    This function also follows the multiple call paradigm as described for the
+//    OutOfProcessExceptionEventCallback() function. The buffer sizes needed for
 //    this function are of the pwszName and pwszValue buffers.
 //
 //----------------------------------------------------------------------------
@@ -7940,13 +7937,13 @@ STDAPI OutOfProcessExceptionEventDebuggerLaunchCallback(__in PDWORD pContext,
 {
     SUPPORTS_DAC_HOST_ONLY;
 
-    if ((pContext == NULL) || 
+    if ((pContext == NULL) ||
         (pExceptionInformation == NULL) ||
         (pExceptionInformation->dwSize < sizeof(WER_RUNTIME_EXCEPTION_INFORMATION)) ||
         (pbCustomDebuggerNeeded == NULL) ||
         (pwszDebuggerLaunch == NULL) ||
         (pchSize == NULL) ||
-        (pbAutoLaunchDebugger == NULL)) 
+        (pbAutoLaunchDebugger == NULL))
     {
         return E_INVALIDARG;
     }
@@ -7973,9 +7970,9 @@ DacHandleWalker::DacHandleWalker()
 DacHandleWalker::~DacHandleWalker()
 {
     SUPPORTS_DAC;
-    
+
     HandleChunkHead *curr = mHead.Next;
-    
+
     while (curr)
     {
         HandleChunkHead *tmp = curr;
@@ -7987,50 +7984,50 @@ DacHandleWalker::~DacHandleWalker()
 HRESULT DacHandleWalker::Init(ClrDataAccess *dac, UINT types[], UINT typeCount)
 {
     SUPPORTS_DAC;
-    
+
     if (dac == NULL || types == NULL)
         return E_POINTER;
-    
+
     mDac = dac;
     m_instanceAge = dac->m_instanceAge;
-    
+
     return Init(BuildTypemask(types, typeCount));
 }
 
 HRESULT DacHandleWalker::Init(ClrDataAccess *dac, UINT types[], UINT typeCount, int gen)
 {
     SUPPORTS_DAC;
-    
+
     if (gen < 0 || gen > (int)*g_gcDacGlobals->max_gen)
         return E_INVALIDARG;
-        
+
     mGenerationFilter = gen;
-    
+
     return Init(dac, types, typeCount);
 }
 
 HRESULT DacHandleWalker::Init(UINT32 typemask)
 {
     SUPPORTS_DAC;
-    
+
     mMap = g_gcDacGlobals->handle_table_map;
     mTypeMask = typemask;
-    
+
     return S_OK;
 }
 
 UINT32 DacHandleWalker::BuildTypemask(UINT types[], UINT typeCount)
 {
     SUPPORTS_DAC;
-    
+
     UINT32 mask = 0;
-    
+
     for (UINT i = 0; i < typeCount; ++i)
     {
         _ASSERTE(types[i] < 32);
         mask |= (1 << types[i]);
     }
-    
+
     return mask;
 }
 
@@ -8039,26 +8036,26 @@ HRESULT DacHandleWalker::Next(unsigned int celt,
              unsigned int *pceltFetched)
 {
     SUPPORTS_DAC;
-    
+
     if (handles == NULL || pceltFetched == NULL)
         return E_POINTER;
-    
+
     SOSHelperEnter();
-    
+
     hr = DoHandleWalk<SOSHandleData, unsigned int, DacHandleWalker::EnumCallbackSOS>(celt, handles, pceltFetched);
-    
+
     SOSHelperLeave();
-    
+
     return hr;
 }
 
 bool DacHandleWalker::FetchMoreHandles(HANDLESCANPROC callback)
 {
     SUPPORTS_DAC;
-    
+
     // The table slots are based on the number of GC heaps in the process.
     int max_slots = 1;
-    
+
 #ifdef FEATURE_SVR_GC
     if (GCHeapUtilities::IsServerHeap())
         max_slots = GCHeapCount();
@@ -8068,9 +8065,9 @@ bool DacHandleWalker::FetchMoreHandles(HANDLESCANPROC callback)
     // them, and the count is the only thing which needs resetting.
     for (HandleChunkHead *curr = &mHead; curr; curr = curr->Next)
         curr->Count = 0;
-    
+
     DacHandleWalkerParam param(&mHead);
-    
+
     do
     {
         // Have we advanced past the end of the current bucket?
@@ -8079,14 +8076,14 @@ bool DacHandleWalker::FetchMoreHandles(HANDLESCANPROC callback)
             mIndex = 0;
             mMap = mMap->pNext;
         }
-        
+
         // Have we walked the entire handle table map?
         if (mMap == NULL)
         {
             mCurr = NULL;
             return false;
         }
-        
+
         if (mMap->pBuckets[mIndex] != NULL)
         {
             for (int i = 0; i < max_slots; ++i)
@@ -8094,7 +8091,7 @@ bool DacHandleWalker::FetchMoreHandles(HANDLESCANPROC callback)
                 DPTR(dac_handle_table) hTable = mMap->pBuckets[mIndex]->pTable[i];
                 if (hTable)
                 {
-                    // Yikes!  The handle table callbacks don't produce the handle type or 
+                    // Yikes!  The handle table callbacks don't produce the handle type or
                     // the AppDomain that we need, and it's too difficult to propogate out
                     // these things (especially the type) without worrying about performance
                     // implications for the GC.  Instead we'll have the callback walk each
@@ -8109,13 +8106,13 @@ bool DacHandleWalker::FetchMoreHandles(HANDLESCANPROC callback)
                             PTR_AppDomain pDomain = SystemDomain::GetAppDomainAtIndex(ADIndex(pTable->uADIndex));
                             param.AppDomain = TO_CDADDR(pDomain.GetAddr());
                             param.Type = handleType;
-                            
+
                             // Either enumerate the handles regularly, or walk the handle
                             // table as the GC does if a generation filter was requested.
                             if (mGenerationFilter != -1)
-                                HndScanHandlesForGC(hTable, callback, 
-                                                    (LPARAM)&param, 0, 
-                                                     &handleType, 1, 
+                                HndScanHandlesForGC(hTable, callback,
+                                                    (LPARAM)&param, 0,
+                                                     &handleType, 1,
                                                      mGenerationFilter, *g_gcDacGlobals->max_gen, 0);
                             else
                                 HndEnumHandles(hTable, &handleType, 1, callback, (LPARAM)&param, 0, FALSE);
@@ -8124,12 +8121,12 @@ bool DacHandleWalker::FetchMoreHandles(HANDLESCANPROC callback)
                 }
             }
         }
-        
+
         // Stop looping as soon as we have found data.  We also stop if we have a failed HRESULT during
         // the callback (this should indicate OOM).
         mIndex++;
     } while (mHead.Count == 0 && SUCCEEDED(param.Result));
-    
+
     mCurr = mHead.Next;
     return true;
 }
@@ -8152,7 +8149,7 @@ HRESULT DacHandleWalker::GetCount(unsigned int *pcelt)
 
 
 void DacHandleWalker::GetRefCountedHandleInfo(
-    OBJECTREF oref, unsigned int uType, 
+    OBJECTREF oref, unsigned int uType,
     unsigned int *pRefCount, unsigned int *pJupiterRefCount, BOOL *pIsPegged, BOOL *pIsStrong)
 {
     SUPPORTS_DAC;
@@ -8166,16 +8163,16 @@ void DacHandleWalker::GetRefCountedHandleInfo(
         {
             if (pRefCount)
                 *pRefCount = (unsigned int)pWrap->GetRefCount();
-                
+
             if (pJupiterRefCount)
                 *pJupiterRefCount = (unsigned int)pWrap->GetJupiterRefCount();
-            
+
             if (pIsPegged)
                 *pIsPegged = pWrap->IsConsideredPegged();
-            
+
             if (pIsStrong)
                 *pIsStrong = pWrap->IsWrapperActive();
-            
+
             return;
         }
     }
@@ -8183,13 +8180,13 @@ void DacHandleWalker::GetRefCountedHandleInfo(
 
     if (pRefCount)
         *pRefCount = 0;
-    
+
     if (pJupiterRefCount)
         *pJupiterRefCount = 0;
-    
+
     if (pIsPegged)
         *pIsPegged = FALSE;
-    
+
     if (pIsStrong)
         *pIsStrong = FALSE;
 }
@@ -8197,16 +8194,16 @@ void DacHandleWalker::GetRefCountedHandleInfo(
 void CALLBACK DacHandleWalker::EnumCallbackSOS(PTR_UNCHECKED_OBJECTREF handle, uintptr_t *pExtraInfo, uintptr_t param1, uintptr_t param2)
 {
     SUPPORTS_DAC;
-    
+
     DacHandleWalkerParam *param = (DacHandleWalkerParam *)param1;
     HandleChunkHead *curr = param->Curr;
-    
+
     // If we failed on a previous call (OOM) don't keep trying to allocate, it's not going to work.
     if (FAILED(param->Result))
         return;
-    
+
     // We've moved past the size of the current chunk.  We'll allocate a new chunk
-    // and stuff the handles there.  These are cleaned up by the destructor 
+    // and stuff the handles there.  These are cleaned up by the destructor
     if (curr->Count >= (curr->Size/sizeof(SOSHandleData)))
     {
         if (curr->Next == NULL)
@@ -8222,14 +8219,14 @@ void CALLBACK DacHandleWalker::EnumCallbackSOS(PTR_UNCHECKED_OBJECTREF handle, u
                 return;
             }
         }
-        
+
         curr = param->Curr = param->Curr->Next;
     }
-    
+
     // Fill the current handle.
     SOSHandleData *dataArray = (SOSHandleData*)curr->pData;
     SOSHandleData &data = dataArray[curr->Count++];
-    
+
     data.Handle = TO_CDADDR(handle.GetAddr());
     data.Type = param->Type;
     if (param->Type == HNDTYPE_DEPENDENT)
@@ -8250,7 +8247,7 @@ DacStackReferenceWalker::DacStackReferenceWalker(ClrDataAccess *dac, DWORD osThr
       mChunkIndex(0), mCurr(0), mIteratorIndex(0)
 {
     Thread *curr = NULL;
-    
+
     for (curr = ThreadStore::GetThreadList(curr);
          curr;
          curr = ThreadStore::GetThreadList(curr))
@@ -8266,7 +8263,7 @@ DacStackReferenceWalker::DacStackReferenceWalker(ClrDataAccess *dac, DWORD osThr
 DacStackReferenceWalker::~DacStackReferenceWalker()
 {
     StackRefChunkHead *curr = mHead.next;
-    
+
     while (curr)
     {
         StackRefChunkHead *tmp = curr;
@@ -8296,21 +8293,21 @@ HRESULT DacStackReferenceWalker::GetCount(unsigned int *pCount)
 {
     if (!pCount)
         return E_POINTER;
-    
+
     SOSHelperEnter();
-    
+
     if (!mEnumerated)
     {
         // Fill out our data structures.
         WalkStack<unsigned int, SOSStackRefData>(0, NULL, DacStackReferenceWalker::GCReportCallbackSOS, DacStackReferenceWalker::GCEnumCallbackSOS);
     }
-    
+
     unsigned int count = 0;
     for(StackRefChunkHead *curr = &mHead; curr; curr = curr->next)
         count += curr->count;
-    
+
     *pCount = count;
-    
+
     SOSHelperLeave();
     return hr;
 }
@@ -8321,16 +8318,16 @@ HRESULT DacStackReferenceWalker::Next(unsigned int count,
 {
     if (stackRefs == NULL || pFetched == NULL)
         return E_POINTER;
-    
+
     SOSHelperEnter();
-    
-    hr = DoStackWalk<unsigned int, SOSStackRefData, 
+
+    hr = DoStackWalk<unsigned int, SOSStackRefData,
                      DacStackReferenceWalker::GCReportCallbackSOS,
                      DacStackReferenceWalker::GCEnumCallbackSOS>
                      (count, stackRefs, pFetched);
-    
+
     SOSHelperLeave();
-    
+
     return hr;
 }
 
@@ -8338,18 +8335,18 @@ HRESULT DacStackReferenceWalker::EnumerateErrors(ISOSStackRefErrorEnum **ppEnum)
 {
     if (!ppEnum)
         return E_POINTER;
-    
+
     SOSHelperEnter();
-    
+
     if (mThread)
     {
         // Fill out our data structures.
         WalkStack<unsigned int, SOSStackRefData>(0, NULL, DacStackReferenceWalker::GCReportCallbackSOS, DacStackReferenceWalker::GCEnumCallbackSOS);
     }
-    
+
     DacStackReferenceErrorEnum *pEnum = new DacStackReferenceErrorEnum(this, mErrors);
     hr = pEnum->QueryInterface(__uuidof(ISOSStackRefErrorEnum), (void**)ppEnum);
-    
+
     SOSHelperLeave();
     return hr;
 }
@@ -8359,13 +8356,13 @@ CLRDATA_ADDRESS DacStackReferenceWalker::ReadPointer(TADDR addr)
     ULONG32 bytesRead = 0;
     TADDR result = 0;
     HRESULT hr = mDac->m_pTarget->ReadVirtual(addr, (BYTE*)&result, sizeof(TADDR), &bytesRead);
-    
+
     if (FAILED(hr) || (bytesRead != sizeof(TADDR)))
         return (CLRDATA_ADDRESS)~0;
-    
+
     return TO_CDADDR(result);
 }
-   
+
 
 void DacStackReferenceWalker::GCEnumCallbackSOS(LPVOID hCallback, OBJECTREF *pObject, uint32_t flags, DacSlotLocation loc)
 {
@@ -8377,7 +8374,7 @@ void DacStackReferenceWalker::GCEnumCallbackSOS(LPVOID hCallback, OBJECTREF *pOb
     // to fix, so we are leaving it for now.
     TADDR addr = 0;
     TADDR obj = 0;
-    
+
     if (loc.targetPtr)
     {
         addr = (TADDR)pObject;
@@ -8387,17 +8384,17 @@ void DacStackReferenceWalker::GCEnumCallbackSOS(LPVOID hCallback, OBJECTREF *pOb
     {
         obj = pObject->GetAddr();
     }
-    
+
     if (flags & GC_CALL_INTERIOR)
     {
         CORDB_ADDRESS fixed_obj = 0;
         HRESULT hr = dsc->pWalker->mHeap.ListNearObjects((CORDB_ADDRESS)obj, NULL, &fixed_obj, NULL);
-        
+
         // If we failed...oh well, SOS won't mind.  We'll just report the interior pointer as is.
         if (SUCCEEDED(hr))
             obj = TO_TADDR(fixed_obj);
     }
-    
+
     SOSStackRefData *data = dsc->pWalker->GetNextObject<SOSStackRefData>(dsc);
     if (data != NULL)
     {
@@ -8408,10 +8405,10 @@ void DacStackReferenceWalker::GCEnumCallbackSOS(LPVOID hCallback, OBJECTREF *pOb
         data->Address = TO_CDADDR(addr);
         data->Object = TO_CDADDR(obj);
         data->Flags = flags;
-        
+
         // Report the frame that the data came from.
         data->StackPointer = TO_CDADDR(dsc->sp);
-        
+
         if (dsc->pFrame)
         {
             data->SourceType = SOS_StackSourceFrame;
@@ -8430,17 +8427,17 @@ void DacStackReferenceWalker::GCReportCallbackSOS(PTR_PTR_Object ppObj, ScanCont
 {
     DacScanContext *dsc = (DacScanContext*)sc;
     CLRDATA_ADDRESS obj = dsc->pWalker->ReadPointer(ppObj.GetAddr());
-    
+
     if (flags & GC_CALL_INTERIOR)
     {
         CORDB_ADDRESS fixed_addr = 0;
         HRESULT hr = dsc->pWalker->mHeap.ListNearObjects((CORDB_ADDRESS)obj, NULL, &fixed_addr, NULL);
-        
+
         // If we failed...oh well, SOS won't mind.  We'll just report the interior pointer as is.
         if (SUCCEEDED(hr))
             obj = TO_CDADDR(fixed_addr);
     }
-    
+
     SOSStackRefData *data = dsc->pWalker->GetNextObject<SOSStackRefData>(dsc);
     if (data != NULL)
     {
@@ -8451,7 +8448,7 @@ void DacStackReferenceWalker::GCReportCallbackSOS(PTR_PTR_Object ppObj, ScanCont
         data->Object = obj;
         data->Flags = flags;
         data->StackPointer = TO_CDADDR(dsc->sp);
-        
+
         if (dsc->pFrame)
         {
             data->SourceType = SOS_StackSourceFrame;
@@ -8473,11 +8470,11 @@ StackWalkAction DacStackReferenceWalker::Callback(CrawlFrame *pCF, VOID *pData)
 
     GCCONTEXT *gcctx = (GCCONTEXT*)pData;
     DacScanContext *dsc = (DacScanContext*)gcctx->sc;
-    
+
     MethodDesc *pMD = pCF->GetFunction();
     gcctx->sc->pMD = pMD;
     gcctx->sc->pCurrentDomain = pCF->GetAppDomain();
-    
+
     PREGDISPLAY pRD = pCF->GetRegisterSet();
     dsc->sp = (TADDR)GetRegdisplaySP(pRD);;
     dsc->pc = PCODEToPINSTR(GetControlPC(pRD));
@@ -8494,7 +8491,7 @@ StackWalkAction DacStackReferenceWalker::Callback(CrawlFrame *pCF, VOID *pData)
 #endif // defined(WIN64EXCEPTIONS)
 
     Frame *pFrame = ((DacScanContext*)gcctx->sc)->pFrame = pCF->GetFrame();
-    
+
     EX_TRY
     {
         if (fReportGCReferences)
@@ -8505,7 +8502,7 @@ StackWalkAction DacStackReferenceWalker::Callback(CrawlFrame *pCF, VOID *pData)
                 _ASSERTE(pCM != NULL);
 
                 unsigned flags = pCF->GetCodeManagerFlags();
-            
+
                 pCM->EnumGcRefs(pCF->GetRegisterSet(),
                                 pCF->GetCodeInfo(),
                                 flags,
@@ -8522,7 +8519,7 @@ StackWalkAction DacStackReferenceWalker::Callback(CrawlFrame *pCF, VOID *pData)
     {
         SOSStackErrorList *err = new SOSStackErrorList;
         err->pNext = NULL;
-        
+
         if (pFrame)
         {
             err->error.SourceType = SOS_StackSourceFrame;
@@ -8533,7 +8530,7 @@ StackWalkAction DacStackReferenceWalker::Callback(CrawlFrame *pCF, VOID *pData)
             err->error.SourceType = SOS_StackSourceIP;
             err->error.Source = TO_CDADDR(dsc->pc);
         }
-        
+
         if (dsc->pWalker->mErrors == NULL)
         {
             dsc->pWalker->mErrors = err;
@@ -8547,7 +8544,7 @@ StackWalkAction DacStackReferenceWalker::Callback(CrawlFrame *pCF, VOID *pData)
             SOSStackErrorList *curr = dsc->pWalker->mErrors;
             while (curr->pNext)
                 curr = curr->pNext;
-            
+
             curr->pNext = err;
         }
     }
@@ -8559,7 +8556,7 @@ StackWalkAction DacStackReferenceWalker::Callback(CrawlFrame *pCF, VOID *pData)
     // If we're executing a LCG dynamic method then we must promote the associated resolver to ensure it
     // doesn't get collected and yank the method code out from under us).
 
-    // Be careful to only promote the reference -- we can also be called to relocate the reference and 
+    // Be careful to only promote the reference -- we can also be called to relocate the reference and
     // that can lead to all sorts of problems since we could be racing for the relocation with the long
     // weak handle we recover the reference from. Promoting the reference is enough, the handle in the
     // reference will be relocated properly as long as we keep it alive till the end of the collection
@@ -8597,7 +8594,7 @@ StackWalkAction DacStackReferenceWalker::Callback(CrawlFrame *pCF, VOID *pData)
                 if (pCF->IsFrameless())
                 {
                     // We need to grab the Context Type here because there are cases where the MethodDesc
-                    // is shared, and thus indicates there should be an instantion argument, but the JIT 
+                    // is shared, and thus indicates there should be an instantion argument, but the JIT
                     // was still allowed to optimize it away and we won't grab it below because we're not
                     // reporting any references from this frame.
                     paramContextType = pCF->GetCodeManager()->GetParamContextType(pCF->GetRegisterSet(), pCF->GetCodeInfo());
@@ -8635,7 +8632,7 @@ StackWalkAction DacStackReferenceWalker::Callback(CrawlFrame *pCF, VOID *pData)
         }
     }
 #endif
-    
+
     return SWA_CONTINUE;
 }
 
@@ -8644,7 +8641,7 @@ DacStackReferenceErrorEnum::DacStackReferenceErrorEnum(DacStackReferenceWalker *
     : mEnum(pEnum), mHead(pErrors), mCurr(pErrors)
 {
     _ASSERTE(mEnum);
-    
+
     if (mHead != NULL)
         mEnum->AddRef();
 }
@@ -8660,14 +8657,14 @@ HRESULT DacStackReferenceErrorEnum::Skip(unsigned int count)
     unsigned int i = 0;
     for (i = 0; i < count && mCurr; ++i)
         mCurr = mCurr->pNext;
-    
+
     return i < count ? S_FALSE : S_OK;
 }
 
 HRESULT DacStackReferenceErrorEnum::Reset()
 {
     mCurr = mHead;
-    
+
     return S_OK;
 }
 
@@ -8675,13 +8672,13 @@ HRESULT DacStackReferenceErrorEnum::GetCount(unsigned int *pCount)
 {
     SOSStackErrorList *curr = mHead;
     unsigned int count = 0;
-    
+
     while (curr)
     {
         curr = curr->pNext;
         count++;
     }
-    
+
     *pCount = count;
     return S_OK;
 }
@@ -8694,7 +8691,7 @@ HRESULT DacStackReferenceErrorEnum::Next(unsigned int count, SOSStackRefError re
     unsigned int i;
     for (i = 0; i < count && mCurr; ++i, mCurr = mCurr->pNext)
         ref[i] = mCurr->error;
-    
+
     *pFetched = i;
     return i < count ? S_FALSE : S_OK;
 }
index 4b58797..0357464 100644 (file)
@@ -28,7 +28,7 @@ Abstract:
 
     If you want to add a PAL_ wrapper function to a native function in
     here, you also need to edit palinternal.h and win32pal.h.
-    
+
 
 
 --*/
@@ -72,7 +72,7 @@ extern "C" {
 // Native system libray handle.
 // On Unix systems, NATIVE_LIBRARY_HANDLE type represents a library handle not registered with the PAL.
 // To get a HMODULE on Unix, call PAL_RegisterLibraryDirect() on a NATIVE_LIBRARY_HANDLE.
-typedef void * NATIVE_LIBRARY_HANDLE;
+typedef PVOID NATIVE_LIBRARY_HANDLE;
 
 /******************* Processor-specific glue  *****************************/
 
@@ -252,7 +252,7 @@ PALIMPORT
 BOOL
 PALAPI
 PAL_IsDebuggerPresent(VOID);
+
 #define MAXIMUM_SUSPEND_COUNT  MAXCHAR
 
 #define CHAR_BIT      8
@@ -301,7 +301,7 @@ PAL_IsDebuggerPresent(VOID);
 #if defined(__cplusplus)
 #define NULL    0
 #else
-#define NULL    ((void *)0)
+#define NULL    ((PVOID)0)
 #endif
 
 #if defined(PAL_STDCPP_COMPAT) && !defined(__cplusplus)
@@ -347,7 +347,7 @@ typedef long time_t;
                                         PAL_INITIALIZE_STD_HANDLES)
 
 // PAL_InitializeDLL() flags - don't start any of the helper threads or register any exceptions
-#define PAL_INITIALIZE_DLL              PAL_INITIALIZE_NONE       
+#define PAL_INITIALIZE_DLL              PAL_INITIALIZE_NONE
 
 // PAL_InitializeCoreCLR() flags
 #define PAL_INITIALIZE_CORECLR         (PAL_INITIALIZE | \
@@ -477,7 +477,7 @@ PALAPI
 PAL_GetTransportPipeName(
     OUT char *name,
     IN DWORD id,
-    IN const char *applicationGroupId, 
+    IN const char *applicationGroupId,
     IN const char *suffix);
 
 PALIMPORT
@@ -498,7 +498,7 @@ PAL_RegisterModule(
     IN LPCSTR lpLibFileName);
 
 PALIMPORT
-VOID 
+VOID
 PALAPI
 PAL_UnregisterModule(
     IN HINSTANCE hInstance);
@@ -777,7 +777,7 @@ RemoveDirectoryW(
 #define RemoveDirectory RemoveDirectoryA
 #endif
 
-typedef struct _BY_HANDLE_FILE_INFORMATION {  
+typedef struct _BY_HANDLE_FILE_INFORMATION {
     DWORD dwFileAttributes;
     FILETIME ftCreationTime;
     FILETIME ftLastAccessTime;
@@ -2381,7 +2381,7 @@ GetThreadTimes(
         OUT LPFILETIME lpExitTime,
         OUT LPFILETIME lpKernelTime,
         OUT LPFILETIME lpUserTime);
-    
+
 #define TLS_OUT_OF_INDEXES ((DWORD)0xFFFFFFFF)
 
 PALIMPORT
@@ -2410,12 +2410,12 @@ TlsFree(
     IN DWORD dwTlsIndex);
 
 PALIMPORT
-void *
+PVOID
 PALAPI
 PAL_GetStackBase(VOID);
 
 PALIMPORT
-void *
+PVOID
 PALAPI
 PAL_GetStackLimit(VOID);
 
@@ -2476,12 +2476,12 @@ PALIMPORT BOOL PALAPI PAL_VirtualUnwindOutOfProc(CONTEXT *context, KNONVOLATILE_
 #define PAL_CS_NATIVE_DATA_SIZE 56
 #elif defined(__NetBSD__) && defined(__i386__)
 #define PAL_CS_NATIVE_DATA_SIZE 56
-#else 
-#warning 
+#else
+#warning
 #error  PAL_CS_NATIVE_DATA_SIZE is not defined for this architecture
 #endif
-    
-// 
+
+//
 typedef struct _CRITICAL_SECTION {
     PVOID DebugInfo;
     LONG LockCount;
@@ -2494,9 +2494,9 @@ typedef struct _CRITICAL_SECTION {
     volatile DWORD dwInitState;
     union CSNativeDataStorage
     {
-        BYTE rgNativeDataStorage[PAL_CS_NATIVE_DATA_SIZE]; 
-        VOID * pvAlign; // make sure the storage is machine-pointer-size aligned
-    } csnds;    
+        BYTE rgNativeDataStorage[PAL_CS_NATIVE_DATA_SIZE];
+        PVOID pvAlign; // make sure the storage is machine-pointer-size aligned
+    } csnds;
 } CRITICAL_SECTION, *PCRITICAL_SECTION, *LPCRITICAL_SECTION;
 
 PALIMPORT VOID PALAPI EnterCriticalSection(IN OUT LPCRITICAL_SECTION lpCriticalSection);
@@ -2661,7 +2661,8 @@ Return value:
     A valid base address if successful.
     0 if failure
 --*/
-void *
+PALIMPORT
+PVOID
 PALAPI
 PAL_LOADLoadPEFile(HANDLE hFile);
 
@@ -2677,9 +2678,10 @@ Return value:
     TRUE - success
     FALSE - failure (incorrect ptr, etc.)
 --*/
+PALIMPORT
 BOOL
 PALAPI
-PAL_LOADUnloadPEFile(void * ptr);
+PAL_LOADUnloadPEFile(PVOID ptr);
 
 #ifdef UNICODE
 #define LoadLibrary LoadLibraryW
@@ -2745,9 +2747,10 @@ GetModuleFileNameExW(
 #endif
 
 // Get base address of the module containing a given symbol
-PALAPI
+PALIMPORT
 LPCVOID
-PAL_GetSymbolModuleBase(void *symbol);
+PALAPI
+PAL_GetSymbolModuleBase(PVOID symbol);
 
 PALIMPORT
 LPCSTR
@@ -2967,7 +2970,7 @@ BOOL
 PALAPI
 IsValidCodePage(
         IN UINT CodePage);
-        
+
 
 #define MB_PRECOMPOSED            0x00000001
 #define MB_ERR_INVALID_CHARS      0x00000008
@@ -3085,7 +3088,7 @@ typedef struct _RUNTIME_FUNCTION {
 #define MAXIMUM_ALLOWED           (0x02000000L)
 
 #define EVENT_MODIFY_STATE        (0x0002)
-#define EVENT_ALL_ACCESS          (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3) 
+#define EVENT_ALL_ACCESS          (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3)
 
 #define MUTANT_QUERY_STATE        (0x0001)
 #define MUTANT_ALL_ACCESS         (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | MUTANT_QUERY_STATE)
@@ -3094,18 +3097,18 @@ typedef struct _RUNTIME_FUNCTION {
 #define SEMAPHORE_MODIFY_STATE    (0x0002)
 #define SEMAPHORE_ALL_ACCESS      (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3)
 
-#define PROCESS_TERMINATE         (0x0001)  
-#define PROCESS_CREATE_THREAD     (0x0002)  
-#define PROCESS_SET_SESSIONID     (0x0004)  
-#define PROCESS_VM_OPERATION      (0x0008)  
-#define PROCESS_VM_READ           (0x0010)  
-#define PROCESS_VM_WRITE          (0x0020)  
-#define PROCESS_DUP_HANDLE        (0x0040)  
-#define PROCESS_CREATE_PROCESS    (0x0080)  
-#define PROCESS_SET_QUOTA         (0x0100)  
-#define PROCESS_SET_INFORMATION   (0x0200)  
-#define PROCESS_QUERY_INFORMATION (0x0400)  
-#define PROCESS_SUSPEND_RESUME    (0x0800)  
+#define PROCESS_TERMINATE         (0x0001)
+#define PROCESS_CREATE_THREAD     (0x0002)
+#define PROCESS_SET_SESSIONID     (0x0004)
+#define PROCESS_VM_OPERATION      (0x0008)
+#define PROCESS_VM_READ           (0x0010)
+#define PROCESS_VM_WRITE          (0x0020)
+#define PROCESS_DUP_HANDLE        (0x0040)
+#define PROCESS_CREATE_PROCESS    (0x0080)
+#define PROCESS_SET_QUOTA         (0x0100)
+#define PROCESS_SET_INFORMATION   (0x0200)
+#define PROCESS_QUERY_INFORMATION (0x0400)
+#define PROCESS_SUSPEND_RESUME    (0x0800)
 #define PROCESS_ALL_ACCESS        (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | \
                                    0xFFF)
 
@@ -3404,12 +3407,12 @@ simultaneously.
 
 Parameters
 
-lpAddend 
-[in/out] Pointer to the variable to increment. 
+lpAddend
+[in/out] Pointer to the variable to increment.
 
 Return Values
 
-The return value is the resulting incremented value. 
+The return value is the resulting incremented value.
 
 --*/
 EXTERN_C
@@ -3449,8 +3452,8 @@ simultaneously.
 
 Parameters
 
-lpAddend 
-[in/out] Pointer to the variable to decrement. 
+lpAddend
+[in/out] Pointer to the variable to decrement.
 
 Return Values
 
@@ -3496,15 +3499,15 @@ variable simultaneously.
 
 Parameters
 
-Target 
+Target
 [in/out] Pointer to the value to exchange. The function sets
 this variable to Value, and returns its prior value.
-Value 
-[in] Specifies a new value for the variable pointed to by Target. 
+Value
+[in] Specifies a new value for the variable pointed to by Target.
 
 Return Values
 
-The function returns the initial value pointed to by Target. 
+The function returns the initial value pointed to by Target.
 
 --*/
 EXTERN_C
@@ -3764,7 +3767,7 @@ PALIMPORT
 BOOL
 PALAPI
 PAL_HasGetCurrentProcessorNumber(VOID);
-    
+
 #define FORMAT_MESSAGE_ALLOCATE_BUFFER 0x00000100
 #define FORMAT_MESSAGE_IGNORE_INSERTS  0x00000200
 #define FORMAT_MESSAGE_FROM_STRING     0x00000400
@@ -3812,23 +3815,23 @@ GetCommandLineW(
 #endif
 
 PALIMPORT
-VOID 
-PALAPI 
+VOID
+PALAPI
 RtlRestoreContext(
   IN PCONTEXT ContextRecord,
   IN PEXCEPTION_RECORD ExceptionRecord
 );
 
 PALIMPORT
-VOID 
-PALAPI 
+VOID
+PALAPI
 RtlCaptureContext(
   OUT PCONTEXT ContextRecord
 );
 
 PALIMPORT
-UINT 
-PALAPI 
+UINT
+PALAPI
 GetWriteWatch(
   IN DWORD dwFlags,
   IN PVOID lpBaseAddress,
@@ -3839,16 +3842,16 @@ GetWriteWatch(
 );
 
 PALIMPORT
-UINT 
-PALAPI 
+UINT
+PALAPI
 ResetWriteWatch(
   IN LPVOID lpBaseAddress,
   IN SIZE_T dwRegionSize
 );
 
 PALIMPORT
-VOID 
-PALAPI 
+VOID
+PALAPI
 FlushProcessWriteBuffers(VOID);
 
 typedef void (*PAL_ActivationFunction)(CONTEXT *context);
@@ -3976,7 +3979,7 @@ CreatePipe(
 // NUMA related APIs
 //
 
-typedef enum _PROCESSOR_CACHE_TYPE { 
+typedef enum _PROCESSOR_CACHE_TYPE {
   CacheUnified,
   CacheInstruction,
   CacheData,
@@ -3989,7 +3992,7 @@ typedef struct _PROCESSOR_NUMBER {
   BYTE Reserved;
 } PROCESSOR_NUMBER, *PPROCESSOR_NUMBER;
 
-typedef enum _LOGICAL_PROCESSOR_RELATIONSHIP { 
+typedef enum _LOGICAL_PROCESSOR_RELATIONSHIP {
   RelationProcessorCore,
   RelationNumaNode,
   RelationCache,
@@ -4271,7 +4274,7 @@ SetThreadIdealProcessorEx(
 #define strnlen       PAL_strnlen
 #define wcsnlen       PAL_wcsnlen
 
-#ifdef _AMD64_ 
+#ifdef _AMD64_
 #define _mm_getcsr    PAL__mm_getcsr
 #define _mm_setcsr    PAL__mm_setcsr
 #endif // _AMD64_
@@ -4315,7 +4318,7 @@ See MSDN doc for memcpy
 EXTERN_C
 PALIMPORT
 DLLEXPORT
-void *PAL_memcpy (void *dest, const void *src, size_t count);
+void *PAL_memcpy (void *dest, const void * src, size_t count);
 
 PALIMPORT void * __cdecl memcpy(void *, const void *, size_t) THROW_DECL;
 
@@ -4519,7 +4522,7 @@ PALIMPORT double __cdecl cosh(double);
 PALIMPORT double __cdecl exp(double);
 PALIMPORT double __cdecl fabs(double);
 PALIMPORT double __cdecl floor(double);
-PALIMPORT double __cdecl fmod(double, double); 
+PALIMPORT double __cdecl fmod(double, double);
 PALIMPORT double __cdecl fma(double, double, double);
 PALIMPORT int __cdecl ilogb(double);
 PALIMPORT double __cdecl log(double);
@@ -4813,7 +4816,7 @@ typedef enum _PAL_Boundary {
     PAL_BoundaryTop,            // closer to main()
     PAL_BoundaryBottom,         // closer to execution
     PAL_BoundaryEH,             // out-of-band during EH
-    
+
     PAL_BoundaryMax = PAL_BoundaryEH
 } PAL_Boundary;
 
@@ -4922,10 +4925,10 @@ public:
     {
         return m_palError;
     }
-    
+
     void SuppressRelease()
     {
-        // Used to avoid calling PAL_Leave() when 
+        // Used to avoid calling PAL_Leave() when
         // another code path will explicitly do so.
         m_fEntered = FALSE;
     }
@@ -4975,7 +4978,7 @@ PALIMPORT
 VOID
 PALAPI
 PAL_FreeExceptionRecords(
-  IN EXCEPTION_RECORD *exceptionRecord, 
+  IN EXCEPTION_RECORD *exceptionRecord,
   IN CONTEXT *contextRecord);
 
 #define EXCEPTION_CONTINUE_SEARCH   0
@@ -5024,7 +5027,7 @@ public:
     PAL_SEHException()
     {
         Clear();
-    }    
+    }
 
     // The copy constructor and copy assignment operators are deleted so that the PAL_SEHException
     // can never be copied, only moved. This enables simple lifetime management of the exception and
@@ -5035,7 +5038,7 @@ public:
     PAL_SEHException(PAL_SEHException&& ex)
     {
         Move(ex);
-    }    
+    }
 
     PAL_SEHException& operator=(PAL_SEHException&& ex)
     {
@@ -5154,21 +5157,21 @@ public:
 class NativeExceptionHolderBase;
 
 PALIMPORT
-NativeExceptionHolderBase **
 PALAPI
+NativeExceptionHolderBase **
 PAL_GetNativeExceptionHolderHead();
 
 extern "C++" {
 
 //
-// This is the base class of native exception holder used to provide 
+// This is the base class of native exception holder used to provide
 // the filter function to the exception dispatcher. This allows the
 // filter to be called during the first pass to better emulate SEH
 // the xplat platforms that only have C++ exception support.
 //
 class NativeExceptionHolderBase
 {
-    // Save the address of the holder head so the destructor 
+    // Save the address of the holder head so the destructor
     // doesn't have access the slow (on Linux) TLS value again.
     NativeExceptionHolderBase **m_head;
 
@@ -5210,13 +5213,13 @@ public:
 
     // Given the currentHolder and locals stack range find the next holder starting with this one
     // To find the first holder, pass nullptr as the currentHolder.
-    static NativeExceptionHolderBase *FindNextHolder(NativeExceptionHolderBase *currentHolder, void *frameLowAddress, void *frameHighAddress);
+    static NativeExceptionHolderBase *FindNextHolder(NativeExceptionHolderBase *currentHolder, PVOID frameLowAddress, PVOID frameHighAddress);
 };
 
 //
 // This is the second part of the native exception filter holder. It is
 // templated because the lambda used to wrap the exception filter is a
-// unknown type. 
+// unknown type.
 //
 template<class FilterType>
 class NativeExceptionHolder : public NativeExceptionHolderBase
@@ -5293,8 +5296,8 @@ public:
     auto tryBlock = [](__ParamType __paramDef)                                  \
     {
 
-// Start of an exception handler. If an exception raised by the RaiseException 
-// occurs in the try block and the disposition is EXCEPTION_EXECUTE_HANDLER, 
+// Start of an exception handler. If an exception raised by the RaiseException
+// occurs in the try block and the disposition is EXCEPTION_EXECUTE_HANDLER,
 // the handler code is executed. If the disposition is EXCEPTION_CONTINUE_SEARCH,
 // the exception is rethrown. The EXCEPTION_CONTINUE_EXECUTION disposition is
 // not supported.
@@ -5339,7 +5342,7 @@ public:
     };                                  \
     const bool isFinally = true;        \
     auto finallyBlock = [&]()           \
-    {                       
+    {
 
 // End of an except or a finally block.
 #define PAL_ENDTRY                      \
@@ -5410,7 +5413,7 @@ public:
 #endif // __cplusplus
 
 // Platform-specific library naming
-// 
+//
 #ifdef __APPLE__
 #define MAKEDLLNAME_W(name) u"lib" name u".dylib"
 #define MAKEDLLNAME_A(name)  "lib" name  ".dylib"
@@ -5436,16 +5439,16 @@ public:
 #define PAL_SHLIB_SUFFIX_W  u".so"
 #endif
 
-#define DBG_EXCEPTION_HANDLED            ((DWORD   )0x00010001L)    
-#define DBG_CONTINUE                     ((DWORD   )0x00010002L)    
-#define DBG_EXCEPTION_NOT_HANDLED        ((DWORD   )0x80010001L)    
+#define DBG_EXCEPTION_HANDLED            ((DWORD   )0x00010001L)
+#define DBG_CONTINUE                     ((DWORD   )0x00010002L)
+#define DBG_EXCEPTION_NOT_HANDLED        ((DWORD   )0x80010001L)
 
-#define DBG_TERMINATE_THREAD             ((DWORD   )0x40010003L)    
-#define DBG_TERMINATE_PROCESS            ((DWORD   )0x40010004L)    
-#define DBG_CONTROL_C                    ((DWORD   )0x40010005L)    
-#define DBG_RIPEXCEPTION                 ((DWORD   )0x40010007L)    
-#define DBG_CONTROL_BREAK                ((DWORD   )0x40010008L)    
-#define DBG_COMMAND_EXCEPTION            ((DWORD   )0x40010009L)    
+#define DBG_TERMINATE_THREAD             ((DWORD   )0x40010003L)
+#define DBG_TERMINATE_PROCESS            ((DWORD   )0x40010004L)
+#define DBG_CONTROL_C                    ((DWORD   )0x40010005L)
+#define DBG_RIPEXCEPTION                 ((DWORD   )0x40010007L)
+#define DBG_CONTROL_BREAK                ((DWORD   )0x40010008L)
+#define DBG_COMMAND_EXCEPTION            ((DWORD   )0x40010009L)
 
 #define STATUS_USER_APC                  ((DWORD   )0x000000C0L)
 #define STATUS_GUARD_PAGE_VIOLATION      ((DWORD   )0x80000001L)
index fe7a4c8..3fefcef 100644 (file)
@@ -143,7 +143,7 @@ typedef struct _eh_frame_hdr
     //   {
     //      encoded_t start_ip;     // first address covered by this FDE
     //      encoded_t fde_offset;   // offset of the FDE
-    //   } binary_search_table[fde_count]; 
+    //   } binary_search_table[fde_count];
 } eh_frame_hdr;
 
 // "DW_EH_PE_datarel|DW_EH_PE_sdata4" encoded fde table entry
@@ -173,7 +173,7 @@ typedef struct dwarf_cie_info
     unsigned int signal_frame : 1;
 } dwarf_cie_info_t;
 
-static bool 
+static bool
 ReadValue8(const libunwindInfo* info, unw_word_t* addr, uint8_t* valp)
 {
     uint8_t value;
@@ -185,7 +185,7 @@ ReadValue8(const libunwindInfo* info, unw_word_t* addr, uint8_t* valp)
     return true;
 }
 
-static bool 
+static bool
 ReadValue16(const libunwindInfo* info, unw_word_t* addr, uint16_t* valp)
 {
     uint16_t value;
@@ -197,7 +197,7 @@ ReadValue16(const libunwindInfo* info, unw_word_t* addr, uint16_t* valp)
     return true;
 }
 
-static bool 
+static bool
 ReadValue32(const libunwindInfo* info, unw_word_t* addr, uint32_t* valp)
 {
     uint32_t value;
@@ -209,7 +209,7 @@ ReadValue32(const libunwindInfo* info, unw_word_t* addr, uint32_t* valp)
     return true;
 }
 
-static bool 
+static bool
 ReadValue64(const libunwindInfo* info, unw_word_t* addr, uint64_t* valp)
 {
     uint64_t value;
@@ -221,7 +221,7 @@ ReadValue64(const libunwindInfo* info, unw_word_t* addr, uint64_t* valp)
     return true;
 }
 
-static bool 
+static bool
 ReadPointer(const libunwindInfo* info, unw_word_t* addr, unw_word_t* valp)
 {
 #ifdef BIT64
@@ -241,7 +241,7 @@ ReadPointer(const libunwindInfo* info, unw_word_t* addr, unw_word_t* valp)
 }
 
 // Read a unsigned "little-endian base 128" value. See Chapter 7.6 of DWARF spec v3.
-static bool 
+static bool
 ReadULEB128(const libunwindInfo* info, unw_word_t* addr, unw_word_t* valp)
 {
     unw_word_t value = 0;
@@ -262,7 +262,7 @@ ReadULEB128(const libunwindInfo* info, unw_word_t* addr, unw_word_t* valp)
 }
 
 // Read a signed "little-endian base 128" value. See Chapter 7.6 of DWARF spec v3.
-static bool 
+static bool
 ReadSLEB128(const libunwindInfo* info, unw_word_t* addr, unw_word_t* valp)
 {
     unw_word_t value = 0;
@@ -278,7 +278,7 @@ ReadSLEB128(const libunwindInfo* info, unw_word_t* addr, unw_word_t* valp)
         shift += 7;
     } while (byte & 0x80);
 
-    if ((shift < (8 * sizeof(unw_word_t))) && ((byte & 0x40) != 0)) {
+    if (((size_t)shift < (8 * sizeof(unw_word_t))) && ((byte & 0x40) != 0)) {
         value |= ((unw_word_t)-1) << shift;
     }
 
@@ -286,7 +286,7 @@ ReadSLEB128(const libunwindInfo* info, unw_word_t* addr, unw_word_t* valp)
     return true;
 }
 
-static bool 
+static bool
 ReadEncodedPointer(const libunwindInfo* info, unw_word_t* addr, unsigned char encoding, unw_word_t funcRel, unw_word_t* valp)
 {
     unw_word_t initialAddr = *addr;
@@ -413,7 +413,7 @@ ReadEncodedPointer(const libunwindInfo* info, unw_word_t* addr, unsigned char en
     return true;
 }
 
-static bool 
+static bool
 LookupTableEntry(const libunwindInfo* info, int32_t ip, unw_word_t tableAddr, size_t tableCount, table_entry* entry, bool* found)
 {
     size_t low, high, mid;
@@ -535,7 +535,7 @@ ParseCie(const libunwindInfo* info, unw_word_t addr, dwarf_cie_info_t* dci)
     uint8_t augmentationString[8];
     memset(augmentationString, 0, sizeof(augmentationString));
 
-    for (int i = 0; i < sizeof(augmentationString); i++)
+    for (size_t i = 0; i < sizeof(augmentationString); i++)
     {
         if (!ReadValue8(info, &addr, &ch)) {
             return false;
@@ -570,7 +570,7 @@ ParseCie(const libunwindInfo* info, unw_word_t addr, dwarf_cie_info_t* dci)
     }
 
     // Parse the augmentation string
-    for (int i = 0; i < sizeof(augmentationString); i++)
+    for (size_t i = 0; i < sizeof(augmentationString); i++)
     {
         bool done = false;
         unw_word_t augmentationSize;
@@ -671,12 +671,12 @@ ExtractProcInfoFromFde(const libunwindInfo* info, unw_word_t* addrp, unw_proc_in
         if (cieOffset == 0) {
             return true;
         }
-        // DWARF says that the CIE_pointer in the FDE is a .debug_frame-relative offset, 
-        // but the GCC-generated .eh_frame sections instead store a "pcrelative" offset, 
+        // DWARF says that the CIE_pointer in the FDE is a .debug_frame-relative offset,
+        // but the GCC-generated .eh_frame sections instead store a "pcrelative" offset,
         // which is just as fine as it's self-contained
         cieAddr = cieOffsetAddr - cieOffset;
     }
-    else 
+    else
     {
         int64_t cieOffset = 0;
 
@@ -694,8 +694,8 @@ ExtractProcInfoFromFde(const libunwindInfo* info, unw_word_t* addrp, unw_proc_in
         if (cieOffset == 0) {
             return true;
         }
-        // DWARF says that the CIE_pointer in the FDE is a .debug_frame-relative offset, 
-        // but the GCC-generated .eh_frame sections instead store a "pcrelative" offset, 
+        // DWARF says that the CIE_pointer in the FDE is a .debug_frame-relative offset,
+        // but the GCC-generated .eh_frame sections instead store a "pcrelative" offset,
         // which is just as fine as it's self-contained
         cieAddr = (unw_word_t)((uint64_t)cieOffsetAddr - cieOffset);
     }
@@ -765,13 +765,13 @@ ExtractProcInfoFromFde(const libunwindInfo* info, unw_word_t* addrp, unw_proc_in
 }
 
 
-static int 
+static int
 get_dyn_info_list_addr(unw_addr_space_t as, unw_word_t *dilap, void *arg)
 {
     return -UNW_ENOINFO;
 }
 
-static int 
+static int
 access_mem(unw_addr_space_t as, unw_word_t addr, unw_word_t *valp, int write, void *arg)
 {
     if (write)
@@ -791,7 +791,7 @@ access_mem(unw_addr_space_t as, unw_word_t addr, unw_word_t *valp, int write, vo
     }
 }
 
-static int 
+static int
 access_reg(unw_addr_space_t as, unw_regnum_t regnum, unw_word_t *valp, int write, void *arg)
 {
     if (write)
@@ -851,28 +851,28 @@ access_reg(unw_addr_space_t as, unw_regnum_t regnum, unw_word_t *valp, int write
     return UNW_ESUCCESS;
 }
 
-static int 
+static int
 access_fpreg(unw_addr_space_t as, unw_regnum_t regnum, unw_fpreg_t *fpvalp, int write, void *arg)
 {
     ASSERT("Not supposed to be ever called\n");
     return -UNW_EINVAL;
 }
 
-static int 
+static int
 resume(unw_addr_space_t as, unw_cursor_t *cp, void *arg)
 {
     ASSERT("Not supposed to be ever called\n");
     return -UNW_EINVAL;
 }
 
-static int 
+static int
 get_proc_name(unw_addr_space_t as, unw_word_t addr, char *bufp, size_t buf_len, unw_word_t *offp, void *arg)
 {
     ASSERT("Not supposed to be ever called\n");
     return -UNW_EINVAL;
 }
 
-static int 
+static int
 find_proc_info(unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pip, int need_unwind_info, void *arg)
 {
     const auto *info = (libunwindInfo*)arg;
@@ -948,7 +948,7 @@ find_proc_info(unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pip, int nee
         ERROR("ELF: reading ehFrameHdrAddr %p\n", ehFrameHdrAddr);
         return -UNW_EINVAL;
     }
-    TRACE("ehFrameHdrAddr %p version %d eh_frame_ptr_enc %d fde_count_enc %d table_enc %d\n", 
+    TRACE("ehFrameHdrAddr %p version %d eh_frame_ptr_enc %d fde_count_enc %d table_enc %d\n",
         ehFrameHdrAddr, ehFrameHdr.version, ehFrameHdr.eh_frame_ptr_enc, ehFrameHdr.fde_count_enc, ehFrameHdr.table_enc);
 
     if (ehFrameHdr.version != DW_EH_VERSION) {
@@ -1000,7 +1000,7 @@ find_proc_info(unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pip, int nee
     return UNW_ESUCCESS;
 }
 
-static void 
+static void
 put_unwind_info(unw_addr_space_t as, unw_proc_info_t *pip, void *arg)
 {
     if (pip->unwind_info != nullptr) {
index 5cfea0c..1d39605 100644 (file)
@@ -58,7 +58,7 @@ PHARDWARE_EXCEPTION_SAFETY_CHECK_FUNCTION g_safeExceptionCheckFunction = NULL;
 
 PGET_GCMARKER_EXCEPTION_CODE g_getGcMarkerExceptionCode = NULL;
 
-// Return address of the SEHProcessException, which is used to enable walking over 
+// Return address of the SEHProcessException, which is used to enable walking over
 // the signal handler trampoline on some Unixes where the libunwind cannot do that.
 void* g_SEHProcessExceptionReturnAddress = NULL;
 
@@ -78,7 +78,7 @@ Return value :
     TRUE  if SEH support initialization succeeded
     FALSE otherwise
 --*/
-BOOL 
+BOOL
 SEHInitialize (CPalThread *pthrCurrent, DWORD flags)
 {
     if (!SEHInitializeSignals(pthrCurrent, flags))
@@ -101,9 +101,9 @@ Parameters :
     None
 
     (no return value)
-    
+
 --*/
-VOID 
+VOID
 SEHCleanup()
 {
     TRACE("Cleaning up SEH\n");
@@ -127,7 +127,7 @@ Return value:
     None
 --*/
 VOID
-PALAPI 
+PALAPI
 PAL_SetHardwareExceptionHandler(
     IN PHARDWARE_EXCEPTION_HANDLER exceptionHandler,
     IN PHARDWARE_EXCEPTION_SAFETY_CHECK_FUNCTION exceptionCheckFunction)
@@ -149,7 +149,7 @@ Return value:
     None
 --*/
 VOID
-PALAPI 
+PALAPI
 PAL_SetGetGcMarkerExceptionCode(
     IN PGET_GCMARKER_EXCEPTION_CODE getGcMarkerExceptionCode)
 {
@@ -172,7 +172,7 @@ Parameters:
     PAL_SEHException* ex - the exception to throw.
 --*/
 VOID
-PALAPI 
+PALAPI
 PAL_ThrowExceptionFromContext(CONTEXT* context, PAL_SEHException* ex)
 {
     // We need to make a copy of the exception off stack, since the "ex" is located in one of the stack
@@ -244,7 +244,7 @@ Parameters:
     PAL_SEHException* exception
 
 Return value:
-    Returns TRUE if the exception happened in managed code and the execution should 
+    Returns TRUE if the exception happened in managed code and the execution should
     continue (with possibly modified context).
     Returns FALSE if the exception happened in managed code and it was not handled.
     In case the exception was handled by calling a catch handler, it doesn't return at all.
@@ -364,8 +364,8 @@ PAL_ERROR SEHDisable(CPalThread *pthrCurrent)
 
 --*/
 
-extern "C" 
-void 
+extern "C"
+void
 PALAPI
 PAL_CatchHardwareExceptionHolderEnter()
 {
@@ -403,21 +403,20 @@ NativeExceptionHolderBase *t_nativeExceptionHolderHead = nullptr;
 
 extern "C"
 NativeExceptionHolderBase **
-PALAPI
 PAL_GetNativeExceptionHolderHead()
 {
     return &t_nativeExceptionHolderHead;
 }
 
 NativeExceptionHolderBase *
-NativeExceptionHolderBase::FindNextHolder(NativeExceptionHolderBase *currentHolder, void *stackLowAddress, void *stackHighAddress)
+NativeExceptionHolderBase::FindNextHolder(NativeExceptionHolderBase *currentHolder, PVOID stackLowAddress, PVOID stackHighAddress)
 {
     NativeExceptionHolderBase *holder = (currentHolder == nullptr) ? t_nativeExceptionHolderHead : currentHolder->m_next;
 
     while (holder != nullptr)
     {
         if (((void *)holder >= stackLowAddress) && ((void *)holder < stackHighAddress))
-        { 
+        {
             return holder;
         }
         // Get next holder
index 928a839..645b3e6 100644 (file)
@@ -87,10 +87,10 @@ GetFullPathNameA(
             SetLastError(ERROR_NOT_ENOUGH_MEMORY);
             goto done;
         }
-    }   
+    }
     else
     {
-        
+
         /* build full path */
         if(!GetCurrentDirectoryA(unixPath))
         {
@@ -100,7 +100,7 @@ GetFullPathNameA(
             SetLastError(ERROR_INTERNAL_ERROR);
             goto done;
         }
-        
+
         if (!unixPath.Append("/", 1) ||
             !unixPath.Append(lpFileName,strlen(lpFileName))
            )
@@ -115,7 +115,7 @@ GetFullPathNameA(
     unixPathBuf = unixPath.OpenStringBuffer(unixPath.GetCount());
     /* do conversion to Unix path */
     FILEDosToUnixPathA( unixPathBuf );
+
     /* now we can canonicalize this */
     FILECanonicalizePath(unixPathBuf);
 
@@ -147,9 +147,9 @@ GetFullPathNameA(
             nRet = 0;
             goto done;
         }
-        else 
+        else
         {
-            (*lpFilePart)++; 
+            (*lpFilePart)++;
         }
     }
 
@@ -188,10 +188,10 @@ GetFullPathNameW(
     ENTRY("GetFullPathNameW(lpFileName=%p (%S), nBufferLength=%u, lpBuffer=%p"
           ", lpFilePart=%p)\n",
           lpFileName?lpFileName:W16_NULLSTRING,
-          lpFileName?lpFileName:W16_NULLSTRING, nBufferLength, 
+          lpFileName?lpFileName:W16_NULLSTRING, nBufferLength,
           lpBuffer, lpFilePart);
 
-    
+
     fileNameLength = WideCharToMultiByte(CP_ACP, 0, lpFileName,
                                          -1, NULL, 0, NULL, NULL);
     if (fileNameLength == 0)
@@ -204,9 +204,9 @@ GetFullPathNameW(
     {
         fileNameA = static_cast<LPSTR>(alloca(fileNameLength));
     }
-    
+
     /* Now convert lpFileName to ANSI. */
-    srcSize = WideCharToMultiByte (CP_ACP, 0, lpFileName, 
+    srcSize = WideCharToMultiByte (CP_ACP, 0, lpFileName,
                                    -1, fileNameA, fileNameLength,
                                    NULL, NULL );
     if( srcSize == 0 )
@@ -216,7 +216,7 @@ GetFullPathNameW(
         SetLastError(ERROR_INVALID_PARAMETER);
         goto done;
     }
-    
+
     bufferASize = nBufferLength * MaxWCharToAcpLengthRatio;
     bufferA = bufferAPS.OpenStringBuffer(bufferASize);
     if (NULL == bufferA)
@@ -226,14 +226,14 @@ GetFullPathNameW(
     }
     length = GetFullPathNameA(fileNameA, bufferASize, bufferA, &lpFilePartA);
     bufferAPS.CloseBuffer(length);
-    
+
     if (length == 0 || length > bufferASize)
     {
         /* Last error is set by GetFullPathNameA */
         nRet = length;
         goto done;
     }
-    
+
     /* Convert back to Unicode the result */
     nRet = MultiByteToWideChar( CP_ACP, 0, bufferA, -1,
                                 lpBuffer, nBufferLength );
@@ -277,7 +277,7 @@ Function:
 See MSDN doc.
 
 Note:
-  Since short path names are not implemented (nor supported) in the PAL, 
+  Since short path names are not implemented (nor supported) in the PAL,
   this function simply copies the given path into the new buffer.
 
 --*/
@@ -322,7 +322,7 @@ GetLongPathNameW(
         {
             ERROR("Buffer is too small, need %d characters\n", dwPathLen);
             SetLastError( ERROR_INSUFFICIENT_BUFFER );
-        } else 
+        } else
         {
             if ( lpszShortPath != lpszLongPath )
             {
@@ -349,7 +349,7 @@ Function:
 See MSDN doc.
 
 Note:
-  Since short path names are not implemented (nor supported) in the PAL, 
+  Since short path names are not implemented (nor supported) in the PAL,
   this function simply copies the given path into the new buffer.
 
 --*/
@@ -394,7 +394,7 @@ GetShortPathNameW(
         {
             ERROR("Buffer is too small, need %d characters\n", dwPathLen);
             SetLastError( ERROR_INSUFFICIENT_BUFFER );
-        } else 
+        } else
         {
             if ( lpszLongPath != lpszShortPath )
             {
@@ -457,7 +457,7 @@ GetTempPathA(
     dwPathLen = GetEnvironmentVariableA("TMPDIR", lpBuffer, nBufferLength);
     if (dwPathLen > 0)
     {
-        /* The env var existed. dwPathLen will be the length without null termination 
+        /* The env var existed. dwPathLen will be the length without null termination
          * if the entire value was successfully retrieved, or it'll be the length
          * required to store the value with null termination.
          */
@@ -466,7 +466,7 @@ GetTempPathA(
             /* The environment variable fit in the buffer. Make sure it ends with '/'. */
             if (lpBuffer[dwPathLen - 1] != '/')
             {
-                /* If adding the slash would still fit in our provided buffer, do it.  Otherwise, 
+                /* If adding the slash would still fit in our provided buffer, do it.  Otherwise,
                  * let the caller know how much space would be needed.
                  */
                 if (dwPathLen + 2 <= nBufferLength)
@@ -485,7 +485,7 @@ GetTempPathA(
             /* The value is too long for the supplied buffer.  dwPathLen will now be the
              * length required to hold the value, but we don't know whether that value
              * is going to be '/' terminated.  Since we'll need enough space for the '/', and since
-             * a caller would assume that the dwPathLen we return will be sufficient, 
+             * a caller would assume that the dwPathLen we return will be sufficient,
              * we make sure to account for it in dwPathLen even if that means we end up saying
              * one more byte of space is needed than actually is.
              */
@@ -496,7 +496,7 @@ GetTempPathA(
     {
         /* no luck, use /tmp/ or /data/local/tmp on Android */
         const char *defaultDir = TEMP_DIRECTORY_PATH;
-        int defaultDirLen = strlen(defaultDir);
+        size_t defaultDirLen = strlen(defaultDir);
         if (defaultDirLen < nBufferLength)
         {
             dwPathLen = defaultDirLen;
@@ -548,7 +548,7 @@ GetTempPathW(
 
     char TempBuffer[nBufferLength > 0 ? nBufferLength : 1];
     DWORD dwRetVal = GetTempPathA( nBufferLength, TempBuffer );
-   
+
     if ( dwRetVal >= nBufferLength )
     {
         ERROR( "lpBuffer was not large enough.\n" )
@@ -558,7 +558,7 @@ GetTempPathW(
     else if ( dwRetVal != 0 )
     {
         /* Convert to wide. */
-        if ( 0 == MultiByteToWideChar( CP_ACP, 0, TempBuffer, -1, 
+        if ( 0 == MultiByteToWideChar( CP_ACP, 0, TempBuffer, -1,
                                        lpBuffer, dwRetVal + 1 ) )
         {
             ASSERT( "An error occurred while converting the string to wide.\n" );
@@ -684,7 +684,7 @@ FILEDosToUnixPathA(
        Truncate at pPointAtDot, unless the dots are path specifiers (. or ..) */
     if (pPointAtDot)
     {
-        /* make sure the trailing dots don't follow a '/', and that they aren't 
+        /* make sure the trailing dots don't follow a '/', and that they aren't
            the only thing in the name */
         if(pPointAtDot != lpPath && *(pPointAtDot-1) != '/')
         {
@@ -733,7 +733,7 @@ FILEDosToUnixPathW(
     if (!lpPath)
     {
         return;
-    }  
+    }
 
     for (p = lpPath; *p; p++)
     {
@@ -812,7 +812,7 @@ FILEDosToUnixPathW(
        Truncate at pPointAtDot, unless the dots are path specifiers (. or ..) */
     if (pPointAtDot)
     {
-        /* make sure the trailing dots don't follow a '/', and that they aren't 
+        /* make sure the trailing dots don't follow a '/', and that they aren't
            the only thing in the name */
         if(pPointAtDot != lpPath && *(pPointAtDot-1) != '/')
         {
@@ -927,18 +927,18 @@ LPCSTR FILEGetFileNameFromFullPathA( LPCSTR lpFullPath )
 
 /*++
 FILECanonicalizePath
-    Removes all instances of '/./', '/../' and '//' from an absolute path. 
-    
+    Removes all instances of '/./', '/../' and '//' from an absolute path.
+
 Parameters:
     LPSTR lpUnixPath : absolute path to modify, in Unix format
 
-(no return value)                                             
+(no return value)
+
 Notes :
 -behavior is undefined if path is not absolute
--the order of steps *is* important: /one/./../two would give /one/two 
+-the order of steps *is* important: /one/./../two would give /one/two
  instead of /two if step 3 was done before step 2
--reason for this function is that GetFullPathName can't use realpath(), since 
+-reason for this function is that GetFullPathName can't use realpath(), since
  realpath() requires the given path to be valid and GetFullPathName does not.
 --*/
 void FILECanonicalizePath(LPSTR lpUnixPath)
@@ -995,14 +995,14 @@ void FILECanonicalizePath(LPSTR lpUnixPath)
             memmove(lpUnixPath, lpUnixPath+3,strlen(lpUnixPath+3)+1);
             continue;
         }
-        
-        /* null-terminate the string before the '/../', so that strrchr will 
+
+        /* null-terminate the string before the '/../', so that strrchr will
            start looking right before it */
         *dotdotptr = '\0';
         slashptr = strrchr(lpUnixPath,'/');
         if(NULL == slashptr)
         {
-            /* this happens if this function was called with a relative path. 
+            /* this happens if this function was called with a relative path.
                don't do that.  */
             ASSERT("can't find leading '/' before '/../ sequence\n");
             break;
@@ -1032,7 +1032,7 @@ void FILECanonicalizePath(LPSTR lpUnixPath)
             }
             else
             {
-                *slashptr = '\0';    
+                *slashptr = '\0';
             }
         }
     }
@@ -1095,11 +1095,11 @@ SearchPathA(
     ENTRY("SearchPathA(lpPath=%p (%s), lpFileName=%p (%s), lpExtension=%p, "
           "nBufferLength=%u, lpBuffer=%p, lpFilePart=%p)\n",
       lpPath,
-      lpPath, lpFileName, lpFileName, lpExtension, nBufferLength, lpBuffer, 
+      lpPath, lpFileName, lpFileName, lpExtension, nBufferLength, lpBuffer,
           lpFilePart);
 
     /* validate parameters */
-    
+
     if(NULL == lpPath)
     {
         ASSERT("lpPath may not be NULL\n");
@@ -1121,7 +1121,7 @@ SearchPathA(
 
     FileNameLength = strlen(lpFileName);
 
-    /* special case : if file name contains absolute path, don't search the 
+    /* special case : if file name contains absolute path, don't search the
        provided path */
     if('\\' == lpFileName[0] || '/' == lpFileName[0])
     {
@@ -1135,7 +1135,7 @@ SearchPathA(
         }
         dw = GetFullPathNameA(lpFileName, length+1, CanonicalFullPath, NULL);
         CanonicalFullPathPS.CloseBuffer(dw);
-        
+
         if (length+1 < dw)
         {
             CanonicalFullPath = CanonicalFullPathPS.OpenStringBuffer(dw-1);
@@ -1149,7 +1149,7 @@ SearchPathA(
             CanonicalFullPathPS.CloseBuffer(dw);
         }
 
-        if (dw == 0) 
+        if (dw == 0)
         {
             WARN("couldn't canonicalize path <%s>, error is %#x. failing.\n",
                  lpFileName, GetLastError());
@@ -1167,13 +1167,13 @@ SearchPathA(
     else
     {
         LPCSTR pNextPath;
-        
+
         pNextPath = lpPath;
-    
-        while (*pNextPath) 
+
+        while (*pNextPath)
         {
             pPathStart = pNextPath;
-            
+
             /* get a pointer to the end of the first path in pPathStart */
             pPathEnd = strchr(pPathStart, ':');
             if (!pPathEnd)
@@ -1188,16 +1188,16 @@ SearchPathA(
                 /* point to the next component in the path string */
                 pNextPath = pPathEnd+1;
             }
-    
+
             PathLength = pPathEnd-pPathStart;
-    
+
             if(0 == PathLength)
             {
                 /* empty component : there were 2 consecutive ':' */
                 continue;
             }
-    
-            /* Construct a pathname by concatenating one path from lpPath, '/' 
+
+            /* Construct a pathname by concatenating one path from lpPath, '/'
                and lpFileName */
             FullPathLength = PathLength + FileNameLength;
             FullPath = FullPathPS.OpenStringBuffer(FullPathLength+1);
@@ -1216,7 +1216,7 @@ SearchPathA(
                 goto done;
             }
 
-            FullPathPS.CloseBuffer(FullPathLength+1);            
+            FullPathPS.CloseBuffer(FullPathLength+1);
             /* Canonicalize the path to deal with back-to-back '/', etc. */
             length = MAX_LONGPATH; //Use it for first try
             CanonicalFullPath = CanonicalFullPathPS.OpenStringBuffer(length);
@@ -1228,7 +1228,7 @@ SearchPathA(
             dw = GetFullPathNameA(FullPath, length+1,
                                   CanonicalFullPath, NULL);
             CanonicalFullPathPS.CloseBuffer(dw);
-            
+
             if (length+1 < dw)
             {
                 CanonicalFullPath = CanonicalFullPathPS.OpenStringBuffer(dw-1);
@@ -1236,15 +1236,15 @@ SearchPathA(
                                       CanonicalFullPath, NULL);
                 CanonicalFullPathPS.CloseBuffer(dw);
             }
-            
-            if (dw == 0) 
+
+            if (dw == 0)
             {
                 /* Call failed - possibly low memory.  Skip the path */
                 WARN("couldn't canonicalize path <%s>, error is %#x. "
                      "skipping it\n", FullPath, GetLastError());
                 continue;
             }
-    
+
             /* see if the file exists */
             if(0 == access(CanonicalFullPath, F_OK))
             {
@@ -1255,7 +1255,7 @@ SearchPathA(
         }
     }
 
-    if (nRet == 0) 
+    if (nRet == 0)
     {
        /* file not found anywhere; say so. in Windows, this always seems to say
           FILE_NOT_FOUND, even if path doesn't exist */
@@ -1263,7 +1263,7 @@ SearchPathA(
     }
     else
     {
-        if (nRet < nBufferLength) 
+        if (nRet < nBufferLength)
         {
             if(NULL == lpBuffer)
             {
@@ -1274,7 +1274,7 @@ SearchPathA(
                 nRet = 0;
                 goto done;
             }
-            
+
             if (strcpy_s(lpBuffer, nBufferLength, CanonicalFullPath) != SAFECRT_SUCCESS)
             {
                 ERROR("strcpy_s failed!\n");
@@ -1299,7 +1299,7 @@ SearchPathA(
         }
         else
         {
-            /* if buffer is too small, report required length, including 
+            /* if buffer is too small, report required length, including
                terminating null */
             nRet++;
         }
@@ -1355,11 +1355,11 @@ SearchPathW(
     ENTRY("SearchPathW(lpPath=%p (%S), lpFileName=%p (%S), lpExtension=%p, "
           "nBufferLength=%u, lpBuffer=%p, lpFilePart=%p)\n",
          lpPath,
-         lpPath, lpFileName, lpFileName, lpExtension, nBufferLength, lpBuffer, 
+         lpPath, lpFileName, lpFileName, lpExtension, nBufferLength, lpBuffer,
           lpFilePart);
 
     /* validate parameters */
-    
+
     if(NULL == lpPath)
     {
         ASSERT("lpPath may not be NULL\n");
@@ -1377,9 +1377,9 @@ SearchPathW(
         ASSERT("lpExtension must be NULL, is %p instead\n", lpExtension);
         SetLastError(ERROR_INVALID_PARAMETER);
         goto done;
-    }          
+    }
 
-    /* special case : if file name contains absolute path, don't search the 
+    /* special case : if file name contains absolute path, don't search the
        provided path */
     if('\\' == lpFileName[0] || '/' == lpFileName[0])
     {
@@ -1404,8 +1404,8 @@ SearchPathW(
             dw = GetFullPathNameW(lpFileName, dw, CanonicalPath, NULL);
             CanonicalPathPS.CloseBuffer(dw);
         }
-        
-        if (dw == 0) 
+
+        if (dw == 0)
         {
             WARN("couldn't canonicalize path <%S>, error is %#x. failing.\n",
                  lpPath, GetLastError());
@@ -1424,7 +1424,7 @@ SearchPathW(
            canonical_size = WideCharToMultiByte(CP_ACP, 0, CanonicalPath, -1,
                            AnsiPath, CanonicalPathLength, NULL, NULL);
            AnsiPathPS.CloseBuffer(canonical_size);
-           
+
         if(0 == access(AnsiPath, F_OK))
         {
             /* found it */
@@ -1436,13 +1436,13 @@ SearchPathW(
         LPCWSTR pNextPath;
 
         pNextPath = lpPath;
-    
+
         FileNameLength = PAL_wcslen(lpFileName);
 
-        while (*pNextPath) 
+        while (*pNextPath)
         {
             pPathStart = pNextPath;
-    
+
             /* get a pointer to the end of the first path in pPathStart */
             pPathEnd = PAL_wcschr(pPathStart, ':');
             if (!pPathEnd)
@@ -1457,16 +1457,16 @@ SearchPathW(
                 /* point to the next component in the path string */
                 pNextPath = pPathEnd+1;
             }
-    
+
             PathLength = pPathEnd-pPathStart;
-    
+
             if(0 == PathLength)
             {
                 /* empty component : there were 2 consecutive ':' */
                 continue;
             }
-    
-            /* Construct a pathname by concatenating one path from lpPath, '/' 
+
+            /* Construct a pathname by concatenating one path from lpPath, '/'
                and lpFileName */
             FullPathLength = PathLength + FileNameLength;
             FullPath = FullPathPS.OpenStringBuffer(FullPathLength+1);
@@ -1478,9 +1478,9 @@ SearchPathW(
             memcpy(FullPath, pPathStart, PathLength*sizeof(WCHAR));
             FullPath[PathLength] = '/';
             PAL_wcscpy(&FullPath[PathLength+1], lpFileName);
-            
+
             FullPathPS.CloseBuffer(FullPathLength+1);
-    
+
             /* Canonicalize the path to deal with back-to-back '/', etc. */
             length = MAX_LONGPATH; //Use it for first try
             CanonicalPath = CanonicalPathPS.OpenStringBuffer(length);
@@ -1492,7 +1492,7 @@ SearchPathW(
             dw = GetFullPathNameW(FullPath, length+1,
                                   CanonicalPath, NULL);
             CanonicalPathPS.CloseBuffer(dw);
-            
+
             if (length+1 < dw)
             {
                 CanonicalPath = CanonicalPathPS.OpenStringBuffer(dw-1);
@@ -1504,15 +1504,15 @@ SearchPathW(
                 dw = GetFullPathNameW(FullPath, dw, CanonicalPath, NULL);
                 CanonicalPathPS.CloseBuffer(dw);
             }
-            
-            if (dw == 0) 
+
+            if (dw == 0)
             {
                 /* Call failed - possibly low memory.  Skip the path */
                 WARN("couldn't canonicalize path <%S>, error is %#x. "
                      "skipping it\n", FullPath, GetLastError());
                 continue;
             }
-    
+
             /* see if the file exists */
             CanonicalPathLength = (PAL_wcslen(CanonicalPath)+1) * MaxWCharToAcpLengthRatio;
             AnsiPath = AnsiPathPS.OpenStringBuffer(CanonicalPathLength);
@@ -1524,7 +1524,7 @@ SearchPathW(
             canonical_size = WideCharToMultiByte(CP_ACP, 0, CanonicalPath, -1,
                                 AnsiPath, CanonicalPathLength, NULL, NULL);
             AnsiPathPS.CloseBuffer(canonical_size);
-               
+
             if(0 == access(AnsiPath, F_OK))
             {
                 /* found it */
@@ -1534,7 +1534,7 @@ SearchPathW(
         }
     }
 
-    if (nRet == 0) 
+    if (nRet == 0)
     {
        /* file not found anywhere; say so. in Windows, this always seems to say
           FILE_NOT_FOUND, even if path doesn't exist */
@@ -1542,7 +1542,7 @@ SearchPathW(
     }
     else
     {
-        /* find out the required buffer size, copy path to buffer if it's 
+        /* find out the required buffer size, copy path to buffer if it's
            large enough */
         nRet = PAL_wcslen(CanonicalPath)+1;
         if(nRet <= nBufferLength)
@@ -1558,10 +1558,10 @@ SearchPathW(
             }
             PAL_wcscpy(lpBuffer, CanonicalPath);
 
-            /* don't include the null-terminator in the count if buffer was 
+            /* don't include the null-terminator in the count if buffer was
                large enough */
             nRet--;
-            
+
             if(NULL != lpFilePart)
             {
                 *lpFilePart = PAL_wcsrchr(lpBuffer, '/');
index e39cd6e..e50ed56 100644 (file)
@@ -87,7 +87,7 @@ using namespace CorUnix;
 CRITICAL_SECTION module_critsec;
 
 /* always the first, in the in-load-order list */
-MODSTRUCT exe_module; 
+MODSTRUCT exe_module;
 MODSTRUCT *pal_module = nullptr;
 
 char * g_szCoreCLRPath = nullptr;
@@ -153,7 +153,7 @@ LoadLibraryExA(
     IN /*Reserved*/ HANDLE hFile,
     IN DWORD dwFlags)
 {
-    if (dwFlags != 0) 
+    if (dwFlags != 0)
     {
         // UNIXTODO: Implement this!
         ASSERT("Needs Implementation!!!");
@@ -195,7 +195,7 @@ LoadLibraryExA(
     LOGEXIT("LoadLibraryExA returns HMODULE %p\n", hModule);
     PERF_EXIT(LoadLibraryExA);
     return hModule;
-    
+
 }
 
 /*++
@@ -211,13 +211,13 @@ LoadLibraryExW(
     IN /*Reserved*/ HANDLE hFile,
     IN DWORD dwFlags)
 {
-    if (dwFlags != 0) 
+    if (dwFlags != 0)
     {
         // UNIXTODO: Implement this!
         ASSERT("Needs Implementation!!!");
         return nullptr;
     }
-    
+
     CHAR * lpstr;
     INT name_length;
     PathCharString pathstr;
@@ -307,7 +307,7 @@ GetProcAddress(
     }
 
     // Get the symbol's address.
-    
+
     // If we're looking for a symbol inside the PAL, we try the PAL_ variant
     // first because otherwise we run the risk of having the non-PAL_
     // variant preferred over the PAL's implementation.
@@ -416,7 +416,7 @@ FreeLibraryAndExitThread(
     IN DWORD dwExitCode)
 {
     PERF_ENTRY(FreeLibraryAndExitThread);
-    ENTRY("FreeLibraryAndExitThread()\n"); 
+    ENTRY("FreeLibraryAndExitThread()\n");
     FreeLibrary(hLibModule);
     ExitThread(dwExitCode);
     LOGEXIT("FreeLibraryAndExitThread\n");
@@ -544,7 +544,7 @@ GetModuleFileNameW(
         SetLastError(ERROR_INSUFFICIENT_BUFFER);
         goto done;
     }
-    
+
     wcscpy_s(lpFileName, nSize, wide_name);
 
     TRACE("file name of module %p is %S\n", hModule, lpFileName);
@@ -611,7 +611,7 @@ PAL_LoadLibraryDirect(
     {
         goto done;
     }
-    
+
     lpstr = pathstr.OpenStringBuffer((PAL_wcslen(lpLibFileName)+1) * MaxWCharToAcpLength);
     if (nullptr == lpstr)
     {
@@ -702,7 +702,7 @@ PALAPI
 PAL_FreeLibraryDirect(
         IN NATIVE_LIBRARY_HANDLE dl_handle)
 {
-    BOOL retValue = 0; 
+    BOOL retValue = 0;
     PERF_ENTRY(PAL_FreeLibraryDirect);
     ENTRY("PAL_FreeLibraryDirect (dl_handle=%p) \n", dl_handle);
 
@@ -815,7 +815,7 @@ Return value:
     non-NULL - the base address of the mapped image
     NULL - error, with last error set.
 --*/
-void *
+PVOID
 PALAPI
 PAL_LOADLoadPEFile(HANDLE hFile)
 {
@@ -857,9 +857,9 @@ Return value:
     TRUE - success
     FALSE - failure (incorrect ptr, etc.)
 --*/
-BOOL 
+BOOL
 PALAPI
-PAL_LOADUnloadPEFile(void * ptr)
+PAL_LOADUnloadPEFile(PVOID ptr)
 {
     BOOL retval = FALSE;
 
@@ -881,7 +881,7 @@ PAL_LOADUnloadPEFile(void * ptr)
 /*++
     PAL_GetSymbolModuleBase
 
-    Get base address of the module containing a given symbol 
+    Get base address of the module containing a given symbol
 
 Parameters:
     void *symbol - address of symbol
@@ -891,7 +891,7 @@ Return value:
 --*/
 LPCVOID
 PALAPI
-PAL_GetSymbolModuleBase(void *symbol)
+PAL_GetSymbolModuleBase(PVOID symbol)
 {
     LPCVOID retval = nullptr;
 
@@ -903,18 +903,18 @@ PAL_GetSymbolModuleBase(void *symbol)
         TRACE("Can't get base address. Argument symbol == nullptr\n");
         SetLastError(ERROR_INVALID_DATA);
     }
-    else 
+    else
     {
         Dl_info info;
         if (dladdr(symbol, &info) != 0)
         {
             retval = info.dli_fbase;
         }
-        else 
+        else
         {
             TRACE("Can't get base address of the current module\n");
             SetLastError(ERROR_INVALID_DATA);
-        }        
+        }
     }
 
     LOGEXIT("PAL_GetPalModuleBase returns %p\n", retval);
@@ -1020,7 +1020,7 @@ BOOL LOADSetExeName(LPWSTR name)
     free(exe_module.lib_name);
     exe_module.lib_name = name;
 
-    // For platforms where we can't trust the handle to be constant, we need to 
+    // For platforms where we can't trust the handle to be constant, we need to
     // store the inode/device pairs for the modules we just initialized.
 #if RETURNS_NEW_HANDLES_ON_REPEAT_DLOPEN
     {
@@ -1038,7 +1038,7 @@ BOOL LOADSetExeName(LPWSTR name)
         }
         TRACE("Executable has inode %d and device %d\n", stat_buf.st_ino, stat_buf.st_dev);
 
-        exe_module.inode = stat_buf.st_ino; 
+        exe_module.inode = stat_buf.st_ino;
         exe_module.device = stat_buf.st_dev;
     }
 #endif
@@ -1062,13 +1062,13 @@ Function :
     Call DllMain for all modules (that have one) with the given "fwReason"
 
 Parameters :
-    DWORD dwReason : parameter to pass down to DllMain, one of DLL_PROCESS_ATTACH, DLL_PROCESS_DETACH, 
+    DWORD dwReason : parameter to pass down to DllMain, one of DLL_PROCESS_ATTACH, DLL_PROCESS_DETACH,
         DLL_THREAD_ATTACH, DLL_THREAD_DETACH
 
     LPVOID lpReserved : parameter to pass down to DllMain
         If dwReason is DLL_PROCESS_ATTACH, lpvReserved is NULL for dynamic loads and non-NULL for static loads.
-        If dwReason is DLL_PROCESS_DETACH, lpvReserved is NULL if DllMain has been called by using FreeLibrary 
-            and non-NULL if DllMain has been called during process termination. 
+        If dwReason is DLL_PROCESS_DETACH, lpvReserved is NULL if DllMain has been called by using FreeLibrary
+            and non-NULL if DllMain has been called during process termination.
 
 (no return value)
 
@@ -1081,7 +1081,7 @@ void LOADCallDllMain(DWORD dwReason, LPVOID lpReserved)
     MODSTRUCT *module = nullptr;
     BOOL InLoadOrder = TRUE; /* true if in load order, false for reverse */
     CPalThread *pThread;
-    
+
     pThread = InternalGetCurrentThread();
     if (UserCreatedThread != pThread->GetThreadType())
     {
@@ -1091,7 +1091,7 @@ void LOADCallDllMain(DWORD dwReason, LPVOID lpReserved)
     /* Validate dwReason */
     switch(dwReason)
     {
-    case DLL_PROCESS_ATTACH: 
+    case DLL_PROCESS_ATTACH:
         ASSERT("got called with DLL_PROCESS_ATTACH parameter! Why?\n");
         break;
     case DLL_PROCESS_DETACH:
@@ -1187,7 +1187,7 @@ static BOOL LOADFreeLibrary(MODSTRUCT *module, BOOL fCallDllMain)
     /* Releasing the last reference : call dlclose(), remove module from the
        process-wide module list */
 
-    TRACE("Reference count for module %p (named %S) now 0; destroying module structure\n", 
+    TRACE("Reference count for module %p (named %S) now 0; destroying module structure\n",
         module, MODNAME(module));
 
     /* unlink the module structure from the list */
@@ -1239,13 +1239,13 @@ Function :
 Parameters :
     MODSTRUCT *module : module whose DllMain must be called
 
-    DWORD dwReason : parameter to pass down to DllMain, one of DLL_PROCESS_ATTACH, DLL_PROCESS_DETACH, 
+    DWORD dwReason : parameter to pass down to DllMain, one of DLL_PROCESS_ATTACH, DLL_PROCESS_DETACH,
         DLL_THREAD_ATTACH, DLL_THREAD_DETACH
 
     LPVOID lpvReserved : parameter to pass down to DllMain,
-        If dwReason is DLL_PROCESS_ATTACH, lpvReserved is NULL for dynamic loads and non-NULL for static loads. 
-        If dwReason is DLL_PROCESS_DETACH, lpvReserved is NULL if DllMain has been called by using FreeLibrary 
-            and non-NULL if DllMain has been called during process termination. 
+        If dwReason is DLL_PROCESS_ATTACH, lpvReserved is NULL for dynamic loads and non-NULL for static loads.
+        If dwReason is DLL_PROCESS_DETACH, lpvReserved is NULL if DllMain has been called by using FreeLibrary
+            and non-NULL if DllMain has been called during process termination.
 
 Returns:
     BOOL : DllMain's return value
@@ -1256,7 +1256,7 @@ static BOOL LOADCallDllMainSafe(MODSTRUCT *module, DWORD dwReason, LPVOID lpRese
     /* reset ENTRY nesting level back to zero while inside the callback... */
     int old_level = DBG_change_entrylevel(0);
 #endif /* _ENABLE_DEBUG_MESSAGES_ */
-    
+
     struct Param
     {
         MODSTRUCT *module;
@@ -1272,9 +1272,9 @@ static BOOL LOADCallDllMainSafe(MODSTRUCT *module, DWORD dwReason, LPVOID lpRese
     PAL_TRY(Param *, pParam, &param)
     {
         TRACE("Calling DllMain (%p) for module %S\n",
-              pParam->module->pDllMain, 
+              pParam->module->pDllMain,
               pParam->module->lib_name ? pParam->module->lib_name : W16_NULLSTRING);
-        
+
         {
             // This module may be foreign to our PAL, so leave our PAL.
             // If it depends on us, it will re-enter.
@@ -1374,13 +1374,13 @@ static bool LOADConvertLibraryPathWideStringToMultibyteString(
     size_t length = (PAL_wcslen(wideLibraryPath)+1) * MaxWCharToAcpLength;
     *multibyteLibraryPathLengthRef = WideCharToMultiByte(CP_ACP, 0, wideLibraryPath, -1, multibyteLibraryPath,
                                                         length, nullptr, nullptr);
-    
+
     if (*multibyteLibraryPathLengthRef == 0)
     {
         DWORD dwLastError = GetLastError();
-        
+
         ASSERT("WideCharToMultiByte failure! error is %d\n", dwLastError);
-        
+
         SetLastError(ERROR_INVALID_PARAMETER);
         return false;
     }
@@ -1409,7 +1409,7 @@ static BOOL LOADValidateModule(MODSTRUCT *module)
 
     /* enumerate through the list of modules to make sure the given handle is
        really a module (HMODULEs are actually MODSTRUCT pointers) */
-    do 
+    do
     {
         if (module == modlist_enum)
         {
@@ -1503,19 +1503,19 @@ Function :
 
 Parameters :
     NATIVE_LIBRARY_HANDLE dl_handle :   handle returned by dl_open, goes in MODSTRUCT::dl_handle
-    
-    char *name :        name of new module. after conversion to widechar, 
+
+    char *name :        name of new module. after conversion to widechar,
                         goes in MODSTRUCT::lib_name
-                        
+
 Return value:
     a pointer to a new, initialized MODSTRUCT strucutre, or NULL on failure.
-    
+
 Notes :
     'name' is used to initialize MODSTRUCT::lib_name. The other member is set to NULL
     In case of failure (in malloc or MBToWC), this function sets LastError.
 --*/
 static MODSTRUCT *LOADAllocModule(NATIVE_LIBRARY_HANDLE dl_handle, LPCSTR name)
-{   
+{
     MODSTRUCT *module;
     LPWSTR wide_name;
 
@@ -1585,8 +1585,8 @@ static MODSTRUCT *LOADAddModule(NATIVE_LIBRARY_HANDLE dl_handle, LPCSTR libraryN
     do
     {
         if (dl_handle == module->dl_handle)
-        {   
-            /* found the handle. increment the refcount and return the 
+        {
+            /* found the handle. increment the refcount and return the
                existing module structure */
             TRACE("Found matching module %p for module name %s\n", module, libraryNameOrPath);
 
@@ -1623,7 +1623,7 @@ static MODSTRUCT *LOADAddModule(NATIVE_LIBRARY_HANDLE dl_handle, LPCSTR libraryN
     exe_module.prev = module;
 
 #if RETURNS_NEW_HANDLES_ON_REPEAT_DLOPEN
-    module->inode = stat_buf.st_ino; 
+    module->inode = stat_buf.st_ino;
     module->device = stat_buf.st_dev;
 #endif
 
@@ -1669,7 +1669,7 @@ static HMODULE LOADRegisterLibraryDirect(NATIVE_LIBRARY_HANDLE dl_handle, LPCSTR
             else
             {
                 // If the target module doesn't have the PAL_RegisterModule export, then use this PAL's
-                // module handle assuming that the target module is referencing this PAL's exported 
+                // module handle assuming that the target module is referencing this PAL's exported
                 // functions on said handle.
                 module->hinstance = (HINSTANCE)module;
             }
@@ -1716,7 +1716,7 @@ static HMODULE LOADLoadLibrary(LPCSTR shortAsciiName, BOOL fDynamic)
     NATIVE_LIBRARY_HANDLE dl_handle = nullptr;
 
     shortAsciiName = FixLibCName(shortAsciiName);
-    
+
     LockModuleList();
 
     dl_handle = LOADLoadLibraryDirect(shortAsciiName);
@@ -1776,8 +1776,8 @@ MODSTRUCT *LOADGetPalLibrary()
 {
     if (pal_module == nullptr)
     {
-        // Initialize the pal module (the module containing LOADGetPalLibrary). Assumes that 
-        // the PAL is linked into the coreclr module because we use the module name containing 
+        // Initialize the pal module (the module containing LOADGetPalLibrary). Assumes that
+        // the PAL is linked into the coreclr module because we use the module name containing
         // this function for the coreclr path.
         TRACE("Loading module for PAL library\n");
 
@@ -1806,7 +1806,7 @@ MODSTRUCT *LOADGetPalLibrary()
                 goto exit;
             }
         }
-        
+
         pal_module = (MODSTRUCT *)LOADLoadLibrary(info.dli_fname, FALSE);
     }
 
@@ -1830,7 +1830,7 @@ Return
 extern "C"
 void LockModuleList()
 {
-    CPalThread * pThread = 
+    CPalThread * pThread =
         (PALIsThreadDataInitialized() ? InternalGetCurrentThread() : nullptr);
 
     InternalEnterCriticalSection(pThread, &module_critsec);
@@ -1852,7 +1852,7 @@ Return
 extern "C"
 void UnlockModuleList()
 {
-    CPalThread * pThread = 
+    CPalThread * pThread =
         (PALIsThreadDataInitialized() ? InternalGetCurrentThread() : nullptr);
 
     InternalLeaveCriticalSection(pThread, &module_critsec);
index 2bf1e43..c84b370 100644 (file)
@@ -138,7 +138,7 @@ TRUE if the Unicode character was found.
 BOOL GetUnicodeData(INT nUnicodeValue, UnicodeDataRec *pDataRec)
 {
     BOOL bRet;
-    if (nUnicodeValue <= UNICODE_DATA_DIRECT_ACCESS)
+    if (nUnicodeValue <= (INT)UNICODE_DATA_DIRECT_ACCESS)
     {
         *pDataRec = UnicodeData[nUnicodeValue];
         bRet = TRUE;
@@ -147,7 +147,7 @@ BOOL GetUnicodeData(INT nUnicodeValue, UnicodeDataRec *pDataRec)
     {
         UnicodeDataRec *dataRec;
         INT nNumOfChars = UNICODE_DATA_SIZE;
-        dataRec = (UnicodeDataRec *) bsearch(&nUnicodeValue, UnicodeData, nNumOfChars, 
+        dataRec = (UnicodeDataRec *) bsearch(&nUnicodeValue, UnicodeData, nNumOfChars,
                        sizeof(UnicodeDataRec), UnicodeDataComp);
         if (dataRec == NULL)
         {
@@ -163,16 +163,16 @@ BOOL GetUnicodeData(INT nUnicodeValue, UnicodeDataRec *pDataRec)
 }
 #endif /* !HAVE_COREFOUNDATION */
 
-/*++ 
+/*++
 Function:
 CODEPAGEGetData
-    
+
     IN UINT CodePage - The code page the caller
     is attempting to retrieve data on.
-    
+
     Returns a pointer to structure, NULL otherwise.
 --*/
-const CP_MAPPING * 
+const CP_MAPPING *
 CODEPAGEGetData( IN UINT CodePage )
 {
     UINT nSize = sizeof( CP_TO_NATIVE_TABLE ) / sizeof( CP_TO_NATIVE_TABLE[ 0 ] );
@@ -192,7 +192,7 @@ CODEPAGEGetData( IN UINT CodePage )
         }
         nIndex++;
     }
-    return NULL;    
+    return NULL;
 }
 
 #if HAVE_COREFOUNDATION
@@ -347,7 +347,7 @@ IsValidCodePage(
         retval = (NULL != CODEPAGEGetData( CodePage ));
         break;
     }
-       
+
     LOGEXIT("IsValidCodePage returns BOOL %d\n",retval);
     PERF_EXIT(IsValidCodePage);
     return retval;
@@ -367,7 +367,7 @@ GetCPInfo(
 {
     const CP_MAPPING * lpStruct = NULL;
     BOOL bRet = FALSE;
-     
+
     PERF_ENTRY(GetCPInfo);
     ENTRY("GetCPInfo(CodePage=%hu, lpCPInfo=%p)\n", CodePage, lpCPInfo);
 
@@ -460,9 +460,9 @@ IsDBCSLeadByteEx(
         {
             goto done;
         }
-         
+
         /*check if the given char is in one of the lead byte ranges*/
-        if( cpinfo.LeadByte[i] <= TestChar && TestChar<= cpinfo.LeadByte[i+1] ) 
+        if( cpinfo.LeadByte[i] <= TestChar && TestChar<= cpinfo.LeadByte[i+1] )
         {
             bRet = TRUE;
             goto done;
@@ -656,14 +656,14 @@ WideCharToMultiByte(
           lpDefaultChar, lpUsedDefaultChar);
 
     if (dwFlags & ~WC_NO_BEST_FIT_CHARS)
-    {  
+    {
         ERROR("dwFlags %d invalid\n", dwFlags);
         SetLastError(ERROR_INVALID_FLAGS);
         goto EXIT;
     }
 
     // No special action is needed for WC_NO_BEST_FIT_CHARS. The default
-    // behavior of this API on Unix is not to find the best fit for a unicode 
+    // behavior of this API on Unix is not to find the best fit for a unicode
     // character that does not map directly into a code point in the given
     // code page. The best fit functionality is not available in wctomb on Unix
     // and is better left unimplemented for security reasons anyway.
@@ -690,7 +690,7 @@ WideCharToMultiByte(
     {
         if (cchWideChar == -1)
         {
-            cchWideChar = PAL_wcslen(lpWideCharStr) + 1; 
+            cchWideChar = PAL_wcslen(lpWideCharStr) + 1;
         }
         retval = UnicodeToUTF8(lpWideCharStr, cchWideChar, lpMultiByteStr, cbMultiByte);
         goto EXIT;
@@ -779,12 +779,12 @@ EXIT:
     /* Flag the cases when WC_NO_BEST_FIT_CHARS was not specified
      * but we found characters that had to be replaced with default
      * characters. Note that Windows would have attempted to find
-     * best fit characters under these conditions and that could pose 
-     * a security risk. 
+     * best fit characters under these conditions and that could pose
+     * a security risk.
      */
     _ASSERT_MSG((dwFlags & WC_NO_BEST_FIT_CHARS) || !usedDefaultChar,
           "WideCharToMultiByte found a string which doesn't round trip: (%p)%S "
-          "and WC_NO_BEST_FIT_CHARS was not specified\n", 
+          "and WC_NO_BEST_FIT_CHARS was not specified\n",
           lpWideCharStr, lpWideCharStr);
 
     LOGEXIT("WideCharToMultiByte returns INT %d\n", retval);
@@ -850,7 +850,7 @@ PAL_GetResourceString(
     // resource. In our case, that will be the English string.
     LPCSTR resourceString = dgettext(lpDomain, lpResourceStr);
 #else // HAVE_LIBINTL_H
-    // UNIXTODO: Implement for OSX using the native localization API 
+    // UNIXTODO: Implement for OSX using the native localization API
 
     // This is a temporary solution until we add the real native resource support.
     LPCSTR resourceString = lpResourceStr;
index 4f7a51f..f9ba166 100644 (file)
@@ -22,7 +22,7 @@ Abstract:
 
 #if !HAVE_COREFOUNDATION
 
-CONST UnicodeDataRec UnicodeData[] DLLEXPORT = {
+CONST UnicodeDataRec UnicodeData[] = {
 
 
 { 0x0000,      0x0020, 0x0000, 0 },
@@ -1846,7 +1846,7 @@ CONST UnicodeDataRec UnicodeData[] DLLEXPORT = {
 { 0xffe0,      0x0010, 0x0000, 13 },
 };
 
-CONST UINT UNICODE_DATA_SIZE DLLEXPORT = sizeof(UnicodeData)/sizeof(UnicodeDataRec);
-CONST UINT UNICODE_DATA_DIRECT_ACCESS DLLEXPORT = 256;
+CONST UINT UNICODE_DATA_SIZE = sizeof(UnicodeData)/sizeof(UnicodeDataRec);
+CONST UINT UNICODE_DATA_DIRECT_ACCESS = 256;
 
 #endif // !HAVE_COREFOUNDATION
index a5610ef..4dae9f3 100644 (file)
@@ -153,7 +153,7 @@ namespace VirtualMemoryLogging
 /*++
 Function:
     VIRTUALInitialize()
-    
+
     Initializes this section's critical section.
 
 Return value:
@@ -256,12 +256,12 @@ static BOOL VIRTUALIsPageCommitted( SIZE_T nBitToRetrieve, CONST PCMI pInformati
         ERROR( "pInformation was NULL!\n" );
         return FALSE;
     }
-    
+
     nByteOffset = nBitToRetrieve / CHAR_BIT;
     nBitOffset = nBitToRetrieve % CHAR_BIT;
 
     byteMask = 1 << nBitOffset;
-    
+
     if ( pInformation->pAllocState[ nByteOffset ] & byteMask )
     {
         return TRUE;
@@ -276,7 +276,7 @@ static BOOL VIRTUALIsPageCommitted( SIZE_T nBitToRetrieve, CONST PCMI pInformati
  *
  *  VIRTUALGetAllocationType
  *
- *      IN SIZE_T Index - The page within the range to retrieve 
+ *      IN SIZE_T Index - The page within the range to retrieve
  *                      the state for.
  *
  *      IN pInformation - The virtual memory object.
@@ -306,18 +306,18 @@ static INT VIRTUALGetAllocationType( SIZE_T Index, CONST PCMI pInformation )
  *
  *  Returns TRUE on success, FALSE otherwise.
  *  Turn on/off memory status bits.
- *         
+ *
  */
-static BOOL VIRTUALSetPageBits ( UINT nStatus, SIZE_T nStartingBit, 
+static BOOL VIRTUALSetPageBits ( UINT nStatus, SIZE_T nStartingBit,
                                  SIZE_T nNumberOfBits, BYTE * pBitArray )
 {
-    /* byte masks for optimized modification of partial bytes (changing less 
-       than 8 bits in a single byte). note that bits are treated in little 
-       endian order : value 1 is bit 0; value 128 is bit 7. in the binary 
+    /* byte masks for optimized modification of partial bytes (changing less
+       than 8 bits in a single byte). note that bits are treated in little
+       endian order : value 1 is bit 0; value 128 is bit 7. in the binary
        representations below, bit 0 is on the right */
 
-    /* start masks : for modifying bits >= n while preserving bits < n. 
-       example : if nStartignBit%8 is 3, then bits 0, 1, 2 remain unchanged 
+    /* start masks : for modifying bits >= n while preserving bits < n.
+       example : if nStartignBit%8 is 3, then bits 0, 1, 2 remain unchanged
        while bits 3..7 are changed; startmasks[3] can be used for this.  */
     static const BYTE startmasks[8] = {
       0xff, /* start at 0 : 1111 1111 */
@@ -330,8 +330,8 @@ static BOOL VIRTUALSetPageBits ( UINT nStatus, SIZE_T nStartingBit,
     0x80  /* start at 7 : 1000 0000 */
     };
 
-    /* end masks : for modifying bits <= n while preserving bits > n. 
-       example : if the last bit to change is 5, then bits 6 & 7 stay unchanged 
+    /* end masks : for modifying bits <= n while preserving bits > n.
+       example : if the last bit to change is 5, then bits 6 & 7 stay unchanged
        while bits 1..5 are changed; endmasks[5] can be used for this.  */
     static const BYTE endmasks[8] = {
       0x01, /* end at 0 : 0000 0001 */
@@ -343,14 +343,14 @@ static BOOL VIRTUALSetPageBits ( UINT nStatus, SIZE_T nStartingBit,
       0x7f, /* end at 6 : 0111 1111 */
       0xff  /* end at 7 : 1111 1111 */
     };
-    /* last example : if only the middle of a byte must be changed, both start 
-       and end masks can be combined (bitwise AND) to obtain the correct mask. 
-       if we want to change bits 2 to 4 : 
+    /* last example : if only the middle of a byte must be changed, both start
+       and end masks can be combined (bitwise AND) to obtain the correct mask.
+       if we want to change bits 2 to 4 :
        startmasks[2] : 0xfc   1111 1100  (change 2,3,4,5,6,7)
        endmasks[4]:    0x1f   0001 1111  (change 0,1,2,3,4)
        bitwise AND :   0x1c   0001 1100  (change 2,3,4)
     */
-    
+
     BYTE byte_mask;
     SIZE_T nLastBit;
     SIZE_T nFirstByte;
@@ -358,8 +358,8 @@ static BOOL VIRTUALSetPageBits ( UINT nStatus, SIZE_T nStartingBit,
     SIZE_T nFullBytes;
 
     TRACE( "VIRTUALSetPageBits( nStatus = %d, nStartingBit = %d, "
-           "nNumberOfBits = %d, pBitArray = 0x%p )\n", 
-           nStatus, nStartingBit, nNumberOfBits, pBitArray ); 
+           "nNumberOfBits = %d, pBitArray = 0x%p )\n",
+           nStatus, nStartingBit, nNumberOfBits, pBitArray );
 
     if ( 0 == nNumberOfBits )
     {
@@ -376,7 +376,7 @@ static BOOL VIRTUALSetPageBits ( UINT nStatus, SIZE_T nStartingBit,
     {
         byte_mask = startmasks[nStartingBit % 8];
 
-        /* if 1st byte is the only changing byte, combine endmask to preserve 
+        /* if 1st byte is the only changing byte, combine endmask to preserve
            trailing bits (see 3rd example above) */
         if( nLastByte == nFirstByte)
         {
@@ -386,7 +386,7 @@ static BOOL VIRTUALSetPageBits ( UINT nStatus, SIZE_T nStartingBit,
         /* byte_mask contains 1 for bits to change, 0 for bits to leave alone */
         if(0 == nStatus)
         {
-            /* bits to change must be set to 0 : invert byte_mask (giving 0 for 
+            /* bits to change must be set to 0 : invert byte_mask (giving 0 for
                bits to change), use bitwise AND */
             pBitArray[nFirstByte] &= ~byte_mask;
         }
@@ -421,7 +421,7 @@ static BOOL VIRTUALSetPageBits ( UINT nStatus, SIZE_T nStartingBit,
     /* byte_mask contains 1 for bits to change, 0 for bits to leave alone */
     if(0 == nStatus)
     {
-        /* bits to change must be set to 0 : invert byte_mask (giving 0 for 
+        /* bits to change must be set to 0 : invert byte_mask (giving 0 for
            bits to change), use bitwise AND */
         pBitArray[nLastByte] &= ~byte_mask;
     }
@@ -446,14 +446,14 @@ static BOOL VIRTUALSetPageBits ( UINT nStatus, SIZE_T nStartingBit,
  *
  *  Returns TRUE on success, FALSE otherwise.
  *  Turn bit on to indicate committed, turn bit off to indicate reserved.
- *         
+ *
  */
-static BOOL VIRTUALSetAllocState( UINT nAction, SIZE_T nStartingBit, 
+static BOOL VIRTUALSetAllocState( UINT nAction, SIZE_T nStartingBit,
                            SIZE_T nNumberOfBits, CONST PCMI pInformation )
 {
     TRACE( "VIRTUALSetAllocState( nAction = %d, nStartingBit = %d, "
-           "nNumberOfBits = %d, pStateArray = 0x%p )\n", 
-           nAction, nStartingBit, nNumberOfBits, pInformation ); 
+           "nNumberOfBits = %d, pStateArray = 0x%p )\n",
+           nAction, nStartingBit, nNumberOfBits, pInformation );
 
     if ( !pInformation )
     {
@@ -461,7 +461,7 @@ static BOOL VIRTUALSetAllocState( UINT nAction, SIZE_T nStartingBit,
         return FALSE;
     }
 
-    return VIRTUALSetPageBits((MEM_COMMIT == nAction) ? 1 : 0, nStartingBit, 
+    return VIRTUALSetPageBits((MEM_COMMIT == nAction) ? 1 : 0, nStartingBit,
                               nNumberOfBits, pInformation->pAllocState);
 }
 
@@ -473,14 +473,14 @@ static BOOL VIRTUALSetAllocState( UINT nAction, SIZE_T nStartingBit,
  *
  *          Returns the PCMI if found, NULL otherwise.
  */
-static PCMI VIRTUALFindRegionInformation( IN UINT_PTR address ) 
+static PCMI VIRTUALFindRegionInformation( IN UINT_PTR address )
 {
     PCMI pEntry = NULL;
-    
+
     TRACE( "VIRTUALFindRegionInformation( %#x )\n", address );
 
     pEntry = pVirtualMemory;
-    
+
     while( pEntry )
     {
         if ( pEntry->startBoundary > address )
@@ -489,11 +489,11 @@ static PCMI VIRTUALFindRegionInformation( IN UINT_PTR address )
             pEntry = NULL;
             break;
         }
-        if ( pEntry->startBoundary + pEntry->memSize > address ) 
+        if ( pEntry->startBoundary + pEntry->memSize > address )
         {
             break;
         }
-        
+
         pEntry = pEntry->pNext;
     }
     return pEntry;
@@ -503,15 +503,15 @@ static PCMI VIRTUALFindRegionInformation( IN UINT_PTR address )
 Function :
 
     VIRTUALReleaseMemory
-    
+
     Removes a PCMI entry from the list.
-    
+
     Returns true on success. FALSE otherwise.
 --*/
 static BOOL VIRTUALReleaseMemory( PCMI pMemoryToBeReleased )
 {
     BOOL bRetVal = TRUE;
-    
+
     if ( !pMemoryToBeReleased )
     {
         ASSERT( "Invalid pointer.\n" );
@@ -534,7 +534,7 @@ static BOOL VIRTUALReleaseMemory( PCMI pMemoryToBeReleased )
         {
             pMemoryToBeReleased->pPrevious->pNext = pMemoryToBeReleased->pNext;
         }
-        
+
         if ( pMemoryToBeReleased->pNext )
         {
             pMemoryToBeReleased->pNext->pPrevious = pMemoryToBeReleased->pPrevious;
@@ -554,7 +554,7 @@ static BOOL VIRTUALReleaseMemory( PCMI pMemoryToBeReleased )
 }
 
 /****
- *  VIRTUALConvertWinFlags() - 
+ *  VIRTUALConvertWinFlags() -
  *          Converts win32 protection flags to
  *          internal VIRTUAL flags.
  *
@@ -583,7 +583,7 @@ static BYTE VIRTUALConvertWinFlags( IN DWORD flProtect )
     case PAGE_EXECUTE_READWRITE:
         MemAccessControl = VIRTUAL_EXECUTE_READWRITE;
         break;
-    
+
     default :
         MemAccessControl = 0;
         ERROR( "Incorrect or no protection flags specified.\n" );
@@ -593,7 +593,7 @@ static BYTE VIRTUALConvertWinFlags( IN DWORD flProtect )
 }
 
 /****
- *  VIRTUALConvertVirtualFlags() - 
+ *  VIRTUALConvertVirtualFlags() -
  *              Converts internal virtual protection
  *              flags to their win32 counterparts.
  */
@@ -678,7 +678,7 @@ static void VIRTUALDisplayList( void  )
         count++;
         p = p->pNext;
     }
-    
+
     InternalLeaveCriticalSection(pthrCurrent, &virtual_critsec);
 }
 #endif
@@ -713,7 +713,7 @@ void VerifyLeftEntry(PCMI pEntry)
  *      Stores the allocation information in the linked list.
  *      NOTE: The caller must own the critical section.
  */
-static BOOL VIRTUALStoreAllocationInfo( 
+static BOOL VIRTUALStoreAllocationInfo(
             IN UINT_PTR startBoundary,  /* Start of the region. */
             IN SIZE_T memSize,          /* Size of the region. */
             IN DWORD flAllocationType,  /* Allocation Types. */
@@ -772,7 +772,7 @@ static BOOL VIRTUALStoreAllocationInfo(
 
         return FALSE;
     }
-    
+
     pMemInfo = pVirtualMemory;
 
     if (pMemInfo && pMemInfo->startBoundary < startBoundary)
@@ -818,7 +818,7 @@ static BOOL VIRTUALStoreAllocationInfo(
 
 /******
  *
- *  VIRTUALResetMemory() - Helper function that resets the memory 
+ *  VIRTUALResetMemory() - Helper function that resets the memory
  *
  *
  */
@@ -843,7 +843,7 @@ static LPVOID VIRTUALResetMemory(
     // occurs.
     st = madvise((LPVOID)StartBoundary, MemSize, MADV_FREE);
     if (st != 0)
-#endif    
+#endif
     {
         // In case the MADV_FREE is not supported, use MADV_DONTNEED
         st = madvise((LPVOID)StartBoundary, MemSize, MADV_DONTNEED);
@@ -1037,7 +1037,7 @@ static LPVOID ReserveVirtualMemory(
  *              exists, and that would be very complicated to work around.
  *
  */
-static LPVOID 
+static LPVOID
 VIRTUALCommitMemory(
                 IN CPalThread *pthrCurrent, /* Currently executing thread */
                 IN LPVOID lpAddress,        /* Region to reserve or commit */
@@ -1072,16 +1072,16 @@ VIRTUALCommitMemory(
 
     /* See if we have already reserved this memory. */
     pInformation = VIRTUALFindRegionInformation( StartBoundary );
-    
+
     if ( !pInformation )
     {
         /* According to the new MSDN docs, if MEM_COMMIT is specified,
         and the memory is not reserved, you reserve and then commit.
         */
-        LPVOID pReservedMemory = 
-                VIRTUALReserveMemory( pthrCurrent, lpAddress, dwSize, 
+        LPVOID pReservedMemory =
+                VIRTUALReserveMemory( pthrCurrent, lpAddress, dwSize,
                                       flAllocationType, flProtect );
-        
+
         TRACE( "Reserve and commit the memory!\n " );
 
         if ( pReservedMemory )
@@ -1089,7 +1089,7 @@ VIRTUALCommitMemory(
             /* Re-align the addresses and try again to find the memory. */
             StartBoundary = (UINT_PTR) ALIGN_DOWN(pReservedMemory, GetVirtualPageSize());
             MemSize = ALIGN_UP((UINT_PTR)pReservedMemory + dwSize, GetVirtualPageSize()) - StartBoundary;
-            
+
             pInformation = VIRTUALFindRegionInformation( StartBoundary );
 
             if ( !pInformation )
@@ -1109,19 +1109,19 @@ VIRTUALCommitMemory(
             goto done;
         }
     }
-               
+
     TRACE( "Committing the memory now..\n");
-    
+
     // Pages that aren't already committed need to be committed. Pages that
     // are committed don't need to be committed, but they might need to have
     // their permissions changed.
     // To get this right, we find runs of pages with similar states and
-    // permissions. If a run is not committed, we commit it and then set 
-    // its permissions. If a run is committed but has different permissions 
-    // from what we're trying to set, we set its permissions. Finally, 
-    // if a run is already committed and has the right permissions, 
+    // permissions. If a run is not committed, we commit it and then set
+    // its permissions. If a run is committed but has different permissions
+    // from what we're trying to set, we set its permissions. Finally,
+    // if a run is already committed and has the right permissions,
     // we don't need to do anything to it.
-    
+
     totalPages = MemSize / GetVirtualPageSize();
     runStart = (StartBoundary - pInformation->startBoundary) /
                 GetVirtualPageSize();   // Page index
@@ -1309,7 +1309,7 @@ Function:
 Note:
   MEM_TOP_DOWN, MEM_PHYSICAL, MEM_WRITE_WATCH are not supported.
   Unsupported flags are ignored.
-  
+
   Page size on i386 is set to 4k.
 
 See MSDN doc.
@@ -1367,7 +1367,7 @@ VirtualAlloc(
         NULL,
         TRUE);
 
-    if ( flAllocationType & MEM_RESET ) 
+    if ( flAllocationType & MEM_RESET )
     {
         if ( flAllocationType != MEM_RESET )
         {
@@ -1387,7 +1387,7 @@ VirtualAlloc(
         }
     }
 
-    if ( flAllocationType & MEM_RESERVE ) 
+    if ( flAllocationType & MEM_RESERVE )
     {
         InternalEnterCriticalSection(pthrCurrent, &virtual_critsec);
         pRetVal = VIRTUALReserveMemory( pthrCurrent, lpAddress, dwSize, flAllocationType, flProtect );
@@ -1406,18 +1406,18 @@ VirtualAlloc(
         if ( pRetVal != NULL )
         {
             /* We are reserving and committing. */
-            pRetVal = VIRTUALCommitMemory( pthrCurrent, pRetVal, dwSize, 
-                                    flAllocationType, flProtect );    
+            pRetVal = VIRTUALCommitMemory( pthrCurrent, pRetVal, dwSize,
+                                    flAllocationType, flProtect );
         }
         else
         {
             /* Just a commit. */
-            pRetVal = VIRTUALCommitMemory( pthrCurrent, lpAddress, dwSize, 
+            pRetVal = VIRTUALCommitMemory( pthrCurrent, lpAddress, dwSize,
                                     flAllocationType, flProtect );
         }
         InternalLeaveCriticalSection(pthrCurrent, &virtual_critsec);
-    }                      
-    
+    }
+
 done:
 #if defined _DEBUG
     VIRTUALDisplayList();
@@ -1488,9 +1488,9 @@ VirtualFree(
             bRetVal = FALSE;
             goto VirtualFreeExit;
         }
-        /* 
+        /*
          * A two byte range straddling 2 pages caues both pages to be either
-         * released or decommitted. So round the dwSize up to the next page 
+         * released or decommitted. So round the dwSize up to the next page
          * boundary and round the lpAddress down to the next page boundary.
          */
         StartBoundary = (UINT_PTR) ALIGN_DOWN(lpAddress, GetVirtualPageSize());
@@ -1506,7 +1506,7 @@ VirtualFree(
             goto VirtualFreeExit;
         }
 
-        TRACE( "Un-committing the following page(s) %d to %d.\n", 
+        TRACE( "Un-committing the following page(s) %d to %d.\n",
                StartBoundary, MemSize );
 
         // Explicitly calling mmap instead of mprotect here makes it
@@ -1531,9 +1531,9 @@ VirtualFree(
 
             /* We can now commit this memory by calling VirtualAlloc().*/
             index = (StartBoundary - pUnCommittedMem->startBoundary) / GetVirtualPageSize();
-            
+
             nNumOfPagesToChange = MemSize / GetVirtualPageSize();
-            VIRTUALSetAllocState( MEM_RESERVE, index, 
+            VIRTUALSetAllocState( MEM_RESERVE, index,
                                   nNumOfPagesToChange, pUnCommittedMem );
 
             goto VirtualFreeExit;
@@ -1546,12 +1546,12 @@ VirtualFree(
             goto VirtualFreeExit;
         }
     }
-    
+
     if ( dwFreeType & MEM_RELEASE )
     {
-        PCMI pMemoryToBeReleased = 
+        PCMI pMemoryToBeReleased =
             VIRTUALFindRegionInformation( (UINT_PTR)lpAddress );
-        
+
         if ( !pMemoryToBeReleased )
         {
             ERROR( "lpAddress must be the base address returned by VirtualAlloc.\n" );
@@ -1567,10 +1567,10 @@ VirtualFree(
             goto VirtualFreeExit;
         }
 
-        TRACE( "Releasing the following memory %d to %d.\n", 
+        TRACE( "Releasing the following memory %d to %d.\n",
                pMemoryToBeReleased->startBoundary, pMemoryToBeReleased->memSize );
 
-        if ( munmap( (LPVOID)pMemoryToBeReleased->startBoundary, 
+        if ( munmap( (LPVOID)pMemoryToBeReleased->startBoundary,
                      pMemoryToBeReleased->memSize ) == 0 )
         {
             if ( VIRTUALReleaseMemory( pMemoryToBeReleased ) == FALSE )
@@ -1594,7 +1594,7 @@ VirtualFree(
 VirtualFreeExit:
 
     LogVaOperation(
-        (dwFreeType & MEM_DECOMMIT) ? VirtualMemoryLogging::VirtualOperation::Decommit 
+        (dwFreeType & MEM_DECOMMIT) ? VirtualMemoryLogging::VirtualOperation::Decommit
                                     : VirtualMemoryLogging::VirtualOperation::Release,
         lpAddress,
         dwSize,
@@ -1640,7 +1640,7 @@ VirtualProtect(
 
     pthrCurrent = InternalGetCurrentThread();
     InternalEnterCriticalSection(pthrCurrent, &virtual_critsec);
-    
+
     StartBoundary = (UINT_PTR) ALIGN_DOWN(lpAddress, GetVirtualPageSize());
     MemSize = ALIGN_UP((UINT_PTR)lpAddress + dwSize, GetVirtualPageSize()) - StartBoundary;
 
@@ -1673,7 +1673,7 @@ VirtualProtect(
         for ( ; Index < NumberOfPagesToChange; Index++  )
         {
             if ( !VIRTUALIsPageCommitted( Index, pEntry ) )
-            {     
+            {
                 ERROR( "You can only change the protection attributes"
                        " on committed memory.\n" )
                 SetLastError( ERROR_INVALID_ADDRESS );
@@ -1682,7 +1682,7 @@ VirtualProtect(
         }
     }
 
-    if ( 0 == mprotect( (LPVOID)StartBoundary, MemSize, 
+    if ( 0 == mprotect( (LPVOID)StartBoundary, MemSize,
                    W32toUnixAccessControl( flNewProtect ) ) )
     {
         /* Reset the access protection. */
@@ -1697,8 +1697,8 @@ VirtualProtect(
         {
             *lpflOldProtect =
                 VIRTUALConvertVirtualFlags( pEntry->pProtectionState[ OffSet ] );
-            
-            memset( pEntry->pProtectionState + OffSet, 
+
+            memset( pEntry->pProtectionState + OffSet,
                     VIRTUALConvertWinFlags( flNewProtect ),
                     NumberOfPagesToChange );
         }
@@ -1816,7 +1816,7 @@ static void VM_ALLOCATE_VirtualQuery(LPCVOID lpAddress, PMEMORY_BASIC_INFORMATIO
 #endif
 
     vm_address = (vm_address_t)lpAddress;
-#ifdef BIT64    
+#ifdef BIT64
     MachRet = vm_region_64(
 #else
     MachRet = vm_region(
@@ -1865,7 +1865,7 @@ static void VM_ALLOCATE_VirtualQuery(LPCVOID lpAddress, PMEMORY_BASIC_INFORMATIO
     }
     else
     {
-        // What should this be?  It's either MEM_MAPPED or MEM_IMAGE, but without an image list, 
+        // What should this be?  It's either MEM_MAPPED or MEM_IMAGE, but without an image list,
         // we can't determine which one it is.
         lpBuffer->Type = MEM_MAPPED;
     }
@@ -1946,10 +1946,10 @@ VirtualQuery(
         /* Can't find a match, or no list present. */
         /* Next, looking for this region in file maps */
         if (!MAPGetRegionInfo((LPVOID)StartBoundary, lpBuffer))
-        { 
+        {
             // When all else fails, call vm_region() if it's available.
 
-            // Initialize the State to be MEM_FREE, in which case AllocationBase, AllocationProtect, 
+            // Initialize the State to be MEM_FREE, in which case AllocationBase, AllocationProtect,
             // Protect, and Type are all undefined.
             lpBuffer->BaseAddress = (LPVOID)StartBoundary;
             lpBuffer->RegionSize = 0;
@@ -1998,7 +1998,7 @@ VirtualQuery(
 ExitVirtualQuery:
 
     InternalLeaveCriticalSection(pthrCurrent, &virtual_critsec);
-    
+
     LOGEXIT( "VirtualQuery returning %d.\n", sizeof( *lpBuffer ) );
     PERF_EXIT(VirtualQuery);
     return sizeof( *lpBuffer );
@@ -2016,8 +2016,8 @@ Function:
 
 See MSDN doc.
 --*/
-UINT 
-PALAPI 
+UINT
+PALAPI
 GetWriteWatch(
   IN DWORD dwFlags,
   IN PVOID lpBaseAddress,
@@ -2040,8 +2040,8 @@ Function:
 
 See MSDN doc.
 --*/
-UINT 
-PALAPI 
+UINT
+PALAPI
 ResetWriteWatch(
   IN LPVOID lpBaseAddress,
   IN SIZE_T dwRegionSize
@@ -2189,7 +2189,7 @@ void ExecutableMemoryAllocator::TryReserveInitialMemory()
     // should not be necessary, but see AllocateMemory() for the reason why it is done.
     int32_t randomOffset = GenerateRandomStartOffset();
     m_nextFreeAddress = ALIGN_UP((void*)(((UINT_PTR)m_startAddress) + randomOffset), VIRTUAL_64KB);
-    _ASSERTE(sizeOfAllocation >= (UINT_PTR)m_nextFreeAddress - (UINT_PTR)m_startAddress);
+    _ASSERTE(sizeOfAllocation >= (int32_t)((UINT_PTR)m_nextFreeAddress - (UINT_PTR)m_startAddress));
     m_remainingReservedMemory =
         ALIGN_DOWN(sizeOfAllocation - ((UINT_PTR)m_nextFreeAddress - (UINT_PTR)m_startAddress), VIRTUAL_64KB);
 }
@@ -2219,7 +2219,7 @@ void* ExecutableMemoryAllocator::AllocateMemory(SIZE_T allocationSize)
 
     // The code below assumes that the caller owns the virtual_critsec lock.
     // So the calculations are not done in thread-safe manner.
-    if ((allocationSize > 0) && (allocationSize <= m_remainingReservedMemory))
+    if ((allocationSize > 0) && (allocationSize <= (SIZE_T)m_remainingReservedMemory))
     {
         allocatedMemory = m_nextFreeAddress;
         m_nextFreeAddress = (void*)(((UINT_PTR)m_nextFreeAddress) + allocationSize);
@@ -2255,7 +2255,7 @@ void *ExecutableMemoryAllocator::AllocateMemoryWithinRange(const void *beginAddr
     // The code below assumes that the caller owns the virtual_critsec lock.
     // So the calculations are not done in thread-safe manner.
 
-    if (allocationSize == 0 || allocationSize > m_remainingReservedMemory)
+    if (allocationSize == 0 || allocationSize > (SIZE_T)m_remainingReservedMemory)
     {
         return nullptr;
     }
index 9fc1346..d00236e 100644 (file)
@@ -53,11 +53,11 @@ characters.
 
 Parameters
 
-lpName 
+lpName
        [in] Pointer to a null-terminated string that specifies the environment variable.
-lpBuffer 
+lpBuffer
        [out] Pointer to a buffer to receive the value of the specified environment variable.
-nSize 
+nSize
        [in] Specifies the size, in TCHARs, of the buffer pointed to by the lpBuffer parameter.
 
 Return Values
@@ -114,7 +114,7 @@ GetEnvironmentVariableA(
     {
         // Enter the environment critical section so that we can safely get
         // the environment variable value without EnvironGetenv making an
-        // intermediate copy. We will just copy the string to the output 
+        // intermediate copy. We will just copy the string to the output
         // buffer anyway, so just stay in the critical section until then.
         InternalEnterCriticalSection(pthrCurrent, &gcsEnvironment);
 
@@ -128,7 +128,7 @@ GetEnvironmentVariableA(
                 strcpy_s(lpBuffer, nSize, value);
                 dwRet = valueLength;
             }
-            else 
+            else
             {
                 dwRet = valueLength + 1;
             }
@@ -262,7 +262,7 @@ variable for the current process.
 
 Parameters
 
-lpName 
+lpName
        [in] Pointer to a null-terminated string that specifies the
        environment variable whose value is being set. The operating
        system creates the environment variable if it does not exist
@@ -303,7 +303,7 @@ SetEnvironmentVariableW(
         lpName?lpName:W16_NULLSTRING,
         lpName?lpName:W16_NULLSTRING, lpValue?lpValue:W16_NULLSTRING, lpValue?lpValue:W16_NULLSTRING);
 
-    if ((nameSize = WideCharToMultiByte(CP_ACP, 0, lpName, -1, name, 0, 
+    if ((nameSize = WideCharToMultiByte(CP_ACP, 0, lpName, -1, name, 0,
                                         nullptr, nullptr)) == 0)
     {
         ERROR("WideCharToMultiByte failed\n");
@@ -318,8 +318,8 @@ SetEnvironmentVariableW(
         SetLastError(ERROR_NOT_ENOUGH_MEMORY);
         goto done;
     }
-    
-    if (0 == WideCharToMultiByte(CP_ACP, 0, lpName,  -1, 
+
+    if (0 == WideCharToMultiByte(CP_ACP, 0, lpName,  -1,
                                  name,  nameSize, nullptr, nullptr))
     {
         ASSERT("WideCharToMultiByte returned 0\n");
@@ -329,7 +329,7 @@ SetEnvironmentVariableW(
 
     if (lpValue != nullptr)
     {
-        if ((valueSize = WideCharToMultiByte(CP_ACP, 0, lpValue, -1, value, 
+        if ((valueSize = WideCharToMultiByte(CP_ACP, 0, lpValue, -1, value,
                                              0, nullptr, nullptr)) == 0)
         {
             ERROR("WideCharToMultiByte failed\n");
@@ -416,7 +416,7 @@ GetEnvironmentStringsW(
     }
 
     wenviron = (WCHAR *)PAL_malloc(sizeof(WCHAR)* (envNum + 1));
-    if (wenviron == nullptr) 
+    if (wenviron == nullptr)
     {
         ERROR("malloc failed\n");
         SetLastError(ERROR_NOT_ENOUGH_MEMORY);
@@ -511,7 +511,7 @@ Parameters
 
 lpszEnvironmentBlock   [in] Pointer to a block of environment strings. The pointer to
                             the block must be obtained by calling the
-                            GetEnvironmentStrings function. 
+                            GetEnvironmentStrings function.
 
 Return Values
 
@@ -685,7 +685,7 @@ Resizes the PAL environment buffer.
 
 Parameters
 
-    newSize 
+    newSize
            [in] New size of palEnvironment
 
 Return Values
@@ -729,7 +729,7 @@ of the environment if it exists.
 
 Parameters
 
-    name 
+    name
            [in] Name of variable to unset.
 
 --*/
@@ -924,7 +924,7 @@ char* EnvironGetenv(const char* name, BOOL copyValue)
     CPalThread * pthrCurrent = InternalGetCurrentThread();
     InternalEnterCriticalSection(pthrCurrent, &gcsEnvironment);
 
-    int nameLength = strlen(name);
+    size_t nameLength = strlen(name);
     for (int i = 0; palEnvironment[i] != nullptr; ++i)
     {
         if (strlen(palEnvironment[i]) < nameLength)
@@ -1019,7 +1019,7 @@ EnvironInitialize(void)
     // space for all of the 'n' current environment variables, but we don't
     // know how many more there will be, we will initially make room for
     // '2n' variables. If even more are added, we will resize again.
-    // If there are no variables, we will still make room for 1 entry to 
+    // If there are no variables, we will still make room for 1 entry to
     // store a nullptr there.
     int initialSize = (variableCount == 0) ? 1 : variableCount * 2;
 
@@ -1044,14 +1044,14 @@ EnvironInitialize(void)
 /*++
 
 Function : _putenv.
-    
+
 See MSDN for more details.
 
 Note:   The BSD implementation can cause
         memory leaks. See man pages for more details.
 --*/
 int
-__cdecl 
+__cdecl
 _putenv( const char * envstring )
 {
     int ret = -1;
@@ -1076,7 +1076,7 @@ _putenv( const char * envstring )
 /*++
 
 Function : PAL_getenv
-    
+
 See MSDN for more details.
 --*/
 char * __cdecl PAL_getenv(const char *varname)
index de1c5ee..89f5941 100644 (file)
@@ -29,7 +29,7 @@ Revision History:
 #include "pal/stackstring.hpp"
 
 #include <errno.h>
-#include <unistd.h> 
+#include <unistd.h>
 #include <time.h>
 #include <pthread.h>
 #include <dlfcn.h>
@@ -49,16 +49,16 @@ static const char URANDOM_DEVICE_NAME[]="/dev/urandom";
 Function :
 
     PAL_GetPALDirectoryW
-    
+
     Returns the fully qualified path name
     where the PALL DLL was loaded from.
-    
-    On failure it returns FALSE and sets the 
+
+    On failure it returns FALSE and sets the
     proper LastError code.
 
 --*/
-BOOL 
-PAL_GetPALDirectoryW(PathWCharString& lpDirectoryName) 
+BOOL
+PAL_GetPALDirectoryW(PathWCharString& lpDirectoryName)
 {
     LPCWSTR lpFullPathAndName = NULL;
     LPCWSTR lpEndPoint = NULL;
@@ -84,8 +84,8 @@ PAL_GetPALDirectoryW(PathWCharString& lpDirectoryName)
         /* The path that we return is required to have
            the trailing slash on the end.*/
         lpEndPoint++;
-    
-        
+
+
         if(!lpDirectoryName.Set(lpFullPathAndName,lpEndPoint - lpFullPathAndName))
         {
             ASSERT( "The buffer was not large enough.\n" );
@@ -101,8 +101,8 @@ PAL_GetPALDirectoryW(PathWCharString& lpDirectoryName)
         /* Error path, should not be executed. */
         SetLastError( ERROR_INTERNAL_ERROR );
     }
-    
-EXIT:    
+
+EXIT:
     PERF_EXIT(PAL_GetPALDirectoryW);
     return bRet;
 }
@@ -117,9 +117,9 @@ PAL_GetPALDirectoryA(PathCharString& lpDirectoryName)
 
     bRet = PAL_GetPALDirectoryW(directory);
 
-    if (bRet) 
+    if (bRet)
     {
-        
+
         int length = WideCharToMultiByte(CP_ACP, 0, directory.GetString(), -1, NULL, 0, NULL, 0);
         LPSTR DirectoryName = lpDirectoryName.OpenStringBuffer(length);
         if (NULL == DirectoryName)
@@ -127,7 +127,7 @@ PAL_GetPALDirectoryA(PathCharString& lpDirectoryName)
             SetLastError( ERROR_INSUFFICIENT_BUFFER );
             bRet = FALSE;
         }
-        
+
         length = WideCharToMultiByte(CP_ACP, 0, directory.GetString(), -1, DirectoryName, length, NULL, 0);
 
         if (0 == length)
@@ -135,7 +135,7 @@ PAL_GetPALDirectoryA(PathCharString& lpDirectoryName)
             bRet = FALSE;
             length++;
         }
-    
+
         lpDirectoryName.CloseBuffer(length - 1);
     }
 
@@ -148,18 +148,18 @@ PAL_GetPALDirectoryA(PathCharString& lpDirectoryName)
 Function :
 
     PAL_GetPALDirectoryW
-    
+
     Returns the fully qualified path name
     where the PALL DLL was loaded from.
-    
-    On failure it returns FALSE and sets the 
+
+    On failure it returns FALSE and sets the
     proper LastError code.
 
 --*/
 PALIMPORT
-BOOL 
+BOOL
 PALAPI
-PAL_GetPALDirectoryW( OUT LPWSTR lpDirectoryName, IN OUT UINT* cchDirectoryName ) 
+PAL_GetPALDirectoryW( OUT LPWSTR lpDirectoryName, IN OUT UINT* cchDirectoryName )
 {
     PathWCharString directory;
     BOOL bRet;
@@ -169,14 +169,14 @@ PAL_GetPALDirectoryW( OUT LPWSTR lpDirectoryName, IN OUT UINT* cchDirectoryName
     bRet = PAL_GetPALDirectoryW(directory);
 
     if (bRet) {
-        
+
         if (directory.GetCount() > *cchDirectoryName)
         {
             SetLastError( ERROR_INSUFFICIENT_BUFFER );
             bRet = FALSE;
         }
         else
-        { 
+        {
             PAL_wcscpy(lpDirectoryName, directory.GetString());
         }
 
@@ -204,7 +204,7 @@ PAL_GetPALDirectoryA(
 
     bRet = PAL_GetPALDirectoryA(directory);
 
-    if (bRet) 
+    if (bRet)
     {
         if (directory.GetCount() > *cchDirectoryName)
         {
@@ -212,10 +212,10 @@ PAL_GetPALDirectoryA(
             bRet = FALSE;
             *cchDirectoryName = directory.GetCount();
         }
-        else if (strcpy_s(lpDirectoryName, directory.GetCount(), directory.GetString()) == SAFECRT_SUCCESS) 
+        else if (strcpy_s(lpDirectoryName, directory.GetCount(), directory.GetString()) == SAFECRT_SUCCESS)
         {
         }
-        else 
+        else
         {
             bRet = FALSE;
         }
@@ -252,7 +252,7 @@ PAL_Random(
         if (rand_des == -1)
         {
             if (errno == ENOENT)
-            {                
+            {
                 sMissingDevURandom = TRUE;
             }
             else
@@ -267,7 +267,7 @@ PAL_Random(
             DWORD offset = 0;
             do
             {
-                DWORD n = read(rand_des, (BYTE*)lpBuffer + offset , dwLength - offset);
+                ssize_t n = read(rand_des, (BYTE*)lpBuffer + offset , dwLength - offset);
                 if (n == -1)
                 {
                     if (errno == EINTR)
@@ -287,7 +287,7 @@ PAL_Random(
 
             close(rand_des);
         }
-    }    
+    }
 
     if (!sInitializedMRand)
     {
index 9b2de94..78baff7 100644 (file)
@@ -357,10 +357,10 @@ GetNumaProcessorNodeEx(
 
     BOOL success = FALSE;
 
-    if ((Processor->Group < g_groupCount) && 
-        (Processor->Number < MaxCpusPerGroup) && 
+    if ((Processor->Group < g_groupCount) &&
+        (Processor->Number < MaxCpusPerGroup) &&
         (Processor->Reserved == 0))
-    {  
+    {
         short cpu = g_groupAndIndexToCpu[Processor->Group * MaxCpusPerGroup + Processor->Number];
         if (cpu != -1)
         {
@@ -372,7 +372,7 @@ GetNumaProcessorNodeEx(
     if (!success)
     {
         *NodeNumber = 0xffff;
-        SetLastError(ERROR_INVALID_PARAMETER);  
+        SetLastError(ERROR_INVALID_PARAMETER);
     }
 
     LOGEXIT("GetNumaProcessorNodeEx returns BOOL %d\n", success);
@@ -431,7 +431,7 @@ GetLogicalProcessorInformationEx(
     else
     {
         // We only support the group relationship
-        SetLastError(ERROR_INVALID_PARAMETER);  
+        SetLastError(ERROR_INVALID_PARAMETER);
     }
 
     LOGEXIT("GetLogicalProcessorInformationEx returns BOOL %d\n", success);
@@ -741,7 +741,7 @@ GetCurrentProcessorNumberEx(
     ENTRY("GetCurrentProcessorNumberEx(ProcNumber=%p\n", ProcNumber);
 
     DWORD cpu = GetCurrentProcessorNumber();
-    _ASSERTE(cpu < g_possibleCpuCount);
+    _ASSERTE((int)cpu < g_possibleCpuCount);
     ProcNumber->Group = g_cpuToAffinity[cpu].Group;
     ProcNumber->Number = g_cpuToAffinity[cpu].Number;
 
@@ -861,14 +861,14 @@ VirtualAllocExNuma(
 )
 {
     PERF_ENTRY(VirtualAllocExNuma);
-    ENTRY("VirtualAllocExNuma(hProcess=%p, lpAddress=%p, dwSize=%u, flAllocationType=%#x, flProtect=%#x, nndPreferred=%d\n", 
+    ENTRY("VirtualAllocExNuma(hProcess=%p, lpAddress=%p, dwSize=%u, flAllocationType=%#x, flProtect=%#x, nndPreferred=%d\n",
         hProcess, lpAddress, dwSize, flAllocationType, flProtect, nndPreferred);
 
     LPVOID result = NULL;
 
     if (hProcess == GetCurrentProcess())
     {
-        if (nndPreferred <= g_highestNumaNode)
+        if ((int)nndPreferred <= g_highestNumaNode)
         {
             result = VirtualAlloc(lpAddress, dwSize, flAllocationType, flProtect);
 #if HAVE_NUMA_H
@@ -894,7 +894,7 @@ VirtualAllocExNuma(
             // The specified node number is larger than the maximum available one
             SetLastError(ERROR_INVALID_PARAMETER);
         }
-    }    
+    }
     else
     {
         // PAL supports allocating from the current process virtual space only
@@ -976,7 +976,7 @@ SetThreadIdealProcessorEx(
             }
         }
 
-        _ASSERTE(prevCpu < g_possibleCpuCount);
+        _ASSERTE((int)prevCpu < g_possibleCpuCount);
         lpPreviousIdealProcessor->Group = g_cpuToAffinity[prevCpu].Group;
         lpPreviousIdealProcessor->Number = g_cpuToAffinity[prevCpu].Number;
         lpPreviousIdealProcessor->Reserved = 0;
index 3a14fa5..77dd32a 100644 (file)
@@ -27,7 +27,7 @@ errno_t __cdecl _FUNC_NAME(
     int drive_set = 0;
     size_t length = 0;
     int bEinval = 0;
-       
+
     /* validation section */
     if (_Path == NULL)
     {
@@ -138,9 +138,9 @@ errno_t __cdecl _FUNC_NAME(
                 goto error_erange;
             }
             _TCSNCPY_S(_Dir, _DirSize, _Path, length);
-                       
+
             // Normalize the path seperator
-            int iIndex;
+            size_t iIndex;
             for(iIndex = 0; iIndex < length; iIndex++)
             {
                 if (_Dir[iIndex] == _T('\\'))
@@ -184,7 +184,7 @@ errno_t __cdecl _FUNC_NAME(
                 // set length to 1 to get the "." in filename buffer.
                 length = 1;
             }
-                       
+
             if (_FilenameSize <= length)
             {
                 goto error_erange;
@@ -200,7 +200,7 @@ errno_t __cdecl _FUNC_NAME(
             // At this time, _Path is pointing to the character after the last slash found.
             // (See comments and code above for clarification).
             //
-            // Returns extension as empty string for strings like "/.". 
+            // Returns extension as empty string for strings like "/.".
             if (dot > _Path)
             {
                 length = (size_t)(tmp - dot);
@@ -208,13 +208,13 @@ errno_t __cdecl _FUNC_NAME(
                 {
                      goto error_erange;
                 }
-                
+
                 /* Since dot pointed to the ".", make sure we actually have an extension
                 like ".cmd" and not just ".", OR
-                
+
                 Confirm that its a string like "/.." - for this, return the
                 second "." in the extension part.
-                
+
                 However, for strings like "/myfile.", return empty string
                 in extension buffer.
                 */
index 2607712..619fae0 100644 (file)
@@ -315,7 +315,7 @@ SIZE_T SharedMemoryHelpers::GetFileSize(int fileDescriptor)
 void SharedMemoryHelpers::SetFileSize(int fileDescriptor, SIZE_T byteCount)
 {
     _ASSERTE(fileDescriptor != -1);
-    _ASSERTE(static_cast<off_t>(byteCount) == byteCount);
+    _ASSERTE(static_cast<SIZE_T>(byteCount) == byteCount);
 
     while (true)
     {
@@ -395,7 +395,7 @@ void SharedMemoryHelpers::ReleaseFileLock(int fileDescriptor)
 
 void SharedMemoryHelpers::BuildSharedFilesPath(PathCharString& destination, const char *suffix, int suffixCharCount)
 {
-    _ASSERTE(strlen(suffix) == suffixCharCount);
+    _ASSERTE((int)strlen(suffix) == suffixCharCount);
 
     VerifyStringOperation(destination.Set(*gSharedFilesPath));
     VerifyStringOperation(destination.Append(suffix, suffixCharCount));
index a9cae77..5615036 100644 (file)
@@ -149,7 +149,7 @@ static int* s_helperPage = 0;
 
 //
 // Mutex to make the FlushProcessWriteBuffersMutex thread safe
-// 
+//
 pthread_mutex_t flushProcessWriteBuffersMutex;
 
 CAllowedObjectTypes aotProcess(otiProcess);
@@ -177,7 +177,7 @@ DWORD g_dwThreadCount;
 LPWSTR g_lpwstrCmdLine = NULL;
 LPWSTR g_lpwstrAppDir = NULL;
 
-// Thread ID of thread that has started the ExitProcess process 
+// Thread ID of thread that has started the ExitProcess process
 Volatile<LONG> terminator = 0;
 
 // Process and session ID of this process.
@@ -227,7 +227,7 @@ enum FILETYPE
 };
 
 #pragma pack(push,1)
-// When creating the semaphore name on Mac running in a sandbox, We reference this structure as a byte array 
+// When creating the semaphore name on Mac running in a sandbox, We reference this structure as a byte array
 // in order to encode its data into a string. Its important to make sure there is no padding between the fields
 // and also at the end of the buffer. Hence, this structure is defined inside a pack(1)
 struct UnambiguousProcessDescriptor
@@ -253,14 +253,13 @@ struct UnambiguousProcessDescriptor
 
 static
 DWORD
-PALAPI
 StartupHelperThread(
     LPVOID p);
 
-static 
-BOOL 
+static
+BOOL
 GetProcessIdDisambiguationKey(
-    IN DWORD processId, 
+    IN DWORD processId,
     OUT UINT64 *disambiguationKey);
 
 PAL_ERROR
@@ -271,7 +270,7 @@ PROCGetProcessStatus(
     DWORD *pdwExitCode);
 
 static
-void 
+void
 CreateSemaphoreName(
     char semName[CLR_SEM_MAX_NAMELEN],
     LPCSTR semaphoreName,
@@ -689,7 +688,7 @@ CorUnix::InternalCreateProcess(
     int iFdOut = -1;
     IPalObject *pobjFileErr = NULL;
     int iFdErr = -1;
-    
+
     pid_t processId;
     PathCharString lpFileNamePS;
     char **lppArgv = NULL;
@@ -711,7 +710,7 @@ CorUnix::InternalCreateProcess(
                lpApplicationName);
         palError = ERROR_INVALID_PARAMETER;
         goto InternalCreateProcessExit;
-    } 
+    }
 
     if (0 != (dwCreationFlags & ~(CREATE_SUSPENDED|CREATE_NEW_CONSOLE)))
     {
@@ -811,7 +810,7 @@ CorUnix::InternalCreateProcess(
         palError = ERROR_FILE_NOT_FOUND;
         goto InternalCreateProcessExit;
     }
-    
+
     /* check type of file */
     iRet = checkFileType(lpFileNamePS);
 
@@ -884,7 +883,7 @@ CorUnix::InternalCreateProcess(
     palError = g_pObjectManager->AllocateObject(
         pThread,
         &otProcess,
-        &oa, 
+        &oa,
         &pobjProcess
         );
 
@@ -926,7 +925,7 @@ CorUnix::InternalCreateProcess(
         &pDummyThread,
         &hDummyThread
         );
-    
+
     if (dwCreationFlags & CREATE_SUSPENDED)
     {
         int pipe_descs[2];
@@ -936,7 +935,7 @@ CorUnix::InternalCreateProcess(
             ERROR("pipe() failed! error is %d (%s)\n", errno, strerror(errno));
             palError = ERROR_NOT_ENOUGH_MEMORY;
             goto InternalCreateProcessExit;
-        }                        
+        }
 
         /* [0] is read end, [1] is write end */
         pDummyThread->suspensionInfo.SetBlockingPipe(pipe_descs[1]);
@@ -954,9 +953,9 @@ CorUnix::InternalCreateProcess(
     if (NO_ERROR != palError)
     {
         ASSERT("Unable to obtain local data for new process object\n");
-        goto InternalCreateProcessExit;    
+        goto InternalCreateProcessExit;
     }
-        
+
 
     /* fork the new process */
     processId = fork();
@@ -974,15 +973,15 @@ CorUnix::InternalCreateProcess(
         goto InternalCreateProcessExit;
     }
 
-    /* From the time the child process begins running, to when it reaches execve, 
+    /* From the time the child process begins running, to when it reaches execve,
     the child process is not a real PAL process and does not own any PAL
-    resources, although it has access to the PAL resources of its parent process. 
-    Thus, while the child process is in this window, it is dangerous for it to affect 
+    resources, although it has access to the PAL resources of its parent process.
+    Thus, while the child process is in this window, it is dangerous for it to affect
     its parent's PAL resources. As a consequence, no PAL code should be used
     in this window; all code should make unix calls. Note the use of _exit
     instead of exit to avoid calling PAL_Terminate and the lack of TRACE's and
     ASSERT's. */
-    
+
     if (processId == 0)  /* child process */
     {
         // At this point, the PAL should be considered uninitialized for this child process.
@@ -991,8 +990,8 @@ CorUnix::InternalCreateProcess(
         // calling PAL functions. Furthermore, nothing should be changing
         // the init_count in the child process at this point since this is the only
         // thread executing.
-        init_count = 0; 
-        
+        init_count = 0;
+
         sigset_t sm;
 
         //
@@ -1005,7 +1004,7 @@ CorUnix::InternalCreateProcess(
         {
             _exit(EXIT_FAILURE);
         }
-        
+
         if (dwCreationFlags & CREATE_SUSPENDED)
         {
             BYTE resume_code = 0;
@@ -1025,7 +1024,7 @@ CorUnix::InternalCreateProcess(
                 }
                 else
                 {
-                    /* note : read might return 0 (and return EAGAIN) if the other 
+                    /* note : read might return 0 (and return EAGAIN) if the other
                        end of the pipe gets closed - for example because the parent
                        process dies (very) abruptly */
                     _exit(EXIT_FAILURE);
@@ -1068,9 +1067,9 @@ CorUnix::InternalCreateProcess(
             if (dup2(iFdErr, STDERR_FILENO) == -1)
             {
                 // Didn't duplicate standard error.
-                _exit(EXIT_FAILURE);            
+                _exit(EXIT_FAILURE);
             }
-            
+
             /* now close the original FDs, we don't need them anymore */
             close(iFdIn);
             close(iFdOut);
@@ -1101,13 +1100,13 @@ CorUnix::InternalCreateProcess(
     pLocalData->dwProcessId = processId;
     pLocalDataLock->ReleaseLock(pThread, TRUE);
     pLocalDataLock = NULL;
-    
-    // 
+
+    //
     // Release file handle info; we don't need them anymore. Note that
     // this must happen after we've released the data locks, as
     // otherwise a deadlock could result.
     //
-    
+
     if (lpStartupInfo->dwFlags & STARTF_USESTDHANDLES)
     {
         pobjFileIn->ReleaseReference(pThread);
@@ -1167,11 +1166,11 @@ InternalCreateProcessExit:
         free(EnvironmentArray);
     }
 
-    /* if we still have the file structures at this point, it means we 
-       encountered an error sometime between when we acquired them and when we 
-       fork()ed. We not only have to release them, we have to give them back 
+    /* if we still have the file structures at this point, it means we
+       encountered an error sometime between when we acquired them and when we
+       fork()ed. We not only have to release them, we have to give them back
        their close-on-exec flag */
-    if (NULL != pobjFileIn) 
+    if (NULL != pobjFileIn)
     {
         if(-1 == fcntl(iFdIn, F_SETFD, 1))
         {
@@ -1180,8 +1179,8 @@ InternalCreateProcessExit:
         }
         pobjFileIn->ReleaseReference(pThread);
     }
-    
-    if (NULL != pobjFileOut) 
+
+    if (NULL != pobjFileOut)
     {
         if(-1 == fcntl(iFdOut, F_SETFD, 1))
         {
@@ -1190,8 +1189,8 @@ InternalCreateProcessExit:
         }
         pobjFileOut->ReleaseReference(pThread);
     }
-    
-    if (NULL != pobjFileErr) 
+
+    if (NULL != pobjFileErr)
     {
         if(-1 == fcntl(iFdErr, F_SETFD, 1))
         {
@@ -1248,7 +1247,7 @@ GetExitCodeProcess(
         &ps,
         &dwExitCode
         );
-    
+
     if (NO_ERROR != palError)
     {
         ASSERT("Couldn't get process status information!\n");
@@ -1270,10 +1269,10 @@ done:
     {
         pThread->SetLastError(palError);
     }
-    
+
     LOGEXIT("GetExitCodeProcess returns BOOL %d\n", NO_ERROR == palError);
     PERF_EXIT(GetExitCodeProcess);
-    
+
     return NO_ERROR == palError;
 }
 
@@ -1317,12 +1316,12 @@ ExitProcess(
     }
     else if (0 != old_terminator)
     {
-        /* another thread has already initiated the termination process. we 
-           could just block on the PALInitLock critical section, but then 
+        /* another thread has already initiated the termination process. we
+           could just block on the PALInitLock critical section, but then
            PROCSuspendOtherThreads would hang... so sleep forever here, we're
-           terminating anyway 
+           terminating anyway
 
-           Update: [TODO] PROCSuspendOtherThreads has been removed. Can this 
+           Update: [TODO] PROCSuspendOtherThreads has been removed. Can this
            code be changed? */
         WARN("termination already started from another thread; blocking.\n");
         poll(NULL, 0, INFTIM);
@@ -1341,7 +1340,7 @@ ExitProcess(
     else
     {
         exit(uExitCode);
-        
+
         /* Should not get here, because we terminate the current process */
         ASSERT("exit has returned\n");
     }
@@ -1372,7 +1371,7 @@ TerminateProcess(
     ENTRY("TerminateProcess(hProcess=%p, uExitCode=%u)\n",hProcess, uExitCode );
 
     ret = PROCEndProcess(hProcess, uExitCode, TRUE);
-    
+
     LOGEXIT("TerminateProcess returns BOOL %d\n", ret);
     PERF_EXIT(TerminateProcess);
     return ret;
@@ -1404,7 +1403,7 @@ RaiseFailFastException(
 /*++
 Function:
   PROCEndProcess
-  
+
   Called from TerminateProcess and ExitProcess. This does the work of
   TerminateProcess, but also takes a flag that determines whether we
   shut down unconditionally. If the flag is set, the PAL will do very
@@ -1426,7 +1425,7 @@ static BOOL PROCEndProcess(HANDLE hProcess, UINT uExitCode, BOOL bTerminateUncon
     {
         if (uExitCode != 0)
             WARN("exit code 0x%x ignored for external process.\n", uExitCode);
-            
+
         if (kill(dwProcessId, SIGKILL) == 0)
         {
             ret = TRUE;
@@ -1463,7 +1462,7 @@ static BOOL PROCEndProcess(HANDLE hProcess, UINT uExitCode, BOOL bTerminateUncon
         }
 
         TerminateCurrentProcessNoExit(bTerminateUnconditionally);
-        
+
         LOGEXIT("PROCEndProcess will not return\n");
 
         // exit() runs atexit handlers possibly registered by foreign code.
@@ -1471,10 +1470,10 @@ static BOOL PROCEndProcess(HANDLE hProcess, UINT uExitCode, BOOL bTerminateUncon
         // registered our own PAL_Terminate with atexit(), the latter will
         // explicitly re-enter us.
         PAL_Leave(PAL_BoundaryBottom);
-        
+
         if (bTerminateUnconditionally)
         {
-            // abort() has the semantics that 
+            // abort() has the semantics that
             // (1) it doesn't run atexit handlers
             // (2) can invoke CrashReporter or produce a coredump,
             // which is appropriate for TerminateProcess calls
@@ -1527,7 +1526,7 @@ static bool IsCoreClrModule(const char* pModulePath)
 // Build the semaphore names using the PID and a value that can be used for distinguishing
 // between processes with the same PID (which ran at different times). This is to avoid
 // cases where a prior process with the same PID exited abnormally without having a chance
-// to clean up its semaphore. 
+// to clean up its semaphore.
 // Note to anyone modifying these names in the future: Semaphore names on OS X are limited
 // to SEM_NAME_LEN characters, including null. SEM_NAME_LEN is 31 (at least on OS X 10.11).
 // NetBSD limits semaphore names to 15 characters, including null (at least up to 7.99.25).
@@ -1561,9 +1560,9 @@ class PAL_RuntimeStartupHelper
     DWORD m_threadId;
     HANDLE m_threadHandle;
     DWORD m_processId;
-#ifdef __APPLE__    
+#ifdef __APPLE__
     char m_applicationGroupId[MAX_APPLICATION_GROUP_ID_LENGTH+1];
-#endif // __APPLE__    
+#endif // __APPLE__
     char m_startupSemName[CLR_SEM_MAX_NAMELEN];
     char m_continueSemName[CLR_SEM_MAX_NAMELEN];
 
@@ -1574,17 +1573,17 @@ class PAL_RuntimeStartupHelper
     // Debugger waits on this semaphore and the runtime signals it on startup.
     sem_t *m_startupSem;
 
-    // Debuggee waits on this semaphore and the debugger signals it after the startup callback 
+    // Debuggee waits on this semaphore and the debugger signals it after the startup callback
     // registered (m_callback) returns.
     sem_t *m_continueSem;
 
     LPCSTR GetApplicationGroupId() const
     {
-#ifdef __APPLE__        
+#ifdef __APPLE__
         return m_applicationGroupId[0] == '\0' ? nullptr : m_applicationGroupId;
 #else // __APPLE__
         return nullptr;
-#endif // __APPLE__        
+#endif // __APPLE__
     }
 
 public:
@@ -1702,8 +1701,8 @@ public:
         // it can be used by the cleanup code that removes the semaphore with sem_unlink.
         ret = GetProcessIdDisambiguationKey(m_processId, &m_processIdDisambiguationKey);
 
-        // If GetProcessIdDisambiguationKey failed for some reason, it should set the value 
-        // to 0. We expect that anyone else opening the semaphore name will also fail and thus 
+        // If GetProcessIdDisambiguationKey failed for some reason, it should set the value
+        // to 0. We expect that anyone else opening the semaphore name will also fail and thus
         // will also try to use 0 as the value.
         _ASSERTE(ret == TRUE || m_processIdDisambiguationKey == 0);
 
@@ -1713,7 +1712,7 @@ public:
 
         TRACE("PAL_RuntimeStartupHelper.Register creating startup '%s' continue '%s'\n", m_startupSemName, m_continueSemName);
 
-        // Create the continue semaphore first so we don't race with PAL_NotifyRuntimeStarted. This open will fail if another 
+        // Create the continue semaphore first so we don't race with PAL_NotifyRuntimeStarted. This open will fail if another
         // debugger is trying to attach to this process because the name will already exist.
         m_continueSem = sem_open(m_continueSemName, O_CREAT | O_EXCL, S_IRWXU, 0);
         if (m_continueSem == SEM_FAILED)
@@ -1787,23 +1786,23 @@ public:
     //
     // There are a couple race conditions that need to be considered here:
     //
-    // * On launch, between the fork and execv in the PAL's CreateProcess where the target process 
-    //   may contain a coreclr module image if the debugger process is running managed code. This 
+    // * On launch, between the fork and execv in the PAL's CreateProcess where the target process
+    //   may contain a coreclr module image if the debugger process is running managed code. This
     //   makes just checking if the coreclr module exists not enough.
     //
-    // * On launch (after the execv) or attach when the coreclr is loaded but before the DAC globals 
+    // * On launch (after the execv) or attach when the coreclr is loaded but before the DAC globals
     //   table is initialized where it is too soon to use/initialize the DAC on the debugger side.
     //
     // They are both fixed by check if the one of transport pipe files has been created.
     //
     bool IsCoreClrProcessReady()
     {
-        char pipeName[MAX_DEBUGGER_TRANSPORT_PIPE_NAME_LENGTH];  
+        char pipeName[MAX_DEBUGGER_TRANSPORT_PIPE_NAME_LENGTH];
 
         PAL_GetTransportPipeName(pipeName, m_processId, GetApplicationGroupId(), "in");
 
         struct stat buf;
-        if (stat(pipeName, &buf) == 0) 
+        if (stat(pipeName, &buf) == 0)
         {
             TRACE("IsCoreClrProcessReady: stat(%s) SUCCEEDED\n", pipeName);
             return true;
@@ -1823,7 +1822,7 @@ public:
             goto exit;
         }
 
-        // Enumerate all the modules in the process and invoke the callback 
+        // Enumerate all the modules in the process and invoke the callback
         // for the coreclr module if found.
         listHead = CreateProcessModules(m_processId, &count);
         if (listHead == NULL)
@@ -1853,7 +1852,7 @@ public:
         }
 
     exit:
-        // Wake up the runtime 
+        // Wake up the runtime
         if (sem_post(m_continueSem) != 0)
         {
             ASSERT("sem_post(continueSem) failed: errno is %d (%s)\n", errno, strerror(errno));
@@ -1898,8 +1897,7 @@ public:
 };
 
 static
-DWORD 
-PALAPI
+DWORD
 StartupHelperThread(LPVOID p)
 {
     TRACE("PAL's StartupHelperThread starting\n");
@@ -1916,7 +1914,7 @@ StartupHelperThread(LPVOID p)
 Parameters:
     dwProcessId - process id of runtime process
     lpApplicationGroupId - A string representing the application group ID of a sandboxed
-                           process running in Mac. Pass NULL if the process is not 
+                           process running in Mac. Pass NULL if the process is not
                            running in a sandbox and other platforms.
     pfnCallback - function to callback for coreclr module found
     parameter - data to pass to callback
@@ -1948,7 +1946,7 @@ PAL_RegisterForRuntimeStartup(
 
     PAL_RuntimeStartupHelper *helper = InternalNew<PAL_RuntimeStartupHelper>(dwProcessId, pfnCallback, parameter);
 
-    // Create the debuggee startup semaphore so the runtime (debuggee) knows to wait for 
+    // Create the debuggee startup semaphore so the runtime (debuggee) knows to wait for
     // a debugger connection.
     PAL_ERROR pe = helper->Register(lpApplicationGroupId);
     if (NO_ERROR != pe)
@@ -2013,14 +2011,14 @@ PAL_NotifyRuntimeStarted()
     UINT64 processIdDisambiguationKey = 0;
     BOOL ret = GetProcessIdDisambiguationKey(gPID, &processIdDisambiguationKey);
 
-    // If GetProcessIdDisambiguationKey failed for some reason, it should set the value 
-    // to 0. We expect that anyone else making the semaphore name will also fail and thus 
+    // If GetProcessIdDisambiguationKey failed for some reason, it should set the value
+    // to 0. We expect that anyone else making the semaphore name will also fail and thus
     // will also try to use 0 as the value.
     _ASSERTE(ret == TRUE || processIdDisambiguationKey == 0);
 
     UnambiguousProcessDescriptor unambiguousProcessDescriptor(gPID, processIdDisambiguationKey);
-    LPCSTR applicationGroupId = 
-#ifdef __APPLE__    
+    LPCSTR applicationGroupId =
+#ifdef __APPLE__
         PAL_GetApplicationGroupId();
 #else
         nullptr;
@@ -2100,7 +2098,7 @@ static_assert_no_msg(MAX_APPLICATION_GROUP_ID_LENGTH
     <= CLR_SEM_MAX_NAMELEN);
 
 // In Apple we are limited by the length of the semaphore name. However, the characters which can be used in the
-// name can be anything between 1 and 255 (since 0 will terminate the string). Thus, we encode each byte b in 
+// name can be anything between 1 and 255 (since 0 will terminate the string). Thus, we encode each byte b in
 // unambiguousProcessDescriptor as b ? b : 1, and mark an additional bit indicating if b is 0 or not. We use 7 bits
 // out of each extra byte so 1 bit will always be '1'. This will ensure that our extra bytes are never 0 which are
 // invalid characters. Thus we need an extra byte for each 7 input bytes. Hence, only extra 2 bytes for the name string.
@@ -2141,7 +2139,7 @@ void CreateSemaphoreName(char semName[CLR_SEM_MAX_NAMELEN], LPCSTR semaphoreName
         semName[length] = 0;
     }
     else
-#endif // __APPLE__    
+#endif // __APPLE__
     {
         length = sprintf_s(
             semName,
@@ -2237,10 +2235,10 @@ GetProcessIdDisambiguationKey(DWORD processId, UINT64 *disambiguationKey)
 
     INDEBUG(int chars = )
     snprintf(statFileName, sizeof(statFileName), "/proc/%d/stat", processId);
-    _ASSERTE(chars > 0 && chars <= sizeof(statFileName));
+    _ASSERTE(chars > 0 && chars <= (int)sizeof(statFileName));
 
     FILE *statFile = fopen(statFileName, "r");
-    if (statFile == nullptr) 
+    if (statFile == nullptr)
     {
         TRACE("GetProcessIdDisambiguationKey: fopen() FAILED");
         SetLastError(ERROR_INVALID_HANDLE);
@@ -2265,7 +2263,7 @@ GetProcessIdDisambiguationKey(DWORD processId, UINT64 *disambiguationKey)
     char *scanStartPosition = strrchr(line, ')') + 2;
 
     // All the format specifiers for the fields in the stat file are provided by 'man proc'.
-    int sscanfRet = sscanf_s(scanStartPosition, 
+    int sscanfRet = sscanf_s(scanStartPosition,
         "%*c %*d %*d %*d %*d %*d %*u %*lu %*lu %*lu %*lu %*lu %*lu %*ld %*ld %*ld %*ld %*ld %*ld %llu \n",
          &starttime);
 
@@ -2290,7 +2288,7 @@ GetProcessIdDisambiguationKey(DWORD processId, UINT64 *disambiguationKey)
 
 /*++
  Function:
-  PAL_GetTransportPipeName 
+  PAL_GetTransportPipeName
 
   Builds the transport pipe names from the process id.
 --*/
@@ -2314,7 +2312,7 @@ PAL_GetTransportPipeName(
         return;
     }
 
-    // If GetProcessIdDisambiguationKey failed for some reason, it should set the value 
+    // If GetProcessIdDisambiguationKey failed for some reason, it should set the value
     // to 0. We expect that anyone else making the pipe name will also fail and thus will
     // also try to use 0 as the value.
     _ASSERTE(ret == TRUE || disambiguationKey == 0);
@@ -2346,7 +2344,7 @@ PAL_GetTransportPipeName(
         }
     }
     else
-#endif // __APPLE__    
+#endif // __APPLE__
     {
         // Get a temp file location
         dwRetVal = ::GetTempPathA(MAX_DEBUGGER_TRANSPORT_PIPE_NAME_LENGTH, formatBuffer);
@@ -2409,7 +2407,7 @@ GetProcessTimes(
         goto GetProcessTimesExit;
     }
 
-    /* First, we need to actually retrieve the relevant statistics from the 
+    /* First, we need to actually retrieve the relevant statistics from the
        OS */
     if (getrusage (RUSAGE_SELF, &resUsage) == -1)
     {
@@ -2418,7 +2416,7 @@ GetProcessTimes(
         SetLastError(ERROR_INTERNAL_ERROR);
         goto GetProcessTimesExit;
     }
-    
+
     TRACE ("getrusage User: %ld sec,%ld microsec. Kernel: %ld sec,%ld"
            " microsec\n",
            resUsage.ru_utime.tv_sec, resUsage.ru_utime.tv_usec,
@@ -2445,7 +2443,7 @@ GetProcessTimes(
         lpKernelTime->dwLowDateTime = (DWORD)calcTime;
         lpKernelTime->dwHighDateTime = (DWORD)(calcTime >> 32);
     }
-    
+
     retval = TRUE;
 
 
@@ -2457,7 +2455,7 @@ GetProcessTimesExit:
 
 #define FILETIME_TO_ULONGLONG(f) \
     (((ULONGLONG)(f).dwHighDateTime << 32) | ((ULONGLONG)(f).dwLowDateTime))
-    
+
 /*++
 Function:
   PAL_GetCPUBusyTime
@@ -2595,7 +2593,7 @@ GetCommandLineW(
           g_lpwstrCmdLine,
           lpwstr);
     PERF_EXIT(GetCommandLineW);
-    
+
     return lpwstr;
 }
 
@@ -2684,7 +2682,7 @@ OpenProcess(
     //
     // TODO: check to see if the process actually exists?
     //
-    
+
 OpenProcessExit:
 
     if (NULL != pobjProcess)
@@ -2718,10 +2716,10 @@ Return
   TRUE if it succeeded, FALSE otherwise
 
 Notes
-  This API is tricky because the module handles are never closed/freed so there can't be any 
-  allocations for the module handle or name strings, etc. The "handles" are actually the base 
-  addresses of the modules. The module handles should only be used by GetModuleFileNameExW 
-  below. 
+  This API is tricky because the module handles are never closed/freed so there can't be any
+  allocations for the module handle or name strings, etc. The "handles" are actually the base
+  addresses of the modules. The module handles should only be used by GetModuleFileNameExW
+  below.
 --*/
 BOOL
 PALAPI
@@ -2772,7 +2770,7 @@ EnumProcessModules(
 Function:
   GetModuleFileNameExW
 
-  Used only with module handles returned from EnumProcessModule (for dbgshim). 
+  Used only with module handles returned from EnumProcessModule (for dbgshim).
 
 --*/
 DWORD
@@ -3010,9 +3008,9 @@ CreateProcessModules(
     pclose(vmmapFile);
 exit:
 
-#elif HAVE_PROCFS_MAPS 
+#elif HAVE_PROCFS_MAPS
 
-    // Here we read /proc/<pid>/maps file in order to parse it and figure out what it says 
+    // Here we read /proc/<pid>/maps file in order to parse it and figure out what it says
     // about a library we are looking for. This file looks something like this:
     //
     // [address]      [perms] [offset] [dev] [inode]     [pathname] - HEADER is not preset in an actual file
@@ -3027,7 +3025,7 @@ exit:
     // 35b1fb0000-35b1fb2000 rw-p 001b0000 08:02 135870  /usr/lib64/libc-2.15.so
 
     // Making something like: /proc/123/maps
-    char mapFileName[100]; 
+    char mapFileName[100];
     char *line = NULL;
     size_t lineLen = 0;
     int count = 0;
@@ -3035,16 +3033,16 @@ exit:
 
     INDEBUG(int chars = )
     snprintf(mapFileName, sizeof(mapFileName), "/proc/%d/maps", dwProcessId);
-    _ASSERTE(chars > 0 && chars <= sizeof(mapFileName));
+    _ASSERTE(chars > 0 && chars <= (int)sizeof(mapFileName));
 
     FILE *mapsFile = fopen(mapFileName, "r");
-    if (mapsFile == NULL) 
+    if (mapsFile == NULL)
     {
         goto exit;
     }
 
-    // Reading maps file line by line 
-    while ((read = getline(&line, &lineLen, mapsFile)) != -1) 
+    // Reading maps file line by line
+    while ((read = getline(&line, &lineLen, mapsFile)) != -1)
     {
         void *startAddress, *endAddress, *offset;
         int devHi, devLo, inode;
@@ -3122,14 +3120,14 @@ DestroyProcessModules(IN ProcessModules *listHead)
 /*++
 Function
   PROCNotifyProcessShutdown
-  
-  Calls the abort handler to do any shutdown cleanup. Call be called 
+
+  Calls the abort handler to do any shutdown cleanup. Call be called
   from the unhandled native exception handler.
 
 (no return value)
 --*/
-__attribute__((destructor)) 
-VOID 
+__attribute__((destructor))
+VOID
 PROCNotifyProcessShutdown()
 {
     // Call back into the coreclr to clean up the debugger transport pipes
@@ -3143,15 +3141,15 @@ PROCNotifyProcessShutdown()
 /*++
 Function
   PROCAbortInitialize()
-  
+
 Abstract
   Initialize the process abort crash dump program file path and
   name. Doing all of this ahead of time so nothing is allocated
   or copied in PROCAbort/signal handler.
-  
+
 Return
   TRUE - succeeds, FALSE - fails
-  
+
 --*/
 BOOL
 PROCAbortInitialize()
@@ -3297,7 +3295,7 @@ Function:
 
   Aborts the process after calling the shutdown cleanup handler. This function
   should be called instead of calling abort() directly.
-  
+
   Does not return
 --*/
 PAL_NORETURN
@@ -3322,7 +3320,7 @@ Abstract
 Return
   TRUE if it succeeded, FALSE otherwise
 --*/
-BOOL 
+BOOL
 InitializeFlushProcessWriteBuffers()
 {
     _ASSERTE(s_helperPage == 0);
@@ -3388,10 +3386,10 @@ Function:
 
 See MSDN doc.
 --*/
-VOID 
-PALAPI 
+VOID
+PALAPI
 FlushProcessWriteBuffers()
-{   
+{
     if (s_flushUsingMemBarrier)
     {
         int status = membarrier(MEMBARRIER_CMD_PRIVATE_EXPEDITED, 0);
@@ -3440,7 +3438,7 @@ PROCGetProcessIDFromHandle(
     PAL_ERROR palError;
     IPalObject *pobjProcess = NULL;
     CPalThread *pThread = InternalGetCurrentThread();
-    
+
     DWORD dwProcessId = 0;
 
     if (hPseudoCurrentProcess == hProcess)
@@ -3448,7 +3446,7 @@ PROCGetProcessIDFromHandle(
         dwProcessId = gPID;
         goto PROCGetProcessIDFromHandleExit;
     }
-    
+
 
     palError = g_pObjectManager->ReferenceObjectByHandle(
         pThread,
@@ -3474,8 +3472,8 @@ PROCGetProcessIDFromHandle(
         {
             dwProcessId = pLocalData->dwProcessId;
             pDataLock->ReleaseLock(pThread, FALSE);
-        }        
-        
+        }
+
         pobjProcess->ReleaseReference(pThread);
     }
 
@@ -3491,7 +3489,7 @@ CorUnix::InitializeProcessData(
 {
     PAL_ERROR palError = NO_ERROR;
     bool fLockInitialized = FALSE;
-    
+
     pGThreadList = NULL;
     g_dwThreadCount = 0;
 
@@ -3519,7 +3517,7 @@ Abstract
 Parameter
     lpwstrCmdLine
     lpwstrFullPath
+
 Return
     PAL_ERROR
 
@@ -3587,7 +3585,7 @@ Abstract
 
 Parameter
   pThread - the initial thread
+
 Return
   PAL_ERROR
 --*/
@@ -3624,7 +3622,7 @@ CorUnix::CreateInitialProcessAndThreadObjects(
     //
     // Create and initialize process object
     //
-    
+
     palError = g_pObjectManager->AllocateObject(
         pThread,
         &otProcess,
@@ -3640,7 +3638,7 @@ CorUnix::CreateInitialProcessAndThreadObjects(
 
     palError = pobjProcess->GetProcessLocalData(
         pThread,
-        WriteLock, 
+        WriteLock,
         &pDataLock,
         reinterpret_cast<void **>(&pLocalData)
         );
@@ -3728,7 +3726,7 @@ PROCCleanupInitialProcess(VOID)
     // Object manager shutdown will handle freeing the underlying
     // thread and process data
     //
-    
+
 }
 
 /*++
@@ -3748,7 +3746,7 @@ CorUnix::PROCAddThread(
     CPalThread *pTargetThread
     )
 {
-    /* protect the access of the thread list with critical section for 
+    /* protect the access of the thread list with critical section for
        mutithreading access */
     InternalEnterCriticalSection(pCurrentThread, &g_csProcess);
 
@@ -3783,7 +3781,7 @@ CorUnix::PROCRemoveThread(
 {
     CPalThread *curThread, *prevThread;
 
-    /* protect the access of the thread list with critical section for 
+    /* protect the access of the thread list with critical section for
        mutithreading access */
     InternalEnterCriticalSection(pCurrentThread, &g_csProcess);
 
@@ -3800,7 +3798,7 @@ CorUnix::PROCRemoveThread(
     if (curThread == pTargetThread)
     {
         pGThreadList =  curThread->GetNext();
-        TRACE("Thread 0x%p (id %#x) removed from the process thread list\n", 
+        TRACE("Thread 0x%p (id %#x) removed from the process thread list\n",
             pTargetThread, pTargetThread->GetThreadId());
         goto EXIT;
     }
@@ -3868,7 +3866,7 @@ VOID
 PROCProcessLock(
     VOID)
 {
-    CPalThread * pThread = 
+    CPalThread * pThread =
         (PALIsThreadDataInitialized() ? InternalGetCurrentThread() : NULL);
 
     InternalEnterCriticalSection(pThread, &g_csProcess);
@@ -3892,10 +3890,10 @@ VOID
 PROCProcessUnlock(
     VOID)
 {
-    CPalThread * pThread = 
+    CPalThread * pThread =
         (PALIsThreadDataInitialized() ? InternalGetCurrentThread() : NULL);
 
-    InternalLeaveCriticalSection(pThread, &g_csProcess);    
+    InternalLeaveCriticalSection(pThread, &g_csProcess);
 }
 
 #if USE_SYSV_SEMAPHORES
@@ -3926,7 +3924,7 @@ PROCCleanupThreadSemIds(void)
     }
 
     PROCProcessUnlock();
-    
+
 }
 #endif // USE_SYSV_SEMAPHORES
 
@@ -3962,8 +3960,8 @@ CorUnix::TerminateCurrentProcessNoExit(BOOL bTerminateUnconditionally)
            could just block on the PALInitLock critical section, but then
            PROCSuspendOtherThreads would hang... so sleep forever here, we're
            terminating anyway
-           Update: [TODO] PROCSuspendOtherThreads has been removed. Can this 
+
+           Update: [TODO] PROCSuspendOtherThreads has been removed. Can this
            code be changed? */
 
         /* note that if *this* thread has already started the termination
@@ -4023,10 +4021,10 @@ PROCGetProcessStatus(
     int status;
 
     //
-    // First, check if we already know the status of this process. This will be 
+    // First, check if we already know the status of this process. This will be
     // the case if this function has already been called for the same process.
     //
-    
+
     palError = g_pObjectManager->ReferenceObjectByHandle(
         pThread,
         hProcess,
@@ -4034,7 +4032,7 @@ PROCGetProcessStatus(
         0,
         &pobjProcess
         );
-    
+
     if (NO_ERROR != palError)
     {
         goto PROCGetProcessStatusExit;
@@ -4046,23 +4044,23 @@ PROCGetProcessStatus(
         &pDataLock,
         reinterpret_cast<void **>(&pLocalData)
         );
-    
+
     if (PS_DONE == pLocalData->ps)
     {
         TRACE("We already called waitpid() on process ID %#x; process has "
-              "terminated, exit code is %d\n", 
+              "terminated, exit code is %d\n",
               pLocalData->dwProcessId, pLocalData->dwExitCode);
-        
+
         *pps = pLocalData->ps;
         *pdwExitCode = pLocalData->dwExitCode;
 
         pDataLock->ReleaseLock(pThread, FALSE);
-        
+
         goto PROCGetProcessStatusExit;
     }
 
-    /* By using waitpid(), we can even retrieve the exit code of a non-PAL 
-       process. However, note that waitpid() can only provide the low 8 bits 
+    /* By using waitpid(), we can even retrieve the exit code of a non-PAL
+       process. However, note that waitpid() can only provide the low 8 bits
        of the exit code. This is all that is required for the PAL spec. */
     TRACE("Looking for status of process; trying wait()");
 
@@ -4070,7 +4068,7 @@ PROCGetProcessStatus(
     {
         /* try to get state of process, using non-blocking call */
         wait_retval = waitpid(pLocalData->dwProcessId, &status, WNOHANG);
-        
+
         if ( wait_retval == (pid_t) pLocalData->dwProcessId )
         {
             /* success; get the exit code */
@@ -4096,10 +4094,10 @@ PROCGetProcessStatus(
         }
         else if (-1 == wait_retval)
         {
-            // This might happen if waitpid() had already been called, but 
-            // this shouldn't happen - we call waitpid once, store the 
+            // This might happen if waitpid() had already been called, but
+            // this shouldn't happen - we call waitpid once, store the
             // result, and use that afterwards.
-            // One legitimate cause of failure is EINTR; if this happens we 
+            // One legitimate cause of failure is EINTR; if this happens we
             // have to try again. A second legitimate cause is ECHILD, which
             // happens if we're trying to retrieve the status of a currently-
             // running process that isn't a child of this process.
@@ -4137,7 +4135,7 @@ PROCGetProcessStatus(
             }
             else
             {
-                // Ignoring unexpected waitpid errno and assuming that 
+                // Ignoring unexpected waitpid errno and assuming that
                 // the process is still running
                 ERROR("waitpid(pid=%u) failed with unexpected errno=%d (%s)\n",
                       pLocalData->dwProcessId, errno, strerror(errno));
@@ -4161,10 +4159,10 @@ PROCGetProcessStatus(
         pLocalData->ps = PS_DONE;
         pLocalData->dwExitCode = *pdwExitCode;
     }
-    
-    TRACE( "State of process 0x%08x : %d (exit code %d)\n", 
+
+    TRACE( "State of process 0x%08x : %d (exit code %d)\n",
            pLocalData->dwProcessId, *pps, *pdwExitCode );
-    
+
     pDataLock->ReleaseLock(pThread, TRUE);
 
 PROCGetProcessStatusExit:
@@ -4173,7 +4171,7 @@ PROCGetProcessStatusExit:
     {
         pobjProcess->ReleaseReference(pThread);
     }
-    
+
     return palError;
 }
 
@@ -4205,14 +4203,14 @@ void PROCDumpThreadList()
     while (NULL != pThread)
     {
         TRACE ("    {pThr=0x%p tid=%#x lwpid=%#x state=%d finsusp=%d}\n",
-               pThread, (int)pThread->GetThreadId(), (int)pThread->GetLwpId(), 
+               pThread, (int)pThread->GetThreadId(), (int)pThread->GetLwpId(),
                (int)pThread->synchronizationInfo.GetThreadState(),
                (int)pThread->suspensionInfo.GetSuspendedForShutdown());
 
         pThread = pThread->GetNext();
     }
     TRACE ("Threads:}\n");
-    
+
     PROCProcessUnlock();
 }
 #endif
@@ -4284,7 +4282,7 @@ getFileName(
             ASSERT("WideCharToMultiByte failure\n");
             return FALSE;
         }
-        
+
         lpPathFileName.CloseBuffer(length -1);
 
         /* Replace '\' by '/' */
@@ -4389,7 +4387,7 @@ Return:
 static
 int
 checkFileType( LPCSTR lpFileName)
-{ 
+{
     struct stat stat_data;
 
     /* check if the file exist */
@@ -4397,7 +4395,7 @@ checkFileType( LPCSTR lpFileName)
     {
         return FILE_ERROR;
     }
-    
+
     /* if it's not a PE/COFF file, check if it is executable */
     if ( -1 != stat( lpFileName, &stat_data ) )
     {
@@ -4437,17 +4435,17 @@ Parameters:
 Return:
     the number of arguments
 
-note: this doesn't yet match precisely the behavior of Windows, but should be 
+note: this doesn't yet match precisely the behavior of Windows, but should be
 sufficient.
 what's here:
 1) stripping nonquoted whitespace
-2) handling of quoted parameters and quoted "parts" of parameters, removal of 
+2) handling of quoted parameters and quoted "parts" of parameters, removal of
    doublequotes (<aaaa"b bbb b"ccc> becomes <aaaab bbb bccc>)
 3) \" as an escaped doublequote, both within doublequoted sequences and out
 what's known missing :
-1) \\ as an escaped backslash, but only if the string of '\' 
-   is followed by a " (escaped or not)                                       
-2) "alternate" escape sequence : double-doublequote within a double-quoted 
+1) \\ as an escaped backslash, but only if the string of '\'
+   is followed by a " (escaped or not)
+2) "alternate" escape sequence : double-doublequote within a double-quoted
     argument (<"aaa a""aa aaa">) expands to a single-doublequote(<aaa a"aa aaa>)
 note that there may be other special cases
 --*/
@@ -4503,7 +4501,7 @@ buildArgv(
 
     /* let's skip the first argument in the command line */
 
-    /* strip leading whitespace; function returns NULL if there's only 
+    /* strip leading whitespace; function returns NULL if there's only
         whitespace, so the if statement below will work correctly */
     lpCommandLine = UTIL_inverse_wcspbrk((LPWSTR)lpCommandLine, W16_WHITESPACE);
 
@@ -4522,14 +4520,14 @@ buildArgv(
             }
             else if('"' == *lpCommandLine)
             {
-                /* got a dquote; skip over it if it's escaped; make sure we 
-                    don't try to look before the first character in the 
+                /* got a dquote; skip over it if it's escaped; make sure we
+                    don't try to look before the first character in the
                     string */
                 if(lpCommandLine > stringstart && '\\' == lpCommandLine[-1])
                 {
                     lpCommandLine++;
                     continue;
-                } 
+                }
 
                 /* found beginning of dquoted sequence, run to the end */
                 /* don't stop if we hit an escaped dquote */
@@ -4546,9 +4544,9 @@ buildArgv(
                     {
                         /* dquote is not escaped, dquoted sequence is over*/
                         break;
-                    } 
+                    }
                     lpCommandLine++;
-                }   
+                }
                 if(NULL == lpCommandLine || '\0' == *lpCommandLine)
                 {
                     /* no terminating dquote */
@@ -4581,11 +4579,11 @@ buildArgv(
 
     pChar = lpAsciiCmdLine;
 
-    /* loops through all the arguments, to find out how many arguments there 
+    /* loops through all the arguments, to find out how many arguments there
        are; while looping replace whitespace by \0 */
 
     /* skip leading whitespace (and replace by '\0') */
-    /* note : there shouldn't be any, command starts either with PE loader name 
+    /* note : there shouldn't be any, command starts either with PE loader name
        or computed application path, but this won't hurt */
     while (*pChar)
     {
@@ -4606,14 +4604,14 @@ buildArgv(
         {
             if('"' == *pChar)
             {
-                /* skip over dquote if it's escaped; make sure we don't try to 
+                /* skip over dquote if it's escaped; make sure we don't try to
                    look before the start of the string for the \ */
                 if(pChar > lpAsciiCmdLine && '\\' == pChar[-1])
                 {
                     pChar++;
                     continue;
                 }
-                
+
                 /* found leading dquote : look for ending dquote */
                 pChar++;
                 while (*pChar)
@@ -4621,17 +4619,17 @@ buildArgv(
                     pChar = strchr(pChar,'"');
                     if(NULL == pChar)
                     {
-                        /* no ending dquote found : argument extends to the end 
+                        /* no ending dquote found : argument extends to the end
                            of the string*/
                         break;
                     }
                     if('\\' != pChar[-1])
                     {
-                        /* found a dquote, and it's not escaped : quoted 
+                        /* found a dquote, and it's not escaped : quoted
                            sequence is over*/
                         break;
-                    }      
-                    /* found a dquote, but it was escaped : skip over it, keep 
+                    }
+                    /* found a dquote, but it was escaped : skip over it, keep
                        looking */
                     pChar++;
                 }
@@ -4648,7 +4646,7 @@ buildArgv(
             /* reached the end of the string : we're done */
             break;
         }
-        /* reached end of arg; replace trailing whitespace by '\0', to split 
+        /* reached end of arg; replace trailing whitespace by '\0', to split
            arguments into separate strings */
         while (isspace((unsigned char) *pChar))
         {
@@ -4669,7 +4667,7 @@ buildArgv(
     lppTemp = lppArgv;
 
     /* at this point all parameters are separated by NULL
-       we need to fill the array of arguments; we must also remove all dquotes 
+       we need to fill the array of arguments; we must also remove all dquotes
        from arguments (new process shouldn't see them) */
     for (i = *pnArg, pChar = lpAsciiCmdLine; i; i--)
     {
@@ -4688,7 +4686,7 @@ buildArgv(
             /* copy character if it's not a dquote */
             if('"' != *pChar)
             {
-                /* if it's the \ of an escaped dquote, skip over it, we'll 
+                /* if it's the \ of an escaped dquote, skip over it, we'll
                    copy the " instead */
                 if( '\\' == pChar[0] && '"' == pChar[1] )
                 {
@@ -4755,7 +4753,7 @@ getPath(
 
             TRACE("file %s exists\n", lpFileName);
             return TRUE;
-        } 
+        }
         else
         {
             TRACE("file %s doesn't exist.\n", lpFileName);
@@ -4771,7 +4769,7 @@ getPath(
         /* convert path to multibyte, check buffer size */
         n = WideCharToMultiByte(CP_ACP, 0, lpwstr, -1, NULL, 0,
             NULL, NULL);
-        
+
         if (!lpPathFileName.Reserve(n + lpFileNameString.GetCount() + 1 ))
         {
             ERROR("StackString Reserve failed!\n");
@@ -4789,7 +4787,7 @@ getPath(
             ASSERT("WideCharToMultiByte failure!\n");
             return FALSE;
         }
-        
+
         lpPathFileName.CloseBuffer(n - 1);
 
         lpPathFileName.Append("/", 1);
@@ -4840,14 +4838,14 @@ getPath(
         {
             lpNext++;
         }
-        
+
         /* search for ':' */
         lpCurrent = strchr(lpNext, ':');
         if (lpCurrent)
         {
             *lpCurrent++ = '\0';
         }
-        
+
         nextLen = strlen(lpNext);
         slashLen = (lpNext[nextLen-1] == '/') ? 0:1;
 
@@ -4857,9 +4855,9 @@ getPath(
             ERROR("StackString ran out of memory for full path\n");
             return FALSE;
         }
-        
+
         lpPathFileName.Set(lpNext, nextLen);
-            
+
         if( slashLen == 1)
         {
             /* append a '/' if there's no '/' at the end of the path */
@@ -4896,4 +4894,4 @@ CorUnix::CProcProcessLocalData::~CProcProcessLocalData()
         DestroyProcessModules(pProcessModules);
     }
 }
-        
+
index cbaa23f..86a0863 100644 (file)
@@ -88,7 +88,7 @@ static Volatile<CPalThread*> free_threads_list = NULL;
 /* NOTE: can't use a CRITICAL_SECTION here (see comment in FreeTHREAD) */
 int free_threads_spinlock = 0;
 
-/* lock to access iEndingThreads counter, condition variable to signal shutdown 
+/* lock to access iEndingThreads counter, condition variable to signal shutdown
 thread when any remaining threads have died, and count of exiting threads that
 can't be suspended. */
 pthread_mutex_t ptmEndThread;
@@ -117,12 +117,12 @@ ThreadInitializationRoutine(
     void *pProcessLocalData
     );
 
-void 
+void
 IncrementEndingThreadCount(
     void
     );
 
-void 
+void
 DecrementEndingThreadCount(
     void
     );
@@ -171,10 +171,10 @@ static void InternalEndCurrentThreadWrapper(void *arg)
     // actually is the current PAL thread, put it back in TLS temporarily.
     pthread_setspecific(thObjKey, pThread);
     (void)PAL_Enter(PAL_BoundaryTop);
-    
+
     /* Call entry point functions of every attached modules to
        indicate the thread is exiting */
-    /* note : no need to enter a critical section for serialization, the loader 
+    /* note : no need to enter a critical section for serialization, the loader
        will lock its own critical section */
     LOADCallDllMain(DLL_THREAD_DETACH, NULL);
 
@@ -228,7 +228,7 @@ Function:
 
 Abstract:
     Allocate CPalThread instance
-  
+
 Return:
     The fresh thread structure, NULL otherwise
 --*/
@@ -266,7 +266,7 @@ Function:
 
 Abstract:
     Free THREAD structure
-  
+
 --*/
 static void FreeTHREAD(CPalThread *pThread)
 {
@@ -281,15 +281,15 @@ static void FreeTHREAD(CPalThread *pThread)
     // check against pThread->dwGuard when getting the current thread's data.
     memset((void*)pThread, 0xcc, sizeof(*pThread));
 #endif
-    
-    // We SHOULD be doing the following, but it causes massive problems. See the 
+
+    // We SHOULD be doing the following, but it causes massive problems. See the
     // comment below.
     //pthread_setspecific(thObjKey, NULL); // Make sure any TLS entry is removed.
 
     //
-    // Never actually free the THREAD structure to make the TLS lookaside cache work. 
-    // THREAD* for terminated thread can be stuck in the lookaside cache code for an 
-    // arbitrary amount of time. The unused THREAD* structures has to remain in a 
+    // Never actually free the THREAD structure to make the TLS lookaside cache work.
+    // THREAD* for terminated thread can be stuck in the lookaside cache code for an
+    // arbitrary amount of time. The unused THREAD* structures has to remain in a
     // valid memory and thus can't be returned to the heap.
     //
     // TODO: is this really true? Why would the entry remain in the cache for
@@ -297,12 +297,12 @@ static void FreeTHREAD(CPalThread *pThread)
     //
 
     /* NOTE: can't use a CRITICAL_SECTION here: EnterCriticalSection(&cs,TRUE) and
-       LeaveCriticalSection(&cs,TRUE) need to access the thread private data 
-       stored in the very THREAD structure that we just destroyed. Entering and 
+       LeaveCriticalSection(&cs,TRUE) need to access the thread private data
+       stored in the very THREAD structure that we just destroyed. Entering and
        leaving the critical section with internal==FALSE leads to possible hangs
-       in the PROCSuspendOtherThreads logic, at shutdown time 
+       in the PROCSuspendOtherThreads logic, at shutdown time
 
-       Update: [TODO] PROCSuspendOtherThreads has been removed. Can this 
+       Update: [TODO] PROCSuspendOtherThreads has been removed. Can this
        code be changed?*/
 
     /* Get the lock */
@@ -322,7 +322,7 @@ Function:
 
 returns the process owner ID of the indicated hThread
 --*/
-DWORD 
+DWORD
 THREADGetThreadProcessId(
     HANDLE hThread
     // UNIXTODO Should take pThread parameter here (modify callers)
@@ -332,7 +332,7 @@ THREADGetThreadProcessId(
     CPalThread *pTargetThread;
     IPalObject *pobjThread = NULL;
     PAL_ERROR palError = NO_ERROR;
-    
+
     DWORD dwProcessId = 0;
 
     pThread = InternalGetCurrentThread();
@@ -366,7 +366,7 @@ THREADGetThreadProcessId(
         ERROR("Couldn't retreive the hThread:%p pid owner !\n", hThread);
     }
 
-    
+
     return dwProcessId;
 }
 
@@ -391,12 +391,12 @@ GetCurrentThreadId(
     // with calling InternalGetCurrentThread (i.e., is our lookaside
     // cache faster on average than pthread_self?)
     //
-    
+
     dwThreadId = (DWORD)THREADSilentGetCurrentThreadId();
-    
-    LOGEXIT("GetCurrentThreadId returns DWORD %#x\n", dwThreadId);    
+
+    LOGEXIT("GetCurrentThreadId returns DWORD %#x\n", dwThreadId);
     PERF_EXIT(GetCurrentThreadId);
-    
+
     return dwThreadId;
 }
 
@@ -419,10 +419,10 @@ PAL_GetCurrentOSThreadId(
     ENTRY("PAL_GetCurrentOSThreadId()\n");
 
     threadId = THREADSilentGetCurrentThreadId();
-    
-    LOGEXIT("PAL_GetCurrentOSThreadId returns %p\n", threadId);    
+
+    LOGEXIT("PAL_GetCurrentOSThreadId returns %p\n", threadId);
     PERF_EXIT(GetCurrentThreadId);
-    
+
     return threadId;
 }
 
@@ -440,7 +440,7 @@ PAL_GetCurrentThread(
 {
     PERF_ENTRY(GetCurrentThread);
     ENTRY("GetCurrentThread()\n");
-    
+
     LOGEXIT("GetCurrentThread returns HANDLE %p\n", hPseudoCurrentThread);
     PERF_EXIT(GetCurrentThread);
 
@@ -464,7 +464,7 @@ SwitchToThread(
     PERF_ENTRY(SwitchToThread);
     ENTRY("SwitchToThread(VOID)\n");
 
-    /* sched_yield yields to another thread in the current process. This implementation 
+    /* sched_yield yields to another thread in the current process. This implementation
        won't work well for cross-process synchronization. */
     ret = (sched_yield() == 0);
 
@@ -497,7 +497,7 @@ CreateThread(
     PAL_ERROR palError;
     CPalThread *pThread;
     HANDLE hNewThread = NULL;
-    
+
     PERF_ENTRY(CreateThread);
     ENTRY("CreateThread(lpThreadAttr=%p, dwStackSize=%u, lpStartAddress=%p, "
           "lpParameter=%p, dwFlags=%#x, lpThreadId=%#x)\n",
@@ -521,7 +521,7 @@ CreateThread(
     if (NO_ERROR != palError)
     {
         pThread->SetLastError(palError);
-    }    
+    }
 
     LOGEXIT("CreateThread returns HANDLE %p\n", hNewThread);
     PERF_EXIT(CreateThread);
@@ -548,7 +548,7 @@ CorUnix::InternalCreateThread(
     bool fAttributesInitialized = FALSE;
     bool fThreadDataAddedToProcessList = FALSE;
     HANDLE hNewThread = NULL;
-    
+
     pthread_t pthread;
     pthread_attr_t pthreadAttr;
     size_t pthreadStackSize;
@@ -572,7 +572,7 @@ CorUnix::InternalCreateThread(
         // which could occur if a DllMain PROCESS_DETACH handler tried to
         // create a new thread for some odd reason).
         //
-        
+
         ERROR("process is terminating, can't create new thread.\n");
 
         if (pThread->GetThreadId() != static_cast<DWORD>(terminator))
@@ -588,7 +588,7 @@ CorUnix::InternalCreateThread(
             //
             // This is the shutdown thread, so just return an error
             //
-            
+
             palError = ERROR_PROCESS_ABORTED;
             goto EXIT;
         }
@@ -598,7 +598,7 @@ CorUnix::InternalCreateThread(
 
     if (lpThreadAttributes != NULL)
     {
-        ASSERT("lpThreadAttributes parameter must be NULL (%p)\n", 
+        ASSERT("lpThreadAttributes parameter must be NULL (%p)\n",
                lpThreadAttributes);
         palError = ERROR_INVALID_PARAMETER;
         goto EXIT;
@@ -623,7 +623,7 @@ CorUnix::InternalCreateThread(
 
     // Ignore the STACK_SIZE_PARAM_IS_A_RESERVATION flag
     dwCreationFlags &= ~STACK_SIZE_PARAM_IS_A_RESERVATION;
-    
+
     if ((dwCreationFlags != 0) && (dwCreationFlags != CREATE_SUSPENDED))
     {
         ASSERT("dwCreationFlags parameter is invalid (%#x)\n", dwCreationFlags);
@@ -657,7 +657,7 @@ CorUnix::InternalCreateThread(
     {
         ERROR("couldn't initialize pthread attributes\n");
         palError = ERROR_INTERNAL_ERROR;
-        goto EXIT;        
+        goto EXIT;
     }
 
     fAttributesInitialized = TRUE;
@@ -730,10 +730,10 @@ CorUnix::InternalCreateThread(
     // Add the thread to the process list
     //
 
-    // 
+    //
     // We use the process lock to ensure that we're not interrupted
     // during the creation process. After adding the CPalThread reference
-    // to the process list, we want to make sure the actual thread has been 
+    // to the process list, we want to make sure the actual thread has been
     // started. Otherwise, there's a window where the thread can be found
     // in the process list but doesn't yet exist in the system.
     //
@@ -771,7 +771,7 @@ CorUnix::InternalCreateThread(
         palError = ERROR_NOT_ENOUGH_MEMORY;
         goto EXIT;
     }
-       
+
     //
     // Wait for the new thread to finish its initial startup tasks
     // (i.e., the ones that might fail)
@@ -783,7 +783,7 @@ CorUnix::InternalCreateThread(
         // the thread's ID in the out params
         //
         *phThread = hNewThread;
-        
+
         if (NULL != lpThreadId)
         {
             *lpThreadId = pNewThread->GetThreadId();
@@ -826,7 +826,7 @@ EXIT:
         {
             PROCRemoveThread(pThread, pNewThread);
         }
-        // 
+        //
         // Once we remove the thread from the process list, we can call
         // PROCProcessUnlock.
         //
@@ -857,7 +857,7 @@ ExitThread(
        IN DWORD dwExitCode)
 {
     CPalThread *pThread;
-      
+
     ENTRY("ExitThread(dwExitCode=%u)\n", dwExitCode);
     PERF_ENTRY_ONLY(ExitThread);
 
@@ -874,7 +874,7 @@ ExitThread(
 
     /* kill the thread (itself), resulting in a call to InternalEndCurrentThread */
     pthread_exit(NULL);
-    
+
     ASSERT("pthread_exit should not return!\n");
     for (;;);
 }
@@ -894,7 +894,7 @@ CorUnix::InternalEndCurrentThread(
 {
     PAL_ERROR palError = NO_ERROR;
     ISynchStateController *pSynchStateController = NULL;
-    
+
 #ifdef PAL_PERF
     PERFDisableThreadProfile(UserCreatedThread != pThread->GetThreadType());
 #endif
@@ -914,7 +914,7 @@ CorUnix::InternalEndCurrentThread(
     }
 
     //
-    // Need to synchronize setting the thread state to TS_DONE since 
+    // Need to synchronize setting the thread state to TS_DONE since
     // this is checked for in InternalSuspendThreadFromData.
     // TODO: Is this still needed after removing InternalSuspendThreadFromData?
     //
@@ -978,10 +978,10 @@ CorUnix::InternalEndCurrentThread(
 
         pThread->GetThreadObject()->ReleaseReference(pThread);
 
-        /* Remove thread for the thread list of the process 
+        /* Remove thread for the thread list of the process
            (don't do if this is the last thread -> gets handled by
             TerminateProcess->PROCCleanupProcess->PROCTerminateOtherThreads) */
-        
+
         PROCRemoveThread(pThread, pThread);
 
 #ifdef FEATURE_PAL_SXS
@@ -989,8 +989,8 @@ CorUnix::InternalEndCurrentThread(
         SEHDisable(pThread);
         PAL_Leave(PAL_BoundaryTop);
 #endif // FEATURE_PAL_SXS
-        
-        
+
+
         //
         // Now release our reference to the thread data. We cannot touch
         // it after this point
@@ -998,7 +998,7 @@ CorUnix::InternalEndCurrentThread(
 
         pThread->ReleaseThreadReference();
         DecrementEndingThreadCount();
-        
+
     }
 }
 
@@ -1016,7 +1016,7 @@ GetThreadPriority(
     CPalThread *pThread;
     PAL_ERROR palError;
     int iPriority = THREAD_PRIORITY_ERROR_RETURN;
-    
+
     PERF_ENTRY(GetThreadPriority);
     ENTRY("GetThreadPriority(hThread=%p)\n", hThread);
 
@@ -1035,7 +1035,7 @@ GetThreadPriority(
 
     LOGEXIT("GetThreadPriorityExit returns int %d\n", iPriority);
     PERF_EXIT(GetThreadPriority);
-    
+
     return iPriority;
 }
 
@@ -1049,7 +1049,7 @@ CorUnix::InternalGetThreadPriority(
     PAL_ERROR palError = NO_ERROR;
     CPalThread *pTargetThread;
     IPalObject *pobjThread = NULL;
-    
+
     palError = InternalGetThreadDataFromHandle(
         pThread,
         hThread,
@@ -1062,7 +1062,7 @@ CorUnix::InternalGetThreadPriority(
     {
         goto InternalGetThreadPriorityExit;
     }
-    
+
     pTargetThread->Lock(pThread);
 
     *piPriority = pTargetThread->GetThreadPriority();
@@ -1094,7 +1094,7 @@ SetThreadPriority(
 {
     CPalThread *pThread;
     PAL_ERROR palError = NO_ERROR;
-    
+
     PERF_ENTRY(SetThreadPriority);
     ENTRY("SetThreadPriority(hThread=%p, nPriority=%#x)\n", hThread, nPriority);
 
@@ -1113,7 +1113,7 @@ SetThreadPriority(
 
     LOGEXIT("SetThreadPriority returns BOOL %d\n", NO_ERROR == palError);
     PERF_EXIT(SetThreadPriority);
-    
+
     return NO_ERROR == palError;
 }
 
@@ -1162,12 +1162,12 @@ CorUnix::InternalSetThreadPriority(
     case THREAD_PRIORITY_ABOVE_NORMAL:  /* fall through */
     case THREAD_PRIORITY_NORMAL:        /* fall through */
     case THREAD_PRIORITY_BELOW_NORMAL:  /* fall through */
-    case THREAD_PRIORITY_LOWEST:        
+    case THREAD_PRIORITY_LOWEST:
 #if PAL_IGNORE_NORMAL_THREAD_PRIORITY
         /* We aren't going to set the thread priority. Just record what it is,
            and exit */
         pTargetThread->m_iThreadPriority = iNewPriority;
-        goto InternalSetThreadPriorityExit;        
+        goto InternalSetThreadPriorityExit;
 #endif
         break;
 
@@ -1175,22 +1175,22 @@ CorUnix::InternalSetThreadPriority(
         ASSERT("Priority %d not supported\n", iNewPriority);
         palError = ERROR_INVALID_PARAMETER;
         goto InternalSetThreadPriorityExit;
-    }  
+    }
 
     /* check if the thread is still running */
     if (TS_DONE == pTargetThread->synchronizationInfo.GetThreadState())
     {
-        /* the thread has exited, set the priority in the thread structure 
+        /* the thread has exited, set the priority in the thread structure
            and exit */
         pTargetThread->m_iThreadPriority = iNewPriority;
-        goto InternalSetThreadPriorityExit;        
+        goto InternalSetThreadPriorityExit;
     }
 
-    /* get the previous thread schedule parameters.  We need to know the 
+    /* get the previous thread schedule parameters.  We need to know the
        scheduling policy to determine the priority range */
     if (pthread_getschedparam(
             pTargetThread->GetPThreadSelf(),
-            &policy, 
+            &policy,
             &schedParam
             ) != 0)
     {
@@ -1215,7 +1215,7 @@ CorUnix::InternalSetThreadPriority(
     min_priority = sched_get_priority_min(policy);
     if( -1 == max_priority || -1 == min_priority)
     {
-        ASSERT("sched_get_priority_min/max failed; error is %d (%s)\n", 
+        ASSERT("sched_get_priority_min/max failed; error is %d (%s)\n",
                errno, strerror(errno));
         palError = ERROR_INTERNAL_ERROR;
         goto InternalSetThreadPriorityExit;
@@ -1225,28 +1225,28 @@ CorUnix::InternalSetThreadPriority(
     min_priority = PAL_THREAD_PRIORITY_MIN;
 #endif
 
-    TRACE("Pthread priorities for policy %d must be in the range %d to %d\n", 
+    TRACE("Pthread priorities for policy %d must be in the range %d to %d\n",
           policy, min_priority, max_priority);
 
     /* explanation for fancy maths below :
-       POSIX doesn't specify the range of thread priorities that can be used 
+       POSIX doesn't specify the range of thread priorities that can be used
        with pthread_setschedparam. Instead, one must use sched_get_priority_min
        and sched_get_priority_max to obtain the lower and upper bounds of this
-       range. Since the PAL also uses a range of values (from Idle [-15] to 
-       Time Critical [+15]), we have to do a mapping from a known range to an 
-       unknown (at compilation) range. 
+       range. Since the PAL also uses a range of values (from Idle [-15] to
+       Time Critical [+15]), we have to do a mapping from a known range to an
+       unknown (at compilation) range.
        We do this by :
-       -substracting the minimal PAL priority from the desired priority. this 
+       -substracting the minimal PAL priority from the desired priority. this
         gives a value between 0 and the PAL priority range
-       -dividing this value by the PAL priority range. this allows us to 
+       -dividing this value by the PAL priority range. this allows us to
         express the desired priority as a floating-point value between 0 and 1
-       -multiplying this value by the PTHREAD priority range. This gives a 
+       -multiplying this value by the PTHREAD priority range. This gives a
         value between 0 and the PTHREAD priority range
-       -adding the minimal PTHREAD priority range. This will give us a value 
-        between the minimal and maximla pthread priority, which should be 
-        equivalent to the original PAL value. 
-        
-        example : suppose a pthread range 100 to 200, and a desired priority 
+       -adding the minimal PTHREAD priority range. This will give us a value
+        between the minimal and maximla pthread priority, which should be
+        equivalent to the original PAL value.
+
+        example : suppose a pthread range 100 to 200, and a desired priority
                   of 0 (halfway between PAL minimum and maximum)
             0 - (IDLE [-15]) = 15
             15 / (TIMECRITICAL[15] - IDLE[-15]) = 0.5
@@ -1259,7 +1259,7 @@ CorUnix::InternalSetThreadPriority(
     posix_priority += min_priority;
 
     schedParam.sched_priority = (int)posix_priority;
-    
+
     TRACE("PAL priority %d is mapped to pthread priority %d\n",
           iNewPriority, schedParam.sched_priority);
 
@@ -1276,12 +1276,12 @@ CorUnix::InternalSetThreadPriority(
             goto InternalSetThreadPriorityExit;
         }
 #endif
-        
+
         ASSERT("Unable to set thread priority to %d (error %d)\n", (int)posix_priority, st);
         palError = ERROR_INTERNAL_ERROR;
         goto InternalSetThreadPriorityExit;
     }
-    
+
     pTargetThread->m_iThreadPriority = iNewPriority;
 
 InternalSetThreadPriorityExit:
@@ -1296,7 +1296,7 @@ InternalSetThreadPriorityExit:
         pobjThread->ReleaseReference(pThread);
     }
 
-    return palError;    
+    return palError;
 }
 
 BOOL
@@ -1326,25 +1326,25 @@ CorUnix::GetThreadTimesInternal(
         &pthrTarget,
         &pobjThread
         );
-    
+
     if (palError != NO_ERROR)
     {
         ASSERT("Unable to get thread data from handle %p"
               "thread\n", hThread);
         SetLastError(ERROR_INTERNAL_ERROR);
         goto SetTimesToZero;
-    }   
+    }
 
     pthrTarget->Lock(pthrCurrent);
-    
+
     mach_port_t mhThread;
     mhThread = pthread_mach_thread_np(pthrTarget->GetPThreadSelf());
-    
+
     kern_return_t status;
     status = thread_info(
-        mhThread, 
-        THREAD_BASIC_INFO, 
-        (thread_info_t)&resUsage, 
+        mhThread,
+        THREAD_BASIC_INFO,
+        (thread_info_t)&resUsage,
         &resUsage_count);
 
     pthrTarget->Unlock(pthrCurrent);
@@ -1481,7 +1481,7 @@ CorUnix::GetThreadTimesInternal(
               "thread\n", hThread);
         SetLastError(ERROR_INTERNAL_ERROR);
         goto SetTimesToZero;
-    }   
+    }
 
     pTargetThread->Lock(pThread);
 
@@ -1511,7 +1511,7 @@ CorUnix::GetThreadTimesInternal(
     calcTime += (__int64) ts.tv_nsec;
     lpUserTime->dwLowDateTime = (DWORD)calcTime;
     lpUserTime->dwHighDateTime = (DWORD)(calcTime >> 32);
-    
+
     /* Set kernel time to zero, for now */
     lpKernelTime->dwLowDateTime = 0;
     lpKernelTime->dwHighDateTime = 0;
@@ -1522,7 +1522,7 @@ CorUnix::GetThreadTimesInternal(
 #endif //HAVE_MACH_THREADS
 
 SetTimesToZero:
-    
+
     lpUserTime->dwLowDateTime = 0;
     lpUserTime->dwHighDateTime = 0;
     lpKernelTime->dwLowDateTime = 0;
@@ -1590,13 +1590,13 @@ GetThreadTimes(
         lpCreationTime->dwLowDateTime = 0;
         lpCreationTime->dwHighDateTime = 0;
     }
-    
+
     if (lpExitTime)
     {
         lpExitTime->dwLowDateTime = 0;
         lpExitTime->dwHighDateTime = 0;
     }
-    
+
     LOGEXIT("GetThreadTimes returns BOOL %d\n", retval);
     PERF_EXIT(GetThreadTimes);
     return (retval);
@@ -1691,7 +1691,7 @@ CPalThread::ThreadEntry(
     if (UserCreatedThread == pThread->GetThreadType())
     {
         /* Inform all loaded modules that a thread has been created */
-        /* note : no need to take a critical section to serialize here; the loader 
+        /* note : no need to take a critical section to serialize here; the loader
            will take the module critical section */
         LOADCallDllMain(DLL_THREAD_ATTACH, NULL);
     }
@@ -1710,7 +1710,7 @@ CPalThread::ThreadEntry(
     TRACE("Thread exited (%u)\n", retValue);
     ExitThread(retValue);
 
-    /* Note: never get here */ 
+    /* Note: never get here */
     ASSERT("ExitThread failed!\n");
     for (;;);
 
@@ -1719,15 +1719,15 @@ fail:
     //
     // Notify InternalCreateThread that a failure occurred
     //
-    
+
     if (NULL != pThread)
     {
         pThread->synchronizationInfo.SetThreadState(TS_FAILED);
         pThread->SetStartStatus(FALSE);
     }
 
-    /* do not call ExitThread : we don't want to call DllMain(), and the thread 
-       isn't in a clean state (e.g. lpThread isn't in TLS). the cleanup work 
+    /* do not call ExitThread : we don't want to call DllMain(), and the thread
+       isn't in a clean state (e.g. lpThread isn't in TLS). the cleanup work
        above should release all resources */
     return NULL;
 }
@@ -1740,7 +1740,7 @@ Abstract:
     Create the CPalThread for the startup thread
     or another external thread entering the PAL
     for the first time
-  
+
 Parameters:
     ppThread - on success, receives the CPalThread
 
@@ -1755,7 +1755,7 @@ CorUnix::CreateThreadData(
 {
     PAL_ERROR palError = NO_ERROR;
     CPalThread *pThread = NULL;
-    
+
     /* Create the thread object */
     pThread = AllocTHREAD();
 
@@ -1794,7 +1794,7 @@ CorUnix::CreateThreadData(
     }
 
     *ppThread = pThread;
-    
+
 CreateThreadDataExit:
 
     if (NO_ERROR != palError)
@@ -1815,7 +1815,7 @@ Function:
 Abstract:
     Creates the IPalObject for a thread, storing
     the reference in the CPalThread
-  
+
 Parameters:
     pThread - the thread data for the creating thread
     pNewThread - the thread data for the thread being initialized
@@ -1862,7 +1862,7 @@ CorUnix::CreateThreadObject(
 
     palError = pobjThread->GetProcessLocalData(
         pThread,
-        WriteLock, 
+        WriteLock,
         &pDataLock,
         reinterpret_cast<void **>(&pLocalData)
         );
@@ -1888,7 +1888,7 @@ CorUnix::CreateThreadObject(
         &hThread,
         &pobjRegisteredThread
         );
-        
+
     //
     // pobjThread is invalidated by the call to RegisterObject, so NULL
     // it out here to prevent it from being released
@@ -1933,13 +1933,13 @@ CreateThreadObjectExit:
         if (!fThreadDataStoredInObject)
         {
             //
-            // The CPalThread for the new thread was never stored in 
+            // The CPalThread for the new thread was never stored in
             // an IPalObject instance, so we need to release the initial
             // reference here. (If it has been stored it will get freed in
             // the owning object's cleanup routine)
             //
 
-            pNewThread->ReleaseThreadReference();            
+            pNewThread->ReleaseThreadReference();
         }
     }
 
@@ -2023,7 +2023,7 @@ CorUnix::InternalCreateDummyThread(
     // pobjThread is invalidated by the above call, so NULL
     // it out here
     //
-    
+
     pobjThread = NULL;
 
     if (NO_ERROR != palError)
@@ -2110,7 +2110,7 @@ CorUnix::InternalGetThreadDataFromHandle(
                 // Transfer object reference to out param
                 //
 
-                *ppobjThread = pobj;                
+                *ppobjThread = pobj;
             }
             else
             {
@@ -2217,10 +2217,10 @@ CPalThread::~CPalThread()
     if (m_fStartItemsInitialized)
     {
         int iError;
-        
+
         iError = pthread_cond_destroy(&m_startCond);
         _ASSERTE(0 == iError);
-        
+
         iError = pthread_mutex_destroy(&m_startMutex);
         _ASSERTE(0 == iError);
     }
@@ -2245,7 +2245,7 @@ CPalThread::ReleaseThreadReference(
     {
         FreeTHREAD(this);
     }
-    
+
 }
 
 PAL_ERROR
@@ -2326,7 +2326,7 @@ CPalThread::SetStartStatus(
     //
     // This routine may get called from CPalThread::ThreadEntry
     //
-    // If we've reached this point there are no further thread 
+    // If we've reached this point there are no further thread
     // suspensions that happen at creation time, so reset
     // m_bCreateSuspended
     //
@@ -2405,7 +2405,7 @@ Parameters :
 Return :
     TRUE in case of a success, FALSE otherwise
 --*/
-BOOL 
+BOOL
 CPalThread::EnsureSignalAlternateStack()
 {
     int st = 0;
@@ -2420,7 +2420,7 @@ CPalThread::EnsureSignalAlternateStack()
         {
             // There is no alternate stack for SIGSEGV handling installed yet so allocate one
 
-            // We include the size of the SignalHandlerWorkerReturnPoint in the alternate stack size since the 
+            // We include the size of the SignalHandlerWorkerReturnPoint in the alternate stack size since the
             // context contained in it is large and the SIGSTKSZ was not sufficient on ARM64 during testing.
             int altStackSize = SIGSTKSZ + ALIGN_UP(sizeof(SignalHandlerWorkerReturnPoint), 16) + GetVirtualPageSize();
 #ifdef HAS_ASAN
@@ -2447,7 +2447,7 @@ CPalThread::EnsureSignalAlternateStack()
                 {
                     m_alternateStack = altStack;
                 }
-                else 
+                else
                 {
                     int st2 = munmap(altStack, altStackSize);
                     _ASSERTE(st2 == 0);
@@ -2471,7 +2471,7 @@ Parameters :
 Return :
     None
 --*/
-void 
+void
 CPalThread::FreeSignalAlternateStack()
 {
     void *altstack = m_alternateStack;
@@ -2481,7 +2481,7 @@ CPalThread::FreeSignalAlternateStack()
     {
         stack_t ss, oss;
         // The man page for sigaltstack says that when the ss.ss_flags is set to SS_DISABLE,
-        // all other ss fields are ignored. However, MUSL implementation checks that the 
+        // all other ss fields are ignored. However, MUSL implementation checks that the
         // ss_size is >= MINSIGSTKSZ even in this case.
         ss.ss_size = MINSIGSTKSZ;
         ss.ss_flags = SS_DISABLE;
@@ -2505,12 +2505,12 @@ to control a global counter that indicates if any threads are about to die.
 Once a thread's state is set to TS_DONE, it cannot be suspended. However,
 the dying thread can still access PAL resources, which is dangerous if the
 thread dies during PAL cleanup. To avoid this, the shutdown thread calls
-WaitForEndingThreads after suspending all other threads. WaitForEndingThreads 
-uses a condition variable along with the global counter to wait for remaining 
-PAL threads to die before proceeding with cleanup. As threads die, they 
+WaitForEndingThreads after suspending all other threads. WaitForEndingThreads
+uses a condition variable along with the global counter to wait for remaining
+PAL threads to die before proceeding with cleanup. As threads die, they
 decrement the counter and signal the condition variable. */
 
-void 
+void
 IncrementEndingThreadCount(
     void
     )
@@ -2526,7 +2526,7 @@ IncrementEndingThreadCount(
     _ASSERT_MSG(iError == 0, "pthread_mutex_unlock returned %d\n", iError);
 }
 
-void 
+void
 DecrementEndingThreadCount(
     void
     )
@@ -2549,7 +2549,7 @@ DecrementEndingThreadCount(
     _ASSERT_MSG(iError == 0, "pthread_mutex_unlock returned %d\n", iError);
 }
 
-void 
+void
 WaitForEndingThreads(
     void
     )
@@ -2562,7 +2562,7 @@ WaitForEndingThreads(
     while (iEndingThreads > 0)
     {
         iError = pthread_cond_wait(&ptcEndThread, &ptmEndThread);
-        _ASSERT_MSG(iError == 0, "pthread_cond_wait returned %d\n", iError);  
+        _ASSERT_MSG(iError == 0, "pthread_cond_wait returned %d\n", iError);
     }
 
     iError = pthread_mutex_unlock(&ptmEndThread);
@@ -2590,7 +2590,7 @@ CorUnix::InitializeEndingThreadsData(
         // Don't bother checking the return value of pthread_mutex_destroy
         // since PAL initialization will now fail.
         //
-        
+
         pthread_mutex_destroy(&ptmEndThread);
         goto InitializeEndingThreadsDataExit;
     }
@@ -2614,14 +2614,14 @@ ThreadCleanupRoutine(
     CPalThread *pThreadToCleanup = NULL;
     IDataLock *pDataLock = NULL;
     PAL_ERROR palError = NO_ERROR;
-        
+
     //
     // Free the CPalThread data for the passed in thread
     //
 
     palError = pObjectToCleanup->GetProcessLocalData(
         pThread,
-        WriteLock, 
+        WriteLock,
         &pDataLock,
         reinterpret_cast<void**>(&pThreadData)
         );
@@ -2637,7 +2637,7 @@ ThreadCleanupRoutine(
         // for the thread data to be available while the rest of the
         // object cleanup takes place).
         //
-        
+
         pThreadToCleanup = pThreadData->pThread;
         pThreadData->pThread = NULL;
         pDataLock->ReleaseLock(pThread, TRUE);
@@ -2647,7 +2647,7 @@ ThreadCleanupRoutine(
     {
         ASSERT("Unable to obtain thread data");
     }
-    
+
 }
 
 PAL_ERROR
@@ -2770,7 +2770,7 @@ CPalThread::GetCachedStackLimit()
     return m_stackLimit;
 }
 
-void *
+PVOID
 PALAPI
 PAL_GetStackBase()
 {
@@ -2778,7 +2778,7 @@ PAL_GetStackBase()
     return thread->GetCachedStackBase();
 }
 
-void *
+PVOID
 PALAPI
 PAL_GetStackLimit()
 {
@@ -2903,7 +2903,7 @@ int CorUnix::CThreadMachExceptionHandlers::GetIndexOfHandler(exception_mask_t bm
     {
         // Entry covers this exception type and the handler isn't null
         if (m_masks[i] & bmExceptionMask && m_handlers[i] != MACH_PORT_NULL)
-        { 
+        {
             _ASSERTE(m_handlers[i] != s_ExceptionPort);
 
             // One more check; has the target handler port become dead?
index 968f8a5..8d69c82 100644 (file)
@@ -17,7 +17,6 @@
 /* memcmp is used to verify the results, so this test is dependent on it. */
 /* ditto with wcslen */
 
-
 int __cdecl main(int argc, char *argv[])
 {
     WCHAR *checkstr = NULL;
@@ -26,16 +25,16 @@ int __cdecl main(int argc, char *argv[])
     if (PAL_Initialize(argc, argv) != 0)
         return(FAIL);
 
-       checkstr = convert("hello world");
+    checkstr = convert("hello world");
     testvswp(buf, _countof(buf), checkstr);
 
     if (memcmp(checkstr, buf, wcslen(checkstr)*2+2) != 0)
     {
         Fail("ERROR: Expected \"%s\", got \"%s\"\n", 
-            convertC(checkstr), convertC(buf));
+        convertC(checkstr), convertC(buf));
     }
 
-       free(checkstr);
+    free(checkstr);
     PAL_Terminate();
     return PASS;
 }
index 1947b59..a40885e 100644 (file)
@@ -22,7 +22,7 @@ struct _mainargs
     char ** argv;
 };
 
-static DWORD PALAPI run_main(struct _mainargs *args)
+static DWORD run_main(struct _mainargs *args)
 {
     return (DWORD) PAL_startup_main(args->argc, args->argv);
 }