Skip to contentSkip to conversation

mktime in include/linux

DISCUSSION Rick Hohensee 3 participants 4 messages Jun 22, 2001

lore
Share & tools
lore
#0 lore raw

Why does Linux have a mktime routine fully coded in linux/time.h that conflicts directly with the ANSI C standard library routine of the same name? It breaks a couple things against libc5, including gcc 3.0. OK, you don't care about libc5. It's still pretty weird. Wierd? Weird.

Rick Hohensee
www.cLIeNUX.com

:;d -d */

Cintpos/     boot/        device/      incoming/    owner/       temp/
Debian/      command/     floppy/      log/         source/
Linux/       configure/   guest/       lost+found/  subroutine/
NetBSD/      dev/         help/        mounts/      suite/

:; cLIeNUX /dev/tty12 22:00:52 /
:;

#1 lore raw
Quoted 4 lines · Rick Hohensee

Why does Linux have a mktime routine fully coded in linux/time.h that conflicts directly with the ANSI C standard library routine of the same name? It breaks a couple things against libc5, including gcc 3.0. OK, you don't care about libc5. It's still pretty weird. Wierd? Weird.

This has been brought up many times on this list: you are not supposed to include kernel headers in userland.

Erik

Signature · 5 lines
J.A.K. (Erik) Mouw, Information and Communication Theory Group, Department
of Electrical Engineering, Faculty of Information Technology and Systems,
Delft University of Technology, PO BOX 5031,  2600 GA Delft, The Netherlands
Phone: +31-15-2783635  Fax: +31-15-2781843  Email: [email protected]
WWW: http://www-ict.its.tudelft.nl/~erik/
#2 lore raw
Quoted 8 lines · Erik Mouw
Quoted 4 lines · Rick Hohensee

Why does Linux have a mktime routine fully coded in linux/time.h that conflicts directly with the ANSI C standard library routine of the same name? It breaks a couple things against libc5, including gcc 3.0. OK, you don't care about libc5. It's still pretty weird. Wierd? Weird.

This has been brought up many times on this list: you are not supposed to include kernel headers in userland.

That's not the problem, I think. Most of time.h, including the definition of mktime, is #ifdef __KERNEL__, so it shouldn't be breaking anything in userland even if you do include it. And you might, in order to obtain the interface definition of struct timespec. What's weird is: why is __KERNEL__ getting #defined in Rick's userland?

There can't, of course, be any blanket prohibition against using kernel headers in userland. Think about ioctl.h, for example.

Signature · 1 line
/Jonathan Lundell.
#3 lore raw
Quoted 18 lines
Quoted 8 lines · Erik Mouw
Quoted 4 lines · Rick Hohensee

Why does Linux have a mktime routine fully coded in linux/time.h that conflicts directly with the ANSI C standard library routine of the same name? It breaks a couple things against libc5, including gcc 3.0. OK, you don't care about libc5. It's still pretty weird. Wierd? Weird.

This has been brought up many times on this list: you are not supposed to include kernel headers in userland.

That's not the problem, I think. Most of time.h, including the definition of mktime, is #ifdef __KERNEL__, so it shouldn't be breaking anything in userland even if you do include it. And you might, in order to obtain the interface definition of struct timespec. What's weird is: why is __KERNEL__ getting #defined in Rick's userland?

Quoted 2 lines

There can't, of course, be any blanket prohibition against using kernel headers in userland. Think about ioctl.h, for example.

Sounds like a clue. Thanks.

Rick

Quoted 3 lines
Signature · 1 line
/Jonathan Lundell.