0001-Add-array_length-support.patch 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. From ce34f0e215324455bbb1e4b18f5723b081cae801 Mon Sep 17 00:00:00 2001
  2. From: Jun Yuan Tan <junyuan.tan@starfivetech.com>
  3. Date: Tue, 23 Nov 2021 12:08:27 +0800
  4. Subject: [PATCH 1/1] Add array_length support
  5. This is needed to build localedef from glibc 2.35 in master branch.
  6. (Commit f5117c6504888fab5423282a4607c552b90fd3f9)
  7. Signed-off-by: Jun Yuan Tan <junyuan.tan@starfivetech.com>
  8. ---
  9. localedef/include/array_length.h | 36 ++++++++++++++++++++++++++++++++++++
  10. 1 file changed, 36 insertions(+)
  11. create mode 100644 localedef/include/array_length.h
  12. diff --git a/localedef/include/array_length.h b/localedef/include/array_length.h
  13. new file mode 100644
  14. index 0000000..12c5126
  15. --- /dev/null
  16. +++ b/localedef/include/array_length.h
  17. @@ -0,0 +1,36 @@
  18. +/* The array_length and array_end macros.
  19. + Copyright (C) 2017-2021 Free Software Foundation, Inc.
  20. + This file is part of the GNU C Library.
  21. +
  22. + The GNU C Library is free software; you can redistribute it and/or
  23. + modify it under the terms of the GNU Lesser General Public
  24. + License as published by the Free Software Foundation; either
  25. + version 2.1 of the License, or (at your option) any later version.
  26. +
  27. + The GNU C Library is distributed in the hope that it will be useful,
  28. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  29. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  30. + Lesser General Public License for more details.
  31. +
  32. + You should have received a copy of the GNU Lesser General Public
  33. + License along with the GNU C Library; if not, see
  34. + <https://www.gnu.org/licenses/>. */
  35. +
  36. +#ifndef _ARRAY_LENGTH_H
  37. +#define _ARRAY_LENGTH_H
  38. +
  39. +/* array_length (VAR) is the number of elements in the array VAR. VAR
  40. + must evaluate to an array, not a pointer. */
  41. +#define array_length(var) \
  42. + (sizeof (var) / sizeof ((var)[0]) \
  43. + + 0 * sizeof (struct { \
  44. + _Static_assert (!__builtin_types_compatible_p \
  45. + (__typeof (var), __typeof (&(var)[0])), \
  46. + "argument must be an array"); \
  47. + }))
  48. +
  49. +/* array_end (VAR) is a pointer one past the end of the array VAR.
  50. + VAR must evaluate to an array, not a pointer. */
  51. +#define array_end(var) (&(var)[array_length (var)])
  52. +
  53. +#endif /* _ARRAY_LENGTH_H */
  54. --
  55. 2.33.1