struct stat.h with nanosecond resolution
Andreas Jaeger
aj@suse.de
Mon Dec 2 05:33:00 GMT 2002
Andi Kleen <ak@suse.de> writes:
> On Mon, Dec 02, 2002 at 03:03:11AM -0800, Ulrich Drepper wrote:
>> Andi Kleen wrote:
>>
>> > Just will it be assignment compatible then with struct timespec ?
>>
>> Of course. The typedef creates just another name for the same type.
>
> But then you are not namespace clean no ?
>
> If I understand it you want to do:
>
> ...
>
> struct timespec {
> ...
> };
> typedef struct timespec __timespec_t;
> ...
>
> Use __timespec_t in stat.h
Andi, you're right, this breaks with:
../sysdeps/unix/sysv/linux/x86_64/bits/stat.h:79: field `st_atim' has incomplete type
since stat.h includes time.h with
#ifdef __USE_XOPEN
# define __need_time_t
# include <time.h> /* For time_t. */
but we need to include it unconditionally and need to make
__timespec_t visible.
>
> That allows an user to later #define timespec to something else.
>
> But it won't allow to redeclare timespec to a different type in the struct
> namespace. It's some time since I did that namespace cleanliness thing, but
> at least for ISO-C I'm pretty sure it not only included the preprocessor
> name space, but also struct and typedef.
>
> What would make more sense and being name space clean in all namespaces
> when POSIX_SOURCE or XOPEN_SOURCE is defined is:
>
> /* in extra header that gets included by sys/stat.h */
> struct __timespec {
> ...
> };
> #if !_XOPEN_SOURCE && !_POSIX_SOURCE
> struct timespec {
> /* same */
> };
> #endif
>
> sys/stat.h:
> #if _XOPEN_SOURCE || _POSIX_SOURCE
> struct __timespec ...; /* strict name space */
> #else
> struct timespec ...; /* easy compatibility */
> #endif
I'm not sure that this is right either. Uli, what is the proper way
to handle <time.h>? I currently don't see a clean solution for
this:-(
Andreas
--
Andreas Jaeger
SuSE Labs aj@suse.de
private aj@arthur.inka.de
http://www.suse.de/~aj
More information about the Libc-alpha
mailing list