uClibc-0.9.31.1-quad-routines.patch 253 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393
  1. diff -Naur uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/Makefile.arch uClibc-0.9.31/libc/sysdeps/linux/sparc/Makefile.arch
  2. --- uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/Makefile.arch 2010-10-14 14:03:46.000000000 +0200
  3. +++ uClibc-0.9.31/libc/sysdeps/linux/sparc/Makefile.arch 2010-10-14 14:36:34.000000000 +0200
  4. @@ -5,8 +5,15 @@
  5. # Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  6. #
  7. -CSRC := brk.c __syscall_error.c qp_ops.c sigaction.c
  8. +CSRC := brk.c __syscall_error.c sigaction.c
  9. SSRC := \
  10. __longjmp.S fork.S vfork.S clone.S setjmp.S bsd-setjmp.S bsd-_setjmp.S \
  11. syscall.S urem.S udiv.S umul.S sdiv.S rem.S pipe.S
  12. +
  13. +CSRC += $(foreach f, \
  14. + q_div.c q_fle.c q_mul.c q_qtoll.c q_stoq.c \
  15. + mp_clz_tab.c q_dtoq.c q_flt.c q_neg.c q_qtos.c q_sub.c \
  16. + q_add.c q_feq.c q_fne.c q_qtod.c q_qtou.c q_ulltoq.c \
  17. + q_cmp.c q_fge.c q_itoq.c q_qtoull.c q_util.c \
  18. + q_cmpe.c q_fgt.c q_lltoq.c q_qtoi.c q_sqrt.c q_utoq.c, soft-fp/$(f))
  19. diff -Naur uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/double.h uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/double.h
  20. --- uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/double.h 1970-01-01 01:00:00.000000000 +0100
  21. +++ uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/double.h 2010-10-14 14:05:37.000000000 +0200
  22. @@ -0,0 +1,264 @@
  23. +/* Software floating-point emulation.
  24. + Definitions for IEEE Double Precision
  25. + Copyright (C) 1997,1998,1999,2006,2007 Free Software Foundation, Inc.
  26. + This file is part of the GNU C Library.
  27. + Contributed by Richard Henderson (rth@cygnus.com),
  28. + Jakub Jelinek (jj@ultra.linux.cz),
  29. + David S. Miller (davem@redhat.com) and
  30. + Peter Maydell (pmaydell@chiark.greenend.org.uk).
  31. +
  32. + The GNU C Library is free software; you can redistribute it and/or
  33. + modify it under the terms of the GNU Lesser General Public
  34. + License as published by the Free Software Foundation; either
  35. + version 2.1 of the License, or (at your option) any later version.
  36. +
  37. + In addition to the permissions in the GNU Lesser General Public
  38. + License, the Free Software Foundation gives you unlimited
  39. + permission to link the compiled version of this file into
  40. + combinations with other programs, and to distribute those
  41. + combinations without any restriction coming from the use of this
  42. + file. (The Lesser General Public License restrictions do apply in
  43. + other respects; for example, they cover modification of the file,
  44. + and distribution when not linked into a combine executable.)
  45. +
  46. + The GNU C Library is distributed in the hope that it will be useful,
  47. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  48. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  49. + Lesser General Public License for more details.
  50. +
  51. + You should have received a copy of the GNU Lesser General Public
  52. + License along with the GNU C Library; if not, write to the Free
  53. + Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
  54. + MA 02110-1301, USA. */
  55. +
  56. +#if _FP_W_TYPE_SIZE < 32
  57. +#error "Here's a nickel kid. Go buy yourself a real computer."
  58. +#endif
  59. +
  60. +#if _FP_W_TYPE_SIZE < 64
  61. +#define _FP_FRACTBITS_D (2 * _FP_W_TYPE_SIZE)
  62. +#else
  63. +#define _FP_FRACTBITS_D _FP_W_TYPE_SIZE
  64. +#endif
  65. +
  66. +#define _FP_FRACBITS_D 53
  67. +#define _FP_FRACXBITS_D (_FP_FRACTBITS_D - _FP_FRACBITS_D)
  68. +#define _FP_WFRACBITS_D (_FP_WORKBITS + _FP_FRACBITS_D)
  69. +#define _FP_WFRACXBITS_D (_FP_FRACTBITS_D - _FP_WFRACBITS_D)
  70. +#define _FP_EXPBITS_D 11
  71. +#define _FP_EXPBIAS_D 1023
  72. +#define _FP_EXPMAX_D 2047
  73. +
  74. +#define _FP_QNANBIT_D \
  75. + ((_FP_W_TYPE)1 << (_FP_FRACBITS_D-2) % _FP_W_TYPE_SIZE)
  76. +#define _FP_QNANBIT_SH_D \
  77. + ((_FP_W_TYPE)1 << (_FP_FRACBITS_D-2+_FP_WORKBITS) % _FP_W_TYPE_SIZE)
  78. +#define _FP_IMPLBIT_D \
  79. + ((_FP_W_TYPE)1 << (_FP_FRACBITS_D-1) % _FP_W_TYPE_SIZE)
  80. +#define _FP_IMPLBIT_SH_D \
  81. + ((_FP_W_TYPE)1 << (_FP_FRACBITS_D-1+_FP_WORKBITS) % _FP_W_TYPE_SIZE)
  82. +#define _FP_OVERFLOW_D \
  83. + ((_FP_W_TYPE)1 << _FP_WFRACBITS_D % _FP_W_TYPE_SIZE)
  84. +
  85. +typedef float DFtype __attribute__((mode(DF)));
  86. +
  87. +#if _FP_W_TYPE_SIZE < 64
  88. +
  89. +union _FP_UNION_D
  90. +{
  91. + DFtype flt;
  92. + struct {
  93. +#if __BYTE_ORDER == __BIG_ENDIAN
  94. + unsigned sign : 1;
  95. + unsigned exp : _FP_EXPBITS_D;
  96. + unsigned frac1 : _FP_FRACBITS_D - (_FP_IMPLBIT_D != 0) - _FP_W_TYPE_SIZE;
  97. + unsigned frac0 : _FP_W_TYPE_SIZE;
  98. +#else
  99. + unsigned frac0 : _FP_W_TYPE_SIZE;
  100. + unsigned frac1 : _FP_FRACBITS_D - (_FP_IMPLBIT_D != 0) - _FP_W_TYPE_SIZE;
  101. + unsigned exp : _FP_EXPBITS_D;
  102. + unsigned sign : 1;
  103. +#endif
  104. + } bits __attribute__((packed));
  105. +};
  106. +
  107. +#define FP_DECL_D(X) _FP_DECL(2,X)
  108. +#define FP_UNPACK_RAW_D(X,val) _FP_UNPACK_RAW_2(D,X,val)
  109. +#define FP_UNPACK_RAW_DP(X,val) _FP_UNPACK_RAW_2_P(D,X,val)
  110. +#define FP_PACK_RAW_D(val,X) _FP_PACK_RAW_2(D,val,X)
  111. +#define FP_PACK_RAW_DP(val,X) \
  112. + do { \
  113. + if (!FP_INHIBIT_RESULTS) \
  114. + _FP_PACK_RAW_2_P(D,val,X); \
  115. + } while (0)
  116. +
  117. +#define FP_UNPACK_D(X,val) \
  118. + do { \
  119. + _FP_UNPACK_RAW_2(D,X,val); \
  120. + _FP_UNPACK_CANONICAL(D,2,X); \
  121. + } while (0)
  122. +
  123. +#define FP_UNPACK_DP(X,val) \
  124. + do { \
  125. + _FP_UNPACK_RAW_2_P(D,X,val); \
  126. + _FP_UNPACK_CANONICAL(D,2,X); \
  127. + } while (0)
  128. +
  129. +#define FP_UNPACK_SEMIRAW_D(X,val) \
  130. + do { \
  131. + _FP_UNPACK_RAW_2(D,X,val); \
  132. + _FP_UNPACK_SEMIRAW(D,2,X); \
  133. + } while (0)
  134. +
  135. +#define FP_UNPACK_SEMIRAW_DP(X,val) \
  136. + do { \
  137. + _FP_UNPACK_RAW_2_P(D,X,val); \
  138. + _FP_UNPACK_SEMIRAW(D,2,X); \
  139. + } while (0)
  140. +
  141. +#define FP_PACK_D(val,X) \
  142. + do { \
  143. + _FP_PACK_CANONICAL(D,2,X); \
  144. + _FP_PACK_RAW_2(D,val,X); \
  145. + } while (0)
  146. +
  147. +#define FP_PACK_DP(val,X) \
  148. + do { \
  149. + _FP_PACK_CANONICAL(D,2,X); \
  150. + if (!FP_INHIBIT_RESULTS) \
  151. + _FP_PACK_RAW_2_P(D,val,X); \
  152. + } while (0)
  153. +
  154. +#define FP_PACK_SEMIRAW_D(val,X) \
  155. + do { \
  156. + _FP_PACK_SEMIRAW(D,2,X); \
  157. + _FP_PACK_RAW_2(D,val,X); \
  158. + } while (0)
  159. +
  160. +#define FP_PACK_SEMIRAW_DP(val,X) \
  161. + do { \
  162. + _FP_PACK_SEMIRAW(D,2,X); \
  163. + if (!FP_INHIBIT_RESULTS) \
  164. + _FP_PACK_RAW_2_P(D,val,X); \
  165. + } while (0)
  166. +
  167. +#define FP_ISSIGNAN_D(X) _FP_ISSIGNAN(D,2,X)
  168. +#define FP_NEG_D(R,X) _FP_NEG(D,2,R,X)
  169. +#define FP_ADD_D(R,X,Y) _FP_ADD(D,2,R,X,Y)
  170. +#define FP_SUB_D(R,X,Y) _FP_SUB(D,2,R,X,Y)
  171. +#define FP_MUL_D(R,X,Y) _FP_MUL(D,2,R,X,Y)
  172. +#define FP_DIV_D(R,X,Y) _FP_DIV(D,2,R,X,Y)
  173. +#define FP_SQRT_D(R,X) _FP_SQRT(D,2,R,X)
  174. +#define _FP_SQRT_MEAT_D(R,S,T,X,Q) _FP_SQRT_MEAT_2(R,S,T,X,Q)
  175. +
  176. +#define FP_CMP_D(r,X,Y,un) _FP_CMP(D,2,r,X,Y,un)
  177. +#define FP_CMP_EQ_D(r,X,Y) _FP_CMP_EQ(D,2,r,X,Y)
  178. +#define FP_CMP_UNORD_D(r,X,Y) _FP_CMP_UNORD(D,2,r,X,Y)
  179. +
  180. +#define FP_TO_INT_D(r,X,rsz,rsg) _FP_TO_INT(D,2,r,X,rsz,rsg)
  181. +#define FP_FROM_INT_D(X,r,rs,rt) _FP_FROM_INT(D,2,X,r,rs,rt)
  182. +
  183. +#define _FP_FRAC_HIGH_D(X) _FP_FRAC_HIGH_2(X)
  184. +#define _FP_FRAC_HIGH_RAW_D(X) _FP_FRAC_HIGH_2(X)
  185. +
  186. +#else
  187. +
  188. +union _FP_UNION_D
  189. +{
  190. + DFtype flt;
  191. + struct {
  192. +#if __BYTE_ORDER == __BIG_ENDIAN
  193. + unsigned sign : 1;
  194. + unsigned exp : _FP_EXPBITS_D;
  195. + _FP_W_TYPE frac : _FP_FRACBITS_D - (_FP_IMPLBIT_D != 0);
  196. +#else
  197. + _FP_W_TYPE frac : _FP_FRACBITS_D - (_FP_IMPLBIT_D != 0);
  198. + unsigned exp : _FP_EXPBITS_D;
  199. + unsigned sign : 1;
  200. +#endif
  201. + } bits __attribute__((packed));
  202. +};
  203. +
  204. +#define FP_DECL_D(X) _FP_DECL(1,X)
  205. +#define FP_UNPACK_RAW_D(X,val) _FP_UNPACK_RAW_1(D,X,val)
  206. +#define FP_UNPACK_RAW_DP(X,val) _FP_UNPACK_RAW_1_P(D,X,val)
  207. +#define FP_PACK_RAW_D(val,X) _FP_PACK_RAW_1(D,val,X)
  208. +#define FP_PACK_RAW_DP(val,X) \
  209. + do { \
  210. + if (!FP_INHIBIT_RESULTS) \
  211. + _FP_PACK_RAW_1_P(D,val,X); \
  212. + } while (0)
  213. +
  214. +#define FP_UNPACK_D(X,val) \
  215. + do { \
  216. + _FP_UNPACK_RAW_1(D,X,val); \
  217. + _FP_UNPACK_CANONICAL(D,1,X); \
  218. + } while (0)
  219. +
  220. +#define FP_UNPACK_DP(X,val) \
  221. + do { \
  222. + _FP_UNPACK_RAW_1_P(D,X,val); \
  223. + _FP_UNPACK_CANONICAL(D,1,X); \
  224. + } while (0)
  225. +
  226. +#define FP_UNPACK_SEMIRAW_D(X,val) \
  227. + do { \
  228. + _FP_UNPACK_RAW_2(1,X,val); \
  229. + _FP_UNPACK_SEMIRAW(D,1,X); \
  230. + } while (0)
  231. +
  232. +#define FP_UNPACK_SEMIRAW_DP(X,val) \
  233. + do { \
  234. + _FP_UNPACK_RAW_2_P(1,X,val); \
  235. + _FP_UNPACK_SEMIRAW(D,1,X); \
  236. + } while (0)
  237. +
  238. +#define FP_PACK_D(val,X) \
  239. + do { \
  240. + _FP_PACK_CANONICAL(D,1,X); \
  241. + _FP_PACK_RAW_1(D,val,X); \
  242. + } while (0)
  243. +
  244. +#define FP_PACK_DP(val,X) \
  245. + do { \
  246. + _FP_PACK_CANONICAL(D,1,X); \
  247. + if (!FP_INHIBIT_RESULTS) \
  248. + _FP_PACK_RAW_1_P(D,val,X); \
  249. + } while (0)
  250. +
  251. +#define FP_PACK_SEMIRAW_D(val,X) \
  252. + do { \
  253. + _FP_PACK_SEMIRAW(D,1,X); \
  254. + _FP_PACK_RAW_1(D,val,X); \
  255. + } while (0)
  256. +
  257. +#define FP_PACK_SEMIRAW_DP(val,X) \
  258. + do { \
  259. + _FP_PACK_SEMIRAW(D,1,X); \
  260. + if (!FP_INHIBIT_RESULTS) \
  261. + _FP_PACK_RAW_1_P(D,val,X); \
  262. + } while (0)
  263. +
  264. +#define FP_ISSIGNAN_D(X) _FP_ISSIGNAN(D,1,X)
  265. +#define FP_NEG_D(R,X) _FP_NEG(D,1,R,X)
  266. +#define FP_ADD_D(R,X,Y) _FP_ADD(D,1,R,X,Y)
  267. +#define FP_SUB_D(R,X,Y) _FP_SUB(D,1,R,X,Y)
  268. +#define FP_MUL_D(R,X,Y) _FP_MUL(D,1,R,X,Y)
  269. +#define FP_DIV_D(R,X,Y) _FP_DIV(D,1,R,X,Y)
  270. +#define FP_SQRT_D(R,X) _FP_SQRT(D,1,R,X)
  271. +#define _FP_SQRT_MEAT_D(R,S,T,X,Q) _FP_SQRT_MEAT_1(R,S,T,X,Q)
  272. +
  273. +/* The implementation of _FP_MUL_D and _FP_DIV_D should be chosen by
  274. + the target machine. */
  275. +
  276. +#define FP_CMP_D(r,X,Y,un) _FP_CMP(D,1,r,X,Y,un)
  277. +#define FP_CMP_EQ_D(r,X,Y) _FP_CMP_EQ(D,1,r,X,Y)
  278. +#define FP_CMP_UNORD_D(r,X,Y) _FP_CMP_UNORD(D,1,r,X,Y)
  279. +
  280. +#define FP_TO_INT_D(r,X,rsz,rsg) _FP_TO_INT(D,1,r,X,rsz,rsg)
  281. +#define FP_FROM_INT_D(X,r,rs,rt) _FP_FROM_INT(D,1,X,r,rs,rt)
  282. +
  283. +#define _FP_FRAC_HIGH_D(X) _FP_FRAC_HIGH_1(X)
  284. +#define _FP_FRAC_HIGH_RAW_D(X) _FP_FRAC_HIGH_1(X)
  285. +
  286. +#endif /* W_TYPE_SIZE < 64 */
  287. diff -Naur uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/extended.h uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/extended.h
  288. --- uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/extended.h 1970-01-01 01:00:00.000000000 +0100
  289. +++ uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/extended.h 2010-10-14 14:05:37.000000000 +0200
  290. @@ -0,0 +1,431 @@
  291. +/* Software floating-point emulation.
  292. + Definitions for IEEE Extended Precision.
  293. + Copyright (C) 1999,2006,2007 Free Software Foundation, Inc.
  294. + This file is part of the GNU C Library.
  295. + Contributed by Jakub Jelinek (jj@ultra.linux.cz).
  296. +
  297. + The GNU C Library is free software; you can redistribute it and/or
  298. + modify it under the terms of the GNU Lesser General Public
  299. + License as published by the Free Software Foundation; either
  300. + version 2.1 of the License, or (at your option) any later version.
  301. +
  302. + In addition to the permissions in the GNU Lesser General Public
  303. + License, the Free Software Foundation gives you unlimited
  304. + permission to link the compiled version of this file into
  305. + combinations with other programs, and to distribute those
  306. + combinations without any restriction coming from the use of this
  307. + file. (The Lesser General Public License restrictions do apply in
  308. + other respects; for example, they cover modification of the file,
  309. + and distribution when not linked into a combine executable.)
  310. +
  311. + The GNU C Library is distributed in the hope that it will be useful,
  312. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  313. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  314. + Lesser General Public License for more details.
  315. +
  316. + You should have received a copy of the GNU Lesser General Public
  317. + License along with the GNU C Library; if not, write to the Free
  318. + Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
  319. + MA 02110-1301, USA. */
  320. +
  321. +#if _FP_W_TYPE_SIZE < 32
  322. +#error "Here's a nickel, kid. Go buy yourself a real computer."
  323. +#endif
  324. +
  325. +#if _FP_W_TYPE_SIZE < 64
  326. +#define _FP_FRACTBITS_E (4*_FP_W_TYPE_SIZE)
  327. +#else
  328. +#define _FP_FRACTBITS_E (2*_FP_W_TYPE_SIZE)
  329. +#endif
  330. +
  331. +#define _FP_FRACBITS_E 64
  332. +#define _FP_FRACXBITS_E (_FP_FRACTBITS_E - _FP_FRACBITS_E)
  333. +#define _FP_WFRACBITS_E (_FP_WORKBITS + _FP_FRACBITS_E)
  334. +#define _FP_WFRACXBITS_E (_FP_FRACTBITS_E - _FP_WFRACBITS_E)
  335. +#define _FP_EXPBITS_E 15
  336. +#define _FP_EXPBIAS_E 16383
  337. +#define _FP_EXPMAX_E 32767
  338. +
  339. +#define _FP_QNANBIT_E \
  340. + ((_FP_W_TYPE)1 << (_FP_FRACBITS_E-2) % _FP_W_TYPE_SIZE)
  341. +#define _FP_QNANBIT_SH_E \
  342. + ((_FP_W_TYPE)1 << (_FP_FRACBITS_E-2+_FP_WORKBITS) % _FP_W_TYPE_SIZE)
  343. +#define _FP_IMPLBIT_E \
  344. + ((_FP_W_TYPE)1 << (_FP_FRACBITS_E-1) % _FP_W_TYPE_SIZE)
  345. +#define _FP_IMPLBIT_SH_E \
  346. + ((_FP_W_TYPE)1 << (_FP_FRACBITS_E-1+_FP_WORKBITS) % _FP_W_TYPE_SIZE)
  347. +#define _FP_OVERFLOW_E \
  348. + ((_FP_W_TYPE)1 << (_FP_WFRACBITS_E % _FP_W_TYPE_SIZE))
  349. +
  350. +typedef float XFtype __attribute__((mode(XF)));
  351. +
  352. +#if _FP_W_TYPE_SIZE < 64
  353. +
  354. +union _FP_UNION_E
  355. +{
  356. + XFtype flt;
  357. + struct
  358. + {
  359. +#if __BYTE_ORDER == __BIG_ENDIAN
  360. + unsigned long pad1 : _FP_W_TYPE_SIZE;
  361. + unsigned long pad2 : (_FP_W_TYPE_SIZE - 1 - _FP_EXPBITS_E);
  362. + unsigned long sign : 1;
  363. + unsigned long exp : _FP_EXPBITS_E;
  364. + unsigned long frac1 : _FP_W_TYPE_SIZE;
  365. + unsigned long frac0 : _FP_W_TYPE_SIZE;
  366. +#else
  367. + unsigned long frac0 : _FP_W_TYPE_SIZE;
  368. + unsigned long frac1 : _FP_W_TYPE_SIZE;
  369. + unsigned exp : _FP_EXPBITS_E;
  370. + unsigned sign : 1;
  371. +#endif /* not bigendian */
  372. + } bits __attribute__((packed));
  373. +};
  374. +
  375. +
  376. +#define FP_DECL_E(X) _FP_DECL(4,X)
  377. +
  378. +#define FP_UNPACK_RAW_E(X, val) \
  379. + do { \
  380. + union _FP_UNION_E _flo; _flo.flt = (val); \
  381. + \
  382. + X##_f[2] = 0; X##_f[3] = 0; \
  383. + X##_f[0] = _flo.bits.frac0; \
  384. + X##_f[1] = _flo.bits.frac1; \
  385. + X##_e = _flo.bits.exp; \
  386. + X##_s = _flo.bits.sign; \
  387. + } while (0)
  388. +
  389. +#define FP_UNPACK_RAW_EP(X, val) \
  390. + do { \
  391. + union _FP_UNION_E *_flo = \
  392. + (union _FP_UNION_E *)(val); \
  393. + \
  394. + X##_f[2] = 0; X##_f[3] = 0; \
  395. + X##_f[0] = _flo->bits.frac0; \
  396. + X##_f[1] = _flo->bits.frac1; \
  397. + X##_e = _flo->bits.exp; \
  398. + X##_s = _flo->bits.sign; \
  399. + } while (0)
  400. +
  401. +#define FP_PACK_RAW_E(val, X) \
  402. + do { \
  403. + union _FP_UNION_E _flo; \
  404. + \
  405. + if (X##_e) X##_f[1] |= _FP_IMPLBIT_E; \
  406. + else X##_f[1] &= ~(_FP_IMPLBIT_E); \
  407. + _flo.bits.frac0 = X##_f[0]; \
  408. + _flo.bits.frac1 = X##_f[1]; \
  409. + _flo.bits.exp = X##_e; \
  410. + _flo.bits.sign = X##_s; \
  411. + \
  412. + (val) = _flo.flt; \
  413. + } while (0)
  414. +
  415. +#define FP_PACK_RAW_EP(val, X) \
  416. + do { \
  417. + if (!FP_INHIBIT_RESULTS) \
  418. + { \
  419. + union _FP_UNION_E *_flo = \
  420. + (union _FP_UNION_E *)(val); \
  421. + \
  422. + if (X##_e) X##_f[1] |= _FP_IMPLBIT_E; \
  423. + else X##_f[1] &= ~(_FP_IMPLBIT_E); \
  424. + _flo->bits.frac0 = X##_f[0]; \
  425. + _flo->bits.frac1 = X##_f[1]; \
  426. + _flo->bits.exp = X##_e; \
  427. + _flo->bits.sign = X##_s; \
  428. + } \
  429. + } while (0)
  430. +
  431. +#define FP_UNPACK_E(X,val) \
  432. + do { \
  433. + FP_UNPACK_RAW_E(X,val); \
  434. + _FP_UNPACK_CANONICAL(E,4,X); \
  435. + } while (0)
  436. +
  437. +#define FP_UNPACK_EP(X,val) \
  438. + do { \
  439. + FP_UNPACK_RAW_EP(X,val); \
  440. + _FP_UNPACK_CANONICAL(E,4,X); \
  441. + } while (0)
  442. +
  443. +#define FP_UNPACK_SEMIRAW_E(X,val) \
  444. + do { \
  445. + FP_UNPACK_RAW_E(X,val); \
  446. + _FP_UNPACK_SEMIRAW(E,4,X); \
  447. + } while (0)
  448. +
  449. +#define FP_UNPACK_SEMIRAW_EP(X,val) \
  450. + do { \
  451. + FP_UNPACK_RAW_EP(X,val); \
  452. + _FP_UNPACK_SEMIRAW(E,4,X); \
  453. + } while (0)
  454. +
  455. +#define FP_PACK_E(val,X) \
  456. + do { \
  457. + _FP_PACK_CANONICAL(E,4,X); \
  458. + FP_PACK_RAW_E(val,X); \
  459. + } while (0)
  460. +
  461. +#define FP_PACK_EP(val,X) \
  462. + do { \
  463. + _FP_PACK_CANONICAL(E,4,X); \
  464. + FP_PACK_RAW_EP(val,X); \
  465. + } while (0)
  466. +
  467. +#define FP_PACK_SEMIRAW_E(val,X) \
  468. + do { \
  469. + _FP_PACK_SEMIRAW(E,4,X); \
  470. + FP_PACK_RAW_E(val,X); \
  471. + } while (0)
  472. +
  473. +#define FP_PACK_SEMIRAW_EP(val,X) \
  474. + do { \
  475. + _FP_PACK_SEMIRAW(E,4,X); \
  476. + FP_PACK_RAW_EP(val,X); \
  477. + } while (0)
  478. +
  479. +#define FP_ISSIGNAN_E(X) _FP_ISSIGNAN(E,4,X)
  480. +#define FP_NEG_E(R,X) _FP_NEG(E,4,R,X)
  481. +#define FP_ADD_E(R,X,Y) _FP_ADD(E,4,R,X,Y)
  482. +#define FP_SUB_E(R,X,Y) _FP_SUB(E,4,R,X,Y)
  483. +#define FP_MUL_E(R,X,Y) _FP_MUL(E,4,R,X,Y)
  484. +#define FP_DIV_E(R,X,Y) _FP_DIV(E,4,R,X,Y)
  485. +#define FP_SQRT_E(R,X) _FP_SQRT(E,4,R,X)
  486. +
  487. +/*
  488. + * Square root algorithms:
  489. + * We have just one right now, maybe Newton approximation
  490. + * should be added for those machines where division is fast.
  491. + * This has special _E version because standard _4 square
  492. + * root would not work (it has to start normally with the
  493. + * second word and not the first), but as we have to do it
  494. + * anyway, we optimize it by doing most of the calculations
  495. + * in two UWtype registers instead of four.
  496. + */
  497. +
  498. +#define _FP_SQRT_MEAT_E(R, S, T, X, q) \
  499. + do { \
  500. + q = (_FP_W_TYPE)1 << (_FP_W_TYPE_SIZE - 1); \
  501. + _FP_FRAC_SRL_4(X, (_FP_WORKBITS)); \
  502. + while (q) \
  503. + { \
  504. + T##_f[1] = S##_f[1] + q; \
  505. + if (T##_f[1] <= X##_f[1]) \
  506. + { \
  507. + S##_f[1] = T##_f[1] + q; \
  508. + X##_f[1] -= T##_f[1]; \
  509. + R##_f[1] += q; \
  510. + } \
  511. + _FP_FRAC_SLL_2(X, 1); \
  512. + q >>= 1; \
  513. + } \
  514. + q = (_FP_W_TYPE)1 << (_FP_W_TYPE_SIZE - 1); \
  515. + while (q) \
  516. + { \
  517. + T##_f[0] = S##_f[0] + q; \
  518. + T##_f[1] = S##_f[1]; \
  519. + if (T##_f[1] < X##_f[1] || \
  520. + (T##_f[1] == X##_f[1] && \
  521. + T##_f[0] <= X##_f[0])) \
  522. + { \
  523. + S##_f[0] = T##_f[0] + q; \
  524. + S##_f[1] += (T##_f[0] > S##_f[0]); \
  525. + _FP_FRAC_DEC_2(X, T); \
  526. + R##_f[0] += q; \
  527. + } \
  528. + _FP_FRAC_SLL_2(X, 1); \
  529. + q >>= 1; \
  530. + } \
  531. + _FP_FRAC_SLL_4(R, (_FP_WORKBITS)); \
  532. + if (X##_f[0] | X##_f[1]) \
  533. + { \
  534. + if (S##_f[1] < X##_f[1] || \
  535. + (S##_f[1] == X##_f[1] && \
  536. + S##_f[0] < X##_f[0])) \
  537. + R##_f[0] |= _FP_WORK_ROUND; \
  538. + R##_f[0] |= _FP_WORK_STICKY; \
  539. + } \
  540. + } while (0)
  541. +
  542. +#define FP_CMP_E(r,X,Y,un) _FP_CMP(E,4,r,X,Y,un)
  543. +#define FP_CMP_EQ_E(r,X,Y) _FP_CMP_EQ(E,4,r,X,Y)
  544. +#define FP_CMP_UNORD_E(r,X,Y) _FP_CMP_UNORD(E,4,r,X,Y)
  545. +
  546. +#define FP_TO_INT_E(r,X,rsz,rsg) _FP_TO_INT(E,4,r,X,rsz,rsg)
  547. +#define FP_FROM_INT_E(X,r,rs,rt) _FP_FROM_INT(E,4,X,r,rs,rt)
  548. +
  549. +#define _FP_FRAC_HIGH_E(X) (X##_f[2])
  550. +#define _FP_FRAC_HIGH_RAW_E(X) (X##_f[1])
  551. +
  552. +#else /* not _FP_W_TYPE_SIZE < 64 */
  553. +union _FP_UNION_E
  554. +{
  555. + XFtype flt;
  556. + struct {
  557. +#if __BYTE_ORDER == __BIG_ENDIAN
  558. + _FP_W_TYPE pad : (_FP_W_TYPE_SIZE - 1 - _FP_EXPBITS_E);
  559. + unsigned sign : 1;
  560. + unsigned exp : _FP_EXPBITS_E;
  561. + _FP_W_TYPE frac : _FP_W_TYPE_SIZE;
  562. +#else
  563. + _FP_W_TYPE frac : _FP_W_TYPE_SIZE;
  564. + unsigned exp : _FP_EXPBITS_E;
  565. + unsigned sign : 1;
  566. +#endif
  567. + } bits;
  568. +};
  569. +
  570. +#define FP_DECL_E(X) _FP_DECL(2,X)
  571. +
  572. +#define FP_UNPACK_RAW_E(X, val) \
  573. + do { \
  574. + union _FP_UNION_E _flo; _flo.flt = (val); \
  575. + \
  576. + X##_f0 = _flo.bits.frac; \
  577. + X##_f1 = 0; \
  578. + X##_e = _flo.bits.exp; \
  579. + X##_s = _flo.bits.sign; \
  580. + } while (0)
  581. +
  582. +#define FP_UNPACK_RAW_EP(X, val) \
  583. + do { \
  584. + union _FP_UNION_E *_flo = \
  585. + (union _FP_UNION_E *)(val); \
  586. + \
  587. + X##_f0 = _flo->bits.frac; \
  588. + X##_f1 = 0; \
  589. + X##_e = _flo->bits.exp; \
  590. + X##_s = _flo->bits.sign; \
  591. + } while (0)
  592. +
  593. +#define FP_PACK_RAW_E(val, X) \
  594. + do { \
  595. + union _FP_UNION_E _flo; \
  596. + \
  597. + if (X##_e) X##_f0 |= _FP_IMPLBIT_E; \
  598. + else X##_f0 &= ~(_FP_IMPLBIT_E); \
  599. + _flo.bits.frac = X##_f0; \
  600. + _flo.bits.exp = X##_e; \
  601. + _flo.bits.sign = X##_s; \
  602. + \
  603. + (val) = _flo.flt; \
  604. + } while (0)
  605. +
  606. +#define FP_PACK_RAW_EP(fs, val, X) \
  607. + do { \
  608. + if (!FP_INHIBIT_RESULTS) \
  609. + { \
  610. + union _FP_UNION_E *_flo = \
  611. + (union _FP_UNION_E *)(val); \
  612. + \
  613. + if (X##_e) X##_f0 |= _FP_IMPLBIT_E; \
  614. + else X##_f0 &= ~(_FP_IMPLBIT_E); \
  615. + _flo->bits.frac = X##_f0; \
  616. + _flo->bits.exp = X##_e; \
  617. + _flo->bits.sign = X##_s; \
  618. + } \
  619. + } while (0)
  620. +
  621. +
  622. +#define FP_UNPACK_E(X,val) \
  623. + do { \
  624. + FP_UNPACK_RAW_E(X,val); \
  625. + _FP_UNPACK_CANONICAL(E,2,X); \
  626. + } while (0)
  627. +
  628. +#define FP_UNPACK_EP(X,val) \
  629. + do { \
  630. + FP_UNPACK_RAW_EP(X,val); \
  631. + _FP_UNPACK_CANONICAL(E,2,X); \
  632. + } while (0)
  633. +
  634. +#define FP_UNPACK_SEMIRAW_E(X,val) \
  635. + do { \
  636. + FP_UNPACK_RAW_E(X,val); \
  637. + _FP_UNPACK_SEMIRAW(E,2,X); \
  638. + } while (0)
  639. +
  640. +#define FP_UNPACK_SEMIRAW_EP(X,val) \
  641. + do { \
  642. + FP_UNPACK_RAW_EP(X,val); \
  643. + _FP_UNPACK_SEMIRAW(E,2,X); \
  644. + } while (0)
  645. +
  646. +#define FP_PACK_E(val,X) \
  647. + do { \
  648. + _FP_PACK_CANONICAL(E,2,X); \
  649. + FP_PACK_RAW_E(val,X); \
  650. + } while (0)
  651. +
  652. +#define FP_PACK_EP(val,X) \
  653. + do { \
  654. + _FP_PACK_CANONICAL(E,2,X); \
  655. + FP_PACK_RAW_EP(val,X); \
  656. + } while (0)
  657. +
  658. +#define FP_PACK_SEMIRAW_E(val,X) \
  659. + do { \
  660. + _FP_PACK_SEMIRAW(E,2,X); \
  661. + FP_PACK_RAW_E(val,X); \
  662. + } while (0)
  663. +
  664. +#define FP_PACK_SEMIRAW_EP(val,X) \
  665. + do { \
  666. + _FP_PACK_SEMIRAW(E,2,X); \
  667. + FP_PACK_RAW_EP(val,X); \
  668. + } while (0)
  669. +
  670. +#define FP_ISSIGNAN_E(X) _FP_ISSIGNAN(E,2,X)
  671. +#define FP_NEG_E(R,X) _FP_NEG(E,2,R,X)
  672. +#define FP_ADD_E(R,X,Y) _FP_ADD(E,2,R,X,Y)
  673. +#define FP_SUB_E(R,X,Y) _FP_SUB(E,2,R,X,Y)
  674. +#define FP_MUL_E(R,X,Y) _FP_MUL(E,2,R,X,Y)
  675. +#define FP_DIV_E(R,X,Y) _FP_DIV(E,2,R,X,Y)
  676. +#define FP_SQRT_E(R,X) _FP_SQRT(E,2,R,X)
  677. +
  678. +/*
  679. + * Square root algorithms:
  680. + * We have just one right now, maybe Newton approximation
  681. + * should be added for those machines where division is fast.
  682. + * We optimize it by doing most of the calculations
  683. + * in one UWtype registers instead of two, although we don't
  684. + * have to.
  685. + */
  686. +#define _FP_SQRT_MEAT_E(R, S, T, X, q) \
  687. + do { \
  688. + q = (_FP_W_TYPE)1 << (_FP_W_TYPE_SIZE - 1); \
  689. + _FP_FRAC_SRL_2(X, (_FP_WORKBITS)); \
  690. + while (q) \
  691. + { \
  692. + T##_f0 = S##_f0 + q; \
  693. + if (T##_f0 <= X##_f0) \
  694. + { \
  695. + S##_f0 = T##_f0 + q; \
  696. + X##_f0 -= T##_f0; \
  697. + R##_f0 += q; \
  698. + } \
  699. + _FP_FRAC_SLL_1(X, 1); \
  700. + q >>= 1; \
  701. + } \
  702. + _FP_FRAC_SLL_2(R, (_FP_WORKBITS)); \
  703. + if (X##_f0) \
  704. + { \
  705. + if (S##_f0 < X##_f0) \
  706. + R##_f0 |= _FP_WORK_ROUND; \
  707. + R##_f0 |= _FP_WORK_STICKY; \
  708. + } \
  709. + } while (0)
  710. +
  711. +#define FP_CMP_E(r,X,Y,un) _FP_CMP(E,2,r,X,Y,un)
  712. +#define FP_CMP_EQ_E(r,X,Y) _FP_CMP_EQ(E,2,r,X,Y)
  713. +#define FP_CMP_UNORD_E(r,X,Y) _FP_CMP_UNORD(E,2,r,X,Y)
  714. +
  715. +#define FP_TO_INT_E(r,X,rsz,rsg) _FP_TO_INT(E,2,r,X,rsz,rsg)
  716. +#define FP_FROM_INT_E(X,r,rs,rt) _FP_FROM_INT(E,2,X,r,rs,rt)
  717. +
  718. +#define _FP_FRAC_HIGH_E(X) (X##_f1)
  719. +#define _FP_FRAC_HIGH_RAW_E(X) (X##_f0)
  720. +
  721. +#endif /* not _FP_W_TYPE_SIZE < 64 */
  722. diff -Naur uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/longlong.h uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/longlong.h
  723. --- uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/longlong.h 1970-01-01 01:00:00.000000000 +0100
  724. +++ uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/longlong.h 2010-10-14 14:05:37.000000000 +0200
  725. @@ -0,0 +1,1461 @@
  726. +/* longlong.h -- definitions for mixed size 32/64 bit arithmetic.
  727. + Copyright (C) 1991, 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
  728. + 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
  729. +
  730. + This file is part of the GNU C Library.
  731. +
  732. + The GNU C Library is free software; you can redistribute it and/or
  733. + modify it under the terms of the GNU Lesser General Public
  734. + License as published by the Free Software Foundation; either
  735. + version 2.1 of the License, or (at your option) any later version.
  736. +
  737. + The GNU C Library is distributed in the hope that it will be useful,
  738. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  739. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  740. + Lesser General Public License for more details.
  741. +
  742. + You should have received a copy of the GNU Lesser General Public
  743. + License along with the GNU C Library; if not, write to the Free
  744. + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  745. + 02111-1307 USA. */
  746. +
  747. +/* You have to define the following before including this file:
  748. +
  749. + UWtype -- An unsigned type, default type for operations (typically a "word")
  750. + UHWtype -- An unsigned type, at least half the size of UWtype.
  751. + UDWtype -- An unsigned type, at least twice as large a UWtype
  752. + W_TYPE_SIZE -- size in bits of UWtype
  753. +
  754. + UQItype -- Unsigned 8 bit type.
  755. + SItype, USItype -- Signed and unsigned 32 bit types.
  756. + DItype, UDItype -- Signed and unsigned 64 bit types.
  757. +
  758. + On a 32 bit machine UWtype should typically be USItype;
  759. + on a 64 bit machine, UWtype should typically be UDItype. */
  760. +
  761. +#define __BITS4 (W_TYPE_SIZE / 4)
  762. +#define __ll_B ((UWtype) 1 << (W_TYPE_SIZE / 2))
  763. +#define __ll_lowpart(t) ((UWtype) (t) & (__ll_B - 1))
  764. +#define __ll_highpart(t) ((UWtype) (t) >> (W_TYPE_SIZE / 2))
  765. +
  766. +#ifndef W_TYPE_SIZE
  767. +#define W_TYPE_SIZE 32
  768. +#define UWtype USItype
  769. +#define UHWtype USItype
  770. +#define UDWtype UDItype
  771. +#endif
  772. +
  773. +extern const UQItype __clz_tab[256] attribute_hidden;
  774. +
  775. +/* Define auxiliary asm macros.
  776. +
  777. + 1) umul_ppmm(high_prod, low_prod, multiplier, multiplicand) multiplies two
  778. + UWtype integers MULTIPLIER and MULTIPLICAND, and generates a two UWtype
  779. + word product in HIGH_PROD and LOW_PROD.
  780. +
  781. + 2) __umulsidi3(a,b) multiplies two UWtype integers A and B, and returns a
  782. + UDWtype product. This is just a variant of umul_ppmm.
  783. +
  784. + 3) udiv_qrnnd(quotient, remainder, high_numerator, low_numerator,
  785. + denominator) divides a UDWtype, composed by the UWtype integers
  786. + HIGH_NUMERATOR and LOW_NUMERATOR, by DENOMINATOR and places the quotient
  787. + in QUOTIENT and the remainder in REMAINDER. HIGH_NUMERATOR must be less
  788. + than DENOMINATOR for correct operation. If, in addition, the most
  789. + significant bit of DENOMINATOR must be 1, then the pre-processor symbol
  790. + UDIV_NEEDS_NORMALIZATION is defined to 1.
  791. +
  792. + 4) sdiv_qrnnd(quotient, remainder, high_numerator, low_numerator,
  793. + denominator). Like udiv_qrnnd but the numbers are signed. The quotient
  794. + is rounded towards 0.
  795. +
  796. + 5) count_leading_zeros(count, x) counts the number of zero-bits from the
  797. + msb to the first nonzero bit in the UWtype X. This is the number of
  798. + steps X needs to be shifted left to set the msb. Undefined for X == 0,
  799. + unless the symbol COUNT_LEADING_ZEROS_0 is defined to some value.
  800. +
  801. + 6) count_trailing_zeros(count, x) like count_leading_zeros, but counts
  802. + from the least significant end.
  803. +
  804. + 7) add_ssaaaa(high_sum, low_sum, high_addend_1, low_addend_1,
  805. + high_addend_2, low_addend_2) adds two UWtype integers, composed by
  806. + HIGH_ADDEND_1 and LOW_ADDEND_1, and HIGH_ADDEND_2 and LOW_ADDEND_2
  807. + respectively. The result is placed in HIGH_SUM and LOW_SUM. Overflow
  808. + (i.e. carry out) is not stored anywhere, and is lost.
  809. +
  810. + 8) sub_ddmmss(high_difference, low_difference, high_minuend, low_minuend,
  811. + high_subtrahend, low_subtrahend) subtracts two two-word UWtype integers,
  812. + composed by HIGH_MINUEND_1 and LOW_MINUEND_1, and HIGH_SUBTRAHEND_2 and
  813. + LOW_SUBTRAHEND_2 respectively. The result is placed in HIGH_DIFFERENCE
  814. + and LOW_DIFFERENCE. Overflow (i.e. carry out) is not stored anywhere,
  815. + and is lost.
  816. +
  817. + If any of these macros are left undefined for a particular CPU,
  818. + C macros are used. */
  819. +
  820. +/* The CPUs come in alphabetical order below.
  821. +
  822. + Please add support for more CPUs here, or improve the current support
  823. + for the CPUs below!
  824. + (E.g. WE32100, IBM360.) */
  825. +
  826. +#if defined (__GNUC__) && !defined (NO_ASM)
  827. +
  828. +/* We sometimes need to clobber "cc" with gcc2, but that would not be
  829. + understood by gcc1. Use cpp to avoid major code duplication. */
  830. +#if __GNUC__ < 2
  831. +#define __CLOBBER_CC
  832. +#define __AND_CLOBBER_CC
  833. +#else /* __GNUC__ >= 2 */
  834. +#define __CLOBBER_CC : "cc"
  835. +#define __AND_CLOBBER_CC , "cc"
  836. +#endif /* __GNUC__ < 2 */
  837. +
  838. +#if defined (__alpha) && W_TYPE_SIZE == 64
  839. +#define umul_ppmm(ph, pl, m0, m1) \
  840. + do { \
  841. + UDItype __m0 = (m0), __m1 = (m1); \
  842. + (ph) = __builtin_alpha_umulh (__m0, __m1); \
  843. + (pl) = __m0 * __m1; \
  844. + } while (0)
  845. +#define UMUL_TIME 46
  846. +#ifndef LONGLONG_STANDALONE
  847. +#define udiv_qrnnd(q, r, n1, n0, d) \
  848. + do { UDItype __r; \
  849. + (q) = __udiv_qrnnd (&__r, (n1), (n0), (d)); \
  850. + (r) = __r; \
  851. + } while (0)
  852. +extern UDItype __udiv_qrnnd (UDItype *, UDItype, UDItype, UDItype);
  853. +#define UDIV_TIME 220
  854. +#endif /* LONGLONG_STANDALONE */
  855. +#ifdef __alpha_cix__
  856. +#define count_leading_zeros(COUNT,X) ((COUNT) = __builtin_clzl (X))
  857. +#define count_trailing_zeros(COUNT,X) ((COUNT) = __builtin_ctzl (X))
  858. +#define COUNT_LEADING_ZEROS_0 64
  859. +#else
  860. +#define count_leading_zeros(COUNT,X) \
  861. + do { \
  862. + UDItype __xr = (X), __t, __a; \
  863. + __t = __builtin_alpha_cmpbge (0, __xr); \
  864. + __a = __clz_tab[__t ^ 0xff] - 1; \
  865. + __t = __builtin_alpha_extbl (__xr, __a); \
  866. + (COUNT) = 64 - (__clz_tab[__t] + __a*8); \
  867. + } while (0)
  868. +#define count_trailing_zeros(COUNT,X) \
  869. + do { \
  870. + UDItype __xr = (X), __t, __a; \
  871. + __t = __builtin_alpha_cmpbge (0, __xr); \
  872. + __t = ~__t & -~__t; \
  873. + __a = ((__t & 0xCC) != 0) * 2; \
  874. + __a += ((__t & 0xF0) != 0) * 4; \
  875. + __a += ((__t & 0xAA) != 0); \
  876. + __t = __builtin_alpha_extbl (__xr, __a); \
  877. + __a <<= 3; \
  878. + __t &= -__t; \
  879. + __a += ((__t & 0xCC) != 0) * 2; \
  880. + __a += ((__t & 0xF0) != 0) * 4; \
  881. + __a += ((__t & 0xAA) != 0); \
  882. + (COUNT) = __a; \
  883. + } while (0)
  884. +#endif /* __alpha_cix__ */
  885. +#endif /* __alpha */
  886. +
  887. +#if defined (__arc__) && W_TYPE_SIZE == 32
  888. +#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
  889. + __asm__ ("add.f %1, %4, %5\n\tadc %0, %2, %3" \
  890. + : "=r" ((USItype) (sh)), \
  891. + "=&r" ((USItype) (sl)) \
  892. + : "%r" ((USItype) (ah)), \
  893. + "rIJ" ((USItype) (bh)), \
  894. + "%r" ((USItype) (al)), \
  895. + "rIJ" ((USItype) (bl)))
  896. +#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
  897. + __asm__ ("sub.f %1, %4, %5\n\tsbc %0, %2, %3" \
  898. + : "=r" ((USItype) (sh)), \
  899. + "=&r" ((USItype) (sl)) \
  900. + : "r" ((USItype) (ah)), \
  901. + "rIJ" ((USItype) (bh)), \
  902. + "r" ((USItype) (al)), \
  903. + "rIJ" ((USItype) (bl)))
  904. +/* Call libgcc routine. */
  905. +#define umul_ppmm(w1, w0, u, v) \
  906. +do { \
  907. + DWunion __w; \
  908. + __w.ll = __umulsidi3 (u, v); \
  909. + w1 = __w.s.high; \
  910. + w0 = __w.s.low; \
  911. +} while (0)
  912. +#define __umulsidi3 __umulsidi3
  913. +UDItype __umulsidi3 (USItype, USItype);
  914. +#endif
  915. +
  916. +#if defined (__arm__) && !defined (__thumb__) && W_TYPE_SIZE == 32
  917. +#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
  918. + __asm__ ("adds %1, %4, %5\n\tadc %0, %2, %3" \
  919. + : "=r" ((USItype) (sh)), \
  920. + "=&r" ((USItype) (sl)) \
  921. + : "%r" ((USItype) (ah)), \
  922. + "rI" ((USItype) (bh)), \
  923. + "%r" ((USItype) (al)), \
  924. + "rI" ((USItype) (bl)) __CLOBBER_CC)
  925. +#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
  926. + __asm__ ("subs %1, %4, %5\n\tsbc %0, %2, %3" \
  927. + : "=r" ((USItype) (sh)), \
  928. + "=&r" ((USItype) (sl)) \
  929. + : "r" ((USItype) (ah)), \
  930. + "rI" ((USItype) (bh)), \
  931. + "r" ((USItype) (al)), \
  932. + "rI" ((USItype) (bl)) __CLOBBER_CC)
  933. +#define umul_ppmm(xh, xl, a, b) \
  934. +{register USItype __t0, __t1, __t2; \
  935. + __asm__ ("%@ Inlined umul_ppmm\n" \
  936. + " mov %2, %5, lsr #16\n" \
  937. + " mov %0, %6, lsr #16\n" \
  938. + " bic %3, %5, %2, lsl #16\n" \
  939. + " bic %4, %6, %0, lsl #16\n" \
  940. + " mul %1, %3, %4\n" \
  941. + " mul %4, %2, %4\n" \
  942. + " mul %3, %0, %3\n" \
  943. + " mul %0, %2, %0\n" \
  944. + " adds %3, %4, %3\n" \
  945. + " addcs %0, %0, #65536\n" \
  946. + " adds %1, %1, %3, lsl #16\n" \
  947. + " adc %0, %0, %3, lsr #16" \
  948. + : "=&r" ((USItype) (xh)), \
  949. + "=r" ((USItype) (xl)), \
  950. + "=&r" (__t0), "=&r" (__t1), "=r" (__t2) \
  951. + : "r" ((USItype) (a)), \
  952. + "r" ((USItype) (b)) __CLOBBER_CC );}
  953. +#define UMUL_TIME 20
  954. +#define UDIV_TIME 100
  955. +#endif /* __arm__ */
  956. +
  957. +#if defined(__arm__)
  958. +/* Let gcc decide how best to implement count_leading_zeros. */
  959. +#define count_leading_zeros(COUNT,X) ((COUNT) = __builtin_clz (X))
  960. +#define COUNT_LEADING_ZEROS_0 32
  961. +#endif
  962. +
  963. +#if defined (__CRIS__) && __CRIS_arch_version >= 3
  964. +#define count_leading_zeros(COUNT, X) ((COUNT) = __builtin_clz (X))
  965. +#if __CRIS_arch_version >= 8
  966. +#define count_trailing_zeros(COUNT, X) ((COUNT) = __builtin_ctz (X))
  967. +#endif
  968. +#endif /* __CRIS__ */
  969. +
  970. +#if defined (__hppa) && W_TYPE_SIZE == 32
  971. +#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
  972. + __asm__ ("add %4,%5,%1\n\taddc %2,%3,%0" \
  973. + : "=r" ((USItype) (sh)), \
  974. + "=&r" ((USItype) (sl)) \
  975. + : "%rM" ((USItype) (ah)), \
  976. + "rM" ((USItype) (bh)), \
  977. + "%rM" ((USItype) (al)), \
  978. + "rM" ((USItype) (bl)))
  979. +#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
  980. + __asm__ ("sub %4,%5,%1\n\tsubb %2,%3,%0" \
  981. + : "=r" ((USItype) (sh)), \
  982. + "=&r" ((USItype) (sl)) \
  983. + : "rM" ((USItype) (ah)), \
  984. + "rM" ((USItype) (bh)), \
  985. + "rM" ((USItype) (al)), \
  986. + "rM" ((USItype) (bl)))
  987. +#if defined (_PA_RISC1_1)
  988. +#define umul_ppmm(w1, w0, u, v) \
  989. + do { \
  990. + union \
  991. + { \
  992. + UDItype __f; \
  993. + struct {USItype __w1, __w0;} __w1w0; \
  994. + } __t; \
  995. + __asm__ ("xmpyu %1,%2,%0" \
  996. + : "=x" (__t.__f) \
  997. + : "x" ((USItype) (u)), \
  998. + "x" ((USItype) (v))); \
  999. + (w1) = __t.__w1w0.__w1; \
  1000. + (w0) = __t.__w1w0.__w0; \
  1001. + } while (0)
  1002. +#define UMUL_TIME 8
  1003. +#else
  1004. +#define UMUL_TIME 30
  1005. +#endif
  1006. +#define UDIV_TIME 40
  1007. +#define count_leading_zeros(count, x) \
  1008. + do { \
  1009. + USItype __tmp; \
  1010. + __asm__ ( \
  1011. + "ldi 1,%0\n" \
  1012. +" extru,= %1,15,16,%%r0 ; Bits 31..16 zero?\n" \
  1013. +" extru,tr %1,15,16,%1 ; No. Shift down, skip add.\n"\
  1014. +" ldo 16(%0),%0 ; Yes. Perform add.\n" \
  1015. +" extru,= %1,23,8,%%r0 ; Bits 15..8 zero?\n" \
  1016. +" extru,tr %1,23,8,%1 ; No. Shift down, skip add.\n"\
  1017. +" ldo 8(%0),%0 ; Yes. Perform add.\n" \
  1018. +" extru,= %1,27,4,%%r0 ; Bits 7..4 zero?\n" \
  1019. +" extru,tr %1,27,4,%1 ; No. Shift down, skip add.\n"\
  1020. +" ldo 4(%0),%0 ; Yes. Perform add.\n" \
  1021. +" extru,= %1,29,2,%%r0 ; Bits 3..2 zero?\n" \
  1022. +" extru,tr %1,29,2,%1 ; No. Shift down, skip add.\n"\
  1023. +" ldo 2(%0),%0 ; Yes. Perform add.\n" \
  1024. +" extru %1,30,1,%1 ; Extract bit 1.\n" \
  1025. +" sub %0,%1,%0 ; Subtract it.\n" \
  1026. + : "=r" (count), "=r" (__tmp) : "1" (x)); \
  1027. + } while (0)
  1028. +#endif
  1029. +
  1030. +#if (defined (__i370__) || defined (__s390__) || defined (__mvs__)) && W_TYPE_SIZE == 32
  1031. +#define smul_ppmm(xh, xl, m0, m1) \
  1032. + do { \
  1033. + union {DItype __ll; \
  1034. + struct {USItype __h, __l;} __i; \
  1035. + } __x; \
  1036. + __asm__ ("lr %N0,%1\n\tmr %0,%2" \
  1037. + : "=&r" (__x.__ll) \
  1038. + : "r" (m0), "r" (m1)); \
  1039. + (xh) = __x.__i.__h; (xl) = __x.__i.__l; \
  1040. + } while (0)
  1041. +#define sdiv_qrnnd(q, r, n1, n0, d) \
  1042. + do { \
  1043. + union {DItype __ll; \
  1044. + struct {USItype __h, __l;} __i; \
  1045. + } __x; \
  1046. + __x.__i.__h = n1; __x.__i.__l = n0; \
  1047. + __asm__ ("dr %0,%2" \
  1048. + : "=r" (__x.__ll) \
  1049. + : "0" (__x.__ll), "r" (d)); \
  1050. + (q) = __x.__i.__l; (r) = __x.__i.__h; \
  1051. + } while (0)
  1052. +#endif
  1053. +
  1054. +#if (defined (__i386__) || defined (__i486__)) && W_TYPE_SIZE == 32
  1055. +#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
  1056. + __asm__ ("add{l} {%5,%1|%1,%5}\n\tadc{l} {%3,%0|%0,%3}" \
  1057. + : "=r" ((USItype) (sh)), \
  1058. + "=&r" ((USItype) (sl)) \
  1059. + : "%0" ((USItype) (ah)), \
  1060. + "g" ((USItype) (bh)), \
  1061. + "%1" ((USItype) (al)), \
  1062. + "g" ((USItype) (bl)))
  1063. +#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
  1064. + __asm__ ("sub{l} {%5,%1|%1,%5}\n\tsbb{l} {%3,%0|%0,%3}" \
  1065. + : "=r" ((USItype) (sh)), \
  1066. + "=&r" ((USItype) (sl)) \
  1067. + : "0" ((USItype) (ah)), \
  1068. + "g" ((USItype) (bh)), \
  1069. + "1" ((USItype) (al)), \
  1070. + "g" ((USItype) (bl)))
  1071. +#define umul_ppmm(w1, w0, u, v) \
  1072. + __asm__ ("mul{l} %3" \
  1073. + : "=a" ((USItype) (w0)), \
  1074. + "=d" ((USItype) (w1)) \
  1075. + : "%0" ((USItype) (u)), \
  1076. + "rm" ((USItype) (v)))
  1077. +#define udiv_qrnnd(q, r, n1, n0, dv) \
  1078. + __asm__ ("div{l} %4" \
  1079. + : "=a" ((USItype) (q)), \
  1080. + "=d" ((USItype) (r)) \
  1081. + : "0" ((USItype) (n0)), \
  1082. + "1" ((USItype) (n1)), \
  1083. + "rm" ((USItype) (dv)))
  1084. +#define count_leading_zeros(count, x) ((count) = __builtin_clz (x))
  1085. +#define count_trailing_zeros(count, x) ((count) = __builtin_ctz (x))
  1086. +#define UMUL_TIME 40
  1087. +#define UDIV_TIME 40
  1088. +#endif /* 80x86 */
  1089. +
  1090. +#if (defined (__x86_64__) || defined (__i386__)) && W_TYPE_SIZE == 64
  1091. +#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
  1092. + __asm__ ("add{q} {%5,%1|%1,%5}\n\tadc{q} {%3,%0|%0,%3}" \
  1093. + : "=r" ((UDItype) (sh)), \
  1094. + "=&r" ((UDItype) (sl)) \
  1095. + : "%0" ((UDItype) (ah)), \
  1096. + "rme" ((UDItype) (bh)), \
  1097. + "%1" ((UDItype) (al)), \
  1098. + "rme" ((UDItype) (bl)))
  1099. +#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
  1100. + __asm__ ("sub{q} {%5,%1|%1,%5}\n\tsbb{q} {%3,%0|%0,%3}" \
  1101. + : "=r" ((UDItype) (sh)), \
  1102. + "=&r" ((UDItype) (sl)) \
  1103. + : "0" ((UDItype) (ah)), \
  1104. + "rme" ((UDItype) (bh)), \
  1105. + "1" ((UDItype) (al)), \
  1106. + "rme" ((UDItype) (bl)))
  1107. +#define umul_ppmm(w1, w0, u, v) \
  1108. + __asm__ ("mul{q} %3" \
  1109. + : "=a" ((UDItype) (w0)), \
  1110. + "=d" ((UDItype) (w1)) \
  1111. + : "%0" ((UDItype) (u)), \
  1112. + "rm" ((UDItype) (v)))
  1113. +#define udiv_qrnnd(q, r, n1, n0, dv) \
  1114. + __asm__ ("div{q} %4" \
  1115. + : "=a" ((UDItype) (q)), \
  1116. + "=d" ((UDItype) (r)) \
  1117. + : "0" ((UDItype) (n0)), \
  1118. + "1" ((UDItype) (n1)), \
  1119. + "rm" ((UDItype) (dv)))
  1120. +#define count_leading_zeros(count, x) ((count) = __builtin_clzl (x))
  1121. +#define count_trailing_zeros(count, x) ((count) = __builtin_ctzl (x))
  1122. +#define UMUL_TIME 40
  1123. +#define UDIV_TIME 40
  1124. +#endif /* x86_64 */
  1125. +
  1126. +#if defined (__i960__) && W_TYPE_SIZE == 32
  1127. +#define umul_ppmm(w1, w0, u, v) \
  1128. + ({union {UDItype __ll; \
  1129. + struct {USItype __l, __h;} __i; \
  1130. + } __xx; \
  1131. + __asm__ ("emul %2,%1,%0" \
  1132. + : "=d" (__xx.__ll) \
  1133. + : "%dI" ((USItype) (u)), \
  1134. + "dI" ((USItype) (v))); \
  1135. + (w1) = __xx.__i.__h; (w0) = __xx.__i.__l;})
  1136. +#define __umulsidi3(u, v) \
  1137. + ({UDItype __w; \
  1138. + __asm__ ("emul %2,%1,%0" \
  1139. + : "=d" (__w) \
  1140. + : "%dI" ((USItype) (u)), \
  1141. + "dI" ((USItype) (v))); \
  1142. + __w; })
  1143. +#endif /* __i960__ */
  1144. +
  1145. +#if defined (__M32R__) && W_TYPE_SIZE == 32
  1146. +#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
  1147. + /* The cmp clears the condition bit. */ \
  1148. + __asm__ ("cmp %0,%0\n\taddx %1,%5\n\taddx %0,%3" \
  1149. + : "=r" ((USItype) (sh)), \
  1150. + "=&r" ((USItype) (sl)) \
  1151. + : "0" ((USItype) (ah)), \
  1152. + "r" ((USItype) (bh)), \
  1153. + "1" ((USItype) (al)), \
  1154. + "r" ((USItype) (bl)) \
  1155. + : "cbit")
  1156. +#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
  1157. + /* The cmp clears the condition bit. */ \
  1158. + __asm__ ("cmp %0,%0\n\tsubx %1,%5\n\tsubx %0,%3" \
  1159. + : "=r" ((USItype) (sh)), \
  1160. + "=&r" ((USItype) (sl)) \
  1161. + : "0" ((USItype) (ah)), \
  1162. + "r" ((USItype) (bh)), \
  1163. + "1" ((USItype) (al)), \
  1164. + "r" ((USItype) (bl)) \
  1165. + : "cbit")
  1166. +#endif /* __M32R__ */
  1167. +
  1168. +#if defined (__mc68000__) && W_TYPE_SIZE == 32
  1169. +#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
  1170. + __asm__ ("add%.l %5,%1\n\taddx%.l %3,%0" \
  1171. + : "=d" ((USItype) (sh)), \
  1172. + "=&d" ((USItype) (sl)) \
  1173. + : "%0" ((USItype) (ah)), \
  1174. + "d" ((USItype) (bh)), \
  1175. + "%1" ((USItype) (al)), \
  1176. + "g" ((USItype) (bl)))
  1177. +#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
  1178. + __asm__ ("sub%.l %5,%1\n\tsubx%.l %3,%0" \
  1179. + : "=d" ((USItype) (sh)), \
  1180. + "=&d" ((USItype) (sl)) \
  1181. + : "0" ((USItype) (ah)), \
  1182. + "d" ((USItype) (bh)), \
  1183. + "1" ((USItype) (al)), \
  1184. + "g" ((USItype) (bl)))
  1185. +
  1186. +/* The '020, '030, '040, '060 and CPU32 have 32x32->64 and 64/32->32q-32r. */
  1187. +#if (defined (__mc68020__) && !defined (__mc68060__))
  1188. +#define umul_ppmm(w1, w0, u, v) \
  1189. + __asm__ ("mulu%.l %3,%1:%0" \
  1190. + : "=d" ((USItype) (w0)), \
  1191. + "=d" ((USItype) (w1)) \
  1192. + : "%0" ((USItype) (u)), \
  1193. + "dmi" ((USItype) (v)))
  1194. +#define UMUL_TIME 45
  1195. +#define udiv_qrnnd(q, r, n1, n0, d) \
  1196. + __asm__ ("divu%.l %4,%1:%0" \
  1197. + : "=d" ((USItype) (q)), \
  1198. + "=d" ((USItype) (r)) \
  1199. + : "0" ((USItype) (n0)), \
  1200. + "1" ((USItype) (n1)), \
  1201. + "dmi" ((USItype) (d)))
  1202. +#define UDIV_TIME 90
  1203. +#define sdiv_qrnnd(q, r, n1, n0, d) \
  1204. + __asm__ ("divs%.l %4,%1:%0" \
  1205. + : "=d" ((USItype) (q)), \
  1206. + "=d" ((USItype) (r)) \
  1207. + : "0" ((USItype) (n0)), \
  1208. + "1" ((USItype) (n1)), \
  1209. + "dmi" ((USItype) (d)))
  1210. +
  1211. +#elif defined (__mcoldfire__) /* not mc68020 */
  1212. +
  1213. +#define umul_ppmm(xh, xl, a, b) \
  1214. + __asm__ ("| Inlined umul_ppmm\n" \
  1215. + " move%.l %2,%/d0\n" \
  1216. + " move%.l %3,%/d1\n" \
  1217. + " move%.l %/d0,%/d2\n" \
  1218. + " swap %/d0\n" \
  1219. + " move%.l %/d1,%/d3\n" \
  1220. + " swap %/d1\n" \
  1221. + " move%.w %/d2,%/d4\n" \
  1222. + " mulu %/d3,%/d4\n" \
  1223. + " mulu %/d1,%/d2\n" \
  1224. + " mulu %/d0,%/d3\n" \
  1225. + " mulu %/d0,%/d1\n" \
  1226. + " move%.l %/d4,%/d0\n" \
  1227. + " clr%.w %/d0\n" \
  1228. + " swap %/d0\n" \
  1229. + " add%.l %/d0,%/d2\n" \
  1230. + " add%.l %/d3,%/d2\n" \
  1231. + " jcc 1f\n" \
  1232. + " add%.l %#65536,%/d1\n" \
  1233. + "1: swap %/d2\n" \
  1234. + " moveq %#0,%/d0\n" \
  1235. + " move%.w %/d2,%/d0\n" \
  1236. + " move%.w %/d4,%/d2\n" \
  1237. + " move%.l %/d2,%1\n" \
  1238. + " add%.l %/d1,%/d0\n" \
  1239. + " move%.l %/d0,%0" \
  1240. + : "=g" ((USItype) (xh)), \
  1241. + "=g" ((USItype) (xl)) \
  1242. + : "g" ((USItype) (a)), \
  1243. + "g" ((USItype) (b)) \
  1244. + : "d0", "d1", "d2", "d3", "d4")
  1245. +#define UMUL_TIME 100
  1246. +#define UDIV_TIME 400
  1247. +#else /* not ColdFire */
  1248. +/* %/ inserts REGISTER_PREFIX, %# inserts IMMEDIATE_PREFIX. */
  1249. +#define umul_ppmm(xh, xl, a, b) \
  1250. + __asm__ ("| Inlined umul_ppmm\n" \
  1251. + " move%.l %2,%/d0\n" \
  1252. + " move%.l %3,%/d1\n" \
  1253. + " move%.l %/d0,%/d2\n" \
  1254. + " swap %/d0\n" \
  1255. + " move%.l %/d1,%/d3\n" \
  1256. + " swap %/d1\n" \
  1257. + " move%.w %/d2,%/d4\n" \
  1258. + " mulu %/d3,%/d4\n" \
  1259. + " mulu %/d1,%/d2\n" \
  1260. + " mulu %/d0,%/d3\n" \
  1261. + " mulu %/d0,%/d1\n" \
  1262. + " move%.l %/d4,%/d0\n" \
  1263. + " eor%.w %/d0,%/d0\n" \
  1264. + " swap %/d0\n" \
  1265. + " add%.l %/d0,%/d2\n" \
  1266. + " add%.l %/d3,%/d2\n" \
  1267. + " jcc 1f\n" \
  1268. + " add%.l %#65536,%/d1\n" \
  1269. + "1: swap %/d2\n" \
  1270. + " moveq %#0,%/d0\n" \
  1271. + " move%.w %/d2,%/d0\n" \
  1272. + " move%.w %/d4,%/d2\n" \
  1273. + " move%.l %/d2,%1\n" \
  1274. + " add%.l %/d1,%/d0\n" \
  1275. + " move%.l %/d0,%0" \
  1276. + : "=g" ((USItype) (xh)), \
  1277. + "=g" ((USItype) (xl)) \
  1278. + : "g" ((USItype) (a)), \
  1279. + "g" ((USItype) (b)) \
  1280. + : "d0", "d1", "d2", "d3", "d4")
  1281. +#define UMUL_TIME 100
  1282. +#define UDIV_TIME 400
  1283. +
  1284. +#endif /* not mc68020 */
  1285. +
  1286. +/* The '020, '030, '040 and '060 have bitfield insns.
  1287. + cpu32 disguises as a 68020, but lacks them. */
  1288. +#if defined (__mc68020__) && !defined (__mcpu32__)
  1289. +#define count_leading_zeros(count, x) \
  1290. + __asm__ ("bfffo %1{%b2:%b2},%0" \
  1291. + : "=d" ((USItype) (count)) \
  1292. + : "od" ((USItype) (x)), "n" (0))
  1293. +/* Some ColdFire architectures have a ff1 instruction supported via
  1294. + __builtin_clz. */
  1295. +#elif defined (__mcfisaaplus__) || defined (__mcfisac__)
  1296. +#define count_leading_zeros(count,x) ((count) = __builtin_clz (x))
  1297. +#define COUNT_LEADING_ZEROS_0 32
  1298. +#endif
  1299. +#endif /* mc68000 */
  1300. +
  1301. +#if defined (__m88000__) && W_TYPE_SIZE == 32
  1302. +#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
  1303. + __asm__ ("addu.co %1,%r4,%r5\n\taddu.ci %0,%r2,%r3" \
  1304. + : "=r" ((USItype) (sh)), \
  1305. + "=&r" ((USItype) (sl)) \
  1306. + : "%rJ" ((USItype) (ah)), \
  1307. + "rJ" ((USItype) (bh)), \
  1308. + "%rJ" ((USItype) (al)), \
  1309. + "rJ" ((USItype) (bl)))
  1310. +#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
  1311. + __asm__ ("subu.co %1,%r4,%r5\n\tsubu.ci %0,%r2,%r3" \
  1312. + : "=r" ((USItype) (sh)), \
  1313. + "=&r" ((USItype) (sl)) \
  1314. + : "rJ" ((USItype) (ah)), \
  1315. + "rJ" ((USItype) (bh)), \
  1316. + "rJ" ((USItype) (al)), \
  1317. + "rJ" ((USItype) (bl)))
  1318. +#define count_leading_zeros(count, x) \
  1319. + do { \
  1320. + USItype __cbtmp; \
  1321. + __asm__ ("ff1 %0,%1" \
  1322. + : "=r" (__cbtmp) \
  1323. + : "r" ((USItype) (x))); \
  1324. + (count) = __cbtmp ^ 31; \
  1325. + } while (0)
  1326. +#define COUNT_LEADING_ZEROS_0 63 /* sic */
  1327. +#if defined (__mc88110__)
  1328. +#define umul_ppmm(wh, wl, u, v) \
  1329. + do { \
  1330. + union {UDItype __ll; \
  1331. + struct {USItype __h, __l;} __i; \
  1332. + } __xx; \
  1333. + __asm__ ("mulu.d %0,%1,%2" \
  1334. + : "=r" (__xx.__ll) \
  1335. + : "r" ((USItype) (u)), \
  1336. + "r" ((USItype) (v))); \
  1337. + (wh) = __xx.__i.__h; \
  1338. + (wl) = __xx.__i.__l; \
  1339. + } while (0)
  1340. +#define udiv_qrnnd(q, r, n1, n0, d) \
  1341. + ({union {UDItype __ll; \
  1342. + struct {USItype __h, __l;} __i; \
  1343. + } __xx; \
  1344. + USItype __q; \
  1345. + __xx.__i.__h = (n1); __xx.__i.__l = (n0); \
  1346. + __asm__ ("divu.d %0,%1,%2" \
  1347. + : "=r" (__q) \
  1348. + : "r" (__xx.__ll), \
  1349. + "r" ((USItype) (d))); \
  1350. + (r) = (n0) - __q * (d); (q) = __q; })
  1351. +#define UMUL_TIME 5
  1352. +#define UDIV_TIME 25
  1353. +#else
  1354. +#define UMUL_TIME 17
  1355. +#define UDIV_TIME 150
  1356. +#endif /* __mc88110__ */
  1357. +#endif /* __m88000__ */
  1358. +
  1359. +#if defined (__mips__) && W_TYPE_SIZE == 32
  1360. +#define umul_ppmm(w1, w0, u, v) \
  1361. + do { \
  1362. + UDItype __x = (UDItype) (USItype) (u) * (USItype) (v); \
  1363. + (w1) = (USItype) (__x >> 32); \
  1364. + (w0) = (USItype) (__x); \
  1365. + } while (0)
  1366. +#define UMUL_TIME 10
  1367. +#define UDIV_TIME 100
  1368. +
  1369. +#if (__mips == 32 || __mips == 64) && ! __mips16
  1370. +#define count_leading_zeros(COUNT,X) ((COUNT) = __builtin_clz (X))
  1371. +#define COUNT_LEADING_ZEROS_0 32
  1372. +#endif
  1373. +#endif /* __mips__ */
  1374. +
  1375. +#if defined (__ns32000__) && W_TYPE_SIZE == 32
  1376. +#define umul_ppmm(w1, w0, u, v) \
  1377. + ({union {UDItype __ll; \
  1378. + struct {USItype __l, __h;} __i; \
  1379. + } __xx; \
  1380. + __asm__ ("meid %2,%0" \
  1381. + : "=g" (__xx.__ll) \
  1382. + : "%0" ((USItype) (u)), \
  1383. + "g" ((USItype) (v))); \
  1384. + (w1) = __xx.__i.__h; (w0) = __xx.__i.__l;})
  1385. +#define __umulsidi3(u, v) \
  1386. + ({UDItype __w; \
  1387. + __asm__ ("meid %2,%0" \
  1388. + : "=g" (__w) \
  1389. + : "%0" ((USItype) (u)), \
  1390. + "g" ((USItype) (v))); \
  1391. + __w; })
  1392. +#define udiv_qrnnd(q, r, n1, n0, d) \
  1393. + ({union {UDItype __ll; \
  1394. + struct {USItype __l, __h;} __i; \
  1395. + } __xx; \
  1396. + __xx.__i.__h = (n1); __xx.__i.__l = (n0); \
  1397. + __asm__ ("deid %2,%0" \
  1398. + : "=g" (__xx.__ll) \
  1399. + : "0" (__xx.__ll), \
  1400. + "g" ((USItype) (d))); \
  1401. + (r) = __xx.__i.__l; (q) = __xx.__i.__h; })
  1402. +#define count_trailing_zeros(count,x) \
  1403. + do { \
  1404. + __asm__ ("ffsd %2,%0" \
  1405. + : "=r" ((USItype) (count)) \
  1406. + : "0" ((USItype) 0), \
  1407. + "r" ((USItype) (x))); \
  1408. + } while (0)
  1409. +#endif /* __ns32000__ */
  1410. +
  1411. +/* FIXME: We should test _IBMR2 here when we add assembly support for the
  1412. + system vendor compilers.
  1413. + FIXME: What's needed for gcc PowerPC VxWorks? __vxworks__ is not good
  1414. + enough, since that hits ARM and m68k too. */
  1415. +#if (defined (_ARCH_PPC) /* AIX */ \
  1416. + || defined (_ARCH_PWR) /* AIX */ \
  1417. + || defined (_ARCH_COM) /* AIX */ \
  1418. + || defined (__powerpc__) /* gcc */ \
  1419. + || defined (__POWERPC__) /* BEOS */ \
  1420. + || defined (__ppc__) /* Darwin */ \
  1421. + || (defined (PPC) && ! defined (CPU_FAMILY)) /* gcc 2.7.x GNU&SysV */ \
  1422. + || (defined (PPC) && defined (CPU_FAMILY) /* VxWorks */ \
  1423. + && CPU_FAMILY == PPC) \
  1424. + ) && W_TYPE_SIZE == 32
  1425. +#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
  1426. + do { \
  1427. + if (__builtin_constant_p (bh) && (bh) == 0) \
  1428. + __asm__ ("{a%I4|add%I4c} %1,%3,%4\n\t{aze|addze} %0,%2" \
  1429. + : "=r" (sh), "=&r" (sl) : "r" (ah), "%r" (al), "rI" (bl));\
  1430. + else if (__builtin_constant_p (bh) && (bh) == ~(USItype) 0) \
  1431. + __asm__ ("{a%I4|add%I4c} %1,%3,%4\n\t{ame|addme} %0,%2" \
  1432. + : "=r" (sh), "=&r" (sl) : "r" (ah), "%r" (al), "rI" (bl));\
  1433. + else \
  1434. + __asm__ ("{a%I5|add%I5c} %1,%4,%5\n\t{ae|adde} %0,%2,%3" \
  1435. + : "=r" (sh), "=&r" (sl) \
  1436. + : "%r" (ah), "r" (bh), "%r" (al), "rI" (bl)); \
  1437. + } while (0)
  1438. +#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
  1439. + do { \
  1440. + if (__builtin_constant_p (ah) && (ah) == 0) \
  1441. + __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{sfze|subfze} %0,%2" \
  1442. + : "=r" (sh), "=&r" (sl) : "r" (bh), "rI" (al), "r" (bl));\
  1443. + else if (__builtin_constant_p (ah) && (ah) == ~(USItype) 0) \
  1444. + __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{sfme|subfme} %0,%2" \
  1445. + : "=r" (sh), "=&r" (sl) : "r" (bh), "rI" (al), "r" (bl));\
  1446. + else if (__builtin_constant_p (bh) && (bh) == 0) \
  1447. + __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{ame|addme} %0,%2" \
  1448. + : "=r" (sh), "=&r" (sl) : "r" (ah), "rI" (al), "r" (bl));\
  1449. + else if (__builtin_constant_p (bh) && (bh) == ~(USItype) 0) \
  1450. + __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{aze|addze} %0,%2" \
  1451. + : "=r" (sh), "=&r" (sl) : "r" (ah), "rI" (al), "r" (bl));\
  1452. + else \
  1453. + __asm__ ("{sf%I4|subf%I4c} %1,%5,%4\n\t{sfe|subfe} %0,%3,%2" \
  1454. + : "=r" (sh), "=&r" (sl) \
  1455. + : "r" (ah), "r" (bh), "rI" (al), "r" (bl)); \
  1456. + } while (0)
  1457. +#define count_leading_zeros(count, x) \
  1458. + __asm__ ("{cntlz|cntlzw} %0,%1" : "=r" (count) : "r" (x))
  1459. +#define COUNT_LEADING_ZEROS_0 32
  1460. +#if defined (_ARCH_PPC) || defined (__powerpc__) || defined (__POWERPC__) \
  1461. + || defined (__ppc__) \
  1462. + || (defined (PPC) && ! defined (CPU_FAMILY)) /* gcc 2.7.x GNU&SysV */ \
  1463. + || (defined (PPC) && defined (CPU_FAMILY) /* VxWorks */ \
  1464. + && CPU_FAMILY == PPC)
  1465. +#define umul_ppmm(ph, pl, m0, m1) \
  1466. + do { \
  1467. + USItype __m0 = (m0), __m1 = (m1); \
  1468. + __asm__ ("mulhwu %0,%1,%2" : "=r" (ph) : "%r" (m0), "r" (m1)); \
  1469. + (pl) = __m0 * __m1; \
  1470. + } while (0)
  1471. +#define UMUL_TIME 15
  1472. +#define smul_ppmm(ph, pl, m0, m1) \
  1473. + do { \
  1474. + SItype __m0 = (m0), __m1 = (m1); \
  1475. + __asm__ ("mulhw %0,%1,%2" : "=r" (ph) : "%r" (m0), "r" (m1)); \
  1476. + (pl) = __m0 * __m1; \
  1477. + } while (0)
  1478. +#define SMUL_TIME 14
  1479. +#define UDIV_TIME 120
  1480. +#elif defined (_ARCH_PWR)
  1481. +#define UMUL_TIME 8
  1482. +#define smul_ppmm(xh, xl, m0, m1) \
  1483. + __asm__ ("mul %0,%2,%3" : "=r" (xh), "=q" (xl) : "r" (m0), "r" (m1))
  1484. +#define SMUL_TIME 4
  1485. +#define sdiv_qrnnd(q, r, nh, nl, d) \
  1486. + __asm__ ("div %0,%2,%4" : "=r" (q), "=q" (r) : "r" (nh), "1" (nl), "r" (d))
  1487. +#define UDIV_TIME 100
  1488. +#endif
  1489. +#endif /* 32-bit POWER architecture variants. */
  1490. +
  1491. +/* We should test _IBMR2 here when we add assembly support for the system
  1492. + vendor compilers. */
  1493. +#if (defined (_ARCH_PPC64) || defined (__powerpc64__)) && W_TYPE_SIZE == 64
  1494. +#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
  1495. + do { \
  1496. + if (__builtin_constant_p (bh) && (bh) == 0) \
  1497. + __asm__ ("{a%I4|add%I4c} %1,%3,%4\n\t{aze|addze} %0,%2" \
  1498. + : "=r" (sh), "=&r" (sl) : "r" (ah), "%r" (al), "rI" (bl));\
  1499. + else if (__builtin_constant_p (bh) && (bh) == ~(UDItype) 0) \
  1500. + __asm__ ("{a%I4|add%I4c} %1,%3,%4\n\t{ame|addme} %0,%2" \
  1501. + : "=r" (sh), "=&r" (sl) : "r" (ah), "%r" (al), "rI" (bl));\
  1502. + else \
  1503. + __asm__ ("{a%I5|add%I5c} %1,%4,%5\n\t{ae|adde} %0,%2,%3" \
  1504. + : "=r" (sh), "=&r" (sl) \
  1505. + : "%r" (ah), "r" (bh), "%r" (al), "rI" (bl)); \
  1506. + } while (0)
  1507. +#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
  1508. + do { \
  1509. + if (__builtin_constant_p (ah) && (ah) == 0) \
  1510. + __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{sfze|subfze} %0,%2" \
  1511. + : "=r" (sh), "=&r" (sl) : "r" (bh), "rI" (al), "r" (bl));\
  1512. + else if (__builtin_constant_p (ah) && (ah) == ~(UDItype) 0) \
  1513. + __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{sfme|subfme} %0,%2" \
  1514. + : "=r" (sh), "=&r" (sl) : "r" (bh), "rI" (al), "r" (bl));\
  1515. + else if (__builtin_constant_p (bh) && (bh) == 0) \
  1516. + __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{ame|addme} %0,%2" \
  1517. + : "=r" (sh), "=&r" (sl) : "r" (ah), "rI" (al), "r" (bl));\
  1518. + else if (__builtin_constant_p (bh) && (bh) == ~(UDItype) 0) \
  1519. + __asm__ ("{sf%I3|subf%I3c} %1,%4,%3\n\t{aze|addze} %0,%2" \
  1520. + : "=r" (sh), "=&r" (sl) : "r" (ah), "rI" (al), "r" (bl));\
  1521. + else \
  1522. + __asm__ ("{sf%I4|subf%I4c} %1,%5,%4\n\t{sfe|subfe} %0,%3,%2" \
  1523. + : "=r" (sh), "=&r" (sl) \
  1524. + : "r" (ah), "r" (bh), "rI" (al), "r" (bl)); \
  1525. + } while (0)
  1526. +#define count_leading_zeros(count, x) \
  1527. + __asm__ ("cntlzd %0,%1" : "=r" (count) : "r" (x))
  1528. +#define COUNT_LEADING_ZEROS_0 64
  1529. +#define umul_ppmm(ph, pl, m0, m1) \
  1530. + do { \
  1531. + UDItype __m0 = (m0), __m1 = (m1); \
  1532. + __asm__ ("mulhdu %0,%1,%2" : "=r" (ph) : "%r" (m0), "r" (m1)); \
  1533. + (pl) = __m0 * __m1; \
  1534. + } while (0)
  1535. +#define UMUL_TIME 15
  1536. +#define smul_ppmm(ph, pl, m0, m1) \
  1537. + do { \
  1538. + DItype __m0 = (m0), __m1 = (m1); \
  1539. + __asm__ ("mulhd %0,%1,%2" : "=r" (ph) : "%r" (m0), "r" (m1)); \
  1540. + (pl) = __m0 * __m1; \
  1541. + } while (0)
  1542. +#define SMUL_TIME 14 /* ??? */
  1543. +#define UDIV_TIME 120 /* ??? */
  1544. +#endif /* 64-bit PowerPC. */
  1545. +
  1546. +#if defined (__ibm032__) /* RT/ROMP */ && W_TYPE_SIZE == 32
  1547. +#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
  1548. + __asm__ ("a %1,%5\n\tae %0,%3" \
  1549. + : "=r" ((USItype) (sh)), \
  1550. + "=&r" ((USItype) (sl)) \
  1551. + : "%0" ((USItype) (ah)), \
  1552. + "r" ((USItype) (bh)), \
  1553. + "%1" ((USItype) (al)), \
  1554. + "r" ((USItype) (bl)))
  1555. +#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
  1556. + __asm__ ("s %1,%5\n\tse %0,%3" \
  1557. + : "=r" ((USItype) (sh)), \
  1558. + "=&r" ((USItype) (sl)) \
  1559. + : "0" ((USItype) (ah)), \
  1560. + "r" ((USItype) (bh)), \
  1561. + "1" ((USItype) (al)), \
  1562. + "r" ((USItype) (bl)))
  1563. +#define umul_ppmm(ph, pl, m0, m1) \
  1564. + do { \
  1565. + USItype __m0 = (m0), __m1 = (m1); \
  1566. + __asm__ ( \
  1567. + "s r2,r2\n" \
  1568. +" mts r10,%2\n" \
  1569. +" m r2,%3\n" \
  1570. +" m r2,%3\n" \
  1571. +" m r2,%3\n" \
  1572. +" m r2,%3\n" \
  1573. +" m r2,%3\n" \
  1574. +" m r2,%3\n" \
  1575. +" m r2,%3\n" \
  1576. +" m r2,%3\n" \
  1577. +" m r2,%3\n" \
  1578. +" m r2,%3\n" \
  1579. +" m r2,%3\n" \
  1580. +" m r2,%3\n" \
  1581. +" m r2,%3\n" \
  1582. +" m r2,%3\n" \
  1583. +" m r2,%3\n" \
  1584. +" m r2,%3\n" \
  1585. +" cas %0,r2,r0\n" \
  1586. +" mfs r10,%1" \
  1587. + : "=r" ((USItype) (ph)), \
  1588. + "=r" ((USItype) (pl)) \
  1589. + : "%r" (__m0), \
  1590. + "r" (__m1) \
  1591. + : "r2"); \
  1592. + (ph) += ((((SItype) __m0 >> 31) & __m1) \
  1593. + + (((SItype) __m1 >> 31) & __m0)); \
  1594. + } while (0)
  1595. +#define UMUL_TIME 20
  1596. +#define UDIV_TIME 200
  1597. +#define count_leading_zeros(count, x) \
  1598. + do { \
  1599. + if ((x) >= 0x10000) \
  1600. + __asm__ ("clz %0,%1" \
  1601. + : "=r" ((USItype) (count)) \
  1602. + : "r" ((USItype) (x) >> 16)); \
  1603. + else \
  1604. + { \
  1605. + __asm__ ("clz %0,%1" \
  1606. + : "=r" ((USItype) (count)) \
  1607. + : "r" ((USItype) (x))); \
  1608. + (count) += 16; \
  1609. + } \
  1610. + } while (0)
  1611. +#endif
  1612. +
  1613. +#if defined(__sh__) && !__SHMEDIA__ && W_TYPE_SIZE == 32
  1614. +#ifndef __sh1__
  1615. +#define umul_ppmm(w1, w0, u, v) \
  1616. + __asm__ ( \
  1617. + "dmulu.l %2,%3\n\tsts%M1 macl,%1\n\tsts%M0 mach,%0" \
  1618. + : "=r<" ((USItype)(w1)), \
  1619. + "=r<" ((USItype)(w0)) \
  1620. + : "r" ((USItype)(u)), \
  1621. + "r" ((USItype)(v)) \
  1622. + : "macl", "mach")
  1623. +#define UMUL_TIME 5
  1624. +#endif
  1625. +
  1626. +/* This is the same algorithm as __udiv_qrnnd_c. */
  1627. +#define UDIV_NEEDS_NORMALIZATION 1
  1628. +
  1629. +#define udiv_qrnnd(q, r, n1, n0, d) \
  1630. + do { \
  1631. + extern UWtype __udiv_qrnnd_16 (UWtype, UWtype) \
  1632. + __attribute__ ((visibility ("hidden"))); \
  1633. + /* r0: rn r1: qn */ /* r0: n1 r4: n0 r5: d r6: d1 */ /* r2: __m */ \
  1634. + __asm__ ( \
  1635. + "mov%M4 %4,r5\n" \
  1636. +" swap.w %3,r4\n" \
  1637. +" swap.w r5,r6\n" \
  1638. +" jsr @%5\n" \
  1639. +" shll16 r6\n" \
  1640. +" swap.w r4,r4\n" \
  1641. +" jsr @%5\n" \
  1642. +" swap.w r1,%0\n" \
  1643. +" or r1,%0" \
  1644. + : "=r" (q), "=&z" (r) \
  1645. + : "1" (n1), "r" (n0), "rm" (d), "r" (&__udiv_qrnnd_16) \
  1646. + : "r1", "r2", "r4", "r5", "r6", "pr"); \
  1647. + } while (0)
  1648. +
  1649. +#define UDIV_TIME 80
  1650. +
  1651. +#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
  1652. + __asm__ ("clrt;subc %5,%1; subc %4,%0" \
  1653. + : "=r" (sh), "=r" (sl) \
  1654. + : "0" (ah), "1" (al), "r" (bh), "r" (bl))
  1655. +
  1656. +#endif /* __sh__ */
  1657. +
  1658. +#if defined (__SH5__) && __SHMEDIA__ && W_TYPE_SIZE == 32
  1659. +#define __umulsidi3(u,v) ((UDItype)(USItype)u*(USItype)v)
  1660. +#define count_leading_zeros(count, x) \
  1661. + do \
  1662. + { \
  1663. + UDItype x_ = (USItype)(x); \
  1664. + SItype c_; \
  1665. + \
  1666. + __asm__ ("nsb %1, %0" : "=r" (c_) : "r" (x_)); \
  1667. + (count) = c_ - 31; \
  1668. + } \
  1669. + while (0)
  1670. +#define COUNT_LEADING_ZEROS_0 32
  1671. +#endif
  1672. +
  1673. +#if defined (__sparc__) && !defined (__arch64__) && !defined (__sparcv9) \
  1674. + && W_TYPE_SIZE == 32
  1675. +#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
  1676. + __asm__ ("addcc %r4,%5,%1\n\taddx %r2,%3,%0" \
  1677. + : "=r" ((USItype) (sh)), \
  1678. + "=&r" ((USItype) (sl)) \
  1679. + : "%rJ" ((USItype) (ah)), \
  1680. + "rI" ((USItype) (bh)), \
  1681. + "%rJ" ((USItype) (al)), \
  1682. + "rI" ((USItype) (bl)) \
  1683. + __CLOBBER_CC)
  1684. +#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
  1685. + __asm__ ("subcc %r4,%5,%1\n\tsubx %r2,%3,%0" \
  1686. + : "=r" ((USItype) (sh)), \
  1687. + "=&r" ((USItype) (sl)) \
  1688. + : "rJ" ((USItype) (ah)), \
  1689. + "rI" ((USItype) (bh)), \
  1690. + "rJ" ((USItype) (al)), \
  1691. + "rI" ((USItype) (bl)) \
  1692. + __CLOBBER_CC)
  1693. +#if defined (__sparc_v8__)
  1694. +#define umul_ppmm(w1, w0, u, v) \
  1695. + __asm__ ("umul %2,%3,%1;rd %%y,%0" \
  1696. + : "=r" ((USItype) (w1)), \
  1697. + "=r" ((USItype) (w0)) \
  1698. + : "r" ((USItype) (u)), \
  1699. + "r" ((USItype) (v)))
  1700. +#define udiv_qrnnd(__q, __r, __n1, __n0, __d) \
  1701. + __asm__ ("mov %2,%%y;nop;nop;nop;udiv %3,%4,%0;umul %0,%4,%1;sub %3,%1,%1"\
  1702. + : "=&r" ((USItype) (__q)), \
  1703. + "=&r" ((USItype) (__r)) \
  1704. + : "r" ((USItype) (__n1)), \
  1705. + "r" ((USItype) (__n0)), \
  1706. + "r" ((USItype) (__d)))
  1707. +#else
  1708. +#if defined (__sparclite__)
  1709. +/* This has hardware multiply but not divide. It also has two additional
  1710. + instructions scan (ffs from high bit) and divscc. */
  1711. +#define umul_ppmm(w1, w0, u, v) \
  1712. + __asm__ ("umul %2,%3,%1;rd %%y,%0" \
  1713. + : "=r" ((USItype) (w1)), \
  1714. + "=r" ((USItype) (w0)) \
  1715. + : "r" ((USItype) (u)), \
  1716. + "r" ((USItype) (v)))
  1717. +#define udiv_qrnnd(q, r, n1, n0, d) \
  1718. + __asm__ ("! Inlined udiv_qrnnd\n" \
  1719. +" wr %%g0,%2,%%y ! Not a delayed write for sparclite\n" \
  1720. +" tst %%g0\n" \
  1721. +" divscc %3,%4,%%g1\n" \
  1722. +" divscc %%g1,%4,%%g1\n" \
  1723. +" divscc %%g1,%4,%%g1\n" \
  1724. +" divscc %%g1,%4,%%g1\n" \
  1725. +" divscc %%g1,%4,%%g1\n" \
  1726. +" divscc %%g1,%4,%%g1\n" \
  1727. +" divscc %%g1,%4,%%g1\n" \
  1728. +" divscc %%g1,%4,%%g1\n" \
  1729. +" divscc %%g1,%4,%%g1\n" \
  1730. +" divscc %%g1,%4,%%g1\n" \
  1731. +" divscc %%g1,%4,%%g1\n" \
  1732. +" divscc %%g1,%4,%%g1\n" \
  1733. +" divscc %%g1,%4,%%g1\n" \
  1734. +" divscc %%g1,%4,%%g1\n" \
  1735. +" divscc %%g1,%4,%%g1\n" \
  1736. +" divscc %%g1,%4,%%g1\n" \
  1737. +" divscc %%g1,%4,%%g1\n" \
  1738. +" divscc %%g1,%4,%%g1\n" \
  1739. +" divscc %%g1,%4,%%g1\n" \
  1740. +" divscc %%g1,%4,%%g1\n" \
  1741. +" divscc %%g1,%4,%%g1\n" \
  1742. +" divscc %%g1,%4,%%g1\n" \
  1743. +" divscc %%g1,%4,%%g1\n" \
  1744. +" divscc %%g1,%4,%%g1\n" \
  1745. +" divscc %%g1,%4,%%g1\n" \
  1746. +" divscc %%g1,%4,%%g1\n" \
  1747. +" divscc %%g1,%4,%%g1\n" \
  1748. +" divscc %%g1,%4,%%g1\n" \
  1749. +" divscc %%g1,%4,%%g1\n" \
  1750. +" divscc %%g1,%4,%%g1\n" \
  1751. +" divscc %%g1,%4,%%g1\n" \
  1752. +" divscc %%g1,%4,%0\n" \
  1753. +" rd %%y,%1\n" \
  1754. +" bl,a 1f\n" \
  1755. +" add %1,%4,%1\n" \
  1756. +"1: ! End of inline udiv_qrnnd" \
  1757. + : "=r" ((USItype) (q)), \
  1758. + "=r" ((USItype) (r)) \
  1759. + : "r" ((USItype) (n1)), \
  1760. + "r" ((USItype) (n0)), \
  1761. + "rI" ((USItype) (d)) \
  1762. + : "g1" __AND_CLOBBER_CC)
  1763. +#define UDIV_TIME 37
  1764. +#define count_leading_zeros(count, x) \
  1765. + do { \
  1766. + __asm__ ("scan %1,1,%0" \
  1767. + : "=r" ((USItype) (count)) \
  1768. + : "r" ((USItype) (x))); \
  1769. + } while (0)
  1770. +/* Early sparclites return 63 for an argument of 0, but they warn that future
  1771. + implementations might change this. Therefore, leave COUNT_LEADING_ZEROS_0
  1772. + undefined. */
  1773. +#else
  1774. +/* SPARC without integer multiplication and divide instructions.
  1775. + (i.e. at least Sun4/20,40,60,65,75,110,260,280,330,360,380,470,490) */
  1776. +#define umul_ppmm(w1, w0, u, v) \
  1777. + __asm__ ("! Inlined umul_ppmm\n" \
  1778. +" wr %%g0,%2,%%y ! SPARC has 0-3 delay insn after a wr\n"\
  1779. +" sra %3,31,%%o5 ! Don't move this insn\n" \
  1780. +" and %2,%%o5,%%o5 ! Don't move this insn\n" \
  1781. +" andcc %%g0,0,%%g1 ! Don't move this insn\n" \
  1782. +" mulscc %%g1,%3,%%g1\n" \
  1783. +" mulscc %%g1,%3,%%g1\n" \
  1784. +" mulscc %%g1,%3,%%g1\n" \
  1785. +" mulscc %%g1,%3,%%g1\n" \
  1786. +" mulscc %%g1,%3,%%g1\n" \
  1787. +" mulscc %%g1,%3,%%g1\n" \
  1788. +" mulscc %%g1,%3,%%g1\n" \
  1789. +" mulscc %%g1,%3,%%g1\n" \
  1790. +" mulscc %%g1,%3,%%g1\n" \
  1791. +" mulscc %%g1,%3,%%g1\n" \
  1792. +" mulscc %%g1,%3,%%g1\n" \
  1793. +" mulscc %%g1,%3,%%g1\n" \
  1794. +" mulscc %%g1,%3,%%g1\n" \
  1795. +" mulscc %%g1,%3,%%g1\n" \
  1796. +" mulscc %%g1,%3,%%g1\n" \
  1797. +" mulscc %%g1,%3,%%g1\n" \
  1798. +" mulscc %%g1,%3,%%g1\n" \
  1799. +" mulscc %%g1,%3,%%g1\n" \
  1800. +" mulscc %%g1,%3,%%g1\n" \
  1801. +" mulscc %%g1,%3,%%g1\n" \
  1802. +" mulscc %%g1,%3,%%g1\n" \
  1803. +" mulscc %%g1,%3,%%g1\n" \
  1804. +" mulscc %%g1,%3,%%g1\n" \
  1805. +" mulscc %%g1,%3,%%g1\n" \
  1806. +" mulscc %%g1,%3,%%g1\n" \
  1807. +" mulscc %%g1,%3,%%g1\n" \
  1808. +" mulscc %%g1,%3,%%g1\n" \
  1809. +" mulscc %%g1,%3,%%g1\n" \
  1810. +" mulscc %%g1,%3,%%g1\n" \
  1811. +" mulscc %%g1,%3,%%g1\n" \
  1812. +" mulscc %%g1,%3,%%g1\n" \
  1813. +" mulscc %%g1,%3,%%g1\n" \
  1814. +" mulscc %%g1,0,%%g1\n" \
  1815. +" add %%g1,%%o5,%0\n" \
  1816. +" rd %%y,%1" \
  1817. + : "=r" ((USItype) (w1)), \
  1818. + "=r" ((USItype) (w0)) \
  1819. + : "%rI" ((USItype) (u)), \
  1820. + "r" ((USItype) (v)) \
  1821. + : "g1", "o5" __AND_CLOBBER_CC)
  1822. +#define UMUL_TIME 39 /* 39 instructions */
  1823. +/* It's quite necessary to add this much assembler for the sparc.
  1824. + The default udiv_qrnnd (in C) is more than 10 times slower! */
  1825. +#define udiv_qrnnd(__q, __r, __n1, __n0, __d) \
  1826. + __asm__ ("! Inlined udiv_qrnnd\n" \
  1827. +" mov 32,%%g1\n" \
  1828. +" subcc %1,%2,%%g0\n" \
  1829. +"1: bcs 5f\n" \
  1830. +" addxcc %0,%0,%0 ! shift n1n0 and a q-bit in lsb\n" \
  1831. +" sub %1,%2,%1 ! this kills msb of n\n" \
  1832. +" addx %1,%1,%1 ! so this can't give carry\n" \
  1833. +" subcc %%g1,1,%%g1\n" \
  1834. +"2: bne 1b\n" \
  1835. +" subcc %1,%2,%%g0\n" \
  1836. +" bcs 3f\n" \
  1837. +" addxcc %0,%0,%0 ! shift n1n0 and a q-bit in lsb\n" \
  1838. +" b 3f\n" \
  1839. +" sub %1,%2,%1 ! this kills msb of n\n" \
  1840. +"4: sub %1,%2,%1\n" \
  1841. +"5: addxcc %1,%1,%1\n" \
  1842. +" bcc 2b\n" \
  1843. +" subcc %%g1,1,%%g1\n" \
  1844. +"! Got carry from n. Subtract next step to cancel this carry.\n" \
  1845. +" bne 4b\n" \
  1846. +" addcc %0,%0,%0 ! shift n1n0 and a 0-bit in lsb\n" \
  1847. +" sub %1,%2,%1\n" \
  1848. +"3: xnor %0,0,%0\n" \
  1849. +" ! End of inline udiv_qrnnd" \
  1850. + : "=&r" ((USItype) (__q)), \
  1851. + "=&r" ((USItype) (__r)) \
  1852. + : "r" ((USItype) (__d)), \
  1853. + "1" ((USItype) (__n1)), \
  1854. + "0" ((USItype) (__n0)) : "g1" __AND_CLOBBER_CC)
  1855. +#define UDIV_TIME (3+7*32) /* 7 instructions/iteration. 32 iterations. */
  1856. +#endif /* __sparclite__ */
  1857. +#endif /* __sparc_v8__ */
  1858. +#endif /* sparc32 */
  1859. +
  1860. +#if ((defined (__sparc__) && defined (__arch64__)) || defined (__sparcv9)) \
  1861. + && W_TYPE_SIZE == 64
  1862. +#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
  1863. + __asm__ ("addcc %r4,%5,%1\n\t" \
  1864. + "add %r2,%3,%0\n\t" \
  1865. + "bcs,a,pn %%xcc, 1f\n\t" \
  1866. + "add %0, 1, %0\n" \
  1867. + "1:" \
  1868. + : "=r" ((UDItype)(sh)), \
  1869. + "=&r" ((UDItype)(sl)) \
  1870. + : "%rJ" ((UDItype)(ah)), \
  1871. + "rI" ((UDItype)(bh)), \
  1872. + "%rJ" ((UDItype)(al)), \
  1873. + "rI" ((UDItype)(bl)) \
  1874. + __CLOBBER_CC)
  1875. +
  1876. +#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
  1877. + __asm__ ("subcc %r4,%5,%1\n\t" \
  1878. + "sub %r2,%3,%0\n\t" \
  1879. + "bcs,a,pn %%xcc, 1f\n\t" \
  1880. + "sub %0, 1, %0\n\t" \
  1881. + "1:" \
  1882. + : "=r" ((UDItype)(sh)), \
  1883. + "=&r" ((UDItype)(sl)) \
  1884. + : "rJ" ((UDItype)(ah)), \
  1885. + "rI" ((UDItype)(bh)), \
  1886. + "rJ" ((UDItype)(al)), \
  1887. + "rI" ((UDItype)(bl)) \
  1888. + __CLOBBER_CC)
  1889. +
  1890. +#define umul_ppmm(wh, wl, u, v) \
  1891. + do { \
  1892. + UDItype tmp1, tmp2, tmp3, tmp4; \
  1893. + __asm__ __volatile__ ( \
  1894. + "srl %7,0,%3\n\t" \
  1895. + "mulx %3,%6,%1\n\t" \
  1896. + "srlx %6,32,%2\n\t" \
  1897. + "mulx %2,%3,%4\n\t" \
  1898. + "sllx %4,32,%5\n\t" \
  1899. + "srl %6,0,%3\n\t" \
  1900. + "sub %1,%5,%5\n\t" \
  1901. + "srlx %5,32,%5\n\t" \
  1902. + "addcc %4,%5,%4\n\t" \
  1903. + "srlx %7,32,%5\n\t" \
  1904. + "mulx %3,%5,%3\n\t" \
  1905. + "mulx %2,%5,%5\n\t" \
  1906. + "sethi %%hi(0x80000000),%2\n\t" \
  1907. + "addcc %4,%3,%4\n\t" \
  1908. + "srlx %4,32,%4\n\t" \
  1909. + "add %2,%2,%2\n\t" \
  1910. + "movcc %%xcc,%%g0,%2\n\t" \
  1911. + "addcc %5,%4,%5\n\t" \
  1912. + "sllx %3,32,%3\n\t" \
  1913. + "add %1,%3,%1\n\t" \
  1914. + "add %5,%2,%0" \
  1915. + : "=r" ((UDItype)(wh)), \
  1916. + "=&r" ((UDItype)(wl)), \
  1917. + "=&r" (tmp1), "=&r" (tmp2), "=&r" (tmp3), "=&r" (tmp4) \
  1918. + : "r" ((UDItype)(u)), \
  1919. + "r" ((UDItype)(v)) \
  1920. + __CLOBBER_CC); \
  1921. + } while (0)
  1922. +#define UMUL_TIME 96
  1923. +#define UDIV_TIME 230
  1924. +#endif /* sparc64 */
  1925. +
  1926. +#if defined (__vax__) && W_TYPE_SIZE == 32
  1927. +#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
  1928. + __asm__ ("addl2 %5,%1\n\tadwc %3,%0" \
  1929. + : "=g" ((USItype) (sh)), \
  1930. + "=&g" ((USItype) (sl)) \
  1931. + : "%0" ((USItype) (ah)), \
  1932. + "g" ((USItype) (bh)), \
  1933. + "%1" ((USItype) (al)), \
  1934. + "g" ((USItype) (bl)))
  1935. +#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
  1936. + __asm__ ("subl2 %5,%1\n\tsbwc %3,%0" \
  1937. + : "=g" ((USItype) (sh)), \
  1938. + "=&g" ((USItype) (sl)) \
  1939. + : "0" ((USItype) (ah)), \
  1940. + "g" ((USItype) (bh)), \
  1941. + "1" ((USItype) (al)), \
  1942. + "g" ((USItype) (bl)))
  1943. +#define umul_ppmm(xh, xl, m0, m1) \
  1944. + do { \
  1945. + union { \
  1946. + UDItype __ll; \
  1947. + struct {USItype __l, __h;} __i; \
  1948. + } __xx; \
  1949. + USItype __m0 = (m0), __m1 = (m1); \
  1950. + __asm__ ("emul %1,%2,$0,%0" \
  1951. + : "=r" (__xx.__ll) \
  1952. + : "g" (__m0), \
  1953. + "g" (__m1)); \
  1954. + (xh) = __xx.__i.__h; \
  1955. + (xl) = __xx.__i.__l; \
  1956. + (xh) += ((((SItype) __m0 >> 31) & __m1) \
  1957. + + (((SItype) __m1 >> 31) & __m0)); \
  1958. + } while (0)
  1959. +#define sdiv_qrnnd(q, r, n1, n0, d) \
  1960. + do { \
  1961. + union {DItype __ll; \
  1962. + struct {SItype __l, __h;} __i; \
  1963. + } __xx; \
  1964. + __xx.__i.__h = n1; __xx.__i.__l = n0; \
  1965. + __asm__ ("ediv %3,%2,%0,%1" \
  1966. + : "=g" (q), "=g" (r) \
  1967. + : "g" (__xx.__ll), "g" (d)); \
  1968. + } while (0)
  1969. +#endif /* __vax__ */
  1970. +
  1971. +#if defined (__xtensa__) && W_TYPE_SIZE == 32
  1972. +/* This code is not Xtensa-configuration-specific, so rely on the compiler
  1973. + to expand builtin functions depending on what configuration features
  1974. + are available. This avoids library calls when the operation can be
  1975. + performed in-line. */
  1976. +#define umul_ppmm(w1, w0, u, v) \
  1977. + do { \
  1978. + DWunion __w; \
  1979. + __w.ll = __builtin_umulsidi3 (u, v); \
  1980. + w1 = __w.s.high; \
  1981. + w0 = __w.s.low; \
  1982. + } while (0)
  1983. +#define __umulsidi3(u, v) __builtin_umulsidi3 (u, v)
  1984. +#define count_leading_zeros(COUNT, X) ((COUNT) = __builtin_clz (X))
  1985. +#define count_trailing_zeros(COUNT, X) ((COUNT) = __builtin_ctz (X))
  1986. +#endif /* __xtensa__ */
  1987. +
  1988. +#if defined (__z8000__) && W_TYPE_SIZE == 16
  1989. +#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
  1990. + __asm__ ("add %H1,%H5\n\tadc %H0,%H3" \
  1991. + : "=r" ((unsigned int)(sh)), \
  1992. + "=&r" ((unsigned int)(sl)) \
  1993. + : "%0" ((unsigned int)(ah)), \
  1994. + "r" ((unsigned int)(bh)), \
  1995. + "%1" ((unsigned int)(al)), \
  1996. + "rQR" ((unsigned int)(bl)))
  1997. +#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
  1998. + __asm__ ("sub %H1,%H5\n\tsbc %H0,%H3" \
  1999. + : "=r" ((unsigned int)(sh)), \
  2000. + "=&r" ((unsigned int)(sl)) \
  2001. + : "0" ((unsigned int)(ah)), \
  2002. + "r" ((unsigned int)(bh)), \
  2003. + "1" ((unsigned int)(al)), \
  2004. + "rQR" ((unsigned int)(bl)))
  2005. +#define umul_ppmm(xh, xl, m0, m1) \
  2006. + do { \
  2007. + union {long int __ll; \
  2008. + struct {unsigned int __h, __l;} __i; \
  2009. + } __xx; \
  2010. + unsigned int __m0 = (m0), __m1 = (m1); \
  2011. + __asm__ ("mult %S0,%H3" \
  2012. + : "=r" (__xx.__i.__h), \
  2013. + "=r" (__xx.__i.__l) \
  2014. + : "%1" (__m0), \
  2015. + "rQR" (__m1)); \
  2016. + (xh) = __xx.__i.__h; (xl) = __xx.__i.__l; \
  2017. + (xh) += ((((signed int) __m0 >> 15) & __m1) \
  2018. + + (((signed int) __m1 >> 15) & __m0)); \
  2019. + } while (0)
  2020. +#endif /* __z8000__ */
  2021. +
  2022. +#endif /* __GNUC__ */
  2023. +
  2024. +/* If this machine has no inline assembler, use C macros. */
  2025. +
  2026. +#if !defined (add_ssaaaa)
  2027. +#define add_ssaaaa(sh, sl, ah, al, bh, bl) \
  2028. + do { \
  2029. + UWtype __x; \
  2030. + __x = (al) + (bl); \
  2031. + (sh) = (ah) + (bh) + (__x < (al)); \
  2032. + (sl) = __x; \
  2033. + } while (0)
  2034. +#endif
  2035. +
  2036. +#if !defined (sub_ddmmss)
  2037. +#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
  2038. + do { \
  2039. + UWtype __x; \
  2040. + __x = (al) - (bl); \
  2041. + (sh) = (ah) - (bh) - (__x > (al)); \
  2042. + (sl) = __x; \
  2043. + } while (0)
  2044. +#endif
  2045. +
  2046. +/* If we lack umul_ppmm but have smul_ppmm, define umul_ppmm in terms of
  2047. + smul_ppmm. */
  2048. +#if !defined (umul_ppmm) && defined (smul_ppmm)
  2049. +#define umul_ppmm(w1, w0, u, v) \
  2050. + do { \
  2051. + UWtype __w1; \
  2052. + UWtype __xm0 = (u), __xm1 = (v); \
  2053. + smul_ppmm (__w1, w0, __xm0, __xm1); \
  2054. + (w1) = __w1 + (-(__xm0 >> (W_TYPE_SIZE - 1)) & __xm1) \
  2055. + + (-(__xm1 >> (W_TYPE_SIZE - 1)) & __xm0); \
  2056. + } while (0)
  2057. +#endif
  2058. +
  2059. +/* If we still don't have umul_ppmm, define it using plain C. */
  2060. +#if !defined (umul_ppmm)
  2061. +#define umul_ppmm(w1, w0, u, v) \
  2062. + do { \
  2063. + UWtype __x0, __x1, __x2, __x3; \
  2064. + UHWtype __ul, __vl, __uh, __vh; \
  2065. + \
  2066. + __ul = __ll_lowpart (u); \
  2067. + __uh = __ll_highpart (u); \
  2068. + __vl = __ll_lowpart (v); \
  2069. + __vh = __ll_highpart (v); \
  2070. + \
  2071. + __x0 = (UWtype) __ul * __vl; \
  2072. + __x1 = (UWtype) __ul * __vh; \
  2073. + __x2 = (UWtype) __uh * __vl; \
  2074. + __x3 = (UWtype) __uh * __vh; \
  2075. + \
  2076. + __x1 += __ll_highpart (__x0);/* this can't give carry */ \
  2077. + __x1 += __x2; /* but this indeed can */ \
  2078. + if (__x1 < __x2) /* did we get it? */ \
  2079. + __x3 += __ll_B; /* yes, add it in the proper pos. */ \
  2080. + \
  2081. + (w1) = __x3 + __ll_highpart (__x1); \
  2082. + (w0) = __ll_lowpart (__x1) * __ll_B + __ll_lowpart (__x0); \
  2083. + } while (0)
  2084. +#endif
  2085. +
  2086. +#if !defined (__umulsidi3)
  2087. +#define __umulsidi3(u, v) \
  2088. + ({DWunion __w; \
  2089. + umul_ppmm (__w.s.high, __w.s.low, u, v); \
  2090. + __w.ll; })
  2091. +#endif
  2092. +
  2093. +/* Define this unconditionally, so it can be used for debugging. */
  2094. +#define __udiv_qrnnd_c(q, r, n1, n0, d) \
  2095. + do { \
  2096. + UWtype __d1, __d0, __q1, __q0; \
  2097. + UWtype __r1, __r0, __m; \
  2098. + __d1 = __ll_highpart (d); \
  2099. + __d0 = __ll_lowpart (d); \
  2100. + \
  2101. + __r1 = (n1) % __d1; \
  2102. + __q1 = (n1) / __d1; \
  2103. + __m = (UWtype) __q1 * __d0; \
  2104. + __r1 = __r1 * __ll_B | __ll_highpart (n0); \
  2105. + if (__r1 < __m) \
  2106. + { \
  2107. + __q1--, __r1 += (d); \
  2108. + if (__r1 >= (d)) /* i.e. we didn't get carry when adding to __r1 */\
  2109. + if (__r1 < __m) \
  2110. + __q1--, __r1 += (d); \
  2111. + } \
  2112. + __r1 -= __m; \
  2113. + \
  2114. + __r0 = __r1 % __d1; \
  2115. + __q0 = __r1 / __d1; \
  2116. + __m = (UWtype) __q0 * __d0; \
  2117. + __r0 = __r0 * __ll_B | __ll_lowpart (n0); \
  2118. + if (__r0 < __m) \
  2119. + { \
  2120. + __q0--, __r0 += (d); \
  2121. + if (__r0 >= (d)) \
  2122. + if (__r0 < __m) \
  2123. + __q0--, __r0 += (d); \
  2124. + } \
  2125. + __r0 -= __m; \
  2126. + \
  2127. + (q) = (UWtype) __q1 * __ll_B | __q0; \
  2128. + (r) = __r0; \
  2129. + } while (0)
  2130. +
  2131. +/* If the processor has no udiv_qrnnd but sdiv_qrnnd, go through
  2132. + __udiv_w_sdiv (defined in libgcc or elsewhere). */
  2133. +#if !defined (udiv_qrnnd) && defined (sdiv_qrnnd)
  2134. +#define udiv_qrnnd(q, r, nh, nl, d) \
  2135. + do { \
  2136. + USItype __r; \
  2137. + (q) = __udiv_w_sdiv (&__r, nh, nl, d); \
  2138. + (r) = __r; \
  2139. + } while (0)
  2140. +#endif
  2141. +
  2142. +/* If udiv_qrnnd was not defined for this processor, use __udiv_qrnnd_c. */
  2143. +#if !defined (udiv_qrnnd)
  2144. +#define UDIV_NEEDS_NORMALIZATION 1
  2145. +#define udiv_qrnnd __udiv_qrnnd_c
  2146. +#endif
  2147. +
  2148. +#if !defined (count_leading_zeros)
  2149. +#define count_leading_zeros(count, x) \
  2150. + do { \
  2151. + UWtype __xr = (x); \
  2152. + UWtype __a; \
  2153. + \
  2154. + if (W_TYPE_SIZE <= 32) \
  2155. + { \
  2156. + __a = __xr < ((UWtype)1<<2*__BITS4) \
  2157. + ? (__xr < ((UWtype)1<<__BITS4) ? 0 : __BITS4) \
  2158. + : (__xr < ((UWtype)1<<3*__BITS4) ? 2*__BITS4 : 3*__BITS4); \
  2159. + } \
  2160. + else \
  2161. + { \
  2162. + for (__a = W_TYPE_SIZE - 8; __a > 0; __a -= 8) \
  2163. + if (((__xr >> __a) & 0xff) != 0) \
  2164. + break; \
  2165. + } \
  2166. + \
  2167. + (count) = W_TYPE_SIZE - (__clz_tab[__xr >> __a] + __a); \
  2168. + } while (0)
  2169. +#define COUNT_LEADING_ZEROS_0 W_TYPE_SIZE
  2170. +#endif
  2171. +
  2172. +#if !defined (count_trailing_zeros)
  2173. +/* Define count_trailing_zeros using count_leading_zeros. The latter might be
  2174. + defined in asm, but if it is not, the C version above is good enough. */
  2175. +#define count_trailing_zeros(count, x) \
  2176. + do { \
  2177. + UWtype __ctz_x = (x); \
  2178. + UWtype __ctz_c; \
  2179. + count_leading_zeros (__ctz_c, __ctz_x & -__ctz_x); \
  2180. + (count) = W_TYPE_SIZE - 1 - __ctz_c; \
  2181. + } while (0)
  2182. +#endif
  2183. +
  2184. +#ifndef UDIV_NEEDS_NORMALIZATION
  2185. +#define UDIV_NEEDS_NORMALIZATION 0
  2186. +#endif
  2187. diff -Naur uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/mp_clz_tab.c uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/mp_clz_tab.c
  2188. --- uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/mp_clz_tab.c 1970-01-01 01:00:00.000000000 +0100
  2189. +++ uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/mp_clz_tab.c 2010-10-14 14:05:37.000000000 +0200
  2190. @@ -0,0 +1,37 @@
  2191. +/* __clz_tab -- support for longlong.h
  2192. + Copyright (C) 1991, 1993, 1994, 1997 Free Software Foundation, Inc.
  2193. + This file is part of the GNU C Library. Its master source is NOT part of
  2194. + the C library, however. The master source lives in the GNU MP Library.
  2195. +
  2196. + The GNU C Library is free software; you can redistribute it and/or
  2197. + modify it under the terms of the GNU Lesser General Public
  2198. + License as published by the Free Software Foundation; either
  2199. + version 2.1 of the License, or (at your option) any later version.
  2200. +
  2201. + The GNU C Library is distributed in the hope that it will be useful,
  2202. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  2203. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  2204. + Lesser General Public License for more details.
  2205. +
  2206. + You should have received a copy of the GNU Lesser General Public
  2207. + License along with the GNU C Library; if not, write to the Free
  2208. + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  2209. + 02111-1307 USA. */
  2210. +
  2211. +#if 0
  2212. +#include <gmp.h>
  2213. +#include "gmp-impl.h"
  2214. +#endif
  2215. +
  2216. +const
  2217. +unsigned char __clz_tab[] =
  2218. +{
  2219. + 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
  2220. + 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
  2221. + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
  2222. + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
  2223. + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
  2224. + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
  2225. + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
  2226. + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
  2227. +};
  2228. diff -Naur uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/op-1.h uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/op-1.h
  2229. --- uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/op-1.h 1970-01-01 01:00:00.000000000 +0100
  2230. +++ uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/op-1.h 2010-10-14 14:05:37.000000000 +0200
  2231. @@ -0,0 +1,302 @@
  2232. +/* Software floating-point emulation.
  2233. + Basic one-word fraction declaration and manipulation.
  2234. + Copyright (C) 1997,1998,1999,2006 Free Software Foundation, Inc.
  2235. + This file is part of the GNU C Library.
  2236. + Contributed by Richard Henderson (rth@cygnus.com),
  2237. + Jakub Jelinek (jj@ultra.linux.cz),
  2238. + David S. Miller (davem@redhat.com) and
  2239. + Peter Maydell (pmaydell@chiark.greenend.org.uk).
  2240. +
  2241. + The GNU C Library is free software; you can redistribute it and/or
  2242. + modify it under the terms of the GNU Lesser General Public
  2243. + License as published by the Free Software Foundation; either
  2244. + version 2.1 of the License, or (at your option) any later version.
  2245. +
  2246. + In addition to the permissions in the GNU Lesser General Public
  2247. + License, the Free Software Foundation gives you unlimited
  2248. + permission to link the compiled version of this file into
  2249. + combinations with other programs, and to distribute those
  2250. + combinations without any restriction coming from the use of this
  2251. + file. (The Lesser General Public License restrictions do apply in
  2252. + other respects; for example, they cover modification of the file,
  2253. + and distribution when not linked into a combine executable.)
  2254. +
  2255. + The GNU C Library is distributed in the hope that it will be useful,
  2256. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  2257. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  2258. + Lesser General Public License for more details.
  2259. +
  2260. + You should have received a copy of the GNU Lesser General Public
  2261. + License along with the GNU C Library; if not, write to the Free
  2262. + Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
  2263. + MA 02110-1301, USA. */
  2264. +
  2265. +#define _FP_FRAC_DECL_1(X) _FP_W_TYPE X##_f
  2266. +#define _FP_FRAC_COPY_1(D,S) (D##_f = S##_f)
  2267. +#define _FP_FRAC_SET_1(X,I) (X##_f = I)
  2268. +#define _FP_FRAC_HIGH_1(X) (X##_f)
  2269. +#define _FP_FRAC_LOW_1(X) (X##_f)
  2270. +#define _FP_FRAC_WORD_1(X,w) (X##_f)
  2271. +
  2272. +#define _FP_FRAC_ADDI_1(X,I) (X##_f += I)
  2273. +#define _FP_FRAC_SLL_1(X,N) \
  2274. + do { \
  2275. + if (__builtin_constant_p(N) && (N) == 1) \
  2276. + X##_f += X##_f; \
  2277. + else \
  2278. + X##_f <<= (N); \
  2279. + } while (0)
  2280. +#define _FP_FRAC_SRL_1(X,N) (X##_f >>= N)
  2281. +
  2282. +/* Right shift with sticky-lsb. */
  2283. +#define _FP_FRAC_SRST_1(X,S,N,sz) __FP_FRAC_SRST_1(X##_f, S, N, sz)
  2284. +#define _FP_FRAC_SRS_1(X,N,sz) __FP_FRAC_SRS_1(X##_f, N, sz)
  2285. +
  2286. +#define __FP_FRAC_SRST_1(X,S,N,sz) \
  2287. +do { \
  2288. + S = (__builtin_constant_p(N) && (N) == 1 \
  2289. + ? X & 1 : (X << (_FP_W_TYPE_SIZE - (N))) != 0); \
  2290. + X = X >> (N); \
  2291. +} while (0)
  2292. +
  2293. +#define __FP_FRAC_SRS_1(X,N,sz) \
  2294. + (X = (X >> (N) | (__builtin_constant_p(N) && (N) == 1 \
  2295. + ? X & 1 : (X << (_FP_W_TYPE_SIZE - (N))) != 0)))
  2296. +
  2297. +#define _FP_FRAC_ADD_1(R,X,Y) (R##_f = X##_f + Y##_f)
  2298. +#define _FP_FRAC_SUB_1(R,X,Y) (R##_f = X##_f - Y##_f)
  2299. +#define _FP_FRAC_DEC_1(X,Y) (X##_f -= Y##_f)
  2300. +#define _FP_FRAC_CLZ_1(z, X) __FP_CLZ(z, X##_f)
  2301. +
  2302. +/* Predicates */
  2303. +#define _FP_FRAC_NEGP_1(X) ((_FP_WS_TYPE)X##_f < 0)
  2304. +#define _FP_FRAC_ZEROP_1(X) (X##_f == 0)
  2305. +#define _FP_FRAC_OVERP_1(fs,X) (X##_f & _FP_OVERFLOW_##fs)
  2306. +#define _FP_FRAC_CLEAR_OVERP_1(fs,X) (X##_f &= ~_FP_OVERFLOW_##fs)
  2307. +#define _FP_FRAC_EQ_1(X, Y) (X##_f == Y##_f)
  2308. +#define _FP_FRAC_GE_1(X, Y) (X##_f >= Y##_f)
  2309. +#define _FP_FRAC_GT_1(X, Y) (X##_f > Y##_f)
  2310. +
  2311. +#define _FP_ZEROFRAC_1 0
  2312. +#define _FP_MINFRAC_1 1
  2313. +#define _FP_MAXFRAC_1 (~(_FP_WS_TYPE)0)
  2314. +
  2315. +/*
  2316. + * Unpack the raw bits of a native fp value. Do not classify or
  2317. + * normalize the data.
  2318. + */
  2319. +
  2320. +#define _FP_UNPACK_RAW_1(fs, X, val) \
  2321. + do { \
  2322. + union _FP_UNION_##fs _flo; _flo.flt = (val); \
  2323. + \
  2324. + X##_f = _flo.bits.frac; \
  2325. + X##_e = _flo.bits.exp; \
  2326. + X##_s = _flo.bits.sign; \
  2327. + } while (0)
  2328. +
  2329. +#define _FP_UNPACK_RAW_1_P(fs, X, val) \
  2330. + do { \
  2331. + union _FP_UNION_##fs *_flo = \
  2332. + (union _FP_UNION_##fs *)(val); \
  2333. + \
  2334. + X##_f = _flo->bits.frac; \
  2335. + X##_e = _flo->bits.exp; \
  2336. + X##_s = _flo->bits.sign; \
  2337. + } while (0)
  2338. +
  2339. +/*
  2340. + * Repack the raw bits of a native fp value.
  2341. + */
  2342. +
  2343. +#define _FP_PACK_RAW_1(fs, val, X) \
  2344. + do { \
  2345. + union _FP_UNION_##fs _flo; \
  2346. + \
  2347. + _flo.bits.frac = X##_f; \
  2348. + _flo.bits.exp = X##_e; \
  2349. + _flo.bits.sign = X##_s; \
  2350. + \
  2351. + (val) = _flo.flt; \
  2352. + } while (0)
  2353. +
  2354. +#define _FP_PACK_RAW_1_P(fs, val, X) \
  2355. + do { \
  2356. + union _FP_UNION_##fs *_flo = \
  2357. + (union _FP_UNION_##fs *)(val); \
  2358. + \
  2359. + _flo->bits.frac = X##_f; \
  2360. + _flo->bits.exp = X##_e; \
  2361. + _flo->bits.sign = X##_s; \
  2362. + } while (0)
  2363. +
  2364. +
  2365. +/*
  2366. + * Multiplication algorithms:
  2367. + */
  2368. +
  2369. +/* Basic. Assuming the host word size is >= 2*FRACBITS, we can do the
  2370. + multiplication immediately. */
  2371. +
  2372. +#define _FP_MUL_MEAT_1_imm(wfracbits, R, X, Y) \
  2373. + do { \
  2374. + R##_f = X##_f * Y##_f; \
  2375. + /* Normalize since we know where the msb of the multiplicands \
  2376. + were (bit B), we know that the msb of the of the product is \
  2377. + at either 2B or 2B-1. */ \
  2378. + _FP_FRAC_SRS_1(R, wfracbits-1, 2*wfracbits); \
  2379. + } while (0)
  2380. +
  2381. +/* Given a 1W * 1W => 2W primitive, do the extended multiplication. */
  2382. +
  2383. +#define _FP_MUL_MEAT_1_wide(wfracbits, R, X, Y, doit) \
  2384. + do { \
  2385. + _FP_W_TYPE _Z_f0, _Z_f1; \
  2386. + doit(_Z_f1, _Z_f0, X##_f, Y##_f); \
  2387. + /* Normalize since we know where the msb of the multiplicands \
  2388. + were (bit B), we know that the msb of the of the product is \
  2389. + at either 2B or 2B-1. */ \
  2390. + _FP_FRAC_SRS_2(_Z, wfracbits-1, 2*wfracbits); \
  2391. + R##_f = _Z_f0; \
  2392. + } while (0)
  2393. +
  2394. +/* Finally, a simple widening multiply algorithm. What fun! */
  2395. +
  2396. +#define _FP_MUL_MEAT_1_hard(wfracbits, R, X, Y) \
  2397. + do { \
  2398. + _FP_W_TYPE _xh, _xl, _yh, _yl, _z_f0, _z_f1, _a_f0, _a_f1; \
  2399. + \
  2400. + /* split the words in half */ \
  2401. + _xh = X##_f >> (_FP_W_TYPE_SIZE/2); \
  2402. + _xl = X##_f & (((_FP_W_TYPE)1 << (_FP_W_TYPE_SIZE/2)) - 1); \
  2403. + _yh = Y##_f >> (_FP_W_TYPE_SIZE/2); \
  2404. + _yl = Y##_f & (((_FP_W_TYPE)1 << (_FP_W_TYPE_SIZE/2)) - 1); \
  2405. + \
  2406. + /* multiply the pieces */ \
  2407. + _z_f0 = _xl * _yl; \
  2408. + _a_f0 = _xh * _yl; \
  2409. + _a_f1 = _xl * _yh; \
  2410. + _z_f1 = _xh * _yh; \
  2411. + \
  2412. + /* reassemble into two full words */ \
  2413. + if ((_a_f0 += _a_f1) < _a_f1) \
  2414. + _z_f1 += (_FP_W_TYPE)1 << (_FP_W_TYPE_SIZE/2); \
  2415. + _a_f1 = _a_f0 >> (_FP_W_TYPE_SIZE/2); \
  2416. + _a_f0 = _a_f0 << (_FP_W_TYPE_SIZE/2); \
  2417. + _FP_FRAC_ADD_2(_z, _z, _a); \
  2418. + \
  2419. + /* normalize */ \
  2420. + _FP_FRAC_SRS_2(_z, wfracbits - 1, 2*wfracbits); \
  2421. + R##_f = _z_f0; \
  2422. + } while (0)
  2423. +
  2424. +
  2425. +/*
  2426. + * Division algorithms:
  2427. + */
  2428. +
  2429. +/* Basic. Assuming the host word size is >= 2*FRACBITS, we can do the
  2430. + division immediately. Give this macro either _FP_DIV_HELP_imm for
  2431. + C primitives or _FP_DIV_HELP_ldiv for the ISO function. Which you
  2432. + choose will depend on what the compiler does with divrem4. */
  2433. +
  2434. +#define _FP_DIV_MEAT_1_imm(fs, R, X, Y, doit) \
  2435. + do { \
  2436. + _FP_W_TYPE _q, _r; \
  2437. + X##_f <<= (X##_f < Y##_f \
  2438. + ? R##_e--, _FP_WFRACBITS_##fs \
  2439. + : _FP_WFRACBITS_##fs - 1); \
  2440. + doit(_q, _r, X##_f, Y##_f); \
  2441. + R##_f = _q | (_r != 0); \
  2442. + } while (0)
  2443. +
  2444. +/* GCC's longlong.h defines a 2W / 1W => (1W,1W) primitive udiv_qrnnd
  2445. + that may be useful in this situation. This first is for a primitive
  2446. + that requires normalization, the second for one that does not. Look
  2447. + for UDIV_NEEDS_NORMALIZATION to tell which your machine needs. */
  2448. +
  2449. +#define _FP_DIV_MEAT_1_udiv_norm(fs, R, X, Y) \
  2450. + do { \
  2451. + _FP_W_TYPE _nh, _nl, _q, _r, _y; \
  2452. + \
  2453. + /* Normalize Y -- i.e. make the most significant bit set. */ \
  2454. + _y = Y##_f << _FP_WFRACXBITS_##fs; \
  2455. + \
  2456. + /* Shift X op correspondingly high, that is, up one full word. */ \
  2457. + if (X##_f < Y##_f) \
  2458. + { \
  2459. + R##_e--; \
  2460. + _nl = 0; \
  2461. + _nh = X##_f; \
  2462. + } \
  2463. + else \
  2464. + { \
  2465. + _nl = X##_f << (_FP_W_TYPE_SIZE - 1); \
  2466. + _nh = X##_f >> 1; \
  2467. + } \
  2468. + \
  2469. + udiv_qrnnd(_q, _r, _nh, _nl, _y); \
  2470. + R##_f = _q | (_r != 0); \
  2471. + } while (0)
  2472. +
  2473. +#define _FP_DIV_MEAT_1_udiv(fs, R, X, Y) \
  2474. + do { \
  2475. + _FP_W_TYPE _nh, _nl, _q, _r; \
  2476. + if (X##_f < Y##_f) \
  2477. + { \
  2478. + R##_e--; \
  2479. + _nl = X##_f << _FP_WFRACBITS_##fs; \
  2480. + _nh = X##_f >> _FP_WFRACXBITS_##fs; \
  2481. + } \
  2482. + else \
  2483. + { \
  2484. + _nl = X##_f << (_FP_WFRACBITS_##fs - 1); \
  2485. + _nh = X##_f >> (_FP_WFRACXBITS_##fs + 1); \
  2486. + } \
  2487. + udiv_qrnnd(_q, _r, _nh, _nl, Y##_f); \
  2488. + R##_f = _q | (_r != 0); \
  2489. + } while (0)
  2490. +
  2491. +
  2492. +/*
  2493. + * Square root algorithms:
  2494. + * We have just one right now, maybe Newton approximation
  2495. + * should be added for those machines where division is fast.
  2496. + */
  2497. +
  2498. +#define _FP_SQRT_MEAT_1(R, S, T, X, q) \
  2499. + do { \
  2500. + while (q != _FP_WORK_ROUND) \
  2501. + { \
  2502. + T##_f = S##_f + q; \
  2503. + if (T##_f <= X##_f) \
  2504. + { \
  2505. + S##_f = T##_f + q; \
  2506. + X##_f -= T##_f; \
  2507. + R##_f += q; \
  2508. + } \
  2509. + _FP_FRAC_SLL_1(X, 1); \
  2510. + q >>= 1; \
  2511. + } \
  2512. + if (X##_f) \
  2513. + { \
  2514. + if (S##_f < X##_f) \
  2515. + R##_f |= _FP_WORK_ROUND; \
  2516. + R##_f |= _FP_WORK_STICKY; \
  2517. + } \
  2518. + } while (0)
  2519. +
  2520. +/*
  2521. + * Assembly/disassembly for converting to/from integral types.
  2522. + * No shifting or overflow handled here.
  2523. + */
  2524. +
  2525. +#define _FP_FRAC_ASSEMBLE_1(r, X, rsize) (r = X##_f)
  2526. +#define _FP_FRAC_DISASSEMBLE_1(X, r, rsize) (X##_f = r)
  2527. +
  2528. +
  2529. +/*
  2530. + * Convert FP values between word sizes
  2531. + */
  2532. +
  2533. +#define _FP_FRAC_COPY_1_1(D, S) (D##_f = S##_f)
  2534. diff -Naur uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/op-2.h uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/op-2.h
  2535. --- uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/op-2.h 1970-01-01 01:00:00.000000000 +0100
  2536. +++ uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/op-2.h 2010-10-14 14:05:37.000000000 +0200
  2537. @@ -0,0 +1,617 @@
  2538. +/* Software floating-point emulation.
  2539. + Basic two-word fraction declaration and manipulation.
  2540. + Copyright (C) 1997,1998,1999,2006,2007 Free Software Foundation, Inc.
  2541. + This file is part of the GNU C Library.
  2542. + Contributed by Richard Henderson (rth@cygnus.com),
  2543. + Jakub Jelinek (jj@ultra.linux.cz),
  2544. + David S. Miller (davem@redhat.com) and
  2545. + Peter Maydell (pmaydell@chiark.greenend.org.uk).
  2546. +
  2547. + The GNU C Library is free software; you can redistribute it and/or
  2548. + modify it under the terms of the GNU Lesser General Public
  2549. + License as published by the Free Software Foundation; either
  2550. + version 2.1 of the License, or (at your option) any later version.
  2551. +
  2552. + In addition to the permissions in the GNU Lesser General Public
  2553. + License, the Free Software Foundation gives you unlimited
  2554. + permission to link the compiled version of this file into
  2555. + combinations with other programs, and to distribute those
  2556. + combinations without any restriction coming from the use of this
  2557. + file. (The Lesser General Public License restrictions do apply in
  2558. + other respects; for example, they cover modification of the file,
  2559. + and distribution when not linked into a combine executable.)
  2560. +
  2561. + The GNU C Library is distributed in the hope that it will be useful,
  2562. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  2563. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  2564. + Lesser General Public License for more details.
  2565. +
  2566. + You should have received a copy of the GNU Lesser General Public
  2567. + License along with the GNU C Library; if not, write to the Free
  2568. + Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
  2569. + MA 02110-1301, USA. */
  2570. +
  2571. +#define _FP_FRAC_DECL_2(X) _FP_W_TYPE X##_f0, X##_f1
  2572. +#define _FP_FRAC_COPY_2(D,S) (D##_f0 = S##_f0, D##_f1 = S##_f1)
  2573. +#define _FP_FRAC_SET_2(X,I) __FP_FRAC_SET_2(X, I)
  2574. +#define _FP_FRAC_HIGH_2(X) (X##_f1)
  2575. +#define _FP_FRAC_LOW_2(X) (X##_f0)
  2576. +#define _FP_FRAC_WORD_2(X,w) (X##_f##w)
  2577. +
  2578. +#define _FP_FRAC_SLL_2(X,N) \
  2579. +(void)(((N) < _FP_W_TYPE_SIZE) \
  2580. + ? ({ \
  2581. + if (__builtin_constant_p(N) && (N) == 1) \
  2582. + { \
  2583. + X##_f1 = X##_f1 + X##_f1 + (((_FP_WS_TYPE)(X##_f0)) < 0); \
  2584. + X##_f0 += X##_f0; \
  2585. + } \
  2586. + else \
  2587. + { \
  2588. + X##_f1 = X##_f1 << (N) | X##_f0 >> (_FP_W_TYPE_SIZE - (N)); \
  2589. + X##_f0 <<= (N); \
  2590. + } \
  2591. + 0; \
  2592. + }) \
  2593. + : ({ \
  2594. + X##_f1 = X##_f0 << ((N) - _FP_W_TYPE_SIZE); \
  2595. + X##_f0 = 0; \
  2596. + }))
  2597. +
  2598. +
  2599. +#define _FP_FRAC_SRL_2(X,N) \
  2600. +(void)(((N) < _FP_W_TYPE_SIZE) \
  2601. + ? ({ \
  2602. + X##_f0 = X##_f0 >> (N) | X##_f1 << (_FP_W_TYPE_SIZE - (N)); \
  2603. + X##_f1 >>= (N); \
  2604. + }) \
  2605. + : ({ \
  2606. + X##_f0 = X##_f1 >> ((N) - _FP_W_TYPE_SIZE); \
  2607. + X##_f1 = 0; \
  2608. + }))
  2609. +
  2610. +/* Right shift with sticky-lsb. */
  2611. +#define _FP_FRAC_SRST_2(X,S, N,sz) \
  2612. +(void)(((N) < _FP_W_TYPE_SIZE) \
  2613. + ? ({ \
  2614. + S = (__builtin_constant_p(N) && (N) == 1 \
  2615. + ? X##_f0 & 1 \
  2616. + : (X##_f0 << (_FP_W_TYPE_SIZE - (N))) != 0); \
  2617. + X##_f0 = (X##_f1 << (_FP_W_TYPE_SIZE - (N)) | X##_f0 >> (N)); \
  2618. + X##_f1 >>= (N); \
  2619. + }) \
  2620. + : ({ \
  2621. + S = ((((N) == _FP_W_TYPE_SIZE \
  2622. + ? 0 \
  2623. + : (X##_f1 << (2*_FP_W_TYPE_SIZE - (N)))) \
  2624. + | X##_f0) != 0); \
  2625. + X##_f0 = (X##_f1 >> ((N) - _FP_W_TYPE_SIZE)); \
  2626. + X##_f1 = 0; \
  2627. + }))
  2628. +
  2629. +#define _FP_FRAC_SRS_2(X,N,sz) \
  2630. +(void)(((N) < _FP_W_TYPE_SIZE) \
  2631. + ? ({ \
  2632. + X##_f0 = (X##_f1 << (_FP_W_TYPE_SIZE - (N)) | X##_f0 >> (N) | \
  2633. + (__builtin_constant_p(N) && (N) == 1 \
  2634. + ? X##_f0 & 1 \
  2635. + : (X##_f0 << (_FP_W_TYPE_SIZE - (N))) != 0)); \
  2636. + X##_f1 >>= (N); \
  2637. + }) \
  2638. + : ({ \
  2639. + X##_f0 = (X##_f1 >> ((N) - _FP_W_TYPE_SIZE) | \
  2640. + ((((N) == _FP_W_TYPE_SIZE \
  2641. + ? 0 \
  2642. + : (X##_f1 << (2*_FP_W_TYPE_SIZE - (N)))) \
  2643. + | X##_f0) != 0)); \
  2644. + X##_f1 = 0; \
  2645. + }))
  2646. +
  2647. +#define _FP_FRAC_ADDI_2(X,I) \
  2648. + __FP_FRAC_ADDI_2(X##_f1, X##_f0, I)
  2649. +
  2650. +#define _FP_FRAC_ADD_2(R,X,Y) \
  2651. + __FP_FRAC_ADD_2(R##_f1, R##_f0, X##_f1, X##_f0, Y##_f1, Y##_f0)
  2652. +
  2653. +#define _FP_FRAC_SUB_2(R,X,Y) \
  2654. + __FP_FRAC_SUB_2(R##_f1, R##_f0, X##_f1, X##_f0, Y##_f1, Y##_f0)
  2655. +
  2656. +#define _FP_FRAC_DEC_2(X,Y) \
  2657. + __FP_FRAC_DEC_2(X##_f1, X##_f0, Y##_f1, Y##_f0)
  2658. +
  2659. +#define _FP_FRAC_CLZ_2(R,X) \
  2660. + do { \
  2661. + if (X##_f1) \
  2662. + __FP_CLZ(R,X##_f1); \
  2663. + else \
  2664. + { \
  2665. + __FP_CLZ(R,X##_f0); \
  2666. + R += _FP_W_TYPE_SIZE; \
  2667. + } \
  2668. + } while(0)
  2669. +
  2670. +/* Predicates */
  2671. +#define _FP_FRAC_NEGP_2(X) ((_FP_WS_TYPE)X##_f1 < 0)
  2672. +#define _FP_FRAC_ZEROP_2(X) ((X##_f1 | X##_f0) == 0)
  2673. +#define _FP_FRAC_OVERP_2(fs,X) (_FP_FRAC_HIGH_##fs(X) & _FP_OVERFLOW_##fs)
  2674. +#define _FP_FRAC_CLEAR_OVERP_2(fs,X) (_FP_FRAC_HIGH_##fs(X) &= ~_FP_OVERFLOW_##fs)
  2675. +#define _FP_FRAC_EQ_2(X, Y) (X##_f1 == Y##_f1 && X##_f0 == Y##_f0)
  2676. +#define _FP_FRAC_GT_2(X, Y) \
  2677. + (X##_f1 > Y##_f1 || (X##_f1 == Y##_f1 && X##_f0 > Y##_f0))
  2678. +#define _FP_FRAC_GE_2(X, Y) \
  2679. + (X##_f1 > Y##_f1 || (X##_f1 == Y##_f1 && X##_f0 >= Y##_f0))
  2680. +
  2681. +#define _FP_ZEROFRAC_2 0, 0
  2682. +#define _FP_MINFRAC_2 0, 1
  2683. +#define _FP_MAXFRAC_2 (~(_FP_WS_TYPE)0), (~(_FP_WS_TYPE)0)
  2684. +
  2685. +/*
  2686. + * Internals
  2687. + */
  2688. +
  2689. +#define __FP_FRAC_SET_2(X,I1,I0) (X##_f0 = I0, X##_f1 = I1)
  2690. +
  2691. +#define __FP_CLZ_2(R, xh, xl) \
  2692. + do { \
  2693. + if (xh) \
  2694. + __FP_CLZ(R,xh); \
  2695. + else \
  2696. + { \
  2697. + __FP_CLZ(R,xl); \
  2698. + R += _FP_W_TYPE_SIZE; \
  2699. + } \
  2700. + } while(0)
  2701. +
  2702. +#if 0
  2703. +
  2704. +#ifndef __FP_FRAC_ADDI_2
  2705. +#define __FP_FRAC_ADDI_2(xh, xl, i) \
  2706. + (xh += ((xl += i) < i))
  2707. +#endif
  2708. +#ifndef __FP_FRAC_ADD_2
  2709. +#define __FP_FRAC_ADD_2(rh, rl, xh, xl, yh, yl) \
  2710. + (rh = xh + yh + ((rl = xl + yl) < xl))
  2711. +#endif
  2712. +#ifndef __FP_FRAC_SUB_2
  2713. +#define __FP_FRAC_SUB_2(rh, rl, xh, xl, yh, yl) \
  2714. + (rh = xh - yh - ((rl = xl - yl) > xl))
  2715. +#endif
  2716. +#ifndef __FP_FRAC_DEC_2
  2717. +#define __FP_FRAC_DEC_2(xh, xl, yh, yl) \
  2718. + do { \
  2719. + UWtype _t = xl; \
  2720. + xh -= yh + ((xl -= yl) > _t); \
  2721. + } while (0)
  2722. +#endif
  2723. +
  2724. +#else
  2725. +
  2726. +#undef __FP_FRAC_ADDI_2
  2727. +#define __FP_FRAC_ADDI_2(xh, xl, i) add_ssaaaa(xh, xl, xh, xl, 0, i)
  2728. +#undef __FP_FRAC_ADD_2
  2729. +#define __FP_FRAC_ADD_2 add_ssaaaa
  2730. +#undef __FP_FRAC_SUB_2
  2731. +#define __FP_FRAC_SUB_2 sub_ddmmss
  2732. +#undef __FP_FRAC_DEC_2
  2733. +#define __FP_FRAC_DEC_2(xh, xl, yh, yl) sub_ddmmss(xh, xl, xh, xl, yh, yl)
  2734. +
  2735. +#endif
  2736. +
  2737. +/*
  2738. + * Unpack the raw bits of a native fp value. Do not classify or
  2739. + * normalize the data.
  2740. + */
  2741. +
  2742. +#define _FP_UNPACK_RAW_2(fs, X, val) \
  2743. + do { \
  2744. + union _FP_UNION_##fs _flo; _flo.flt = (val); \
  2745. + \
  2746. + X##_f0 = _flo.bits.frac0; \
  2747. + X##_f1 = _flo.bits.frac1; \
  2748. + X##_e = _flo.bits.exp; \
  2749. + X##_s = _flo.bits.sign; \
  2750. + } while (0)
  2751. +
  2752. +#define _FP_UNPACK_RAW_2_P(fs, X, val) \
  2753. + do { \
  2754. + union _FP_UNION_##fs *_flo = \
  2755. + (union _FP_UNION_##fs *)(val); \
  2756. + \
  2757. + X##_f0 = _flo->bits.frac0; \
  2758. + X##_f1 = _flo->bits.frac1; \
  2759. + X##_e = _flo->bits.exp; \
  2760. + X##_s = _flo->bits.sign; \
  2761. + } while (0)
  2762. +
  2763. +
  2764. +/*
  2765. + * Repack the raw bits of a native fp value.
  2766. + */
  2767. +
  2768. +#define _FP_PACK_RAW_2(fs, val, X) \
  2769. + do { \
  2770. + union _FP_UNION_##fs _flo; \
  2771. + \
  2772. + _flo.bits.frac0 = X##_f0; \
  2773. + _flo.bits.frac1 = X##_f1; \
  2774. + _flo.bits.exp = X##_e; \
  2775. + _flo.bits.sign = X##_s; \
  2776. + \
  2777. + (val) = _flo.flt; \
  2778. + } while (0)
  2779. +
  2780. +#define _FP_PACK_RAW_2_P(fs, val, X) \
  2781. + do { \
  2782. + union _FP_UNION_##fs *_flo = \
  2783. + (union _FP_UNION_##fs *)(val); \
  2784. + \
  2785. + _flo->bits.frac0 = X##_f0; \
  2786. + _flo->bits.frac1 = X##_f1; \
  2787. + _flo->bits.exp = X##_e; \
  2788. + _flo->bits.sign = X##_s; \
  2789. + } while (0)
  2790. +
  2791. +
  2792. +/*
  2793. + * Multiplication algorithms:
  2794. + */
  2795. +
  2796. +/* Given a 1W * 1W => 2W primitive, do the extended multiplication. */
  2797. +
  2798. +#define _FP_MUL_MEAT_2_wide(wfracbits, R, X, Y, doit) \
  2799. + do { \
  2800. + _FP_FRAC_DECL_4(_z); _FP_FRAC_DECL_2(_b); _FP_FRAC_DECL_2(_c); \
  2801. + \
  2802. + doit(_FP_FRAC_WORD_4(_z,1), _FP_FRAC_WORD_4(_z,0), X##_f0, Y##_f0); \
  2803. + doit(_b_f1, _b_f0, X##_f0, Y##_f1); \
  2804. + doit(_c_f1, _c_f0, X##_f1, Y##_f0); \
  2805. + doit(_FP_FRAC_WORD_4(_z,3), _FP_FRAC_WORD_4(_z,2), X##_f1, Y##_f1); \
  2806. + \
  2807. + __FP_FRAC_ADD_3(_FP_FRAC_WORD_4(_z,3),_FP_FRAC_WORD_4(_z,2), \
  2808. + _FP_FRAC_WORD_4(_z,1), 0, _b_f1, _b_f0, \
  2809. + _FP_FRAC_WORD_4(_z,3),_FP_FRAC_WORD_4(_z,2), \
  2810. + _FP_FRAC_WORD_4(_z,1)); \
  2811. + __FP_FRAC_ADD_3(_FP_FRAC_WORD_4(_z,3),_FP_FRAC_WORD_4(_z,2), \
  2812. + _FP_FRAC_WORD_4(_z,1), 0, _c_f1, _c_f0, \
  2813. + _FP_FRAC_WORD_4(_z,3),_FP_FRAC_WORD_4(_z,2), \
  2814. + _FP_FRAC_WORD_4(_z,1)); \
  2815. + \
  2816. + /* Normalize since we know where the msb of the multiplicands \
  2817. + were (bit B), we know that the msb of the of the product is \
  2818. + at either 2B or 2B-1. */ \
  2819. + _FP_FRAC_SRS_4(_z, wfracbits-1, 2*wfracbits); \
  2820. + R##_f0 = _FP_FRAC_WORD_4(_z,0); \
  2821. + R##_f1 = _FP_FRAC_WORD_4(_z,1); \
  2822. + } while (0)
  2823. +
  2824. +/* Given a 1W * 1W => 2W primitive, do the extended multiplication.
  2825. + Do only 3 multiplications instead of four. This one is for machines
  2826. + where multiplication is much more expensive than subtraction. */
  2827. +
  2828. +#define _FP_MUL_MEAT_2_wide_3mul(wfracbits, R, X, Y, doit) \
  2829. + do { \
  2830. + _FP_FRAC_DECL_4(_z); _FP_FRAC_DECL_2(_b); _FP_FRAC_DECL_2(_c); \
  2831. + _FP_W_TYPE _d; \
  2832. + int _c1, _c2; \
  2833. + \
  2834. + _b_f0 = X##_f0 + X##_f1; \
  2835. + _c1 = _b_f0 < X##_f0; \
  2836. + _b_f1 = Y##_f0 + Y##_f1; \
  2837. + _c2 = _b_f1 < Y##_f0; \
  2838. + doit(_d, _FP_FRAC_WORD_4(_z,0), X##_f0, Y##_f0); \
  2839. + doit(_FP_FRAC_WORD_4(_z,2), _FP_FRAC_WORD_4(_z,1), _b_f0, _b_f1); \
  2840. + doit(_c_f1, _c_f0, X##_f1, Y##_f1); \
  2841. + \
  2842. + _b_f0 &= -_c2; \
  2843. + _b_f1 &= -_c1; \
  2844. + __FP_FRAC_ADD_3(_FP_FRAC_WORD_4(_z,3),_FP_FRAC_WORD_4(_z,2), \
  2845. + _FP_FRAC_WORD_4(_z,1), (_c1 & _c2), 0, _d, \
  2846. + 0, _FP_FRAC_WORD_4(_z,2), _FP_FRAC_WORD_4(_z,1)); \
  2847. + __FP_FRAC_ADDI_2(_FP_FRAC_WORD_4(_z,3),_FP_FRAC_WORD_4(_z,2), \
  2848. + _b_f0); \
  2849. + __FP_FRAC_ADDI_2(_FP_FRAC_WORD_4(_z,3),_FP_FRAC_WORD_4(_z,2), \
  2850. + _b_f1); \
  2851. + __FP_FRAC_DEC_3(_FP_FRAC_WORD_4(_z,3),_FP_FRAC_WORD_4(_z,2), \
  2852. + _FP_FRAC_WORD_4(_z,1), \
  2853. + 0, _d, _FP_FRAC_WORD_4(_z,0)); \
  2854. + __FP_FRAC_DEC_3(_FP_FRAC_WORD_4(_z,3),_FP_FRAC_WORD_4(_z,2), \
  2855. + _FP_FRAC_WORD_4(_z,1), 0, _c_f1, _c_f0); \
  2856. + __FP_FRAC_ADD_2(_FP_FRAC_WORD_4(_z,3), _FP_FRAC_WORD_4(_z,2), \
  2857. + _c_f1, _c_f0, \
  2858. + _FP_FRAC_WORD_4(_z,3), _FP_FRAC_WORD_4(_z,2)); \
  2859. + \
  2860. + /* Normalize since we know where the msb of the multiplicands \
  2861. + were (bit B), we know that the msb of the of the product is \
  2862. + at either 2B or 2B-1. */ \
  2863. + _FP_FRAC_SRS_4(_z, wfracbits-1, 2*wfracbits); \
  2864. + R##_f0 = _FP_FRAC_WORD_4(_z,0); \
  2865. + R##_f1 = _FP_FRAC_WORD_4(_z,1); \
  2866. + } while (0)
  2867. +
  2868. +#define _FP_MUL_MEAT_2_gmp(wfracbits, R, X, Y) \
  2869. + do { \
  2870. + _FP_FRAC_DECL_4(_z); \
  2871. + _FP_W_TYPE _x[2], _y[2]; \
  2872. + _x[0] = X##_f0; _x[1] = X##_f1; \
  2873. + _y[0] = Y##_f0; _y[1] = Y##_f1; \
  2874. + \
  2875. + mpn_mul_n(_z_f, _x, _y, 2); \
  2876. + \
  2877. + /* Normalize since we know where the msb of the multiplicands \
  2878. + were (bit B), we know that the msb of the of the product is \
  2879. + at either 2B or 2B-1. */ \
  2880. + _FP_FRAC_SRS_4(_z, wfracbits-1, 2*wfracbits); \
  2881. + R##_f0 = _z_f[0]; \
  2882. + R##_f1 = _z_f[1]; \
  2883. + } while (0)
  2884. +
  2885. +/* Do at most 120x120=240 bits multiplication using double floating
  2886. + point multiplication. This is useful if floating point
  2887. + multiplication has much bigger throughput than integer multiply.
  2888. + It is supposed to work for _FP_W_TYPE_SIZE 64 and wfracbits
  2889. + between 106 and 120 only.
  2890. + Caller guarantees that X and Y has (1LLL << (wfracbits - 1)) set.
  2891. + SETFETZ is a macro which will disable all FPU exceptions and set rounding
  2892. + towards zero, RESETFE should optionally reset it back. */
  2893. +
  2894. +#define _FP_MUL_MEAT_2_120_240_double(wfracbits, R, X, Y, setfetz, resetfe) \
  2895. + do { \
  2896. + static const double _const[] = { \
  2897. + /* 2^-24 */ 5.9604644775390625e-08, \
  2898. + /* 2^-48 */ 3.5527136788005009e-15, \
  2899. + /* 2^-72 */ 2.1175823681357508e-22, \
  2900. + /* 2^-96 */ 1.2621774483536189e-29, \
  2901. + /* 2^28 */ 2.68435456e+08, \
  2902. + /* 2^4 */ 1.600000e+01, \
  2903. + /* 2^-20 */ 9.5367431640625e-07, \
  2904. + /* 2^-44 */ 5.6843418860808015e-14, \
  2905. + /* 2^-68 */ 3.3881317890172014e-21, \
  2906. + /* 2^-92 */ 2.0194839173657902e-28, \
  2907. + /* 2^-116 */ 1.2037062152420224e-35}; \
  2908. + double _a240, _b240, _c240, _d240, _e240, _f240, \
  2909. + _g240, _h240, _i240, _j240, _k240; \
  2910. + union { double d; UDItype i; } _l240, _m240, _n240, _o240, \
  2911. + _p240, _q240, _r240, _s240; \
  2912. + UDItype _t240, _u240, _v240, _w240, _x240, _y240 = 0; \
  2913. + \
  2914. + if (wfracbits < 106 || wfracbits > 120) \
  2915. + abort(); \
  2916. + \
  2917. + setfetz; \
  2918. + \
  2919. + _e240 = (double)(long)(X##_f0 & 0xffffff); \
  2920. + _j240 = (double)(long)(Y##_f0 & 0xffffff); \
  2921. + _d240 = (double)(long)((X##_f0 >> 24) & 0xffffff); \
  2922. + _i240 = (double)(long)((Y##_f0 >> 24) & 0xffffff); \
  2923. + _c240 = (double)(long)(((X##_f1 << 16) & 0xffffff) | (X##_f0 >> 48)); \
  2924. + _h240 = (double)(long)(((Y##_f1 << 16) & 0xffffff) | (Y##_f0 >> 48)); \
  2925. + _b240 = (double)(long)((X##_f1 >> 8) & 0xffffff); \
  2926. + _g240 = (double)(long)((Y##_f1 >> 8) & 0xffffff); \
  2927. + _a240 = (double)(long)(X##_f1 >> 32); \
  2928. + _f240 = (double)(long)(Y##_f1 >> 32); \
  2929. + _e240 *= _const[3]; \
  2930. + _j240 *= _const[3]; \
  2931. + _d240 *= _const[2]; \
  2932. + _i240 *= _const[2]; \
  2933. + _c240 *= _const[1]; \
  2934. + _h240 *= _const[1]; \
  2935. + _b240 *= _const[0]; \
  2936. + _g240 *= _const[0]; \
  2937. + _s240.d = _e240*_j240;\
  2938. + _r240.d = _d240*_j240 + _e240*_i240;\
  2939. + _q240.d = _c240*_j240 + _d240*_i240 + _e240*_h240;\
  2940. + _p240.d = _b240*_j240 + _c240*_i240 + _d240*_h240 + _e240*_g240;\
  2941. + _o240.d = _a240*_j240 + _b240*_i240 + _c240*_h240 + _d240*_g240 + _e240*_f240;\
  2942. + _n240.d = _a240*_i240 + _b240*_h240 + _c240*_g240 + _d240*_f240; \
  2943. + _m240.d = _a240*_h240 + _b240*_g240 + _c240*_f240; \
  2944. + _l240.d = _a240*_g240 + _b240*_f240; \
  2945. + _k240 = _a240*_f240; \
  2946. + _r240.d += _s240.d; \
  2947. + _q240.d += _r240.d; \
  2948. + _p240.d += _q240.d; \
  2949. + _o240.d += _p240.d; \
  2950. + _n240.d += _o240.d; \
  2951. + _m240.d += _n240.d; \
  2952. + _l240.d += _m240.d; \
  2953. + _k240 += _l240.d; \
  2954. + _s240.d -= ((_const[10]+_s240.d)-_const[10]); \
  2955. + _r240.d -= ((_const[9]+_r240.d)-_const[9]); \
  2956. + _q240.d -= ((_const[8]+_q240.d)-_const[8]); \
  2957. + _p240.d -= ((_const[7]+_p240.d)-_const[7]); \
  2958. + _o240.d += _const[7]; \
  2959. + _n240.d += _const[6]; \
  2960. + _m240.d += _const[5]; \
  2961. + _l240.d += _const[4]; \
  2962. + if (_s240.d != 0.0) _y240 = 1; \
  2963. + if (_r240.d != 0.0) _y240 = 1; \
  2964. + if (_q240.d != 0.0) _y240 = 1; \
  2965. + if (_p240.d != 0.0) _y240 = 1; \
  2966. + _t240 = (DItype)_k240; \
  2967. + _u240 = _l240.i; \
  2968. + _v240 = _m240.i; \
  2969. + _w240 = _n240.i; \
  2970. + _x240 = _o240.i; \
  2971. + R##_f1 = (_t240 << (128 - (wfracbits - 1))) \
  2972. + | ((_u240 & 0xffffff) >> ((wfracbits - 1) - 104)); \
  2973. + R##_f0 = ((_u240 & 0xffffff) << (168 - (wfracbits - 1))) \
  2974. + | ((_v240 & 0xffffff) << (144 - (wfracbits - 1))) \
  2975. + | ((_w240 & 0xffffff) << (120 - (wfracbits - 1))) \
  2976. + | ((_x240 & 0xffffff) >> ((wfracbits - 1) - 96)) \
  2977. + | _y240; \
  2978. + resetfe; \
  2979. + } while (0)
  2980. +
  2981. +/*
  2982. + * Division algorithms:
  2983. + */
  2984. +
  2985. +#define _FP_DIV_MEAT_2_udiv(fs, R, X, Y) \
  2986. + do { \
  2987. + _FP_W_TYPE _n_f2, _n_f1, _n_f0, _r_f1, _r_f0, _m_f1, _m_f0; \
  2988. + if (_FP_FRAC_GT_2(X, Y)) \
  2989. + { \
  2990. + _n_f2 = X##_f1 >> 1; \
  2991. + _n_f1 = X##_f1 << (_FP_W_TYPE_SIZE - 1) | X##_f0 >> 1; \
  2992. + _n_f0 = X##_f0 << (_FP_W_TYPE_SIZE - 1); \
  2993. + } \
  2994. + else \
  2995. + { \
  2996. + R##_e--; \
  2997. + _n_f2 = X##_f1; \
  2998. + _n_f1 = X##_f0; \
  2999. + _n_f0 = 0; \
  3000. + } \
  3001. + \
  3002. + /* Normalize, i.e. make the most significant bit of the \
  3003. + denominator set. */ \
  3004. + _FP_FRAC_SLL_2(Y, _FP_WFRACXBITS_##fs); \
  3005. + \
  3006. + udiv_qrnnd(R##_f1, _r_f1, _n_f2, _n_f1, Y##_f1); \
  3007. + umul_ppmm(_m_f1, _m_f0, R##_f1, Y##_f0); \
  3008. + _r_f0 = _n_f0; \
  3009. + if (_FP_FRAC_GT_2(_m, _r)) \
  3010. + { \
  3011. + R##_f1--; \
  3012. + _FP_FRAC_ADD_2(_r, Y, _r); \
  3013. + if (_FP_FRAC_GE_2(_r, Y) && _FP_FRAC_GT_2(_m, _r)) \
  3014. + { \
  3015. + R##_f1--; \
  3016. + _FP_FRAC_ADD_2(_r, Y, _r); \
  3017. + } \
  3018. + } \
  3019. + _FP_FRAC_DEC_2(_r, _m); \
  3020. + \
  3021. + if (_r_f1 == Y##_f1) \
  3022. + { \
  3023. + /* This is a special case, not an optimization \
  3024. + (_r/Y##_f1 would not fit into UWtype). \
  3025. + As _r is guaranteed to be < Y, R##_f0 can be either \
  3026. + (UWtype)-1 or (UWtype)-2. But as we know what kind \
  3027. + of bits it is (sticky, guard, round), we don't care. \
  3028. + We also don't care what the reminder is, because the \
  3029. + guard bit will be set anyway. -jj */ \
  3030. + R##_f0 = -1; \
  3031. + } \
  3032. + else \
  3033. + { \
  3034. + udiv_qrnnd(R##_f0, _r_f1, _r_f1, _r_f0, Y##_f1); \
  3035. + umul_ppmm(_m_f1, _m_f0, R##_f0, Y##_f0); \
  3036. + _r_f0 = 0; \
  3037. + if (_FP_FRAC_GT_2(_m, _r)) \
  3038. + { \
  3039. + R##_f0--; \
  3040. + _FP_FRAC_ADD_2(_r, Y, _r); \
  3041. + if (_FP_FRAC_GE_2(_r, Y) && _FP_FRAC_GT_2(_m, _r)) \
  3042. + { \
  3043. + R##_f0--; \
  3044. + _FP_FRAC_ADD_2(_r, Y, _r); \
  3045. + } \
  3046. + } \
  3047. + if (!_FP_FRAC_EQ_2(_r, _m)) \
  3048. + R##_f0 |= _FP_WORK_STICKY; \
  3049. + } \
  3050. + } while (0)
  3051. +
  3052. +
  3053. +#define _FP_DIV_MEAT_2_gmp(fs, R, X, Y) \
  3054. + do { \
  3055. + _FP_W_TYPE _x[4], _y[2], _z[4]; \
  3056. + _y[0] = Y##_f0; _y[1] = Y##_f1; \
  3057. + _x[0] = _x[3] = 0; \
  3058. + if (_FP_FRAC_GT_2(X, Y)) \
  3059. + { \
  3060. + R##_e++; \
  3061. + _x[1] = (X##_f0 << (_FP_WFRACBITS_##fs-1 - _FP_W_TYPE_SIZE) | \
  3062. + X##_f1 >> (_FP_W_TYPE_SIZE - \
  3063. + (_FP_WFRACBITS_##fs-1 - _FP_W_TYPE_SIZE))); \
  3064. + _x[2] = X##_f1 << (_FP_WFRACBITS_##fs-1 - _FP_W_TYPE_SIZE); \
  3065. + } \
  3066. + else \
  3067. + { \
  3068. + _x[1] = (X##_f0 << (_FP_WFRACBITS_##fs - _FP_W_TYPE_SIZE) | \
  3069. + X##_f1 >> (_FP_W_TYPE_SIZE - \
  3070. + (_FP_WFRACBITS_##fs - _FP_W_TYPE_SIZE))); \
  3071. + _x[2] = X##_f1 << (_FP_WFRACBITS_##fs - _FP_W_TYPE_SIZE); \
  3072. + } \
  3073. + \
  3074. + (void) mpn_divrem (_z, 0, _x, 4, _y, 2); \
  3075. + R##_f1 = _z[1]; \
  3076. + R##_f0 = _z[0] | ((_x[0] | _x[1]) != 0); \
  3077. + } while (0)
  3078. +
  3079. +
  3080. +/*
  3081. + * Square root algorithms:
  3082. + * We have just one right now, maybe Newton approximation
  3083. + * should be added for those machines where division is fast.
  3084. + */
  3085. +
  3086. +#define _FP_SQRT_MEAT_2(R, S, T, X, q) \
  3087. + do { \
  3088. + while (q) \
  3089. + { \
  3090. + T##_f1 = S##_f1 + q; \
  3091. + if (T##_f1 <= X##_f1) \
  3092. + { \
  3093. + S##_f1 = T##_f1 + q; \
  3094. + X##_f1 -= T##_f1; \
  3095. + R##_f1 += q; \
  3096. + } \
  3097. + _FP_FRAC_SLL_2(X, 1); \
  3098. + q >>= 1; \
  3099. + } \
  3100. + q = (_FP_W_TYPE)1 << (_FP_W_TYPE_SIZE - 1); \
  3101. + while (q != _FP_WORK_ROUND) \
  3102. + { \
  3103. + T##_f0 = S##_f0 + q; \
  3104. + T##_f1 = S##_f1; \
  3105. + if (T##_f1 < X##_f1 || \
  3106. + (T##_f1 == X##_f1 && T##_f0 <= X##_f0)) \
  3107. + { \
  3108. + S##_f0 = T##_f0 + q; \
  3109. + S##_f1 += (T##_f0 > S##_f0); \
  3110. + _FP_FRAC_DEC_2(X, T); \
  3111. + R##_f0 += q; \
  3112. + } \
  3113. + _FP_FRAC_SLL_2(X, 1); \
  3114. + q >>= 1; \
  3115. + } \
  3116. + if (X##_f0 | X##_f1) \
  3117. + { \
  3118. + if (S##_f1 < X##_f1 || \
  3119. + (S##_f1 == X##_f1 && S##_f0 < X##_f0)) \
  3120. + R##_f0 |= _FP_WORK_ROUND; \
  3121. + R##_f0 |= _FP_WORK_STICKY; \
  3122. + } \
  3123. + } while (0)
  3124. +
  3125. +
  3126. +/*
  3127. + * Assembly/disassembly for converting to/from integral types.
  3128. + * No shifting or overflow handled here.
  3129. + */
  3130. +
  3131. +#define _FP_FRAC_ASSEMBLE_2(r, X, rsize) \
  3132. +(void)((rsize <= _FP_W_TYPE_SIZE) \
  3133. + ? ({ r = X##_f0; }) \
  3134. + : ({ \
  3135. + r = X##_f1; \
  3136. + r <<= _FP_W_TYPE_SIZE; \
  3137. + r += X##_f0; \
  3138. + }))
  3139. +
  3140. +#define _FP_FRAC_DISASSEMBLE_2(X, r, rsize) \
  3141. + do { \
  3142. + X##_f0 = r; \
  3143. + X##_f1 = (rsize <= _FP_W_TYPE_SIZE ? 0 : r >> _FP_W_TYPE_SIZE); \
  3144. + } while (0)
  3145. +
  3146. +/*
  3147. + * Convert FP values between word sizes
  3148. + */
  3149. +
  3150. +#define _FP_FRAC_COPY_1_2(D, S) (D##_f = S##_f0)
  3151. +
  3152. +#define _FP_FRAC_COPY_2_1(D, S) ((D##_f0 = S##_f), (D##_f1 = 0))
  3153. +
  3154. +#define _FP_FRAC_COPY_2_2(D,S) _FP_FRAC_COPY_2(D,S)
  3155. diff -Naur uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/op-4.h uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/op-4.h
  3156. --- uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/op-4.h 1970-01-01 01:00:00.000000000 +0100
  3157. +++ uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/op-4.h 2010-10-14 14:05:37.000000000 +0200
  3158. @@ -0,0 +1,688 @@
  3159. +/* Software floating-point emulation.
  3160. + Basic four-word fraction declaration and manipulation.
  3161. + Copyright (C) 1997,1998,1999,2006,2007 Free Software Foundation, Inc.
  3162. + This file is part of the GNU C Library.
  3163. + Contributed by Richard Henderson (rth@cygnus.com),
  3164. + Jakub Jelinek (jj@ultra.linux.cz),
  3165. + David S. Miller (davem@redhat.com) and
  3166. + Peter Maydell (pmaydell@chiark.greenend.org.uk).
  3167. +
  3168. + The GNU C Library is free software; you can redistribute it and/or
  3169. + modify it under the terms of the GNU Lesser General Public
  3170. + License as published by the Free Software Foundation; either
  3171. + version 2.1 of the License, or (at your option) any later version.
  3172. +
  3173. + In addition to the permissions in the GNU Lesser General Public
  3174. + License, the Free Software Foundation gives you unlimited
  3175. + permission to link the compiled version of this file into
  3176. + combinations with other programs, and to distribute those
  3177. + combinations without any restriction coming from the use of this
  3178. + file. (The Lesser General Public License restrictions do apply in
  3179. + other respects; for example, they cover modification of the file,
  3180. + and distribution when not linked into a combine executable.)
  3181. +
  3182. + The GNU C Library is distributed in the hope that it will be useful,
  3183. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  3184. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  3185. + Lesser General Public License for more details.
  3186. +
  3187. + You should have received a copy of the GNU Lesser General Public
  3188. + License along with the GNU C Library; if not, write to the Free
  3189. + Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
  3190. + MA 02110-1301, USA. */
  3191. +
  3192. +#define _FP_FRAC_DECL_4(X) _FP_W_TYPE X##_f[4]
  3193. +#define _FP_FRAC_COPY_4(D,S) \
  3194. + (D##_f[0] = S##_f[0], D##_f[1] = S##_f[1], \
  3195. + D##_f[2] = S##_f[2], D##_f[3] = S##_f[3])
  3196. +#define _FP_FRAC_SET_4(X,I) __FP_FRAC_SET_4(X, I)
  3197. +#define _FP_FRAC_HIGH_4(X) (X##_f[3])
  3198. +#define _FP_FRAC_LOW_4(X) (X##_f[0])
  3199. +#define _FP_FRAC_WORD_4(X,w) (X##_f[w])
  3200. +
  3201. +#define _FP_FRAC_SLL_4(X,N) \
  3202. + do { \
  3203. + _FP_I_TYPE _up, _down, _skip, _i; \
  3204. + _skip = (N) / _FP_W_TYPE_SIZE; \
  3205. + _up = (N) % _FP_W_TYPE_SIZE; \
  3206. + _down = _FP_W_TYPE_SIZE - _up; \
  3207. + if (!_up) \
  3208. + for (_i = 3; _i >= _skip; --_i) \
  3209. + X##_f[_i] = X##_f[_i-_skip]; \
  3210. + else \
  3211. + { \
  3212. + for (_i = 3; _i > _skip; --_i) \
  3213. + X##_f[_i] = X##_f[_i-_skip] << _up \
  3214. + | X##_f[_i-_skip-1] >> _down; \
  3215. + X##_f[_i--] = X##_f[0] << _up; \
  3216. + } \
  3217. + for (; _i >= 0; --_i) \
  3218. + X##_f[_i] = 0; \
  3219. + } while (0)
  3220. +
  3221. +/* This one was broken too */
  3222. +#define _FP_FRAC_SRL_4(X,N) \
  3223. + do { \
  3224. + _FP_I_TYPE _up, _down, _skip, _i; \
  3225. + _skip = (N) / _FP_W_TYPE_SIZE; \
  3226. + _down = (N) % _FP_W_TYPE_SIZE; \
  3227. + _up = _FP_W_TYPE_SIZE - _down; \
  3228. + if (!_down) \
  3229. + for (_i = 0; _i <= 3-_skip; ++_i) \
  3230. + X##_f[_i] = X##_f[_i+_skip]; \
  3231. + else \
  3232. + { \
  3233. + for (_i = 0; _i < 3-_skip; ++_i) \
  3234. + X##_f[_i] = X##_f[_i+_skip] >> _down \
  3235. + | X##_f[_i+_skip+1] << _up; \
  3236. + X##_f[_i++] = X##_f[3] >> _down; \
  3237. + } \
  3238. + for (; _i < 4; ++_i) \
  3239. + X##_f[_i] = 0; \
  3240. + } while (0)
  3241. +
  3242. +
  3243. +/* Right shift with sticky-lsb.
  3244. + * What this actually means is that we do a standard right-shift,
  3245. + * but that if any of the bits that fall off the right hand side
  3246. + * were one then we always set the LSbit.
  3247. + */
  3248. +#define _FP_FRAC_SRST_4(X,S,N,size) \
  3249. + do { \
  3250. + _FP_I_TYPE _up, _down, _skip, _i; \
  3251. + _FP_W_TYPE _s; \
  3252. + _skip = (N) / _FP_W_TYPE_SIZE; \
  3253. + _down = (N) % _FP_W_TYPE_SIZE; \
  3254. + _up = _FP_W_TYPE_SIZE - _down; \
  3255. + for (_s = _i = 0; _i < _skip; ++_i) \
  3256. + _s |= X##_f[_i]; \
  3257. + if (!_down) \
  3258. + for (_i = 0; _i <= 3-_skip; ++_i) \
  3259. + X##_f[_i] = X##_f[_i+_skip]; \
  3260. + else \
  3261. + { \
  3262. + _s |= X##_f[_i] << _up; \
  3263. + for (_i = 0; _i < 3-_skip; ++_i) \
  3264. + X##_f[_i] = X##_f[_i+_skip] >> _down \
  3265. + | X##_f[_i+_skip+1] << _up; \
  3266. + X##_f[_i++] = X##_f[3] >> _down; \
  3267. + } \
  3268. + for (; _i < 4; ++_i) \
  3269. + X##_f[_i] = 0; \
  3270. + S = (_s != 0); \
  3271. + } while (0)
  3272. +
  3273. +#define _FP_FRAC_SRS_4(X,N,size) \
  3274. + do { \
  3275. + int _sticky; \
  3276. + _FP_FRAC_SRST_4(X, _sticky, N, size); \
  3277. + X##_f[0] |= _sticky; \
  3278. + } while (0)
  3279. +
  3280. +#define _FP_FRAC_ADD_4(R,X,Y) \
  3281. + __FP_FRAC_ADD_4(R##_f[3], R##_f[2], R##_f[1], R##_f[0], \
  3282. + X##_f[3], X##_f[2], X##_f[1], X##_f[0], \
  3283. + Y##_f[3], Y##_f[2], Y##_f[1], Y##_f[0])
  3284. +
  3285. +#define _FP_FRAC_SUB_4(R,X,Y) \
  3286. + __FP_FRAC_SUB_4(R##_f[3], R##_f[2], R##_f[1], R##_f[0], \
  3287. + X##_f[3], X##_f[2], X##_f[1], X##_f[0], \
  3288. + Y##_f[3], Y##_f[2], Y##_f[1], Y##_f[0])
  3289. +
  3290. +#define _FP_FRAC_DEC_4(X,Y) \
  3291. + __FP_FRAC_DEC_4(X##_f[3], X##_f[2], X##_f[1], X##_f[0], \
  3292. + Y##_f[3], Y##_f[2], Y##_f[1], Y##_f[0])
  3293. +
  3294. +#define _FP_FRAC_ADDI_4(X,I) \
  3295. + __FP_FRAC_ADDI_4(X##_f[3], X##_f[2], X##_f[1], X##_f[0], I)
  3296. +
  3297. +#define _FP_ZEROFRAC_4 0,0,0,0
  3298. +#define _FP_MINFRAC_4 0,0,0,1
  3299. +#define _FP_MAXFRAC_4 (~(_FP_WS_TYPE)0), (~(_FP_WS_TYPE)0), (~(_FP_WS_TYPE)0), (~(_FP_WS_TYPE)0)
  3300. +
  3301. +#define _FP_FRAC_ZEROP_4(X) ((X##_f[0] | X##_f[1] | X##_f[2] | X##_f[3]) == 0)
  3302. +#define _FP_FRAC_NEGP_4(X) ((_FP_WS_TYPE)X##_f[3] < 0)
  3303. +#define _FP_FRAC_OVERP_4(fs,X) (_FP_FRAC_HIGH_##fs(X) & _FP_OVERFLOW_##fs)
  3304. +#define _FP_FRAC_CLEAR_OVERP_4(fs,X) (_FP_FRAC_HIGH_##fs(X) &= ~_FP_OVERFLOW_##fs)
  3305. +
  3306. +#define _FP_FRAC_EQ_4(X,Y) \
  3307. + (X##_f[0] == Y##_f[0] && X##_f[1] == Y##_f[1] \
  3308. + && X##_f[2] == Y##_f[2] && X##_f[3] == Y##_f[3])
  3309. +
  3310. +#define _FP_FRAC_GT_4(X,Y) \
  3311. + (X##_f[3] > Y##_f[3] || \
  3312. + (X##_f[3] == Y##_f[3] && (X##_f[2] > Y##_f[2] || \
  3313. + (X##_f[2] == Y##_f[2] && (X##_f[1] > Y##_f[1] || \
  3314. + (X##_f[1] == Y##_f[1] && X##_f[0] > Y##_f[0]) \
  3315. + )) \
  3316. + )) \
  3317. + )
  3318. +
  3319. +#define _FP_FRAC_GE_4(X,Y) \
  3320. + (X##_f[3] > Y##_f[3] || \
  3321. + (X##_f[3] == Y##_f[3] && (X##_f[2] > Y##_f[2] || \
  3322. + (X##_f[2] == Y##_f[2] && (X##_f[1] > Y##_f[1] || \
  3323. + (X##_f[1] == Y##_f[1] && X##_f[0] >= Y##_f[0]) \
  3324. + )) \
  3325. + )) \
  3326. + )
  3327. +
  3328. +
  3329. +#define _FP_FRAC_CLZ_4(R,X) \
  3330. + do { \
  3331. + if (X##_f[3]) \
  3332. + { \
  3333. + __FP_CLZ(R,X##_f[3]); \
  3334. + } \
  3335. + else if (X##_f[2]) \
  3336. + { \
  3337. + __FP_CLZ(R,X##_f[2]); \
  3338. + R += _FP_W_TYPE_SIZE; \
  3339. + } \
  3340. + else if (X##_f[1]) \
  3341. + { \
  3342. + __FP_CLZ(R,X##_f[1]); \
  3343. + R += _FP_W_TYPE_SIZE*2; \
  3344. + } \
  3345. + else \
  3346. + { \
  3347. + __FP_CLZ(R,X##_f[0]); \
  3348. + R += _FP_W_TYPE_SIZE*3; \
  3349. + } \
  3350. + } while(0)
  3351. +
  3352. +
  3353. +#define _FP_UNPACK_RAW_4(fs, X, val) \
  3354. + do { \
  3355. + union _FP_UNION_##fs _flo; _flo.flt = (val); \
  3356. + X##_f[0] = _flo.bits.frac0; \
  3357. + X##_f[1] = _flo.bits.frac1; \
  3358. + X##_f[2] = _flo.bits.frac2; \
  3359. + X##_f[3] = _flo.bits.frac3; \
  3360. + X##_e = _flo.bits.exp; \
  3361. + X##_s = _flo.bits.sign; \
  3362. + } while (0)
  3363. +
  3364. +#define _FP_UNPACK_RAW_4_P(fs, X, val) \
  3365. + do { \
  3366. + union _FP_UNION_##fs *_flo = \
  3367. + (union _FP_UNION_##fs *)(val); \
  3368. + \
  3369. + X##_f[0] = _flo->bits.frac0; \
  3370. + X##_f[1] = _flo->bits.frac1; \
  3371. + X##_f[2] = _flo->bits.frac2; \
  3372. + X##_f[3] = _flo->bits.frac3; \
  3373. + X##_e = _flo->bits.exp; \
  3374. + X##_s = _flo->bits.sign; \
  3375. + } while (0)
  3376. +
  3377. +#define _FP_PACK_RAW_4(fs, val, X) \
  3378. + do { \
  3379. + union _FP_UNION_##fs _flo; \
  3380. + _flo.bits.frac0 = X##_f[0]; \
  3381. + _flo.bits.frac1 = X##_f[1]; \
  3382. + _flo.bits.frac2 = X##_f[2]; \
  3383. + _flo.bits.frac3 = X##_f[3]; \
  3384. + _flo.bits.exp = X##_e; \
  3385. + _flo.bits.sign = X##_s; \
  3386. + (val) = _flo.flt; \
  3387. + } while (0)
  3388. +
  3389. +#define _FP_PACK_RAW_4_P(fs, val, X) \
  3390. + do { \
  3391. + union _FP_UNION_##fs *_flo = \
  3392. + (union _FP_UNION_##fs *)(val); \
  3393. + \
  3394. + _flo->bits.frac0 = X##_f[0]; \
  3395. + _flo->bits.frac1 = X##_f[1]; \
  3396. + _flo->bits.frac2 = X##_f[2]; \
  3397. + _flo->bits.frac3 = X##_f[3]; \
  3398. + _flo->bits.exp = X##_e; \
  3399. + _flo->bits.sign = X##_s; \
  3400. + } while (0)
  3401. +
  3402. +/*
  3403. + * Multiplication algorithms:
  3404. + */
  3405. +
  3406. +/* Given a 1W * 1W => 2W primitive, do the extended multiplication. */
  3407. +
  3408. +#define _FP_MUL_MEAT_4_wide(wfracbits, R, X, Y, doit) \
  3409. + do { \
  3410. + _FP_FRAC_DECL_8(_z); _FP_FRAC_DECL_2(_b); _FP_FRAC_DECL_2(_c); \
  3411. + _FP_FRAC_DECL_2(_d); _FP_FRAC_DECL_2(_e); _FP_FRAC_DECL_2(_f); \
  3412. + \
  3413. + doit(_FP_FRAC_WORD_8(_z,1), _FP_FRAC_WORD_8(_z,0), X##_f[0], Y##_f[0]); \
  3414. + doit(_b_f1, _b_f0, X##_f[0], Y##_f[1]); \
  3415. + doit(_c_f1, _c_f0, X##_f[1], Y##_f[0]); \
  3416. + doit(_d_f1, _d_f0, X##_f[1], Y##_f[1]); \
  3417. + doit(_e_f1, _e_f0, X##_f[0], Y##_f[2]); \
  3418. + doit(_f_f1, _f_f0, X##_f[2], Y##_f[0]); \
  3419. + __FP_FRAC_ADD_3(_FP_FRAC_WORD_8(_z,3),_FP_FRAC_WORD_8(_z,2), \
  3420. + _FP_FRAC_WORD_8(_z,1), 0,_b_f1,_b_f0, \
  3421. + 0,0,_FP_FRAC_WORD_8(_z,1)); \
  3422. + __FP_FRAC_ADD_3(_FP_FRAC_WORD_8(_z,3),_FP_FRAC_WORD_8(_z,2), \
  3423. + _FP_FRAC_WORD_8(_z,1), 0,_c_f1,_c_f0, \
  3424. + _FP_FRAC_WORD_8(_z,3),_FP_FRAC_WORD_8(_z,2), \
  3425. + _FP_FRAC_WORD_8(_z,1)); \
  3426. + __FP_FRAC_ADD_3(_FP_FRAC_WORD_8(_z,4),_FP_FRAC_WORD_8(_z,3), \
  3427. + _FP_FRAC_WORD_8(_z,2), 0,_d_f1,_d_f0, \
  3428. + 0,_FP_FRAC_WORD_8(_z,3),_FP_FRAC_WORD_8(_z,2)); \
  3429. + __FP_FRAC_ADD_3(_FP_FRAC_WORD_8(_z,4),_FP_FRAC_WORD_8(_z,3), \
  3430. + _FP_FRAC_WORD_8(_z,2), 0,_e_f1,_e_f0, \
  3431. + _FP_FRAC_WORD_8(_z,4),_FP_FRAC_WORD_8(_z,3), \
  3432. + _FP_FRAC_WORD_8(_z,2)); \
  3433. + __FP_FRAC_ADD_3(_FP_FRAC_WORD_8(_z,4),_FP_FRAC_WORD_8(_z,3), \
  3434. + _FP_FRAC_WORD_8(_z,2), 0,_f_f1,_f_f0, \
  3435. + _FP_FRAC_WORD_8(_z,4),_FP_FRAC_WORD_8(_z,3), \
  3436. + _FP_FRAC_WORD_8(_z,2)); \
  3437. + doit(_b_f1, _b_f0, X##_f[0], Y##_f[3]); \
  3438. + doit(_c_f1, _c_f0, X##_f[3], Y##_f[0]); \
  3439. + doit(_d_f1, _d_f0, X##_f[1], Y##_f[2]); \
  3440. + doit(_e_f1, _e_f0, X##_f[2], Y##_f[1]); \
  3441. + __FP_FRAC_ADD_3(_FP_FRAC_WORD_8(_z,5),_FP_FRAC_WORD_8(_z,4), \
  3442. + _FP_FRAC_WORD_8(_z,3), 0,_b_f1,_b_f0, \
  3443. + 0,_FP_FRAC_WORD_8(_z,4),_FP_FRAC_WORD_8(_z,3)); \
  3444. + __FP_FRAC_ADD_3(_FP_FRAC_WORD_8(_z,5),_FP_FRAC_WORD_8(_z,4), \
  3445. + _FP_FRAC_WORD_8(_z,3), 0,_c_f1,_c_f0, \
  3446. + _FP_FRAC_WORD_8(_z,5),_FP_FRAC_WORD_8(_z,4), \
  3447. + _FP_FRAC_WORD_8(_z,3)); \
  3448. + __FP_FRAC_ADD_3(_FP_FRAC_WORD_8(_z,5),_FP_FRAC_WORD_8(_z,4), \
  3449. + _FP_FRAC_WORD_8(_z,3), 0,_d_f1,_d_f0, \
  3450. + _FP_FRAC_WORD_8(_z,5),_FP_FRAC_WORD_8(_z,4), \
  3451. + _FP_FRAC_WORD_8(_z,3)); \
  3452. + __FP_FRAC_ADD_3(_FP_FRAC_WORD_8(_z,5),_FP_FRAC_WORD_8(_z,4), \
  3453. + _FP_FRAC_WORD_8(_z,3), 0,_e_f1,_e_f0, \
  3454. + _FP_FRAC_WORD_8(_z,5),_FP_FRAC_WORD_8(_z,4), \
  3455. + _FP_FRAC_WORD_8(_z,3)); \
  3456. + doit(_b_f1, _b_f0, X##_f[2], Y##_f[2]); \
  3457. + doit(_c_f1, _c_f0, X##_f[1], Y##_f[3]); \
  3458. + doit(_d_f1, _d_f0, X##_f[3], Y##_f[1]); \
  3459. + doit(_e_f1, _e_f0, X##_f[2], Y##_f[3]); \
  3460. + doit(_f_f1, _f_f0, X##_f[3], Y##_f[2]); \
  3461. + __FP_FRAC_ADD_3(_FP_FRAC_WORD_8(_z,6),_FP_FRAC_WORD_8(_z,5), \
  3462. + _FP_FRAC_WORD_8(_z,4), 0,_b_f1,_b_f0, \
  3463. + 0,_FP_FRAC_WORD_8(_z,5),_FP_FRAC_WORD_8(_z,4)); \
  3464. + __FP_FRAC_ADD_3(_FP_FRAC_WORD_8(_z,6),_FP_FRAC_WORD_8(_z,5), \
  3465. + _FP_FRAC_WORD_8(_z,4), 0,_c_f1,_c_f0, \
  3466. + _FP_FRAC_WORD_8(_z,6),_FP_FRAC_WORD_8(_z,5), \
  3467. + _FP_FRAC_WORD_8(_z,4)); \
  3468. + __FP_FRAC_ADD_3(_FP_FRAC_WORD_8(_z,6),_FP_FRAC_WORD_8(_z,5), \
  3469. + _FP_FRAC_WORD_8(_z,4), 0,_d_f1,_d_f0, \
  3470. + _FP_FRAC_WORD_8(_z,6),_FP_FRAC_WORD_8(_z,5), \
  3471. + _FP_FRAC_WORD_8(_z,4)); \
  3472. + __FP_FRAC_ADD_3(_FP_FRAC_WORD_8(_z,7),_FP_FRAC_WORD_8(_z,6), \
  3473. + _FP_FRAC_WORD_8(_z,5), 0,_e_f1,_e_f0, \
  3474. + 0,_FP_FRAC_WORD_8(_z,6),_FP_FRAC_WORD_8(_z,5)); \
  3475. + __FP_FRAC_ADD_3(_FP_FRAC_WORD_8(_z,7),_FP_FRAC_WORD_8(_z,6), \
  3476. + _FP_FRAC_WORD_8(_z,5), 0,_f_f1,_f_f0, \
  3477. + _FP_FRAC_WORD_8(_z,7),_FP_FRAC_WORD_8(_z,6), \
  3478. + _FP_FRAC_WORD_8(_z,5)); \
  3479. + doit(_b_f1, _b_f0, X##_f[3], Y##_f[3]); \
  3480. + __FP_FRAC_ADD_2(_FP_FRAC_WORD_8(_z,7),_FP_FRAC_WORD_8(_z,6), \
  3481. + _b_f1,_b_f0, \
  3482. + _FP_FRAC_WORD_8(_z,7),_FP_FRAC_WORD_8(_z,6)); \
  3483. + \
  3484. + /* Normalize since we know where the msb of the multiplicands \
  3485. + were (bit B), we know that the msb of the of the product is \
  3486. + at either 2B or 2B-1. */ \
  3487. + _FP_FRAC_SRS_8(_z, wfracbits-1, 2*wfracbits); \
  3488. + __FP_FRAC_SET_4(R, _FP_FRAC_WORD_8(_z,3), _FP_FRAC_WORD_8(_z,2), \
  3489. + _FP_FRAC_WORD_8(_z,1), _FP_FRAC_WORD_8(_z,0)); \
  3490. + } while (0)
  3491. +
  3492. +#define _FP_MUL_MEAT_4_gmp(wfracbits, R, X, Y) \
  3493. + do { \
  3494. + _FP_FRAC_DECL_8(_z); \
  3495. + \
  3496. + mpn_mul_n(_z_f, _x_f, _y_f, 4); \
  3497. + \
  3498. + /* Normalize since we know where the msb of the multiplicands \
  3499. + were (bit B), we know that the msb of the of the product is \
  3500. + at either 2B or 2B-1. */ \
  3501. + _FP_FRAC_SRS_8(_z, wfracbits-1, 2*wfracbits); \
  3502. + __FP_FRAC_SET_4(R, _FP_FRAC_WORD_8(_z,3), _FP_FRAC_WORD_8(_z,2), \
  3503. + _FP_FRAC_WORD_8(_z,1), _FP_FRAC_WORD_8(_z,0)); \
  3504. + } while (0)
  3505. +
  3506. +/*
  3507. + * Helper utility for _FP_DIV_MEAT_4_udiv:
  3508. + * pppp = m * nnn
  3509. + */
  3510. +#define umul_ppppmnnn(p3,p2,p1,p0,m,n2,n1,n0) \
  3511. + do { \
  3512. + UWtype _t; \
  3513. + umul_ppmm(p1,p0,m,n0); \
  3514. + umul_ppmm(p2,_t,m,n1); \
  3515. + __FP_FRAC_ADDI_2(p2,p1,_t); \
  3516. + umul_ppmm(p3,_t,m,n2); \
  3517. + __FP_FRAC_ADDI_2(p3,p2,_t); \
  3518. + } while (0)
  3519. +
  3520. +/*
  3521. + * Division algorithms:
  3522. + */
  3523. +
  3524. +#define _FP_DIV_MEAT_4_udiv(fs, R, X, Y) \
  3525. + do { \
  3526. + int _i; \
  3527. + _FP_FRAC_DECL_4(_n); _FP_FRAC_DECL_4(_m); \
  3528. + _FP_FRAC_SET_4(_n, _FP_ZEROFRAC_4); \
  3529. + if (_FP_FRAC_GT_4(X, Y)) \
  3530. + { \
  3531. + _n_f[3] = X##_f[0] << (_FP_W_TYPE_SIZE - 1); \
  3532. + _FP_FRAC_SRL_4(X, 1); \
  3533. + } \
  3534. + else \
  3535. + R##_e--; \
  3536. + \
  3537. + /* Normalize, i.e. make the most significant bit of the \
  3538. + denominator set. */ \
  3539. + _FP_FRAC_SLL_4(Y, _FP_WFRACXBITS_##fs); \
  3540. + \
  3541. + for (_i = 3; ; _i--) \
  3542. + { \
  3543. + if (X##_f[3] == Y##_f[3]) \
  3544. + { \
  3545. + /* This is a special case, not an optimization \
  3546. + (X##_f[3]/Y##_f[3] would not fit into UWtype). \
  3547. + As X## is guaranteed to be < Y, R##_f[_i] can be either \
  3548. + (UWtype)-1 or (UWtype)-2. */ \
  3549. + R##_f[_i] = -1; \
  3550. + if (!_i) \
  3551. + break; \
  3552. + __FP_FRAC_SUB_4(X##_f[3], X##_f[2], X##_f[1], X##_f[0], \
  3553. + Y##_f[2], Y##_f[1], Y##_f[0], 0, \
  3554. + X##_f[2], X##_f[1], X##_f[0], _n_f[_i]); \
  3555. + _FP_FRAC_SUB_4(X, Y, X); \
  3556. + if (X##_f[3] > Y##_f[3]) \
  3557. + { \
  3558. + R##_f[_i] = -2; \
  3559. + _FP_FRAC_ADD_4(X, Y, X); \
  3560. + } \
  3561. + } \
  3562. + else \
  3563. + { \
  3564. + udiv_qrnnd(R##_f[_i], X##_f[3], X##_f[3], X##_f[2], Y##_f[3]); \
  3565. + umul_ppppmnnn(_m_f[3], _m_f[2], _m_f[1], _m_f[0], \
  3566. + R##_f[_i], Y##_f[2], Y##_f[1], Y##_f[0]); \
  3567. + X##_f[2] = X##_f[1]; \
  3568. + X##_f[1] = X##_f[0]; \
  3569. + X##_f[0] = _n_f[_i]; \
  3570. + if (_FP_FRAC_GT_4(_m, X)) \
  3571. + { \
  3572. + R##_f[_i]--; \
  3573. + _FP_FRAC_ADD_4(X, Y, X); \
  3574. + if (_FP_FRAC_GE_4(X, Y) && _FP_FRAC_GT_4(_m, X)) \
  3575. + { \
  3576. + R##_f[_i]--; \
  3577. + _FP_FRAC_ADD_4(X, Y, X); \
  3578. + } \
  3579. + } \
  3580. + _FP_FRAC_DEC_4(X, _m); \
  3581. + if (!_i) \
  3582. + { \
  3583. + if (!_FP_FRAC_EQ_4(X, _m)) \
  3584. + R##_f[0] |= _FP_WORK_STICKY; \
  3585. + break; \
  3586. + } \
  3587. + } \
  3588. + } \
  3589. + } while (0)
  3590. +
  3591. +
  3592. +/*
  3593. + * Square root algorithms:
  3594. + * We have just one right now, maybe Newton approximation
  3595. + * should be added for those machines where division is fast.
  3596. + */
  3597. +
  3598. +#define _FP_SQRT_MEAT_4(R, S, T, X, q) \
  3599. + do { \
  3600. + while (q) \
  3601. + { \
  3602. + T##_f[3] = S##_f[3] + q; \
  3603. + if (T##_f[3] <= X##_f[3]) \
  3604. + { \
  3605. + S##_f[3] = T##_f[3] + q; \
  3606. + X##_f[3] -= T##_f[3]; \
  3607. + R##_f[3] += q; \
  3608. + } \
  3609. + _FP_FRAC_SLL_4(X, 1); \
  3610. + q >>= 1; \
  3611. + } \
  3612. + q = (_FP_W_TYPE)1 << (_FP_W_TYPE_SIZE - 1); \
  3613. + while (q) \
  3614. + { \
  3615. + T##_f[2] = S##_f[2] + q; \
  3616. + T##_f[3] = S##_f[3]; \
  3617. + if (T##_f[3] < X##_f[3] || \
  3618. + (T##_f[3] == X##_f[3] && T##_f[2] <= X##_f[2])) \
  3619. + { \
  3620. + S##_f[2] = T##_f[2] + q; \
  3621. + S##_f[3] += (T##_f[2] > S##_f[2]); \
  3622. + __FP_FRAC_DEC_2(X##_f[3], X##_f[2], \
  3623. + T##_f[3], T##_f[2]); \
  3624. + R##_f[2] += q; \
  3625. + } \
  3626. + _FP_FRAC_SLL_4(X, 1); \
  3627. + q >>= 1; \
  3628. + } \
  3629. + q = (_FP_W_TYPE)1 << (_FP_W_TYPE_SIZE - 1); \
  3630. + while (q) \
  3631. + { \
  3632. + T##_f[1] = S##_f[1] + q; \
  3633. + T##_f[2] = S##_f[2]; \
  3634. + T##_f[3] = S##_f[3]; \
  3635. + if (T##_f[3] < X##_f[3] || \
  3636. + (T##_f[3] == X##_f[3] && (T##_f[2] < X##_f[2] || \
  3637. + (T##_f[2] == X##_f[2] && T##_f[1] <= X##_f[1])))) \
  3638. + { \
  3639. + S##_f[1] = T##_f[1] + q; \
  3640. + S##_f[2] += (T##_f[1] > S##_f[1]); \
  3641. + S##_f[3] += (T##_f[2] > S##_f[2]); \
  3642. + __FP_FRAC_DEC_3(X##_f[3], X##_f[2], X##_f[1], \
  3643. + T##_f[3], T##_f[2], T##_f[1]); \
  3644. + R##_f[1] += q; \
  3645. + } \
  3646. + _FP_FRAC_SLL_4(X, 1); \
  3647. + q >>= 1; \
  3648. + } \
  3649. + q = (_FP_W_TYPE)1 << (_FP_W_TYPE_SIZE - 1); \
  3650. + while (q != _FP_WORK_ROUND) \
  3651. + { \
  3652. + T##_f[0] = S##_f[0] + q; \
  3653. + T##_f[1] = S##_f[1]; \
  3654. + T##_f[2] = S##_f[2]; \
  3655. + T##_f[3] = S##_f[3]; \
  3656. + if (_FP_FRAC_GE_4(X,T)) \
  3657. + { \
  3658. + S##_f[0] = T##_f[0] + q; \
  3659. + S##_f[1] += (T##_f[0] > S##_f[0]); \
  3660. + S##_f[2] += (T##_f[1] > S##_f[1]); \
  3661. + S##_f[3] += (T##_f[2] > S##_f[2]); \
  3662. + _FP_FRAC_DEC_4(X, T); \
  3663. + R##_f[0] += q; \
  3664. + } \
  3665. + _FP_FRAC_SLL_4(X, 1); \
  3666. + q >>= 1; \
  3667. + } \
  3668. + if (!_FP_FRAC_ZEROP_4(X)) \
  3669. + { \
  3670. + if (_FP_FRAC_GT_4(X,S)) \
  3671. + R##_f[0] |= _FP_WORK_ROUND; \
  3672. + R##_f[0] |= _FP_WORK_STICKY; \
  3673. + } \
  3674. + } while (0)
  3675. +
  3676. +
  3677. +/*
  3678. + * Internals
  3679. + */
  3680. +
  3681. +#define __FP_FRAC_SET_4(X,I3,I2,I1,I0) \
  3682. + (X##_f[3] = I3, X##_f[2] = I2, X##_f[1] = I1, X##_f[0] = I0)
  3683. +
  3684. +#ifndef __FP_FRAC_ADD_3
  3685. +#define __FP_FRAC_ADD_3(r2,r1,r0,x2,x1,x0,y2,y1,y0) \
  3686. + do { \
  3687. + _FP_W_TYPE _c1, _c2; \
  3688. + r0 = x0 + y0; \
  3689. + _c1 = r0 < x0; \
  3690. + r1 = x1 + y1; \
  3691. + _c2 = r1 < x1; \
  3692. + r1 += _c1; \
  3693. + _c2 |= r1 < _c1; \
  3694. + r2 = x2 + y2 + _c2; \
  3695. + } while (0)
  3696. +#endif
  3697. +
  3698. +#ifndef __FP_FRAC_ADD_4
  3699. +#define __FP_FRAC_ADD_4(r3,r2,r1,r0,x3,x2,x1,x0,y3,y2,y1,y0) \
  3700. + do { \
  3701. + _FP_W_TYPE _c1, _c2, _c3; \
  3702. + r0 = x0 + y0; \
  3703. + _c1 = r0 < x0; \
  3704. + r1 = x1 + y1; \
  3705. + _c2 = r1 < x1; \
  3706. + r1 += _c1; \
  3707. + _c2 |= r1 < _c1; \
  3708. + r2 = x2 + y2; \
  3709. + _c3 = r2 < x2; \
  3710. + r2 += _c2; \
  3711. + _c3 |= r2 < _c2; \
  3712. + r3 = x3 + y3 + _c3; \
  3713. + } while (0)
  3714. +#endif
  3715. +
  3716. +#ifndef __FP_FRAC_SUB_3
  3717. +#define __FP_FRAC_SUB_3(r2,r1,r0,x2,x1,x0,y2,y1,y0) \
  3718. + do { \
  3719. + _FP_W_TYPE _c1, _c2; \
  3720. + r0 = x0 - y0; \
  3721. + _c1 = r0 > x0; \
  3722. + r1 = x1 - y1; \
  3723. + _c2 = r1 > x1; \
  3724. + r1 -= _c1; \
  3725. + _c2 |= _c1 && (y1 == x1); \
  3726. + r2 = x2 - y2 - _c2; \
  3727. + } while (0)
  3728. +#endif
  3729. +
  3730. +#ifndef __FP_FRAC_SUB_4
  3731. +#define __FP_FRAC_SUB_4(r3,r2,r1,r0,x3,x2,x1,x0,y3,y2,y1,y0) \
  3732. + do { \
  3733. + _FP_W_TYPE _c1, _c2, _c3; \
  3734. + r0 = x0 - y0; \
  3735. + _c1 = r0 > x0; \
  3736. + r1 = x1 - y1; \
  3737. + _c2 = r1 > x1; \
  3738. + r1 -= _c1; \
  3739. + _c2 |= _c1 && (y1 == x1); \
  3740. + r2 = x2 - y2; \
  3741. + _c3 = r2 > x2; \
  3742. + r2 -= _c2; \
  3743. + _c3 |= _c2 && (y2 == x2); \
  3744. + r3 = x3 - y3 - _c3; \
  3745. + } while (0)
  3746. +#endif
  3747. +
  3748. +#ifndef __FP_FRAC_DEC_3
  3749. +#define __FP_FRAC_DEC_3(x2,x1,x0,y2,y1,y0) \
  3750. + do { \
  3751. + UWtype _t0, _t1, _t2; \
  3752. + _t0 = x0, _t1 = x1, _t2 = x2; \
  3753. + __FP_FRAC_SUB_3 (x2, x1, x0, _t2, _t1, _t0, y2, y1, y0); \
  3754. + } while (0)
  3755. +#endif
  3756. +
  3757. +#ifndef __FP_FRAC_DEC_4
  3758. +#define __FP_FRAC_DEC_4(x3,x2,x1,x0,y3,y2,y1,y0) \
  3759. + do { \
  3760. + UWtype _t0, _t1, _t2, _t3; \
  3761. + _t0 = x0, _t1 = x1, _t2 = x2, _t3 = x3; \
  3762. + __FP_FRAC_SUB_4 (x3,x2,x1,x0,_t3,_t2,_t1,_t0, y3,y2,y1,y0); \
  3763. + } while (0)
  3764. +#endif
  3765. +
  3766. +#ifndef __FP_FRAC_ADDI_4
  3767. +#define __FP_FRAC_ADDI_4(x3,x2,x1,x0,i) \
  3768. + do { \
  3769. + UWtype _t; \
  3770. + _t = ((x0 += i) < i); \
  3771. + x1 += _t; _t = (x1 < _t); \
  3772. + x2 += _t; _t = (x2 < _t); \
  3773. + x3 += _t; \
  3774. + } while (0)
  3775. +#endif
  3776. +
  3777. +/* Convert FP values between word sizes. This appears to be more
  3778. + * complicated than I'd have expected it to be, so these might be
  3779. + * wrong... These macros are in any case somewhat bogus because they
  3780. + * use information about what various FRAC_n variables look like
  3781. + * internally [eg, that 2 word vars are X_f0 and x_f1]. But so do
  3782. + * the ones in op-2.h and op-1.h.
  3783. + */
  3784. +#define _FP_FRAC_COPY_1_4(D, S) (D##_f = S##_f[0])
  3785. +
  3786. +#define _FP_FRAC_COPY_2_4(D, S) \
  3787. +do { \
  3788. + D##_f0 = S##_f[0]; \
  3789. + D##_f1 = S##_f[1]; \
  3790. +} while (0)
  3791. +
  3792. +/* Assembly/disassembly for converting to/from integral types.
  3793. + * No shifting or overflow handled here.
  3794. + */
  3795. +/* Put the FP value X into r, which is an integer of size rsize. */
  3796. +#define _FP_FRAC_ASSEMBLE_4(r, X, rsize) \
  3797. + do { \
  3798. + if (rsize <= _FP_W_TYPE_SIZE) \
  3799. + r = X##_f[0]; \
  3800. + else if (rsize <= 2*_FP_W_TYPE_SIZE) \
  3801. + { \
  3802. + r = X##_f[1]; \
  3803. + r <<= _FP_W_TYPE_SIZE; \
  3804. + r += X##_f[0]; \
  3805. + } \
  3806. + else \
  3807. + { \
  3808. + /* I'm feeling lazy so we deal with int == 3words (implausible)*/ \
  3809. + /* and int == 4words as a single case. */ \
  3810. + r = X##_f[3]; \
  3811. + r <<= _FP_W_TYPE_SIZE; \
  3812. + r += X##_f[2]; \
  3813. + r <<= _FP_W_TYPE_SIZE; \
  3814. + r += X##_f[1]; \
  3815. + r <<= _FP_W_TYPE_SIZE; \
  3816. + r += X##_f[0]; \
  3817. + } \
  3818. + } while (0)
  3819. +
  3820. +/* "No disassemble Number Five!" */
  3821. +/* move an integer of size rsize into X's fractional part. We rely on
  3822. + * the _f[] array consisting of words of size _FP_W_TYPE_SIZE to avoid
  3823. + * having to mask the values we store into it.
  3824. + */
  3825. +#define _FP_FRAC_DISASSEMBLE_4(X, r, rsize) \
  3826. + do { \
  3827. + X##_f[0] = r; \
  3828. + X##_f[1] = (rsize <= _FP_W_TYPE_SIZE ? 0 : r >> _FP_W_TYPE_SIZE); \
  3829. + X##_f[2] = (rsize <= 2*_FP_W_TYPE_SIZE ? 0 : r >> 2*_FP_W_TYPE_SIZE); \
  3830. + X##_f[3] = (rsize <= 3*_FP_W_TYPE_SIZE ? 0 : r >> 3*_FP_W_TYPE_SIZE); \
  3831. + } while (0);
  3832. +
  3833. +#define _FP_FRAC_COPY_4_1(D, S) \
  3834. +do { \
  3835. + D##_f[0] = S##_f; \
  3836. + D##_f[1] = D##_f[2] = D##_f[3] = 0; \
  3837. +} while (0)
  3838. +
  3839. +#define _FP_FRAC_COPY_4_2(D, S) \
  3840. +do { \
  3841. + D##_f[0] = S##_f0; \
  3842. + D##_f[1] = S##_f1; \
  3843. + D##_f[2] = D##_f[3] = 0; \
  3844. +} while (0)
  3845. +
  3846. +#define _FP_FRAC_COPY_4_4(D,S) _FP_FRAC_COPY_4(D,S)
  3847. diff -Naur uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/op-8.h uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/op-8.h
  3848. --- uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/op-8.h 1970-01-01 01:00:00.000000000 +0100
  3849. +++ uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/op-8.h 2010-10-14 14:05:37.000000000 +0200
  3850. @@ -0,0 +1,111 @@
  3851. +/* Software floating-point emulation.
  3852. + Basic eight-word fraction declaration and manipulation.
  3853. + Copyright (C) 1997,1998,1999,2006 Free Software Foundation, Inc.
  3854. + This file is part of the GNU C Library.
  3855. + Contributed by Richard Henderson (rth@cygnus.com),
  3856. + Jakub Jelinek (jj@ultra.linux.cz) and
  3857. + Peter Maydell (pmaydell@chiark.greenend.org.uk).
  3858. +
  3859. + The GNU C Library is free software; you can redistribute it and/or
  3860. + modify it under the terms of the GNU Lesser General Public
  3861. + License as published by the Free Software Foundation; either
  3862. + version 2.1 of the License, or (at your option) any later version.
  3863. +
  3864. + In addition to the permissions in the GNU Lesser General Public
  3865. + License, the Free Software Foundation gives you unlimited
  3866. + permission to link the compiled version of this file into
  3867. + combinations with other programs, and to distribute those
  3868. + combinations without any restriction coming from the use of this
  3869. + file. (The Lesser General Public License restrictions do apply in
  3870. + other respects; for example, they cover modification of the file,
  3871. + and distribution when not linked into a combine executable.)
  3872. +
  3873. + The GNU C Library is distributed in the hope that it will be useful,
  3874. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  3875. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  3876. + Lesser General Public License for more details.
  3877. +
  3878. + You should have received a copy of the GNU Lesser General Public
  3879. + License along with the GNU C Library; if not, write to the Free
  3880. + Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
  3881. + MA 02110-1301, USA. */
  3882. +
  3883. +/* We need just a few things from here for op-4, if we ever need some
  3884. + other macros, they can be added. */
  3885. +#define _FP_FRAC_DECL_8(X) _FP_W_TYPE X##_f[8]
  3886. +#define _FP_FRAC_HIGH_8(X) (X##_f[7])
  3887. +#define _FP_FRAC_LOW_8(X) (X##_f[0])
  3888. +#define _FP_FRAC_WORD_8(X,w) (X##_f[w])
  3889. +
  3890. +#define _FP_FRAC_SLL_8(X,N) \
  3891. + do { \
  3892. + _FP_I_TYPE _up, _down, _skip, _i; \
  3893. + _skip = (N) / _FP_W_TYPE_SIZE; \
  3894. + _up = (N) % _FP_W_TYPE_SIZE; \
  3895. + _down = _FP_W_TYPE_SIZE - _up; \
  3896. + if (!_up) \
  3897. + for (_i = 7; _i >= _skip; --_i) \
  3898. + X##_f[_i] = X##_f[_i-_skip]; \
  3899. + else \
  3900. + { \
  3901. + for (_i = 7; _i > _skip; --_i) \
  3902. + X##_f[_i] = X##_f[_i-_skip] << _up \
  3903. + | X##_f[_i-_skip-1] >> _down; \
  3904. + X##_f[_i--] = X##_f[0] << _up; \
  3905. + } \
  3906. + for (; _i >= 0; --_i) \
  3907. + X##_f[_i] = 0; \
  3908. + } while (0)
  3909. +
  3910. +#define _FP_FRAC_SRL_8(X,N) \
  3911. + do { \
  3912. + _FP_I_TYPE _up, _down, _skip, _i; \
  3913. + _skip = (N) / _FP_W_TYPE_SIZE; \
  3914. + _down = (N) % _FP_W_TYPE_SIZE; \
  3915. + _up = _FP_W_TYPE_SIZE - _down; \
  3916. + if (!_down) \
  3917. + for (_i = 0; _i <= 7-_skip; ++_i) \
  3918. + X##_f[_i] = X##_f[_i+_skip]; \
  3919. + else \
  3920. + { \
  3921. + for (_i = 0; _i < 7-_skip; ++_i) \
  3922. + X##_f[_i] = X##_f[_i+_skip] >> _down \
  3923. + | X##_f[_i+_skip+1] << _up; \
  3924. + X##_f[_i++] = X##_f[7] >> _down; \
  3925. + } \
  3926. + for (; _i < 8; ++_i) \
  3927. + X##_f[_i] = 0; \
  3928. + } while (0)
  3929. +
  3930. +
  3931. +/* Right shift with sticky-lsb.
  3932. + * What this actually means is that we do a standard right-shift,
  3933. + * but that if any of the bits that fall off the right hand side
  3934. + * were one then we always set the LSbit.
  3935. + */
  3936. +#define _FP_FRAC_SRS_8(X,N,size) \
  3937. + do { \
  3938. + _FP_I_TYPE _up, _down, _skip, _i; \
  3939. + _FP_W_TYPE _s; \
  3940. + _skip = (N) / _FP_W_TYPE_SIZE; \
  3941. + _down = (N) % _FP_W_TYPE_SIZE; \
  3942. + _up = _FP_W_TYPE_SIZE - _down; \
  3943. + for (_s = _i = 0; _i < _skip; ++_i) \
  3944. + _s |= X##_f[_i]; \
  3945. + if (!_down) \
  3946. + for (_i = 0; _i <= 7-_skip; ++_i) \
  3947. + X##_f[_i] = X##_f[_i+_skip]; \
  3948. + else \
  3949. + { \
  3950. + _s |= X##_f[_i] << _up; \
  3951. + for (_i = 0; _i < 7-_skip; ++_i) \
  3952. + X##_f[_i] = X##_f[_i+_skip] >> _down \
  3953. + | X##_f[_i+_skip+1] << _up; \
  3954. + X##_f[_i++] = X##_f[7] >> _down; \
  3955. + } \
  3956. + for (; _i < 8; ++_i) \
  3957. + X##_f[_i] = 0; \
  3958. + /* don't fix the LSB until the very end when we're sure f[0] is stable */ \
  3959. + X##_f[0] |= (_s != 0); \
  3960. + } while (0)
  3961. +
  3962. diff -Naur uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/op-common.h uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/op-common.h
  3963. --- uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/op-common.h 1970-01-01 01:00:00.000000000 +0100
  3964. +++ uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/op-common.h 2010-10-14 14:05:37.000000000 +0200
  3965. @@ -0,0 +1,1359 @@
  3966. +/* Software floating-point emulation. Common operations.
  3967. + Copyright (C) 1997,1998,1999,2006,2007 Free Software Foundation, Inc.
  3968. + This file is part of the GNU C Library.
  3969. + Contributed by Richard Henderson (rth@cygnus.com),
  3970. + Jakub Jelinek (jj@ultra.linux.cz),
  3971. + David S. Miller (davem@redhat.com) and
  3972. + Peter Maydell (pmaydell@chiark.greenend.org.uk).
  3973. +
  3974. + The GNU C Library is free software; you can redistribute it and/or
  3975. + modify it under the terms of the GNU Lesser General Public
  3976. + License as published by the Free Software Foundation; either
  3977. + version 2.1 of the License, or (at your option) any later version.
  3978. +
  3979. + In addition to the permissions in the GNU Lesser General Public
  3980. + License, the Free Software Foundation gives you unlimited
  3981. + permission to link the compiled version of this file into
  3982. + combinations with other programs, and to distribute those
  3983. + combinations without any restriction coming from the use of this
  3984. + file. (The Lesser General Public License restrictions do apply in
  3985. + other respects; for example, they cover modification of the file,
  3986. + and distribution when not linked into a combine executable.)
  3987. +
  3988. + The GNU C Library is distributed in the hope that it will be useful,
  3989. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  3990. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  3991. + Lesser General Public License for more details.
  3992. +
  3993. + You should have received a copy of the GNU Lesser General Public
  3994. + License along with the GNU C Library; if not, write to the Free
  3995. + Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
  3996. + MA 02110-1301, USA. */
  3997. +
  3998. +#define _FP_DECL(wc, X) \
  3999. + _FP_I_TYPE X##_c __attribute__((unused)), X##_s, X##_e; \
  4000. + _FP_FRAC_DECL_##wc(X)
  4001. +
  4002. +/*
  4003. + * Finish truely unpacking a native fp value by classifying the kind
  4004. + * of fp value and normalizing both the exponent and the fraction.
  4005. + */
  4006. +
  4007. +#define _FP_UNPACK_CANONICAL(fs, wc, X) \
  4008. +do { \
  4009. + switch (X##_e) \
  4010. + { \
  4011. + default: \
  4012. + _FP_FRAC_HIGH_RAW_##fs(X) |= _FP_IMPLBIT_##fs; \
  4013. + _FP_FRAC_SLL_##wc(X, _FP_WORKBITS); \
  4014. + X##_e -= _FP_EXPBIAS_##fs; \
  4015. + X##_c = FP_CLS_NORMAL; \
  4016. + break; \
  4017. + \
  4018. + case 0: \
  4019. + if (_FP_FRAC_ZEROP_##wc(X)) \
  4020. + X##_c = FP_CLS_ZERO; \
  4021. + else \
  4022. + { \
  4023. + /* a denormalized number */ \
  4024. + _FP_I_TYPE _shift; \
  4025. + _FP_FRAC_CLZ_##wc(_shift, X); \
  4026. + _shift -= _FP_FRACXBITS_##fs; \
  4027. + _FP_FRAC_SLL_##wc(X, (_shift+_FP_WORKBITS)); \
  4028. + X##_e -= _FP_EXPBIAS_##fs - 1 + _shift; \
  4029. + X##_c = FP_CLS_NORMAL; \
  4030. + FP_SET_EXCEPTION(FP_EX_DENORM); \
  4031. + } \
  4032. + break; \
  4033. + \
  4034. + case _FP_EXPMAX_##fs: \
  4035. + if (_FP_FRAC_ZEROP_##wc(X)) \
  4036. + X##_c = FP_CLS_INF; \
  4037. + else \
  4038. + { \
  4039. + X##_c = FP_CLS_NAN; \
  4040. + /* Check for signaling NaN */ \
  4041. + if (!(_FP_FRAC_HIGH_RAW_##fs(X) & _FP_QNANBIT_##fs)) \
  4042. + FP_SET_EXCEPTION(FP_EX_INVALID); \
  4043. + } \
  4044. + break; \
  4045. + } \
  4046. +} while (0)
  4047. +
  4048. +/* Finish unpacking an fp value in semi-raw mode: the mantissa is
  4049. + shifted by _FP_WORKBITS but the implicit MSB is not inserted and
  4050. + other classification is not done. */
  4051. +#define _FP_UNPACK_SEMIRAW(fs, wc, X) _FP_FRAC_SLL_##wc(X, _FP_WORKBITS)
  4052. +
  4053. +/* A semi-raw value has overflowed to infinity. Adjust the mantissa
  4054. + and exponent appropriately. */
  4055. +#define _FP_OVERFLOW_SEMIRAW(fs, wc, X) \
  4056. +do { \
  4057. + if (FP_ROUNDMODE == FP_RND_NEAREST \
  4058. + || (FP_ROUNDMODE == FP_RND_PINF && !X##_s) \
  4059. + || (FP_ROUNDMODE == FP_RND_MINF && X##_s)) \
  4060. + { \
  4061. + X##_e = _FP_EXPMAX_##fs; \
  4062. + _FP_FRAC_SET_##wc(X, _FP_ZEROFRAC_##wc); \
  4063. + } \
  4064. + else \
  4065. + { \
  4066. + X##_e = _FP_EXPMAX_##fs - 1; \
  4067. + _FP_FRAC_SET_##wc(X, _FP_MAXFRAC_##wc); \
  4068. + } \
  4069. + FP_SET_EXCEPTION(FP_EX_INEXACT); \
  4070. + FP_SET_EXCEPTION(FP_EX_OVERFLOW); \
  4071. +} while (0)
  4072. +
  4073. +/* Check for a semi-raw value being a signaling NaN and raise the
  4074. + invalid exception if so. */
  4075. +#define _FP_CHECK_SIGNAN_SEMIRAW(fs, wc, X) \
  4076. +do { \
  4077. + if (X##_e == _FP_EXPMAX_##fs \
  4078. + && !_FP_FRAC_ZEROP_##wc(X) \
  4079. + && !(_FP_FRAC_HIGH_##fs(X) & _FP_QNANBIT_SH_##fs)) \
  4080. + FP_SET_EXCEPTION(FP_EX_INVALID); \
  4081. +} while (0)
  4082. +
  4083. +/* Choose a NaN result from an operation on two semi-raw NaN
  4084. + values. */
  4085. +#define _FP_CHOOSENAN_SEMIRAW(fs, wc, R, X, Y, OP) \
  4086. +do { \
  4087. + /* _FP_CHOOSENAN expects raw values, so shift as required. */ \
  4088. + _FP_FRAC_SRL_##wc(X, _FP_WORKBITS); \
  4089. + _FP_FRAC_SRL_##wc(Y, _FP_WORKBITS); \
  4090. + _FP_CHOOSENAN(fs, wc, R, X, Y, OP); \
  4091. + _FP_FRAC_SLL_##wc(R, _FP_WORKBITS); \
  4092. +} while (0)
  4093. +
  4094. +/* Test whether a biased exponent is normal (not zero or maximum). */
  4095. +#define _FP_EXP_NORMAL(fs, wc, X) (((X##_e + 1) & _FP_EXPMAX_##fs) > 1)
  4096. +
  4097. +/* Prepare to pack an fp value in semi-raw mode: the mantissa is
  4098. + rounded and shifted right, with the rounding possibly increasing
  4099. + the exponent (including changing a finite value to infinity). */
  4100. +#define _FP_PACK_SEMIRAW(fs, wc, X) \
  4101. +do { \
  4102. + _FP_ROUND(wc, X); \
  4103. + if (_FP_FRAC_HIGH_##fs(X) \
  4104. + & (_FP_OVERFLOW_##fs >> 1)) \
  4105. + { \
  4106. + _FP_FRAC_HIGH_##fs(X) &= ~(_FP_OVERFLOW_##fs >> 1); \
  4107. + X##_e++; \
  4108. + if (X##_e == _FP_EXPMAX_##fs) \
  4109. + _FP_OVERFLOW_SEMIRAW(fs, wc, X); \
  4110. + } \
  4111. + _FP_FRAC_SRL_##wc(X, _FP_WORKBITS); \
  4112. + if (!_FP_EXP_NORMAL(fs, wc, X) && !_FP_FRAC_ZEROP_##wc(X)) \
  4113. + { \
  4114. + if (X##_e == 0) \
  4115. + FP_SET_EXCEPTION(FP_EX_UNDERFLOW); \
  4116. + else \
  4117. + { \
  4118. + if (!_FP_KEEPNANFRACP) \
  4119. + { \
  4120. + _FP_FRAC_SET_##wc(X, _FP_NANFRAC_##fs); \
  4121. + X##_s = _FP_NANSIGN_##fs; \
  4122. + } \
  4123. + else \
  4124. + _FP_FRAC_HIGH_RAW_##fs(X) |= _FP_QNANBIT_##fs; \
  4125. + } \
  4126. + } \
  4127. +} while (0)
  4128. +
  4129. +/*
  4130. + * Before packing the bits back into the native fp result, take care
  4131. + * of such mundane things as rounding and overflow. Also, for some
  4132. + * kinds of fp values, the original parts may not have been fully
  4133. + * extracted -- but that is ok, we can regenerate them now.
  4134. + */
  4135. +
  4136. +#define _FP_PACK_CANONICAL(fs, wc, X) \
  4137. +do { \
  4138. + switch (X##_c) \
  4139. + { \
  4140. + case FP_CLS_NORMAL: \
  4141. + X##_e += _FP_EXPBIAS_##fs; \
  4142. + if (X##_e > 0) \
  4143. + { \
  4144. + _FP_ROUND(wc, X); \
  4145. + if (_FP_FRAC_OVERP_##wc(fs, X)) \
  4146. + { \
  4147. + _FP_FRAC_CLEAR_OVERP_##wc(fs, X); \
  4148. + X##_e++; \
  4149. + } \
  4150. + _FP_FRAC_SRL_##wc(X, _FP_WORKBITS); \
  4151. + if (X##_e >= _FP_EXPMAX_##fs) \
  4152. + { \
  4153. + /* overflow */ \
  4154. + switch (FP_ROUNDMODE) \
  4155. + { \
  4156. + case FP_RND_NEAREST: \
  4157. + X##_c = FP_CLS_INF; \
  4158. + break; \
  4159. + case FP_RND_PINF: \
  4160. + if (!X##_s) X##_c = FP_CLS_INF; \
  4161. + break; \
  4162. + case FP_RND_MINF: \
  4163. + if (X##_s) X##_c = FP_CLS_INF; \
  4164. + break; \
  4165. + } \
  4166. + if (X##_c == FP_CLS_INF) \
  4167. + { \
  4168. + /* Overflow to infinity */ \
  4169. + X##_e = _FP_EXPMAX_##fs; \
  4170. + _FP_FRAC_SET_##wc(X, _FP_ZEROFRAC_##wc); \
  4171. + } \
  4172. + else \
  4173. + { \
  4174. + /* Overflow to maximum normal */ \
  4175. + X##_e = _FP_EXPMAX_##fs - 1; \
  4176. + _FP_FRAC_SET_##wc(X, _FP_MAXFRAC_##wc); \
  4177. + } \
  4178. + FP_SET_EXCEPTION(FP_EX_OVERFLOW); \
  4179. + FP_SET_EXCEPTION(FP_EX_INEXACT); \
  4180. + } \
  4181. + } \
  4182. + else \
  4183. + { \
  4184. + /* we've got a denormalized number */ \
  4185. + X##_e = -X##_e + 1; \
  4186. + if (X##_e <= _FP_WFRACBITS_##fs) \
  4187. + { \
  4188. + _FP_FRAC_SRS_##wc(X, X##_e, _FP_WFRACBITS_##fs); \
  4189. + _FP_ROUND(wc, X); \
  4190. + if (_FP_FRAC_HIGH_##fs(X) \
  4191. + & (_FP_OVERFLOW_##fs >> 1)) \
  4192. + { \
  4193. + X##_e = 1; \
  4194. + _FP_FRAC_SET_##wc(X, _FP_ZEROFRAC_##wc); \
  4195. + } \
  4196. + else \
  4197. + { \
  4198. + X##_e = 0; \
  4199. + _FP_FRAC_SRL_##wc(X, _FP_WORKBITS); \
  4200. + FP_SET_EXCEPTION(FP_EX_UNDERFLOW); \
  4201. + } \
  4202. + } \
  4203. + else \
  4204. + { \
  4205. + /* underflow to zero */ \
  4206. + X##_e = 0; \
  4207. + if (!_FP_FRAC_ZEROP_##wc(X)) \
  4208. + { \
  4209. + _FP_FRAC_SET_##wc(X, _FP_MINFRAC_##wc); \
  4210. + _FP_ROUND(wc, X); \
  4211. + _FP_FRAC_LOW_##wc(X) >>= (_FP_WORKBITS); \
  4212. + } \
  4213. + FP_SET_EXCEPTION(FP_EX_UNDERFLOW); \
  4214. + } \
  4215. + } \
  4216. + break; \
  4217. + \
  4218. + case FP_CLS_ZERO: \
  4219. + X##_e = 0; \
  4220. + _FP_FRAC_SET_##wc(X, _FP_ZEROFRAC_##wc); \
  4221. + break; \
  4222. + \
  4223. + case FP_CLS_INF: \
  4224. + X##_e = _FP_EXPMAX_##fs; \
  4225. + _FP_FRAC_SET_##wc(X, _FP_ZEROFRAC_##wc); \
  4226. + break; \
  4227. + \
  4228. + case FP_CLS_NAN: \
  4229. + X##_e = _FP_EXPMAX_##fs; \
  4230. + if (!_FP_KEEPNANFRACP) \
  4231. + { \
  4232. + _FP_FRAC_SET_##wc(X, _FP_NANFRAC_##fs); \
  4233. + X##_s = _FP_NANSIGN_##fs; \
  4234. + } \
  4235. + else \
  4236. + _FP_FRAC_HIGH_RAW_##fs(X) |= _FP_QNANBIT_##fs; \
  4237. + break; \
  4238. + } \
  4239. +} while (0)
  4240. +
  4241. +/* This one accepts raw argument and not cooked, returns
  4242. + * 1 if X is a signaling NaN.
  4243. + */
  4244. +#define _FP_ISSIGNAN(fs, wc, X) \
  4245. +({ \
  4246. + int __ret = 0; \
  4247. + if (X##_e == _FP_EXPMAX_##fs) \
  4248. + { \
  4249. + if (!_FP_FRAC_ZEROP_##wc(X) \
  4250. + && !(_FP_FRAC_HIGH_RAW_##fs(X) & _FP_QNANBIT_##fs)) \
  4251. + __ret = 1; \
  4252. + } \
  4253. + __ret; \
  4254. +})
  4255. +
  4256. +
  4257. +
  4258. +
  4259. +
  4260. +/* Addition on semi-raw values. */
  4261. +#define _FP_ADD_INTERNAL(fs, wc, R, X, Y, OP) \
  4262. +do { \
  4263. + if (X##_s == Y##_s) \
  4264. + { \
  4265. + /* Addition. */ \
  4266. + R##_s = X##_s; \
  4267. + int ediff = X##_e - Y##_e; \
  4268. + if (ediff > 0) \
  4269. + { \
  4270. + R##_e = X##_e; \
  4271. + if (Y##_e == 0) \
  4272. + { \
  4273. + /* Y is zero or denormalized. */ \
  4274. + if (_FP_FRAC_ZEROP_##wc(Y)) \
  4275. + { \
  4276. + _FP_CHECK_SIGNAN_SEMIRAW(fs, wc, X); \
  4277. + _FP_FRAC_COPY_##wc(R, X); \
  4278. + goto add_done; \
  4279. + } \
  4280. + else \
  4281. + { \
  4282. + FP_SET_EXCEPTION(FP_EX_DENORM); \
  4283. + ediff--; \
  4284. + if (ediff == 0) \
  4285. + { \
  4286. + _FP_FRAC_ADD_##wc(R, X, Y); \
  4287. + goto add3; \
  4288. + } \
  4289. + if (X##_e == _FP_EXPMAX_##fs) \
  4290. + { \
  4291. + _FP_CHECK_SIGNAN_SEMIRAW(fs, wc, X); \
  4292. + _FP_FRAC_COPY_##wc(R, X); \
  4293. + goto add_done; \
  4294. + } \
  4295. + goto add1; \
  4296. + } \
  4297. + } \
  4298. + else if (X##_e == _FP_EXPMAX_##fs) \
  4299. + { \
  4300. + /* X is NaN or Inf, Y is normal. */ \
  4301. + _FP_CHECK_SIGNAN_SEMIRAW(fs, wc, X); \
  4302. + _FP_FRAC_COPY_##wc(R, X); \
  4303. + goto add_done; \
  4304. + } \
  4305. + \
  4306. + /* Insert implicit MSB of Y. */ \
  4307. + _FP_FRAC_HIGH_##fs(Y) |= _FP_IMPLBIT_SH_##fs; \
  4308. + \
  4309. + add1: \
  4310. + /* Shift the mantissa of Y to the right EDIFF steps; \
  4311. + remember to account later for the implicit MSB of X. */ \
  4312. + if (ediff <= _FP_WFRACBITS_##fs) \
  4313. + _FP_FRAC_SRS_##wc(Y, ediff, _FP_WFRACBITS_##fs); \
  4314. + else if (!_FP_FRAC_ZEROP_##wc(Y)) \
  4315. + _FP_FRAC_SET_##wc(Y, _FP_MINFRAC_##wc); \
  4316. + _FP_FRAC_ADD_##wc(R, X, Y); \
  4317. + } \
  4318. + else if (ediff < 0) \
  4319. + { \
  4320. + ediff = -ediff; \
  4321. + R##_e = Y##_e; \
  4322. + if (X##_e == 0) \
  4323. + { \
  4324. + /* X is zero or denormalized. */ \
  4325. + if (_FP_FRAC_ZEROP_##wc(X)) \
  4326. + { \
  4327. + _FP_CHECK_SIGNAN_SEMIRAW(fs, wc, Y); \
  4328. + _FP_FRAC_COPY_##wc(R, Y); \
  4329. + goto add_done; \
  4330. + } \
  4331. + else \
  4332. + { \
  4333. + FP_SET_EXCEPTION(FP_EX_DENORM); \
  4334. + ediff--; \
  4335. + if (ediff == 0) \
  4336. + { \
  4337. + _FP_FRAC_ADD_##wc(R, Y, X); \
  4338. + goto add3; \
  4339. + } \
  4340. + if (Y##_e == _FP_EXPMAX_##fs) \
  4341. + { \
  4342. + _FP_CHECK_SIGNAN_SEMIRAW(fs, wc, Y); \
  4343. + _FP_FRAC_COPY_##wc(R, Y); \
  4344. + goto add_done; \
  4345. + } \
  4346. + goto add2; \
  4347. + } \
  4348. + } \
  4349. + else if (Y##_e == _FP_EXPMAX_##fs) \
  4350. + { \
  4351. + /* Y is NaN or Inf, X is normal. */ \
  4352. + _FP_CHECK_SIGNAN_SEMIRAW(fs, wc, Y); \
  4353. + _FP_FRAC_COPY_##wc(R, Y); \
  4354. + goto add_done; \
  4355. + } \
  4356. + \
  4357. + /* Insert implicit MSB of X. */ \
  4358. + _FP_FRAC_HIGH_##fs(X) |= _FP_IMPLBIT_SH_##fs; \
  4359. + \
  4360. + add2: \
  4361. + /* Shift the mantissa of X to the right EDIFF steps; \
  4362. + remember to account later for the implicit MSB of Y. */ \
  4363. + if (ediff <= _FP_WFRACBITS_##fs) \
  4364. + _FP_FRAC_SRS_##wc(X, ediff, _FP_WFRACBITS_##fs); \
  4365. + else if (!_FP_FRAC_ZEROP_##wc(X)) \
  4366. + _FP_FRAC_SET_##wc(X, _FP_MINFRAC_##wc); \
  4367. + _FP_FRAC_ADD_##wc(R, Y, X); \
  4368. + } \
  4369. + else \
  4370. + { \
  4371. + /* ediff == 0. */ \
  4372. + if (!_FP_EXP_NORMAL(fs, wc, X)) \
  4373. + { \
  4374. + if (X##_e == 0) \
  4375. + { \
  4376. + /* X and Y are zero or denormalized. */ \
  4377. + R##_e = 0; \
  4378. + if (_FP_FRAC_ZEROP_##wc(X)) \
  4379. + { \
  4380. + if (!_FP_FRAC_ZEROP_##wc(Y)) \
  4381. + FP_SET_EXCEPTION(FP_EX_DENORM); \
  4382. + _FP_FRAC_COPY_##wc(R, Y); \
  4383. + goto add_done; \
  4384. + } \
  4385. + else if (_FP_FRAC_ZEROP_##wc(Y)) \
  4386. + { \
  4387. + FP_SET_EXCEPTION(FP_EX_DENORM); \
  4388. + _FP_FRAC_COPY_##wc(R, X); \
  4389. + goto add_done; \
  4390. + } \
  4391. + else \
  4392. + { \
  4393. + FP_SET_EXCEPTION(FP_EX_DENORM); \
  4394. + _FP_FRAC_ADD_##wc(R, X, Y); \
  4395. + if (_FP_FRAC_HIGH_##fs(R) & _FP_IMPLBIT_SH_##fs) \
  4396. + { \
  4397. + /* Normalized result. */ \
  4398. + _FP_FRAC_HIGH_##fs(R) \
  4399. + &= ~(_FP_W_TYPE)_FP_IMPLBIT_SH_##fs; \
  4400. + R##_e = 1; \
  4401. + } \
  4402. + goto add_done; \
  4403. + } \
  4404. + } \
  4405. + else \
  4406. + { \
  4407. + /* X and Y are NaN or Inf. */ \
  4408. + _FP_CHECK_SIGNAN_SEMIRAW(fs, wc, X); \
  4409. + _FP_CHECK_SIGNAN_SEMIRAW(fs, wc, Y); \
  4410. + R##_e = _FP_EXPMAX_##fs; \
  4411. + if (_FP_FRAC_ZEROP_##wc(X)) \
  4412. + _FP_FRAC_COPY_##wc(R, Y); \
  4413. + else if (_FP_FRAC_ZEROP_##wc(Y)) \
  4414. + _FP_FRAC_COPY_##wc(R, X); \
  4415. + else \
  4416. + _FP_CHOOSENAN_SEMIRAW(fs, wc, R, X, Y, OP); \
  4417. + goto add_done; \
  4418. + } \
  4419. + } \
  4420. + /* The exponents of X and Y, both normal, are equal. The \
  4421. + implicit MSBs will always add to increase the \
  4422. + exponent. */ \
  4423. + _FP_FRAC_ADD_##wc(R, X, Y); \
  4424. + R##_e = X##_e + 1; \
  4425. + _FP_FRAC_SRS_##wc(R, 1, _FP_WFRACBITS_##fs); \
  4426. + if (R##_e == _FP_EXPMAX_##fs) \
  4427. + /* Overflow to infinity (depending on rounding mode). */ \
  4428. + _FP_OVERFLOW_SEMIRAW(fs, wc, R); \
  4429. + goto add_done; \
  4430. + } \
  4431. + add3: \
  4432. + if (_FP_FRAC_HIGH_##fs(R) & _FP_IMPLBIT_SH_##fs) \
  4433. + { \
  4434. + /* Overflow. */ \
  4435. + _FP_FRAC_HIGH_##fs(R) &= ~(_FP_W_TYPE)_FP_IMPLBIT_SH_##fs; \
  4436. + R##_e++; \
  4437. + _FP_FRAC_SRS_##wc(R, 1, _FP_WFRACBITS_##fs); \
  4438. + if (R##_e == _FP_EXPMAX_##fs) \
  4439. + /* Overflow to infinity (depending on rounding mode). */ \
  4440. + _FP_OVERFLOW_SEMIRAW(fs, wc, R); \
  4441. + } \
  4442. + add_done: ; \
  4443. + } \
  4444. + else \
  4445. + { \
  4446. + /* Subtraction. */ \
  4447. + int ediff = X##_e - Y##_e; \
  4448. + if (ediff > 0) \
  4449. + { \
  4450. + R##_e = X##_e; \
  4451. + R##_s = X##_s; \
  4452. + if (Y##_e == 0) \
  4453. + { \
  4454. + /* Y is zero or denormalized. */ \
  4455. + if (_FP_FRAC_ZEROP_##wc(Y)) \
  4456. + { \
  4457. + _FP_CHECK_SIGNAN_SEMIRAW(fs, wc, X); \
  4458. + _FP_FRAC_COPY_##wc(R, X); \
  4459. + goto sub_done; \
  4460. + } \
  4461. + else \
  4462. + { \
  4463. + FP_SET_EXCEPTION(FP_EX_DENORM); \
  4464. + ediff--; \
  4465. + if (ediff == 0) \
  4466. + { \
  4467. + _FP_FRAC_SUB_##wc(R, X, Y); \
  4468. + goto sub3; \
  4469. + } \
  4470. + if (X##_e == _FP_EXPMAX_##fs) \
  4471. + { \
  4472. + _FP_CHECK_SIGNAN_SEMIRAW(fs, wc, X); \
  4473. + _FP_FRAC_COPY_##wc(R, X); \
  4474. + goto sub_done; \
  4475. + } \
  4476. + goto sub1; \
  4477. + } \
  4478. + } \
  4479. + else if (X##_e == _FP_EXPMAX_##fs) \
  4480. + { \
  4481. + /* X is NaN or Inf, Y is normal. */ \
  4482. + _FP_CHECK_SIGNAN_SEMIRAW(fs, wc, X); \
  4483. + _FP_FRAC_COPY_##wc(R, X); \
  4484. + goto sub_done; \
  4485. + } \
  4486. + \
  4487. + /* Insert implicit MSB of Y. */ \
  4488. + _FP_FRAC_HIGH_##fs(Y) |= _FP_IMPLBIT_SH_##fs; \
  4489. + \
  4490. + sub1: \
  4491. + /* Shift the mantissa of Y to the right EDIFF steps; \
  4492. + remember to account later for the implicit MSB of X. */ \
  4493. + if (ediff <= _FP_WFRACBITS_##fs) \
  4494. + _FP_FRAC_SRS_##wc(Y, ediff, _FP_WFRACBITS_##fs); \
  4495. + else if (!_FP_FRAC_ZEROP_##wc(Y)) \
  4496. + _FP_FRAC_SET_##wc(Y, _FP_MINFRAC_##wc); \
  4497. + _FP_FRAC_SUB_##wc(R, X, Y); \
  4498. + } \
  4499. + else if (ediff < 0) \
  4500. + { \
  4501. + ediff = -ediff; \
  4502. + R##_e = Y##_e; \
  4503. + R##_s = Y##_s; \
  4504. + if (X##_e == 0) \
  4505. + { \
  4506. + /* X is zero or denormalized. */ \
  4507. + if (_FP_FRAC_ZEROP_##wc(X)) \
  4508. + { \
  4509. + _FP_CHECK_SIGNAN_SEMIRAW(fs, wc, Y); \
  4510. + _FP_FRAC_COPY_##wc(R, Y); \
  4511. + goto sub_done; \
  4512. + } \
  4513. + else \
  4514. + { \
  4515. + FP_SET_EXCEPTION(FP_EX_DENORM); \
  4516. + ediff--; \
  4517. + if (ediff == 0) \
  4518. + { \
  4519. + _FP_FRAC_SUB_##wc(R, Y, X); \
  4520. + goto sub3; \
  4521. + } \
  4522. + if (Y##_e == _FP_EXPMAX_##fs) \
  4523. + { \
  4524. + _FP_CHECK_SIGNAN_SEMIRAW(fs, wc, Y); \
  4525. + _FP_FRAC_COPY_##wc(R, Y); \
  4526. + goto sub_done; \
  4527. + } \
  4528. + goto sub2; \
  4529. + } \
  4530. + } \
  4531. + else if (Y##_e == _FP_EXPMAX_##fs) \
  4532. + { \
  4533. + /* Y is NaN or Inf, X is normal. */ \
  4534. + _FP_CHECK_SIGNAN_SEMIRAW(fs, wc, Y); \
  4535. + _FP_FRAC_COPY_##wc(R, Y); \
  4536. + goto sub_done; \
  4537. + } \
  4538. + \
  4539. + /* Insert implicit MSB of X. */ \
  4540. + _FP_FRAC_HIGH_##fs(X) |= _FP_IMPLBIT_SH_##fs; \
  4541. + \
  4542. + sub2: \
  4543. + /* Shift the mantissa of X to the right EDIFF steps; \
  4544. + remember to account later for the implicit MSB of Y. */ \
  4545. + if (ediff <= _FP_WFRACBITS_##fs) \
  4546. + _FP_FRAC_SRS_##wc(X, ediff, _FP_WFRACBITS_##fs); \
  4547. + else if (!_FP_FRAC_ZEROP_##wc(X)) \
  4548. + _FP_FRAC_SET_##wc(X, _FP_MINFRAC_##wc); \
  4549. + _FP_FRAC_SUB_##wc(R, Y, X); \
  4550. + } \
  4551. + else \
  4552. + { \
  4553. + /* ediff == 0. */ \
  4554. + if (!_FP_EXP_NORMAL(fs, wc, X)) \
  4555. + { \
  4556. + if (X##_e == 0) \
  4557. + { \
  4558. + /* X and Y are zero or denormalized. */ \
  4559. + R##_e = 0; \
  4560. + if (_FP_FRAC_ZEROP_##wc(X)) \
  4561. + { \
  4562. + _FP_FRAC_COPY_##wc(R, Y); \
  4563. + if (_FP_FRAC_ZEROP_##wc(Y)) \
  4564. + R##_s = (FP_ROUNDMODE == FP_RND_MINF); \
  4565. + else \
  4566. + { \
  4567. + FP_SET_EXCEPTION(FP_EX_DENORM); \
  4568. + R##_s = Y##_s; \
  4569. + } \
  4570. + goto sub_done; \
  4571. + } \
  4572. + else if (_FP_FRAC_ZEROP_##wc(Y)) \
  4573. + { \
  4574. + FP_SET_EXCEPTION(FP_EX_DENORM); \
  4575. + _FP_FRAC_COPY_##wc(R, X); \
  4576. + R##_s = X##_s; \
  4577. + goto sub_done; \
  4578. + } \
  4579. + else \
  4580. + { \
  4581. + FP_SET_EXCEPTION(FP_EX_DENORM); \
  4582. + _FP_FRAC_SUB_##wc(R, X, Y); \
  4583. + R##_s = X##_s; \
  4584. + if (_FP_FRAC_HIGH_##fs(R) & _FP_IMPLBIT_SH_##fs) \
  4585. + { \
  4586. + /* |X| < |Y|, negate result. */ \
  4587. + _FP_FRAC_SUB_##wc(R, Y, X); \
  4588. + R##_s = Y##_s; \
  4589. + } \
  4590. + else if (_FP_FRAC_ZEROP_##wc(R)) \
  4591. + R##_s = (FP_ROUNDMODE == FP_RND_MINF); \
  4592. + goto sub_done; \
  4593. + } \
  4594. + } \
  4595. + else \
  4596. + { \
  4597. + /* X and Y are NaN or Inf, of opposite signs. */ \
  4598. + _FP_CHECK_SIGNAN_SEMIRAW(fs, wc, X); \
  4599. + _FP_CHECK_SIGNAN_SEMIRAW(fs, wc, Y); \
  4600. + R##_e = _FP_EXPMAX_##fs; \
  4601. + if (_FP_FRAC_ZEROP_##wc(X)) \
  4602. + { \
  4603. + if (_FP_FRAC_ZEROP_##wc(Y)) \
  4604. + { \
  4605. + /* Inf - Inf. */ \
  4606. + R##_s = _FP_NANSIGN_##fs; \
  4607. + _FP_FRAC_SET_##wc(R, _FP_NANFRAC_##fs); \
  4608. + _FP_FRAC_SLL_##wc(R, _FP_WORKBITS); \
  4609. + FP_SET_EXCEPTION(FP_EX_INVALID); \
  4610. + } \
  4611. + else \
  4612. + { \
  4613. + /* Inf - NaN. */ \
  4614. + R##_s = Y##_s; \
  4615. + _FP_FRAC_COPY_##wc(R, Y); \
  4616. + } \
  4617. + } \
  4618. + else \
  4619. + { \
  4620. + if (_FP_FRAC_ZEROP_##wc(Y)) \
  4621. + { \
  4622. + /* NaN - Inf. */ \
  4623. + R##_s = X##_s; \
  4624. + _FP_FRAC_COPY_##wc(R, X); \
  4625. + } \
  4626. + else \
  4627. + { \
  4628. + /* NaN - NaN. */ \
  4629. + _FP_CHOOSENAN_SEMIRAW(fs, wc, R, X, Y, OP); \
  4630. + } \
  4631. + } \
  4632. + goto sub_done; \
  4633. + } \
  4634. + } \
  4635. + /* The exponents of X and Y, both normal, are equal. The \
  4636. + implicit MSBs cancel. */ \
  4637. + R##_e = X##_e; \
  4638. + _FP_FRAC_SUB_##wc(R, X, Y); \
  4639. + R##_s = X##_s; \
  4640. + if (_FP_FRAC_HIGH_##fs(R) & _FP_IMPLBIT_SH_##fs) \
  4641. + { \
  4642. + /* |X| < |Y|, negate result. */ \
  4643. + _FP_FRAC_SUB_##wc(R, Y, X); \
  4644. + R##_s = Y##_s; \
  4645. + } \
  4646. + else if (_FP_FRAC_ZEROP_##wc(R)) \
  4647. + { \
  4648. + R##_e = 0; \
  4649. + R##_s = (FP_ROUNDMODE == FP_RND_MINF); \
  4650. + goto sub_done; \
  4651. + } \
  4652. + goto norm; \
  4653. + } \
  4654. + sub3: \
  4655. + if (_FP_FRAC_HIGH_##fs(R) & _FP_IMPLBIT_SH_##fs) \
  4656. + { \
  4657. + int diff; \
  4658. + /* Carry into most significant bit of larger one of X and Y, \
  4659. + canceling it; renormalize. */ \
  4660. + _FP_FRAC_HIGH_##fs(R) &= _FP_IMPLBIT_SH_##fs - 1; \
  4661. + norm: \
  4662. + _FP_FRAC_CLZ_##wc(diff, R); \
  4663. + diff -= _FP_WFRACXBITS_##fs; \
  4664. + _FP_FRAC_SLL_##wc(R, diff); \
  4665. + if (R##_e <= diff) \
  4666. + { \
  4667. + /* R is denormalized. */ \
  4668. + diff = diff - R##_e + 1; \
  4669. + _FP_FRAC_SRS_##wc(R, diff, _FP_WFRACBITS_##fs); \
  4670. + R##_e = 0; \
  4671. + } \
  4672. + else \
  4673. + { \
  4674. + R##_e -= diff; \
  4675. + _FP_FRAC_HIGH_##fs(R) &= ~(_FP_W_TYPE)_FP_IMPLBIT_SH_##fs; \
  4676. + } \
  4677. + } \
  4678. + sub_done: ; \
  4679. + } \
  4680. +} while (0)
  4681. +
  4682. +#define _FP_ADD(fs, wc, R, X, Y) _FP_ADD_INTERNAL(fs, wc, R, X, Y, '+')
  4683. +#define _FP_SUB(fs, wc, R, X, Y) \
  4684. + do { \
  4685. + if (!(Y##_e == _FP_EXPMAX_##fs && !_FP_FRAC_ZEROP_##wc(Y))) Y##_s ^= 1; \
  4686. + _FP_ADD_INTERNAL(fs, wc, R, X, Y, '-'); \
  4687. + } while (0)
  4688. +
  4689. +
  4690. +/*
  4691. + * Main negation routine. FIXME -- when we care about setting exception
  4692. + * bits reliably, this will not do. We should examine all of the fp classes.
  4693. + */
  4694. +
  4695. +#define _FP_NEG(fs, wc, R, X) \
  4696. + do { \
  4697. + _FP_FRAC_COPY_##wc(R, X); \
  4698. + R##_c = X##_c; \
  4699. + R##_e = X##_e; \
  4700. + R##_s = 1 ^ X##_s; \
  4701. + } while (0)
  4702. +
  4703. +
  4704. +/*
  4705. + * Main multiplication routine. The input values should be cooked.
  4706. + */
  4707. +
  4708. +#define _FP_MUL(fs, wc, R, X, Y) \
  4709. +do { \
  4710. + R##_s = X##_s ^ Y##_s; \
  4711. + switch (_FP_CLS_COMBINE(X##_c, Y##_c)) \
  4712. + { \
  4713. + case _FP_CLS_COMBINE(FP_CLS_NORMAL,FP_CLS_NORMAL): \
  4714. + R##_c = FP_CLS_NORMAL; \
  4715. + R##_e = X##_e + Y##_e + 1; \
  4716. + \
  4717. + _FP_MUL_MEAT_##fs(R,X,Y); \
  4718. + \
  4719. + if (_FP_FRAC_OVERP_##wc(fs, R)) \
  4720. + _FP_FRAC_SRS_##wc(R, 1, _FP_WFRACBITS_##fs); \
  4721. + else \
  4722. + R##_e--; \
  4723. + break; \
  4724. + \
  4725. + case _FP_CLS_COMBINE(FP_CLS_NAN,FP_CLS_NAN): \
  4726. + _FP_CHOOSENAN(fs, wc, R, X, Y, '*'); \
  4727. + break; \
  4728. + \
  4729. + case _FP_CLS_COMBINE(FP_CLS_NAN,FP_CLS_NORMAL): \
  4730. + case _FP_CLS_COMBINE(FP_CLS_NAN,FP_CLS_INF): \
  4731. + case _FP_CLS_COMBINE(FP_CLS_NAN,FP_CLS_ZERO): \
  4732. + R##_s = X##_s; \
  4733. + \
  4734. + case _FP_CLS_COMBINE(FP_CLS_INF,FP_CLS_INF): \
  4735. + case _FP_CLS_COMBINE(FP_CLS_INF,FP_CLS_NORMAL): \
  4736. + case _FP_CLS_COMBINE(FP_CLS_ZERO,FP_CLS_NORMAL): \
  4737. + case _FP_CLS_COMBINE(FP_CLS_ZERO,FP_CLS_ZERO): \
  4738. + _FP_FRAC_COPY_##wc(R, X); \
  4739. + R##_c = X##_c; \
  4740. + break; \
  4741. + \
  4742. + case _FP_CLS_COMBINE(FP_CLS_NORMAL,FP_CLS_NAN): \
  4743. + case _FP_CLS_COMBINE(FP_CLS_INF,FP_CLS_NAN): \
  4744. + case _FP_CLS_COMBINE(FP_CLS_ZERO,FP_CLS_NAN): \
  4745. + R##_s = Y##_s; \
  4746. + \
  4747. + case _FP_CLS_COMBINE(FP_CLS_NORMAL,FP_CLS_INF): \
  4748. + case _FP_CLS_COMBINE(FP_CLS_NORMAL,FP_CLS_ZERO): \
  4749. + _FP_FRAC_COPY_##wc(R, Y); \
  4750. + R##_c = Y##_c; \
  4751. + break; \
  4752. + \
  4753. + case _FP_CLS_COMBINE(FP_CLS_INF,FP_CLS_ZERO): \
  4754. + case _FP_CLS_COMBINE(FP_CLS_ZERO,FP_CLS_INF): \
  4755. + R##_s = _FP_NANSIGN_##fs; \
  4756. + R##_c = FP_CLS_NAN; \
  4757. + _FP_FRAC_SET_##wc(R, _FP_NANFRAC_##fs); \
  4758. + FP_SET_EXCEPTION(FP_EX_INVALID); \
  4759. + break; \
  4760. + \
  4761. + default: \
  4762. + abort(); \
  4763. + } \
  4764. +} while (0)
  4765. +
  4766. +
  4767. +/*
  4768. + * Main division routine. The input values should be cooked.
  4769. + */
  4770. +
  4771. +#define _FP_DIV(fs, wc, R, X, Y) \
  4772. +do { \
  4773. + R##_s = X##_s ^ Y##_s; \
  4774. + switch (_FP_CLS_COMBINE(X##_c, Y##_c)) \
  4775. + { \
  4776. + case _FP_CLS_COMBINE(FP_CLS_NORMAL,FP_CLS_NORMAL): \
  4777. + R##_c = FP_CLS_NORMAL; \
  4778. + R##_e = X##_e - Y##_e; \
  4779. + \
  4780. + _FP_DIV_MEAT_##fs(R,X,Y); \
  4781. + break; \
  4782. + \
  4783. + case _FP_CLS_COMBINE(FP_CLS_NAN,FP_CLS_NAN): \
  4784. + _FP_CHOOSENAN(fs, wc, R, X, Y, '/'); \
  4785. + break; \
  4786. + \
  4787. + case _FP_CLS_COMBINE(FP_CLS_NAN,FP_CLS_NORMAL): \
  4788. + case _FP_CLS_COMBINE(FP_CLS_NAN,FP_CLS_INF): \
  4789. + case _FP_CLS_COMBINE(FP_CLS_NAN,FP_CLS_ZERO): \
  4790. + R##_s = X##_s; \
  4791. + _FP_FRAC_COPY_##wc(R, X); \
  4792. + R##_c = X##_c; \
  4793. + break; \
  4794. + \
  4795. + case _FP_CLS_COMBINE(FP_CLS_NORMAL,FP_CLS_NAN): \
  4796. + case _FP_CLS_COMBINE(FP_CLS_INF,FP_CLS_NAN): \
  4797. + case _FP_CLS_COMBINE(FP_CLS_ZERO,FP_CLS_NAN): \
  4798. + R##_s = Y##_s; \
  4799. + _FP_FRAC_COPY_##wc(R, Y); \
  4800. + R##_c = Y##_c; \
  4801. + break; \
  4802. + \
  4803. + case _FP_CLS_COMBINE(FP_CLS_NORMAL,FP_CLS_INF): \
  4804. + case _FP_CLS_COMBINE(FP_CLS_ZERO,FP_CLS_INF): \
  4805. + case _FP_CLS_COMBINE(FP_CLS_ZERO,FP_CLS_NORMAL): \
  4806. + R##_c = FP_CLS_ZERO; \
  4807. + break; \
  4808. + \
  4809. + case _FP_CLS_COMBINE(FP_CLS_NORMAL,FP_CLS_ZERO): \
  4810. + FP_SET_EXCEPTION(FP_EX_DIVZERO); \
  4811. + case _FP_CLS_COMBINE(FP_CLS_INF,FP_CLS_ZERO): \
  4812. + case _FP_CLS_COMBINE(FP_CLS_INF,FP_CLS_NORMAL): \
  4813. + R##_c = FP_CLS_INF; \
  4814. + break; \
  4815. + \
  4816. + case _FP_CLS_COMBINE(FP_CLS_INF,FP_CLS_INF): \
  4817. + case _FP_CLS_COMBINE(FP_CLS_ZERO,FP_CLS_ZERO): \
  4818. + R##_s = _FP_NANSIGN_##fs; \
  4819. + R##_c = FP_CLS_NAN; \
  4820. + _FP_FRAC_SET_##wc(R, _FP_NANFRAC_##fs); \
  4821. + FP_SET_EXCEPTION(FP_EX_INVALID); \
  4822. + break; \
  4823. + \
  4824. + default: \
  4825. + abort(); \
  4826. + } \
  4827. +} while (0)
  4828. +
  4829. +
  4830. +/*
  4831. + * Main differential comparison routine. The inputs should be raw not
  4832. + * cooked. The return is -1,0,1 for normal values, 2 otherwise.
  4833. + */
  4834. +
  4835. +#define _FP_CMP(fs, wc, ret, X, Y, un) \
  4836. + do { \
  4837. + /* NANs are unordered */ \
  4838. + if ((X##_e == _FP_EXPMAX_##fs && !_FP_FRAC_ZEROP_##wc(X)) \
  4839. + || (Y##_e == _FP_EXPMAX_##fs && !_FP_FRAC_ZEROP_##wc(Y))) \
  4840. + { \
  4841. + ret = un; \
  4842. + } \
  4843. + else \
  4844. + { \
  4845. + int __is_zero_x; \
  4846. + int __is_zero_y; \
  4847. + \
  4848. + __is_zero_x = (!X##_e && _FP_FRAC_ZEROP_##wc(X)) ? 1 : 0; \
  4849. + __is_zero_y = (!Y##_e && _FP_FRAC_ZEROP_##wc(Y)) ? 1 : 0; \
  4850. + \
  4851. + if (__is_zero_x && __is_zero_y) \
  4852. + ret = 0; \
  4853. + else if (__is_zero_x) \
  4854. + ret = Y##_s ? 1 : -1; \
  4855. + else if (__is_zero_y) \
  4856. + ret = X##_s ? -1 : 1; \
  4857. + else if (X##_s != Y##_s) \
  4858. + ret = X##_s ? -1 : 1; \
  4859. + else if (X##_e > Y##_e) \
  4860. + ret = X##_s ? -1 : 1; \
  4861. + else if (X##_e < Y##_e) \
  4862. + ret = X##_s ? 1 : -1; \
  4863. + else if (_FP_FRAC_GT_##wc(X, Y)) \
  4864. + ret = X##_s ? -1 : 1; \
  4865. + else if (_FP_FRAC_GT_##wc(Y, X)) \
  4866. + ret = X##_s ? 1 : -1; \
  4867. + else \
  4868. + ret = 0; \
  4869. + } \
  4870. + } while (0)
  4871. +
  4872. +
  4873. +/* Simplification for strict equality. */
  4874. +
  4875. +#define _FP_CMP_EQ(fs, wc, ret, X, Y) \
  4876. + do { \
  4877. + /* NANs are unordered */ \
  4878. + if ((X##_e == _FP_EXPMAX_##fs && !_FP_FRAC_ZEROP_##wc(X)) \
  4879. + || (Y##_e == _FP_EXPMAX_##fs && !_FP_FRAC_ZEROP_##wc(Y))) \
  4880. + { \
  4881. + ret = 1; \
  4882. + } \
  4883. + else \
  4884. + { \
  4885. + ret = !(X##_e == Y##_e \
  4886. + && _FP_FRAC_EQ_##wc(X, Y) \
  4887. + && (X##_s == Y##_s || (!X##_e && _FP_FRAC_ZEROP_##wc(X)))); \
  4888. + } \
  4889. + } while (0)
  4890. +
  4891. +/* Version to test unordered. */
  4892. +
  4893. +#define _FP_CMP_UNORD(fs, wc, ret, X, Y) \
  4894. + do { \
  4895. + ret = ((X##_e == _FP_EXPMAX_##fs && !_FP_FRAC_ZEROP_##wc(X)) \
  4896. + || (Y##_e == _FP_EXPMAX_##fs && !_FP_FRAC_ZEROP_##wc(Y))); \
  4897. + } while (0)
  4898. +
  4899. +/*
  4900. + * Main square root routine. The input value should be cooked.
  4901. + */
  4902. +
  4903. +#define _FP_SQRT(fs, wc, R, X) \
  4904. +do { \
  4905. + _FP_FRAC_DECL_##wc(T); _FP_FRAC_DECL_##wc(S); \
  4906. + _FP_W_TYPE q; \
  4907. + switch (X##_c) \
  4908. + { \
  4909. + case FP_CLS_NAN: \
  4910. + _FP_FRAC_COPY_##wc(R, X); \
  4911. + R##_s = X##_s; \
  4912. + R##_c = FP_CLS_NAN; \
  4913. + break; \
  4914. + case FP_CLS_INF: \
  4915. + if (X##_s) \
  4916. + { \
  4917. + R##_s = _FP_NANSIGN_##fs; \
  4918. + R##_c = FP_CLS_NAN; /* NAN */ \
  4919. + _FP_FRAC_SET_##wc(R, _FP_NANFRAC_##fs); \
  4920. + FP_SET_EXCEPTION(FP_EX_INVALID); \
  4921. + } \
  4922. + else \
  4923. + { \
  4924. + R##_s = 0; \
  4925. + R##_c = FP_CLS_INF; /* sqrt(+inf) = +inf */ \
  4926. + } \
  4927. + break; \
  4928. + case FP_CLS_ZERO: \
  4929. + R##_s = X##_s; \
  4930. + R##_c = FP_CLS_ZERO; /* sqrt(+-0) = +-0 */ \
  4931. + break; \
  4932. + case FP_CLS_NORMAL: \
  4933. + R##_s = 0; \
  4934. + if (X##_s) \
  4935. + { \
  4936. + R##_c = FP_CLS_NAN; /* sNAN */ \
  4937. + R##_s = _FP_NANSIGN_##fs; \
  4938. + _FP_FRAC_SET_##wc(R, _FP_NANFRAC_##fs); \
  4939. + FP_SET_EXCEPTION(FP_EX_INVALID); \
  4940. + break; \
  4941. + } \
  4942. + R##_c = FP_CLS_NORMAL; \
  4943. + if (X##_e & 1) \
  4944. + _FP_FRAC_SLL_##wc(X, 1); \
  4945. + R##_e = X##_e >> 1; \
  4946. + _FP_FRAC_SET_##wc(S, _FP_ZEROFRAC_##wc); \
  4947. + _FP_FRAC_SET_##wc(R, _FP_ZEROFRAC_##wc); \
  4948. + q = _FP_OVERFLOW_##fs >> 1; \
  4949. + _FP_SQRT_MEAT_##wc(R, S, T, X, q); \
  4950. + } \
  4951. + } while (0)
  4952. +
  4953. +/*
  4954. + * Convert from FP to integer. Input is raw.
  4955. + */
  4956. +
  4957. +/* RSIGNED can have following values:
  4958. + * 0: the number is required to be 0..(2^rsize)-1, if not, NV is set plus
  4959. + * the result is either 0 or (2^rsize)-1 depending on the sign in such
  4960. + * case.
  4961. + * 1: the number is required to be -(2^(rsize-1))..(2^(rsize-1))-1, if not,
  4962. + * NV is set plus the result is either -(2^(rsize-1)) or (2^(rsize-1))-1
  4963. + * depending on the sign in such case.
  4964. + * -1: the number is required to be -(2^(rsize-1))..(2^rsize)-1, if not, NV is
  4965. + * set plus the result is either -(2^(rsize-1)) or (2^(rsize-1))-1
  4966. + * depending on the sign in such case.
  4967. + */
  4968. +#define _FP_TO_INT(fs, wc, r, X, rsize, rsigned) \
  4969. +do { \
  4970. + if (X##_e < _FP_EXPBIAS_##fs) \
  4971. + { \
  4972. + r = 0; \
  4973. + if (X##_e == 0) \
  4974. + { \
  4975. + if (!_FP_FRAC_ZEROP_##wc(X)) \
  4976. + { \
  4977. + FP_SET_EXCEPTION(FP_EX_INEXACT); \
  4978. + FP_SET_EXCEPTION(FP_EX_DENORM); \
  4979. + } \
  4980. + } \
  4981. + else \
  4982. + FP_SET_EXCEPTION(FP_EX_INEXACT); \
  4983. + } \
  4984. + else if (X##_e >= _FP_EXPBIAS_##fs + rsize - (rsigned > 0 || X##_s) \
  4985. + || (!rsigned && X##_s)) \
  4986. + { \
  4987. + /* Overflow or converting to the most negative integer. */ \
  4988. + if (rsigned) \
  4989. + { \
  4990. + r = 1; \
  4991. + r <<= rsize - 1; \
  4992. + r -= 1 - X##_s; \
  4993. + } else { \
  4994. + r = 0; \
  4995. + if (X##_s) \
  4996. + r = ~r; \
  4997. + } \
  4998. + \
  4999. + if (rsigned && X##_s && X##_e == _FP_EXPBIAS_##fs + rsize - 1) \
  5000. + { \
  5001. + /* Possibly converting to most negative integer; check the \
  5002. + mantissa. */ \
  5003. + int inexact = 0; \
  5004. + (void)((_FP_FRACBITS_##fs > rsize) \
  5005. + ? ({ _FP_FRAC_SRST_##wc(X, inexact, \
  5006. + _FP_FRACBITS_##fs - rsize, \
  5007. + _FP_FRACBITS_##fs); 0; }) \
  5008. + : 0); \
  5009. + if (!_FP_FRAC_ZEROP_##wc(X)) \
  5010. + FP_SET_EXCEPTION(FP_EX_INVALID); \
  5011. + else if (inexact) \
  5012. + FP_SET_EXCEPTION(FP_EX_INEXACT); \
  5013. + } \
  5014. + else \
  5015. + FP_SET_EXCEPTION(FP_EX_INVALID); \
  5016. + } \
  5017. + else \
  5018. + { \
  5019. + _FP_FRAC_HIGH_RAW_##fs(X) |= _FP_IMPLBIT_##fs; \
  5020. + if (X##_e >= _FP_EXPBIAS_##fs + _FP_FRACBITS_##fs - 1) \
  5021. + { \
  5022. + _FP_FRAC_ASSEMBLE_##wc(r, X, rsize); \
  5023. + r <<= X##_e - _FP_EXPBIAS_##fs - _FP_FRACBITS_##fs + 1; \
  5024. + } \
  5025. + else \
  5026. + { \
  5027. + int inexact; \
  5028. + _FP_FRAC_SRST_##wc(X, inexact, \
  5029. + (_FP_FRACBITS_##fs + _FP_EXPBIAS_##fs - 1 \
  5030. + - X##_e), \
  5031. + _FP_FRACBITS_##fs); \
  5032. + if (inexact) \
  5033. + FP_SET_EXCEPTION(FP_EX_INEXACT); \
  5034. + _FP_FRAC_ASSEMBLE_##wc(r, X, rsize); \
  5035. + } \
  5036. + if (rsigned && X##_s) \
  5037. + r = -r; \
  5038. + } \
  5039. +} while (0)
  5040. +
  5041. +/* Convert integer to fp. Output is raw. RTYPE is unsigned even if
  5042. + input is signed. */
  5043. +#define _FP_FROM_INT(fs, wc, X, r, rsize, rtype) \
  5044. + do { \
  5045. + if (r) \
  5046. + { \
  5047. + rtype ur_; \
  5048. + \
  5049. + if ((X##_s = (r < 0))) \
  5050. + r = -(rtype)r; \
  5051. + \
  5052. + ur_ = (rtype) r; \
  5053. + (void)((rsize <= _FP_W_TYPE_SIZE) \
  5054. + ? ({ \
  5055. + int lz_; \
  5056. + __FP_CLZ(lz_, (_FP_W_TYPE)ur_); \
  5057. + X##_e = _FP_EXPBIAS_##fs + _FP_W_TYPE_SIZE - 1 - lz_; \
  5058. + }) \
  5059. + : ((rsize <= 2 * _FP_W_TYPE_SIZE) \
  5060. + ? ({ \
  5061. + int lz_; \
  5062. + __FP_CLZ_2(lz_, (_FP_W_TYPE)(ur_ >> _FP_W_TYPE_SIZE), \
  5063. + (_FP_W_TYPE)ur_); \
  5064. + X##_e = (_FP_EXPBIAS_##fs + 2 * _FP_W_TYPE_SIZE - 1 \
  5065. + - lz_); \
  5066. + }) \
  5067. + : (abort(), 0))); \
  5068. + \
  5069. + if (rsize - 1 + _FP_EXPBIAS_##fs >= _FP_EXPMAX_##fs \
  5070. + && X##_e >= _FP_EXPMAX_##fs) \
  5071. + { \
  5072. + /* Exponent too big; overflow to infinity. (May also \
  5073. + happen after rounding below.) */ \
  5074. + _FP_OVERFLOW_SEMIRAW(fs, wc, X); \
  5075. + goto pack_semiraw; \
  5076. + } \
  5077. + \
  5078. + if (rsize <= _FP_FRACBITS_##fs \
  5079. + || X##_e < _FP_EXPBIAS_##fs + _FP_FRACBITS_##fs) \
  5080. + { \
  5081. + /* Exactly representable; shift left. */ \
  5082. + _FP_FRAC_DISASSEMBLE_##wc(X, ur_, rsize); \
  5083. + _FP_FRAC_SLL_##wc(X, (_FP_EXPBIAS_##fs \
  5084. + + _FP_FRACBITS_##fs - 1 - X##_e)); \
  5085. + } \
  5086. + else \
  5087. + { \
  5088. + /* More bits in integer than in floating type; need to \
  5089. + round. */ \
  5090. + if (_FP_EXPBIAS_##fs + _FP_WFRACBITS_##fs - 1 < X##_e) \
  5091. + ur_ = ((ur_ >> (X##_e - _FP_EXPBIAS_##fs \
  5092. + - _FP_WFRACBITS_##fs + 1)) \
  5093. + | ((ur_ << (rsize - (X##_e - _FP_EXPBIAS_##fs \
  5094. + - _FP_WFRACBITS_##fs + 1))) \
  5095. + != 0)); \
  5096. + _FP_FRAC_DISASSEMBLE_##wc(X, ur_, rsize); \
  5097. + if ((_FP_EXPBIAS_##fs + _FP_WFRACBITS_##fs - 1 - X##_e) > 0) \
  5098. + _FP_FRAC_SLL_##wc(X, (_FP_EXPBIAS_##fs \
  5099. + + _FP_WFRACBITS_##fs - 1 - X##_e)); \
  5100. + _FP_FRAC_HIGH_##fs(X) &= ~(_FP_W_TYPE)_FP_IMPLBIT_SH_##fs; \
  5101. + pack_semiraw: \
  5102. + _FP_PACK_SEMIRAW(fs, wc, X); \
  5103. + } \
  5104. + } \
  5105. + else \
  5106. + { \
  5107. + X##_s = 0; \
  5108. + X##_e = 0; \
  5109. + _FP_FRAC_SET_##wc(X, _FP_ZEROFRAC_##wc); \
  5110. + } \
  5111. + } while (0)
  5112. +
  5113. +
  5114. +/* Extend from a narrower floating-point format to a wider one. Input
  5115. + and output are raw. */
  5116. +#define FP_EXTEND(dfs,sfs,dwc,swc,D,S) \
  5117. +do { \
  5118. + if (_FP_FRACBITS_##dfs < _FP_FRACBITS_##sfs \
  5119. + || (_FP_EXPMAX_##dfs - _FP_EXPBIAS_##dfs \
  5120. + < _FP_EXPMAX_##sfs - _FP_EXPBIAS_##sfs) \
  5121. + || (_FP_EXPBIAS_##dfs < _FP_EXPBIAS_##sfs + _FP_FRACBITS_##sfs - 1 \
  5122. + && _FP_EXPBIAS_##dfs != _FP_EXPBIAS_##sfs)) \
  5123. + abort(); \
  5124. + D##_s = S##_s; \
  5125. + _FP_FRAC_COPY_##dwc##_##swc(D, S); \
  5126. + if (_FP_EXP_NORMAL(sfs, swc, S)) \
  5127. + { \
  5128. + D##_e = S##_e + _FP_EXPBIAS_##dfs - _FP_EXPBIAS_##sfs; \
  5129. + _FP_FRAC_SLL_##dwc(D, (_FP_FRACBITS_##dfs - _FP_FRACBITS_##sfs)); \
  5130. + } \
  5131. + else \
  5132. + { \
  5133. + if (S##_e == 0) \
  5134. + { \
  5135. + if (_FP_FRAC_ZEROP_##swc(S)) \
  5136. + D##_e = 0; \
  5137. + else if (_FP_EXPBIAS_##dfs \
  5138. + < _FP_EXPBIAS_##sfs + _FP_FRACBITS_##sfs - 1) \
  5139. + { \
  5140. + FP_SET_EXCEPTION(FP_EX_DENORM); \
  5141. + _FP_FRAC_SLL_##dwc(D, (_FP_FRACBITS_##dfs \
  5142. + - _FP_FRACBITS_##sfs)); \
  5143. + D##_e = 0; \
  5144. + } \
  5145. + else \
  5146. + { \
  5147. + int _lz; \
  5148. + FP_SET_EXCEPTION(FP_EX_DENORM); \
  5149. + _FP_FRAC_CLZ_##swc(_lz, S); \
  5150. + _FP_FRAC_SLL_##dwc(D, \
  5151. + _lz + _FP_FRACBITS_##dfs \
  5152. + - _FP_FRACTBITS_##sfs); \
  5153. + D##_e = (_FP_EXPBIAS_##dfs - _FP_EXPBIAS_##sfs + 1 \
  5154. + + _FP_FRACXBITS_##sfs - _lz); \
  5155. + } \
  5156. + } \
  5157. + else \
  5158. + { \
  5159. + D##_e = _FP_EXPMAX_##dfs; \
  5160. + if (!_FP_FRAC_ZEROP_##swc(S)) \
  5161. + { \
  5162. + if (!(_FP_FRAC_HIGH_RAW_##sfs(S) & _FP_QNANBIT_##sfs)) \
  5163. + FP_SET_EXCEPTION(FP_EX_INVALID); \
  5164. + _FP_FRAC_SLL_##dwc(D, (_FP_FRACBITS_##dfs \
  5165. + - _FP_FRACBITS_##sfs)); \
  5166. + } \
  5167. + } \
  5168. + } \
  5169. +} while (0)
  5170. +
  5171. +/* Truncate from a wider floating-point format to a narrower one.
  5172. + Input and output are semi-raw. */
  5173. +#define FP_TRUNC(dfs,sfs,dwc,swc,D,S) \
  5174. +do { \
  5175. + if (_FP_FRACBITS_##sfs < _FP_FRACBITS_##dfs \
  5176. + || (_FP_EXPBIAS_##sfs < _FP_EXPBIAS_##dfs + _FP_FRACBITS_##dfs - 1 \
  5177. + && _FP_EXPBIAS_##sfs != _FP_EXPBIAS_##dfs)) \
  5178. + abort(); \
  5179. + D##_s = S##_s; \
  5180. + if (_FP_EXP_NORMAL(sfs, swc, S)) \
  5181. + { \
  5182. + D##_e = S##_e + _FP_EXPBIAS_##dfs - _FP_EXPBIAS_##sfs; \
  5183. + if (D##_e >= _FP_EXPMAX_##dfs) \
  5184. + _FP_OVERFLOW_SEMIRAW(dfs, dwc, D); \
  5185. + else \
  5186. + { \
  5187. + if (D##_e <= 0) \
  5188. + { \
  5189. + if (D##_e < 1 - _FP_FRACBITS_##dfs) \
  5190. + { \
  5191. + _FP_FRAC_SET_##swc(S, _FP_ZEROFRAC_##swc); \
  5192. + _FP_FRAC_LOW_##swc(S) |= 1; \
  5193. + } \
  5194. + else \
  5195. + { \
  5196. + _FP_FRAC_HIGH_##sfs(S) |= _FP_IMPLBIT_SH_##sfs; \
  5197. + _FP_FRAC_SRS_##swc(S, (_FP_WFRACBITS_##sfs \
  5198. + - _FP_WFRACBITS_##dfs + 1 - D##_e), \
  5199. + _FP_WFRACBITS_##sfs); \
  5200. + } \
  5201. + D##_e = 0; \
  5202. + } \
  5203. + else \
  5204. + _FP_FRAC_SRS_##swc(S, (_FP_WFRACBITS_##sfs \
  5205. + - _FP_WFRACBITS_##dfs), \
  5206. + _FP_WFRACBITS_##sfs); \
  5207. + _FP_FRAC_COPY_##dwc##_##swc(D, S); \
  5208. + } \
  5209. + } \
  5210. + else \
  5211. + { \
  5212. + if (S##_e == 0) \
  5213. + { \
  5214. + D##_e = 0; \
  5215. + if (_FP_FRAC_ZEROP_##swc(S)) \
  5216. + _FP_FRAC_SET_##dwc(D, _FP_ZEROFRAC_##dwc); \
  5217. + else \
  5218. + { \
  5219. + FP_SET_EXCEPTION(FP_EX_DENORM); \
  5220. + if (_FP_EXPBIAS_##sfs \
  5221. + < _FP_EXPBIAS_##dfs + _FP_FRACBITS_##dfs - 1) \
  5222. + { \
  5223. + _FP_FRAC_SRS_##swc(S, (_FP_WFRACBITS_##sfs \
  5224. + - _FP_WFRACBITS_##dfs), \
  5225. + _FP_WFRACBITS_##sfs); \
  5226. + _FP_FRAC_COPY_##dwc##_##swc(D, S); \
  5227. + } \
  5228. + else \
  5229. + { \
  5230. + _FP_FRAC_SET_##dwc(D, _FP_ZEROFRAC_##dwc); \
  5231. + _FP_FRAC_LOW_##dwc(D) |= 1; \
  5232. + } \
  5233. + } \
  5234. + } \
  5235. + else \
  5236. + { \
  5237. + D##_e = _FP_EXPMAX_##dfs; \
  5238. + if (_FP_FRAC_ZEROP_##swc(S)) \
  5239. + _FP_FRAC_SET_##dwc(D, _FP_ZEROFRAC_##dwc); \
  5240. + else \
  5241. + { \
  5242. + _FP_CHECK_SIGNAN_SEMIRAW(sfs, swc, S); \
  5243. + _FP_FRAC_SRL_##swc(S, (_FP_WFRACBITS_##sfs \
  5244. + - _FP_WFRACBITS_##dfs)); \
  5245. + _FP_FRAC_COPY_##dwc##_##swc(D, S); \
  5246. + /* Semi-raw NaN must have all workbits cleared. */ \
  5247. + _FP_FRAC_LOW_##dwc(D) \
  5248. + &= ~(_FP_W_TYPE) ((1 << _FP_WORKBITS) - 1); \
  5249. + _FP_FRAC_HIGH_##dfs(D) |= _FP_QNANBIT_SH_##dfs; \
  5250. + } \
  5251. + } \
  5252. + } \
  5253. +} while (0)
  5254. +
  5255. +/*
  5256. + * Helper primitives.
  5257. + */
  5258. +
  5259. +/* Count leading zeros in a word. */
  5260. +
  5261. +#ifndef __FP_CLZ
  5262. +/* GCC 3.4 and later provide the builtins for us. */
  5263. +#define __FP_CLZ(r, x) \
  5264. + do { \
  5265. + if (sizeof (_FP_W_TYPE) == sizeof (unsigned int)) \
  5266. + r = __builtin_clz (x); \
  5267. + else if (sizeof (_FP_W_TYPE) == sizeof (unsigned long)) \
  5268. + r = __builtin_clzl (x); \
  5269. + else if (sizeof (_FP_W_TYPE) == sizeof (unsigned long long)) \
  5270. + r = __builtin_clzll (x); \
  5271. + else \
  5272. + abort (); \
  5273. + } while (0)
  5274. +#endif /* ndef __FP_CLZ */
  5275. +
  5276. +#define _FP_DIV_HELP_imm(q, r, n, d) \
  5277. + do { \
  5278. + q = n / d, r = n % d; \
  5279. + } while (0)
  5280. +
  5281. +
  5282. +/* A restoring bit-by-bit division primitive. */
  5283. +
  5284. +#define _FP_DIV_MEAT_N_loop(fs, wc, R, X, Y) \
  5285. + do { \
  5286. + int count = _FP_WFRACBITS_##fs; \
  5287. + _FP_FRAC_DECL_##wc (u); \
  5288. + _FP_FRAC_DECL_##wc (v); \
  5289. + _FP_FRAC_COPY_##wc (u, X); \
  5290. + _FP_FRAC_COPY_##wc (v, Y); \
  5291. + _FP_FRAC_SET_##wc (R, _FP_ZEROFRAC_##wc); \
  5292. + /* Normalize U and V. */ \
  5293. + _FP_FRAC_SLL_##wc (u, _FP_WFRACXBITS_##fs); \
  5294. + _FP_FRAC_SLL_##wc (v, _FP_WFRACXBITS_##fs); \
  5295. + /* First round. Since the operands are normalized, either the \
  5296. + first or second bit will be set in the fraction. Produce a \
  5297. + normalized result by checking which and adjusting the loop \
  5298. + count and exponent accordingly. */ \
  5299. + if (_FP_FRAC_GE_1 (u, v)) \
  5300. + { \
  5301. + _FP_FRAC_SUB_##wc (u, u, v); \
  5302. + _FP_FRAC_LOW_##wc (R) |= 1; \
  5303. + count--; \
  5304. + } \
  5305. + else \
  5306. + R##_e--; \
  5307. + /* Subsequent rounds. */ \
  5308. + do { \
  5309. + int msb = (_FP_WS_TYPE) _FP_FRAC_HIGH_##wc (u) < 0; \
  5310. + _FP_FRAC_SLL_##wc (u, 1); \
  5311. + _FP_FRAC_SLL_##wc (R, 1); \
  5312. + if (msb || _FP_FRAC_GE_1 (u, v)) \
  5313. + { \
  5314. + _FP_FRAC_SUB_##wc (u, u, v); \
  5315. + _FP_FRAC_LOW_##wc (R) |= 1; \
  5316. + } \
  5317. + } while (--count > 0); \
  5318. + /* If there's anything left in U, the result is inexact. */ \
  5319. + _FP_FRAC_LOW_##wc (R) |= !_FP_FRAC_ZEROP_##wc (u); \
  5320. + } while (0)
  5321. +
  5322. +#define _FP_DIV_MEAT_1_loop(fs, R, X, Y) _FP_DIV_MEAT_N_loop (fs, 1, R, X, Y)
  5323. +#define _FP_DIV_MEAT_2_loop(fs, R, X, Y) _FP_DIV_MEAT_N_loop (fs, 2, R, X, Y)
  5324. +#define _FP_DIV_MEAT_4_loop(fs, R, X, Y) _FP_DIV_MEAT_N_loop (fs, 4, R, X, Y)
  5325. diff -Naur uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_add.c uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_add.c
  5326. --- uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_add.c 1970-01-01 01:00:00.000000000 +0100
  5327. +++ uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_add.c 2010-10-14 14:05:37.000000000 +0200
  5328. @@ -0,0 +1,39 @@
  5329. +/* Software floating-point emulation.
  5330. + Return a + b
  5331. + Copyright (C) 1997,1999,2006 Free Software Foundation, Inc.
  5332. + This file is part of the GNU C Library.
  5333. + Contributed by Richard Henderson (rth@cygnus.com) and
  5334. + Jakub Jelinek (jj@ultra.linux.cz).
  5335. +
  5336. + The GNU C Library is free software; you can redistribute it and/or
  5337. + modify it under the terms of the GNU Lesser General Public
  5338. + License as published by the Free Software Foundation; either
  5339. + version 2.1 of the License, or (at your option) any later version.
  5340. +
  5341. + The GNU C Library is distributed in the hope that it will be useful,
  5342. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  5343. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  5344. + Lesser General Public License for more details.
  5345. +
  5346. + You should have received a copy of the GNU Lesser General Public
  5347. + License along with the GNU C Library; if not, write to the Free
  5348. + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  5349. + 02111-1307 USA. */
  5350. +
  5351. +#include "soft-fp.h"
  5352. +#include "quad.h"
  5353. +
  5354. +long double _Q_add(const long double a, const long double b)
  5355. +{
  5356. + FP_DECL_EX;
  5357. + FP_DECL_Q(A); FP_DECL_Q(B); FP_DECL_Q(C);
  5358. + long double c;
  5359. +
  5360. + FP_INIT_ROUNDMODE;
  5361. + FP_UNPACK_SEMIRAW_Q(A, a);
  5362. + FP_UNPACK_SEMIRAW_Q(B, b);
  5363. + FP_ADD_Q(C, A, B);
  5364. + FP_PACK_SEMIRAW_Q(c, C);
  5365. + FP_HANDLE_EXCEPTIONS;
  5366. + return c;
  5367. +}
  5368. diff -Naur uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_cmp.c uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_cmp.c
  5369. --- uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_cmp.c 1970-01-01 01:00:00.000000000 +0100
  5370. +++ uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_cmp.c 2010-10-14 14:05:37.000000000 +0200
  5371. @@ -0,0 +1,41 @@
  5372. +/* Software floating-point emulation.
  5373. + Compare a and b, return float condition code.
  5374. + Copyright (C) 1997,1999 Free Software Foundation, Inc.
  5375. + This file is part of the GNU C Library.
  5376. + Contributed by Richard Henderson (rth@cygnus.com) and
  5377. + Jakub Jelinek (jj@ultra.linux.cz).
  5378. +
  5379. + The GNU C Library is free software; you can redistribute it and/or
  5380. + modify it under the terms of the GNU Lesser General Public
  5381. + License as published by the Free Software Foundation; either
  5382. + version 2.1 of the License, or (at your option) any later version.
  5383. +
  5384. + The GNU C Library is distributed in the hope that it will be useful,
  5385. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  5386. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  5387. + Lesser General Public License for more details.
  5388. +
  5389. + You should have received a copy of the GNU Lesser General Public
  5390. + License along with the GNU C Library; if not, write to the Free
  5391. + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  5392. + 02111-1307 USA. */
  5393. +
  5394. +#include "soft-fp.h"
  5395. +#include "quad.h"
  5396. +
  5397. +int _Q_cmp(const long double a, const long double b)
  5398. +{
  5399. + FP_DECL_EX;
  5400. + FP_DECL_Q(A); FP_DECL_Q(B);
  5401. + int r;
  5402. +
  5403. + FP_UNPACK_RAW_Q(A, a);
  5404. + FP_UNPACK_RAW_Q(B, b);
  5405. + FP_CMP_Q(r, B, A, 3);
  5406. + if (r == -1) r = 2;
  5407. + if (r == 3 && (FP_ISSIGNAN_Q(A) || FP_ISSIGNAN_Q(B)))
  5408. + FP_SET_EXCEPTION(FP_EX_INVALID);
  5409. + FP_HANDLE_EXCEPTIONS;
  5410. +
  5411. + return r;
  5412. +}
  5413. diff -Naur uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_cmpe.c uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_cmpe.c
  5414. --- uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_cmpe.c 1970-01-01 01:00:00.000000000 +0100
  5415. +++ uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_cmpe.c 2010-10-14 14:05:37.000000000 +0200
  5416. @@ -0,0 +1,42 @@
  5417. +/* Software floating-point emulation.
  5418. + Compare a and b, return float condition code.
  5419. + Signal exception (unless masked) if unordered.
  5420. + Copyright (C) 1997,1999 Free Software Foundation, Inc.
  5421. + This file is part of the GNU C Library.
  5422. + Contributed by Richard Henderson (rth@cygnus.com) and
  5423. + Jakub Jelinek (jj@ultra.linux.cz).
  5424. +
  5425. + The GNU C Library is free software; you can redistribute it and/or
  5426. + modify it under the terms of the GNU Lesser General Public
  5427. + License as published by the Free Software Foundation; either
  5428. + version 2.1 of the License, or (at your option) any later version.
  5429. +
  5430. + The GNU C Library is distributed in the hope that it will be useful,
  5431. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  5432. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  5433. + Lesser General Public License for more details.
  5434. +
  5435. + You should have received a copy of the GNU Lesser General Public
  5436. + License along with the GNU C Library; if not, write to the Free
  5437. + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  5438. + 02111-1307 USA. */
  5439. +
  5440. +#include "soft-fp.h"
  5441. +#include "quad.h"
  5442. +
  5443. +int _Q_cmpe(const long double a, const long double b)
  5444. +{
  5445. + FP_DECL_EX;
  5446. + FP_DECL_Q(A); FP_DECL_Q(B);
  5447. + int r;
  5448. +
  5449. + FP_UNPACK_RAW_Q(A, a);
  5450. + FP_UNPACK_RAW_Q(B, b);
  5451. + FP_CMP_Q(r, B, A, 3);
  5452. + if (r == -1) r = 2;
  5453. + if (r == 3)
  5454. + FP_SET_EXCEPTION(FP_EX_INVALID);
  5455. + FP_HANDLE_EXCEPTIONS;
  5456. +
  5457. + return r;
  5458. +}
  5459. diff -Naur uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_div.c uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_div.c
  5460. --- uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_div.c 1970-01-01 01:00:00.000000000 +0100
  5461. +++ uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_div.c 2010-10-14 14:05:37.000000000 +0200
  5462. @@ -0,0 +1,39 @@
  5463. +/* Software floating-point emulation.
  5464. + Return a / b
  5465. + Copyright (C) 1997, 1999, 2006 Free Software Foundation, Inc.
  5466. + This file is part of the GNU C Library.
  5467. + Contributed by Richard Henderson (rth@cygnus.com) and
  5468. + Jakub Jelinek (jj@ultra.linux.cz).
  5469. +
  5470. + The GNU C Library is free software; you can redistribute it and/or
  5471. + modify it under the terms of the GNU Lesser General Public
  5472. + License as published by the Free Software Foundation; either
  5473. + version 2.1 of the License, or (at your option) any later version.
  5474. +
  5475. + The GNU C Library is distributed in the hope that it will be useful,
  5476. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  5477. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  5478. + Lesser General Public License for more details.
  5479. +
  5480. + You should have received a copy of the GNU Lesser General Public
  5481. + License along with the GNU C Library; if not, write to the Free
  5482. + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  5483. + 02111-1307 USA. */
  5484. +
  5485. +#include "soft-fp.h"
  5486. +#include "quad.h"
  5487. +
  5488. +long double _Q_div(const long double a, const long double b)
  5489. +{
  5490. + FP_DECL_EX;
  5491. + FP_DECL_Q(A); FP_DECL_Q(B); FP_DECL_Q(C);
  5492. + long double c;
  5493. +
  5494. + FP_INIT_ROUNDMODE;
  5495. + FP_UNPACK_Q(A, a);
  5496. + FP_UNPACK_Q(B, b);
  5497. + FP_DIV_Q(C, A, B);
  5498. + FP_PACK_Q(c, C);
  5499. + FP_HANDLE_EXCEPTIONS;
  5500. + return c;
  5501. +}
  5502. diff -Naur uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_dtoq.c uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_dtoq.c
  5503. --- uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_dtoq.c 1970-01-01 01:00:00.000000000 +0100
  5504. +++ uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_dtoq.c 2010-10-14 14:05:37.000000000 +0200
  5505. @@ -0,0 +1,44 @@
  5506. +/* Software floating-point emulation.
  5507. + Return (long double)(a)
  5508. + Copyright (C) 1997,1999,2006 Free Software Foundation, Inc.
  5509. + This file is part of the GNU C Library.
  5510. + Contributed by Richard Henderson (rth@cygnus.com) and
  5511. + Jakub Jelinek (jj@ultra.linux.cz).
  5512. +
  5513. + The GNU C Library is free software; you can redistribute it and/or
  5514. + modify it under the terms of the GNU Lesser General Public
  5515. + License as published by the Free Software Foundation; either
  5516. + version 2.1 of the License, or (at your option) any later version.
  5517. +
  5518. + The GNU C Library is distributed in the hope that it will be useful,
  5519. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  5520. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  5521. + Lesser General Public License for more details.
  5522. +
  5523. + You should have received a copy of the GNU Lesser General Public
  5524. + License along with the GNU C Library; if not, write to the Free
  5525. + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  5526. + 02111-1307 USA. */
  5527. +
  5528. +#include "soft-fp.h"
  5529. +#include "double.h"
  5530. +#include "quad.h"
  5531. +
  5532. +long double _Q_dtoq(const double a)
  5533. +{
  5534. + FP_DECL_EX;
  5535. + FP_DECL_D(A);
  5536. + FP_DECL_Q(C);
  5537. + long double c;
  5538. +
  5539. + FP_INIT_ROUNDMODE;
  5540. + FP_UNPACK_RAW_D(A, a);
  5541. +#if (2 * _FP_W_TYPE_SIZE) < _FP_FRACBITS_Q
  5542. + FP_EXTEND(Q,D,4,2,C,A);
  5543. +#else
  5544. + FP_EXTEND(Q,D,2,1,C,A);
  5545. +#endif
  5546. + FP_PACK_RAW_Q(c, C);
  5547. + FP_HANDLE_EXCEPTIONS;
  5548. + return c;
  5549. +}
  5550. diff -Naur uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_feq.c uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_feq.c
  5551. --- uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_feq.c 1970-01-01 01:00:00.000000000 +0100
  5552. +++ uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_feq.c 2010-10-14 14:05:37.000000000 +0200
  5553. @@ -0,0 +1,40 @@
  5554. +/* Software floating-point emulation.
  5555. + Return 1 if a == b
  5556. + Copyright (C) 1997,1999 Free Software Foundation, Inc.
  5557. + This file is part of the GNU C Library.
  5558. + Contributed by Richard Henderson (rth@cygnus.com) and
  5559. + Jakub Jelinek (jj@ultra.linux.cz).
  5560. +
  5561. + The GNU C Library is free software; you can redistribute it and/or
  5562. + modify it under the terms of the GNU Lesser General Public
  5563. + License as published by the Free Software Foundation; either
  5564. + version 2.1 of the License, or (at your option) any later version.
  5565. +
  5566. + The GNU C Library is distributed in the hope that it will be useful,
  5567. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  5568. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  5569. + Lesser General Public License for more details.
  5570. +
  5571. + You should have received a copy of the GNU Lesser General Public
  5572. + License along with the GNU C Library; if not, write to the Free
  5573. + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  5574. + 02111-1307 USA. */
  5575. +
  5576. +#include "soft-fp.h"
  5577. +#include "quad.h"
  5578. +
  5579. +int _Q_feq(const long double a, const long double b)
  5580. +{
  5581. + FP_DECL_EX;
  5582. + FP_DECL_Q(A); FP_DECL_Q(B);
  5583. + int r;
  5584. +
  5585. + FP_UNPACK_RAW_Q(A, a);
  5586. + FP_UNPACK_RAW_Q(B, b);
  5587. + FP_CMP_EQ_Q(r, A, B);
  5588. + if (r && (FP_ISSIGNAN_Q(A) || FP_ISSIGNAN_Q(B)))
  5589. + FP_SET_EXCEPTION(FP_EX_INVALID);
  5590. + FP_HANDLE_EXCEPTIONS;
  5591. +
  5592. + return !r;
  5593. +}
  5594. diff -Naur uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_fge.c uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_fge.c
  5595. --- uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_fge.c 1970-01-01 01:00:00.000000000 +0100
  5596. +++ uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_fge.c 2010-10-14 14:05:37.000000000 +0200
  5597. @@ -0,0 +1,40 @@
  5598. +/* Software floating-point emulation.
  5599. + Return 1 if a >= b
  5600. + Copyright (C) 1997,1999 Free Software Foundation, Inc.
  5601. + This file is part of the GNU C Library.
  5602. + Contributed by Richard Henderson (rth@cygnus.com) and
  5603. + Jakub Jelinek (jj@ultra.linux.cz).
  5604. +
  5605. + The GNU C Library is free software; you can redistribute it and/or
  5606. + modify it under the terms of the GNU Lesser General Public
  5607. + License as published by the Free Software Foundation; either
  5608. + version 2.1 of the License, or (at your option) any later version.
  5609. +
  5610. + The GNU C Library is distributed in the hope that it will be useful,
  5611. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  5612. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  5613. + Lesser General Public License for more details.
  5614. +
  5615. + You should have received a copy of the GNU Lesser General Public
  5616. + License along with the GNU C Library; if not, write to the Free
  5617. + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  5618. + 02111-1307 USA. */
  5619. +
  5620. +#include "soft-fp.h"
  5621. +#include "quad.h"
  5622. +
  5623. +int _Q_fge(const long double a, const long double b)
  5624. +{
  5625. + FP_DECL_EX;
  5626. + FP_DECL_Q(A); FP_DECL_Q(B);
  5627. + int r;
  5628. +
  5629. + FP_UNPACK_RAW_Q(A, a);
  5630. + FP_UNPACK_RAW_Q(B, b);
  5631. + FP_CMP_Q(r, B, A, 3);
  5632. + if (r == 3)
  5633. + FP_SET_EXCEPTION(FP_EX_INVALID);
  5634. + FP_HANDLE_EXCEPTIONS;
  5635. +
  5636. + return (r <= 0);
  5637. +}
  5638. diff -Naur uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_fgt.c uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_fgt.c
  5639. --- uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_fgt.c 1970-01-01 01:00:00.000000000 +0100
  5640. +++ uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_fgt.c 2010-10-14 14:05:37.000000000 +0200
  5641. @@ -0,0 +1,40 @@
  5642. +/* Software floating-point emulation.
  5643. + Return 1 if a > b
  5644. + Copyright (C) 1997,1999 Free Software Foundation, Inc.
  5645. + This file is part of the GNU C Library.
  5646. + Contributed by Richard Henderson (rth@cygnus.com) and
  5647. + Jakub Jelinek (jj@ultra.linux.cz).
  5648. +
  5649. + The GNU C Library is free software; you can redistribute it and/or
  5650. + modify it under the terms of the GNU Lesser General Public
  5651. + License as published by the Free Software Foundation; either
  5652. + version 2.1 of the License, or (at your option) any later version.
  5653. +
  5654. + The GNU C Library is distributed in the hope that it will be useful,
  5655. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  5656. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  5657. + Lesser General Public License for more details.
  5658. +
  5659. + You should have received a copy of the GNU Lesser General Public
  5660. + License along with the GNU C Library; if not, write to the Free
  5661. + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  5662. + 02111-1307 USA. */
  5663. +
  5664. +#include "soft-fp.h"
  5665. +#include "quad.h"
  5666. +
  5667. +int _Q_fgt(const long double a, const long double b)
  5668. +{
  5669. + FP_DECL_EX;
  5670. + FP_DECL_Q(A); FP_DECL_Q(B);
  5671. + int r;
  5672. +
  5673. + FP_UNPACK_RAW_Q(A, a);
  5674. + FP_UNPACK_RAW_Q(B, b);
  5675. + FP_CMP_Q(r, B, A, 3);
  5676. + if (r == 3)
  5677. + FP_SET_EXCEPTION(FP_EX_INVALID);
  5678. + FP_HANDLE_EXCEPTIONS;
  5679. +
  5680. + return (r == -1);
  5681. +}
  5682. diff -Naur uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_fle.c uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_fle.c
  5683. --- uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_fle.c 1970-01-01 01:00:00.000000000 +0100
  5684. +++ uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_fle.c 2010-10-14 14:05:37.000000000 +0200
  5685. @@ -0,0 +1,40 @@
  5686. +/* Software floating-point emulation.
  5687. + Return 1 if a <= b
  5688. + Copyright (C) 1997,1999 Free Software Foundation, Inc.
  5689. + This file is part of the GNU C Library.
  5690. + Contributed by Richard Henderson (rth@cygnus.com) and
  5691. + Jakub Jelinek (jj@ultra.linux.cz).
  5692. +
  5693. + The GNU C Library is free software; you can redistribute it and/or
  5694. + modify it under the terms of the GNU Lesser General Public
  5695. + License as published by the Free Software Foundation; either
  5696. + version 2.1 of the License, or (at your option) any later version.
  5697. +
  5698. + The GNU C Library is distributed in the hope that it will be useful,
  5699. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  5700. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  5701. + Lesser General Public License for more details.
  5702. +
  5703. + You should have received a copy of the GNU Lesser General Public
  5704. + License along with the GNU C Library; if not, write to the Free
  5705. + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  5706. + 02111-1307 USA. */
  5707. +
  5708. +#include "soft-fp.h"
  5709. +#include "quad.h"
  5710. +
  5711. +int _Q_fle(const long double a, const long double b)
  5712. +{
  5713. + FP_DECL_EX;
  5714. + FP_DECL_Q(A); FP_DECL_Q(B);
  5715. + int r;
  5716. +
  5717. + FP_UNPACK_RAW_Q(A, a);
  5718. + FP_UNPACK_RAW_Q(B, b);
  5719. + FP_CMP_Q(r, B, A, -2);
  5720. + if (r == -2)
  5721. + FP_SET_EXCEPTION(FP_EX_INVALID);
  5722. + FP_HANDLE_EXCEPTIONS;
  5723. +
  5724. + return (r >= 0);
  5725. +}
  5726. diff -Naur uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_flt.c uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_flt.c
  5727. --- uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_flt.c 1970-01-01 01:00:00.000000000 +0100
  5728. +++ uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_flt.c 2010-10-14 14:05:37.000000000 +0200
  5729. @@ -0,0 +1,40 @@
  5730. +/* Software floating-point emulation.
  5731. + Return 1 if a < b
  5732. + Copyright (C) 1997,1999 Free Software Foundation, Inc.
  5733. + This file is part of the GNU C Library.
  5734. + Contributed by Richard Henderson (rth@cygnus.com) and
  5735. + Jakub Jelinek (jj@ultra.linux.cz).
  5736. +
  5737. + The GNU C Library is free software; you can redistribute it and/or
  5738. + modify it under the terms of the GNU Lesser General Public
  5739. + License as published by the Free Software Foundation; either
  5740. + version 2.1 of the License, or (at your option) any later version.
  5741. +
  5742. + The GNU C Library is distributed in the hope that it will be useful,
  5743. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  5744. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  5745. + Lesser General Public License for more details.
  5746. +
  5747. + You should have received a copy of the GNU Lesser General Public
  5748. + License along with the GNU C Library; if not, write to the Free
  5749. + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  5750. + 02111-1307 USA. */
  5751. +
  5752. +#include "soft-fp.h"
  5753. +#include "quad.h"
  5754. +
  5755. +int _Q_flt(const long double a, const long double b)
  5756. +{
  5757. + FP_DECL_EX;
  5758. + FP_DECL_Q(A); FP_DECL_Q(B);
  5759. + int r;
  5760. +
  5761. + FP_UNPACK_RAW_Q(A, a);
  5762. + FP_UNPACK_RAW_Q(B, b);
  5763. + FP_CMP_Q(r, B, A, 3);
  5764. + if (r == 3)
  5765. + FP_SET_EXCEPTION(FP_EX_INVALID);
  5766. + FP_HANDLE_EXCEPTIONS;
  5767. +
  5768. + return (r == 1);
  5769. +}
  5770. diff -Naur uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_fne.c uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_fne.c
  5771. --- uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_fne.c 1970-01-01 01:00:00.000000000 +0100
  5772. +++ uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_fne.c 2010-10-14 14:05:37.000000000 +0200
  5773. @@ -0,0 +1,40 @@
  5774. +/* Software floating-point emulation.
  5775. + Return 1 if a != b
  5776. + Copyright (C) 1997,1999 Free Software Foundation, Inc.
  5777. + This file is part of the GNU C Library.
  5778. + Contributed by Richard Henderson (rth@cygnus.com) and
  5779. + Jakub Jelinek (jj@ultra.linux.cz).
  5780. +
  5781. + The GNU C Library is free software; you can redistribute it and/or
  5782. + modify it under the terms of the GNU Lesser General Public
  5783. + License as published by the Free Software Foundation; either
  5784. + version 2.1 of the License, or (at your option) any later version.
  5785. +
  5786. + The GNU C Library is distributed in the hope that it will be useful,
  5787. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  5788. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  5789. + Lesser General Public License for more details.
  5790. +
  5791. + You should have received a copy of the GNU Lesser General Public
  5792. + License along with the GNU C Library; if not, write to the Free
  5793. + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  5794. + 02111-1307 USA. */
  5795. +
  5796. +#include "soft-fp.h"
  5797. +#include "quad.h"
  5798. +
  5799. +int _Q_fne(const long double a, const long double b)
  5800. +{
  5801. + FP_DECL_EX;
  5802. + FP_DECL_Q(A); FP_DECL_Q(B);
  5803. + int r;
  5804. +
  5805. + FP_UNPACK_RAW_Q(A, a);
  5806. + FP_UNPACK_RAW_Q(B, b);
  5807. + FP_CMP_EQ_Q(r, A, B);
  5808. + if (r && (FP_ISSIGNAN_Q(A) || FP_ISSIGNAN_Q(B)))
  5809. + FP_SET_EXCEPTION(FP_EX_INVALID);
  5810. + FP_HANDLE_EXCEPTIONS;
  5811. +
  5812. + return r;
  5813. +}
  5814. diff -Naur uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_itoq.c uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_itoq.c
  5815. --- uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_itoq.c 1970-01-01 01:00:00.000000000 +0100
  5816. +++ uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_itoq.c 2010-10-14 14:05:37.000000000 +0200
  5817. @@ -0,0 +1,38 @@
  5818. +/* Software floating-point emulation.
  5819. + Return (long double)(a)
  5820. + Copyright (C) 1997,1999,2006 Free Software Foundation, Inc.
  5821. + This file is part of the GNU C Library.
  5822. + Contributed by Richard Henderson (rth@cygnus.com) and
  5823. + Jakub Jelinek (jj@ultra.linux.cz).
  5824. +
  5825. + The GNU C Library is free software; you can redistribute it and/or
  5826. + modify it under the terms of the GNU Lesser General Public
  5827. + License as published by the Free Software Foundation; either
  5828. + version 2.1 of the License, or (at your option) any later version.
  5829. +
  5830. + The GNU C Library is distributed in the hope that it will be useful,
  5831. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  5832. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  5833. + Lesser General Public License for more details.
  5834. +
  5835. + You should have received a copy of the GNU Lesser General Public
  5836. + License along with the GNU C Library; if not, write to the Free
  5837. + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  5838. + 02111-1307 USA. */
  5839. +
  5840. +#include "soft-fp.h"
  5841. +#include "quad.h"
  5842. +
  5843. +long double _Q_itoq(const int a)
  5844. +{
  5845. + FP_DECL_EX;
  5846. + FP_DECL_Q(C);
  5847. + int b = a;
  5848. + long double c;
  5849. +
  5850. + FP_FROM_INT_Q(C, b, 32, unsigned int);
  5851. + FP_PACK_RAW_Q(c, C);
  5852. + FP_CLEAR_EXCEPTIONS;
  5853. + FP_HANDLE_EXCEPTIONS;
  5854. + return c;
  5855. +}
  5856. diff -Naur uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_lltoq.c uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_lltoq.c
  5857. --- uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_lltoq.c 1970-01-01 01:00:00.000000000 +0100
  5858. +++ uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_lltoq.c 2010-10-14 14:05:37.000000000 +0200
  5859. @@ -0,0 +1,38 @@
  5860. +/* Software floating-point emulation.
  5861. + Return (long double)a
  5862. + Copyright (C) 1997, 1999, 2006 Free Software Foundation, Inc.
  5863. + This file is part of the GNU C Library.
  5864. + Contributed by Richard Henderson (rth@cygnus.com) and
  5865. + Jakub Jelinek (jj@ultra.linux.cz).
  5866. +
  5867. + The GNU C Library is free software; you can redistribute it and/or
  5868. + modify it under the terms of the GNU Lesser General Public
  5869. + License as published by the Free Software Foundation; either
  5870. + version 2.1 of the License, or (at your option) any later version.
  5871. +
  5872. + The GNU C Library is distributed in the hope that it will be useful,
  5873. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  5874. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  5875. + Lesser General Public License for more details.
  5876. +
  5877. + You should have received a copy of the GNU Lesser General Public
  5878. + License along with the GNU C Library; if not, write to the Free
  5879. + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  5880. + 02111-1307 USA. */
  5881. +
  5882. +#include "soft-fp.h"
  5883. +#include "quad.h"
  5884. +
  5885. +long double _Q_lltoq(const long long a)
  5886. +{
  5887. + FP_DECL_EX;
  5888. + FP_DECL_Q(C);
  5889. + long double c;
  5890. + long long b = a;
  5891. +
  5892. + FP_FROM_INT_Q(C, b, 64, unsigned long long);
  5893. + FP_PACK_RAW_Q(c, C);
  5894. + FP_CLEAR_EXCEPTIONS;
  5895. + FP_HANDLE_EXCEPTIONS;
  5896. + return c;
  5897. +}
  5898. diff -Naur uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_mul.c uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_mul.c
  5899. --- uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_mul.c 1970-01-01 01:00:00.000000000 +0100
  5900. +++ uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_mul.c 2010-10-14 14:05:37.000000000 +0200
  5901. @@ -0,0 +1,39 @@
  5902. +/* Software floating-point emulation.
  5903. + Return a * b
  5904. + Copyright (C) 1997,1999 Free Software Foundation, Inc.
  5905. + This file is part of the GNU C Library.
  5906. + Contributed by Richard Henderson (rth@cygnus.com) and
  5907. + Jakub Jelinek (jj@ultra.linux.cz).
  5908. +
  5909. + The GNU C Library is free software; you can redistribute it and/or
  5910. + modify it under the terms of the GNU Lesser General Public
  5911. + License as published by the Free Software Foundation; either
  5912. + version 2.1 of the License, or (at your option) any later version.
  5913. +
  5914. + The GNU C Library is distributed in the hope that it will be useful,
  5915. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  5916. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  5917. + Lesser General Public License for more details.
  5918. +
  5919. + You should have received a copy of the GNU Lesser General Public
  5920. + License along with the GNU C Library; if not, write to the Free
  5921. + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  5922. + 02111-1307 USA. */
  5923. +
  5924. +#include "soft-fp.h"
  5925. +#include "quad.h"
  5926. +
  5927. +long double _Q_mul(const long double a, const long double b)
  5928. +{
  5929. + FP_DECL_EX;
  5930. + FP_DECL_Q(A); FP_DECL_Q(B); FP_DECL_Q(C);
  5931. + long double c;
  5932. +
  5933. + FP_INIT_ROUNDMODE;
  5934. + FP_UNPACK_Q(A, a);
  5935. + FP_UNPACK_Q(B, b);
  5936. + FP_MUL_Q(C, A, B);
  5937. + FP_PACK_Q(c, C);
  5938. + FP_HANDLE_EXCEPTIONS;
  5939. + return c;
  5940. +}
  5941. diff -Naur uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_neg.c uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_neg.c
  5942. --- uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_neg.c 1970-01-01 01:00:00.000000000 +0100
  5943. +++ uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_neg.c 2010-10-14 14:05:37.000000000 +0200
  5944. @@ -0,0 +1,47 @@
  5945. +/* Software floating-point emulation.
  5946. + Return !a
  5947. + Copyright (C) 1997,1999 Free Software Foundation, Inc.
  5948. + This file is part of the GNU C Library.
  5949. + Contributed by Richard Henderson (rth@cygnus.com) and
  5950. + Jakub Jelinek (jj@ultra.linux.cz).
  5951. +
  5952. + The GNU C Library is free software; you can redistribute it and/or
  5953. + modify it under the terms of the GNU Lesser General Public
  5954. + License as published by the Free Software Foundation; either
  5955. + version 2.1 of the License, or (at your option) any later version.
  5956. +
  5957. + The GNU C Library is distributed in the hope that it will be useful,
  5958. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  5959. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  5960. + Lesser General Public License for more details.
  5961. +
  5962. + You should have received a copy of the GNU Lesser General Public
  5963. + License along with the GNU C Library; if not, write to the Free
  5964. + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  5965. + 02111-1307 USA. */
  5966. +
  5967. +#include "soft-fp.h"
  5968. +#include "quad.h"
  5969. +
  5970. +long double _Q_neg(const long double a)
  5971. +{
  5972. + FP_DECL_EX;
  5973. + long double c = a;
  5974. +
  5975. +#if (__BYTE_ORDER == __BIG_ENDIAN)
  5976. + ((UWtype *)&c)[0] ^= (((UWtype)1) << (W_TYPE_SIZE - 1));
  5977. +#elif (__BYTE_ORDER == __LITTLE_ENDIAN) && (W_TYPE_SIZE == 64)
  5978. + ((UWtype *)&c)[1] ^= (((UWtype)1) << (W_TYPE_SIZE - 1));
  5979. +#elif (__BYTE_ORDER == __LITTLE_ENDIAN) && (W_TYPE_SIZE == 32)
  5980. + ((UWtype *)&c)[3] ^= (((UWtype)1) << (W_TYPE_SIZE - 1));
  5981. +#else
  5982. + FP_DECL_Q(A); FP_DECL_Q(C);
  5983. +
  5984. + FP_UNPACK_Q(A, a);
  5985. + FP_NEG_Q(C, A);
  5986. + FP_PACK_Q(c, C);
  5987. +#endif
  5988. + FP_CLEAR_EXCEPTIONS;
  5989. + FP_HANDLE_EXCEPTIONS;
  5990. + return c;
  5991. +}
  5992. diff -Naur uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_qtod.c uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_qtod.c
  5993. --- uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_qtod.c 1970-01-01 01:00:00.000000000 +0100
  5994. +++ uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_qtod.c 2010-10-14 14:05:37.000000000 +0200
  5995. @@ -0,0 +1,45 @@
  5996. +/* Software floating-point emulation.
  5997. + Return (double)a
  5998. + Copyright (C) 1997,1999,2006 Free Software Foundation, Inc.
  5999. + This file is part of the GNU C Library.
  6000. + Contributed by Richard Henderson (rth@cygnus.com) and
  6001. + Jakub Jelinek (jj@ultra.linux.cz).
  6002. +
  6003. + The GNU C Library is free software; you can redistribute it and/or
  6004. + modify it under the terms of the GNU Lesser General Public
  6005. + License as published by the Free Software Foundation; either
  6006. + version 2.1 of the License, or (at your option) any later version.
  6007. +
  6008. + The GNU C Library is distributed in the hope that it will be useful,
  6009. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  6010. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  6011. + Lesser General Public License for more details.
  6012. +
  6013. + You should have received a copy of the GNU Lesser General Public
  6014. + License along with the GNU C Library; if not, write to the Free
  6015. + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  6016. + 02111-1307 USA. */
  6017. +
  6018. +#include "soft-fp.h"
  6019. +#include "double.h"
  6020. +#include "quad.h"
  6021. +
  6022. +double _Q_qtod(const long double a)
  6023. +{
  6024. + FP_DECL_EX;
  6025. + FP_DECL_Q(A);
  6026. + FP_DECL_D(R);
  6027. + double r;
  6028. +
  6029. + FP_INIT_ROUNDMODE;
  6030. + FP_UNPACK_SEMIRAW_Q(A, a);
  6031. +#if (2 * _FP_W_TYPE_SIZE) < _FP_FRACBITS_Q
  6032. + FP_TRUNC(D,Q,2,4,R,A);
  6033. +#else
  6034. + FP_TRUNC(D,Q,1,2,R,A);
  6035. +#endif
  6036. + FP_PACK_SEMIRAW_D(r, R);
  6037. + FP_HANDLE_EXCEPTIONS;
  6038. +
  6039. + return r;
  6040. +}
  6041. diff -Naur uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_qtoi.c uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_qtoi.c
  6042. --- uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_qtoi.c 1970-01-01 01:00:00.000000000 +0100
  6043. +++ uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_qtoi.c 2010-10-14 14:05:37.000000000 +0200
  6044. @@ -0,0 +1,38 @@
  6045. +/* Software floating-point emulation.
  6046. + Return (int)a
  6047. + Copyright (C) 1997,1999,2006 Free Software Foundation, Inc.
  6048. + This file is part of the GNU C Library.
  6049. + Contributed by Richard Henderson (rth@cygnus.com) and
  6050. + Jakub Jelinek (jj@ultra.linux.cz).
  6051. +
  6052. + The GNU C Library is free software; you can redistribute it and/or
  6053. + modify it under the terms of the GNU Lesser General Public
  6054. + License as published by the Free Software Foundation; either
  6055. + version 2.1 of the License, or (at your option) any later version.
  6056. +
  6057. + The GNU C Library is distributed in the hope that it will be useful,
  6058. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  6059. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  6060. + Lesser General Public License for more details.
  6061. +
  6062. + You should have received a copy of the GNU Lesser General Public
  6063. + License along with the GNU C Library; if not, write to the Free
  6064. + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  6065. + 02111-1307 USA. */
  6066. +
  6067. +#define FP_ROUNDMODE FP_RND_ZERO
  6068. +#include "soft-fp.h"
  6069. +#include "quad.h"
  6070. +
  6071. +int _Q_qtoi(const long double a)
  6072. +{
  6073. + FP_DECL_EX;
  6074. + FP_DECL_Q(A);
  6075. + unsigned int r;
  6076. +
  6077. + FP_UNPACK_RAW_Q(A, a);
  6078. + FP_TO_INT_Q(r, A, 32, 1);
  6079. + FP_HANDLE_EXCEPTIONS;
  6080. +
  6081. + return r;
  6082. +}
  6083. diff -Naur uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_qtoll.c uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_qtoll.c
  6084. --- uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_qtoll.c 1970-01-01 01:00:00.000000000 +0100
  6085. +++ uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_qtoll.c 2010-10-14 14:05:37.000000000 +0200
  6086. @@ -0,0 +1,38 @@
  6087. +/* Software floating-point emulation.
  6088. + Return (long long)a
  6089. + Copyright (C) 1997, 1999, 2006 Free Software Foundation, Inc.
  6090. + This file is part of the GNU C Library.
  6091. + Contributed by Richard Henderson (rth@cygnus.com) and
  6092. + Jakub Jelinek (jj@ultra.linux.cz).
  6093. +
  6094. + The GNU C Library is free software; you can redistribute it and/or
  6095. + modify it under the terms of the GNU Lesser General Public
  6096. + License as published by the Free Software Foundation; either
  6097. + version 2.1 of the License, or (at your option) any later version.
  6098. +
  6099. + The GNU C Library is distributed in the hope that it will be useful,
  6100. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  6101. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  6102. + Lesser General Public License for more details.
  6103. +
  6104. + You should have received a copy of the GNU Lesser General Public
  6105. + License along with the GNU C Library; if not, write to the Free
  6106. + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  6107. + 02111-1307 USA. */
  6108. +
  6109. +#define FP_ROUNDMODE FP_RND_ZERO
  6110. +#include "soft-fp.h"
  6111. +#include "quad.h"
  6112. +
  6113. +long long _Q_qtoll(const long double a)
  6114. +{
  6115. + FP_DECL_EX;
  6116. + FP_DECL_Q(A);
  6117. + unsigned long long r;
  6118. +
  6119. + FP_UNPACK_RAW_Q(A, a);
  6120. + FP_TO_INT_Q(r, A, 64, 1);
  6121. + FP_HANDLE_EXCEPTIONS;
  6122. +
  6123. + return r;
  6124. +}
  6125. diff -Naur uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_qtos.c uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_qtos.c
  6126. --- uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_qtos.c 1970-01-01 01:00:00.000000000 +0100
  6127. +++ uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_qtos.c 2010-10-14 14:05:37.000000000 +0200
  6128. @@ -0,0 +1,45 @@
  6129. +/* Software floating-point emulation.
  6130. + Return (float)a
  6131. + Copyright (C) 1997,1999,2006 Free Software Foundation, Inc.
  6132. + This file is part of the GNU C Library.
  6133. + Contributed by Richard Henderson (rth@cygnus.com) and
  6134. + Jakub Jelinek (jj@ultra.linux.cz).
  6135. +
  6136. + The GNU C Library is free software; you can redistribute it and/or
  6137. + modify it under the terms of the GNU Lesser General Public
  6138. + License as published by the Free Software Foundation; either
  6139. + version 2.1 of the License, or (at your option) any later version.
  6140. +
  6141. + The GNU C Library is distributed in the hope that it will be useful,
  6142. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  6143. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  6144. + Lesser General Public License for more details.
  6145. +
  6146. + You should have received a copy of the GNU Lesser General Public
  6147. + License along with the GNU C Library; if not, write to the Free
  6148. + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  6149. + 02111-1307 USA. */
  6150. +
  6151. +#include "soft-fp.h"
  6152. +#include "single.h"
  6153. +#include "quad.h"
  6154. +
  6155. +float _Q_qtos(const long double a)
  6156. +{
  6157. + FP_DECL_EX;
  6158. + FP_DECL_Q(A);
  6159. + FP_DECL_S(R);
  6160. + float r;
  6161. +
  6162. + FP_INIT_ROUNDMODE;
  6163. + FP_UNPACK_SEMIRAW_Q(A, a);
  6164. +#if (2 * _FP_W_TYPE_SIZE) < _FP_FRACBITS_Q
  6165. + FP_TRUNC(S,Q,1,4,R,A);
  6166. +#else
  6167. + FP_TRUNC(S,Q,1,2,R,A);
  6168. +#endif
  6169. + FP_PACK_SEMIRAW_S(r, R);
  6170. + FP_HANDLE_EXCEPTIONS;
  6171. +
  6172. + return r;
  6173. +}
  6174. diff -Naur uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_qtou.c uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_qtou.c
  6175. --- uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_qtou.c 1970-01-01 01:00:00.000000000 +0100
  6176. +++ uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_qtou.c 2010-10-14 14:05:37.000000000 +0200
  6177. @@ -0,0 +1,38 @@
  6178. +/* Software floating-point emulation.
  6179. + Return (unsigned int)a
  6180. + Copyright (C) 1997, 1999, 2006 Free Software Foundation, Inc.
  6181. + This file is part of the GNU C Library.
  6182. + Contributed by Richard Henderson (rth@cygnus.com) and
  6183. + Jakub Jelinek (jj@ultra.linux.cz).
  6184. +
  6185. + The GNU C Library is free software; you can redistribute it and/or
  6186. + modify it under the terms of the GNU Lesser General Public
  6187. + License as published by the Free Software Foundation; either
  6188. + version 2.1 of the License, or (at your option) any later version.
  6189. +
  6190. + The GNU C Library is distributed in the hope that it will be useful,
  6191. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  6192. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  6193. + Lesser General Public License for more details.
  6194. +
  6195. + You should have received a copy of the GNU Lesser General Public
  6196. + License along with the GNU C Library; if not, write to the Free
  6197. + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  6198. + 02111-1307 USA. */
  6199. +
  6200. +#define FP_ROUNDMODE FP_RND_ZERO
  6201. +#include "soft-fp.h"
  6202. +#include "quad.h"
  6203. +
  6204. +unsigned int _Q_qtou(const long double a)
  6205. +{
  6206. + FP_DECL_EX;
  6207. + FP_DECL_Q(A);
  6208. + unsigned int r;
  6209. +
  6210. + FP_UNPACK_RAW_Q(A, a);
  6211. + FP_TO_INT_Q(r, A, 32, -1);
  6212. + FP_HANDLE_EXCEPTIONS;
  6213. +
  6214. + return r;
  6215. +}
  6216. diff -Naur uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_qtoull.c uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_qtoull.c
  6217. --- uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_qtoull.c 1970-01-01 01:00:00.000000000 +0100
  6218. +++ uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_qtoull.c 2010-10-14 14:05:37.000000000 +0200
  6219. @@ -0,0 +1,38 @@
  6220. +/* Software floating-point emulation.
  6221. + Return (unsigned long long)a
  6222. + Copyright (C) 1997, 1999, 2006 Free Software Foundation, Inc.
  6223. + This file is part of the GNU C Library.
  6224. + Contributed by Richard Henderson (rth@cygnus.com) and
  6225. + Jakub Jelinek (jj@ultra.linux.cz).
  6226. +
  6227. + The GNU C Library is free software; you can redistribute it and/or
  6228. + modify it under the terms of the GNU Lesser General Public
  6229. + License as published by the Free Software Foundation; either
  6230. + version 2.1 of the License, or (at your option) any later version.
  6231. +
  6232. + The GNU C Library is distributed in the hope that it will be useful,
  6233. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  6234. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  6235. + Lesser General Public License for more details.
  6236. +
  6237. + You should have received a copy of the GNU Lesser General Public
  6238. + License along with the GNU C Library; if not, write to the Free
  6239. + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  6240. + 02111-1307 USA. */
  6241. +
  6242. +#define FP_ROUNDMODE FP_RND_ZERO
  6243. +#include "soft-fp.h"
  6244. +#include "quad.h"
  6245. +
  6246. +unsigned long long _Q_qtoull(const long double a)
  6247. +{
  6248. + FP_DECL_EX;
  6249. + FP_DECL_Q(A);
  6250. + unsigned long long r;
  6251. +
  6252. + FP_UNPACK_RAW_Q(A, a);
  6253. + FP_TO_INT_Q(r, A, 64, -1);
  6254. + FP_HANDLE_EXCEPTIONS;
  6255. +
  6256. + return r;
  6257. +}
  6258. diff -Naur uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_sqrt.c uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_sqrt.c
  6259. --- uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_sqrt.c 1970-01-01 01:00:00.000000000 +0100
  6260. +++ uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_sqrt.c 2010-10-14 14:05:37.000000000 +0200
  6261. @@ -0,0 +1,39 @@
  6262. +/* Software floating-point emulation.
  6263. + Return sqrtl(a)
  6264. + Copyright (C) 1997, 1999, 2006 Free Software Foundation, Inc.
  6265. + This file is part of the GNU C Library.
  6266. + Contributed by Richard Henderson (rth@cygnus.com) and
  6267. + Jakub Jelinek (jj@ultra.linux.cz).
  6268. +
  6269. + The GNU C Library is free software; you can redistribute it and/or
  6270. + modify it under the terms of the GNU Lesser General Public
  6271. + License as published by the Free Software Foundation; either
  6272. + version 2.1 of the License, or (at your option) any later version.
  6273. +
  6274. + The GNU C Library is distributed in the hope that it will be useful,
  6275. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  6276. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  6277. + Lesser General Public License for more details.
  6278. +
  6279. + You should have received a copy of the GNU Lesser General Public
  6280. + License along with the GNU C Library; if not, write to the Free
  6281. + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  6282. + 02111-1307 USA. */
  6283. +
  6284. +#include "soft-fp.h"
  6285. +#include "quad.h"
  6286. +
  6287. +long double _Q_sqrt(const long double a)
  6288. +{
  6289. + FP_DECL_EX;
  6290. + FP_DECL_Q(A); FP_DECL_Q(C);
  6291. + long double c;
  6292. +
  6293. + FP_INIT_ROUNDMODE;
  6294. + FP_UNPACK_Q(A, a);
  6295. + FP_SQRT_Q(C, A);
  6296. + FP_PACK_Q(c, C);
  6297. + FP_HANDLE_EXCEPTIONS;
  6298. + return c;
  6299. +}
  6300. +strong_alias (_Q_sqrt, __ieee754_sqrtl);
  6301. diff -Naur uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_stoq.c uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_stoq.c
  6302. --- uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_stoq.c 1970-01-01 01:00:00.000000000 +0100
  6303. +++ uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_stoq.c 2010-10-14 14:05:37.000000000 +0200
  6304. @@ -0,0 +1,43 @@
  6305. +/* Software floating-point emulation.
  6306. + c = (long double)(a)
  6307. + Copyright (C) 1997,1999,2006 Free Software Foundation, Inc.
  6308. + This file is part of the GNU C Library.
  6309. + Contributed by Richard Henderson (rth@cygnus.com) and
  6310. + Jakub Jelinek (jj@ultra.linux.cz).
  6311. +
  6312. + The GNU C Library is free software; you can redistribute it and/or
  6313. + modify it under the terms of the GNU Lesser General Public
  6314. + License as published by the Free Software Foundation; either
  6315. + version 2.1 of the License, or (at your option) any later version.
  6316. +
  6317. + The GNU C Library is distributed in the hope that it will be useful,
  6318. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  6319. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  6320. + Lesser General Public License for more details.
  6321. +
  6322. + You should have received a copy of the GNU Lesser General Public
  6323. + License along with the GNU C Library; if not, write to the Free
  6324. + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  6325. + 02111-1307 USA. */
  6326. +
  6327. +#include "soft-fp.h"
  6328. +#include "single.h"
  6329. +#include "quad.h"
  6330. +
  6331. +long double _Q_stoq(const float a)
  6332. +{
  6333. + FP_DECL_EX;
  6334. + FP_DECL_S(A);
  6335. + FP_DECL_Q(C);
  6336. + long double c;
  6337. +
  6338. + FP_UNPACK_RAW_S(A, a);
  6339. +#if (2 * _FP_W_TYPE_SIZE) < _FP_FRACBITS_Q
  6340. + FP_EXTEND(Q,S,4,1,C,A);
  6341. +#else
  6342. + FP_EXTEND(Q,S,2,1,C,A);
  6343. +#endif
  6344. + FP_PACK_RAW_Q(c, C);
  6345. + FP_HANDLE_EXCEPTIONS;
  6346. + return c;
  6347. +}
  6348. diff -Naur uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_sub.c uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_sub.c
  6349. --- uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_sub.c 1970-01-01 01:00:00.000000000 +0100
  6350. +++ uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_sub.c 2010-10-14 14:05:37.000000000 +0200
  6351. @@ -0,0 +1,39 @@
  6352. +/* Software floating-point emulation.
  6353. + c = a - b
  6354. + Copyright (C) 1997,1999,2006 Free Software Foundation, Inc.
  6355. + This file is part of the GNU C Library.
  6356. + Contributed by Richard Henderson (rth@cygnus.com) and
  6357. + Jakub Jelinek (jj@ultra.linux.cz).
  6358. +
  6359. + The GNU C Library is free software; you can redistribute it and/or
  6360. + modify it under the terms of the GNU Lesser General Public
  6361. + License as published by the Free Software Foundation; either
  6362. + version 2.1 of the License, or (at your option) any later version.
  6363. +
  6364. + The GNU C Library is distributed in the hope that it will be useful,
  6365. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  6366. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  6367. + Lesser General Public License for more details.
  6368. +
  6369. + You should have received a copy of the GNU Lesser General Public
  6370. + License along with the GNU C Library; if not, write to the Free
  6371. + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  6372. + 02111-1307 USA. */
  6373. +
  6374. +#include "soft-fp.h"
  6375. +#include "quad.h"
  6376. +
  6377. +long double _Q_sub(const long double a, const long double b)
  6378. +{
  6379. + FP_DECL_EX;
  6380. + FP_DECL_Q(A); FP_DECL_Q(B); FP_DECL_Q(C);
  6381. + long double c;
  6382. +
  6383. + FP_INIT_ROUNDMODE;
  6384. + FP_UNPACK_SEMIRAW_Q(A, a);
  6385. + FP_UNPACK_SEMIRAW_Q(B, b);
  6386. + FP_SUB_Q(C, A, B);
  6387. + FP_PACK_SEMIRAW_Q(c, C);
  6388. + FP_HANDLE_EXCEPTIONS;
  6389. + return c;
  6390. +}
  6391. diff -Naur uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_ulltoq.c uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_ulltoq.c
  6392. --- uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_ulltoq.c 1970-01-01 01:00:00.000000000 +0100
  6393. +++ uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_ulltoq.c 2010-10-14 14:05:37.000000000 +0200
  6394. @@ -0,0 +1,38 @@
  6395. +/* Software floating-point emulation.
  6396. + Return (long double)(a)
  6397. + Copyright (C) 1997, 1999, 2006 Free Software Foundation, Inc.
  6398. + This file is part of the GNU C Library.
  6399. + Contributed by Richard Henderson (rth@cygnus.com) and
  6400. + Jakub Jelinek (jj@ultra.linux.cz).
  6401. +
  6402. + The GNU C Library is free software; you can redistribute it and/or
  6403. + modify it under the terms of the GNU Lesser General Public
  6404. + License as published by the Free Software Foundation; either
  6405. + version 2.1 of the License, or (at your option) any later version.
  6406. +
  6407. + The GNU C Library is distributed in the hope that it will be useful,
  6408. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  6409. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  6410. + Lesser General Public License for more details.
  6411. +
  6412. + You should have received a copy of the GNU Lesser General Public
  6413. + License along with the GNU C Library; if not, write to the Free
  6414. + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  6415. + 02111-1307 USA. */
  6416. +
  6417. +#include "soft-fp.h"
  6418. +#include "quad.h"
  6419. +
  6420. +long double _Q_ulltoq(const unsigned long long a)
  6421. +{
  6422. + FP_DECL_EX;
  6423. + FP_DECL_Q(C);
  6424. + long double c;
  6425. + unsigned long long b = a;
  6426. +
  6427. + FP_FROM_INT_Q(C, b, 64, unsigned long long);
  6428. + FP_PACK_RAW_Q(c, C);
  6429. + FP_CLEAR_EXCEPTIONS;
  6430. + FP_HANDLE_EXCEPTIONS;
  6431. + return c;
  6432. +}
  6433. diff -Naur uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_util.c uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_util.c
  6434. --- uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_util.c 1970-01-01 01:00:00.000000000 +0100
  6435. +++ uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_util.c 2010-10-14 14:05:37.000000000 +0200
  6436. @@ -0,0 +1,57 @@
  6437. +/* Software floating-point emulation.
  6438. + Helper routine for _Q_* routines.
  6439. + Simulate exceptions using double arithmetics.
  6440. + Copyright (C) 1999 Free Software Foundation, Inc.
  6441. + This file is part of the GNU C Library.
  6442. + Contributed by Jakub Jelinek (jj@ultra.linux.cz).
  6443. +
  6444. + The GNU C Library is free software; you can redistribute it and/or
  6445. + modify it under the terms of the GNU Lesser General Public
  6446. + License as published by the Free Software Foundation; either
  6447. + version 2.1 of the License, or (at your option) any later version.
  6448. +
  6449. + The GNU C Library is distributed in the hope that it will be useful,
  6450. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  6451. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  6452. + Lesser General Public License for more details.
  6453. +
  6454. + You should have received a copy of the GNU Lesser General Public
  6455. + License along with the GNU C Library; if not, write to the Free
  6456. + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  6457. + 02111-1307 USA. */
  6458. +
  6459. +#include "soft-fp.h"
  6460. +
  6461. +unsigned long long ___Q_numbers [] = {
  6462. +0x0000000000000000ULL, /* Zero */
  6463. +0x0010100000000000ULL, /* Very tiny number */
  6464. +0x0010000000000000ULL, /* Minimum normalized number */
  6465. +0x7fef000000000000ULL, /* A huge double number */
  6466. +};
  6467. +
  6468. +double ___Q_simulate_exceptions(int exceptions)
  6469. +{
  6470. + double d, *p = (double *)___Q_numbers;
  6471. + if (exceptions & FP_EX_INVALID)
  6472. + d = p[0]/p[0];
  6473. + if (exceptions & FP_EX_OVERFLOW)
  6474. + {
  6475. + d = p[3] + p[3];
  6476. + exceptions &= ~FP_EX_INEXACT;
  6477. + }
  6478. + if (exceptions & FP_EX_UNDERFLOW)
  6479. + {
  6480. + if (exceptions & FP_EX_INEXACT)
  6481. + {
  6482. + d = p[2] * p[2];
  6483. + exceptions &= ~FP_EX_INEXACT;
  6484. + }
  6485. + else
  6486. + d = p[1] - p[2];
  6487. + }
  6488. + if (exceptions & FP_EX_DIVZERO)
  6489. + d = 1.0/p[0];
  6490. + if (exceptions & FP_EX_INEXACT)
  6491. + d = p[3] - p[2];
  6492. + return d;
  6493. +}
  6494. diff -Naur uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_utoq.c uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_utoq.c
  6495. --- uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/q_utoq.c 1970-01-01 01:00:00.000000000 +0100
  6496. +++ uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/q_utoq.c 2010-10-14 14:05:37.000000000 +0200
  6497. @@ -0,0 +1,38 @@
  6498. +/* Software floating-point emulation.
  6499. + c = (long double)(a)
  6500. + Copyright (C) 1997, 1999, 2006 Free Software Foundation, Inc.
  6501. + This file is part of the GNU C Library.
  6502. + Contributed by Richard Henderson (rth@cygnus.com) and
  6503. + Jakub Jelinek (jj@ultra.linux.cz).
  6504. +
  6505. + The GNU C Library is free software; you can redistribute it and/or
  6506. + modify it under the terms of the GNU Lesser General Public
  6507. + License as published by the Free Software Foundation; either
  6508. + version 2.1 of the License, or (at your option) any later version.
  6509. +
  6510. + The GNU C Library is distributed in the hope that it will be useful,
  6511. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  6512. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  6513. + Lesser General Public License for more details.
  6514. +
  6515. + You should have received a copy of the GNU Lesser General Public
  6516. + License along with the GNU C Library; if not, write to the Free
  6517. + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  6518. + 02111-1307 USA. */
  6519. +
  6520. +#include "soft-fp.h"
  6521. +#include "quad.h"
  6522. +
  6523. +long double _Q_utoq(const unsigned int a)
  6524. +{
  6525. + FP_DECL_EX;
  6526. + FP_DECL_Q(C);
  6527. + long double c;
  6528. + unsigned int b = a;
  6529. +
  6530. + FP_FROM_INT_Q(C, b, 32, unsigned int);
  6531. + FP_PACK_RAW_Q(c, C);
  6532. + FP_CLEAR_EXCEPTIONS;
  6533. + FP_HANDLE_EXCEPTIONS;
  6534. + return c;
  6535. +}
  6536. diff -Naur uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/quad.h uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/quad.h
  6537. --- uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/quad.h 1970-01-01 01:00:00.000000000 +0100
  6538. +++ uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/quad.h 2010-10-14 14:05:37.000000000 +0200
  6539. @@ -0,0 +1,271 @@
  6540. +/* Software floating-point emulation.
  6541. + Definitions for IEEE Quad Precision.
  6542. + Copyright (C) 1997,1998,1999,2006,2007 Free Software Foundation, Inc.
  6543. + This file is part of the GNU C Library.
  6544. + Contributed by Richard Henderson (rth@cygnus.com),
  6545. + Jakub Jelinek (jj@ultra.linux.cz),
  6546. + David S. Miller (davem@redhat.com) and
  6547. + Peter Maydell (pmaydell@chiark.greenend.org.uk).
  6548. +
  6549. + The GNU C Library is free software; you can redistribute it and/or
  6550. + modify it under the terms of the GNU Lesser General Public
  6551. + License as published by the Free Software Foundation; either
  6552. + version 2.1 of the License, or (at your option) any later version.
  6553. +
  6554. + In addition to the permissions in the GNU Lesser General Public
  6555. + License, the Free Software Foundation gives you unlimited
  6556. + permission to link the compiled version of this file into
  6557. + combinations with other programs, and to distribute those
  6558. + combinations without any restriction coming from the use of this
  6559. + file. (The Lesser General Public License restrictions do apply in
  6560. + other respects; for example, they cover modification of the file,
  6561. + and distribution when not linked into a combine executable.)
  6562. +
  6563. + The GNU C Library is distributed in the hope that it will be useful,
  6564. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  6565. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  6566. + Lesser General Public License for more details.
  6567. +
  6568. + You should have received a copy of the GNU Lesser General Public
  6569. + License along with the GNU C Library; if not, write to the Free
  6570. + Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
  6571. + MA 02110-1301, USA. */
  6572. +
  6573. +#if _FP_W_TYPE_SIZE < 32
  6574. +#error "Here's a nickel, kid. Go buy yourself a real computer."
  6575. +#endif
  6576. +
  6577. +#if _FP_W_TYPE_SIZE < 64
  6578. +#define _FP_FRACTBITS_Q (4*_FP_W_TYPE_SIZE)
  6579. +#else
  6580. +#define _FP_FRACTBITS_Q (2*_FP_W_TYPE_SIZE)
  6581. +#endif
  6582. +
  6583. +#define _FP_FRACBITS_Q 113
  6584. +#define _FP_FRACXBITS_Q (_FP_FRACTBITS_Q - _FP_FRACBITS_Q)
  6585. +#define _FP_WFRACBITS_Q (_FP_WORKBITS + _FP_FRACBITS_Q)
  6586. +#define _FP_WFRACXBITS_Q (_FP_FRACTBITS_Q - _FP_WFRACBITS_Q)
  6587. +#define _FP_EXPBITS_Q 15
  6588. +#define _FP_EXPBIAS_Q 16383
  6589. +#define _FP_EXPMAX_Q 32767
  6590. +
  6591. +#define _FP_QNANBIT_Q \
  6592. + ((_FP_W_TYPE)1 << (_FP_FRACBITS_Q-2) % _FP_W_TYPE_SIZE)
  6593. +#define _FP_QNANBIT_SH_Q \
  6594. + ((_FP_W_TYPE)1 << (_FP_FRACBITS_Q-2+_FP_WORKBITS) % _FP_W_TYPE_SIZE)
  6595. +#define _FP_IMPLBIT_Q \
  6596. + ((_FP_W_TYPE)1 << (_FP_FRACBITS_Q-1) % _FP_W_TYPE_SIZE)
  6597. +#define _FP_IMPLBIT_SH_Q \
  6598. + ((_FP_W_TYPE)1 << (_FP_FRACBITS_Q-1+_FP_WORKBITS) % _FP_W_TYPE_SIZE)
  6599. +#define _FP_OVERFLOW_Q \
  6600. + ((_FP_W_TYPE)1 << (_FP_WFRACBITS_Q % _FP_W_TYPE_SIZE))
  6601. +
  6602. +typedef float TFtype __attribute__((mode(TF)));
  6603. +
  6604. +#if _FP_W_TYPE_SIZE < 64
  6605. +
  6606. +union _FP_UNION_Q
  6607. +{
  6608. + TFtype flt;
  6609. + struct
  6610. + {
  6611. +#if __BYTE_ORDER == __BIG_ENDIAN
  6612. + unsigned sign : 1;
  6613. + unsigned exp : _FP_EXPBITS_Q;
  6614. + unsigned long frac3 : _FP_FRACBITS_Q - (_FP_IMPLBIT_Q != 0)-(_FP_W_TYPE_SIZE * 3);
  6615. + unsigned long frac2 : _FP_W_TYPE_SIZE;
  6616. + unsigned long frac1 : _FP_W_TYPE_SIZE;
  6617. + unsigned long frac0 : _FP_W_TYPE_SIZE;
  6618. +#else
  6619. + unsigned long frac0 : _FP_W_TYPE_SIZE;
  6620. + unsigned long frac1 : _FP_W_TYPE_SIZE;
  6621. + unsigned long frac2 : _FP_W_TYPE_SIZE;
  6622. + unsigned long frac3 : _FP_FRACBITS_Q - (_FP_IMPLBIT_Q != 0)-(_FP_W_TYPE_SIZE * 3);
  6623. + unsigned exp : _FP_EXPBITS_Q;
  6624. + unsigned sign : 1;
  6625. +#endif /* not bigendian */
  6626. + } bits __attribute__((packed));
  6627. +};
  6628. +
  6629. +
  6630. +#define FP_DECL_Q(X) _FP_DECL(4,X)
  6631. +#define FP_UNPACK_RAW_Q(X,val) _FP_UNPACK_RAW_4(Q,X,val)
  6632. +#define FP_UNPACK_RAW_QP(X,val) _FP_UNPACK_RAW_4_P(Q,X,val)
  6633. +#define FP_PACK_RAW_Q(val,X) _FP_PACK_RAW_4(Q,val,X)
  6634. +#define FP_PACK_RAW_QP(val,X) \
  6635. + do { \
  6636. + if (!FP_INHIBIT_RESULTS) \
  6637. + _FP_PACK_RAW_4_P(Q,val,X); \
  6638. + } while (0)
  6639. +
  6640. +#define FP_UNPACK_Q(X,val) \
  6641. + do { \
  6642. + _FP_UNPACK_RAW_4(Q,X,val); \
  6643. + _FP_UNPACK_CANONICAL(Q,4,X); \
  6644. + } while (0)
  6645. +
  6646. +#define FP_UNPACK_QP(X,val) \
  6647. + do { \
  6648. + _FP_UNPACK_RAW_4_P(Q,X,val); \
  6649. + _FP_UNPACK_CANONICAL(Q,4,X); \
  6650. + } while (0)
  6651. +
  6652. +#define FP_UNPACK_SEMIRAW_Q(X,val) \
  6653. + do { \
  6654. + _FP_UNPACK_RAW_4(Q,X,val); \
  6655. + _FP_UNPACK_SEMIRAW(Q,4,X); \
  6656. + } while (0)
  6657. +
  6658. +#define FP_UNPACK_SEMIRAW_QP(X,val) \
  6659. + do { \
  6660. + _FP_UNPACK_RAW_4_P(Q,X,val); \
  6661. + _FP_UNPACK_SEMIRAW(Q,4,X); \
  6662. + } while (0)
  6663. +
  6664. +#define FP_PACK_Q(val,X) \
  6665. + do { \
  6666. + _FP_PACK_CANONICAL(Q,4,X); \
  6667. + _FP_PACK_RAW_4(Q,val,X); \
  6668. + } while (0)
  6669. +
  6670. +#define FP_PACK_QP(val,X) \
  6671. + do { \
  6672. + _FP_PACK_CANONICAL(Q,4,X); \
  6673. + if (!FP_INHIBIT_RESULTS) \
  6674. + _FP_PACK_RAW_4_P(Q,val,X); \
  6675. + } while (0)
  6676. +
  6677. +#define FP_PACK_SEMIRAW_Q(val,X) \
  6678. + do { \
  6679. + _FP_PACK_SEMIRAW(Q,4,X); \
  6680. + _FP_PACK_RAW_4(Q,val,X); \
  6681. + } while (0)
  6682. +
  6683. +#define FP_PACK_SEMIRAW_QP(val,X) \
  6684. + do { \
  6685. + _FP_PACK_SEMIRAW(Q,4,X); \
  6686. + if (!FP_INHIBIT_RESULTS) \
  6687. + _FP_PACK_RAW_4_P(Q,val,X); \
  6688. + } while (0)
  6689. +
  6690. +#define FP_ISSIGNAN_Q(X) _FP_ISSIGNAN(Q,4,X)
  6691. +#define FP_NEG_Q(R,X) _FP_NEG(Q,4,R,X)
  6692. +#define FP_ADD_Q(R,X,Y) _FP_ADD(Q,4,R,X,Y)
  6693. +#define FP_SUB_Q(R,X,Y) _FP_SUB(Q,4,R,X,Y)
  6694. +#define FP_MUL_Q(R,X,Y) _FP_MUL(Q,4,R,X,Y)
  6695. +#define FP_DIV_Q(R,X,Y) _FP_DIV(Q,4,R,X,Y)
  6696. +#define FP_SQRT_Q(R,X) _FP_SQRT(Q,4,R,X)
  6697. +#define _FP_SQRT_MEAT_Q(R,S,T,X,Q) _FP_SQRT_MEAT_4(R,S,T,X,Q)
  6698. +
  6699. +#define FP_CMP_Q(r,X,Y,un) _FP_CMP(Q,4,r,X,Y,un)
  6700. +#define FP_CMP_EQ_Q(r,X,Y) _FP_CMP_EQ(Q,4,r,X,Y)
  6701. +#define FP_CMP_UNORD_Q(r,X,Y) _FP_CMP_UNORD(Q,4,r,X,Y)
  6702. +
  6703. +#define FP_TO_INT_Q(r,X,rsz,rsg) _FP_TO_INT(Q,4,r,X,rsz,rsg)
  6704. +#define FP_FROM_INT_Q(X,r,rs,rt) _FP_FROM_INT(Q,4,X,r,rs,rt)
  6705. +
  6706. +#define _FP_FRAC_HIGH_Q(X) _FP_FRAC_HIGH_4(X)
  6707. +#define _FP_FRAC_HIGH_RAW_Q(X) _FP_FRAC_HIGH_4(X)
  6708. +
  6709. +#else /* not _FP_W_TYPE_SIZE < 64 */
  6710. +union _FP_UNION_Q
  6711. +{
  6712. + TFtype flt /* __attribute__((mode(TF))) */ ;
  6713. + struct {
  6714. + _FP_W_TYPE a, b;
  6715. + } longs;
  6716. + struct {
  6717. +#if __BYTE_ORDER == __BIG_ENDIAN
  6718. + unsigned sign : 1;
  6719. + unsigned exp : _FP_EXPBITS_Q;
  6720. + _FP_W_TYPE frac1 : _FP_FRACBITS_Q - (_FP_IMPLBIT_Q != 0) - _FP_W_TYPE_SIZE;
  6721. + _FP_W_TYPE frac0 : _FP_W_TYPE_SIZE;
  6722. +#else
  6723. + _FP_W_TYPE frac0 : _FP_W_TYPE_SIZE;
  6724. + _FP_W_TYPE frac1 : _FP_FRACBITS_Q - (_FP_IMPLBIT_Q != 0) - _FP_W_TYPE_SIZE;
  6725. + unsigned exp : _FP_EXPBITS_Q;
  6726. + unsigned sign : 1;
  6727. +#endif
  6728. + } bits;
  6729. +};
  6730. +
  6731. +#define FP_DECL_Q(X) _FP_DECL(2,X)
  6732. +#define FP_UNPACK_RAW_Q(X,val) _FP_UNPACK_RAW_2(Q,X,val)
  6733. +#define FP_UNPACK_RAW_QP(X,val) _FP_UNPACK_RAW_2_P(Q,X,val)
  6734. +#define FP_PACK_RAW_Q(val,X) _FP_PACK_RAW_2(Q,val,X)
  6735. +#define FP_PACK_RAW_QP(val,X) \
  6736. + do { \
  6737. + if (!FP_INHIBIT_RESULTS) \
  6738. + _FP_PACK_RAW_2_P(Q,val,X); \
  6739. + } while (0)
  6740. +
  6741. +#define FP_UNPACK_Q(X,val) \
  6742. + do { \
  6743. + _FP_UNPACK_RAW_2(Q,X,val); \
  6744. + _FP_UNPACK_CANONICAL(Q,2,X); \
  6745. + } while (0)
  6746. +
  6747. +#define FP_UNPACK_QP(X,val) \
  6748. + do { \
  6749. + _FP_UNPACK_RAW_2_P(Q,X,val); \
  6750. + _FP_UNPACK_CANONICAL(Q,2,X); \
  6751. + } while (0)
  6752. +
  6753. +#define FP_UNPACK_SEMIRAW_Q(X,val) \
  6754. + do { \
  6755. + _FP_UNPACK_RAW_2(Q,X,val); \
  6756. + _FP_UNPACK_SEMIRAW(Q,2,X); \
  6757. + } while (0)
  6758. +
  6759. +#define FP_UNPACK_SEMIRAW_QP(X,val) \
  6760. + do { \
  6761. + _FP_UNPACK_RAW_2_P(Q,X,val); \
  6762. + _FP_UNPACK_SEMIRAW(Q,2,X); \
  6763. + } while (0)
  6764. +
  6765. +#define FP_PACK_Q(val,X) \
  6766. + do { \
  6767. + _FP_PACK_CANONICAL(Q,2,X); \
  6768. + _FP_PACK_RAW_2(Q,val,X); \
  6769. + } while (0)
  6770. +
  6771. +#define FP_PACK_QP(val,X) \
  6772. + do { \
  6773. + _FP_PACK_CANONICAL(Q,2,X); \
  6774. + if (!FP_INHIBIT_RESULTS) \
  6775. + _FP_PACK_RAW_2_P(Q,val,X); \
  6776. + } while (0)
  6777. +
  6778. +#define FP_PACK_SEMIRAW_Q(val,X) \
  6779. + do { \
  6780. + _FP_PACK_SEMIRAW(Q,2,X); \
  6781. + _FP_PACK_RAW_2(Q,val,X); \
  6782. + } while (0)
  6783. +
  6784. +#define FP_PACK_SEMIRAW_QP(val,X) \
  6785. + do { \
  6786. + _FP_PACK_SEMIRAW(Q,2,X); \
  6787. + if (!FP_INHIBIT_RESULTS) \
  6788. + _FP_PACK_RAW_2_P(Q,val,X); \
  6789. + } while (0)
  6790. +
  6791. +#define FP_ISSIGNAN_Q(X) _FP_ISSIGNAN(Q,2,X)
  6792. +#define FP_NEG_Q(R,X) _FP_NEG(Q,2,R,X)
  6793. +#define FP_ADD_Q(R,X,Y) _FP_ADD(Q,2,R,X,Y)
  6794. +#define FP_SUB_Q(R,X,Y) _FP_SUB(Q,2,R,X,Y)
  6795. +#define FP_MUL_Q(R,X,Y) _FP_MUL(Q,2,R,X,Y)
  6796. +#define FP_DIV_Q(R,X,Y) _FP_DIV(Q,2,R,X,Y)
  6797. +#define FP_SQRT_Q(R,X) _FP_SQRT(Q,2,R,X)
  6798. +#define _FP_SQRT_MEAT_Q(R,S,T,X,Q) _FP_SQRT_MEAT_2(R,S,T,X,Q)
  6799. +
  6800. +#define FP_CMP_Q(r,X,Y,un) _FP_CMP(Q,2,r,X,Y,un)
  6801. +#define FP_CMP_EQ_Q(r,X,Y) _FP_CMP_EQ(Q,2,r,X,Y)
  6802. +#define FP_CMP_UNORD_Q(r,X,Y) _FP_CMP_UNORD(Q,2,r,X,Y)
  6803. +
  6804. +#define FP_TO_INT_Q(r,X,rsz,rsg) _FP_TO_INT(Q,2,r,X,rsz,rsg)
  6805. +#define FP_FROM_INT_Q(X,r,rs,rt) _FP_FROM_INT(Q,2,X,r,rs,rt)
  6806. +
  6807. +#define _FP_FRAC_HIGH_Q(X) _FP_FRAC_HIGH_2(X)
  6808. +#define _FP_FRAC_HIGH_RAW_Q(X) _FP_FRAC_HIGH_2(X)
  6809. +
  6810. +#endif /* not _FP_W_TYPE_SIZE < 64 */
  6811. diff -Naur uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/sfp-machine.h uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/sfp-machine.h
  6812. --- uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/sfp-machine.h 1970-01-01 01:00:00.000000000 +0100
  6813. +++ uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/sfp-machine.h 2010-10-14 14:05:37.000000000 +0200
  6814. @@ -0,0 +1,213 @@
  6815. +/* Machine-dependent software floating-point definitions.
  6816. + Sparc userland (_Q_*) version.
  6817. + Copyright (C) 1997,1998,1999, 2002, 2006 Free Software Foundation, Inc.
  6818. + This file is part of the GNU C Library.
  6819. + Contributed by Richard Henderson (rth@cygnus.com),
  6820. + Jakub Jelinek (jj@ultra.linux.cz) and
  6821. + David S. Miller (davem@redhat.com).
  6822. +
  6823. + The GNU C Library is free software; you can redistribute it and/or
  6824. + modify it under the terms of the GNU Lesser General Public
  6825. + License as published by the Free Software Foundation; either
  6826. + version 2.1 of the License, or (at your option) any later version.
  6827. +
  6828. + The GNU C Library is distributed in the hope that it will be useful,
  6829. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  6830. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  6831. + Lesser General Public License for more details.
  6832. +
  6833. + You should have received a copy of the GNU Lesser General Public
  6834. + License along with the GNU C Library; if not, write to the Free
  6835. + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  6836. + 02111-1307 USA. */
  6837. +
  6838. +#include <fpu_control.h>
  6839. +#include <stdlib.h>
  6840. +
  6841. +#define _FP_W_TYPE_SIZE 32
  6842. +#define _FP_W_TYPE unsigned long
  6843. +#define _FP_WS_TYPE signed long
  6844. +#define _FP_I_TYPE long
  6845. +
  6846. +#define _FP_MUL_MEAT_S(R,X,Y) \
  6847. + _FP_MUL_MEAT_1_wide(_FP_WFRACBITS_S,R,X,Y,umul_ppmm)
  6848. +#define _FP_MUL_MEAT_D(R,X,Y) \
  6849. + _FP_MUL_MEAT_2_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm)
  6850. +#define _FP_MUL_MEAT_Q(R,X,Y) \
  6851. + _FP_MUL_MEAT_4_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm)
  6852. +
  6853. +#define _FP_DIV_MEAT_S(R,X,Y) _FP_DIV_MEAT_1_udiv(S,R,X,Y)
  6854. +#define _FP_DIV_MEAT_D(R,X,Y) _FP_DIV_MEAT_2_udiv(D,R,X,Y)
  6855. +#define _FP_DIV_MEAT_Q(R,X,Y) _FP_DIV_MEAT_4_udiv(Q,R,X,Y)
  6856. +
  6857. +#define _FP_NANFRAC_S ((_FP_QNANBIT_S << 1) - 1)
  6858. +#define _FP_NANFRAC_D ((_FP_QNANBIT_D << 1) - 1), -1
  6859. +#define _FP_NANFRAC_Q ((_FP_QNANBIT_Q << 1) - 1), -1, -1, -1
  6860. +#define _FP_NANSIGN_S 0
  6861. +#define _FP_NANSIGN_D 0
  6862. +#define _FP_NANSIGN_Q 0
  6863. +
  6864. +#define _FP_KEEPNANFRACP 1
  6865. +
  6866. +/* If one NaN is signaling and the other is not,
  6867. + * we choose that one, otherwise we choose X.
  6868. + */
  6869. +/* For _Qp_* and _Q_*, this should prefer X, for
  6870. + * CPU instruction emulation this should prefer Y.
  6871. + * (see SPAMv9 B.2.2 section).
  6872. + */
  6873. +#define _FP_CHOOSENAN(fs, wc, R, X, Y, OP) \
  6874. + do { \
  6875. + if ((_FP_FRAC_HIGH_RAW_##fs(X) & _FP_QNANBIT_##fs) \
  6876. + && !(_FP_FRAC_HIGH_RAW_##fs(Y) & _FP_QNANBIT_##fs)) \
  6877. + { \
  6878. + R##_s = Y##_s; \
  6879. + _FP_FRAC_COPY_##wc(R,Y); \
  6880. + } \
  6881. + else \
  6882. + { \
  6883. + R##_s = X##_s; \
  6884. + _FP_FRAC_COPY_##wc(R,X); \
  6885. + } \
  6886. + R##_c = FP_CLS_NAN; \
  6887. + } while (0)
  6888. +
  6889. +/* Some assembly to speed things up. */
  6890. +#define __FP_FRAC_ADD_3(r2,r1,r0,x2,x1,x0,y2,y1,y0) \
  6891. + __asm__ ("addcc %r7,%8,%2\n\
  6892. + addxcc %r5,%6,%1\n\
  6893. + addx %r3,%4,%0" \
  6894. + : "=r" ((USItype)(r2)), \
  6895. + "=&r" ((USItype)(r1)), \
  6896. + "=&r" ((USItype)(r0)) \
  6897. + : "%rJ" ((USItype)(x2)), \
  6898. + "rI" ((USItype)(y2)), \
  6899. + "%rJ" ((USItype)(x1)), \
  6900. + "rI" ((USItype)(y1)), \
  6901. + "%rJ" ((USItype)(x0)), \
  6902. + "rI" ((USItype)(y0)) \
  6903. + : "cc")
  6904. +
  6905. +#define __FP_FRAC_SUB_3(r2,r1,r0,x2,x1,x0,y2,y1,y0) \
  6906. + __asm__ ("subcc %r7,%8,%2\n\
  6907. + subxcc %r5,%6,%1\n\
  6908. + subx %r3,%4,%0" \
  6909. + : "=r" ((USItype)(r2)), \
  6910. + "=&r" ((USItype)(r1)), \
  6911. + "=&r" ((USItype)(r0)) \
  6912. + : "%rJ" ((USItype)(x2)), \
  6913. + "rI" ((USItype)(y2)), \
  6914. + "%rJ" ((USItype)(x1)), \
  6915. + "rI" ((USItype)(y1)), \
  6916. + "%rJ" ((USItype)(x0)), \
  6917. + "rI" ((USItype)(y0)) \
  6918. + : "cc")
  6919. +
  6920. +#define __FP_FRAC_ADD_4(r3,r2,r1,r0,x3,x2,x1,x0,y3,y2,y1,y0) \
  6921. + do { \
  6922. + /* We need to fool gcc, as we need to pass more than 10 \
  6923. + input/outputs. */ \
  6924. + register USItype _t1 __asm__ ("g1"), _t2 __asm__ ("g2"); \
  6925. + __asm__ __volatile__ ("\
  6926. + addcc %r8,%9,%1\n\
  6927. + addxcc %r6,%7,%0\n\
  6928. + addxcc %r4,%5,%%g2\n\
  6929. + addx %r2,%3,%%g1" \
  6930. + : "=&r" ((USItype)(r1)), \
  6931. + "=&r" ((USItype)(r0)) \
  6932. + : "%rJ" ((USItype)(x3)), \
  6933. + "rI" ((USItype)(y3)), \
  6934. + "%rJ" ((USItype)(x2)), \
  6935. + "rI" ((USItype)(y2)), \
  6936. + "%rJ" ((USItype)(x1)), \
  6937. + "rI" ((USItype)(y1)), \
  6938. + "%rJ" ((USItype)(x0)), \
  6939. + "rI" ((USItype)(y0)) \
  6940. + : "cc", "g1", "g2"); \
  6941. + __asm__ __volatile__ ("" : "=r" (_t1), "=r" (_t2)); \
  6942. + r3 = _t1; r2 = _t2; \
  6943. + } while (0)
  6944. +
  6945. +#define __FP_FRAC_SUB_4(r3,r2,r1,r0,x3,x2,x1,x0,y3,y2,y1,y0) \
  6946. + do { \
  6947. + /* We need to fool gcc, as we need to pass more than 10 \
  6948. + input/outputs. */ \
  6949. + register USItype _t1 __asm__ ("g1"), _t2 __asm__ ("g2"); \
  6950. + __asm__ __volatile__ ("\
  6951. + subcc %r8,%9,%1\n\
  6952. + subxcc %r6,%7,%0\n\
  6953. + subxcc %r4,%5,%%g2\n\
  6954. + subx %r2,%3,%%g1" \
  6955. + : "=&r" ((USItype)(r1)), \
  6956. + "=&r" ((USItype)(r0)) \
  6957. + : "%rJ" ((USItype)(x3)), \
  6958. + "rI" ((USItype)(y3)), \
  6959. + "%rJ" ((USItype)(x2)), \
  6960. + "rI" ((USItype)(y2)), \
  6961. + "%rJ" ((USItype)(x1)), \
  6962. + "rI" ((USItype)(y1)), \
  6963. + "%rJ" ((USItype)(x0)), \
  6964. + "rI" ((USItype)(y0)) \
  6965. + : "cc", "g1", "g2"); \
  6966. + __asm__ __volatile__ ("" : "=r" (_t1), "=r" (_t2)); \
  6967. + r3 = _t1; r2 = _t2; \
  6968. + } while (0)
  6969. +
  6970. +#define __FP_FRAC_DEC_3(x2,x1,x0,y2,y1,y0) __FP_FRAC_SUB_3(x2,x1,x0,x2,x1,x0,y2,y1,y0)
  6971. +
  6972. +#define __FP_FRAC_DEC_4(x3,x2,x1,x0,y3,y2,y1,y0) __FP_FRAC_SUB_4(x3,x2,x1,x0,x3,x2,x1,x0,y3,y2,y1,y0)
  6973. +
  6974. +#define __FP_FRAC_ADDI_4(x3,x2,x1,x0,i) \
  6975. + __asm__ ("addcc %3,%4,%3\n\
  6976. + addxcc %2,%%g0,%2\n\
  6977. + addxcc %1,%%g0,%1\n\
  6978. + addx %0,%%g0,%0" \
  6979. + : "=&r" ((USItype)(x3)), \
  6980. + "=&r" ((USItype)(x2)), \
  6981. + "=&r" ((USItype)(x1)), \
  6982. + "=&r" ((USItype)(x0)) \
  6983. + : "rI" ((USItype)(i)), \
  6984. + "0" ((USItype)(x3)), \
  6985. + "1" ((USItype)(x2)), \
  6986. + "2" ((USItype)(x1)), \
  6987. + "3" ((USItype)(x0)) \
  6988. + : "cc")
  6989. +
  6990. +/* Obtain the current rounding mode. */
  6991. +#ifndef FP_ROUNDMODE
  6992. +#define FP_ROUNDMODE ((_fcw >> 30) & 0x3)
  6993. +#endif
  6994. +
  6995. +/* Exception flags. */
  6996. +#define FP_EX_INVALID (1 << 4)
  6997. +#define FP_EX_OVERFLOW (1 << 3)
  6998. +#define FP_EX_UNDERFLOW (1 << 2)
  6999. +#define FP_EX_DIVZERO (1 << 1)
  7000. +#define FP_EX_INEXACT (1 << 0)
  7001. +
  7002. +#define _FP_DECL_EX fpu_control_t _fcw
  7003. +
  7004. +#define FP_INIT_ROUNDMODE \
  7005. +do { \
  7006. + _FPU_GETCW(_fcw); \
  7007. +} while (0)
  7008. +
  7009. +/* Simulate exceptions using double arithmetics. */
  7010. +extern double ___Q_simulate_exceptions(int exc);
  7011. +
  7012. +#define FP_HANDLE_EXCEPTIONS \
  7013. +do { \
  7014. + if (!_fex) \
  7015. + { \
  7016. + /* This is the common case, so we do it inline. \
  7017. + * We need to clear cexc bits if any. \
  7018. + */ \
  7019. + extern unsigned long long ___Q_numbers[]; \
  7020. + __asm__ __volatile__("\
  7021. + ldd [%0], %%f30\n\
  7022. + faddd %%f30, %%f30, %%f30\
  7023. + " : : "r" (___Q_numbers) : "f30"); \
  7024. + } \
  7025. + else \
  7026. + ___Q_simulate_exceptions (_fex); \
  7027. +} while (0)
  7028. diff -Naur uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/single.h uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/single.h
  7029. --- uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/single.h 1970-01-01 01:00:00.000000000 +0100
  7030. +++ uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/single.h 2010-10-14 14:05:37.000000000 +0200
  7031. @@ -0,0 +1,151 @@
  7032. +/* Software floating-point emulation.
  7033. + Definitions for IEEE Single Precision.
  7034. + Copyright (C) 1997,1998,1999,2006 Free Software Foundation, Inc.
  7035. + This file is part of the GNU C Library.
  7036. + Contributed by Richard Henderson (rth@cygnus.com),
  7037. + Jakub Jelinek (jj@ultra.linux.cz),
  7038. + David S. Miller (davem@redhat.com) and
  7039. + Peter Maydell (pmaydell@chiark.greenend.org.uk).
  7040. +
  7041. + The GNU C Library is free software; you can redistribute it and/or
  7042. + modify it under the terms of the GNU Lesser General Public
  7043. + License as published by the Free Software Foundation; either
  7044. + version 2.1 of the License, or (at your option) any later version.
  7045. +
  7046. + In addition to the permissions in the GNU Lesser General Public
  7047. + License, the Free Software Foundation gives you unlimited
  7048. + permission to link the compiled version of this file into
  7049. + combinations with other programs, and to distribute those
  7050. + combinations without any restriction coming from the use of this
  7051. + file. (The Lesser General Public License restrictions do apply in
  7052. + other respects; for example, they cover modification of the file,
  7053. + and distribution when not linked into a combine executable.)
  7054. +
  7055. + The GNU C Library is distributed in the hope that it will be useful,
  7056. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  7057. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  7058. + Lesser General Public License for more details.
  7059. +
  7060. + You should have received a copy of the GNU Lesser General Public
  7061. + License along with the GNU C Library; if not, write to the Free
  7062. + Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
  7063. + MA 02110-1301, USA. */
  7064. +
  7065. +#if _FP_W_TYPE_SIZE < 32
  7066. +#error "Here's a nickel kid. Go buy yourself a real computer."
  7067. +#endif
  7068. +
  7069. +#define _FP_FRACTBITS_S _FP_W_TYPE_SIZE
  7070. +
  7071. +#define _FP_FRACBITS_S 24
  7072. +#define _FP_FRACXBITS_S (_FP_FRACTBITS_S - _FP_FRACBITS_S)
  7073. +#define _FP_WFRACBITS_S (_FP_WORKBITS + _FP_FRACBITS_S)
  7074. +#define _FP_WFRACXBITS_S (_FP_FRACTBITS_S - _FP_WFRACBITS_S)
  7075. +#define _FP_EXPBITS_S 8
  7076. +#define _FP_EXPBIAS_S 127
  7077. +#define _FP_EXPMAX_S 255
  7078. +#define _FP_QNANBIT_S ((_FP_W_TYPE)1 << (_FP_FRACBITS_S-2))
  7079. +#define _FP_QNANBIT_SH_S ((_FP_W_TYPE)1 << (_FP_FRACBITS_S-2+_FP_WORKBITS))
  7080. +#define _FP_IMPLBIT_S ((_FP_W_TYPE)1 << (_FP_FRACBITS_S-1))
  7081. +#define _FP_IMPLBIT_SH_S ((_FP_W_TYPE)1 << (_FP_FRACBITS_S-1+_FP_WORKBITS))
  7082. +#define _FP_OVERFLOW_S ((_FP_W_TYPE)1 << (_FP_WFRACBITS_S))
  7083. +
  7084. +/* The implementation of _FP_MUL_MEAT_S and _FP_DIV_MEAT_S should be
  7085. + chosen by the target machine. */
  7086. +
  7087. +typedef float SFtype __attribute__((mode(SF)));
  7088. +
  7089. +union _FP_UNION_S
  7090. +{
  7091. + SFtype flt;
  7092. + struct {
  7093. +#if __BYTE_ORDER == __BIG_ENDIAN
  7094. + unsigned sign : 1;
  7095. + unsigned exp : _FP_EXPBITS_S;
  7096. + unsigned frac : _FP_FRACBITS_S - (_FP_IMPLBIT_S != 0);
  7097. +#else
  7098. + unsigned frac : _FP_FRACBITS_S - (_FP_IMPLBIT_S != 0);
  7099. + unsigned exp : _FP_EXPBITS_S;
  7100. + unsigned sign : 1;
  7101. +#endif
  7102. + } bits __attribute__((packed));
  7103. +};
  7104. +
  7105. +#define FP_DECL_S(X) _FP_DECL(1,X)
  7106. +#define FP_UNPACK_RAW_S(X,val) _FP_UNPACK_RAW_1(S,X,val)
  7107. +#define FP_UNPACK_RAW_SP(X,val) _FP_UNPACK_RAW_1_P(S,X,val)
  7108. +#define FP_PACK_RAW_S(val,X) _FP_PACK_RAW_1(S,val,X)
  7109. +#define FP_PACK_RAW_SP(val,X) \
  7110. + do { \
  7111. + if (!FP_INHIBIT_RESULTS) \
  7112. + _FP_PACK_RAW_1_P(S,val,X); \
  7113. + } while (0)
  7114. +
  7115. +#define FP_UNPACK_S(X,val) \
  7116. + do { \
  7117. + _FP_UNPACK_RAW_1(S,X,val); \
  7118. + _FP_UNPACK_CANONICAL(S,1,X); \
  7119. + } while (0)
  7120. +
  7121. +#define FP_UNPACK_SP(X,val) \
  7122. + do { \
  7123. + _FP_UNPACK_RAW_1_P(S,X,val); \
  7124. + _FP_UNPACK_CANONICAL(S,1,X); \
  7125. + } while (0)
  7126. +
  7127. +#define FP_UNPACK_SEMIRAW_S(X,val) \
  7128. + do { \
  7129. + _FP_UNPACK_RAW_1(S,X,val); \
  7130. + _FP_UNPACK_SEMIRAW(S,1,X); \
  7131. + } while (0)
  7132. +
  7133. +#define FP_UNPACK_SEMIRAW_SP(X,val) \
  7134. + do { \
  7135. + _FP_UNPACK_RAW_1_P(S,X,val); \
  7136. + _FP_UNPACK_SEMIRAW(S,1,X); \
  7137. + } while (0)
  7138. +
  7139. +#define FP_PACK_S(val,X) \
  7140. + do { \
  7141. + _FP_PACK_CANONICAL(S,1,X); \
  7142. + _FP_PACK_RAW_1(S,val,X); \
  7143. + } while (0)
  7144. +
  7145. +#define FP_PACK_SP(val,X) \
  7146. + do { \
  7147. + _FP_PACK_CANONICAL(S,1,X); \
  7148. + if (!FP_INHIBIT_RESULTS) \
  7149. + _FP_PACK_RAW_1_P(S,val,X); \
  7150. + } while (0)
  7151. +
  7152. +#define FP_PACK_SEMIRAW_S(val,X) \
  7153. + do { \
  7154. + _FP_PACK_SEMIRAW(S,1,X); \
  7155. + _FP_PACK_RAW_1(S,val,X); \
  7156. + } while (0)
  7157. +
  7158. +#define FP_PACK_SEMIRAW_SP(val,X) \
  7159. + do { \
  7160. + _FP_PACK_SEMIRAW(S,1,X); \
  7161. + if (!FP_INHIBIT_RESULTS) \
  7162. + _FP_PACK_RAW_1_P(S,val,X); \
  7163. + } while (0)
  7164. +
  7165. +#define FP_ISSIGNAN_S(X) _FP_ISSIGNAN(S,1,X)
  7166. +#define FP_NEG_S(R,X) _FP_NEG(S,1,R,X)
  7167. +#define FP_ADD_S(R,X,Y) _FP_ADD(S,1,R,X,Y)
  7168. +#define FP_SUB_S(R,X,Y) _FP_SUB(S,1,R,X,Y)
  7169. +#define FP_MUL_S(R,X,Y) _FP_MUL(S,1,R,X,Y)
  7170. +#define FP_DIV_S(R,X,Y) _FP_DIV(S,1,R,X,Y)
  7171. +#define FP_SQRT_S(R,X) _FP_SQRT(S,1,R,X)
  7172. +#define _FP_SQRT_MEAT_S(R,S,T,X,Q) _FP_SQRT_MEAT_1(R,S,T,X,Q)
  7173. +
  7174. +#define FP_CMP_S(r,X,Y,un) _FP_CMP(S,1,r,X,Y,un)
  7175. +#define FP_CMP_EQ_S(r,X,Y) _FP_CMP_EQ(S,1,r,X,Y)
  7176. +#define FP_CMP_UNORD_S(r,X,Y) _FP_CMP_UNORD(S,1,r,X,Y)
  7177. +
  7178. +#define FP_TO_INT_S(r,X,rsz,rsg) _FP_TO_INT(S,1,r,X,rsz,rsg)
  7179. +#define FP_FROM_INT_S(X,r,rs,rt) _FP_FROM_INT(S,1,X,r,rs,rt)
  7180. +
  7181. +#define _FP_FRAC_HIGH_S(X) _FP_FRAC_HIGH_1(X)
  7182. +#define _FP_FRAC_HIGH_RAW_S(X) _FP_FRAC_HIGH_1(X)
  7183. diff -Naur uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/soft-fp.h uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/soft-fp.h
  7184. --- uClibc-0.9.31.ori/libc/sysdeps/linux/sparc/soft-fp/soft-fp.h 1970-01-01 01:00:00.000000000 +0100
  7185. +++ uClibc-0.9.31/libc/sysdeps/linux/sparc/soft-fp/soft-fp.h 2010-10-14 14:05:37.000000000 +0200
  7186. @@ -0,0 +1,205 @@
  7187. +/* Software floating-point emulation.
  7188. + Copyright (C) 1997,1998,1999,2000,2002,2003,2005,2006,2007
  7189. + Free Software Foundation, Inc.
  7190. + This file is part of the GNU C Library.
  7191. + Contributed by Richard Henderson (rth@cygnus.com),
  7192. + Jakub Jelinek (jj@ultra.linux.cz),
  7193. + David S. Miller (davem@redhat.com) and
  7194. + Peter Maydell (pmaydell@chiark.greenend.org.uk).
  7195. +
  7196. + The GNU C Library is free software; you can redistribute it and/or
  7197. + modify it under the terms of the GNU Lesser General Public
  7198. + License as published by the Free Software Foundation; either
  7199. + version 2.1 of the License, or (at your option) any later version.
  7200. +
  7201. + In addition to the permissions in the GNU Lesser General Public
  7202. + License, the Free Software Foundation gives you unlimited
  7203. + permission to link the compiled version of this file into
  7204. + combinations with other programs, and to distribute those
  7205. + combinations without any restriction coming from the use of this
  7206. + file. (The Lesser General Public License restrictions do apply in
  7207. + other respects; for example, they cover modification of the file,
  7208. + and distribution when not linked into a combine executable.)
  7209. +
  7210. + The GNU C Library is distributed in the hope that it will be useful,
  7211. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  7212. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  7213. + Lesser General Public License for more details.
  7214. +
  7215. + You should have received a copy of the GNU Lesser General Public
  7216. + License along with the GNU C Library; if not, write to the Free
  7217. + Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
  7218. + MA 02110-1301, USA. */
  7219. +
  7220. +#ifndef SOFT_FP_H
  7221. +#define SOFT_FP_H
  7222. +
  7223. +#include "sfp-machine.h"
  7224. +
  7225. +/* Allow sfp-machine to have its own byte order definitions. */
  7226. +#ifndef __BYTE_ORDER
  7227. +#ifdef _LIBC
  7228. +#include <endian.h>
  7229. +#else
  7230. +#error "endianness not defined by sfp-machine.h"
  7231. +#endif
  7232. +#endif
  7233. +
  7234. +#define _FP_WORKBITS 3
  7235. +#define _FP_WORK_LSB ((_FP_W_TYPE)1 << 3)
  7236. +#define _FP_WORK_ROUND ((_FP_W_TYPE)1 << 2)
  7237. +#define _FP_WORK_GUARD ((_FP_W_TYPE)1 << 1)
  7238. +#define _FP_WORK_STICKY ((_FP_W_TYPE)1 << 0)
  7239. +
  7240. +#ifndef FP_RND_NEAREST
  7241. +# define FP_RND_NEAREST 0
  7242. +# define FP_RND_ZERO 1
  7243. +# define FP_RND_PINF 2
  7244. +# define FP_RND_MINF 3
  7245. +#endif
  7246. +#ifndef FP_ROUNDMODE
  7247. +# define FP_ROUNDMODE FP_RND_NEAREST
  7248. +#endif
  7249. +
  7250. +/* By default don't care about exceptions. */
  7251. +#ifndef FP_EX_INVALID
  7252. +#define FP_EX_INVALID 0
  7253. +#endif
  7254. +#ifndef FP_EX_OVERFLOW
  7255. +#define FP_EX_OVERFLOW 0
  7256. +#endif
  7257. +#ifndef FP_EX_UNDERFLOW
  7258. +#define FP_EX_UNDERFLOW 0
  7259. +#endif
  7260. +#ifndef FP_EX_DIVZERO
  7261. +#define FP_EX_DIVZERO 0
  7262. +#endif
  7263. +#ifndef FP_EX_INEXACT
  7264. +#define FP_EX_INEXACT 0
  7265. +#endif
  7266. +#ifndef FP_EX_DENORM
  7267. +#define FP_EX_DENORM 0
  7268. +#endif
  7269. +
  7270. +#ifdef _FP_DECL_EX
  7271. +#define FP_DECL_EX \
  7272. + int _fex = 0; \
  7273. + _FP_DECL_EX
  7274. +#else
  7275. +#define FP_DECL_EX int _fex = 0
  7276. +#endif
  7277. +
  7278. +#ifndef FP_INIT_ROUNDMODE
  7279. +#define FP_INIT_ROUNDMODE do {} while (0)
  7280. +#endif
  7281. +
  7282. +#ifndef FP_HANDLE_EXCEPTIONS
  7283. +#define FP_HANDLE_EXCEPTIONS do {} while (0)
  7284. +#endif
  7285. +
  7286. +#ifndef FP_INHIBIT_RESULTS
  7287. +/* By default we write the results always.
  7288. + * sfp-machine may override this and e.g.
  7289. + * check if some exceptions are unmasked
  7290. + * and inhibit it in such a case.
  7291. + */
  7292. +#define FP_INHIBIT_RESULTS 0
  7293. +#endif
  7294. +
  7295. +#define FP_SET_EXCEPTION(ex) \
  7296. + _fex |= (ex)
  7297. +
  7298. +#define FP_UNSET_EXCEPTION(ex) \
  7299. + _fex &= ~(ex)
  7300. +
  7301. +#define FP_CLEAR_EXCEPTIONS \
  7302. + _fex = 0
  7303. +
  7304. +#define _FP_ROUND_NEAREST(wc, X) \
  7305. +do { \
  7306. + if ((_FP_FRAC_LOW_##wc(X) & 15) != _FP_WORK_ROUND) \
  7307. + _FP_FRAC_ADDI_##wc(X, _FP_WORK_ROUND); \
  7308. +} while (0)
  7309. +
  7310. +#define _FP_ROUND_ZERO(wc, X) (void)0
  7311. +
  7312. +#define _FP_ROUND_PINF(wc, X) \
  7313. +do { \
  7314. + if (!X##_s && (_FP_FRAC_LOW_##wc(X) & 7)) \
  7315. + _FP_FRAC_ADDI_##wc(X, _FP_WORK_LSB); \
  7316. +} while (0)
  7317. +
  7318. +#define _FP_ROUND_MINF(wc, X) \
  7319. +do { \
  7320. + if (X##_s && (_FP_FRAC_LOW_##wc(X) & 7)) \
  7321. + _FP_FRAC_ADDI_##wc(X, _FP_WORK_LSB); \
  7322. +} while (0)
  7323. +
  7324. +#define _FP_ROUND(wc, X) \
  7325. +do { \
  7326. + if (_FP_FRAC_LOW_##wc(X) & 7) \
  7327. + FP_SET_EXCEPTION(FP_EX_INEXACT); \
  7328. + switch (FP_ROUNDMODE) \
  7329. + { \
  7330. + case FP_RND_NEAREST: \
  7331. + _FP_ROUND_NEAREST(wc,X); \
  7332. + break; \
  7333. + case FP_RND_ZERO: \
  7334. + _FP_ROUND_ZERO(wc,X); \
  7335. + break; \
  7336. + case FP_RND_PINF: \
  7337. + _FP_ROUND_PINF(wc,X); \
  7338. + break; \
  7339. + case FP_RND_MINF: \
  7340. + _FP_ROUND_MINF(wc,X); \
  7341. + break; \
  7342. + } \
  7343. +} while (0)
  7344. +
  7345. +#define FP_CLS_NORMAL 0
  7346. +#define FP_CLS_ZERO 1
  7347. +#define FP_CLS_INF 2
  7348. +#define FP_CLS_NAN 3
  7349. +
  7350. +#define _FP_CLS_COMBINE(x,y) (((x) << 2) | (y))
  7351. +
  7352. +#include "op-1.h"
  7353. +#include "op-2.h"
  7354. +#include "op-4.h"
  7355. +#include "op-8.h"
  7356. +#include "op-common.h"
  7357. +
  7358. +/* Sigh. Silly things longlong.h needs. */
  7359. +#define UWtype _FP_W_TYPE
  7360. +#define W_TYPE_SIZE _FP_W_TYPE_SIZE
  7361. +
  7362. +typedef int QItype __attribute__((mode(QI)));
  7363. +typedef int SItype __attribute__((mode(SI)));
  7364. +typedef int DItype __attribute__((mode(DI)));
  7365. +typedef unsigned int UQItype __attribute__((mode(QI)));
  7366. +typedef unsigned int USItype __attribute__((mode(SI)));
  7367. +typedef unsigned int UDItype __attribute__((mode(DI)));
  7368. +#if _FP_W_TYPE_SIZE == 32
  7369. +typedef unsigned int UHWtype __attribute__((mode(HI)));
  7370. +#elif _FP_W_TYPE_SIZE == 64
  7371. +typedef USItype UHWtype;
  7372. +#endif
  7373. +
  7374. +#ifndef CMPtype
  7375. +#define CMPtype int
  7376. +#endif
  7377. +
  7378. +#define SI_BITS (__CHAR_BIT__ * (int)sizeof(SItype))
  7379. +#define DI_BITS (__CHAR_BIT__ * (int)sizeof(DItype))
  7380. +
  7381. +#ifndef umul_ppmm
  7382. +#include "longlong.h"
  7383. +#endif
  7384. +
  7385. +#ifdef _LIBC
  7386. +#include <stdlib.h>
  7387. +#else
  7388. +extern void abort (void);
  7389. +#endif
  7390. +
  7391. +#endif