http://hi.baidu.com/serial_story/blog/item/fcec44ec707dd5dd2e2e21ed.html

 

【整理】Linux内核中的atoi,itoa等函数

对于普通应用程序,可以通过包含头文件stdlib.h和stdio.h,string.h等,然后调用需要的itoa(),atoi()等函数,

但是对于Linux内核来说,无法使用那些C库中的函数。

对此Linux内核里有了相应的实现:

对于atoi()用simple_strtol() ,simple_strtoul()等函数替代;
对于itoa(),用snprintf()。

其他相关函数,自己去看/lib/vsprintf.c。
比如:

simple_strtoul,simple_strtol,simple_strtoull,strict_strtoul,strict_strtol,strict_strtoull,strict_strtoll,vsnprintf,vscnprintf

另外,对于常见的字符相关处理函数,都在/lib/string.c中:

strnicmp,strcasecmp,strncasecmp,strcpy,strncpy,strlcpy,strcat,strncat,strlcat,strcmp,strncmp,strchr,strrchr,strnchr,strstrip,strlen,strnlen,strspn,strcspn,strpbrk,strsep,sysfs_streq

以及内存相关操作函数:

memset,memcpy,memmove,memcmp,memscan,strstr,memchr

【引用】

1。Re: Itoa and atoi functions in kernel space

http://mail.nl.linux.org/kernelnewbies/2005-07/msg00417.html

2。内核中可以引用stdlib.h和stdio.h吗?

http://linux.chinaunix.net/bbs/viewthread.php?tid=910745


 

GitHub 加速计划 / li / linux-dash
13
2
下载
A beautiful web dashboard for Linux
最近提交(Master分支:4 个月前 )
186a802e added ecosystem file for PM2 5 年前
5def40a3 Add host customization support for the NodeJS version 5 年前
Logo

AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。

更多推荐