constexpr_ceil
[folly.git] / folly / portability / Unistd.cpp
old mode 100755 (executable)
new mode 100644 (file)
index 32e01f1..ff582ed
 #include <folly/portability/Unistd.h>
 
 #ifdef _WIN32
+
 #include <cstdio>
+
 #include <fcntl.h>
+
 #include <folly/portability/Sockets.h>
 #include <folly/portability/Windows.h>
 
 // Including ntdef.h requires building as a driver, but all we want
 // is a status code, but we need NTSTATUS defined for that. Luckily
 // bcrypt.h also defines NTSTATUS, so we'll use that one instead.
-#include <bcrypt.h>
-#include <ntstatus.h>
+#include <bcrypt.h> // @manual
+#include <ntstatus.h> // @manual
 
 // Generic wrapper for the p* family of functions.
 template <class F, class... Args>
@@ -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
@@ -205,13 +234,14 @@ ssize_t readlink(const char* path, char* buf, size_t buflen) {
     return -1;
   }
 
-  HANDLE h = CreateFile(path,
-                        GENERIC_READ,
-                        FILE_SHARE_READ,
-                        nullptr,
-                        OPEN_EXISTING,
-                        FILE_FLAG_BACKUP_SEMANTICS,
-                        nullptr);
+  HANDLE h = CreateFileA(
+      path,
+      GENERIC_READ,
+      FILE_SHARE_READ,
+      nullptr,
+      OPEN_EXISTING,
+      FILE_FLAG_BACKUP_SEMANTICS,
+      nullptr);
   if (h == INVALID_HANDLE_VALUE) {
     return -1;
   }
@@ -228,7 +258,9 @@ ssize_t readlink(const char* path, char* buf, size_t buflen) {
   return ret;
 }
 
-void* sbrk(intptr_t i) { return (void*)-1; }
+void* sbrk(intptr_t /* i */) {
+  return (void*)-1;
+}
 
 unsigned int sleep(unsigned int seconds) {
   Sleep((DWORD)(seconds * 1000));
@@ -303,4 +335,5 @@ ssize_t write(int fh, void const* buf, size_t count) {
 }
 }
 }
+
 #endif