1c87b03e5Sespie/* -*- Mode: C -*- */ 2c87b03e5Sespie 3c87b03e5Sespieautogen definitions fixincl; 4c87b03e5Sespie 5c87b03e5Sespie/* Define all the fixes we know about for repairing damaged headers. 6c87b03e5Sespie Please see the README before adding or changing entries in this file. 7c87b03e5Sespie 8c87b03e5Sespie This is the sort command: 9c87b03e5Sespie 10c87b03e5Sespie blocksort output=inclhack.sorted \ 11c87b03e5Sespie pattern='^/\*$' \ 12c87b03e5Sespie trailer='^/\*EOF\*[/]' \ 13c87b03e5Sespie input=inclhack.def \ 14c87b03e5Sespie key='hackname[ ]*=[ ]*(.*);' 15c87b03e5Sespie 16c87b03e5Sespie Set up a debug test so we can make the templates emit special 17c87b03e5Sespie code while debugging these fixes: */ 18c87b03e5Sespie 19c87b03e5Sespie#ifdef DEBUG 20c87b03e5SespieFIXINC_DEBUG = yes; 21c87b03e5Sespie#endif 22c87b03e5Sespie 23c87b03e5Sespie/* 24c87b03e5Sespie * Completely replace <_int_varargs.h> with a file that includes gcc's 25c87b03e5Sespie * stdarg.h or varargs.h files as appropriate on DG/UX 26c87b03e5Sespie */ 27c87b03e5Sespiefix = { 28c87b03e5Sespie hackname = AAB_dgux_int_varargs; 29c87b03e5Sespie files = _int_varargs.h; 30c87b03e5Sespie replace = <<- _EOF_ 31c87b03e5Sespie #ifndef __INT_VARARGS_H 32c87b03e5Sespie #define __INT_VARARGS_H 33c87b03e5Sespie 34c87b03e5Sespie /********************************************************/ 35c87b03e5Sespie /* Define the common stuff for varargs/stdarg/stdio. */ 36c87b03e5Sespie /********************************************************/ 37c87b03e5Sespie 38c87b03e5Sespie /* 39c87b03e5Sespie ** This file is a DG internal header. Never include this 40c87b03e5Sespie ** file directly. 41c87b03e5Sespie */ 42c87b03e5Sespie 43c87b03e5Sespie #ifndef ___int_features_h 44c87b03e5Sespie #include <sys/_int_features.h> 45c87b03e5Sespie #endif 46c87b03e5Sespie 47c87b03e5Sespie #if !(defined(_VA_LIST) || defined(_VA_LIST_)) 48c87b03e5Sespie #define _VA_LIST 49c87b03e5Sespie #define _VA_LIST_ 50c87b03e5Sespie 51c87b03e5Sespie #ifdef __LINT__ 52c87b03e5Sespie 53c87b03e5Sespie #ifdef __STDC__ 54c87b03e5Sespie typedef void * va_list; 55c87b03e5Sespie #else 56c87b03e5Sespie typedef char * va_list; 57c87b03e5Sespie #endif 58c87b03e5Sespie 59c87b03e5Sespie #else 60c87b03e5Sespie #if _M88K_ANY 61c87b03e5Sespie 62c87b03e5Sespie #if defined(__DCC__) 63c87b03e5Sespie 64c87b03e5Sespie typedef struct { 65c87b03e5Sespie int next_arg; 66c87b03e5Sespie int *mem_ptr; 67c87b03e5Sespie int *reg_ptr; 68c87b03e5Sespie } va_list; 69c87b03e5Sespie 70c87b03e5Sespie #else /* ! defined(__DCC__) */ 71c87b03e5Sespie 72c87b03e5Sespie typedef struct { 73c87b03e5Sespie int __va_arg; /* argument number */ 74c87b03e5Sespie int *__va_stk; /* start of args passed on stack */ 75c87b03e5Sespie int *__va_reg; /* start of args passed in regs */ 76c87b03e5Sespie } va_list; 77c87b03e5Sespie 78c87b03e5Sespie #endif /* ! defined(__DCC__) */ 79c87b03e5Sespie 80c87b03e5Sespie #elif _IX86_ANY 81c87b03e5Sespie 82c87b03e5Sespie #if defined(__GNUC__) || defined(__STDC__) 83c87b03e5Sespie typedef void * va_list; 84c87b03e5Sespie #else 85c87b03e5Sespie typedef char * va_list; 86c87b03e5Sespie #endif 87c87b03e5Sespie 88c87b03e5Sespie #endif /* _IX86_ANY */ 89c87b03e5Sespie 90c87b03e5Sespie #endif /* __LINT__ */ 91c87b03e5Sespie #endif /* !(defined(_VA_LIST) || defined(_VA_LIST_)) */ 92c87b03e5Sespie #endif /* #ifndef __INT_VARARGS_H */ 93c87b03e5Sespie _EOF_; 94c87b03e5Sespie}; 95c87b03e5Sespie 96c87b03e5Sespie 97c87b03e5Sespie/* 98c87b03e5Sespie * This fixes __FD_ZERO bug for linux 2.x.y (x <= 2 && y <= some n) 99c87b03e5Sespie */ 100c87b03e5Sespiefix = { 101c87b03e5Sespie hackname = AAB_fd_zero_asm_posix_types_h; 102c87b03e5Sespie files = asm/posix_types.h; 103c87b03e5Sespie mach = 'i[34567]86-*-linux*'; 104c87b03e5Sespie bypass = '} while'; 105c87b03e5Sespie 106c87b03e5Sespie /* 107c87b03e5Sespie * Define _POSIX_TYPES_H_WRAPPER at the end of the wrapper, not 108c87b03e5Sespie * the start, so that if #include_next gets another instance of 109c87b03e5Sespie * the wrapper, this will follow the #include_next chain until 110c87b03e5Sespie * we arrive at the real <asm/posix_types.h>. 111c87b03e5Sespie */ 112c87b03e5Sespie replace = <<- _EndOfHeader_ 113c87b03e5Sespie /* This file fixes a bug in the __FD_ZERO macro 114c87b03e5Sespie for older versions of the Linux kernel. */ 115c87b03e5Sespie #ifndef _POSIX_TYPES_H_WRAPPER 116c87b03e5Sespie #include <features.h> 117c87b03e5Sespie #include_next <asm/posix_types.h> 118c87b03e5Sespie 119c87b03e5Sespie #if defined(__FD_ZERO) && !defined(__GLIBC__) 120c87b03e5Sespie #undef __FD_ZERO 121c87b03e5Sespie #define __FD_ZERO(fdsetp) \ 122c87b03e5Sespie do { \ 123c87b03e5Sespie int __d0, __d1; \ 124c87b03e5Sespie __asm__ __volatile__("cld ; rep ; stosl" \ 125c87b03e5Sespie : "=&c" (__d0), "=&D" (__d1) \ 126c87b03e5Sespie : "a" (0), "0" (__FDSET_LONGS), \ 127c87b03e5Sespie "1" ((__kernel_fd_set *) (fdsetp)) :"memory"); \ 128c87b03e5Sespie } while (0) 129c87b03e5Sespie #endif 130c87b03e5Sespie 131c87b03e5Sespie #define _POSIX_TYPES_H_WRAPPER 132c87b03e5Sespie #endif /* _POSIX_TYPES_H_WRAPPER */ 133c87b03e5Sespie _EndOfHeader_; 134c87b03e5Sespie}; 135c87b03e5Sespie 136c87b03e5Sespie 137c87b03e5Sespie/* 138c87b03e5Sespie * This fixes __FD_ZERO bug for glibc-1.x 139c87b03e5Sespie */ 140c87b03e5Sespiefix = { 141c87b03e5Sespie hackname = AAB_fd_zero_gnu_types_h; 142c87b03e5Sespie files = gnu/types.h; 143c87b03e5Sespie mach = 'i[34567]86-*-linux*'; 144c87b03e5Sespie 145c87b03e5Sespie /* 146c87b03e5Sespie * Define _TYPES_H_WRAPPER at the end of the wrapper, not 147c87b03e5Sespie * the start, so that if #include_next gets another instance of 148c87b03e5Sespie * the wrapper, this will follow the #include_next chain until 149c87b03e5Sespie * we arrive at the real <gnu/types.h>. 150c87b03e5Sespie */ 151c87b03e5Sespie replace = 152c87b03e5Sespie 153c87b03e5Sespie'/* This file fixes a bug in the __FD_ZERO macro present in glibc 1.x. */ 154c87b03e5Sespie\#ifndef _TYPES_H_WRAPPER 155c87b03e5Sespie\#include <features.h> 156c87b03e5Sespie \#include_next <gnu/types.h> 157c87b03e5Sespie 158c87b03e5Sespie\#if defined(__FD_ZERO) && !defined(__GLIBC__) 159c87b03e5Sespie\#undef __FD_ZERO 160c87b03e5Sespie\# define __FD_ZERO(fdsetp) \\ 161c87b03e5Sespie do { \\ 162c87b03e5Sespie int __d0, __d1; \\ 163c87b03e5Sespie __asm__ __volatile__("cld ; rep ; stosl" \\ 164c87b03e5Sespie : "=&c" (__d0), "=&D" (__d1) \\ 165c87b03e5Sespie : "a" (0), "0" (__FDSET_LONGS), \\ 166c87b03e5Sespie "1" ((__fd_set *) (fdsetp)) :"memory"); \\ 167c87b03e5Sespie } while (0) 168c87b03e5Sespie\#endif 169c87b03e5Sespie 170c87b03e5Sespie\#define _TYPES_H_WRAPPER 171c87b03e5Sespie\#endif /* _TYPES_H_WRAPPER */ 172c87b03e5Sespie'; 173c87b03e5Sespie}; 174c87b03e5Sespie 175c87b03e5Sespie 176c87b03e5Sespie/* 177c87b03e5Sespie * This fixes __FD_ZERO bug for glibc-2.0.x 178c87b03e5Sespie */ 179c87b03e5Sespiefix = { 180c87b03e5Sespie hackname = AAB_fd_zero_selectbits_h; 181c87b03e5Sespie files = selectbits.h; 182c87b03e5Sespie mach = 'i[34567]86-*-linux*'; 183c87b03e5Sespie 184c87b03e5Sespie /* 185c87b03e5Sespie * Define _SELECTBITS_H_WRAPPER at the end of the wrapper, not 186c87b03e5Sespie * the start, so that if #include_next gets another instance of 187c87b03e5Sespie * the wrapper, this will follow the #include_next chain until 188c87b03e5Sespie * we arrive at the real <selectbits.h>. 189c87b03e5Sespie */ 190c87b03e5Sespie replace = 191c87b03e5Sespie 192c87b03e5Sespie'/* This file fixes a bug in the __FD_ZERO macro present in glibc 2.0.x. */ 193c87b03e5Sespie\#ifndef _SELECTBITS_H_WRAPPER 194c87b03e5Sespie\#include <features.h> 195c87b03e5Sespie \#include_next <selectbits.h> 196c87b03e5Sespie 197c87b03e5Sespie\#if defined(__FD_ZERO) && defined(__GLIBC__) \\ 198c87b03e5Sespie && defined(__GLIBC_MINOR__) && __GLIBC__ == 2 \\ 199c87b03e5Sespie && __GLIBC_MINOR__ == 0 200c87b03e5Sespie\#undef __FD_ZERO 201c87b03e5Sespie\#define __FD_ZERO(fdsetp) \\ 202c87b03e5Sespie do { \\ 203c87b03e5Sespie int __d0, __d1; \\ 204c87b03e5Sespie __asm__ __volatile__ ("cld; rep; stosl" \\ 205c87b03e5Sespie : "=&c" (__d0), "=&D" (__d1) \\ 206c87b03e5Sespie : "a" (0), "0" (sizeof (__fd_set) \\ 207c87b03e5Sespie / sizeof (__fd_mask)), \\ 208c87b03e5Sespie "1" ((__fd_mask *) (fdsetp)) \\ 209c87b03e5Sespie : "memory"); \\ 210c87b03e5Sespie } while (0) 211c87b03e5Sespie\#endif 212c87b03e5Sespie 213c87b03e5Sespie\#define _SELECTBITS_H_WRAPPER 214c87b03e5Sespie\#endif /* _SELECTBITS_H_WRAPPER */ 215c87b03e5Sespie'; 216c87b03e5Sespie}; 217c87b03e5Sespie 218c87b03e5Sespie 219c87b03e5Sespie/* 220c87b03e5Sespie * Solaris <sys/varargs.h> is a DDK (aka kernel-land) header providing 221c87b03e5Sespie * the same interface as <stdarg.h>. No idea why they couldn't have just 222c87b03e5Sespie * used the standard header. 223c87b03e5Sespie */ 224c87b03e5Sespiefix = { 225c87b03e5Sespie hackname = AAB_solaris_sys_varargs_h; 226c87b03e5Sespie files = "sys/varargs.h"; 227c87b03e5Sespie mach = '*-*-solaris*'; 228c87b03e5Sespie replace = "#ifdef __STDC__\n" 229c87b03e5Sespie "#include <stdarg.h>\n" 230c87b03e5Sespie "#else\n" 231c87b03e5Sespie "#include <varargs.h>\n" 232c87b03e5Sespie "#endif\n"; 233c87b03e5Sespie}; 234c87b03e5Sespie 235c87b03e5Sespie 236c87b03e5Sespie/* 237c87b03e5Sespie * Fix non-ANSI memcpy declaration that conflicts with gcc's builtin 238c87b03e5Sespie * declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because 239c87b03e5Sespie * many other systems have similar text but correct versions of the file. 240c87b03e5Sespie * To ensure only Sun's is fixed, we grep for a likely unique string. 241c87b03e5Sespie * Fix also on sysV68 R3V7.1 (head/memory.h\t50.1\t ) 242c87b03e5Sespie */ 243c87b03e5Sespiefix = { 244c87b03e5Sespie hackname = AAB_sun_memcpy; 245c87b03e5Sespie files = memory.h; 246c87b03e5Sespie select = "/\\*\t@\\(#\\)" 247c87b03e5Sespie "(head/memory.h\t50.1\t " 248c87b03e5Sespie "|memory\\.h 1\\.[2-4] 8./../.. SMI; from S5R2 1\\.2\t)\\*/"; 249c87b03e5Sespie 250c87b03e5Sespie replace = 251c87b03e5Sespie'/* This file was generated by fixincludes */ 252c87b03e5Sespie\#ifndef __memory_h__ 253c87b03e5Sespie\#define __memory_h__ 254c87b03e5Sespie 255c87b03e5Sespie\#ifdef __STDC__ 256c87b03e5Sespieextern void *memccpy(); 257c87b03e5Sespieextern void *memchr(); 258c87b03e5Sespieextern void *memcpy(); 259c87b03e5Sespieextern void *memset(); 260c87b03e5Sespie\#else 261c87b03e5Sespieextern char *memccpy(); 262c87b03e5Sespieextern char *memchr(); 263c87b03e5Sespieextern char *memcpy(); 264c87b03e5Sespieextern char *memset(); 265c87b03e5Sespie\#endif /* __STDC__ */ 266c87b03e5Sespie 267c87b03e5Sespieextern int memcmp(); 268c87b03e5Sespie 269c87b03e5Sespie\#endif /* __memory_h__ */ 270c87b03e5Sespie'; 271c87b03e5Sespie 272c87b03e5Sespie}; 273c87b03e5Sespie 274c87b03e5Sespie 275c87b03e5Sespie/* 276c87b03e5Sespie * Completely replace <sys/varargs.h> with a file that includes gcc's 277c87b03e5Sespie * stdarg.h or varargs.h files as appropriate. 278c87b03e5Sespie */ 279c87b03e5Sespie#ifdef SVR4 280c87b03e5Sespiefix = { 281c87b03e5Sespie hackname = AAB_svr4_no_varargs; 282c87b03e5Sespie files = sys/varargs.h; 283c87b03e5Sespie replace = "/* This file was generated by fixincludes. */\n" 284c87b03e5Sespie "#ifndef _SYS_VARARGS_H\n" 285c87b03e5Sespie "#define _SYS_VARARGS_H\n\n" 286c87b03e5Sespie 287c87b03e5Sespie "#ifdef __STDC__\n" 288c87b03e5Sespie "#include <stdarg.h>\n" 289c87b03e5Sespie "#else\n" 290c87b03e5Sespie "#include <varargs.h>\n" 291c87b03e5Sespie "#endif\n\n" 292c87b03e5Sespie 293c87b03e5Sespie "#endif /* _SYS_VARARGS_H */\n"; 294c87b03e5Sespie}; 295c87b03e5Sespie#endif 296c87b03e5Sespie 297c87b03e5Sespie 298c87b03e5Sespie/* 299c87b03e5Sespie * Completely replace <sys/byteorder.h>; with a file that implements gcc's 300c87b03e5Sespie * optimized byteswapping. 301c87b03e5Sespie */ 302c87b03e5Sespiefix = { 303c87b03e5Sespie hackname = AAB_svr4_replace_byteorder; 3044e43c760Sespie mach = "*-*-sysv4*"; 3054e43c760Sespie mach = "i[34567]86-*-sysv5*"; 3064e43c760Sespie mach = "i[34567]86-*-sco3.2v5*"; 3074e43c760Sespie mach = "i[34567]86-*-udk*"; 3084e43c760Sespie mach = "i[34567]86-*-solaris2.[0-4]"; 3094e43c760Sespie mach = "powerpcle-*-solaris2.[0-4]"; 3104e43c760Sespie mach = "sparc-*-solaris2.[0-4]"; 3114e43c760Sespie mach = "i[34567]86-sequent-ptx*"; 312c87b03e5Sespie files = sys/byteorder.h; 313c87b03e5Sespie replace = '#ifndef _SYS_BYTEORDER_H 314c87b03e5Sespie\#define _SYS_BYTEORDER_H 315c87b03e5Sespie 316c87b03e5Sespie/* Functions to convert `short\' and `long\' quantities from host byte order 317c87b03e5Sespie to (internet) network byte order (i.e. big-endian). 318c87b03e5Sespie 319c87b03e5Sespie Written by Ron Guilmette (rfg@ncd.com). 320c87b03e5Sespie 321c87b03e5Sespie This isn\'t actually used by GCC. It is installed by fixinc.svr4. 322c87b03e5Sespie 323c87b03e5Sespie For big-endian machines these functions are essentially no-ops. 324c87b03e5Sespie 325c87b03e5Sespie For little-endian machines, we define the functions using specialized 326c87b03e5Sespie asm sequences in cases where doing so yields better code (e.g. i386). */ 327c87b03e5Sespie 328c87b03e5Sespie\#if !defined (__GNUC__) && !defined (__GNUG__) 329c87b03e5Sespie\#error You lose! This file is only useful with GNU compilers. 330c87b03e5Sespie\#endif 331c87b03e5Sespie 332c87b03e5Sespie\#ifndef __BYTE_ORDER__ 333c87b03e5Sespie/* Byte order defines. These are as defined on UnixWare 1.1, but with 334c87b03e5Sespie double underscores added at the front and back. */ 335c87b03e5Sespie\#define __LITTLE_ENDIAN__ 1234 336c87b03e5Sespie\#define __BIG_ENDIAN__ 4321 337c87b03e5Sespie\#define __PDP_ENDIAN__ 3412 338c87b03e5Sespie\#endif 339c87b03e5Sespie 340c87b03e5Sespie\#ifdef __STDC__ 341c87b03e5Sespiestatic __inline__ unsigned long htonl (unsigned long); 342c87b03e5Sespiestatic __inline__ unsigned short htons (unsigned int); 343c87b03e5Sespiestatic __inline__ unsigned long ntohl (unsigned long); 344c87b03e5Sespiestatic __inline__ unsigned short ntohs (unsigned int); 345c87b03e5Sespie\#endif /* defined (__STDC__) */ 346c87b03e5Sespie 347c87b03e5Sespie\#if defined (__i386__) 348c87b03e5Sespie 349c87b03e5Sespie\#ifndef __BYTE_ORDER__ 350c87b03e5Sespie\#define __BYTE_ORDER__ __LITTLE_ENDIAN__ 351c87b03e5Sespie\#endif 352c87b03e5Sespie 353c87b03e5Sespie/* Convert a host long to a network long. */ 354c87b03e5Sespie 355c87b03e5Sespie/* We must use a new-style function definition, so that this will also 356c87b03e5Sespie be valid for C++. */ 357c87b03e5Sespiestatic __inline__ unsigned long 358c87b03e5Sespiehtonl (unsigned long __arg) 359c87b03e5Sespie{ 360c87b03e5Sespie register unsigned long __result; 361c87b03e5Sespie 362c87b03e5Sespie __asm__ ("xchg%B0 %b0,%h0 ; ror%L0 $16,%0 ; xchg%B0 %b0,%h0" \ 363c87b03e5Sespie : "=q" (__result) : "0" (__arg)); 364c87b03e5Sespie return __result; 365c87b03e5Sespie} 366c87b03e5Sespie 367c87b03e5Sespie/* Convert a host short to a network short. */ 368c87b03e5Sespie 369c87b03e5Sespiestatic __inline__ unsigned short 370c87b03e5Sespiehtons (unsigned int __arg) 371c87b03e5Sespie{ 372c87b03e5Sespie register unsigned short __result; 373c87b03e5Sespie 374c87b03e5Sespie __asm__ ("xchg%B0 %b0,%h0" : "=q" (__result) : "0" (__arg)); 375c87b03e5Sespie return __result; 376c87b03e5Sespie} 377c87b03e5Sespie 378c87b03e5Sespie\#elif ((defined (__i860__) && !defined (__i860_big_endian__)) \\ 379c87b03e5Sespie || defined (__ns32k__) || defined (__vax__) \\ 380c87b03e5Sespie || defined (__spur__) || defined (__arm__)) 381c87b03e5Sespie 382c87b03e5Sespie\#ifndef __BYTE_ORDER__ 383c87b03e5Sespie\#define __BYTE_ORDER__ __LITTLE_ENDIAN__ 384c87b03e5Sespie\#endif 385c87b03e5Sespie 386c87b03e5Sespie/* For other little-endian machines, using C code is just as efficient as 387c87b03e5Sespie using assembly code. */ 388c87b03e5Sespie 389c87b03e5Sespie/* Convert a host long to a network long. */ 390c87b03e5Sespie 391c87b03e5Sespiestatic __inline__ unsigned long 392c87b03e5Sespiehtonl (unsigned long __arg) 393c87b03e5Sespie{ 394c87b03e5Sespie register unsigned long __result; 395c87b03e5Sespie 396c87b03e5Sespie __result = (__arg >> 24) & 0x000000ff; 397c87b03e5Sespie __result |= (__arg >> 8) & 0x0000ff00; 398c87b03e5Sespie __result |= (__arg << 8) & 0x00ff0000; 399c87b03e5Sespie __result |= (__arg << 24) & 0xff000000; 400c87b03e5Sespie return __result; 401c87b03e5Sespie} 402c87b03e5Sespie 403c87b03e5Sespie/* Convert a host short to a network short. */ 404c87b03e5Sespie 405c87b03e5Sespiestatic __inline__ unsigned short 406c87b03e5Sespiehtons (unsigned int __arg) 407c87b03e5Sespie{ 408c87b03e5Sespie register unsigned short __result; 409c87b03e5Sespie 410c87b03e5Sespie __result = (__arg << 8) & 0xff00; 411c87b03e5Sespie __result |= (__arg >> 8) & 0x00ff; 412c87b03e5Sespie return __result; 413c87b03e5Sespie} 414c87b03e5Sespie 415c87b03e5Sespie\#else /* must be a big-endian machine */ 416c87b03e5Sespie 417c87b03e5Sespie\#ifndef __BYTE_ORDER__ 418c87b03e5Sespie\#define __BYTE_ORDER__ __BIG_ENDIAN__ 419c87b03e5Sespie\#endif 420c87b03e5Sespie 421c87b03e5Sespie/* Convert a host long to a network long. */ 422c87b03e5Sespie 423c87b03e5Sespiestatic __inline__ unsigned long 424c87b03e5Sespiehtonl (unsigned long __arg) 425c87b03e5Sespie{ 426c87b03e5Sespie return __arg; 427c87b03e5Sespie} 428c87b03e5Sespie 429c87b03e5Sespie/* Convert a host short to a network short. */ 430c87b03e5Sespie 431c87b03e5Sespiestatic __inline__ unsigned short 432c87b03e5Sespiehtons (unsigned int __arg) 433c87b03e5Sespie{ 434c87b03e5Sespie return __arg; 435c87b03e5Sespie} 436c87b03e5Sespie 437c87b03e5Sespie\#endif /* big-endian */ 438c87b03e5Sespie 439c87b03e5Sespie/* Convert a network long to a host long. */ 440c87b03e5Sespie 441c87b03e5Sespiestatic __inline__ unsigned long 442c87b03e5Sespientohl (unsigned long __arg) 443c87b03e5Sespie{ 444c87b03e5Sespie return htonl (__arg); 445c87b03e5Sespie} 446c87b03e5Sespie 447c87b03e5Sespie/* Convert a network short to a host short. */ 448c87b03e5Sespie 449c87b03e5Sespiestatic __inline__ unsigned short 450c87b03e5Sespientohs (unsigned int __arg) 451c87b03e5Sespie{ 452c87b03e5Sespie return htons (__arg); 453c87b03e5Sespie} 454c87b03e5Sespie\#endif 455c87b03e5Sespie'; 456c87b03e5Sespie}; 457c87b03e5Sespie 458c87b03e5Sespie 459c87b03e5Sespie/* 460c87b03e5Sespie * Cancel out ansi_compat.h on Ultrix. Replace it with an empty file. 461c87b03e5Sespie */ 462c87b03e5Sespiefix = { 463c87b03e5Sespie hackname = AAB_ultrix_ansi_compat; 464c87b03e5Sespie files = ansi_compat.h; 465c87b03e5Sespie select = ULTRIX; 466c87b03e5Sespie replace = "/* This file intentionally left blank. */\n"; 467c87b03e5Sespie}; 468c87b03e5Sespie 469c87b03e5Sespie 470c87b03e5Sespie/* 471c87b03e5Sespie * The Ultrix 4.3 file limits.h is a symbolic link to sys/limits.h. 472c87b03e5Sespie * Replace limits.h with a file that includes sys/limits.h. 473c87b03e5Sespie */ 474c87b03e5Sespiefix = { 475c87b03e5Sespie hackname = AAB_ultrix_limits; 476c87b03e5Sespie files = limits.h; 477c87b03e5Sespie mach = "*-*-ultrix4.3"; 478c87b03e5Sespie replace = 479c87b03e5Sespie'#ifndef _LIMITS_INCLUDED 480c87b03e5Sespie\#define _LIMITS_INCLUDED 481c87b03e5Sespie\#include <sys/limits.h> 482c87b03e5Sespie\#endif /* _LIMITS_INCLUDED */ 483c87b03e5Sespie'; 484c87b03e5Sespie}; 485c87b03e5Sespie 486c87b03e5Sespie 487c87b03e5Sespie/* 488c87b03e5Sespie * The ULTRIX 4.3 version of memory.h duplicates definitions 489c87b03e5Sespie * present in strings.h. Replace memory.h with a file that includes 490c87b03e5Sespie * strings.h to prevent problems from multiple inclusion. 491c87b03e5Sespie */ 492c87b03e5Sespiefix = { 493c87b03e5Sespie hackname = AAB_ultrix_memory; 494c87b03e5Sespie files = memory.h; 495c87b03e5Sespie mach = "*-*-ultrix4.3"; 496c87b03e5Sespie replace = 497c87b03e5Sespie'#ifndef _MEMORY_INCLUDED 498c87b03e5Sespie\#define _MEMORY_INCLUDED 499c87b03e5Sespie\#include <strings.h> 500c87b03e5Sespie\#endif /* _MEMORY_INCLUDED */ 501c87b03e5Sespie'; 502c87b03e5Sespie}; 503c87b03e5Sespie 504c87b03e5Sespie 505c87b03e5Sespie/* 506c87b03e5Sespie * The Ultrix 4.3 file string.h is a symbolic link to strings.h. 507c87b03e5Sespie * Replace string.h link with a file that includes strings.h to prevent 508c87b03e5Sespie * problems from multiple inclusion. 509c87b03e5Sespie */ 510c87b03e5Sespiefix = { 511c87b03e5Sespie hackname = AAB_ultrix_string; 512c87b03e5Sespie files = string.h; 513c87b03e5Sespie mach = "*-*-ultrix4.3"; 514c87b03e5Sespie replace = 515c87b03e5Sespie'#ifndef _STRING_INCLUDED 516c87b03e5Sespie\#define _STRING_INCLUDED 517c87b03e5Sespie\#include <strings.h> 518c87b03e5Sespie\#endif /* _STRING_INCLUDED */ 519c87b03e5Sespie'; 520c87b03e5Sespie}; 521c87b03e5Sespie 522c87b03e5Sespie 523c87b03e5Sespie/* 524c87b03e5Sespie * pthread.h on AIX 4.3.3 tries to define a macro without whitspace 525c87b03e5Sespie * which violates a requirement of ISO C. 526c87b03e5Sespie */ 527c87b03e5Sespiefix = { 528c87b03e5Sespie hackname = aix_pthread; 529c87b03e5Sespie files = "pthread.h"; 530c87b03e5Sespie select = "(#define [A-Za-z_0-9]+)(\\\\\n[^A-Za-z_0-9 \t\n(])"; 531c87b03e5Sespie c_fix = format; 532c87b03e5Sespie c_fix_arg = "%1 %2"; 533c87b03e5Sespie test_text = "#define PTHREAD_MUTEX_INITIALIZER\\\\\n" 534c87b03e5Sespie "{...init stuff...}"; 535c87b03e5Sespie}; 536c87b03e5Sespie 537c87b03e5Sespie 538c87b03e5Sespie/* 539c87b03e5Sespie * sys/machine.h on AIX 4.3.3 puts whitespace between a \ and a newline 540c87b03e5Sespie * in an otherwise harmless (and #ifed out) macro definition 541c87b03e5Sespie */ 542c87b03e5Sespiefix = { 543c87b03e5Sespie hackname = aix_sysmachine; 544c87b03e5Sespie files = sys/machine.h; 545c87b03e5Sespie select = "\\\\ +\n"; 546c87b03e5Sespie c_fix = format; 547c87b03e5Sespie c_fix_arg = "\\\n"; 548c87b03e5Sespie test_text = "#define FOO \\\n" 549c87b03e5Sespie " bar \\ \n baz \\ \n bat"; 550c87b03e5Sespie}; 551c87b03e5Sespie 552c87b03e5Sespie 553c87b03e5Sespie/* 554c87b03e5Sespie * sys/wait.h on AIX 3.2.5 puts the declaration of wait3 before the 555c87b03e5Sespie * definition of struct rusage, so the prototype added by fixproto fails. 556c87b03e5Sespie */ 557c87b03e5Sespiefix = { 558c87b03e5Sespie hackname = aix_syswait; 559c87b03e5Sespie files = sys/wait.h; 560c87b03e5Sespie select = "^extern pid_t wait3\\(\\);\n"; 561c87b03e5Sespie select = "bos325,"; 562c87b03e5Sespie c_fix = format; 563c87b03e5Sespie c_fix_arg = "struct rusage;\n%0"; 564c87b03e5Sespie test_text = "/* bos325, */\n" 565c87b03e5Sespie "extern pid_t wait3();\n" 566c87b03e5Sespie "\t/* pid_t wait3(int *, int, struct rusage *); */"; 567c87b03e5Sespie}; 568c87b03e5Sespie 569c87b03e5Sespie 570c87b03e5Sespie/* 571c87b03e5Sespie * sys/signal.h on some versions of AIX uses volatile in the typedef of 572c87b03e5Sespie * sig_atomic_t, which causes gcc to generate a warning about duplicate 573c87b03e5Sespie * volatile when a sig_atomic_t variable is declared volatile, as 574c87b03e5Sespie * required by ANSI C. 575c87b03e5Sespie */ 576c87b03e5Sespiefix = { 577c87b03e5Sespie hackname = aix_volatile; 578c87b03e5Sespie files = sys/signal.h; 579c87b03e5Sespie select = "typedef volatile int sig_atomic_t"; 580c87b03e5Sespie c_fix = format; 581c87b03e5Sespie c_fix_arg = "typedef int sig_atomic_t"; 582c87b03e5Sespie test_text = "typedef volatile int sig_atomic_t;"; 583c87b03e5Sespie}; 584c87b03e5Sespie 585c87b03e5Sespie 586c87b03e5Sespie/* 587c87b03e5Sespie * Fix __assert declaration in assert.h on Alpha OSF/1. 588c87b03e5Sespie */ 589c87b03e5Sespiefix = { 590c87b03e5Sespie hackname = alpha___assert; 591c87b03e5Sespie files = "assert.h"; 592c87b03e5Sespie select = '__assert\(char \*, char \*, int\)'; 593c87b03e5Sespie c_fix = format; 594c87b03e5Sespie c_fix_arg = "__assert(const char *, const char *, int)"; 595c87b03e5Sespie test_text = 'extern void __assert(char *, char *, int);'; 596c87b03e5Sespie}; 597c87b03e5Sespie 598c87b03e5Sespie 599c87b03e5Sespie/* 600c87b03e5Sespie * Obey __PRAGMA_EXTERN_PREFIX for Tru64 UNIX V5 <sys/stat.h>. 601c87b03e5Sespie */ 602c87b03e5Sespiefix = { 603c87b03e5Sespie hackname = alpha___extern_prefix; 604c87b03e5Sespie files = sys/stat.h; 605c87b03e5Sespie select = "#[ \t]*if[ \t]*defined\\(__DECC\\)"; 606c87b03e5Sespie 607c87b03e5Sespie mach = "alpha*-dec-osf5*"; 608c87b03e5Sespie c_fix = format; 609c87b03e5Sespie c_fix_arg = "%0 || defined(__PRAGMA_EXTERN_PREFIX)"; 610c87b03e5Sespie 611c87b03e5Sespie test_text = "# if defined(__DECC)"; 612c87b03e5Sespie}; 613c87b03e5Sespie 614c87b03e5Sespie 615c87b03e5Sespie/* 616c87b03e5Sespie * Fix assert macro in assert.h on Alpha OSF/1. 617c87b03e5Sespie * The superfluous int cast breaks C++. 618c87b03e5Sespie */ 619c87b03e5Sespiefix = { 620c87b03e5Sespie hackname = alpha_assert; 621c87b03e5Sespie files = "assert.h"; 622c87b03e5Sespie select = '(#define assert\(EX\).*)\(\(int\) \(EX\)\)'; 623c87b03e5Sespie c_fix = format; 624c87b03e5Sespie c_fix_arg = "%1(EX)"; 625c87b03e5Sespie test_text = '#define assert(EX) (((int) (EX)) ? (void)0 : __assert(#EX, __FILE__, __LINE__))'; 626c87b03e5Sespie}; 627c87b03e5Sespie 628c87b03e5Sespie 629c87b03e5Sespie/* 630c87b03e5Sespie * Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX. 631c87b03e5Sespie */ 632c87b03e5Sespiefix = { 633c87b03e5Sespie hackname = alpha_getopt; 634c87b03e5Sespie files = "stdio.h"; 635c87b03e5Sespie files = "stdlib.h"; 636c87b03e5Sespie select = 'getopt\(int, char \*\[\], *char \*\)'; 637c87b03e5Sespie c_fix = format; 638c87b03e5Sespie c_fix_arg = "getopt(int, char *const[], const char *)"; 639c87b03e5Sespie test_text = 'extern int getopt(int, char *[], char *);'; 640c87b03e5Sespie}; 641c87b03e5Sespie 642c87b03e5Sespie 643c87b03e5Sespie/* 644c87b03e5Sespie * Remove erroneous parentheses in sym.h on Alpha OSF/1. 645c87b03e5Sespie */ 646c87b03e5Sespiefix = { 647c87b03e5Sespie hackname = alpha_parens; 648c87b03e5Sespie files = sym.h; 649c87b03e5Sespie select = '#ifndef\(__mips64\)'; 650c87b03e5Sespie c_fix = format; 651c87b03e5Sespie c_fix_arg = "#ifndef __mips64"; 652c87b03e5Sespie test_text = "#ifndef(__mips64) /* bogus */\nextern int foo;\n#endif"; 653c87b03e5Sespie}; 654c87b03e5Sespie 655c87b03e5Sespie 656c87b03e5Sespie/* 657c87b03e5Sespie * Recognize GCC in Tru64 UNIX V5.1B <pthread.h>. 658c87b03e5Sespie */ 659c87b03e5Sespiefix = { 660c87b03e5Sespie hackname = alpha_pthread_gcc; 661c87b03e5Sespie files = pthread.h; 662c87b03e5Sespie select = "#else\n# error <pthread.h>: unrecognized compiler."; 663c87b03e5Sespie 664c87b03e5Sespie mach = "alpha*-dec-osf*"; 665c87b03e5Sespie c_fix = format; 666c87b03e5Sespie c_fix_arg = "#elif defined (__GNUC__)\n" 667c87b03e5Sespie "# define _PTHREAD_ENV_GCC\n" 668c87b03e5Sespie "%0"; 669c87b03e5Sespie 670c87b03e5Sespie test_text = "# define _PTHREAD_ENV_INTELC\n" 671c87b03e5Sespie "#else\n" 672c87b03e5Sespie "# error <pthread.h>: unrecognized compiler.\n" 673c87b03e5Sespie "#endif"; 674c87b03e5Sespie}; 675c87b03e5Sespie 676c87b03e5Sespie 677c87b03e5Sespie/* 678c87b03e5Sespie * Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0 679c87b03e5Sespie */ 680c87b03e5Sespiefix = { 681c87b03e5Sespie hackname = alpha_sbrk; 682c87b03e5Sespie files = unistd.h; 683c87b03e5Sespie select = "char[ \t]*\\*[\t ]*sbrk[ \t]*\\("; 684c87b03e5Sespie c_fix = format; 685c87b03e5Sespie c_fix_arg = "void *sbrk("; 686c87b03e5Sespie test_text = "extern char* sbrk(ptrdiff_t increment);"; 687c87b03e5Sespie}; 688c87b03e5Sespie 689c87b03e5Sespie 690c87b03e5Sespie/* 691c87b03e5Sespie * Fix this ARM/RISCiX file where ___type is a Compiler 692c87b03e5Sespie * hint that is specific to the Norcroft compiler. 693c87b03e5Sespie */ 694c87b03e5Sespiefix = { 695c87b03e5Sespie hackname = arm_norcroft_hint; 696c87b03e5Sespie select = "___type p_type"; 697c87b03e5Sespie files = "X11/Intrinsic.h"; 698c87b03e5Sespie c_fix = format; 699c87b03e5Sespie c_fix_arg = "p_type"; 700c87b03e5Sespie test_text = "___type p_type mumble;"; 701c87b03e5Sespie}; 702c87b03e5Sespie 703c87b03e5Sespie 704c87b03e5Sespie/* 705c87b03e5Sespie * Fix this ARM/RISCiX file to avoid interfering 706c87b03e5Sespie * with the use of __wchar_t in cc1plus. 707c87b03e5Sespie */ 708c87b03e5Sespiefix = { 709c87b03e5Sespie hackname = arm_wchar; 710c87b03e5Sespie files = stdlib.h; 711c87b03e5Sespie select = "#[ \t]*define[ \t]*__wchar_t"; 712c87b03e5Sespie 713c87b03e5Sespie c_fix = format; 714c87b03e5Sespie c_fix_arg = "%1_GCC_WCHAR_T"; 715c87b03e5Sespie c_fix_arg = "(#[ \t]*(ifndef|define)[ \t]+)__wchar_t"; 716c87b03e5Sespie 717c87b03e5Sespie test_text = 718c87b03e5Sespie "# ifndef \t __wchar_t /* we don't have wchar_t yet, ... */\n" 719c87b03e5Sespie "# define __wchar_t short\n" 720c87b03e5Sespie "# endif /* __wchar_t */"; 721c87b03e5Sespie}; 722c87b03e5Sespie 723c87b03e5Sespie 724c87b03e5Sespie/* 725c87b03e5Sespie * This file in A/UX 3.0.x/3.1.x contains an __asm directive for c89; 726c87b03e5Sespie * gcc doesn't understand it. 727c87b03e5Sespie */ 728c87b03e5Sespiefix = { 729c87b03e5Sespie hackname = aux_asm; 730c87b03e5Sespie files = sys/param.h; 731c87b03e5Sespie select = "#ifndef NOINLINE"; 732c87b03e5Sespie 733c87b03e5Sespie c_fix = format; 734c87b03e5Sespie c_fix_arg = "#if !defined(NOINLINE) && !defined(__GNUC__)"; 735c87b03e5Sespie 736c87b03e5Sespie test_text = 737c87b03e5Sespie "#ifndef NOINLINE /* ain't got no inline, so we got it */\n" 738c87b03e5Sespie "#endif /* NOINLINE */"; 739c87b03e5Sespie}; 740c87b03e5Sespie 741c87b03e5Sespie 742c87b03e5Sespie/* 743c87b03e5Sespie * For C++, avoid any typedef or macro definition of bool, 744c87b03e5Sespie * and use the built in type instead. 745c87b03e5Sespie * HP/UX 10.20 also has it in curses_colr/curses.h. 746c87b03e5Sespie */ 747c87b03e5Sespiefix = { 748c87b03e5Sespie hackname = avoid_bool_define; 749c87b03e5Sespie files = curses.h; 750c87b03e5Sespie files = curses_colr/curses.h; 751c87b03e5Sespie files = term.h; 752c87b03e5Sespie files = tinfo.h; 753c87b03e5Sespie 754c87b03e5Sespie select = "#[ \t]*define[ \t]+bool[ \t]"; 755c87b03e5Sespie bypass = "we must use the C\\+\\+ compiler's type"; 756c87b03e5Sespie 757c87b03e5Sespie c_fix = format; 758c87b03e5Sespie c_fix_arg = "#ifndef __cplusplus\n%0\n#endif"; 759c87b03e5Sespie c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+bool[ \t].*"; 760c87b03e5Sespie 761c87b03e5Sespie test_text = "# define bool\t char \n"; 762c87b03e5Sespie}; 763c87b03e5Sespie 764c87b03e5Sespie 765c87b03e5Sespiefix = { 766c87b03e5Sespie hackname = avoid_bool_type; 767c87b03e5Sespie files = curses.h; 768c87b03e5Sespie files = curses_colr/curses.h; 769c87b03e5Sespie files = term.h; 770c87b03e5Sespie files = tinfo.h; 771c87b03e5Sespie 772c87b03e5Sespie select = "^[ \t]*typedef[ \t].*[ \t]bool[ \t]*;"; 773c87b03e5Sespie bypass = "we must use the C\\+\\+ compiler's type"; 774c87b03e5Sespie 775c87b03e5Sespie c_fix = format; 776c87b03e5Sespie c_fix_arg = "#ifndef __cplusplus\n%0\n#endif"; 777c87b03e5Sespie 778c87b03e5Sespie test_text = "typedef unsigned int\tbool \t; /* bool\n type */"; 779c87b03e5Sespie}; 780c87b03e5Sespie 781c87b03e5Sespie 782c87b03e5Sespie/* 783c87b03e5Sespie * For C++, avoid any typedef definition of wchar_t, 784c87b03e5Sespie * and use the built in type instead. 785c87b03e5Sespie * Don't do this for headers that are smart enough to do the right 786c87b03e5Sespie * thing (recent [n]curses.h and Xlib.h). 787c87b03e5Sespie * Don't do it for <linux/nls.h> which is never used from C++ anyway, 788c87b03e5Sespie * and will be broken by the edit. 789c87b03e5Sespie */ 790c87b03e5Sespie 791c87b03e5Sespiefix = { 792c87b03e5Sespie hackname = avoid_wchar_t_type; 793c87b03e5Sespie 794c87b03e5Sespie select = "^[ \t]*typedef[ \t].*[ \t]wchar_t[ \t]*;"; 795c87b03e5Sespie bypass = "we must use the C\\+\\+ compiler's type"; 796c87b03e5Sespie bypass = "_LINUX_NLS_H"; 797c87b03e5Sespie bypass = "XFree86: xc/lib/X11/Xlib\\.h"; 798c87b03e5Sespie 799c87b03e5Sespie c_fix = format; 800c87b03e5Sespie c_fix_arg = "#ifndef __cplusplus\n%0\n#endif"; 801c87b03e5Sespie 802c87b03e5Sespie test_text = "typedef unsigned short\twchar_t \t; /* wchar_t\n type */"; 803c87b03e5Sespie}; 804c87b03e5Sespie 805c87b03e5Sespie 806c87b03e5Sespie/* 807c87b03e5Sespie * Fix #defines under Alpha OSF/1: 808c87b03e5Sespie * The following files contain '#pragma extern_prefix "_FOO"' followed by 809c87b03e5Sespie * a '#define something(x,y,z) _FOOsomething(x,y,z)'. The intent of these 810c87b03e5Sespie * statements is to reduce namespace pollution. While these macros work 811c87b03e5Sespie * properly in most cases, they don't allow you to take a pointer to the 812c87b03e5Sespie * "something" being modified. To get around this limitation, change these 813c87b03e5Sespie * statements to be of the form '#define something _FOOsomething'. 814c87b03e5Sespie * 815c87b03e5Sespie * sed ain't egrep, lesson 2463: sed can use self-referential 816c87b03e5Sespie * regular expressions. In the substitute expression below, 817c87b03e5Sespie * "\\1" and "\\2" refer to subexpressions found earlier in the 818c87b03e5Sespie * same match. So, we continue to use sed. "extern_prefix" will 819c87b03e5Sespie * be a rare match anyway... 820c87b03e5Sespie */ 821c87b03e5Sespiefix = { 822c87b03e5Sespie hackname = bad_lval; 823c87b03e5Sespie 824c87b03e5Sespie select = "^[ \t]*#[ \t]*pragma[ \t]+extern_prefix"; 825c87b03e5Sespie 826c87b03e5Sespie files = libgen.h; 827c87b03e5Sespie files = dirent.h; 828c87b03e5Sespie files = ftw.h; 829c87b03e5Sespie files = grp.h; 830c87b03e5Sespie files = ndbm.h; 831c87b03e5Sespie files = pthread.h; 832c87b03e5Sespie files = pwd.h; 833c87b03e5Sespie files = signal.h; 834c87b03e5Sespie files = standards.h; 835c87b03e5Sespie files = stdlib.h; 836c87b03e5Sespie files = string.h; 837c87b03e5Sespie files = stropts.h; 838c87b03e5Sespie files = time.h; 839c87b03e5Sespie files = unistd.h; 840c87b03e5Sespie 841c87b03e5Sespie sed = 842c87b03e5Sespie "s/^[ \t]*#[ \t]*define[ \t][ \t]*\\([^(]*\\)\\(([^)]*)\\)[ \t]*" 843c87b03e5Sespie "\\(_.*\\)\\1\\2[ \t]*$/#define \\1 \\3\\1/"; 844c87b03e5Sespie 845c87b03e5Sespie test_text = '#pragma extern_prefix "_FOO"'"\n" 846c87b03e5Sespie "#define something(x,y,z) _FOOsomething(x,y,z)\n" 847c87b03e5Sespie "#define mumble _FOOmumble"; 848c87b03e5Sespie}; 849c87b03e5Sespie 850c87b03e5Sespie 851c87b03e5Sespie/* 852c87b03e5Sespie * Fix `typedef struct term;' on hppa1.1-hp-hpux9. 853c87b03e5Sespie */ 854c87b03e5Sespiefix = { 855c87b03e5Sespie hackname = bad_struct_term; 856c87b03e5Sespie files = curses.h; 857c87b03e5Sespie select = "^[ \t]*typedef[ \t]+struct[ \t]+term[ \t]*;"; 858c87b03e5Sespie c_fix = format; 859c87b03e5Sespie c_fix_arg = "struct term;"; 860c87b03e5Sespie 861c87b03e5Sespie test_text = 'typedef struct term;'; 862c87b03e5Sespie}; 863c87b03e5Sespie 864c87b03e5Sespie 865c87b03e5Sespie/* 866c87b03e5Sespie * Fix one other error in this file: 867c87b03e5Sespie * a mismatched quote not inside a C comment. 868c87b03e5Sespie */ 869c87b03e5Sespiefix = { 870c87b03e5Sespie hackname = badquote; 871c87b03e5Sespie files = sundev/vuid_event.h; 872c87b03e5Sespie select = "doesn't"; 873c87b03e5Sespie c_fix = format; 874c87b03e5Sespie c_fix_arg = "does not"; 875c87b03e5Sespie 876c87b03e5Sespie test_text = "/* doesn't have matched single quotes */"; 877c87b03e5Sespie}; 878c87b03e5Sespie 879c87b03e5Sespie 880c87b03e5Sespie/* 881c87b03e5Sespie * check for broken assert.h that needs stdio.h 882c87b03e5Sespie */ 883c87b03e5Sespiefix = { 884c87b03e5Sespie hackname = broken_assert_stdio; 885c87b03e5Sespie files = assert.h; 886c87b03e5Sespie select = stderr; 887c87b03e5Sespie bypass = "include.*stdio\\.h"; 888c87b03e5Sespie c_fix = wrap; 889c87b03e5Sespie c_fix_arg = "#include <stdio.h>\n"; 890c87b03e5Sespie test_text = "extern FILE* stderr;"; 891c87b03e5Sespie}; 892c87b03e5Sespie 893c87b03e5Sespie 894c87b03e5Sespie/* 895c87b03e5Sespie * check for broken assert.h that needs stdlib.h 896c87b03e5Sespie */ 897c87b03e5Sespiefix = { 898c87b03e5Sespie hackname = broken_assert_stdlib; 899c87b03e5Sespie files = assert.h; 900c87b03e5Sespie select = 'exit *\(|abort *\('; 901c87b03e5Sespie bypass = "include.*stdlib\\.h"; 902c87b03e5Sespie c_fix = wrap; 903c87b03e5Sespie c_fix_arg = "#ifdef __cplusplus\n" 904c87b03e5Sespie "#include <stdlib.h>\n" 905c87b03e5Sespie "#endif\n"; 906c87b03e5Sespie test_text = "extern void exit ( int );"; 907c87b03e5Sespie}; 908c87b03e5Sespie 909c87b03e5Sespie 910c87b03e5Sespie/* 911c87b03e5Sespie * Remove `extern double cabs' declarations from math.h. 912c87b03e5Sespie * This conflicts with C99. Discovered on AIX. 913c87b03e5Sespie * SunOS4 has its cabs() declaration followed by a comment which 914c87b03e5Sespie * terminates on the following line. 915c87b03e5Sespie */ 916c87b03e5Sespiefix = { 917c87b03e5Sespie hackname = broken_cabs; 918c87b03e5Sespie files = "math.h"; 919c87b03e5Sespie select = '^extern[ \t]+double[ \t]+cabs'; 920c87b03e5Sespie 921c87b03e5Sespie c_fix = format; 922c87b03e5Sespie c_fix_arg = ""; 923c87b03e5Sespie c_fix_arg = "^extern[ \t]+double[ \t]+cabs\\((struct dbl_hypot|)\\);"; 924c87b03e5Sespie 925c87b03e5Sespie test_text = "#ifdef __STDC__\n" 926c87b03e5Sespie "extern double cabs(struct dbl_hypot);\n" 927c87b03e5Sespie "#else\n" 928c87b03e5Sespie "extern double cabs();\n" 929c87b03e5Sespie "#endif\n" 930c87b03e5Sespie "extern double cabs(); /* This is a comment\n" 931c87b03e5Sespie " and it ends here. */"; 932c87b03e5Sespie}; 933c87b03e5Sespie 934c87b03e5Sespie 935c87b03e5Sespie/* 936c87b03e5Sespie * Fix various macros used to define ioctl numbers. 937c87b03e5Sespie * The traditional syntax was: 938c87b03e5Sespie * 939c87b03e5Sespie * #define _CTRL(n, x) (('n'<<8)+x) 940c87b03e5Sespie * #define TCTRLCFOO _CTRL(T, 1) 941c87b03e5Sespie * 942c87b03e5Sespie * but this does not work with the C standard, which disallows macro 943c87b03e5Sespie * expansion inside strings. We have to rewrite it thus: 944c87b03e5Sespie * 945c87b03e5Sespie * #define _CTRL(n, x) ((n<<8)+x) 946c87b03e5Sespie * #define TCTRLCFOO _CTRL('T', 1) 947c87b03e5Sespie * 948c87b03e5Sespie * The select expressions match too much, but the c_fix code is cautious. 949c87b03e5Sespie * 950c87b03e5Sespie * CTRL might be: CTRL _CTRL ISCTRL BSD43_CTRL ... 951c87b03e5Sespie */ 952c87b03e5Sespiefix = { 953c87b03e5Sespie hackname = ctrl_quotes_def; 954c87b03e5Sespie select = "define[ \t]+[A-Z0-9_]+CTRL\\([a-zA-Z][,)]"; 955c87b03e5Sespie c_fix = char_macro_def; 956c87b03e5Sespie c_fix_arg = "CTRL"; 957c87b03e5Sespie 958c87b03e5Sespie /* 959c87b03e5Sespie * This is two tests in order to ensure that the "CTRL(c)" can 960c87b03e5Sespie * be selected in isolation from the multi-arg format 961c87b03e5Sespie */ 962c87b03e5Sespie test_text = "#define BSD43_CTRL(n, x) (('n'<<8)+x)\n"; 963c87b03e5Sespie test_text = "#define _CTRL(c) ('c'&037)"; 964c87b03e5Sespie}; 965c87b03e5Sespie 966c87b03e5Sespiefix = { 967c87b03e5Sespie hackname = ctrl_quotes_use; 968c87b03e5Sespie select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+CTRL[ \t]*\\( *[^,']"; 969c87b03e5Sespie c_fix = char_macro_use; 970c87b03e5Sespie c_fix_arg = "CTRL"; 971c87b03e5Sespie test_text = "#define TCTRLFOO BSD43_CTRL(T, 1)"; 972c87b03e5Sespie}; 973c87b03e5Sespie 974c87b03e5Sespie 975c87b03e5Sespie/* 976c87b03e5Sespie * sys/mman.h on HP/UX is not C++ ready, 977c87b03e5Sespie * even though NO_IMPLICIT_EXTERN_C is defined on HP/UX. 978c87b03e5Sespie * 979c87b03e5Sespie * rpc/types.h on OSF1/2.0 is not C++ ready, 980c87b03e5Sespie * even though NO_IMPLICIT_EXTERN_C is defined for the alpha. 981c87b03e5Sespie * 982c87b03e5Sespie * The problem is the declaration of malloc. 983c87b03e5Sespie */ 984c87b03e5Sespiefix = { 985c87b03e5Sespie hackname = cxx_unready; 986c87b03e5Sespie files = sys/mman.h; 987c87b03e5Sespie files = rpc/types.h; 988c87b03e5Sespie select = '[^#]+malloc.*;'; /* Catch any form of declaration 989c87b03e5Sespie not within a macro. */ 990c87b03e5Sespie bypass = '"C"|__BEGIN_DECLS'; 991c87b03e5Sespie 992c87b03e5Sespie c_fix = wrap; 993c87b03e5Sespie c_fix_arg = "#ifdef __cplusplus\n" 994c87b03e5Sespie "extern \"C\" {\n" 995c87b03e5Sespie "#endif\n"; 996c87b03e5Sespie c_fix_arg = "#ifdef __cplusplus\n" 997c87b03e5Sespie "}\n" 998c87b03e5Sespie "#endif\n"; 999c87b03e5Sespie test_text = "extern void* malloc( size_t );"; 1000c87b03e5Sespie}; 1001c87b03e5Sespie 1002c87b03e5Sespie 1003c87b03e5Sespie/* 1004c87b03e5Sespie * Fix <c_asm.h> on Digital UNIX V4.0: 1005c87b03e5Sespie * It contains a prototype for a DEC C internal asm() function, 1006c87b03e5Sespie * clashing with gcc's asm keyword. So protect this with __DECC. 1007c87b03e5Sespie */ 1008c87b03e5Sespiefix = { 1009c87b03e5Sespie hackname = dec_intern_asm; 1010c87b03e5Sespie files = c_asm.h; 1011c87b03e5Sespie sed = "/^[ \t]*float[ \t]*fasm/i\\\n#ifdef __DECC\n"; 1012c87b03e5Sespie sed = "/^[ \t]*#[ \t]*pragma[ \t]*intrinsic([ \t]*dasm/a\\\n" 1013c87b03e5Sespie "#endif\n"; 1014c87b03e5Sespie test_text = 1015c87b03e5Sespie "float fasm {\n" 1016c87b03e5Sespie " ... asm stuff ...\n" 1017c87b03e5Sespie "};\n#pragma intrinsic( dasm )\n/* END ASM TEST*/"; 1018c87b03e5Sespie}; 1019c87b03e5Sespie 1020c87b03e5Sespie 1021c87b03e5Sespie/* 1022c87b03e5Sespie * Fix typo in <wchar.h> on DJGPP 2.03. 1023c87b03e5Sespie */ 1024c87b03e5Sespiefix = { 1025c87b03e5Sespie hackname = djgpp_wchar_h; 1026c87b03e5Sespie file = wchar.h; 1027c87b03e5Sespie select = "__DJ_wint_t"; 1028c87b03e5Sespie bypass = "sys/djtypes.h"; 1029c87b03e5Sespie c_fix = format; 1030c87b03e5Sespie c_fix_arg = "%0\n#include <sys/djtypes.h>"; 1031c87b03e5Sespie c_fix_arg = "#include <stddef.h>"; 1032c87b03e5Sespie test_text = "#include <stddef.h>\n" 1033c87b03e5Sespie "extern __DJ_wint_t x;\n"; 1034c87b03e5Sespie}; 1035c87b03e5Sespie 1036c87b03e5Sespie 1037c87b03e5Sespie/* 1038c87b03e5Sespie * Fix these Sun OS files to avoid an invalid identifier in an #ifdef. 1039c87b03e5Sespie */ 1040c87b03e5Sespiefix = { 1041c87b03e5Sespie hackname = ecd_cursor; 1042c87b03e5Sespie files = "sunwindow/win_lock.h"; 1043c87b03e5Sespie files = "sunwindow/win_cursor.h"; 1044c87b03e5Sespie select = 'ecd\.cursor'; 1045c87b03e5Sespie c_fix = format; 1046c87b03e5Sespie c_fix_arg = 'ecd_cursor'; 1047c87b03e5Sespie 1048c87b03e5Sespie test_text = "#ifdef ecd.cursor\n#error bogus\n#endif /* ecd+cursor */"; 1049c87b03e5Sespie}; 1050c87b03e5Sespie 1051c87b03e5Sespie 1052c87b03e5Sespie/* 1053c87b03e5Sespie * fix-header doesn't fix fabs' prototype, and I have no idea why. 1054c87b03e5Sespie */ 1055c87b03e5Sespiefix = { 1056c87b03e5Sespie hackname = fix_header_breakage; 1057c87b03e5Sespie mach = "m88k-motorola-sysv3*"; 1058c87b03e5Sespie files = "math.h"; 1059c87b03e5Sespie 1060c87b03e5Sespie select = 'extern double floor\(\), ceil\(\), fmod\(\), fabs\(\);'; 1061c87b03e5Sespie c_fix = format; 1062c87b03e5Sespie c_fix_arg = 1063c87b03e5Sespie 'extern double floor(), ceil(), fmod(), fabs _PARAMS((double));'; 1064c87b03e5Sespie test_text = 'extern double floor(), ceil(), fmod(), fabs();'; 1065c87b03e5Sespie}; 1066c87b03e5Sespie 1067c87b03e5Sespie 1068c87b03e5Sespie/* 1069c87b03e5Sespie * Between 8/24/1998 and 2/17/2001, FreeBSD system headers presume 1070c87b03e5Sespie * neither the existence of GCC 3 nor its exact feature set yet break 1071c87b03e5Sespie * (by design?) when __GNUC__ is set beyond 2. 1072c87b03e5Sespie */ 1073c87b03e5Sespiefix = { 1074c87b03e5Sespie hackname = freebsd_gcc3_breakage; 1075c87b03e5Sespie mach = *-*-freebsd*; 1076c87b03e5Sespie files = sys/cdefs.h; 1077c87b03e5Sespie select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7$'; 1078c87b03e5Sespie bypass = '__GNUC__[ \t]*([>=]=[ \t]*[3-9]|>[ \t]*2)'; 1079c87b03e5Sespie c_fix = format; 1080c87b03e5Sespie c_fix_arg = '%0 || __GNUC__ >= 3'; 1081c87b03e5Sespie test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7'; 1082c87b03e5Sespie}; 1083c87b03e5Sespie 1084c87b03e5Sespie 1085c87b03e5Sespie/* 1086c87b03e5Sespie * Fix these files to use the same types that we think they should. 1087c87b03e5Sespie */ 1088c87b03e5Sespiefix = { 1089c87b03e5Sespie hackname = gnu_types; 1090c87b03e5Sespie files = "sys/types.h"; 1091c87b03e5Sespie files = "stdlib.h"; 1092c87b03e5Sespie files = "sys/stdtypes.h"; 1093c87b03e5Sespie files = "stddef.h"; 1094c87b03e5Sespie files = "memory.h"; 1095c87b03e5Sespie files = "unistd.h"; 1096c87b03e5Sespie bypass = '_GCC_(PTRDIFF|SIZE|WCHAR)_T'; 1097c87b03e5Sespie select = "^[ \t]*typedef[ \t]+.*[ \t](ptrdiff|size|wchar)_t;"; 1098c87b03e5Sespie c_fix = gnu_type; 1099c87b03e5Sespie 1100c87b03e5Sespie test_text = "typedef long int ptrdiff_t; /* long int */\n" 1101c87b03e5Sespie "typedef uint_t size_t; /* uint_t */\n" 1102c87b03e5Sespie "typedef ushort_t wchar_t; /* ushort_t */"; 1103c87b03e5Sespie}; 1104c87b03e5Sespie 1105c87b03e5Sespie 1106c87b03e5Sespie/* 1107c87b03e5Sespie * Fix HP & Sony's use of "../machine/xxx.h" 1108c87b03e5Sespie * to refer to: <machine/xxx.h> 1109c87b03e5Sespie */ 1110c87b03e5Sespiefix = { 1111c87b03e5Sespie hackname = hp_inline; 1112c87b03e5Sespie files = sys/spinlock.h; 1113c87b03e5Sespie files = machine/machparam.h; 1114c87b03e5Sespie select = "[ \t]*#[ \t]*include[ \t]+" '"\.\./machine/'; 1115c87b03e5Sespie 1116c87b03e5Sespie c_fix = format; 1117c87b03e5Sespie c_fix_arg = "%1<machine/%2.h>"; 1118c87b03e5Sespie 1119c87b03e5Sespie c_fix_arg = "([ \t]*#[ \t]*include[ \t]+)" '"\.\./machine/' 1120c87b03e5Sespie '([a-z]+)\.h"'; 1121c87b03e5Sespie 1122c87b03e5Sespie test_text = ' # include "../machine/mumble.h"'; 1123c87b03e5Sespie}; 1124c87b03e5Sespie 1125c87b03e5Sespie 1126c87b03e5Sespie/* 1127c87b03e5Sespie * Check for (...) in C++ code in HP/UX sys/file.h. 1128c87b03e5Sespie */ 1129c87b03e5Sespiefix = { 1130c87b03e5Sespie hackname = hp_sysfile; 1131c87b03e5Sespie files = sys/file.h; 1132c87b03e5Sespie select = "HPUX_SOURCE"; 1133c87b03e5Sespie 1134c87b03e5Sespie c_fix = format; 1135c87b03e5Sespie c_fix_arg = "(struct file *, ...)"; 1136c87b03e5Sespie c_fix_arg = '\(\.\.\.\)'; 1137c87b03e5Sespie 1138c87b03e5Sespie test_text = "extern void foo(...); /* HPUX_SOURCE - bad varargs */"; 1139c87b03e5Sespie}; 1140c87b03e5Sespie 1141c87b03e5Sespie 1142c87b03e5Sespie/* 1143c87b03e5Sespie * Delete C++ double pow (double, int) inline function from HP-UX 10 & 11 1144c87b03e5Sespie * math.h to prevent clash with define in c_std/bits/std_cmath.h. 1145c87b03e5Sespie */ 1146c87b03e5Sespiefix = { 1147c87b03e5Sespie hackname = hpux10_cpp_pow_inline; 1148c87b03e5Sespie files = fixinc-test-limits.h, math.h; 1149c87b03e5Sespie select = <<- END_POW_INLINE 1150c87b03e5Sespie ^# +ifdef +__cplusplus 1151c87b03e5Sespie +} 1152c87b03e5Sespie +inline +double +pow\(double +__d,int +__expon\) +{ 1153c87b03e5Sespie [ ]+return +pow\(__d,\(double\)__expon\); 1154c87b03e5Sespie +} 1155c87b03e5Sespie +extern +"C" +{ 1156c87b03e5Sespie #else 1157c87b03e5Sespie # +endif 1158c87b03e5Sespie END_POW_INLINE; 1159c87b03e5Sespie 1160c87b03e5Sespie c_fix = format; 1161c87b03e5Sespie c_fix_arg = ""; 1162c87b03e5Sespie 1163c87b03e5Sespie test_text = 1164c87b03e5Sespie "# ifdef __cplusplus\n" 1165c87b03e5Sespie " }\n" 1166c87b03e5Sespie " inline double pow(double __d,int __expon) {\n" 1167c87b03e5Sespie "\t return pow(__d,(double)__expon);\n" 1168c87b03e5Sespie " }\n" 1169c87b03e5Sespie ' extern "C"' " {\n" 1170c87b03e5Sespie "#else\n" 1171c87b03e5Sespie "# endif"; 1172c87b03e5Sespie}; 1173c87b03e5Sespie 1174c87b03e5Sespiefix = { 1175c87b03e5Sespie hackname = hpux11_cpp_pow_inline; 1176c87b03e5Sespie files = math.h; 1177c87b03e5Sespie select = " +inline double pow\\(double d,int expon\\) {\n" 1178c87b03e5Sespie " +return pow\\(d, \\(double\\)expon\\);\n" 1179c87b03e5Sespie " +}\n"; 1180c87b03e5Sespie c_fix = format; 1181c87b03e5Sespie c_fix_arg = ""; 1182c87b03e5Sespie 1183c87b03e5Sespie test_text = 1184c87b03e5Sespie " inline double pow(double d,int expon) {\n" 1185c87b03e5Sespie " return pow(d, (double)expon);\n" 1186c87b03e5Sespie " }\n"; 1187c87b03e5Sespie}; 1188c87b03e5Sespie 1189c87b03e5Sespie 1190c87b03e5Sespie/* 1191c87b03e5Sespie * Fix hpux 10.X missing ctype declarations 1 1192c87b03e5Sespie */ 1193c87b03e5Sespiefix = { 1194c87b03e5Sespie hackname = hpux10_ctype_declarations1; 1195c87b03e5Sespie files = ctype.h; 1196c87b03e5Sespie select = "^#[ \t]*define _toupper\\(__c\\)[ \t]*__toupper\\(__c\\)"; 1197c87b03e5Sespie bypass = "^[ \t]*extern[ \t]*int[ \t]*__tolower[ \t]*\\("; 1198c87b03e5Sespie c_fix = format; 1199c87b03e5Sespie c_fix_arg = "#ifdef _PROTOTYPES\n" 1200c87b03e5Sespie "extern int __tolower(int);\n" 1201c87b03e5Sespie "extern int __toupper(int);\n" 1202c87b03e5Sespie "#else /* NOT _PROTOTYPES */\n" 1203c87b03e5Sespie "extern int __tolower();\n" 1204c87b03e5Sespie "extern int __toupper();\n" 1205c87b03e5Sespie "#endif /* _PROTOTYPES */\n\n" 1206c87b03e5Sespie "%0\n"; 1207c87b03e5Sespie 1208c87b03e5Sespie test_text = "# define _toupper(__c) __toupper(__c)\n"; 1209c87b03e5Sespie}; 1210c87b03e5Sespie 1211c87b03e5Sespie 1212c87b03e5Sespie/* 1213c87b03e5Sespie * Fix hpux 10.X missing ctype declarations 2 1214c87b03e5Sespie */ 1215c87b03e5Sespiefix = { 1216c87b03e5Sespie hackname = hpux10_ctype_declarations2; 1217c87b03e5Sespie files = ctype.h; 1218c87b03e5Sespie select = "^# if defined\\(_SB_CTYPE_MACROS\\) && \\!defined\\(__lint\\)"; 1219c87b03e5Sespie bypass = "^[ \t]*extern[ \t]*int[ \t]*_isalnum[ \t]*\\("; 1220c87b03e5Sespie c_fix = format; 1221c87b03e5Sespie c_fix_arg = "%0\n\n" 1222c87b03e5Sespie "#ifdef _PROTOTYPES\n" 1223c87b03e5Sespie " extern int _isalnum(int);\n" 1224c87b03e5Sespie " extern int _isalpha(int);\n" 1225c87b03e5Sespie " extern int _iscntrl(int);\n" 1226c87b03e5Sespie " extern int _isdigit(int);\n" 1227c87b03e5Sespie " extern int _isgraph(int);\n" 1228c87b03e5Sespie " extern int _islower(int);\n" 1229c87b03e5Sespie " extern int _isprint(int);\n" 1230c87b03e5Sespie " extern int _ispunct(int);\n" 1231c87b03e5Sespie " extern int _isspace(int);\n" 1232c87b03e5Sespie " extern int _isupper(int);\n" 1233c87b03e5Sespie " extern int _isxdigit(int);\n" 1234c87b03e5Sespie "# else /* not _PROTOTYPES */\n" 1235c87b03e5Sespie " extern int _isalnum();\n" 1236c87b03e5Sespie " extern int _isalpha();\n" 1237c87b03e5Sespie " extern int _iscntrl();\n" 1238c87b03e5Sespie " extern int _isdigit();\n" 1239c87b03e5Sespie " extern int _isgraph();\n" 1240c87b03e5Sespie " extern int _islower();\n" 1241c87b03e5Sespie " extern int _isprint();\n" 1242c87b03e5Sespie " extern int _ispunct();\n" 1243c87b03e5Sespie " extern int _isspace();\n" 1244c87b03e5Sespie " extern int _isupper();\n" 1245c87b03e5Sespie " extern int _isxdigit();\n" 1246c87b03e5Sespie "#endif /* _PROTOTYPES */\n"; 1247c87b03e5Sespie 1248c87b03e5Sespie test_text = "# if defined(_SB_CTYPE_MACROS) && !defined(__lint)\n" 1249c87b03e5Sespie " extern unsigned int *__SB_masks;\n"; 1250c87b03e5Sespie}; 1251c87b03e5Sespie 1252c87b03e5Sespie 1253c87b03e5Sespie/* 1254c87b03e5Sespie * Make sure hpux defines abs in header. 1255c87b03e5Sespie */ 1256c87b03e5Sespiefix = { 1257c87b03e5Sespie hackname = hpux11_abs; 1258c87b03e5Sespie mach = ia64-hp-hpux11*; 1259c87b03e5Sespie files = stdlib.h; 1260c87b03e5Sespie select = "ifndef _MATH_INCLUDED"; 1261c87b03e5Sespie c_fix = format; 1262c87b03e5Sespie c_fix_arg = "if !defined(_MATH_INCLUDED) || defined(__GNUG__)"; 1263c87b03e5Sespie// sed = "s/ifndef _MATH_INCLUDED/if !defined(_MATH_INCLUDED) || defined(__GNUG__)/"; 1264c87b03e5Sespie test_text = "#ifndef _MATH_INCLUDED"; 1265c87b03e5Sespie}; 1266c87b03e5Sespie 1267c87b03e5Sespie 1268c87b03e5Sespie/* 1269c87b03e5Sespie * Keep HP-UX 11 from stomping on C++ math namespace 1270c87b03e5Sespie * with defines for fabsf. 1271c87b03e5Sespie */ 1272c87b03e5Sespiefix = { 1273c87b03e5Sespie hackname = hpux11_fabsf; 1274c87b03e5Sespie files = math.h; 1275c87b03e5Sespie select = "^[ \t]*#[ \t]*define[ \t]+fabsf\\(.*"; 1276c87b03e5Sespie bypass = "__cplusplus"; 1277c87b03e5Sespie 1278c87b03e5Sespie c_fix = format; 1279c87b03e5Sespie c_fix_arg = "#ifndef __cplusplus\n%0\n#endif"; 1280c87b03e5Sespie 1281c87b03e5Sespie test_text = 1282c87b03e5Sespie "#ifdef _PA_RISC\n" 1283c87b03e5Sespie "# define fabsf(x) ((float)fabs((double)(float)(x)))\n" 1284c87b03e5Sespie "#endif"; 1285c87b03e5Sespie}; 1286c87b03e5Sespie 1287c87b03e5Sespie 1288c87b03e5Sespie/* 1289c87b03e5Sespie * Prevent HP-UX 11 from defining __size_t and preventing size_t from 1290c87b03e5Sespie * being defined by having it define _hpux_size_t instead. 1291c87b03e5Sespie */ 1292c87b03e5Sespiefix = { 1293c87b03e5Sespie hackname = hpux11_size_t; 1294c87b03e5Sespie mach = "*-hp-hpux11*"; 1295c87b03e5Sespie select = "__size_t"; 1296c87b03e5Sespie 1297c87b03e5Sespie c_fix = format; 1298c87b03e5Sespie c_fix_arg = "_hpux_size_t"; 1299c87b03e5Sespie 1300c87b03e5Sespie test_text = 1301c87b03e5Sespie "#define __size_t size_t\n" 1302c87b03e5Sespie " extern int getpwuid_r( char *, __size_t, struct passwd **);\n"; 1303c87b03e5Sespie}; 1304c87b03e5Sespie 1305c87b03e5Sespie 1306c87b03e5Sespie/* 1307c87b03e5Sespie * In inttypes.h on HPUX 11, the use of __CONCAT__ in the definition 1308c87b03e5Sespie * of UINT32_C has undefined behavior according to ISO/ANSI: 1309c87b03e5Sespie * the arguments to __CONCAT__ are not macro expanded before the 1310c87b03e5Sespie * concatination happens so the trailing ')' in the first argument 1311c87b03e5Sespie * is concatinated with the 'l' in the second argument creating an 1312c87b03e5Sespie * invalid pp token. The behavior of invalid pp tokens is undefined. 1313c87b03e5Sespie * GCC does not handle these invalid tokens the way the HP compiler does. 1314c87b03e5Sespie * This problem will potentially occur anytime macros are used in the 1315c87b03e5Sespie * arguments to __CONCAT__. A general solution to this problem would be to 1316c87b03e5Sespie * insert another layer of macro between __CONCAT__ and its use 1317c87b03e5Sespie * in UINT32_C. An example of this solution can be found in the C standard. 1318c87b03e5Sespie * A more specific solution, the one used here, is to change the UINT32_C 1319c87b03e5Sespie * macro to not used macros in the arguments to __CONCAT__. 1320c87b03e5Sespie */ 1321c87b03e5Sespiefix = { 1322c87b03e5Sespie hackname = hpux11_uint32_c; 1323c87b03e5Sespie files = inttypes.h; 1324c87b03e5Sespie select = "^#define UINT32_C\\(__c\\)[ \t]*" 1325c87b03e5Sespie "__CONCAT__\\(__CONCAT_U__\\(__c\\),l\\)"; 1326c87b03e5Sespie c_fix = format; 1327c87b03e5Sespie c_fix_arg = '#define UINT32_C(__c) __CONCAT__(__c,ul)'; 1328c87b03e5Sespie test_text = 1329c87b03e5Sespie "#define CONCAT_U__(__c)\t__CONCAT__(__c,u)\n" 1330c87b03e5Sespie "#define UINT32_C(__c)\t__CONCAT__(__CONCAT_U__(__c),l)"; 1331c87b03e5Sespie}; 1332c87b03e5Sespie 1333c87b03e5Sespie 1334c87b03e5Sespie/* 1335c87b03e5Sespie * Fix hpux 11.00 broken vsnprintf declaration 1336c87b03e5Sespie */ 1337c87b03e5Sespiefix = { 1338c87b03e5Sespie hackname = hpux11_vsnprintf; 1339c87b03e5Sespie files = stdio.h; 1340c87b03e5Sespie select = '(extern int vsnprintf\(char \*, _[hpux]*_size_t, ' 1341c87b03e5Sespie 'const char \*,) __va__list\);'; 1342c87b03e5Sespie c_fix = format; 1343c87b03e5Sespie c_fix_arg = "%1 __va_list);"; 1344c87b03e5Sespie 1345c87b03e5Sespie test_text = 'extern int vsnprintf(char *, _hpux_size_t, const char *,' 1346c87b03e5Sespie ' __va__list);'; 1347c87b03e5Sespie}; 1348c87b03e5Sespie 1349c87b03e5Sespie 1350c87b03e5Sespie/* 13514e43c760Sespie * Fix hpux 11.00 broken snprintf declaration 13524e43c760Sespie * (third argument is char *, needs to be const char * to prevent 13534e43c760Sespie * spurious warnings with -Wwrite-strings or in C++). 13544e43c760Sespie */ 13554e43c760Sespiefix = { 13564e43c760Sespie hackname = hpux11_snprintf; 13574e43c760Sespie files = stdio.h; 13584e43c760Sespie select = '(extern int snprintf *\(char *\*, *(|__|_hpux_)size_t,)' 13594e43c760Sespie ' *(char *\*, *\.\.\.\);)'; 13604e43c760Sespie c_fix = format; 13614e43c760Sespie c_fix_arg = '%1 const %3'; 13624e43c760Sespie 13634e43c760Sespie test_text = "extern int snprintf(char *, size_t, char *, ...);\n" 13644e43c760Sespie "extern int snprintf(char *, __size_t, char *, ...);\n" 13654e43c760Sespie "extern int snprintf(char *, _hpux_size_t, char *, ...);"; 13664e43c760Sespie}; 13674e43c760Sespie 13684e43c760Sespie 13694e43c760Sespie/* 1370c87b03e5Sespie * get rid of bogus inline definitions in HP-UX 8.0 1371c87b03e5Sespie */ 1372c87b03e5Sespiefix = { 1373c87b03e5Sespie hackname = hpux8_bogus_inlines; 1374c87b03e5Sespie files = math.h; 1375c87b03e5Sespie select = inline; 1376c87b03e5Sespie sed = "s@inline int abs(int [a-z][a-z]*) {.*}" 1377c87b03e5Sespie "@extern \"C\" int abs(int);@"; 1378c87b03e5Sespie sed = "s@inline double abs(double [a-z][a-z]*) {.*}@@"; 1379c87b03e5Sespie sed = "s@inline int sqr(int [a-z][a-z]*) {.*}@@"; 1380c87b03e5Sespie sed = "s@inline double sqr(double [a-z][a-z]*) {.*}@@"; 1381c87b03e5Sespie test_text = "inline int abs(int v) { return (v>=0)?v:-v; }\n" 1382c87b03e5Sespie "inline double sqr(double v) { return v**0.5; }"; 1383c87b03e5Sespie}; 1384c87b03e5Sespie 1385c87b03e5Sespie 1386c87b03e5Sespie/* 1387c87b03e5Sespie * Fix hpux broken ctype macros 1388c87b03e5Sespie */ 1389c87b03e5Sespiefix = { 1390c87b03e5Sespie hackname = hpux_ctype_macros; 1391c87b03e5Sespie files = ctype.h; 1392c87b03e5Sespie select = '((: |\()__SB_masks \? )' 1393c87b03e5Sespie '(__SB_masks\[__(alnum|c)\] & _IS)'; 1394c87b03e5Sespie c_fix = format; 1395c87b03e5Sespie c_fix_arg = "%1(int)%3"; 1396c87b03e5Sespie 1397c87b03e5Sespie test_text = ": __SB_masks ? __SB_masks[__alnum] & _ISCNTRL\n" 1398c87b03e5Sespie "# define isalpha(__c) (__SB_masks ? __SB_masks[__c] & _IS\n"; 1399c87b03e5Sespie}; 1400c87b03e5Sespie 1401c87b03e5Sespie 1402c87b03e5Sespie/* 1403c87b03e5Sespie * HP-UX long_double 1404c87b03e5Sespie */ 1405c87b03e5Sespiefix = { 1406c87b03e5Sespie hackname = hpux_long_double; 1407c87b03e5Sespie files = stdlib.h; 1408c87b03e5Sespie select = "extern[ \t]long_double[ \t]strtold"; 1409c87b03e5Sespie bypass = "long_double_t"; 1410c87b03e5Sespie sed = "/^#[ \t]*ifndef _LONG_DOUBLE/,/\\/\\* _LONG_DOUBLE \\*\\//D"; 1411c87b03e5Sespie sed = "s/long_double/long double/g"; 1412c87b03e5Sespie 1413c87b03e5Sespie test_text = "# ifndef _LONG_DOUBLE\n" 1414c87b03e5Sespie "# define _LONG_DOUBLE\n" 1415c87b03e5Sespie " typedef struct {\n" 1416c87b03e5Sespie " unsigned int word1, word2, word3, word4;\n" 1417c87b03e5Sespie " } long_double;\n" 1418c87b03e5Sespie "# endif /* _LONG_DOUBLE */\n" 1419c87b03e5Sespie "extern long_double strtold(const char *, char **);\n"; 1420c87b03e5Sespie}; 1421c87b03e5Sespie 1422c87b03e5Sespie 1423c87b03e5Sespie/* 1424c87b03e5Sespie * HPUX 10.x sys/param.h defines MAXINT which clashes with values.h 1425c87b03e5Sespie */ 1426c87b03e5Sespiefix = { 1427c87b03e5Sespie hackname = hpux_maxint; 1428c87b03e5Sespie files = sys/param.h; 1429c87b03e5Sespie files = values.h; 1430c87b03e5Sespie select = "^#[ \t]*define[ \t]+MAXINT[ \t]"; 1431c87b03e5Sespie bypass = "^#[ \t]*ifndef[ \t]+MAXINT"; 1432c87b03e5Sespie test = 1433c87b03e5Sespie "-n \"`egrep '#[ \t]*define[ \t]+MAXINT[ \t]' sys/param.h`\""; 1434c87b03e5Sespie 1435c87b03e5Sespie c_fix = format; 1436c87b03e5Sespie c_fix_arg = "#ifndef MAXINT\n%0\n#endif"; 1437c87b03e5Sespie c_fix_arg = "^#[ \t]*define[ \t]+MAXINT[ \t].*"; 1438c87b03e5Sespie 1439c87b03e5Sespie test_text = '#define MAXINT 0x7FFFFFFF'; 1440c87b03e5Sespie}; 1441c87b03e5Sespie 1442c87b03e5Sespie 1443c87b03e5Sespie/* 1444c87b03e5Sespie * Fix hpux10.20 <sys/time.h> to avoid invalid forward decl 1445c87b03e5Sespie */ 1446c87b03e5Sespiefix = { 1447c87b03e5Sespie hackname = hpux_systime; 1448c87b03e5Sespie files = sys/time.h; 1449c87b03e5Sespie select = "^extern struct sigevent;"; 1450c87b03e5Sespie 1451c87b03e5Sespie c_fix = format; 1452c87b03e5Sespie c_fix_arg = "struct sigevent;"; 1453c87b03e5Sespie 1454c87b03e5Sespie test_text = 'extern struct sigevent;'; 1455c87b03e5Sespie}; 1456c87b03e5Sespie 1457c87b03e5Sespie 1458c87b03e5Sespie/* 1459c87b03e5Sespie * Fix return type of abort and free 1460c87b03e5Sespie */ 1461c87b03e5Sespiefix = { 1462c87b03e5Sespie hackname = int_abort_free_and_exit; 1463c87b03e5Sespie files = stdlib.h; 1464c87b03e5Sespie select = "int[ \t]+(abort|free|exit)[ \t]*\\("; 1465c87b03e5Sespie 1466c87b03e5Sespie c_fix = format; 1467c87b03e5Sespie c_fix_arg = "void\t%1("; 1468c87b03e5Sespie 1469c87b03e5Sespie test_text = "extern int abort(int);\n" 1470c87b03e5Sespie "extern int free(void*);\n" 1471c87b03e5Sespie "extern int exit(void*);"; 1472c87b03e5Sespie}; 1473c87b03e5Sespie 1474c87b03e5Sespie 1475c87b03e5Sespie/* 1476c87b03e5Sespie * Fix various macros used to define ioctl numbers. 1477c87b03e5Sespie * The traditional syntax was: 1478c87b03e5Sespie * 1479c87b03e5Sespie * #define _IO(n, x) (('n'<<8)+x) 1480c87b03e5Sespie * #define TIOCFOO _IO(T, 1) 1481c87b03e5Sespie * 1482c87b03e5Sespie * but this does not work with the C standard, which disallows macro 1483c87b03e5Sespie * expansion inside strings. We have to rewrite it thus: 1484c87b03e5Sespie * 1485c87b03e5Sespie * #define _IO(n, x) ((n<<8)+x) 1486c87b03e5Sespie * #define TIOCFOO _IO('T', 1) 1487c87b03e5Sespie * 1488c87b03e5Sespie * The select expressions match too much, but the c_fix code is cautious. 1489c87b03e5Sespie * 1490c87b03e5Sespie * _IO might be: _IO DESIO BSD43__IO with W, R, WR, C, ... suffixes. 1491c87b03e5Sespie */ 1492c87b03e5Sespiefix = { 1493c87b03e5Sespie hackname = io_quotes_def; 1494c87b03e5Sespie select = "define[ \t]+[A-Z0-9_]+IO[A-Z]*\\([a-zA-Z][,)]"; 1495c87b03e5Sespie c_fix = char_macro_def; 1496c87b03e5Sespie c_fix_arg = "IO"; 1497c87b03e5Sespie test_text = 1498c87b03e5Sespie "#define BSD43__IOWR(n, x) (('n'<<8)+x)\n" 1499c87b03e5Sespie "#define _IOWN(x,y,t) (_IOC_IN|(((t)&_IOCPARM_MASK)<<16)|('x'<<8)|y)\n" 1500c87b03e5Sespie "#define _IO(x,y) ('x'<<8|y)"; 1501c87b03e5Sespie test_text = 1502c87b03e5Sespie "#define XX_IO(x) ('x'<<8|256)"; 1503c87b03e5Sespie}; 1504c87b03e5Sespie 1505c87b03e5Sespiefix = { 1506c87b03e5Sespie hackname = io_quotes_use; 1507c87b03e5Sespie select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+IO[A-Z]*[ \t]*" 1508c87b03e5Sespie "\\( *[^,']"; 1509c87b03e5Sespie c_fix = char_macro_use; 1510c87b03e5Sespie c_fix_arg = "IO"; 1511c87b03e5Sespie test_text = "#define TIOCFOO BSD43__IOWR(T, 1)\n" 1512c87b03e5Sespie "#define TIOCFOO \\\\\n" 1513c87b03e5Sespie "BSD43__IOWR(T, 1) /* Some are multi-line */"; 1514c87b03e5Sespie}; 1515c87b03e5Sespie 1516c87b03e5Sespie 1517c87b03e5Sespie/* 1518c87b03e5Sespie * Check for missing ';' in struct 1519c87b03e5Sespie */ 1520c87b03e5Sespiefix = { 1521c87b03e5Sespie hackname = ip_missing_semi; 1522c87b03e5Sespie files = netinet/ip.h; 1523c87b03e5Sespie select = "}$"; 1524c87b03e5Sespie sed = "/^struct/,/^};/s/}$/};/"; 1525c87b03e5Sespie test_text= 1526c87b03e5Sespie "struct mumble {\n" 1527c87b03e5Sespie " union {\n" 1528c87b03e5Sespie " int x;\n" 1529c87b03e5Sespie " }\n" 1530c87b03e5Sespie "}; /* mumbled struct */\n"; 1531c87b03e5Sespie}; 1532c87b03e5Sespie 1533c87b03e5Sespie 1534c87b03e5Sespie/* 1535c87b03e5Sespie * IRIX 6.5.1[89] <internal/sgimacros.h> unconditionally defines 1536c87b03e5Sespie * __restrict as restrict iff __c99. This is wrong for C++, which 1537c87b03e5Sespie * needs many C99 features, but only supports __restrict. 1538c87b03e5Sespie */ 1539c87b03e5Sespiefix = { 1540c87b03e5Sespie hackname = irix___restrict; 1541c87b03e5Sespie files = internal/sgimacros.h; 1542c87b03e5Sespie select = "(#ifdef __c99\n)(#[ \t]*define __restrict restrict)"; 1543c87b03e5Sespie 1544c87b03e5Sespie mach = "mips-sgi-irix6.5"; 1545c87b03e5Sespie c_fix = format; 1546c87b03e5Sespie c_fix_arg = "%1" 1547c87b03e5Sespie "# ifndef __cplusplus\n%2\n# endif"; 1548c87b03e5Sespie 1549c87b03e5Sespie test_text = "#ifdef __c99\n# define __restrict restrict"; 1550c87b03e5Sespie}; 1551c87b03e5Sespie 1552c87b03e5Sespie/* 15534e43c760Sespie * IRIX 6.5.22 <internal/math_core.h> uses the SGI c99 __generic() intrinsic 15544e43c760Sespie * to define the fpclasify, isfinite, isinf, isnan, isnormal and signbit 15554e43c760Sespie * functions. 15564e43c760Sespie * 15574e43c760Sespie * This was probably introduced around IRIX 6.5.18 15584e43c760Sespie */ 15594e43c760Sespiefix = { 15604e43c760Sespie hackname = irix___generic1; 15614e43c760Sespie files = internal/math_core.h; 15624e43c760Sespie mach = "mips-sgi-irix6.5"; 15634e43c760Sespie select = "#define ([a-z]+)\\(x\\) *__generic.*"; 15644e43c760Sespie 15654e43c760Sespie c_fix = format; 15664e43c760Sespie c_fix_arg = "extern int %1(double);\n" 15674e43c760Sespie "extern int %1f(float);\n" 15684e43c760Sespie "extern int %1l(long double);\n" 15694e43c760Sespie "#define %1(x) (sizeof(x) == sizeof(double) ? _%1(x) \\\n" 15704e43c760Sespie " : sizeof(x) == sizeof(float) ? _%1f(x) \\\n" 15714e43c760Sespie " : _%1l(x))\n"; 15724e43c760Sespie 15734e43c760Sespie test_text = 15744e43c760Sespie "#define isnan(x) __generic(x,,, _isnan, _isnanf, _isnanl,,,)(x)\n"; 15754e43c760Sespie}; 15764e43c760Sespie 15774e43c760Sespie 15784e43c760Sespie/* Likewise <internal/math_core.h> on IRIX 6.5.19 and later uses the SGI 15794e43c760Sespie compiler's __generic intrinsic to define isgreater, isgreaterequal, 15804e43c760Sespie isless, islessequal, islessgreater and isunordered functions. */ 15814e43c760Sespiefix = { 15824e43c760Sespie hackname = irix___generic2; 15834e43c760Sespie files = internal/math_core.h; 15844e43c760Sespie mach = "mips-sgi-irix6.5"; 15854e43c760Sespie select = "#define ([a-z]+)\\(x,y\\) *__generic.*"; 15864e43c760Sespie 15874e43c760Sespie c_fix = format; 15884e43c760Sespie c_fix_arg = "#define %1(x,y) \\\n" 15894e43c760Sespie " ((sizeof(x)<=4 && sizeof(y)<=4) ? _%1f(x,y) \\\n" 15904e43c760Sespie " : (sizeof(x)<=8 && sizeof(y)<=8) ? _%1(x,y) \\\n" 15914e43c760Sespie " : _%1l(x,y))\n"; 15924e43c760Sespie 15934e43c760Sespie test_text = 15944e43c760Sespie "#define isless(x,y) __generic(x,y,, _isless, _islessf, _islessl,,,)(x,y)"; 15954e43c760Sespie}; 15964e43c760Sespie 15974e43c760Sespie 15984e43c760Sespie/* 1599c87b03e5Sespie * IRIX 5.2's <sys/asm.h> contains an asm comment with a contraction 1600c87b03e5Sespie * that causes the assembly preprocessor to complain about an 1601c87b03e5Sespie * unterminated character constant. 1602c87b03e5Sespie */ 1603c87b03e5Sespiefix = { 1604c87b03e5Sespie hackname = irix_asm_apostrophe; 1605c87b03e5Sespie files = sys/asm.h; 1606c87b03e5Sespie 1607c87b03e5Sespie select = "^[ \t]*#.*[Ww]e're"; 1608c87b03e5Sespie c_fix = format; 1609c87b03e5Sespie c_fix_arg = "%1 are"; 1610c87b03e5Sespie c_fix_arg = "^([ \t]*#.*[Ww]e)'re"; 1611c87b03e5Sespie test_text = "\t# and we're on vacation"; 1612c87b03e5Sespie}; 1613c87b03e5Sespie 1614c87b03e5Sespie 1615c87b03e5Sespie/* 1616c87b03e5Sespie * Non-traditional "const" declaration in Irix's limits.h. 1617c87b03e5Sespie */ 1618c87b03e5Sespiefix = { 1619c87b03e5Sespie hackname = irix_limits_const; 1620c87b03e5Sespie files = fixinc-test-limits.h, limits.h; 1621c87b03e5Sespie select = "^extern const "; 1622c87b03e5Sespie c_fix = format; 1623c87b03e5Sespie c_fix_arg = "extern __const "; 1624c87b03e5Sespie test_text = "extern const char limit; /* test limits */"; 1625c87b03e5Sespie}; 1626c87b03e5Sespie 1627c87b03e5Sespie 1628c87b03e5Sespie/* 1629c87b03e5Sespie * IRIX 6.5.1[78] <sys/socket.h> has a broken definition of socklen_t. 1630c87b03e5Sespie * Various socket function prototypes use different types instead, 1631c87b03e5Sespie * depending on the API in use (BSD, XPG4/5), but the socklen_t 1632c87b03e5Sespie * definition doesn't reflect this (SGI Bug Id 864477, fixed in 1633c87b03e5Sespie * IRIX 6.5.19). 1634c87b03e5Sespie */ 1635c87b03e5Sespiefix = { 1636c87b03e5Sespie hackname = irix_socklen_t; 1637c87b03e5Sespie files = sys/socket.h; 1638c87b03e5Sespie select = "(#define _SOCKLEN_T\n)(typedef u_int32_t socklen_t;)"; 1639c87b03e5Sespie 1640c87b03e5Sespie mach = "mips-sgi-irix6.5"; 1641c87b03e5Sespie c_fix = format; 1642c87b03e5Sespie c_fix_arg = "%1" 1643c87b03e5Sespie "#if _NO_XOPEN4 && _NO_XOPEN5\n" 1644c87b03e5Sespie "typedef int socklen_t;\n" 1645c87b03e5Sespie "#else\n" 1646c87b03e5Sespie "%2\n" 1647c87b03e5Sespie "#endif /* _NO_XOPEN4 && _NO_XOPEN5 */"; 1648c87b03e5Sespie 1649c87b03e5Sespie test_text = "#define _SOCKLEN_T\ntypedef u_int32_t socklen_t;"; 1650c87b03e5Sespie}; 1651c87b03e5Sespie 1652c87b03e5Sespie/* 1653c87b03e5Sespie * IRIX 5.x's stdio.h and IRIX 6.5's internal/stdio_core.h declare 1654c87b03e5Sespie * some functions that take a va_list as 1655c87b03e5Sespie * taking char *. However, GCC uses void * for va_list, so 1656c87b03e5Sespie * calling vfprintf with a va_list fails in C++. */ 1657c87b03e5Sespiefix = { 1658c87b03e5Sespie hackname = irix_stdio_va_list; 1659c87b03e5Sespie files = stdio.h; 1660c87b03e5Sespie files = internal/stdio_core.h; 1661c87b03e5Sespie 1662c87b03e5Sespie select = '/\* va_list \*/ char \*'; 1663c87b03e5Sespie c_fix = format; 1664c87b03e5Sespie c_fix_arg = "__gnuc_va_list"; 1665c87b03e5Sespie test_text = 1666c87b03e5Sespie "extern int printf( const char *, /* va_list */ char * );"; 1667c87b03e5Sespie}; 1668c87b03e5Sespie 1669c87b03e5Sespie 1670c87b03e5Sespie/* 1671c87b03e5Sespie * IRIX 6.5.19 <internal/wchar_core.h> provides the XPG4 variant of 1672c87b03e5Sespie * wcsftime by default. ISO C99 requires the XPG5 variant instead. 1673c87b03e5Sespie */ 1674c87b03e5Sespiefix = { 1675c87b03e5Sespie hackname = irix_wcsftime; 1676c87b03e5Sespie files = internal/wchar_core.h; 1677c87b03e5Sespie select = "#if _NO_XOPEN5\n(extern size_t[ \t]+wcsftime.*const char \*.*)"; 1678c87b03e5Sespie 1679c87b03e5Sespie mach = "mips-sgi-irix6.5"; 1680c87b03e5Sespie c_fix = format; 1681c87b03e5Sespie c_fix_arg = "#if _NO_XOPEN5 && !defined(__c99)\n%1"; 1682c87b03e5Sespie 1683c87b03e5Sespie test_text = "#if _NO_XOPEN5\n" 1684c87b03e5Sespie "extern size_t wcsftime(wchar_t *, __SGI_LIBC_NAMESPACE_QUALIFIER size_t, const char *, const struct tm *);"; 1685c87b03e5Sespie}; 1686c87b03e5Sespie 1687c87b03e5Sespie/* 1688c87b03e5Sespie * Fixing ISC fmod declaration 1689c87b03e5Sespie */ 1690c87b03e5Sespiefix = { 1691c87b03e5Sespie hackname = isc_fmod; 1692c87b03e5Sespie files = math.h; 1693c87b03e5Sespie select = 'fmod\(double\)'; 1694c87b03e5Sespie c_fix = format; 1695c87b03e5Sespie c_fix_arg = "fmod(double, double)"; 1696c87b03e5Sespie test_text = "extern double fmod(double);"; 1697c87b03e5Sespie}; 1698c87b03e5Sespie 1699c87b03e5Sespie 1700c87b03e5Sespie/* 1701c87b03e5Sespie * On Interactive Unix 2.2, certain traditional Unix definitions 1702c87b03e5Sespie * (notably getc and putc in stdio.h) are omitted if __STDC__ is 1703c87b03e5Sespie * defined, not just if _POSIX_SOURCE is defined. This makes it 1704c87b03e5Sespie * impossible to compile any nontrivial program except with -posix. 1705c87b03e5Sespie */ 1706c87b03e5Sespiefix = { 1707c87b03e5Sespie hackname = isc_omits_with_stdc; 1708c87b03e5Sespie 1709c87b03e5Sespie files = "stdio.h"; 1710c87b03e5Sespie files = "math.h"; 1711c87b03e5Sespie files = "ctype.h"; 1712c87b03e5Sespie files = "sys/limits.h"; 1713c87b03e5Sespie files = "sys/fcntl.h"; 1714c87b03e5Sespie files = "sys/dirent.h"; 1715c87b03e5Sespie 1716c87b03e5Sespie select = '!defined\(__STDC__\) && !defined\(_POSIX_SOURCE\)'; 1717c87b03e5Sespie c_fix = format; 1718c87b03e5Sespie c_fix_arg = '!defined(_POSIX_SOURCE)'; 1719c87b03e5Sespie test_text = "#if !defined(__STDC__) && !defined(_POSIX_SOURCE) /* ? ! */" 1720c87b03e5Sespie "\nint foo;\n#endif"; 1721c87b03e5Sespie}; 1722c87b03e5Sespie 1723c87b03e5Sespie 1724c87b03e5Sespie/* 1725c87b03e5Sespie * These files in Sun OS 4.x and ARM/RISCiX and BSD4.3 1726c87b03e5Sespie * use / * * / to concatenate tokens. 1727c87b03e5Sespie */ 1728c87b03e5Sespiefix = { 1729c87b03e5Sespie hackname = kandr_concat; 1730c87b03e5Sespie files = "sparc/asm_linkage.h"; 1731c87b03e5Sespie files = "sun3/asm_linkage.h"; 1732c87b03e5Sespie files = "sun3x/asm_linkage.h"; 1733c87b03e5Sespie files = "sun4/asm_linkage.h"; 1734c87b03e5Sespie files = "sun4c/asm_linkage.h"; 1735c87b03e5Sespie files = "sun4m/asm_linkage.h"; 1736c87b03e5Sespie files = "sun4c/debug/asm_linkage.h"; 1737c87b03e5Sespie files = "sun4m/debug/asm_linkage.h"; 1738c87b03e5Sespie files = "arm/as_support.h"; 1739c87b03e5Sespie files = "arm/mc_type.h"; 1740c87b03e5Sespie files = "arm/xcb.h"; 1741c87b03e5Sespie files = "dev/chardefmac.h"; 1742c87b03e5Sespie files = "dev/ps_irq.h"; 1743c87b03e5Sespie files = "dev/screen.h"; 1744c87b03e5Sespie files = "dev/scsi.h"; 1745c87b03e5Sespie files = "sys/tty.h"; 1746c87b03e5Sespie files = "Xm.acorn/XmP.h"; 1747c87b03e5Sespie files = bsd43/bsd43_.h; 1748c87b03e5Sespie select = '/\*\*/'; 1749c87b03e5Sespie c_fix = format; 1750c87b03e5Sespie c_fix_arg = '##'; 1751c87b03e5Sespie test_text = "#define __CONCAT__(a,b) a/**/b"; 1752c87b03e5Sespie}; 1753c87b03e5Sespie 1754c87b03e5Sespie 1755c87b03e5Sespie/* 1756c87b03e5Sespie * Fix libc1 _G_va_list definition, used in declarations of several 1757c87b03e5Sespie * more-or-less standard functions, for example vasprintf. 1758c87b03e5Sespie */ 1759c87b03e5Sespiefix = { 1760c87b03e5Sespie hackname = libc1_G_va_list; 1761c87b03e5Sespie files = _G_config.h; 1762c87b03e5Sespie mach = '*-*-linux*libc1'; 1763c87b03e5Sespie select = 'typedef void \* _G_va_list;'; 1764c87b03e5Sespie c_fix = format; 1765c87b03e5Sespie c_fix_arg = "typedef __builtin_va_list _G_va_list;"; 1766c87b03e5Sespie test_text = 'typedef void * _G_va_list;'; 1767c87b03e5Sespie}; 1768c87b03e5Sespie 1769c87b03e5Sespie 1770c87b03e5Sespie/* 1771c87b03e5Sespie * GNU libc1 string.h does not prototype memcpy and memcmp for gcc 1772c87b03e5Sespie * versions > 1. This fix will open up the declaration for all 1773c87b03e5Sespie * versions of GCC and for g++. 1774c87b03e5Sespie */ 1775c87b03e5Sespiefix = { 1776c87b03e5Sespie hackname = libc1_ifdefd_memx; 1777c87b03e5Sespie 1778c87b03e5Sespie /* The string.h result is overwritten by AAB_ultrix_string when doing 1779c87b03e5Sespie "make check" and will fail. Therefore, we add the following kludgery 1780c87b03e5Sespie to insert the test_text into the special testing header. :-} */ 1781c87b03e5Sespie files = testing.h; 1782c87b03e5Sespie files = string.h; 1783c87b03e5Sespie 1784c87b03e5Sespie c_fix = format; 1785c87b03e5Sespie select = "' is a built-in function for gcc 2\\.x\\. \\*/"; 1786c87b03e5Sespie bypass = __cplusplus; 1787c87b03e5Sespie c_fix_arg = "%1"; 1788c87b03e5Sespie c_fix_arg = 1789c87b03e5Sespie '/\* `mem...\' is a built-in function for gcc 2\.x\. \*/' "\n" 1790c87b03e5Sespie '#if defined\(__STDC__\) && __GNUC__ < 2' "\n" 1791c87b03e5Sespie "(/\\* .* \\*/\n" 1792c87b03e5Sespie "extern [a-z_]+ mem.*(\n[^#].*)*;)\n" 1793c87b03e5Sespie "#endif"; 1794c87b03e5Sespie 1795c87b03e5Sespie test_text = 1796c87b03e5Sespie "/* \\`memcpy' is a built-in function for gcc 2.x. */\n" 1797c87b03e5Sespie "#if defined(__STDC__) && __GNUC__ < 2\n" 1798c87b03e5Sespie "/* Copy N bytes of SRC to DEST. */\n" 1799c87b03e5Sespie "extern __ptr_t memcpy __P ((__ptr_t __dest, __const __ptr_t __src,\n" 1800c87b03e5Sespie " size_t __n));\n" 1801c87b03e5Sespie "#endif"; 1802c87b03e5Sespie}; 1803c87b03e5Sespie 1804c87b03e5Sespie 1805c87b03e5Sespie/* 1806c87b03e5Sespie * In limits.h, put #ifndefs around things that are supposed to be defined 1807c87b03e5Sespie * in float.h to avoid redefinition errors if float.h is included first. 1808c87b03e5Sespie * On HP/UX this patch does not work, because on HP/UX limits.h uses 1809c87b03e5Sespie * multi line comments and the inserted #endif winds up inside the 1810c87b03e5Sespie * comment. Fortunately, HP/UX already uses #ifndefs in limits.h; if 1811c87b03e5Sespie * we find a #ifndef FLT_MIN we assume that all the required #ifndefs 1812c87b03e5Sespie * are there, and we do not add them ourselves. 1813c87b03e5Sespie * 1814c87b03e5Sespie * QNX Software Systems also guards the defines, but doesn't define 1815c87b03e5Sespie * FLT_MIN. Therefore, bypass the fix for *either* guarded FLT_MIN 1816c87b03e5Sespie * or guarded FLT_MAX. 1817c87b03e5Sespie */ 1818c87b03e5Sespiefix = { 1819c87b03e5Sespie hackname = limits_ifndefs; 1820c87b03e5Sespie files = "sys/limits.h"; 1821c87b03e5Sespie files = "limits.h"; 1822c87b03e5Sespie bypass = "ifndef[ \t]+FLT_(MIN|MAX)"; 1823c87b03e5Sespie 1824c87b03e5Sespie c_fix = format; 1825c87b03e5Sespie c_fix_arg = "#ifndef %1\n%0\n#endif"; 1826c87b03e5Sespie c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+" 1827c87b03e5Sespie "((FLT|DBL)_(MIN|MAX|DIG))[ \t].*"; 1828c87b03e5Sespie test_text = " #\tdefine\tDBL_DIG \t 0 /* somthin' */"; 1829c87b03e5Sespie}; 1830c87b03e5Sespie 1831c87b03e5Sespie 1832c87b03e5Sespie/* 1833c87b03e5Sespie * Delete the '#define void int' line from curses.h on Lynx 1834c87b03e5Sespie */ 1835c87b03e5Sespiefix = { 1836c87b03e5Sespie hackname = lynx_void_int; 1837c87b03e5Sespie files = curses.h; 1838c87b03e5Sespie select = "#[ \t]*define[ \t]+void[ \t]+int[ \t]*"; 1839c87b03e5Sespie c_fix = format; 1840c87b03e5Sespie c_fix_arg = ""; 1841c87b03e5Sespie test_text = "# define\tvoid\tint \t/* curses foiled again */"; 1842c87b03e5Sespie}; 1843c87b03e5Sespie 1844c87b03e5Sespie 1845c87b03e5Sespie/* 1846c87b03e5Sespie * Fix fcntl prototype in fcntl.h on LynxOS. 1847c87b03e5Sespie */ 1848c87b03e5Sespiefix = { 1849c87b03e5Sespie hackname = lynxos_fcntl_proto; 1850c87b03e5Sespie files = fcntl.h; 1851c87b03e5Sespie select = "fcntl[ \t]*" '\(int, int, int\)'; 1852c87b03e5Sespie c_fix = format; 1853c87b03e5Sespie c_fix_arg = '%1...)'; 1854c87b03e5Sespie c_fix_arg = "(fcntl[ \t]*" '\(int, int, )int\)'; 1855c87b03e5Sespie test_text = "extern int fcntl(int, int, int);"; 1856c87b03e5Sespie}; 1857c87b03e5Sespie 1858c87b03e5Sespie 1859c87b03e5Sespie/* 1860c87b03e5Sespie * libm.a on m88k-motorola-sysv3 contains a stupid optimization for 1861c87b03e5Sespie * function hypot(), which returns the second argument without even 1862c87b03e5Sespie * looking at its value, if the other is 0.0. 1863c87b03e5Sespie */ 1864c87b03e5Sespiefix = { 1865c87b03e5Sespie hackname = m88k_bad_hypot_opt; 1866c87b03e5Sespie mach = "m88k-motorola-sysv3*"; 1867c87b03e5Sespie files = "math.h"; 1868c87b03e5Sespie select = "^extern double hypot\\(\\);\n"; 1869c87b03e5Sespie c_fix = format; 1870c87b03e5Sespie c_fix_arg = "%0" 1871c87b03e5Sespie "/* Workaround a stupid Motorola optimization if one\n" 1872c87b03e5Sespie " of x or y is 0.0 and the other is negative! */\n" 1873c87b03e5Sespie "#ifdef __STDC__\n" 1874c87b03e5Sespie "static __inline__ double fake_hypot (double x, double y)\n" 1875c87b03e5Sespie "#else\n" 1876c87b03e5Sespie "static __inline__ double fake_hypot (x, y)\n" 1877c87b03e5Sespie "\tdouble x, y;\n" 1878c87b03e5Sespie "#endif\n" 1879c87b03e5Sespie "{\n" 1880c87b03e5Sespie "\treturn fabs (hypot (x, y));\n" 1881c87b03e5Sespie "}\n" 1882c87b03e5Sespie "#define hypot\tfake_hypot\n"; 1883c87b03e5Sespie test_text = "extern double hypot();"; 1884c87b03e5Sespie}; 1885c87b03e5Sespie 1886c87b03e5Sespie 1887c87b03e5Sespie/* 1888c87b03e5Sespie * Fix incorrect S_IF* definitions on m88k-sysv3. 1889c87b03e5Sespie */ 1890c87b03e5Sespiefix = { 1891c87b03e5Sespie hackname = m88k_bad_s_if; 1892c87b03e5Sespie mach = "m88k-*-sysv3*"; 1893c87b03e5Sespie files = sys/stat.h; 1894c87b03e5Sespie select = "#define[ \t]+S_IS[A-Z]+\\(m\\)[ \t]+\\(m[ \t]*&"; 1895c87b03e5Sespie 1896c87b03e5Sespie c_fix = format; 1897c87b03e5Sespie c_fix_arg = '#define %1(m) (((m) & S_IFMT) == %2)'; 1898c87b03e5Sespie c_fix_arg = "#define[ \t]+(S_IS[A-Z]+)\\(m\\)[ \t]+" 1899c87b03e5Sespie "\\(m[ \t]*&[ \t]*" 1900c87b03e5Sespie "(S_IF[A-Z][A-Z][A-Z]+|0[0-9]+)" 1901c87b03e5Sespie "[ \t]*\\)"; 1902c87b03e5Sespie test_text = '#define S_ISREG(m) (m & S_IFREG) /* is regular? */'; 1903c87b03e5Sespie}; 1904c87b03e5Sespie 1905c87b03e5Sespie 1906c87b03e5Sespie/* 1907c87b03e5Sespie * Put cpp wrappers around these include files to avoid redeclaration 1908c87b03e5Sespie * errors during multiple inclusion on m88k-tektronix-sysv3. 1909c87b03e5Sespie */ 1910c87b03e5Sespiefix = { 1911c87b03e5Sespie hackname = m88k_multi_incl; 1912c87b03e5Sespie mach = "m88k-tektronix-sysv3*"; 1913c87b03e5Sespie files = "time.h"; 1914c87b03e5Sespie bypass = "#ifndef"; 1915c87b03e5Sespie c_fix = wrap; 1916c87b03e5Sespie test_text = ""; 1917c87b03e5Sespie}; 1918c87b03e5Sespie 1919c87b03e5Sespie 1920c87b03e5Sespie/* 1921c87b03e5Sespie * Fix BSD machine/ansi.h to use __builtin_va_list to define _BSD_VA_LIST_. 1922c87b03e5Sespie * 1923c87b03e5Sespie * On NetBSD, machine is a symbolic link to an architecture specific 1924c87b03e5Sespie * directory name, so we can't match a specific file name here. 1925c87b03e5Sespie */ 1926c87b03e5Sespiefix = { 1927c87b03e5Sespie hackname = machine_ansi_h_va_list; 1928c87b03e5Sespie select = "define[ \t]+_BSD_VA_LIST_[ \t]"; 1929c87b03e5Sespie bypass = '__builtin_va_list'; 1930c87b03e5Sespie 1931c87b03e5Sespie c_fix = format; 1932c87b03e5Sespie c_fix_arg = "%1__builtin_va_list"; 1933c87b03e5Sespie c_fix_arg = "(define[ \t]+_BSD_VA_LIST_[ \t]+).*"; 1934c87b03e5Sespie 1935c87b03e5Sespie test_text = " # define _BSD_VA_LIST_\tchar**"; 1936c87b03e5Sespie}; 1937c87b03e5Sespie 1938c87b03e5Sespie 1939c87b03e5Sespie/* 1940c87b03e5Sespie * Fix non-ansi machine name defines 1941c87b03e5Sespie */ 1942c87b03e5Sespiefix = { 1943c87b03e5Sespie hackname = machine_name; 1944c87b03e5Sespie c_test = machine_name; 1945c87b03e5Sespie c_fix = machine_name; 1946c87b03e5Sespie 1947c87b03e5Sespie test_text = "/* MACH_DIFF: */\n" 1948c87b03e5Sespie "#if defined( i386 ) || defined( sparc ) || defined( vax )" 1949c87b03e5Sespie "\n/* no uniform test, so be careful :-) */"; 1950c87b03e5Sespie}; 1951c87b03e5Sespie 1952c87b03e5Sespie 1953c87b03e5Sespie/* 1954c87b03e5Sespie * Some math.h files define struct exception, which conflicts with 1955c87b03e5Sespie * the class exception defined in the C++ file std/stdexcept.h. We 1956c87b03e5Sespie * redefine it to __math_exception. This is not a great fix, but I 1957c87b03e5Sespie * haven't been able to think of anything better. 1958c87b03e5Sespie * Note that we have to put the #ifdef/#endif blocks at beginning 1959c87b03e5Sespie * and end of file, because fixproto runs after us and may insert 1960c87b03e5Sespie * additional references to struct exception. 1961c87b03e5Sespie */ 1962c87b03e5Sespiefix = { 1963c87b03e5Sespie hackname = math_exception; 1964c87b03e5Sespie files = math.h; 1965c87b03e5Sespie select = "struct exception"; 1966c87b03e5Sespie bypass = 'We have a problem when using C\+\+'; 1967c87b03e5Sespie c_fix = wrap; 1968c87b03e5Sespie 1969c87b03e5Sespie c_fix_arg = "#ifdef __cplusplus\n" 1970c87b03e5Sespie "#define exception __math_exception\n" 1971c87b03e5Sespie "#endif\n"; 1972c87b03e5Sespie 1973c87b03e5Sespie c_fix_arg = "#ifdef __cplusplus\n" 1974c87b03e5Sespie "#undef exception\n" 1975c87b03e5Sespie "#endif\n"; 1976c87b03e5Sespie 1977c87b03e5Sespie test_text = "typedef struct exception t_math_exception;"; 1978c87b03e5Sespie}; 1979c87b03e5Sespie 1980c87b03e5Sespie 1981c87b03e5Sespie/* 1982c87b03e5Sespie * This looks pretty broken to me. ``dbl_max_def'' will contain 1983c87b03e5Sespie * "define DBL_MAX " at the start, when what we really want is just 1984c87b03e5Sespie * the value portion. Can't figure out how to write a test case 1985c87b03e5Sespie * for this either :-( 1986c87b03e5Sespie */ 1987c87b03e5Sespiefix = { 1988c87b03e5Sespie hackname = math_huge_val_from_dbl_max; 1989c87b03e5Sespie files = math.h; 1990c87b03e5Sespie 1991c87b03e5Sespie /* 1992c87b03e5Sespie * IF HUGE_VAL is defined to be DBL_MAX *and* DBL_MAX is _not_ defined 1993c87b03e5Sespie * in math.h, this fix applies. 1994c87b03e5Sespie */ 1995c87b03e5Sespie select = "define[ \t]+HUGE_VAL[ \t]+DBL_MAX"; 1996c87b03e5Sespie bypass = "define[ \t]+DBL_MAX"; 1997c87b03e5Sespie 1998c87b03e5Sespie shell = 1999c87b03e5Sespie /* 2000c87b03e5Sespie * See if we have a definition for DBL_MAX in float.h. 2001c87b03e5Sespie * If we do, we will replace the one in math.h with that one. 2002c87b03e5Sespie */ 2003c87b03e5Sespie 2004c87b03e5Sespie "\tdbl_max_def=`egrep 'define[ \t]+DBL_MAX[ \t]+.*' float.h " 2005c87b03e5Sespie "| sed 's/.*DBL_MAX[ \t]*//' 2>/dev/null`\n\n" 2006c87b03e5Sespie 2007c87b03e5Sespie "\tif ( test -n \"${dbl_max_def}\" ) > /dev/null 2>&1\n" 2008c87b03e5Sespie "\tthen sed -e '/define[ \t]*HUGE_VAL[ \t]*DBL_MAX/" 2009c87b03e5Sespie "s@DBL_MAX@'\"$dbl_max_def@\"\n" 2010c87b03e5Sespie "\telse cat\n" 2011c87b03e5Sespie "\tfi"; 2012c87b03e5Sespie 2013c87b03e5Sespie test_text = 2014c87b03e5Sespie "`echo '#define DBL_MAX\t3.1415e+9 /* really big */' >> float.h`\n" 2015c87b03e5Sespie "#define HUGE_VAL DBL_MAX"; 2016c87b03e5Sespie}; 2017c87b03e5Sespie 2018c87b03e5Sespie 2019c87b03e5Sespie/* 2020c87b03e5Sespie * In any case, put #ifndef .. #endif around #define HUGE_VAL in math.h. 2021c87b03e5Sespie */ 2022c87b03e5Sespiefix = { 2023c87b03e5Sespie hackname = math_huge_val_ifndef; 2024c87b03e5Sespie files = math.h; 2025c87b03e5Sespie files = math/math.h; 2026c87b03e5Sespie select = "define[ \t]+HUGE_VAL"; 2027c87b03e5Sespie 2028c87b03e5Sespie c_fix = format; 2029c87b03e5Sespie c_fix_arg = "#ifndef HUGE_VAL\n%0\n#endif"; 2030c87b03e5Sespie c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+HUGE_VAL[ \t].*"; 2031c87b03e5Sespie 2032c87b03e5Sespie test_text = "# define\tHUGE_VAL 3.4e+40"; 2033c87b03e5Sespie}; 2034c87b03e5Sespie 2035c87b03e5Sespie 2036c87b03e5Sespie/* 2037c87b03e5Sespie * nested comment 2038c87b03e5Sespie */ 2039c87b03e5Sespiefix = { 2040c87b03e5Sespie hackname = nested_auth_des; 2041c87b03e5Sespie files = rpc/rpc.h; 2042c87b03e5Sespie select = '(/\*.*rpc/auth_des\.h>.*)/\*'; 2043c87b03e5Sespie c_fix = format; 2044c87b03e5Sespie c_fix_arg = "%1*/ /*"; 2045c87b03e5Sespie test_text = "/*#include <rpc/auth_des.h> /* skip this */"; 2046c87b03e5Sespie}; 2047c87b03e5Sespie 2048c87b03e5Sespie 2049c87b03e5Sespie/* 2050c87b03e5Sespie * Fix nested comments in Motorola's <limits.h> and <sys/limits.h> 2051c87b03e5Sespie */ 2052c87b03e5Sespiefix = { 2053c87b03e5Sespie hackname = nested_motorola; 2054c87b03e5Sespie mach = "m68k-motorola-sysv*"; 2055c87b03e5Sespie files = sys/limits.h; 2056c87b03e5Sespie files = limits.h; 2057c87b03e5Sespie select = "max # bytes atomic in write|error value returned by Math lib"; 2058c87b03e5Sespie 2059c87b03e5Sespie sed = "s@^\\(#undef[ \t][ \t]*PIPE_BUF[ \t]*" 2060c87b03e5Sespie "/\\* max # bytes atomic in write to a\\)$@\\1 */@"; 2061c87b03e5Sespie sed = "s@\\(/\\*#define\tHUGE_VAL\t3.[0-9e+]* \\)" 2062c87b03e5Sespie "\\(/\\*error value returned by Math lib\\*/\\)$@\\1*/ \\2@"; 2063c87b03e5Sespie 2064c87b03e5Sespie test_text = 2065c87b03e5Sespie "#undef PIPE_BUF /* max # bytes atomic in write to a\n" 2066c87b03e5Sespie "\t\t/* PIPE */\n" 2067c87b03e5Sespie "/*#define\tHUGE_VAL\t3.9e+9 /*error value returned by Math lib*/"; 2068c87b03e5Sespie}; 2069c87b03e5Sespie 2070c87b03e5Sespie 2071c87b03e5Sespie/* 2072c87b03e5Sespie * Fixing nested comments in ISC <sys/limits.h> 2073c87b03e5Sespie */ 2074c87b03e5Sespiefix = { 2075c87b03e5Sespie hackname = nested_sys_limits; 2076c87b03e5Sespie files = sys/limits.h; 2077c87b03e5Sespie select = CHILD_MAX; 2078c87b03e5Sespie sed = "/CHILD_MAX/s,/\\* Max, Max,"; 2079c87b03e5Sespie sed = "/OPEN_MAX/s,/\\* Max, Max,"; 2080c87b03e5Sespie test_text = "/*\n#define CHILD_MAX 20 /* Max, Max, ... */ /*\n" 2081c87b03e5Sespie "#define OPEN_MAX 20 /* Max, Max, ... */\n"; 2082c87b03e5Sespie}; 2083c87b03e5Sespie 2084c87b03e5Sespie 2085c87b03e5Sespie/* 2086c87b03e5Sespie * fix bogus recursive stdlib.h in NEWS-OS 4.0C 2087c87b03e5Sespie */ 2088c87b03e5Sespiefix = { 2089c87b03e5Sespie hackname = news_os_recursion; 2090c87b03e5Sespie files = stdlib.h; 2091c87b03e5Sespie select = "[ \t]*#include <stdlib\\.h>.*"; 2092c87b03e5Sespie 2093c87b03e5Sespie c_fix = format; 2094c87b03e5Sespie c_fix_arg = "#ifdef BOGUS_RECURSION\n%0\n#endif"; 2095c87b03e5Sespie test_text = "#include <stdlib.h>"; 2096c87b03e5Sespie}; 2097c87b03e5Sespie 2098c87b03e5Sespie 2099c87b03e5Sespie/* 2100c87b03e5Sespie * NeXT 3.2 adds const prefix to some math functions. 2101c87b03e5Sespie * These conflict with the built-in functions. 2102c87b03e5Sespie */ 2103c87b03e5Sespiefix = { 2104c87b03e5Sespie hackname = next_math_prefix; 2105c87b03e5Sespie files = ansi/math.h; 2106c87b03e5Sespie select = "^extern[ \t]+double[ \t]+__const__[ \t]"; 2107c87b03e5Sespie 2108c87b03e5Sespie c_fix = format; 2109c87b03e5Sespie c_fix_arg = "extern double %1("; 2110c87b03e5Sespie c_fix_arg = "^extern[ \t]+double[ \t]+__const__[ \t]+([a-z]+)\\("; 2111c87b03e5Sespie 2112c87b03e5Sespie test_text = "extern\tdouble\t__const__\tmumble();"; 2113c87b03e5Sespie}; 2114c87b03e5Sespie 2115c87b03e5Sespie 2116c87b03e5Sespie/* 2117c87b03e5Sespie * NeXT 3.2 uses the word "template" as a parameter for some 2118c87b03e5Sespie * functions. GCC reports an invalid use of a reserved key word 2119c87b03e5Sespie * with the built-in functions. 2120c87b03e5Sespie */ 2121c87b03e5Sespiefix = { 2122c87b03e5Sespie hackname = next_template; 2123c87b03e5Sespie files = bsd/libc.h; 2124c87b03e5Sespie select = "[ \t]template\\)"; 2125c87b03e5Sespie 2126c87b03e5Sespie c_fix = format; 2127c87b03e5Sespie c_fix_arg = "(%1)"; 2128c87b03e5Sespie c_fix_arg = "\\(([^)]*)[ \t]template\\)"; 2129c87b03e5Sespie test_text = "extern mumble( char * template); /* fix */"; 2130c87b03e5Sespie}; 2131c87b03e5Sespie 2132c87b03e5Sespie 2133c87b03e5Sespie/* 2134c87b03e5Sespie * NeXT 3.2 includes the keyword volatile in the abort() and exit() 2135c87b03e5Sespie * function prototypes. That conflicts with the built-in functions. 2136c87b03e5Sespie */ 2137c87b03e5Sespiefix = { 2138c87b03e5Sespie hackname = next_volitile; 2139c87b03e5Sespie files = ansi/stdlib.h; 2140c87b03e5Sespie select = "^extern[ \t]+volatile[ \t]+void[ \t]"; 2141c87b03e5Sespie 2142c87b03e5Sespie c_fix = format; 2143c87b03e5Sespie c_fix_arg = "extern void %1("; 2144c87b03e5Sespie c_fix_arg = "^extern[ \t]+volatile[ \t]+void[ \t]+(exit|abort)\\("; 2145c87b03e5Sespie 2146c87b03e5Sespie test_text = "extern\tvolatile\tvoid\tabort();"; 2147c87b03e5Sespie}; 2148c87b03e5Sespie 2149c87b03e5Sespie 2150c87b03e5Sespie/* 2151c87b03e5Sespie * NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1. 2152c87b03e5Sespie * Note that version 3 of the NeXT system has wait.h in a different directory, 2153c87b03e5Sespie * so that this code won't do anything. But wait.h in version 3 has a 2154c87b03e5Sespie * conditional, so it doesn't need this fix. So everything is okay. 2155c87b03e5Sespie */ 2156c87b03e5Sespiefix = { 2157c87b03e5Sespie hackname = next_wait_union; 2158c87b03e5Sespie files = sys/wait.h; 2159c87b03e5Sespie 2160c87b03e5Sespie select = 'wait\(union wait'; 2161c87b03e5Sespie c_fix = format; 2162c87b03e5Sespie c_fix_arg = "wait(void"; 2163c87b03e5Sespie test_text = "extern pid_d wait(union wait*);"; 2164c87b03e5Sespie}; 2165c87b03e5Sespie 2166c87b03e5Sespie 2167c87b03e5Sespie/* 2168c87b03e5Sespie * a missing semi-colon at the end of the nodeent structure definition. 2169c87b03e5Sespie */ 2170c87b03e5Sespiefix = { 2171c87b03e5Sespie hackname = nodeent_syntax; 2172c87b03e5Sespie files = netdnet/dnetdb.h; 2173c87b03e5Sespie select = "char[ \t]*\\*na_addr[ \t]*$"; 2174c87b03e5Sespie c_fix = format; 2175c87b03e5Sespie c_fix_arg = "%0;"; 2176c87b03e5Sespie test_text = "char *na_addr\t"; 2177c87b03e5Sespie}; 2178c87b03e5Sespie 2179c87b03e5Sespie 2180c87b03e5Sespie/* 21814e43c760Sespie * obstack.h used casts as lvalues. 21824e43c760Sespie * 21834e43c760Sespie * We need to change postincrements of casted pointers (which are 21844e43c760Sespie * then dereferenced and assigned into) of the form 21854e43c760Sespie * 21864e43c760Sespie * *((TYPE*)PTRVAR)++ = (VALUE) 21874e43c760Sespie * 21884e43c760Sespie * into expressions like 21894e43c760Sespie * 21904e43c760Sespie * ((*((TYPE*)PTRVAR) = (VALUE)), (PTRVAR += sizeof (TYPE))) 21914e43c760Sespie * 21924e43c760Sespie * which is correct for the cases used in obstack.h since PTRVAR is 21934e43c760Sespie * of type char * and the value of the expression is not used. 21944e43c760Sespie */ 21954e43c760Sespiefix = { 21964e43c760Sespie hackname = obstack_lvalue_cast; 21974e43c760Sespie files = obstack.h; 21984e43c760Sespie select = '\*\(\(([^()]*)\*\)(.*)\)\+\+ = \(([^()]*)\)'; 21994e43c760Sespie c_fix = format; 22004e43c760Sespie c_fix_arg = "((*((%1*)%2) = (%3)), (%2 += sizeof (%1)))"; 22014e43c760Sespie test_text = "*((void **) (h)->next_free)++ = (aptr)"; 22024e43c760Sespie}; 22034e43c760Sespie 22044e43c760Sespie 22054e43c760Sespie/* 2206c87b03e5Sespie * sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by 2207c87b03e5Sespie * defining regex.h related types. This causes libg++ build and usage 2208c87b03e5Sespie * failures. Fixing this correctly requires checking and modifying 3 files. 2209c87b03e5Sespie */ 2210c87b03e5Sespiefix = { 2211c87b03e5Sespie hackname = osf_namespace_a; 2212c87b03e5Sespie files = reg_types.h; 2213c87b03e5Sespie files = sys/lc_core.h; 2214c87b03e5Sespie test = " -r reg_types.h"; 2215c87b03e5Sespie test = " -r sys/lc_core.h"; 2216c87b03e5Sespie test = " -n \"`grep '} regex_t;' reg_types.h`\""; 2217c87b03e5Sespie test = " -z \"`grep __regex_t regex.h`\""; 2218c87b03e5Sespie 2219c87b03e5Sespie c_fix = format; 2220c87b03e5Sespie c_fix_arg = "__%0"; 2221c87b03e5Sespie c_fix_arg = "reg(ex|off|match)_t"; 2222c87b03e5Sespie 2223c87b03e5Sespie test_text = "`touch sys/lc_core.h`" 2224c87b03e5Sespie "typedef struct {\n int stuff, mo_suff;\n} regex_t;\n" 2225c87b03e5Sespie "extern regex_t re;\n" 2226c87b03e5Sespie "extern regoff_t ro;\n" 2227c87b03e5Sespie "extern regmatch_t rm;\n"; 2228c87b03e5Sespie}; 2229c87b03e5Sespie 2230c87b03e5Sespiefix = { 2231c87b03e5Sespie hackname = osf_namespace_c; 2232c87b03e5Sespie files = regex.h; 2233c87b03e5Sespie test = " -r reg_types.h"; 2234c87b03e5Sespie test = " -r sys/lc_core.h"; 2235c87b03e5Sespie test = " -n \"`grep '} regex_t;' reg_types.h`\""; 2236c87b03e5Sespie test = " -z \"`grep __regex_t regex.h`\""; 2237c87b03e5Sespie 2238c87b03e5Sespie select = "#include <reg_types\.h>.*"; 2239c87b03e5Sespie c_fix = format; 2240c87b03e5Sespie c_fix_arg = "%0\n" 2241c87b03e5Sespie "typedef __regex_t\tregex_t;\n" 2242c87b03e5Sespie "typedef __regoff_t\tregoff_t;\n" 2243c87b03e5Sespie "typedef __regmatch_t\tregmatch_t;"; 2244c87b03e5Sespie 2245c87b03e5Sespie test_text = "#include <reg_types.h>"; 2246c87b03e5Sespie}; 2247c87b03e5Sespie 2248c87b03e5Sespie 2249c87b03e5Sespie/* 2250c87b03e5Sespie * Fix __page_size* declarations in pthread.h AIX 4.1.[34]. 2251c87b03e5Sespie * The original ones fail if uninitialized externs are not common. 2252c87b03e5Sespie * This is the default for all ANSI standard C++ compilers. 2253c87b03e5Sespie */ 2254c87b03e5Sespiefix = { 2255c87b03e5Sespie hackname = pthread_page_size; 2256c87b03e5Sespie files = pthread.h; 2257c87b03e5Sespie select = "^int __page_size"; 2258c87b03e5Sespie c_fix = format; 2259c87b03e5Sespie c_fix_arg = "extern %0"; 2260c87b03e5Sespie test_text = "int __page_size;"; 2261c87b03e5Sespie}; 2262c87b03e5Sespie 2263c87b03e5Sespie 2264c87b03e5Sespie/* 2265c87b03e5Sespie * Fix return type of fread and fwrite on sysV68 2266c87b03e5Sespie */ 2267c87b03e5Sespiefix = { 2268c87b03e5Sespie hackname = read_ret_type; 2269c87b03e5Sespie files = stdio.h; 2270c87b03e5Sespie select = "extern int\t.*, fread\\(\\), fwrite\\(\\)"; 2271c87b03e5Sespie c_fix = format; 2272c87b03e5Sespie c_fix_arg = "extern unsigned int fread(), fwrite();\n%1%2"; 2273c87b03e5Sespie c_fix_arg = "(extern int\t.*), fread\\(\\), fwrite\\(\\)(.*)"; 2274c87b03e5Sespie 2275c87b03e5Sespie test_text = "extern int\tfclose(), fflush(), fread(), fwrite(), foo();"; 2276c87b03e5Sespie}; 2277c87b03e5Sespie 2278c87b03e5Sespie 2279c87b03e5Sespie/* 2280*a67f0032Smiod * Fix casts as lvalues in glibc's <rpc/xdr.h>. 2281*a67f0032Smiod */ 2282*a67f0032Smiodfix = { 2283*a67f0032Smiod hackname = rpc_xdr_lvalue_cast_a; 2284*a67f0032Smiod files = rpc/xdr.h; 2285*a67f0032Smiod select = "#define[ \t]*IXDR_GET_LONG.*\\\\\n.*__extension__.*"; 2286*a67f0032Smiod c_fix = format; 2287*a67f0032Smiod c_fix_arg = "#define IXDR_GET_LONG(buf) ((long)IXDR_GET_U_INT32(buf))"; 2288*a67f0032Smiod test_text = "#define IXDR_GET_LONG(buf) \\\\\n" 2289*a67f0032Smiod "\t((long)ntohl((u_long)*__extension__((u_int32_t*)(buf))++))"; 2290*a67f0032Smiod}; 2291*a67f0032Smiod 2292*a67f0032Smiod 2293*a67f0032Smiodfix = { 2294*a67f0032Smiod hackname = rpc_xdr_lvalue_cast_b; 2295*a67f0032Smiod files = rpc/xdr.h; 2296*a67f0032Smiod select = "#define[ \t]*IXDR_PUT_LONG.*\\\\\n.*__extension__.*"; 2297*a67f0032Smiod c_fix = format; 2298*a67f0032Smiod c_fix_arg = "#define IXDR_PUT_LONG(buf, v) ((long)IXDR_PUT_INT32(buf, (long)(v)))"; 2299*a67f0032Smiod test_text = "#define IXDR_PUT_LONG(buf, v) \\\\\n" 2300*a67f0032Smiod "\t(*__extension__((u_int32_t*)(buf))++ = (long)htonl((u_long)(v)))"; 2301*a67f0032Smiod}; 2302*a67f0032Smiod 2303*a67f0032Smiod 2304*a67f0032Smiod/* 2305c87b03e5Sespie * function class(double x) conflicts with C++ keyword on rs/6000 2306c87b03e5Sespie */ 2307c87b03e5Sespiefix = { 2308c87b03e5Sespie hackname = rs6000_double; 2309c87b03e5Sespie files = math.h; 2310c87b03e5Sespie select = '[^a-zA-Z_]class\('; 2311c87b03e5Sespie 2312c87b03e5Sespie c_fix = format; 2313c87b03e5Sespie c_fix_arg = "#ifndef __cplusplus\n%0\n#endif"; 2314c87b03e5Sespie c_fix_arg = '^.*[^a-zA-Z_]class\(.*'; 2315c87b03e5Sespie 2316c87b03e5Sespie test_text = "extern int class();"; 2317c87b03e5Sespie}; 2318c87b03e5Sespie 2319c87b03e5Sespie 2320c87b03e5Sespie/* 2321c87b03e5Sespie * Wrong fchmod prototype on RS/6000. 2322c87b03e5Sespie */ 2323c87b03e5Sespiefix = { 2324c87b03e5Sespie hackname = rs6000_fchmod; 2325c87b03e5Sespie files = sys/stat.h; 2326c87b03e5Sespie select = 'fchmod\(char \*'; 2327c87b03e5Sespie c_fix = format; 2328c87b03e5Sespie c_fix_arg = "fchmod(int"; 2329c87b03e5Sespie test_text = "extern int fchmod(char *, mode_t);"; 2330c87b03e5Sespie}; 2331c87b03e5Sespie 2332c87b03e5Sespie 2333c87b03e5Sespie/* 2334c87b03e5Sespie * parameters conflict with C++ new on rs/6000 2335c87b03e5Sespie */ 2336c87b03e5Sespiefix = { 2337c87b03e5Sespie hackname = rs6000_param; 2338c87b03e5Sespie files = "stdio.h"; 2339c87b03e5Sespie files = "unistd.h"; 2340c87b03e5Sespie 2341c87b03e5Sespie select = 'rename\(const char \*old, const char \*new\)'; 2342c87b03e5Sespie c_fix = format; 2343c87b03e5Sespie c_fix_arg = 'rename(const char *_old, const char *_new)'; 2344c87b03e5Sespie 2345c87b03e5Sespie test_text = 'extern int rename(const char *old, const char *new);'; 2346c87b03e5Sespie}; 2347c87b03e5Sespie 2348c87b03e5Sespie 2349c87b03e5Sespie/* 2350c87b03e5Sespie * On OpenServer and on UnixWare 7, <math.h> uses the native compiler 2351c87b03e5Sespie * __builtin_generic. We fix that usage to use the GCC equivalent. 2352c87b03e5Sespie * It also has a plethora of inline functions that conflict with libstdc++. 2353c87b03e5Sespie */ 2354c87b03e5Sespiefix = { 2355c87b03e5Sespie hackname = sco_math; 2356c87b03e5Sespie files = math.h; 2357c87b03e5Sespie files = posix/math.h; 2358c87b03e5Sespie files = ansi/math.h; 2359c87b03e5Sespie files = xpg4/math.h; 2360c87b03e5Sespie files = xpg4v2/math.h; 2361c87b03e5Sespie files = xpg4plus/math.h; 2362c87b03e5Sespie files = ods_30_compat/math.h; 2363c87b03e5Sespie files = oldstyle/math.h; 2364c87b03e5Sespie select = "__builtin_generic"; 2365c87b03e5Sespie sed = "/#define.*__fp_class(a) \\\\/i\\\n" 2366c87b03e5Sespie "#ifndef __GNUC__\n"; 2367c87b03e5Sespie sed = 2368c87b03e5Sespie"/.*__builtin_generic/a\\\n" 2369c87b03e5Sespie"#else\\\n" 2370c87b03e5Sespie"#define __fp_class(a) \\\\\\\n" 2371c87b03e5Sespie" __builtin_choose_expr(__builtin_types_compatible_p(typeof(a),long double),\\\\\\\n" 2372c87b03e5Sespie" __fpclassifyl(a), \\\\\\\n" 2373c87b03e5Sespie" __builtin_choose_expr(__builtin_types_compatible_p(typeof(a), float), \\\\\\\n" 2374c87b03e5Sespie" __fpclassifyf(a),__fpclassify(a)))\\\n" 2375c87b03e5Sespie"#endif"; 2376c87b03e5Sespie 2377c87b03e5Sespie sed = "/extern \"C\\+\\+\"/N;" 2378c87b03e5Sespie "/inline double abs/i\\\n" 2379c87b03e5Sespie "#ifndef __GNUC__\n"; 2380c87b03e5Sespie sed = "/inline long double trunc/N;" 2381c87b03e5Sespie "/inline long double trunc.*}.*extern \"C\\+\\+\"/a\\\n" 2382c87b03e5Sespie "#endif /* ! __GNUC__ */"; 2383c87b03e5Sespie 2384c87b03e5Sespie test_text = 2385c87b03e5Sespie "#define __fp_class(a) \\\\\n" 2386c87b03e5Sespie " __builtin_generic(a,\"ld:__fplcassifyl;f:__fpclassifyf;:__fpclassify\")\n"; 2387c87b03e5Sespie 2388c87b03e5Sespie}; 2389c87b03e5Sespie 2390c87b03e5Sespie 2391c87b03e5Sespie/* 2392c87b03e5Sespie * On SCO OpenServer prior to 5.0.7MP1, <sys/regset.h> and <ieeefp.h> 2393c87b03e5Sespie * have a clash on struct _fpstate and struct fpstate. 2394c87b03e5Sespie */ 2395c87b03e5Sespiefix = { 2396c87b03e5Sespie hackname = sco_regset; 2397c87b03e5Sespie files = sys/regset.h; 2398c87b03e5Sespie mach = "*-*-sco3.2v5*"; 2399c87b03e5Sespie select = "(struct[ \t]+_*)fpstate"; 2400c87b03e5Sespie c_fix = format; 2401c87b03e5Sespie c_fix_arg = "%1rsfpstate"; 2402c87b03e5Sespie 2403c87b03e5Sespie test_text = 2404c87b03e5Sespie "union u_fps { struct\tfpstate { int whatever; } };\n" 2405c87b03e5Sespie "union _u_fps { struct _fpstate { int whatever; } };\n"; 2406c87b03e5Sespie}; 2407c87b03e5Sespie 2408c87b03e5Sespie 2409c87b03e5Sespie/* 2410c87b03e5Sespie * The string.h header file on SCO Open Server has some inline C++ functions 2411c87b03e5Sespie * that confuse and upset libstdc++ horribly. Protect them from being defined 2412c87b03e5Sespie * when using GCC. 2413c87b03e5Sespie */ 2414c87b03e5Sespiefix = { 2415c87b03e5Sespie hackname = sco_string; 2416c87b03e5Sespie files = ansi/string.h; 2417c87b03e5Sespie files = posix/string.h; 2418c87b03e5Sespie files = xpg4/string.h; 2419c87b03e5Sespie files = xpg4v2/string.h; 2420c87b03e5Sespie files = xpg4plus/string.h; 2421c87b03e5Sespie files = ods_30_compat/string.h; 2422c87b03e5Sespie files = oldstyle/string.h; 2423c87b03e5Sespie files = string.h; 2424c87b03e5Sespie mach = "*-*-sco3.2v5*"; 2425c87b03e5Sespie select = "inline char"; 2426c87b03e5Sespie sed = "/extern \"C\\+\\+\"/N;" 2427c87b03e5Sespie "/inline void.*memchr/i\\\n" 2428c87b03e5Sespie "#ifndef __GNUC__\n"; 2429c87b03e5Sespie sed = "/return.*strstr/N;" 2430c87b03e5Sespie "/return.*strstr.*}/a\\\n" 2431c87b03e5Sespie "#endif /* ! __GNUC__ */"; 2432c87b03e5Sespie 2433c87b03e5Sespie test_text = 2434c87b03e5Sespie "extern \"C++\" {\n" 2435c87b03e5Sespie "inline void *memchr(void *__1, int __2, size_t __3)\n" 2436c87b03e5Sespie " { return (void *)memchr((const void *)__1, __2, __3); }\n" 2437c87b03e5Sespie "inline char *strstr(char *__1, const char *__2)\n" 2438c87b03e5Sespie " { return (char *)strstr((const char *)__1, __2); }\n" 2439c87b03e5Sespie "}\n"; 2440c87b03e5Sespie}; 2441c87b03e5Sespie 2442c87b03e5Sespie 2443c87b03e5Sespie/* 2444c87b03e5Sespie * The static functions lstat() and fchmod() in <sys/stat.h> 2445c87b03e5Sespie * cause G++ grief since they're not wrapped in "if __cplusplus". 2446c87b03e5Sespie * 2447c87b03e5Sespie * On SCO OpenServer 5.0.0 through (at least) 5.0.5 <sys/stat.h> contains 2448c87b03e5Sespie * tiny static wrappers that aren't C++ safe. 2449c87b03e5Sespie */ 2450c87b03e5Sespiefix = { 2451c87b03e5Sespie hackname = sco_static_func; 2452c87b03e5Sespie files = sys/stat.h; 2453c87b03e5Sespie mach = "i?86-*-sco3.2*"; 2454c87b03e5Sespie select = "^static int"; 2455c87b03e5Sespie 2456c87b03e5Sespie sed = "/^static int/i\\\n" 2457c87b03e5Sespie "#if __cplusplus\\\n" 2458c87b03e5Sespie "extern \"C\" {\\\n" 2459c87b03e5Sespie "#endif /* __cplusplus */"; 2460c87b03e5Sespie 2461c87b03e5Sespie sed = "/^}$/a\\\n" 2462c87b03e5Sespie "#if __cplusplus\\\n" 2463c87b03e5Sespie " }\\\n" 2464c87b03e5Sespie "#endif /* __cplusplus */"; 2465c87b03e5Sespie 2466c87b03e5Sespie test_text = 2467c87b03e5Sespie "#ifdef __STDC__\n" 2468c87b03e5Sespie "static int\tstat(const char *__f, struct stat *__p) {\n" 2469c87b03e5Sespie "\treturn __stat32(__f, __p);\n" 2470c87b03e5Sespie "}\n\n# else /* !__STDC__ THIS FAILS ON BSD SYSTEMS */\n" 2471c87b03e5Sespie 2472c87b03e5Sespie "static int\tstat(__f, __p)\n" 2473c87b03e5Sespie "\tchar *__f;\n" 2474c87b03e5Sespie "\tstruct stat *__p;\n" 2475c87b03e5Sespie "{\n" 2476c87b03e5Sespie "\treturn __stat32(__f, __p);\n" 2477c87b03e5Sespie "}\n" 2478c87b03e5Sespie "#endif"; 2479c87b03e5Sespie}; 2480c87b03e5Sespie 2481c87b03e5Sespie 2482c87b03e5Sespie/* 2483c87b03e5Sespie * Fix prototype declaration of utime in sys/times.h. 2484c87b03e5Sespie * In 3.2v4.0 the const is missing. 2485c87b03e5Sespie */ 2486c87b03e5Sespiefix = { 2487c87b03e5Sespie hackname = sco_utime; 2488c87b03e5Sespie files = sys/times.h; 2489c87b03e5Sespie mach = "i?86-*-sco3.2v4*"; 2490c87b03e5Sespie 2491c87b03e5Sespie select = '\(const char \*, struct utimbuf \*\);'; 2492c87b03e5Sespie c_fix = format; 2493c87b03e5Sespie c_fix_arg = '(const char *, const struct utimbuf *);'; 2494c87b03e5Sespie 2495c87b03e5Sespie test_text = "extern int utime(const char *, struct utimbuf *);"; 2496c87b03e5Sespie}; 2497c87b03e5Sespie 2498c87b03e5Sespie 2499c87b03e5Sespie/* 2500c87b03e5Sespie * Sun Solaris 2.5.1, 2.6 defines PTHREAD_{MUTEX|COND}_INITIALIZER 2501c87b03e5Sespie * incorrectly, so we replace them with versions that correspond to 2502c87b03e5Sespie * the definition. We also explicitly name this fix "1" and the next 2503c87b03e5Sespie * fix "2" because this one does not deal with the last field. This 2504c87b03e5Sespie * fix needs to run before the next. 2505c87b03e5Sespie */ 2506c87b03e5Sespiefix = { 2507c87b03e5Sespie hackname = solaris_mutex_init_1; 2508c87b03e5Sespie select = '@\(#\)pthread.h' "[ \t]+1.1[0-9][ \t]+9[567]/[0-9/]+ SMI"; 2509c87b03e5Sespie files = pthread.h; 2510c87b03e5Sespie sed = "/define[ \t]*PTHREAD_MUTEX_INI/s/{0, 0,/{{{0}, 0}, {{{0}}},/\n" 2511c87b03e5Sespie "/define[ \t]*PTHREAD_COND_INI/s/{0,/{{{0},0},/"; 2512c87b03e5Sespie test_text = 2513c87b03e5Sespie '#ident "@(#)pthread.h 1.16 97/05/05 SMI"'"\n" 2514c87b03e5Sespie "#define PTHREAD_MUTEX_INITIALIZER\t{0, 0, 0}\n" 2515c87b03e5Sespie "#define PTHREAD_COND_INITIALIZER\t{0, 0} /* */\n"; 2516c87b03e5Sespie}; 2517c87b03e5Sespie 2518c87b03e5Sespie 2519c87b03e5Sespie/* 2520c87b03e5Sespie * Sun Solaris defines PTHREAD_MUTEX_INITIALIZER with a trailing 2521c87b03e5Sespie * "0" for the last field of the pthread_mutex_t structure, which is 2522c87b03e5Sespie * of type upad64_t, which itself is typedef'd to int64_t, but with 2523c87b03e5Sespie * __STDC__ defined (e.g. by -ansi) it is a union. So change the 2524c87b03e5Sespie * initializer to "{0}" instead 2525c87b03e5Sespie */ 2526c87b03e5Sespiefix = { 2527c87b03e5Sespie hackname = solaris_mutex_init_2; 2528c87b03e5Sespie select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI"; 2529c87b03e5Sespie files = pthread.h; 2530c87b03e5Sespie c_fix = format; 2531c87b03e5Sespie c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n" 2532c87b03e5Sespie "%0\n" 2533c87b03e5Sespie "#else\n" 2534c87b03e5Sespie "%1, {0}}%3\n" 2535c87b03e5Sespie "#endif"; 2536c87b03e5Sespie c_fix_arg = "(^#define[ \t]+PTHREAD_(MUTEX|COND)_INITIALIZER[ \t]+{.*)" 2537c87b03e5Sespie ",[ \t]*0}" "(|[ \t].*)$"; 2538c87b03e5Sespie test_text = 2539c87b03e5Sespie '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n" 2540c87b03e5Sespie "#define PTHREAD_MUTEX_INITIALIZER\t{{{0},0}, {{{0}}}, 0}\n" 2541c87b03e5Sespie "#define PTHREAD_COND_INITIALIZER\t{{{0}, 0}, 0}\t/* DEFAULTCV */\n" 2542c87b03e5Sespie "#define PTHREAD_RWLOCK_INITIALIZER\t" 2543c87b03e5Sespie "{0, 0, 0, {0, 0, 0}, {0, 0}, {0, 0}}"; 2544c87b03e5Sespie}; 2545c87b03e5Sespie 2546c87b03e5Sespie 2547c87b03e5Sespie/* 2548c87b03e5Sespie * Solaris 2.8 has what appears to be some gross workaround for 2549c87b03e5Sespie * some old version of their c++ compiler. G++ doesn't want it 2550c87b03e5Sespie * either, but doesn't want to be tied to SunPRO version numbers. 2551c87b03e5Sespie */ 2552c87b03e5Sespiefix = { 2553c87b03e5Sespie hackname = solaris_stdio_tag; 2554c87b03e5Sespie files = stdio_tag.h; 2555c87b03e5Sespie 2556c87b03e5Sespie select = '__cplusplus < 54321L'; 2557c87b03e5Sespie sed = 's/defined(__cplusplus) && (__cplusplus < 54321L)/0/'; 2558c87b03e5Sespie 2559c87b03e5Sespie test_text = "#if\tdefined(__cplusplus) && (__cplusplus < 54321L)"; 2560c87b03e5Sespie}; 2561c87b03e5Sespie 2562c87b03e5Sespie/* 2563c87b03e5Sespie * <widec.h> until Solaris 2.5.1 defines macros for a couple of <wchar.h> 2564c87b03e5Sespie * functions, breaking their prototypes if that file is included afterwards. 2565c87b03e5Sespie * Include <wchar.h> early to avoid this issue, as is done on Solaris 2.6 2566c87b03e5Sespie * and up. 2567c87b03e5Sespie */ 2568c87b03e5Sespiefix = { 2569c87b03e5Sespie hackname = solaris_widec; 2570c87b03e5Sespie files = widec.h; 2571c87b03e5Sespie mach = '*-*-solaris2.[0-5]'; 2572c87b03e5Sespie mach = '*-*-solaris2.[0-5].*'; 2573c87b03e5Sespie bypass = "include.*wchar\\.h"; 2574c87b03e5Sespie select = "#include <euc.h>"; 2575c87b03e5Sespie c_fix = format; 2576c87b03e5Sespie c_fix_arg = "%0\n#include <wchar.h>"; 2577c87b03e5Sespie test_text = "#include <euc.h>"; 2578c87b03e5Sespie}; 2579c87b03e5Sespie 2580c87b03e5Sespie 2581c87b03e5Sespie/* 2582c87b03e5Sespie * Add a `static' declaration of `getrnge' into <regexp.h>. 2583c87b03e5Sespie * 2584c87b03e5Sespie * Don't do this if there is already a `static void getrnge' declaration 2585c87b03e5Sespie * present, since this would cause a redeclaration error. Solaris 2.x has 2586c87b03e5Sespie * such a declaration. 2587c87b03e5Sespie */ 2588c87b03e5Sespie#ifdef SVR4 2589c87b03e5Sespiefix = { 2590c87b03e5Sespie hackname = static_getrnge; 2591c87b03e5Sespie files = regexp.h; 2592c87b03e5Sespie bypass = "static void getrnge"; 2593c87b03e5Sespie sed = "/^static int[ \t]*size;/c\\\n" 2594c87b03e5Sespie "static int size ;\\\n\\\n" 2595c87b03e5Sespie "static int getrnge ();"; 2596c87b03e5Sespie}; 2597c87b03e5Sespie#endif 2598c87b03e5Sespie 2599c87b03e5Sespie 2600c87b03e5Sespie/* 2601c87b03e5Sespie * a missing semi-colon at the end of the statsswtch structure definition. 2602c87b03e5Sespie */ 2603c87b03e5Sespiefix = { 2604c87b03e5Sespie hackname = statsswtch; 2605c87b03e5Sespie files = rpcsvc/rstat.h; 2606c87b03e5Sespie select = "boottime$"; 2607c87b03e5Sespie c_fix = format; 2608c87b03e5Sespie c_fix_arg = "boottime;"; 2609c87b03e5Sespie test_text = "struct statswtch {\n int boottime\n};"; 2610c87b03e5Sespie}; 2611c87b03e5Sespie 2612c87b03e5Sespie 2613c87b03e5Sespie/* 2614c87b03e5Sespie * Arrange for stdio.h to use stdarg.h to define __gnuc_va_list. 2615c87b03e5Sespie * On 4BSD-derived systems, stdio.h defers to machine/ansi.h; that's 2616c87b03e5Sespie * OK too. 2617c87b03e5Sespie */ 2618c87b03e5Sespiefix = { 2619c87b03e5Sespie hackname = stdio_stdarg_h; 2620c87b03e5Sespie files = stdio.h; 2621c87b03e5Sespie bypass = "include.*(stdarg\.h|machine/ansi\.h)"; 2622c87b03e5Sespie 2623c87b03e5Sespie c_fix = wrap; 2624c87b03e5Sespie 2625c87b03e5Sespie c_fix_arg = "#define __need___va_list\n#include <stdarg.h>\n"; 2626c87b03e5Sespie 2627c87b03e5Sespie test_text = ""; 2628c87b03e5Sespie}; 2629c87b03e5Sespie 2630c87b03e5Sespie 2631c87b03e5Sespie/* 2632c87b03e5Sespie * Don't use or define the name va_list in stdio.h. 2633c87b03e5Sespie * This is for ANSI and also to interoperate properly with gcc's 2634c87b03e5Sespie * varargs.h. Note _BSD_VA_LIST_ is dealt with elsewhere. The 2635c87b03e5Sespie * presence of __gnuc_va_list, __DJ_va_list, or _G_va_list is taken 2636c87b03e5Sespie * to indicate that the header knows what it's doing -- under SUSv2, 2637c87b03e5Sespie * stdio.h is required to define va_list, and we shouldn't break that. 2638c87b03e5Sespie */ 2639c87b03e5Sespiefix = { 2640c87b03e5Sespie hackname = stdio_va_list; 2641c87b03e5Sespie files = stdio.h; 2642c87b03e5Sespie files = internal/stdio_core.h; 2643c87b03e5Sespie files = internal/wchar_core.h; 2644c87b03e5Sespie bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list'; 2645c87b03e5Sespie 2646c87b03e5Sespie /* 2647c87b03e5Sespie * Use __gnuc_va_list in arg types in place of va_list. 2648c87b03e5Sespie * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A 2649c87b03e5Sespie * use __gnuc_va_list instead of __VA_LIST__. We're hoping the 2650c87b03e5Sespie * trailing parentheses and semicolon save all other systems from this. 2651c87b03e5Sespie * Define __not_va_list__ (something harmless and unused) 2652c87b03e5Sespie * instead of va_list. 2653c87b03e5Sespie * Don't claim to have defined va_list. 2654c87b03e5Sespie */ 26554e43c760Sespie sed = "s@[ \t]va_list @ __gnuc_va_list @\n" 26564e43c760Sespie "s@[ \t]va_list)@ __gnuc_va_list)@\n" 2657c87b03e5Sespie "s@(va_list)&@(__gnuc_va_list)\\&@\n" 2658c87b03e5Sespie "s@ _VA_LIST_));@ __gnuc_va_list));@\n" 2659c87b03e5Sespie "s@ __VA_LIST__));@ __gnuc_va_list));@\n" 2660c87b03e5Sespie "s@ va_list@ __not_va_list__@\n" 2661c87b03e5Sespie "s@\\*va_list@*__not_va_list__@\n" 2662c87b03e5Sespie "s@ __va_list)@ __gnuc_va_list)@\n" 2663c87b03e5Sespie "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;" 2664c87b03e5Sespie "@typedef \\1 __not_va_list__;@\n" 2665c87b03e5Sespie "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n" 2666c87b03e5Sespie "s@GNUC_VA_LIST@GNUC_Va_LIST@\n" 2667c87b03e5Sespie "s@_NEED___VA_LIST@_NEED___Va_LIST@\n" 2668c87b03e5Sespie "s@VA_LIST@DUMMY_VA_LIST@\n" 2669c87b03e5Sespie "s@_Va_LIST@_VA_LIST@"; 2670c87b03e5Sespie test_text = "extern void mumble( va_list);"; 2671c87b03e5Sespie}; 2672c87b03e5Sespie 2673c87b03e5Sespie 2674c87b03e5Sespie/* 2675c87b03e5Sespie * "!__STDC__" or "__STDC__==0" or "__STDC__!=1" or "__STDC__-0==0" 2676c87b03e5Sespie * is "!defined( __STRICT_ANSI__ )" 2677c87b03e5Sespie */ 2678c87b03e5Sespiefix = { 2679c87b03e5Sespie hackname = strict_ansi_not; 2680c87b03e5Sespie select = "^([ \t]*#[ \t]*if.*)" 2681c87b03e5Sespie "(!__STDC__" 2682c87b03e5Sespie "|__STDC__[ \t]*==[ \t]*0" 2683c87b03e5Sespie "|__STDC__[ \t]*!=[ \t]*1" 2684c87b03e5Sespie "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*0)"; 2685c87b03e5Sespie /* Tru64 UNIX V4.0F/V5.1 <standards.h> supports GCC usage of __STDC__. */ 2686c87b03e5Sespie bypass = 'GNU and MIPS C compilers define __STDC__ differently'; 2687c87b03e5Sespie /* GNU gmp.h uses "__STDC__ != 1" only if __SCO_VERSION__, which 2688c87b03e5Sespie is not defined by GCC, so it is safe. */ 2689c87b03e5Sespie bypass = '__SCO_VERSION__.*__STDC__ != 1'; 2690c87b03e5Sespie c_test = stdc_0_in_system_headers; 2691c87b03e5Sespie 2692c87b03e5Sespie c_fix = format; 2693c87b03e5Sespie c_fix_arg = "%1 !defined(__STRICT_ANSI__)"; 2694c87b03e5Sespie 2695c87b03e5Sespie test_text = "#if !__STDC__ \n" 2696c87b03e5Sespie "#if __STDC__ == 0\n" 2697c87b03e5Sespie "#if __STDC__ != 1\n" 2698c87b03e5Sespie "#if __STDC__ - 0 == 0" 2699c87b03e5Sespie "/* not std C */\nint foo;\n" 2700c87b03e5Sespie "\n#end-end-end-end-if :-)"; 2701c87b03e5Sespie}; 2702c87b03e5Sespie 2703c87b03e5Sespie/* 2704c87b03e5Sespie * "__STDC__-0==0" 2705c87b03e5Sespie * is "!defined( __STRICT_ANSI__ )" on continued #if-s 2706c87b03e5Sespie */ 2707c87b03e5Sespiefix = { 2708c87b03e5Sespie hackname = strict_ansi_not_ctd; 2709c87b03e5Sespie files = math.h, limits.h, stdio.h, signal.h, 2710c87b03e5Sespie stdlib.h, sys/signal.h, time.h; 2711c87b03e5Sespie /* 2712c87b03e5Sespie * Starting at the beginning of a line, skip white space and 2713c87b03e5Sespie * a leading "(" or "&&" or "||". One of those must be found. 2714c87b03e5Sespie * Then, zero, one or more copies of a "defined(_FOO_BAR_) &&" 2715c87b03e5Sespie * expression. If these are nested, then they must accumulate 2716c87b03e5Sespie * because we won't match any closing parentheses. Finally, 2717c87b03e5Sespie * after skipping over all that, we must then match our suspect 2718c87b03e5Sespie * phrase: "__STDC__-0==0" with or without white space. 2719c87b03e5Sespie */ 2720c87b03e5Sespie select = "^([ \t]*" '(\(|&&|\|\|)' 2721c87b03e5Sespie "([ \t(]*!*[ \t]*defined\\([a-zA-Z_0-9]+\\)[ \t]*[|&][|&])*" 2722c87b03e5Sespie "[ \t(]*)" 2723c87b03e5Sespie "(__STDC__[ \t]*(|-[ \t]*0[ \t]*)==[ \t]*0)"; 2724c87b03e5Sespie c_test = stdc_0_in_system_headers; 2725c87b03e5Sespie 2726c87b03e5Sespie c_fix = format; 2727c87b03e5Sespie c_fix_arg = "%1 !defined(__STRICT_ANSI__)"; 2728c87b03e5Sespie 2729c87b03e5Sespie test_text = "#if 1 && \\\\\n" 2730c87b03e5Sespie "&& defined(mumbling) |& (__STDC__ - 0 == 0) \\\\\n" 2731c87b03e5Sespie "( __STDC__ == 0 && !defined(_XOPEN_SOURCE) \\\\\n" 2732c87b03e5Sespie "|| __STDC__ - 0 == 0 ) /* not std C */\n" 2733c87b03e5Sespie "int foo;\n#endif"; 2734c87b03e5Sespie}; 2735c87b03e5Sespie 2736c87b03e5Sespie 2737c87b03e5Sespie/* 2738c87b03e5Sespie * "__STDC__!=0" or "__STDC__==1" or "__STDC__-0==1" 2739c87b03e5Sespie * is "defined( __STRICT_ANSI__ )" 2740c87b03e5Sespie */ 2741c87b03e5Sespiefix = { 2742c87b03e5Sespie hackname = strict_ansi_only; 2743c87b03e5Sespie select = "^([ \t]*#[ \t]*if.*)" 2744c87b03e5Sespie "(__STDC__[ \t]*!=[ \t]*0" 2745c87b03e5Sespie "|__STDC__[ \t]*==[ \t]*1" 2746c87b03e5Sespie "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*1" 2747c87b03e5Sespie "|__STDC__[ \t]*-[ \t]*0[ \t]*!=[ \t]*0)"; 2748c87b03e5Sespie c_test = stdc_0_in_system_headers; 2749c87b03e5Sespie 2750c87b03e5Sespie c_fix = format; 2751c87b03e5Sespie c_fix_arg = "%1 defined(__STRICT_ANSI__)"; 2752c87b03e5Sespie 2753c87b03e5Sespie test_text = "#if __STDC__ == 1 /* is std C\n */\nint foo;\n#endif"; 2754c87b03e5Sespie}; 2755c87b03e5Sespie 2756c87b03e5Sespie 2757c87b03e5Sespie/* 2758c87b03e5Sespie * IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s 2759c87b03e5Sespie * in prototype without previous definition. 2760c87b03e5Sespie */ 2761c87b03e5Sespiefix = { 2762c87b03e5Sespie hackname = struct_file; 2763c87b03e5Sespie files = rpc/xdr.h; 2764c87b03e5Sespie select = '^.*xdrstdio_create.*struct __file_s'; 2765c87b03e5Sespie c_fix = format; 2766c87b03e5Sespie c_fix_arg = "struct __file_s;\n%0"; 2767c87b03e5Sespie test_text = "extern void xdrstdio_create( struct __file_s* );"; 2768c87b03e5Sespie}; 2769c87b03e5Sespie 2770c87b03e5Sespie 2771c87b03e5Sespie/* 2772c87b03e5Sespie * IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr 2773c87b03e5Sespie * in prototype without previous definition. 2774c87b03e5Sespie */ 2775c87b03e5Sespiefix = { 2776c87b03e5Sespie hackname = struct_sockaddr; 2777c87b03e5Sespie files = rpc/auth.h; 2778c87b03e5Sespie select = "^.*authdes_create.*struct sockaddr"; 2779c87b03e5Sespie bypass = "<sys/socket\.h>"; 2780c87b03e5Sespie c_fix = format; 2781c87b03e5Sespie c_fix_arg = "struct sockaddr;\n%0"; 2782c87b03e5Sespie test_text = "extern AUTH* authdes_create( struct sockaddr* );"; 2783c87b03e5Sespie}; 2784c87b03e5Sespie 2785c87b03e5Sespie 2786c87b03e5Sespie/* 2787c87b03e5Sespie * Apply fix this to all OSs since this problem seems to effect 2788c87b03e5Sespie * more than just SunOS. 2789c87b03e5Sespie */ 2790c87b03e5Sespiefix = { 2791c87b03e5Sespie hackname = sun_auth_proto; 2792c87b03e5Sespie files = rpc/auth.h; 2793c87b03e5Sespie files = rpc/clnt.h; 2794c87b03e5Sespie files = rpc/svc.h; 2795c87b03e5Sespie files = rpc/xdr.h; 2796c87b03e5Sespie /* 2797c87b03e5Sespie * Select those files containing '(*name)()'. 2798c87b03e5Sespie */ 2799c87b03e5Sespie select = '\(\*[a-z][a-z_]*\)\(\)'; 2800c87b03e5Sespie 2801c87b03e5Sespie c_fix = format; 2802c87b03e5Sespie c_fix_arg = "#ifdef __cplusplus\n%1(...);%2\n" 2803c87b03e5Sespie "#else\n%1();%2\n#endif"; 2804c87b03e5Sespie c_fix_arg = '(.*\(\*[a-z][a-z_]*\))\(\);(.*)'; 2805c87b03e5Sespie 2806c87b03e5Sespie test_text = 2807c87b03e5Sespie "struct auth_t {\n" 2808c87b03e5Sespie " int (*name)(); /* C++ bad */\n" 2809c87b03e5Sespie "};"; 2810c87b03e5Sespie}; 2811c87b03e5Sespie 2812c87b03e5Sespie 2813c87b03e5Sespie/* 2814c87b03e5Sespie * Fix bogus #ifdef on SunOS 4.1. 2815c87b03e5Sespie */ 2816c87b03e5Sespiefix = { 2817c87b03e5Sespie hackname = sun_bogus_ifdef; 2818c87b03e5Sespie files = "hsfs/hsfs_spec.h"; 2819c87b03e5Sespie files = "hsfs/iso_spec.h"; 2820c87b03e5Sespie select = '#ifdef(.*\|\|.*)'; 2821c87b03e5Sespie c_fix = format; 2822c87b03e5Sespie c_fix_arg = "#if%1"; 2823c87b03e5Sespie 2824c87b03e5Sespie test_text = "#ifdef __i386__ || __vax__ || __sun4c__"; 2825c87b03e5Sespie}; 2826c87b03e5Sespie 2827c87b03e5Sespie 2828c87b03e5Sespie/* 2829c87b03e5Sespie * Fix the CAT macro in SunOS memvar.h. 2830c87b03e5Sespie */ 2831c87b03e5Sespiefix = { 2832c87b03e5Sespie hackname = sun_catmacro; 2833c87b03e5Sespie files = pixrect/memvar.h; 2834c87b03e5Sespie select = "^#define[ \t]+CAT\\(a,b\\).*"; 2835c87b03e5Sespie c_fix = format; 2836c87b03e5Sespie 2837c87b03e5Sespie c_fix_arg = 2838c87b03e5Sespie "#ifdef __STDC__\n" 2839c87b03e5Sespie "# define CAT(a,b) a##b\n" 2840c87b03e5Sespie "#else\n%0\n#endif"; 2841c87b03e5Sespie 2842c87b03e5Sespie test_text = 2843c87b03e5Sespie "#define CAT(a,b)\ta/**/b"; 2844c87b03e5Sespie}; 2845c87b03e5Sespie 2846c87b03e5Sespie 2847c87b03e5Sespie/* 2848c87b03e5Sespie * Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1. 2849c87b03e5Sespie * Also fix return type of {m,re}alloc in <malloc.h> on sysV68 2850c87b03e5Sespie */ 2851c87b03e5Sespiefix = { 2852c87b03e5Sespie hackname = sun_malloc; 2853c87b03e5Sespie files = malloc.h; 2854c87b03e5Sespie 2855c87b03e5Sespie sed = "s/typedef[ \t]char \\*\tmalloc_t/typedef void \\*\tmalloc_t/g"; 2856c87b03e5Sespie sed = "s/int[ \t][ \t]*free/void\tfree/g"; 2857c87b03e5Sespie sed = "s/char\\([ \t]*\\*[ \t]*malloc\\)/void\\1/g"; 2858c87b03e5Sespie sed = "s/char\\([ \t]*\\*[ \t]*realloc\\)/void\\1/g"; 2859c87b03e5Sespie sed = "s/char\\([ \t]*\\*[ \t]*calloc\\)/void\\1/g"; 2860c87b03e5Sespie 2861c87b03e5Sespie test_text = 2862c87b03e5Sespie "typedef char *\tmalloc_t;\n" 2863c87b03e5Sespie "int \tfree();\n" 2864c87b03e5Sespie "char*\tmalloc();\n" 2865c87b03e5Sespie "char*\tcalloc();\n" 2866c87b03e5Sespie "char*\trealloc();"; 2867c87b03e5Sespie}; 2868c87b03e5Sespie 2869c87b03e5Sespie 2870c87b03e5Sespie/* 2871c87b03e5Sespie * Check for yet more missing ';' in struct (in SunOS 4.0.x) 2872c87b03e5Sespie */ 2873c87b03e5Sespiefix = { 2874c87b03e5Sespie hackname = sun_rusers_semi; 2875c87b03e5Sespie files = rpcsvc/rusers.h; 2876c87b03e5Sespie select = "_cnt$"; 2877c87b03e5Sespie sed = "/^struct/,/^};/s/_cnt$/_cnt;/"; 2878c87b03e5Sespie test_text = "struct mumble\n int _cnt\n};"; 2879c87b03e5Sespie}; 2880c87b03e5Sespie 2881c87b03e5Sespie 2882c87b03e5Sespie/* 2883c87b03e5Sespie * signal.h on SunOS defines signal using (), 2884c87b03e5Sespie * which causes trouble when compiling with g++ -pedantic. 2885c87b03e5Sespie */ 2886c87b03e5Sespiefix = { 2887c87b03e5Sespie hackname = sun_signal; 2888c87b03e5Sespie files = sys/signal.h; 2889c87b03e5Sespie files = signal.h; 2890c87b03e5Sespie select = "^void\t" '\(\*signal\(\)\)\(\);.*'; 2891c87b03e5Sespie 2892c87b03e5Sespie c_fix = format; 2893c87b03e5Sespie c_fix_arg = 2894c87b03e5Sespie "#ifdef __cplusplus\n" 2895c87b03e5Sespie "void\t(*signal(...))(...);\n" 2896c87b03e5Sespie "#else\n%0\n#endif"; 2897c87b03e5Sespie 2898c87b03e5Sespie test_text = "void\t(*signal())();"; 2899c87b03e5Sespie}; 2900c87b03e5Sespie 2901c87b03e5Sespie 2902c87b03e5Sespie/* 2903c87b03e5Sespie * math.h on SunOS 4 puts the declaration of matherr before the definition 2904c87b03e5Sespie * of struct exception, so the prototype (added by fixproto) causes havoc. 2905c87b03e5Sespie */ 2906c87b03e5Sespiefix = { 2907c87b03e5Sespie hackname = sunos_matherr_decl; 2908c87b03e5Sespie files = math.h; 2909c87b03e5Sespie 2910c87b03e5Sespie /* If matherr has a prototype already, the header needs no fix. */ 2911c87b03e5Sespie bypass = 'matherr.*(struct exception|__MATH_EXCEPTION)'; 2912c87b03e5Sespie select = matherr; 2913c87b03e5Sespie 2914c87b03e5Sespie c_fix = wrap; 2915c87b03e5Sespie c_fix_arg = "struct exception;\n"; 2916c87b03e5Sespie 2917c87b03e5Sespie test_text = "extern int matherr();"; 2918c87b03e5Sespie}; 2919c87b03e5Sespie 2920c87b03e5Sespie 2921c87b03e5Sespie/* 2922c87b03e5Sespie * Correct the return type for strlen in strings.h in SunOS 4. 2923c87b03e5Sespie */ 2924c87b03e5Sespiefix = { 2925c87b03e5Sespie hackname = sunos_strlen; 2926c87b03e5Sespie files = strings.h; 2927c87b03e5Sespie select = "int[ \t]*strlen\\(\\);(.*)"; 2928c87b03e5Sespie c_fix = format; 2929c87b03e5Sespie c_fix_arg = "__SIZE_TYPE__ strlen();%1"; 2930c87b03e5Sespie test_text = " int\tstrlen(); /* string length */"; 2931c87b03e5Sespie}; 2932c87b03e5Sespie 2933c87b03e5Sespie 2934c87b03e5Sespie/* 2935c87b03e5Sespie * Solaris math.h and floatingpoint.h define __P without protection, 2936c87b03e5Sespie * which conflicts with the fixproto definition. The fixproto 2937c87b03e5Sespie * definition and the Solaris definition are used the same way. 2938c87b03e5Sespie */ 2939c87b03e5Sespiefix = { 2940c87b03e5Sespie hackname = svr4__p; 2941c87b03e5Sespie files = math.h; 2942c87b03e5Sespie files = floatingpoint.h; 2943c87b03e5Sespie select = "^#define[ \t]+__P.*"; 2944c87b03e5Sespie c_fix = format; 2945c87b03e5Sespie c_fix_arg = "#ifndef __P\n%0\n#endif"; 2946c87b03e5Sespie 2947c87b03e5Sespie test_text = "#define __P(a) a"; 2948c87b03e5Sespie}; 2949c87b03e5Sespie 2950c87b03e5Sespie 2951c87b03e5Sespie/* 2952c87b03e5Sespie * Disable apparent native compiler optimization cruft in SVR4.2 <string.h> 2953c87b03e5Sespie * that is visible to any ANSI compiler using this include. Simply 2954c87b03e5Sespie * delete the lines that #define some string functions to internal forms. 2955c87b03e5Sespie */ 2956c87b03e5Sespiefix = { 2957c87b03e5Sespie hackname = svr4_disable_opt; 2958c87b03e5Sespie files = string.h; 2959c87b03e5Sespie select = '#define.*__std_hdr_'; 2960c87b03e5Sespie sed = '/#define.*__std_hdr_/d'; 2961c87b03e5Sespie test_text = "#define strlen __std_hdr_strlen\n"; 2962c87b03e5Sespie}; 2963c87b03e5Sespie 2964c87b03e5Sespie 2965c87b03e5Sespie/* 2966c87b03e5Sespie * Conditionalize some of <sys/endian.h> on __GNUC__ and __GNUG__. 2967c87b03e5Sespie * On some systems (UnixWare 2, UnixWare 7), the file is byteorder.h 2968c87b03e5Sespie * but we still "hijack" it and redirect it to the GNU byteorder.h.. 2969c87b03e5Sespie */ 2970c87b03e5Sespie#ifdef SVR5 2971c87b03e5Sespiefix = { 2972c87b03e5Sespie hackname = svr4_endian; 2973c87b03e5Sespie files = sys/endian.h; 2974c87b03e5Sespie#ifdef LATER 2975c87b03e5Sespie /* 2976c87b03e5Sespie * since we emit our own sys/byteorder.h, 2977c87b03e5Sespie * this fix can never be applied to that file. 2978c87b03e5Sespie */ 2979c87b03e5Sespie files = sys/byteorder.h; 2980c87b03e5Sespie#endif 2981c87b03e5Sespie bypass = '__GNUC__'; 2982c87b03e5Sespie 2983c87b03e5Sespie sed = "/#\tifdef\t__STDC__/i\\\n" 2984c87b03e5Sespie "# if !defined (__GNUC__) && !defined (__GNUG__)\n"; 2985c87b03e5Sespie 2986c87b03e5Sespie sed = "/#\t\tinclude\t<sys\\/byteorder.h>/s/\t\t/ /"; 2987c87b03e5Sespie 2988c87b03e5Sespie sed = "/# include\t<sys\\/byteorder.h>/i\\\n" 2989c87b03e5Sespie "# endif /* !defined (__GNUC__) && !defined (__GNUG__) */\n"; 2990c87b03e5Sespie}; 2991c87b03e5Sespie#endif /* SVR5 */ 2992c87b03e5Sespie 2993c87b03e5Sespie 2994c87b03e5Sespie/* 2995c87b03e5Sespie * Remove useless extern keyword from struct forward declarations 2996c87b03e5Sespie * in <sys/stream.h> and <sys/strsubr.h> 2997c87b03e5Sespie */ 2998c87b03e5Sespie#ifdef SVR4 2999c87b03e5Sespiefix = { 3000c87b03e5Sespie hackname = svr4_extern_struct; 3001c87b03e5Sespie files = sys/stream.h; 3002c87b03e5Sespie files = sys/strsubr.h; 3003c87b03e5Sespie select = 'extern struct [a-z_]*;'; 3004c87b03e5Sespie sed = 's/extern struct \([a-z][a-z_]*\)/struct \1/'; 3005c87b03e5Sespie}; 3006c87b03e5Sespie#endif 3007c87b03e5Sespie 3008c87b03e5Sespie/* 3009c87b03e5Sespie * Fix declarations of `ftw' and `nftw' in <ftw.h>. On some/most SVR4 3010c87b03e5Sespie * systems the file <ftw.h> contains extern declarations of these 3011c87b03e5Sespie * functions followed by explicitly `static' definitions of these 3012c87b03e5Sespie * functions... and that's not allowed according to ANSI C. (Note 3013c87b03e5Sespie * however that on Solaris, this header file glitch has been pre-fixed by 3014c87b03e5Sespie * Sun. In the Solaris version of <ftw.h> there are no static 3015c87b03e5Sespie * definitions of any function so we don't need to do any of this stuff 3016c87b03e5Sespie * when on Solaris. 3017c87b03e5Sespie */ 3018c87b03e5Sespie#ifdef SVR4 3019c87b03e5Sespie#ifndef SOLARIS 3020c87b03e5Sespiefix = { 3021c87b03e5Sespie hackname = svr4_ftw; 3022c87b03e5Sespie files = ftw.h; 3023c87b03e5Sespie select = '^extern int ftw\(const'; 3024c87b03e5Sespie 3025c87b03e5Sespie sed = '/^extern int ftw(const/i' "\\\n" 3026c87b03e5Sespie "#if !defined(_STYPES)\\\n" 3027c87b03e5Sespie "static\\\n" 3028c87b03e5Sespie "#else\\\n" 3029c87b03e5Sespie "extern\\\n" 3030c87b03e5Sespie "#endif"; 3031c87b03e5Sespie sed = 's/extern \(int ftw(const.*\)$/\1/'; 3032c87b03e5Sespie sed = "/^extern int nftw/i\\\n" 3033c87b03e5Sespie "#if defined(_STYPES)\\\n" 3034c87b03e5Sespie "static\\\n" 3035c87b03e5Sespie "#else\\\n" 3036c87b03e5Sespie "extern\\\n" 3037c87b03e5Sespie "#endif"; 3038c87b03e5Sespie sed = 's/extern \(int nftw.*\)$/\1/'; 3039c87b03e5Sespie sed = "/^extern int ftw(),/c\\\n" 3040c87b03e5Sespie "#if !defined(_STYPES)\\\n" 3041c87b03e5Sespie "static\\\n" 3042c87b03e5Sespie "#else\\\n" 3043c87b03e5Sespie "extern\\\n" 3044c87b03e5Sespie "#endif\\\n" 3045c87b03e5Sespie " int ftw();\\\n" 3046c87b03e5Sespie "#if defined(_STYPES)\\\n" 3047c87b03e5Sespie "static\\\n" 3048c87b03e5Sespie "#else\\\n" 3049c87b03e5Sespie "extern\\\n" 3050c87b03e5Sespie "#endif\\\n" 3051c87b03e5Sespie " int nftw();"; 3052c87b03e5Sespie}; 3053c87b03e5Sespie#endif 3054c87b03e5Sespie#endif 3055c87b03e5Sespie 3056c87b03e5Sespie 3057c87b03e5Sespie/* 3058c87b03e5Sespie * Fix broken decl of getcwd present on some svr4 systems. 3059c87b03e5Sespie */ 3060c87b03e5Sespiefix = { 3061c87b03e5Sespie hackname = svr4_getcwd; 3062c87b03e5Sespie files = stdlib.h; 3063c87b03e5Sespie files = unistd.h; 3064c87b03e5Sespie files = prototypes.h; 3065c87b03e5Sespie select = 'getcwd\(char \*, int\)'; 3066c87b03e5Sespie 3067c87b03e5Sespie c_fix = format; 3068c87b03e5Sespie c_fix_arg = "getcwd(char *, size_t)"; 3069c87b03e5Sespie 3070c87b03e5Sespie test_text = "extern char* getcwd(char *, int);"; 3071c87b03e5Sespie}; 3072c87b03e5Sespie 3073c87b03e5Sespie 3074c87b03e5Sespie/* 3075c87b03e5Sespie * set ifdef _KERNEL 3076c87b03e5Sespie */ 3077c87b03e5Sespie#ifdef SVR4 3078c87b03e5Sespiefix = { 3079c87b03e5Sespie hackname = svr4_kernel; 3080c87b03e5Sespie files = fs/rfs/rf_cache.h; 3081c87b03e5Sespie files = sys/erec.h; 3082c87b03e5Sespie files = sys/err.h; 3083c87b03e5Sespie files = sys/char.h; 3084c87b03e5Sespie files = sys/getpages.h; 3085c87b03e5Sespie files = sys/map.h; 3086c87b03e5Sespie files = sys/cmn_err.h; 3087c87b03e5Sespie files = sys/kdebugger.h; 3088c87b03e5Sespie bypass = '_KERNEL'; 3089c87b03e5Sespie c_fix = wrap; 3090c87b03e5Sespie 3091c87b03e5Sespie c_fix_arg = "#ifdef _KERNEL\n"; 3092c87b03e5Sespie c_fix_arg = "#endif /* _KERNEL */\n"; 3093c87b03e5Sespie test_text = ""; 3094c87b03e5Sespie}; 3095c87b03e5Sespie#endif 3096c87b03e5Sespie 3097c87b03e5Sespie/* 3098c87b03e5Sespie * Delete any #defines of `__i386' which may be present in <ieeefp.h>. They 3099c87b03e5Sespie * tend to conflict with the compiler's own definition of this symbol. (We 3100c87b03e5Sespie * will use the compiler's definition.) 3101c87b03e5Sespie * Likewise __sparc, for Solaris, and __i860, and a few others 3102c87b03e5Sespie * (guessing it is necessary for all of them). 3103c87b03e5Sespie */ 3104c87b03e5Sespie#ifdef SVR4 3105c87b03e5Sespiefix = { 3106c87b03e5Sespie hackname = svr4_mach_defines; 3107c87b03e5Sespie files = ieeefp.h; 3108c87b03e5Sespie select = "#define[ \t]*__(i386|mips|sparc|m88k|m68k)[ \t]"; 3109c87b03e5Sespie sed = "/#define[ \t]*__\\(i386|mips|sparc|m88k|m68k\\)[ \t]/d"; 3110c87b03e5Sespie}; 3111c87b03e5Sespie#endif 3112c87b03e5Sespie 3113c87b03e5Sespie 3114c87b03e5Sespie/* 3115c87b03e5Sespie * Fix declarations of `makedev', `major', and `minor' in <sys/mkdev.h>. 3116c87b03e5Sespie * They are declared as non-static then immediately redeclared as static. 3117c87b03e5Sespie */ 3118c87b03e5Sespie#ifdef SVR5 3119c87b03e5Sespiefix = { 3120c87b03e5Sespie hackname = svr4_mkdev; 3121c87b03e5Sespie files = sys/mkdev.h; 3122c87b03e5Sespie select = '^static'; 3123c87b03e5Sespie 3124c87b03e5Sespie sed = "/^dev_t makedev(/s/^/static /"; 3125c87b03e5Sespie sed = "/^major_t major(/s/^/static /"; 3126c87b03e5Sespie sed = "/^minor_t minor(/s/^/static /"; 3127c87b03e5Sespie}; 3128c87b03e5Sespie#endif /* SVR5 */ 3129c87b03e5Sespie 3130c87b03e5Sespie 3131c87b03e5Sespie/* 3132c87b03e5Sespie * Fix reference to NC_NPI_RAW in <sys/netcspace.h>. 3133c87b03e5Sespie * Also fix types of array initializers. 3134c87b03e5Sespie */ 3135c87b03e5Sespie#ifdef SVR4 3136c87b03e5Sespiefix = { 3137c87b03e5Sespie hackname = svr4_netcspace; 3138c87b03e5Sespie files = sys/netcspace.h; 3139c87b03e5Sespie select = 'NC_NPI_RAW'; 3140c87b03e5Sespie sed = 's/NC_NPI_RAW/NC_TPI_RAW/g'; 3141c87b03e5Sespie sed = 's/NC_/(unsigned long) NC_/'; 3142c87b03e5Sespie}; 3143c87b03e5Sespie#endif 3144c87b03e5Sespie 3145c87b03e5Sespie/* 3146c87b03e5Sespie * Fix reference to NMSZ in <sys/adv.h>. 3147c87b03e5Sespie */ 3148c87b03e5Sespie#ifdef SVR4 3149c87b03e5Sespiefix = { 3150c87b03e5Sespie hackname = svr4_nmsz; 3151c87b03e5Sespie files = sys/adv.h; 3152c87b03e5Sespie select = '\[NMSZ\]'; 3153c87b03e5Sespie sed = 's/\[NMSZ\]/\[RFS_NMSZ\]/g'; 3154c87b03e5Sespie}; 3155c87b03e5Sespie#endif 3156c87b03e5Sespie 3157c87b03e5Sespie 3158c87b03e5Sespie/* 3159c87b03e5Sespie * Fix broken decl of profil present on some svr4 systems. 3160c87b03e5Sespie */ 3161c87b03e5Sespiefix = { 3162c87b03e5Sespie hackname = svr4_profil; 3163c87b03e5Sespie files = stdlib.h; 3164c87b03e5Sespie files = unistd.h; 3165c87b03e5Sespie 3166c87b03e5Sespie select = 3167c87b03e5Sespie 'profil\(unsigned short \*, unsigned int, unsigned int, unsigned int\)'; 3168c87b03e5Sespie c_fix = format; 3169c87b03e5Sespie c_fix_arg = 'profil(unsigned short *, size_t, int, unsigned int)'; 3170c87b03e5Sespie 3171c87b03e5Sespie test_text = 3172c87b03e5Sespie 'profil(unsigned short *, unsigned int, unsigned int, unsigned int);'; 3173c87b03e5Sespie}; 3174c87b03e5Sespie 3175c87b03e5Sespie 3176c87b03e5Sespie/* 3177c87b03e5Sespie * Convert functions to prototype form, and fix arg names in <sys/stat.h>. 3178c87b03e5Sespie */ 3179c87b03e5Sespie#ifdef SVR4 3180c87b03e5Sespiefix = { 3181c87b03e5Sespie hackname = svr4_proto_form; 3182c87b03e5Sespie files = sys/stat.h; 3183c87b03e5Sespie select = 'const extern'; 3184c87b03e5Sespie 3185c87b03e5Sespie sed = "/^stat([ \t]*[^c]/ {\nN\nN\n" 3186c87b03e5Sespie "s/(.*)\\n/( /\n" 3187c87b03e5Sespie "s/;\\n/, /\n" 3188c87b03e5Sespie "s/;$/)/\n" "}"; 3189c87b03e5Sespie 3190c87b03e5Sespie sed = "/^lstat([ \t]*[^c]/ {\nN\nN\n" 3191c87b03e5Sespie "s/(.*)\\n/( /\n" 3192c87b03e5Sespie "s/;\\n/, /\n" 3193c87b03e5Sespie "s/;$/)/\n" "}"; 3194c87b03e5Sespie 3195c87b03e5Sespie sed = "/^fstat([ \t]*[^i]/ {\nN\nN\n" 3196c87b03e5Sespie "s/(.*)\\n/( /\n" 3197c87b03e5Sespie "s/;\\n/, /\n" 3198c87b03e5Sespie "s/;$/)/\n" "}"; 3199c87b03e5Sespie 3200c87b03e5Sespie sed = "/^mknod([ \t]*[^c]/{\nN\nN\nN\n" 3201c87b03e5Sespie "s/(.*)\\n/( /\n" 3202c87b03e5Sespie "s/;\\n/, /g\n" 3203c87b03e5Sespie "s/;$/)/\n" "}"; 3204c87b03e5Sespie 3205c87b03e5Sespie sed = "1,$s/\\([^A-Za-z]\\)path\\([^A-Za-z]\\)/\\1__path\\2/g"; 3206c87b03e5Sespie sed = "1,$s/\\([^A-Za-z]\\)buf\\([^A-Za-z]\\)/\\1__buf\\2/g"; 3207c87b03e5Sespie sed = "1,$s/\\([^A-Za-z]\\)fd\\([^A-Za-z]\\)/\\1__fd\\2/g"; 3208c87b03e5Sespie sed = "1,$s/ret\\([^u]\\)/__ret\\1/g"; 3209c87b03e5Sespie sed = "1,$s/\\([^_]\\)mode\\([^_]\\)/\\1__mode\\2/g"; 3210c87b03e5Sespie sed = "1,$s/\\([^_r]\\)dev\\([^_]\\)/\\1__dev\\2/g"; 3211c87b03e5Sespie}; 3212c87b03e5Sespie#endif 3213c87b03e5Sespie 3214c87b03e5Sespie/* 3215c87b03e5Sespie * Add a prototyped declaration of mmap to <sys/mman.h>. 3216c87b03e5Sespie */ 3217c87b03e5Sespie#ifdef SVR4 3218c87b03e5Sespiefix = { 3219c87b03e5Sespie hackname = svr4_proto_mmap; 3220c87b03e5Sespie files = sys/mman.h; 3221c87b03e5Sespie select = '^extern caddr_t mmap();$'; 3222c87b03e5Sespie sed = '/^extern caddr_t mmap();$/c' "\\\n" 3223c87b03e5Sespie "#ifdef __STDC__\\\n" 3224c87b03e5Sespie "extern caddr_t mmap (caddr_t, size_t, int, int, int, off_t);\\\n" 3225c87b03e5Sespie "#else /* !defined(__STDC__) */\\\n" 3226c87b03e5Sespie "extern caddr_t mmap ();\\\n" 3227c87b03e5Sespie "#endif /* !defined(__STDC__) */\\\n"; 3228c87b03e5Sespie}; 3229c87b03e5Sespie#endif 3230c87b03e5Sespie 3231c87b03e5Sespie/* 3232c87b03e5Sespie * Add a #define of _SIGACTION_ into <sys/signal.h>. 3233c87b03e5Sespie */ 3234c87b03e5Sespie#ifdef SVR4 3235c87b03e5Sespiefix = { 3236c87b03e5Sespie hackname = svr4_sigaction; 3237c87b03e5Sespie files = sys/signal.h; 3238c87b03e5Sespie sed = "/^struct sigaction {/i\\\n" 3239c87b03e5Sespie "#define _SIGACTION_"; 3240c87b03e5Sespie sed = 's/(void *(\*)())/(void (*)(int))/'; 3241c87b03e5Sespie}; 3242c87b03e5Sespie#endif 3243c87b03e5Sespie 3244c87b03e5Sespie/* 3245c87b03e5Sespie * Put storage class at start of decl, to avoid warning. 3246c87b03e5Sespie */ 3247c87b03e5Sespie#ifdef SVR4 3248c87b03e5Sespiefix = { 3249c87b03e5Sespie hackname = svr4_storage_class; 3250c87b03e5Sespie files = rpc/types.h; 3251c87b03e5Sespie select = 'const extern'; 3252c87b03e5Sespie sed = 's/const extern/extern const/g'; 3253c87b03e5Sespie}; 3254c87b03e5Sespie#endif 3255c87b03e5Sespie 3256c87b03e5Sespie 3257c87b03e5Sespie/* 3258c87b03e5Sespie * Like svr4_mach_defines, but with newfangled syntax. 3259c87b03e5Sespie * Source lines are of #define __i386 #machine(i386). Delete them. 3260c87b03e5Sespie */ 3261c87b03e5Sespie#ifdef SVR5 3262c87b03e5Sespiefix = { 3263c87b03e5Sespie hackname = svr5_mach_defines; 3264c87b03e5Sespie files = ieeefp.h; 3265c87b03e5Sespie select = "#define[ \t]*__i386.*\(i386\)"; 3266c87b03e5Sespie sed = "/#define[ \t]*__i386.*/d"; 3267c87b03e5Sespie}; 3268c87b03e5Sespie#endif /* SVR5 */ 3269c87b03e5Sespie 3270c87b03e5Sespie 3271c87b03e5Sespie/* 3272c87b03e5Sespie * Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn} 3273c87b03e5Sespie * in string.h on sysV68 3274c87b03e5Sespie * Correct the return type for strlen in string.h on Lynx. 3275c87b03e5Sespie * Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0. 3276c87b03e5Sespie * Add missing const for strdup on OSF/1 V3.0. 3277c87b03e5Sespie * On sysV88 layout is slightly different. 3278c87b03e5Sespie */ 3279c87b03e5Sespiefix = { 3280c87b03e5Sespie hackname = sysv68_string; 3281c87b03e5Sespie files = testing.h; 3282c87b03e5Sespie files = string.h; 3283c87b03e5Sespie 3284c87b03e5Sespie sed = "s/extern[ \t]*int[ \t]*strlen();/extern unsigned int strlen();/"; 3285c87b03e5Sespie sed = "s/extern[ \t]*int[ \t]*ffs[ \t]*(long);/extern int ffs(int);/"; 3286c87b03e5Sespie sed = "s/strdup(char \\*s1);/strdup(const char *s1);/"; 3287c87b03e5Sespie 3288c87b03e5Sespie sed = "/^extern char$/N"; 3289c87b03e5Sespie sed = "s/^extern char\\(\\n\t\\*memccpy(),\\)$/extern void\\1/"; 3290c87b03e5Sespie 3291c87b03e5Sespie sed = "/^extern int$/N"; 3292c87b03e5Sespie sed = "s/^extern int\\(\\n\tstrlen(),\\)/extern size_t\\1/"; 3293c87b03e5Sespie 3294c87b03e5Sespie sed = "/^\tstrncmp(),$/N"; 3295c87b03e5Sespie sed = 's/^\(' "\t" 'strncmp()\),\n\(' "\t" 'strlen(),\)$/' 3296c87b03e5Sespie '\1;' "\\\nextern unsigned int\\\n\\2/"; 3297c87b03e5Sespie 3298c87b03e5Sespie test_text = 3299c87b03e5Sespie "extern int strlen();\n" 3300c87b03e5Sespie 3301c87b03e5Sespie "extern int ffs(long);\n" 3302c87b03e5Sespie 3303c87b03e5Sespie "extern char\n" 3304c87b03e5Sespie "\t*memccpy(),\n" 3305c87b03e5Sespie "\tmemcpy();\n" 3306c87b03e5Sespie 3307c87b03e5Sespie "extern int\n" 3308c87b03e5Sespie "\tstrcmp(),\n" 3309c87b03e5Sespie "\tstrncmp(),\n" 3310c87b03e5Sespie "\tstrlen(),\n" 3311c87b03e5Sespie "\tstrspn();\n" 3312c87b03e5Sespie 3313c87b03e5Sespie "extern int\n" 3314c87b03e5Sespie "\tstrlen(), strspn();"; 3315c87b03e5Sespie}; 3316c87b03e5Sespie 3317c87b03e5Sespie 3318c87b03e5Sespie/* 3319c87b03e5Sespie * Fix return type of calloc, malloc, realloc, bsearch and exit 3320c87b03e5Sespie */ 3321c87b03e5Sespiefix = { 3322c87b03e5Sespie hackname = sysz_stdlib_for_sun; 3323c87b03e5Sespie files = stdlib.h; 3324c87b03e5Sespie 3325c87b03e5Sespie select = "char[ \t]*\\*[ \t]*(calloc|malloc|realloc|bsearch)[ \t]*\\("; 3326c87b03e5Sespie c_fix = format; 3327c87b03e5Sespie c_fix_arg = "void *\t%1("; 3328c87b03e5Sespie 3329c87b03e5Sespie test_text = 3330c87b03e5Sespie "extern char*\tcalloc(size_t);\n" 3331c87b03e5Sespie "extern char*\tmalloc(size_t);\n" 3332c87b03e5Sespie "extern char*\trealloc(void*,size_t);\n" 3333c87b03e5Sespie "extern char*\tbsearch(void*,size_t,size_t);\n"; 3334c87b03e5Sespie}; 3335c87b03e5Sespie 3336c87b03e5Sespie 3337c87b03e5Sespie/* 3338c87b03e5Sespie * __thread is now a keyword. 3339c87b03e5Sespie */ 3340c87b03e5Sespiefix = { 3341c87b03e5Sespie hackname = thread_keyword; 3342c87b03e5Sespie files = "pthread.h"; 3343c87b03e5Sespie files = "bits/sigthread.h"; 3344c87b03e5Sespie select = "([* ])__thread([,)])"; 3345c87b03e5Sespie c_fix = format; 3346c87b03e5Sespie c_fix_arg = "%1__thr%2"; 3347c87b03e5Sespie 3348c87b03e5Sespie test_text = 3349c87b03e5Sespie "extern int pthread_create (pthread_t *__restrict __thread,\n" 3350c87b03e5Sespie "extern int pthread_kill (pthread_t __thread, int __signo);\n" 3351c87b03e5Sespie "extern int pthread_cancel (pthread_t __thread);"; 3352c87b03e5Sespie}; 3353c87b03e5Sespie 3354c87b03e5Sespie/* 3355c87b03e5Sespie * if the #if says _cplusplus, not the double underscore __cplusplus 3356c87b03e5Sespie * that it should be 3357c87b03e5Sespie */ 3358c87b03e5Sespiefix = { 3359c87b03e5Sespie hackname = tinfo_cplusplus; 3360c87b03e5Sespie files = tinfo.h; 3361c87b03e5Sespie select = "[ \t]_cplusplus"; 3362c87b03e5Sespie 3363c87b03e5Sespie c_fix = format; 3364c87b03e5Sespie c_fix_arg = " __cplusplus"; 3365c87b03e5Sespie test_text = "#ifdef _cplusplus\nint bogus;\n#endif"; 3366c87b03e5Sespie}; 3367c87b03e5Sespie 3368c87b03e5Sespie 3369c87b03e5Sespie/* 3370c87b03e5Sespie * function parameter to atexit is missing "void" on VAX Ultrix 4.3. 3371c87b03e5Sespie */ 3372c87b03e5Sespiefix = { 3373c87b03e5Sespie hackname = ultrix_atexit_param; 3374c87b03e5Sespie files = stdlib.h; 3375c87b03e5Sespie select = 'atexit\(.*\(\)'; 3376c87b03e5Sespie 3377c87b03e5Sespie c_fix = format; 3378c87b03e5Sespie c_fix_arg = "atexit( void (*__func)( void )"; 3379c87b03e5Sespie 3380c87b03e5Sespie test_text = "int atexit( void (*__func)() );\n"; 3381c87b03e5Sespie}; 3382c87b03e5Sespie 3383c87b03e5Sespie 3384c87b03e5Sespie/* 3385c87b03e5Sespie * parameter to atof not const on DECstation Ultrix V4.0 and NEWS-OS 4.2R. 3386c87b03e5Sespie */ 3387c87b03e5Sespiefix = { 3388c87b03e5Sespie hackname = ultrix_atof_param; 3389c87b03e5Sespie files = math.h; 3390c87b03e5Sespie select = "atof\\([ \t]*char"; 3391c87b03e5Sespie 3392c87b03e5Sespie c_fix = format; 3393c87b03e5Sespie c_fix_arg = "atof(const char"; 3394c87b03e5Sespie 3395c87b03e5Sespie test_text = "extern double atof( char *__nptr);\n"; 3396c87b03e5Sespie}; 3397c87b03e5Sespie 3398c87b03e5Sespie 3399c87b03e5Sespie/* 3400c87b03e5Sespie * parameters not const on DECstation Ultrix V4.0 and OSF/1. 3401c87b03e5Sespie */ 3402c87b03e5Sespiefix = { 3403c87b03e5Sespie hackname = ultrix_const; 3404c87b03e5Sespie files = stdio.h; 3405c87b03e5Sespie select = 'perror\( char \*'; 3406c87b03e5Sespie 3407c87b03e5Sespie c_fix = format; 3408c87b03e5Sespie c_fix_arg = "%1 const %3 *__"; 3409c87b03e5Sespie c_fix_arg = "([ \t*](perror|fputs|fwrite|scanf|fscanf)\\(.*)" 3410c87b03e5Sespie "[ \t]+(char|void) \\*__"; 3411c87b03e5Sespie 3412c87b03e5Sespie test_text = 3413c87b03e5Sespie "extern void perror( char *__s );\n" 3414c87b03e5Sespie "extern int fputs( char *__s, FILE *);\n" 3415c87b03e5Sespie "extern size_t fwrite( void *__ptr, size_t, size_t, FILE *);\n" 3416c87b03e5Sespie "extern int fscanf( FILE *__stream, char *__format, ...);\n" 3417c87b03e5Sespie "extern int scanf( char *__format, ...);\n"; 3418c87b03e5Sespie}; 3419c87b03e5Sespie 3420c87b03e5Sespie 3421c87b03e5Sespie/* 3422c87b03e5Sespie * parameters not const on DECstation Ultrix V4.0 and OSF/1. 3423c87b03e5Sespie */ 3424c87b03e5Sespiefix = { 3425c87b03e5Sespie hackname = ultrix_const2; 3426c87b03e5Sespie files = stdio.h; 3427c87b03e5Sespie 3428c87b03e5Sespie select = '\*fopen\( char \*'; 3429c87b03e5Sespie c_fix = format; 3430c87b03e5Sespie c_fix_arg = "%1( const char *%3, const char *"; 3431c87b03e5Sespie c_fix_arg = "([ \t*](fopen|sscanf|popen|tempnam))\\(" 3432c87b03e5Sespie "[ \t]*char[ \t]*\\*([^,]*)," 3433c87b03e5Sespie "[ \t]*char[ \t]*\\*[ \t]*"; 3434c87b03e5Sespie 3435c87b03e5Sespie test_text = 3436c87b03e5Sespie "extern FILE *fopen( char *__filename, char *__type );\n" 3437c87b03e5Sespie "extern int sscanf( char *__s, char *__format, ...);\n" 3438c87b03e5Sespie "extern FILE *popen(char *, char *);\n" 3439c87b03e5Sespie "extern char *tempnam(char*,char*);\n"; 3440c87b03e5Sespie}; 3441c87b03e5Sespie 3442c87b03e5Sespie 3443c87b03e5Sespie/* 3444c87b03e5Sespie * Ultrix V4.[35] puts the declaration of uname before the definition 3445c87b03e5Sespie * of struct utsname, so the prototype (added by fixproto) causes havoc. 3446c87b03e5Sespie */ 3447c87b03e5Sespiefix = { 3448c87b03e5Sespie hackname = ultrix_fix_fixproto; 3449c87b03e5Sespie files = sys/utsname.h; 3450c87b03e5Sespie select = ULTRIX; 3451c87b03e5Sespie 3452c87b03e5Sespie c_fix = format; 3453c87b03e5Sespie c_fix_arg = "struct utsname;\n%0"; 3454c87b03e5Sespie c_fix_arg = "^[ \t]*extern[ \t]*int[ \t]*uname\\(\\);"; 3455c87b03e5Sespie 3456c87b03e5Sespie test_text = 3457c87b03e5Sespie "/* ULTRIX's uname */\nextern\tint\tuname();"; 3458c87b03e5Sespie}; 3459c87b03e5Sespie 3460c87b03e5Sespie 3461c87b03e5Sespie/* 3462c87b03e5Sespie * Check for bad #ifdef line (in Ultrix 4.1) 3463c87b03e5Sespie */ 3464c87b03e5Sespiefix = { 3465c87b03e5Sespie hackname = ultrix_ifdef; 3466c87b03e5Sespie select = "^#ifdef KERNEL[ \t]+&&"; 3467c87b03e5Sespie files = sys/file.h; 3468c87b03e5Sespie 3469c87b03e5Sespie c_fix = format; 3470c87b03e5Sespie c_fix_arg = "#if defined(KERNEL) &&"; 3471c87b03e5Sespie 3472c87b03e5Sespie test_text = 3473c87b03e5Sespie "#ifdef KERNEL\t&& defined( mumbojumbo )\nint oops;\n#endif"; 3474c87b03e5Sespie}; 3475c87b03e5Sespie 3476c87b03e5Sespie 3477c87b03e5Sespie/* 3478c87b03e5Sespie * Strip "|| CC$gfloat" from Ultrix math headers. 3479c87b03e5Sespie */ 3480c87b03e5Sespiefix = { 3481c87b03e5Sespie hackname = ultrix_math_ifdef; 3482c87b03e5Sespie files = sys/limits.h; 3483c87b03e5Sespie files = float.h; 3484c87b03e5Sespie files = math.h; 3485c87b03e5Sespie select = "^(#if.*)\\|\\|[ \t]+CC\\$[a-z]+"; 3486c87b03e5Sespie c_fix = format; 3487c87b03e5Sespie c_fix_arg = "%1"; 3488c87b03e5Sespie 3489c87b03e5Sespie test_text = '#if defined(__GFLOAT) || CC\$gfloat'; 3490c87b03e5Sespie}; 3491c87b03e5Sespie 3492c87b03e5Sespie 3493c87b03e5Sespie/* 3494c87b03e5Sespie * Avoid nested comments on Ultrix 4.3. 3495c87b03e5Sespie */ 3496c87b03e5Sespiefix = { 3497c87b03e5Sespie hackname = ultrix_nested_ioctl; 3498c87b03e5Sespie files = sys/ioctl.h; 3499c87b03e5Sespie select = "^/\\* #define SIOCSCREEN"; 3500c87b03e5Sespie sed = "/^\\/\\* #define SIOCSCREEN/s@/\\* screend@*//* screend@"; 3501c87b03e5Sespie test_text = 3502c87b03e5Sespie "/* #define SIOCSCREENON _IOWR('i', 49, int)" 3503c87b03e5Sespie "/* screend, net/gw_screen.h */\n"; 3504c87b03e5Sespie}; 3505c87b03e5Sespie 3506c87b03e5Sespie 3507c87b03e5Sespiefix = { 3508c87b03e5Sespie hackname = ultrix_nested_svc; 3509c87b03e5Sespie files = rpc/svc.h; 3510c87b03e5Sespie select = "^ \\*[ \t]*int protocol; */\\*"; 3511c87b03e5Sespie sed = "s@^\\( \\*\tint protocol; \\)/\\*@\\1*/ /*@"; 3512c87b03e5Sespie test_text = 3513c87b03e5Sespie " *\tint protocol; /* like TCP or UDP\n"; 3514c87b03e5Sespie}; 3515c87b03e5Sespie 3516c87b03e5Sespie 3517c87b03e5Sespie/* 3518c87b03e5Sespie * Add missing prototype for lstat and define for S_ISLNK 3519c87b03e5Sespie * in Ultrix V4.3 sys/stat.h. 3520c87b03e5Sespie */ 3521c87b03e5Sespiefix = { 3522c87b03e5Sespie hackname = ultrix_stat; 3523c87b03e5Sespie files = sys/stat.h; 3524c87b03e5Sespie select = "@\\(#\\)stat\\.h.*6\\.1.*\\(ULTRIX\\)"; 3525c87b03e5Sespie sed = "/^#define[ \t]S_IFPORT[ \t]*S_IFIFO$/a\\\n" 3526c87b03e5Sespie "\\\n" 3527c87b03e5Sespie "/* macro to test for symbolic link */\\\n" 3528c87b03e5Sespie "#define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)\\\n" 3529c87b03e5Sespie "\n"; 3530c87b03e5Sespie sed = "/^[ \t]*fstat(),$/a\\\n" 3531c87b03e5Sespie "\tlstat(),\n"; 3532c87b03e5Sespie test_text = 3533c87b03e5Sespie "@(#)stat.h 6.1 (ULTRIX)\n" 3534c87b03e5Sespie "#define S_IFPORT S_IFIFO\n" 3535c87b03e5Sespie "\tfstat(),\n/* THE INSERTION LINE FAILS ON BSD SYSTEMS */"; 3536c87b03e5Sespie}; 3537c87b03e5Sespie 3538c87b03e5Sespie 3539c87b03e5Sespie/* 3540c87b03e5Sespie * Check for superfluous `static' (in Ultrix 4.2) 3541c87b03e5Sespie * On Ultrix 4.3, includes of other files (r3_cpu.h,r4_cpu.h) is broken. 3542c87b03e5Sespie */ 3543c87b03e5Sespiefix = { 3544c87b03e5Sespie hackname = ultrix_static; 3545c87b03e5Sespie files = machine/cpu.h; 3546c87b03e5Sespie select = '#include "r[34]_cpu'; 3547c87b03e5Sespie sed = "s/^static struct tlb_pid_state/struct tlb_pid_state/"; 3548c87b03e5Sespie sed = 's/^#include "r3_cpu\.h"$/#include <machine\/r3_cpu\.h>/'; 3549c87b03e5Sespie sed = 's/^#include "r4_cpu\.h"$/#include <machine\/r4_cpu\.h>/'; 3550c87b03e5Sespie test_text = 3551c87b03e5Sespie "static struct tlb_pid_state {\n" 3552c87b03e5Sespie "#include \"r3_cpu.h\"\n"; 3553c87b03e5Sespie}; 3554c87b03e5Sespie 3555c87b03e5Sespie 3556c87b03e5Sespie/* 3557c87b03e5Sespie * Add once-only latch to Ultrix V4.3 strings.h. 3558c87b03e5Sespie */ 3559c87b03e5Sespiefix = { 3560c87b03e5Sespie hackname = ultrix_strings; 3561c87b03e5Sespie files = strings.h; 3562c87b03e5Sespie select = "@\\(#\\)strings\\.h.*6\\.1.*\\(ULTRIX\\)"; 3563c87b03e5Sespie c_fix = wrap; 3564c87b03e5Sespie test_text = 3565c87b03e5Sespie "@(#)strings.h 6.1 (ULTRIX)\n"; 3566c87b03e5Sespie}; 3567c87b03e5Sespie 3568c87b03e5Sespie 3569c87b03e5Sespie/* 3570c87b03e5Sespie * Fix multiple defines for NULL. Sometimes, we stumble into \r\n 3571c87b03e5Sespie * terminated lines, so accommodate these. Test both ways. 3572c87b03e5Sespie */ 3573c87b03e5Sespiefix = { 3574c87b03e5Sespie hackname = undefine_null; 3575c87b03e5Sespie select = "^#[ \t]*define[ \t]+NULL[ \t]"; 3576c87b03e5Sespie bypass = "#[ \t]*(ifn|un)def[ \t]+NULL($|[ \t\r])"; 3577c87b03e5Sespie 3578c87b03e5Sespie c_fix = format; 3579c87b03e5Sespie c_fix_arg = "#ifndef NULL%2\n#define NULL%1%2\n#endif%2\n"; 3580c87b03e5Sespie c_fix_arg = "^#[ \t]*define[ \t]*[ \t]NULL([^\r\n]+)([\r]*)\n"; 3581c87b03e5Sespie 3582c87b03e5Sespie test_text = "#define NULL 0UL\r\n#define NULL\t((void*)0)\n"; 3583c87b03e5Sespie}; 3584c87b03e5Sespie 3585c87b03e5Sespie/* 3586c87b03e5Sespie * On Cray Unicos/Mk some standard headers use the C99 keyword "restrict" 3587c87b03e5Sespie * which must be replaced by __restrict__ for GCC. 3588c87b03e5Sespie */ 3589c87b03e5Sespiefix = { 3590c87b03e5Sespie hackname = unicosmk_restrict; 3591c87b03e5Sespie files = stdio.h; 3592c87b03e5Sespie files = stdlib.h; 3593c87b03e5Sespie files = wchar.h; 3594c87b03e5Sespie mach = "*-*-unicosmk*"; 3595c87b03e5Sespie select = "(\\*[ \t]*)restrict([ \t]+)"; 3596c87b03e5Sespie 3597c87b03e5Sespie c_fix = format; 3598c87b03e5Sespie c_fix_arg = "%1__restrict__%2"; 3599c87b03e5Sespie 3600c87b03e5Sespie test_text = "void f (char * restrict x);"; 3601c87b03e5Sespie}; 3602c87b03e5Sespie 3603c87b03e5Sespie/* 3604c87b03e5Sespie * If arpa/inet.h prototypes are incompatible with the ones we just 3605c87b03e5Sespie * installed in <sys/byteorder.h>, just remove the protos. 3606c87b03e5Sespie * Because of this close association, this patch must be applied only 3607c87b03e5Sespie * on those systems where the replacement byteorder header is installed. 3608c87b03e5Sespie */ 3609c87b03e5Sespiefix = { 3610c87b03e5Sespie hackname = uw7_byteorder_fix; 3611c87b03e5Sespie files = arpa/inet.h; 3612c87b03e5Sespie select = "in_port_t"; 3613c87b03e5Sespie test = "-f sys/byteorder.h"; 3614c87b03e5Sespie#ifndef SVR5 3615c87b03e5Sespie mach = "*-*-sysv4*"; 3616c87b03e5Sespie mach = "i?86-*-sysv5*"; 3617c87b03e5Sespie mach = "i?86-*-udk*"; 3618c87b03e5Sespie mach = "i?86-*-solaris2.[0-4]"; 3619c87b03e5Sespie mach = "powerpcle-*-solaris2.[0-4]"; 3620c87b03e5Sespie mach = "sparc-*-solaris2.[0-4]"; 3621c87b03e5Sespie#endif /* SVR5 */ 3622c87b03e5Sespie 3623c87b03e5Sespie c_fix = format; 3624c87b03e5Sespie c_fix_arg = ""; 3625c87b03e5Sespie c_fix_arg = "^extern.*[ \t](htons|ntohs).*\\(in_port_t\\).*;"; 3626c87b03e5Sespie 3627c87b03e5Sespie test_text = "extern in_port_t\thtons __P((in_port_t));\n" 3628c87b03e5Sespie "extern in_port_t\tntohs __P((in_port_t));" 3629c87b03e5Sespie "`[ ! -d $DESTDIR/sys ] && mkdir $DESTDIR/sys\n" 3630c87b03e5Sespie "echo '/* DUMMY */' >> sys/byteorder.h`"; 3631c87b03e5Sespie}; 3632c87b03e5Sespie 3633c87b03e5Sespie 3634c87b03e5Sespie/* 3635c87b03e5Sespie * Fix definitions of macros used by va-i960.h in VxWorks header file. 3636c87b03e5Sespie */ 3637c87b03e5Sespiefix = { 3638c87b03e5Sespie hackname = va_i960_macro; 3639c87b03e5Sespie files = arch/i960/archI960.h; 3640c87b03e5Sespie select = "__(vsiz|vali|vpad|alignof__)"; 3641c87b03e5Sespie 3642c87b03e5Sespie c_fix = format; 3643c87b03e5Sespie c_fix_arg = "__vx%1"; 3644c87b03e5Sespie 3645c87b03e5Sespie test_text = 3646c87b03e5Sespie "extern int __vsiz vsiz;\n" 3647c87b03e5Sespie "extern int __vali vali;\n" 3648c87b03e5Sespie "extern int __vpad vpad;\n" 3649c87b03e5Sespie "#define __alignof__(x) ..."; 3650c87b03e5Sespie}; 3651c87b03e5Sespie 3652c87b03e5Sespie 3653c87b03e5Sespie/* 3654c87b03e5Sespie * AIX headers define NULL to be cast to a void pointer, 3655c87b03e5Sespie * which is illegal in ANSI C++. 3656c87b03e5Sespie */ 3657c87b03e5Sespiefix = { 3658c87b03e5Sespie hackname = void_null; 3659c87b03e5Sespie files = curses.h; 3660c87b03e5Sespie files = dbm.h; 3661c87b03e5Sespie files = locale.h; 3662c87b03e5Sespie files = stdio.h; 3663c87b03e5Sespie files = stdlib.h; 3664c87b03e5Sespie files = string.h; 3665c87b03e5Sespie files = time.h; 3666c87b03e5Sespie files = unistd.h; 3667c87b03e5Sespie files = sys/dir.h; 3668c87b03e5Sespie files = sys/param.h; 3669c87b03e5Sespie files = sys/types.h; 3670c87b03e5Sespie select = "^#[ \t]*define[ \t]+NULL[ \t]+\\(\\(void[ \t]*\\*\\)0\\)"; 3671c87b03e5Sespie c_fix = format; 3672c87b03e5Sespie c_fix_arg = "#define NULL 0"; 3673c87b03e5Sespie test_text = "# define\tNULL \t((void *)0) /* typed NULL */"; 3674c87b03e5Sespie}; 3675c87b03e5Sespie 3676c87b03e5Sespie 3677c87b03e5Sespie/* 3678c87b03e5Sespie * Make VxWorks header which is almost gcc ready fully gcc ready. 3679c87b03e5Sespie */ 3680c87b03e5Sespiefix = { 3681c87b03e5Sespie hackname = vxworks_gcc_problem; 3682c87b03e5Sespie files = types/vxTypesBase.h; 3683c87b03e5Sespie select = "__GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__"; 3684c87b03e5Sespie 3685c87b03e5Sespie sed = "s/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/" 3686c87b03e5Sespie "#if 1/"; 3687c87b03e5Sespie 3688c87b03e5Sespie sed = "/[ \t]size_t/i\\\n" 3689c87b03e5Sespie "#ifndef _GCC_SIZE_T\\\n" 3690c87b03e5Sespie "#define _GCC_SIZE_T\n"; 3691c87b03e5Sespie 3692c87b03e5Sespie sed = "/[ \t]size_t/a\\\n" 3693c87b03e5Sespie "#endif\n"; 3694c87b03e5Sespie 3695c87b03e5Sespie sed = "/[ \t]ptrdiff_t/i\\\n" 3696c87b03e5Sespie "#ifndef _GCC_PTRDIFF_T\\\n" 3697c87b03e5Sespie "#define _GCC_PTRDIFF_T\n"; 3698c87b03e5Sespie 3699c87b03e5Sespie sed = "/[ \t]ptrdiff_t/a\\\n" 3700c87b03e5Sespie "#endif\n"; 3701c87b03e5Sespie 3702c87b03e5Sespie sed = "/[ \t]wchar_t/i\\\n" 3703c87b03e5Sespie "#ifndef _GCC_WCHAR_T\\\n" 3704c87b03e5Sespie "#define _GCC_WCHAR_T\n"; 3705c87b03e5Sespie 3706c87b03e5Sespie sed = "/[ \t]wchar_t/a\\\n" 3707c87b03e5Sespie "#endif\n"; 3708c87b03e5Sespie 3709c87b03e5Sespie test_text = 3710c87b03e5Sespie "#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__\n" 3711c87b03e5Sespie "typedef unsigned int size_t;\n" 3712c87b03e5Sespie "typedef long ptrdiff_t;\n" 3713c87b03e5Sespie "typedef unsigned short wchar_t;\n" 3714c87b03e5Sespie "#endif /* __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__ */\n"; 3715c87b03e5Sespie}; 3716c87b03e5Sespie 3717c87b03e5Sespie 3718c87b03e5Sespie/* 3719c87b03e5Sespie * Fix VxWorks <time.h> to not require including <vxTypes.h>. 3720c87b03e5Sespie */ 3721c87b03e5Sespiefix = { 3722c87b03e5Sespie hackname = vxworks_needs_vxtypes; 3723c87b03e5Sespie files = time.h; 3724c87b03e5Sespie select = "uint_t([ \t]+_clocks_per_sec)"; 3725c87b03e5Sespie c_fix = format; 3726c87b03e5Sespie c_fix_arg = "unsigned int%1"; 3727c87b03e5Sespie test_text = "uint_t\t_clocks_per_sec;"; 3728c87b03e5Sespie}; 3729c87b03e5Sespie 3730c87b03e5Sespie 3731c87b03e5Sespie/* 3732c87b03e5Sespie * Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>. 3733c87b03e5Sespie */ 3734c87b03e5Sespiefix = { 3735c87b03e5Sespie hackname = vxworks_needs_vxworks; 3736c87b03e5Sespie files = sys/stat.h; 3737c87b03e5Sespie test = " -r types/vxTypesOld.h"; 3738c87b03e5Sespie test = " -n \"`egrep '#include' $file`\""; 3739c87b03e5Sespie test = " -n \"`egrep ULONG $file`\""; 3740c87b03e5Sespie select = "#[ \t]define[ \t]+__INCstath"; 3741c87b03e5Sespie 3742c87b03e5Sespie sed = "/#[ \t]define[ \t][ \t]*__INCstath/a\\\n" 3743c87b03e5Sespie "#include <types/vxTypesOld.h>\n"; 3744c87b03e5Sespie 3745c87b03e5Sespie test_text = "`touch types/vxTypesOld.h`" 3746c87b03e5Sespie "#include </dev/null> /* ULONG */\n" 3747c87b03e5Sespie "# define\t__INCstath <sys/stat.h>"; 3748c87b03e5Sespie}; 3749c87b03e5Sespie 3750c87b03e5Sespie 3751c87b03e5Sespie/* 3752c87b03e5Sespie * Another bad dependency in VxWorks 5.2 <time.h>. 3753c87b03e5Sespie */ 3754c87b03e5Sespiefix = { 3755c87b03e5Sespie hackname = vxworks_time; 3756c87b03e5Sespie files = time.h; 3757c87b03e5Sespie test = " -r vxWorks.h"; 3758c87b03e5Sespie 3759c87b03e5Sespie select = "#[ \t]*define[ \t]+VOIDFUNCPTR[ \t].*"; 3760c87b03e5Sespie c_fix = format; 3761c87b03e5Sespie 3762c87b03e5Sespie c_fix_arg = 3763c87b03e5Sespie "#ifndef __gcc_VOIDFUNCPTR_defined\n" 3764c87b03e5Sespie "#ifdef __cplusplus\n" 3765c87b03e5Sespie "typedef void (*__gcc_VOIDFUNCPTR) (...);\n" 3766c87b03e5Sespie "#else\n" 3767c87b03e5Sespie "typedef void (*__gcc_VOIDFUNCPTR) ();\n" 3768c87b03e5Sespie "#endif\n" 3769c87b03e5Sespie "#define __gcc_VOIDFUNCPTR_defined\n" 3770c87b03e5Sespie "#endif\n" 3771c87b03e5Sespie "#define VOIDFUNCPTR __gcc_VOIDFUNCPTR"; 3772c87b03e5Sespie 3773c87b03e5Sespie test_text = "`touch vxWorks.h`" 3774c87b03e5Sespie "#define VOIDFUNCPTR (void(*)())"; 3775c87b03e5Sespie}; 3776c87b03e5Sespie 3777c87b03e5Sespie 3778c87b03e5Sespie/* 3779c87b03e5Sespie * WindISS math.h headers include bogus extern declarations of 3780c87b03e5Sespie * numerous math functions that conflict with libstdc++-v3. 3781c87b03e5Sespie */ 3782c87b03e5Sespiefix = { 3783c87b03e5Sespie hackname = windiss_math1; 3784c87b03e5Sespie files = math.h; 3785c87b03e5Sespie mach = "*-*-windiss"; 3786c87b03e5Sespie sed = "s|inline long double cosl.*|#ifndef __GNUC__|"; 3787c87b03e5Sespie 3788c87b03e5Sespie test_text = "inline long double cosl(long double);"; 3789c87b03e5Sespie}; 3790c87b03e5Sespie 3791c87b03e5Sespiefix = { 3792c87b03e5Sespie hackname = windiss_math2; 3793c87b03e5Sespie files = math.h; 3794c87b03e5Sespie mach = "*-*-windiss"; 3795c87b03e5Sespie sed = "s|/\\* long double declarations \\*/|" 3796c87b03e5Sespie "#endif /* __GNUC__ */|"; 3797c87b03e5Sespie 3798c87b03e5Sespie test_text = "/* long double declarations */"; 3799c87b03e5Sespie}; 3800c87b03e5Sespie 3801c87b03e5Sespie/* 3802c87b03e5Sespie * WindISS headers include "diab/va_list.h" instead of "stdarg.h" 3803c87b03e5Sespie */ 3804c87b03e5Sespiefix = { 3805c87b03e5Sespie select = '(#include.*)diab/va_list.h'; 3806c87b03e5Sespie hackname = windiss_valist; 3807c87b03e5Sespie sed = "s|diab/va_list.h|stdarg.h|"; 3808c87b03e5Sespie mach = "*-*-windiss"; 3809c87b03e5Sespie 3810c87b03e5Sespie test_text = "#include <diab/va_list.h>"; 3811c87b03e5Sespie}; 3812c87b03e5Sespie 3813c87b03e5Sespie/* 3814c87b03e5Sespie * There are several name conflicts with C++ reserved words in X11 header 3815c87b03e5Sespie * files. These are fixed in some versions, so don't do the fixes if 3816c87b03e5Sespie * we find __cplusplus in the file. These were found on the RS/6000. 3817c87b03e5Sespie */ 3818c87b03e5Sespiefix = { 3819c87b03e5Sespie hackname = x11_class; 3820c87b03e5Sespie files = X11/ShellP.h; 3821c87b03e5Sespie bypass = __cplusplus; 3822c87b03e5Sespie select = "^([ \t]*char \\*)class;(.*)"; 3823c87b03e5Sespie c_fix = format; 3824c87b03e5Sespie c_fix_arg = "#ifdef __cplusplus\n%1c_class;%2\n" 3825c87b03e5Sespie "#else\n%1class;%2\n#endif"; 3826c87b03e5Sespie test_text = 3827c87b03e5Sespie "struct {\n" 3828c87b03e5Sespie " char *class;\n" 3829c87b03e5Sespie "} mumble;\n"; 3830c87b03e5Sespie}; 3831c87b03e5Sespie 3832c87b03e5Sespie 3833c87b03e5Sespie/* 3834c87b03e5Sespie * class in Xm/BaseClassI.h 3835c87b03e5Sespie */ 3836c87b03e5Sespiefix = { 3837c87b03e5Sespie hackname = x11_class_usage; 3838c87b03e5Sespie files = Xm/BaseClassI.h; 3839c87b03e5Sespie bypass = "__cplusplus"; 3840c87b03e5Sespie 3841c87b03e5Sespie select = " class\\)"; 3842c87b03e5Sespie c_fix = format; 3843c87b03e5Sespie c_fix_arg = " c_class)"; 3844c87b03e5Sespie 3845c87b03e5Sespie test_text = "extern mumble (int class);\n"; 3846c87b03e5Sespie}; 3847c87b03e5Sespie 3848c87b03e5Sespie 3849c87b03e5Sespie/* 3850c87b03e5Sespie * new in Xm/Traversal.h 3851c87b03e5Sespie */ 3852c87b03e5Sespiefix = { 3853c87b03e5Sespie hackname = x11_new; 3854c87b03e5Sespie files = Xm/Traversal.h; 3855c87b03e5Sespie bypass = __cplusplus; 3856c87b03e5Sespie 3857c87b03e5Sespie sed = "/Widget\told, new;/i\\\n" 3858c87b03e5Sespie "#ifdef __cplusplus\\\n" 3859c87b03e5Sespie "\tWidget\told, c_new;\\\n" 3860c87b03e5Sespie "#else\n"; 3861c87b03e5Sespie 3862c87b03e5Sespie sed = "/Widget\told, new;/a\\\n" 3863c87b03e5Sespie "#endif\n"; 3864c87b03e5Sespie 3865c87b03e5Sespie sed = "s/Widget new,/Widget c_new,/g"; 3866c87b03e5Sespie test_text = 3867c87b03e5Sespie "struct wedge {\n" 3868c87b03e5Sespie " Widget\told, new; /* fixinc check FAILS ON BSD */\n" 3869c87b03e5Sespie "};\nextern Wedged( Widget new, Widget old );"; 3870c87b03e5Sespie}; 3871c87b03e5Sespie 3872c87b03e5Sespie 3873c87b03e5Sespie/* 3874c87b03e5Sespie * Incorrect sprintf declaration in X11/Xmu.h 3875c87b03e5Sespie */ 3876c87b03e5Sespiefix = { 3877c87b03e5Sespie hackname = x11_sprintf; 3878c87b03e5Sespie files = X11/Xmu.h; 3879c87b03e5Sespie files = X11/Xmu/Xmu.h; 3880c87b03e5Sespie select = "^extern char \\*\tsprintf\\(\\);$"; 3881c87b03e5Sespie 3882c87b03e5Sespie c_fix = format; 3883c87b03e5Sespie c_fix_arg = "#ifndef __STDC__\n%0\n#endif /* !defined __STDC__ */"; 3884c87b03e5Sespie 3885c87b03e5Sespie test_text = "extern char *\tsprintf();"; 3886c87b03e5Sespie}; 3887c87b03e5Sespie 3888c87b03e5Sespie/*EOF*/ 3889