From 5421943db76f354ad49b93f58dfaba89908e592e Mon Sep 17 00:00:00 2001 From: guangli-dai Date: Thu, 30 Jul 2026 09:51:53 -0700 Subject: [PATCH] Add comments to retain context for syscall usage in file read/write. --- include/jemalloc/internal/os/posix/file.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/jemalloc/internal/os/posix/file.h b/include/jemalloc/internal/os/posix/file.h index 5a67c952..a3886fbc 100644 --- a/include/jemalloc/internal/os/posix/file.h +++ b/include/jemalloc/internal/os/posix/file.h @@ -14,6 +14,14 @@ JEMALLOC_ALWAYS_INLINE ssize_t os_file_write_once(int fd, const void *buf, size_t bytes) { #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 + * result in the widest plausible type to avoid compiler warnings. + */ return (ssize_t)syscall(SYS_write, fd, buf, bytes); #else return (ssize_t)write(fd, buf, bytes);