0016-contrib-zvbi-fix-compilation-with-clang.patch 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. From bdb8e1579896b8787115b759d34d1a000649b126 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Felix=20Paul=20K=C3=BChne?= <fkuehne@videolan.org>
  3. Date: Thu, 8 Aug 2013 21:41:46 +0200
  4. Subject: [PATCH 2/2] contrib/zvbi: fix compilation with clang
  5. ---
  6. contrib/src/zvbi/rules.mak | 3 +
  7. contrib/src/zvbi/zvbi-fix-clang-support.patch | 455 ++++++++++++++++++++++++++
  8. 2 files changed, 458 insertions(+)
  9. create mode 100644 contrib/src/zvbi/zvbi-fix-clang-support.patch
  10. diff --git a/contrib/src/zvbi/rules.mak b/contrib/src/zvbi/rules.mak
  11. index a34c2ca..7584eed 100644
  12. --- a/contrib/src/zvbi/rules.mak
  13. +++ b/contrib/src/zvbi/rules.mak
  14. @@ -20,6 +20,9 @@ zvbi: zvbi-$(ZVBI_VERSION).tar.bz2 .sum-zvbi
  15. ifdef HAVE_WIN32
  16. $(APPLY) $(SRC)/zvbi/zvbi-win32.patch
  17. endif
  18. +ifdef HAVE_DARWIN_OS
  19. + $(APPLY) $(SRC)/zvbi/zvbi-fix-clang-support.patch
  20. +endif
  21. $(MOVE)
  22. DEPS_zvbi = pthreads iconv $(DEPS_iconv)
  23. diff --git a/contrib/src/zvbi/zvbi-fix-clang-support.patch b/contrib/src/zvbi/zvbi-fix-clang-support.patch
  24. new file mode 100644
  25. index 0000000..5226a3c
  26. --- /dev/null
  27. +++ b/contrib/src/zvbi/zvbi-fix-clang-support.patch
  28. @@ -0,0 +1,455 @@
  29. +diff -ru zvbi/src/misc.h zvbi-fixed/src/misc.h
  30. +--- zvbi/src/misc.h 2013-07-02 04:32:31.000000000 +0200
  31. ++++ zvbi-fixed/src/misc.h 2013-08-08 21:37:22.000000000 +0200
  32. +@@ -52,17 +52,6 @@
  33. + # define unlikely(expr) __builtin_expect(expr, 0)
  34. + #endif
  35. +
  36. +-#undef __i386__
  37. +-#undef __i686__
  38. +-/* FIXME #cpu is deprecated
  39. +-#if #cpu (i386)
  40. +-# define __i386__ 1
  41. +-#endif
  42. +-#if #cpu (i686)
  43. +-# define __i686__ 1
  44. +-#endif
  45. +-*/
  46. +-
  47. + /* &x == PARENT (&x.tm_min, struct tm, tm_min),
  48. + safer than &x == (struct tm *) &x.tm_min. A NULL _ptr is safe and
  49. + will return NULL, not -offsetof(_member). */
  50. +@@ -156,8 +145,6 @@
  51. +
  52. + #define likely(expr) (expr)
  53. + #define unlikely(expr) (expr)
  54. +-#undef __i386__
  55. +-#undef __i686__
  56. +
  57. + static char *
  58. + PARENT_HELPER (char *p, unsigned int offset)
  59. +diff -ru zvbi/src/packet.c zvbi-fixed/src/packet.c
  60. +--- zvbi/src/packet.c 2013-07-10 13:37:28.000000000 +0200
  61. ++++ zvbi-fixed/src/packet.c 2013-08-08 21:36:48.000000000 +0200
  62. +@@ -1859,24 +1859,22 @@
  63. + int i, j, err = 0;
  64. +
  65. + /* XXX nested function not portable, to be removed */
  66. +- int
  67. +- bits(int count)
  68. +- {
  69. +- int r, n;
  70. +-
  71. +- r = buf;
  72. +-
  73. +- if ((n = count - left) > 0) {
  74. +- r |= (buf = *triplet++) << left;
  75. +- left = 18;
  76. +- } else
  77. +- n = count;
  78. +-
  79. +- buf >>= n;
  80. +- left -= n;
  81. +-
  82. +- return r & ((1UL << count) - 1);
  83. +- }
  84. ++#define bits(count) ({ \
  85. ++ int r, n; \
  86. ++ \
  87. ++ r = buf; \
  88. ++ \
  89. ++ if ((n = count - left) > 0) { \
  90. ++ r |= (buf = *triplet++) << left; \
  91. ++ left = 18; \
  92. ++ } else \
  93. ++ n = count; \
  94. ++ \
  95. ++ buf >>= n; \
  96. ++ left -= n; \
  97. ++ \
  98. ++ (r & ((1UL << count) - 1)); \
  99. ++ })
  100. +
  101. + if ((designation = vbi_unham8 (*p)) < 0)
  102. + return FALSE;
  103. +Only in zvbi-fixed/src: packet.c.orig
  104. +diff -ru zvbi/src/teletext.c zvbi-fixed/src/teletext.c
  105. +--- zvbi/src/teletext.c 2013-07-02 06:03:54.000000000 +0200
  106. ++++ zvbi-fixed/src/teletext.c 2013-08-08 21:37:06.000000000 +0200
  107. +@@ -1258,180 +1258,177 @@
  108. + int pdc_hr;
  109. +
  110. + /* XXX nested function not portable, to be removed */
  111. +- void
  112. +- flush(int column)
  113. +- {
  114. +- int row = inv_row + active_row;
  115. +- int i;
  116. +-
  117. +- if (row >= ROWS)
  118. +- return;
  119. +-
  120. +- if (type == OBJECT_TYPE_PASSIVE && !mac.unicode) {
  121. +- active_column = column;
  122. +- return;
  123. +- }
  124. +-
  125. +- printv("flush [%04x%c,F%d%c,B%d%c,S%d%c,O%d%c,H%d%c] %d ... %d\n",
  126. +- ac.unicode, mac.unicode ? '*' : ' ',
  127. +- ac.foreground, mac.foreground ? '*' : ' ',
  128. +- ac.background, mac.background ? '*' : ' ',
  129. +- ac.size, mac.size ? '*' : ' ',
  130. +- ac.opacity, mac.opacity ? '*' : ' ',
  131. +- ac.flash, mac.flash ? '*' : ' ',
  132. +- active_column, column - 1);
  133. +-
  134. +- for (i = inv_column + active_column; i < inv_column + column;) {
  135. +- vbi_char c;
  136. +-
  137. +- if (i > 39)
  138. +- break;
  139. +-
  140. +- c = acp[i];
  141. +-
  142. +- if (mac.underline) {
  143. +- int u = ac.underline;
  144. +-
  145. +- if (!mac.unicode)
  146. +- ac.unicode = c.unicode;
  147. +-
  148. +- if (vbi_is_gfx(ac.unicode)) {
  149. +- if (u)
  150. +- ac.unicode &= ~0x20; /* separated */
  151. +- else
  152. +- ac.unicode |= 0x20; /* contiguous */
  153. +- mac.unicode = ~0;
  154. +- u = 0;
  155. +- }
  156. +-
  157. +- c.underline = u;
  158. +- }
  159. +- if (mac.foreground)
  160. +- c.foreground = (ac.foreground != VBI_TRANSPARENT_BLACK) ?
  161. +- ac.foreground : (row_color_transparent) ?
  162. +- VBI_TRANSPARENT_BLACK : row_color;
  163. +- if (mac.background)
  164. +- c.background = (ac.background != VBI_TRANSPARENT_BLACK) ?
  165. +- ac.background : (row_color_transparent) ?
  166. +- VBI_TRANSPARENT_BLACK : row_color;
  167. +- if (invert) {
  168. +- int t = c.foreground;
  169. +-
  170. +- c.foreground = c.background;
  171. +- c.background = t;
  172. +- }
  173. +- if (mac.opacity)
  174. +- c.opacity = ac.opacity;
  175. +- if (mac.flash)
  176. +- c.flash = ac.flash;
  177. +- if (mac.conceal)
  178. +- c.conceal = ac.conceal;
  179. +- if (mac.unicode) {
  180. +- c.unicode = ac.unicode;
  181. +- mac.unicode = 0;
  182. +-
  183. +- if (mac.size)
  184. +- c.size = ac.size;
  185. +- else if (c.size > VBI_DOUBLE_SIZE)
  186. +- c.size = VBI_NORMAL_SIZE;
  187. +- }
  188. +-
  189. +- acp[i] = c;
  190. +-
  191. +- if (type == OBJECT_TYPE_PASSIVE)
  192. +- break;
  193. +-
  194. +- i++;
  195. +-
  196. +- if (type != OBJECT_TYPE_PASSIVE
  197. +- && type != OBJECT_TYPE_ADAPTIVE) {
  198. +- int raw;
  199. +-
  200. +- raw = (row == 0 && i < 9) ?
  201. +- 0x20 : vbi_unpar8 (vtp->data.lop.raw[row][i - 1]);
  202. +-
  203. +- /* set-after spacing attributes cancelling non-spacing */
  204. +-
  205. +- switch (raw) {
  206. +- case 0x00 ... 0x07: /* alpha + foreground color */
  207. +- case 0x10 ... 0x17: /* mosaic + foreground color */
  208. +- printv("... fg term %d %02x\n", i, raw);
  209. +- mac.foreground = 0;
  210. +- mac.conceal = 0;
  211. +- break;
  212. +-
  213. +- case 0x08: /* flash */
  214. +- mac.flash = 0;
  215. +- break;
  216. +-
  217. +- case 0x0A: /* end box */
  218. +- case 0x0B: /* start box */
  219. +- if (i < COLUMNS && vbi_unpar8 (vtp->data.lop.raw[row][i]) == raw) {
  220. +- printv("... boxed term %d %02x\n", i, raw);
  221. +- mac.opacity = 0;
  222. +- }
  223. +-
  224. +- break;
  225. +-
  226. +- case 0x0D: /* double height */
  227. +- case 0x0E: /* double width */
  228. +- case 0x0F: /* double size */
  229. +- printv("... size term %d %02x\n", i, raw);
  230. +- mac.size = 0;
  231. +- break;
  232. +- }
  233. +-
  234. +- if (i > 39)
  235. +- break;
  236. +-
  237. +- raw = (row == 0 && i < 8) ?
  238. +- 0x20 : vbi_unpar8 (vtp->data.lop.raw[row][i]);
  239. +-
  240. +- /* set-at spacing attributes cancelling non-spacing */
  241. +-
  242. +- switch (raw) {
  243. +- case 0x09: /* steady */
  244. +- mac.flash = 0;
  245. +- break;
  246. +-
  247. +- case 0x0C: /* normal size */
  248. +- printv("... size term %d %02x\n", i, raw);
  249. +- mac.size = 0;
  250. +- break;
  251. +-
  252. +- case 0x18: /* conceal */
  253. +- mac.conceal = 0;
  254. +- break;
  255. +-
  256. +- /*
  257. +- * Non-spacing underlined/separated display attribute
  258. +- * cannot be cancelled by a subsequent spacing attribute.
  259. +- */
  260. +-
  261. +- case 0x1C: /* black background */
  262. +- case 0x1D: /* new background */
  263. +- printv("... bg term %d %02x\n", i, raw);
  264. +- mac.background = 0;
  265. +- break;
  266. +- }
  267. +- }
  268. +- }
  269. +-
  270. +- active_column = column;
  271. +- }
  272. ++#define flush(column) \
  273. ++ ({ \
  274. ++ int row = inv_row + active_row; \
  275. ++ int i; \
  276. ++ \
  277. ++ if (row >= ROWS) \
  278. ++ break; \
  279. ++ \
  280. ++ if (type == OBJECT_TYPE_PASSIVE && !mac.unicode) { \
  281. ++ active_column = column; \
  282. ++ break; \
  283. ++ } \
  284. ++ \
  285. ++ printv("flush [%04x%c,F%d%c,B%d%c,S%d%c,O%d%c,H%d%c] %d ... %d\n", \
  286. ++ ac.unicode, mac.unicode ? '*' : ' ', \
  287. ++ ac.foreground, mac.foreground ? '*' : ' ', \
  288. ++ ac.background, mac.background ? '*' : ' ', \
  289. ++ ac.size, mac.size ? '*' : ' ', \
  290. ++ ac.opacity, mac.opacity ? '*' : ' ', \
  291. ++ ac.flash, mac.flash ? '*' : ' ', \
  292. ++ active_column, column - 1); \
  293. ++ \
  294. ++ for (i = inv_column + active_column; i < inv_column + column;) { \
  295. ++ vbi_char c; \
  296. ++ \
  297. ++ if (i > 39) \
  298. ++ break; \
  299. ++ \
  300. ++ c = acp[i]; \
  301. ++ \
  302. ++ if (mac.underline) { \
  303. ++ int u = ac.underline; \
  304. ++ \
  305. ++ if (!mac.unicode) \
  306. ++ ac.unicode = c.unicode; \
  307. ++ \
  308. ++ if (vbi_is_gfx(ac.unicode)) { \
  309. ++ if (u) \
  310. ++ ac.unicode &= ~0x20; /* separated */ \
  311. ++ else \
  312. ++ ac.unicode |= 0x20; /* contiguous */ \
  313. ++ mac.unicode = ~0; \
  314. ++ u = 0; \
  315. ++ } \
  316. ++ \
  317. ++ c.underline = u; \
  318. ++ } \
  319. ++ if (mac.foreground) \
  320. ++ c.foreground = (ac.foreground != VBI_TRANSPARENT_BLACK) ? \
  321. ++ ac.foreground : (row_color_transparent) ? \
  322. ++ VBI_TRANSPARENT_BLACK : row_color; \
  323. ++ if (mac.background) \
  324. ++ c.background = (ac.background != VBI_TRANSPARENT_BLACK) ? \
  325. ++ ac.background : (row_color_transparent) ? \
  326. ++ VBI_TRANSPARENT_BLACK : row_color; \
  327. ++ if (invert) { \
  328. ++ int t = c.foreground; \
  329. ++ \
  330. ++ c.foreground = c.background; \
  331. ++ c.background = t; \
  332. ++ } \
  333. ++ if (mac.opacity) \
  334. ++ c.opacity = ac.opacity; \
  335. ++ if (mac.flash) \
  336. ++ c.flash = ac.flash; \
  337. ++ if (mac.conceal) \
  338. ++ c.conceal = ac.conceal; \
  339. ++ if (mac.unicode) { \
  340. ++ c.unicode = ac.unicode; \
  341. ++ mac.unicode = 0; \
  342. ++ \
  343. ++ if (mac.size) \
  344. ++ c.size = ac.size; \
  345. ++ else if (c.size > VBI_DOUBLE_SIZE) \
  346. ++ c.size = VBI_NORMAL_SIZE; \
  347. ++ } \
  348. ++ \
  349. ++ acp[i] = c; \
  350. ++ \
  351. ++ if (type == OBJECT_TYPE_PASSIVE) \
  352. ++ break; \
  353. ++ \
  354. ++ i++; \
  355. ++ \
  356. ++ if (type != OBJECT_TYPE_PASSIVE \
  357. ++ && type != OBJECT_TYPE_ADAPTIVE) { \
  358. ++ int raw; \
  359. ++ \
  360. ++ raw = (row == 0 && i < 9) ? \
  361. ++ 0x20 : vbi_unpar8 (vtp->data.lop.raw[row][i - 1]); \
  362. ++ \
  363. ++ /* set-after spacing attributes cancelling non-spacing */ \
  364. ++ \
  365. ++ switch (raw) { \
  366. ++ case 0x00 ... 0x07: /* alpha + foreground color */ \
  367. ++ case 0x10 ... 0x17: /* mosaic + foreground color */ \
  368. ++ printv("... fg term %d %02x\n", i, raw); \
  369. ++ mac.foreground = 0; \
  370. ++ mac.conceal = 0; \
  371. ++ break; \
  372. ++ \
  373. ++ case 0x08: /* flash */ \
  374. ++ mac.flash = 0; \
  375. ++ break; \
  376. ++ \
  377. ++ case 0x0A: /* end box */ \
  378. ++ case 0x0B: /* start box */ \
  379. ++ if (i < COLUMNS && vbi_unpar8 (vtp->data.lop.raw[row][i]) == raw) { \
  380. ++ printv("... boxed term %d %02x\n", i, raw); \
  381. ++ mac.opacity = 0; \
  382. ++ } \
  383. ++ \
  384. ++ break; \
  385. ++ \
  386. ++ case 0x0D: /* double height */ \
  387. ++ case 0x0E: /* double width */ \
  388. ++ case 0x0F: /* double size */ \
  389. ++ printv("... size term %d %02x\n", i, raw); \
  390. ++ mac.size = 0; \
  391. ++ break; \
  392. ++ } \
  393. ++ \
  394. ++ if (i > 39) \
  395. ++ break; \
  396. ++ \
  397. ++ raw = (row == 0 && i < 8) ? \
  398. ++ 0x20 : vbi_unpar8 (vtp->data.lop.raw[row][i]); \
  399. ++ \
  400. ++ /* set-at spacing attributes cancelling non-spacing */ \
  401. ++ \
  402. ++ switch (raw) { \
  403. ++ case 0x09: /* steady */ \
  404. ++ mac.flash = 0; \
  405. ++ break; \
  406. ++ \
  407. ++ case 0x0C: /* normal size */ \
  408. ++ printv("... size term %d %02x\n", i, raw); \
  409. ++ mac.size = 0; \
  410. ++ break; \
  411. ++ \
  412. ++ case 0x18: /* conceal */ \
  413. ++ mac.conceal = 0; \
  414. ++ break; \
  415. ++ \
  416. ++ /* \
  417. ++ * Non-spacing underlined/separated display attribute \
  418. ++ * cannot be cancelled by a subsequent spacing attribute. \
  419. ++ */ \
  420. ++ \
  421. ++ case 0x1C: /* black background */ \
  422. ++ case 0x1D: /* new background */ \
  423. ++ printv("... bg term %d %02x\n", i, raw); \
  424. ++ mac.background = 0; \
  425. ++ break; \
  426. ++ } \
  427. ++ } \
  428. ++ } \
  429. ++ \
  430. ++ active_column = column; \
  431. ++ })
  432. +
  433. + /* XXX nested function not portable, to be removed */
  434. +- void
  435. +- flush_row(void)
  436. +- {
  437. +- if (type == OBJECT_TYPE_PASSIVE || type == OBJECT_TYPE_ADAPTIVE)
  438. +- flush(active_column + 1);
  439. +- else
  440. +- flush(COLUMNS);
  441. +-
  442. +- if (type != OBJECT_TYPE_PASSIVE)
  443. +- memset(&mac, 0, sizeof(mac));
  444. +- }
  445. ++#define flush_row do {\
  446. ++ if (type == OBJECT_TYPE_PASSIVE || type == OBJECT_TYPE_ADAPTIVE) \
  447. ++ flush(active_column + 1); \
  448. ++ else \
  449. ++ flush(COLUMNS); \
  450. ++\
  451. ++ if (type != OBJECT_TYPE_PASSIVE) \
  452. ++ memset(&mac, 0, sizeof(mac)); \
  453. ++ } while (0)
  454. +
  455. + active_column = 0;
  456. + active_row = 0;
  457. +@@ -1554,7 +1551,7 @@
  458. + printv("enh set_active row %d col %d\n", row, column);
  459. +
  460. + if (row > active_row)
  461. +- flush_row();
  462. ++ flush_row;
  463. + else
  464. + flush(active_column + 1);
  465. +
  466. +@@ -1752,7 +1749,7 @@
  467. + break;
  468. +
  469. + case 0x15 ... 0x17: /* object definition */
  470. +- flush_row();
  471. ++ flush_row;
  472. + printv("enh obj definition 0x%02x 0x%02x\n", p->mode, p->data);
  473. + printv("enh terminated\n");
  474. + goto swedish;
  475. +@@ -1768,7 +1765,7 @@
  476. + case 0x1F: /* termination marker */
  477. + default:
  478. + terminate:
  479. +- flush_row();
  480. ++ flush_row;
  481. + printv("enh terminated %02x\n", p->mode);
  482. + goto swedish;
  483. + }
  484. --
  485. 1.8.3.1 (Apple Git-46)