GCC with OpenMP stream-computing extension and BatchQueue algorithm
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

4490 lines
138 KiB

  1. /* -*- Mode: C -*- */
  2. autogen definitions fixincl;
  3. /* Define all the fixes we know about for repairing damaged headers.
  4. Please see the README before adding or changing entries in this file.
  5. This is the sort command:
  6. blocksort output=inclhack.sorted \
  7. pattern='^/\*$' \
  8. trailer='^/\*EOF\*[/]' \
  9. input=inclhack.def \
  10. key='hackname[ ]*=[ ]*(.*);'
  11. Set up a debug test so we can make the templates emit special
  12. code while debugging these fixes: */
  13. #ifdef DEBUG
  14. FIXINC_DEBUG = yes;
  15. #endif
  16. /* On AIX when _LARGE_FILES is defined stdio.h defines fopen to
  17. * fopen64 etc. and this causes problems when building with g++
  18. * because cstdio udefs everything from stdio.h, leaving us with
  19. * ::fopen has not been declared errors. This fixes stdio.h to
  20. * undef those defines and use __asm__ to alias the symbols if
  21. * building with g++ and -D_LARGE_FILES
  22. */
  23. fix = {
  24. hackname = AAB_aix_stdio;
  25. files = stdio.h;
  26. select = "define fopen fopen64";
  27. mach = "*-*-aix*";
  28. test-text = ''; /* no way to test */
  29. c_fix = wrap;
  30. c_fix_arg = "";
  31. c_fix_arg = <<- _EOArg_
  32. #if defined __GNUG__ && defined _LARGE_FILES && defined __cplusplus
  33. #define __need__aix_stdio_h_fix
  34. #ifdef __need__aix_stdio_h_fix
  35. #undef fseeko
  36. #undef ftello
  37. #undef fgetpos
  38. #undef fsetpos
  39. #undef fopen
  40. #undef freopen
  41. /* Alias the symbols using asm */
  42. extern "C" {
  43. extern int fgetpos(FILE *, fpos64_t *) __asm__("fgetpos64");
  44. extern FILE *fopen(const char *, const char *) __asm__("fopen64");
  45. extern FILE *freopen(const char *, const char *, FILE *) __asm__("freopen64");
  46. extern int fseeko(FILE *, off64_t, int) __asm__("fseeko64");
  47. extern int fsetpos(FILE *, const fpos64_t *) __asm__("fsetpos64");
  48. extern off64_t ftello(FILE *) __asm__("ftello64");
  49. }
  50. #endif
  51. #endif
  52. _EOArg_;
  53. };
  54. /*
  55. * On Mac OS 10.3.9, the 'long double' functions are available in
  56. * libSystem, but are not prototyped in math.h.
  57. */
  58. fix = {
  59. hackname = AAB_darwin7_9_long_double_funcs;
  60. mach = "*-*-darwin7.9*";
  61. files = architecture/ppc/math.h;
  62. bypass = "powl";
  63. replace = <<- _EndOfHeader_
  64. /* This file prototypes the long double functions available on Mac OS
  65. 10.3.9. */
  66. #ifndef __MATH__
  67. # undef __APPLE_CC__
  68. # define __APPLE_CC__ 1345
  69. # include_next <architecture/ppc/math.h>
  70. # undef __APPLE_CC__
  71. # define __APPLE_CC__ 1
  72. # ifndef __LIBMLDBL_COMPAT
  73. # ifdef __LONG_DOUBLE_128__
  74. # define __LIBMLDBL_COMPAT(sym) __asm("_" #sym "$LDBL128")
  75. # else
  76. # define __LIBMLDBL_COMPAT(sym)
  77. # endif /* __LONG_DOUBLE_128__ */
  78. # endif /* __LIBMLDBL_COMPAT */
  79. # ifdef __cplusplus
  80. extern "C" {
  81. # endif
  82. extern long double acosl( long double ) __LIBMLDBL_COMPAT(acosl);
  83. extern long double asinl( long double ) __LIBMLDBL_COMPAT(asinl);
  84. extern long double atanl( long double ) __LIBMLDBL_COMPAT(atanl);
  85. extern long double atan2l( long double, long double ) __LIBMLDBL_COMPAT(atan2l);
  86. extern long double cosl( long double ) __LIBMLDBL_COMPAT(cosl);
  87. extern long double sinl( long double ) __LIBMLDBL_COMPAT(sinl);
  88. extern long double tanl( long double ) __LIBMLDBL_COMPAT(tanl);
  89. extern long double acoshl( long double ) __LIBMLDBL_COMPAT(acoshl);
  90. extern long double asinhl( long double ) __LIBMLDBL_COMPAT(asinhl);
  91. extern long double atanhl( long double ) __LIBMLDBL_COMPAT(atanhl);
  92. extern long double coshl( long double ) __LIBMLDBL_COMPAT(coshl);
  93. extern long double sinhl( long double ) __LIBMLDBL_COMPAT(sinhl);
  94. extern long double tanhl( long double ) __LIBMLDBL_COMPAT(tanhl);
  95. extern long double expl( long double ) __LIBMLDBL_COMPAT(expl);
  96. extern long double exp2l( long double ) __LIBMLDBL_COMPAT(exp2l);
  97. extern long double expm1l( long double ) __LIBMLDBL_COMPAT(expm1l);
  98. extern long double logl( long double ) __LIBMLDBL_COMPAT(logl);
  99. extern long double log10l( long double ) __LIBMLDBL_COMPAT(log10l);
  100. extern long double log2l( long double ) __LIBMLDBL_COMPAT(log2l);
  101. extern long double log1pl( long double ) __LIBMLDBL_COMPAT(log1pl);
  102. extern long double logbl( long double ) __LIBMLDBL_COMPAT(logbl);
  103. extern long double modfl( long double, long double * ) __LIBMLDBL_COMPAT(modfl);
  104. extern long double ldexpl( long double, int ) __LIBMLDBL_COMPAT(ldexpl);
  105. extern long double frexpl( long double, int * ) __LIBMLDBL_COMPAT(frexpl);
  106. extern int ilogbl( long double ) __LIBMLDBL_COMPAT(ilogbl);
  107. extern long double scalbnl( long double, int ) __LIBMLDBL_COMPAT(scalbnl);
  108. extern long double scalblnl( long double, long int ) __LIBMLDBL_COMPAT(scalblnl);
  109. extern long double fabsl( long double ) __LIBMLDBL_COMPAT(fabsl);
  110. extern long double cbrtl( long double ) __LIBMLDBL_COMPAT(cbrtl);
  111. extern long double hypotl( long double, long double ) __LIBMLDBL_COMPAT(hypotl);
  112. extern long double powl( long double, long double ) __LIBMLDBL_COMPAT(powl);
  113. extern long double sqrtl( long double ) __LIBMLDBL_COMPAT(sqrtl);
  114. extern long double erfl( long double ) __LIBMLDBL_COMPAT(erfl);
  115. extern long double erfcl( long double ) __LIBMLDBL_COMPAT(erfcl);
  116. extern long double lgammal( long double ) __LIBMLDBL_COMPAT(lgammal);
  117. extern long double tgammal( long double ) __LIBMLDBL_COMPAT(tgammal);
  118. extern long double ceill( long double ) __LIBMLDBL_COMPAT(ceill);
  119. extern long double floorl( long double ) __LIBMLDBL_COMPAT(floorl);
  120. extern long double nearbyintl( long double ) __LIBMLDBL_COMPAT(nearbyintl);
  121. extern long double rintl( long double ) __LIBMLDBL_COMPAT(rintl);
  122. extern long int lrintl( long double ) __LIBMLDBL_COMPAT(lrintl);
  123. extern long long int llrintl( long double ) __LIBMLDBL_COMPAT(llrintl);
  124. extern long double roundl( long double ) __LIBMLDBL_COMPAT(roundl);
  125. extern long int lroundl( long double ) __LIBMLDBL_COMPAT(lroundl);
  126. extern long long int llroundl( long double ) __LIBMLDBL_COMPAT(llroundl);
  127. extern long double truncl( long double ) __LIBMLDBL_COMPAT(truncl);
  128. extern long double fmodl( long double, long double) __LIBMLDBL_COMPAT(fmodl);
  129. extern long double remainderl( long double, long double ) __LIBMLDBL_COMPAT(remainderl);
  130. extern long double remquol( long double, long double, int * ) __LIBMLDBL_COMPAT(remquol);
  131. extern long double copysignl( long double, long double ) __LIBMLDBL_COMPAT(copysignl);
  132. extern long double nanl( const char * ) __LIBMLDBL_COMPAT(nanl);
  133. extern long double nextafterl( long double, long double ) __LIBMLDBL_COMPAT(nextafterl);
  134. extern long double nexttowardl( long double, long double ) __LIBMLDBL_COMPAT(nexttowardl);
  135. extern long double fdiml( long double, long double ) __LIBMLDBL_COMPAT(fdiml);
  136. extern long double fmaxl( long double, long double ) __LIBMLDBL_COMPAT(fmaxl);
  137. extern long double fminl( long double, long double ) __LIBMLDBL_COMPAT(fminl);
  138. extern long double fmal( long double, long double, long double ) __LIBMLDBL_COMPAT(fmal);
  139. # ifdef __cplusplus
  140. }
  141. # endif
  142. #endif /* __MATH__ */
  143. _EndOfHeader_;
  144. };
  145. /*
  146. * ... and for the previous fix to be useful, you have to not use ""
  147. * includes.
  148. */
  149. fix = {
  150. hackname = AAB_darwin7_9_long_double_funcs_2;
  151. mach = "*-*-darwin7.9*";
  152. files = math.h;
  153. select = '#include[ \t]+\"';
  154. c_fix = format;
  155. c_fix_arg = "%1<%2.h>";
  156. c_fix_arg = '([ \t]*#[ \t]*include[ \t]+)"([a-z0-9/]+)\.h"';
  157. test_text = '#include "architecture/ppc/math.h"';
  158. };
  159. /*
  160. * This fixes __FD_ZERO bug for linux 2.x.y (x <= 2 && y <= some n)
  161. */
  162. fix = {
  163. hackname = AAB_fd_zero_asm_posix_types_h;
  164. files = asm/posix_types.h;
  165. mach = 'i[34567]86-*-linux*';
  166. bypass = '} while';
  167. bypass = 'x86_64';
  168. bypass = 'posix_types_64';
  169. /*
  170. * Define _POSIX_TYPES_H_WRAPPER at the end of the wrapper, not
  171. * the start, so that if #include_next gets another instance of
  172. * the wrapper, this will follow the #include_next chain until
  173. * we arrive at the real <asm/posix_types.h>.
  174. */
  175. replace = <<- _EndOfHeader_
  176. /* This file fixes a bug in the __FD_ZERO macro
  177. for older versions of the Linux kernel. */
  178. #ifndef _POSIX_TYPES_H_WRAPPER
  179. #include <features.h>
  180. #include_next <asm/posix_types.h>
  181. #if defined(__FD_ZERO) && !defined(__GLIBC__)
  182. #undef __FD_ZERO
  183. #define __FD_ZERO(fdsetp) \
  184. do { \
  185. int __d0, __d1; \
  186. __asm__ __volatile__("cld ; rep ; stosl" \
  187. : "=&c" (__d0), "=&D" (__d1) \
  188. : "a" (0), "0" (__FDSET_LONGS), \
  189. "1" ((__kernel_fd_set *) (fdsetp)) :"memory"); \
  190. } while (0)
  191. #endif
  192. #define _POSIX_TYPES_H_WRAPPER
  193. #endif /* _POSIX_TYPES_H_WRAPPER */
  194. _EndOfHeader_;
  195. };
  196. /*
  197. * This fixes __FD_ZERO bug for glibc-1.x
  198. */
  199. fix = {
  200. hackname = AAB_fd_zero_gnu_types_h;
  201. files = gnu/types.h;
  202. mach = 'i[34567]86-*-linux*';
  203. /*
  204. * Define _TYPES_H_WRAPPER at the end of the wrapper, not
  205. * the start, so that if #include_next gets another instance of
  206. * the wrapper, this will follow the #include_next chain until
  207. * we arrive at the real <gnu/types.h>.
  208. */
  209. replace = <<- _EndOfHeader_
  210. /* This file fixes a bug in the __FD_ZERO macro present in glibc 1.x. */
  211. #ifndef _TYPES_H_WRAPPER
  212. #include <features.h>
  213. #include_next <gnu/types.h>
  214. #if defined(__FD_ZERO) && !defined(__GLIBC__)
  215. #undef __FD_ZERO
  216. # define __FD_ZERO(fdsetp) \
  217. do { \
  218. int __d0, __d1; \
  219. __asm__ __volatile__("cld ; rep ; stosl" \
  220. : "=&c" (__d0), "=&D" (__d1) \
  221. : "a" (0), "0" (__FDSET_LONGS), \
  222. "1" ((__fd_set *) (fdsetp)) :"memory"); \
  223. } while (0)
  224. #endif
  225. #define _TYPES_H_WRAPPER
  226. #endif /* _TYPES_H_WRAPPER */
  227. _EndOfHeader_;
  228. };
  229. /*
  230. * This fixes __FD_ZERO bug for glibc-2.0.x
  231. */
  232. fix = {
  233. hackname = AAB_fd_zero_selectbits_h;
  234. files = selectbits.h;
  235. mach = 'i[34567]86-*-linux*';
  236. /*
  237. * Define _SELECTBITS_H_WRAPPER at the end of the wrapper, not
  238. * the start, so that if #include_next gets another instance of
  239. * the wrapper, this will follow the #include_next chain until
  240. * we arrive at the real <selectbits.h>.
  241. */
  242. replace = <<- _EndOfHeader_
  243. /* This file fixes a bug in the __FD_ZERO macro present in glibc 2.0.x. */
  244. #ifndef _SELECTBITS_H_WRAPPER
  245. #include <features.h>
  246. #include_next <selectbits.h>
  247. #if defined(__FD_ZERO) && defined(__GLIBC__) \\
  248. && defined(__GLIBC_MINOR__) && __GLIBC__ == 2 \\
  249. && __GLIBC_MINOR__ == 0
  250. #undef __FD_ZERO
  251. #define __FD_ZERO(fdsetp) \\
  252. do { \\
  253. int __d0, __d1; \\
  254. __asm__ __volatile__ ("cld; rep; stosl" \\
  255. : "=&c" (__d0), "=&D" (__d1) \\
  256. : "a" (0), "0" (sizeof (__fd_set) \\
  257. / sizeof (__fd_mask)), \\
  258. "1" ((__fd_mask *) (fdsetp)) \\
  259. : "memory"); \\
  260. } while (0)
  261. #endif
  262. #define _SELECTBITS_H_WRAPPER
  263. #endif /* _SELECTBITS_H_WRAPPER */
  264. _EndOfHeader_;
  265. };
  266. /*
  267. * Solaris <sys/varargs.h> is a DDK (aka kernel-land) header providing
  268. * the same interface as <stdarg.h>. No idea why they couldn't have just
  269. * used the standard header.
  270. */
  271. fix = {
  272. hackname = AAB_solaris_sys_varargs_h;
  273. files = "sys/varargs.h";
  274. mach = '*-*-solaris*';
  275. replace = <<- _EndOfHeader_
  276. #ifdef __STDC__
  277. #include <stdarg.h>
  278. #else
  279. #include <varargs.h>
  280. #endif
  281. _EndOfHeader_;
  282. };
  283. /*
  284. * Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
  285. * declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because
  286. * many other systems have similar text but correct versions of the file.
  287. * To ensure only Sun's is fixed, we grep for a likely unique string.
  288. * Fix also on sysV68 R3V7.1 (head/memory.h\t50.1\t )
  289. */
  290. fix = {
  291. hackname = AAB_sun_memcpy;
  292. files = memory.h;
  293. select = "/\\*\t@\\(#\\)"
  294. "(head/memory.h\t50.1\t "
  295. "|memory\\.h 1\\.[2-4] 8./../.. SMI; from S5R2 1\\.2\t)\\*/";
  296. replace = <<- _EndOfHeader_
  297. /* This file was generated by fixincludes */
  298. #ifndef __memory_h__
  299. #define __memory_h__
  300. #ifdef __STDC__
  301. extern void *memccpy();
  302. extern void *memchr();
  303. extern void *memcpy();
  304. extern void *memset();
  305. #else
  306. extern char *memccpy();
  307. extern char *memchr();
  308. extern char *memcpy();
  309. extern char *memset();
  310. #endif /* __STDC__ */
  311. extern int memcmp();
  312. #endif /* __memory_h__ */
  313. _EndOfHeader_;
  314. };
  315. /*
  316. * complex.h on AIX 5 and AIX 6 define _Complex_I and I in terms of __I,
  317. * which only is provided by AIX xlc C99.
  318. */
  319. fix = {
  320. hackname = aix_complex;
  321. mach = "*-*-aix*";
  322. files = complex.h;
  323. select = "#define[ \t]_Complex_I[ \t]__I";
  324. c_fix = format;
  325. c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)";
  326. test_text = "#define _Complex_I __I\n";
  327. };
  328. /*
  329. * pthread.h on AIX 4.3.3 tries to define a macro without whitspace
  330. * which violates a requirement of ISO C.
  331. */
  332. fix = {
  333. hackname = aix_pthread;
  334. files = "pthread.h";
  335. select = "(#define [A-Za-z_0-9]+)(\\\\\n[^A-Za-z_0-9 \t\n(])";
  336. c_fix = format;
  337. c_fix_arg = "%1 %2";
  338. test_text = "#define PTHREAD_MUTEX_INITIALIZER\\\\\n"
  339. "{...init stuff...}";
  340. };
  341. /*
  342. * AIX stdint.h fixes.
  343. */
  344. fix = {
  345. hackname = aix_stdint_1;
  346. mach = "*-*-aix*";
  347. files = stdint-aix.h, stdint.h;
  348. select = "#define[ \t]UINT8_MAX[ \t]\\(255U\\)\n"
  349. "#define[ \t]UINT16_MAX[ \t]\\(65535U\\)";
  350. c_fix = format;
  351. c_fix_arg = "#define UINT8_MAX (255)\n"
  352. "#define UINT16_MAX (65535)";
  353. test_text = "#define UINT8_MAX (255U)\n"
  354. "#define UINT16_MAX (65535U)";
  355. };
  356. fix = {
  357. hackname = aix_stdint_2;
  358. mach = "*-*-aix*";
  359. files = stdint-aix.h, stdint.h;
  360. select = "#define[ \t]INTPTR_MIN[ \t]INT64_MIN\n"
  361. "#define[ \t]INTPTR_MAX[ \t]INT64_MAX\n"
  362. "#define[ \t]UINTPTR_MAX[ \t]UINT64_MAX\n"
  363. "#else\n"
  364. "#define[ \t]INTPTR_MIN[ \t]INT32_MIN\n"
  365. "#define[ \t]INTPTR_MAX[ \t]INT32_MAX\n"
  366. "#define[ \t]UINTPTR_MAX[ \t]UINT32_MAX";
  367. c_fix = format;
  368. c_fix_arg = "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
  369. "#define INTPTR_MAX 9223372036854775807L\n"
  370. "#define UINTPTR_MAX 18446744073709551615UL\n"
  371. "#else\n"
  372. "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
  373. "#define INTPTR_MAX 2147483647L\n"
  374. "#define UINTPTR_MAX 4294967295UL";
  375. test_text = "#define INTPTR_MIN INT64_MIN\n"
  376. "#define INTPTR_MAX INT64_MAX\n"
  377. "#define UINTPTR_MAX UINT64_MAX\n"
  378. "#else\n"
  379. "#define INTPTR_MIN INT32_MIN\n"
  380. "#define INTPTR_MAX INT32_MAX\n"
  381. "#define UINTPTR_MAX UINT32_MAX";
  382. };
  383. fix = {
  384. hackname = aix_stdint_3;
  385. mach = "*-*-aix*";
  386. files = stdint-aix.h, stdint.h;
  387. select = "#define[ \t]PTRDIFF_MIN[ \t]INT64_MIN\n"
  388. "#define[ \t]PTRDIFF_MAX[ \t]INT64_MAX\n"
  389. "#else\n"
  390. "#define[ \t]PTRDIFF_MIN[ \t]*INT32_MIN\n"
  391. "#define[ \t]PTRDIFF_MAX[ \t]*INT32_MAX";
  392. c_fix = format;
  393. c_fix_arg = "#define PTRDIFF_MIN (-9223372036854775807L - 1)\n"
  394. "#define PTRDIFF_MAX 9223372036854775807L\n"
  395. "#else\n"
  396. "#define PTRDIFF_MIN (-2147483647L - 1)\n"
  397. "#define PTRDIFF_MAX 2147483647L";
  398. test_text = "#define PTRDIFF_MIN INT64_MIN\n"
  399. "#define PTRDIFF_MAX INT64_MAX\n"
  400. "#else\n"
  401. "#define PTRDIFF_MIN INT32_MIN\n"
  402. "#define PTRDIFF_MAX INT32_MAX";
  403. };
  404. fix = {
  405. hackname = aix_stdint_4;
  406. mach = "*-*-aix*";
  407. files = stdint-aix.h, stdint.h;
  408. select = "#define[ \t]SIZE_MAX[ \t]UINT64_MAX\n"
  409. "#else\n"
  410. "#define[ \t]SIZE_MAX[ \t]*UINT32_MAX";
  411. c_fix = format;
  412. c_fix_arg = "#define SIZE_MAX 18446744073709551615UL\n"
  413. "#else\n"
  414. "#define SIZE_MAX 4294967295UL";
  415. test_text = "#define SIZE_MAX UINT64_MAX\n"
  416. "#else\n"
  417. "#define SIZE_MAX UINT32_MAX";
  418. };
  419. fix = {
  420. hackname = aix_stdint_5;
  421. mach = "*-*-aix*";
  422. files = stdint-aix.h, stdint.h;
  423. select = "#define[ \t]UINT8_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)\n"
  424. "#define[ \t]UINT16_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)";
  425. c_fix = format;
  426. c_fix_arg = "#define UINT8_C(c) c\n"
  427. "#define UINT16_C(c) c";
  428. test_text = "#define UINT8_C(c) __CONCAT__(c,U)\n"
  429. "#define UINT16_C(c) __CONCAT__(c,U)";
  430. };
  431. /*
  432. * sys/machine.h on AIX 4.3.3 puts whitespace between a \ and a newline
  433. * in an otherwise harmless (and #ifed out) macro definition
  434. */
  435. fix = {
  436. hackname = aix_sysmachine;
  437. files = sys/machine.h;
  438. select = "\\\\ +\n";
  439. c_fix = format;
  440. c_fix_arg = "\\\n";
  441. test_text = "#define FOO \\\n"
  442. " bar \\ \n baz \\ \n bat";
  443. };
  444. /*
  445. * sys/wait.h on AIX 5.2 defines macros that have both signed and
  446. * unsigned types in conditional expressions.
  447. */
  448. fix = {
  449. hackname = aix_syswait_2;
  450. files = sys/wait.h;
  451. select = '\? (\(\(\(\(unsigned[^)]*\)[^)]*\) >> [^)]*\) \& 0xff\) : -1)';
  452. c_fix = format;
  453. c_fix_arg = "? (int)%1";
  454. test_text = "#define WSTOPSIG(__x) (int)(WIFSTOPPED(__x) ? ((((unsigned int)__x) >> 8) & 0xff) : -1)";
  455. };
  456. /*
  457. * sys/signal.h on some versions of AIX uses volatile in the typedef of
  458. * sig_atomic_t, which causes gcc to generate a warning about duplicate
  459. * volatile when a sig_atomic_t variable is declared volatile, as
  460. * required by ANSI C.
  461. */
  462. fix = {
  463. hackname = aix_volatile;
  464. files = sys/signal.h;
  465. select = "typedef volatile int sig_atomic_t";
  466. c_fix = format;
  467. c_fix_arg = "typedef int sig_atomic_t";
  468. test_text = "typedef volatile int sig_atomic_t;";
  469. };
  470. /*
  471. * Fix __assert declaration in assert.h on Alpha OSF/1.
  472. */
  473. fix = {
  474. hackname = alpha___assert;
  475. files = "assert.h";
  476. select = '__assert\(char \*, char \*, int\)';
  477. c_fix = format;
  478. c_fix_arg = "__assert(const char *, const char *, int)";
  479. test_text = 'extern void __assert(char *, char *, int);';
  480. };
  481. /*
  482. * Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX V4/5 headers.
  483. */
  484. fix = {
  485. hackname = alpha___extern_prefix;
  486. select = "(.*)(defined\\(__DECC\\)|def[ \t]*__DECC)[ \t]*\n"
  487. "(#[ \t]*pragma[ \t]*extern_prefix.*)";
  488. mach = "alpha*-dec-osf*";
  489. c_fix = format;
  490. c_fix_arg = "%1 (defined(__DECC) || defined(__PRAGMA_EXTERN_PREFIX))\n%3";
  491. test_text = "#ifdef __DECC\n"
  492. "#pragma extern_prefix \"_P\"\n"
  493. "# if defined(__DECC)\n"
  494. "# pragma extern_prefix \"_E\"\n"
  495. "# if !defined(_LIBC_POLLUTION_H_) && defined(__DECC)\n"
  496. "# pragma extern_prefix \"\"";
  497. };
  498. /*
  499. * Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX V4/5 <standards.h>.
  500. */
  501. fix = {
  502. hackname = alpha___extern_prefix_standards;
  503. files = standards.h;
  504. select = ".*!defined\\(_LIBC_POLLUTION_H_\\) && !defined\\(__DECC\\)";
  505. mach = "alpha*-dec-osf*";
  506. c_fix = format;
  507. c_fix_arg = "%0 && !defined(__PRAGMA_EXTERN_PREFIX)";
  508. test_text = "#if (_ISO_C_SOURCE>=19990L) "
  509. "&& !defined(_LIBC_POLLUTION_H_) && !defined(__DECC)";
  510. };
  511. /*
  512. * Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX V5 <sys/mount.h> and
  513. * <sys/stat.h>. The tests for __DECC are special in various ways, so
  514. * alpha__extern_prefix cannot be used.
  515. */
  516. fix = {
  517. hackname = alpha___extern_prefix_sys_stat;
  518. files = sys/stat.h;
  519. files = sys/mount.h;
  520. select = "#[ \t]*if[ \t]*defined\\(__DECC\\)";
  521. mach = "alpha*-dec-osf5*";
  522. c_fix = format;
  523. c_fix_arg = "%0 || defined(__PRAGMA_EXTERN_PREFIX)";
  524. test_text = "# if defined(__DECC)";
  525. };
  526. /*
  527. * Fix assert macro in assert.h on Alpha OSF/1.
  528. * The superfluous int cast breaks C++.
  529. */
  530. fix = {
  531. hackname = alpha_assert;
  532. files = "assert.h";
  533. select = "(#[ \t]*" 'define assert\(EX\).*)\(\(int\) \(EX\)\)';
  534. c_fix = format;
  535. c_fix_arg = "%1(EX)";
  536. test_text = '#define assert(EX) (((int) (EX)) ? (void)0 '
  537. ': __assert(#EX, __FILE__, __LINE__))';
  538. };
  539. /*
  540. * Fix #defines under Alpha OSF/1:
  541. * The following files contain '#pragma extern_prefix "_FOO"' followed by
  542. * a '#define something(x,y,z) _FOOsomething(x,y,z)'. The intent of these
  543. * statements is to reduce namespace pollution. While these macros work
  544. * properly in most cases, they don't allow you to take a pointer to the
  545. * "something" being modified. To get around this limitation, change these
  546. * statements to be of the form '#define something _FOOsomething'.
  547. *
  548. * sed ain't egrep, lesson 2463: sed can use self-referential
  549. * regular expressions. In the substitute expression below,
  550. * "\\1" and "\\2" refer to subexpressions found earlier in the
  551. * same match. So, we continue to use sed. "extern_prefix" will
  552. * be a rare match anyway...
  553. */
  554. fix = {
  555. hackname = alpha_bad_lval;
  556. select = "^[ \t]*#[ \t]*pragma[ \t]+extern_prefix";
  557. mach = "alpha*-dec-osf*";
  558. sed =
  559. "s/^[ \t]*#[ \t]*define[ \t][ \t]*\\([^(]*\\)\\(([^)]*)\\)[ \t]*"
  560. "\\(_.*\\)\\1\\2[ \t]*$/#define \\1 \\3\\1/";
  561. test_text = '#pragma extern_prefix "_FOO"'"\n"
  562. "#define something(x,y,z) _FOOsomething(x,y,z)\n"
  563. "#define mumble _FOOmumble";
  564. };
  565. /*
  566. * Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
  567. */
  568. fix = {
  569. hackname = alpha_getopt;
  570. files = "stdio.h";
  571. files = "stdlib.h";
  572. select = 'getopt\(int, char \*\[\], *char \*\)';
  573. c_fix = format;
  574. c_fix_arg = "getopt(int, char *const[], const char *)";
  575. test_text = 'extern int getopt(int, char *[], char *);';
  576. };
  577. /*
  578. * Fix missing semicolon on Alpha OSF/4 in <net/if.h>
  579. */
  580. fix = {
  581. hackname = alpha_if_semicolon;
  582. files = net/if.h;
  583. select = "struct[ \t]+sockaddr[ \t]+vmif_paddr[ \t]+/\\*";
  584. c_fix = format;
  585. c_fix_arg = "struct sockaddr vmif_paddr;\t/*";
  586. test_text = ' struct sockaddr vmif_paddr /* protocol address */';
  587. };
  588. /*
  589. * Remove erroneous parentheses in sym.h on Alpha OSF/1.
  590. */
  591. fix = {
  592. hackname = alpha_parens;
  593. files = sym.h;
  594. select = '#ifndef\(__mips64\)';
  595. c_fix = format;
  596. c_fix_arg = "#ifndef __mips64";
  597. test_text = "#ifndef(__mips64) /* bogus */\nextern int foo;\n#endif";
  598. };
  599. /*
  600. * Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX <pthread.h>.
  601. */
  602. fix = {
  603. hackname = alpha_pthread;
  604. files = pthread.h;
  605. select = "((#[ \t]*if)([ \t]*defined[ \t]*\\(_PTHREAD_ENV_DECC\\)"
  606. "|def _PTHREAD_ENV_DECC)(.*))\n"
  607. "(#[ \t]*define _PTHREAD_USE_PTDNAM_)";
  608. mach = "alpha*-dec-osf*";
  609. c_fix = format;
  610. c_fix_arg = "%2 defined (_PTHREAD_ENV_DECC)%4 "
  611. "|| defined (__PRAGMA_EXTERN_PREFIX)\n%5";
  612. test_text = "# if defined (_PTHREAD_ENV_DECC) "
  613. "|| defined (_PTHREAD_ENV_EPCC)\n"
  614. "# define _PTHREAD_USE_PTDNAM_\n"
  615. "# endif\n"
  616. "# ifdef _PTHREAD_ENV_DECC\n"
  617. "# define _PTHREAD_USE_PTDNAM_\n"
  618. "# endif";
  619. };
  620. /*
  621. * Recognize GCC in Tru64 UNIX V5.1B <pthread.h>.
  622. */
  623. fix = {
  624. hackname = alpha_pthread_gcc;
  625. files = pthread.h;
  626. select = "#else\n# error <pthread.h>: unrecognized compiler.";
  627. mach = "alpha*-dec-osf*";
  628. c_fix = format;
  629. c_fix_arg = "#elif defined (__GNUC__)\n"
  630. "# define _PTHREAD_ENV_GCC\n"
  631. "%0";
  632. test_text = "# define _PTHREAD_ENV_INTELC\n"
  633. "#else\n"
  634. "# error <pthread.h>: unrecognized compiler.\n"
  635. "#endif";
  636. };
  637. /*
  638. * Compaq Tru64 v5.1 defines all of its PTHREAD_*_INITIALIZER macros
  639. * incorrectly, specifying less fields in the initializers than are
  640. * defined in the corresponding structure types. Use of these macros
  641. * in user code results in spurious warnings.
  642. */
  643. fix = {
  644. hackname = alpha_pthread_init;
  645. files = pthread.h;
  646. select = ' \* @\(#\).RCSfile: pthread\.h,v \$'
  647. ' .Revision: 1\.1\.33\.21 \$ \(DEC\)'
  648. ' .Date: 2000/08/15 15:30:13 \$';
  649. mach = "alpha*-dec-osf*";
  650. sed = "s@MVALID\\(.*\\)A}@MVALID\\1A, 0, 0, 0, 0, 0, 0 }@\n"
  651. "s@MVALID\\(.*\\)_}@MVALID\\1_, 0, 0, 0, 0 }@\n"
  652. "s@CVALID\\(.*\\)A}@CVALID\\1A, 0, 0, 0, 0 }@\n"
  653. "s@CVALID\\(.*\\)_}@CVALID\\1_, 0, 0 }@\n"
  654. "s@WVALID\\(.*\\)A}@WVALID\\1A, 0, 0, 0, 0, 0, 0, 0, 0, 0 }@\n"
  655. "s@WVALID\\(.*\\)_}@WVALID\\1_, 0, 0, 0, 0, 0, 0, 0 }@\n";
  656. test_text = <<- _EOText_
  657. /*
  658. * @(#)_RCSfile: pthread.h,v $ _Revision: 1.1.33.21 $ (DEC) _Date: 2000/08/15 15:30:13 $
  659. */
  660. #ifndef _PTHREAD_NOMETER_STATIC
  661. # define PTHREAD_MUTEX_INITIALIZER \
  662. {_PTHREAD_MSTATE_CONFIG, _PTHREAD_MVALID | _PTHREAD_MVF_STA}
  663. # define PTHREAD_COND_INITIALIZER \
  664. {_PTHREAD_CSTATE_SLOW, _PTHREAD_CVALID | _PTHREAD_CVF_STA}
  665. # define PTHREAD_MUTEX_INITWITHNAME_NP(_n_,_a_) \
  666. {_PTHREAD_MSTATE_CONFIG, _PTHREAD_MVALID | _PTHREAD_MVF_STA, _n_, _a_}
  667. # define PTHREAD_COND_INITWITHNAME_NP(_n_,_a_) \
  668. {_PTHREAD_CSTATE_SLOW, _PTHREAD_CVALID | _PTHREAD_CVF_STA, _n_, _a_}
  669. #else
  670. # define PTHREAD_MUTEX_INITIALIZER {0, _PTHREAD_MVALID | _PTHREAD_MVF_STA}
  671. # define PTHREAD_MUTEX_INITWITHNAME_NP(_n_,_a_) \
  672. {0, _PTHREAD_MVALID | _PTHREAD_MVF_STA, _n_, _a_}
  673. # define PTHREAD_COND_INITWITHNAME_NP(_n_,_a_) \
  674. {0, _PTHREAD_CVALID | _PTHREAD_CVF_STA, _n_, _a_}
  675. #endif
  676. #define PTHREAD_RWLOCK_INITIALIZER {_PTHREAD_RWVALID | _PTHREAD_RWVF_STA}
  677. #define PTHREAD_RWLOCK_INITWITHNAME_NP(_n_,_a_) \
  678. {_PTHREAD_RWVALID | _PTHREAD_RWVF_STA, _n_, _a_}
  679. _EOText_;
  680. };
  681. /*
  682. * Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
  683. * And OpenBSD.
  684. */
  685. fix = {
  686. hackname = alpha_sbrk;
  687. files = unistd.h;
  688. select = "char[ \t]*\\*[\t ]*sbrk[ \t]*\\(";
  689. c_fix = format;
  690. c_fix_arg = "void *sbrk(";
  691. test_text = "extern char* sbrk(ptrdiff_t increment);";
  692. };
  693. /*
  694. * For C++, avoid any typedef or macro definition of bool,
  695. * and use the built in type instead.
  696. * HP/UX 10.20 also has it in curses_colr/curses.h.
  697. */
  698. fix = {
  699. hackname = avoid_bool_define;
  700. files = curses.h;
  701. files = curses_colr/curses.h;
  702. files = term.h;
  703. files = tinfo.h;
  704. select = "#[ \t]*define[ \t]+bool[ \t]";
  705. bypass = "__cplusplus";
  706. c_fix = format;
  707. c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
  708. c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+bool[ \t].*";
  709. test_text = "# define bool\t char \n";
  710. };
  711. fix = {
  712. hackname = avoid_bool_type;
  713. files = curses.h;
  714. files = curses_colr/curses.h;
  715. files = term.h;
  716. files = tinfo.h;
  717. select = "^[ \t]*typedef[ \t].*[ \t]bool[ \t]*;";
  718. bypass = "__cplusplus";
  719. c_fix = format;
  720. c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
  721. test_text = "typedef unsigned int\tbool \t; /* bool\n type */";
  722. };
  723. /*
  724. * For C++, avoid any typedef definition of wchar_t,
  725. * and use the built in type instead.
  726. * Don't do this for headers that are smart enough to do the right
  727. * thing (recent [n]curses.h and Xlib.h).
  728. * Don't do it for <linux/nls.h> which is never used from C++ anyway,
  729. * and will be broken by the edit.
  730. */
  731. fix = {
  732. hackname = avoid_wchar_t_type;
  733. select = "^[ \t]*typedef[ \t].*[ \t]wchar_t[ \t]*;";
  734. bypass = "__cplusplus";
  735. bypass = "_LINUX_NLS_H";
  736. bypass = "XFree86: xc/lib/X11/Xlib\\.h";
  737. c_fix = format;
  738. c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
  739. test_text = "typedef unsigned short\twchar_t \t; /* wchar_t\n type */";
  740. };
  741. /*
  742. * Fix `typedef struct term;' on hppa1.1-hp-hpux9.
  743. */
  744. fix = {
  745. hackname = bad_struct_term;
  746. files = curses.h;
  747. select = "^[ \t]*typedef[ \t]+struct[ \t]+term[ \t]*;";
  748. c_fix = format;
  749. c_fix_arg = "struct term;";
  750. test_text = 'typedef struct term;';
  751. };
  752. /*
  753. * Fix one other error in this file:
  754. * a mismatched quote not inside a C comment.
  755. */
  756. fix = {
  757. hackname = badquote;
  758. files = sundev/vuid_event.h;
  759. select = "doesn't";
  760. c_fix = format;
  761. c_fix_arg = "does not";
  762. test_text = "/* doesn't have matched single quotes */";
  763. };
  764. /*
  765. * check for broken assert.h that needs stdio.h
  766. */
  767. fix = {
  768. hackname = broken_assert_stdio;
  769. files = assert.h;
  770. select = stderr;
  771. bypass = "include.*stdio\\.h";
  772. c_fix = wrap;
  773. c_fix_arg = "#include <stdio.h>\n";
  774. test_text = "extern FILE* stderr;";
  775. };
  776. /*
  777. * check for broken assert.h that needs stdlib.h
  778. */
  779. fix = {
  780. hackname = broken_assert_stdlib;
  781. files = assert.h;
  782. select = 'exit *\(|abort *\(';
  783. bypass = "include.*stdlib\\.h";
  784. c_fix = wrap;
  785. c_fix_arg = "#ifdef __cplusplus\n"
  786. "#include <stdlib.h>\n"
  787. "#endif\n";
  788. test_text = "extern void exit ( int );";
  789. };
  790. /*
  791. * Remove `extern double cabs' declarations from math.h.
  792. * This conflicts with C99. Discovered on AIX.
  793. * IRIX 5 and IRIX 6 before 6.5.18 (where C99 support was introduced)
  794. * declares cabs() to take a struct __cabs_s argument.
  795. * SunOS4 has its cabs() declaration followed by a comment which
  796. * terminates on the following line.
  797. * Darwin hides its broken cabs in architecture-specific subdirs.
  798. */
  799. fix = {
  800. hackname = broken_cabs;
  801. files = math.h, "architecture/*/math.h";
  802. select = "^extern[ \t]+double[ \t]+cabs";
  803. sed = "s/^extern[ \t]*double[ \t]*cabs[ \t]*\([^\\\)]*\);//";
  804. sed = "s/^extern[ \t]*long[ \t]*double[ \t]*cabsl[ \t]*\([^\\\)]*\);//";
  805. test_text = "#ifdef __STDC__\n"
  806. "extern double cabs(struct dbl_hypot);\n"
  807. "#else\n"
  808. "extern double cabs();\n"
  809. "#endif\n"
  810. "extern double cabs ( _Complex z );\n"
  811. "extern double cabs(); /* This is a comment\n"
  812. " and it ends here. */\n"
  813. "extern double cabs(struct __cabs_s);\n"
  814. "extern long double cabsl( struct __cabsl_s );";
  815. };
  816. /*
  817. * Fixup Darwin's broken check for __builtin_nanf.
  818. */
  819. fix = {
  820. hackname = broken_nan;
  821. /*
  822. * It is tempting to omit the first "files" entry. Do not.
  823. * The testing machinery will take the first "files" entry as the name
  824. * of a test file to play with. It would be a nuisance to have a directory
  825. * with the name "*".
  826. */
  827. files = "architecture/ppc/math.h";
  828. files = "architecture/*/math.h";
  829. select = "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)";
  830. bypass = "powl";
  831. c_fix = format;
  832. c_fix_arg = "#if 1";
  833. test_text = "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)";
  834. };
  835. /*
  836. * Various systems derived from BSD4.4 contain a macro definition
  837. * for vfscanf that interacts badly with requirements of builtin-attrs.def.
  838. * Known to be fixed in FreeBSD 5 system headers.
  839. */
  840. fix = {
  841. hackname = bsd_stdio_attrs_conflict;
  842. mach = "*-*-*bsd*";
  843. mach = "*-*-*darwin*";
  844. files = stdio.h;
  845. select = "^#define[ \t]*vfscanf[ \t]*__svfscanf[ \t]*$";
  846. c_fix = format;
  847. c_fix_arg = '#define _BSD_STRING(_BSD_X) _BSD_STRINGX(_BSD_X)' "\n"
  848. '#define _BSD_STRINGX(_BSD_X) #_BSD_X' "\n"
  849. 'int vfscanf(FILE *, const char *, __builtin_va_list) '
  850. '__asm__ (_BSD_STRING(__USER_LABEL_PREFIX__) "__svfscanf");';
  851. test_text = '#define vfscanf __svfscanf';
  852. };
  853. /*
  854. * Fix various macros used to define ioctl numbers.
  855. * The traditional syntax was:
  856. *
  857. * #define _CTRL(n, x) (('n'<<8)+x)
  858. * #define TCTRLCFOO _CTRL(T, 1)
  859. *
  860. * but this does not work with the C standard, which disallows macro
  861. * expansion inside strings. We have to rewrite it thus:
  862. *
  863. * #define _CTRL(n, x) ((n<<8)+x)
  864. * #define TCTRLCFOO _CTRL('T', 1)
  865. *
  866. * The select expressions match too much, but the c_fix code is cautious.
  867. *
  868. * CTRL might be: CTRL _CTRL ISCTRL BSD43_CTRL ...
  869. */
  870. fix = {
  871. hackname = ctrl_quotes_def;
  872. select = "define[ \t]+[A-Z0-9_]+CTRL\\([a-zA-Z][,)]";
  873. c_fix = char_macro_def;
  874. c_fix_arg = "CTRL";
  875. /*
  876. * This is two tests in order to ensure that the "CTRL(c)" can
  877. * be selected in isolation from the multi-arg format
  878. */
  879. test_text = "#define BSD43_CTRL(n, x) (('n'<<8)+x)\n";
  880. test_text = "#define _CTRL(c) ('c'&037)";
  881. };
  882. fix = {
  883. hackname = ctrl_quotes_use;
  884. select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+CTRL[ \t]*\\( *[^,']";
  885. c_fix = char_macro_use;
  886. c_fix_arg = "CTRL";
  887. test_text = "#define TCTRLFOO BSD43_CTRL(T, 1)";
  888. };
  889. /*
  890. * sys/mman.h on HP/UX is not C++ ready,
  891. * even though NO_IMPLICIT_EXTERN_C is defined on HP/UX.
  892. *
  893. * rpc/types.h on OSF1/2.0 is not C++ ready,
  894. * even though NO_IMPLICIT_EXTERN_C is defined for the alpha.
  895. *
  896. * The problem is the declaration of malloc.
  897. */
  898. fix = {
  899. hackname = cxx_unready;
  900. files = sys/mman.h;
  901. files = rpc/types.h;
  902. select = '[^#]+malloc.*;'; /* Catch any form of declaration
  903. not within a macro. */
  904. bypass = '"C"|__BEGIN_DECLS';
  905. c_fix = wrap;
  906. c_fix_arg = "#ifdef __cplusplus\n"
  907. "extern \"C\" {\n"
  908. "#endif\n";
  909. c_fix_arg = "#ifdef __cplusplus\n"
  910. "}\n"
  911. "#endif\n";
  912. test_text = "extern void* malloc( size_t );";
  913. };
  914. /*
  915. * On darwin8 and earlier, mach-o/swap.h isn't properly guarded
  916. * by 'extern "C"'. On darwin7 some mach/ headers aren't properly guarded.
  917. */
  918. fix = {
  919. hackname = darwin_externc;
  920. mach = "*-*-darwin*";
  921. files = mach-o/swap.h;
  922. files = mach/mach_time.h;
  923. files = mach/mach_traps.h;
  924. files = mach/message.h;
  925. files = mach/mig.h;
  926. files = mach/semaphore.h;
  927. bypass = "extern \"C\"";
  928. bypass = "__BEGIN_DECLS";
  929. c_fix = wrap;
  930. c_fix_arg = "#ifdef __cplusplus\n"
  931. "extern \"C\" {\n"
  932. "#endif\n";
  933. c_fix_arg = "#ifdef __cplusplus\n"
  934. "}\n"
  935. "#endif\n";
  936. test_text = "extern void swap_fat_header();\n";
  937. };
  938. /*
  939. * AvailabilityMacros.h on Darwin breaks with GCC 4.0, because of
  940. * bad __GNUC__ tests.
  941. */
  942. fix = {
  943. hackname = darwin_gcc4_breakage;
  944. mach = "*-*-darwin*";
  945. files = AvailabilityMacros.h;
  946. select = "\\(__GNUC__ >= 3\\) && \\(__GNUC_MINOR__ >= 1\\)";
  947. c_fix = format;
  948. c_fix_arg = "((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))";
  949. test_text = "#if defined(__GNUC__) && (__GNUC__ >= 3) && "
  950. "(__GNUC_MINOR__ >= 1)\n";
  951. };
  952. /*
  953. * __private_extern__ doesn't exist in FSF GCC. Even if it did,
  954. * why would you ever put it in a system header file?
  955. */
  956. fix = {
  957. hackname = darwin_private_extern;
  958. mach = "*-*-darwin*";
  959. files = mach-o/dyld.h;
  960. select = "__private_extern__ [a-z_]+ _dyld_";
  961. c_fix = format;
  962. c_fix_arg = "extern";
  963. c_fix_arg = "__private_extern__";
  964. test_text = "__private_extern__ int _dyld_func_lookup(\n"
  965. "const char *dyld_func_name,\n"
  966. "unsigned long *address);\n";
  967. };
  968. /*
  969. * Darwin headers have a stdint.h that defines UINT8_C and UINT16_C to
  970. * unsigned constants.
  971. */
  972. fix = {
  973. hackname = darwin_stdint_1;
  974. mach = "*-*-darwin*";
  975. files = stdint-darwin.h, stdint.h;
  976. c_fix = format;
  977. c_fix_arg = "#define UINT8_C(v)\tv\n#define UINT16_C(v)\tv";
  978. select = "#define UINT8_C\\(v\\)[ \t]+\\(v ## U\\)\n"
  979. "#define UINT16_C\\(v\\)[ \t]+\\(v ## U\\)";
  980. test_text = "#define UINT8_C(v) (v ## U)\n"
  981. "#define UINT16_C(v) (v ## U)";
  982. };
  983. /*
  984. * Darwin headers have a stdint.h that defines INTPTR_MIN and INTPTR_MAX
  985. * with wrong types.
  986. */
  987. fix = {
  988. hackname = darwin_stdint_2;
  989. mach = "*-*-darwin*";
  990. files = stdint-darwin.h, stdint.h;
  991. c_fix = format;
  992. c_fix_arg = "#if __WORDSIZE == 64\n"
  993. "#define INTPTR_MAX 9223372036854775807L\n"
  994. "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
  995. "#else\n"
  996. "#define INTPTR_MAX 2147483647L\n"
  997. "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
  998. "#endif";
  999. select = "#if __WORDSIZE == 64\n"
  1000. "#define INTPTR_MIN[ \t]+INT64_MIN\n"
  1001. "#define INTPTR_MAX[ \t]+INT64_MAX\n"
  1002. "#else\n"
  1003. "#define INTPTR_MIN[ \t]+INT32_MIN\n"
  1004. "#define INTPTR_MAX[ \t]+INT32_MAX\n"
  1005. "#endif";
  1006. test_text = "#if __WORDSIZE == 64\n"
  1007. "#define INTPTR_MIN INT64_MIN\n"
  1008. "#define INTPTR_MAX INT64_MAX\n"
  1009. "#else\n"
  1010. "#define INTPTR_MIN INT32_MIN\n"
  1011. "#define INTPTR_MAX INT32_MAX\n"
  1012. "#endif";
  1013. };
  1014. /*
  1015. * Darwin headers have a stdint.h that defines UINTPTR_MAX with a wrong type.
  1016. */
  1017. fix = {
  1018. hackname = darwin_stdint_3;
  1019. mach = "*-*-darwin*";
  1020. files = stdint-darwin.h, stdint.h;
  1021. c_fix = format;
  1022. c_fix_arg = "#if __WORDSIZE == 64\n"
  1023. "#define UINTPTR_MAX 18446744073709551615UL\n"
  1024. "#else\n"
  1025. "#define UINTPTR_MAX 4294967295UL\n"
  1026. "#endif";
  1027. select = "#if __WORDSIZE == 64\n"
  1028. "#define UINTPTR_MAX[ \t]+UINT64_MAX\n"
  1029. "#else\n"
  1030. "#define UINTPTR_MAX[ \t]+UINT32_MAX\n"
  1031. "#endif";
  1032. test_text = "#if __WORDSIZE == 64\n"
  1033. "#define UINTPTR_MAX UINT64_MAX\n"
  1034. "#else\n"
  1035. "#define UINTPTR_MAX UINT32_MAX\n"
  1036. "#endif";
  1037. };
  1038. /*
  1039. * Darwin headers have a stdint.h that defines SIZE_MAX with a wrong type.
  1040. */
  1041. fix = {
  1042. hackname = darwin_stdint_4;
  1043. mach = "*-*-darwin*";
  1044. files = stdint-darwin.h, stdint.h;
  1045. c_fix = format;
  1046. c_fix_arg = "#if __WORDSIZE == 64\n"
  1047. "#define SIZE_MAX 18446744073709551615UL\n"
  1048. "#else\n"
  1049. "#define SIZE_MAX 4294967295UL\n"
  1050. "#endif";
  1051. select = "#if __WORDSIZE == 64\n"
  1052. "#define SIZE_MAX[ \t]+UINT64_MAX\n"
  1053. "#else\n"
  1054. "#define SIZE_MAX[ \t]+UINT32_MAX\n"
  1055. "#endif";
  1056. test_text = "#if __WORDSIZE == 64\n"
  1057. "#define SIZE_MAX UINT64_MAX\n"
  1058. "#else\n"
  1059. "#define SIZE_MAX UINT32_MAX\n"
  1060. "#endif";
  1061. };
  1062. /*
  1063. * Darwin headers have a stdint.h that defines {U,}INTMAX_{MIN,MAX}
  1064. * with a wrong type.
  1065. */
  1066. fix = {
  1067. hackname = darwin_stdint_5;
  1068. mach = "*-*-darwin*";
  1069. files = stdint-darwin.h, stdint.h;
  1070. c_fix = format;
  1071. c_fix_arg = "#if __WORDSIZE == 64\n"
  1072. "#define INTMAX_MIN (-9223372036854775807L - 1)\n"
  1073. "#define INTMAX_MAX 9223372036854775807L\n"
  1074. "#define UINTMAX_MAX 18446744073709551615UL\n"
  1075. "#else\n"
  1076. "#define INTMAX_MIN (-9223372036854775807LL - 1)\n"
  1077. "#define INTMAX_MAX 9223372036854775807LL\n"
  1078. "#define UINTMAX_MAX 18446744073709551615ULL\n"
  1079. "#endif";
  1080. select = "#define INTMAX_MIN[ \t]+INT64_MIN\n"
  1081. "#define INTMAX_MAX[ \t]+INT64_MAX\n"
  1082. "\n"
  1083. "#define UINTMAX_MAX[ \t]+UINT64_MAX";
  1084. test_text = "#define INTMAX_MIN INT64_MIN\n"
  1085. "#define INTMAX_MAX INT64_MAX\n"
  1086. "\n"
  1087. "#define UINTMAX_MAX UINT64_MAX";
  1088. };
  1089. /*
  1090. * Darwin headers have a stdint.h that defines {U,}INTMAX_C
  1091. * with a wrong type.
  1092. */
  1093. fix = {
  1094. hackname = darwin_stdint_6;
  1095. mach = "*-*-darwin*";
  1096. files = stdint-darwin.h, stdint.h;
  1097. c_fix = format;
  1098. c_fix_arg = "#if __WORDSIZE == 64\n"
  1099. "#define PTRDIFF_MIN (-9223372036854775807L - 1)\n"
  1100. "#define PTRDIFF_MAX 9223372036854775807L\n"
  1101. "#else\n"
  1102. "#define PTRDIFF_MIN (-2147483647 - 1)\n"
  1103. "#define PTRDIFF_MAX 2147483647\n"
  1104. "#endif";
  1105. select = "#if __WORDSIZE == 64\n"
  1106. "#define PTRDIFF_MIN[ \t]+INT64_MIN\n"
  1107. "#define PTRDIFF_MAX[ \t]+INT64_MAX\n"
  1108. "#else\n"
  1109. "#define PTRDIFF_MIN[ \t]+INT32_MIN\n"
  1110. "#define PTRDIFF_MAX[ \t]+INT32_MAX\n"
  1111. "#endif";
  1112. test_text = "#if __WORDSIZE == 64\n"
  1113. "#define PTRDIFF_MIN INT64_MIN\n"
  1114. "#define PTRDIFF_MAX INT64_MAX\n"
  1115. "#else\n"
  1116. "#define PTRDIFF_MIN INT32_MIN\n"
  1117. "#define PTRDIFF_MAX INT32_MAX\n"
  1118. "#endif";
  1119. };
  1120. /*
  1121. * Darwin headers have a stdint.h that defines {U,}INTMAX_C
  1122. * with a wrong type.
  1123. */
  1124. fix = {
  1125. hackname = darwin_stdint_7;
  1126. mach = "*-*-darwin*";
  1127. files = stdint-darwin.h, stdint.h;
  1128. c_fix = format;
  1129. c_fix_arg = "#if __WORDSIZE == 64\n"
  1130. "#define INTMAX_C(v) (v ## L)\n"
  1131. "#define UINTMAX_C(v) (v ## UL)\n"
  1132. "#else\n"
  1133. "#define INTMAX_C(v) (v ## LL)\n"
  1134. "#define UINTMAX_C(v) (v ## ULL)\n"
  1135. "#endif";
  1136. select = "#define INTMAX_C\\(v\\)[ \t]+\\(v ## LL\\)\n"
  1137. "#define UINTMAX_C\\(v\\)[ \t]+\\(v ## ULL\\)";
  1138. test_text = "#define INTMAX_C(v) (v ## LL)\n"
  1139. "#define UINTMAX_C(v) (v ## ULL)";
  1140. };
  1141. /*
  1142. * Fix <c_asm.h> on Digital UNIX V4.0:
  1143. * It contains a prototype for a DEC C internal asm() function,
  1144. * clashing with gcc's asm keyword. So protect this with __DECC.
  1145. */
  1146. fix = {
  1147. hackname = dec_intern_asm;
  1148. files = c_asm.h;
  1149. sed = "/^[ \t]*float[ \t]*fasm/i\\\n#ifdef __DECC\n";
  1150. sed = "/^[ \t]*#[ \t]*pragma[ \t]*intrinsic([ \t]*dasm/a\\\n"
  1151. "#endif\n";
  1152. test_text =
  1153. "float fasm {\n"
  1154. " ... asm stuff ...\n"
  1155. "};\n#pragma intrinsic( dasm )\n/* END ASM TEST*/";
  1156. };
  1157. /*
  1158. * Fix typo in <wchar.h> on DJGPP 2.03.
  1159. */
  1160. fix = {
  1161. hackname = djgpp_wchar_h;
  1162. file = wchar.h;
  1163. select = "__DJ_wint_t";
  1164. bypass = "sys/djtypes.h";
  1165. c_fix = format;
  1166. c_fix_arg = "%0\n#include <sys/djtypes.h>";
  1167. c_fix_arg = "#include <stddef.h>";
  1168. test_text = "#include <stddef.h>\n"
  1169. "extern __DJ_wint_t x;\n";
  1170. };
  1171. /*
  1172. * Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
  1173. */
  1174. fix = {
  1175. hackname = ecd_cursor;
  1176. files = "sunwindow/win_lock.h";
  1177. files = "sunwindow/win_cursor.h";
  1178. select = 'ecd\.cursor';
  1179. c_fix = format;
  1180. c_fix_arg = 'ecd_cursor';
  1181. test_text = "#ifdef ecd.cursor\n#error bogus\n#endif /* ecd+cursor */";
  1182. };
  1183. /*
  1184. * Between 8/24/1998 and 2/17/2001, FreeBSD system headers presume
  1185. * neither the existence of GCC 3 nor its exact feature set yet break
  1186. * (by design?) when __GNUC__ is set beyond 2.
  1187. */
  1188. fix = {
  1189. hackname = freebsd_gcc3_breakage;
  1190. mach = "*-*-freebsd*";
  1191. files = sys/cdefs.h;
  1192. select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7$';
  1193. bypass = '__GNUC__[ \t]*([>=]=[ \t]*[3-9]|>[ \t]*2)';
  1194. c_fix = format;
  1195. c_fix_arg = '%0 || __GNUC__ >= 3';
  1196. test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7';
  1197. };
  1198. /*
  1199. * Some releases of FreeBSD 4 and FreeBSD 5.0 and 5.1 system headers presume
  1200. * neither the existence of GCC 4 nor its exact feature set yet break
  1201. * (by design?) when __GNUC__ is set beyond 3.
  1202. */
  1203. fix = {
  1204. hackname = freebsd_gcc4_breakage;
  1205. mach = "*-*-freebsd*";
  1206. files = sys/cdefs.h;
  1207. select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 \|\| __GNUC__ == 3$';
  1208. c_fix = format;
  1209. c_fix_arg = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ >= 3';
  1210. test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ == 3';
  1211. };
  1212. /*
  1213. * Some versions of glibc don't expect the C99 inline semantics.
  1214. */
  1215. fix = {
  1216. hackname = glibc_c99_inline_1;
  1217. files = features.h, '*/features.h';
  1218. select = "^ *&& !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__$";
  1219. c_fix = format;
  1220. c_fix_arg = "%0 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)";
  1221. test_text = <<-EOT
  1222. #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
  1223. && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__
  1224. # define __USE_EXTERN_INLINES 1
  1225. #endif
  1226. EOT;
  1227. };
  1228. /*
  1229. * Similar, but a version that didn't have __NO_INLINE__
  1230. */
  1231. fix = {
  1232. hackname = glibc_c99_inline_1a;
  1233. files = features.h, '*/features.h';
  1234. select = "(\\) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__)\n"
  1235. "(#[ \t]*define[ \t]*__USE_EXTERN_INLINES[ \t]*1)";
  1236. c_fix = format;
  1237. c_fix_arg = "%1 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)\n%2";
  1238. test_text = <<-EOT
  1239. #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__
  1240. # define __USE_EXTERN_INLINES 1
  1241. #endif
  1242. EOT;
  1243. };
  1244. /*
  1245. * The glibc_c99_inline_1 fix should have fixed everything. Unfortunately
  1246. * there are many glibc headers which do not respect __USE_EXTERN_INLINES.
  1247. * The remaining glibc_c99_inline_* fixes deal with some of those headers.
  1248. */
  1249. fix = {
  1250. hackname = glibc_c99_inline_2;
  1251. files = sys/stat.h, '*/sys/stat.h';
  1252. select = "extern __inline__ int";
  1253. sed = "s/extern int \\(stat\\)/"
  1254. "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
  1255. "__inline__ int \\1/";
  1256. sed = "s/extern int \\([lf]stat\\)/"
  1257. "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
  1258. "__inline__ int \\1/";
  1259. sed = "s/extern int \\(mknod\\)/"
  1260. "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
  1261. "__inline__ int \\1/";
  1262. sed = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\(stat\\)/"
  1263. "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
  1264. "__inline__ int __REDIRECT\\1 (\\2/";
  1265. sed = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\([lf]stat\\)/"
  1266. "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
  1267. "__inline__ int __REDIRECT\\1 (\\2/";
  1268. sed = "s/^extern __inline__ int/"
  1269. "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
  1270. "__inline__ int/";
  1271. test_text = <<-EOT
  1272. extern int fstat64 (int __fd, struct stat64 *__buf) __THROW __nonnull ((2));
  1273. extern __inline__ int
  1274. __NTH (fstat64 (int __fd, struct stat64 *__statbuf))
  1275. {}
  1276. EOT;
  1277. };
  1278. fix = {
  1279. hackname = glibc_c99_inline_3;
  1280. files = bits/string2.h, '*/bits/string2.h';
  1281. select = "extern __inline";
  1282. bypass = "__extern_inline|__GNU_STDC_INLINE__";
  1283. c_fix = format;
  1284. c_fix_arg = "# if defined(__cplusplus) || defined(__GNUC_STDC_INLINE__)";
  1285. c_fix_arg = "^# ifdef __cplusplus$";
  1286. test_text = <<-EOT
  1287. # ifdef __cplusplus
  1288. # define __STRING_INLINE inline
  1289. # else
  1290. # define __STRING_INLINE extern __inline
  1291. # endif
  1292. EOT;
  1293. };
  1294. fix = {
  1295. hackname = glibc_c99_inline_4;
  1296. files = sys/sysmacros.h, '*/sys/sysmacros.h', wchar.h, '*/wchar.h';
  1297. bypass = "__extern_inline|__gnu_inline__";
  1298. select = "(^| )extern __inline";
  1299. c_fix = format;
  1300. c_fix_arg = "%0 __attribute__ ((__gnu_inline__))";
  1301. test_text = <<-EOT
  1302. __extension__ extern __inline unsigned int
  1303. extern __inline unsigned int
  1304. EOT;
  1305. };
  1306. /* glibc-2.3.5 defines pthread mutex initializers incorrectly,
  1307. * so we replace them with versions that correspond to the
  1308. * definition.
  1309. */
  1310. fix = {
  1311. hackname = glibc_mutex_init;
  1312. files = pthread.h;
  1313. select = '\{ *\{ *0, *\} *\}';
  1314. sed = "/define[ \t]\\{1,\\}PTHREAD_MUTEX_INITIALIZER[ \t]*\\\\/{\n"
  1315. "N\ns/{ { 0, } }/{ { 0, 0, 0, 0, 0, 0 } }/\n}";
  1316. sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
  1317. "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0 }/";
  1318. sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
  1319. "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0 }/";
  1320. sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
  1321. "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0 }/";
  1322. sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
  1323. "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
  1324. sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
  1325. "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0, 0 }/";
  1326. sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
  1327. "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
  1328. sed = "/define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\/"
  1329. "N;s/^[ \t]*#[ \t]*"
  1330. "\\(define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\\\)\\n"
  1331. "[ \t]*{ { 0, } }/# if __WORDSIZE == 64\\\n"
  1332. "# \\1\\\n"
  1333. " { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
  1334. "# else\\\n"
  1335. "# \\1\\\n"
  1336. " { { 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
  1337. "# endif/";
  1338. sed = "s/{ \\(0, 0, 0, 0, 0, 0, "
  1339. "PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP\\) }/{ \\1, 0 }/";
  1340. sed = "/define[ \t]\\{1,\\}PTHREAD_COND_INITIALIZER/"
  1341. "s/{ { 0, } }/{ { 0, 0, 0, 0, 0, (void *) 0, 0, 0 } }/";
  1342. test_text = <<- _EOText_
  1343. #define PTHREAD_MUTEX_INITIALIZER \\
  1344. { { 0, } }
  1345. #ifdef __USE_GNU
  1346. # if __WORDSIZE == 64
  1347. # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
  1348. { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
  1349. # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
  1350. { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
  1351. # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
  1352. { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
  1353. # else
  1354. # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
  1355. { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
  1356. # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
  1357. { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
  1358. # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
  1359. { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
  1360. # endif
  1361. #endif
  1362. # define PTHREAD_RWLOCK_INITIALIZER \\
  1363. { { 0, } }
  1364. # ifdef __USE_GNU
  1365. # if __WORDSIZE == 64
  1366. # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
  1367. { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \\
  1368. PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
  1369. # else
  1370. # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
  1371. { { 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
  1372. # endif
  1373. # endif
  1374. #define PTHREAD_COND_INITIALIZER { { 0, } }
  1375. _EOText_;
  1376. };
  1377. /* glibc versions before 2.5 have a version of stdint.h that defines
  1378. UINT8_C and UINT16_C to produce unsigned constants, as do uClibc
  1379. versions with stdint.h based on those glibc versions. */
  1380. fix = {
  1381. hackname = glibc_stdint;
  1382. files = stdint.h;
  1383. select = "GNU C Library";
  1384. c_fix = format;
  1385. c_fix_arg = "# define UINT8_C(c)\tc\n# define UINT16_C(c)\tc";
  1386. c_fix_arg = "# define UINT8_C\\(c\\)\tc ## U\n# define UINT16_C\\(c\\)\tc ## U";
  1387. test_text = "/* This file is part of the GNU C Library. */\n# define UINT8_C(c)\tc ## U\n# define UINT16_C(c)\tc ## U";
  1388. };
  1389. /* Some versions of glibc have a version of bits/string2.h that
  1390. produces "value computed is not used" warnings from strncpy; fix
  1391. this definition by using __builtin_strncpy instead as in newer
  1392. versions. */
  1393. fix = {
  1394. hackname = glibc_strncpy;
  1395. files = bits/string2.h;
  1396. bypass = "__builtin_strncpy";
  1397. c_fix = format;
  1398. c_fix_arg = "# define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)";
  1399. c_fix_arg = "# define strncpy([^\n]*\\\\\n)*[^\n]*";
  1400. test_text = <<-EOT
  1401. # define strncpy(dest, src, n) \
  1402. (__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n) \\
  1403. ? (strlen (src) + 1 >= ((size_t) (n)) \\
  1404. ? (char *) memcpy (dest, src, n) \\
  1405. : strncpy (dest, src, n)) \\
  1406. : strncpy (dest, src, n)))
  1407. EOT;
  1408. };
  1409. /* glibc's tgmath.h relies on an expression that is not an integer
  1410. constant expression being treated as it was by GCC 4.4 and
  1411. earlier. */
  1412. fix = {
  1413. hackname = glibc_tgmath;
  1414. files = tgmath.h;
  1415. select = '\(\(\(type\) 0.25\) && \(\(type\) 0.25 - 1\)\)';
  1416. bypass = "__floating_type\\(type\\) \\\\\n.*__builtin_classify_type";
  1417. c_fix = format;
  1418. c_fix_arg = "(__builtin_classify_type ((type) 0) == 8 || (__builtin_classify_type ((type) 0) == 9 && __builtin_classify_type (__real__ ((type) 0)) == 8))";
  1419. test_text = "# define __floating_type(type) (((type) 0.25) && ((type) 0.25 - 1))";
  1420. };
  1421. /*
  1422. * Fix these files to use the types we think they should for
  1423. * ptrdiff_t, size_t, and wchar_t.
  1424. *
  1425. * This defines the types in terms of macros predefined by our 'cpp'.
  1426. * This is supposedly necessary for glibc's handling of these types.
  1427. * It's probably not necessary for anyone else, but it doesn't hurt.
  1428. */
  1429. fix = {
  1430. hackname = gnu_types;
  1431. files = "sys/types.h";
  1432. files = "stdlib.h";
  1433. files = "sys/stdtypes.h";
  1434. files = "stddef.h";
  1435. files = "memory.h";
  1436. files = "unistd.h";
  1437. bypass = '_GCC_(PTRDIFF|SIZE|WCHAR)_T';
  1438. select = "^[ \t]*typedef[ \t]+.*[ \t](ptrdiff|size|wchar)_t;";
  1439. c_fix = gnu_type;
  1440. /* The Solaris 10 headers already define these types correctly. */
  1441. mach = '*-*-solaris2.1[0-9]*';
  1442. not_machine = true;
  1443. test_text = "typedef long int ptrdiff_t; /* long int */\n"
  1444. "typedef uint_t size_t; /* uint_t */\n"
  1445. "typedef ushort_t wchar_t; /* ushort_t */";
  1446. };
  1447. /*
  1448. * Fix HP & Sony's use of "../machine/xxx.h"
  1449. * to refer to: <machine/xxx.h>
  1450. */
  1451. fix = {
  1452. hackname = hp_inline;
  1453. files = sys/spinlock.h;
  1454. files = machine/machparam.h;
  1455. select = "[ \t]*#[ \t]*include[ \t]+" '"\.\./machine/';
  1456. c_fix = format;
  1457. c_fix_arg = "%1<machine/%2.h>";
  1458. c_fix_arg = "([ \t]*#[ \t]*include[ \t]+)" '"\.\./machine/'
  1459. '([a-z]+)\.h"';
  1460. test_text = ' # include "../machine/mumble.h"';
  1461. };
  1462. /*
  1463. * Check for (...) in C++ code in HP/UX sys/file.h.
  1464. */
  1465. fix = {
  1466. hackname = hp_sysfile;
  1467. files = sys/file.h;
  1468. select = "HPUX_SOURCE";
  1469. c_fix = format;
  1470. c_fix_arg = "(struct file *, ...)";
  1471. c_fix_arg = '\(\.\.\.\)';
  1472. test_text = "extern void foo(...); /* HPUX_SOURCE - bad varargs */";
  1473. };
  1474. /*
  1475. * Un-Hide a series of five FP defines from post-1999 compliance GCC:
  1476. * FP_NORMAL, FP_ZERO, FP_INFINITE, FP_SUBNORMAL and FP_NAN
  1477. */
  1478. fix = {
  1479. hackname = hppa_hpux_fp_macros;
  1480. mach = "hppa*-hp-hpux11*";
  1481. files = math.h;
  1482. select = "#[ \t]*define[ \t]*FP_NORMAL.*\n"
  1483. "#[ \t]*define[ \t]*FP_ZERO.*\n"
  1484. "#[ \t]*define[ \t]*FP_INFINITE.*\n"
  1485. "#[ \t]*define[ \t]*FP_SUBNORMAL.*\n"
  1486. "#[ \t]*define[ \t]*FP_NAN.*\n";
  1487. c_fix = format;
  1488. c_fix_arg = <<- _EOFix_
  1489. #endif /* _INCLUDE_HPUX_SOURCE */
  1490. #if defined(_INCLUDE_HPUX_SOURCE) || \
  1491. (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))
  1492. %0#endif
  1493. #ifdef _INCLUDE_HPUX_SOURCE
  1494. _EOFix_;
  1495. test_text =
  1496. "# define FP_NORMAL 0\n"
  1497. "# define FP_ZERO 1\n"
  1498. "# define FP_INFINITE 2\n"
  1499. "# define FP_SUBNORMAL 3\n"
  1500. "# define FP_NAN 4\n";
  1501. };
  1502. /*
  1503. * Delete C++ double pow (double, int) inline function from HP-UX 10 & 11
  1504. * math.h to prevent clash with define in c_std/bits/std_cmath.h.
  1505. */
  1506. fix = {
  1507. hackname = hpux10_cpp_pow_inline;
  1508. files = fixinc-test-limits.h, math.h;
  1509. select = <<- END_POW_INLINE
  1510. ^# +ifdef +__cplusplus
  1511. +\}
  1512. +inline +double +pow\(double +__d,int +__expon\) +\{
  1513. [ ]+return +pow\(__d,\(double\)__expon\);
  1514. +\}
  1515. +extern +"C" +\{
  1516. #else
  1517. # +endif
  1518. END_POW_INLINE;
  1519. c_fix = format;
  1520. c_fix_arg = "";
  1521. test_text =
  1522. "# ifdef __cplusplus\n"
  1523. " }\n"
  1524. " inline double pow(double __d,int __expon) {\n"
  1525. "\t return pow(__d,(double)__expon);\n"
  1526. " }\n"
  1527. ' extern "C"' " {\n"
  1528. "#else\n"
  1529. "# endif";
  1530. };
  1531. fix = {
  1532. hackname = hpux11_cpp_pow_inline;
  1533. files = math.h;
  1534. select = " +inline double pow\\(double d,int expon\\) \\{\n"
  1535. " +return pow\\(d, \\(double\\)expon\\);\n"
  1536. " +\\}\n";
  1537. c_fix = format;
  1538. c_fix_arg = "";
  1539. test_text =
  1540. " inline double pow(double d,int expon) {\n"
  1541. " return pow(d, (double)expon);\n"
  1542. " }\n";
  1543. };
  1544. /*
  1545. * Fix hpux 10.X missing ctype declarations 1
  1546. */
  1547. fix = {
  1548. hackname = hpux10_ctype_declarations1;
  1549. files = ctype.h;
  1550. select = "^#[ \t]*define _toupper\\(__c\\)[ \t]*__toupper\\(__c\\)";
  1551. bypass = "^[ \t]*extern[ \t]*int[ \t]*__tolower[ \t]*\\(";
  1552. c_fix = format;
  1553. c_fix_arg = "#ifdef _PROTOTYPES\n"
  1554. "extern int __tolower(int);\n"
  1555. "extern int __toupper(int);\n"
  1556. "#else /* NOT _PROTOTYPES */\n"
  1557. "extern int __tolower();\n"
  1558. "extern int __toupper();\n"
  1559. "#endif /* _PROTOTYPES */\n\n"
  1560. "%0\n";
  1561. test_text = "# define _toupper(__c) __toupper(__c)\n";
  1562. };
  1563. /*
  1564. * Fix hpux 10.X missing ctype declarations 2
  1565. */
  1566. fix = {
  1567. hackname = hpux10_ctype_declarations2;
  1568. files = ctype.h;
  1569. select = "^# if defined\\(_SB_CTYPE_MACROS\\) && \\!defined\\(__lint\\)";
  1570. bypass = "^[ \t]*extern[ \t]*int[ \t]*_isalnum[ \t]*\\(";
  1571. c_fix = format;
  1572. c_fix_arg = "%0\n\n"
  1573. "#ifdef _PROTOTYPES\n"
  1574. " extern int _isalnum(int);\n"
  1575. " extern int _isalpha(int);\n"
  1576. " extern int _iscntrl(int);\n"
  1577. " extern int _isdigit(int);\n"
  1578. " extern int _isgraph(int);\n"
  1579. " extern int _islower(int);\n"
  1580. " extern int _isprint(int);\n"
  1581. " extern int _ispunct(int);\n"
  1582. " extern int _isspace(int);\n"
  1583. " extern int _isupper(int);\n"
  1584. " extern int _isxdigit(int);\n"
  1585. "# else /* not _PROTOTYPES */\n"
  1586. " extern int _isalnum();\n"
  1587. " extern int _isalpha();\n"
  1588. " extern int _iscntrl();\n"
  1589. " extern int _isdigit();\n"
  1590. " extern int _isgraph();\n"
  1591. " extern int _islower();\n"
  1592. " extern int _isprint();\n"
  1593. " extern int _ispunct();\n"
  1594. " extern int _isspace();\n"
  1595. " extern int _isupper();\n"
  1596. " extern int _isxdigit();\n"
  1597. "#endif /* _PROTOTYPES */\n";
  1598. test_text = "# if defined(_SB_CTYPE_MACROS) && !defined(__lint)\n"
  1599. " extern unsigned int *__SB_masks;\n";
  1600. };
  1601. /*
  1602. * Fix hpux 10.X missing stdio declarations
  1603. */
  1604. fix = {
  1605. hackname = hpux10_stdio_declarations;
  1606. files = stdio.h;
  1607. select = "^#[ \t]*define _iob[ \t]*__iob";
  1608. bypass = "^[ \t]*extern[ \t]*int[ \t]*vsnprintf[ \t]*\\(";
  1609. c_fix = format;
  1610. c_fix_arg = "%0\n\n"
  1611. "# if defined(__STDC__) || defined(__cplusplus)\n"
  1612. " extern int snprintf(char *, size_t, const char *, ...);\n"
  1613. " extern int vsnprintf(char *, size_t, const char *, __va_list);\n"
  1614. "# else /* not __STDC__) || __cplusplus */\n"
  1615. " extern int snprintf();\n"
  1616. " extern int vsnprintf();\n"
  1617. "# endif /* __STDC__) || __cplusplus */\n";
  1618. test_text = "# define _iob __iob\n";
  1619. };
  1620. /*
  1621. * Make sure hpux defines abs in header.
  1622. */
  1623. fix = {
  1624. hackname = hpux11_abs;
  1625. mach = "ia64-hp-hpux11*";
  1626. files = stdlib.h;
  1627. select = "ifndef _MATH_INCLUDED";
  1628. c_fix = format;
  1629. c_fix_arg = "if !defined(_MATH_INCLUDED) || defined(__GNUG__)";
  1630. test_text = "#ifndef _MATH_INCLUDED";
  1631. };
  1632. /*
  1633. * Keep HP-UX 11 from stomping on C++ math namespace
  1634. * with defines for fabsf.
  1635. */
  1636. fix = {
  1637. hackname = hpux11_fabsf;
  1638. files = math.h;
  1639. select = "^[ \t]*#[ \t]*define[ \t]+fabsf\\(.*";
  1640. bypass = "__cplusplus";
  1641. c_fix = format;
  1642. c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
  1643. test_text =
  1644. "#ifdef _PA_RISC\n"
  1645. "# define fabsf(x) ((float)fabs((double)(float)(x)))\n"
  1646. "#endif";
  1647. };
  1648. /*
  1649. * Fix C99 constant in __POINTER_SET define.
  1650. */
  1651. fix = {
  1652. hackname = hpux11_pthread_const;
  1653. mach = "*-hp-hpux11.[0-3]*";
  1654. files = sys/pthread.h;
  1655. select = "^#define[ \t]*__POINTER_SET[ \t]*\\(\\(void \\*\\) 1LL\\)";
  1656. c_fix = format;
  1657. c_fix_arg = "#define __POINTER_SET\t\t((void *) 1L)";
  1658. test_text = "#define __POINTER_SET\t\t((void *) 1LL)";
  1659. };
  1660. /*
  1661. * Prevent HP-UX 11 from defining __size_t and preventing size_t from
  1662. * being defined by having it define _hpux_size_t instead.
  1663. */
  1664. fix = {
  1665. hackname = hpux11_size_t;
  1666. mach = "*-hp-hpux11*";
  1667. select = "__size_t";
  1668. c_fix = format;
  1669. c_fix_arg = "_hpux_size_t";
  1670. test_text =
  1671. "#define __size_t size_t\n"
  1672. " extern int getpwuid_r( char *, __size_t, struct passwd **);\n";
  1673. };
  1674. /*
  1675. * Fix hpux 11.00 broken snprintf declaration
  1676. * (third argument is char *, needs to be const char * to prevent
  1677. * spurious warnings with -Wwrite-strings or in C++).
  1678. */
  1679. fix = {
  1680. hackname = hpux11_snprintf;
  1681. files = stdio.h;
  1682. select = '(extern int snprintf *\(char *\*, *(|__|_hpux_)size_t,)'
  1683. ' *(char *\*, *\.\.\.\);)';
  1684. c_fix = format;
  1685. c_fix_arg = '%1 const %3';
  1686. test_text = "extern int snprintf(char *, size_t, char *, ...);\n"
  1687. "extern int snprintf(char *, __size_t, char *, ...);\n"
  1688. "extern int snprintf(char *, _hpux_size_t, char *, ...);";
  1689. };
  1690. /*
  1691. * Fix hpux 11.00 broken vsnprintf declaration
  1692. */
  1693. fix = {
  1694. hackname = hpux11_vsnprintf;
  1695. files = stdio.h;
  1696. select = '(extern int vsnprintf\(char \*, _[hpux]*_size_t, '
  1697. 'const char \*,) __va__list\);';
  1698. c_fix = format;
  1699. c_fix_arg = "%1 __va_list);";
  1700. test_text = 'extern int vsnprintf(char *, _hpux_size_t, const char *,'
  1701. ' __va__list);';
  1702. };
  1703. /*
  1704. * get rid of bogus inline definitions in HP-UX 8.0
  1705. */
  1706. fix = {
  1707. hackname = hpux8_bogus_inlines;
  1708. files = math.h;
  1709. select = inline;
  1710. bypass = "__GNUG__";
  1711. sed = "s@inline int abs(int [a-z][a-z]*) {.*}"
  1712. "@extern \"C\" int abs(int);@";
  1713. sed = "s@inline double abs(double [a-z][a-z]*) {.*}@@";
  1714. sed = "s@inline int sqr(int [a-z][a-z]*) {.*}@@";
  1715. sed = "s@inline double sqr(double [a-z][a-z]*) {.*}@@";
  1716. test_text = "inline int abs(int v) { return (v>=0)?v:-v; }\n"
  1717. "inline double sqr(double v) { return v**0.5; }";
  1718. };
  1719. /*
  1720. * Fix hpux broken ctype macros
  1721. */
  1722. fix = {
  1723. hackname = hpux_ctype_macros;
  1724. files = ctype.h;
  1725. select = '((: |\()__SB_masks \? )'
  1726. '(__SB_masks\[__(alnum|c)\] & _IS)';
  1727. c_fix = format;
  1728. c_fix_arg = "%1(int)%3";
  1729. test_text = ": __SB_masks ? __SB_masks[__alnum] & _ISCNTRL\n"
  1730. "# define isalpha(__c) (__SB_masks ? __SB_masks[__c] & _IS\n";
  1731. };
  1732. /*
  1733. * Fix hpux broken #ifndef _XOPEN_SOURCE_EXTENDED conditional on htonl etc.
  1734. */
  1735. fix = {
  1736. hackname = hpux_htonl;
  1737. files = netinet/in.h;
  1738. select = "#ifndef _XOPEN_SOURCE_EXTENDED\n"
  1739. "(/\\*\n"
  1740. " \\* Macros for number representation conversion\\.\n"
  1741. " \\*/\n"
  1742. "#ifndef ntohl)";
  1743. c_fix = format;
  1744. c_fix_arg = "#if 1\n%1";
  1745. test_text = "#ifndef _XOPEN_SOURCE_EXTENDED\n"
  1746. "/*\n"
  1747. " * Macros for number representation conversion.\n"
  1748. " */\n"
  1749. "#ifndef ntohl\n"
  1750. "#define ntohl(x) (x)\n"
  1751. "#define ntohs(x) (x)\n"
  1752. "#define htonl(x) (x)\n"
  1753. "#define htons(x) (x)\n"
  1754. "#endif\n"
  1755. "#endif /* ! _XOPEN_SOURCE_EXTENDED */";
  1756. };
  1757. /*
  1758. * HP-UX long_double
  1759. */
  1760. fix = {
  1761. hackname = hpux_long_double;
  1762. mach = "*-*-hpux10*";
  1763. mach = "*-*-hpux11.[012]*";
  1764. files = stdlib.h;
  1765. select = "extern[ \t]long_double[ \t]strtold";
  1766. bypass = "long_double_t";
  1767. sed = "/^#[ \t]*ifndef _LONG_DOUBLE/,/\\/\\* _LONG_DOUBLE \\*\\//D";
  1768. sed = "s/long_double/long double/g";
  1769. test_text = "# ifndef _LONG_DOUBLE\n"
  1770. "# define _LONG_DOUBLE\n"
  1771. " typedef struct {\n"
  1772. " unsigned int word1, word2, word3, word4;\n"
  1773. " } long_double;\n"
  1774. "# endif /* _LONG_DOUBLE */\n"
  1775. "extern long_double strtold(const char *, char **);\n";
  1776. };
  1777. /*
  1778. * We cannot use the above rule on 11.31 because it removes the strtold
  1779. * definition. ia64 is OK with no hack, PA needs some help.
  1780. */
  1781. fix = {
  1782. hackname = hpux_long_double_2;
  1783. mach = "hppa*-*-hpux11.3*";
  1784. files = stdlib.h;
  1785. select = "#[ \t]*if[ \t]*!defined\\(__ia64\\) \\|\\| defined\\(_PROTOTYPES\\) \\|\\| defined\\(_LONG_DOUBLE_STRUCT\\)";
  1786. c_fix = format;
  1787. c_fix_arg = "# if !defined(_PROTOTYPES) || defined(_LONG_DOUBLE_STRUCT)";
  1788. test_text = "# if !defined(__ia64) || !defined(_PROTOTYPES) || defined(_LONG_DOUBLE_STRUCT)\n";
  1789. };
  1790. /*
  1791. * Fix hpux10.20 <sys/time.h> to avoid invalid forward decl
  1792. */
  1793. fix = {
  1794. hackname = hpux_systime;
  1795. files = sys/time.h;
  1796. select = "^extern struct sigevent;";
  1797. c_fix = format;
  1798. c_fix_arg = "struct sigevent;";
  1799. test_text = 'extern struct sigevent;';
  1800. };
  1801. /*
  1802. * Wrap spu_info in ifdef _KERNEL. GCC cannot handle an array of unknown
  1803. * type and mpinfou is only defined when _KERNEL is set.
  1804. */
  1805. fix = {
  1806. hackname = hpux_spu_info;
  1807. mach = "*-hp-hpux*";
  1808. /*
  1809. * It is tempting to omit the first "files" entry. Do not.
  1810. * The testing machinery will take the first "files" entry as the name
  1811. * of a test file to play with. It would be a nuisance to have a directory
  1812. * with the name "*".
  1813. */
  1814. files = "ia64/sys/getppdp.h";
  1815. files = "*/sys/getppdp.h";
  1816. select = "^.*extern.*spu_info.*";
  1817. c_fix = format;
  1818. c_fix_arg = "#ifdef _KERNEL\n%0\n#endif";
  1819. test_text = "extern union mpinfou spu_info[];";
  1820. };
  1821. fix = {
  1822. hackname = hpux11_extern_sendfile;
  1823. mach = "*-hp-hpux11.[12]*";
  1824. files = sys/socket.h;
  1825. select = "^[ \t]*extern sbsize_t sendfile.*\n.*, int\\)\\);\n";
  1826. c_fix = format;
  1827. c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
  1828. test_text = " extern sbsize_t sendfile __((int, int, off_t, bsize_t,\n const struct iovec *, int));\n";
  1829. };
  1830. fix = {
  1831. hackname = hpux11_extern_sendpath;
  1832. mach = "*-hp-hpux11.[12]*";
  1833. files = sys/socket.h;
  1834. select = "^[ \t]*extern sbsize_t sendpath.*\n.*, int\\)\\);\n";
  1835. c_fix = format;
  1836. c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
  1837. test_text = " extern sbsize_t sendpath __((int, int, off_t, bsize_t,\n const struct iovec *, int));\n";
  1838. };
  1839. fix = {
  1840. hackname = hpux_extern_errno;
  1841. mach = "*-hp-hpux10.*";
  1842. mach = "*-hp-hpux11.[0-2]*";
  1843. files = errno.h;
  1844. select = "^[ \t]*extern int errno;$";
  1845. c_fix = format;
  1846. c_fix_arg = "#ifdef __cplusplus\nextern \"C\" {\n#endif\n%0\n#ifdef __cplusplus\n}\n#endif";
  1847. test_text = " extern int errno;\n";
  1848. };
  1849. /*
  1850. * Add missing braces to pthread initializer defines.
  1851. */
  1852. fix = {
  1853. hackname = hpux_pthread_initializers;
  1854. mach = "*-hp-hpux11.[0-3]*";
  1855. files = sys/pthread.h;
  1856. sed = "s@^[ \t]*1, 1, 1, 1,[ \t]*\\\\"
  1857. "@\t{ 1, 1, 1, 1 },\t\t\t\t\t\t\t\\\\@";
  1858. sed = "s@^[ \t]*1,[ \t]*\\\\"
  1859. "@\t{ 1, 0 }@";
  1860. sed = "/^[ \t]*0$/d";
  1861. sed = "s@__PTHREAD_MUTEX_VALID, 0"
  1862. "@{ __PTHREAD_MUTEX_VALID, 0 }@";
  1863. sed = "s@^[ \t]*0, 0, -1, 0,[ \t]*\\\\"
  1864. "@\t{ 0, 0, -1, 0 },\t\t\t\t\t\t\\\\@";
  1865. sed = "s@0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
  1866. "@{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
  1867. sed = "s@^[ \t]*__LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
  1868. "@\t{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
  1869. sed = "s@^[ \t]*0, 0[ \t]*\\\\"
  1870. "@\t{ 0, 0 }\t\t\t\t\t\t\t\\\\@";
  1871. sed = "s@__PTHREAD_COND_VALID, 0"
  1872. "@{ __PTHREAD_COND_VALID, 0 }@";
  1873. sed = "s@__LWP_COND_VALID, 0,[ \t]*\\\\"
  1874. "@{ __LWP_COND_VALID, 0 },\t\t\t\t\t\\\\@";
  1875. sed = "s@__PTHREAD_RWLOCK_VALID, 0"
  1876. "@{ __PTHREAD_RWLOCK_VALID, 0 }@";
  1877. sed = "s@__LWP_RWLOCK_VALID, 0,[ \t]*\\\\"
  1878. "@{ __LWP_RWLOCK_VALID, 0 },\t\t\t\t\t\\\\@";
  1879. sed = "s@^[ \t]*0, 0, 0, 0, 0, 0, 0[ \t]*\\\\"
  1880. "@\t{ 0, 0, 0, 0, 0 }, { 0, 0}\t\t\t\t\t\\\\@";
  1881. test_text = "#define PTHREAD_MUTEX_INITIALIZER {\t\t\t\t\t\\\\\n"
  1882. "\t__PTHREAD_MUTEX_VALID, 0,\t\t\t\t\t\\\\\n"
  1883. "\t(PTHREAD_MUTEX_DEFAULT | PTHREAD_PROCESS_PRIVATE),\t\t\\\\\n"
  1884. "\t__SPNLCK_INITIALIZER,\t\t\t\t\t\t\\\\\n"
  1885. "\t0, 0, -1, 0,\t\t\t\t\t\t\t\\\\\n"
  1886. "\t0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,\t\t\t\t\\\\\n"
  1887. "\t0, 0\t\t\t\t\t\t\t\t\\\\\n"
  1888. "}\n";
  1889. };
  1890. fix = {
  1891. hackname = hpux_c99_intptr;
  1892. mach = "*-hp-hpux11.3*";
  1893. files = stdint-hpux11.h, stdint.h;
  1894. sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MAX[ \t]*INT32_MAX[ \t]*$@#define PTRDIFF_MAX (2147483647l)@";
  1895. sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MIN[ \t]*INT32_MIN[ \t]*$@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
  1896. sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MAX[ \t]*INT32_MAX[ \t]*$@#define INTPTR_MAX (2147483647l)@";
  1897. sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MIN[ \t]*INT32_MIN[ \t]*$@#define INTPTR_MIN (-INTPTR_MAX - 1)@";
  1898. sed = "s@^[ \t]*#[ \t]*define[ \t]*UINTPTR_MAX[ \t]*UINT32_MAX[ \t]*$@#define UINTPTR_MAX (4294967295ul)@";
  1899. sed = "s@^[ \t]*#[ \t]*define[ \t]*SIZE_MAX[ \t]*UINT32_MAX[ \t]*$@#define SIZE_MAX (4294967295ul)@";
  1900. test_text = "#define PTRDIFF_MAX INT32_MAX\n"
  1901. "#define PTRDIFF_MIN INT32_MIN\n"
  1902. "#define INTPTR_MAX INT32_MAX\n"
  1903. "#define INTPTR_MIN INT32_MIN\n"
  1904. "#define UINTPTR_MAX UINT32_MAX\n"
  1905. "#define SIZE_MAX UINT32_MAX\n";
  1906. };
  1907. /*
  1908. * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
  1909. */
  1910. fix = {
  1911. hackname = hpux_c99_inttypes;
  1912. mach = "*-hp-hpux11.[23]*";
  1913. files = inttypes.h;
  1914. files = stdint-hpux11.h, stdint.h;
  1915. sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*__CONCAT_U__(__c)[ \t]*$@#define UINT8_C(__c) (__c)@";
  1916. sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*__CONCAT_U__(__c)[ \t]*$@#define UINT16_C(__c) (__c)@";
  1917. sed = "s@^[ \t]*#[ \t]*define[ \t]*INT32_C(__c)[ \t]*__CONCAT__(__c,l)[ \t]*$@#define INT32_C(__c) (__c)@";
  1918. sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT32_C(__c)[ \t].*$@#define UINT32_C(__c) __CONCAT__(__c,u)@";
  1919. test_text = "#define UINT8_C(__c) __CONCAT_U__(__c)\n"
  1920. "#define UINT16_C(__c) __CONCAT_U__(__c)\n"
  1921. "#define INT32_C(__c) __CONCAT__(__c,l)\n"
  1922. "#define UINT32_C(__c) __CONCAT__(__c,ul)\n";
  1923. };
  1924. fix = {
  1925. hackname = hpux_c99_inttypes2;
  1926. mach = "*-hp-hpux11.2*";
  1927. files = stdint-hpux11.h, stdint.h;
  1928. sed = "s@^[ \t]*#[ \t]*define[ \t]*INT8_C(__c)[ \t]*((signed char)(__c))[ \t]*$@#define INT8_C(__c) (__c)@";
  1929. sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*((unsigned char)(__c))[ \t]*$@#define UINT8_C(__c) (__c)@";
  1930. sed = "s@^[ \t]*#[ \t]*define[ \t]*INT16_C(__c)[ \t]*((short)(__c))[ \t]*$@#define INT16_C(__c) (__c)@";
  1931. sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*((unsigned short)(__c))[ \t]*$@#define UINT16_C(__c) (__c)@";
  1932. test_text = "# define INT8_C(__c) ((signed char)(__c))\n"
  1933. "# define UINT8_C(__c) ((unsigned char)(__c))\n"
  1934. "# define INT16_C(__c) ((short)(__c))\n"
  1935. "# define UINT16_C(__c) ((unsigned short)(__c))\n";
  1936. };
  1937. fix = {
  1938. hackname = hpux_stdint_least_fast;
  1939. mach = "*-hp-hpux11.2*";
  1940. files = stdint-hpux11.h, stdint.h;
  1941. select =
  1942. "^[ \t]*#[ \t]*define[ \t]+UINT_(LEAST|FAST)64_MAX[ \t]+ULLONG_MAX";
  1943. c_fix = format;
  1944. c-fix-arg = "# define UINT_%164_MAX __UINT64_MAX__";
  1945. test-text = "# define UINT_FAST64_MAX ULLONG_MAX\n"
  1946. "# define UINT_LEAST64_MAX ULLONG_MAX\n";
  1947. _EOFix_;
  1948. };
  1949. fix = {
  1950. hackname = hpux_inttype_int8_t;
  1951. mach = "*-hp-hpux1[01].*";
  1952. files = sys/_inttypes.h;
  1953. select = "^[ \t]*typedef[ \t]*char[ \t]*int(_least){0,1}8_t.*";
  1954. c_fix = format;
  1955. c_fix_arg = "typedef signed char int%18_t;";
  1956. test_text = "typedef char int_least8_t;\n"
  1957. "typedef char int8_t;\n";
  1958. };
  1959. fix = {
  1960. hackname = hpux_imaginary_i;
  1961. mach = "ia64-hp-hpux11.*";
  1962. files = complex.h;
  1963. select = "^[ \t]*#[ \t]*define[ \t]*_Complex_I.*";
  1964. c_fix = format;
  1965. c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)";
  1966. test_text = "#define _Complex_I (0.f+_Imaginary_I)\n";
  1967. };
  1968. /*
  1969. * Fix glibc definition of HUGE_VAL in terms of hex floating point constant
  1970. */
  1971. fix = {
  1972. hackname = huge_val_hex;
  1973. files = bits/huge_val.h;
  1974. select = "^#[ \t]*define[ \t]*HUGE_VAL[ \t].*0x1\\.0p.*";
  1975. bypass = "__builtin_huge_val";
  1976. c_fix = format;
  1977. c_fix_arg = "#define HUGE_VAL (__builtin_huge_val())\n";
  1978. test_text = "# define HUGE_VAL\t(__extension__ 0x1.0p2047)";
  1979. };
  1980. /*
  1981. * Fix glibc definition of HUGE_VALF in terms of hex floating point constant
  1982. */
  1983. fix = {
  1984. hackname = huge_valf_hex;
  1985. files = bits/huge_val.h;
  1986. select = "^#[ \t]*define[ \t]*HUGE_VALF[ \t].*0x1\\.0p.*";
  1987. bypass = "__builtin_huge_valf";
  1988. c_fix = format;
  1989. c_fix_arg = "#define HUGE_VALF (__builtin_huge_valf())\n";
  1990. test_text = "# define HUGE_VALF (__extension__ 0x1.0p255f)";
  1991. };
  1992. /*
  1993. * Fix glibc definition of HUGE_VALL in terms of hex floating point constant
  1994. */
  1995. fix = {
  1996. hackname = huge_vall_hex;
  1997. files = bits/huge_val.h;
  1998. select = "^#[ \t]*define[ \t]*HUGE_VALL[ \t].*0x1\\.0p.*";
  1999. bypass = "__builtin_huge_vall";
  2000. c_fix = format;
  2001. c_fix_arg = "#define HUGE_VALL (__builtin_huge_vall())\n";
  2002. test_text = "# define HUGE_VALL (__extension__ 0x1.0p32767L)";
  2003. };
  2004. /*
  2005. * Fix return type of abort and free
  2006. */
  2007. fix = {
  2008. hackname = int_abort_free_and_exit;
  2009. files = stdlib.h;
  2010. select = "int[ \t]+(abort|free|exit)[ \t]*\\(";
  2011. bypass = "_CLASSIC_ANSI_TYPES";
  2012. c_fix = format;
  2013. c_fix_arg = "void\t%1(";
  2014. test_text = "extern int abort(int);\n"
  2015. "extern int free(void*);\n"
  2016. "extern int exit(void*);";
  2017. };
  2018. /*
  2019. * Fix various macros used to define ioctl numbers.
  2020. * The traditional syntax was:
  2021. *
  2022. * #define _IO(n, x) (('n'<<8)+x)
  2023. * #define TIOCFOO _IO(T, 1)
  2024. *
  2025. * but this does not work with the C standard, which disallows macro
  2026. * expansion inside strings. We have to rewrite it thus:
  2027. *
  2028. * #define _IO(n, x) ((n<<8)+x)
  2029. * #define TIOCFOO _IO('T', 1)
  2030. *
  2031. * The select expressions match too much, but the c_fix code is cautious.
  2032. *
  2033. * _IO might be: _IO DESIO BSD43__IO with W, R, WR, C, ... suffixes.
  2034. */
  2035. fix = {
  2036. hackname = io_quotes_def;
  2037. select = "define[ \t]+[A-Z0-9_]+IO[A-Z]*\\([a-zA-Z][,)]";
  2038. c_fix = char_macro_def;
  2039. c_fix_arg = "IO";
  2040. test_text =
  2041. "#define BSD43__IOWR(n, x) (('n'<<8)+x)\n"
  2042. "#define _IOWN(x,y,t) (_IOC_IN|(((t)&_IOCPARM_MASK)<<16)|('x'<<8)|y)\n"
  2043. "#define _IO(x,y) ('x'<<8|y)";
  2044. test_text =
  2045. "#define XX_IO(x) ('x'<<8|256)";
  2046. };
  2047. fix = {
  2048. hackname = io_quotes_use;
  2049. select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+IO[A-Z]*[ \t]*"
  2050. "\\( *[^,']";
  2051. c_fix = char_macro_use;
  2052. c_fix_arg = "IO";
  2053. test_text = "#define TIOCFOO BSD43__IOWR(T, 1)\n"
  2054. "#define TIOCFOO \\\\\n"
  2055. "BSD43__IOWR(T, 1) /* Some are multi-line */";
  2056. };
  2057. /*
  2058. * Check for missing ';' in struct
  2059. */
  2060. fix = {
  2061. hackname = ip_missing_semi;
  2062. files = netinet/ip.h;
  2063. select = "}$";
  2064. sed = "/^struct/,/^};/s/}$/};/";
  2065. test_text=
  2066. "struct mumble {\n"
  2067. " union {\n"
  2068. " int x;\n"
  2069. " }\n"
  2070. "}; /* mumbled struct */\n";
  2071. };
  2072. /*
  2073. * IRIX 6.5.1[89] <internal/sgimacros.h> unconditionally defines
  2074. * __restrict as restrict iff __c99. This is wrong for C++, which
  2075. * needs many C99 features, but only supports __restrict.
  2076. */
  2077. fix = {
  2078. hackname = irix___restrict;
  2079. files = internal/sgimacros.h;
  2080. select = "(#ifdef __c99\n)(#[ \t]*define __restrict restrict)";
  2081. mach = "mips-sgi-irix6.5";
  2082. c_fix = format;
  2083. c_fix_arg = "%1"
  2084. "# ifndef __cplusplus\n%2\n# endif";
  2085. test_text = "#ifdef __c99\n# define __restrict restrict";
  2086. };
  2087. /*
  2088. * IRIX 6.5.22 <internal/math_core.h> uses the SGI c99 __generic() intrinsic
  2089. * to define the fpclasify, isfinite, isinf, isnan, isnormal and signbit
  2090. * functions.
  2091. *
  2092. * This was probably introduced around IRIX 6.5.18
  2093. */
  2094. fix = {
  2095. hackname = irix___generic1;
  2096. files = internal/math_core.h;
  2097. mach = "mips-sgi-irix6.5";
  2098. select = "#define ([a-z]+)\\(x\\) *__generic.*";
  2099. c_fix = format;
  2100. c_fix_arg = "extern int %1(double);\n"
  2101. "extern int %1f(float);\n"
  2102. "extern int %1l(long double);\n"
  2103. "#define %1(x) (sizeof(x) == sizeof(double) ? _%1(x) \\\n"
  2104. " : sizeof(x) == sizeof(float) ? _%1f(x) \\\n"
  2105. " : _%1l(x))\n";
  2106. test_text =
  2107. "#define isnan(x) __generic(x,,, _isnan, _isnanf, _isnanl,,,)(x)\n";
  2108. };
  2109. /* Likewise <internal/math_core.h> on IRIX 6.5.19 and later uses the SGI
  2110. compiler's __generic intrinsic to define isgreater, isgreaterequal,
  2111. isless, islessequal, islessgreater and isunordered functions. */
  2112. fix = {
  2113. hackname = irix___generic2;
  2114. files = internal/math_core.h;
  2115. mach = "mips-sgi-irix6.5";
  2116. select = "#define ([a-z]+)\\(x,y\\) *__generic.*";
  2117. c_fix = format;
  2118. c_fix_arg = "#define %1(x,y) \\\n"
  2119. " ((sizeof(x)<=4 && sizeof(y)<=4) ? _%1f(x,y) \\\n"
  2120. " : (sizeof(x)<=8 && sizeof(y)<=8) ? _%1(x,y) \\\n"
  2121. " : _%1l(x,y))\n";
  2122. test_text =
  2123. "#define isless(x,y) __generic(x,y,, _isless, _islessf, _islessl,,,)(x,y)";
  2124. };
  2125. /*
  2126. * IRIX 5.2's <sys/asm.h> contains an asm comment with a contraction
  2127. * that causes the assembly preprocessor to complain about an
  2128. * unterminated character constant.
  2129. */
  2130. fix = {
  2131. hackname = irix_asm_apostrophe;
  2132. files = sys/asm.h;
  2133. select = "^[ \t]*#.*[Ww]e're";
  2134. c_fix = format;
  2135. c_fix_arg = "%1 are";
  2136. c_fix_arg = "^([ \t]*#.*[Ww]e)'re";
  2137. test_text = "\t# and we're on vacation";
  2138. };
  2139. /*
  2140. * IRIX 6.5 complex.h defines _Complex_I and _Imaginary_I in terms of __I__,
  2141. * which is a MIPSpro compiler builtin. Remove _Imaginary_I and imaginary
  2142. * definitions which are not supported by GCC.
  2143. */
  2144. fix = {
  2145. hackname = irix_complex;
  2146. mach = "mips-sgi-irix6.5";
  2147. files = complex.h;
  2148. select = "#define[ \t]_Complex_I[ \t]\\(\\(float[ \t]_Complex\\)[ \t]\\(__I__\\)\\)";
  2149. sed = "s/#define[ \t]_Complex_I[ \t]((float[ \t]_Complex)[ \t](__I__))/"
  2150. "#define _Complex_I (__extension__ 1.0iF)/";
  2151. sed = "/#define[ \t]imaginary[ \t]_Imaginary/d";
  2152. sed = "/#define[ \t]_Imaginary_I/d";
  2153. sed = "s/#define[ \t]I[ \t]_Imaginary_I/#define I _Complex_I/";
  2154. test_text = "#define _Complex_I ((float _Complex) (__I__))\n"
  2155. "#define imaginary _Imaginary\n"
  2156. "// #define _Imaginary_I ((float _Imaginary) 1)\n"
  2157. "#define _Imaginary_I __I__\n"
  2158. "#define I _Imaginary_I";
  2159. };
  2160. /*
  2161. * Non-traditional "const" declaration in Irix's limits.h.
  2162. */
  2163. fix = {
  2164. hackname = irix_limits_const;
  2165. files = fixinc-test-limits.h, limits.h;
  2166. select = "^extern const ";
  2167. c_fix = format;
  2168. c_fix_arg = "extern __const ";
  2169. test_text = "extern const char limit; /* test limits */";
  2170. };
  2171. /*
  2172. * IRIX 6.5.1[78] <sys/socket.h> has a broken definition of socklen_t.
  2173. * Various socket function prototypes use different types instead,
  2174. * depending on the API in use (BSD, XPG4/5), but the socklen_t
  2175. * definition doesn't reflect this (SGI Bug Id 864477, fixed in
  2176. * IRIX 6.5.19).
  2177. */
  2178. fix = {
  2179. hackname = irix_socklen_t;
  2180. files = sys/socket.h;
  2181. select = "(#define _SOCKLEN_T\n)(typedef u_int32_t socklen_t;)";
  2182. mach = "mips-sgi-irix6.5";
  2183. c_fix = format;
  2184. c_fix_arg = "%1"
  2185. "#if _NO_XOPEN4 && _NO_XOPEN5\n"
  2186. "typedef int socklen_t;\n"
  2187. "#else\n"
  2188. "%2\n"
  2189. "#endif /* _NO_XOPEN4 && _NO_XOPEN5 */";
  2190. test_text = "#define _SOCKLEN_T\ntypedef u_int32_t socklen_t;";
  2191. };
  2192. /*
  2193. * IRIX 6.5 <stdint.h> only works with ISO C99 and errors out
  2194. * otherwise.
  2195. */
  2196. fix = {
  2197. hackname = irix_stdint_c99_mode;
  2198. files = stdint.h;
  2199. select = "(#ifndef __c99\n)(#error This header file is to be used only for c99 mode compilations)";
  2200. mach = "mips-sgi-irix6.5";
  2201. c_fix = format;
  2202. c_fix_arg = "#if 0\n"
  2203. "%2";
  2204. test_text =
  2205. "#ifndef __c99\n#error This header file is to be used only for c99 mode compilations\n#else";
  2206. };
  2207. /*
  2208. * IRIX 6.5 <stdint.h> has some *_MIN/MAX constants whose types don't
  2209. * match the corresponding types, as required by ISO C99.
  2210. */
  2211. fix = {
  2212. hackname = irix_stdint_c99_types;
  2213. files = stdint-irix65.h, stdint.h;
  2214. mach = "mips-sgi-irix6.5";
  2215. sed = "s@^#define INT64_MIN.*(-0x7fffffffffffffff - 1)$@"
  2216. "#define INT64_MIN (-0x7fffffffffffffffLL - 1)@";
  2217. sed = "s@^#define INT64_MAX.*0x7fffffffffffffff$@"
  2218. "#define INT64_MAX 0x7fffffffffffffffLL@";
  2219. sed = "s@^#define UINT32_MAX.*0xffffffff$@"
  2220. "#define UINT32_MAX 0xffffffffU@";
  2221. sed = "s@^#define UINT64_MAX.*0xffffffffffffffff$@"
  2222. "#define UINT64_MAX 0xffffffffffffffffULL@";
  2223. sed = "s@^#define INTPTR_MIN.*INT32_MIN$@"
  2224. "#define INTPTR_MIN (-0x7fffffffL - 1)@";
  2225. sed = "s@^#define INTPTR_MAX.*INT32_MAX$@"
  2226. "#define INTPTR_MAX 0x7fffffffL@";
  2227. sed = "s@^#define UINTPTR_MAX.*UINT32_MAX$@"
  2228. "#define UINTPTR_MAX 0xffffffffUL@";
  2229. sed = "s@^#define INTPTR_MIN.*INT64_MIN@"
  2230. "#define INTPTR_MIN (-0x7fffffffffffffffL - 1)@";
  2231. sed = "s@^#define INTPTR_MAX.*INT64_MAX$@"
  2232. "#define INTPTR_MAX 0x7fffffffffffffffL@";
  2233. sed = "s@^#define UINTPTR_MAX.*UINT64_MAX$@"
  2234. "#define UINTPTR_MAX 0xffffffffffffffffUL@";
  2235. sed = "s@^#define PTRDIFF_MIN.*INT64_MIN$@"
  2236. "#define PTRDIFF_MIN (-0x7fffffffffffffffL - 1)@";
  2237. sed = "s@^#define PTRDIFF_MAX.*INT64_MAX$@"
  2238. "#define PTRDIFF_MAX 0x7fffffffffffffffL@";
  2239. sed = "s@^#define SIZE_MAX.*UINT64_MAX$@"
  2240. "#define SIZE_MAX 0xffffffffffffffffUL@";
  2241. test_text = "#define INT64_MIN (-0x7fffffffffffffff - 1)\n"
  2242. "#define INT64_MAX 0x7fffffffffffffff\n"
  2243. "#define UINT32_MAX 0xffffffff\n"
  2244. "#define UINT64_MAX 0xffffffffffffffff\n"
  2245. "#define INTPTR_MIN INT32_MIN\n"
  2246. "#define INTPTR_MAX INT32_MAX\n"
  2247. "#define UINTPTR_MAX UINT32_MAX\n"
  2248. "#define INTPTR_MIN INT64_MIN\n"
  2249. "#define INTPTR_MAX INT64_MAX\n"
  2250. "#define UINTPTR_MAX UINT64_MAX\n"
  2251. "#define PTRDIFF_MIN INT64_MIN\n"
  2252. "#define PTRDIFF_MAX INT64_MAX\n"
  2253. "#define SIZE_MAX UINT64_MAX";
  2254. };
  2255. /*
  2256. * IRIX 6.5 <stdint.h> uses casts in some macros which cannot thus be used
  2257. * in preprocessor tests, although ISO C99 requires this.
  2258. */
  2259. fix = {
  2260. hackname = irix_stdint_c99_macros;
  2261. files = stdint-irix65.h, stdint.h;
  2262. mach = "mips-sgi-irix6.5";
  2263. sed = "s@^#define INT8_C(x).*int.*_t.*$@#define INT8_C(x) (x)@";
  2264. sed = "s@^#define INT16_C(x).*int.*_t.*$@#define INT16_C(x) (x)@";
  2265. sed = "s@^#define INT32_C(x).*int.*_t.*$@#define INT32_C(x) (x)@";
  2266. sed = "s@^#define INT64_C(x).*int.*_t.*$@#define INT64_C(x) (x ## LL)@";
  2267. sed = "s@^#define UINT8_C(x).*int.*_t.*$@#define UINT8_C(x) (x)@";
  2268. sed = "s@^#define UINT16_C(x).*int.*_t.*$@#define UINT16_C(x) (x)@";
  2269. sed = "s@^#define UINT32_C(x).*int.*_t.*$@#define UINT32_C(x) (x ## U)@";
  2270. sed = "s@^#define UINT64_C(x).*int.*_t.*$@#define UINT64_C(x) (x ## ULL)@";
  2271. sed = "s@^#define INTMAX_C(x).*int.*_t.*$@#define INTMAX_C(x) (x ## LL)@";
  2272. sed = "s@^#define UINTMAX_C(x).*int.*_t.*$@#define UINTMAX_C(x) (x ## ULL)@";
  2273. test_text = "#define INT8_C(x) (int_least8_t)(x)\n"
  2274. "#define INT16_C(x) (int_least16_t)(x)\n"
  2275. "#define INT32_C(x) (int_least32_t)(x)\n"
  2276. "#define INT64_C(x) (int_least64_t)(x)\n"
  2277. "#define UINT8_C(x) (uint_least8_t)(x)\n"
  2278. "#define UINT16_C(x) (uint_least16_t)(x)\n"
  2279. "#define UINT32_C(x) (uint_least32_t)(x)\n"
  2280. "#define UINT64_C(x) (uint_least64_t)(x)\n"
  2281. "#define INTMAX_C(x) (intmax_t)(x)\n"
  2282. "#define UINTMAX_C(x) (uintmax_t)(x)";
  2283. };
  2284. /*
  2285. * IRIX 5.x's stdio.h and IRIX 6.5's internal/stdio_core.h declare
  2286. * some functions that take a va_list as
  2287. * taking char *. However, GCC uses void * for va_list, so
  2288. * calling vfprintf with a va_list fails in C++. */
  2289. fix = {
  2290. hackname = irix_stdio_va_list;
  2291. files = stdio.h;
  2292. files = internal/stdio_core.h;
  2293. select = '/\* va_list \*/ char \*';
  2294. c_fix = format;
  2295. c_fix_arg = "__gnuc_va_list";
  2296. test_text =
  2297. "extern int printf( const char *, /* va_list */ char * );";
  2298. };
  2299. /*
  2300. * IRIX 6.5.19 <internal/wchar_core.h> provides the XPG4 variant of
  2301. * wcsftime by default. ISO C99 requires the XPG5 variant instead.
  2302. */
  2303. fix = {
  2304. hackname = irix_wcsftime;
  2305. files = internal/wchar_core.h;
  2306. select = "#if _NO_XOPEN5\n(extern size_t[ \t]+wcsftime.*const char \*.*)";
  2307. mach = "mips-sgi-irix6.5";
  2308. c_fix = format;
  2309. c_fix_arg = "#if _NO_XOPEN5 && !defined(__c99)\n%1";
  2310. test_text = "#if _NO_XOPEN5\n"
  2311. "extern size_t wcsftime(wchar_t *, "
  2312. "__SGI_LIBC_NAMESPACE_QUALIFIER size_t, const char *, "
  2313. "const struct tm *);";
  2314. };
  2315. /*
  2316. * These files in Sun OS 4.x and ARM/RISCiX and BSD4.3
  2317. * use / * * / to concatenate tokens.
  2318. */
  2319. fix = {
  2320. hackname = kandr_concat;
  2321. files = "sparc/asm_linkage.h";
  2322. files = "sun*/asm_linkage.h";
  2323. files = "arm/as_support.h";
  2324. files = "arm/mc_type.h";
  2325. files = "arm/xcb.h";
  2326. files = "dev/chardefmac.h";
  2327. files = "dev/ps_irq.h";
  2328. files = "dev/screen.h";
  2329. files = "dev/scsi.h";
  2330. files = "sys/tty.h";
  2331. files = "Xm.acorn/XmP.h";
  2332. files = bsd43/bsd43_.h;
  2333. select = '/\*\*/';
  2334. c_fix = format;
  2335. c_fix_arg = '##';
  2336. test_text = "#define __CONCAT__(a,b) a/**/b";
  2337. };
  2338. /* The /usr/include/sys/ucontext.h on ia64-*linux-gnu systems defines
  2339. * an _SC_GR0_OFFSET macro using an idiom that isn't a compile time
  2340. * constant on recent versions of g++.
  2341. */
  2342. fix = {
  2343. hackname = linux_ia64_ucontext;
  2344. files = "sys/ucontext.h";
  2345. mach = "ia64-*-linux*";
  2346. select = '\(\(\(char \*\) &\(\(struct sigcontext \*\) 0\)'
  2347. '->sc_gr\[0\]\) - \(char \*\) 0\)';
  2348. c_fix = format;
  2349. c_fix_arg = "__builtin_offsetof \(struct sigcontext, sc_gr[0]\)";
  2350. test_text = "# define _SC_GR0_OFFSET\t\\\\\n"
  2351. "\t(((char *) &((struct sigcontext *) 0)->sc_gr[0]) - (char *) 0)\n";
  2352. };
  2353. /*
  2354. * Remove header file warning from sys/time.h. Autoconf's
  2355. * AC_HEADER_TIME recommends to include both sys/time.h and time.h
  2356. * which causes warning on LynxOS. Remove the warning.
  2357. */
  2358. fix = {
  2359. hackname = lynxos_no_warning_in_sys_time_h;
  2360. files = sys/time.h;
  2361. select = "#warning[ \t]+Using <time.h> instead of <sys/time.h>";
  2362. c_fix = format;
  2363. c_fix_arg = "";
  2364. test_text = "#warning Using <time.h> instead of <sys/time.h>";
  2365. };
  2366. /*
  2367. * Add missing declaration for putenv.
  2368. */
  2369. fix = {
  2370. hackname = lynxos_missing_putenv;
  2371. mach = '*-*-lynxos*';
  2372. files = stdlib.h;
  2373. bypass = 'putenv[ \t]*\\(';
  2374. select = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
  2375. c_fix = format;
  2376. c_fix_arg = "%0\n"
  2377. "extern int putenv _AP((char *));";
  2378. c_fix_arg = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
  2379. test_text = "extern char *getenv _AP((const char *));";
  2380. };
  2381. /*
  2382. * Fix BSD machine/ansi.h to use __builtin_va_list to define _BSD_VA_LIST_.
  2383. *
  2384. * On NetBSD, machine is a symbolic link to an architecture specific
  2385. * directory name, so we can't match a specific file name here.
  2386. */
  2387. fix = {
  2388. hackname = machine_ansi_h_va_list;
  2389. select = "define[ \t]+_BSD_VA_LIST_[ \t]";
  2390. bypass = '__builtin_va_list';
  2391. c_fix = format;
  2392. c_fix_arg = "%1__builtin_va_list";
  2393. c_fix_arg = "(define[ \t]+_BSD_VA_LIST_[ \t]+).*";
  2394. test_text = " # define _BSD_VA_LIST_\tchar**";
  2395. };
  2396. /*
  2397. * Fix non-ansi machine name defines
  2398. */
  2399. fix = {
  2400. hackname = machine_name;
  2401. c_test = machine_name;
  2402. c_fix = machine_name;
  2403. test_text = "/* MACH_DIFF: */\n"
  2404. "#if defined( i386 ) || defined( sparc ) || defined( vax )"
  2405. "\n/* no uniform test, so be careful :-) */";
  2406. };
  2407. /*
  2408. * Some math.h files define struct exception (it's in the System V
  2409. * Interface Definition), which conflicts with the class exception defined
  2410. * in the C++ file std/stdexcept.h. We redefine it to __math_exception.
  2411. * This is not a great fix, but I haven't been able to think of anything
  2412. * better.
  2413. */
  2414. fix = {
  2415. hackname = math_exception;
  2416. files = math.h;
  2417. select = "struct exception";
  2418. /*
  2419. * This should be bypassed on __cplusplus, but some supposedly C++ C++
  2420. * aware headers, such as Solaris 8 and 9, don't wrap their struct
  2421. * exception either. So currently we bypass only for glibc, based on a
  2422. * comment in the fixed glibc header. Ick.
  2423. */
  2424. bypass = 'We have a problem when using C\+\+|for C\+\+, '
  2425. '_[a-z0-9A-Z_]+_exception; for C, exception';
  2426. c_fix = wrap;
  2427. c_fix_arg = "#ifdef __cplusplus\n"
  2428. "#define exception __math_exception\n"
  2429. "#endif\n";
  2430. c_fix_arg = "#ifdef __cplusplus\n"
  2431. "#undef exception\n"
  2432. "#endif\n";
  2433. test_text = "typedef struct exception t_math_exception;";
  2434. };
  2435. /*
  2436. * This looks pretty broken to me. ``dbl_max_def'' will contain
  2437. * "define DBL_MAX " at the start, when what we really want is just
  2438. * the value portion. Can't figure out how to write a test case
  2439. * for this either :-(
  2440. */
  2441. fix = {
  2442. hackname = math_huge_val_from_dbl_max;
  2443. files = math.h;
  2444. /*
  2445. * IF HUGE_VAL is defined to be DBL_MAX *and* DBL_MAX is _not_ defined
  2446. * in math.h, this fix applies.
  2447. */
  2448. select = "define[ \t]+HUGE_VAL[ \t]+DBL_MAX";
  2449. bypass = "define[ \t]+DBL_MAX";
  2450. shell =
  2451. /*
  2452. * See if we have a definition for DBL_MAX in float.h.
  2453. * If we do, we will replace the one in math.h with that one.
  2454. */
  2455. "\tdbl_max_def=`egrep 'define[ \t]+DBL_MAX[ \t]+.*' float.h "
  2456. "| sed 's/.*DBL_MAX[ \t]*//' 2>/dev/null`\n\n"
  2457. "\tif ( test -n \"${dbl_max_def}\" ) > /dev/null 2>&1\n"
  2458. "\tthen sed -e '/define[ \t]*HUGE_VAL[ \t]*DBL_MAX/"
  2459. "s@DBL_MAX@'\"$dbl_max_def@\"\n"
  2460. "\telse cat\n"
  2461. "\tfi";
  2462. test_text =
  2463. "`echo '#define DBL_MAX\t3.1415e+9 /* really big */' >> float.h`\n"
  2464. "#define HUGE_VAL DBL_MAX";
  2465. };
  2466. /*
  2467. * nested comment
  2468. */
  2469. fix = {
  2470. hackname = nested_auth_des;
  2471. files = rpc/rpc.h;
  2472. select = '(/\*.*rpc/auth_des\.h>.*)/\*';
  2473. c_fix = format;
  2474. c_fix_arg = "%1*/ /*";
  2475. test_text = "/*#include <rpc/auth_des.h> /* skip this */";
  2476. };
  2477. /*
  2478. * Some versions of NetBSD don't expect the C99 inline semantics.
  2479. */
  2480. fix = {
  2481. hackname = netbsd_c99_inline_1;
  2482. mach = "*-*-netbsd*";
  2483. files = signal.h;
  2484. select = "extern __inline int";
  2485. c_fix = format;
  2486. c_fix_arg = "extern\n"
  2487. "#ifdef __GNUC_STDC_INLINE__\n"
  2488. "__attribute__((__gnu_inline__))\n"
  2489. "#endif\n"
  2490. "__inline int";
  2491. test_text = "extern __inline int\nsigaddset(sigset_t *set, int signo)\n{}";
  2492. };
  2493. fix = {
  2494. hackname = netbsd_c99_inline_2;
  2495. mach = "*-*-netbsd*";
  2496. files = signal.h;
  2497. select = "#define _SIGINLINE extern __inline";
  2498. c_fix = format;
  2499. c_fix_arg = <<- _EOArg_
  2500. #ifdef __GNUC_STDC_INLINE__
  2501. #define _SIGINLINE extern __attribute__((__gnu_inline__)) __inline
  2502. #else
  2503. %0
  2504. #endif
  2505. _EOArg_;
  2506. test_text = "#define _SIGINLINE extern __inline";
  2507. };
  2508. /*
  2509. * NetBSD has a semicolon after the ending '}' for some extern "C".
  2510. */
  2511. fix = {
  2512. hackname = netbsd_extra_semicolon;
  2513. mach = "*-*-netbsd*";
  2514. files = sys/cdefs.h;
  2515. select = "#define[ \t]*__END_DECLS[ \t]*};";
  2516. c_fix = format;
  2517. c_fix_arg = "#define __END_DECLS }";
  2518. test_text = "#define __END_DECLS };";
  2519. };
  2520. /* newlib's stdint.h has several failures to conform to C99. The fix
  2521. for these removed a comment that can be matched to identify unfixed
  2522. versions. */
  2523. fix = {
  2524. hackname = newlib_stdint_1;
  2525. files = stdint-newlib.h, stdint.h;
  2526. select = "@todo - Add support for wint_t types";
  2527. sed = "s@#define INT32_MIN.*@#define INT32_MIN (-INT32_MAX - 1)@";
  2528. sed = "s@#define INT32_MAX.*@#define INT32_MAX __INT32_MAX__@";
  2529. sed = "s@#define UINT32_MAX.*@#define UINT32_MAX __UINT32_MAX__@";
  2530. sed = "s@#define INT_LEAST32_MIN.*@#define INT_LEAST32_MIN (-INT_LEAST32_MAX - 1)@";
  2531. sed = "s@#define INT_LEAST32_MAX.*@#define INT_LEAST32_MAX __INT_LEAST32_MAX__@";
  2532. sed = "s@#define UINT_LEAST32_MAX.*@#define UINT_LEAST32_MAX __UINT_LEAST32_MAX__@";
  2533. sed = 's@#define INT_FAST\([0-9]*\)_MIN.*@#define INT_FAST\1_MIN (-INT_FAST\1_MAX - 1)@';
  2534. sed = 's@#define INT_FAST\([0-9]*\)_MAX.*@#define INT_FAST\1_MAX __INT_FAST\1_MAX__@';
  2535. sed = 's@#define UINT_FAST\([0-9]*\)_MAX.*@#define UINT_FAST\1_MAX __UINT_FAST\1_MAX__@';
  2536. sed = "s@#define SIZE_MAX.*@#define SIZE_MAX __SIZE_MAX__@";
  2537. sed = "s@#define PTRDIFF_MIN.*@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
  2538. sed = "s@#define PTRDIFF_MAX.*@#define PTRDIFF_MAX __PTRDIFF_MAX__@";
  2539. sed = "s@#define UINT8_C.*@#define UINT8_C(c) __UINT8_C(c)@";
  2540. sed = "s@#define UINT16_C.*@#define UINT16_C(c) __UINT16_C(c)@";
  2541. test_text = "/* @todo - Add support for wint_t types. */\n"
  2542. "#define INT32_MIN (-2147483647-1)\n"
  2543. "#define INT32_MAX 2147483647\n"
  2544. "#define UINT32_MAX 4294967295U\n"
  2545. "#define INT_LEAST32_MIN (-2147483647-1)\n"
  2546. "#define INT_LEAST32_MAX 2147483647\n"
  2547. "#define UINT_LEAST32_MAX 4294967295U\n"
  2548. "#define INT_FAST8_MIN INT8_MIN\n"
  2549. "#define INT_FAST8_MAX INT8_MAX\n"
  2550. "#define UINT_FAST8_MAX UINT8_MAX\n"
  2551. "#define SIZE_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1)\n"
  2552. "#define PTRDIFF_MIN (-__STDINT_EXP(LONG_MAX) - 1L)\n"
  2553. "#define PTRDIFF_MAX __STDINT_EXP(LONG_MAX)\n"
  2554. "#define UINT8_C(x) x##U\n"
  2555. "#define UINT16_C(x) x##U";
  2556. };
  2557. fix = {
  2558. hackname = newlib_stdint_2;
  2559. files = stdint-newlib.h, stdint.h;
  2560. select = "@todo - Add support for wint_t types";
  2561. c_fix = format;
  2562. c_fix_arg = "#define INTMAX_MAX __INTMAX_MAX__\n"
  2563. "#define INTMAX_MIN (-INTMAX_MAX - 1)\n"
  2564. "#define UINTMAX_MAX __UINTMAX_MAX__\n"
  2565. "#define WCHAR_MAX __WCHAR_MAX__\n"
  2566. "#define WCHAR_MIN __WCHAR_MIN__\n"
  2567. "#define WINT_MAX __WINT_MAX__\n"
  2568. "#define WINT_MIN __WINT_MIN__\n\n"
  2569. "%0";
  2570. c_fix_arg = '/\*\* Macros for minimum-width integer constant expressions \*/';
  2571. test_text = "/* @todo - Add support for wint_t types. */\n"
  2572. "/** Macros for minimum-width integer constant expressions */";
  2573. };
  2574. /*
  2575. * NeXT 3.2 adds const prefix to some math functions.
  2576. * These conflict with the built-in functions.
  2577. */
  2578. fix = {
  2579. hackname = next_math_prefix;
  2580. files = ansi/math.h;
  2581. select = "^extern[ \t]+double[ \t]+__const__[ \t]";
  2582. c_fix = format;
  2583. c_fix_arg = "extern double %1(";
  2584. c_fix_arg = "^extern[ \t]+double[ \t]+__const__[ \t]+([a-z]+)\\(";
  2585. test_text = "extern\tdouble\t__const__\tmumble();";
  2586. };
  2587. /*
  2588. * NeXT 3.2 uses the word "template" as a parameter for some
  2589. * functions. GCC reports an invalid use of a reserved key word
  2590. * with the built-in functions.
  2591. */
  2592. fix = {
  2593. hackname = next_template;
  2594. files = bsd/libc.h;
  2595. select = "[ \t]template\\)";
  2596. c_fix = format;
  2597. c_fix_arg = "(%1)";
  2598. c_fix_arg = "\\(([^)]*)[ \t]template\\)";
  2599. test_text = "extern mumble( char * template); /* fix */";
  2600. };
  2601. /*
  2602. * NeXT 3.2 includes the keyword volatile in the abort() and exit()
  2603. * function prototypes. That conflicts with the built-in functions.
  2604. */
  2605. fix = {
  2606. hackname = next_volitile;
  2607. files = ansi/stdlib.h;
  2608. select = "^extern[ \t]+volatile[ \t]+void[ \t]";
  2609. c_fix = format;
  2610. c_fix_arg = "extern void %1(";
  2611. c_fix_arg = "^extern[ \t]+volatile[ \t]+void[ \t]+(exit|abort)\\(";
  2612. test_text = "extern\tvolatile\tvoid\tabort();";
  2613. };
  2614. /*
  2615. * NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
  2616. * Note that version 3 of the NeXT system has wait.h in a different directory,
  2617. * so that this code won't do anything. But wait.h in version 3 has a
  2618. * conditional, so it doesn't need this fix. So everything is okay.
  2619. */
  2620. fix = {
  2621. hackname = next_wait_union;
  2622. files = sys/wait.h;
  2623. select = 'wait\(union wait';
  2624. c_fix = format;
  2625. c_fix_arg = "wait(void";
  2626. test_text = "extern pid_d wait(union wait*);";
  2627. };
  2628. /*
  2629. * a missing semi-colon at the end of the nodeent structure definition.
  2630. */
  2631. fix = {
  2632. hackname = nodeent_syntax;
  2633. files = netdnet/dnetdb.h;
  2634. select = "char[ \t]*\\*na_addr[ \t]*$";
  2635. c_fix = format;
  2636. c_fix_arg = "%0;";
  2637. test_text = "char *na_addr\t";
  2638. };
  2639. /*
  2640. * Fix OpenBSD's NULL definition.
  2641. */
  2642. fix = {
  2643. hackname = openbsd_null_definition;
  2644. mach = "*-*-openbsd*";
  2645. files = locale.h, stddef.h, stdio.h, string.h,
  2646. time.h, unistd.h, wchar.h, sys/param.h;
  2647. select = "__GNUG__";
  2648. c_fix = format;
  2649. c_fix_arg = "#ifndef NULL\n"
  2650. "#ifdef __cplusplus\n"
  2651. "#ifdef __GNUG__\n"
  2652. "#define NULL\t__null\n"
  2653. "#else\t /* ! __GNUG__ */\n"
  2654. "#define NULL\t0L\n"
  2655. "#endif\t /* __GNUG__ */\n"
  2656. "#else\t /* ! __cplusplus */\n"
  2657. "#define NULL\t((void *)0)\n"
  2658. "#endif\t /* __cplusplus */\n"
  2659. "#endif\t /* !NULL */";
  2660. c_fix_arg = "^#ifndef[ \t]*NULL\n"
  2661. "^#ifdef[ \t]*__GNUG__\n"
  2662. "^#define[ \t]*NULL[ \t]*__null\n"
  2663. "^#else\n"
  2664. "^#define[ \t]*NULL[ \t]*0L\n"
  2665. "^#endif\n"
  2666. "^#endif";
  2667. test_text =
  2668. "#ifndef NULL\n"
  2669. "#ifdef __GNUG__\n"
  2670. "#define NULL __null\n"
  2671. "#else\n"
  2672. "#define NULL 0L\n"
  2673. "#endif\n"
  2674. "#endif\n";
  2675. };
  2676. /*
  2677. * obstack.h used casts as lvalues.
  2678. *
  2679. * We need to change postincrements of casted pointers (which are
  2680. * then dereferenced and assigned into) of the form
  2681. *
  2682. * *((TYPE*)PTRVAR)++ = (VALUE)
  2683. *
  2684. * into expressions like
  2685. *
  2686. * ((*((TYPE*)PTRVAR) = (VALUE)), (PTRVAR += sizeof (TYPE)))
  2687. *
  2688. * which is correct for the cases used in obstack.h since PTRVAR is
  2689. * of type char * and the value of the expression is not used.
  2690. */
  2691. fix = {
  2692. hackname = obstack_lvalue_cast;
  2693. files = obstack.h;
  2694. select = '\*\(\(([^()]*)\*\)(.*)\)\+\+ = \(([^()]*)\)';
  2695. c_fix = format;
  2696. c_fix_arg = "((*((%1*)%2) = (%3)), (%2 += sizeof (%1)))";
  2697. test_text = "*((void **) (h)->next_free)++ = (aptr)";
  2698. };
  2699. /*
  2700. * Fix OpenBSD's va_start define.
  2701. */
  2702. fix = {
  2703. hackname = openbsd_va_start;
  2704. mach = "*-*-openbsd*";
  2705. files = stdarg.h;
  2706. select = '__builtin_stdarg_start';
  2707. c_fix = format;
  2708. c_fix_arg = __builtin_va_start;
  2709. test_text = "#define va_start(v,l) __builtin_stdarg_start((v),l)";
  2710. };
  2711. /*
  2712. * sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by
  2713. * defining regex.h related types. This causes libg++ build and usage
  2714. * failures. Fixing this correctly requires checking and modifying 3 files.
  2715. */
  2716. fix = {
  2717. hackname = osf_namespace_a;
  2718. files = reg_types.h;
  2719. files = sys/lc_core.h;
  2720. test = " -r reg_types.h";
  2721. test = " -r sys/lc_core.h";
  2722. test = " -n \"`grep '} regex_t;' reg_types.h`\"";
  2723. test = " -z \"`grep __regex_t regex.h`\"";
  2724. c_fix = format;
  2725. c_fix_arg = "__%0";
  2726. c_fix_arg = "reg(ex|off|match)_t";
  2727. test_text = "`touch sys/lc_core.h`"
  2728. "typedef struct {\n int stuff, mo_suff;\n} regex_t;\n"
  2729. "extern regex_t re;\n"
  2730. "extern regoff_t ro;\n"
  2731. "extern regmatch_t rm;\n";
  2732. };
  2733. fix = {
  2734. hackname = osf_namespace_c;
  2735. files = regex.h;
  2736. test = " -r reg_types.h";
  2737. test = " -r sys/lc_core.h";
  2738. test = " -n \"`grep '} regex_t;' reg_types.h`\"";
  2739. test = " -z \"`grep __regex_t regex.h`\"";
  2740. select = "#include <reg_types\.h>.*";
  2741. c_fix = format;
  2742. c_fix_arg = "%0\n"
  2743. "typedef __regex_t\tregex_t;\n"
  2744. "typedef __regoff_t\tregoff_t;\n"
  2745. "typedef __regmatch_t\tregmatch_t;";
  2746. test_text = "#include <reg_types.h>";
  2747. };
  2748. /*
  2749. * On broken glibc-2.3.3 systems an array of incomplete structures is
  2750. * passed to __sigsetjmp. Fix that to take a pointer instead.
  2751. */
  2752. fix = {
  2753. hackname = pthread_incomplete_struct_argument;
  2754. files = pthread.h;
  2755. select = "struct __jmp_buf_tag";
  2756. c_fix = format;
  2757. c_fix_arg = "%1 *%2%3";
  2758. c_fix_arg = "^(extern int __sigsetjmp \\(struct __jmp_buf_tag) (__env)\\[1\\](.*)$";
  2759. test_text = "extern int __sigsetjmp (struct __jmp_buf_tag __env[1], int __savemask);";
  2760. };
  2761. /*
  2762. * Fix return type of fread and fwrite on sysV68
  2763. */
  2764. fix = {
  2765. hackname = read_ret_type;
  2766. files = stdio.h;
  2767. select = "extern int\t.*, fread\\(\\), fwrite\\(\\)";
  2768. c_fix = format;
  2769. c_fix_arg = "extern unsigned int fread(), fwrite();\n%1%2";
  2770. c_fix_arg = "(extern int\t.*), fread\\(\\), fwrite\\(\\)(.*)";
  2771. test_text = "extern int\tfclose(), fflush(), fread(), fwrite(), foo();";
  2772. };
  2773. /*
  2774. * Fix casts as lvalues in glibc's <rpc/xdr.h>.
  2775. */
  2776. fix = {
  2777. hackname = rpc_xdr_lvalue_cast_a;
  2778. files = rpc/xdr.h;
  2779. select = "#define[ \t]*IXDR_GET_LONG.*\\\\\n.*__extension__.*";
  2780. c_fix = format;
  2781. c_fix_arg = "#define IXDR_GET_LONG(buf) ((long)IXDR_GET_U_INT32(buf))";
  2782. test_text = "#define IXDR_GET_LONG(buf) \\\\\n"
  2783. "\t((long)ntohl((u_long)*__extension__((u_int32_t*)(buf))++))";
  2784. };
  2785. fix = {
  2786. hackname = rpc_xdr_lvalue_cast_b;
  2787. files = rpc/xdr.h;
  2788. select = "#define[ \t]*IXDR_PUT_LONG.*\\\\\n.*__extension__.*";
  2789. c_fix = format;
  2790. c_fix_arg = "#define IXDR_PUT_LONG(buf, v) ((long)IXDR_PUT_INT32(buf, (long)(v)))";
  2791. test_text = "#define IXDR_PUT_LONG(buf, v) \\\\\n"
  2792. "\t(*__extension__((u_int32_t*)(buf))++ = (long)htonl((u_long)(v)))";
  2793. };
  2794. /*
  2795. * function class(double x) conflicts with C++ keyword on rs/6000
  2796. */
  2797. fix = {
  2798. hackname = rs6000_double;
  2799. files = math.h;
  2800. select = '[^a-zA-Z_]class\(';
  2801. c_fix = format;
  2802. c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
  2803. c_fix_arg = '^.*[^a-zA-Z_]class\(.*';
  2804. test_text = "extern int class();";
  2805. };
  2806. /*
  2807. * Wrong fchmod prototype on RS/6000.
  2808. */
  2809. fix = {
  2810. hackname = rs6000_fchmod;
  2811. files = sys/stat.h;
  2812. select = 'fchmod\(char \*';
  2813. c_fix = format;
  2814. c_fix_arg = "fchmod(int";
  2815. test_text = "extern int fchmod(char *, mode_t);";
  2816. };
  2817. /*
  2818. * parameters conflict with C++ new on rs/6000
  2819. */
  2820. fix = {
  2821. hackname = rs6000_param;
  2822. files = "stdio.h";
  2823. files = "unistd.h";
  2824. select = 'rename\(const char \*old, const char \*new\)';
  2825. c_fix = format;
  2826. c_fix_arg = 'rename(const char *_old, const char *_new)';
  2827. test_text = 'extern int rename(const char *old, const char *new);';
  2828. };
  2829. /*
  2830. * Solaris 10+ complex.h defines _Complex_I and _Imaginary_I in terms of
  2831. * themselves, which are Sun Studio compiler intrinsics. Remove _Imaginary_I
  2832. * and imaginary definitions which are not supported by GCC.
  2833. */
  2834. fix = {
  2835. hackname = solaris_complex;
  2836. mach = "*-*-solaris2.*";
  2837. files = complex.h;
  2838. select = "#define[ \t]_Complex_I[ \t]_Complex_I";
  2839. sed = "s/#define[ \t]_Complex_I[ \t]_Complex_I/"
  2840. "#define\t_Complex_I\t(__extension__ 1.0iF)/";
  2841. sed = "/#define[ \t]_Imaginary_I[ \t]_Imaginary_I/d";
  2842. sed = "/#define[ \t]imaginary[ \t]_Imaginary/d";
  2843. sed = "s/#define[ \t]I[ \t]\\{1,\\}_Imaginary_I/#define\tI\t\t_Complex_I/";
  2844. test_text = "#define _Complex_I _Complex_I\n"
  2845. "#define complex _Complex\n"
  2846. "#define _Imaginary_I _Imaginary_I\n"
  2847. "#define imaginary _Imaginary\n"
  2848. "#undef I\n"
  2849. "#define I _Imaginary_I";
  2850. };
  2851. /*
  2852. * Sun Solaris 10 defines several C99 math macros in terms of
  2853. * builtins specific to the Studio compiler, in particular not
  2854. * compatible with the GNU compiler.
  2855. */
  2856. fix = {
  2857. hackname = solaris_math_1;
  2858. select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
  2859. bypass = "__GNUC__";
  2860. files = iso/math_c99.h;
  2861. c_fix = format;
  2862. c_fix_arg = "#define\tHUGE_VA%1\t(__builtin_huge_va%2())";
  2863. c_fix_arg = "^#define[ \t]+HUGE_VA([LF]+)[ \t]+__builtin_huge_va([lf]+)";
  2864. test_text =
  2865. '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
  2866. "#undef HUGE_VAL\n"
  2867. "#define HUGE_VAL __builtin_huge_val\n"
  2868. "#undef HUGE_VALF\n"
  2869. "#define HUGE_VALF __builtin_huge_valf\n"
  2870. "#undef HUGE_VALL\n"
  2871. "#define HUGE_VALL __builtin_huge_vall";
  2872. };
  2873. fix = {
  2874. hackname = solaris_math_2;
  2875. select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
  2876. bypass = "__GNUC__";
  2877. files = iso/math_c99