Use pal.h directly in Unix twowaypipe code and remove windefs.h.
authorAditya Mandaleeka <adityam@microsoft.com>
Thu, 18 Feb 2016 00:56:28 +0000 (16:56 -0800)
committerAditya Mandaleeka <adityam@microsoft.com>
Thu, 18 Feb 2016 04:10:31 +0000 (20:10 -0800)
Commit migrated from https://github.com/dotnet/coreclr/commit/4fee7ae253a271cc70028202104e92128d1a5bd8

src/coreclr/src/debug/debug-pal/unix/twowaypipe.cpp
src/coreclr/src/debug/debug-pal/unix/windefs.h [deleted file]

index f8f82be..062dc1a 100644 (file)
@@ -2,21 +2,22 @@
 // The .NET Foundation licenses this file to you under the MIT license.
 // See the LICENSE file in the project root for more information.
 
+#include <pal.h>
+
 #include <unistd.h>
 #include <fcntl.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <stdio.h>
 #include <limits.h>
+#include <pal_assert.h>
 
-#include "windefs.h"
 #include "twowaypipe.h"
 
 #define PIPE_NAME_FORMAT_STR "/tmp/clr-debug-pipe-%d-%s"
 
 static void GetPipeName(char *name, DWORD id, const char *suffix)
 {
-    int chars = snprintf(name, PATH_MAX, PIPE_NAME_FORMAT_STR, id, suffix);
+    int chars = _snprintf(name, PATH_MAX, PIPE_NAME_FORMAT_STR, id, suffix);
     _ASSERTE(chars > 0 && chars < PATH_MAX);
 }
 
@@ -42,15 +43,14 @@ bool TwoWayPipe::CreateServer(DWORD id)
 
     if (mkfifo(outPipeName, S_IRWXU) == -1)
     {
-        remove(inPipeName);
+        unlink(inPipeName);
         return false;
-    }    
+    }
 
     m_state = Created;
     return true;
 }
 
-
 // Connects to a previously opened server side of the pipe.
 // Id is used to locate the pipe on the machine. 
 // true - success, false - failure (use GetLastError() for more details)
@@ -138,6 +138,7 @@ int TwoWayPipe::Read(void *buffer, DWORD bufferSize)
         {
             break;
         }
+
         buffer = (char*)buffer + bytesRead;
         cb -= bytesRead;
     }
@@ -164,6 +165,7 @@ int TwoWayPipe::Write(const void *data, DWORD dataSize)
         {
             break;
         }
+
         data = (char*)data + bytesWritten;
         cb -= bytesWritten;
     }
@@ -175,7 +177,6 @@ int TwoWayPipe::Write(const void *data, DWORD dataSize)
 // true - success, false - failure (use GetLastError() for more details)
 bool TwoWayPipe::Disconnect()
 {
-
     if (m_outboundPipe != INVALID_PIPE && m_outboundPipe != 0)
     {
         close(m_outboundPipe);
@@ -186,21 +187,19 @@ bool TwoWayPipe::Disconnect()
     {
         close(m_inboundPipe);
         m_inboundPipe = INVALID_PIPE;
-    }    
+    }
 
     if (m_state == ServerConnected || m_state == Created)
     {
-
         char inPipeName[PATH_MAX];
         GetPipeName(inPipeName, m_id, "in");
-        remove(inPipeName);
+        unlink(inPipeName);
 
         char outPipeName[PATH_MAX];
         GetPipeName(outPipeName, m_id, "out");
-        remove(outPipeName);
+        unlink(outPipeName);
     }
 
     m_state = NotInitialized;
     return true;
 }
-
diff --git a/src/coreclr/src/debug/debug-pal/unix/windefs.h b/src/coreclr/src/debug/debug-pal/unix/windefs.h
deleted file mode 100644 (file)
index 4b46f76..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-// It'd be nice to be able to include some existing header from the main PAL, 
-// but they tend to pull too much stuff that breaks everything.
-
-#include <cstddef>
-#include <assert.h>
-#define _ASSERTE assert
-
-typedef unsigned int DWORD;