0018-prevent-pow-optimization.patch 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. From: Lukas Schwaighofer <lukas@schwaighofer.name>
  2. Date: Tue, 26 Feb 2019 23:13:58 +0100
  3. Subject: Prevent optimizing the pow() function
  4. With the current GCC 8.2.0 from Debian, a section of code calling pow() in
  5. zzjson_parse.c is turned into a sequence calling exp(). Since no exp()
  6. implementation is available in syslinux those optimizations need to be
  7. disabled.
  8. ---
  9. com32/gpllib/zzjson/zzjson_parse.c | 6 +++++-
  10. 1 file changed, 5 insertions(+), 1 deletion(-)
  11. diff --git a/com32/gpllib/zzjson/zzjson_parse.c b/com32/gpllib/zzjson/zzjson_parse.c
  12. index ecb6f61..e66a9d8 100644
  13. --- a/com32/gpllib/zzjson/zzjson_parse.c
  14. +++ b/com32/gpllib/zzjson/zzjson_parse.c
  15. @@ -138,6 +138,10 @@ static ZZJSON *parse_string2(ZZJSON_CONFIG *config) {
  16. return zzjson;
  17. }
  18. +static double __attribute__((optimize("O0"))) pow_noopt(double x, double y) {
  19. + return pow(x, y);
  20. +}
  21. +
  22. static ZZJSON *parse_number(ZZJSON_CONFIG *config) {
  23. ZZJSON *zzjson;
  24. unsigned long long ival = 0, expo = 0;
  25. @@ -213,7 +217,7 @@ skipexpo:
  26. if (dbl) {
  27. dval = sign * (long long) ival;
  28. dval += sign * frac;
  29. - dval *= pow(10.0, (double) signexpo * expo);
  30. + dval *= pow_noopt(10.0, (double) signexpo * expo);
  31. }
  32. zzjson = config->calloc(1, sizeof(ZZJSON));