我们从2011年坚守至今,只想做存粹的技术论坛。  由于网站在外面,点击附件后要很长世间才弹出下载,请耐心等待,勿重复点击不要用Edge和IE浏览器下载,否则提示不安全下载不了

 找回密码
 立即注册
搜索
查看: 689|回复: 0

有多少人有能力跳出这个泥潭的?---newlib's Reentrancy - 英

[复制链接]

该用户从未签到

1万

主题

1292

回帖

936

积分

管理员

积分
936

社区居民最爱沙发原创达人社区明星终身成就奖优秀斑竹奖宣传大使奖特殊贡献奖

QQ
发表于 2013-3-29 10:53:26 | 显示全部楼层 |阅读模式
            Reentrancy
Reentrancy is a characteristic of library functions which allows multiple processes to use the same address space with assurance that the values stored in those spaces will remain constant between calls.

The Red Hat newlib implementation of the library functions ensures that whenever possible, these library functions are reentrant.
However, there are some functions that can not be trivially made reentrant. Hooks have been provided to allow you to use these functions in a fully reentrant fashion.

These hooks use the structure _reent deined in ‘reent.h’. A variable deined as ‘struct _reent’ is called a reentrancy structure. All functions which must manipulate global in- formation are available in two versions. The irst version has the usual name, and uses a single global instance of the reentrancy structure. The second has a diferent name, nor- mally formed by prepending ‘_’ and appending ‘_r’, and takes a pointer to the particular reentrancy structure to use.

For example, the function fopen takes two arguments, ile and mode, and uses the global reentrancy structure. The function _fopen_r takes the arguments, struct reent, which is a pointer to an instance of the reentrancy structure, ile and mode.

There are two versions of ‘struct _reent’, a normal one and one for small memory systems, controlled by the _REENT_SMALL deinition from the (automatically included)
‘<sys/config.h>’.
Each function which uses the global reentrancy structure uses the global variable _impure_
ptr, which points to a reentrancy structure.
This means that you have two ways to achieve reentrancy. Both require that each thread
of execution control initialize a unique global variable of type ‘struct _reent’:
1. Use the reentrant versions of the library functions, after initializing a global reentrancy structure for each process. Use the pointer to this structure as the extra argument for all library functions.
2. Ensure that each thread of execution control has a pointer to its own unique reentrancy structure in the global variable _impure_ptr, and call the standard library subroutines.
The following functions are provided in both reentrant and non-reentrant versions.
Equivalent for errno variable:
_errno_r
Locale functions:
_localeconv_r _setlocale_r
Equivalents for stdio variables:
_stdin_r _stdout_r _stderr_r
------------------------------------------
278 Red Hat newlib C Library, Full
Stdio functions:
_fdopen_r _perror_r _tempnam_r
_fopen_r _putchar_r _tmpnam_r
_getchar_r _puts_r _tmpfile_r
_gets_r _remove_r _vfprintf_r
_iprintf_r _rename_r _vsnprintf_r
_mkstemp_r _snprintf_r _vsprintf_r
_mktemp_t _sprintf_r
Signal functions:
_init_signal_r _signal_r
_kill_r __sigtramp_r
_raise_r
Stdlib functions:
_calloc_r _mblen_r _setenv_r
_dtoa_r _mbstowcs_r _srand_r
_free_r _mbtowc_r _strtod_r
_getenv_r _memalign_r _strtol_r
_mallinfo_r _mstats_r _strtoul_r
_malloc_r _putenv_r _system_r
_malloc_r _rand_r _wcstombs_r
_malloc_stats_r _realloc_r _wctomb_r
String functions:
_strdup_r _strtok_r
System functions:
_close_r _link_r _unlink_r
_execve_r _lseek_r _wait_r
_fcntl_r _open_r _write_r
_fork_r _read_r
_fstat_r _sbrk_r
_gettimeofday_r _stat_r
_getpid_r _times_r
Time function:
_asctime_r
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

论坛开启做任务可以
额外奖励金币快速赚
积分升级了


Copyright ©2011-2024 NTpcb.com All Right Reserved.  Powered by Discuz! (NTpcb)

本站信息均由会员发表,不代表NTpcb立场,如侵犯了您的权利请发帖投诉

平平安安
TOP
快速回复 返回顶部 返回列表