inclhack.def 144 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869
  1. /* -*- Mode: C -*- */
  2. autogen definitions fixincl;
  3. /* Define all the fixes we know about for repairing damaged headers.
  4. Please see the README before adding or changing entries in this file.
  5. This is the sort command:
  6. blocksort output=inclhack.sorted \
  7. pattern='^/\*$' \
  8. trailer='^/\*EOF\*[/]' \
  9. input=inclhack.def \
  10. key=$'hackname[ \t]*=[ \t]*(.*);'
  11. Set up a debug test so we can make the templates emit special
  12. code while debugging these fixes: */
  13. #ifdef DEBUG
  14. FIXINC_DEBUG = yes;
  15. #endif
  16. /* On AIX when _LARGE_FILES is defined stdio.h defines fopen to
  17. * fopen64 etc. and this causes problems when building with g++
  18. * because cstdio udefs everything from stdio.h, leaving us with
  19. * ::fopen has not been declared errors. This fixes stdio.h to
  20. * undef those defines and use __asm__ to alias the symbols if
  21. * building with g++ and -D_LARGE_FILES
  22. */
  23. fix = {
  24. hackname = AAB_aix_stdio;
  25. files = stdio.h;
  26. select = "define fopen fopen64";
  27. mach = "*-*-aix*";
  28. test-text = ''; /* no way to test */
  29. c_fix = wrap;
  30. c_fix_arg = "";
  31. c_fix_arg = <<- _EOArg_
  32. #if defined __GNUG__ && defined _LARGE_FILES && defined __cplusplus
  33. #define __need__aix_stdio_h_fix
  34. #ifdef __need__aix_stdio_h_fix
  35. #undef fseeko
  36. #undef ftello
  37. #undef fgetpos
  38. #undef fsetpos
  39. #undef fopen
  40. #undef freopen
  41. /* Alias the symbols using asm */
  42. extern "C" {
  43. extern int fgetpos(FILE *, fpos64_t *) __asm__("fgetpos64");
  44. extern FILE *fopen(const char *, const char *) __asm__("fopen64");
  45. extern FILE *freopen(const char *, const char *, FILE *) __asm__("freopen64");
  46. extern int fseeko(FILE *, off64_t, int) __asm__("fseeko64");
  47. extern int fsetpos(FILE *, const fpos64_t *) __asm__("fsetpos64");
  48. extern off64_t ftello(FILE *) __asm__("ftello64");
  49. }
  50. #endif
  51. #endif
  52. _EOArg_;
  53. };
  54. /* On AIX when _LARGE_FILES is defined fcntl.h defines open to
  55. * open64 and creat to creat64. This fixes fcntl.h to
  56. * undef those defines and use __asm__ to alias the symbols if
  57. * building with g++ and -D_LARGE_FILES
  58. */
  59. fix = {
  60. hackname = AAB_aix_fcntl;
  61. files = fcntl.h;
  62. select = "define open[ \t]open64";
  63. mach = "*-*-aix*";
  64. test-text = ''; /* no way to test */
  65. c_fix = wrap;
  66. c_fix_arg = "";
  67. c_fix_arg = <<- _EOArg_
  68. #if defined __GNUG__ && defined _LARGE_FILES && defined __cplusplus
  69. #define __need__aix_fcntl_h_fix
  70. #ifdef __need__aix_fcntl_h_fix
  71. #undef open
  72. #undef creat
  73. #undef openat
  74. /* Alias the symbols using asm */
  75. extern "C" {
  76. extern int open(const char *, int, ...) __asm__("open64");
  77. extern int creat(const char *, mode_t) __asm__("creat64");
  78. #if (_XOPEN_SOURCE >= 700)
  79. extern int openat(int, const char *, int, ...) __asm__("open64at");
  80. #endif
  81. }
  82. #endif
  83. #endif
  84. _EOArg_;
  85. };
  86. /*
  87. * On Mac OS 10.3.9, the 'long double' functions are available in
  88. * libSystem, but are not prototyped in math.h.
  89. */
  90. fix = {
  91. hackname = AAB_darwin7_9_long_double_funcs;
  92. mach = "*-*-darwin7.9*";
  93. files = architecture/ppc/math.h;
  94. bypass = "powl";
  95. replace = <<- _EndOfHeader_
  96. /* This file prototypes the long double functions available on Mac OS
  97. 10.3.9. */
  98. #ifndef __MATH__
  99. # undef __APPLE_CC__
  100. # define __APPLE_CC__ 1345
  101. # include_next <architecture/ppc/math.h>
  102. # undef __APPLE_CC__
  103. # define __APPLE_CC__ 1
  104. # ifndef __LIBMLDBL_COMPAT
  105. # ifdef __LONG_DOUBLE_128__
  106. # define __LIBMLDBL_COMPAT(sym) __asm("_" #sym "$LDBL128")
  107. # else
  108. # define __LIBMLDBL_COMPAT(sym)
  109. # endif /* __LONG_DOUBLE_128__ */
  110. # endif /* __LIBMLDBL_COMPAT */
  111. # ifdef __cplusplus
  112. extern "C" {
  113. # endif
  114. extern long double acosl( long double ) __LIBMLDBL_COMPAT(acosl);
  115. extern long double asinl( long double ) __LIBMLDBL_COMPAT(asinl);
  116. extern long double atanl( long double ) __LIBMLDBL_COMPAT(atanl);
  117. extern long double atan2l( long double, long double ) __LIBMLDBL_COMPAT(atan2l);
  118. extern long double cosl( long double ) __LIBMLDBL_COMPAT(cosl);
  119. extern long double sinl( long double ) __LIBMLDBL_COMPAT(sinl);
  120. extern long double tanl( long double ) __LIBMLDBL_COMPAT(tanl);
  121. extern long double acoshl( long double ) __LIBMLDBL_COMPAT(acoshl);
  122. extern long double asinhl( long double ) __LIBMLDBL_COMPAT(asinhl);
  123. extern long double atanhl( long double ) __LIBMLDBL_COMPAT(atanhl);
  124. extern long double coshl( long double ) __LIBMLDBL_COMPAT(coshl);
  125. extern long double sinhl( long double ) __LIBMLDBL_COMPAT(sinhl);
  126. extern long double tanhl( long double ) __LIBMLDBL_COMPAT(tanhl);
  127. extern long double expl( long double ) __LIBMLDBL_COMPAT(expl);
  128. extern long double exp2l( long double ) __LIBMLDBL_COMPAT(exp2l);
  129. extern long double expm1l( long double ) __LIBMLDBL_COMPAT(expm1l);
  130. extern long double logl( long double ) __LIBMLDBL_COMPAT(logl);
  131. extern long double log10l( long double ) __LIBMLDBL_COMPAT(log10l);
  132. extern long double log2l( long double ) __LIBMLDBL_COMPAT(log2l);
  133. extern long double log1pl( long double ) __LIBMLDBL_COMPAT(log1pl);
  134. extern long double logbl( long double ) __LIBMLDBL_COMPAT(logbl);
  135. extern long double modfl( long double, long double * ) __LIBMLDBL_COMPAT(modfl);
  136. extern long double ldexpl( long double, int ) __LIBMLDBL_COMPAT(ldexpl);
  137. extern long double frexpl( long double, int * ) __LIBMLDBL_COMPAT(frexpl);
  138. extern int ilogbl( long double ) __LIBMLDBL_COMPAT(ilogbl);
  139. extern long double scalbnl( long double, int ) __LIBMLDBL_COMPAT(scalbnl);
  140. extern long double scalblnl( long double, long int ) __LIBMLDBL_COMPAT(scalblnl);
  141. extern long double fabsl( long double ) __LIBMLDBL_COMPAT(fabsl);
  142. extern long double cbrtl( long double ) __LIBMLDBL_COMPAT(cbrtl);
  143. extern long double hypotl( long double, long double ) __LIBMLDBL_COMPAT(hypotl);
  144. extern long double powl( long double, long double ) __LIBMLDBL_COMPAT(powl);
  145. extern long double sqrtl( long double ) __LIBMLDBL_COMPAT(sqrtl);
  146. extern long double erfl( long double ) __LIBMLDBL_COMPAT(erfl);
  147. extern long double erfcl( long double ) __LIBMLDBL_COMPAT(erfcl);
  148. extern long double lgammal( long double ) __LIBMLDBL_COMPAT(lgammal);
  149. extern long double tgammal( long double ) __LIBMLDBL_COMPAT(tgammal);
  150. extern long double ceill( long double ) __LIBMLDBL_COMPAT(ceill);
  151. extern long double floorl( long double ) __LIBMLDBL_COMPAT(floorl);
  152. extern long double nearbyintl( long double ) __LIBMLDBL_COMPAT(nearbyintl);
  153. extern long double rintl( long double ) __LIBMLDBL_COMPAT(rintl);
  154. extern long int lrintl( long double ) __LIBMLDBL_COMPAT(lrintl);
  155. extern long long int llrintl( long double ) __LIBMLDBL_COMPAT(llrintl);
  156. extern long double roundl( long double ) __LIBMLDBL_COMPAT(roundl);
  157. extern long int lroundl( long double ) __LIBMLDBL_COMPAT(lroundl);
  158. extern long long int llroundl( long double ) __LIBMLDBL_COMPAT(llroundl);
  159. extern long double truncl( long double ) __LIBMLDBL_COMPAT(truncl);
  160. extern long double fmodl( long double, long double) __LIBMLDBL_COMPAT(fmodl);
  161. extern long double remainderl( long double, long double ) __LIBMLDBL_COMPAT(remainderl);
  162. extern long double remquol( long double, long double, int * ) __LIBMLDBL_COMPAT(remquol);
  163. extern long double copysignl( long double, long double ) __LIBMLDBL_COMPAT(copysignl);
  164. extern long double nanl( const char * ) __LIBMLDBL_COMPAT(nanl);
  165. extern long double nextafterl( long double, long double ) __LIBMLDBL_COMPAT(nextafterl);
  166. extern long double nexttowardl( long double, long double ) __LIBMLDBL_COMPAT(nexttowardl);
  167. extern long double fdiml( long double, long double ) __LIBMLDBL_COMPAT(fdiml);
  168. extern long double fmaxl( long double, long double ) __LIBMLDBL_COMPAT(fmaxl);
  169. extern long double fminl( long double, long double ) __LIBMLDBL_COMPAT(fminl);
  170. extern long double fmal( long double, long double, long double ) __LIBMLDBL_COMPAT(fmal);
  171. # ifdef __cplusplus
  172. }
  173. # endif
  174. #endif /* __MATH__ */
  175. _EndOfHeader_;
  176. };
  177. /*
  178. * This fixes __FD_ZERO bug for linux 2.x.y (x <= 2 && y <= some n)
  179. */
  180. fix = {
  181. hackname = AAB_fd_zero_asm_posix_types_h;
  182. files = asm/posix_types.h;
  183. mach = 'i[34567]86-*-linux*';
  184. bypass = '} while';
  185. bypass = 'x86_64';
  186. bypass = 'posix_types_64';
  187. /*
  188. * Define _POSIX_TYPES_H_WRAPPER at the end of the wrapper, not
  189. * the start, so that if #include_next gets another instance of
  190. * the wrapper, this will follow the #include_next chain until
  191. * we arrive at the real <asm/posix_types.h>.
  192. */
  193. replace = <<- _EndOfHeader_
  194. /* This file fixes a bug in the __FD_ZERO macro
  195. for older versions of the Linux kernel. */
  196. #ifndef _POSIX_TYPES_H_WRAPPER
  197. #include <features.h>
  198. #include_next <asm/posix_types.h>
  199. #if defined(__FD_ZERO) && !defined(__GLIBC__)
  200. #undef __FD_ZERO
  201. #define __FD_ZERO(fdsetp) \
  202. do { \
  203. int __d0, __d1; \
  204. __asm__ __volatile__("cld ; rep ; stosl" \
  205. : "=&c" (__d0), "=&D" (__d1) \
  206. : "a" (0), "0" (__FDSET_LONGS), \
  207. "1" ((__kernel_fd_set *) (fdsetp)) :"memory"); \
  208. } while (0)
  209. #endif
  210. #define _POSIX_TYPES_H_WRAPPER
  211. #endif /* _POSIX_TYPES_H_WRAPPER */
  212. _EndOfHeader_;
  213. };
  214. /*
  215. * This fixes __FD_ZERO bug for glibc-1.x
  216. */
  217. fix = {
  218. hackname = AAB_fd_zero_gnu_types_h;
  219. files = gnu/types.h;
  220. mach = 'i[34567]86-*-linux*';
  221. /*
  222. * Define _TYPES_H_WRAPPER at the end of the wrapper, not
  223. * the start, so that if #include_next gets another instance of
  224. * the wrapper, this will follow the #include_next chain until
  225. * we arrive at the real <gnu/types.h>.
  226. */
  227. replace = <<- _EndOfHeader_
  228. /* This file fixes a bug in the __FD_ZERO macro present in glibc 1.x. */
  229. #ifndef _TYPES_H_WRAPPER
  230. #include <features.h>
  231. #include_next <gnu/types.h>
  232. #if defined(__FD_ZERO) && !defined(__GLIBC__)
  233. #undef __FD_ZERO
  234. # define __FD_ZERO(fdsetp) \
  235. do { \
  236. int __d0, __d1; \
  237. __asm__ __volatile__("cld ; rep ; stosl" \
  238. : "=&c" (__d0), "=&D" (__d1) \
  239. : "a" (0), "0" (__FDSET_LONGS), \
  240. "1" ((__fd_set *) (fdsetp)) :"memory"); \
  241. } while (0)
  242. #endif
  243. #define _TYPES_H_WRAPPER
  244. #endif /* _TYPES_H_WRAPPER */
  245. _EndOfHeader_;
  246. };
  247. /*
  248. * This fixes __FD_ZERO bug for glibc-2.0.x
  249. */
  250. fix = {
  251. hackname = AAB_fd_zero_selectbits_h;
  252. files = selectbits.h;
  253. mach = 'i[34567]86-*-linux*';
  254. /*
  255. * Define _SELECTBITS_H_WRAPPER at the end of the wrapper, not
  256. * the start, so that if #include_next gets another instance of
  257. * the wrapper, this will follow the #include_next chain until
  258. * we arrive at the real <selectbits.h>.
  259. */
  260. replace = <<- _EndOfHeader_
  261. /* This file fixes a bug in the __FD_ZERO macro present in glibc 2.0.x. */
  262. #ifndef _SELECTBITS_H_WRAPPER
  263. #include <features.h>
  264. #include_next <selectbits.h>
  265. #if defined(__FD_ZERO) && defined(__GLIBC__) \\
  266. && defined(__GLIBC_MINOR__) && __GLIBC__ == 2 \\
  267. && __GLIBC_MINOR__ == 0
  268. #undef __FD_ZERO
  269. #define __FD_ZERO(fdsetp) \\
  270. do { \\
  271. int __d0, __d1; \\
  272. __asm__ __volatile__ ("cld; rep; stosl" \\
  273. : "=&c" (__d0), "=&D" (__d1) \\
  274. : "a" (0), "0" (sizeof (__fd_set) \\
  275. / sizeof (__fd_mask)), \\
  276. "1" ((__fd_mask *) (fdsetp)) \\
  277. : "memory"); \\
  278. } while (0)
  279. #endif
  280. #define _SELECTBITS_H_WRAPPER
  281. #endif /* _SELECTBITS_H_WRAPPER */
  282. _EndOfHeader_;
  283. };
  284. /*
  285. * Solaris <sys/varargs.h> is a DDK (aka kernel-land) header providing
  286. * the same interface as <stdarg.h>. No idea why they couldn't have just
  287. * used the standard header.
  288. */
  289. fix = {
  290. hackname = AAB_solaris_sys_varargs_h;
  291. files = "sys/varargs.h";
  292. mach = '*-*-solaris*';
  293. replace = <<- _EndOfHeader_
  294. #ifdef __STDC__
  295. #include <stdarg.h>
  296. #else
  297. #include <varargs.h>
  298. #endif
  299. _EndOfHeader_;
  300. };
  301. /*
  302. * Fix non-ANSI memcpy declaration that conflicts with gcc's builtin
  303. * declaration on Sun OS 4.x. We must only fix this on Sun OS 4.x, because
  304. * many other systems have similar text but correct versions of the file.
  305. * To ensure only Sun's is fixed, we grep for a likely unique string.
  306. * Fix also on sysV68 R3V7.1 (head/memory.h\t50.1\t )
  307. */
  308. fix = {
  309. hackname = AAB_sun_memcpy;
  310. files = memory.h;
  311. select = "/\\*\t@\\(#\\)"
  312. "(head/memory.h\t50.1\t "
  313. "|memory\\.h 1\\.[2-4] 8./../.. SMI; from S5R2 1\\.2\t)\\*/";
  314. replace = <<- _EndOfHeader_
  315. /* This file was generated by fixincludes */
  316. #ifndef __memory_h__
  317. #define __memory_h__
  318. #ifdef __STDC__
  319. extern void *memccpy();
  320. extern void *memchr();
  321. extern void *memcpy();
  322. extern void *memset();
  323. #else
  324. extern char *memccpy();
  325. extern char *memchr();
  326. extern char *memcpy();
  327. extern char *memset();
  328. #endif /* __STDC__ */
  329. extern int memcmp();
  330. #endif /* __memory_h__ */
  331. _EndOfHeader_;
  332. };
  333. /*
  334. * Fix assert.h on VxWorks:
  335. */
  336. fix = {
  337. hackname = AAB_vxworks_assert;
  338. files = assert.h;
  339. mach = "*-*-vxworks*";
  340. replace = <<- _EndOfHeader_
  341. #ifndef _ASSERT_H
  342. #define _ASSERT_H
  343. #ifdef assert
  344. #undef assert
  345. #endif
  346. #if defined(__STDC__) || defined(__cplusplus)
  347. extern void __assert (const char*);
  348. #else
  349. extern void __assert ();
  350. #endif
  351. #ifdef NDEBUG
  352. #define assert(ign) ((void)0)
  353. #else
  354. #define ASSERT_STRINGIFY(str) ASSERT_STRINGIFY_HELPER(str)
  355. #define ASSERT_STRINGIFY_HELPER(str) #str
  356. #define assert(test) ((void) \
  357. ((test) ? ((void)0) : \
  358. __assert("Assertion failed: " ASSERT_STRINGIFY(test) ", file " \
  359. __FILE__ ", line " ASSERT_STRINGIFY(__LINE__) "\n")))
  360. #endif
  361. #endif
  362. _EndOfHeader_;
  363. };
  364. /*
  365. * Add needed include to regs.h (NOT the gcc header) on VxWorks
  366. */
  367. fix = {
  368. hackname = AAB_vxworks_regs_vxtypes;
  369. files = regs.h;
  370. mach = "*-*-vxworks*";
  371. replace = <<- _EndOfHeader_
  372. #ifndef _REGS_H
  373. #define _REGS_H
  374. #include <types/vxTypesOld.h>
  375. #include_next <arch/../regs.h>
  376. #endif
  377. _EndOfHeader_;
  378. };
  379. /*
  380. * Make VxWorks stdint.h a bit more compliant - add typedefs
  381. */
  382. fix = {
  383. hackname = AAB_vxworks_stdint;
  384. files = stdint.h;
  385. mach = "*-*-vxworks*";
  386. replace = <<- _EndOfHeader_
  387. #ifndef _STDINT_H
  388. #define _STDINT_H
  389. /* get int*_t, uint*_t */
  390. #include <types/vxTypes.h>
  391. /* get legacy vxworks types for compatibility */
  392. #include <types/vxTypesOld.h>
  393. typedef long intptr_t;
  394. typedef unsigned long uintptr_t;
  395. typedef int64_t intmax_t;
  396. typedef uint64_t uintmax_t;
  397. typedef int8_t int_least8_t;
  398. typedef int16_t int_least16_t;
  399. typedef int32_t int_least32_t;
  400. typedef int64_t int_least64_t;
  401. typedef uint8_t uint_least8_t;
  402. typedef uint16_t uint_least16_t;
  403. typedef uint32_t uint_least32_t;
  404. typedef uint64_t uint_least64_t;
  405. typedef int8_t int_fast8_t;
  406. typedef int int_fast16_t;
  407. typedef int32_t int_fast32_t;
  408. typedef int64_t int_fast64_t;
  409. typedef uint8_t uint_fast8_t;
  410. typedef unsigned int uint_fast16_t;
  411. typedef uint32_t uint_fast32_t;
  412. typedef uint64_t uint_fast64_t;
  413. /* Ranges */
  414. #define UINT8_MAX (~(uint8_t)0)
  415. #define UINT8_MIN 0
  416. #define UINT16_MAX (~(uint16_t)0)
  417. #define UINT16_MIN 0
  418. #define UINT32_MAX (~(uint32_t)0)
  419. #define UINT32_MIN 0
  420. #define UINT64_MAX (~(uint64_t)0)
  421. #define UINT64_MIN 0
  422. #define UINTPTR_MAX (~(uintptr_t)0)
  423. #define UINTPTR_MIN 0
  424. /* Need to do int_fast16_t as well, as type
  425. size may be architecture dependent */
  426. #define UINT_FAST16_MAX (~(uint_fast16_t)0)
  427. #define UINT_FAST16_MAX 0
  428. #define INT8_MAX (UINT8_MAX>>1)
  429. #define INT8_MIN (INT8_MAX+1)
  430. #define INT16_MAX (UINT16_MAX>>1)
  431. #define INT16_MIN (INT16_MAX+1)
  432. #define INT32_MAX (UINT32_MAX>>1)
  433. #define INT32_MIN (INT32_MAX+1)
  434. #define INT64_MAX (UINT64_MAX>>1)
  435. #define INT64_MIN (INT64_MAX+1)
  436. #define INTPTR_MAX (UINTPTR_MAX>>1)
  437. #define INTPTR_MIN (INTPTR_MAX+1)
  438. #define INT_FAST16_MAX (UINT_FAST16_MAX>>1)
  439. #define INT_FAST16_MIN (INT_FAST16_MAX+1)
  440. /* now define equiv. constants */
  441. #define UINT_FAST8_MAX UINT8_MAX
  442. #define UINT_FAST8_MIN UINT_FAST8_MIN
  443. #define INT_FAST8_MAX INT8_MAX
  444. #define INT_FAST8_MIN INT8_MIN
  445. #define UINT_FAST32_MAX UINT32_MAX
  446. #define UINT_FAST32_MIN UINT32_MIN
  447. #define INT_FAST32_MAX INT32_MAX
  448. #define INT_FAST32_MIN INT32_MIN
  449. #define UINT_FAST64_MAX UINT64_MAX
  450. #define UINT_FAST64_MIN UINT64_MIN
  451. #define INT_FAST64_MAX INT64_MAX
  452. #define INT_FAST64_MIN INT64_MIN
  453. #define UINT_LEAST8_MAX UINT8_MAX
  454. #define UINT_LEAST8_MIN UINT8_MIN
  455. #define INT_LEAST8_MAX INT8_MAX
  456. #define INT_LEAST8_MIN INT8_MIN
  457. #define UINT_LEAST16_MAX UINT16_MAX
  458. #define UINT_LEAST16_MIN UINT16_MIN
  459. #define INT_LEAST16_MAX INT16_MAX
  460. #define INT_LEAST16_MIN INT16_MIN
  461. #define UINT_LEAST32_MAX UINT32_MAX
  462. #define UINT_LEAST32_MIN UINT32_MIN
  463. #define INT_LEAST32_MAX INT32_MAX
  464. #define INT_LEAST32_MIN INT32_MIN
  465. #define UINT_LEAST64_MAX UINT64_MAX
  466. #define UINT_LEAST64_MIN UINT64_MIN
  467. #define INT_LEAST64_MAX INT64_MAX
  468. #define INT_LEAST64_MIN INT64_MIN
  469. #define UINTMAX_MAX UINT64_MAX
  470. #define UINTMAX_MIN UINT64_MIN
  471. #define INTMAX_MAX INT64_MAX
  472. #define INTMAX_MIN INT64_MIN
  473. #endif
  474. _EndOfHeader_;
  475. };
  476. /*
  477. * This hack makes makes unistd.h more POSIX-compliant on VxWorks
  478. */
  479. fix = {
  480. hackname = AAB_vxworks_unistd;
  481. files = unistd.h;
  482. mach = "*-*-vxworks*";
  483. replace = <<- _EndOfHeader_
  484. #ifndef _UNISTD_H
  485. #define _UNISTD_H
  486. #include_next <unistd.h>
  487. #include <ioLib.h>
  488. #ifndef STDIN_FILENO
  489. #define STDIN_FILENO 0
  490. #endif
  491. #ifndef STDOUT_FILENO
  492. #define STDOUT_FILENO 1
  493. #endif
  494. #ifndef STDERR_FILENO
  495. #define STDERR_FILENO 2
  496. #endif
  497. #endif /* _UNISTD_H */
  498. _EndOfHeader_;
  499. };
  500. /*
  501. * assert.h on AIX 7 redefines static_assert as _Static_assert without
  502. * protecting C++.
  503. */
  504. fix = {
  505. hackname = aix_assert;
  506. mach = "*-*-aix*";
  507. files = assert.h;
  508. select = "#define[ \t]static_assert[ \t]_Static_assert";
  509. c_fix = format;
  510. c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
  511. test_text = "#define static_assert _Static_assert";
  512. };
  513. /*
  514. * complex.h on AIX 5 and AIX 6 define _Complex_I and I in terms of __I,
  515. * which only is provided by AIX xlc C99.
  516. */
  517. fix = {
  518. hackname = aix_complex;
  519. mach = "*-*-aix*";
  520. files = complex.h;
  521. select = "#define[ \t]_Complex_I[ \t]__I";
  522. c_fix = format;
  523. c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)";
  524. test_text = "#define _Complex_I __I\n";
  525. };
  526. /*
  527. * On AIX some headers are not properly guarded by 'extern "C"'.
  528. */
  529. fix = {
  530. hackname = aix_externc;
  531. mach = "*-*-aix*";
  532. files = ctype.h;
  533. files = fcntl.h;
  534. files = langinfo.h;
  535. files = ldfcn.h;
  536. files = sys/localedef.h;
  537. files = sys/times.h;
  538. bypass = "extern \"C\"";
  539. c_fix = wrap;
  540. c_fix_arg = "#ifdef __cplusplus\n"
  541. "extern \"C\" {\n"
  542. "#endif\n";
  543. c_fix_arg = "#ifdef __cplusplus\n"
  544. "}\n"
  545. "#endif\n";
  546. test_text = "extern int __n_pthreads;\n";
  547. };
  548. /*
  549. * On AIX sys/socket.h assumes C++.
  550. */
  551. fix = {
  552. hackname = aix_externcpp1;
  553. mach = "*-*-aix*";
  554. files = "sys/socket.h";
  555. select = "#ifdef __cplusplus";
  556. c_fix = format;
  557. c_fix_arg = "#ifdef __cplusplus\n"
  558. "extern \"C++\" {";
  559. test_text = "#ifdef __cplusplus";
  560. };
  561. fix = {
  562. hackname = aix_externcpp2;
  563. mach = "*-*-aix*";
  564. files = "sys/socket.h";
  565. select = "#else /\\* __cplusplus \\*/";
  566. c_fix = format;
  567. c_fix_arg = "} /* extern \"C++\" */\n"
  568. "#else /* __cplusplus */";
  569. test_text = "#else /* __cplusplus */";
  570. };
  571. /*
  572. * malloc.h on AIX6 uses XLC++ specific builtin syntax
  573. */
  574. fix = {
  575. hackname = aix_malloc;
  576. mach = "*-*-aix*";
  577. files = "malloc.h";
  578. select = "#ifdef __cplusplus";
  579. c_fix = format;
  580. c_fix_arg = "#if (defined(__cplusplus) && defined(__IBMCPP__))";
  581. test_text = "#ifdef __cplusplus";
  582. };
  583. /*
  584. * net/if_arp.h defines a variable fc_softc instead of adding a
  585. * typedef for the struct on AIX 5.2, 5.3, 6.1 and 7.1
  586. */
  587. fix = {
  588. hackname = aix_net_if_arp;
  589. mach = "*-*-aix*";
  590. files = "net/if_arp.h";
  591. select = "^struct fc_softc \\{";
  592. c_fix = format;
  593. c_fix_arg = "typedef struct _fc_softc {";
  594. test_text = "struct fc_softc {\n int a;\n};";
  595. };
  596. /*
  597. * Fix AIX definition of NULL for G++.
  598. */
  599. fix = {
  600. hackname = aix_null;
  601. mach = "*-*-aix*";
  602. files = curses.h, dbm.h, locale.h, stdio.h, stdlib.h, string.h,
  603. time.h, unistd.h, wchar.h, sys/dir.h, sys/param.h, sys/types.h;
  604. bypass = __null;
  605. select = "#define[ \t]+NULL[ \t]+\\(*0L*\\)*";
  606. c_fix = format;
  607. c_fix_arg = <<- _EOFix_
  608. #ifndef NULL
  609. #ifdef __cplusplus
  610. #ifdef __GNUG__
  611. #define NULL __null
  612. #else /* ! __GNUG__ */
  613. #define NULL 0L
  614. #endif /* __GNUG__ */
  615. #else /* ! __cplusplus */
  616. #define NULL ((void *)0)
  617. #endif /* __cplusplus */
  618. #endif /* !NULL */
  619. _EOFix_;
  620. test_text = "# define\tNULL \t(0L) /* typed NULL */";
  621. };
  622. /*
  623. * pthread.h on AIX defines PTHREAD_ONCE_INIT, PTHREAD_MUTEX_INITIALIZER,
  624. * PTHREAD_COND_INITIALIZER and PTHREAD_RWLOCK_INITIALIZER without enough
  625. * braces.
  626. */
  627. fix = {
  628. hackname = aix_once_init_1;
  629. mach = "*-*-aix*";
  630. files = "pthread.h";
  631. select = "#define[ \t]PTHREAD_ONCE_INIT \\\\\n"
  632. "\\{ \\\\\n";
  633. c_fix = format;
  634. c_fix_arg = "#define PTHREAD_ONCE_INIT \\\n"
  635. "{{ \\\n";
  636. test_text = "#define PTHREAD_ONCE_INIT \\\\\n"
  637. "{ \\\\\n";
  638. };
  639. fix = {
  640. hackname = aix_once_init_2;
  641. mach = "*-*-aix*";
  642. files = "pthread.h";
  643. select = "[ \t]0 \\\\\n"
  644. "\\}\n";
  645. c_fix = format;
  646. c_fix_arg = " 0 \\\n"
  647. "}}\n";
  648. test_text = " 0 \\\\\n"
  649. "}\n";
  650. };
  651. fix = {
  652. hackname = aix_mutex_initializer_1;
  653. mach = "*-*-aix*";
  654. files = "pthread.h";
  655. select = "#define[ \t]PTHREAD_MUTEX_INITIALIZER \\\\\n"
  656. "\\{ \\\\\n";
  657. c_fix = format;
  658. c_fix_arg = "#define PTHREAD_MUTEX_INITIALIZER \\\n"
  659. "{{ \\\n";
  660. test_text = "#define PTHREAD_MUTEX_INITIALIZER \\\\\n"
  661. "{ \\\\\n";
  662. };
  663. fix = {
  664. hackname = aix_cond_initializer_1;
  665. mach = "*-*-aix*";
  666. files = "pthread.h";
  667. select = "#define[ \t]PTHREAD_COND_INITIALIZER \\\\\n"
  668. "\\{ \\\\\n";
  669. c_fix = format;
  670. c_fix_arg = "#define PTHREAD_COND_INITIALIZER \\\n"
  671. "{{ \\\n";
  672. test_text = "#define PTHREAD_COND_INITIALIZER \\\\\n"
  673. "{ \\\\\n";
  674. };
  675. fix = {
  676. hackname = aix_rwlock_initializer_1;
  677. mach = "*-*-aix*";
  678. files = "pthread.h";
  679. select = "#define[ \t]PTHREAD_RWLOCK_INITIALIZER \\\\\n"
  680. "\\{ \\\\\n";
  681. c_fix = format;
  682. c_fix_arg = "#define PTHREAD_RWLOCK_INITIALIZER \\\n"
  683. "{{ \\\n";
  684. test_text = "#define PTHREAD_RWLOCK_INITIALIZER \\\\\n"
  685. "{ \\\\\n";
  686. };
  687. /*
  688. * pthread.h on AIX 4.3.3 tries to define a macro without whitspace
  689. * which violates a requirement of ISO C.
  690. */
  691. fix = {
  692. hackname = aix_pthread;
  693. files = "pthread.h";
  694. select = "(#define[\t ][A-Za-z_0-9]+)(\\\\\n[^A-Za-z_0-9 \t\n(])";
  695. c_fix = format;
  696. c_fix_arg = "%1 %2";
  697. test_text = "#define PTHREAD_MUTEX_INITIALIZER\\\\\n"
  698. "{...init stuff...}";
  699. };
  700. /*
  701. * AIX stdint.h fixes.
  702. */
  703. fix = {
  704. hackname = aix_stdint_1;
  705. mach = "*-*-aix*";
  706. files = stdint-aix.h, stdint.h;
  707. select = "#define[ \t]UINT8_MAX[ \t]\\(255U\\)\n"
  708. "#define[ \t]UINT16_MAX[ \t]\\(65535U\\)";
  709. c_fix = format;
  710. c_fix_arg = "#define UINT8_MAX (255)\n"
  711. "#define UINT16_MAX (65535)";
  712. test_text = "#define UINT8_MAX (255U)\n"
  713. "#define UINT16_MAX (65535U)";
  714. };
  715. /*
  716. * aix_stdint_2
  717. */
  718. fix = {
  719. hackname = aix_stdint_2;
  720. mach = "*-*-aix*";
  721. files = stdint-aix.h, stdint.h;
  722. select = "#define[ \t]INTPTR_MIN[ \t]INT64_MIN\n"
  723. "#define[ \t]INTPTR_MAX[ \t]INT64_MAX\n"
  724. "#define[ \t]UINTPTR_MAX[ \t]UINT64_MAX\n"
  725. "#else\n"
  726. "#define[ \t]INTPTR_MIN[ \t]INT32_MIN\n"
  727. "#define[ \t]INTPTR_MAX[ \t]INT32_MAX\n"
  728. "#define[ \t]UINTPTR_MAX[ \t]UINT32_MAX";
  729. c_fix = format;
  730. c_fix_arg = "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
  731. "#define INTPTR_MAX 9223372036854775807L\n"
  732. "#define UINTPTR_MAX 18446744073709551615UL\n"
  733. "#else\n"
  734. "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
  735. "#define INTPTR_MAX 2147483647L\n"
  736. "#define UINTPTR_MAX 4294967295UL";
  737. test_text = "#define INTPTR_MIN INT64_MIN\n"
  738. "#define INTPTR_MAX INT64_MAX\n"
  739. "#define UINTPTR_MAX UINT64_MAX\n"
  740. "#else\n"
  741. "#define INTPTR_MIN INT32_MIN\n"
  742. "#define INTPTR_MAX INT32_MAX\n"
  743. "#define UINTPTR_MAX UINT32_MAX";
  744. };
  745. /*
  746. * aix_stdint_3
  747. */
  748. fix = {
  749. hackname = aix_stdint_3;
  750. mach = "*-*-aix*";
  751. files = stdint-aix.h, stdint.h;
  752. select = "#define[ \t]PTRDIFF_MIN[ \t]INT64_MIN\n"
  753. "#define[ \t]PTRDIFF_MAX[ \t]INT64_MAX\n"
  754. "#else\n"
  755. "#define[ \t]PTRDIFF_MIN[ \t]*INT32_MIN\n"
  756. "#define[ \t]PTRDIFF_MAX[ \t]*INT32_MAX";
  757. c_fix = format;
  758. c_fix_arg = "#define PTRDIFF_MIN (-9223372036854775807L - 1)\n"
  759. "#define PTRDIFF_MAX 9223372036854775807L\n"
  760. "#else\n"
  761. "#define PTRDIFF_MIN (-2147483647L - 1)\n"
  762. "#define PTRDIFF_MAX 2147483647L";
  763. test_text = "#define PTRDIFF_MIN INT64_MIN\n"
  764. "#define PTRDIFF_MAX INT64_MAX\n"
  765. "#else\n"
  766. "#define PTRDIFF_MIN INT32_MIN\n"
  767. "#define PTRDIFF_MAX INT32_MAX";
  768. };
  769. /*
  770. * aix_stdint_4
  771. */
  772. fix = {
  773. hackname = aix_stdint_4;
  774. mach = "*-*-aix*";
  775. files = stdint-aix.h, stdint.h;
  776. select = "#define[ \t]SIZE_MAX[ \t]UINT64_MAX\n"
  777. "#else\n"
  778. "#define[ \t]SIZE_MAX[ \t]*UINT32_MAX";
  779. c_fix = format;
  780. c_fix_arg = "#define SIZE_MAX 18446744073709551615UL\n"
  781. "#else\n"
  782. "#define SIZE_MAX 4294967295UL";
  783. test_text = "#define SIZE_MAX UINT64_MAX\n"
  784. "#else\n"
  785. "#define SIZE_MAX UINT32_MAX";
  786. };
  787. /*
  788. * aix_stdint_5
  789. */
  790. fix = {
  791. hackname = aix_stdint_5;
  792. mach = "*-*-aix*";
  793. files = stdint-aix.h, stdint.h;
  794. select = "#define[ \t]UINT8_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)\n"
  795. "#define[ \t]UINT16_C\\(c\\)[ \t]__CONCAT__\\(c,U\\)";
  796. c_fix = format;
  797. c_fix_arg = "#define UINT8_C(c) c\n"
  798. "#define UINT16_C(c) c";
  799. test_text = "#define UINT8_C(c) __CONCAT__(c,U)\n"
  800. "#define UINT16_C(c) __CONCAT__(c,U)";
  801. };
  802. /*
  803. * stdlib.h on AIX 4.3 declares strtof() with a non-const first argument.
  804. */
  805. fix = {
  806. hackname = aix_strtof_const;
  807. files = stdlib.h;
  808. select = "((extern[ \t]+)?float[ \t]+strtof)\\(char \\*, char \\*\\*\\);";
  809. c_fix = format;
  810. c_fix_arg = "%1(const char *, char **);";
  811. test_text = "extern float strtof(char *, char **);";
  812. };
  813. /*
  814. * sys/machine.h on AIX 4.3.3 puts whitespace between a \ and a newline
  815. * in an otherwise harmless (and #ifed out) macro definition
  816. */
  817. fix = {
  818. hackname = aix_sysmachine;
  819. files = sys/machine.h;
  820. select = "\\\\ +\n";
  821. c_fix = format;
  822. c_fix_arg = "\\\n";
  823. test_text = "#define FOO \\\n"
  824. " bar \\ \n baz \\ \n bat";
  825. };
  826. /*
  827. * sys/wait.h on AIX 5.2 defines macros that have both signed and
  828. * unsigned types in conditional expressions.
  829. */
  830. fix = {
  831. hackname = aix_syswait_2;
  832. files = sys/wait.h;
  833. select = '\? (\(\(\(\(unsigned[^)]*\)[^)]*\) >> [^)]*\) \& 0xff\) : -1)';
  834. c_fix = format;
  835. c_fix_arg = "? (int)%1";
  836. test_text = "#define WSTOPSIG(__x) "
  837. "(int)(WIFSTOPPED(__x) ? ((((unsigned int)__x) >> 8) & 0xff) : -1)";
  838. };
  839. /*
  840. * sys/signal.h on some versions of AIX uses volatile in the typedef of
  841. * sig_atomic_t, which causes gcc to generate a warning about duplicate
  842. * volatile when a sig_atomic_t variable is declared volatile, as
  843. * required by ANSI C.
  844. */
  845. fix = {
  846. hackname = aix_volatile;
  847. files = sys/signal.h;
  848. select = "typedef volatile int sig_atomic_t";
  849. c_fix = format;
  850. c_fix_arg = "typedef int sig_atomic_t";
  851. test_text = "typedef volatile int sig_atomic_t;";
  852. };
  853. /*
  854. * Fix __assert declaration in assert.h on Alpha OSF/1.
  855. */
  856. fix = {
  857. hackname = alpha___assert;
  858. files = "assert.h";
  859. select = '__assert\(char \*, char \*, int\)';
  860. c_fix = format;
  861. c_fix_arg = "__assert(const char *, const char *, int)";
  862. test_text = 'extern void __assert(char *, char *, int);';
  863. };
  864. /*
  865. * Fix assert macro in assert.h on Alpha OSF/1.
  866. * The superfluous int cast breaks C++.
  867. */
  868. fix = {
  869. hackname = alpha_assert;
  870. files = "assert.h";
  871. select = "(#[ \t]*" 'define assert\(EX\).*)\(\(int\) \(EX\)\)';
  872. c_fix = format;
  873. c_fix_arg = "%1(EX)";
  874. test_text = '#define assert(EX) (((int) (EX)) ? (void)0 '
  875. ': __assert(#EX, __FILE__, __LINE__))';
  876. };
  877. /*
  878. * Fix getopt declarations in stdio.h and stdlib.h on Alpha OSF/1 and AIX.
  879. */
  880. fix = {
  881. hackname = alpha_getopt;
  882. files = "stdio.h";
  883. files = "stdlib.h";
  884. select = 'getopt\(int, char \*\[\], *char \*\)';
  885. c_fix = format;
  886. c_fix_arg = "getopt(int, char *const[], const char *)";
  887. test_text = 'extern int getopt(int, char *[], char *);';
  888. };
  889. /*
  890. * Fix missing semicolon on Alpha OSF/4 in <net/if.h>
  891. */
  892. fix = {
  893. hackname = alpha_if_semicolon;
  894. files = net/if.h;
  895. select = "struct[ \t]+sockaddr[ \t]+vmif_paddr[ \t]+/\\*";
  896. c_fix = format;
  897. c_fix_arg = "struct sockaddr vmif_paddr;\t/*";
  898. test_text = ' struct sockaddr vmif_paddr /* protocol address */';
  899. };
  900. /*
  901. * Remove erroneous parentheses in sym.h on Alpha OSF/1.
  902. */
  903. fix = {
  904. hackname = alpha_parens;
  905. files = sym.h;
  906. select = '#ifndef\(__mips64\)';
  907. c_fix = format;
  908. c_fix_arg = "#ifndef __mips64";
  909. test_text = "#ifndef(__mips64) /* bogus */\nextern int foo;\n#endif";
  910. };
  911. /*
  912. * Fix return value of sbrk in unistd.h on Alpha OSF/1 V2.0
  913. * And OpenBSD.
  914. */
  915. fix = {
  916. hackname = alpha_sbrk;
  917. files = unistd.h;
  918. select = "char[ \t]*\\*[\t ]*sbrk[ \t]*\\(";
  919. c_fix = format;
  920. c_fix_arg = "void *sbrk(";
  921. test_text = "extern char* sbrk(ptrdiff_t increment);";
  922. };
  923. /*
  924. * For C++, avoid any typedef or macro definition of bool,
  925. * and use the built in type instead.
  926. * HP/UX 10.20 also has it in curses_colr/curses.h.
  927. */
  928. fix = {
  929. hackname = avoid_bool_define;
  930. files = curses.h;
  931. files = curses_colr/curses.h;
  932. files = term.h;
  933. files = tinfo.h;
  934. select = "#[ \t]*define[ \t]+bool[ \t]";
  935. bypass = "__cplusplus";
  936. c_fix = format;
  937. c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
  938. c_fix_arg = "^[ \t]*#[ \t]*define[ \t]+bool[ \t].*";
  939. test_text = "# define bool\t char \n";
  940. };
  941. /*
  942. * avoid_bool_type
  943. */
  944. fix = {
  945. hackname = avoid_bool_type;
  946. files = curses.h;
  947. files = curses_colr/curses.h;
  948. files = term.h;
  949. files = tinfo.h;
  950. select = "^[ \t]*typedef[ \t].*[ \t]bool[ \t]*;";
  951. bypass = "__cplusplus";
  952. c_fix = format;
  953. c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
  954. test_text = "typedef unsigned int\tbool \t; /* bool\n type */";
  955. };
  956. /*
  957. * For C++, avoid any typedef definition of wchar_t,
  958. * and use the built in type instead.
  959. * Don't do this for headers that are smart enough to do the right
  960. * thing (recent [n]curses.h and Xlib.h).
  961. * Don't do it for <linux/nls.h> which is never used from C++ anyway,
  962. * and will be broken by the edit.
  963. */
  964. fix = {
  965. hackname = avoid_wchar_t_type;
  966. select = "^[ \t]*typedef[ \t].*[ \t]wchar_t[ \t]*;";
  967. bypass = "__cplusplus";
  968. bypass = "_LINUX_NLS_H";
  969. bypass = "XFree86: xc/lib/X11/Xlib\\.h";
  970. c_fix = format;
  971. c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
  972. test_text = "typedef unsigned short\twchar_t \t; /* wchar_t\n type */";
  973. };
  974. /*
  975. * Fix `typedef struct term;' on hppa1.1-hp-hpux9.
  976. */
  977. fix = {
  978. hackname = bad_struct_term;
  979. files = curses.h;
  980. select = "^[ \t]*typedef[ \t]+struct[ \t]+term[ \t]*;";
  981. c_fix = format;
  982. c_fix_arg = "struct term;";
  983. test_text = 'typedef struct term;';
  984. };
  985. /*
  986. * Fix one other error in this file:
  987. * a mismatched quote not inside a C comment.
  988. */
  989. fix = {
  990. hackname = badquote;
  991. files = sundev/vuid_event.h;
  992. select = "doesn't";
  993. c_fix = format;
  994. c_fix_arg = "does not";
  995. test_text = "/* doesn't have matched single quotes */";
  996. };
  997. /*
  998. * check for broken assert.h that needs stdio.h
  999. */
  1000. fix = {
  1001. hackname = broken_assert_stdio;
  1002. files = assert.h;
  1003. select = stderr;
  1004. bypass = "include.*stdio\\.h";
  1005. c_fix = wrap;
  1006. c_fix_arg = "#include <stdio.h>\n";
  1007. test_text = "extern FILE* stderr;";
  1008. };
  1009. /*
  1010. * check for broken assert.h that needs stdlib.h
  1011. */
  1012. fix = {
  1013. hackname = broken_assert_stdlib;
  1014. files = assert.h;
  1015. select = 'exit *\(|abort *\(';
  1016. bypass = "include.*stdlib\\.h";
  1017. c_fix = wrap;
  1018. c_fix_arg = "#ifdef __cplusplus\n"
  1019. "#include <stdlib.h>\n"
  1020. "#endif\n";
  1021. test_text = "extern void exit ( int );";
  1022. };
  1023. /*
  1024. * Remove `extern double cabs' declarations from math.h.
  1025. * This conflicts with C99. Discovered on AIX.
  1026. * Darwin hides its broken cabs in architecture-specific subdirs.
  1027. */
  1028. fix = {
  1029. hackname = broken_cabs;
  1030. files = math.h, "architecture/*/math.h";
  1031. select = "^extern[ \t]+double[ \t]+cabs";
  1032. sed = "s/^extern[ \t]*double[ \t]*cabs[ \t]*\([^\\\)]*\);//";
  1033. sed = "s/^extern[ \t]*long[ \t]*double[ \t]*cabsl[ \t]*\([^\\\)]*\);//";
  1034. test_text = "#ifdef __STDC__\n"
  1035. "extern double cabs(struct dbl_hypot);\n"
  1036. "#else\n"
  1037. "extern double cabs();\n"
  1038. "#endif\n"
  1039. "extern double cabs ( _Complex z );";
  1040. };
  1041. /*
  1042. * Fixup Darwin's broken check for __builtin_nanf.
  1043. */
  1044. fix = {
  1045. hackname = broken_nan;
  1046. /*
  1047. * It is tempting to omit the first "files" entry. Do not.
  1048. * The testing machinery will take the first "files" entry as the name
  1049. * of a test file to play with. It would be a nuisance to have a directory
  1050. * with the name "*".
  1051. */
  1052. files = "architecture/ppc/math.h";
  1053. files = "architecture/*/math.h";
  1054. select = '#if defined\(__APPLE_CC__\) && \(__APPLE_CC__ >= 1345\)';
  1055. bypass = "powl";
  1056. c_fix = format;
  1057. c_fix_arg = "#if 1";
  1058. test_text = "#if defined(__APPLE_CC__) && (__APPLE_CC__ >= 1345)";
  1059. };
  1060. /*
  1061. * Various systems derived from BSD4.4 contain a macro definition
  1062. * for vfscanf that interacts badly with requirements of builtin-attrs.def.
  1063. * Known to be fixed in FreeBSD 5 system headers.
  1064. */
  1065. fix = {
  1066. hackname = bsd_stdio_attrs_conflict;
  1067. mach = "*-*-*bsd*";
  1068. mach = "*-*-*darwin*";
  1069. files = stdio.h;
  1070. select = "^#define[ \t]*vfscanf[ \t]*__svfscanf[ \t]*$";
  1071. c_fix = format;
  1072. c_fix_arg = '#define _BSD_STRING(_BSD_X) _BSD_STRINGX(_BSD_X)' "\n"
  1073. '#define _BSD_STRINGX(_BSD_X) #_BSD_X' "\n"
  1074. 'int vfscanf(FILE *, const char *, __builtin_va_list) '
  1075. '__asm__ (_BSD_STRING(__USER_LABEL_PREFIX__) "__svfscanf");';
  1076. test_text = '#define vfscanf __svfscanf';
  1077. };
  1078. /*
  1079. * Fix various macros used to define ioctl numbers.
  1080. * The traditional syntax was:
  1081. *
  1082. * #define _CTRL(n, x) (('n'<<8)+x)
  1083. * #define TCTRLCFOO _CTRL(T, 1)
  1084. *
  1085. * but this does not work with the C standard, which disallows macro
  1086. * expansion inside strings. We have to rewrite it thus:
  1087. *
  1088. * #define _CTRL(n, x) ((n<<8)+x)
  1089. * #define TCTRLCFOO _CTRL('T', 1)
  1090. *
  1091. * The select expressions match too much, but the c_fix code is cautious.
  1092. *
  1093. * CTRL might be: CTRL _CTRL ISCTRL BSD43_CTRL ...
  1094. */
  1095. fix = {
  1096. hackname = ctrl_quotes_def;
  1097. select = "define[ \t]+[A-Z0-9_]+CTRL\\([a-zA-Z][,)]";
  1098. c_fix = char_macro_def;
  1099. c_fix_arg = "CTRL";
  1100. /*
  1101. * This is two tests in order to ensure that the "CTRL(c)" can
  1102. * be selected in isolation from the multi-arg format
  1103. */
  1104. test_text = "#define BSD43_CTRL(n, x) (('n'<<8)+x)\n";
  1105. test_text = "#define _CTRL(c) ('c'&037)";
  1106. };
  1107. /*
  1108. * Fix various macros used to define ioctl numbers.
  1109. */
  1110. fix = {
  1111. hackname = ctrl_quotes_use;
  1112. select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+CTRL[ \t]*\\( *[^,']";
  1113. c_fix = char_macro_use;
  1114. c_fix_arg = "CTRL";
  1115. test_text = "#define TCTRLFOO BSD43_CTRL(T, 1)";
  1116. };
  1117. /*
  1118. * sys/mman.h on HP/UX is not C++ ready,
  1119. * even though NO_IMPLICIT_EXTERN_C is defined on HP/UX.
  1120. *
  1121. * rpc/types.h on OSF1/2.0 is not C++ ready,
  1122. * even though NO_IMPLICIT_EXTERN_C is defined for the alpha.
  1123. *
  1124. * The problem is the declaration of malloc.
  1125. */
  1126. fix = {
  1127. hackname = cxx_unready;
  1128. files = sys/mman.h;
  1129. files = rpc/types.h;
  1130. select = '[^#]+malloc.*;'; /* Catch any form of declaration
  1131. not within a macro. */
  1132. bypass = '"C"|__BEGIN_DECLS';
  1133. c_fix = wrap;
  1134. c_fix_arg = "#ifdef __cplusplus\n"
  1135. "extern \"C\" {\n"
  1136. "#endif\n";
  1137. c_fix_arg = "#ifdef __cplusplus\n"
  1138. "}\n"
  1139. "#endif\n";
  1140. test_text = "extern void* malloc( size_t );";
  1141. };
  1142. /*
  1143. * For the AAB_darwin7_9_long_double_funcs fix to be useful,
  1144. * you have to not use "" includes.
  1145. */
  1146. fix = {
  1147. hackname = darwin_9_long_double_funcs_2;
  1148. mach = "*-*-darwin7.9*";
  1149. files = math.h;
  1150. select = '#include[ \t]+\"';
  1151. c_fix = format;
  1152. c_fix_arg = "%1<%2.h>";
  1153. c_fix_arg = '([ \t]*#[ \t]*include[ \t]+)"([a-z0-9/]+)\.h"';
  1154. test_text = '#include "architecture/ppc/math.h"';
  1155. };
  1156. /*
  1157. * On darwin8 and earlier, mach-o/swap.h isn't properly guarded
  1158. * by 'extern "C"'. On darwin7 some mach/ headers aren't properly guarded.
  1159. */
  1160. fix = {
  1161. hackname = darwin_externc;
  1162. mach = "*-*-darwin*";
  1163. files = mach-o/swap.h;
  1164. files = mach/mach_time.h;
  1165. files = mach/mach_traps.h;
  1166. files = mach/message.h;
  1167. files = mach/mig.h;
  1168. files = mach/semaphore.h;
  1169. bypass = "extern \"C\"";
  1170. bypass = "__BEGIN_DECLS";
  1171. c_fix = wrap;
  1172. c_fix_arg = "#ifdef __cplusplus\n"
  1173. "extern \"C\" {\n"
  1174. "#endif\n";
  1175. c_fix_arg = "#ifdef __cplusplus\n"
  1176. "}\n"
  1177. "#endif\n";
  1178. test_text = "extern void swap_fat_header();\n";
  1179. };
  1180. /*
  1181. * AvailabilityMacros.h on Darwin breaks with GCC 4.0, because of
  1182. * bad __GNUC__ tests.
  1183. */
  1184. fix = {
  1185. hackname = darwin_gcc4_breakage;
  1186. mach = "*-*-darwin*";
  1187. files = AvailabilityMacros.h;
  1188. select = "\\(__GNUC__ >= 3\\) && \\(__GNUC_MINOR__ >= 1\\)";
  1189. c_fix = format;
  1190. c_fix_arg = "((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))";
  1191. test_text = "#if defined(__GNUC__) && (__GNUC__ >= 3) && "
  1192. "(__GNUC_MINOR__ >= 1)\n";
  1193. };
  1194. /*
  1195. * __private_extern__ doesn't exist in FSF GCC. Even if it did,
  1196. * why would you ever put it in a system header file?
  1197. */
  1198. fix = {
  1199. hackname = darwin_private_extern;
  1200. mach = "*-*-darwin*";
  1201. files = mach-o/dyld.h;
  1202. select = "__private_extern__ [a-z_]+ _dyld_";
  1203. c_fix = format;
  1204. c_fix_arg = "extern";
  1205. c_fix_arg = "__private_extern__";
  1206. test_text = "__private_extern__ int _dyld_func_lookup(\n"
  1207. "const char *dyld_func_name,\n"
  1208. "unsigned long *address);\n";
  1209. };
  1210. /*
  1211. * Darwin headers have a stdint.h that defines UINT8_C and UINT16_C to
  1212. * unsigned constants.
  1213. */
  1214. fix = {
  1215. hackname = darwin_stdint_1;
  1216. mach = "*-*-darwin*";
  1217. files = stdint-darwin.h, stdint.h;
  1218. c_fix = format;
  1219. c_fix_arg = "#define UINT8_C(v)\tv\n#define UINT16_C(v)\tv";
  1220. select = "#define UINT8_C\\(v\\)[ \t]+\\(v ## U\\)\n"
  1221. "#define UINT16_C\\(v\\)[ \t]+\\(v ## U\\)";
  1222. test_text = "#define UINT8_C(v) (v ## U)\n"
  1223. "#define UINT16_C(v) (v ## U)";
  1224. };
  1225. /*
  1226. * Darwin headers have a stdint.h that defines INTPTR_MIN and INTPTR_MAX
  1227. * with wrong types.
  1228. */
  1229. fix = {
  1230. hackname = darwin_stdint_2;
  1231. mach = "*-*-darwin*";
  1232. files = stdint-darwin.h, stdint.h;
  1233. c_fix = format;
  1234. c_fix_arg = "#if __WORDSIZE == 64\n"
  1235. "#define INTPTR_MAX 9223372036854775807L\n"
  1236. "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
  1237. "#else\n"
  1238. "#define INTPTR_MAX 2147483647L\n"
  1239. "#define INTPTR_MIN (-INTPTR_MAX-1)\n"
  1240. "#endif";
  1241. select = "#if __WORDSIZE == 64\n"
  1242. "#define INTPTR_MIN[ \t]+INT64_MIN\n"
  1243. "#define INTPTR_MAX[ \t]+INT64_MAX\n"
  1244. "#else\n"
  1245. "#define INTPTR_MIN[ \t]+INT32_MIN\n"
  1246. "#define INTPTR_MAX[ \t]+INT32_MAX\n"
  1247. "#endif";
  1248. test_text = "#if __WORDSIZE == 64\n"
  1249. "#define INTPTR_MIN INT64_MIN\n"
  1250. "#define INTPTR_MAX INT64_MAX\n"
  1251. "#else\n"
  1252. "#define INTPTR_MIN INT32_MIN\n"
  1253. "#define INTPTR_MAX INT32_MAX\n"
  1254. "#endif";
  1255. };
  1256. /*
  1257. * Darwin headers have a stdint.h that defines UINTPTR_MAX with a wrong type.
  1258. */
  1259. fix = {
  1260. hackname = darwin_stdint_3;
  1261. mach = "*-*-darwin*";
  1262. files = stdint-darwin.h, stdint.h;
  1263. c_fix = format;
  1264. c_fix_arg = "#if __WORDSIZE == 64\n"
  1265. "#define UINTPTR_MAX 18446744073709551615UL\n"
  1266. "#else\n"
  1267. "#define UINTPTR_MAX 4294967295UL\n"
  1268. "#endif";
  1269. select = "#if __WORDSIZE == 64\n"
  1270. "#define UINTPTR_MAX[ \t]+UINT64_MAX\n"
  1271. "#else\n"
  1272. "#define UINTPTR_MAX[ \t]+UINT32_MAX\n"
  1273. "#endif";
  1274. test_text = "#if __WORDSIZE == 64\n"
  1275. "#define UINTPTR_MAX UINT64_MAX\n"
  1276. "#else\n"
  1277. "#define UINTPTR_MAX UINT32_MAX\n"
  1278. "#endif";
  1279. };
  1280. /*
  1281. * Darwin headers have a stdint.h that defines SIZE_MAX with a wrong type.
  1282. */
  1283. fix = {
  1284. hackname = darwin_stdint_4;
  1285. mach = "*-*-darwin*";
  1286. files = stdint-darwin.h, stdint.h;
  1287. c_fix = format;
  1288. c_fix_arg = "#if __WORDSIZE == 64\n"
  1289. "#define SIZE_MAX 18446744073709551615UL\n"
  1290. "#else\n"
  1291. "#define SIZE_MAX 4294967295UL\n"
  1292. "#endif";
  1293. select = "#if __WORDSIZE == 64\n"
  1294. "#define SIZE_MAX[ \t]+UINT64_MAX\n"
  1295. "#else\n"
  1296. "#define SIZE_MAX[ \t]+UINT32_MAX\n"
  1297. "#endif";
  1298. test_text = "#if __WORDSIZE == 64\n"
  1299. "#define SIZE_MAX UINT64_MAX\n"
  1300. "#else\n"
  1301. "#define SIZE_MAX UINT32_MAX\n"
  1302. "#endif";
  1303. };
  1304. /*
  1305. * Darwin headers have a stdint.h that defines {U,}INTMAX_{MIN,MAX}
  1306. * with a wrong type.
  1307. */
  1308. fix = {
  1309. hackname = darwin_stdint_5;
  1310. mach = "*-*-darwin*";
  1311. files = stdint-darwin.h, stdint.h;
  1312. c_fix = format;
  1313. c_fix_arg = "#if __WORDSIZE == 64\n"
  1314. "#define INTMAX_MIN (-9223372036854775807L - 1)\n"
  1315. "#define INTMAX_MAX 9223372036854775807L\n"
  1316. "#define UINTMAX_MAX 18446744073709551615UL\n"
  1317. "#else\n"
  1318. "#define INTMAX_MIN (-9223372036854775807LL - 1)\n"
  1319. "#define INTMAX_MAX 9223372036854775807LL\n"
  1320. "#define UINTMAX_MAX 18446744073709551615ULL\n"
  1321. "#endif";
  1322. select = "#define INTMAX_MIN[ \t]+INT64_MIN\n"
  1323. "#define INTMAX_MAX[ \t]+INT64_MAX\n"
  1324. "\n"
  1325. "#define UINTMAX_MAX[ \t]+UINT64_MAX";
  1326. test_text = "#define INTMAX_MIN INT64_MIN\n"
  1327. "#define INTMAX_MAX INT64_MAX\n"
  1328. "\n"
  1329. "#define UINTMAX_MAX UINT64_MAX";
  1330. };
  1331. /*
  1332. * Darwin headers have a stdint.h that defines {U,}INTMAX_C
  1333. * with a wrong type.
  1334. */
  1335. fix = {
  1336. hackname = darwin_stdint_6;
  1337. mach = "*-*-darwin*";
  1338. files = stdint-darwin.h, stdint.h;
  1339. c_fix = format;
  1340. c_fix_arg = "#if __WORDSIZE == 64\n"
  1341. "#define PTRDIFF_MIN (-9223372036854775807L - 1)\n"
  1342. "#define PTRDIFF_MAX 9223372036854775807L\n"
  1343. "#else\n"
  1344. "#define PTRDIFF_MIN (-2147483647 - 1)\n"
  1345. "#define PTRDIFF_MAX 2147483647\n"
  1346. "#endif";
  1347. select = "#if __WORDSIZE == 64\n"
  1348. "#define PTRDIFF_MIN[ \t]+INT64_MIN\n"
  1349. "#define PTRDIFF_MAX[ \t]+INT64_MAX\n"
  1350. "#else\n"
  1351. "#define PTRDIFF_MIN[ \t]+INT32_MIN\n"
  1352. "#define PTRDIFF_MAX[ \t]+INT32_MAX\n"
  1353. "#endif";
  1354. test_text = "#if __WORDSIZE == 64\n"
  1355. "#define PTRDIFF_MIN INT64_MIN\n"
  1356. "#define PTRDIFF_MAX INT64_MAX\n"
  1357. "#else\n"
  1358. "#define PTRDIFF_MIN INT32_MIN\n"
  1359. "#define PTRDIFF_MAX INT32_MAX\n"
  1360. "#endif";
  1361. };
  1362. /*
  1363. * Darwin headers have a stdint.h that defines {U,}INTMAX_C
  1364. * with a wrong type.
  1365. */
  1366. fix = {
  1367. hackname = darwin_stdint_7;
  1368. mach = "*-*-darwin*";
  1369. files = stdint-darwin.h, stdint.h;
  1370. c_fix = format;
  1371. c_fix_arg = "#if __WORDSIZE == 64\n"
  1372. "#define INTMAX_C(v) (v ## L)\n"
  1373. "#define UINTMAX_C(v) (v ## UL)\n"
  1374. "#else\n"
  1375. "#define INTMAX_C(v) (v ## LL)\n"
  1376. "#define UINTMAX_C(v) (v ## ULL)\n"
  1377. "#endif";
  1378. select = "#define INTMAX_C\\(v\\)[ \t]+\\(v ## LL\\)\n"
  1379. "#define UINTMAX_C\\(v\\)[ \t]+\\(v ## ULL\\)";
  1380. test_text = "#define INTMAX_C(v) (v ## LL)\n"
  1381. "#define UINTMAX_C(v) (v ## ULL)";
  1382. };
  1383. /*
  1384. * Fix <c_asm.h> on Digital UNIX V4.0:
  1385. * It contains a prototype for a DEC C internal asm() function,
  1386. * clashing with gcc's asm keyword. So protect this with __DECC.
  1387. */
  1388. fix = {
  1389. hackname = dec_intern_asm;
  1390. files = c_asm.h;
  1391. sed = "/^[ \t]*float[ \t]*fasm/i\\\n#ifdef __DECC\n";
  1392. sed = "/^[ \t]*#[ \t]*pragma[ \t]*intrinsic([ \t]*dasm/a\\\n"
  1393. "#endif\n";
  1394. test_text =
  1395. "float fasm {\n"
  1396. " ... asm stuff ...\n"
  1397. "};\n#pragma intrinsic( dasm )\n/* END ASM TEST*/";
  1398. };
  1399. /*
  1400. * Fix typo in <wchar.h> on DJGPP 2.03.
  1401. */
  1402. fix = {
  1403. hackname = djgpp_wchar_h;
  1404. file = wchar.h;
  1405. select = "__DJ_wint_t";
  1406. bypass = "sys/djtypes.h";
  1407. c_fix = format;
  1408. c_fix_arg = "%0\n#include <sys/djtypes.h>";
  1409. c_fix_arg = "#include <stddef.h>";
  1410. test_text = "#include <stddef.h>\n"
  1411. "extern __DJ_wint_t x;\n";
  1412. };
  1413. /*
  1414. * Fix these Sun OS files to avoid an invalid identifier in an #ifdef.
  1415. */
  1416. fix = {
  1417. hackname = ecd_cursor;
  1418. files = "sunwindow/win_lock.h";
  1419. files = "sunwindow/win_cursor.h";
  1420. select = 'ecd\.cursor';
  1421. c_fix = format;
  1422. c_fix_arg = 'ecd_cursor';
  1423. test_text = "#ifdef ecd.cursor\n#error bogus\n#endif /* ecd+cursor */";
  1424. };
  1425. /*
  1426. * Incorrect feraiseexcept extern inline in bits/fenv.h on x86_64
  1427. * that fails when compiling for SSE-less 32-bit x86.
  1428. */
  1429. fix = {
  1430. hackname = feraiseexcept_nosse_divbyzero;
  1431. mach = 'i[34567]86-*-linux*', 'x86*-linux*', 'amd64-*-linux*';
  1432. files = bits/fenv.h, '*/bits/fenv.h';
  1433. select = "^([\t ]*)__asm__ __volatile__ \\(\"divss %1, %0 *\" : "
  1434. ": \"x\" \\(__f\\), \"x\" \\(__g\\)\\);$";
  1435. bypass = "\"fdivp .*; fwait\"";
  1436. c_fix = format;
  1437. c_fix_arg = <<- _EOText_
  1438. # ifdef __SSE_MATH__
  1439. %0
  1440. # else
  1441. %1__asm__ __volatile__ ("fdivp %%%%st, %%%%st(1); fwait"
  1442. %1 : "=t" (__f) : "0" (__f), "u" (__g) : "st(1)");
  1443. # endif
  1444. _EOText_;
  1445. test_text = <<- _EOText_
  1446. __asm__ __volatile__ ("divss %1, %0" : : "x" (__f), "x" (__g));
  1447. _EOText_;
  1448. };
  1449. /*
  1450. * Incorrect feraiseexcept extern inline in bits/fenv.h on x86_64
  1451. * that fails when compiling for SSE-less 32-bit x86.
  1452. */
  1453. fix = {
  1454. hackname = feraiseexcept_nosse_invalid;
  1455. mach = 'i[34567]86-*-linux*', 'x86*-linux*', 'amd64-*-linux*';
  1456. files = bits/fenv.h, '*/bits/fenv.h';
  1457. select = "^([\t ]*)__asm__ __volatile__ \\(\"divss %0, %0 *\" : "
  1458. ": \"x\" \\(__f\\)\\);$";
  1459. bypass = "\"fdiv .*; fwait\"";
  1460. c_fix = format;
  1461. c_fix_arg = <<- _EOText_
  1462. # ifdef __SSE_MATH__
  1463. %0
  1464. # else
  1465. %1__asm__ __volatile__ ("fdiv %%%%st, %%%%st(0); fwait"
  1466. %1 : "=t" (__f) : "0" (__f));
  1467. # endif
  1468. _EOText_;
  1469. test_text = <<- _EOText_
  1470. __asm__ __volatile__ ("divss %0, %0" : : "x" (__f));
  1471. _EOText_;
  1472. };
  1473. /*
  1474. * Between 8/24/1998 and 2/17/2001, FreeBSD system headers presume
  1475. * neither the existence of GCC 3 nor its exact feature set yet break
  1476. * (by design?) when __GNUC__ is set beyond 2.
  1477. */
  1478. fix = {
  1479. hackname = freebsd_gcc3_breakage;
  1480. mach = "*-*-freebsd*";
  1481. files = sys/cdefs.h;
  1482. select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7$';
  1483. bypass = '__GNUC__[ \t]*([>=]=[ \t]*[3-9]|>[ \t]*2)';
  1484. c_fix = format;
  1485. c_fix_arg = '%0 || __GNUC__ >= 3';
  1486. test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7';
  1487. };
  1488. /*
  1489. * Some releases of FreeBSD 4 and FreeBSD 5.0 and 5.1 system headers presume
  1490. * neither the existence of GCC 4 nor its exact feature set yet break
  1491. * (by design?) when __GNUC__ is set beyond 3.
  1492. */
  1493. fix = {
  1494. hackname = freebsd_gcc4_breakage;
  1495. mach = "*-*-freebsd*";
  1496. files = sys/cdefs.h;
  1497. select = '^#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 \|\| __GNUC__ == 3$';
  1498. c_fix = format;
  1499. c_fix_arg = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ >= 3';
  1500. test_text = '#if __GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ == 3';
  1501. };
  1502. /*
  1503. * Some versions of glibc don't expect the C99 inline semantics.
  1504. */
  1505. fix = {
  1506. hackname = glibc_c99_inline_1;
  1507. files = features.h, '*/features.h';
  1508. select = "^ *&& !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__$";
  1509. c_fix = format;
  1510. c_fix_arg = "%0 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)";
  1511. test_text = <<-EOT
  1512. #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ \
  1513. && !defined __OPTIMIZE_SIZE__ && !defined __NO_INLINE__
  1514. # define __USE_EXTERN_INLINES 1
  1515. #endif
  1516. EOT;
  1517. };
  1518. /*
  1519. * Similar, but a version that didn't have __NO_INLINE__
  1520. */
  1521. fix = {
  1522. hackname = glibc_c99_inline_1a;
  1523. files = features.h, '*/features.h';
  1524. select = "(\\) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__)\n"
  1525. "(#[ \t]*define[ \t]*__USE_EXTERN_INLINES[ \t]*1)";
  1526. c_fix = format;
  1527. c_fix_arg = "%1 && (defined __extern_inline || defined __GNUC_GNU_INLINE__)\n%2";
  1528. test_text = <<-EOT
  1529. #if __GNUC_PREREQ (2, 7) && defined __OPTIMIZE__ && !defined __OPTIMIZE_SIZE__
  1530. # define __USE_EXTERN_INLINES 1
  1531. #endif
  1532. EOT;
  1533. };
  1534. /*
  1535. * The glibc_c99_inline_1 fix should have fixed everything. Unfortunately
  1536. * there are many glibc headers which do not respect __USE_EXTERN_INLINES.
  1537. * The remaining glibc_c99_inline_* fixes deal with some of those headers.
  1538. */
  1539. fix = {
  1540. hackname = glibc_c99_inline_2;
  1541. files = sys/stat.h, '*/sys/stat.h';
  1542. select = "extern __inline__ int";
  1543. sed = "s/extern int \\(stat\\)/"
  1544. "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
  1545. "__inline__ int \\1/";
  1546. sed = "s/extern int \\([lf]stat\\)/"
  1547. "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
  1548. "__inline__ int \\1/";
  1549. sed = "s/extern int \\(mknod\\)/"
  1550. "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
  1551. "__inline__ int \\1/";
  1552. sed = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\(stat\\)/"
  1553. "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
  1554. "__inline__ int __REDIRECT\\1 (\\2/";
  1555. sed = "s/extern int __REDIRECT\\(_NTH\\)\\{0,1\\} (\\([lf]stat\\)/"
  1556. "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
  1557. "__inline__ int __REDIRECT\\1 (\\2/";
  1558. sed = "s/^extern __inline__ int/"
  1559. "#ifdef __GNUC_GNU_INLINE__\\\nextern\\\n#endif\\\n"
  1560. "__inline__ int/";
  1561. test_text = <<-EOT
  1562. extern int fstat64 (int __fd, struct stat64 *__buf) __THROW __nonnull ((2));
  1563. extern __inline__ int
  1564. __NTH (fstat64 (int __fd, struct stat64 *__statbuf))
  1565. {}
  1566. EOT;
  1567. };
  1568. /*
  1569. * glibc_c99_inline_3
  1570. */
  1571. fix = {
  1572. hackname = glibc_c99_inline_3;
  1573. files = bits/string2.h, '*/bits/string2.h';
  1574. select = "extern __inline";
  1575. bypass = "__extern_inline|__GNU_STDC_INLINE__";
  1576. c_fix = format;
  1577. c_fix_arg = "# if defined(__cplusplus) || defined(__GNUC_STDC_INLINE__)";
  1578. c_fix_arg = "^# ifdef __cplusplus$";
  1579. test_text = <<-EOT
  1580. # ifdef __cplusplus
  1581. # define __STRING_INLINE inline
  1582. # else
  1583. # define __STRING_INLINE extern __inline
  1584. # endif
  1585. EOT;
  1586. };
  1587. /*
  1588. * glibc_c99_inline_4
  1589. */
  1590. fix = {
  1591. hackname = glibc_c99_inline_4;
  1592. files = sys/sysmacros.h, '*/sys/sysmacros.h', wchar.h, '*/wchar.h',
  1593. pthread.h, '*/pthread.h';
  1594. bypass = "__extern_inline|__gnu_inline__";
  1595. select = "(^| )extern __inline";
  1596. c_fix = format;
  1597. c_fix_arg = "%0 __attribute__ ((__gnu_inline__))";
  1598. test_text = <<-EOT
  1599. __extension__ extern __inline unsigned int
  1600. extern __inline unsigned int
  1601. EOT;
  1602. };
  1603. /* glibc-2.3.5 defines pthread mutex initializers incorrectly,
  1604. * so we replace them with versions that correspond to the
  1605. * definition.
  1606. */
  1607. fix = {
  1608. hackname = glibc_mutex_init;
  1609. files = pthread.h;
  1610. select = '\{ *\{ *0, *\} *\}';
  1611. sed = "/define[ \t]\\{1,\\}PTHREAD_MUTEX_INITIALIZER[ \t]*\\\\/{\n"
  1612. "N\ns/{ { 0, } }/{ { 0, 0, 0, 0, 0, 0 } }/\n}";
  1613. sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
  1614. "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0 }/";
  1615. sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
  1616. "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0 }/";
  1617. sed = "s/{ \\(0, 0, 0, 0, PTHREAD_MUTEX_"
  1618. "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0 }/";
  1619. sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
  1620. "\\(RECURSIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
  1621. sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
  1622. "\\(ERRORCHECK\\)_NP\\) }/{ \\1, 0, 0 }/";
  1623. sed = "s/{ \\(0, 0, 0, PTHREAD_MUTEX_"
  1624. "\\(ADAPTIVE\\)_NP\\) }/{ \\1, 0, 0 }/";
  1625. sed = "/define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\/"
  1626. "N;s/^[ \t]*#[ \t]*"
  1627. "\\(define[ \t]\\{1,\\}PTHREAD_RWLOCK_INITIALIZER[ \t]*\\\\\\)\\n"
  1628. "[ \t]*{ { 0, } }/# if __WORDSIZE == 64\\\n"
  1629. "# \\1\\\n"
  1630. " { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
  1631. "# else\\\n"
  1632. "# \\1\\\n"
  1633. " { { 0, 0, 0, 0, 0, 0, 0, 0 } }\\\n"
  1634. "# endif/";
  1635. sed = "s/{ \\(0, 0, 0, 0, 0, 0, "
  1636. "PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP\\) }/{ \\1, 0 }/";
  1637. sed = "/define[ \t]\\{1,\\}PTHREAD_COND_INITIALIZER/"
  1638. "s/{ { 0, } }/{ { 0, 0, 0, 0, 0, (void *) 0, 0, 0 } }/";
  1639. test_text = <<- _EOText_
  1640. #define PTHREAD_MUTEX_INITIALIZER \\
  1641. { { 0, } }
  1642. #ifdef __USE_GNU
  1643. # if __WORDSIZE == 64
  1644. # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
  1645. { { 0, 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
  1646. # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
  1647. { { 0, 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
  1648. # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
  1649. { { 0, 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
  1650. # else
  1651. # define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP \\
  1652. { { 0, 0, 0, PTHREAD_MUTEX_RECURSIVE_NP } }
  1653. # define PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP \\
  1654. { { 0, 0, 0, PTHREAD_MUTEX_ERRORCHECK_NP } }
  1655. # define PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP \\
  1656. { { 0, 0, 0, PTHREAD_MUTEX_ADAPTIVE_NP } }
  1657. # endif
  1658. #endif
  1659. # define PTHREAD_RWLOCK_INITIALIZER \\
  1660. { { 0, } }
  1661. # ifdef __USE_GNU
  1662. # if __WORDSIZE == 64
  1663. # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
  1664. { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \\
  1665. PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
  1666. # else
  1667. # define PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \\
  1668. { { 0, 0, 0, 0, 0, 0, PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP } }
  1669. # endif
  1670. # endif
  1671. #define PTHREAD_COND_INITIALIZER { { 0, } }
  1672. _EOText_;
  1673. };
  1674. /* glibc versions before 2.5 have a version of stdint.h that defines
  1675. UINT8_C and UINT16_C to produce unsigned constants, as do uClibc
  1676. versions with stdint.h based on those glibc versions. */
  1677. fix = {
  1678. hackname = glibc_stdint;
  1679. files = stdint.h;
  1680. select = "GNU C Library";
  1681. c_fix = format;
  1682. c_fix_arg = "# define UINT8_C(c)\tc\n# define UINT16_C(c)\tc";
  1683. c_fix_arg = "# define UINT8_C\\(c\\)\tc ## U\n# define UINT16_C\\(c\\)\tc ## U";
  1684. test_text = "/* This file is part of the GNU C Library. */\n"
  1685. "# define UINT8_C(c)\tc ## U\n"
  1686. "# define UINT16_C(c)\tc ## U";
  1687. };
  1688. /* Some versions of glibc have a version of bits/string2.h that
  1689. produces "value computed is not used" warnings from strncpy; fix
  1690. this definition by using __builtin_strncpy instead as in newer
  1691. versions. */
  1692. fix = {
  1693. hackname = glibc_strncpy;
  1694. files = bits/string2.h, '*/bits/string2.h';
  1695. bypass = "__builtin_strncpy";
  1696. c_fix = format;
  1697. c_fix_arg = "# define strncpy(dest, src, n) __builtin_strncpy (dest, src, n)";
  1698. c_fix_arg = "# define strncpy([^\n]*\\\\\n)*[^\n]*";
  1699. test_text = <<-EOT
  1700. # define strncpy(dest, src, n) \
  1701. (__extension__ (__builtin_constant_p (src) && __builtin_constant_p (n) \\
  1702. ? (strlen (src) + 1 >= ((size_t) (n)) \\
  1703. ? (char *) memcpy (dest, src, n) \\
  1704. : strncpy (dest, src, n)) \\
  1705. : strncpy (dest, src, n)))
  1706. EOT;
  1707. };
  1708. /* glibc's tgmath.h relies on an expression that is not an integer
  1709. constant expression being treated as it was by GCC 4.4 and
  1710. earlier. */
  1711. fix = {
  1712. hackname = glibc_tgmath;
  1713. files = tgmath.h;
  1714. select = '\(\(\(type\) 0.25\) && \(\(type\) 0.25 - 1\)\)';
  1715. bypass = "__floating_type\\(type\\) \\\\\n.*__builtin_classify_type";
  1716. c_fix = format;
  1717. c_fix_arg = "(__builtin_classify_type ((type) 0) == 8 || "
  1718. "(__builtin_classify_type ((type) 0) == 9 && "
  1719. "__builtin_classify_type (__real__ ((type) 0)) == 8))";
  1720. test_text = "# define __floating_type(type) (((type) 0.25) && ((type) 0.25 - 1))";
  1721. };
  1722. /*
  1723. * Fix these files to use the types we think they should for
  1724. * ptrdiff_t, size_t, and wchar_t.
  1725. *
  1726. * This defines the types in terms of macros predefined by our 'cpp'.
  1727. * This is supposedly necessary for glibc's handling of these types.
  1728. * It's probably not necessary for anyone else, but it doesn't hurt.
  1729. */
  1730. fix = {
  1731. hackname = gnu_types;
  1732. files = "sys/types.h";
  1733. files = "stdlib.h";
  1734. files = "sys/stdtypes.h";
  1735. files = "stddef.h";
  1736. files = "memory.h";
  1737. files = "unistd.h";
  1738. bypass = '_GCC_(PTRDIFF|SIZE|WCHAR)_T';
  1739. select = "^[ \t]*typedef[ \t]+.*[ \t](ptrdiff|size|wchar)_t;";
  1740. c_fix = gnu_type;
  1741. /* The Solaris 10 headers already define these types correctly. */
  1742. mach = '*-*-solaris2.1[0-9]*';
  1743. not_machine = true;
  1744. test_text = "typedef long int ptrdiff_t; /* long int */\n"
  1745. "typedef uint_t size_t; /* uint_t */\n"
  1746. "typedef ushort_t wchar_t; /* ushort_t */";
  1747. };
  1748. /*
  1749. * Fix HP & Sony's use of "../machine/xxx.h"
  1750. * to refer to: <machine/xxx.h>
  1751. */
  1752. fix = {
  1753. hackname = hp_inline;
  1754. files = sys/spinlock.h;
  1755. files = machine/machparam.h;
  1756. select = "[ \t]*#[ \t]*include[ \t]+" '"\.\./machine/';
  1757. c_fix = format;
  1758. c_fix_arg = "%1<machine/%2.h>";
  1759. c_fix_arg = "([ \t]*#[ \t]*include[ \t]+)" '"\.\./machine/'
  1760. '([a-z]+)\.h"';
  1761. test_text = ' # include "../machine/mumble.h"';
  1762. };
  1763. /*
  1764. * Check for (...) in C++ code in HP/UX sys/file.h.
  1765. */
  1766. fix = {
  1767. hackname = hp_sysfile;
  1768. files = sys/file.h;
  1769. select = "HPUX_SOURCE";
  1770. c_fix = format;
  1771. c_fix_arg = "(struct file *, ...)";
  1772. c_fix_arg = '\(\.\.\.\)';
  1773. test_text = "extern void foo(...); /* HPUX_SOURCE - bad varargs */";
  1774. };
  1775. /*
  1776. * Un-Hide a series of five FP defines from post-1999 compliance GCC:
  1777. * FP_NORMAL, FP_ZERO, FP_INFINITE, FP_SUBNORMAL and FP_NAN
  1778. */
  1779. fix = {
  1780. hackname = hppa_hpux_fp_macros;
  1781. mach = "hppa*-hp-hpux11*";
  1782. files = math.h;
  1783. select = "#[ \t]*define[ \t]*FP_NORMAL.*\n"
  1784. "#[ \t]*define[ \t]*FP_ZERO.*\n"
  1785. "#[ \t]*define[ \t]*FP_INFINITE.*\n"
  1786. "#[ \t]*define[ \t]*FP_SUBNORMAL.*\n"
  1787. "#[ \t]*define[ \t]*FP_NAN.*\n";
  1788. c_fix = format;
  1789. c_fix_arg = <<- _EOFix_
  1790. #endif /* _INCLUDE_HPUX_SOURCE */
  1791. #if defined(_INCLUDE_HPUX_SOURCE) || \
  1792. (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))
  1793. %0#endif
  1794. #ifdef _INCLUDE_HPUX_SOURCE
  1795. _EOFix_;
  1796. test_text =
  1797. "# define FP_NORMAL 0\n"
  1798. "# define FP_ZERO 1\n"
  1799. "# define FP_INFINITE 2\n"
  1800. "# define FP_SUBNORMAL 3\n"
  1801. "# define FP_NAN 4\n";
  1802. };
  1803. /*
  1804. * Delete C++ double pow (double, int) inline function from HP-UX 10 & 11
  1805. * math.h to prevent clash with define in c_std/bits/std_cmath.h.
  1806. */
  1807. fix = {
  1808. hackname = hpux10_cpp_pow_inline;
  1809. files = fixinc-test-limits.h, math.h;
  1810. select = <<- END_POW_INLINE
  1811. ^# +ifdef +__cplusplus
  1812. +\}
  1813. +inline +double +pow\(double +__d,int +__expon\) +\{
  1814. [ ]+return +pow\(__d,\(double\)__expon\);
  1815. +\}
  1816. +extern +"C" +\{
  1817. #else
  1818. # +endif
  1819. END_POW_INLINE;
  1820. c_fix = format;
  1821. c_fix_arg = "";
  1822. test_text =
  1823. "# ifdef __cplusplus\n"
  1824. " }\n"
  1825. " inline double pow(double __d,int __expon) {\n"
  1826. "\t return pow(__d,(double)__expon);\n"
  1827. " }\n"
  1828. ' extern "C"' " {\n"
  1829. "#else\n"
  1830. "# endif";
  1831. };
  1832. fix = {
  1833. hackname = hpux11_cpp_pow_inline;
  1834. files = math.h;
  1835. select = " +inline double pow\\(double d,int expon\\) \\{\n"
  1836. " +return pow\\(d, \\(double\\)expon\\);\n"
  1837. " +\\}\n";
  1838. c_fix = format;
  1839. c_fix_arg = "";
  1840. test_text =
  1841. " inline double pow(double d,int expon) {\n"
  1842. " return pow(d, (double)expon);\n"
  1843. " }\n";
  1844. };
  1845. /*
  1846. * Fix hpux 10.X missing ctype declarations 1
  1847. */
  1848. fix = {
  1849. hackname = hpux10_ctype_declarations1;
  1850. files = ctype.h;
  1851. select = "^#[ \t]*define _toupper\\(__c\\)[ \t]*__toupper\\(__c\\)";
  1852. bypass = "^[ \t]*extern[ \t]*int[ \t]*__tolower[ \t]*\\(";
  1853. c_fix = format;
  1854. c_fix_arg = "#ifdef _PROTOTYPES\n"
  1855. "extern int __tolower(int);\n"
  1856. "extern int __toupper(int);\n"
  1857. "#else /* NOT _PROTOTYPES */\n"
  1858. "extern int __tolower();\n"
  1859. "extern int __toupper();\n"
  1860. "#endif /* _PROTOTYPES */\n\n"
  1861. "%0\n";
  1862. test_text = "# define _toupper(__c) __toupper(__c)\n";
  1863. };
  1864. /*
  1865. * Fix hpux 10.X missing ctype declarations 2
  1866. */
  1867. fix = {
  1868. hackname = hpux10_ctype_declarations2;
  1869. files = ctype.h;
  1870. select = "^# if defined\\(_SB_CTYPE_MACROS\\) && \\!defined\\(__lint\\)";
  1871. bypass = "^[ \t]*extern[ \t]*int[ \t]*_isalnum[ \t]*\\(";
  1872. c_fix = format;
  1873. c_fix_arg = "%0\n\n"
  1874. "#ifdef _PROTOTYPES\n"
  1875. " extern int _isalnum(int);\n"
  1876. " extern int _isalpha(int);\n"
  1877. " extern int _iscntrl(int);\n"
  1878. " extern int _isdigit(int);\n"
  1879. " extern int _isgraph(int);\n"
  1880. " extern int _islower(int);\n"
  1881. " extern int _isprint(int);\n"
  1882. " extern int _ispunct(int);\n"
  1883. " extern int _isspace(int);\n"
  1884. " extern int _isupper(int);\n"
  1885. " extern int _isxdigit(int);\n"
  1886. "# else /* not _PROTOTYPES */\n"
  1887. " extern int _isalnum();\n"
  1888. " extern int _isalpha();\n"
  1889. " extern int _iscntrl();\n"
  1890. " extern int _isdigit();\n"
  1891. " extern int _isgraph();\n"
  1892. " extern int _islower();\n"
  1893. " extern int _isprint();\n"
  1894. " extern int _ispunct();\n"
  1895. " extern int _isspace();\n"
  1896. " extern int _isupper();\n"
  1897. " extern int _isxdigit();\n"
  1898. "#endif /* _PROTOTYPES */\n";
  1899. test_text = "# if defined(_SB_CTYPE_MACROS) && !defined(__lint)\n"
  1900. " extern unsigned int *__SB_masks;\n";
  1901. };
  1902. /*
  1903. * Fix hpux 10.X missing stdio declarations
  1904. */
  1905. fix = {
  1906. hackname = hpux10_stdio_declarations;
  1907. files = stdio.h;
  1908. select = "^#[ \t]*define _iob[ \t]*__iob";
  1909. bypass = "^[ \t]*extern[ \t]*int[ \t]*vsnprintf[ \t]*\\(";
  1910. c_fix = format;
  1911. c_fix_arg = "%0\n\n"
  1912. "# if defined(__STDC__) || defined(__cplusplus)\n"
  1913. " extern int snprintf(char *, size_t, const char *, ...);\n"
  1914. " extern int vsnprintf(char *, size_t, const char *, __va_list);\n"
  1915. "# else /* not __STDC__) || __cplusplus */\n"
  1916. " extern int snprintf();\n"
  1917. " extern int vsnprintf();\n"
  1918. "# endif /* __STDC__) || __cplusplus */\n";
  1919. test_text = "# define _iob __iob\n";
  1920. };
  1921. /*
  1922. * Make sure hpux defines abs in header.
  1923. */
  1924. fix = {
  1925. hackname = hpux11_abs;
  1926. mach = "*-hp-hpux11*";
  1927. files = stdlib.h;
  1928. select = "ifndef _MATH_INCLUDED";
  1929. c_fix = format;
  1930. c_fix_arg = "if !defined(_MATH_INCLUDED) || defined(__GNUG__)";
  1931. test_text = "#ifndef _MATH_INCLUDED";
  1932. };
  1933. /*
  1934. * Fix hpux11 __LWP_RWLOCK_VALID define
  1935. */
  1936. fix = {
  1937. hackname = hpux11_lwp_rwlock_valid;
  1938. mach = "*-hp-hpux11*";
  1939. files = sys/pthread.h;
  1940. select = "#define __LWP_RWLOCK_VALID[ \t]*0x8c91";
  1941. c_fix = format;
  1942. c_fix_arg = "#define __LWP_RWLOCK_VALID -29551";
  1943. test_text = "#define __LWP_RWLOCK_VALID 0x8c91";
  1944. };
  1945. /*
  1946. * hpux sendfile()
  1947. */
  1948. fix = {
  1949. hackname = hpux11_extern_sendfile;
  1950. mach = "*-hp-hpux11.[12]*";
  1951. files = sys/socket.h;
  1952. select = "^[ \t]*extern sbsize_t sendfile.*\n.*, int\\)\\);\n";
  1953. c_fix = format;
  1954. c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
  1955. test_text = " extern sbsize_t sendfile __((int, int, off_t, bsize_t,\n"
  1956. " const struct iovec *, int));\n";
  1957. };
  1958. /*
  1959. * hpux sendpath()
  1960. */
  1961. fix = {
  1962. hackname = hpux11_extern_sendpath;
  1963. mach = "*-hp-hpux11.[12]*";
  1964. files = sys/socket.h;
  1965. select = "^[ \t]*extern sbsize_t sendpath.*\n.*, int\\)\\);\n";
  1966. c_fix = format;
  1967. c_fix_arg = "#ifndef _APP32_64BIT_OFF_T\n%0#endif\n";
  1968. test_text = " extern sbsize_t sendpath __((int, int, off_t, bsize_t,\n"
  1969. " const struct iovec *, int));\n";
  1970. };
  1971. /*
  1972. * Keep HP-UX 11 from stomping on C++ math namespace
  1973. * with defines for fabsf.
  1974. */
  1975. fix = {
  1976. hackname = hpux11_fabsf;
  1977. files = math.h;
  1978. select = "^[ \t]*#[ \t]*define[ \t]+fabsf\\(.*";
  1979. bypass = "__cplusplus";
  1980. c_fix = format;
  1981. c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
  1982. test_text =
  1983. "#ifdef _PA_RISC\n"
  1984. "# define fabsf(x) ((float)fabs((double)(float)(x)))\n"
  1985. "#endif";
  1986. };
  1987. /*
  1988. * Fix C99 constant in __POINTER_SET define.
  1989. */
  1990. fix = {
  1991. hackname = hpux11_pthread_const;
  1992. mach = "*-hp-hpux11.[0-3]*";
  1993. files = sys/pthread.h;
  1994. select = "^#define[ \t]*__POINTER_SET[ \t]*\\(\\(void \\*\\) 1LL\\)";
  1995. c_fix = format;
  1996. c_fix_arg = "#define __POINTER_SET\t\t((void *) 1L)";
  1997. test_text = "#define __POINTER_SET\t\t((void *) 1LL)";
  1998. };
  1999. /*
  2000. * Prevent HP-UX 11 from defining __size_t and preventing size_t from
  2001. * being defined by having it define _hpux_size_t instead.
  2002. */
  2003. fix = {
  2004. hackname = hpux11_size_t;
  2005. mach = "*-hp-hpux11*";
  2006. select = "__size_t";
  2007. c_fix = format;
  2008. c_fix_arg = "_hpux_size_t";
  2009. test_text =
  2010. "#define __size_t size_t\n"
  2011. " extern int getpwuid_r( char *, __size_t, struct passwd **);\n";
  2012. };
  2013. /*
  2014. * Fix hpux 11.00 broken snprintf declaration
  2015. * (third argument is char *, needs to be const char * to prevent
  2016. * spurious warnings with -Wwrite-strings or in C++).
  2017. */
  2018. fix = {
  2019. hackname = hpux11_snprintf;
  2020. files = stdio.h;
  2021. select = '(extern int snprintf *\(char *\*, *(|__|_hpux_)size_t,)'
  2022. ' *(char *\*, *\.\.\.\);)';
  2023. c_fix = format;
  2024. c_fix_arg = '%1 const %3';
  2025. test_text = "extern int snprintf(char *, size_t, char *, ...);\n"
  2026. "extern int snprintf(char *, __size_t, char *, ...);\n"
  2027. "extern int snprintf(char *, _hpux_size_t, char *, ...);";
  2028. };
  2029. /*
  2030. * Fix hpux 11.00 broken vsnprintf declaration
  2031. */
  2032. fix = {
  2033. hackname = hpux11_vsnprintf;
  2034. files = stdio.h;
  2035. select = '(extern int vsnprintf\(char \*, _[hpux]*_size_t, '
  2036. 'const char \*,) __va__list\);';
  2037. c_fix = format;
  2038. c_fix_arg = "%1 __va_list);";
  2039. test_text = 'extern int vsnprintf(char *, _hpux_size_t, const char *,'
  2040. ' __va__list);';
  2041. };
  2042. /*
  2043. * get rid of bogus inline definitions in HP-UX 8.0
  2044. */
  2045. fix = {
  2046. hackname = hpux8_bogus_inlines;
  2047. files = math.h;
  2048. select = inline;
  2049. bypass = "__GNUG__";
  2050. sed = "s@inline int abs(int [a-z][a-z]*) {.*}"
  2051. "@extern \"C\" int abs(int);@";
  2052. sed = "s@inline double abs(double [a-z][a-z]*) {.*}@@";
  2053. sed = "s@inline int sqr(int [a-z][a-z]*) {.*}@@";
  2054. sed = "s@inline double sqr(double [a-z][a-z]*) {.*}@@";
  2055. test_text = "inline int abs(int v) { return (v>=0)?v:-v; }\n"
  2056. "inline double sqr(double v) { return v**0.5; }";
  2057. };
  2058. /*
  2059. * hpux intptr
  2060. */
  2061. fix = {
  2062. hackname = hpux_c99_intptr;
  2063. mach = "*-hp-hpux11.3*";
  2064. files = stdint-hpux11.h, stdint.h;
  2065. sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MAX[ \t]*"
  2066. "INT32_MAX[ \t]*$@#define PTRDIFF_MAX (2147483647l)@";
  2067. sed = "s@^[ \t]*#[ \t]*define[ \t]*PTRDIFF_MIN[ \t]*"
  2068. "INT32_MIN[ \t]*$@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
  2069. sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MAX[ \t]*"
  2070. "INT32_MAX[ \t]*$@#define INTPTR_MAX (2147483647l)@";
  2071. sed = "s@^[ \t]*#[ \t]*define[ \t]*INTPTR_MIN[ \t]*"
  2072. "INT32_MIN[ \t]*$@#define INTPTR_MIN (-INTPTR_MAX - 1)@";
  2073. sed = "s@^[ \t]*#[ \t]*define[ \t]*UINTPTR_MAX[ \t]*"
  2074. "UINT32_MAX[ \t]*$@#define UINTPTR_MAX (4294967295ul)@";
  2075. sed = "s@^[ \t]*#[ \t]*define[ \t]*SIZE_MAX[ \t]*"
  2076. "UINT32_MAX[ \t]*$@#define SIZE_MAX (4294967295ul)@";
  2077. test_text = "#define PTRDIFF_MAX INT32_MAX\n"
  2078. "#define PTRDIFF_MIN INT32_MIN\n"
  2079. "#define INTPTR_MAX INT32_MAX\n"
  2080. "#define INTPTR_MIN INT32_MIN\n"
  2081. "#define UINTPTR_MAX UINT32_MAX\n"
  2082. "#define SIZE_MAX UINT32_MAX\n";
  2083. };
  2084. /*
  2085. * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
  2086. */
  2087. fix = {
  2088. hackname = hpux_c99_inttypes;
  2089. mach = "*-hp-hpux11.[23]*";
  2090. files = inttypes.h;
  2091. files = stdint-hpux11.h, stdint.h;
  2092. sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*"
  2093. "__CONCAT_U__(__c)[ \t]*$@#define UINT8_C(__c) (__c)@";
  2094. sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*"
  2095. "__CONCAT_U__(__c)[ \t]*$@#define UINT16_C(__c) (__c)@";
  2096. sed = "s@^[ \t]*#[ \t]*define[ \t]*INT32_C(__c)[ \t]*"
  2097. "__CONCAT__(__c,l)[ \t]*$@#define INT32_C(__c) (__c)@";
  2098. sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT32_C(__c)[ \t].*$@"
  2099. "#define UINT32_C(__c) __CONCAT__(__c,u)@";
  2100. test_text = "#define UINT8_C(__c) __CONCAT_U__(__c)\n"
  2101. "#define UINT16_C(__c) __CONCAT_U__(__c)\n"
  2102. "#define INT32_C(__c) __CONCAT__(__c,l)\n"
  2103. "#define UINT32_C(__c) __CONCAT__(__c,ul)\n";
  2104. };
  2105. /*
  2106. * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
  2107. */
  2108. fix = {
  2109. hackname = hpux_c99_inttypes2;
  2110. mach = "*-hp-hpux11.2*";
  2111. files = stdint-hpux11.h, stdint.h;
  2112. sed = "s@^[ \t]*#[ \t]*define[ \t]*INT8_C(__c)[ \t]*"
  2113. "((signed char)(__c))[ \t]*$@#define INT8_C(__c) (__c)@";
  2114. sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT8_C(__c)[ \t]*"
  2115. "((unsigned char)(__c))[ \t]*$@#define UINT8_C(__c) (__c)@";
  2116. sed = "s@^[ \t]*#[ \t]*define[ \t]*INT16_C(__c)[ \t]*"
  2117. "((short)(__c))[ \t]*$@#define INT16_C(__c) (__c)@";
  2118. sed = "s@^[ \t]*#[ \t]*define[ \t]*UINT16_C(__c)[ \t]*"
  2119. "((unsigned short)(__c))[ \t]*$@#define UINT16_C(__c) (__c)@";
  2120. test_text = "# define INT8_C(__c) ((signed char)(__c))\n"
  2121. "# define UINT8_C(__c) ((unsigned char)(__c))\n"
  2122. "# define INT16_C(__c) ((short)(__c))\n"
  2123. "# define UINT16_C(__c) ((unsigned short)(__c))\n";
  2124. };
  2125. /*
  2126. * Fix hpux broken ctype macros
  2127. */
  2128. fix = {
  2129. hackname = hpux_ctype_macros;
  2130. files = ctype.h;
  2131. select = '((: |\()__SB_masks \? )'
  2132. '(__SB_masks\[__(alnum|c)\] & _IS)';
  2133. c_fix = format;
  2134. c_fix_arg = "%1(int)%3";
  2135. test_text = ": __SB_masks ? __SB_masks[__alnum] & _ISCNTRL\n"
  2136. "# define isalpha(__c) (__SB_masks ? __SB_masks[__c] & _IS\n";
  2137. };
  2138. /*
  2139. * hpux errno()
  2140. */
  2141. fix = {
  2142. hackname = hpux_extern_errno;
  2143. mach = "*-hp-hpux10.*";
  2144. mach = "*-hp-hpux11.[0-2]*";
  2145. files = errno.h;
  2146. select = "^[ \t]*extern int errno;$";
  2147. c_fix = format;
  2148. c_fix_arg = "#ifdef __cplusplus\n"
  2149. "extern \"C\" {\n"
  2150. "#endif\n"
  2151. "%0\n"
  2152. "#ifdef __cplusplus\n"
  2153. "}\n"
  2154. "#endif";
  2155. test_text = " extern int errno;\n";
  2156. };
  2157. /*
  2158. * Fix hpux broken #ifndef _XOPEN_SOURCE_EXTENDED conditional on htonl etc.
  2159. */
  2160. fix = {
  2161. hackname = hpux_htonl;
  2162. files = netinet/in.h;
  2163. select = "#ifndef _XOPEN_SOURCE_EXTENDED[ \t]*\n"
  2164. "(/\\*\n"
  2165. " \\* Macros for number representation conversion\\.\n"
  2166. " \\*/\n"
  2167. "#ifndef ntohl)";
  2168. c_fix = format;
  2169. c_fix_arg = "#if 1\n%1";
  2170. test_text = "#ifndef _XOPEN_SOURCE_EXTENDED\n"
  2171. "/*\n"
  2172. " * Macros for number representation conversion.\n"
  2173. " */\n"
  2174. "#ifndef ntohl\n"
  2175. "#define ntohl(x) (x)\n"
  2176. "#define ntohs(x) (x)\n"
  2177. "#define htonl(x) (x)\n"
  2178. "#define htons(x) (x)\n"
  2179. "#endif\n"
  2180. "#endif /* ! _XOPEN_SOURCE_EXTENDED */";
  2181. };
  2182. /*
  2183. * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
  2184. */
  2185. fix = {
  2186. hackname = hpux_imaginary_i;
  2187. mach = "ia64-hp-hpux11.*";
  2188. files = complex.h;
  2189. select = "^[ \t]*#[ \t]*define[ \t]*_Complex_I.*";
  2190. c_fix = format;
  2191. c_fix_arg = "#define _Complex_I (__extension__ 1.0iF)";
  2192. test_text = "#define _Complex_I (0.f+_Imaginary_I)\n";
  2193. };
  2194. /*
  2195. * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
  2196. */
  2197. fix = {
  2198. hackname = hpux_inttype_int8_t;
  2199. mach = "*-hp-hpux1[01].*";
  2200. files = sys/_inttypes.h;
  2201. select = "^[ \t]*typedef[ \t]*char[ \t]*int(_least){0,1}8_t.*";
  2202. c_fix = format;
  2203. c_fix_arg = "typedef signed char int%18_t;";
  2204. test_text = "typedef char int_least8_t;\n"
  2205. "typedef char int8_t;\n";
  2206. };
  2207. /*
  2208. * HP-UX long_double
  2209. */
  2210. fix = {
  2211. hackname = hpux_long_double;
  2212. mach = "*-*-hpux10*";
  2213. mach = "*-*-hpux11.[012]*";
  2214. files = stdlib.h;
  2215. select = "extern[ \t]long_double[ \t]strtold";
  2216. bypass = "long_double_t";
  2217. sed = "/^#[ \t]*ifndef _LONG_DOUBLE/,/\\/\\* _LONG_DOUBLE \\*\\//D";
  2218. sed = "s/long_double/long double/g";
  2219. test_text = "# ifndef _LONG_DOUBLE\n"
  2220. "# define _LONG_DOUBLE\n"
  2221. " typedef struct {\n"
  2222. " unsigned int word1, word2, word3, word4;\n"
  2223. " } long_double;\n"
  2224. "# endif /* _LONG_DOUBLE */\n"
  2225. "extern long_double strtold(const char *, char **);\n";
  2226. };
  2227. /*
  2228. * We cannot use the above rule on 11.31 because it removes the strtold
  2229. * definition. ia64 is OK with no hack, PA needs some help.
  2230. */
  2231. fix = {
  2232. hackname = hpux_long_double_2;
  2233. mach = "hppa*-*-hpux11.3*";
  2234. files = stdlib.h;
  2235. select = "#[ \t]*if[ \t]*!defined\\(__ia64\\) \\|\\| "
  2236. "defined\\(_PROTOTYPES\\) \\|\\| "
  2237. "defined\\(_LONG_DOUBLE_STRUCT\\)";
  2238. c_fix = format;
  2239. c_fix_arg = "# if !defined(_PROTOTYPES) || defined(_LONG_DOUBLE_STRUCT)";
  2240. test_text = "# if !defined(__ia64) || "
  2241. "!defined(_PROTOTYPES) || "
  2242. "defined(_LONG_DOUBLE_STRUCT)\n";
  2243. };
  2244. /*
  2245. * Add missing braces to pthread initializer defines.
  2246. */
  2247. fix = {
  2248. hackname = hpux_pthread_initializers;
  2249. mach = "*-hp-hpux11.[0-3]*";
  2250. files = sys/pthread.h;
  2251. sed = "s@^[ \t]*1, 1, 1, 1,[ \t]*\\\\"
  2252. "@\t{ 1, 1, 1, 1 },\t\t\t\t\t\t\t\\\\@";
  2253. sed = "s@^[ \t]*1,[ \t]*\\\\"
  2254. "@\t{ 1, 0 }@";
  2255. sed = "/^[ \t]*0$/d";
  2256. sed = "s@__PTHREAD_MUTEX_VALID, 0"
  2257. "@{ __PTHREAD_MUTEX_VALID, 0 }@";
  2258. sed = "s@^[ \t]*0, 0, -1, 0,[ \t]*\\\\"
  2259. "@\t{ 0, 0, -1, 0 },\t\t\t\t\t\t\\\\@";
  2260. sed = "s@0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
  2261. "@{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
  2262. sed = "s@^[ \t]*__LWP_MTX_VALID, 0, 1, 1, 1, 1,[ \t]*\\\\"
  2263. "@\t{ 0, __LWP_MTX_VALID }, { 0, 1, 1, 1, 1 },\t\t\t\\\\@";
  2264. sed = "s@^[ \t]*0, 0[ \t]*\\\\"
  2265. "@\t{ 0, 0 }\t\t\t\t\t\t\t\\\\@";
  2266. sed = "s@__PTHREAD_COND_VALID, 0"
  2267. "@{ __PTHREAD_COND_VALID, 0 }@";
  2268. sed = "s@__LWP_COND_VALID, 0,[ \t]*\\\\"
  2269. "@{ __LWP_COND_VALID, 0 },\t\t\t\t\t\\\\@";
  2270. sed = "s@__PTHREAD_RWLOCK_VALID, 0"
  2271. "@{ __PTHREAD_RWLOCK_VALID, 0 }@";
  2272. sed = "s@__LWP_RWLOCK_VALID, 0,[ \t]*\\\\"
  2273. "@{ __LWP_RWLOCK_VALID, 0 },\t\t\t\t\t\\\\@";
  2274. sed = "s@^[ \t]*0, 0, 0, 0, 0, 0, 0[ \t]*\\\\"
  2275. "@\t{ 0, 0, 0, 0, 0 }, { 0, 0}\t\t\t\t\t\\\\@";
  2276. test_text = "#define PTHREAD_MUTEX_INITIALIZER {\t\t\t\t\t\\\\\n"
  2277. "\t__PTHREAD_MUTEX_VALID, 0,\t\t\t\t\t\\\\\n"
  2278. "\t(PTHREAD_MUTEX_DEFAULT | PTHREAD_PROCESS_PRIVATE),\t\t\\\\\n"
  2279. "\t__SPNLCK_INITIALIZER,\t\t\t\t\t\t\\\\\n"
  2280. "\t0, 0, -1, 0,\t\t\t\t\t\t\t\\\\\n"
  2281. "\t0, __LWP_MTX_VALID, 0, 1, 1, 1, 1,\t\t\t\t\\\\\n"
  2282. "\t0, 0\t\t\t\t\t\t\t\t\\\\\n"
  2283. "}\n";
  2284. };
  2285. /*
  2286. * Wrap spu_info in ifdef _KERNEL. GCC cannot handle an array of unknown
  2287. * type and mpinfou is only defined when _KERNEL is set.
  2288. */
  2289. fix = {
  2290. hackname = hpux_spu_info;
  2291. mach = "*-hp-hpux*";
  2292. /*
  2293. * It is tempting to omit the first "files" entry. Do not.
  2294. * The testing machinery will take the first "files" entry as the name
  2295. * of a test file to play with. It would be a nuisance to have a directory
  2296. * with the name "*".
  2297. */
  2298. files = "ia64/sys/getppdp.h";
  2299. files = "*/sys/getppdp.h";
  2300. select = "^.*extern.*spu_info.*";
  2301. c_fix = format;
  2302. c_fix_arg = "#ifdef _KERNEL\n%0\n#endif";
  2303. test_text = "extern union mpinfou spu_info[];";
  2304. };
  2305. /*
  2306. * These hacks are need in inttypes.h on 11.23 and in stdint.h on 11.31.
  2307. */
  2308. fix = {
  2309. hackname = hpux_stdint_least_fast;
  2310. mach = "*-hp-hpux11.2*";
  2311. files = stdint-hpux11.h, stdint.h;
  2312. select =
  2313. "^[ \t]*#[ \t]*define[ \t]+UINT_(LEAST|FAST)64_MAX[ \t]+ULLONG_MAX";
  2314. c_fix = format;
  2315. c-fix-arg = "# define UINT_%164_MAX __UINT64_MAX__";
  2316. test-text = "# define UINT_FAST64_MAX ULLONG_MAX\n"
  2317. "# define UINT_LEAST64_MAX ULLONG_MAX\n";
  2318. _EOFix_;
  2319. };
  2320. /*
  2321. * Fix hpux10.20 <sys/time.h> to avoid invalid forward decl
  2322. */
  2323. fix = {
  2324. hackname = hpux_systime;
  2325. files = sys/time.h;
  2326. select = "^extern struct sigevent;";
  2327. c_fix = format;
  2328. c_fix_arg = "struct sigevent;";
  2329. test_text = 'extern struct sigevent;';
  2330. };
  2331. /*
  2332. * Fix glibc definition of HUGE_VAL in terms of hex floating point constant
  2333. */
  2334. fix = {
  2335. hackname = huge_val_hex;
  2336. files = bits/huge_val.h, '*/bits/huge_val.h';
  2337. select = "^#[ \t]*define[ \t]*HUGE_VAL[ \t].*0x1\\.0p.*";
  2338. bypass = "__builtin_huge_val";
  2339. c_fix = format;
  2340. c_fix_arg = "#define HUGE_VAL (__builtin_huge_val())\n";
  2341. test_text = "# define HUGE_VAL\t(__extension__ 0x1.0p2047)";
  2342. };
  2343. /*
  2344. * Fix glibc definition of HUGE_VALF in terms of hex floating point constant
  2345. */
  2346. fix = {
  2347. hackname = huge_valf_hex;
  2348. files = bits/huge_val.h, '*/bits/huge_val.h';
  2349. select = "^#[ \t]*define[ \t]*HUGE_VALF[ \t].*0x1\\.0p.*";
  2350. bypass = "__builtin_huge_valf";
  2351. c_fix = format;
  2352. c_fix_arg = "#define HUGE_VALF (__builtin_huge_valf())\n";
  2353. test_text = "# define HUGE_VALF (__extension__ 0x1.0p255f)";
  2354. };
  2355. /*
  2356. * Fix glibc definition of HUGE_VALL in terms of hex floating point constant
  2357. */
  2358. fix = {
  2359. hackname = huge_vall_hex;
  2360. files = bits/huge_val.h, '*/bits/huge_val.h';
  2361. select = "^#[ \t]*define[ \t]*HUGE_VALL[ \t].*0x1\\.0p.*";
  2362. bypass = "__builtin_huge_vall";
  2363. c_fix = format;
  2364. c_fix_arg = "#define HUGE_VALL (__builtin_huge_vall())\n";
  2365. test_text = "# define HUGE_VALL (__extension__ 0x1.0p32767L)";
  2366. };
  2367. /*
  2368. * Fix return type of abort and free
  2369. */
  2370. fix = {
  2371. hackname = int_abort_free_and_exit;
  2372. files = stdlib.h;
  2373. select = "int[ \t]+(abort|free|exit)[ \t]*\\(";
  2374. bypass = "_CLASSIC_ANSI_TYPES";
  2375. c_fix = format;
  2376. c_fix_arg = "void\t%1(";
  2377. test_text = "extern int abort(int);\n"
  2378. "extern int free(void*);\n"
  2379. "extern int exit(void*);";
  2380. };
  2381. /*
  2382. * Fix various macros used to define ioctl numbers.
  2383. * The traditional syntax was:
  2384. *
  2385. * #define _IO(n, x) (('n'<<8)+x)
  2386. * #define TIOCFOO _IO(T, 1)
  2387. *
  2388. * but this does not work with the C standard, which disallows macro
  2389. * expansion inside strings. We have to rewrite it thus:
  2390. *
  2391. * #define _IO(n, x) ((n<<8)+x)
  2392. * #define TIOCFOO _IO('T', 1)
  2393. *
  2394. * The select expressions match too much, but the c_fix code is cautious.
  2395. *
  2396. * _IO might be: _IO DESIO BSD43__IO with W, R, WR, C, ... suffixes.
  2397. */
  2398. fix = {
  2399. hackname = io_quotes_def;
  2400. select = "define[ \t]+[A-Z0-9_]+IO[A-Z]*\\([a-zA-Z][,)]";
  2401. c_fix = char_macro_def;
  2402. c_fix_arg = "IO";
  2403. test_text =
  2404. "#define BSD43__IOWR(n, x) (('n'<<8)+x)\n"
  2405. "#define _IOWN(x,y,t) (_IOC_IN|(((t)&_IOCPARM_MASK)<<16)|('x'<<8)|y)\n"
  2406. "#define _IO(x,y) ('x'<<8|y)";
  2407. test_text =
  2408. "#define XX_IO(x) ('x'<<8|256)";
  2409. };
  2410. /*
  2411. * Fix the usage of the ioctl macro numbers.
  2412. */
  2413. fix = {
  2414. hackname = io_quotes_use;
  2415. select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+IO[A-Z]*[ \t]*"
  2416. "\\( *[^,']";
  2417. c_fix = char_macro_use;
  2418. c_fix_arg = "IO";
  2419. test_text = "#define TIOCFOO BSD43__IOWR(T, 1)\n"
  2420. "#define TIOCFOO \\\\\n"
  2421. "BSD43__IOWR(T, 1) /* Some are multi-line */";
  2422. };
  2423. /*
  2424. * Check for missing ';' in struct
  2425. */
  2426. fix = {
  2427. hackname = ip_missing_semi;
  2428. files = netinet/ip.h;
  2429. select = "}$";
  2430. sed = "/^struct/,/^};/s/}$/};/";
  2431. test_text=
  2432. "struct mumble {\n"
  2433. " union {\n"
  2434. " int x;\n"
  2435. " }\n"
  2436. "}; /* mumbled struct */\n";
  2437. };
  2438. /*
  2439. * Non-traditional "const" declaration in Irix's limits.h.
  2440. */
  2441. fix = {
  2442. hackname = irix_limits_const;
  2443. files = fixinc-test-limits.h, limits.h;
  2444. select = "^extern const ";
  2445. c_fix = format;
  2446. c_fix_arg = "extern __const ";
  2447. test_text = "extern const char limit; /* test limits */";
  2448. };
  2449. /*
  2450. * IRIX 5.x's stdio.h declares some functions that take a va_list as
  2451. * taking char *. However, GCC uses void * for va_list, so
  2452. * calling vfprintf with a va_list fails in C++. */
  2453. fix = {
  2454. hackname = irix_stdio_va_list;
  2455. files = stdio.h;
  2456. select = '/\* va_list \*/ char \*';
  2457. c_fix = format;
  2458. c_fix_arg = "__gnuc_va_list";
  2459. test_text =
  2460. "extern int printf( const char *, /* va_list */ char * );";
  2461. };
  2462. /*
  2463. * These files in Sun OS 4.x and ARM/RISCiX and BSD4.3
  2464. * use / * * / to concatenate tokens.
  2465. */
  2466. fix = {
  2467. hackname = kandr_concat;
  2468. files = "sparc/asm_linkage.h";
  2469. files = "sun*/asm_linkage.h";
  2470. files = "arm/as_support.h";
  2471. files = "arm/mc_type.h";
  2472. files = "arm/xcb.h";
  2473. files = "dev/chardefmac.h";
  2474. files = "dev/ps_irq.h";
  2475. files = "dev/screen.h";
  2476. files = "dev/scsi.h";
  2477. files = "sys/tty.h";
  2478. files = "Xm.acorn/XmP.h";
  2479. files = bsd43/bsd43_.h;
  2480. select = '/\*\*/';
  2481. c_fix = format;
  2482. c_fix_arg = '##';
  2483. test_text = "#define __CONCAT__(a,b) a/**/b";
  2484. };
  2485. /*
  2486. * The /usr/include/sys/ucontext.h on ia64-*linux-gnu systems defines
  2487. * an _SC_GR0_OFFSET macro using an idiom that isn't a compile time
  2488. * constant on recent versions of g++.
  2489. */
  2490. fix = {
  2491. hackname = linux_ia64_ucontext;
  2492. files = "sys/ucontext.h";
  2493. mach = "ia64-*-linux*";
  2494. select = '\(\(\(char \*\) &\(\(struct sigcontext \*\) 0\)'
  2495. '->sc_gr\[0\]\) - \(char \*\) 0\)';
  2496. c_fix = format;
  2497. c_fix_arg = "__builtin_offsetof \(struct sigcontext, sc_gr[0]\)";
  2498. test_text = "# define _SC_GR0_OFFSET\t\\\\\n"
  2499. "\t(((char *) &((struct sigcontext *) 0)->sc_gr[0]) - (char *) 0)\n";
  2500. };
  2501. /*
  2502. * Remove header file warning from sys/time.h. Autoconf's
  2503. * AC_HEADER_TIME recommends to include both sys/time.h and time.h
  2504. * which causes warning on LynxOS. Remove the warning.
  2505. */
  2506. fix = {
  2507. hackname = lynxos_no_warning_in_sys_time_h;
  2508. files = sys/time.h;
  2509. select = "#warning[ \t]+Using <time.h> instead of <sys/time.h>";
  2510. c_fix = format;
  2511. c_fix_arg = "";
  2512. test_text = "#warning Using <time.h> instead of <sys/time.h>";
  2513. };
  2514. /*
  2515. * Add missing declaration for putenv.
  2516. */
  2517. fix = {
  2518. hackname = lynxos_missing_putenv;
  2519. mach = '*-*-lynxos*';
  2520. files = stdlib.h;
  2521. bypass = 'putenv[ \t]*\\(';
  2522. select = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
  2523. c_fix = format;
  2524. c_fix_arg = "%0\n"
  2525. "extern int putenv _AP((char *));";
  2526. c_fix_arg = "extern char \\*getenv[ \t]*_AP\\(\\(const char \\*\\)\\);";
  2527. test_text = "extern char *getenv _AP((const char *));";
  2528. };
  2529. /*
  2530. * Fix BSD machine/ansi.h to use __builtin_va_list to define _BSD_VA_LIST_.
  2531. *
  2532. * On NetBSD, machine is a symbolic link to an architecture specific
  2533. * directory name, so we can't match a specific file name here.
  2534. */
  2535. fix = {
  2536. hackname = machine_ansi_h_va_list;
  2537. select = "define[ \t]+_BSD_VA_LIST_[ \t]";
  2538. bypass = '__builtin_va_list';
  2539. c_fix = format;
  2540. c_fix_arg = "%1__builtin_va_list";
  2541. c_fix_arg = "(define[ \t]+_BSD_VA_LIST_[ \t]+).*";
  2542. test_text = " # define _BSD_VA_LIST_\tchar**";
  2543. };
  2544. /*
  2545. * Fix non-ansi machine name defines
  2546. */
  2547. fix = {
  2548. hackname = machine_name;
  2549. c_test = machine_name;
  2550. c_fix = machine_name;
  2551. test_text = "/* MACH_DIFF: */\n"
  2552. "#if defined( i386 ) || defined( sparc ) || defined( vax )"
  2553. "\n/* no uniform test, so be careful :-) */";
  2554. };
  2555. /*
  2556. * Some math.h files define struct exception (it's in the System V
  2557. * Interface Definition), which conflicts with the class exception defined
  2558. * in the C++ file std/stdexcept.h. We redefine it to __math_exception.
  2559. * This is not a great fix, but I haven't been able to think of anything
  2560. * better.
  2561. */
  2562. fix = {
  2563. hackname = math_exception;
  2564. files = math.h;
  2565. select = "struct exception";
  2566. /*
  2567. * This should be bypassed on __cplusplus, but some supposedly C++
  2568. * aware headers, such as Solaris 8 and 9, don't wrap their struct
  2569. * exception either. So currently we bypass only for glibc, based on a
  2570. * comment in the fixed glibc header. Ick.
  2571. */
  2572. bypass = 'We have a problem when using C\+\+|for C\+\+, '
  2573. '_[a-z0-9A-Z_]+_exception; for C, exception';
  2574. /* The Solaris 10 headers already get this right. */
  2575. mach = '*-*-solaris2.1[0-9]*';
  2576. not_machine = true;
  2577. c_fix = wrap;
  2578. c_fix_arg = "#ifdef __cplusplus\n"
  2579. "#define exception __math_exception\n"
  2580. "#endif\n";
  2581. c_fix_arg = "#ifdef __cplusplus\n"
  2582. "#undef exception\n"
  2583. "#endif\n";
  2584. test_text = "typedef struct exception t_math_exception;";
  2585. };
  2586. /*
  2587. * This looks pretty broken to me. ``dbl_max_def'' will contain
  2588. * "define DBL_MAX " at the start, when what we really want is just
  2589. * the value portion. Can't figure out how to write a test case
  2590. * for this either :-(
  2591. */
  2592. fix = {
  2593. hackname = math_huge_val_from_dbl_max;
  2594. files = math.h;
  2595. /*
  2596. * IF HUGE_VAL is defined to be DBL_MAX *and* DBL_MAX is _not_ defined
  2597. * in math.h, this fix applies.
  2598. */
  2599. select = "define[ \t]+HUGE_VAL[ \t]+DBL_MAX";
  2600. bypass = "define[ \t]+DBL_MAX";
  2601. shell =
  2602. /*
  2603. * See if we have a definition for DBL_MAX in float.h.
  2604. * If we do, we will replace the one in math.h with that one.
  2605. */
  2606. "\tdbl_max_def=`egrep 'define[ \t]+DBL_MAX[ \t]+.*' float.h "
  2607. "| sed 's/.*DBL_MAX[ \t]*//' 2>/dev/null`\n\n"
  2608. "\tif ( test -n \"${dbl_max_def}\" ) > /dev/null 2>&1\n"
  2609. "\tthen sed -e '/define[ \t]*HUGE_VAL[ \t]*DBL_MAX/"
  2610. "s@DBL_MAX@'\"$dbl_max_def@\"\n"
  2611. "\telse cat\n"
  2612. "\tfi";
  2613. test_text =
  2614. "`echo '#define DBL_MAX\t3.1415e+9 /* really big */' >> float.h`\n"
  2615. "#define HUGE_VAL DBL_MAX";
  2616. };
  2617. /*
  2618. * nested comment
  2619. */
  2620. fix = {
  2621. hackname = nested_auth_des;
  2622. files = rpc/rpc.h;
  2623. select = '(/\*.*rpc/auth_des\.h>.*)/\*';
  2624. c_fix = format;
  2625. c_fix_arg = "%1*/ /*";
  2626. test_text = "/*#include <rpc/auth_des.h> /* skip this */";
  2627. };
  2628. /*
  2629. * Some versions of NetBSD don't expect the C99 inline semantics.
  2630. */
  2631. fix = {
  2632. hackname = netbsd_c99_inline_1;
  2633. mach = "*-*-netbsd*";
  2634. files = signal.h;
  2635. select = "extern __inline int";
  2636. c_fix = format;
  2637. c_fix_arg = "extern\n"
  2638. "#ifdef __GNUC_STDC_INLINE__\n"
  2639. "__attribute__((__gnu_inline__))\n"
  2640. "#endif\n"
  2641. "__inline int";
  2642. test_text = "extern __inline int\nsigaddset(sigset_t *set, int signo)\n{}";
  2643. };
  2644. /*
  2645. * netbsd_c99_inline_2
  2646. */
  2647. fix = {
  2648. hackname = netbsd_c99_inline_2;
  2649. mach = "*-*-netbsd*";
  2650. files = signal.h;
  2651. select = "#define _SIGINLINE extern __inline";
  2652. c_fix = format;
  2653. c_fix_arg = <<- _EOArg_
  2654. #ifdef __GNUC_STDC_INLINE__
  2655. #define _SIGINLINE extern __attribute__((__gnu_inline__)) __inline
  2656. #else
  2657. %0
  2658. #endif
  2659. _EOArg_;
  2660. test_text = "#define _SIGINLINE extern __inline";
  2661. };
  2662. /*
  2663. * NetBSD has a semicolon after the ending '}' for some extern "C".
  2664. */
  2665. fix = {
  2666. hackname = netbsd_extra_semicolon;
  2667. mach = "*-*-netbsd*";
  2668. files = sys/cdefs.h;
  2669. select = "#define[ \t]*__END_DECLS[ \t]*};";
  2670. c_fix = format;
  2671. c_fix_arg = "#define __END_DECLS }";
  2672. test_text = "#define __END_DECLS };";
  2673. };
  2674. /*
  2675. * newlib's stdint.h has several failures to conform to C99. The fix
  2676. * for these removed a comment that can be matched to identify unfixed
  2677. * versions.
  2678. */
  2679. fix = {
  2680. hackname = newlib_stdint_1;
  2681. files = stdint-newlib.h, stdint.h;
  2682. select = "@todo - Add support for wint_t types";
  2683. sed = "s@#define INT32_MIN.*@#define INT32_MIN (-INT32_MAX - 1)@";
  2684. sed = "s@#define INT32_MAX.*@#define INT32_MAX __INT32_MAX__@";
  2685. sed = "s@#define UINT32_MAX.*@#define UINT32_MAX __UINT32_MAX__@";
  2686. sed = "s@#define INT_LEAST32_MIN.*@"
  2687. "#define INT_LEAST32_MIN (-INT_LEAST32_MAX - 1)@";
  2688. sed = "s@#define INT_LEAST32_MAX.*@"
  2689. "#define INT_LEAST32_MAX __INT_LEAST32_MAX__@";
  2690. sed = "s@#define UINT_LEAST32_MAX.*@"
  2691. "#define UINT_LEAST32_MAX __UINT_LEAST32_MAX__@";
  2692. sed = 's@#define INT_FAST\([0-9]*\)_MIN.*@'
  2693. '#define INT_FAST\1_MIN (-INT_FAST\1_MAX - 1)@';
  2694. sed = 's@#define INT_FAST\([0-9]*\)_MAX.*@'
  2695. '#define INT_FAST\1_MAX __INT_FAST\1_MAX__@';
  2696. sed = 's@#define UINT_FAST\([0-9]*\)_MAX.*@'
  2697. '#define UINT_FAST\1_MAX __UINT_FAST\1_MAX__@';
  2698. sed = "s@#define SIZE_MAX.*@#define SIZE_MAX __SIZE_MAX__@";
  2699. sed = "s@#define PTRDIFF_MIN.*@#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)@";
  2700. sed = "s@#define PTRDIFF_MAX.*@#define PTRDIFF_MAX __PTRDIFF_MAX__@";
  2701. sed = "s@#define UINT8_C.*@#define UINT8_C(c) __UINT8_C(c)@";
  2702. sed = "s@#define UINT16_C.*@#define UINT16_C(c) __UINT16_C(c)@";
  2703. test_text = "/* @todo - Add support for wint_t types. */\n"
  2704. "#define INT32_MIN (-2147483647-1)\n"
  2705. "#define INT32_MAX 2147483647\n"
  2706. "#define UINT32_MAX 4294967295U\n"
  2707. "#define INT_LEAST32_MIN (-2147483647-1)\n"
  2708. "#define INT_LEAST32_MAX 2147483647\n"
  2709. "#define UINT_LEAST32_MAX 4294967295U\n"
  2710. "#define INT_FAST8_MIN INT8_MIN\n"
  2711. "#define INT_FAST8_MAX INT8_MAX\n"
  2712. "#define UINT_FAST8_MAX UINT8_MAX\n"
  2713. "#define SIZE_MAX (__STDINT_EXP(LONG_MAX) * 2UL + 1)\n"
  2714. "#define PTRDIFF_MIN (-__STDINT_EXP(LONG_MAX) - 1L)\n"
  2715. "#define PTRDIFF_MAX __STDINT_EXP(LONG_MAX)\n"
  2716. "#define UINT8_C(x) x##U\n"
  2717. "#define UINT16_C(x) x##U";
  2718. };
  2719. /*
  2720. * newlib_stdint_2
  2721. */
  2722. fix = {
  2723. hackname = newlib_stdint_2;
  2724. files = stdint-newlib.h, stdint.h;
  2725. select = "@todo - Add support for wint_t types";
  2726. c_fix = format;
  2727. c_fix_arg = "#define INTMAX_MAX __INTMAX_MAX__\n"
  2728. "#define INTMAX_MIN (-INTMAX_MAX - 1)\n"
  2729. "#define UINTMAX_MAX __UINTMAX_MAX__\n"
  2730. "#define WCHAR_MAX __WCHAR_MAX__\n"
  2731. "#define WCHAR_MIN __WCHAR_MIN__\n"
  2732. "#define WINT_MAX __WINT_MAX__\n"
  2733. "#define WINT_MIN __WINT_MIN__\n\n"
  2734. "%0";
  2735. c_fix_arg = '/\*\* Macros for minimum-width integer constant expressions \*/';
  2736. test_text = "/* @todo - Add support for wint_t types. */\n"
  2737. "/** Macros for minimum-width integer constant expressions */";
  2738. };
  2739. /*
  2740. * NeXT 3.2 adds const prefix to some math functions.
  2741. * These conflict with the built-in functions.
  2742. */
  2743. fix = {
  2744. hackname = next_math_prefix;
  2745. files = ansi/math.h;
  2746. select = "^extern[ \t]+double[ \t]+__const__[ \t]";
  2747. c_fix = format;
  2748. c_fix_arg = "extern double %1(";
  2749. c_fix_arg = "^extern[ \t]+double[ \t]+__const__[ \t]+([a-z]+)\\(";
  2750. test_text = "extern\tdouble\t__const__\tmumble();";
  2751. };
  2752. /*
  2753. * NeXT 3.2 uses the word "template" as a parameter for some
  2754. * functions. GCC reports an invalid use of a reserved key word
  2755. * with the built-in functions.
  2756. */
  2757. fix = {
  2758. hackname = next_template;
  2759. files = bsd/libc.h;
  2760. select = "[ \t]template\\)";
  2761. c_fix = format;
  2762. c_fix_arg = "(%1)";
  2763. c_fix_arg = "\\(([^)]*)[ \t]template\\)";
  2764. test_text = "extern mumble( char * template); /* fix */";
  2765. };
  2766. /*
  2767. * NeXT 3.2 includes the keyword volatile in the abort() and exit()
  2768. * function prototypes. That conflicts with the built-in functions.
  2769. */
  2770. fix = {
  2771. hackname = next_volitile;
  2772. files = ansi/stdlib.h;
  2773. select = "^extern[ \t]+volatile[ \t]+void[ \t]";
  2774. c_fix = format;
  2775. c_fix_arg = "extern void %1(";
  2776. c_fix_arg = "^extern[ \t]+volatile[ \t]+void[ \t]+(exit|abort)\\(";
  2777. test_text = "extern\tvolatile\tvoid\tabort();";
  2778. };
  2779. /*
  2780. * NeXT 2.0 defines 'int wait(union wait*)', which conflicts with Posix.1.
  2781. * Note that version 3 of the NeXT system has wait.h in a different directory,
  2782. * so that this code won't do anything. But wait.h in version 3 has a
  2783. * conditional, so it doesn't need this fix. So everything is okay.
  2784. */
  2785. fix = {
  2786. hackname = next_wait_union;
  2787. files = sys/wait.h;
  2788. select = 'wait\(union wait';
  2789. c_fix = format;
  2790. c_fix_arg = "wait(void";
  2791. test_text = "extern pid_d wait(union wait*);";
  2792. };
  2793. /*
  2794. * a missing semi-colon at the end of the nodeent structure definition.
  2795. */
  2796. fix = {
  2797. hackname = nodeent_syntax;
  2798. files = netdnet/dnetdb.h;
  2799. select = "char[ \t]*\\*na_addr[ \t]*$";
  2800. c_fix = format;
  2801. c_fix_arg = "%0;";
  2802. test_text = "char *na_addr\t";
  2803. };
  2804. /*
  2805. * Fix OpenBSD's NULL definition.
  2806. */
  2807. fix = {
  2808. hackname = openbsd_null_definition;
  2809. mach = "*-*-openbsd*";
  2810. files = locale.h, stddef.h, stdio.h, string.h,
  2811. time.h, unistd.h, wchar.h, sys/param.h;
  2812. select = "__GNUG__";
  2813. c_fix = format;
  2814. c_fix_arg = "#ifndef NULL\n"
  2815. "#ifdef __cplusplus\n"
  2816. "#ifdef __GNUG__\n"
  2817. "#define NULL\t__null\n"
  2818. "#else\t /* ! __GNUG__ */\n"
  2819. "#define NULL\t0L\n"
  2820. "#endif\t /* __GNUG__ */\n"
  2821. "#else\t /* ! __cplusplus */\n"
  2822. "#define NULL\t((void *)0)\n"
  2823. "#endif\t /* __cplusplus */\n"
  2824. "#endif\t /* !NULL */";
  2825. c_fix_arg = "^#ifndef[ \t]*NULL\n"
  2826. "^#ifdef[ \t]*__GNUG__\n"
  2827. "^#define[ \t]*NULL[ \t]*__null\n"
  2828. "^#else\n"
  2829. "^#define[ \t]*NULL[ \t]*0L\n"
  2830. "^#endif\n"
  2831. "^#endif";
  2832. test_text =
  2833. "#ifndef NULL\n"
  2834. "#ifdef __GNUG__\n"
  2835. "#define NULL __null\n"
  2836. "#else\n"
  2837. "#define NULL 0L\n"
  2838. "#endif\n"
  2839. "#endif\n";
  2840. };
  2841. /*
  2842. * obstack.h used casts as lvalues.
  2843. *
  2844. * We need to change postincrements of casted pointers (which are
  2845. * then dereferenced and assigned into) of the form
  2846. *
  2847. * *((TYPE*)PTRVAR)++ = (VALUE)
  2848. *
  2849. * into expressions like
  2850. *
  2851. * ((*((TYPE*)PTRVAR) = (VALUE)), (PTRVAR += sizeof (TYPE)))
  2852. *
  2853. * which is correct for the cases used in obstack.h since PTRVAR is
  2854. * of type char * and the value of the expression is not used.
  2855. */
  2856. fix = {
  2857. hackname = obstack_lvalue_cast;
  2858. files = obstack.h;
  2859. select = '\*\(\(([^()]*)\*\)(.*)\)\+\+ = \(([^()]*)\)';
  2860. c_fix = format;
  2861. c_fix_arg = "((*((%1*)%2) = (%3)), (%2 += sizeof (%1)))";
  2862. test_text = "*((void **) (h)->next_free)++ = (aptr)";
  2863. };
  2864. /*
  2865. * Fix OpenBSD's va_start define.
  2866. */
  2867. fix = {
  2868. hackname = openbsd_va_start;
  2869. mach = "*-*-openbsd*";
  2870. files = stdarg.h;
  2871. select = '__builtin_stdarg_start';
  2872. c_fix = format;
  2873. c_fix_arg = __builtin_va_start;
  2874. test_text = "#define va_start(v,l) __builtin_stdarg_start((v),l)";
  2875. };
  2876. /*
  2877. * sys/lc_core.h on some versions of OSF1/4.x pollutes the namespace by
  2878. * defining regex.h related types. This causes libg++ build and usage
  2879. * failures. Fixing this correctly requires checking and modifying 3 files.
  2880. */
  2881. fix = {
  2882. hackname = osf_namespace_a;
  2883. files = reg_types.h;
  2884. files = sys/lc_core.h;
  2885. test = " -r reg_types.h";
  2886. test = " -r sys/lc_core.h";
  2887. test = " -n \"`grep '} regex_t;' reg_types.h`\"";
  2888. test = " -z \"`grep __regex_t regex.h`\"";
  2889. c_fix = format;
  2890. c_fix_arg = "__%0";
  2891. c_fix_arg = "reg(ex|off|match)_t";
  2892. test_text = "`touch sys/lc_core.h`"
  2893. "typedef struct {\n int stuff, mo_suff;\n} regex_t;\n"
  2894. "extern regex_t re;\n"
  2895. "extern regoff_t ro;\n"
  2896. "extern regmatch_t rm;\n";
  2897. };
  2898. fix = {
  2899. hackname = osf_namespace_c;
  2900. files = regex.h;
  2901. test = " -r reg_types.h";
  2902. test = " -r sys/lc_core.h";
  2903. test = " -n \"`grep '} regex_t;' reg_types.h`\"";
  2904. test = " -z \"`grep __regex_t regex.h`\"";
  2905. select = "#include <reg_types\.h>.*";
  2906. c_fix = format;
  2907. c_fix_arg = "%0\n"
  2908. "typedef __regex_t\tregex_t;\n"
  2909. "typedef __regoff_t\tregoff_t;\n"
  2910. "typedef __regmatch_t\tregmatch_t;";
  2911. test_text = "#include <reg_types.h>";
  2912. };
  2913. /*
  2914. * On broken glibc-2.3.3 systems an array of incomplete structures is
  2915. * passed to __sigsetjmp. Fix that to take a pointer instead.
  2916. */
  2917. fix = {
  2918. hackname = pthread_incomplete_struct_argument;
  2919. files = pthread.h;
  2920. select = "struct __jmp_buf_tag";
  2921. c_fix = format;
  2922. c_fix_arg = "%1 *%2%3";
  2923. c_fix_arg = "^(extern int __sigsetjmp \\(struct __jmp_buf_tag) "
  2924. "(__env)\\[1\\](.*)$";
  2925. test_text = "extern int __sigsetjmp (struct __jmp_buf_tag __env[1], "
  2926. "int __savemask);";
  2927. };
  2928. /*
  2929. * Fix return type of fread and fwrite on sysV68
  2930. */
  2931. fix = {
  2932. hackname = read_ret_type;
  2933. files = stdio.h;
  2934. select = "extern int\t.*, fread\\(\\), fwrite\\(\\)";
  2935. c_fix = format;
  2936. c_fix_arg = "extern unsigned int fread(), fwrite();\n%1%2";
  2937. c_fix_arg = "(extern int\t.*), fread\\(\\), fwrite\\(\\)(.*)";
  2938. test_text = "extern int\tfclose(), fflush(), fread(), fwrite(), foo();";
  2939. };
  2940. /*
  2941. * Fix casts as lvalues in glibc's <rpc/xdr.h>.
  2942. */
  2943. fix = {
  2944. hackname = rpc_xdr_lvalue_cast_a;
  2945. files = rpc/xdr.h;
  2946. select = "#define[ \t]*IXDR_GET_LONG.*\\\\\n.*__extension__.*";
  2947. c_fix = format;
  2948. c_fix_arg = "#define IXDR_GET_LONG(buf) ((long)IXDR_GET_U_INT32(buf))";
  2949. test_text = "#define IXDR_GET_LONG(buf) \\\\\n"
  2950. "\t((long)ntohl((u_long)*__extension__((u_int32_t*)(buf))++))";
  2951. };
  2952. /*
  2953. * rpc_xdr_lvalue_cast_b
  2954. */
  2955. fix = {
  2956. hackname = rpc_xdr_lvalue_cast_b;
  2957. files = rpc/xdr.h;
  2958. select = "#define[ \t]*IXDR_PUT_LONG.*\\\\\n.*__extension__.*";
  2959. c_fix = format;
  2960. c_fix_arg = "#define IXDR_PUT_LONG(buf, v) ((long)IXDR_PUT_INT32(buf, (long)(v)))";
  2961. test_text = "#define IXDR_PUT_LONG(buf, v) \\\\\n"
  2962. "\t(*__extension__((u_int32_t*)(buf))++ = (long)htonl((u_long)(v)))";
  2963. };
  2964. /*
  2965. * function class(double x) conflicts with C++ keyword on rs/6000
  2966. */
  2967. fix = {
  2968. hackname = rs6000_double;
  2969. files = math.h;
  2970. select = '[^a-zA-Z_]class\(';
  2971. c_fix = format;
  2972. c_fix_arg = "#ifndef __cplusplus\n%0\n#endif";
  2973. c_fix_arg = '^.*[^a-zA-Z_]class\(.*';
  2974. test_text = "extern int class();";
  2975. };
  2976. /*
  2977. * Wrong fchmod prototype on RS/6000.
  2978. */
  2979. fix = {
  2980. hackname = rs6000_fchmod;
  2981. files = sys/stat.h;
  2982. select = 'fchmod\(char \*';
  2983. c_fix = format;
  2984. c_fix_arg = "fchmod(int";
  2985. test_text = "extern int fchmod(char *, mode_t);";
  2986. };
  2987. /*
  2988. * parameters conflict with C++ new on rs/6000
  2989. */
  2990. fix = {
  2991. hackname = rs6000_param;
  2992. files = "stdio.h";
  2993. files = "unistd.h";
  2994. select = 'rename\(const char \*old, const char \*new\)';
  2995. c_fix = format;
  2996. c_fix_arg = 'rename(const char *_old, const char *_new)';
  2997. test_text = 'extern int rename(const char *old, const char *new);';
  2998. };
  2999. /*
  3000. * Solaris 10+ <sys/feature_tests.h> defines _RESTRICT_KYWD as restrict
  3001. * for C99. This is wrong for C++, which needs many C99 features, but
  3002. * only supports __restrict.
  3003. */
  3004. fix = {
  3005. hackname = solaris___restrict;
  3006. files = sys/feature_tests.h;
  3007. select = "#define[ \t]*_RESTRICT_KYWD[ \t]*restrict";
  3008. mach = "*-*-solaris2*";
  3009. c_fix = format;
  3010. c_fix_arg = "#ifdef __cplusplus\n#define\t_RESTRICT_KYWD\t__restrict\n"
  3011. "#else\n%0\n#endif";
  3012. test_text = "#define _RESTRICT_KYWD restrict";
  3013. };
  3014. /*
  3015. * Solaris 10+ complex.h defines _Complex_I and _Imaginary_I in terms of
  3016. * themselves, which are Sun Studio compiler intrinsics. Remove _Imaginary_I
  3017. * and imaginary definitions which are not supported by GCC.
  3018. */
  3019. fix = {
  3020. hackname = solaris_complex;
  3021. mach = "*-*-solaris2.*";
  3022. files = complex.h;
  3023. select = "#define[ \t]_Complex_I[ \t]_Complex_I";
  3024. sed = "s/#define[ \t]_Complex_I[ \t]_Complex_I/"
  3025. "#define\t_Complex_I\t(__extension__ 1.0iF)/";
  3026. sed = "/#define[ \t]_Imaginary_I[ \t]_Imaginary_I/d";
  3027. sed = "/#define[ \t]imaginary[ \t]_Imaginary/d";
  3028. sed = "s/#define[ \t]I[ \t]\\{1,\\}_Imaginary_I/#define\tI\t\t_Complex_I/";
  3029. test_text = "#define _Complex_I _Complex_I\n"
  3030. "#define complex _Complex\n"
  3031. "#define _Imaginary_I _Imaginary_I\n"
  3032. "#define imaginary _Imaginary\n"
  3033. "#undef I\n"
  3034. "#define I _Imaginary_I";
  3035. };
  3036. /*
  3037. * Solaris 10+ <complex.h> is wrapped in #ifndef __cplusplus. Wrap in
  3038. * extern "C" instead so libstdc++ can use it.
  3039. */
  3040. fix = {
  3041. hackname = solaris_complex_cxx;
  3042. mach = "*-*-solaris2.*";
  3043. files = complex.h;
  3044. sed = "/#if[ \t]*!defined(__cplusplus)/c\\\n"
  3045. "#ifdef\t__cplusplus\\\nextern \"C\" {\\\n#endif";
  3046. sed = "/#endif[ \t]*\\/\\* !defined(__cplusplus) \\*\\//c\\\n"
  3047. "#ifdef\t__cplusplus\\\n}\\\n#endif";
  3048. test_text = "#if !defined(__cplusplus)\n"
  3049. "#endif /* !defined(__cplusplus) */";
  3050. };
  3051. /*
  3052. * g++ rejects functions declared with both C and C++ linkage.
  3053. */
  3054. fix = {
  3055. hackname = solaris_cxx_linkage;
  3056. mach = '*-*-solaris2*';
  3057. files = "iso/stdlib_iso.h";
  3058. select = "(#if __cplusplus >= 199711L)\n"
  3059. "(extern \"C\\+\\+\" \\{\n)"
  3060. "(.*(bsearch|qsort).*)";
  3061. c_fix = format;
  3062. c_fix_arg = "%1 && !__GNUG__\n%2%3";
  3063. test_text =
  3064. "#if __cplusplus >= 199711L\n"
  3065. "extern \"C++\" {\n"
  3066. " void *bsearch(const void *, const void *, size_t, size_t,";
  3067. };
  3068. /*
  3069. * Solaris <iso/stdio_iso.h> doesn't declare getc for C++ with
  3070. * _STRICT_STDC, but uses it.
  3071. */
  3072. fix = {
  3073. hackname = solaris_getc_strict_stdc;
  3074. mach = "*-*-solaris2*";
  3075. files = "iso/stdio_iso.h";
  3076. select = "(.*&& )!defined\\(_STRICT_STDC\\)(.*)";
  3077. c_fix = format;
  3078. c_fix_arg = "%1(!defined(_STRICT_STDC) || (__cplusplus >= 199711L))%2";
  3079. test_text =
  3080. "#if !defined(_REENTRANT) && !defined(_LP64) && !defined(_STRICT_STDC)";
  3081. };
  3082. /*
  3083. * Sun Solaris 2 has a version of sys/int_const.h that defines
  3084. * UINT8_C and UINT16_C to unsigned constants.
  3085. */
  3086. fix = {
  3087. hackname = solaris_int_const;
  3088. files = sys/int_const.h;
  3089. mach = '*-*-solaris2*';
  3090. c_fix = format;
  3091. c_fix_arg = "#define\tUINT8_C(c)\t(c)\n"
  3092. "%1\n"
  3093. "#define\tUINT16_C(c)\t(c)";
  3094. select = "^#define[ \t]+UINT8_C\\(c\\)[ \t]+__CONCAT__.*\n"
  3095. "(/\*.*\*/)\n"
  3096. "#define[ \t]+UINT16_C\\(c\\)[ \t]+__CONCAT__.*";
  3097. test_text =
  3098. "#define UINT8_C(c) __CONCAT__(c,u)\n"
  3099. "/* CSTYLED */\n"
  3100. "#define UINT16_C(c) __CONCAT__(c,u)";
  3101. };
  3102. /*
  3103. * Sun Solaris 2 has a version of sys/int_limits.h that defines
  3104. * UINT8_MAX and UINT16_MAX to unsigned constants.
  3105. */
  3106. fix = {
  3107. hackname = solaris_int_limits_1;
  3108. files = sys/int_limits.h;
  3109. mach = '*-*-solaris2*';
  3110. c_fix = format;
  3111. c_fix_arg = "#define\tUINT8_MAX\t(255)\n"
  3112. "#define\tUINT16_MAX\t(65535)";
  3113. select = "^#define[ \t]+UINT8_MAX[ \t]+\\(255U\\)\n"
  3114. "#define[ \t]+UINT16_MAX[ \t]+\\(65535U\\)";
  3115. test_text =
  3116. "#define UINT8_MAX (255U)\n"
  3117. "#define UINT16_MAX (65535U)";
  3118. };
  3119. /*
  3120. * Sun Solaris 2 has a version of sys/int_limits.h that defines
  3121. * INT_FAST16 limits to wrong values for sys/int_types.h.
  3122. */
  3123. fix = {
  3124. hackname = solaris_int_limits_2;
  3125. files = sys/int_limits.h;
  3126. mach = '*-*-solaris2*';
  3127. c_fix = format;
  3128. c_fix_arg = "#define\t%1_FAST16_%2 %132_%2";
  3129. select = "^#define[ \t]+(INT|UINT)_FAST16_(MAX|MIN)[ \t](INT|UINT)16.*";
  3130. test_text =
  3131. "#define INT_FAST16_MAX INT16_MAX\n"
  3132. "#define UINT_FAST16_MAX UINT16_MAX\n"
  3133. "#define INT_FAST16_MIN INT16_MIN";
  3134. };
  3135. /*
  3136. * Sun Solaris 2 has a version of sys/int_limits.h that defines
  3137. * SIZE_MAX as unsigned long.
  3138. */
  3139. fix = {
  3140. hackname = solaris_int_limits_3;
  3141. files = sys/int_limits.h;
  3142. mach = '*-*-solaris2*';
  3143. c_fix = format;
  3144. c_fix_arg = "#define\tSIZE_MAX\t4294967295U";
  3145. select = "^#define[ \t]+SIZE_MAX[ \t]+4294967295UL";
  3146. test_text =
  3147. "#define SIZE_MAX 4294967295UL";
  3148. };
  3149. /*
  3150. * Sun Solaris 10 defines several C99 math macros in terms of
  3151. * builtins specific to the Studio compiler, in particular not
  3152. * compatible with the GNU compiler.
  3153. */
  3154. fix = {
  3155. hackname = solaris_math_1;
  3156. select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
  3157. bypass = "__GNUC__";
  3158. files = iso/math_c99.h;
  3159. c_fix = format;
  3160. c_fix_arg = "#define\tHUGE_VA%1\t(__builtin_huge_va%2())";
  3161. c_fix_arg = "^#define[ \t]+HUGE_VA([LF]+)[ \t]+__builtin_huge_va([lf]+)";
  3162. test_text =
  3163. '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
  3164. "#undef HUGE_VAL\n"
  3165. "#define HUGE_VAL __builtin_huge_val\n"
  3166. "#undef HUGE_VALF\n"
  3167. "#define HUGE_VALF __builtin_huge_valf\n"
  3168. "#undef HUGE_VALL\n"
  3169. "#define HUGE_VALL __builtin_huge_vall";
  3170. };
  3171. /*
  3172. * On Solaris 11, if you do isinf(NaN) you'll get a floating point
  3173. * exception. Provide an alternative using GCC's builtin.
  3174. */
  3175. fix = {
  3176. hackname = solaris_math_10;
  3177. select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
  3178. files = iso/math_c99.h;
  3179. c_fix = format;
  3180. c_fix_arg = "#define\tisinf(x) __builtin_isinf(x)";
  3181. c_fix_arg = "^#define[ \t]+isinf\\(x\\)[ \t]+__extension__\\([ \t]*\\\\\n"
  3182. "[ \t]*\\{[ \t]*__typeof\\(x\\)[ \t]*__x_i[ \t]*=[ \t]*\\(x\\);"
  3183. "[ \t]*\\\\\n"
  3184. "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*"
  3185. "INFINITY[ \t]*\\|\\|[ \t]*\\\\\n"
  3186. "[ \t]*__x_i[ \t]*==[ \t]*\\(__typeof\\(__x_i\\)\\)[ \t]*"
  3187. "\\(-INFINITY\\);[ \t]*\\}\\)";
  3188. test_text =
  3189. '#pragma ident "@(#)math_c99.h 1.12 07/01/21 SMI"'"\n"
  3190. "#undef isinf\n"
  3191. "#define isinf(x) __extension__( \\\\\n"
  3192. " { __typeof(x) __x_i = (x); \\\\\n"
  3193. " __x_i == (__typeof(__x_i)) INFINITY || \\\\\n"
  3194. " __x_i == (__typeof(__x_i)) (-INFINITY); })";
  3195. };
  3196. /*
  3197. * Solaris math INFINITY
  3198. */
  3199. fix = {
  3200. hackname = solaris_math_2;
  3201. select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
  3202. bypass = "__GNUC__";
  3203. files = iso/math_c99.h;
  3204. c_fix = format;
  3205. c_fix_arg = "#define\tINFINITY\t(__builtin_inff())";
  3206. c_fix_arg = "^#define[ \t]+INFINITY[ \t]+__builtin_infinity";
  3207. test_text =
  3208. '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
  3209. "#undef INFINITY\n"
  3210. "#define INFINITY __builtin_infinity";
  3211. };
  3212. /*
  3213. * Solaris math NAN
  3214. */
  3215. fix = {
  3216. hackname = solaris_math_3;
  3217. select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
  3218. bypass = "__GNUC__";
  3219. files = iso/math_c99.h;
  3220. c_fix = format;
  3221. c_fix_arg = "#define\tNAN\t\t(__builtin_nanf(\"\"))";
  3222. c_fix_arg = "^#define[ \t]+NAN[ \t]+__builtin_nan";
  3223. test_text =
  3224. '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
  3225. "#undef NAN\n"
  3226. "#define NAN __builtin_nan";
  3227. };
  3228. /*
  3229. * Solaris math fpclassify
  3230. */
  3231. fix = {
  3232. hackname = solaris_math_4;
  3233. select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
  3234. bypass = "__GNUC__";
  3235. files = iso/math_c99.h;
  3236. c_fix = format;
  3237. c_fix_arg = "#define\tfpclassify(x) \\\n"
  3238. " __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, "
  3239. "FP_SUBNORMAL, FP_ZERO, (x))";
  3240. c_fix_arg = "^#define[ \t]+fpclassify\\(x\\)[ \t]+__builtin_fpclassify\\(x\\)";
  3241. test_text =
  3242. '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
  3243. "#undef fpclassify\n"
  3244. "#define fpclassify(x) __builtin_fpclassify(x)";
  3245. };
  3246. /*
  3247. * Solaris math signbit
  3248. */
  3249. fix = {
  3250. hackname = solaris_math_8;
  3251. select = '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ SMI";
  3252. bypass = "__GNUC__";
  3253. files = iso/math_c99.h;
  3254. c_fix = format;
  3255. c_fix_arg = "#define\tsignbit(x)\t(sizeof(x) == sizeof(float) \\\n"
  3256. "\t\t\t ? __builtin_signbitf(x) \\\n"
  3257. "\t\t\t : sizeof(x) == sizeof(long double) \\\n"
  3258. "\t\t\t ? __builtin_signbitl(x) \\\n"
  3259. "\t\t\t : __builtin_signbit(x))";
  3260. c_fix_arg = "^#define[ \t]+signbit\\(x\\)[ \t]+__builtin_signbit\\(x\\)";
  3261. test_text = <<- _EOText_
  3262. #ident "@(#)math_c99.h 1.9 04/11/01 SMI"
  3263. #undef signbit
  3264. #define signbit(x) __builtin_signbit(x)
  3265. _EOText_;
  3266. };
  3267. /*
  3268. * Solaris math comparison macros
  3269. */
  3270. fix = {
  3271. hackname = solaris_math_9;
  3272. select = '@\(#\)math_c99.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
  3273. bypass = "__GNUC__";
  3274. files = iso/math_c99.h;
  3275. c_fix = format;
  3276. c_fix_arg = "#define\t%1(x, y)%2__builtin_%1(x, y)";
  3277. c_fix_arg = "^#define[ \t]+([a-z]+)\\(x, y\\)([ \t]+)\\(\\(x\\) "
  3278. "__builtin_[a-z]+\\(y\\)\\)";
  3279. test_text =
  3280. '#ident "@(#)math_c99.h 1.9 04/11/01 SMI"'"\n"
  3281. "#undef isgreater\n"
  3282. "#define isgreater(x, y) ((x) __builtin_isgreater(y))\n"
  3283. "#undef isgreaterequal\n"
  3284. "#define isgreaterequal(x, y) ((x) __builtin_isgreaterequal(y))\n"
  3285. "#undef isless\n"
  3286. "#define isless(x, y) ((x) __builtin_isless(y))\n"
  3287. "#undef islessequal\n"
  3288. "#define islessequal(x, y) ((x) __builtin_islessequal(y))\n"
  3289. "#undef islessgreater\n"
  3290. "#define islessgreater(x, y) ((x) __builtin_islessgreater(y))\n"
  3291. "#undef isunordered\n"
  3292. "#define isunordered(x, y) ((x) __builtin_isunordered(y))";
  3293. };
  3294. /*
  3295. * Newer Solaris 10/11 GCC signbit implementations cause strict-aliasing
  3296. * warnings.
  3297. */
  3298. fix = {
  3299. hackname = solaris_math_11;
  3300. select = '@\(#\)math_c99\.h' "[ \t]+1\\.[0-9]+[ \t]+[0-9/]+ ";
  3301. files = iso/math_c99.h;
  3302. c_fix = format;
  3303. c_fix_arg = << _EOArg_
  3304. #undef signbit
  3305. #define signbit(x) (sizeof(x) == sizeof(float) \
  3306. ? __builtin_signbitf(x) \
  3307. : sizeof(x) == sizeof(long double) \
  3308. ? __builtin_signbitl(x) \
  3309. : __builtin_signbit(x))
  3310. _EOArg_;
  3311. c_fix_arg = << _EOArg_
  3312. ^#undef[ ]+signbit
  3313. #if defined\(__sparc\)
  3314. #define[ ]+signbit\(x\)[ ]+__extension__\( \\
  3315. [ ]+\{[ ]*__typeof\(x\)[ ]*__x_s[ ]*=[ ]*\(x\);[ ]*\\
  3316. [ ]+\(int\)[ ]*\(\*\(unsigned[ ]*\*\)[ ]*\&__x_s[ ]*>>[ ]*31\);[ ]*\}\)
  3317. #elif defined\(__i386\) \|\| defined\(__amd64\)
  3318. #define[ ]+signbit\(x\)[ ]+__extension__\( \\
  3319. [ ]+\{ __typeof\(x\) __x_s = \(x\); \\
  3320. [ ]+\(sizeof \(__x_s\) == sizeof \(float\) \? \\
  3321. [ ]+\(int\) \(\*\(unsigned \*\) \&__x_s >> 31\) : \\
  3322. [ ]+sizeof \(__x_s\) == sizeof \(double\) \? \\
  3323. [ ]+\(int\) \(\(\(unsigned \*\) \&__x_s\)\[1\] >> 31\) : \\
  3324. [ ]+\(int\) \(\(\(unsigned short \*\) \&__x_s\)\[4\] >> 15\)\); \}\)
  3325. #endif
  3326. _EOArg_;
  3327. test_text = << _EOText_
  3328. /* @(#)math_c99.h 1.14 13/03/27 */
  3329. #undef signbit
  3330. #if defined(__sparc)
  3331. #define signbit(x) __extension__( \\
  3332. { __typeof(x) __x_s = (x); \\
  3333. (int) (*(unsigned *) &__x_s >> 31); })
  3334. #elif defined(__i386) || defined(__amd64)
  3335. #define signbit(x) __extension__( \\
  3336. { __typeof(x) __x_s = (x); \\
  3337. (sizeof (__x_s) == sizeof (float) ? \\
  3338. (int) (*(unsigned *) &__x_s >> 31) : \\
  3339. sizeof (__x_s) == sizeof (double) ? \\
  3340. (int) (((unsigned *) &__x_s)[1] >> 31) : \\
  3341. (int) (((unsigned short *) &__x_s)[4] >> 15)); })
  3342. #endif
  3343. _EOText_;
  3344. };
  3345. /*
  3346. * Sun Solaris defines PTHREAD_ONCE_INIT as an array containing a
  3347. * structure. As such, it need two levels of brackets, but only
  3348. * contains one. Wrap the macro definition in an extra layer.
  3349. */
  3350. fix = {
  3351. hackname = solaris_once_init_1;
  3352. select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
  3353. files = pthread.h;
  3354. mach = '*-*-solaris*';
  3355. c_fix = format;
  3356. c_fix_arg = "%1{%2}%3";
  3357. c_fix_arg = "(^#define[ \t]+PTHREAD_ONCE_INIT[ \t]+\\{)([^}]+)(\\})[ \t]*$";
  3358. test_text =
  3359. '#pragma ident "@(#)pthread.h 1.37 04/09/28 SMI"'"\n"
  3360. "#define PTHREAD_ONCE_INIT\t{0, 0, 0, PTHREAD_ONCE_NOTDONE}";
  3361. };
  3362. /*
  3363. * Solaris 10+ <spawn.h> uses char *const argv[_RESTRICT_KYWD] in the
  3364. * posix_spawn declarations, which doesn't work with C++.
  3365. */
  3366. fix = {
  3367. hackname = solaris_posix_spawn_restrict;
  3368. files = spawn.h;
  3369. mach = '*-*-solaris2*';
  3370. c_fix = format;
  3371. c_fix_arg = "%1*_RESTRICT_KYWD %2%3";
  3372. select = "(.*[ \t]+)([a-z]+)\\[_RESTRICT_KYWD\\](.*)";
  3373. test_text =
  3374. "char *const argv[_RESTRICT_KYWD],\n"
  3375. "char *const envp[_RESTRICT_KYWD]);";
  3376. };
  3377. /*
  3378. * The pow overloads with int were removed in C++ 2011 DR 550.
  3379. */
  3380. fix = {
  3381. hackname = solaris_pow_int_overload;
  3382. mach = '*-*-solaris2*';
  3383. files = "iso/math_iso.h";
  3384. select = "^[ \t]*inline [a-z ]* pow\\([^()]*, int [^()]*\\)"
  3385. " *\\{[^{}]*\n[^{}]*\\}";
  3386. c_fix = format;
  3387. c_fix_arg = "#if __cplusplus < 201103L\n%0\n#endif";
  3388. test_text =
  3389. " inline long double pow(long double __X, int __Y) { return\n"
  3390. " __powl(__X, (long double) (__Y)); }";
  3391. };
  3392. /*
  3393. * Sun Solaris defines PTHREAD_RWLOCK_INITIALIZER with a "0" for some
  3394. * fields of the pthread_rwlock_t structure, which are of type
  3395. * upad64_t, which itself is typedef'd to int64_t, but with __STDC__
  3396. * defined (e.g. by -ansi) it is a union. So change the initializer
  3397. * to "{0}" instead.
  3398. */
  3399. fix = {
  3400. hackname = solaris_rwlock_init_1;
  3401. select = '@\(#\)pthread.h' "[ \t]+1.[0-9]+[ \t]+[0-9/]+ SMI";
  3402. files = pthread.h;
  3403. mach = '*-*-solaris*';
  3404. c_fix = format;
  3405. c_fix_arg = "#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)\n"
  3406. "%0\n"
  3407. "#else\n"
  3408. "%1{0, 0, 0, {{0}, {0}, {0}}, {{0}, {0}}, {{0}, {0}}}\n"
  3409. "#endif";
  3410. c_fix_arg = "(^#define[ \t]+PTHREAD_RWLOCK_INITIALIZER[ \t]+)"
  3411. "\\{0, 0, 0, \\{0, 0, 0\\}, \\{0, 0\\}, \\{0, 0\\}\\}[ \t]*$";
  3412. test_text =
  3413. '#ident "@(#)pthread.h 1.26 98/04/12 SMI"'"\n"
  3414. "#define PTHREAD_RWLOCK_INITIALIZER\t{0, 0, 0, {0, 0, 0}, {0, 0}, {0, 0}}";
  3415. };
  3416. /*
  3417. * Before Solaris 10, <stdio.h> lacks declarations of std::__filbuf and
  3418. * std::__flsbuf, but <iso/stdio_iso.h> uses them.
  3419. */
  3420. fix = {
  3421. hackname = solaris_std___filbuf;
  3422. files = stdio.h;
  3423. mach = '*-*-solaris2*';
  3424. bypass = "using std::__filbuf";
  3425. select = "(using std::perror;\n)(#endif)";
  3426. c_fix = format;
  3427. c_fix_arg = "%1#ifndef _LP64\n"
  3428. "using std::__filbuf;\n"
  3429. "using std::__flsbuf;\n"
  3430. "#endif\n%2";
  3431. test_text = "using std::perror;\n"
  3432. "#endif";
  3433. };
  3434. /*
  3435. * Sun Solaris 8 has what appears to be some gross workaround for
  3436. * some old version of their c++ compiler. G++ doesn't want it
  3437. * either, but doesn't want to be tied to SunPRO version numbers.
  3438. */
  3439. fix = {
  3440. hackname = solaris_stdio_tag;
  3441. files = stdio_tag.h;
  3442. select = '__cplusplus < 54321L';
  3443. /* In Solaris 10, the code in stdio_tag.h is conditionalized on
  3444. "!defined(__GNUC__)" so we no longer need to fix it. */
  3445. bypass = '__GNUC__';
  3446. sed = 's/defined(__cplusplus) && (__cplusplus < 54321L)/0/';
  3447. test_text = "#if\tdefined(__cplusplus) && (__cplusplus < 54321L)";
  3448. };
  3449. /*
  3450. * a missing semi-colon at the end of the statsswtch structure definition.
  3451. */
  3452. fix = {
  3453. hackname = statsswtch;
  3454. files = rpcsvc/rstat.h;
  3455. select = "boottime$";
  3456. c_fix = format;
  3457. c_fix_arg = "boottime;";
  3458. test_text = "struct statswtch {\n int boottime\n};";
  3459. };
  3460. /*
  3461. * Arrange for stdio.h to use stdarg.h to define __gnuc_va_list.
  3462. * On 4BSD-derived systems, stdio.h defers to machine/ansi.h; that's
  3463. * OK too.
  3464. */
  3465. fix = {
  3466. hackname = stdio_stdarg_h;
  3467. files = stdio.h;
  3468. bypass = "include.*(stdarg\.h|machine/ansi\.h)";
  3469. /*
  3470. * On Solaris 10, this fix is unncessary; <stdio.h> includes
  3471. * <iso/stdio_iso.h>, which includes <sys/va_list.h>.
  3472. */
  3473. mach = '*-*-solaris2.1[0-9]*';
  3474. not_machine = true;
  3475. c_fix = wrap;
  3476. c_fix_arg = "#define __need___va_list\n#include <stdarg.h>\n";
  3477. test_text = "";
  3478. };
  3479. /*
  3480. * Don't use or define the name va_list in stdio.h. This is for
  3481. * ANSI. Note _BSD_VA_LIST_ is dealt with elsewhere. The presence
  3482. * of __gnuc_va_list, __DJ_va_list, or _G_va_list is taken to
  3483. * indicate that the header knows what it's doing -- under SUSv2,
  3484. * stdio.h is required to define va_list, and we shouldn't break
  3485. * that.
  3486. */
  3487. fix = {
  3488. hackname = stdio_va_list;
  3489. files = stdio.h;
  3490. bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
  3491. /*
  3492. * On Solaris 10, the definition in
  3493. * <stdio.h> is guarded appropriately by the _XPG4 feature macro;
  3494. * there is therefore no need for this fix there.
  3495. */
  3496. mach = '*-*-solaris2.1[0-9]*';
  3497. not_machine = true;
  3498. /*
  3499. * Use __gnuc_va_list in arg types in place of va_list.
  3500. * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
  3501. * use __gnuc_va_list instead of __VA_LIST__. We're hoping the
  3502. * trailing parentheses and semicolon save all other systems from this.
  3503. * Define __not_va_list__ (something harmless and unused)
  3504. * instead of va_list.
  3505. * Don't claim to have defined va_list.
  3506. */
  3507. sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
  3508. "s@(va_list)&@(__gnuc_va_list)\\&@\n"
  3509. "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
  3510. "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
  3511. "s@ va_list@ __not_va_list__@\n"
  3512. "s@\\*va_list@*__not_va_list__@\n"
  3513. "s@ __va_list)@ __gnuc_va_list)@\n"
  3514. "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
  3515. "@typedef \\1 __not_va_list__;@\n"
  3516. "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
  3517. "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
  3518. "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
  3519. "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
  3520. "s@VA_LIST@DUMMY_VA_LIST@\n"
  3521. "s@_Va_LIST@_VA_LIST@";
  3522. test_text = "extern void mumble( va_list);";
  3523. };
  3524. /*
  3525. * Fix headers that use va_list from stdio.h to use the updated
  3526. * va_list from the stdio_va_list change. Note _BSD_VA_LIST_ is
  3527. * dealt with elsewhere. The presence of __gnuc_va_list,
  3528. * __DJ_va_list, or _G_va_list is taken to indicate that the header
  3529. * knows what it's doing.
  3530. */
  3531. fix = {
  3532. hackname = stdio_va_list_clients;
  3533. files = com_err.h;
  3534. files = cps.h;
  3535. files = curses.h;
  3536. files = krb5.h;
  3537. files = lc_core.h;
  3538. files = pfmt.h;
  3539. files = wchar.h;
  3540. files = curses_colr/curses.h;
  3541. bypass = '__gnuc_va_list|_BSD_VA_LIST_|__DJ_va_list|_G_va_list';
  3542. /* Don't fix, if we use va_list from stdarg.h, or if the use is
  3543. otherwise protected. */
  3544. bypass = 'include <stdarg\.h>|#ifdef va_start';
  3545. /*
  3546. * Use __gnuc_va_list in arg types in place of va_list.
  3547. * On 386BSD use __gnuc_va_list instead of _VA_LIST_. On Tru64 UNIX V5.1A
  3548. * use __gnuc_va_list instead of __VA_LIST__. We're hoping the
  3549. * trailing parentheses and semicolon save all other systems from this.
  3550. * Define __not_va_list__ (something harmless and unused)
  3551. * instead of va_list.
  3552. * Don't claim to have defined va_list.
  3553. */
  3554. sed = "s@[ \t]va_list\\([ \t)]\\)@ __gnuc_va_list\\1@\n"
  3555. "s@(va_list)&@(__gnuc_va_list)\\&@\n"
  3556. "s@ _VA_LIST_));@ __gnuc_va_list));@\n"
  3557. "s@ __VA_LIST__));@ __gnuc_va_list));@\n"
  3558. "s@ va_list@ __not_va_list__@\n"
  3559. "s@\\*va_list@*__not_va_list__@\n"
  3560. "s@ __va_list)@ __gnuc_va_list)@\n"
  3561. "s@typedef[ \t]\\(.*\\)[ \t]va_list[ \t]*;"
  3562. "@typedef \\1 __not_va_list__;@\n"
  3563. "s@typedef[ \t]*__va_list__@typedef __gnuc_va_list@\n"
  3564. "s@GNUC_VA_LIST@GNUC_Va_LIST@\n"
  3565. "s@_VA_LIST_DEFINED@_Va_LIST_DEFINED@\n"
  3566. "s@_NEED___VA_LIST@_NEED___Va_LIST@\n"
  3567. "s@VA_LIST@DUMMY_VA_LIST@\n"
  3568. "s@_Va_LIST@_VA_LIST@";
  3569. test_text = "extern void mumble( va_list);";
  3570. };
  3571. /*
  3572. * "!__STDC__" or "__STDC__==0" or "__STDC__!=1" or "__STDC__-0==0"
  3573. * is "!defined( __STRICT_ANSI__ )"
  3574. */
  3575. fix = {
  3576. hackname = strict_ansi_not;
  3577. select = "^([ \t]*#[ \t]*if.*)"
  3578. "(!__STDC__"
  3579. "|__STDC__[ \t]*==[ \t]*0"
  3580. "|__STDC__[ \t]*!=[ \t]*1"
  3581. "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*0)";
  3582. /* Tru64 UNIX V4.0F/V5.1 <standards.h> supports GCC usage of __STDC__. */
  3583. bypass = 'GNU and MIPS C compilers define __STDC__ differently';
  3584. /* GNU gmp.h uses "__STDC__ != 1" only if __SCO_VERSION__, which
  3585. is not defined by GCC, so it is safe. */
  3586. bypass = '__SCO_VERSION__.*__STDC__ != 1';
  3587. c_test = stdc_0_in_system_headers;
  3588. c_fix = format;
  3589. c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
  3590. test_text = "#if !__STDC__ \n"
  3591. "#if __STDC__ == 0\n"
  3592. "#if __STDC__ != 1\n"
  3593. "#if __STDC__ - 0 == 0"
  3594. "/* not std C */\nint foo;\n"
  3595. "\n#end-end-end-end-if :-)";
  3596. };
  3597. /*
  3598. * "__STDC__-0==0"
  3599. * is "!defined( __STRICT_ANSI__ )" on continued #if-s
  3600. */
  3601. fix = {
  3602. hackname = strict_ansi_not_ctd;
  3603. files = math.h, limits.h, stdio.h, signal.h,
  3604. stdlib.h, sys/signal.h, time.h;
  3605. /*
  3606. * Starting at the beginning of a line, skip white space and
  3607. * a leading "(" or "&&" or "||". One of those must be found.
  3608. * Then, zero, one or more copies of a "defined(_FOO_BAR_) &&"
  3609. * expression. If these are nested, then they must accumulate
  3610. * because we won't match any closing parentheses. Finally,
  3611. * after skipping over all that, we must then match our suspect
  3612. * phrase: "__STDC__-0==0" with or without white space.
  3613. */
  3614. select = "^([ \t]*" '(\(|&&|\|\|)'
  3615. "([ \t(]*!*[ \t]*defined\\([a-zA-Z_0-9]+\\)[ \t]*[|&][|&])*"
  3616. "[ \t(]*)"
  3617. "(__STDC__[ \t]*(|-[ \t]*0[ \t]*)==[ \t]*0)";
  3618. c_test = stdc_0_in_system_headers;
  3619. c_fix = format;
  3620. c_fix_arg = "%1 !defined(__STRICT_ANSI__)";
  3621. test_text = "#if 1 && \\\\\n"
  3622. "&& defined(mumbling) |& (__STDC__ - 0 == 0) \\\\\n"
  3623. "( __STDC__ == 0 && !defined(_XOPEN_SOURCE) \\\\\n"
  3624. "|| __STDC__ - 0 == 0 ) /* not std C */\n"
  3625. "int foo;\n#endif";
  3626. };
  3627. /*
  3628. * "__STDC__!=0" or "__STDC__==1" or "__STDC__-0==1"
  3629. * is "defined( __STRICT_ANSI__ )"
  3630. */
  3631. fix = {
  3632. hackname = strict_ansi_only;
  3633. select = "^([ \t]*#[ \t]*if.*)"
  3634. "(__STDC__[ \t]*!=[ \t]*0"
  3635. "|__STDC__[ \t]*==[ \t]*1"
  3636. "|__STDC__[ \t]*-[ \t]*0[ \t]*==[ \t]*1"
  3637. "|__STDC__[ \t]*-[ \t]*0[ \t]*!=[ \t]*0)";
  3638. c_test = stdc_0_in_system_headers;
  3639. c_fix = format;
  3640. c_fix_arg = "%1 defined(__STRICT_ANSI__)";
  3641. test_text = "#if __STDC__ == 1 /* is std C\n */\nint foo;\n#endif";
  3642. };
  3643. /*
  3644. * IRIX 4.0.5 <rpc/xdr.h> uses struct __file_s
  3645. * in prototype without previous definition.
  3646. */
  3647. fix = {
  3648. hackname = struct_file;
  3649. files = rpc/xdr.h;
  3650. select = '^.*xdrstdio_create.*struct __file_s';
  3651. c_fix = format;
  3652. c_fix_arg = "struct __file_s;\n%0";
  3653. test_text = "extern void xdrstdio_create( struct __file_s* );";
  3654. };
  3655. /*
  3656. * IRIX 4.0.5 <rpc/auth.h> uses struct sockaddr
  3657. * in prototype without previous definition.
  3658. *
  3659. * Don't fix OpenBSD, which uses struct sockaddr_in prototyping the same
  3660. * function, and does define it.
  3661. */
  3662. fix = {
  3663. hackname = struct_sockaddr;
  3664. files = rpc/auth.h;
  3665. select = "^.*authdes_create.*struct sockaddr[^_]";
  3666. bypass = "<sys/socket\.h>";
  3667. bypass = "struct sockaddr;\n";
  3668. c_fix = format;
  3669. c_fix_arg = "struct sockaddr;\n%0";
  3670. test_text = "extern AUTH* authdes_create( struct sockaddr* );";
  3671. };
  3672. /*
  3673. * Apply fix this to all OSs since this problem seems to effect
  3674. * more than just SunOS.
  3675. */
  3676. fix = {
  3677. hackname = sun_auth_proto;
  3678. files = rpc/auth.h;
  3679. files = rpc/clnt.h;
  3680. files = rpc/svc.h;
  3681. files = rpc/xdr.h;
  3682. bypass = "__cplusplus";
  3683. /*
  3684. * Select those files containing '(*name)()'.
  3685. */
  3686. select = '\(\*[a-z][a-z_]*\)\(\)';
  3687. c_fix = format;
  3688. c_fix_arg = "#ifdef __cplusplus\n%1(...);%2\n"
  3689. "#else\n%1();%2\n#endif";
  3690. c_fix_arg = '(.*\(\*[a-z][a-z_]*\))\(\);(.*)';
  3691. test_text =
  3692. "struct auth_t {\n"
  3693. " int (*name)(); /* C++ bad */\n"
  3694. "};";
  3695. };
  3696. /*
  3697. * Fix bogus #ifdef on SunOS 4.1.
  3698. */
  3699. fix = {
  3700. hackname = sun_bogus_ifdef;
  3701. files = "hsfs/hsfs_spec.h";
  3702. files = "hsfs/iso_spec.h";
  3703. select = '#ifdef(.*\|\|.*)';
  3704. c_fix = format;
  3705. c_fix_arg = "#if%1";
  3706. test_text = "#ifdef __i386__ || __vax__ || __sun4c__";
  3707. };
  3708. /*
  3709. * Fix the CAT macro in SunOS memvar.h.
  3710. */
  3711. fix = {
  3712. hackname = sun_catmacro;
  3713. files = pixrect/memvar.h;
  3714. select = "^#define[ \t]+CAT\\(a,b\\).*";
  3715. c_fix = format;
  3716. c_fix_arg =
  3717. "#ifdef __STDC__\n"
  3718. "# define CAT(a,b) a##b\n"
  3719. "#else\n%0\n#endif";
  3720. test_text =
  3721. "#define CAT(a,b)\ta/**/b";
  3722. };
  3723. /*
  3724. * Fix return type of free and {c,m,re}alloc in <malloc.h> on SunOS 4.1.
  3725. * Also fix return type of {m,re}alloc in <malloc.h> on sysV68
  3726. */
  3727. fix = {
  3728. hackname = sun_malloc;
  3729. files = malloc.h;
  3730. bypass = "_CLASSIC_ANSI_TYPES";
  3731. sed = "s/typedef[ \t]char \\*\tmalloc_t/typedef void \\*\tmalloc_t/g";
  3732. sed = "s/int[ \t][ \t]*free/void\tfree/g";
  3733. sed = "s/char\\([ \t]*\\*[ \t]*malloc\\)/void\\1/g";
  3734. sed = "s/char\\([ \t]*\\*[ \t]*realloc\\)/void\\1/g";
  3735. sed = "s/char\\([ \t]*\\*[ \t]*calloc\\)/void\\1/g";
  3736. test_text =
  3737. "typedef char *\tmalloc_t;\n"
  3738. "int \tfree();\n"
  3739. "char*\tmalloc();\n"
  3740. "char*\tcalloc();\n"
  3741. "char*\trealloc();";
  3742. };
  3743. /*
  3744. * Check for yet more missing ';' in struct (in SunOS 4.0.x)
  3745. */
  3746. fix = {
  3747. hackname = sun_rusers_semi;
  3748. files = rpcsvc/rusers.h;
  3749. select = "_cnt$";
  3750. sed = "/^struct/,/^};/s/_cnt$/_cnt;/";
  3751. test_text = "struct mumble\n int _cnt\n};";
  3752. };
  3753. /*
  3754. * signal.h on SunOS defines signal using (),
  3755. * which causes trouble when compiling with g++ -pedantic.
  3756. */
  3757. fix = {
  3758. hackname = sun_signal;
  3759. files = sys/signal.h;
  3760. files = signal.h;
  3761. select = "^void\t" '\(\*signal\(\)\)\(\);.*';
  3762. c_fix = format;
  3763. c_fix_arg =
  3764. "#ifdef __cplusplus\n"
  3765. "void\t(*signal(...))(...);\n"
  3766. "#else\n%0\n#endif";
  3767. test_text = "void\t(*signal())();";
  3768. };
  3769. /*
  3770. * Correct the return type for strlen in strings.h in SunOS 4.
  3771. */
  3772. fix = {
  3773. hackname = sunos_strlen;
  3774. files = strings.h;
  3775. select = "int[ \t]*strlen\\(\\);(.*)";
  3776. c_fix = format;
  3777. c_fix_arg = "__SIZE_TYPE__ strlen();%1";
  3778. test_text = " int\tstrlen(); /* string length */";
  3779. };
  3780. /*
  3781. * Linux kernel's vt.h breaks C++
  3782. */
  3783. fix = {
  3784. hackname = suse_linux_vt_cxx;
  3785. files = linux/vt.h;
  3786. select = "^[ \t]*unsigned int new;";
  3787. c_fix = format;
  3788. c_fix_arg = "unsigned int newev;";
  3789. test_text = " unsigned int new; /* New console (if changing) */";
  3790. };
  3791. /*
  3792. * Disable apparent native compiler optimization cruft in SVR4.2 <string.h>
  3793. * that is visible to any ANSI compiler using this include. Simply
  3794. * delete the lines that #define some string functions to internal forms.
  3795. */
  3796. fix = {
  3797. hackname = svr4_disable_opt;
  3798. files = string.h;
  3799. select = '#define.*__std_hdr_';
  3800. sed = '/#define.*__std_hdr_/d';
  3801. test_text = "#define strlen __std_hdr_strlen\n";
  3802. };
  3803. /*
  3804. * Fix broken decl of getcwd present on some svr4 systems.
  3805. */
  3806. fix = {
  3807. hackname = svr4_getcwd;
  3808. files = stdlib.h;
  3809. files = unistd.h;
  3810. files = prototypes.h;
  3811. select = 'getcwd\(char \*, int\)';
  3812. c_fix = format;
  3813. c_fix_arg = "getcwd(char *, size_t)";
  3814. test_text = "extern char* getcwd(char *, int);";
  3815. };
  3816. /*
  3817. * Fix broken decl of profil present on some svr4 systems.
  3818. */
  3819. fix = {
  3820. hackname = svr4_profil;
  3821. files = stdlib.h;
  3822. files = unistd.h;
  3823. select =
  3824. 'profil\(unsigned short \*, unsigned int, unsigned int, unsigned int\)';
  3825. c_fix = format;
  3826. c_fix_arg = 'profil(unsigned short *, size_t, int, unsigned int)';
  3827. test_text =
  3828. 'profil(unsigned short *, unsigned int, unsigned int, unsigned int);';
  3829. };
  3830. /*
  3831. * Correct types for signal handler constants like SIG_DFL; they might be
  3832. * void (*) (), and should be void (*) (int). C++ doesn't like the
  3833. * old style.
  3834. */
  3835. fix = {
  3836. hackname = svr4_sighandler_type;
  3837. files = sys/signal.h;
  3838. select = 'void *\(\*\)\(\)';
  3839. c_fix = format;
  3840. c_fix_arg = "void (*)(int)";
  3841. test_text = "#define SIG_DFL (void(*)())0\n"
  3842. "#define SIG_IGN (void (*)())0\n";
  3843. };
  3844. /*
  3845. * Some SysV r4 systems, including Sequent's DYNIX/ptx, use the local
  3846. * function 'getrnge' in <regexp.h> before they declare it. For these
  3847. * systems add a 'static int' declaration of 'getrnge' into <regexp.h>
  3848. * early on.
  3849. *
  3850. * 'getrnge' traditionally manipulates a file-scope global called 'size',
  3851. * so put the declaration right after the declaration of 'size'.
  3852. *
  3853. * Don't do this if there is already a `static void getrnge' declaration
  3854. * present, since this would cause a redeclaration error. Solaris 2.x has
  3855. * such a declaration.
  3856. */
  3857. fix = {
  3858. hackname = svr4_undeclared_getrnge;
  3859. files = regexp.h;
  3860. select = "getrnge";
  3861. bypass = "static void getrnge";
  3862. c_fix = format;
  3863. c_fix_arg = "%0\n"
  3864. "static int getrnge ();";
  3865. c_fix_arg = "^static int[ \t]+size;";
  3866. test_text = "static int size;\n"
  3867. "/* stuff which calls getrnge() */\n"
  3868. "static getrnge()\n"
  3869. "{}";
  3870. };
  3871. /*
  3872. * Fix return value of mem{ccpy,chr,cpy,set} and str{len,spn,cspn}
  3873. * in string.h on sysV68
  3874. * Correct the return type for strlen in string.h on Lynx.
  3875. * Correct the argument type for ffs in string.h on Alpha OSF/1 V2.0.
  3876. * Add missing const for strdup on OSF/1 V3.0.
  3877. * On sysV88 layout is slightly different.
  3878. */
  3879. fix = {
  3880. hackname = sysv68_string;
  3881. files = testing.h;
  3882. files = string.h;
  3883. bypass = "_CLASSIC_ANSI_TYPES";
  3884. sed = "s/extern[ \t]*int[ \t]*strlen();/extern unsigned int strlen();/";
  3885. sed = "s/extern[ \t]*int[ \t]*ffs[ \t]*(long);/extern int ffs(int);/";
  3886. sed = "s/strdup(char \\*s1);/strdup(const char *s1);/";
  3887. sed = "/^extern char$/N";
  3888. sed = "s/^extern char\\(\\n\t\\*memccpy(),\\)$/extern void\\1/";
  3889. sed = "/^extern int$/N";
  3890. sed = "s/^extern int\\(\\n\tstrlen(),\\)/extern size_t\\1/";
  3891. sed = "/^\tstrncmp(),$/N";
  3892. sed = 's/^\(' "\t" 'strncmp()\),\n\(' "\t" 'strlen(),\)$/'
  3893. '\1;' "\\\nextern unsigned int\\\n\\2/";
  3894. test_text =
  3895. "extern int strlen();\n"
  3896. "extern int ffs(long);\n"
  3897. "extern char\n"
  3898. "\t*memccpy(),\n"
  3899. "\tmemcpy();\n"
  3900. "extern int\n"
  3901. "\tstrcmp(),\n"
  3902. "\tstrncmp(),\n"
  3903. "\tstrlen(),\n"
  3904. "\tstrspn();\n"
  3905. "extern int\n"
  3906. "\tstrlen(), strspn();";
  3907. };
  3908. /*
  3909. * Fix return type of calloc, malloc, realloc, bsearch and exit
  3910. */
  3911. fix = {
  3912. hackname = sysz_stdlib_for_sun;
  3913. files = stdlib.h;
  3914. bypass = "_CLASSIC_ANSI_TYPES";
  3915. select = "char[ \t]*\\*[ \t]*(calloc|malloc|realloc|bsearch)[ \t]*\\(";
  3916. c_fix = format;
  3917. c_fix_arg = "void *\t%1(";
  3918. test_text =
  3919. "extern char*\tcalloc(size_t);\n"
  3920. "extern char*\tmalloc(size_t);\n"
  3921. "extern char*\trealloc(void*,size_t);\n"
  3922. "extern char*\tbsearch(void*,size_t,size_t);\n";
  3923. };
  3924. /*
  3925. * __thread is now a keyword.
  3926. */
  3927. fix = {
  3928. hackname = thread_keyword;
  3929. files = "pthread.h";
  3930. files = bits/sigthread.h, '*/bits/sigthread.h';
  3931. select = "([* ])__thread([,)])";
  3932. c_fix = format;
  3933. c_fix_arg = "%1__thr%2";
  3934. test_text =
  3935. "extern int pthread_create (pthread_t *__restrict __thread,\n"
  3936. "extern int pthread_kill (pthread_t __thread, int __signo);\n"
  3937. "extern int pthread_cancel (pthread_t __thread);";
  3938. };
  3939. /*
  3940. * if the #if says _cplusplus, not the double underscore __cplusplus
  3941. * that it should be
  3942. */
  3943. fix = {
  3944. hackname = tinfo_cplusplus;
  3945. files = tinfo.h;
  3946. select = "[ \t]_cplusplus";
  3947. c_fix = format;
  3948. c_fix_arg = " __cplusplus";
  3949. test_text = "#ifdef _cplusplus\nint bogus;\n#endif";
  3950. };
  3951. /*
  3952. * parameters not const on DECstation Ultrix V4.0 and OSF/1.
  3953. */
  3954. fix = {
  3955. hackname = ultrix_const;
  3956. files = stdio.h;
  3957. select = 'perror\( char \*';
  3958. c_fix = format;
  3959. c_fix_arg = "%1 const %3 *__";
  3960. c_fix_arg = "([ \t*](perror|fputs|fwrite|scanf|fscanf)\\(.*)"
  3961. "[ \t]+(char|void) \\*__";
  3962. test_text =
  3963. "extern void perror( char *__s );\n"
  3964. "extern int fputs( char *__s, FILE *);\n"
  3965. "extern size_t fwrite( void *__ptr, size_t, size_t, FILE *);\n"
  3966. "extern int fscanf( FILE *__stream, char *__format, ...);\n"
  3967. "extern int scanf( char *__format, ...);\n";
  3968. };
  3969. /*
  3970. * parameters not const on DECstation Ultrix V4.0 and OSF/1.
  3971. */
  3972. fix = {
  3973. hackname = ultrix_const2;
  3974. files = stdio.h;
  3975. select = '\*fopen\( char \*';
  3976. c_fix = format;
  3977. c_fix_arg = "%1( const char *%3, const char *";
  3978. c_fix_arg = "([ \t*](fopen|sscanf|popen|tempnam))\\("
  3979. "[ \t]*char[ \t]*\\*([^,]*),"
  3980. "[ \t]*char[ \t]*\\*[ \t]*";
  3981. test_text =
  3982. "extern FILE *fopen( char *__filename, char *__type );\n"
  3983. "extern int sscanf( char *__s, char *__format, ...);\n"
  3984. "extern FILE *popen(char *, char *);\n"
  3985. "extern char *tempnam(char*,char*);\n";
  3986. };
  3987. /*
  3988. * Fix definitions of macros used by va-i960.h in VxWorks header file.
  3989. */
  3990. fix = {
  3991. hackname = va_i960_macro;
  3992. files = arch/i960/archI960.h;
  3993. select = "__(vsiz|vali|vpad|alignof__)";
  3994. c_fix = format;
  3995. c_fix_arg = "__vx%1";
  3996. test_text =
  3997. "extern int __vsiz vsiz;\n"
  3998. "extern int __vali vali;\n"
  3999. "extern int __vpad vpad;\n"
  4000. "#define __alignof__(x) ...";
  4001. };
  4002. /*
  4003. * On VMS, add missing braces around sigset_t constants.
  4004. */
  4005. fix = {
  4006. hackname = vms_add_missing_braces;
  4007. select = "(_SIG_[A-Z]+_SET[ \t]+= \\{)(0x[0F]+, 0x[0F]+)";
  4008. mach = "*-*-*vms*";
  4009. files = "rtldef/signal.h";
  4010. c_fix = format;
  4011. c_fix_arg = '%1 {%2} ';
  4012. test_text = "static const __sigset_t _SIG_EMPTY_SET = "
  4013. "{0x00000000, 0x00000000},\n"
  4014. " _SIG_FULL_SET = {0xFFFFFFFF, 0xFFFFFFFF};\n";
  4015. };
  4016. /*
  4017. * On VMS, some DEC-C builtins are directly used.
  4018. */
  4019. fix = {
  4020. hackname = vms_decc_builtin;
  4021. select = "(__MEMSET|__MEMMOVE|__MEMCPY|__STRLEN|__STRCPY)";
  4022. mach = "*-*-*vms*";
  4023. files = rtldef/string.h, rtldef/time.h, rtldef/strings.h,
  4024. rtldef/socket.h;
  4025. sed = "s@__MEMSET@memset@";
  4026. sed = "s@__MEMMOVE@memmove@";
  4027. sed = "s@__MEMCPY@memcpy@";
  4028. sed = "s@__STRLEN@strlen@";
  4029. sed = "s@__STRCPY@strcpy@";
  4030. test_text = "define FD_ZERO(__p) __MEMSET((__p), 0, sizeof(*(__p)))\n";
  4031. };
  4032. /*
  4033. * Define __CAN_USE_EXTERN_PREFIX on vms.
  4034. */
  4035. fix = {
  4036. hackname = vms_define_can_use_extern_prefix;
  4037. files = "rtldef/decc$types.h";
  4038. select = "#[ \t]*else\n"
  4039. "#[ \t]*if defined\\(__DECCXX\\)\n"
  4040. "#[ \t]*define __CAN_USE_EXTERN_PREFIX 1\n";
  4041. mach = "*-*-*vms*";
  4042. c_fix = format;
  4043. c_fix_arg = "%0"
  4044. "# elif defined (__GNUC__)\n"
  4045. "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n";
  4046. test_text = "# else\n"
  4047. "# if defined(__DECCXX)\n"
  4048. "#\tdefine __CAN_USE_EXTERN_PREFIX 1\n"
  4049. "# endif\n"
  4050. "# endif\n";
  4051. };
  4052. /*
  4053. * On VMS, disable the use of dec-c string builtins
  4054. */
  4055. fix = {
  4056. hackname = vms_disable_decc_string_builtins;
  4057. select = "#if !defined\\(__VAX\\)\n";
  4058. mach = "*-*-*vms*";
  4059. files = "rtldef/string.h";
  4060. c_fix = format;
  4061. c_fix_arg = "#if !defined(__VAX) && !defined(__GNUC__)\n";
  4062. test_text = "#if !defined(__VAX)\n";
  4063. };
  4064. /*
  4065. * On VMS, fix incompatible redeclaration of hostalias.
  4066. */
  4067. fix = {
  4068. hackname = vms_do_not_redeclare_hostalias;
  4069. select = "(void[ \t]+fp_nquery \\(const u_char \\*, int, FILE \\*\\);)\n"
  4070. "(__char_ptr32[ \t]+hostalias \\(const char \\*\\);)";
  4071. mach = "*-*-*vms*";
  4072. files = "rtldef/resolv.h";
  4073. c_fix = format;
  4074. c_fix_arg = "%1\n"
  4075. "/* %2 */";
  4076. test_text = "void fp_nquery (const u_char *, int, FILE *);\n"
  4077. "__char_ptr32 hostalias (const char *);\n";
  4078. };
  4079. /*
  4080. * On VMS, forward declare structure before referencing them in prototypes.
  4081. */
  4082. fix = {
  4083. hackname = vms_forward_declare_struct;
  4084. select = "(/\\* forward decls for C\\+\\+ \\*/\n)"
  4085. "#ifdef __cplusplus\n";
  4086. mach = "*-*-*vms*";
  4087. files = rtldef/if.h;
  4088. c_fix = format;
  4089. c_fix_arg = "%1"
  4090. "#if defined (__cplusplus) || defined (__GNUC__)\n";
  4091. test_text = "/* forward decls for C++ */\n"
  4092. "#ifdef __cplusplus\n"
  4093. "struct foo;\n"
  4094. "#endif\n";
  4095. };
  4096. /*
  4097. * On VMS, do not declare getopt and al if pointers are 64 bit.
  4098. */
  4099. fix = {
  4100. hackname = vms_no_64bit_getopt;
  4101. select = "^[ \t]*(extern[ \t]*)?(int[ \t]*(getopt|optind|opterr|optopt)"
  4102. "|(char \\*optarg))([ \t]*\\(.*\\))?;\n";
  4103. mach = "*-*-*vms*";
  4104. files = rtldef/stdio.h, rtldef/unistd.h;
  4105. c_fix = format;
  4106. c_fix_arg = <<- _EOArg_
  4107. #if __INITIAL_POINTER_SIZE != 64 /* getopt is short ptr only. */
  4108. %0#endif
  4109. _EOArg_;
  4110. test_text = "int getopt (int, char * const [], const char *);";
  4111. };
  4112. /*
  4113. * On VMS, force the use of fast setjmp, as the normal setjmp uses conditions
  4114. * which is not yet fully supported by gcc.
  4115. */
  4116. fix = {
  4117. hackname = vms_use_fast_setjmp;
  4118. select = "(#[ \t]*if[ \t]*defined\\(__FAST_SETJMP\\)[ \t]*\\|\\|)";
  4119. mach = "*-*-*vms*";
  4120. files = rtldef/setjmp.h;
  4121. c_fix = format;
  4122. c_fix_arg = "%0 defined (__GNUC__) ||";
  4123. test_text = "# if defined(__FAST_SETJMP) || defined(__UNIX_SETJMP)";
  4124. };
  4125. /*
  4126. * On VMS, use pragma extern_model instead of VAX-C keywords.
  4127. */
  4128. fix = {
  4129. hackname = vms_use_pragma_extern_model;
  4130. select = "#if defined\\(__DECC\\) \\|\\| defined\\(__DECCXX\\)\n"
  4131. "# pragma extern_model __save\n";
  4132. mach = "*-*-*vms*";
  4133. c_fix = format;
  4134. c_fix_arg = "#if defined(__DECC) || defined(__DECCXX) || defined(__GNUC__)\n"
  4135. "# pragma extern_model __save\n";
  4136. test_text = "#if defined(__DECC) || defined(__DECCXX)\n"
  4137. "# pragma extern_model __save\n"
  4138. "# pragma extern_model strict_refdef\n"
  4139. " extern struct x zz$yy;\n"
  4140. "# pragma extern_model __restore\n"
  4141. "#endif\n";
  4142. };
  4143. /*
  4144. * On VMS, change <resource.h> to <sys/resource.h> to avoid a
  4145. * conflict while building gcc. Likewise for <builtins.h>
  4146. */
  4147. fix = {
  4148. hackname = vms_use_quoted_include;
  4149. select = "(#[ \t]*include[ \t]+)<(resource|builtins)\\.h>";
  4150. mach = "*-*-*vms*";
  4151. files = rtldef/wait.h, starlet_c/pthread.h;
  4152. c_fix = format;
  4153. c_fix_arg = '%1<sys/%2.h>';
  4154. test_text = "# include <resource.h>";
  4155. };
  4156. /*
  4157. * AIX and Interix headers define NULL to be cast to a void pointer,
  4158. * which is illegal in ANSI C++.
  4159. */
  4160. fix = {
  4161. hackname = void_null;
  4162. files = curses.h, dbm.h, locale.h, stdio.h, stdlib.h, string.h,
  4163. time.h, unistd.h, sys/dir.h, sys/param.h, sys/types.h;
  4164. /* avoid changing C++ friendly NULL */
  4165. bypass = __cplusplus;
  4166. bypass = __null;
  4167. select = "^#[ \t]*define[ \t]+NULL[ \t]+\\(\\(void[ \t]*\\*\\)0\\)";
  4168. c_fix = format;
  4169. c_fix_arg = <<- _EOFix_
  4170. #ifndef NULL
  4171. #ifdef __cplusplus
  4172. #ifdef __GNUG__
  4173. #define NULL __null
  4174. #else /* ! __GNUG__ */
  4175. #define NULL 0L
  4176. #endif /* __GNUG__ */
  4177. #else /* ! __cplusplus */
  4178. #define NULL ((void *)0)
  4179. #endif /* __cplusplus */
  4180. #endif /* !NULL */
  4181. _EOFix_;
  4182. test_text = "# define\tNULL \t((void *)0) /* typed NULL */";
  4183. };
  4184. /*
  4185. * Make VxWorks header which is almost gcc ready fully gcc ready.
  4186. */
  4187. fix = {
  4188. hackname = vxworks_gcc_problem;
  4189. files = types/vxTypesBase.h;
  4190. select = "__GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__";
  4191. sed = "s/#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__/"
  4192. "#if 1/";
  4193. sed = "/[ \t]size_t/i\\\n"
  4194. "#ifndef _GCC_SIZE_T\\\n"
  4195. "#define _GCC_SIZE_T\n";
  4196. sed = "/[ \t]size_t/a\\\n"
  4197. "#endif\n";
  4198. sed = "/[ \t]ptrdiff_t/i\\\n"
  4199. "#ifndef _GCC_PTRDIFF_T\\\n"
  4200. "#define _GCC_PTRDIFF_T\n";
  4201. sed = "/[ \t]ptrdiff_t/a\\\n"
  4202. "#endif\n";
  4203. sed = "/[ \t]wchar_t/i\\\n"
  4204. "#ifndef _GCC_WCHAR_T\\\n"
  4205. "#define _GCC_WCHAR_T\n";
  4206. sed = "/[ \t]wchar_t/a\\\n"
  4207. "#endif\n";
  4208. test_text =
  4209. "#ifdef __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__\n"
  4210. "typedef unsigned int size_t;\n"
  4211. "typedef long ptrdiff_t;\n"
  4212. "typedef unsigned short wchar_t;\n"
  4213. "#endif /* __GNUC_TYPEOF_FEATURE_BROKEN_USE_DEFAULT_UNTIL_FIXED__ */\n";
  4214. };
  4215. /*
  4216. * Wrap VxWorks ioctl to keep everything pretty
  4217. */
  4218. fix = {
  4219. hackname = vxworks_ioctl_macro;
  4220. files = ioLib.h;
  4221. mach = "*-*-vxworks*";
  4222. c_fix = format;
  4223. c_fix_arg = "%0\n"
  4224. "#define ioctl(fd, func, arg) (ioctl)(fd, func, (int)(arg))\n";
  4225. c_fix_arg = "extern[\t ]+int[\t ]+ioctl[\t ]*\\([\t ,[:alnum:]]*\\);";
  4226. test_text = "extern int ioctl ( int asdf1234, int jkl , int qwerty ) ;";
  4227. };
  4228. /*
  4229. * Wrap VxWorks mkdir to be posix compliant
  4230. */
  4231. fix = {
  4232. hackname = vxworks_mkdir_macro;
  4233. files = sys/stat.h;
  4234. mach = "*-*-vxworks*";
  4235. c_fix = format;
  4236. c_fix_arg = "%0\n"
  4237. "#define mkdir(dir, ...) ((void)0, ##__VA_ARGS__, (mkdir)(dir))\n";
  4238. c_fix_arg = "extern[\t ]+STATUS[\t ]+mkdir[\t ]*"
  4239. "\\([\t ]*const[\t ]+char[\t ]*\\*[\t ]*" /* arg type */
  4240. "(|[_[:alpha:]][_[:alnum:]]*)" /* arg name (optional) */
  4241. "\\)[\t ]*;";
  4242. test_text = "extern STATUS mkdir (const char * _qwerty) ;";
  4243. };
  4244. /*
  4245. * Fix VxWorks <time.h> to not require including <vxTypes.h>.
  4246. */
  4247. fix = {
  4248. hackname = vxworks_needs_vxtypes;
  4249. files = time.h;
  4250. select = "uint_t([ \t]+_clocks_per_sec)";
  4251. c_fix = format;
  4252. c_fix_arg = "unsigned int%1";
  4253. test_text = "uint_t\t_clocks_per_sec;";
  4254. };
  4255. /*
  4256. * Fix VxWorks <sys/stat.h> to not require including <vxWorks.h>.
  4257. */
  4258. fix = {
  4259. hackname = vxworks_needs_vxworks;
  4260. files = sys/stat.h;
  4261. test = " -r types/vxTypesOld.h";
  4262. test = " -n \"`egrep '#include' $file`\"";
  4263. test = " -n \"`egrep ULONG $file`\"";
  4264. select = "#[ \t]define[ \t]+__INCstath";
  4265. sed = "/#[ \t]define[ \t][ \t]*__INCstath/a\\\n"
  4266. "#include <types/vxTypesOld.h>\n";
  4267. test_text = "`touch types/vxTypesOld.h`"
  4268. "#include </dev/null> /* ULONG */\n"
  4269. "# define\t__INCstath <sys/stat.h>";
  4270. };
  4271. /*
  4272. * Make it so VxWorks does not include gcc/regs.h accidentally
  4273. */
  4274. fix = {
  4275. hackname = vxworks_regs;
  4276. mach = "*-*-vxworks*";
  4277. select = "#[\t ]*include[\t ]+[<\"]regs.h[>\"]";
  4278. c_fix = format;
  4279. c_fix_arg = "#include <arch/../regs.h>";
  4280. test_text = "#include <regs.h>\n";
  4281. };
  4282. /*
  4283. * Another bad dependency in VxWorks 5.2 <time.h>.
  4284. */
  4285. fix = {
  4286. hackname = vxworks_time;
  4287. files = time.h;
  4288. test = " -r vxWorks.h";
  4289. select = "#[ \t]*define[ \t]+VOIDFUNCPTR[ \t].*";
  4290. c_fix = format;
  4291. c_fix_arg =
  4292. "#ifndef __gcc_VOIDFUNCPTR_defined\n"
  4293. "#ifdef __cplusplus\n"
  4294. "typedef void (*__gcc_VOIDFUNCPTR) (...);\n"
  4295. "#else\n"
  4296. "typedef void (*__gcc_VOIDFUNCPTR) ();\n"
  4297. "#endif\n"
  4298. "#define __gcc_VOIDFUNCPTR_defined\n"
  4299. "#endif\n"
  4300. "#define VOIDFUNCPTR __gcc_VOIDFUNCPTR";
  4301. test_text = "`touch vxWorks.h`"
  4302. "#define VOIDFUNCPTR (void(*)())";
  4303. };
  4304. /*
  4305. * This hack makes write const-correct on VxWorks
  4306. */
  4307. fix = {
  4308. hackname = vxworks_write_const;
  4309. files = ioLib.h;
  4310. mach = "*-*-vxworks*";
  4311. c_fix = format;
  4312. c_fix_arg = "extern int write (int, const char*, size_t);";
  4313. c_fix_arg = "extern[\t ]+int[\t ]+write[\t ]*\\("
  4314. "[\t ]*int[\t ]*,"
  4315. "[\t ]*char[\t ]*\\*[\t ]*,"
  4316. "[\t ]*size_t[\t ]*\\)[\t ]*;";
  4317. test_text = "extern int write ( int , char * , size_t ) ;";
  4318. };
  4319. /*
  4320. * There are several name conflicts with C++ reserved words in X11 header
  4321. * files. These are fixed in some versions, so don't do the fixes if
  4322. * we find __cplusplus in the file. These were found on the RS/6000.
  4323. */
  4324. fix = {
  4325. hackname = x11_class;
  4326. files = X11/ShellP.h;
  4327. bypass = __cplusplus;
  4328. select = "^([ \t]*char \\*)class;(.*)";
  4329. c_fix = format;
  4330. c_fix_arg = "#ifdef __cplusplus\n%1c_class;%2\n"
  4331. "#else\n%1class;%2\n#endif";
  4332. test_text =
  4333. "struct {\n"
  4334. " char *class;\n"
  4335. "} mumble;\n";
  4336. };
  4337. /*
  4338. * class in Xm/BaseClassI.h
  4339. */
  4340. fix = {
  4341. hackname = x11_class_usage;
  4342. files = Xm/BaseClassI.h;
  4343. bypass = "__cplusplus";
  4344. select = " class\\)";
  4345. c_fix = format;
  4346. c_fix_arg = " c_class)";
  4347. test_text = "extern mumble (int class);\n";
  4348. };
  4349. /*
  4350. * new in Xm/Traversal.h
  4351. */
  4352. fix = {
  4353. hackname = x11_new;
  4354. files = Xm/Traversal.h;
  4355. bypass = __cplusplus;
  4356. sed = "/Widget\told, new;/i\\\n"
  4357. "#ifdef __cplusplus\\\n"
  4358. "\\\tWidget\told, c_new;\\\n"
  4359. "#else\n";
  4360. sed = "/Widget\told, new;/a\\\n"
  4361. "#endif\n";
  4362. sed = "s/Widget new,/Widget c_new,/g";
  4363. test_text =
  4364. "struct wedge {\n"
  4365. " Widget\told, new;\n"
  4366. "};\nextern Wedged( Widget new, Widget old );";
  4367. };
  4368. /*
  4369. * Incorrect sprintf declaration in X11/Xmu.h
  4370. */
  4371. fix = {
  4372. hackname = x11_sprintf;
  4373. files = X11/Xmu.h;
  4374. files = X11/Xmu/Xmu.h;
  4375. select = "^extern char \\*\tsprintf\\(\\);$";
  4376. c_fix = format;
  4377. c_fix_arg = "#ifndef __STDC__\n%0\n#endif /* !defined __STDC__ */";
  4378. test_text = "extern char *\tsprintf();";
  4379. };
  4380. /*EOF*/