mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-07-23 09:07:18 +03:00
Add malloc_open() / malloc_close() reentrancy safe helpers
This commit is contained in:
parent
60f472f367
commit
8c2e15d1a5
2 changed files with 32 additions and 50 deletions
|
|
@ -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 */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue