0017-Replace-builtin-strlen-that-appears-to-get-optimized.patch 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. From 698a6ce88524b727d265b204d648e78d8acb485c Mon Sep 17 00:00:00 2001
  2. From: Merlin Mathesius <mmathesi@redhat.com>
  3. Date: Wed, 13 May 2020 11:58:37 -0500
  4. Subject: [PATCH] Replace builtin strlen that appears to get optimized away
  5. [From https://src.fedoraproject.org/rpms/syslinux/raw/rawhide/f/0006-Replace-builtin-strlen-that-appears-to-get-optimized.patch]
  6. Signed-off-by: Peter Seiderer <ps.report@gmx.net>
  7. ---
  8. dos/string.h | 12 +++++++++++-
  9. 1 file changed, 11 insertions(+), 1 deletion(-)
  10. diff --git a/dos/string.h b/dos/string.h
  11. index f648de2d..407d0233 100644
  12. --- a/dos/string.h
  13. +++ b/dos/string.h
  14. @@ -5,12 +5,22 @@
  15. #ifndef _STRING_H
  16. #define _STRING_H
  17. +#include <stddef.h>
  18. +
  19. /* Standard routines */
  20. #define memcpy(a,b,c) __builtin_memcpy(a,b,c)
  21. #define memmove(a,b,c) __builtin_memmove(a,b,c)
  22. #define memset(a,b,c) __builtin_memset(a,b,c)
  23. #define strcpy(a,b) __builtin_strcpy(a,b)
  24. -#define strlen(a) __builtin_strlen(a)
  25. +#define strlen(a) inline_strlen(a)
  26. +
  27. +/* replacement for builtin strlen that appears to get optimized away */
  28. +static inline size_t inline_strlen(const char *str)
  29. +{
  30. + size_t l;
  31. + for (l = 0; *str++; l++);
  32. + return l;
  33. +}
  34. /* This only returns true or false */
  35. static inline int memcmp(const void *__m1, const void *__m2, unsigned int __n)
  36. --
  37. 2.30.1