rigtorp / ipc-bench

Latency benchmarks of Unix IPC mechanisms
MIT License
556 stars 165 forks source link

Use proper header for gettimeofday. #16

Closed sergeyklay closed 3 years ago

sergeyklay commented 3 years ago

As *BSD and Linux man says, gettimeofday is from sys/time.h, not time.h

rigtorp commented 3 years ago

Thanks!

rigtorp commented 3 years ago

Eh no you are wrong, this broke everything. On linux and bsd it's in time.h

rigtorp commented 3 years ago

See here for example https://www.unix.com/man-page/FreeBSD/2/clock_gettime/

sergeyklay commented 3 years ago

@rigtorp Yes, clock_gettime is from time.h, my bad. But,

BSD

$ man gettimeofday | head

GETTIMEOFDAY(2)             BSD System Calls Manual            GETTIMEOFDAY(2)

NAME
     gettimeofday, settimeofday -- get/set date and time

SYNOPSIS
     #include <sys/time.h>

     int

Linux

$ man gettimeofday | head

GETTIMEOFDAY(2)                                                                     Linux Programmer's Manual                                                                    GETTIMEOFDAY(2)

NAME
       gettimeofday, settimeofday - get / set time

SYNOPSIS
       #include <sys/time.h>

       int gettimeofday(struct timeval *restrict tv,
                        struct timezone *restrict tz);

As you can see bot Linux and BSD say gettimeofday from sys/time.h, not time.h.

rigtorp commented 3 years ago

Yeah I updated the code to include both.