diff options
author | Dagfinn Ilmari Mannsåker <ilmari@ilmari.org> | 2020-02-12 20:18:40 +0000 |
---|---|---|
committer | Dagfinn Ilmari Mannsåker <ilmari@ilmari.org> | 2020-02-12 20:26:11 +0000 |
commit | 96d019622c8664693f6966a219cfdfd9c81ac025 (patch) | |
tree | 49e7b3a53161c4228c111086f15973cd8c3c9568 /pp_sys.c | |
parent | 97277bd37fa26714515f17503588be90e2fcd3fa (diff) | |
download | perl-96d019622c8664693f6966a219cfdfd9c81ac025.tar.gz |
Revert "pp_(get|set)priority: remove ancient glibc C++ workaround"
It turns out that even though the headers correctly define the argument
as `int` under C++, -Wc++-compat doesn't know this.
Add a comment to stop others from falling into the same trap I did.
This reverts commit 34d254cefc451e5ab438acf22a51d7b557c05a0e.
Diffstat (limited to 'pp_sys.c')
-rw-r--r-- | pp_sys.c | 17 |
1 files changed, 15 insertions, 2 deletions
@@ -4619,13 +4619,24 @@ PP(pp_setpgrp) #endif } +/* + * The glibc headers typedef __priority_which_t to an enum under C, but + * under C++, it keeps it as int. -Wc++-compat doesn't know this, so we + * need to explicitly cast it to shut up the warning. + */ +#if defined(__GLIBC__) && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3) || (__GLIBC__ > 2)) +# define PRIORITY_WHICH_T(which) (__priority_which_t)which +#else +# define PRIORITY_WHICH_T(which) which +#endif + PP(pp_getpriority) { #ifdef HAS_GETPRIORITY dSP; dTARGET; const int who = POPi; const int which = TOPi; - SETi( getpriority(which, who) ); + SETi( getpriority(PRIORITY_WHICH_T(which), who) ); RETURN; #else DIE(aTHX_ PL_no_func, "getpriority"); @@ -4640,13 +4651,15 @@ PP(pp_setpriority) const int who = POPi; const int which = TOPi; TAINT_PROPER("setpriority"); - SETi( setpriority(which, who, niceval) >= 0 ); + SETi( setpriority(PRIORITY_WHICH_T(which), who, niceval) >= 0 ); RETURN; #else DIE(aTHX_ PL_no_func, "setpriority"); #endif } +#undef PRIORITY_WHICH_T + /* Time calls. */ PP(pp_time) |