aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQi Wang <interwq@gwu.edu>2018-04-06 11:40:44 -0700
committerQi Wang <interwq@gmail.com>2018-04-09 16:50:30 -0700
commitd3e0976a2c1591b9fe433e7a383d8825683995f0 (patch)
tree1f611f54eb6fdfb99390497572333deb14d7b905 /src
parent4df483f0fd76a64e116b1c4f316f8b941078114d (diff)
downloadplatform_external_jemalloc_new-d3e0976a2c1591b9fe433e7a383d8825683995f0.tar.gz
platform_external_jemalloc_new-d3e0976a2c1591b9fe433e7a383d8825683995f0.tar.bz2
platform_external_jemalloc_new-d3e0976a2c1591b9fe433e7a383d8825683995f0.zip
Fix type warning on Windows.
Add cast since read / write has unsigned return type on windows.
Diffstat (limited to 'src')
-rw-r--r--src/malloc_io.c15
-rw-r--r--src/pages.c15
-rw-r--r--src/prof.c7
3 files changed, 7 insertions, 30 deletions
diff --git a/src/malloc_io.c b/src/malloc_io.c
index fd27bd1c..7bdc13f9 100644
--- a/src/malloc_io.c
+++ b/src/malloc_io.c
@@ -70,20 +70,7 @@ static char *x2s(uintmax_t x, bool alt_form, bool uppercase, char *s,
/* malloc_message() setup. */
static void
wrtmessage(void *cbopaque, const char *s) {
-#if defined(JEMALLOC_USE_SYSCALL) && defined(SYS_write)
- /*
- * Use syscall(2) rather than write(2) when possible in order to avoid
- * the possibility of memory allocation within libc. This is necessary
- * on FreeBSD; most operating systems do not have this problem though.
- *
- * syscall() returns long or int, depending on platform, so capture the
- * unused result in the widest plausible type to avoid compiler
- * warnings.
- */
- UNUSED long result = syscall(SYS_write, STDERR_FILENO, s, strlen(s));
-#else
- UNUSED ssize_t result = write(STDERR_FILENO, s, strlen(s));
-#endif
+ malloc_write_fd(STDERR_FILENO, s, strlen(s));
}
JEMALLOC_EXPORT void (*je_malloc_message)(void *, const char *s);
diff --git a/src/pages.c b/src/pages.c
index 82405219..26002692 100644
--- a/src/pages.c
+++ b/src/pages.c
@@ -436,7 +436,6 @@ static bool
os_overcommits_proc(void) {
int fd;
char buf[1];
- ssize_t nread;
#if defined(JEMALLOC_USE_SYSCALL) && defined(SYS_open)
#if defined(O_CLOEXEC)
@@ -474,12 +473,7 @@ os_overcommits_proc(void) {
return false; /* Error. */
}
-#if defined(JEMALLOC_USE_SYSCALL) && defined(SYS_read)
- nread = (ssize_t)syscall(SYS_read, fd, &buf, sizeof(buf));
-#else
- nread = read(fd, &buf, sizeof(buf));
-#endif
-
+ ssize_t nread = malloc_read_fd(fd, &buf, sizeof(buf));
#if defined(JEMALLOC_USE_SYSCALL) && defined(SYS_close)
syscall(SYS_close, fd);
#else
@@ -543,12 +537,7 @@ init_thp_state(void) {
goto label_error;
}
-#if defined(JEMALLOC_USE_SYSCALL) && defined(SYS_read)
- ssize_t nread = (ssize_t)syscall(SYS_read, fd, &buf, sizeof(buf));
-#else
- ssize_t nread = read(fd, &buf, sizeof(buf));
-#endif
-
+ ssize_t nread = malloc_read_fd(fd, &buf, sizeof(buf));
#if defined(JEMALLOC_USE_SYSCALL) && defined(SYS_close)
syscall(SYS_close, fd);
#else
diff --git a/src/prof.c b/src/prof.c
index 293684ca..13df641a 100644
--- a/src/prof.c
+++ b/src/prof.c
@@ -978,7 +978,7 @@ prof_dump_flush(bool propagate_err) {
cassert(config_prof);
- err = write(prof_dump_fd, prof_dump_buf, prof_dump_buf_end);
+ err = malloc_write_fd(prof_dump_fd, prof_dump_buf, prof_dump_buf_end);
if (err == -1) {
if (!propagate_err) {
malloc_write("<jemalloc>: write() failed during heap "
@@ -1471,8 +1471,9 @@ prof_dump_maps(bool propagate_err) {
goto label_return;
}
}
- nread = read(mfd, &prof_dump_buf[prof_dump_buf_end],
- PROF_DUMP_BUFSIZE - prof_dump_buf_end);
+ nread = malloc_read_fd(mfd,
+ &prof_dump_buf[prof_dump_buf_end], PROF_DUMP_BUFSIZE
+ - prof_dump_buf_end);
} while (nread > 0);
} else {
ret = true;