0001-pppd-workaround-sparc-asm-termbits.h-issue.patch 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. From ef37e5b112734f551132b613438788fd4ef8797a Mon Sep 17 00:00:00 2001
  2. From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
  3. Date: Fri, 12 Jul 2024 20:24:22 +0200
  4. Subject: [PATCH] pppd: workaround sparc <asm/termbits.h> issue
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. The SPARC version of the <asm/termbits.h> kernel header has an issue:
  9. it defines "struct termio", which conflicts with the definition in
  10. <bits/ioctl-types.h>, causing a build failure in pppd.
  11. This issue was fixed in the upstream Linux kernel in commit
  12. c32d18e7942d7589b62e301eb426b32623366565 ("sparc: move struct termio
  13. to asm/termios.h"), which is going to appear in Linux 6.10.
  14. In order to support building with older toolchains, this patch
  15. includes in the pppd source code a copy of the fixed SPARC
  16. <asm/termbits.h> in the pppd code base, and uses it if we're on SPARC
  17. with kernel headers older than 6.10.
  18. Fixes:
  19. In file included from termios_linux.h:39:
  20. /home/thomas/projets/buildroot/output/host/sparc64-buildroot-linux-gnu/sysroot/usr/include/asm/termbits.h:17:8: error: redefinition of ‘struct termio’
  21. 17 | struct termio {
  22. | ^~~~~~
  23. CC pppd-ipv6cp.o
  24. In file included from /home/thomas/projets/buildroot/output/host/sparc64-buildroot-linux-gnu/sysroot/usr/include/sys/ioctl.h:29,
  25. from sys-linux.c:76:
  26. /home/thomas/projets/buildroot/output/host/sparc64-buildroot-linux-gnu/sysroot/usr/include/bits/ioctl-types.h:36:8: note: originally defined here
  27. 36 | struct termio
  28. | ^~~~~~
  29. Upstream: https://github.com/ppp-project/ppp/pull/504
  30. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
  31. ---
  32. pppd/sparc-termbits.h | 247 ++++++++++++++++++++++++++++++++++++++++++
  33. pppd/termios_linux.h | 6 +
  34. 2 files changed, 253 insertions(+)
  35. create mode 100644 pppd/sparc-termbits.h
  36. diff --git a/pppd/sparc-termbits.h b/pppd/sparc-termbits.h
  37. new file mode 100644
  38. index 0000000..f92a27a
  39. --- /dev/null
  40. +++ b/pppd/sparc-termbits.h
  41. @@ -0,0 +1,247 @@
  42. +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  43. +#ifndef _SPARC_TERMBITS_H
  44. +#define _SPARC_TERMBITS_H
  45. +
  46. +#include <linux/posix_types.h>
  47. +
  48. +typedef unsigned char cc_t;
  49. +typedef unsigned int speed_t;
  50. +
  51. +#if defined(__sparc__) && defined(__arch64__)
  52. +typedef unsigned int tcflag_t;
  53. +#else
  54. +typedef unsigned long tcflag_t;
  55. +#endif
  56. +
  57. +#define NCCS 17
  58. +struct termios {
  59. + tcflag_t c_iflag; /* input mode flags */
  60. + tcflag_t c_oflag; /* output mode flags */
  61. + tcflag_t c_cflag; /* control mode flags */
  62. + tcflag_t c_lflag; /* local mode flags */
  63. + cc_t c_line; /* line discipline */
  64. + cc_t c_cc[NCCS]; /* control characters */
  65. +};
  66. +
  67. +struct termios2 {
  68. + tcflag_t c_iflag; /* input mode flags */
  69. + tcflag_t c_oflag; /* output mode flags */
  70. + tcflag_t c_cflag; /* control mode flags */
  71. + tcflag_t c_lflag; /* local mode flags */
  72. + cc_t c_line; /* line discipline */
  73. + cc_t c_cc[NCCS+2]; /* control characters */
  74. + speed_t c_ispeed; /* input speed */
  75. + speed_t c_ospeed; /* output speed */
  76. +};
  77. +
  78. +struct ktermios {
  79. + tcflag_t c_iflag; /* input mode flags */
  80. + tcflag_t c_oflag; /* output mode flags */
  81. + tcflag_t c_cflag; /* control mode flags */
  82. + tcflag_t c_lflag; /* local mode flags */
  83. + cc_t c_line; /* line discipline */
  84. + cc_t c_cc[NCCS+2]; /* control characters */
  85. + speed_t c_ispeed; /* input speed */
  86. + speed_t c_ospeed; /* output speed */
  87. +};
  88. +
  89. +/* c_cc characters */
  90. +#define VINTR 0
  91. +#define VQUIT 1
  92. +#define VERASE 2
  93. +#define VKILL 3
  94. +#define VEOF 4
  95. +#define VEOL 5
  96. +#define VEOL2 6
  97. +#define VSWTC 7
  98. +#define VSTART 8
  99. +#define VSTOP 9
  100. +
  101. +
  102. +
  103. +#define VSUSP 10
  104. +#define VDSUSP 11 /* SunOS POSIX nicety I do believe... */
  105. +#define VREPRINT 12
  106. +#define VDISCARD 13
  107. +#define VWERASE 14
  108. +#define VLNEXT 15
  109. +
  110. +/* Kernel keeps vmin/vtime separated, user apps assume vmin/vtime is
  111. + * shared with eof/eol
  112. + */
  113. +#define VMIN VEOF
  114. +#define VTIME VEOL
  115. +
  116. +/* c_iflag bits */
  117. +#define IGNBRK 0x00000001
  118. +#define BRKINT 0x00000002
  119. +#define IGNPAR 0x00000004
  120. +#define PARMRK 0x00000008
  121. +#define INPCK 0x00000010
  122. +#define ISTRIP 0x00000020
  123. +#define INLCR 0x00000040
  124. +#define IGNCR 0x00000080
  125. +#define ICRNL 0x00000100
  126. +#define IUCLC 0x00000200
  127. +#define IXON 0x00000400
  128. +#define IXANY 0x00000800
  129. +#define IXOFF 0x00001000
  130. +#define IMAXBEL 0x00002000
  131. +#define IUTF8 0x00004000
  132. +
  133. +/* c_oflag bits */
  134. +#define OPOST 0x00000001
  135. +#define OLCUC 0x00000002
  136. +#define ONLCR 0x00000004
  137. +#define OCRNL 0x00000008
  138. +#define ONOCR 0x00000010
  139. +#define ONLRET 0x00000020
  140. +#define OFILL 0x00000040
  141. +#define OFDEL 0x00000080
  142. +#define NLDLY 0x00000100
  143. +#define NL0 0x00000000
  144. +#define NL1 0x00000100
  145. +#define CRDLY 0x00000600
  146. +#define CR0 0x00000000
  147. +#define CR1 0x00000200
  148. +#define CR2 0x00000400
  149. +#define CR3 0x00000600
  150. +#define TABDLY 0x00001800
  151. +#define TAB0 0x00000000
  152. +#define TAB1 0x00000800
  153. +#define TAB2 0x00001000
  154. +#define TAB3 0x00001800
  155. +#define XTABS 0x00001800
  156. +#define BSDLY 0x00002000
  157. +#define BS0 0x00000000
  158. +#define BS1 0x00002000
  159. +#define VTDLY 0x00004000
  160. +#define VT0 0x00000000
  161. +#define VT1 0x00004000
  162. +#define FFDLY 0x00008000
  163. +#define FF0 0x00000000
  164. +#define FF1 0x00008000
  165. +#define PAGEOUT 0x00010000 /* SUNOS specific */
  166. +#define WRAP 0x00020000 /* SUNOS specific */
  167. +
  168. +/* c_cflag bit meaning */
  169. +#define CBAUD 0x0000100f
  170. +#define B0 0x00000000 /* hang up */
  171. +#define B50 0x00000001
  172. +#define B75 0x00000002
  173. +#define B110 0x00000003
  174. +#define B134 0x00000004
  175. +#define B150 0x00000005
  176. +#define B200 0x00000006
  177. +#define B300 0x00000007
  178. +#define B600 0x00000008
  179. +#define B1200 0x00000009
  180. +#define B1800 0x0000000a
  181. +#define B2400 0x0000000b
  182. +#define B4800 0x0000000c
  183. +#define B9600 0x0000000d
  184. +#define B19200 0x0000000e
  185. +#define B38400 0x0000000f
  186. +#define EXTA B19200
  187. +#define EXTB B38400
  188. +#define CSIZE 0x00000030
  189. +#define CS5 0x00000000
  190. +#define CS6 0x00000010
  191. +#define CS7 0x00000020
  192. +#define CS8 0x00000030
  193. +#define CSTOPB 0x00000040
  194. +#define CREAD 0x00000080
  195. +#define PARENB 0x00000100
  196. +#define PARODD 0x00000200
  197. +#define HUPCL 0x00000400
  198. +#define CLOCAL 0x00000800
  199. +#define CBAUDEX 0x00001000
  200. +/* We'll never see these speeds with the Zilogs, but for completeness... */
  201. +#define BOTHER 0x00001000
  202. +#define B57600 0x00001001
  203. +#define B115200 0x00001002
  204. +#define B230400 0x00001003
  205. +#define B460800 0x00001004
  206. +/* This is what we can do with the Zilogs. */
  207. +#define B76800 0x00001005
  208. +/* This is what we can do with the SAB82532. */
  209. +#define B153600 0x00001006
  210. +#define B307200 0x00001007
  211. +#define B614400 0x00001008
  212. +#define B921600 0x00001009
  213. +/* And these are the rest... */
  214. +#define B500000 0x0000100a
  215. +#define B576000 0x0000100b
  216. +#define B1000000 0x0000100c
  217. +#define B1152000 0x0000100d
  218. +#define B1500000 0x0000100e
  219. +#define B2000000 0x0000100f
  220. +/* These have totally bogus values and nobody uses them
  221. + so far. Later on we'd have to use say 0x10000x and
  222. + adjust CBAUD constant and drivers accordingly.
  223. +#define B2500000 0x00001010
  224. +#define B3000000 0x00001011
  225. +#define B3500000 0x00001012
  226. +#define B4000000 0x00001013 */
  227. +#define CIBAUD 0x100f0000 /* input baud rate (not used) */
  228. +#define CMSPAR 0x40000000 /* mark or space (stick) parity */
  229. +#define CRTSCTS 0x80000000 /* flow control */
  230. +
  231. +#define IBSHIFT 16 /* Shift from CBAUD to CIBAUD */
  232. +
  233. +/* c_lflag bits */
  234. +#define ISIG 0x00000001
  235. +#define ICANON 0x00000002
  236. +#define XCASE 0x00000004
  237. +#define ECHO 0x00000008
  238. +#define ECHOE 0x00000010
  239. +#define ECHOK 0x00000020
  240. +#define ECHONL 0x00000040
  241. +#define NOFLSH 0x00000080
  242. +#define TOSTOP 0x00000100
  243. +#define ECHOCTL 0x00000200
  244. +#define ECHOPRT 0x00000400
  245. +#define ECHOKE 0x00000800
  246. +#define DEFECHO 0x00001000 /* SUNOS thing, what is it? */
  247. +#define FLUSHO 0x00002000
  248. +#define PENDIN 0x00004000
  249. +#define IEXTEN 0x00008000
  250. +#define EXTPROC 0x00010000
  251. +
  252. +/* modem lines */
  253. +#define TIOCM_LE 0x001
  254. +#define TIOCM_DTR 0x002
  255. +#define TIOCM_RTS 0x004
  256. +#define TIOCM_ST 0x008
  257. +#define TIOCM_SR 0x010
  258. +#define TIOCM_CTS 0x020
  259. +#define TIOCM_CAR 0x040
  260. +#define TIOCM_RNG 0x080
  261. +#define TIOCM_DSR 0x100
  262. +#define TIOCM_CD TIOCM_CAR
  263. +#define TIOCM_RI TIOCM_RNG
  264. +#define TIOCM_OUT1 0x2000
  265. +#define TIOCM_OUT2 0x4000
  266. +#define TIOCM_LOOP 0x8000
  267. +
  268. +/* ioctl (fd, TIOCSERGETLSR, &result) where result may be as below */
  269. +#define TIOCSER_TEMT 0x01 /* Transmitter physically empty */
  270. +
  271. +
  272. +/* tcflow() and TCXONC use these */
  273. +#define TCOOFF 0
  274. +#define TCOON 1
  275. +#define TCIOFF 2
  276. +#define TCION 3
  277. +
  278. +/* tcflush() and TCFLSH use these */
  279. +#define TCIFLUSH 0
  280. +#define TCOFLUSH 1
  281. +#define TCIOFLUSH 2
  282. +
  283. +/* tcsetattr uses these */
  284. +#define TCSANOW 0
  285. +#define TCSADRAIN 1
  286. +#define TCSAFLUSH 2
  287. +
  288. +#endif /* _SPARC_TERMBITS_H */
  289. diff --git a/pppd/termios_linux.h b/pppd/termios_linux.h
  290. index a234d30..9812017 100644
  291. --- a/pppd/termios_linux.h
  292. +++ b/pppd/termios_linux.h
  293. @@ -32,7 +32,13 @@
  294. #include <sys/ioctl.h>
  295. #include <sys/types.h>
  296. #include <asm/ioctls.h>
  297. +#include <linux/version.h>
  298. +
  299. +#if defined(__sparc__) && LINUX_VERSION_CODE < KERNEL_VERSION(6,10,0)
  300. +#include "sparc-termbits.h"
  301. +#else
  302. #include <asm/termbits.h>
  303. +#endif
  304. #if defined(BOTHER) && defined(TCGETS2)
  305. #define termios termios2
  306. --
  307. 2.45.2