Correct the API of some functions in the portability headers
authorChristopher Dykes <cdykes@fb.com>
Thu, 2 Feb 2017 01:22:36 +0000 (17:22 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Thu, 2 Feb 2017 01:32:56 +0000 (17:32 -0800)
Summary: They were based on the signatures of the original functions as defined by MSVC. They should be based on the signatures as defined by Posix instead.

Reviewed By: yfeldblum

Differential Revision: D4471711

fbshipit-source-id: 8a6fd60ba2b326ca57058c119fc77c46f1d21d10

folly/portability/Unistd.cpp
folly/portability/Unistd.h

index 741be705a3e7f003062002f02f41164dfe5f0105..32e01f1f00aef2ae4a5064a7dc1f7cd4212f17ac 100755 (executable)
@@ -159,7 +159,9 @@ int isatty(int fh) { return _isatty(fh); }
 
 int lockf(int fd, int cmd, off_t len) { return _locking(fd, cmd, len); }
 
-long lseek(int fh, long off, int orig) { return _lseek(fh, off, orig); }
+off_t lseek(int fh, off_t off, int orig) {
+  return _lseek(fh, off, orig);
+}
 
 int rmdir(const char* path) { return _rmdir(path); }
 
@@ -169,11 +171,11 @@ int pipe(int pth[2]) {
   return socketpair(PF_UNIX, SOCK_STREAM, 0, pth);
 }
 
-int pread(int fd, void* buf, size_t count, off_t offset) {
+ssize_t pread(int fd, void* buf, size_t count, off_t offset) {
   return wrapPositional(_read, fd, offset, buf, (unsigned int)count);
 }
 
-int pwrite(int fd, const void* buf, size_t count, off_t offset) {
+ssize_t pwrite(int fd, const void* buf, size_t count, off_t offset) {
   return wrapPositional(_write, fd, offset, buf, (unsigned int)count);
 }
 
@@ -228,8 +230,6 @@ ssize_t readlink(const char* path, char* buf, size_t buflen) {
 
 void* sbrk(intptr_t i) { return (void*)-1; }
 
-int setmode(int fh, int md) { return _setmode(fh, md); }
-
 unsigned int sleep(unsigned int seconds) {
   Sleep((DWORD)(seconds * 1000));
   return 0;
@@ -252,8 +252,6 @@ long sysconf(int tp) {
   }
 }
 
-long tell(int fh) { return _tell(fh); }
-
 int truncate(const char* path, off_t len) {
   int fd = _open(path, O_WRONLY);
   if (!fd) {
index 4d4548e0fefa5d7229a1e2f6d8ac25b84189ca5c..8cbae7a6cd337b7d1d95bae1cd7cf7d486fd0fe8 100755 (executable)
@@ -68,18 +68,16 @@ pid_t getppid();
 int getuid();
 int isatty(int fh);
 int lockf(int fd, int cmd, off_t len);
-long lseek(int fh, long off, int orig);
+off_t lseek(int fh, off_t off, int orig);
 ssize_t read(int fh, void* buf, size_t mcc);
 int rmdir(const char* path);
 int pipe(int pth[2]);
-int pread(int fd, void* buf, size_t count, off_t offset);
-int pwrite(int fd, const void* buf, size_t count, off_t offset);
+ssize_t pread(int fd, void* buf, size_t count, off_t offset);
+ssize_t pwrite(int fd, const void* buf, size_t count, off_t offset);
 ssize_t readlink(const char* path, char* buf, size_t buflen);
-int setmode(int fh, int md);
 void* sbrk(intptr_t i);
 unsigned int sleep(unsigned int seconds);
 long sysconf(int tp);
-long tell(int fh);
 int truncate(const char* path, off_t len);
 int usleep(unsigned int ms);
 ssize_t write(int fh, void const* buf, size_t count);