Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run.c doesn't compile on OpenBSD #7

Open
Veraellyunjie opened this issue Oct 7, 2022 · 1 comment
Open

run.c doesn't compile on OpenBSD #7

Veraellyunjie opened this issue Oct 7, 2022 · 1 comment
Labels
bug Something isn't working triaged The bug is verified and can be worked on

Comments

@Veraellyunjie
Copy link

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
Copy link
Owner

bdrung commented Oct 7, 2022

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. :)

@bdrung bdrung added bug Something isn't working triaged The bug is verified and can be worked on labels Oct 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triaged The bug is verified and can be worked on
Projects
None yet
Development

No branches or pull requests

2 participants