0001-Fix-building-with-musl.patch 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. From 9664809da36bd7bada3e44f50cfc042539fb61ee Mon Sep 17 00:00:00 2001
  2. From: Paul Eggleton <paul.eggleton@linux.intel.com>
  3. Date: Sun, 14 Jul 2019 19:13:21 -0700
  4. Subject: [PATCH] Fix building with musl
  5. Upstream-status: Pending
  6. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
  7. ---
  8. termios2.c | 27 +++++++++++++++++++++++++++
  9. termios2.h | 5 +++++
  10. 2 files changed, 32 insertions(+)
  11. diff --git a/termios2.c b/termios2.c
  12. index 97c3be0..88ff6fc 100644
  13. --- a/termios2.c
  14. +++ b/termios2.c
  15. @@ -37,6 +37,7 @@
  16. #include <errno.h>
  17. #include <termios.h>
  18. #include <sys/ioctl.h>
  19. +#include <asm/ioctls.h>
  20. /* Contains the definition of the termios2 structure and some related
  21. constants that we should normally include from system
  22. @@ -53,6 +54,10 @@
  23. */
  24. #define IBAUD0 020000000000
  25. +#if !defined(__GLIBC__)
  26. +#define __MAX_BAUD B4000000
  27. +#endif
  28. +
  29. int
  30. tc2setattr(int fd, int optional_actions, const struct termios *tios)
  31. {
  32. @@ -79,8 +84,13 @@ tc2setattr(int fd, int optional_actions, const struct termios *tios)
  33. t2.c_cflag = tios->c_cflag;
  34. t2.c_lflag = tios->c_lflag;
  35. t2.c_line = tios->c_line;
  36. +#if !defined(__GLIBC__)
  37. + t2.c_ispeed = tios->__c_ispeed;
  38. + t2.c_ospeed = tios->__c_ospeed;
  39. +#else
  40. t2.c_ispeed = tios->c_ispeed;
  41. t2.c_ospeed = tios->c_ospeed;
  42. +#endif
  43. memcpy(&t2.c_cc[0], &tios->c_cc[0], K_NCCS * sizeof (cc_t));
  44. return ioctl(fd, cmd, &t2);
  45. @@ -101,8 +111,13 @@ tc2getattr(int fd, struct termios *tios)
  46. tios->c_cflag = t2.c_cflag;
  47. tios->c_lflag = t2.c_lflag;
  48. tios->c_line = t2.c_line;
  49. +#if !defined(__GLIBC__)
  50. + tios->__c_ispeed = t2.c_ispeed;
  51. + tios->__c_ospeed = t2.c_ospeed;
  52. +#else
  53. tios->c_ispeed = t2.c_ispeed;
  54. tios->c_ospeed = t2.c_ospeed;
  55. +#endif
  56. memcpy(&tios->c_cc[0], &t2.c_cc[0], K_NCCS * sizeof (cc_t));
  57. for (i = K_NCCS; i < NCCS; i++)
  58. @@ -131,7 +146,11 @@ cf2setispeed(struct termios *tios, speed_t speed)
  59. errno = EINVAL;
  60. return -1;
  61. }
  62. +#if !defined(__GLIBC__)
  63. + tios->__c_ispeed = speed;
  64. +#else
  65. tios->c_ispeed = speed;
  66. +#endif
  67. tios->c_cflag &= ~((CBAUD | CBAUDEX) << IBSHIFT);
  68. tios->c_cflag |= (speed << IBSHIFT);
  69. @@ -156,7 +175,11 @@ cf2setospeed_custom(struct termios *tios, int speed)
  70. }
  71. tios->c_cflag &= ~(CBAUD | CBAUDEX);
  72. tios->c_cflag |= BOTHER;
  73. +#if !defined(__GLIBC__)
  74. + tios->__c_ospeed = speed;
  75. +#else
  76. tios->c_ospeed = speed;
  77. +#endif
  78. return 0;
  79. }
  80. @@ -177,7 +200,11 @@ cf2setispeed_custom(struct termios *tios, int speed)
  81. } else {
  82. tios->c_cflag &= ~((CBAUD | CBAUDEX) << IBSHIFT);
  83. tios->c_cflag |= (BOTHER << IBSHIFT);
  84. +#if !defined(__GLIBC__)
  85. + tios->__c_ispeed = speed;
  86. +#else
  87. tios->c_ispeed = speed;
  88. +#endif
  89. }
  90. return 0;
  91. diff --git a/termios2.h b/termios2.h
  92. index e13b0e3..63dd0ce 100644
  93. --- a/termios2.h
  94. +++ b/termios2.h
  95. @@ -37,8 +37,13 @@
  96. /* And define these new ones */
  97. #define cfsetospeed_custom cf2setospeed_custom
  98. #define cfsetispeed_custom cf2setispeed_custom
  99. +#if defined(__linux__) && !defined(__GLIBC__)
  100. +#define cfgetospeed_custom(tiop) ((tiop)->__c_ospeed)
  101. +#define cfgetispeed_custom(tiop) ((tiop)->__c_ispeed)
  102. +#else
  103. #define cfgetospeed_custom(tiop) ((tiop)->c_ospeed)
  104. #define cfgetispeed_custom(tiop) ((tiop)->c_ispeed)
  105. +#endif
  106. /* Replacements for the standard tcsetattr(3), tcgetattr(3)
  107. * functions. Same user interface, but these use the new termios2