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

clock_gettime(): not found during config due to including the wrong sched.h header instead of the correct time.h #1566

Open
BalkanMadman opened this issue Feb 26, 2025 · 1 comment · May be fixed by #1567

Comments

@BalkanMadman
Copy link

Hello! We, at Gentoo, work on improving the state of NGINX ecosystem. As part of our efforts, I have been working on better supporting your module.

Getting straight to the point. Your config check checks whether clock_gettime() is available, additionally including the sched.h header.

nginx-vod-module/config

Lines 125 to 145 in 26f0687

# clock_gettime
#
ngx_feature="clock_gettime()"
ngx_feature_name="NGX_HAVE_CLOCK_GETTIME"
ngx_feature_run=no
ngx_feature_incs="#include <sched.h>"
ngx_feature_path=
ngx_feature_libs=
ngx_feature_test="clock_gettime()"
. auto/feature
if [ $ngx_found != yes ]; then
ngx_feature="clock_gettime() in librt"
ngx_feature_libs="-lrt"
. auto/feature
if [ $ngx_found = yes ]; then
ngx_module_libs="$ngx_module_libs $ngx_feature_libs"
fi
fi

This fails, because, according to POSIX and GNU, the clock_gettime() function is provided by time.h, not sched.h.

Thus, the line

ngx_feature_incs="#include <sched.h>"

should be changed to

ngx_feature_incs="#include <time.h>"

to check for clock_gettime() properly. I will follow this issue with a PR fixing this.

@BalkanMadman
Copy link
Author

BalkanMadman commented Feb 26, 2025

Moreover, even with the correct header the check still fails, as the function expect two arguments, but none are provided.

The line

ngx_feature_test="clock_gettime()"

should be changed to something like

ngx_feature_test="clockid_t c; clock_gettime(c, NULL)"

@BalkanMadman BalkanMadman linked a pull request Feb 26, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant