bdrung / startup-time

Measure startup time of different programming languages
ISC License
147 stars 17 forks source link

run.c doesn't compile on OpenBSD #7

Open Veraellyunjie opened 2 years ago

Veraellyunjie commented 2 years ago
uname
OpenBSD
clang run.c -o run
run.c:36:5: error: use of undeclared identifier 'cpu_set_t'
    cpu_set_t cpu_set;
    ^
run.c:64:5: warning: implicit declaration of function 'CPU_ZERO' is invalid in C99 [-Wimplicit-function-declaration]
    CPU_ZERO(&cpu_set);
    ^
run.c:64:15: error: use of undeclared identifier 'cpu_set'; did you mean 'cgetset'?
    CPU_ZERO(&cpu_set);
              ^~~~~~~
              cgetset
/usr/include/stdlib.h:277:6: note: 'cgetset' declared here
int      cgetset(const char *);
         ^
run.c:65:5: warning: implicit declaration of function 'CPU_SET' is invalid in C99 [-Wimplicit-function-declaration]
    CPU_SET(core, &cpu_set);
    ^
run.c:65:20: error: use of undeclared identifier 'cpu_set'; did you mean 'cgetset'?
    CPU_SET(core, &cpu_set);
                   ^~~~~~~
                   cgetset
/usr/include/stdlib.h:277:6: note: 'cgetset' declared here
int      cgetset(const char *);
         ^
run.c:66:17: warning: implicit declaration of function 'sched_setaffinity' is invalid in C99 [-Wimplicit-function-declaration]
    if(unlikely(sched_setaffinity(getpid(), sizeof(cpu_set), &cpu_set) == -1)) {
                ^
run.c:66:52: error: use of undeclared identifier 'cpu_set'
    if(unlikely(sched_setaffinity(getpid(), sizeof(cpu_set), &cpu_set) == -1)) {
                                                   ^
run.c:66:63: error: use of undeclared identifier 'cpu_set'; did you mean 'cgetset'?
    if(unlikely(sched_setaffinity(getpid(), sizeof(cpu_set), &cpu_set) == -1)) {
                                                              ^~~~~~~
                                                              cgetset
run.c:28:39: note: expanded from macro 'unlikely'
#define unlikely(x) __builtin_expect((x),0)
                                      ^
/usr/include/stdlib.h:277:6: note: 'cgetset' declared here
int      cgetset(const char *);
         ^
3 warnings and 5 errors generated.
egcc run.c -o run
run.c: In function 'main':
run.c:36:5: error: unknown type name 'cpu_set_t'
   36 |     cpu_set_t cpu_set;
      |     ^~~~~~~~~
run.c:64:5: warning: implicit declaration of function 'CPU_ZERO' [-Wimplicit-function-declaration]
   64 |     CPU_ZERO(&cpu_set);
      |     ^~~~~~~~
run.c:65:5: warning: implicit declaration of function 'CPU_SET'; did you mean 'L_SET'? [-Wimplicit-function-declaration]
   65 |     CPU_SET(core, &cpu_set);
      |     ^~~~~~~
      |     L_SET
run.c:66:17: warning: implicit declaration of function 'sched_setaffinity' [-Wimplicit-function-declaration]
   66 |     if(unlikely(sched_setaffinity(getpid(), sizeof(cpu_set), &cpu_set) == -1)) {
      |                 ^~~~~~~~~~~~~~~~~
run.c:28:39: note: in definition of macro 'unlikely'
   28 | #define unlikely(x) __builtin_expect((x),0)
      |                                       ^
bdrung commented 2 years ago

cpu_set_t is only defined on Linux, which is used for sched_setaffinity. This part of the code needs to be adapted to an equivalent on BSD. Patches are welcome. :)