I am trying to port tcmalloc to uclibc. Tcmalloc has a definition for sbrk function, which in turn calls the __sbrk from libc. Uclibc on the other hand does not have __sbrk function, but has sbrk.

Any ideas about how I can call uclibc sbrk from tcmalloc sbrk?

有帮助吗?

解决方案

sbrk is a (old) system call, but most memory allocators are built above mmap. See also this question

You should use the syscall, not emulate it. And I would prefer using mmap, not sbrk

Doing a system call (usually mmap) is the only way to get more memory from the linux kernel.

From the application's (or library's) point of view, a system call is atomic (it is mostly a single machine instruction like SYSCALL, SYSENTER, int 0x80 etc.).

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top