diff options
author | Jason Molenda <jmolenda@apple.com> | 2017-11-02 03:17:07 +0000 |
---|---|---|
committer | Jason Molenda <jmolenda@apple.com> | 2017-11-02 03:17:07 +0000 |
commit | 23502721870be84917fb97e4c9b8ae0755bd220e (patch) | |
tree | 7d7862578e7402c4c718f432c630f4e548e94e22 /lldb/source/Host/common/File.cpp | |
parent | edc2def4a65764991ffb50e9c9af1c740ced534c (diff) | |
download | bcm5719-llvm-23502721870be84917fb97e4c9b8ae0755bd220e.tar.gz bcm5719-llvm-23502721870be84917fb97e4c9b8ae0755bd220e.zip |
Revert r317182 for https://reviews.llvm.org/D39128
we're still failing on android. I'll ask Larry to
ask Pavel for any tips he might be able to give.
llvm-svn: 317183
Diffstat (limited to 'lldb/source/Host/common/File.cpp')
-rw-r--r-- | lldb/source/Host/common/File.cpp | 124 |
1 files changed, 0 insertions, 124 deletions
diff --git a/lldb/source/Host/common/File.cpp b/lldb/source/Host/common/File.cpp index ec5c435d778..6ee4e894756 100644 --- a/lldb/source/Host/common/File.cpp +++ b/lldb/source/Host/common/File.cpp @@ -14,7 +14,6 @@ #include <limits.h> #include <stdarg.h> #include <stdio.h> -#include <assert.h> #ifdef _WIN32 #include "lldb/Host/windows/windows.h" @@ -72,129 +71,6 @@ static const char *GetStreamOpenModeFromOptions(uint32_t options) { int File::kInvalidDescriptor = -1; FILE *File::kInvalidStream = NULL; -File::File(File &&rhs) - : IOObject(eFDTypeFile, false), m_descriptor(kInvalidDescriptor), - m_stream(kInvalidStream), m_options(), m_own_stream(false), - m_is_interactive(eLazyBoolCalculate), - m_is_real_terminal(eLazyBoolCalculate), - m_supports_colors(eLazyBoolCalculate) -{ - Swap(rhs); -} - -File& File::operator= (File &&rhs) -{ - Close(); - Swap(rhs); - return *this; -} - -void File::Swap(File &rhs) -{ - std::swap(m_descriptor, rhs.m_descriptor); - std::swap(m_stream, rhs.m_stream); - std::swap(m_own_stream, rhs.m_own_stream); - std::swap(m_options, rhs.m_options); - std::swap(m_is_interactive, rhs.m_is_interactive); - std::swap(m_is_real_terminal, rhs.m_is_real_terminal); - std::swap(m_supports_colors, rhs.m_supports_colors); -} - -#if defined(__linux__) - -struct context { - void *cookie; - int (*readfn)(void *, char *, int); - int (*writefn)(void *, const char *, int); - int (*closefn)(void *); -}; - -static ssize_t -write_wrapper(void *c, const char *buf, size_t size) -{ - auto ctx = (struct context *)c; - if (size > INT_MAX) { - size = INT_MAX; - } - ssize_t wrote = ctx->writefn(ctx->cookie, buf, (int)size); - assert(wrote < 0 || (size_t)wrote <= size); - if (wrote < 0) { - return -1; - } else { - return (int)wrote; - } -} - -static ssize_t -read_wrapper(void *c, char *buf, size_t size) -{ - auto ctx = (struct context *)c; - if (size > INT_MAX) { - size = INT_MAX; - } - ssize_t read = ctx->writefn(ctx->cookie, buf, (int)size); - assert(read < 0 || (size_t)read <= size); - if (read < 0) { - return -1; - } else { - return (int)read; - } -} - -static int -close_wrapper(void *c) -{ - auto ctx = (struct context *)c; - int ret = ctx->closefn(ctx->cookie); - delete ctx; - return ret; -} - -#endif - -File::File(void *cookie, - int (*readfn)(void *, char *, int), - int (*writefn)(void *, const char *, int), - int (*closefn)(void *)) - : IOObject(eFDTypeFile, false), m_descriptor(kInvalidDescriptor), - m_stream(kInvalidStream), m_options(), m_own_stream(false), - m_is_interactive(eLazyBoolCalculate), - m_is_real_terminal(eLazyBoolCalculate), - m_supports_colors(eLazyBoolCalculate) -{ -#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) - m_stream = funopen(cookie, readfn, writefn, NULL, closefn); -#elif defined(__linux__) - cookie_io_functions_t io_funcs = {}; - io_funcs.read = read_wrapper; - io_funcs.write = write_wrapper; - io_funcs.close = close_wrapper; - const char *mode = NULL; - if (readfn && writefn) { - mode = "r+"; - } else if (readfn) { - mode = "r"; - } else if (writefn) { - mode = "w"; - } - if (mode) { - struct context *ctx = new context; - ctx->readfn = readfn; - ctx->writefn = writefn; - ctx->closefn = closefn; - ctx->cookie = cookie; - m_stream = fopencookie(ctx, mode, io_funcs); - if (!m_stream) { - delete ctx; - } - } -#endif - if (m_stream) { - m_own_stream = true; - } -} - - File::File(const char *path, uint32_t options, uint32_t permissions) : IOObject(eFDTypeFile, false), m_descriptor(kInvalidDescriptor), m_stream(kInvalidStream), m_options(), m_own_stream(false), |