How to implement my own ctime() in linux kernel?

H

Hao Xu

Hi everyone!

I think that everyone knows ctime() in glibc:

The ctime(), gmtime() and localtime() functions all take an argument
of data type time_t which represents calendar time. When interpreted
as an absolute time value, it represents the number of seconds
elapsed since 00:00:00 on January 1, 1970, Coordinated Universal Time (UTC).

Now I need to use the function of ctime() in linux kernel, but it
seems that I cannot access ctime() in the linux kernel, right? So I have
to reimplement ctime() in the linux kernel. I found that the algorithm
of glibc ctime() is very complex, I don't understand it. Does anyone has
any good ideas about how to implement ctime()?

Thanks!
 
K

Keith Thompson

Hao Xu said:
I think that everyone knows ctime() in glibc:

Well, everyone here knows about the ctime() function defined by the C
standard.

[snip]
Now I need to use the function of ctime() in linux kernel, but it
seems that I cannot access ctime() in the linux kernel, right?

No idea.
So I have to reimplement ctime() in the linux kernel. I found that
the algorithm of glibc ctime() is very complex, I don't understand
it. Does anyone has any good ideas about how to implement ctime()?

Not here. If you have a working implementation, you might be able to
just copy it into your code, whether you understand the algorithm or
not. If that doesn't work, you'll need to try a Linux-specific
programming group.
 
M

Mark McIntyre

Now I need to use the function of ctime() in linux kernel, but it
seems that I cannot access ctime() in the linux kernel, right?

No idea.
So I have
to reimplement ctime() in the linux kernel. I found that the algorithm
of glibc ctime() is very complex, I don't understand it.

Thats probably because it needs to be. I'd suggest you study the algo and
understand it...
Does anyone has
any good ideas about how to implement ctime()?

Ask in comp.unix.progammer. This is not a C question.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top