非线程安全的函数

来源:互联网 发布:广州多益网络员工收入 编辑:程序博客网 时间:2024/05/17 01:27

http://blog.csdn.net/yaochunnian/article/details/7258446


下表是 UNIX环境高级编程列出 POSIX.1规范中的非线程安全的函数:


asctimeecvtgethostentgetutxlineputc_unlockedbasenameencryptgetlogingmtimeputchar_unlockedcatgetsendgrentgetnetbyaddrhcreateputenvcryptendpwentgetnetbynamehdestroypututxlinectimeendutxentgetopthsearchranddbm_clearerrfcvtgetprotobynameinet_ntoareaddirdbm_closeftwgetprotobynumberL64asetenvdbm_deletegetcvtgetprotobynumberlgammasetgrentdbm_errorgetc_unlockedgetprotoentlgammafsetkeydbm_fetchgetchar_unlockedgetpwentlgammalsetpwentdbm_firstkeygetdategetpwnamlocaleconvsetutxentdbm_nextkeygetenvgetpwuidlrand48strerrordbm_opengetgrentgetservbynamemrand48strtokdbm_storegetgrgidgetservbyportnftwttynamedirnamegetgrnamgetserventnl_langinfounsetenvdlerrorgethostbyaddrgetutxentptsnamewcstombsdrand48gethostbynamegetutxidptsnameectomb


除此之外:

inet_ntoa  ----> inet_ntop

asctime(), ctime(), gmtime() and localtime()返回指针指向静态数据,因此不是线程安全的。

线程安全版本为time_r(), ctime_r(), gmtime_r() and localtime_r()are specified by SUSv2, and available since libc 5.2.5. 最好使用使用gettimeofday。

gethostbyname, gethostbyaddr是不可重入函数;已经被getaddrinfo, getnameinfo替代


打印时间,使用strftime。


原创粉丝点击