-
-
Notifications
You must be signed in to change notification settings - Fork 33.6k
gh-142379: configure.ac: detect unusable termio operations #142380
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
base: main
Are you sure you want to change the base?
Conversation
cd5b91f to
fd47b13
Compare
Some termio operations are not actually usable on some architectures. For example, the TCGETA, TCSETA, TCSETAF and TCSETAW are defined with a reference to "struct termio" on alpha, hppa and sparc64, but "struct termio" is no longer defined since glibc 2.42, causing a build failure. Instead of using those operations as soon as they are defined, this commit checks more carefully that they are actually usable. This is done using a new m4 macro PY_CHECK_IOCTL. Signed-off-by: Thomas Petazzoni <[email protected]>
fd47b13 to
d766640
Compare
| {"TCFLSH", TCFLSH}, | ||
| #endif | ||
| #ifdef TCGETA | ||
| #if defined(HAVE_TCGETA) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use ifdef HAVE_TCGETA
| dnl PY_CHECK_IOCTL(IOCTL_SYMBOL) | ||
| AC_DEFUN([PY_CHECK_IOCTL], | ||
| [ | ||
| AC_MSG_CHECKING([for $1]) | ||
| AC_COMPILE_IFELSE( | ||
| [AC_LANG_PROGRAM( | ||
| [[#include <sys/ioctl.h>]], | ||
| [[ | ||
| /* Test whether $1 is declared */ | ||
| long val = $1; | ||
| return 0; | ||
| ]] | ||
| )], | ||
| [AC_MSG_RESULT([yes]) | ||
| AC_DEFINE([HAVE_$1], [1], | ||
| [Define this if $1 termio operation is usable])], | ||
| [AC_MSG_RESULT([no])] | ||
| ) | ||
| ]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make this a generic function instead? it's useful for checking the presence of a macro. Make the includes and the expected macro type parameters of that function, as well as the name of your HAVE_ macro as you did. This could be useful elsewhere.
Ina ddition, there is no need for the return 0; as it's implicit. Also remove `/* Test whether $1 is declared */ because it's trivial what it does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback @picnixz. Actually such a generic macro already "exists" to some degree, it's AC_CHECK_DECL. However, we can't use it in our specific case because what AC_CHECK_DECL does is:
#ifndef YOUR_DECLARATION
(void) YOUR_DECLARATION;
#endif
The idea being: the #ifndef test if it is a macro => if it is, then fine, we're good. If it's not a macro, it checks if it's a valid r-value.
In our case, TCGETA is a macro, BUT we need to check that it is actually usable, not just "defined". And that's why AC_CHECK_DECL doesn't do the trick.
If you still think a generic macro would be good, what name should it have? Indeed, PY_CHECK_DECL would be very confusing if it has this subtle difference with AC_CHECK_DECL. Or maybe PY_CHECK_USABLE_DECL ?
And of course, our macro isn't as generic as AC_CHECK_DECL, because if the declaration exists but has no value (like #define FOO), then our test will fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My idea was actually different. What I wanted to test is:
TYPE holder = $1;
where you specify TYPE (in your case it's long). And for the name, it would be PY_CHECK_CONSTANT. I wanted you to actually remove the comment but not the test itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes a lot of sense, will do!
Some termio operations are not actually usable on some architectures. For example, the TCGETA, TCSETA, TCSETAF and TCSETAW are defined with a reference to "struct termio" on alpha, hppa and sparc64, but "struct termio" is no longer defined since glibc 2.42, causing a build failure.
Instead of using those operations as soon as they are defined, this commit checks more carefully that they are actually usable. This is done using a new m4 macro PY_CHECK_IOCTL.