⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 envlock.c

📁 KPIT GNU Tools is a set of GNU development tools for Renesas microcontrollers.
💻 C
字号:
/*FUNCTION<<__env_lock>>, <<__env_unlock>>---lock environ variableINDEX	__env_lockINDEX	__env_unlockANSI_SYNOPSIS	#include "envlock.h"	void __env_lock (struct _reent *<[reent]>);	void __env_unlock (struct _reent *<[reent]>);TRAD_SYNOPSIS	void __env_lock(<[reent]>)	struct _reent *<[reent]>;	void __env_unlock(<[reent]>)	struct _reent *<[reent]>;DESCRIPTIONThe <<setenv>> family of routines call these functions when they need tomodify the environ variable.  The version of these routines supplied in thelibrary use the lock API defined in sys/lock.h.  If multiple threads ofexecution can call <<setenv>>, or if <<setenv>> can be called reentrantly,then you need to define your own versions of these functions in order tosafely lock the memory pool during a call.  If you do not, the memory poolmay become corrupted.A call to <<setenv>> may call <<__env_lock>> recursively; that is,the sequence of calls may go <<__env_lock>>, <<__env_lock>>,<<__env_unlock>>, <<__env_unlock>>.  Any implementation of theseroutines must be careful to avoid causing a thread to wait for a lockthat it already holds.*/#include "envlock.h"#include <sys/lock.h>#ifndef __SINGLE_THREAD____LOCK_INIT_RECURSIVE(static, __env_lock_object);#endifvoid__env_lock (ptr)     struct _reent *ptr;{#ifndef __SINGLE_THREAD__  __lock_acquire_recursive (__env_lock_object);#endif}void__env_unlock (ptr)     struct _reent *ptr;{#ifndef __SINGLE_THREAD__  __lock_release_recursive (__env_lock_object);#endif}

⌨️ 快捷键说明

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