You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2015/07/31 01:25:27 UTC

[4/4] mesos git commit: Split up platform specific functions into separate headers.

Split up platform specific functions into separate headers.

To support the upcoming Windows Containerizer (MESOS-3094), we're
splitting up (refactoring) platform specific functions into separate
files.

We will avoid having `#ifdef __WINDOWS__` all over the stout/libprcess
code by separating Posix/Windows versions. This first patch is to
establish a pattern in splitting up the headers.

Patterns:

* gzip.hpp, thread.hpp - Functions are moved to a Posix folder; copied
  to a Windows folder and gutted for later implementation.
* abort.hpp, exit.hpp, unreachable.hpp - Added macro for
  `__attribute__((noreturn))`.
* duration.hpp - An #ifdef for one of the headers (time.h vs
  Winsock2.h). No need to split the header.
* format.hpp - Missing Windows function (vasprintf) implementation
  added.
* ip.hpp - Added aliases for Windows functions.
* net.hpp - Curl functions were moved to Posix/Windows folders.

Other:

* Instances of #include "local file.hpp" were changed to #include
  <stout/local file.hpp>" to match os.hpp.
* Some missing #endif comments (i.e. `// __APPLE__`) were added.

Review: https://reviews.apache.org/r/36625


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/f8dd73df
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/f8dd73df
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/f8dd73df

Branch: refs/heads/master
Commit: f8dd73dfd1621f0da883a1e65f4fa73c9ddff23f
Parents: 8661672
Author: Joseph Wu <jo...@mesosphere.io>
Authored: Thu Jul 30 15:40:42 2015 -0700
Committer: Benjamin Hindman <be...@gmail.com>
Committed: Thu Jul 30 16:25:05 2015 -0700

----------------------------------------------------------------------
 .../3rdparty/stout/include/Makefile.am          |   9 +-
 .../3rdparty/stout/include/stout/abort.hpp      |  19 +-
 .../3rdparty/stout/include/stout/attributes.hpp |  25 +++
 .../3rdparty/stout/include/stout/duration.hpp   |   8 +-
 .../3rdparty/stout/include/stout/exit.hpp       |   7 +-
 .../3rdparty/stout/include/stout/format.hpp     |  14 +-
 .../3rdparty/stout/include/stout/gzip.hpp       | 136 +------------
 .../3rdparty/stout/include/stout/ip.hpp         |  44 ++--
 .../3rdparty/stout/include/stout/net.hpp        | 200 +++++--------------
 .../3rdparty/stout/include/stout/posix/gzip.hpp | 150 ++++++++++++++
 .../3rdparty/stout/include/stout/posix/net.hpp  | 166 +++++++++++++++
 .../stout/include/stout/unreachable.hpp         |   9 +-
 .../stout/include/stout/windows/format.hpp      |  69 +++++++
 .../stout/include/stout/windows/gzip.hpp        |  47 +++++
 .../stout/include/stout/windows/net.hpp         |  46 +++++
 .../include/stout/windows/preprocessor.hpp      |  34 ++++
 16 files changed, 675 insertions(+), 308 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/f8dd73df/3rdparty/libprocess/3rdparty/stout/include/Makefile.am
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/Makefile.am b/3rdparty/libprocess/3rdparty/stout/include/Makefile.am
index b299ce8..cb40231 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/Makefile.am
+++ b/3rdparty/libprocess/3rdparty/stout/include/Makefile.am
@@ -13,6 +13,7 @@
 # Headers.
 nobase_include_HEADERS =		\
   stout/abort.hpp			\
+  stout/attributes.hpp			\
   stout/base64.hpp			\
   stout/bits.hpp			\
   stout/bytes.hpp			\
@@ -40,6 +41,8 @@ nobase_include_HEADERS =		\
   stout/json.hpp			\
   stout/lambda.hpp			\
   stout/linkedhashmap.hpp		\
+  stout/posix/gzip.hpp			\
+  stout/posix/net.hpp			\
   stout/list.hpp			\
   stout/mac.hpp				\
   stout/multihashmap.hpp		\
@@ -89,4 +92,8 @@ nobase_include_HEADERS =		\
   stout/unreachable.hpp			\
   stout/utils.hpp			\
   stout/uuid.hpp			\
-  stout/version.hpp
+  stout/version.hpp			\
+  stout/windows/format.hpp		\
+  stout/windows/gzip.hpp		\
+  stout/windows/net.hpp			\
+  stout/windows/preprocessor.hpp	\

http://git-wip-us.apache.org/repos/asf/mesos/blob/f8dd73df/3rdparty/libprocess/3rdparty/stout/include/stout/abort.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/abort.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/abort.hpp
index 3aa9487..f620f39 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/abort.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/abort.hpp
@@ -18,10 +18,18 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+
+#ifdef __WINDOWS__
+#include <stout/windows/preprocessor.hpp>
+#else
 #include <unistd.h>
+#endif // __WINDOWS__
 
 #include <string>
 
+#include <stout/attributes.hpp>
+
+
 // Signal safe abort which prints a message.
 #define __STRINGIZE(x) #x
 #define _STRINGIZE(x) __STRINGIZE(x)
