国产毛片a精品毛-国产毛片黄片-国产毛片久久国产-国产毛片久久精品-青娱乐极品在线-青娱乐精品

查看: 5541|回復: 2
打印 上一主題 下一主題

有多少人有能力跳出這個泥潭的?---newlib's Reentrancy

[復制鏈接]
跳轉到指定樓層
樓主
發表于 2009-11-17 23:47:22 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
關鍵詞: newlib , Reentrancy , 能力 , 泥潭
                                  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)
’.
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
沙發
 樓主| 發表于 2009-11-17 23:58:52 | 只看該作者
在網上找了很多關于newlib 的printf 不要OS真接重定向到UART的問題,到目前為止,竟沒有發現有人能正常使用printf 的全部功能的記載。
曾經找到一個關于老外的一個正式回復的貼子,但是發現老外也沒有說真話,看來要用好newlib 的printf 的全部功能不容易!還得下一翻功夫!
板凳
 樓主| 發表于 2009-11-18 00:02:13 | 只看該作者
how to retarget newlib printf scanf to embedded systemUART ?:
Hi Wayne,

You need to do following things to redirect stdout to UART.
1) Please include syscalls.c in your project from following path,
../newlib/libc/sys/arm
2) Without changing any other functions from syscalls.c, change only _read and
_write functions like following.

int _read (int file, char *ptr, int len)
{
/* GetChar : Your implementation to receive the character
from the serial port.*/
//*ptr=GetChar();
return (1);
}

int _write(int file,char *ptr,int len)
{
int i;
/* PutChar : Your implementation to send the character to the
serial port.*/
for(i=0;i {
//PutChar(*ptr++);
}
return len;
}
This implementation of redirecting stdin and stdout to serial port will
override default
implementation of stdin and stdout.
Do not forget to include directories with required header files in your project.

This implementation works for H8/300 and SH targets. It should also work for
ARM target.
Please refer to following link for more details,
http://billgatliff.com/articles/newlib/newlib.pdf

Good Luck.
您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規則

關于我們  -  服務條款  -  使用指南  -  站點地圖  -  友情鏈接  -  聯系我們
電子工程網 © 版權所有   京ICP備16069177號 | 京公網安備11010502021702
快速回復 返回頂部 返回列表
主站蜘蛛池模板: 国产精品天天看特色大片不卡 | 视频在线观看一区二区三区 | 国产成人综合亚洲欧美在 | 在线免费观看亚洲 | 欧美www在线观看 | 99久久免费国产精精品 | 一级做a爰片久久毛片免费 一级做a爰片久久毛片毛片 | 亚洲tv精品一区二区三区 | 亚洲另类天天更新影院在线观看 | 国产三级一区二区三区 | 国产在线精品成人一区二区三区 | www.四虎影| 五月天六月婷婷开心激情 | 韩国免费毛片在线看 | 在线免费观看一级毛片 | 国产成人宗合 | 亚洲第一狼人社区 | a一级一色一情 | 9久热久爱免费精品视频在线观看 | 九九热国产在线 | 一级做a爰片性色毛片男 | 四虎家庭影院 | 久久亚洲精中文字幕冲田杏梨 | 日本特黄一级 | 国产69精品久久久久99不卡 | 国产午夜一区二区在线观看 | 亚洲欧美精品成人久久91 | 最新亚洲人成网站在线影院 | 亚洲国产欧美91 | 成人在线免费视频观看 | a亚洲| 亚洲国产欧美一区二区欧美 | 中文字幕精品一区二区三区在线 | 免费一级a毛片在线播出 | 婷婷综合丁香 | 亚洲第一区二区快射影院 | 青青操手机看 | 欧美日韩在线网站 | 国产精品四虎 | 国产视频一区在线播放 | 日韩在线免费看 |