mlock.c

来自「用于嵌入式Linux系统的标准C的库函数」· C语言 代码 · 共 53 行

C
53
字号
#ifndef MALLOC_PROVIDED/*FUNCTION<<__malloc_lock>>, <<__malloc_unlock>>--lock malloc poolINDEX	__malloc_lockINDEX	__malloc_unlockANSI_SYNOPSIS	#include <malloc.h>	void __malloc_lock (struct _reent *<[reent]>);	void __malloc_unlock (struct _reent *<[reent]>);TRAD_SYNOPSIS	void __malloc_lock(<[reent]>)	struct _reent *<[reent]>;	void __malloc_unlock(<[reent]>)	struct _reent *<[reent]>;DESCRIPTIONThe <<malloc>> family of routines call these functions when they needto lock the memory pool.  The version of these routines supplied inthe library does not do anything.  If multiple threads of executioncan call <<malloc>>, or if <<malloc>> can be called reentrantly, thenyou need to define your own versions of these functions in order tosafely lock the memory pool during a call.  If you do not, the memorypool may become corrupted.A call to <<malloc>> may call <<__malloc_lock>> recursively; that is,the sequence of calls may go <<__malloc_lock>>, <<__malloc_lock>>,<<__malloc_unlock>>, <<__malloc_unlock>>.  Any implementation of theseroutines must be careful to avoid causing a thread to wait for a lockthat it already holds.*/#include <malloc.h>void__malloc_lock (ptr)     struct _reent *ptr;{}void__malloc_unlock (ptr)     struct _reent *ptr;{}#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?