malloc/free 是系统调用还是 libc 提供的库例程? [英] Is malloc/free a syscall or a library routine provided by libc?

查看:65
本文介绍了malloc/free 是系统调用还是 libc 提供的库例程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果 malloc/free 在 libc 中作为库例程实现,那么它是在 sbrk 系统调用或 mmap 系统调用之上实现的,还是其他什么?

If malloc/free is implemented as a library routine in libc, then is it implemented on top of the sbrk syscall or the mmap syscall, or something else?

一般来说,sys/syscall.h 中声明的函数是否包含目标机器中的所有系统调用?

And to be general, does the function declared in sys/syscall.h contains ALL the system calls in the target machine?

推荐答案

mallocfree 是标准的 C 库函数,由每个 C 实现来实现.

malloc and free are standard C library functions which are to be implemented by each C implementation.

C 标准仅定义了这些函数的行为方式以及对它们的预期行为.如何实现它们取决于每个实现.

The C standard only defines the way in which these functions behave and the behavior expected from them. How they are to be implemented in left to each implementation.

简而言之,它们是您使用的实现的实现细节.

In short they are implementation detail of the implementation you use.

(一个实现"包括编译器、链接器、运行时库,可能还有其他一些东西.)

(An "implementation" consists of the compiler, the linker, the runtime library, and probably a few other things.)

这篇关于malloc/free 是系统调用还是 libc 提供的库例程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