mirror of
https://gitee.com/cosyos/cosyos.git
synced 2026-02-05 11:29:44 +08:00
10
说明文档/开发流程.md
10
说明文档/开发流程.md
@@ -37,11 +37,11 @@ CosyOS支持高等级优化,您完全可以选择8级(default),speed偏
|
||||
原因是C51的可重入栈效率十分低下,对于XBPSTACK,还存在关中断行为。<br>
|
||||
对于不可重入的库函数或自定义函数,如需要可重入,可采用下述的方法。<br>
|
||||
(1)替换法:对于不可重入的库函数,可考虑替换为其它的可重入库函数,实现相同的功能。<br>
|
||||
| non-reentrant | reentrant | 替换条件 |
|
||||
|--------------------|--------------------------------|----|
|
||||
| strncpy(s1, s2, n) | memcpy(s1, s2, n) | 推荐s2的长度至少为n |
|
||||
| strncat(s1, s2, n) | memcpy(s1 + strlen(s1), s2, n) | 推荐s2的长度至少为n |
|
||||
| strcat(s1, s2) | strcpy(s1 + strlen(s1), s2) | 无 |
|
||||
| non-reentrant | reentrant | 替换条件 |
|
||||
|--------------------|--------------------------------|----------------------------------|
|
||||
| strncpy(s1, s2, n) | memcpy(s1, s2, n) | 推荐s2的有效长度至少为n |
|
||||
| strncat(s1, s2, n) | memcpy(s1 + strlen(s1), s2, n) | 推荐s2的有效长度至少为n |
|
||||
| strcat(s1, s2) | strcpy(s1 + strlen(s1), s2) | 无 |
|
||||
| strncmp(s1, s2, n) | memcmp(s1, s2, n) | 确保其中一个字符串的有效长度至少为n |
|
||||
|
||||
(2)可重入版本<br>
|
||||
|
||||
Reference in New Issue
Block a user