inclhack.def 164 KB

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