- 论坛徽章:
- 0
|
本帖最后由 davelv 于 2010-08-10 10:11 编辑
在我这里多线程time()函数没有出现什么问题。楼主不如把自己测试源码贴出来让大家看看
以下是glibc2.12的time()实现
- /* Return the time now, and store it in *TIMER if not NULL. */
- time_t
- time (timer)
- time_t *timer;
- {
- __set_errno (ENOSYS);
- if (timer != NULL)
- *timer = (time_t) -1;
- return (time_t) -1;
- }
复制代码 ctime 不是线程安全的,所以有ctime_r作为替代。
- /* Return a string as returned by asctime which
- is the representation of *T in that form. */
- char *
- ctime (const time_t *t)
- {
- /* The C Standard says ctime (t) is equivalent to asctime (localtime (t)).
- In particular, ctime and asctime must yield the same pointer. */
- return asctime (localtime (t));
- }
复制代码
- /* Return a string as returned by asctime which is the representation
- of *T in that form. Reentrant version. */
- char *
- ctime_r (const time_t *t, char *buf)
- {
- struct tm tm;
- return __asctime_r (__localtime_r (t, &tm), buf);
- }
复制代码 |
|