projects
/
folly.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Remove global init of ThreadLocal in Random
[folly.git]
/
folly
/
FileUtil.cpp
diff --git
a/folly/FileUtil.cpp
b/folly/FileUtil.cpp
index 393f54081907680578d44f517549a5267e4d766d..a452644ecf15a67a1fef96322d213de7a4ec3f73 100644
(file)
--- a/
folly/FileUtil.cpp
+++ b/
folly/FileUtil.cpp
@@
-1,5
+1,5
@@
/*
/*
- * Copyright 201
3
Facebook, Inc.
+ * Copyright 201
4
Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@
-14,11
+14,16
@@
* limitations under the License.
*/
* limitations under the License.
*/
-#include
"folly/FileUtil.h"
+#include
<folly/FileUtil.h>
#include <cerrno>
#include <cerrno>
+#ifdef __APPLE__
+#include <fcntl.h>
+#endif
+#include <sys/file.h>
+#include <sys/socket.h>
-#include
"folly/detail/FileUtilDetail.h"
+#include
<folly/detail/FileUtilDetail.h>
namespace folly {
namespace folly {
@@
-38,7
+43,7
@@
int closeNoInt(int fd) {
// Interestingly enough, the Single Unix Specification says that the state
// of the file descriptor is unspecified if close returns EINTR. In that
// case, the safe thing to do is also not to retry close() -- leaking a file
// Interestingly enough, the Single Unix Specification says that the state
// of the file descriptor is unspecified if close returns EINTR. In that
// case, the safe thing to do is also not to retry close() -- leaking a file
- // descriptor is
probab
ly better than closing the wrong file.
+ // descriptor is
definite
ly better than closing the wrong file.
if (r == -1 && errno == EINTR) {
r = 0;
}
if (r == -1 && errno == EINTR) {
r = 0;
}
@@
-49,8
+54,22
@@
int fsyncNoInt(int fd) {
return wrapNoInt(fsync, fd);
}
return wrapNoInt(fsync, fd);
}
+int dupNoInt(int fd) {
+ return wrapNoInt(dup, fd);
+}
+
+int dup2NoInt(int oldfd, int newfd) {
+ return wrapNoInt(dup2, oldfd, newfd);
+}
+
int fdatasyncNoInt(int fd) {
int fdatasyncNoInt(int fd) {
+#if defined(__APPLE__)
+ return wrapNoInt(fcntl, fd, F_FULLFSYNC);
+#elif defined(__FreeBSD__)
+ return wrapNoInt(fsync, fd);
+#else
return wrapNoInt(fdatasync, fd);
return wrapNoInt(fdatasync, fd);
+#endif
}
int ftruncateNoInt(int fd, off_t len) {
}
int ftruncateNoInt(int fd, off_t len) {
@@
-61,6
+80,14
@@
int truncateNoInt(const char* path, off_t len) {
return wrapNoInt(truncate, path, len);
}
return wrapNoInt(truncate, path, len);
}
+int flockNoInt(int fd, int operation) {
+ return wrapNoInt(flock, fd, operation);
+}
+
+int shutdownNoInt(int fd, int how) {
+ return wrapNoInt(shutdown, fd, how);
+}
+
ssize_t readNoInt(int fd, void* buf, size_t count) {
return wrapNoInt(read, fd, buf, count);
}
ssize_t readNoInt(int fd, void* buf, size_t count) {
return wrapNoInt(read, fd, buf, count);
}
@@
-105,7
+132,7
@@
ssize_t readvFull(int fd, iovec* iov, int count) {
return wrapvFull(readv, fd, iov, count);
}
return wrapvFull(readv, fd, iov, count);
}
-#if
def
FOLLY_HAVE_PREADV
+#if FOLLY_HAVE_PREADV
ssize_t preadvFull(int fd, iovec* iov, int count, off_t offset) {
return wrapvFull(preadv, fd, iov, count, offset);
}
ssize_t preadvFull(int fd, iovec* iov, int count, off_t offset) {
return wrapvFull(preadv, fd, iov, count, offset);
}
@@
-115,11
+142,10
@@
ssize_t writevFull(int fd, iovec* iov, int count) {
return wrapvFull(writev, fd, iov, count);
}
return wrapvFull(writev, fd, iov, count);
}
-#if
def
FOLLY_HAVE_PWRITEV
+#if FOLLY_HAVE_PWRITEV
ssize_t pwritevFull(int fd, iovec* iov, int count, off_t offset) {
return wrapvFull(pwritev, fd, iov, count, offset);
}
#endif
} // namespaces
ssize_t pwritevFull(int fd, iovec* iov, int count, off_t offset) {
return wrapvFull(pwritev, fd, iov, count, offset);
}
#endif
} // namespaces
-