From: Christopher Dykes Date: Thu, 2 Feb 2017 01:22:36 +0000 (-0800) Subject: Correct the API of some functions in the portability headers X-Git-Tag: v2017.03.06.00~61 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=23688fa8212bbf501f126cc4952d57e0480c5371;p=folly.git Correct the API of some functions in the portability headers 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 --- diff --git a/folly/portability/Unistd.cpp b/folly/portability/Unistd.cpp index 741be705..32e01f1f 100755 --- a/folly/portability/Unistd.cpp +++ b/folly/portability/Unistd.cpp @@ -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) { diff --git a/folly/portability/Unistd.h b/folly/portability/Unistd.h index 4d4548e0..8cbae7a6 100755 --- a/folly/portability/Unistd.h +++ b/folly/portability/Unistd.h @@ -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);