@@ -29,9 +37,8 @@
 
 #define ABORT(...) _Abort(_ABORT_PREFIX, __VA_ARGS__)
 
-inline __attribute__((noreturn)) void _Abort(
-    const char* prefix,
-    const char* message)
+
+inline NORETURN void _Abort(const char* prefix, const char* message)
 {
   // Write the failure message in an async-signal safe manner,
   // assuming strlen is async-signal safe or optimized out.
@@ -47,10 +54,10 @@ inline __attribute__((noreturn)) void _Abort(
 }
 
 
-inline __attribute__((noreturn)) void _Abort(
-  const char* prefix,
-  const std::string& message) {
+inline NORETURN void _Abort(const char* prefix, const std::string& message)
+{
   _Abort(prefix, message.c_str());
 }
 
+
 #endif // __STOUT_ABORT_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/f8dd73df/3rdparty/libprocess/3rdparty/stout/include/stout/attributes.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/attributes.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/attributes.hpp
new file mode 100644
index 0000000..2708704
--- /dev/null
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/attributes.hpp
@@ -0,0 +1,25 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef __STOUT_ATTRIBUTES_HPP__
+#define __STOUT_ATTRIBUTES_HPP__
+
+
+#ifdef __WINDOWS__
+#define NORETURN __declspec(noreturn)
+#else
+#define NORETURN __attribute__((noreturn))
+#endif // __WINDOWS__
+
+
+#endif // __STOUT_ATTRIBUTES_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/f8dd73df/3rdparty/libprocess/3rdparty/stout/include/stout/duration.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/duration.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/duration.hpp
index bba8303..35fb034 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/duration.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/duration.hpp
@@ -16,7 +16,13 @@
 
 #include <ctype.h> // For 'isdigit'.
 #include <limits.h> // For 'LLONG_(MAX|MIN)'.
-#include <time.h> // For 'timeval'.
+
+// For 'timeval'.
+#ifdef __WINDOWS__
+#include <Winsock2.h>
+#else
+#include <time.h>
+#endif // __WINDOWS__
 
 #include <iomanip>
 #include <iostream>

http://git-wip-us.apache.org/repos/asf/mesos/blob/f8dd73df/3rdparty/libprocess/3rdparty/stout/include/stout/exit.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/exit.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/exit.hpp
index 8c16a22..38dabd4 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/exit.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/exit.hpp
@@ -21,6 +21,9 @@
 #include <sstream>
 #include <string>
 
+#include <stout/attributes.hpp>
+
+
 // Exit takes an exit status and provides a stream for output prior to
 // exiting. This is like glog's LOG(FATAL) or CHECK, except that it
 // does _not_ print a stack trace.
@@ -28,11 +31,12 @@
 // Ex: EXIT(1) << "Cgroups are not present in this system.";
 #define EXIT(status) __Exit(status).stream()
 
+
 struct __Exit
 {
   __Exit(int _status) : status(_status) {}
 
-  __attribute__((noreturn)) ~__Exit()
+  NORETURN ~__Exit()
   {
     std::cerr << out.str() << std::endl;
     exit(status);
@@ -47,4 +51,5 @@ struct __Exit
   const int status;
 };
 
+
 #endif // __STOUT_EXIT_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/f8dd73df/3rdparty/libprocess/3rdparty/stout/include/stout/format.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/format.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/format.hpp
index 4e8c3bd..6926756 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/format.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/format.hpp
@@ -15,14 +15,20 @@
 #define __STOUT_FORMAT_HPP__
 
 #include <stdarg.h> // For 'va_list', 'va_start', 'va_end'.
-#include <stdio.h> // For 'vasprintf'.
+
+// For 'vasprintf'.
+#ifdef __WINDOWS__
+#include <stout/windows/format.hpp>
+#else
+#include <stdio.h>
+#endif // __WINDOWS__
 
 #include <string>
 #include <type_traits> // For 'is_pod'.
 
-#include "error.hpp"
-#include "stringify.hpp"
-#include "try.hpp"
+#include <stout/error.hpp>
+#include <stout/stringify.hpp>
+#include <stout/try.hpp>
 
 
 // The 'strings::format' functions produces strings based on the

http://git-wip-us.apache.org/repos/asf/mesos/blob/f8dd73df/3rdparty/libprocess/3rdparty/stout/include/stout/gzip.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/gzip.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/gzip.hpp
index 0b95819..85c773a 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/gzip.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/gzip.hpp
@@ -14,136 +14,14 @@
 #ifndef __STOUT_GZIP_HPP__
 #define __STOUT_GZIP_HPP__
 
-#include <zlib.h>
 
-#include <string>
+// For readability, we minimize the number of #ifdef blocks in the code by
+// splitting platform specifc system calls into separate directories.
+#ifdef __WINDOWS__
+#include <stout/windows/gzip.hpp>
+#else
+#include <stout/posix/gzip.hpp>
+#endif // __WINDOWS__
 
-#include "error.hpp"
-#include "stringify.hpp"
-#include "try.hpp"
-
-// Compression utilities.
-// TODO(bmahler): Provide streaming compression / decompression as well.
-namespace gzip {
-
-// We use a 16KB buffer with zlib compression / decompression.
-#define GZIP_BUFFER_SIZE 16384
-
-// Returns a gzip compressed version of the provided string.
-// The compression level should be within the range [-1, 9].
-// See zlib.h:
-//   #define Z_NO_COMPRESSION         0
-//   #define Z_BEST_SPEED             1
-//   #define Z_BEST_COMPRESSION       9
-//   #define Z_DEFAULT_COMPRESSION  (-1)
-inline Try<std::string> compress(
-    const std::string& decompressed,
-    int level = Z_DEFAULT_COMPRESSION)
-{
-  // Verify the level is within range.
-  if (!(level == Z_DEFAULT_COMPRESSION ||
-      (level >= Z_NO_COMPRESSION && level <= Z_BEST_COMPRESSION))) {
-    return Error("Invalid compression level: " + stringify(level));
-  }
-
-  z_stream_s stream;
-  stream.next_in =
-    const_cast<Bytef*>(reinterpret_cast<const Bytef*>(decompressed.data()));
-  stream.avail_in = decompressed.length();
-  stream.zalloc = Z_NULL;
-  stream.zfree = Z_NULL;
-  stream.opaque = Z_NULL;
-
-  int code = deflateInit2(
-      &stream,
-      level,          // Compression level.
-      Z_DEFLATED,     // Compression method.
-      MAX_WBITS + 16, // Zlib magic for gzip compression / decompression.
-      8,              // Default memLevel value.
-      Z_DEFAULT_STRATEGY);
-
-  if (code != Z_OK) {
-    return Error("Failed to initialize zlib: " + std::string(stream.msg));
-  }
-
-  // Build up the compressed result.
-  Bytef buffer[GZIP_BUFFER_SIZE];
-  std::string result = "";
-  do {
-    stream.next_out = buffer;
-    stream.avail_out = GZIP_BUFFER_SIZE;
-    code = deflate(&stream, stream.avail_in > 0 ? Z_NO_FLUSH : Z_FINISH);
-
-    if (code != Z_OK && code != Z_STREAM_END) {
-      Error error(std::string(stream.msg));
-      deflateEnd(&stream);
-      return error;
-    }
-
-    // Consume output and reset the buffer.
-    result.append(
-        reinterpret_cast<char*>(buffer),
-        GZIP_BUFFER_SIZE - stream.avail_out);
-    stream.next_out = buffer;
-    stream.avail_out = GZIP_BUFFER_SIZE;
-  } while (code != Z_STREAM_END);
-
-  code = deflateEnd(&stream);
-  if (code != Z_OK) {
-    return Error("Failed to clean up zlib: " + std::string(stream.msg));
-  }
-  return result;
-}
-
-
-// Returns a gzip decompressed version of the provided string.
-inline Try<std::string> decompress(const std::string& compressed)
-{
-  z_stream_s stream;
-  stream.next_in =
-    const_cast<Bytef*>(reinterpret_cast<const Bytef*>(compressed.data()));
-  stream.avail_in = compressed.length();
-  stream.zalloc = Z_NULL;
-  stream.zfree = Z_NULL;
-  stream.opaque = Z_NULL;
-
-  int code = inflateInit2(
-      &stream,
-      MAX_WBITS + 16); // Zlib magic for gzip compression / decompression.
-
-  if (code != Z_OK) {
-    return Error("Failed to initialize zlib: " + std::string(stream.msg));
-  }
-
-  // Build up the decompressed result.
-  Bytef buffer[GZIP_BUFFER_SIZE];
-  std::string result = "";
-  do {
-    stream.next_out = buffer;
-    stream.avail_out = GZIP_BUFFER_SIZE;
-    code = inflate(&stream, stream.avail_in > 0 ? Z_NO_FLUSH : Z_FINISH);
-
-    if (code != Z_OK && code != Z_STREAM_END) {
-      Error error(std::string(stream.msg));
-      inflateEnd(&stream);
-      return error;
-    }
-
-    // Consume output and reset the buffer.
-    result.append(
-        reinterpret_cast<char*>(buffer),
-        GZIP_BUFFER_SIZE - stream.avail_out);
-    stream.next_out = buffer;
-    stream.avail_out = GZIP_BUFFER_SIZE;
-  } while (code != Z_STREAM_END);
-
-  code = inflateEnd(&stream);
-  if (code != Z_OK) {
-    return Error("Failed to clean up zlib: " + std::string(stream.msg));
-  }
-  return result;
-}
-
-} // namespace gzip {
 
 #endif // __STOUT_GZIP_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/f8dd73df/3rdparty/libprocess/3rdparty/stout/include/stout/ip.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/ip.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/ip.hpp
index a0ea237..41ceb2e 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/ip.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/ip.hpp
@@ -14,11 +14,16 @@
 #ifndef __STOUT_IP_HPP__
 #define __STOUT_IP_HPP__
 
+// For 'sockaddr'.
+#ifdef __WINDOWS__
+#include <Winsock2.h>
+#else
 #include <arpa/inet.h>
+#endif // __WINDOWS__
 
 #if defined(__linux__) || defined(__APPLE__)
 #include <ifaddrs.h>
-#endif
+#endif // __linux__ || __APPLE__
 #include <stdint.h>
 #include <stdio.h>
 #include <string.h>
@@ -27,11 +32,18 @@
 #include <net/if.h>
 #include <net/if_dl.h>
 #include <net/if_types.h>
-#endif
+#endif // __APPLE__
 
+// Note: Header grouping and ordering is considered before
+// inclusion/exclusion by platform.
+// For 'inet_pton', 'inet_ntop'.
+#ifdef __WINDOWS__
+#include <Ws2tcpip.h>
+#else
 #include <netinet/in.h>
-
 #include <sys/socket.h>
+#endif // __WINDOWS__
+
 #include <sys/types.h>
 
 #include <iostream>
@@ -39,17 +51,21 @@
 #include <vector>
 
 
-#include "abort.hpp"
-#include "bits.hpp"
-#include "error.hpp"
-#include "none.hpp"
-#include "numify.hpp"
-#include "option.hpp"
-#include "result.hpp"
-#include "stringify.hpp"
-#include "strings.hpp"
-#include "try.hpp"
-#include "unreachable.hpp"
+#include <stout/abort.hpp>
+#include <stout/bits.hpp>
+#include <stout/error.hpp>
+#include <stout/none.hpp>
+#include <stout/numify.hpp>
+#include <stout/option.hpp>
+#include <stout/result.hpp>
+#include <stout/stringify.hpp>
+#include <stout/strings.hpp>
+#include <stout/try.hpp>
+#include <stout/unreachable.hpp>
+
+#ifdef __WINDOWS__
+#include <stout/windows/preprocessor.hpp>
+#endif // __WINDOWS__
 
 
 namespace net {

http://git-wip-us.apache.org/repos/asf/mesos/blob/f8dd73df/3rdparty/libprocess/3rdparty/stout/include/stout/net.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/net.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/net.hpp
index a538fb1..3f829ba 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/net.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/net.hpp
@@ -14,33 +14,50 @@
 #ifndef __STOUT_NET_HPP__
 #define __STOUT_NET_HPP__
 
+#ifndef __WINDOWS__
 #include <netdb.h>
+#endif // __WINDOWS__
+
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 
+#ifndef __WINDOWS__
 #include <arpa/inet.h>
+#endif // __WINDOWS__
 
 #ifdef __APPLE__
 #include <net/if.h>
 #include <net/if_dl.h>
 #include <net/if_types.h>
-#endif
+#endif // __APPLE__
 
+// Note: Header grouping and ordering is considered before
+// inclusion/exclusion by platform.
+#ifndef __WINDOWS__
 #include <sys/param.h>
 
 #include <curl/curl.h>
+#endif // __WINDOWS__
 
 #include <iostream>
 #include <set>
 #include <string>
 
-#include "error.hpp"
-#include "ip.hpp"
-#include "option.hpp"
-#include "os.hpp"
-#include "stringify.hpp"
-#include "try.hpp"
+#include <stout/error.hpp>
+#include <stout/ip.hpp>
+#include <stout/option.hpp>
+#include <stout/stringify.hpp>
+#include <stout/try.hpp>
+
+
+// For readability, we minimize the number of #ifdef blocks in the code by
+// splitting platform specifc system calls into separate directories.
+#ifdef __WINDOWS__
+#include <stout/windows/net.hpp>
+#else
+#include <stout/posix/net.hpp>
+#endif // __WINDOWS__
 
 
 // Network utilities.
@@ -84,125 +101,6 @@ inline struct sockaddr_storage createSockaddrStorage(const IP& ip, int port)
 }
 
 
-// Initializes libraries that net:: functions depend on, in a
-// thread-safe way. This does not have to be called explicitly by
-// the user of any functions in question. They will call this
-// themselves by need.
-inline void initialize()
-{
-  // We use a static struct variable to initialize in a thread-safe
-  // way, at least with respect to calls within net::*, since there
-  // is no way to guarantee that another library is not concurrently
-  // initializing CURL. Thread safety is provided by the fact that
-  // the value 'curl' should get constructed (i.e., the CURL
-  // constructor invoked) in a thread safe way (as of GCC 4.3 and
-  // required for C++11).
-  struct CURL
-  {
-    CURL()
-    {
-      // This is the only one function in libcurl that is not deemed
-      // thread-safe. (And it must be called at least once before any
-      // other libcurl function is used.)
-      curl_global_init(CURL_GLOBAL_ALL);
-    }
-  };
-
-  static CURL curl;
-}
-
-
-// Downloads the header of the specified HTTP URL with a HEAD request
-// and queries its "content-length" field. (Note that according to the
-// HTTP specification there is no guarantee that this field contains
-// any useful value.)
-inline Try<Bytes> contentLength(const std::string& url)
-{
-  initialize();
-
-  CURL* curl = curl_easy_init();
-  if (curl == NULL) {
-    curl_easy_cleanup(curl);
-    return Error("Failed to initialize libcurl");
-  }
-
-  curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
-  curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, true);
-  curl_easy_setopt(curl, CURLOPT_HEADER, 1);
-  curl_easy_setopt(curl, CURLOPT_NOBODY, 1);
-
-  CURLcode curlErrorCode = curl_easy_perform(curl);
-  if (curlErrorCode != 0) {
-    curl_easy_cleanup(curl);
-    return Error(curl_easy_strerror(curlErrorCode));
-  }
-
-  double result;
-  curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &result);
-
-  curl_easy_cleanup(curl);
-
-  if (result < 0) {
-    return Error("No URL content-length available");
-  }
-
-  return Bytes(uint64_t(result));
-}
-
-
-// Returns the HTTP response code resulting from attempting to
-// download the specified HTTP or FTP URL into a file at the specified
-// path.
-inline Try<int> download(const std::string& url, const std::string& path)
-{
-  initialize();
-
-  Try<int> fd = os::open(
-      path,
-      O_CREAT | O_WRONLY | O_CLOEXEC,
-      S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
-
-  if (fd.isError()) {
-    return Error(fd.error());
-  }
-
-  CURL* curl = curl_easy_init();
-
-  if (curl == NULL) {
-    curl_easy_cleanup(curl);
-    os::close(fd.get());
-    return Error("Failed to initialize libcurl");
-  }
-
-  curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
-  curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL);
-  curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, true);
-
-  FILE* file = fdopen(fd.get(), "w");
-  if (file == NULL) {
-    return ErrnoError("Failed to open file handle of '" + path + "'");
-  }
-  curl_easy_setopt(curl, CURLOPT_WRITEDATA, file);
-
-  CURLcode curlErrorCode = curl_easy_perform(curl);
-  if (curlErrorCode != 0) {
-    curl_easy_cleanup(curl);
-    fclose(file);
-    return Error(curl_easy_strerror(curlErrorCode));
-  }
-
-  long code;
-  curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &code);
-  curl_easy_cleanup(curl);
-
-  if (fclose(file) != 0) {
-    return ErrnoError("Failed to close file handle of '" + path + "'");
-  }
-
-  return Try<int>::some(code);
-}
-
-
 inline Try<std::string> hostname()
 {
   char host[512];
@@ -211,7 +109,7 @@ inline Try<std::string> hostname()
     return ErrnoError();
   }
 
