diff options
author | Aditya Mandaleeka <adityam@microsoft.com> | 2016-02-17 16:56:28 -0800 |
---|---|---|
committer | Aditya Mandaleeka <adityam@microsoft.com> | 2016-02-17 20:10:31 -0800 |
commit | 4fee7ae253a271cc70028202104e92128d1a5bd8 (patch) | |
tree | 898614a0680218e640d0bf21d69002ff941622c3 /src | |
parent | d931b57022622db8e38b41c697eba730ec4f0c41 (diff) | |
download | coreclr-4fee7ae253a271cc70028202104e92128d1a5bd8.tar.gz coreclr-4fee7ae253a271cc70028202104e92128d1a5bd8.tar.bz2 coreclr-4fee7ae253a271cc70028202104e92128d1a5bd8.zip |
Use pal.h directly in Unix twowaypipe code and remove windefs.h.
Diffstat (limited to 'src')
-rw-r--r-- | src/debug/debug-pal/unix/twowaypipe.cpp | 23 | ||||
-rw-r--r-- | src/debug/debug-pal/unix/windefs.h | 12 |
2 files changed, 11 insertions, 24 deletions
diff --git a/src/debug/debug-pal/unix/twowaypipe.cpp b/src/debug/debug-pal/unix/twowaypipe.cpp index f8f82be546..062dc1a145 100644 --- a/src/debug/debug-pal/unix/twowaypipe.cpp +++ b/src/debug/debug-pal/unix/twowaypipe.cpp @@ -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/debug/debug-pal/unix/windefs.h b/src/debug/debug-pal/unix/windefs.h deleted file mode 100644 index 4b46f76e8e..0000000000 --- a/src/debug/debug-pal/unix/windefs.h +++ /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; |