From 1b67e9aa7d339e7e79845c66906e1bd47f22cdfa Mon Sep 17 00:00:00 2001 From: Yedidya Feldblum Date: Fri, 2 Jun 2017 15:34:42 -0700 Subject: [PATCH] Apply clang-format to folly/portability/ Summary: [Folly] Apply `clang-format` to `folly/portability/`. With some manual rearrangement in the places where `clang-format` does awkward things, with the result that `clang-format` over `folly/portability/` becomes a no-op. Reviewed By: igorsugak Differential Revision: D5170107 fbshipit-source-id: ceadd96740b4877cbae947846f0e738e6aaf5ed1 --- folly/portability/Asm.h | 2 +- folly/portability/BitsFunctexcept.cpp | 5 +-- folly/portability/BitsFunctexcept.h | 7 ++-- folly/portability/Builtins.h | 16 ++++---- folly/portability/Constexpr.h | 5 ++- folly/portability/Event.h | 6 +-- folly/portability/Fcntl.cpp | 4 +- folly/portability/Memory.cpp | 9 +++-- folly/portability/OpenSSL.cpp | 1 - folly/portability/OpenSSL.h | 27 +++++++------ folly/portability/Sockets.cpp | 8 +++- folly/portability/Stdio.cpp | 19 +++++++-- folly/portability/Stdlib.cpp | 9 ++++- folly/portability/String.h | 2 +- folly/portability/SysMman.cpp | 3 ++ folly/portability/SysMman.h | 11 ++++-- folly/portability/SysStat.cpp | 12 ++++-- folly/portability/SysStat.h | 2 +- folly/portability/SysTime.cpp | 3 ++ folly/portability/SysUio.cpp | 4 +- folly/portability/Time.cpp | 7 ++-- folly/portability/Time.h | 23 +++++------ folly/portability/Unistd.cpp | 56 ++++++++++++++++++++------- folly/portability/Unistd.h | 6 +++ folly/portability/Windows.h | 4 +- folly/portability/test/TimeTest.cpp | 2 +- 26 files changed, 167 insertions(+), 86 deletions(-) mode change 100755 => 100644 folly/portability/Asm.h mode change 100755 => 100644 folly/portability/Builtins.h mode change 100755 => 100644 folly/portability/Constexpr.h mode change 100755 => 100644 folly/portability/Fcntl.cpp mode change 100755 => 100644 folly/portability/Sockets.cpp mode change 100755 => 100644 folly/portability/Stdio.cpp mode change 100755 => 100644 folly/portability/String.h mode change 100755 => 100644 folly/portability/SysMman.cpp mode change 100755 => 100644 folly/portability/SysMman.h mode change 100755 => 100644 folly/portability/SysStat.cpp mode change 100755 => 100644 folly/portability/SysStat.h mode change 100755 => 100644 folly/portability/SysTime.cpp mode change 100755 => 100644 folly/portability/SysUio.cpp mode change 100755 => 100644 folly/portability/Time.cpp mode change 100755 => 100644 folly/portability/Time.h mode change 100755 => 100644 folly/portability/Unistd.cpp mode change 100755 => 100644 folly/portability/Unistd.h mode change 100755 => 100644 folly/portability/Windows.h diff --git a/folly/portability/Asm.h b/folly/portability/Asm.h old mode 100755 new mode 100644 index 94b50442..f3343649 --- a/folly/portability/Asm.h +++ b/folly/portability/Asm.h @@ -19,7 +19,7 @@ #include #ifdef _MSC_VER -# include +#include #endif namespace folly { diff --git a/folly/portability/BitsFunctexcept.cpp b/folly/portability/BitsFunctexcept.cpp index 80e4a543..cf7f171e 100644 --- a/folly/portability/BitsFunctexcept.cpp +++ b/folly/portability/BitsFunctexcept.cpp @@ -24,7 +24,7 @@ #else -FOLLY_NAMESPACE_STD_BEGIN +namespace std { #if _LIBCPP_VERSION < 4000 void __throw_length_error(char const* msg) { @@ -45,7 +45,6 @@ void __throw_bad_alloc() { throw std::bad_alloc(); } #endif - -FOLLY_NAMESPACE_STD_END +} #endif diff --git a/folly/portability/BitsFunctexcept.h b/folly/portability/BitsFunctexcept.h index 72deb3e8..e0f13de9 100644 --- a/folly/portability/BitsFunctexcept.h +++ b/folly/portability/BitsFunctexcept.h @@ -27,10 +27,10 @@ #else -FOLLY_NAMESPACE_STD_BEGIN +namespace std { #if _LIBCPP_VERSION < 4000 -[[noreturn]] void __throw_length_error(char const* msg); // @nolint +[[noreturn]] void __throw_length_error(char const* msg); [[noreturn]] void __throw_logic_error(char const* msg); [[noreturn]] void __throw_out_of_range(char const* msg); #endif @@ -38,7 +38,6 @@ FOLLY_NAMESPACE_STD_BEGIN #if _CPPLIB_VER // msvc c++ std lib [[noreturn]] void __throw_bad_alloc(); #endif - -FOLLY_NAMESPACE_STD_END +} #endif diff --git a/folly/portability/Builtins.h b/folly/portability/Builtins.h old mode 100755 new mode 100644 index 932d9c40..817d1add --- a/folly/portability/Builtins.h +++ b/folly/portability/Builtins.h @@ -43,7 +43,7 @@ FOLLY_ALWAYS_INLINE void __builtin___clear_cache(char* begin, char* end) { FOLLY_ALWAYS_INLINE int __builtin_clz(unsigned int x) { unsigned long index; - return (int)(_BitScanReverse(&index, (unsigned long)x) ? 31 - index : 32); + return int(_BitScanReverse(&index, (unsigned long)x) ? 31 - index : 32); } FOLLY_ALWAYS_INLINE int __builtin_clzl(unsigned long x) { @@ -52,28 +52,30 @@ FOLLY_ALWAYS_INLINE int __builtin_clzl(unsigned long x) { FOLLY_ALWAYS_INLINE int __builtin_clzll(unsigned long long x) { unsigned long index; - return (int)(_BitScanReverse64(&index, x) ? 63 - index : 64); + return int(_BitScanReverse64(&index, x) ? 63 - index : 64); } FOLLY_ALWAYS_INLINE int __builtin_ctzll(unsigned long long x) { unsigned long index; - return (int)(_BitScanForward64(&index, x) ? index : 64); + return int(_BitScanForward64(&index, x) ? index : 64); } FOLLY_ALWAYS_INLINE int __builtin_ffs(int x) { unsigned long index; - return (int)(_BitScanForward(&index, (unsigned long)x) ? index + 1 : 0); + return int(_BitScanForward(&index, (unsigned long)x) ? index + 1 : 0); } -FOLLY_ALWAYS_INLINE int __builtin_ffsl(long x) { return __builtin_ffs((int)x); } +FOLLY_ALWAYS_INLINE int __builtin_ffsl(long x) { + return __builtin_ffs(int(x)); +} FOLLY_ALWAYS_INLINE int __builtin_ffsll(long long x) { unsigned long index; - return (int)(_BitScanForward64(&index, (unsigned long long)x) ? index + 1 : 0); + return int(_BitScanForward64(&index, (unsigned long long)x) ? index + 1 : 0); } FOLLY_ALWAYS_INLINE int __builtin_popcountll(unsigned long long x) { - return (int)__popcnt64(x); + return int(__popcnt64(x)); } FOLLY_ALWAYS_INLINE void* __builtin_return_address(unsigned int frame) { diff --git a/folly/portability/Constexpr.h b/folly/portability/Constexpr.h old mode 100755 new mode 100644 index 2813194b..4d99b621 --- a/folly/portability/Constexpr.h +++ b/folly/portability/Constexpr.h @@ -87,8 +87,9 @@ template constexpr size_t constexpr_strlen_internal(const Char* s, size_t len) { return *s == Char(0) ? len : constexpr_strlen_internal(s + 1, len + 1); } -static_assert(constexpr_strlen_internal("123456789", 0) == 9, - "Someone appears to have broken constexpr_strlen..."); +static_assert( + constexpr_strlen_internal("123456789", 0) == 9, + "Someone appears to have broken constexpr_strlen..."); } // namespace detail template diff --git a/folly/portability/Event.h b/folly/portability/Event.h index 9adb7786..1d6fe86a 100644 --- a/folly/portability/Event.h +++ b/folly/portability/Event.h @@ -18,14 +18,14 @@ #ifdef _MSC_VER // This needs to be before the libevent include. -# include +#include #endif #include #ifdef _MSC_VER -# include -# include +#include +#include #endif namespace folly { diff --git a/folly/portability/Fcntl.cpp b/folly/portability/Fcntl.cpp old mode 100755 new mode 100644 index 60e59fc5..30bab8fb --- a/folly/portability/Fcntl.cpp +++ b/folly/portability/Fcntl.cpp @@ -24,7 +24,9 @@ namespace folly { namespace portability { namespace fcntl { -int creat(char const* fn, int pm) { return _creat(fn, pm); } +int creat(char const* fn, int pm) { + return _creat(fn, pm); +} int fcntl(int fd, int cmd, ...) { va_list args; diff --git a/folly/portability/Memory.cpp b/folly/portability/Memory.cpp index c4a0fff3..ca138c03 100644 --- a/folly/portability/Memory.cpp +++ b/folly/portability/Memory.cpp @@ -23,10 +23,11 @@ namespace folly { namespace detail { -#if _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600 || \ - (defined(__ANDROID__) && (__ANDROID_API__ > 15)) || \ - (defined(__APPLE__) && (__MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_6 || \ - __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_3_0)) +#if _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600 || \ + (defined(__ANDROID__) && (__ANDROID_API__ > 15)) || \ + (defined(__APPLE__) && \ + (__MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_6 || \ + __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_3_0)) // Use posix_memalign, but mimic the behaviour of memalign void* aligned_malloc(size_t size, size_t align) { diff --git a/folly/portability/OpenSSL.cpp b/folly/portability/OpenSSL.cpp index 53b020c7..fb47df42 100644 --- a/folly/portability/OpenSSL.cpp +++ b/folly/portability/OpenSSL.cpp @@ -174,7 +174,6 @@ void HMAC_CTX_free(HMAC_CTX* ctx) { } #endif - } } } diff --git a/folly/portability/OpenSSL.h b/folly/portability/OpenSSL.h index a75b015b..38ebc8e7 100644 --- a/folly/portability/OpenSSL.h +++ b/folly/portability/OpenSSL.h @@ -47,37 +47,37 @@ // OPENSSL_VERSION_NUMBER to maintain compatibility. The following variables are // intended to be specific to OpenSSL. #if !defined(OPENSSL_IS_BORINGSSL) -# define FOLLY_OPENSSL_IS_100 \ +#define FOLLY_OPENSSL_IS_100 \ (OPENSSL_VERSION_NUMBER >= 0x10000003L && \ OPENSSL_VERSION_NUMBER < 0x1000105fL) -# define FOLLY_OPENSSL_IS_101 \ +#define FOLLY_OPENSSL_IS_101 \ (OPENSSL_VERSION_NUMBER >= 0x1000105fL && \ OPENSSL_VERSION_NUMBER < 0x1000200fL) -# define FOLLY_OPENSSL_IS_102 \ +#define FOLLY_OPENSSL_IS_102 \ (OPENSSL_VERSION_NUMBER >= 0x1000200fL && \ OPENSSL_VERSION_NUMBER < 0x10100000L) -# define FOLLY_OPENSSL_IS_110 (OPENSSL_VERSION_NUMBER >= 0x10100000L) +#define FOLLY_OPENSSL_IS_110 (OPENSSL_VERSION_NUMBER >= 0x10100000L) #endif -#if !OPENSSL_IS_BORINGSSL && !FOLLY_OPENSSL_IS_100 && !FOLLY_OPENSSL_IS_101 \ - && !FOLLY_OPENSSL_IS_102 && !FOLLY_OPENSSL_IS_110 -# warning Compiling with unsupported OpenSSL version +#if !OPENSSL_IS_BORINGSSL && !FOLLY_OPENSSL_IS_100 && !FOLLY_OPENSSL_IS_101 && \ + !FOLLY_OPENSSL_IS_102 && !FOLLY_OPENSSL_IS_110 +#warning Compiling with unsupported OpenSSL version #endif // BoringSSL and OpenSSL 0.9.8f later with TLS extension support SNI. -#if OPENSSL_IS_BORINGSSL || \ +#if OPENSSL_IS_BORINGSSL || \ (OPENSSL_VERSION_NUMBER >= 0x00908070L && !defined(OPENSSL_NO_TLSEXT)) -# define FOLLY_OPENSSL_HAS_SNI 1 +#define FOLLY_OPENSSL_HAS_SNI 1 #else -# define FOLLY_OPENSSL_HAS_SNI 0 +#define FOLLY_OPENSSL_HAS_SNI 0 #endif // BoringSSL and OpenSSL 1.0.2 later with TLS extension support ALPN. -#if OPENSSL_IS_BORINGSSL || \ +#if OPENSSL_IS_BORINGSSL || \ (OPENSSL_VERSION_NUMBER >= 0x1000200fL && !defined(OPENSSL_NO_TLSEXT)) -# define FOLLY_OPENSSL_HAS_ALPN 1 +#define FOLLY_OPENSSL_HAS_ALPN 1 #else -# define FOLLY_OPENSSL_HAS_ALPN 0 +#define FOLLY_OPENSSL_HAS_ALPN 0 #endif // This attempts to "unify" the OpenSSL libcrypto/libssl APIs between @@ -138,7 +138,6 @@ STACK_OF(X509) * X509_STORE_CTX_get0_untrusted(X509_STORE_CTX* ctx); // minor version upgrade will need to remove this #define OPENSSL_lh_new OPENSSL_LH_new #endif - } } } diff --git a/folly/portability/Sockets.cpp b/folly/portability/Sockets.cpp old mode 100755 new mode 100644 index b5f0b7d5..db1c2fb1 --- a/folly/portability/Sockets.cpp +++ b/folly/portability/Sockets.cpp @@ -37,7 +37,9 @@ static struct FSPInit { WSADATA dat; WSAStartup(MAKEWORD(2, 2), &dat); } - ~FSPInit() { WSACleanup(); } + ~FSPInit() { + WSACleanup(); + } } fspInit; bool is_fh_socket(int fh) { @@ -271,7 +273,9 @@ ssize_t recvmsg(int s, struct msghdr* message, int /* flags */) { msg.dwFlags = 0; msg.dwBufferCount = (DWORD)message->msg_iovlen; msg.lpBuffers = new WSABUF[message->msg_iovlen]; - SCOPE_EXIT { delete[] msg.lpBuffers; }; + SCOPE_EXIT { + delete[] msg.lpBuffers; + }; for (size_t i = 0; i < message->msg_iovlen; i++) { msg.lpBuffers[i].buf = (CHAR*)message->msg_iov[i].iov_base; msg.lpBuffers[i].len = (ULONG)message->msg_iov[i].iov_len; diff --git a/folly/portability/Stdio.cpp b/folly/portability/Stdio.cpp old mode 100755 new mode 100644 index 4b3c664b..41da526e --- a/folly/portability/Stdio.cpp +++ b/folly/portability/Stdio.cpp @@ -17,7 +17,9 @@ #include #ifdef _WIN32 + #include + #include #include @@ -25,7 +27,9 @@ extern "C" { int dprintf(int fd, const char* fmt, ...) { va_list args; va_start(args, fmt); - SCOPE_EXIT { va_end(args); }; + SCOPE_EXIT { + va_end(args); + }; int ret = vsnprintf(nullptr, 0, fmt, args); if (ret <= 0) { @@ -33,7 +37,9 @@ int dprintf(int fd, const char* fmt, ...) { } size_t len = size_t(ret); char* buf = new char[len + 1]; - SCOPE_EXIT { delete[] buf; }; + SCOPE_EXIT { + delete[] buf; + }; if (size_t(vsnprintf(buf, len + 1, fmt, args)) == len && write(fd, buf, len) == ssize_t(len)) { return ret; @@ -42,9 +48,13 @@ int dprintf(int fd, const char* fmt, ...) { return -1; } -int pclose(FILE* f) { return _pclose(f); } +int pclose(FILE* f) { + return _pclose(f); +} -FILE* popen(const char* name, const char* mode) { return _popen(name, mode); } +FILE* popen(const char* name, const char* mode) { + return _popen(name, mode); +} void setbuffer(FILE* f, char* buf, size_t size) { setvbuf(f, buf, _IOFBF, size); @@ -63,4 +73,5 @@ int vasprintf(char** dest, const char* format, va_list ap) { return -1; } } + #endif diff --git a/folly/portability/Stdlib.cpp b/folly/portability/Stdlib.cpp index e790a3ea..55895673 100644 --- a/folly/portability/Stdlib.cpp +++ b/folly/portability/Stdlib.cpp @@ -17,7 +17,9 @@ #include #ifdef _WIN32 + #include + #include #include @@ -25,7 +27,9 @@ #include extern "C" { -char* mktemp(char* tn) { return _mktemp(tn); } +char* mktemp(char* tn) { + return _mktemp(tn); +} // While yes, this is for a directory, due to this being windows, // a file and directory can't have the same name, resulting in this @@ -135,9 +139,11 @@ int unsetenv(const char* name) { return 0; } } + #endif #if !__linux__ && !FOLLY_MOBILE + #include #include @@ -162,4 +168,5 @@ extern "C" int clearenv() { return 0; } + #endif diff --git a/folly/portability/String.h b/folly/portability/String.h old mode 100755 new mode 100644 index fc7e85a3..02d24185 --- a/folly/portability/String.h +++ b/folly/portability/String.h @@ -16,8 +16,8 @@ #pragma once -#include #include +#include #include diff --git a/folly/portability/SysMman.cpp b/folly/portability/SysMman.cpp old mode 100755 new mode 100644 index cc248073..af76d8bb --- a/folly/portability/SysMman.cpp +++ b/folly/portability/SysMman.cpp @@ -17,7 +17,9 @@ #include #ifdef _WIN32 + #include + #include #include @@ -213,4 +215,5 @@ int munmap(void* addr, size_t length) { return 0; } } + #endif diff --git a/folly/portability/SysMman.h b/folly/portability/SysMman.h old mode 100755 new mode 100644 index 7522a417..3f305470 --- a/folly/portability/SysMman.h +++ b/folly/portability/SysMman.h @@ -17,16 +17,20 @@ #pragma once #ifndef _WIN32 + #include // MAP_ANONYMOUS is named MAP_ANON on OSX/BSD. #if defined(__APPLE__) || defined(__FreeBSD__) -# if !defined(MAP_ANONYMOUS) && defined(MAP_ANON) -# define MAP_ANONYMOUS MAP_ANON -# endif +#if !defined(MAP_ANONYMOUS) && defined(MAP_ANON) +#define MAP_ANONYMOUS MAP_ANON +#endif #endif + #else + #include + #include #define MAP_ANONYMOUS 1 @@ -56,4 +60,5 @@ int mprotect(void* addr, size_t size, int prot); int munlock(const void* addr, size_t length); int munmap(void* addr, size_t length); } + #endif diff --git a/folly/portability/SysStat.cpp b/folly/portability/SysStat.cpp old mode 100755 new mode 100644 index 8efb001b..50415940 --- a/folly/portability/SysStat.cpp +++ b/folly/portability/SysStat.cpp @@ -20,7 +20,9 @@ #include extern "C" { -int chmod(char const* fn, int am) { return _chmod(fn, am); } +int chmod(char const* fn, int am) { + return _chmod(fn, am); +} int fchmod(int fd, mode_t mode) { HANDLE h = (HANDLE)_get_osfhandle(fd); @@ -49,12 +51,16 @@ int fchmod(int fd, mode_t mode) { } // Just return the result of a normal stat for now -int lstat(const char* path, struct stat* st) { return stat(path, st); } +int lstat(const char* path, struct stat* st) { + return stat(path, st); +} int mkdir(const char* fn, int /* mode */) { return _mkdir(fn); } -int umask(int md) { return _umask(md); } +int umask(int md) { + return _umask(md); +} } #endif diff --git a/folly/portability/SysStat.h b/folly/portability/SysStat.h old mode 100755 new mode 100644 index 89acc45c..39571082 --- a/folly/portability/SysStat.h +++ b/folly/portability/SysStat.h @@ -35,7 +35,7 @@ #define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR) #define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP) -#define S_ISDIR(mode) (((mode) & _S_IFDIR) == _S_IFDIR ? 1 : 0) +#define S_ISDIR(mode) (((mode) & (_S_IFDIR)) == (_S_IFDIR) ? 1 : 0) // This isn't defined anywhere, so give a sane value. #define MAXSYMLINKS 255 diff --git a/folly/portability/SysTime.cpp b/folly/portability/SysTime.cpp old mode 100755 new mode 100644 index b9a9f042..48b343f4 --- a/folly/portability/SysTime.cpp +++ b/folly/portability/SysTime.cpp @@ -17,7 +17,9 @@ #include #ifdef _WIN32 + #include + #include extern "C" { @@ -58,4 +60,5 @@ void timersub(timeval* a, timeval* b, timeval* res) { } } } + #endif diff --git a/folly/portability/SysUio.cpp b/folly/portability/SysUio.cpp old mode 100755 new mode 100644 index 54f7202c..9a80d27c --- a/folly/portability/SysUio.cpp +++ b/folly/portability/SysUio.cpp @@ -73,7 +73,9 @@ static ssize_t doVecOperation(int fd, const iovec* iov, int count) { if (lockf(fd, F_LOCK, 0) == -1) { return -1; } - SCOPE_EXIT { lockf(fd, F_ULOCK, 0); }; + SCOPE_EXIT { + lockf(fd, F_ULOCK, 0); + }; ssize_t bytesProcessed = 0; int curIov = 0; diff --git a/folly/portability/Time.cpp b/folly/portability/Time.cpp old mode 100755 new mode 100644 index cb644929..54b3d0a1 --- a/folly/portability/Time.cpp +++ b/folly/portability/Time.cpp @@ -325,9 +325,10 @@ int nanosleep(const struct timespec* request, struct timespec* remain) { return 0; } -char* strptime(const char* __restrict s, - const char* __restrict f, - struct tm* __restrict tm) { +char* strptime( + const char* __restrict s, + const char* __restrict f, + struct tm* __restrict tm) { // Isn't the C++ standard lib nice? std::get_time is defined such that its // format parameters are the exact same as strptime. Of course, we have to // create a string stream first, and imbue it with the current C locale, and diff --git a/folly/portability/Time.h b/folly/portability/Time.h old mode 100755 new mode 100644 index 0ed24a27..eb6c7941 --- a/folly/portability/Time.h +++ b/folly/portability/Time.h @@ -27,16 +27,16 @@ // solve that by pretending we have it here in the header and // then enable our implementation on the source side so that // gets linked in instead. -#if __MACH__ && ( \ - MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12 || \ - __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_10_0) +#if __MACH__ && \ + (MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12 || \ + __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_10_0) -# ifdef FOLLY_HAVE_CLOCK_GETTIME -# undef FOLLY_HAVE_CLOCK_GETTIME -# endif +#ifdef FOLLY_HAVE_CLOCK_GETTIME +#undef FOLLY_HAVE_CLOCK_GETTIME +#endif -# define FOLLY_HAVE_CLOCK_GETTIME 1 -# define FOLLY_FORCE_CLOCK_GETTIME_DEFINITION 1 +#define FOLLY_HAVE_CLOCK_GETTIME 1 +#define FOLLY_FORCE_CLOCK_GETTIME_DEFINITION 1 #endif @@ -62,8 +62,9 @@ char* ctime_r(const time_t* t, char* buf); tm* gmtime_r(const time_t* t, tm* res); tm* localtime_r(const time_t* t, tm* o); int nanosleep(const struct timespec* request, struct timespec* remain); -char* strptime(const char* __restrict buf, - const char* __restrict fmt, - struct tm* __restrict tm); +char* strptime( + const char* __restrict buf, + const char* __restrict fmt, + struct tm* __restrict tm); } #endif diff --git a/folly/portability/Unistd.cpp b/folly/portability/Unistd.cpp old mode 100755 new mode 100644 index a587ba6a..24652914 --- a/folly/portability/Unistd.cpp +++ b/folly/portability/Unistd.cpp @@ -21,8 +21,11 @@ #include #ifdef _WIN32 + #include + #include + #include #include @@ -60,9 +63,13 @@ static int wrapPositional(F f, int fd, off_t offset, Args... args) { namespace folly { namespace portability { namespace unistd { -int access(char const* fn, int am) { return _access(fn, am); } +int access(char const* fn, int am) { + return _access(fn, am); +} -int chdir(const char* path) { return _chdir(path); } +int chdir(const char* path) { + return _chdir(path); +} int close(int fh) { if (folly::portability::sockets::is_fh_socket(fh)) { @@ -111,9 +118,13 @@ int close(int fh) { return _close(fh); } -int dup(int fh) { return _dup(fh); } +int dup(int fh) { + return _dup(fh); +} -int dup2(int fhs, int fhd) { return _dup2(fhs, fhd); } +int dup2(int fhs, int fhd) { + return _dup2(fhs, fhd); +} int fsync(int fd) { HANDLE h = (HANDLE)_get_osfhandle(fd); @@ -141,29 +152,47 @@ int ftruncate(int fd, off_t len) { return 0; } -char* getcwd(char* buf, int sz) { return _getcwd(buf, sz); } +char* getcwd(char* buf, int sz) { + return _getcwd(buf, sz); +} -int getdtablesize() { return _getmaxstdio(); } +int getdtablesize() { + return _getmaxstdio(); +} -int getgid() { return 1; } +int getgid() { + return 1; +} -pid_t getpid() { return (pid_t)uint64_t(GetCurrentProcessId()); } +pid_t getpid() { + return (pid_t)uint64_t(GetCurrentProcessId()); +} // No major need to implement this, and getting a non-potentially // stale ID on windows is a bit involved. -pid_t getppid() { return (pid_t)1; } +pid_t getppid() { + return (pid_t)1; +} -int getuid() { return 1; } +int getuid() { + return 1; +} -int isatty(int fh) { return _isatty(fh); } +int isatty(int fh) { + return _isatty(fh); +} -int lockf(int fd, int cmd, off_t len) { return _locking(fd, cmd, len); } +int lockf(int fd, int cmd, off_t len) { + return _locking(fd, cmd, len); +} off_t lseek(int fh, off_t off, int orig) { return _lseek(fh, off, orig); } -int rmdir(const char* path) { return _rmdir(path); } +int rmdir(const char* path) { + return _rmdir(path); +} int pipe(int pth[2]) { // We need to be able to listen to pipes with @@ -306,4 +335,5 @@ ssize_t write(int fh, void const* buf, size_t count) { } } } + #endif diff --git a/folly/portability/Unistd.h b/folly/portability/Unistd.h old mode 100755 new mode 100644 index 8cbae7a6..b4cd106a --- a/folly/portability/Unistd.h +++ b/folly/portability/Unistd.h @@ -17,10 +17,15 @@ #pragma once #ifndef _WIN32 + #include + #else + #include + #include + #include // This is different from the normal headers because there are a few cases, @@ -86,4 +91,5 @@ ssize_t write(int fh, void const* buf, size_t count); } /* using override */ using namespace folly::portability::unistd; + #endif diff --git a/folly/portability/Windows.h b/folly/portability/Windows.h old mode 100755 new mode 100644 index 7ccfde8c..2402bf1f --- a/folly/portability/Windows.h +++ b/folly/portability/Windows.h @@ -29,12 +29,12 @@ #ifndef __STDC__ /* nolint */ #define __STDC__ 1 -#include // nolint #include // nolint +#include // nolint #undef __STDC__ #else -#include // nolint #include // nolint +#include // nolint #endif #if defined(min) || defined(max) diff --git a/folly/portability/test/TimeTest.cpp b/folly/portability/test/TimeTest.cpp index 50aa1cba..b5541d54 100644 --- a/folly/portability/test/TimeTest.cpp +++ b/folly/portability/test/TimeTest.cpp @@ -16,8 +16,8 @@ #include -#include #include +#include #include -- 2.34.1