-  // TODO(evelinad): Add AF_UNSPEC when we will support IPv6
+  // TODO(evelinad): Add AF_UNSPEC when we will support IPv6.
   struct addrinfo hints = createAddrInfo(SOCK_STREAM, AF_INET, AI_CANONNAME);
   struct addrinfo* result = NULL;
 
@@ -253,6 +151,30 @@ inline Try<std::string> getHostname(const IP& ip)
 }
 
 
+// Returns the names of all the link devices in the system.
+inline Try<std::set<std::string>> links()
+{
+#if !defined(__linux__) && !defined(__APPLE__)
+  return Error("Not implemented");
+#else
+  struct ifaddrs* ifaddr = NULL;
+  if (getifaddrs(&ifaddr) == -1) {
+    return ErrnoError();
+  }
+
+  std::set<std::string> names;
+  for (struct ifaddrs* ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) {
+    if (ifa->ifa_name != NULL) {
+      names.insert(ifa->ifa_name);
+    }
+  }
+
+  freeifaddrs(ifaddr);
+  return names;
+#endif
+}
+
+
 // Returns a Try of the IP for the provided hostname or an error if no IP is
 // obtained.
 inline Try<IP> getIP(const std::string& hostname, int family)
@@ -282,30 +204,6 @@ inline Try<IP> getIP(const std::string& hostname, int family)
   return ip.get();
 }
 
