зеркало из https://github.com/mozilla/gecko-dev.git
Bug 860827 - Move TEMP_FAILURE_RETRY to FileUtils.h and rename it. r=tbsaunde
This commit is contained in:
Родитель
5feea46ee3
Коммит
793356fe8f
|
@ -119,22 +119,13 @@ mozilla::fallocate(PRFileDesc *aFD, int64_t aLength)
|
|||
|
||||
#ifdef ReadSysFile_PRESENT
|
||||
|
||||
#undef TEMP_FAILURE_RETRY
|
||||
#define TEMP_FAILURE_RETRY(exp) (__extension__({ \
|
||||
typeof (exp) _rc; \
|
||||
do { \
|
||||
_rc = (exp); \
|
||||
} while (_rc == -1 && errno == EINTR); \
|
||||
_rc; \
|
||||
}))
|
||||
|
||||
bool
|
||||
mozilla::ReadSysFile(
|
||||
const char* aFilename,
|
||||
char* aBuf,
|
||||
size_t aBufSize)
|
||||
{
|
||||
int fd = TEMP_FAILURE_RETRY(open(aFilename, O_RDONLY));
|
||||
int fd = MOZ_TEMP_FAILURE_RETRY(open(aFilename, O_RDONLY));
|
||||
if (fd < 0) {
|
||||
return false;
|
||||
}
|
||||
|
@ -145,7 +136,8 @@ mozilla::ReadSysFile(
|
|||
ssize_t bytesRead;
|
||||
size_t offset = 0;
|
||||
do {
|
||||
bytesRead = TEMP_FAILURE_RETRY(read(fd, aBuf + offset, aBufSize - offset));
|
||||
bytesRead = MOZ_TEMP_FAILURE_RETRY(
|
||||
read(fd, aBuf + offset, aBufSize - offset));
|
||||
if (bytesRead == -1) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -154,6 +154,14 @@ and run in non-GONK builds. */
|
|||
#define ReadSysFile_PRESENT
|
||||
#endif /* ReadSysFile_PRESENT */
|
||||
|
||||
#define MOZ_TEMP_FAILURE_RETRY(exp) (__extension__({ \
|
||||
typeof (exp) _rc; \
|
||||
do { \
|
||||
_rc = (exp); \
|
||||
} while (_rc == -1 && errno == EINTR); \
|
||||
_rc; \
|
||||
}))
|
||||
|
||||
/**
|
||||
* Read the contents of a file.
|
||||
* This function is intended for reading a single-lined text files from
|
||||
|
|
|
@ -35,7 +35,7 @@ WriteFile(
|
|||
ssize_t ret;
|
||||
size_t offt;
|
||||
|
||||
fd = TEMP_FAILURE_RETRY(
|
||||
fd = MOZ_TEMP_FAILURE_RETRY(
|
||||
open(aFilename, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR));
|
||||
if (fd == -1) {
|
||||
fprintf(stderr, "open(): %s: %s\n", aFilename, strerror(errno));
|
||||
|
@ -44,7 +44,8 @@ WriteFile(
|
|||
|
||||
offt = 0;
|
||||
do {
|
||||
ret = TEMP_FAILURE_RETRY(write(fd, (char*)aContents + offt, aContentsLen - offt));
|
||||
ret = MOZ_TEMP_FAILURE_RETRY(
|
||||
write(fd, (char*)aContents + offt, aContentsLen - offt));
|
||||
if (ret == -1) {
|
||||
fprintf(stderr, "write(): %s: %s\n", aFilename, strerror(errno));
|
||||
close(fd);
|
||||
|
@ -53,7 +54,7 @@ WriteFile(
|
|||
offt += ret;
|
||||
} while (offt < aContentsLen);
|
||||
|
||||
ret = TEMP_FAILURE_RETRY(close(fd));
|
||||
ret = MOZ_TEMP_FAILURE_RETRY(close(fd));
|
||||
if (ret == -1) {
|
||||
fprintf(stderr, "close(): %s: %s\n", aFilename, strerror(errno));
|
||||
return false;
|
||||
|
|
Загрузка…
Ссылка в новой задаче