mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-07-23 13:13:06 +00:00
Add malloc_open() / malloc_close() reentrancy safe helpers
This commit is contained in:
committed by
Qi Wang
parent
60f472f367
commit
8c2e15d1a5
@@ -134,4 +134,25 @@ malloc_read_fd(int fd, void *buf, size_t count) {
|
||||
return bytes_read;
|
||||
}
|
||||
|
||||
static inline int malloc_open(const char *path, int flags) {
|
||||
int fd;
|
||||
#if defined(JEMALLOC_USE_SYSCALL) && defined(SYS_open)
|
||||
fd = (int)syscall(SYS_open, path, flags);
|
||||
#elif defined(JEMALLOC_USE_SYSCALL) && defined(SYS_openat)
|
||||
fd = (int)syscall(SYS_openat, AT_FDCWD, path, flags);
|
||||
#else
|
||||
fd = open(path, flags);
|
||||
#endif
|
||||
return fd;
|
||||
}
|
||||
|
||||
static inline int malloc_close(int fd) {
|
||||
#if defined(JEMALLOC_USE_SYSCALL) && defined(SYS_close)
|
||||
return (int)syscall(SYS_close, fd);
|
||||
#else
|
||||
return close(fd);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#endif /* JEMALLOC_INTERNAL_MALLOC_IO_H */
|
||||
|
||||
Reference in New Issue
Block a user