-
-// Returns the names of all the link devices in the system.
-inline Try<std::set<std::string> > links()
-{
-#if !defined(__linux__) && !defined(__APPLE__)
-  return Error("Not implemented");
-#else
-  struct ifaddrs* ifaddr = NULL;
-  if (getifaddrs(&ifaddr) == -1) {
-    return ErrnoError();
-  }
-
-  std::set<std::string> names;
-  for (struct ifaddrs* ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) {
-    if (ifa->ifa_name != NULL) {
-      names.insert(ifa->ifa_name);
-    }
-  }
-
-  freeifaddrs(ifaddr);
-  return names;
-#endif
-}
-
 } // namespace net {
 
 #endif // __STOUT_NET_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/f8dd73df/3rdparty/libprocess/3rdparty/stout/include/stout/posix/gzip.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/posix/gzip.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/posix/gzip.hpp
new file mode 100644
index 0000000..d5abf41
--- /dev/null
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/posix/gzip.hpp
@@ -0,0 +1,150 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef __STOUT_POSIX_GZIP_HPP__
+#define __STOUT_POSIX_GZIP_HPP__
+
+#include <zlib.h>
+
+#include <string>
+
+#include <stout/error.hpp>
+#include <stout/stringify.hpp>
+#include <stout/try.hpp>
+
+
+// Compression utilities.
+// TODO(bmahler): Provide streaming compression / decompression as well.
+namespace gzip {
+
+// We use a 16KB buffer with zlib compression / decompression.
+#define GZIP_BUFFER_SIZE 16384
+
+// Returns a gzip compressed version of the provided string.
+// The compression level should be within the range [-1, 9].
+// See zlib.h:
+//   #define Z_NO_COMPRESSION         0
+//   #define Z_BEST_SPEED             1
+//   #define Z_BEST_COMPRESSION       9
+//   #define Z_DEFAULT_COMPRESSION  (-1)
+inline Try<std::string> compress(
+    const std::string& decompressed,
+    int level = Z_DEFAULT_COMPRESSION)
+{
+  // Verify the level is within range.
+  if (!(level == Z_DEFAULT_COMPRESSION ||
+      (level >= Z_NO_COMPRESSION && level <= Z_BEST_COMPRESSION))) {
+    return Error("Invalid compression level: " + stringify(level));
+  }
+
+  z_stream_s stream;
+  stream.next_in =
+    const_cast<Bytef*>(reinterpret_cast<const Bytef*>(decompressed.data()));
+  stream.avail_in = decompressed.length();
+  stream.zalloc = Z_NULL;
+  stream.zfree = Z_NULL;
+  stream.opaque = Z_NULL;
+
+  int code = deflateInit2(
+      &stream,
+      level,          // Compression level.
+      Z_DEFLATED,     // Compression method.
+      MAX_WBITS + 16, // Zlib magic for gzip compression / decompression.
+      8,              // Default memLevel value.
+      Z_DEFAULT_STRATEGY);
+
+  if (code != Z_OK) {
+    return Error("Failed to initialize zlib: " + std::string(stream.msg));
+  }
+
+  // Build up the compressed result.
+  Bytef buffer[GZIP_BUFFER_SIZE];
+  std::string result = "";
+  do {
+    stream.next_out = buffer;
+    stream.avail_out = GZIP_BUFFER_SIZE;
+    code = deflate(&stream, stream.avail_in > 0 ? Z_NO_FLUSH : Z_FINISH);
+
+    if (code != Z_OK && code != Z_STREAM_END) {
+      Error error(std::string(stream.msg));
+      deflateEnd(&stream);
+      return error;
+    }
+
+    // Consume output and reset the buffer.
+    result.append(
+        reinterpret_cast<char*>(buffer),
+        GZIP_BUFFER_SIZE - stream.avail_out);
+    stream.next_out = buffer;
+    stream.avail_out = GZIP_BUFFER_SIZE;
+  } while (code != Z_STREAM_END);
+
+  code = deflateEnd(&stream);
+  if (code != Z_OK) {
+    return Error("Failed to clean up zlib: " + std::string(stream.msg));
+  }
+  return result;
+}
+
+
+// Returns a gzip decompressed version of the provided string.
+inline Try<std::string> decompress(const std::string& compressed)
+{
+  z_stream_s stream;
+  stream.next_in =
+    const_cast<Bytef*>(reinterpret_cast<const Bytef*>(compressed.data()));
+  stream.avail_in = compressed.length();
+  stream.zalloc = Z_NULL;
+  stream.zfree = Z_NULL;
+  stream.opaque = Z_NULL;
+
+  int code = inflateInit2(
+      &stream,
+      MAX_WBITS + 16); // Zlib magic for gzip compression / decompression.
+
+  if (code != Z_OK) {
+    return Error("Failed to initialize zlib: " + std::string(stream.msg));
+  }
+
+  // Build up the decompressed result.
+  Bytef buffer[GZIP_BUFFER_SIZE];
+  std::string result = "";
+  do {
+    stream.next_out = buffer;
+    stream.avail_out = GZIP_BUFFER_SIZE;
+    code = inflate(&stream, stream.avail_in > 0 ? Z_NO_FLUSH : Z_FINISH);
+
+    if (code != Z_OK && code != Z_STREAM_END) {
+      Error error(std::string(stream.msg));
+      inflateEnd(&stream);
+      return error;
+    }
+
+    // Consume output and reset the buffer.
+    result.append(
+        reinterpret_cast<char*>(buffer),
+        GZIP_BUFFER_SIZE - stream.avail_out);
+    stream.next_out = buffer;
+    stream.avail_out = GZIP_BUFFER_SIZE;
+  } while (code != Z_STREAM_END);
+
+  code = inflateEnd(&stream);
+  if (code != Z_OK) {
+    return Error("Failed to clean up zlib: " + std::string(stream.msg));
+  }
+  return result;
+}
+
+} // namespace gzip {
+
+#endif // __STOUT_POSIX_GZIP_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/f8dd73df/3rdparty/libprocess/3rdparty/stout/include/stout/posix/net.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/posix/net.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/posix/net.hpp
new file mode 100644
index 0000000..11e3895
--- /dev/null
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/posix/net.hpp
@@ -0,0 +1,166 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef __STOUT_POSIX_NET_HPP__
+#define __STOUT_POSIX_NET_HPP__
+
+#include <netdb.h>
+
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <arpa/inet.h>
+
+#ifdef __APPLE__
+#include <net/if.h>
+#include <net/if_dl.h>
+#include <net/if_types.h>
+#endif // __APPLE__
+
+#include <sys/param.h>
+
+#include <curl/curl.h>
+
+#include <string>
+
+#include <stout/error.hpp>
+#include <stout/ip.hpp>
+#include <stout/os.hpp>
+#include <stout/try.hpp>
+
+
+// Network utilities.
+namespace net {
+
+// Initializes libraries that net:: functions depend on, in a
+// thread-safe way. This does not have to be called explicitly by
+// the user of any functions in question. They will call this
+// themselves by need.
+inline void initialize()
+{
+  // We use a static struct variable to initialize in a thread-safe
+  // way, at least with respect to calls within net::*, since there
+  // is no way to guarantee that another library is not concurrently
+  // initializing CURL. Thread safety is provided by the fact that
+  // the value 'curl' should get constructed (i.e., the CURL
+  // constructor invoked) in a thread safe way (as of GCC 4.3 and
+  // required for C++11).
+  struct CURL
+  {
+    CURL()
+    {
+      // This is the only one function in libcurl that is not deemed
+      // thread-safe. (And it must be called at least once before any
+      // other libcurl function is used.)
+      curl_global_init(CURL_GLOBAL_ALL);
+    }
+  };
+
+  static CURL curl;
+}
+
+
+// Downloads the header of the specified HTTP URL with a HEAD request
+// and queries its "content-length" field. (Note that according to the
+// HTTP specification there is no guarantee that this field contains
+// any useful value.)
+inline Try<Bytes> contentLength(const std::string& url)
+{
+  initialize();
+
+  CURL* curl = curl_easy_init();
+  if (curl == NULL) {
+    curl_easy_cleanup(curl);
+    return Error("Failed to initialize libcurl");
+  }
+
+  curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
+  curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, true);
+  curl_easy_setopt(curl, CURLOPT_HEADER, 1);
+  curl_easy_setopt(curl, CURLOPT_NOBODY, 1);
+
+  CURLcode curlErrorCode = curl_easy_perform(curl);
+  if (curlErrorCode != 0) {
+    curl_easy_cleanup(curl);
+    return Error(curl_easy_strerror(curlErrorCode));
+  }
+
+  double result;
+  curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &result);
+
+  curl_easy_cleanup(curl);
+
+  if (result < 0) {
+    return Error("No URL content-length available");
+  }
+
+  return Bytes(uint64_t(result));
+}
+
+
+// Returns the HTTP response code resulting from attempting to
+// download the specified HTTP or FTP URL into a file at the specified
+// path.
+inline Try<int> download(const std::string& url, const std::string& path)
+{
+  initialize();
+
+  Try<int> fd = os::open(
+      path,
+      O_CREAT | O_WRONLY | O_CLOEXEC,
+      S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+
+  if (fd.isError()) {
+    return Error(fd.error());
+  }
+
+  CURL* curl = curl_easy_init();
+
+  if (curl == NULL) {
+    curl_easy_cleanup(curl);
+    os::close(fd.get());
+    return Error("Failed to initialize libcurl");
+  }
+
+  curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
+  curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL);
+  curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, true);
+
+  FILE* file = fdopen(fd.get(), "w");
+  if (file == NULL) {
+    return ErrnoError("Failed to open file handle of '" + path + "'");
+  }
+  curl_easy_setopt(curl, CURLOPT_WRITEDATA, file);
+
+  CURLcode curlErrorCode = curl_easy_perform(curl);
+  if (curlErrorCode != 0) {
+    curl_easy_cleanup(curl);
+    fclose(file);
+    return Error(curl_easy_strerror(curlErrorCode));
+  }
+
+  long code;
+  curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &code);
+  curl_easy_cleanup(curl);
+
+  if (fclose(file) != 0) {
+    return ErrnoError("Failed to close file handle of '" + path + "'");
+  }
+
+  return Try<int>::some(code);
+}
+
+} // namespace net {
+
+#endif // __STOUT_POSIX_NET_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/f8dd73df/3rdparty/libprocess/3rdparty/stout/include/stout/unreachable.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/unreachable.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/unreachable.hpp
index fed0a7b..cd4caf6 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/unreachable.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/unreachable.hpp
@@ -16,12 +16,19 @@
 
 #include <iostream>
 
+#include <stout/abort.hpp>
+#include <stout/attributes.hpp>
+
+
 #define UNREACHABLE() Unreachable(__FILE__, __LINE__)
 
-inline __attribute__((noreturn)) void Unreachable(const char *file, int line) {
+
+inline NORETURN void Unreachable(const char* file, int line)
+{
   std::cerr << "Reached unreachable statement at " << file << ':'
             << line << std::endl;
   abort();
 }
 
+
 #endif // __STOUT_UNREACHABLE_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/f8dd73df/3rdparty/libprocess/3rdparty/stout/include/stout/windows/format.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/windows/format.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/windows/format.hpp
new file mode 100644
index 0000000..dcf5097
--- /dev/null
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/windows/format.hpp
@@ -0,0 +1,69 @@
+/**
+ * Copyright 2015 Mesosphere, Inc.
+ *
+ * This file has been modified from its original form by Mesosphere, Inc.
+ * All modifications made to this file by Mesosphere (the “Modifications”)
+ * are copyright 2015 Mesosphere, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ---
+ *
+ * The original file on which the Modifications have been made were
+ * provided to Mesosphere pursuant to the following terms:
+ *
+ * Copyright (C) 2014 insane coder (http://insanecoding.blogspot.com/,
+ * http://asprintf.insanecoding.org/)
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+#ifndef __STOUT_WINDOWS_FORMAT_HPP__
+#define __STOUT_WINDOWS_FORMAT_HPP__
+
+#include <stdio.h> // For '_vscprintf', 'vsnprintf'.
+#include <stdlib.h> // For 'malloc', 'free'.
+#include <limits.h> // For 'INT_MAX'.
+
+
+inline int vasprintf(char** buffer, const char* format, va_list args)
+{
+  int result = -1;
+  int size = _vscprintf(format, args) + 1;
+
+  if (size >= 0 && size < INT_MAX) {
+    *buffer = (char*) malloc(size);
+
+    if (*buffer) {
+      result = vsnprintf(*buffer, size, format, args);
+
+      if (result < 0) {
+        free(*buffer);
+      }
+    }
+  }
+
+  return result;
+}
+
+
+#endif // __STOUT_WINDOWS_FORMAT_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/f8dd73df/3rdparty/libprocess/3rdparty/stout/include/stout/windows/gzip.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/windows/gzip.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/windows/gzip.hpp
new file mode 100644
index 0000000..017cfb3
--- /dev/null
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/windows/gzip.hpp
@@ -0,0 +1,47 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef __STOUT_WINDOWS_GZIP_HPP__
+#define __STOUT_WINDOWS_GZIP_HPP__
+
+#include <string>
+
+#include <stout/try.hpp>
+
+
+namespace gzip {
+
+// Returns a gzip compressed version of the provided string.
+// The compression level should be within the range [-1, 9].
+// See zlib.h:
+//   #define Z_NO_COMPRESSION         0
+//   #define Z_BEST_SPEED             1
+//   #define Z_BEST_COMPRESSION       9
+//   #define Z_DEFAULT_COMPRESSION  (-1)
+inline Try<std::string> compress(
+    const std::string& decompressed,
+    int level = Z_DEFAULT_COMPRESSION)
+{
+  UNIMPLEMENTED;
+}
+
+
+// Returns a gzip decompressed version of the provided string.
+inline Try<std::string> decompress(const std::string& compressed)
+{
+  UNIMPLEMENTED;
+}
+
+} // namespace gzip {
+
+#endif // __STOUT_WINDOWS_GZIP_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/f8dd73df/3rdparty/libprocess/3rdparty/stout/include/stout/windows/net.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/windows/net.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/windows/net.hpp
new file mode 100644
index 0000000..4f82796
--- /dev/null
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/windows/net.hpp
@@ -0,0 +1,46 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef __STOUT_WINDOWS_NET_HPP__
+#define __STOUT_WINDOWS_NET_HPP__
+
+#include <string>
+
+#include <stout/ip.hpp>
+#include <stout/try.hpp>
+
+
+// Network utilities.
+namespace net {
+
+// Downloads the header of the specified HTTP URL with a HEAD request
+// and queries its "content-length" field. (Note that according to the
+// HTTP specification there is no guarantee that this field contains
+// any useful value.)
+inline Try<Bytes> contentLength(const std::string& url)
+{
+  UNIMPLEMENTED;
+}
+
+
+// Returns the HTTP response code resulting from attempting to
+// download the specified HTTP or FTP URL into a file at the specified
+// path.
+inline Try<int> download(const std::string& url, const std::string& path)
+{
+  UNIMPLEMENTED;
+}
+
+} // namespace net {
+
+#endif // __STOUT_WINDOWS_NET_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/f8dd73df/3rdparty/libprocess/3rdparty/stout/include/stout/windows/preprocessor.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/windows/preprocessor.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/windows/preprocessor.hpp
new file mode 100644
index 0000000..de41db6
--- /dev/null
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/windows/preprocessor.hpp
@@ -0,0 +1,34 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef __STOUT_WINDOWS_PREPROCESSOR_HPP__
+#define __STOUT_WINDOWS_PREPROCESSOR_HPP__
+
+// Provides aliases to Windows-specific nuances.
+
+// Normally defined in unistd.h.
+#define STDIN_FILENO 0
+#define STDOUT_FILENO 1
+#define STDERR_FILENO 2
+
+// Alias for method in stdio.h.
+#define write(fd, buf, count) _write(fd, buf, count)
+
+// Aliases for 'inet_pton' and 'inet_ntop'.
+#define inet_pton(af, cp, buf) InetPton(af, cp, buf)
+#define inet_ntop(af, cp, buf, len) InetNtop(af, cp, buf, len)
+
+// TODO(aclemmer): Not defined on Windows.  This value is temporary.
+#define MAXHOSTNAMELEN 64
+
+#endif // __STOUT_WINDOWS_PREPROCESSOR_HPP__