minilzo.c 209 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372
  1. /* minilzo.c -- mini subset of the LZO real-time data compression library
  2. This file is part of the LZO real-time data compression library.
  3. Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
  4. All Rights Reserved.
  5. The LZO library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU General Public License as
  7. published by the Free Software Foundation; either version 2 of
  8. the License, or (at your option) any later version.
  9. The LZO library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with the LZO library; see the file COPYING.
  15. If not, write to the Free Software Foundation, Inc.,
  16. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  17. Markus F.X.J. Oberhumer
  18. <markus@oberhumer.com>
  19. http://www.oberhumer.com/opensource/lzo/
  20. */
  21. /*
  22. * NOTE:
  23. * the full LZO package can be found at
  24. * http://www.oberhumer.com/opensource/lzo/
  25. */
  26. #include <stdio.h>
  27. #define __LZO_IN_MINILZO 1
  28. #if defined(LZO_CFG_FREESTANDING)
  29. # undef MINILZO_HAVE_CONFIG_H
  30. # define LZO_LIBC_FREESTANDING 1
  31. # define LZO_OS_FREESTANDING 1
  32. #endif
  33. #ifdef MINILZO_HAVE_CONFIG_H
  34. # include <config.h>
  35. #endif
  36. #include <limits.h>
  37. #include <stddef.h>
  38. #if defined(MINILZO_CFG_USE_INTERNAL_LZODEFS)
  39. #ifndef __LZODEFS_H_INCLUDED
  40. #define __LZODEFS_H_INCLUDED 1
  41. #if defined(__CYGWIN32__) && !defined(__CYGWIN__)
  42. # define __CYGWIN__ __CYGWIN32__
  43. #endif
  44. #if 1 && defined(__INTERIX) && defined(__GNUC__) && !defined(_ALL_SOURCE)
  45. # define _ALL_SOURCE 1
  46. #endif
  47. #if defined(__mips__) && defined(__R5900__)
  48. # if !defined(__LONG_MAX__)
  49. # define __LONG_MAX__ 9223372036854775807L
  50. # endif
  51. #endif
  52. #if 0
  53. #elif !defined(__LZO_LANG_OVERRIDE)
  54. #if (defined(__clang__) || defined(__GNUC__)) && defined(__ASSEMBLER__)
  55. # if (__ASSEMBLER__+0) <= 0
  56. # error "__ASSEMBLER__"
  57. # else
  58. # define LZO_LANG_ASSEMBLER 1
  59. # endif
  60. #elif defined(__cplusplus)
  61. # if (__cplusplus+0) <= 0
  62. # error "__cplusplus"
  63. # elif (__cplusplus < 199711L)
  64. # define LZO_LANG_CXX 1
  65. # elif defined(_MSC_VER) && defined(_MSVC_LANG) && (_MSVC_LANG+0 >= 201402L) && 1
  66. # define LZO_LANG_CXX _MSVC_LANG
  67. # else
  68. # define LZO_LANG_CXX __cplusplus
  69. # endif
  70. # define LZO_LANG_CPLUSPLUS LZO_LANG_CXX
  71. #else
  72. # if defined(__STDC_VERSION__) && (__STDC_VERSION__+0 >= 199409L)
  73. # define LZO_LANG_C __STDC_VERSION__
  74. # else
  75. # define LZO_LANG_C 1
  76. # endif
  77. #endif
  78. #endif
  79. #if !defined(LZO_CFG_NO_DISABLE_WUNDEF)
  80. #if defined(__ARMCC_VERSION)
  81. # pragma diag_suppress 193
  82. #elif defined(__clang__) && defined(__clang_minor__)
  83. # pragma clang diagnostic ignored "-Wundef"
  84. #elif defined(__INTEL_COMPILER)
  85. # pragma warning(disable: 193)
  86. #elif defined(__KEIL__) && defined(__C166__)
  87. # pragma warning disable = 322
  88. #elif defined(__GNUC__) && defined(__GNUC_MINOR__) && !defined(__PATHSCALE__)
  89. # if ((__GNUC__-0) >= 5 || ((__GNUC__-0) == 4 && (__GNUC_MINOR__-0) >= 2))
  90. # pragma GCC diagnostic ignored "-Wundef"
  91. # endif
  92. #elif defined(_MSC_VER) && !defined(__clang__) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__)
  93. # if ((_MSC_VER-0) >= 1300)
  94. # pragma warning(disable: 4668)
  95. # endif
  96. #endif
  97. #endif
  98. #if 0 && defined(__POCC__) && defined(_WIN32)
  99. # if (__POCC__ >= 400)
  100. # pragma warn(disable: 2216)
  101. # endif
  102. #endif
  103. #if 0 && defined(__WATCOMC__)
  104. # if (__WATCOMC__ >= 1050) && (__WATCOMC__ < 1060)
  105. # pragma warning 203 9
  106. # endif
  107. #endif
  108. #if defined(__BORLANDC__) && defined(__MSDOS__) && !defined(__FLAT__)
  109. # pragma option -h
  110. #endif
  111. #if !(LZO_CFG_NO_DISABLE_WCRTNONSTDC)
  112. #ifndef _CRT_NONSTDC_NO_DEPRECATE
  113. #define _CRT_NONSTDC_NO_DEPRECATE 1
  114. #endif
  115. #ifndef _CRT_NONSTDC_NO_WARNINGS
  116. #define _CRT_NONSTDC_NO_WARNINGS 1
  117. #endif
  118. #ifndef _CRT_SECURE_NO_DEPRECATE
  119. #define _CRT_SECURE_NO_DEPRECATE 1
  120. #endif
  121. #ifndef _CRT_SECURE_NO_WARNINGS
  122. #define _CRT_SECURE_NO_WARNINGS 1
  123. #endif
  124. #endif
  125. #if 0
  126. #define LZO_0xffffUL 0xfffful
  127. #define LZO_0xffffffffUL 0xfffffffful
  128. #else
  129. #define LZO_0xffffUL 65535ul
  130. #define LZO_0xffffffffUL 4294967295ul
  131. #endif
  132. #define LZO_0xffffL LZO_0xffffUL
  133. #define LZO_0xffffffffL LZO_0xffffffffUL
  134. #if (LZO_0xffffL == LZO_0xffffffffL)
  135. # error "your preprocessor is broken 1"
  136. #endif
  137. #if (16ul * 16384ul != 262144ul)
  138. # error "your preprocessor is broken 2"
  139. #endif
  140. #if 0
  141. #if (32767 >= 4294967295ul)
  142. # error "your preprocessor is broken 3"
  143. #endif
  144. #if (65535u >= 4294967295ul)
  145. # error "your preprocessor is broken 4"
  146. #endif
  147. #endif
  148. #if defined(__COUNTER__)
  149. # ifndef LZO_CFG_USE_COUNTER
  150. # define LZO_CFG_USE_COUNTER 1
  151. # endif
  152. #else
  153. # undef LZO_CFG_USE_COUNTER
  154. #endif
  155. #if (UINT_MAX == LZO_0xffffL)
  156. #if defined(__ZTC__) && defined(__I86__) && !defined(__OS2__)
  157. # if !defined(MSDOS)
  158. # define MSDOS 1
  159. # endif
  160. # if !defined(_MSDOS)
  161. # define _MSDOS 1
  162. # endif
  163. #elif 0 && defined(__VERSION) && defined(MB_LEN_MAX)
  164. # if (__VERSION == 520) && (MB_LEN_MAX == 1)
  165. # if !defined(__AZTEC_C__)
  166. # define __AZTEC_C__ __VERSION
  167. # endif
  168. # if !defined(__DOS__)
  169. # define __DOS__ 1
  170. # endif
  171. # endif
  172. #endif
  173. #endif
  174. #if (UINT_MAX == LZO_0xffffL)
  175. #if defined(_MSC_VER) && defined(M_I86HM)
  176. # define ptrdiff_t long
  177. # define _PTRDIFF_T_DEFINED 1
  178. #endif
  179. #endif
  180. #if (UINT_MAX == LZO_0xffffL)
  181. # undef __LZO_RENAME_A
  182. # undef __LZO_RENAME_B
  183. # if defined(__AZTEC_C__) && defined(__DOS__)
  184. # define __LZO_RENAME_A 1
  185. # elif defined(_MSC_VER) && defined(MSDOS)
  186. # if (_MSC_VER < 600)
  187. # define __LZO_RENAME_A 1
  188. # elif (_MSC_VER < 700)
  189. # define __LZO_RENAME_B 1
  190. # endif
  191. # elif defined(__TSC__) && defined(__OS2__)
  192. # define __LZO_RENAME_A 1
  193. # elif defined(__MSDOS__) && defined(__TURBOC__) && (__TURBOC__ < 0x0410)
  194. # define __LZO_RENAME_A 1
  195. # elif defined(__PACIFIC__) && defined(DOS)
  196. # if !defined(__far)
  197. # define __far far
  198. # endif
  199. # if !defined(__near)
  200. # define __near near
  201. # endif
  202. # endif
  203. # if defined(__LZO_RENAME_A)
  204. # if !defined(__cdecl)
  205. # define __cdecl cdecl
  206. # endif
  207. # if !defined(__far)
  208. # define __far far
  209. # endif
  210. # if !defined(__huge)
  211. # define __huge huge
  212. # endif
  213. # if !defined(__near)
  214. # define __near near
  215. # endif
  216. # if !defined(__pascal)
  217. # define __pascal pascal
  218. # endif
  219. # if !defined(__huge)
  220. # define __huge huge
  221. # endif
  222. # elif defined(__LZO_RENAME_B)
  223. # if !defined(__cdecl)
  224. # define __cdecl _cdecl
  225. # endif
  226. # if !defined(__far)
  227. # define __far _far
  228. # endif
  229. # if !defined(__huge)
  230. # define __huge _huge
  231. # endif
  232. # if !defined(__near)
  233. # define __near _near
  234. # endif
  235. # if !defined(__pascal)
  236. # define __pascal _pascal
  237. # endif
  238. # elif (defined(__PUREC__) || defined(__TURBOC__)) && defined(__TOS__)
  239. # if !defined(__cdecl)
  240. # define __cdecl cdecl
  241. # endif
  242. # if !defined(__pascal)
  243. # define __pascal pascal
  244. # endif
  245. # endif
  246. # undef __LZO_RENAME_A
  247. # undef __LZO_RENAME_B
  248. #endif
  249. #if (UINT_MAX == LZO_0xffffL)
  250. #if defined(__AZTEC_C__) && defined(__DOS__)
  251. # define LZO_BROKEN_CDECL_ALT_SYNTAX 1
  252. #elif defined(_MSC_VER) && defined(MSDOS)
  253. # if (_MSC_VER < 600)
  254. # define LZO_BROKEN_INTEGRAL_CONSTANTS 1
  255. # endif
  256. # if (_MSC_VER < 700)
  257. # define LZO_BROKEN_INTEGRAL_PROMOTION 1
  258. # define LZO_BROKEN_SIZEOF 1
  259. # endif
  260. #elif defined(__PACIFIC__) && defined(DOS)
  261. # define LZO_BROKEN_INTEGRAL_CONSTANTS 1
  262. #elif defined(__TURBOC__) && defined(__MSDOS__)
  263. # if (__TURBOC__ < 0x0150)
  264. # define LZO_BROKEN_CDECL_ALT_SYNTAX 1
  265. # define LZO_BROKEN_INTEGRAL_CONSTANTS 1
  266. # define LZO_BROKEN_INTEGRAL_PROMOTION 1
  267. # endif
  268. # if (__TURBOC__ < 0x0200)
  269. # define LZO_BROKEN_SIZEOF 1
  270. # endif
  271. # if (__TURBOC__ < 0x0400) && defined(__cplusplus)
  272. # define LZO_BROKEN_CDECL_ALT_SYNTAX 1
  273. # endif
  274. #elif (defined(__PUREC__) || defined(__TURBOC__)) && defined(__TOS__)
  275. # define LZO_BROKEN_CDECL_ALT_SYNTAX 1
  276. # define LZO_BROKEN_SIZEOF 1
  277. #endif
  278. #endif
  279. #if defined(__WATCOMC__) && (__WATCOMC__ < 900)
  280. # define LZO_BROKEN_INTEGRAL_CONSTANTS 1
  281. #endif
  282. #if defined(_CRAY) && defined(_CRAY1)
  283. # define LZO_BROKEN_SIGNED_RIGHT_SHIFT 1
  284. #endif
  285. #define LZO_PP_STRINGIZE(x) #x
  286. #define LZO_PP_MACRO_EXPAND(x) LZO_PP_STRINGIZE(x)
  287. #define LZO_PP_CONCAT0() /*empty*/
  288. #define LZO_PP_CONCAT1(a) a
  289. #define LZO_PP_CONCAT2(a,b) a ## b
  290. #define LZO_PP_CONCAT3(a,b,c) a ## b ## c
  291. #define LZO_PP_CONCAT4(a,b,c,d) a ## b ## c ## d
  292. #define LZO_PP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e
  293. #define LZO_PP_CONCAT6(a,b,c,d,e,f) a ## b ## c ## d ## e ## f
  294. #define LZO_PP_CONCAT7(a,b,c,d,e,f,g) a ## b ## c ## d ## e ## f ## g
  295. #define LZO_PP_ECONCAT0() LZO_PP_CONCAT0()
  296. #define LZO_PP_ECONCAT1(a) LZO_PP_CONCAT1(a)
  297. #define LZO_PP_ECONCAT2(a,b) LZO_PP_CONCAT2(a,b)
  298. #define LZO_PP_ECONCAT3(a,b,c) LZO_PP_CONCAT3(a,b,c)
  299. #define LZO_PP_ECONCAT4(a,b,c,d) LZO_PP_CONCAT4(a,b,c,d)
  300. #define LZO_PP_ECONCAT5(a,b,c,d,e) LZO_PP_CONCAT5(a,b,c,d,e)
  301. #define LZO_PP_ECONCAT6(a,b,c,d,e,f) LZO_PP_CONCAT6(a,b,c,d,e,f)
  302. #define LZO_PP_ECONCAT7(a,b,c,d,e,f,g) LZO_PP_CONCAT7(a,b,c,d,e,f,g)
  303. #define LZO_PP_EMPTY /*empty*/
  304. #define LZO_PP_EMPTY0() /*empty*/
  305. #define LZO_PP_EMPTY1(a) /*empty*/
  306. #define LZO_PP_EMPTY2(a,b) /*empty*/
  307. #define LZO_PP_EMPTY3(a,b,c) /*empty*/
  308. #define LZO_PP_EMPTY4(a,b,c,d) /*empty*/
  309. #define LZO_PP_EMPTY5(a,b,c,d,e) /*empty*/
  310. #define LZO_PP_EMPTY6(a,b,c,d,e,f) /*empty*/
  311. #define LZO_PP_EMPTY7(a,b,c,d,e,f,g) /*empty*/
  312. #if 1
  313. #define LZO_CPP_STRINGIZE(x) #x
  314. #define LZO_CPP_MACRO_EXPAND(x) LZO_CPP_STRINGIZE(x)
  315. #define LZO_CPP_CONCAT2(a,b) a ## b
  316. #define LZO_CPP_CONCAT3(a,b,c) a ## b ## c
  317. #define LZO_CPP_CONCAT4(a,b,c,d) a ## b ## c ## d
  318. #define LZO_CPP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e
  319. #define LZO_CPP_CONCAT6(a,b,c,d,e,f) a ## b ## c ## d ## e ## f
  320. #define LZO_CPP_CONCAT7(a,b,c,d,e,f,g) a ## b ## c ## d ## e ## f ## g
  321. #define LZO_CPP_ECONCAT2(a,b) LZO_CPP_CONCAT2(a,b)
  322. #define LZO_CPP_ECONCAT3(a,b,c) LZO_CPP_CONCAT3(a,b,c)
  323. #define LZO_CPP_ECONCAT4(a,b,c,d) LZO_CPP_CONCAT4(a,b,c,d)
  324. #define LZO_CPP_ECONCAT5(a,b,c,d,e) LZO_CPP_CONCAT5(a,b,c,d,e)
  325. #define LZO_CPP_ECONCAT6(a,b,c,d,e,f) LZO_CPP_CONCAT6(a,b,c,d,e,f)
  326. #define LZO_CPP_ECONCAT7(a,b,c,d,e,f,g) LZO_CPP_CONCAT7(a,b,c,d,e,f,g)
  327. #endif
  328. #define __LZO_MASK_GEN(o,b) (((((o) << ((b)-((b)!=0))) - (o)) << 1) + (o)*((b)!=0))
  329. #if 1 && defined(__cplusplus)
  330. # if !defined(__STDC_CONSTANT_MACROS)
  331. # define __STDC_CONSTANT_MACROS 1
  332. # endif
  333. # if !defined(__STDC_LIMIT_MACROS)
  334. # define __STDC_LIMIT_MACROS 1
  335. # endif
  336. #endif
  337. #if defined(__cplusplus)
  338. # define LZO_EXTERN_C extern "C"
  339. # define LZO_EXTERN_C_BEGIN extern "C" {
  340. # define LZO_EXTERN_C_END }
  341. #else
  342. # define LZO_EXTERN_C extern
  343. # define LZO_EXTERN_C_BEGIN /*empty*/
  344. # define LZO_EXTERN_C_END /*empty*/
  345. #endif
  346. #if !defined(__LZO_OS_OVERRIDE)
  347. #if (LZO_OS_FREESTANDING)
  348. # define LZO_INFO_OS "freestanding"
  349. #elif (LZO_OS_EMBEDDED)
  350. # define LZO_INFO_OS "embedded"
  351. #elif 1 && defined(__IAR_SYSTEMS_ICC__)
  352. # define LZO_OS_EMBEDDED 1
  353. # define LZO_INFO_OS "embedded"
  354. #elif defined(__CYGWIN__) && defined(__GNUC__)
  355. # define LZO_OS_CYGWIN 1
  356. # define LZO_INFO_OS "cygwin"
  357. #elif defined(__EMX__) && defined(__GNUC__)
  358. # define LZO_OS_EMX 1
  359. # define LZO_INFO_OS "emx"
  360. #elif defined(__BEOS__)
  361. # define LZO_OS_BEOS 1
  362. # define LZO_INFO_OS "beos"
  363. #elif defined(__Lynx__)
  364. # define LZO_OS_LYNXOS 1
  365. # define LZO_INFO_OS "lynxos"
  366. #elif defined(__OS400__)
  367. # define LZO_OS_OS400 1
  368. # define LZO_INFO_OS "os400"
  369. #elif defined(__QNX__)
  370. # define LZO_OS_QNX 1
  371. # define LZO_INFO_OS "qnx"
  372. #elif defined(__BORLANDC__) && defined(__DPMI32__) && (__BORLANDC__ >= 0x0460)
  373. # define LZO_OS_DOS32 1
  374. # define LZO_INFO_OS "dos32"
  375. #elif defined(__BORLANDC__) && defined(__DPMI16__)
  376. # define LZO_OS_DOS16 1
  377. # define LZO_INFO_OS "dos16"
  378. #elif defined(__ZTC__) && defined(DOS386)
  379. # define LZO_OS_DOS32 1
  380. # define LZO_INFO_OS "dos32"
  381. #elif defined(__OS2__) || defined(__OS2V2__)
  382. # if (UINT_MAX == LZO_0xffffL)
  383. # define LZO_OS_OS216 1
  384. # define LZO_INFO_OS "os216"
  385. # elif (UINT_MAX == LZO_0xffffffffL)
  386. # define LZO_OS_OS2 1
  387. # define LZO_INFO_OS "os2"
  388. # else
  389. # error "check your limits.h header"
  390. # endif
  391. #elif defined(__WIN64__) || defined(_WIN64) || defined(WIN64)
  392. # define LZO_OS_WIN64 1
  393. # define LZO_INFO_OS "win64"
  394. #elif defined(__WIN32__) || defined(_WIN32) || defined(WIN32) || defined(__WINDOWS_386__)
  395. # define LZO_OS_WIN32 1
  396. # define LZO_INFO_OS "win32"
  397. #elif defined(__MWERKS__) && defined(__INTEL__)
  398. # define LZO_OS_WIN32 1
  399. # define LZO_INFO_OS "win32"
  400. #elif defined(__WINDOWS__) || defined(_WINDOWS) || defined(_Windows)
  401. # if (UINT_MAX == LZO_0xffffL)
  402. # define LZO_OS_WIN16 1
  403. # define LZO_INFO_OS "win16"
  404. # elif (UINT_MAX == LZO_0xffffffffL)
  405. # define LZO_OS_WIN32 1
  406. # define LZO_INFO_OS "win32"
  407. # else
  408. # error "check your limits.h header"
  409. # endif
  410. #elif defined(__DOS__) || defined(__MSDOS__) || defined(_MSDOS) || defined(MSDOS) || (defined(__PACIFIC__) && defined(DOS))
  411. # if (UINT_MAX == LZO_0xffffL)
  412. # define LZO_OS_DOS16 1
  413. # define LZO_INFO_OS "dos16"
  414. # elif (UINT_MAX == LZO_0xffffffffL)
  415. # define LZO_OS_DOS32 1
  416. # define LZO_INFO_OS "dos32"
  417. # else
  418. # error "check your limits.h header"
  419. # endif
  420. #elif defined(__WATCOMC__)
  421. # if defined(__NT__) && (UINT_MAX == LZO_0xffffL)
  422. # define LZO_OS_DOS16 1
  423. # define LZO_INFO_OS "dos16"
  424. # elif defined(__NT__) && (__WATCOMC__ < 1100)
  425. # define LZO_OS_WIN32 1
  426. # define LZO_INFO_OS "win32"
  427. # elif defined(__linux__) || defined(__LINUX__)
  428. # define LZO_OS_POSIX 1
  429. # define LZO_INFO_OS "posix"
  430. # else
  431. # error "please specify a target using the -bt compiler option"
  432. # endif
  433. #elif defined(__palmos__)
  434. # define LZO_OS_PALMOS 1
  435. # define LZO_INFO_OS "palmos"
  436. #elif defined(__TOS__) || defined(__atarist__)
  437. # define LZO_OS_TOS 1
  438. # define LZO_INFO_OS "tos"
  439. #elif defined(macintosh) && !defined(__arm__) && !defined(__i386__) && !defined(__ppc__) && !defined(__x64_64__)
  440. # define LZO_OS_MACCLASSIC 1
  441. # define LZO_INFO_OS "macclassic"
  442. #elif defined(__VMS)
  443. # define LZO_OS_VMS 1
  444. # define LZO_INFO_OS "vms"
  445. #elif (defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)
  446. # define LZO_OS_CONSOLE 1
  447. # define LZO_OS_CONSOLE_PS2 1
  448. # define LZO_INFO_OS "console"
  449. # define LZO_INFO_OS_CONSOLE "ps2"
  450. #elif defined(__mips__) && defined(__psp__)
  451. # define LZO_OS_CONSOLE 1
  452. # define LZO_OS_CONSOLE_PSP 1
  453. # define LZO_INFO_OS "console"
  454. # define LZO_INFO_OS_CONSOLE "psp"
  455. #else
  456. # define LZO_OS_POSIX 1
  457. # define LZO_INFO_OS "posix"
  458. #endif
  459. #if (LZO_OS_POSIX)
  460. # if defined(_AIX) || defined(__AIX__) || defined(__aix__)
  461. # define LZO_OS_POSIX_AIX 1
  462. # define LZO_INFO_OS_POSIX "aix"
  463. # elif defined(__FreeBSD__)
  464. # define LZO_OS_POSIX_FREEBSD 1
  465. # define LZO_INFO_OS_POSIX "freebsd"
  466. # elif defined(__hpux__) || defined(__hpux)
  467. # define LZO_OS_POSIX_HPUX 1
  468. # define LZO_INFO_OS_POSIX "hpux"
  469. # elif defined(__INTERIX)
  470. # define LZO_OS_POSIX_INTERIX 1
  471. # define LZO_INFO_OS_POSIX "interix"
  472. # elif defined(__IRIX__) || defined(__irix__)
  473. # define LZO_OS_POSIX_IRIX 1
  474. # define LZO_INFO_OS_POSIX "irix"
  475. # elif defined(__linux__) || defined(__linux) || defined(__LINUX__)
  476. # define LZO_OS_POSIX_LINUX 1
  477. # define LZO_INFO_OS_POSIX "linux"
  478. # elif defined(__APPLE__) && defined(__MACH__)
  479. # if ((__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__-0) >= 20000)
  480. # define LZO_OS_POSIX_DARWIN 1040
  481. # define LZO_INFO_OS_POSIX "darwin_iphone"
  482. # elif ((__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__-0) >= 1040)
  483. # define LZO_OS_POSIX_DARWIN __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
  484. # define LZO_INFO_OS_POSIX "darwin"
  485. # else
  486. # define LZO_OS_POSIX_DARWIN 1
  487. # define LZO_INFO_OS_POSIX "darwin"
  488. # endif
  489. # define LZO_OS_POSIX_MACOSX LZO_OS_POSIX_DARWIN
  490. # elif defined(__minix__) || defined(__minix)
  491. # define LZO_OS_POSIX_MINIX 1
  492. # define LZO_INFO_OS_POSIX "minix"
  493. # elif defined(__NetBSD__)
  494. # define LZO_OS_POSIX_NETBSD 1
  495. # define LZO_INFO_OS_POSIX "netbsd"
  496. # elif defined(__OpenBSD__)
  497. # define LZO_OS_POSIX_OPENBSD 1
  498. # define LZO_INFO_OS_POSIX "openbsd"
  499. # elif defined(__osf__)
  500. # define LZO_OS_POSIX_OSF 1
  501. # define LZO_INFO_OS_POSIX "osf"
  502. # elif defined(__solaris__) || defined(__sun)
  503. # if defined(__SVR4) || defined(__svr4__)
  504. # define LZO_OS_POSIX_SOLARIS 1
  505. # define LZO_INFO_OS_POSIX "solaris"
  506. # else
  507. # define LZO_OS_POSIX_SUNOS 1
  508. # define LZO_INFO_OS_POSIX "sunos"
  509. # endif
  510. # elif defined(__ultrix__) || defined(__ultrix)
  511. # define LZO_OS_POSIX_ULTRIX 1
  512. # define LZO_INFO_OS_POSIX "ultrix"
  513. # elif defined(_UNICOS)
  514. # define LZO_OS_POSIX_UNICOS 1
  515. # define LZO_INFO_OS_POSIX "unicos"
  516. # else
  517. # define LZO_OS_POSIX_UNKNOWN 1
  518. # define LZO_INFO_OS_POSIX "unknown"
  519. # endif
  520. #endif
  521. #endif
  522. #if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16)
  523. # if (UINT_MAX != LZO_0xffffL)
  524. # error "unexpected configuration - check your compiler defines"
  525. # endif
  526. # if (ULONG_MAX != LZO_0xffffffffL)
  527. # error "unexpected configuration - check your compiler defines"
  528. # endif
  529. #endif
  530. #if (LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_WIN32 || LZO_OS_WIN64)
  531. # if (UINT_MAX != LZO_0xffffffffL)
  532. # error "unexpected configuration - check your compiler defines"
  533. # endif
  534. # if (ULONG_MAX != LZO_0xffffffffL)
  535. # error "unexpected configuration - check your compiler defines"
  536. # endif
  537. #endif
  538. #if defined(CIL) && defined(_GNUCC) && defined(__GNUC__)
  539. # define LZO_CC_CILLY 1
  540. # define LZO_INFO_CC "Cilly"
  541. # if defined(__CILLY__)
  542. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__CILLY__)
  543. # else
  544. # define LZO_INFO_CCVER "unknown"
  545. # endif
  546. #elif 0 && defined(SDCC) && defined(__VERSION__) && !defined(__GNUC__)
  547. # define LZO_CC_SDCC 1
  548. # define LZO_INFO_CC "sdcc"
  549. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(SDCC)
  550. #elif defined(__PATHSCALE__) && defined(__PATHCC_PATCHLEVEL__)
  551. # define LZO_CC_PATHSCALE (__PATHCC__ * 0x10000L + (__PATHCC_MINOR__-0) * 0x100 + (__PATHCC_PATCHLEVEL__-0))
  552. # define LZO_INFO_CC "Pathscale C"
  553. # define LZO_INFO_CCVER __PATHSCALE__
  554. # if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__)
  555. # define LZO_CC_PATHSCALE_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0))
  556. # endif
  557. #elif defined(__INTEL_COMPILER) && ((__INTEL_COMPILER-0) > 0)
  558. # define LZO_CC_INTELC __INTEL_COMPILER
  559. # define LZO_INFO_CC "Intel C"
  560. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__INTEL_COMPILER)
  561. # if defined(_MSC_VER) && ((_MSC_VER-0) > 0)
  562. # define LZO_CC_INTELC_MSC _MSC_VER
  563. # elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__)
  564. # define LZO_CC_INTELC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0))
  565. # endif
  566. #elif defined(__POCC__) && defined(_WIN32)
  567. # define LZO_CC_PELLESC 1
  568. # define LZO_INFO_CC "Pelles C"
  569. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__POCC__)
  570. #elif defined(__ARMCC_VERSION) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__)
  571. # if defined(__GNUC_PATCHLEVEL__)
  572. # define LZO_CC_ARMCC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0))
  573. # else
  574. # define LZO_CC_ARMCC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100)
  575. # endif
  576. # define LZO_CC_ARMCC __ARMCC_VERSION
  577. # define LZO_INFO_CC "ARM C Compiler"
  578. # define LZO_INFO_CCVER __VERSION__
  579. #elif defined(__clang__) && defined(__c2__) && defined(__c2_version__) && defined(_MSC_VER)
  580. # define LZO_CC_CLANG (__clang_major__ * 0x10000L + (__clang_minor__-0) * 0x100 + (__clang_patchlevel__-0))
  581. # define LZO_CC_CLANG_C2 _MSC_VER
  582. # define LZO_CC_CLANG_VENDOR_MICROSOFT 1
  583. # define LZO_INFO_CC "clang/c2"
  584. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__c2_version__)
  585. #elif defined(__clang__) && defined(__llvm__) && defined(__VERSION__)
  586. # if defined(__clang_major__) && defined(__clang_minor__) && defined(__clang_patchlevel__)
  587. # define LZO_CC_CLANG (__clang_major__ * 0x10000L + (__clang_minor__-0) * 0x100 + (__clang_patchlevel__-0))
  588. # else
  589. # define LZO_CC_CLANG 0x010000L
  590. # endif
  591. # if defined(_MSC_VER) && ((_MSC_VER-0) > 0)
  592. # define LZO_CC_CLANG_MSC _MSC_VER
  593. # elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__)
  594. # define LZO_CC_CLANG_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0))
  595. # endif
  596. # if defined(__APPLE_CC__)
  597. # define LZO_CC_CLANG_VENDOR_APPLE 1
  598. # define LZO_INFO_CC "clang/apple"
  599. # else
  600. # define LZO_CC_CLANG_VENDOR_LLVM 1
  601. # define LZO_INFO_CC "clang"
  602. # endif
  603. # if defined(__clang_version__)
  604. # define LZO_INFO_CCVER __clang_version__
  605. # else
  606. # define LZO_INFO_CCVER __VERSION__
  607. # endif
  608. #elif defined(__llvm__) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__)
  609. # if defined(__GNUC_PATCHLEVEL__)
  610. # define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0))
  611. # else
  612. # define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100)
  613. # endif
  614. # define LZO_CC_LLVM LZO_CC_LLVM_GNUC
  615. # define LZO_INFO_CC "llvm-gcc"
  616. # define LZO_INFO_CCVER __VERSION__
  617. #elif defined(__ACK__) && defined(_ACK)
  618. # define LZO_CC_ACK 1
  619. # define LZO_INFO_CC "Amsterdam Compiler Kit C"
  620. # define LZO_INFO_CCVER "unknown"
  621. #elif defined(__ARMCC_VERSION) && !defined(__GNUC__)
  622. # define LZO_CC_ARMCC __ARMCC_VERSION
  623. # define LZO_CC_ARMCC_ARMCC __ARMCC_VERSION
  624. # define LZO_INFO_CC "ARM C Compiler"
  625. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__ARMCC_VERSION)
  626. #elif defined(__AZTEC_C__)
  627. # define LZO_CC_AZTECC 1
  628. # define LZO_INFO_CC "Aztec C"
  629. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__AZTEC_C__)
  630. #elif defined(__CODEGEARC__)
  631. # define LZO_CC_CODEGEARC 1
  632. # define LZO_INFO_CC "CodeGear C"
  633. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__CODEGEARC__)
  634. #elif defined(__BORLANDC__)
  635. # define LZO_CC_BORLANDC 1
  636. # define LZO_INFO_CC "Borland C"
  637. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__BORLANDC__)
  638. #elif defined(_CRAYC) && defined(_RELEASE)
  639. # define LZO_CC_CRAYC 1
  640. # define LZO_INFO_CC "Cray C"
  641. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_RELEASE)
  642. #elif defined(__DMC__) && defined(__SC__)
  643. # define LZO_CC_DMC 1
  644. # define LZO_INFO_CC "Digital Mars C"
  645. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__DMC__)
  646. #elif defined(__DECC)
  647. # define LZO_CC_DECC 1
  648. # define LZO_INFO_CC "DEC C"
  649. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__DECC)
  650. #elif (defined(__ghs) || defined(__ghs__)) && defined(__GHS_VERSION_NUMBER) && ((__GHS_VERSION_NUMBER-0) > 0)
  651. # define LZO_CC_GHS 1
  652. # define LZO_INFO_CC "Green Hills C"
  653. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__GHS_VERSION_NUMBER)
  654. # if defined(_MSC_VER) && ((_MSC_VER-0) > 0)
  655. # define LZO_CC_GHS_MSC _MSC_VER
  656. # elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__)
  657. # define LZO_CC_GHS_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0))
  658. # endif
  659. #elif defined(__HIGHC__)
  660. # define LZO_CC_HIGHC 1
  661. # define LZO_INFO_CC "MetaWare High C"
  662. # define LZO_INFO_CCVER "unknown"
  663. #elif defined(__HP_aCC) && ((__HP_aCC-0) > 0)
  664. # define LZO_CC_HPACC __HP_aCC
  665. # define LZO_INFO_CC "HP aCC"
  666. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__HP_aCC)
  667. #elif defined(__IAR_SYSTEMS_ICC__)
  668. # define LZO_CC_IARC 1
  669. # define LZO_INFO_CC "IAR C"
  670. # if defined(__VER__)
  671. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__VER__)
  672. # else
  673. # define LZO_INFO_CCVER "unknown"
  674. # endif
  675. #elif defined(__IBMC__) && ((__IBMC__-0) > 0)
  676. # define LZO_CC_IBMC __IBMC__
  677. # define LZO_INFO_CC "IBM C"
  678. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__IBMC__)
  679. #elif defined(__IBMCPP__) && ((__IBMCPP__-0) > 0)
  680. # define LZO_CC_IBMC __IBMCPP__
  681. # define LZO_INFO_CC "IBM C"
  682. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__IBMCPP__)
  683. #elif defined(__KEIL__) && defined(__C166__)
  684. # define LZO_CC_KEILC 1
  685. # define LZO_INFO_CC "Keil C"
  686. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__C166__)
  687. #elif defined(__LCC__) && defined(_WIN32) && defined(__LCCOPTIMLEVEL)
  688. # define LZO_CC_LCCWIN32 1
  689. # define LZO_INFO_CC "lcc-win32"
  690. # define LZO_INFO_CCVER "unknown"
  691. #elif defined(__LCC__)
  692. # define LZO_CC_LCC 1
  693. # define LZO_INFO_CC "lcc"
  694. # if defined(__LCC_VERSION__)
  695. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__LCC_VERSION__)
  696. # else
  697. # define LZO_INFO_CCVER "unknown"
  698. # endif
  699. #elif defined(__MWERKS__) && ((__MWERKS__-0) > 0)
  700. # define LZO_CC_MWERKS __MWERKS__
  701. # define LZO_INFO_CC "Metrowerks C"
  702. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__MWERKS__)
  703. #elif (defined(__NDPC__) || defined(__NDPX__)) && defined(__i386)
  704. # define LZO_CC_NDPC 1
  705. # define LZO_INFO_CC "Microway NDP C"
  706. # define LZO_INFO_CCVER "unknown"
  707. #elif defined(__PACIFIC__)
  708. # define LZO_CC_PACIFICC 1
  709. # define LZO_INFO_CC "Pacific C"
  710. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PACIFIC__)
  711. #elif defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__)
  712. # if defined(__PGIC_PATCHLEVEL__)
  713. # define LZO_CC_PGI (__PGIC__ * 0x10000L + (__PGIC_MINOR__-0) * 0x100 + (__PGIC_PATCHLEVEL__-0))
  714. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PGIC__) "." LZO_PP_MACRO_EXPAND(__PGIC_MINOR__) "." LZO_PP_MACRO_EXPAND(__PGIC_PATCHLEVEL__)
  715. # else
  716. # define LZO_CC_PGI (__PGIC__ * 0x10000L + (__PGIC_MINOR__-0) * 0x100)
  717. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PGIC__) "." LZO_PP_MACRO_EXPAND(__PGIC_MINOR__) ".0"
  718. # endif
  719. # define LZO_INFO_CC "Portland Group PGI C"
  720. #elif defined(__PGI) && (defined(__linux__) || defined(__WIN32__))
  721. # define LZO_CC_PGI 1
  722. # define LZO_INFO_CC "Portland Group PGI C"
  723. # define LZO_INFO_CCVER "unknown"
  724. #elif defined(__PUREC__) && defined(__TOS__)
  725. # define LZO_CC_PUREC 1
  726. # define LZO_INFO_CC "Pure C"
  727. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PUREC__)
  728. #elif defined(__SC__) && defined(__ZTC__)
  729. # define LZO_CC_SYMANTECC 1
  730. # define LZO_INFO_CC "Symantec C"
  731. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SC__)
  732. #elif defined(__SUNPRO_C)
  733. # define LZO_INFO_CC "SunPro C"
  734. # if ((__SUNPRO_C-0) > 0)
  735. # define LZO_CC_SUNPROC __SUNPRO_C
  736. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_C)
  737. # else
  738. # define LZO_CC_SUNPROC 1
  739. # define LZO_INFO_CCVER "unknown"
  740. # endif
  741. #elif defined(__SUNPRO_CC)
  742. # define LZO_INFO_CC "SunPro C"
  743. # if ((__SUNPRO_CC-0) > 0)
  744. # define LZO_CC_SUNPROC __SUNPRO_CC
  745. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_CC)
  746. # else
  747. # define LZO_CC_SUNPROC 1
  748. # define LZO_INFO_CCVER "unknown"
  749. # endif
  750. #elif defined(__TINYC__)
  751. # define LZO_CC_TINYC 1
  752. # define LZO_INFO_CC "Tiny C"
  753. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__TINYC__)
  754. #elif defined(__TSC__)
  755. # define LZO_CC_TOPSPEEDC 1
  756. # define LZO_INFO_CC "TopSpeed C"
  757. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__TSC__)
  758. #elif defined(__WATCOMC__)
  759. # define LZO_CC_WATCOMC 1
  760. # define LZO_INFO_CC "Watcom C"
  761. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__WATCOMC__)
  762. #elif defined(__TURBOC__)
  763. # define LZO_CC_TURBOC 1
  764. # define LZO_INFO_CC "Turbo C"
  765. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__TURBOC__)
  766. #elif defined(__ZTC__)
  767. # define LZO_CC_ZORTECHC 1
  768. # define LZO_INFO_CC "Zortech C"
  769. # if ((__ZTC__-0) == 0x310)
  770. # define LZO_INFO_CCVER "0x310"
  771. # else
  772. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__ZTC__)
  773. # endif
  774. #elif defined(__GNUC__) && defined(__VERSION__)
  775. # if defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)
  776. # define LZO_CC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100 + (__GNUC_PATCHLEVEL__-0))
  777. # elif defined(__GNUC_MINOR__)
  778. # define LZO_CC_GNUC (__GNUC__ * 0x10000L + (__GNUC_MINOR__-0) * 0x100)
  779. # else
  780. # define LZO_CC_GNUC (__GNUC__ * 0x10000L)
  781. # endif
  782. # define LZO_INFO_CC "gcc"
  783. # define LZO_INFO_CCVER __VERSION__
  784. #elif defined(_MSC_VER) && ((_MSC_VER-0) > 0)
  785. # define LZO_CC_MSC _MSC_VER
  786. # define LZO_INFO_CC "Microsoft C"
  787. # if defined(_MSC_FULL_VER)
  788. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) "." LZO_PP_MACRO_EXPAND(_MSC_FULL_VER)
  789. # else
  790. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER)
  791. # endif
  792. #else
  793. # define LZO_CC_UNKNOWN 1
  794. # define LZO_INFO_CC "unknown"
  795. # define LZO_INFO_CCVER "unknown"
  796. #endif
  797. #if (LZO_CC_GNUC) && defined(__OPEN64__)
  798. # if defined(__OPENCC__) && defined(__OPENCC_MINOR__) && defined(__OPENCC_PATCHLEVEL__)
  799. # define LZO_CC_OPEN64 (__OPENCC__ * 0x10000L + (__OPENCC_MINOR__-0) * 0x100 + (__OPENCC_PATCHLEVEL__-0))
  800. # define LZO_CC_OPEN64_GNUC LZO_CC_GNUC
  801. # endif
  802. #endif
  803. #if (LZO_CC_GNUC) && defined(__PCC__)
  804. # if defined(__PCC__) && defined(__PCC_MINOR__) && defined(__PCC_MINORMINOR__)
  805. # define LZO_CC_PCC (__PCC__ * 0x10000L + (__PCC_MINOR__-0) * 0x100 + (__PCC_MINORMINOR__-0))
  806. # define LZO_CC_PCC_GNUC LZO_CC_GNUC
  807. # endif
  808. #endif
  809. #if 0 && (LZO_CC_MSC && (_MSC_VER >= 1200)) && !defined(_MSC_FULL_VER)
  810. # error "LZO_CC_MSC: _MSC_FULL_VER is not defined"
  811. #endif
  812. #if !defined(__LZO_ARCH_OVERRIDE) && !(LZO_ARCH_GENERIC) && defined(_CRAY)
  813. # if (UINT_MAX > LZO_0xffffffffL) && defined(_CRAY)
  814. # if defined(_CRAYMPP) || defined(_CRAYT3D) || defined(_CRAYT3E)
  815. # define LZO_ARCH_CRAY_MPP 1
  816. # elif defined(_CRAY1)
  817. # define LZO_ARCH_CRAY_PVP 1
  818. # endif
  819. # endif
  820. #endif
  821. #if !defined(__LZO_ARCH_OVERRIDE)
  822. #if (LZO_ARCH_GENERIC)
  823. # define LZO_INFO_ARCH "generic"
  824. #elif (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16)
  825. # define LZO_ARCH_I086 1
  826. # define LZO_INFO_ARCH "i086"
  827. #elif defined(__aarch64__) || defined(_M_ARM64)
  828. # define LZO_ARCH_ARM64 1
  829. # define LZO_INFO_ARCH "arm64"
  830. #elif defined(__alpha__) || defined(__alpha) || defined(_M_ALPHA)
  831. # define LZO_ARCH_ALPHA 1
  832. # define LZO_INFO_ARCH "alpha"
  833. #elif (LZO_ARCH_CRAY_MPP) && (defined(_CRAYT3D) || defined(_CRAYT3E))
  834. # define LZO_ARCH_ALPHA 1
  835. # define LZO_INFO_ARCH "alpha"
  836. #elif defined(__amd64__) || defined(__x86_64__) || defined(_M_AMD64)
  837. # define LZO_ARCH_AMD64 1
  838. # define LZO_INFO_ARCH "amd64"
  839. #elif defined(__arm__) || defined(_M_ARM)
  840. # define LZO_ARCH_ARM 1
  841. # define LZO_INFO_ARCH "arm"
  842. #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCARM__)
  843. # define LZO_ARCH_ARM 1
  844. # define LZO_INFO_ARCH "arm"
  845. #elif (UINT_MAX <= LZO_0xffffL) && defined(__AVR__)
  846. # define LZO_ARCH_AVR 1
  847. # define LZO_INFO_ARCH "avr"
  848. #elif defined(__avr32__) || defined(__AVR32__)
  849. # define LZO_ARCH_AVR32 1
  850. # define LZO_INFO_ARCH "avr32"
  851. #elif defined(__bfin__)
  852. # define LZO_ARCH_BLACKFIN 1
  853. # define LZO_INFO_ARCH "blackfin"
  854. #elif (UINT_MAX == LZO_0xffffL) && defined(__C166__)
  855. # define LZO_ARCH_C166 1
  856. # define LZO_INFO_ARCH "c166"
  857. #elif defined(__cris__)
  858. # define LZO_ARCH_CRIS 1
  859. # define LZO_INFO_ARCH "cris"
  860. #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCEZ80__)
  861. # define LZO_ARCH_EZ80 1
  862. # define LZO_INFO_ARCH "ez80"
  863. #elif defined(__H8300__) || defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__)
  864. # define LZO_ARCH_H8300 1
  865. # define LZO_INFO_ARCH "h8300"
  866. #elif defined(__hppa__) || defined(__hppa)
  867. # define LZO_ARCH_HPPA 1
  868. # define LZO_INFO_ARCH "hppa"
  869. #elif defined(__386__) || defined(__i386__) || defined(__i386) || defined(_M_IX86) || defined(_M_I386)
  870. # define LZO_ARCH_I386 1
  871. # define LZO_ARCH_IA32 1
  872. # define LZO_INFO_ARCH "i386"
  873. #elif (LZO_CC_ZORTECHC && defined(__I86__))
  874. # define LZO_ARCH_I386 1
  875. # define LZO_ARCH_IA32 1
  876. # define LZO_INFO_ARCH "i386"
  877. #elif (LZO_OS_DOS32 && LZO_CC_HIGHC) && defined(_I386)
  878. # define LZO_ARCH_I386 1
  879. # define LZO_ARCH_IA32 1
  880. # define LZO_INFO_ARCH "i386"
  881. #elif defined(__ia64__) || defined(__ia64) || defined(_M_IA64)
  882. # define LZO_ARCH_IA64 1
  883. # define LZO_INFO_ARCH "ia64"
  884. #elif (UINT_MAX == LZO_0xffffL) && defined(__m32c__)
  885. # define LZO_ARCH_M16C 1
  886. # define LZO_INFO_ARCH "m16c"
  887. #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCM16C__)
  888. # define LZO_ARCH_M16C 1
  889. # define LZO_INFO_ARCH "m16c"
  890. #elif defined(__m32r__)
  891. # define LZO_ARCH_M32R 1
  892. # define LZO_INFO_ARCH "m32r"
  893. #elif (LZO_OS_TOS) || defined(__m68k__) || defined(__m68000__) || defined(__mc68000__) || defined(__mc68020__) || defined(_M_M68K)
  894. # define LZO_ARCH_M68K 1
  895. # define LZO_INFO_ARCH "m68k"
  896. #elif (UINT_MAX == LZO_0xffffL) && defined(__C251__)
  897. # define LZO_ARCH_MCS251 1
  898. # define LZO_INFO_ARCH "mcs251"
  899. #elif (UINT_MAX == LZO_0xffffL) && defined(__C51__)
  900. # define LZO_ARCH_MCS51 1
  901. # define LZO_INFO_ARCH "mcs51"
  902. #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICC8051__)
  903. # define LZO_ARCH_MCS51 1
  904. # define LZO_INFO_ARCH "mcs51"
  905. #elif defined(__mips__) || defined(__mips) || defined(_MIPS_ARCH) || defined(_M_MRX000)
  906. # define LZO_ARCH_MIPS 1
  907. # define LZO_INFO_ARCH "mips"
  908. #elif (UINT_MAX == LZO_0xffffL) && defined(__MSP430__)
  909. # define LZO_ARCH_MSP430 1
  910. # define LZO_INFO_ARCH "msp430"
  911. #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICC430__)
  912. # define LZO_ARCH_MSP430 1
  913. # define LZO_INFO_ARCH "msp430"
  914. #elif defined(__powerpc__) || defined(__powerpc) || defined(__ppc__) || defined(__PPC__) || defined(_M_PPC) || defined(_ARCH_PPC) || defined(_ARCH_PWR)
  915. # define LZO_ARCH_POWERPC 1
  916. # define LZO_INFO_ARCH "powerpc"
  917. #elif defined(__powerpc64__) || defined(__powerpc64) || defined(__ppc64__) || defined(__PPC64__)
  918. # define LZO_ARCH_POWERPC 1
  919. # define LZO_INFO_ARCH "powerpc"
  920. #elif defined(__powerpc64le__) || defined(__powerpc64le) || defined(__ppc64le__) || defined(__PPC64LE__)
  921. # define LZO_ARCH_POWERPC 1
  922. # define LZO_INFO_ARCH "powerpc"
  923. #elif defined(__riscv)
  924. # define LZO_ARCH_RISCV 1
  925. # define LZO_INFO_ARCH "riscv"
  926. #elif defined(__s390__) || defined(__s390) || defined(__s390x__) || defined(__s390x)
  927. # define LZO_ARCH_S390 1
  928. # define LZO_INFO_ARCH "s390"
  929. #elif defined(__sh__) || defined(_M_SH)
  930. # define LZO_ARCH_SH 1
  931. # define LZO_INFO_ARCH "sh"
  932. #elif defined(__sparc__) || defined(__sparc) || defined(__sparcv8)
  933. # define LZO_ARCH_SPARC 1
  934. # define LZO_INFO_ARCH "sparc"
  935. #elif defined(__SPU__)
  936. # define LZO_ARCH_SPU 1
  937. # define LZO_INFO_ARCH "spu"
  938. #elif (UINT_MAX == LZO_0xffffL) && defined(__z80)
  939. # define LZO_ARCH_Z80 1
  940. # define LZO_INFO_ARCH "z80"
  941. #elif (LZO_ARCH_CRAY_PVP)
  942. # if defined(_CRAYSV1)
  943. # define LZO_ARCH_CRAY_SV1 1
  944. # define LZO_INFO_ARCH "cray_sv1"
  945. # elif (_ADDR64)
  946. # define LZO_ARCH_CRAY_T90 1
  947. # define LZO_INFO_ARCH "cray_t90"
  948. # elif (_ADDR32)
  949. # define LZO_ARCH_CRAY_YMP 1
  950. # define LZO_INFO_ARCH "cray_ymp"
  951. # else
  952. # define LZO_ARCH_CRAY_XMP 1
  953. # define LZO_INFO_ARCH "cray_xmp"
  954. # endif
  955. #else
  956. # define LZO_ARCH_UNKNOWN 1
  957. # define LZO_INFO_ARCH "unknown"
  958. #endif
  959. #endif
  960. #if !defined(LZO_ARCH_ARM_THUMB2)
  961. #if (LZO_ARCH_ARM)
  962. # if defined(__thumb__) || defined(__thumb) || defined(_M_THUMB)
  963. # if defined(__thumb2__)
  964. # define LZO_ARCH_ARM_THUMB2 1
  965. # elif 1 && defined(__TARGET_ARCH_THUMB) && ((__TARGET_ARCH_THUMB)+0 >= 4)
  966. # define LZO_ARCH_ARM_THUMB2 1
  967. # elif 1 && defined(_MSC_VER) && defined(_M_THUMB) && ((_M_THUMB)+0 >= 7)
  968. # define LZO_ARCH_ARM_THUMB2 1
  969. # endif
  970. # endif
  971. #endif
  972. #endif
  973. #if (LZO_ARCH_ARM_THUMB2)
  974. # undef LZO_INFO_ARCH
  975. # define LZO_INFO_ARCH "arm_thumb2"
  976. #endif
  977. #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_DOS32 || LZO_OS_OS2)
  978. # error "FIXME - missing define for CPU architecture"
  979. #endif
  980. #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN32)
  981. # error "FIXME - missing LZO_OS_WIN32 define for CPU architecture"
  982. #endif
  983. #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN64)
  984. # error "FIXME - missing LZO_OS_WIN64 define for CPU architecture"
  985. #endif
  986. #if (LZO_OS_OS216 || LZO_OS_WIN16)
  987. # define LZO_ARCH_I086PM 1
  988. #elif 1 && (LZO_OS_DOS16 && defined(BLX286))
  989. # define LZO_ARCH_I086PM 1
  990. #elif 1 && (LZO_OS_DOS16 && defined(DOSX286))
  991. # define LZO_ARCH_I086PM 1
  992. #elif 1 && (LZO_OS_DOS16 && LZO_CC_BORLANDC && defined(__DPMI16__))
  993. # define LZO_ARCH_I086PM 1
  994. #endif
  995. #if (LZO_ARCH_AMD64 && !LZO_ARCH_X64)
  996. # define LZO_ARCH_X64 1
  997. #elif (!LZO_ARCH_AMD64 && LZO_ARCH_X64) && defined(__LZO_ARCH_OVERRIDE)
  998. # define LZO_ARCH_AMD64 1
  999. #endif
  1000. #if (LZO_ARCH_ARM64 && !LZO_ARCH_AARCH64)
  1001. # define LZO_ARCH_AARCH64 1
  1002. #elif (!LZO_ARCH_ARM64 && LZO_ARCH_AARCH64) && defined(__LZO_ARCH_OVERRIDE)
  1003. # define LZO_ARCH_ARM64 1
  1004. #endif
  1005. #if (LZO_ARCH_I386 && !LZO_ARCH_X86)
  1006. # define LZO_ARCH_X86 1
  1007. #elif (!LZO_ARCH_I386 && LZO_ARCH_X86) && defined(__LZO_ARCH_OVERRIDE)
  1008. # define LZO_ARCH_I386 1
  1009. #endif
  1010. #if (LZO_ARCH_AMD64 && !LZO_ARCH_X64) || (!LZO_ARCH_AMD64 && LZO_ARCH_X64)
  1011. # error "unexpected configuration - check your compiler defines"
  1012. #endif
  1013. #if (LZO_ARCH_ARM64 && !LZO_ARCH_AARCH64) || (!LZO_ARCH_ARM64 && LZO_ARCH_AARCH64)
  1014. # error "unexpected configuration - check your compiler defines"
  1015. #endif
  1016. #if (LZO_ARCH_I386 && !LZO_ARCH_X86) || (!LZO_ARCH_I386 && LZO_ARCH_X86)
  1017. # error "unexpected configuration - check your compiler defines"
  1018. #endif
  1019. #if (LZO_ARCH_ARM_THUMB1 && !LZO_ARCH_ARM)
  1020. # error "unexpected configuration - check your compiler defines"
  1021. #endif
  1022. #if (LZO_ARCH_ARM_THUMB2 && !LZO_ARCH_ARM)
  1023. # error "unexpected configuration - check your compiler defines"
  1024. #endif
  1025. #if (LZO_ARCH_ARM_THUMB1 && LZO_ARCH_ARM_THUMB2)
  1026. # error "unexpected configuration - check your compiler defines"
  1027. #endif
  1028. #if (LZO_ARCH_I086PM && !LZO_ARCH_I086)
  1029. # error "unexpected configuration - check your compiler defines"
  1030. #endif
  1031. #if (LZO_ARCH_I086)
  1032. # if (UINT_MAX != LZO_0xffffL)
  1033. # error "unexpected configuration - check your compiler defines"
  1034. # endif
  1035. # if (ULONG_MAX != LZO_0xffffffffL)
  1036. # error "unexpected configuration - check your compiler defines"
  1037. # endif
  1038. #endif
  1039. #if (LZO_ARCH_I386)
  1040. # if (UINT_MAX != LZO_0xffffL) && defined(__i386_int16__)
  1041. # error "unexpected configuration - check your compiler defines"
  1042. # endif
  1043. # if (UINT_MAX != LZO_0xffffffffL) && !defined(__i386_int16__)
  1044. # error "unexpected configuration - check your compiler defines"
  1045. # endif
  1046. # if (ULONG_MAX != LZO_0xffffffffL)
  1047. # error "unexpected configuration - check your compiler defines"
  1048. # endif
  1049. #endif
  1050. #if (LZO_ARCH_AMD64 || LZO_ARCH_I386)
  1051. # if !defined(LZO_TARGET_FEATURE_SSE2)
  1052. # if defined(__SSE2__)
  1053. # define LZO_TARGET_FEATURE_SSE2 1
  1054. # elif defined(_MSC_VER) && (defined(_M_IX86_FP) && ((_M_IX86_FP)+0 >= 2))
  1055. # define LZO_TARGET_FEATURE_SSE2 1
  1056. # elif (LZO_CC_INTELC_MSC || LZO_CC_MSC) && defined(_M_AMD64)
  1057. # define LZO_TARGET_FEATURE_SSE2 1
  1058. # endif
  1059. # endif
  1060. # if !defined(LZO_TARGET_FEATURE_SSSE3)
  1061. # if (LZO_TARGET_FEATURE_SSE2)
  1062. # if defined(__SSSE3__)
  1063. # define LZO_TARGET_FEATURE_SSSE3 1
  1064. # elif defined(_MSC_VER) && defined(__AVX__)
  1065. # define LZO_TARGET_FEATURE_SSSE3 1
  1066. # endif
  1067. # endif
  1068. # endif
  1069. # if !defined(LZO_TARGET_FEATURE_SSE4_2)
  1070. # if (LZO_TARGET_FEATURE_SSSE3)
  1071. # if defined(__SSE4_2__)
  1072. # define LZO_TARGET_FEATURE_SSE4_2 1
  1073. # endif
  1074. # endif
  1075. # endif
  1076. # if !defined(LZO_TARGET_FEATURE_AVX)
  1077. # if (LZO_TARGET_FEATURE_SSSE3)
  1078. # if defined(__AVX__)
  1079. # define LZO_TARGET_FEATURE_AVX 1
  1080. # endif
  1081. # endif
  1082. # endif
  1083. # if !defined(LZO_TARGET_FEATURE_AVX2)
  1084. # if (LZO_TARGET_FEATURE_AVX)
  1085. # if defined(__AVX2__)
  1086. # define LZO_TARGET_FEATURE_AVX2 1
  1087. # endif
  1088. # endif
  1089. # endif
  1090. #endif
  1091. #if (LZO_TARGET_FEATURE_SSSE3 && !(LZO_TARGET_FEATURE_SSE2))
  1092. # error "unexpected configuration - check your compiler defines"
  1093. #endif
  1094. #if (LZO_TARGET_FEATURE_SSE4_2 && !(LZO_TARGET_FEATURE_SSSE3))
  1095. # error "unexpected configuration - check your compiler defines"
  1096. #endif
  1097. #if (LZO_TARGET_FEATURE_AVX && !(LZO_TARGET_FEATURE_SSSE3))
  1098. # error "unexpected configuration - check your compiler defines"
  1099. #endif
  1100. #if (LZO_TARGET_FEATURE_AVX2 && !(LZO_TARGET_FEATURE_AVX))
  1101. # error "unexpected configuration - check your compiler defines"
  1102. #endif
  1103. #if (LZO_ARCH_ARM)
  1104. # if !defined(LZO_TARGET_FEATURE_NEON)
  1105. # if defined(__ARM_NEON) && ((__ARM_NEON)+0)
  1106. # define LZO_TARGET_FEATURE_NEON 1
  1107. # elif 1 && defined(__ARM_NEON__) && ((__ARM_NEON__)+0)
  1108. # define LZO_TARGET_FEATURE_NEON 1
  1109. # elif 1 && defined(__TARGET_FEATURE_NEON) && ((__TARGET_FEATURE_NEON)+0)
  1110. # define LZO_TARGET_FEATURE_NEON 1
  1111. # endif
  1112. # endif
  1113. #elif (LZO_ARCH_ARM64)
  1114. # if !defined(LZO_TARGET_FEATURE_NEON)
  1115. # if 1
  1116. # define LZO_TARGET_FEATURE_NEON 1
  1117. # endif
  1118. # endif
  1119. #endif
  1120. #if 0
  1121. #elif !defined(__LZO_MM_OVERRIDE)
  1122. #if (LZO_ARCH_I086)
  1123. #if (UINT_MAX != LZO_0xffffL)
  1124. # error "unexpected configuration - check your compiler defines"
  1125. #endif
  1126. #if defined(__TINY__) || defined(M_I86TM) || defined(_M_I86TM)
  1127. # define LZO_MM_TINY 1
  1128. #elif defined(__HUGE__) || defined(_HUGE_) || defined(M_I86HM) || defined(_M_I86HM)
  1129. # define LZO_MM_HUGE 1
  1130. #elif defined(__SMALL__) || defined(M_I86SM) || defined(_M_I86SM) || defined(SMALL_MODEL)
  1131. # define LZO_MM_SMALL 1
  1132. #elif defined(__MEDIUM__) || defined(M_I86MM) || defined(_M_I86MM)
  1133. # define LZO_MM_MEDIUM 1
  1134. #elif defined(__COMPACT__) || defined(M_I86CM) || defined(_M_I86CM)
  1135. # define LZO_MM_COMPACT 1
  1136. #elif defined(__LARGE__) || defined(M_I86LM) || defined(_M_I86LM) || defined(LARGE_MODEL)
  1137. # define LZO_MM_LARGE 1
  1138. #elif (LZO_CC_AZTECC)
  1139. # if defined(_LARGE_CODE) && defined(_LARGE_DATA)
  1140. # define LZO_MM_LARGE 1
  1141. # elif defined(_LARGE_CODE)
  1142. # define LZO_MM_MEDIUM 1
  1143. # elif defined(_LARGE_DATA)
  1144. # define LZO_MM_COMPACT 1
  1145. # else
  1146. # define LZO_MM_SMALL 1
  1147. # endif
  1148. #elif (LZO_CC_ZORTECHC && defined(__VCM__))
  1149. # define LZO_MM_LARGE 1
  1150. #else
  1151. # error "unknown LZO_ARCH_I086 memory model"
  1152. #endif
  1153. #if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16)
  1154. #define LZO_HAVE_MM_HUGE_PTR 1
  1155. #define LZO_HAVE_MM_HUGE_ARRAY 1
  1156. #if (LZO_MM_TINY)
  1157. # undef LZO_HAVE_MM_HUGE_ARRAY
  1158. #endif
  1159. #if (LZO_CC_AZTECC || LZO_CC_PACIFICC || LZO_CC_ZORTECHC)
  1160. # undef LZO_HAVE_MM_HUGE_PTR
  1161. # undef LZO_HAVE_MM_HUGE_ARRAY
  1162. #elif (LZO_CC_DMC || LZO_CC_SYMANTECC)
  1163. # undef LZO_HAVE_MM_HUGE_ARRAY
  1164. #elif (LZO_CC_MSC && defined(_QC))
  1165. # undef LZO_HAVE_MM_HUGE_ARRAY
  1166. # if (_MSC_VER < 600)
  1167. # undef LZO_HAVE_MM_HUGE_PTR
  1168. # endif
  1169. #elif (LZO_CC_TURBOC && (__TURBOC__ < 0x0295))
  1170. # undef LZO_HAVE_MM_HUGE_ARRAY
  1171. #endif
  1172. #if (LZO_ARCH_I086PM) && !(LZO_HAVE_MM_HUGE_PTR)
  1173. # if (LZO_OS_DOS16)
  1174. # error "unexpected configuration - check your compiler defines"
  1175. # elif (LZO_CC_ZORTECHC)
  1176. # else
  1177. # error "unexpected configuration - check your compiler defines"
  1178. # endif
  1179. #endif
  1180. #if defined(__cplusplus)
  1181. extern "C" {
  1182. #endif
  1183. #if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0200))
  1184. extern void __near __cdecl _AHSHIFT(void);
  1185. # define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT)
  1186. #elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC)
  1187. extern void __near __cdecl _AHSHIFT(void);
  1188. # define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT)
  1189. #elif (LZO_CC_MSC || LZO_CC_TOPSPEEDC)
  1190. extern void __near __cdecl _AHSHIFT(void);
  1191. # define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT)
  1192. #elif (LZO_CC_TURBOC && (__TURBOC__ >= 0x0295))
  1193. extern void __near __cdecl _AHSHIFT(void);
  1194. # define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT)
  1195. #elif ((LZO_CC_AZTECC || LZO_CC_PACIFICC || LZO_CC_TURBOC) && LZO_OS_DOS16)
  1196. # define LZO_MM_AHSHIFT 12
  1197. #elif (LZO_CC_WATCOMC)
  1198. extern unsigned char _HShift;
  1199. # define LZO_MM_AHSHIFT ((unsigned) _HShift)
  1200. #else
  1201. # error "FIXME - implement LZO_MM_AHSHIFT"
  1202. #endif
  1203. #if defined(__cplusplus)
  1204. }
  1205. #endif
  1206. #endif
  1207. #elif (LZO_ARCH_C166)
  1208. #if !defined(__MODEL__)
  1209. # error "FIXME - LZO_ARCH_C166 __MODEL__"
  1210. #elif ((__MODEL__) == 0)
  1211. # define LZO_MM_SMALL 1
  1212. #elif ((__MODEL__) == 1)
  1213. # define LZO_MM_SMALL 1
  1214. #elif ((__MODEL__) == 2)
  1215. # define LZO_MM_LARGE 1
  1216. #elif ((__MODEL__) == 3)
  1217. # define LZO_MM_TINY 1
  1218. #elif ((__MODEL__) == 4)
  1219. # define LZO_MM_XTINY 1
  1220. #elif ((__MODEL__) == 5)
  1221. # define LZO_MM_XSMALL 1
  1222. #else
  1223. # error "FIXME - LZO_ARCH_C166 __MODEL__"
  1224. #endif
  1225. #elif (LZO_ARCH_MCS251)
  1226. #if !defined(__MODEL__)
  1227. # error "FIXME - LZO_ARCH_MCS251 __MODEL__"
  1228. #elif ((__MODEL__) == 0)
  1229. # define LZO_MM_SMALL 1
  1230. #elif ((__MODEL__) == 2)
  1231. # define LZO_MM_LARGE 1
  1232. #elif ((__MODEL__) == 3)
  1233. # define LZO_MM_TINY 1
  1234. #elif ((__MODEL__) == 4)
  1235. # define LZO_MM_XTINY 1
  1236. #elif ((__MODEL__) == 5)
  1237. # define LZO_MM_XSMALL 1
  1238. #else
  1239. # error "FIXME - LZO_ARCH_MCS251 __MODEL__"
  1240. #endif
  1241. #elif (LZO_ARCH_MCS51)
  1242. #if !defined(__MODEL__)
  1243. # error "FIXME - LZO_ARCH_MCS51 __MODEL__"
  1244. #elif ((__MODEL__) == 1)
  1245. # define LZO_MM_SMALL 1
  1246. #elif ((__MODEL__) == 2)
  1247. # define LZO_MM_LARGE 1
  1248. #elif ((__MODEL__) == 3)
  1249. # define LZO_MM_TINY 1
  1250. #elif ((__MODEL__) == 4)
  1251. # define LZO_MM_XTINY 1
  1252. #elif ((__MODEL__) == 5)
  1253. # define LZO_MM_XSMALL 1
  1254. #else
  1255. # error "FIXME - LZO_ARCH_MCS51 __MODEL__"
  1256. #endif
  1257. #elif (LZO_ARCH_CRAY_PVP)
  1258. # define LZO_MM_PVP 1
  1259. #else
  1260. # define LZO_MM_FLAT 1
  1261. #endif
  1262. #if (LZO_MM_COMPACT)
  1263. # define LZO_INFO_MM "compact"
  1264. #elif (LZO_MM_FLAT)
  1265. # define LZO_INFO_MM "flat"
  1266. #elif (LZO_MM_HUGE)
  1267. # define LZO_INFO_MM "huge"
  1268. #elif (LZO_MM_LARGE)
  1269. # define LZO_INFO_MM "large"
  1270. #elif (LZO_MM_MEDIUM)
  1271. # define LZO_INFO_MM "medium"
  1272. #elif (LZO_MM_PVP)
  1273. # define LZO_INFO_MM "pvp"
  1274. #elif (LZO_MM_SMALL)
  1275. # define LZO_INFO_MM "small"
  1276. #elif (LZO_MM_TINY)
  1277. # define LZO_INFO_MM "tiny"
  1278. #else
  1279. # error "unknown memory model"
  1280. #endif
  1281. #endif
  1282. #if !defined(__lzo_gnuc_extension__)
  1283. #if (LZO_CC_GNUC >= 0x020800ul)
  1284. # define __lzo_gnuc_extension__ __extension__
  1285. #elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
  1286. # define __lzo_gnuc_extension__ __extension__
  1287. #elif (LZO_CC_IBMC >= 600)
  1288. # define __lzo_gnuc_extension__ __extension__
  1289. #endif
  1290. #endif
  1291. #if !defined(__lzo_gnuc_extension__)
  1292. # define __lzo_gnuc_extension__ /*empty*/
  1293. #endif
  1294. #if !defined(lzo_has_builtin)
  1295. #if (LZO_CC_CLANG) && defined(__has_builtin)
  1296. # define lzo_has_builtin __has_builtin
  1297. #endif
  1298. #endif
  1299. #if !defined(lzo_has_builtin)
  1300. # define lzo_has_builtin(x) 0
  1301. #endif
  1302. #if !defined(lzo_has_attribute)
  1303. #if (LZO_CC_CLANG) && defined(__has_attribute)
  1304. # define lzo_has_attribute __has_attribute
  1305. #endif
  1306. #endif
  1307. #if !defined(lzo_has_attribute)
  1308. # define lzo_has_attribute(x) 0
  1309. #endif
  1310. #if !defined(lzo_has_declspec_attribute)
  1311. #if (LZO_CC_CLANG) && defined(__has_declspec_attribute)
  1312. # define lzo_has_declspec_attribute __has_declspec_attribute
  1313. #endif
  1314. #endif
  1315. #if !defined(lzo_has_declspec_attribute)
  1316. # define lzo_has_declspec_attribute(x) 0
  1317. #endif
  1318. #if !defined(lzo_has_feature)
  1319. #if (LZO_CC_CLANG) && defined(__has_feature)
  1320. # define lzo_has_feature __has_feature
  1321. #endif
  1322. #endif
  1323. #if !defined(lzo_has_feature)
  1324. # define lzo_has_feature(x) 0
  1325. #endif
  1326. #if !defined(lzo_has_extension)
  1327. #if (LZO_CC_CLANG) && defined(__has_extension)
  1328. # define lzo_has_extension __has_extension
  1329. #elif (LZO_CC_CLANG) && defined(__has_feature)
  1330. # define lzo_has_extension __has_feature
  1331. #endif
  1332. #endif
  1333. #if !defined(lzo_has_extension)
  1334. # define lzo_has_extension(x) 0
  1335. #endif
  1336. #if !defined(LZO_CFG_USE_NEW_STYLE_CASTS) && defined(__cplusplus) && 0
  1337. # if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul))
  1338. # define LZO_CFG_USE_NEW_STYLE_CASTS 0
  1339. # elif (LZO_CC_INTELC && (__INTEL_COMPILER < 1200))
  1340. # define LZO_CFG_USE_NEW_STYLE_CASTS 0
  1341. # else
  1342. # define LZO_CFG_USE_NEW_STYLE_CASTS 1
  1343. # endif
  1344. #endif
  1345. #if !defined(LZO_CFG_USE_NEW_STYLE_CASTS)
  1346. # define LZO_CFG_USE_NEW_STYLE_CASTS 0
  1347. #endif
  1348. #if !defined(__cplusplus)
  1349. # if defined(LZO_CFG_USE_NEW_STYLE_CASTS)
  1350. # undef LZO_CFG_USE_NEW_STYLE_CASTS
  1351. # endif
  1352. # define LZO_CFG_USE_NEW_STYLE_CASTS 0
  1353. #endif
  1354. #if !defined(LZO_REINTERPRET_CAST)
  1355. # if (LZO_CFG_USE_NEW_STYLE_CASTS)
  1356. # define LZO_REINTERPRET_CAST(t,e) (reinterpret_cast<t> (e))
  1357. # endif
  1358. #endif
  1359. #if !defined(LZO_REINTERPRET_CAST)
  1360. # define LZO_REINTERPRET_CAST(t,e) ((t) (e))
  1361. #endif
  1362. #if !defined(LZO_STATIC_CAST)
  1363. # if (LZO_CFG_USE_NEW_STYLE_CASTS)
  1364. # define LZO_STATIC_CAST(t,e) (static_cast<t> (e))
  1365. # endif
  1366. #endif
  1367. #if !defined(LZO_STATIC_CAST)
  1368. # define LZO_STATIC_CAST(t,e) ((t) (e))
  1369. #endif
  1370. #if !defined(LZO_STATIC_CAST2)
  1371. # define LZO_STATIC_CAST2(t1,t2,e) LZO_STATIC_CAST(t1, LZO_STATIC_CAST(t2, e))
  1372. #endif
  1373. #if !defined(LZO_UNCONST_CAST)
  1374. # if (LZO_CFG_USE_NEW_STYLE_CASTS)
  1375. # define LZO_UNCONST_CAST(t,e) (const_cast<t> (e))
  1376. # elif (LZO_HAVE_MM_HUGE_PTR)
  1377. # define LZO_UNCONST_CAST(t,e) ((t) (e))
  1378. # elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE)
  1379. # define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((lzo_uintptr_t) ((const void *) (e)))))
  1380. # endif
  1381. #endif
  1382. #if !defined(LZO_UNCONST_CAST)
  1383. # define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((const void *) (e))))
  1384. #endif
  1385. #if !defined(LZO_UNCONST_VOLATILE_CAST)
  1386. # if (LZO_CFG_USE_NEW_STYLE_CASTS)
  1387. # define LZO_UNCONST_VOLATILE_CAST(t,e) (const_cast<t> (e))
  1388. # elif (LZO_HAVE_MM_HUGE_PTR)
  1389. # define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) (e))
  1390. # elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE)
  1391. # define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) ((volatile void *) ((lzo_uintptr_t) ((volatile const void *) (e)))))
  1392. # endif
  1393. #endif
  1394. #if !defined(LZO_UNCONST_VOLATILE_CAST)
  1395. # define LZO_UNCONST_VOLATILE_CAST(t,e) ((t) ((volatile void *) ((volatile const void *) (e))))
  1396. #endif
  1397. #if !defined(LZO_UNVOLATILE_CAST)
  1398. # if (LZO_CFG_USE_NEW_STYLE_CASTS)
  1399. # define LZO_UNVOLATILE_CAST(t,e) (const_cast<t> (e))
  1400. # elif (LZO_HAVE_MM_HUGE_PTR)
  1401. # define LZO_UNVOLATILE_CAST(t,e) ((t) (e))
  1402. # elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE)
  1403. # define LZO_UNVOLATILE_CAST(t,e) ((t) ((void *) ((lzo_uintptr_t) ((volatile void *) (e)))))
  1404. # endif
  1405. #endif
  1406. #if !defined(LZO_UNVOLATILE_CAST)
  1407. # define LZO_UNVOLATILE_CAST(t,e) ((t) ((void *) ((volatile void *) (e))))
  1408. #endif
  1409. #if !defined(LZO_UNVOLATILE_CONST_CAST)
  1410. # if (LZO_CFG_USE_NEW_STYLE_CASTS)
  1411. # define LZO_UNVOLATILE_CONST_CAST(t,e) (const_cast<t> (e))
  1412. # elif (LZO_HAVE_MM_HUGE_PTR)
  1413. # define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) (e))
  1414. # elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE)
  1415. # define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) ((const void *) ((lzo_uintptr_t) ((volatile const void *) (e)))))
  1416. # endif
  1417. #endif
  1418. #if !defined(LZO_UNVOLATILE_CONST_CAST)
  1419. # define LZO_UNVOLATILE_CONST_CAST(t,e) ((t) ((const void *) ((volatile const void *) (e))))
  1420. #endif
  1421. #if !defined(LZO_PCAST)
  1422. # if (LZO_HAVE_MM_HUGE_PTR)
  1423. # define LZO_PCAST(t,e) ((t) (e))
  1424. # endif
  1425. #endif
  1426. #if !defined(LZO_PCAST)
  1427. # define LZO_PCAST(t,e) LZO_STATIC_CAST(t, LZO_STATIC_CAST(void *, e))
  1428. #endif
  1429. #if !defined(LZO_CCAST)
  1430. # if (LZO_HAVE_MM_HUGE_PTR)
  1431. # define LZO_CCAST(t,e) ((t) (e))
  1432. # endif
  1433. #endif
  1434. #if !defined(LZO_CCAST)
  1435. # define LZO_CCAST(t,e) LZO_STATIC_CAST(t, LZO_STATIC_CAST(const void *, e))
  1436. #endif
  1437. #if !defined(LZO_ICONV)
  1438. # define LZO_ICONV(t,e) LZO_STATIC_CAST(t, e)
  1439. #endif
  1440. #if !defined(LZO_ICAST)
  1441. # define LZO_ICAST(t,e) LZO_STATIC_CAST(t, e)
  1442. #endif
  1443. #if !defined(LZO_ITRUNC)
  1444. # define LZO_ITRUNC(t,e) LZO_STATIC_CAST(t, e)
  1445. #endif
  1446. #if !defined(__lzo_cte)
  1447. # if (LZO_CC_MSC || LZO_CC_WATCOMC)
  1448. # define __lzo_cte(e) ((void)0,(e))
  1449. # elif 1
  1450. # define __lzo_cte(e) ((void)0,(e))
  1451. # endif
  1452. #endif
  1453. #if !defined(__lzo_cte)
  1454. # define __lzo_cte(e) (e)
  1455. #endif
  1456. #if !defined(LZO_BLOCK_BEGIN)
  1457. # define LZO_BLOCK_BEGIN do {
  1458. # define LZO_BLOCK_END } while __lzo_cte(0)
  1459. #endif
  1460. #if !defined(LZO_UNUSED)
  1461. # if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600))
  1462. # define LZO_UNUSED(var) ((void) &var)
  1463. # elif (LZO_CC_BORLANDC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PELLESC || LZO_CC_TURBOC)
  1464. # define LZO_UNUSED(var) if (&var) ; else
  1465. # elif (LZO_CC_CLANG && (LZO_CC_CLANG >= 0x030200ul))
  1466. # define LZO_UNUSED(var) ((void) &var)
  1467. # elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE)
  1468. # define LZO_UNUSED(var) ((void) var)
  1469. # elif (LZO_CC_MSC && (_MSC_VER < 900))
  1470. # define LZO_UNUSED(var) if (&var) ; else
  1471. # elif (LZO_CC_KEILC)
  1472. # define LZO_UNUSED(var) {extern int lzo_unused__[1-2*!(sizeof(var)>0)]; (void)lzo_unused__;}
  1473. # elif (LZO_CC_PACIFICC)
  1474. # define LZO_UNUSED(var) ((void) sizeof(var))
  1475. # elif (LZO_CC_WATCOMC) && defined(__cplusplus)
  1476. # define LZO_UNUSED(var) ((void) var)
  1477. # else
  1478. # define LZO_UNUSED(var) ((void) &var)
  1479. # endif
  1480. #endif
  1481. #if !defined(LZO_UNUSED_RESULT)
  1482. # define LZO_UNUSED_RESULT(var) LZO_UNUSED(var)
  1483. #endif
  1484. #if !defined(LZO_UNUSED_FUNC)
  1485. # if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600))
  1486. # define LZO_UNUSED_FUNC(func) ((void) func)
  1487. # elif (LZO_CC_BORLANDC || LZO_CC_NDPC || LZO_CC_TURBOC)
  1488. # define LZO_UNUSED_FUNC(func) if (func) ; else
  1489. # elif (LZO_CC_CLANG || LZO_CC_LLVM)
  1490. # define LZO_UNUSED_FUNC(func) ((void) &func)
  1491. # elif (LZO_CC_MSC && (_MSC_VER < 900))
  1492. # define LZO_UNUSED_FUNC(func) if (func) ; else
  1493. # elif (LZO_CC_MSC)
  1494. # define LZO_UNUSED_FUNC(func) ((void) &func)
  1495. # elif (LZO_CC_KEILC || LZO_CC_PELLESC)
  1496. # define LZO_UNUSED_FUNC(func) {extern int lzo_unused__[1-2*!(sizeof((int)func)>0)]; (void)lzo_unused__;}
  1497. # else
  1498. # define LZO_UNUSED_FUNC(func) ((void) func)
  1499. # endif
  1500. #endif
  1501. #if !defined(LZO_UNUSED_LABEL)
  1502. # if (LZO_CC_CLANG >= 0x020800ul)
  1503. # define LZO_UNUSED_LABEL(l) (__lzo_gnuc_extension__ ((void) ((const void *) &&l)))
  1504. # elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_INTELC || LZO_CC_WATCOMC)
  1505. # define LZO_UNUSED_LABEL(l) if __lzo_cte(0) goto l
  1506. # else
  1507. # define LZO_UNUSED_LABEL(l) switch (0) case 1:goto l
  1508. # endif
  1509. #endif
  1510. #if !defined(LZO_DEFINE_UNINITIALIZED_VAR)
  1511. # if 0
  1512. # define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var
  1513. # elif 0 && (LZO_CC_GNUC)
  1514. # define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = var
  1515. # else
  1516. # define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = init
  1517. # endif
  1518. #endif
  1519. #if !defined(__lzo_inline)
  1520. #if (LZO_CC_TURBOC && (__TURBOC__ <= 0x0295))
  1521. #elif defined(__cplusplus)
  1522. # define __lzo_inline inline
  1523. #elif defined(__STDC_VERSION__) && (__STDC_VERSION__-0 >= 199901L)
  1524. # define __lzo_inline inline
  1525. #elif (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0550))
  1526. # define __lzo_inline __inline
  1527. #elif (LZO_CC_ARMCC_GNUC || LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI)
  1528. # define __lzo_inline __inline__
  1529. #elif (LZO_CC_DMC)
  1530. # define __lzo_inline __inline
  1531. #elif (LZO_CC_GHS)
  1532. # define __lzo_inline __inline__
  1533. #elif (LZO_CC_IBMC >= 600)
  1534. # define __lzo_inline __inline__
  1535. #elif (LZO_CC_INTELC)
  1536. # define __lzo_inline __inline
  1537. #elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x2405))
  1538. # define __lzo_inline __inline
  1539. #elif (LZO_CC_MSC && (_MSC_VER >= 900))
  1540. # define __lzo_inline __inline
  1541. #elif (LZO_CC_SUNPROC >= 0x5100)
  1542. # define __lzo_inline __inline__
  1543. #endif
  1544. #endif
  1545. #if defined(__lzo_inline)
  1546. # ifndef __lzo_HAVE_inline
  1547. # define __lzo_HAVE_inline 1
  1548. # endif
  1549. #else
  1550. # define __lzo_inline /*empty*/
  1551. #endif
  1552. #if !defined(__lzo_forceinline)
  1553. #if (LZO_CC_GNUC >= 0x030200ul)
  1554. # define __lzo_forceinline __inline__ __attribute__((__always_inline__))
  1555. #elif (LZO_CC_IBMC >= 700)
  1556. # define __lzo_forceinline __inline__ __attribute__((__always_inline__))
  1557. #elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 450))
  1558. # define __lzo_forceinline __forceinline
  1559. #elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800))
  1560. # define __lzo_forceinline __inline__ __attribute__((__always_inline__))
  1561. #elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
  1562. # define __lzo_forceinline __inline__ __attribute__((__always_inline__))
  1563. #elif (LZO_CC_MSC && (_MSC_VER >= 1200))
  1564. # define __lzo_forceinline __forceinline
  1565. #elif (LZO_CC_PGI >= 0x0d0a00ul)
  1566. # define __lzo_forceinline __inline__ __attribute__((__always_inline__))
  1567. #elif (LZO_CC_SUNPROC >= 0x5100)
  1568. # define __lzo_forceinline __inline__ __attribute__((__always_inline__))
  1569. #endif
  1570. #endif
  1571. #if defined(__lzo_forceinline)
  1572. # ifndef __lzo_HAVE_forceinline
  1573. # define __lzo_HAVE_forceinline 1
  1574. # endif
  1575. #else
  1576. # define __lzo_forceinline __lzo_inline
  1577. #endif
  1578. #if !defined(__lzo_noinline)
  1579. #if 1 && (LZO_ARCH_I386) && (LZO_CC_GNUC >= 0x040000ul) && (LZO_CC_GNUC < 0x040003ul)
  1580. # define __lzo_noinline __attribute__((__noinline__,__used__))
  1581. #elif (LZO_CC_GNUC >= 0x030200ul)
  1582. # define __lzo_noinline __attribute__((__noinline__))
  1583. #elif (LZO_CC_IBMC >= 700)
  1584. # define __lzo_noinline __attribute__((__noinline__))
  1585. #elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 600))
  1586. # define __lzo_noinline __declspec(noinline)
  1587. #elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800))
  1588. # define __lzo_noinline __attribute__((__noinline__))
  1589. #elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
  1590. # define __lzo_noinline __attribute__((__noinline__))
  1591. #elif (LZO_CC_MSC && (_MSC_VER >= 1300))
  1592. # define __lzo_noinline __declspec(noinline)
  1593. #elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x3200) && (LZO_OS_WIN32 || LZO_OS_WIN64))
  1594. # if defined(__cplusplus)
  1595. # else
  1596. # define __lzo_noinline __declspec(noinline)
  1597. # endif
  1598. #elif (LZO_CC_PGI >= 0x0d0a00ul)
  1599. # define __lzo_noinline __attribute__((__noinline__))
  1600. #elif (LZO_CC_SUNPROC >= 0x5100)
  1601. # define __lzo_noinline __attribute__((__noinline__))
  1602. #endif
  1603. #endif
  1604. #if defined(__lzo_noinline)
  1605. # ifndef __lzo_HAVE_noinline
  1606. # define __lzo_HAVE_noinline 1
  1607. # endif
  1608. #else
  1609. # define __lzo_noinline /*empty*/
  1610. #endif
  1611. #if (__lzo_HAVE_forceinline || __lzo_HAVE_noinline) && !(__lzo_HAVE_inline)
  1612. # error "unexpected configuration - check your compiler defines"
  1613. #endif
  1614. #if !defined(__lzo_static_inline)
  1615. #if (LZO_CC_IBMC)
  1616. # define __lzo_static_inline __lzo_gnuc_extension__ static __lzo_inline
  1617. #endif
  1618. #endif
  1619. #if !defined(__lzo_static_inline)
  1620. # define __lzo_static_inline static __lzo_inline
  1621. #endif
  1622. #if !defined(__lzo_static_forceinline)
  1623. #if (LZO_CC_IBMC)
  1624. # define __lzo_static_forceinline __lzo_gnuc_extension__ static __lzo_forceinline
  1625. #endif
  1626. #endif
  1627. #if !defined(__lzo_static_forceinline)
  1628. # define __lzo_static_forceinline static __lzo_forceinline
  1629. #endif
  1630. #if !defined(__lzo_static_noinline)
  1631. #if (LZO_CC_IBMC)
  1632. # define __lzo_static_noinline __lzo_gnuc_extension__ static __lzo_noinline
  1633. #endif
  1634. #endif
  1635. #if !defined(__lzo_static_noinline)
  1636. # define __lzo_static_noinline static __lzo_noinline
  1637. #endif
  1638. #if !defined(__lzo_c99_extern_inline)
  1639. #if defined(__GNUC_GNU_INLINE__)
  1640. # define __lzo_c99_extern_inline __lzo_inline
  1641. #elif defined(__GNUC_STDC_INLINE__)
  1642. # define __lzo_c99_extern_inline extern __lzo_inline
  1643. #elif defined(__STDC_VERSION__) && (__STDC_VERSION__-0 >= 199901L)
  1644. # define __lzo_c99_extern_inline extern __lzo_inline
  1645. #endif
  1646. #if !defined(__lzo_c99_extern_inline) && (__lzo_HAVE_inline)
  1647. # define __lzo_c99_extern_inline __lzo_inline
  1648. #endif
  1649. #endif
  1650. #if defined(__lzo_c99_extern_inline)
  1651. # ifndef __lzo_HAVE_c99_extern_inline
  1652. # define __lzo_HAVE_c99_extern_inline 1
  1653. # endif
  1654. #else
  1655. # define __lzo_c99_extern_inline /*empty*/
  1656. #endif
  1657. #if !defined(__lzo_may_alias)
  1658. #if (LZO_CC_GNUC >= 0x030400ul)
  1659. # define __lzo_may_alias __attribute__((__may_alias__))
  1660. #elif (LZO_CC_CLANG >= 0x020900ul)
  1661. # define __lzo_may_alias __attribute__((__may_alias__))
  1662. #elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 1210)) && 0
  1663. # define __lzo_may_alias __attribute__((__may_alias__))
  1664. #elif (LZO_CC_PGI >= 0x0d0a00ul) && 0
  1665. # define __lzo_may_alias __attribute__((__may_alias__))
  1666. #endif
  1667. #endif
  1668. #if defined(__lzo_may_alias)
  1669. # ifndef __lzo_HAVE_may_alias
  1670. # define __lzo_HAVE_may_alias 1
  1671. # endif
  1672. #else
  1673. # define __lzo_may_alias /*empty*/
  1674. #endif
  1675. #if !defined(__lzo_noreturn)
  1676. #if (LZO_CC_GNUC >= 0x020700ul)
  1677. # define __lzo_noreturn __attribute__((__noreturn__))
  1678. #elif (LZO_CC_IBMC >= 700)
  1679. # define __lzo_noreturn __attribute__((__noreturn__))
  1680. #elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 450))
  1681. # define __lzo_noreturn __declspec(noreturn)
  1682. #elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 600))
  1683. # define __lzo_noreturn __attribute__((__noreturn__))
  1684. #elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
  1685. # define __lzo_noreturn __attribute__((__noreturn__))
  1686. #elif (LZO_CC_MSC && (_MSC_VER >= 1200))
  1687. # define __lzo_noreturn __declspec(noreturn)
  1688. #elif (LZO_CC_PGI >= 0x0d0a00ul)
  1689. # define __lzo_noreturn __attribute__((__noreturn__))
  1690. #endif
  1691. #endif
  1692. #if defined(__lzo_noreturn)
  1693. # ifndef __lzo_HAVE_noreturn
  1694. # define __lzo_HAVE_noreturn 1
  1695. # endif
  1696. #else
  1697. # define __lzo_noreturn /*empty*/
  1698. #endif
  1699. #if !defined(__lzo_nothrow)
  1700. #if (LZO_CC_GNUC >= 0x030300ul)
  1701. # define __lzo_nothrow __attribute__((__nothrow__))
  1702. #elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 450)) && defined(__cplusplus)
  1703. # define __lzo_nothrow __declspec(nothrow)
  1704. #elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 900))
  1705. # define __lzo_nothrow __attribute__((__nothrow__))
  1706. #elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
  1707. # define __lzo_nothrow __attribute__((__nothrow__))
  1708. #elif (LZO_CC_MSC && (_MSC_VER >= 1200)) && defined(__cplusplus)
  1709. # define __lzo_nothrow __declspec(nothrow)
  1710. #endif
  1711. #endif
  1712. #if defined(__lzo_nothrow)
  1713. # ifndef __lzo_HAVE_nothrow
  1714. # define __lzo_HAVE_nothrow 1
  1715. # endif
  1716. #else
  1717. # define __lzo_nothrow /*empty*/
  1718. #endif
  1719. #if !defined(__lzo_restrict)
  1720. #if (LZO_CC_GNUC >= 0x030400ul)
  1721. # define __lzo_restrict __restrict__
  1722. #elif (LZO_CC_IBMC >= 800) && !defined(__cplusplus)
  1723. # define __lzo_restrict __restrict__
  1724. #elif (LZO_CC_IBMC >= 1210)
  1725. # define __lzo_restrict __restrict__
  1726. #elif (LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 600))
  1727. #elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 600))
  1728. # define __lzo_restrict __restrict__
  1729. #elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM)
  1730. # define __lzo_restrict __restrict__
  1731. #elif (LZO_CC_MSC && (_MSC_VER >= 1400))
  1732. # define __lzo_restrict __restrict
  1733. #elif (LZO_CC_PGI >= 0x0d0a00ul)
  1734. # define __lzo_restrict __restrict__
  1735. #endif
  1736. #endif
  1737. #if defined(__lzo_restrict)
  1738. # ifndef __lzo_HAVE_restrict
  1739. # define __lzo_HAVE_restrict 1
  1740. # endif
  1741. #else
  1742. # define __lzo_restrict /*empty*/
  1743. #endif
  1744. #if !defined(__lzo_alignof)
  1745. #if (LZO_CC_ARMCC || LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI)
  1746. # define __lzo_alignof(e) __alignof__(e)
  1747. #elif (LZO_CC_GHS) && !defined(__cplusplus)
  1748. # define __lzo_alignof(e) __alignof__(e)
  1749. #elif (LZO_CC_IBMC >= 600)
  1750. # define __lzo_alignof(e) (__lzo_gnuc_extension__ __alignof__(e))
  1751. #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 700))
  1752. # define __lzo_alignof(e) __alignof__(e)
  1753. #elif (LZO_CC_MSC && (_MSC_VER >= 1300))
  1754. # define __lzo_alignof(e) __alignof(e)
  1755. #elif (LZO_CC_SUNPROC >= 0x5100)
  1756. # define __lzo_alignof(e) __alignof__(e)
  1757. #endif
  1758. #endif
  1759. #if defined(__lzo_alignof)
  1760. # ifndef __lzo_HAVE_alignof
  1761. # define __lzo_HAVE_alignof 1
  1762. # endif
  1763. #endif
  1764. #if !defined(__lzo_struct_packed)
  1765. #if (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020800ul)) && defined(__cplusplus)
  1766. #elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020700ul))
  1767. #elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul)) && defined(__cplusplus)
  1768. #elif (LZO_CC_PCC && (LZO_CC_PCC < 0x010100ul))
  1769. #elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC < 0x5110)) && !defined(__cplusplus)
  1770. #elif (LZO_CC_GNUC >= 0x030400ul) && !(LZO_CC_PCC_GNUC) && (LZO_ARCH_AMD64 || LZO_ARCH_I386)
  1771. # define __lzo_struct_packed(s) struct s {
  1772. # define __lzo_struct_packed_end() } __attribute__((__gcc_struct__,__packed__));
  1773. # define __lzo_struct_packed_ma_end() } __lzo_may_alias __attribute__((__gcc_struct__,__packed__));
  1774. #elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || (LZO_CC_PGI >= 0x0d0a00ul) || (LZO_CC_SUNPROC >= 0x5100))
  1775. # define __lzo_struct_packed(s) struct s {
  1776. # define __lzo_struct_packed_end() } __attribute__((__packed__));
  1777. # define __lzo_struct_packed_ma_end() } __lzo_may_alias __attribute__((__packed__));
  1778. #elif (LZO_CC_IBMC >= 700)
  1779. # define __lzo_struct_packed(s) __lzo_gnuc_extension__ struct s {
  1780. # define __lzo_struct_packed_end() } __attribute__((__packed__));
  1781. # define __lzo_struct_packed_ma_end() } __lzo_may_alias __attribute__((__packed__));
  1782. #elif (LZO_CC_INTELC_MSC) || (LZO_CC_MSC && (_MSC_VER >= 1300))
  1783. # define __lzo_struct_packed(s) __pragma(pack(push,1)) struct s {
  1784. # define __lzo_struct_packed_end() } __pragma(pack(pop));
  1785. #elif (LZO_CC_WATCOMC && (__WATCOMC__ >= 900))
  1786. # define __lzo_struct_packed(s) _Packed struct s {
  1787. # define __lzo_struct_packed_end() };
  1788. #endif
  1789. #endif
  1790. #if defined(__lzo_struct_packed) && !defined(__lzo_struct_packed_ma)
  1791. # define __lzo_struct_packed_ma(s) __lzo_struct_packed(s)
  1792. #endif
  1793. #if defined(__lzo_struct_packed_end) && !defined(__lzo_struct_packed_ma_end)
  1794. # define __lzo_struct_packed_ma_end() __lzo_struct_packed_end()
  1795. #endif
  1796. #if !defined(__lzo_byte_struct)
  1797. #if defined(__lzo_struct_packed)
  1798. # define __lzo_byte_struct(s,n) __lzo_struct_packed(s) unsigned char a[n]; __lzo_struct_packed_end()
  1799. # define __lzo_byte_struct_ma(s,n) __lzo_struct_packed_ma(s) unsigned char a[n]; __lzo_struct_packed_ma_end()
  1800. #elif (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_PGI || (LZO_CC_SUNPROC >= 0x5100))
  1801. # define __lzo_byte_struct(s,n) struct s { unsigned char a[n]; } __attribute__((__packed__));
  1802. # define __lzo_byte_struct_ma(s,n) struct s { unsigned char a[n]; } __lzo_may_alias __attribute__((__packed__));
  1803. #endif
  1804. #endif
  1805. #if defined(__lzo_byte_struct) && !defined(__lzo_byte_struct_ma)
  1806. # define __lzo_byte_struct_ma(s,n) __lzo_byte_struct(s,n)
  1807. #endif
  1808. #if !defined(__lzo_struct_align16) && (__lzo_HAVE_alignof)
  1809. #if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x030000ul))
  1810. #elif (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020800ul)) && defined(__cplusplus)
  1811. #elif (LZO_CC_CILLY || LZO_CC_PCC)
  1812. #elif (LZO_CC_INTELC_MSC) || (LZO_CC_MSC && (_MSC_VER >= 1300))
  1813. # define __lzo_struct_align16(s) struct __declspec(align(16)) s {
  1814. # define __lzo_struct_align16_end() };
  1815. # define __lzo_struct_align32(s) struct __declspec(align(32)) s {
  1816. # define __lzo_struct_align32_end() };
  1817. # define __lzo_struct_align64(s) struct __declspec(align(64)) s {
  1818. # define __lzo_struct_align64_end() };
  1819. #elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_GNUC || (LZO_CC_IBMC >= 700) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE)
  1820. # define __lzo_struct_align16(s) struct s {
  1821. # define __lzo_struct_align16_end() } __attribute__((__aligned__(16)));
  1822. # define __lzo_struct_align32(s) struct s {
  1823. # define __lzo_struct_align32_end() } __attribute__((__aligned__(32)));
  1824. # define __lzo_struct_align64(s) struct s {
  1825. # define __lzo_struct_align64_end() } __attribute__((__aligned__(64)));
  1826. #endif
  1827. #endif
  1828. #if !defined(__lzo_union_um)
  1829. #if (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020800ul)) && defined(__cplusplus)
  1830. #elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020700ul))
  1831. #elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul)) && defined(__cplusplus)
  1832. #elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER < 810))
  1833. #elif (LZO_CC_PCC && (LZO_CC_PCC < 0x010100ul))
  1834. #elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC < 0x5110)) && !defined(__cplusplus)
  1835. #elif (LZO_CC_ARMCC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || (LZO_CC_PGI >= 0x0d0a00ul) || (LZO_CC_SUNPROC >= 0x5100))
  1836. # define __lzo_union_am(s) union s {
  1837. # define __lzo_union_am_end() } __lzo_may_alias;
  1838. # define __lzo_union_um(s) union s {
  1839. # define __lzo_union_um_end() } __lzo_may_alias __attribute__((__packed__));
  1840. #elif (LZO_CC_IBMC >= 700)
  1841. # define __lzo_union_am(s) __lzo_gnuc_extension__ union s {
  1842. # define __lzo_union_am_end() } __lzo_may_alias;
  1843. # define __lzo_union_um(s) __lzo_gnuc_extension__ union s {
  1844. # define __lzo_union_um_end() } __lzo_may_alias __attribute__((__packed__));
  1845. #elif (LZO_CC_INTELC_MSC) || (LZO_CC_MSC && (_MSC_VER >= 1300))
  1846. # define __lzo_union_um(s) __pragma(pack(push,1)) union s {
  1847. # define __lzo_union_um_end() } __pragma(pack(pop));
  1848. #elif (LZO_CC_WATCOMC && (__WATCOMC__ >= 900))
  1849. # define __lzo_union_um(s) _Packed union s {
  1850. # define __lzo_union_um_end() };
  1851. #endif
  1852. #endif
  1853. #if !defined(__lzo_union_am)
  1854. # define __lzo_union_am(s) union s {
  1855. # define __lzo_union_am_end() };
  1856. #endif
  1857. #if !defined(__lzo_constructor)
  1858. #if (LZO_CC_GNUC >= 0x030400ul)
  1859. # define __lzo_constructor __attribute__((__constructor__,__used__))
  1860. #elif (LZO_CC_GNUC >= 0x020700ul)
  1861. # define __lzo_constructor __attribute__((__constructor__))
  1862. #elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800))
  1863. # define __lzo_constructor __attribute__((__constructor__,__used__))
  1864. #elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
  1865. # define __lzo_constructor __attribute__((__constructor__))
  1866. #endif
  1867. #endif
  1868. #if defined(__lzo_constructor)
  1869. # ifndef __lzo_HAVE_constructor
  1870. # define __lzo_HAVE_constructor 1
  1871. # endif
  1872. #endif
  1873. #if !defined(__lzo_destructor)
  1874. #if (LZO_CC_GNUC >= 0x030400ul)
  1875. # define __lzo_destructor __attribute__((__destructor__,__used__))
  1876. #elif (LZO_CC_GNUC >= 0x020700ul)
  1877. # define __lzo_destructor __attribute__((__destructor__))
  1878. #elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 800))
  1879. # define __lzo_destructor __attribute__((__destructor__,__used__))
  1880. #elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
  1881. # define __lzo_destructor __attribute__((__destructor__))
  1882. #endif
  1883. #endif
  1884. #if defined(__lzo_destructor)
  1885. # ifndef __lzo_HAVE_destructor
  1886. # define __lzo_HAVE_destructor 1
  1887. # endif
  1888. #endif
  1889. #if (__lzo_HAVE_destructor) && !(__lzo_HAVE_constructor)
  1890. # error "unexpected configuration - check your compiler defines"
  1891. #endif
  1892. #if !defined(__lzo_likely) && !defined(__lzo_unlikely)
  1893. #if (LZO_CC_GNUC >= 0x030200ul)
  1894. # define __lzo_likely(e) (__builtin_expect(!!(e),1))
  1895. # define __lzo_unlikely(e) (__builtin_expect(!!(e),0))
  1896. #elif (LZO_CC_IBMC >= 1010)
  1897. # define __lzo_likely(e) (__builtin_expect(!!(e),1))
  1898. # define __lzo_unlikely(e) (__builtin_expect(!!(e),0))
  1899. #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800))
  1900. # define __lzo_likely(e) (__builtin_expect(!!(e),1))
  1901. # define __lzo_unlikely(e) (__builtin_expect(!!(e),0))
  1902. #elif (LZO_CC_CLANG && LZO_CC_CLANG_C2)
  1903. #elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
  1904. # define __lzo_likely(e) (__builtin_expect(!!(e),1))
  1905. # define __lzo_unlikely(e) (__builtin_expect(!!(e),0))
  1906. #endif
  1907. #endif
  1908. #if defined(__lzo_likely)
  1909. # ifndef __lzo_HAVE_likely
  1910. # define __lzo_HAVE_likely 1
  1911. # endif
  1912. #else
  1913. # define __lzo_likely(e) (e)
  1914. #endif
  1915. #if defined(__lzo_very_likely)
  1916. # ifndef __lzo_HAVE_very_likely
  1917. # define __lzo_HAVE_very_likely 1
  1918. # endif
  1919. #else
  1920. # define __lzo_very_likely(e) __lzo_likely(e)
  1921. #endif
  1922. #if defined(__lzo_unlikely)
  1923. # ifndef __lzo_HAVE_unlikely
  1924. # define __lzo_HAVE_unlikely 1
  1925. # endif
  1926. #else
  1927. # define __lzo_unlikely(e) (e)
  1928. #endif
  1929. #if defined(__lzo_very_unlikely)
  1930. # ifndef __lzo_HAVE_very_unlikely
  1931. # define __lzo_HAVE_very_unlikely 1
  1932. # endif
  1933. #else
  1934. # define __lzo_very_unlikely(e) __lzo_unlikely(e)
  1935. #endif
  1936. #if !defined(__lzo_loop_forever)
  1937. # if (LZO_CC_IBMC)
  1938. # define __lzo_loop_forever() LZO_BLOCK_BEGIN for (;;) { ; } LZO_BLOCK_END
  1939. # else
  1940. # define __lzo_loop_forever() do { ; } while __lzo_cte(1)
  1941. # endif
  1942. #endif
  1943. #if !defined(__lzo_unreachable)
  1944. #if (LZO_CC_CLANG && (LZO_CC_CLANG >= 0x020800ul)) && lzo_has_builtin(__builtin_unreachable)
  1945. # define __lzo_unreachable() __builtin_unreachable();
  1946. #elif (LZO_CC_GNUC >= 0x040500ul)
  1947. # define __lzo_unreachable() __builtin_unreachable();
  1948. #elif (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 1300)) && 1
  1949. # define __lzo_unreachable() __builtin_unreachable();
  1950. #endif
  1951. #endif
  1952. #if defined(__lzo_unreachable)
  1953. # ifndef __lzo_HAVE_unreachable
  1954. # define __lzo_HAVE_unreachable 1
  1955. # endif
  1956. #else
  1957. # if 0
  1958. # define __lzo_unreachable() ((void)0);
  1959. # else
  1960. # define __lzo_unreachable() __lzo_loop_forever();
  1961. # endif
  1962. #endif
  1963. #if !defined(lzo_unused_funcs_impl)
  1964. # if 1 && (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || (LZO_CC_GNUC >= 0x020700ul) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI)
  1965. # define lzo_unused_funcs_impl(r,f) static r __attribute__((__unused__)) f
  1966. # elif 1 && (LZO_CC_BORLANDC || LZO_CC_GNUC)
  1967. # define lzo_unused_funcs_impl(r,f) static r f
  1968. # else
  1969. # define lzo_unused_funcs_impl(r,f) __lzo_static_forceinline r f
  1970. # endif
  1971. #endif
  1972. #ifndef __LZO_CTA_NAME
  1973. #if (LZO_CFG_USE_COUNTER)
  1974. # define __LZO_CTA_NAME(a) LZO_PP_ECONCAT2(a,__COUNTER__)
  1975. #else
  1976. # define __LZO_CTA_NAME(a) LZO_PP_ECONCAT2(a,__LINE__)
  1977. #endif
  1978. #endif
  1979. #if !defined(LZO_COMPILE_TIME_ASSERT_HEADER)
  1980. # if (LZO_CC_AZTECC || LZO_CC_ZORTECHC)
  1981. # define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-!(e)]; LZO_EXTERN_C_END
  1982. # elif (LZO_CC_DMC || LZO_CC_SYMANTECC)
  1983. # define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1u-2*!(e)]; LZO_EXTERN_C_END
  1984. # elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295))
  1985. # define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-!(e)]; LZO_EXTERN_C_END
  1986. # elif (LZO_CC_CLANG && (LZO_CC_CLANG < 0x020900ul)) && defined(__cplusplus)
  1987. # define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN int __LZO_CTA_NAME(lzo_cta_f__)(int [1-2*!(e)]); LZO_EXTERN_C_END
  1988. # elif (LZO_CC_GNUC) && defined(__CHECKER__) && defined(__SPARSE_CHECKER__)
  1989. # define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN enum {__LZO_CTA_NAME(lzo_cta_e__)=1/!!(e)} __attribute__((__unused__)); LZO_EXTERN_C_END
  1990. # else
  1991. # define LZO_COMPILE_TIME_ASSERT_HEADER(e) LZO_EXTERN_C_BEGIN extern int __LZO_CTA_NAME(lzo_cta__)[1-2*!(e)]; LZO_EXTERN_C_END
  1992. # endif
  1993. #endif
  1994. #if !defined(LZO_COMPILE_TIME_ASSERT)
  1995. # if (LZO_CC_AZTECC)
  1996. # define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-!(e)];}
  1997. # elif (LZO_CC_CLANG && (LZO_CC_CLANG >= 0x030000ul))
  1998. # define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-2*!(e)] __attribute__((__unused__));}
  1999. # elif (LZO_CC_DMC || LZO_CC_PACIFICC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC)
  2000. # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break;
  2001. # elif (LZO_CC_GNUC) && defined(__CHECKER__) && defined(__SPARSE_CHECKER__)
  2002. # define LZO_COMPILE_TIME_ASSERT(e) {(void) (0/!!(e));}
  2003. # elif (LZO_CC_GNUC >= 0x040700ul) && (LZO_CFG_USE_COUNTER) && defined(__cplusplus)
  2004. # define LZO_COMPILE_TIME_ASSERT(e) {enum {__LZO_CTA_NAME(lzo_cta_e__)=1/!!(e)} __attribute__((__unused__));}
  2005. # elif (LZO_CC_GNUC >= 0x040700ul)
  2006. # define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-2*!(e)] __attribute__((__unused__));}
  2007. # elif (LZO_CC_MSC && (_MSC_VER < 900))
  2008. # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break;
  2009. # elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295))
  2010. # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break;
  2011. # else
  2012. # define LZO_COMPILE_TIME_ASSERT(e) {typedef int __LZO_CTA_NAME(lzo_cta_t__)[1-2*!(e)];}
  2013. # endif
  2014. #endif
  2015. #if (LZO_LANG_ASSEMBLER)
  2016. # undef LZO_COMPILE_TIME_ASSERT_HEADER
  2017. # define LZO_COMPILE_TIME_ASSERT_HEADER(e) /*empty*/
  2018. #else
  2019. LZO_COMPILE_TIME_ASSERT_HEADER(1 == 1)
  2020. #if defined(__cplusplus)
  2021. extern "C" { LZO_COMPILE_TIME_ASSERT_HEADER(2 == 2) }
  2022. #endif
  2023. LZO_COMPILE_TIME_ASSERT_HEADER(3 == 3)
  2024. #endif
  2025. #if (LZO_ARCH_I086 || LZO_ARCH_I386) && (LZO_OS_DOS16 || LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_OS216 || LZO_OS_WIN16 || LZO_OS_WIN32 || LZO_OS_WIN64)
  2026. # if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC)
  2027. # elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC)
  2028. # define __lzo_cdecl __cdecl
  2029. # define __lzo_cdecl_atexit /*empty*/
  2030. # define __lzo_cdecl_main __cdecl
  2031. # if (LZO_OS_OS2 && (LZO_CC_DMC || LZO_CC_SYMANTECC))
  2032. # define __lzo_cdecl_qsort __pascal
  2033. # elif (LZO_OS_OS2 && (LZO_CC_ZORTECHC))
  2034. # define __lzo_cdecl_qsort _stdcall
  2035. # else
  2036. # define __lzo_cdecl_qsort __cdecl
  2037. # endif
  2038. # elif (LZO_CC_WATCOMC)
  2039. # define __lzo_cdecl __cdecl
  2040. # else
  2041. # define __lzo_cdecl __cdecl
  2042. # define __lzo_cdecl_atexit __cdecl
  2043. # define __lzo_cdecl_main __cdecl
  2044. # define __lzo_cdecl_qsort __cdecl
  2045. # endif
  2046. # if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC || LZO_CC_WATCOMC)
  2047. # elif (LZO_OS_OS2 && (LZO_CC_DMC || LZO_CC_SYMANTECC))
  2048. # define __lzo_cdecl_sighandler __pascal
  2049. # elif (LZO_OS_OS2 && (LZO_CC_ZORTECHC))
  2050. # define __lzo_cdecl_sighandler _stdcall
  2051. # elif (LZO_CC_MSC && (_MSC_VER >= 1400)) && defined(_M_CEE_PURE)
  2052. # define __lzo_cdecl_sighandler __clrcall
  2053. # elif (LZO_CC_MSC && (_MSC_VER >= 600 && _MSC_VER < 700))
  2054. # if defined(_DLL)
  2055. # define __lzo_cdecl_sighandler _far _cdecl _loadds
  2056. # elif defined(_MT)
  2057. # define __lzo_cdecl_sighandler _far _cdecl
  2058. # else
  2059. # define __lzo_cdecl_sighandler _cdecl
  2060. # endif
  2061. # else
  2062. # define __lzo_cdecl_sighandler __cdecl
  2063. # endif
  2064. #elif (LZO_ARCH_I386) && (LZO_CC_WATCOMC)
  2065. # define __lzo_cdecl __cdecl
  2066. #elif (LZO_ARCH_M68K && LZO_OS_TOS && (LZO_CC_PUREC || LZO_CC_TURBOC))
  2067. # define __lzo_cdecl cdecl
  2068. #endif
  2069. #if !defined(__lzo_cdecl)
  2070. # define __lzo_cdecl /*empty*/
  2071. #endif
  2072. #if !defined(__lzo_cdecl_atexit)
  2073. # define __lzo_cdecl_atexit /*empty*/
  2074. #endif
  2075. #if !defined(__lzo_cdecl_main)
  2076. # define __lzo_cdecl_main /*empty*/
  2077. #endif
  2078. #if !defined(__lzo_cdecl_qsort)
  2079. # define __lzo_cdecl_qsort /*empty*/
  2080. #endif
  2081. #if !defined(__lzo_cdecl_sighandler)
  2082. # define __lzo_cdecl_sighandler /*empty*/
  2083. #endif
  2084. #if !defined(__lzo_cdecl_va)
  2085. # define __lzo_cdecl_va __lzo_cdecl
  2086. #endif
  2087. #if !(LZO_CFG_NO_WINDOWS_H)
  2088. #if !defined(LZO_HAVE_WINDOWS_H)
  2089. #if (LZO_OS_CYGWIN || (LZO_OS_EMX && defined(__RSXNT__)) || LZO_OS_WIN32 || LZO_OS_WIN64)
  2090. # if (LZO_CC_WATCOMC && (__WATCOMC__ < 1000))
  2091. # elif ((LZO_OS_WIN32 && defined(__PW32__)) && (LZO_CC_GNUC && (LZO_CC_GNUC < 0x030000ul)))
  2092. # elif ((LZO_OS_CYGWIN || defined(__MINGW32__)) && (LZO_CC_GNUC && (LZO_CC_GNUC < 0x025f00ul)))
  2093. # else
  2094. # define LZO_HAVE_WINDOWS_H 1
  2095. # endif
  2096. #endif
  2097. #endif
  2098. #endif
  2099. #define LZO_SIZEOF_CHAR 1
  2100. #ifndef LZO_SIZEOF_SHORT
  2101. #if defined(SIZEOF_SHORT)
  2102. # define LZO_SIZEOF_SHORT (SIZEOF_SHORT)
  2103. #elif defined(__SIZEOF_SHORT__)
  2104. # define LZO_SIZEOF_SHORT (__SIZEOF_SHORT__)
  2105. #endif
  2106. #endif
  2107. #ifndef LZO_SIZEOF_INT
  2108. #if defined(SIZEOF_INT)
  2109. # define LZO_SIZEOF_INT (SIZEOF_INT)
  2110. #elif defined(__SIZEOF_INT__)
  2111. # define LZO_SIZEOF_INT (__SIZEOF_INT__)
  2112. #endif
  2113. #endif
  2114. #ifndef LZO_SIZEOF_LONG
  2115. #if defined(SIZEOF_LONG)
  2116. # define LZO_SIZEOF_LONG (SIZEOF_LONG)
  2117. #elif defined(__SIZEOF_LONG__)
  2118. # define LZO_SIZEOF_LONG (__SIZEOF_LONG__)
  2119. #endif
  2120. #endif
  2121. #ifndef LZO_SIZEOF_LONG_LONG
  2122. #if defined(SIZEOF_LONG_LONG)
  2123. # define LZO_SIZEOF_LONG_LONG (SIZEOF_LONG_LONG)
  2124. #elif defined(__SIZEOF_LONG_LONG__)
  2125. # define LZO_SIZEOF_LONG_LONG (__SIZEOF_LONG_LONG__)
  2126. #endif
  2127. #endif
  2128. #ifndef LZO_SIZEOF___INT16
  2129. #if defined(SIZEOF___INT16)
  2130. # define LZO_SIZEOF___INT16 (SIZEOF___INT16)
  2131. #endif
  2132. #endif
  2133. #ifndef LZO_SIZEOF___INT32
  2134. #if defined(SIZEOF___INT32)
  2135. # define LZO_SIZEOF___INT32 (SIZEOF___INT32)
  2136. #endif
  2137. #endif
  2138. #ifndef LZO_SIZEOF___INT64
  2139. #if defined(SIZEOF___INT64)
  2140. # define LZO_SIZEOF___INT64 (SIZEOF___INT64)
  2141. #endif
  2142. #endif
  2143. #ifndef LZO_SIZEOF_VOID_P
  2144. #if defined(SIZEOF_VOID_P)
  2145. # define LZO_SIZEOF_VOID_P (SIZEOF_VOID_P)
  2146. #elif defined(__SIZEOF_POINTER__)
  2147. # define LZO_SIZEOF_VOID_P (__SIZEOF_POINTER__)
  2148. #endif
  2149. #endif
  2150. #ifndef LZO_SIZEOF_SIZE_T
  2151. #if defined(SIZEOF_SIZE_T)
  2152. # define LZO_SIZEOF_SIZE_T (SIZEOF_SIZE_T)
  2153. #elif defined(__SIZEOF_SIZE_T__)
  2154. # define LZO_SIZEOF_SIZE_T (__SIZEOF_SIZE_T__)
  2155. #endif
  2156. #endif
  2157. #ifndef LZO_SIZEOF_PTRDIFF_T
  2158. #if defined(SIZEOF_PTRDIFF_T)
  2159. # define LZO_SIZEOF_PTRDIFF_T (SIZEOF_PTRDIFF_T)
  2160. #elif defined(__SIZEOF_PTRDIFF_T__)
  2161. # define LZO_SIZEOF_PTRDIFF_T (__SIZEOF_PTRDIFF_T__)
  2162. #endif
  2163. #endif
  2164. #define __LZO_LSR(x,b) (((x)+0ul) >> (b))
  2165. #if !defined(LZO_SIZEOF_SHORT)
  2166. # if (LZO_ARCH_CRAY_PVP)
  2167. # define LZO_SIZEOF_SHORT 8
  2168. # elif (USHRT_MAX == LZO_0xffffL)
  2169. # define LZO_SIZEOF_SHORT 2
  2170. # elif (__LZO_LSR(USHRT_MAX,7) == 1)
  2171. # define LZO_SIZEOF_SHORT 1
  2172. # elif (__LZO_LSR(USHRT_MAX,15) == 1)
  2173. # define LZO_SIZEOF_SHORT 2
  2174. # elif (__LZO_LSR(USHRT_MAX,31) == 1)
  2175. # define LZO_SIZEOF_SHORT 4
  2176. # elif (__LZO_LSR(USHRT_MAX,63) == 1)
  2177. # define LZO_SIZEOF_SHORT 8
  2178. # elif (__LZO_LSR(USHRT_MAX,127) == 1)
  2179. # define LZO_SIZEOF_SHORT 16
  2180. # else
  2181. # error "LZO_SIZEOF_SHORT"
  2182. # endif
  2183. #endif
  2184. LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_SHORT == sizeof(short))
  2185. #if !defined(LZO_SIZEOF_INT)
  2186. # if (LZO_ARCH_CRAY_PVP)
  2187. # define LZO_SIZEOF_INT 8
  2188. # elif (UINT_MAX == LZO_0xffffL)
  2189. # define LZO_SIZEOF_INT 2
  2190. # elif (UINT_MAX == LZO_0xffffffffL)
  2191. # define LZO_SIZEOF_INT 4
  2192. # elif (__LZO_LSR(UINT_MAX,7) == 1)
  2193. # define LZO_SIZEOF_INT 1
  2194. # elif (__LZO_LSR(UINT_MAX,15) == 1)
  2195. # define LZO_SIZEOF_INT 2
  2196. # elif (__LZO_LSR(UINT_MAX,31) == 1)
  2197. # define LZO_SIZEOF_INT 4
  2198. # elif (__LZO_LSR(UINT_MAX,63) == 1)
  2199. # define LZO_SIZEOF_INT 8
  2200. # elif (__LZO_LSR(UINT_MAX,127) == 1)
  2201. # define LZO_SIZEOF_INT 16
  2202. # else
  2203. # error "LZO_SIZEOF_INT"
  2204. # endif
  2205. #endif
  2206. LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_INT == sizeof(int))
  2207. #if !defined(LZO_SIZEOF_LONG)
  2208. # if (ULONG_MAX == LZO_0xffffffffL)
  2209. # define LZO_SIZEOF_LONG 4
  2210. # elif (__LZO_LSR(ULONG_MAX,7) == 1)
  2211. # define LZO_SIZEOF_LONG 1
  2212. # elif (__LZO_LSR(ULONG_MAX,15) == 1)
  2213. # define LZO_SIZEOF_LONG 2
  2214. # elif (__LZO_LSR(ULONG_MAX,31) == 1)
  2215. # define LZO_SIZEOF_LONG 4
  2216. # elif (__LZO_LSR(ULONG_MAX,39) == 1)
  2217. # define LZO_SIZEOF_LONG 5
  2218. # elif (__LZO_LSR(ULONG_MAX,63) == 1)
  2219. # define LZO_SIZEOF_LONG 8
  2220. # elif (__LZO_LSR(ULONG_MAX,127) == 1)
  2221. # define LZO_SIZEOF_LONG 16
  2222. # else
  2223. # error "LZO_SIZEOF_LONG"
  2224. # endif
  2225. #endif
  2226. LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_LONG == sizeof(long))
  2227. #if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64)
  2228. #if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8)
  2229. # if defined(__LONG_MAX__) && defined(__LONG_LONG_MAX__)
  2230. # if (LZO_CC_GNUC >= 0x030300ul)
  2231. # if ((__LONG_MAX__-0) == (__LONG_LONG_MAX__-0))
  2232. # define LZO_SIZEOF_LONG_LONG LZO_SIZEOF_LONG
  2233. # elif (__LZO_LSR(__LONG_LONG_MAX__,30) == 1)
  2234. # define LZO_SIZEOF_LONG_LONG 4
  2235. # endif
  2236. # endif
  2237. # endif
  2238. #endif
  2239. #endif
  2240. #if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64)
  2241. #if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8)
  2242. #if (LZO_ARCH_I086 && LZO_CC_DMC)
  2243. #elif (LZO_CC_CILLY) && defined(__GNUC__)
  2244. # define LZO_SIZEOF_LONG_LONG 8
  2245. #elif (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE)
  2246. # define LZO_SIZEOF_LONG_LONG 8
  2247. #elif ((LZO_OS_WIN32 || LZO_OS_WIN64 || defined(_WIN32)) && LZO_CC_MSC && (_MSC_VER >= 1400))
  2248. # define LZO_SIZEOF_LONG_LONG 8
  2249. #elif (LZO_OS_WIN64 || defined(_WIN64))
  2250. # define LZO_SIZEOF___INT64 8
  2251. #elif (LZO_ARCH_I386 && (LZO_CC_DMC))
  2252. # define LZO_SIZEOF_LONG_LONG 8
  2253. #elif (LZO_ARCH_I386 && (LZO_CC_SYMANTECC && (__SC__ >= 0x700)))
  2254. # define LZO_SIZEOF_LONG_LONG 8
  2255. #elif (LZO_ARCH_I386 && (LZO_CC_INTELC && defined(__linux__)))
  2256. # define LZO_SIZEOF_LONG_LONG 8
  2257. #elif (LZO_ARCH_I386 && (LZO_CC_MWERKS || LZO_CC_PELLESC || LZO_CC_PGI || LZO_CC_SUNPROC))
  2258. # define LZO_SIZEOF_LONG_LONG 8
  2259. #elif (LZO_ARCH_I386 && (LZO_CC_INTELC || LZO_CC_MSC))
  2260. # define LZO_SIZEOF___INT64 8
  2261. #elif ((LZO_OS_WIN32 || defined(_WIN32)) && (LZO_CC_MSC))
  2262. # define LZO_SIZEOF___INT64 8
  2263. #elif (LZO_ARCH_I386 && (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0520)))
  2264. # define LZO_SIZEOF___INT64 8
  2265. #elif (LZO_ARCH_I386 && (LZO_CC_WATCOMC && (__WATCOMC__ >= 1100)))
  2266. # define LZO_SIZEOF___INT64 8
  2267. #elif (LZO_CC_GHS && defined(__LLONG_BIT) && ((__LLONG_BIT-0) == 64))
  2268. # define LZO_SIZEOF_LONG_LONG 8
  2269. #elif (LZO_CC_WATCOMC && defined(_INTEGRAL_MAX_BITS) && ((_INTEGRAL_MAX_BITS-0) == 64))
  2270. # define LZO_SIZEOF___INT64 8
  2271. #elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__)
  2272. # define LZO_SIZEOF_LONG_LONG 8
  2273. #elif (defined(__vms) || defined(__VMS)) && ((__INITIAL_POINTER_SIZE-0) == 64)
  2274. # define LZO_SIZEOF_LONG_LONG 8
  2275. #elif (LZO_CC_SDCC) && (LZO_SIZEOF_INT == 2)
  2276. #elif 1 && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
  2277. # define LZO_SIZEOF_LONG_LONG 8
  2278. #endif
  2279. #endif
  2280. #endif
  2281. #if defined(__cplusplus) && (LZO_CC_GNUC)
  2282. # if (LZO_CC_GNUC < 0x020800ul)
  2283. # undef LZO_SIZEOF_LONG_LONG
  2284. # endif
  2285. #endif
  2286. #if (LZO_CFG_NO_LONG_LONG)
  2287. # undef LZO_SIZEOF_LONG_LONG
  2288. #elif defined(__NO_LONG_LONG)
  2289. # undef LZO_SIZEOF_LONG_LONG
  2290. #elif defined(_NO_LONGLONG)
  2291. # undef LZO_SIZEOF_LONG_LONG
  2292. #endif
  2293. #if !defined(LZO_WORDSIZE)
  2294. #if (LZO_ARCH_ALPHA)
  2295. # define LZO_WORDSIZE 8
  2296. #elif (LZO_ARCH_AMD64)
  2297. # define LZO_WORDSIZE 8
  2298. #elif (LZO_ARCH_ARM64)
  2299. # define LZO_WORDSIZE 8
  2300. #elif (LZO_ARCH_AVR)
  2301. # define LZO_WORDSIZE 1
  2302. #elif (LZO_ARCH_H8300)
  2303. # if defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__)
  2304. # define LZO_WORDSIZE 4
  2305. # else
  2306. # define LZO_WORDSIZE 2
  2307. # endif
  2308. #elif (LZO_ARCH_I086)
  2309. # define LZO_WORDSIZE 2
  2310. #elif (LZO_ARCH_IA64)
  2311. # define LZO_WORDSIZE 8
  2312. #elif (LZO_ARCH_M16C)
  2313. # define LZO_WORDSIZE 2
  2314. #elif (LZO_ARCH_SPU)
  2315. # define LZO_WORDSIZE 4
  2316. #elif (LZO_ARCH_Z80)
  2317. # define LZO_WORDSIZE 1
  2318. #elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__))
  2319. # define LZO_WORDSIZE 8
  2320. #elif (LZO_OS_OS400 || defined(__OS400__))
  2321. # define LZO_WORDSIZE 8
  2322. #elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64)
  2323. # define LZO_WORDSIZE 8
  2324. #endif
  2325. #endif
  2326. #if !defined(LZO_SIZEOF_VOID_P)
  2327. #if defined(__ILP32__) || defined(__ILP32) || defined(_ILP32)
  2328. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(int) == 4)
  2329. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 4)
  2330. # define LZO_SIZEOF_VOID_P 4
  2331. #elif defined(__ILP64__) || defined(__ILP64) || defined(_ILP64)
  2332. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(int) == 8)
  2333. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 8)
  2334. # define LZO_SIZEOF_VOID_P 8
  2335. #elif defined(__LLP64__) || defined(__LLP64) || defined(_LLP64) || defined(_WIN64)
  2336. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 4)
  2337. # define LZO_SIZEOF_VOID_P 8
  2338. #elif defined(__LP64__) || defined(__LP64) || defined(_LP64)
  2339. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(long) == 8)
  2340. # define LZO_SIZEOF_VOID_P 8
  2341. #elif (LZO_ARCH_AVR)
  2342. # define LZO_SIZEOF_VOID_P 2
  2343. #elif (LZO_ARCH_C166 || LZO_ARCH_MCS51 || LZO_ARCH_MCS251 || LZO_ARCH_MSP430)
  2344. # define LZO_SIZEOF_VOID_P 2
  2345. #elif (LZO_ARCH_H8300)
  2346. # if defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__)
  2347. LZO_COMPILE_TIME_ASSERT_HEADER(LZO_WORDSIZE == 4)
  2348. # if defined(__NORMAL_MODE__)
  2349. # define LZO_SIZEOF_VOID_P 2
  2350. # else
  2351. # define LZO_SIZEOF_VOID_P 4
  2352. # endif
  2353. # else
  2354. LZO_COMPILE_TIME_ASSERT_HEADER(LZO_WORDSIZE == 2)
  2355. # define LZO_SIZEOF_VOID_P 2
  2356. # endif
  2357. # if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x040000ul)) && (LZO_SIZEOF_INT == 4)
  2358. # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_INT
  2359. # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_INT
  2360. # endif
  2361. #elif (LZO_ARCH_I086)
  2362. # if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM)
  2363. # define LZO_SIZEOF_VOID_P 2
  2364. # elif (LZO_MM_COMPACT || LZO_MM_LARGE || LZO_MM_HUGE)
  2365. # define LZO_SIZEOF_VOID_P 4
  2366. # else
  2367. # error "invalid LZO_ARCH_I086 memory model"
  2368. # endif
  2369. #elif (LZO_ARCH_M16C)
  2370. # if defined(__m32c_cpu__) || defined(__m32cm_cpu__)
  2371. # define LZO_SIZEOF_VOID_P 4
  2372. # else
  2373. # define LZO_SIZEOF_VOID_P 2
  2374. # endif
  2375. #elif (LZO_ARCH_SPU)
  2376. # define LZO_SIZEOF_VOID_P 4
  2377. #elif (LZO_ARCH_Z80)
  2378. # define LZO_SIZEOF_VOID_P 2
  2379. #elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__))
  2380. # define LZO_SIZEOF_VOID_P 4
  2381. #elif (LZO_OS_OS400 || defined(__OS400__))
  2382. # if defined(__LLP64_IFC__)
  2383. # define LZO_SIZEOF_VOID_P 8
  2384. # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG
  2385. # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG
  2386. # else
  2387. # define LZO_SIZEOF_VOID_P 16
  2388. # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG
  2389. # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG
  2390. # endif
  2391. #elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64)
  2392. # define LZO_SIZEOF_VOID_P 8
  2393. # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG
  2394. # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG
  2395. #endif
  2396. #endif
  2397. #if !defined(LZO_SIZEOF_VOID_P)
  2398. # define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG
  2399. #endif
  2400. LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_VOID_P == sizeof(void *))
  2401. #if !defined(LZO_SIZEOF_SIZE_T)
  2402. #if (LZO_ARCH_I086 || LZO_ARCH_M16C)
  2403. # define LZO_SIZEOF_SIZE_T 2
  2404. #endif
  2405. #endif
  2406. #if !defined(LZO_SIZEOF_SIZE_T)
  2407. # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_VOID_P
  2408. #endif
  2409. #if defined(offsetof)
  2410. LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_SIZE_T == sizeof(size_t))
  2411. #endif
  2412. #if !defined(LZO_SIZEOF_PTRDIFF_T)
  2413. #if (LZO_ARCH_I086)
  2414. # if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM || LZO_MM_HUGE)
  2415. # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_VOID_P
  2416. # elif (LZO_MM_COMPACT || LZO_MM_LARGE)
  2417. # if (LZO_CC_BORLANDC || LZO_CC_TURBOC)
  2418. # define LZO_SIZEOF_PTRDIFF_T 4
  2419. # else
  2420. # define LZO_SIZEOF_PTRDIFF_T 2
  2421. # endif
  2422. # else
  2423. # error "invalid LZO_ARCH_I086 memory model"
  2424. # endif
  2425. #endif
  2426. #endif
  2427. #if !defined(LZO_SIZEOF_PTRDIFF_T)
  2428. # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_SIZE_T
  2429. #endif
  2430. #if defined(offsetof)
  2431. LZO_COMPILE_TIME_ASSERT_HEADER(LZO_SIZEOF_PTRDIFF_T == sizeof(ptrdiff_t))
  2432. #endif
  2433. #if !defined(LZO_WORDSIZE)
  2434. # define LZO_WORDSIZE LZO_SIZEOF_VOID_P
  2435. #endif
  2436. #if (LZO_ABI_NEUTRAL_ENDIAN)
  2437. # undef LZO_ABI_BIG_ENDIAN
  2438. # undef LZO_ABI_LITTLE_ENDIAN
  2439. #elif !(LZO_ABI_BIG_ENDIAN) && !(LZO_ABI_LITTLE_ENDIAN)
  2440. #if (LZO_ARCH_ALPHA) && (LZO_ARCH_CRAY_MPP)
  2441. # define LZO_ABI_BIG_ENDIAN 1
  2442. #elif (LZO_ARCH_IA64) && (LZO_OS_POSIX_LINUX || LZO_OS_WIN64)
  2443. # define LZO_ABI_LITTLE_ENDIAN 1
  2444. #elif (LZO_ARCH_ALPHA || LZO_ARCH_AMD64 || LZO_ARCH_BLACKFIN || LZO_ARCH_CRIS || LZO_ARCH_I086 || LZO_ARCH_I386 || LZO_ARCH_MSP430 || LZO_ARCH_RISCV)
  2445. # define LZO_ABI_LITTLE_ENDIAN 1
  2446. #elif (LZO_ARCH_AVR32 || LZO_ARCH_M68K || LZO_ARCH_S390 || LZO_ARCH_SPU)
  2447. # define LZO_ABI_BIG_ENDIAN 1
  2448. #elif 1 && defined(__IAR_SYSTEMS_ICC__) && defined(__LITTLE_ENDIAN__)
  2449. # if (__LITTLE_ENDIAN__ == 1)
  2450. # define LZO_ABI_LITTLE_ENDIAN 1
  2451. # else
  2452. # define LZO_ABI_BIG_ENDIAN 1
  2453. # endif
  2454. #elif 1 && defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__)
  2455. # define LZO_ABI_BIG_ENDIAN 1
  2456. #elif 1 && defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)
  2457. # define LZO_ABI_LITTLE_ENDIAN 1
  2458. #elif 1 && (LZO_ARCH_ARM) && defined(__ARM_BIG_ENDIAN) && ((__ARM_BIG_ENDIAN)+0)
  2459. # define LZO_ABI_BIG_ENDIAN 1
  2460. #elif 1 && (LZO_ARCH_ARM) && defined(__ARMEB__) && !defined(__ARMEL__)
  2461. # define LZO_ABI_BIG_ENDIAN 1
  2462. #elif 1 && (LZO_ARCH_ARM) && defined(__ARMEL__) && !defined(__ARMEB__)
  2463. # define LZO_ABI_LITTLE_ENDIAN 1
  2464. #elif 1 && (LZO_ARCH_ARM) && defined(_MSC_VER) && defined(_WIN32)
  2465. # define LZO_ABI_LITTLE_ENDIAN 1
  2466. #elif 1 && (LZO_ARCH_ARM && LZO_CC_ARMCC_ARMCC)
  2467. # if defined(__BIG_ENDIAN) && defined(__LITTLE_ENDIAN)
  2468. # error "unexpected configuration - check your compiler defines"
  2469. # elif defined(__BIG_ENDIAN)
  2470. # define LZO_ABI_BIG_ENDIAN 1
  2471. # else
  2472. # define LZO_ABI_LITTLE_ENDIAN 1
  2473. # endif
  2474. # define LZO_ABI_LITTLE_ENDIAN 1
  2475. #elif 1 && (LZO_ARCH_ARM64) && defined(__ARM_BIG_ENDIAN) && ((__ARM_BIG_ENDIAN)+0)
  2476. # define LZO_ABI_BIG_ENDIAN 1
  2477. #elif 1 && (LZO_ARCH_ARM64) && defined(__AARCH64EB__) && !defined(__AARCH64EL__)
  2478. # define LZO_ABI_BIG_ENDIAN 1
  2479. #elif 1 && (LZO_ARCH_ARM64) && defined(__AARCH64EL__) && !defined(__AARCH64EB__)
  2480. # define LZO_ABI_LITTLE_ENDIAN 1
  2481. #elif 1 && (LZO_ARCH_ARM64) && defined(_MSC_VER) && defined(_WIN32)
  2482. # define LZO_ABI_LITTLE_ENDIAN 1
  2483. #elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEB__) && !defined(__MIPSEL__)
  2484. # define LZO_ABI_BIG_ENDIAN 1
  2485. #elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEL__) && !defined(__MIPSEB__)
  2486. # define LZO_ABI_LITTLE_ENDIAN 1
  2487. #endif
  2488. #endif
  2489. #if (LZO_ABI_BIG_ENDIAN) && (LZO_ABI_LITTLE_ENDIAN)
  2490. # error "unexpected configuration - check your compiler defines"
  2491. #endif
  2492. #if (LZO_ABI_BIG_ENDIAN)
  2493. # define LZO_INFO_ABI_ENDIAN "be"
  2494. #elif (LZO_ABI_LITTLE_ENDIAN)
  2495. # define LZO_INFO_ABI_ENDIAN "le"
  2496. #elif (LZO_ABI_NEUTRAL_ENDIAN)
  2497. # define LZO_INFO_ABI_ENDIAN "neutral"
  2498. #endif
  2499. #if (LZO_SIZEOF_INT == 1 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2)
  2500. # define LZO_ABI_I8LP16 1
  2501. # define LZO_INFO_ABI_PM "i8lp16"
  2502. #elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2)
  2503. # define LZO_ABI_ILP16 1
  2504. # define LZO_INFO_ABI_PM "ilp16"
  2505. #elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4)
  2506. # define LZO_ABI_LP32 1
  2507. # define LZO_INFO_ABI_PM "lp32"
  2508. #elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4)
  2509. # define LZO_ABI_ILP32 1
  2510. # define LZO_INFO_ABI_PM "ilp32"
  2511. #elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 8 && LZO_SIZEOF_SIZE_T == 8)
  2512. # define LZO_ABI_LLP64 1
  2513. # define LZO_INFO_ABI_PM "llp64"
  2514. #elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8)
  2515. # define LZO_ABI_LP64 1
  2516. # define LZO_INFO_ABI_PM "lp64"
  2517. #elif (LZO_SIZEOF_INT == 8 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8)
  2518. # define LZO_ABI_ILP64 1
  2519. # define LZO_INFO_ABI_PM "ilp64"
  2520. #elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 4)
  2521. # define LZO_ABI_IP32L64 1
  2522. # define LZO_INFO_ABI_PM "ip32l64"
  2523. #endif
  2524. #if (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_VOID_P == 4 && LZO_WORDSIZE == 8)
  2525. # define LZO_ABI_IP32W64 1
  2526. # ifndef LZO_INFO_ABI_PM
  2527. # define LZO_INFO_ABI_PM "ip32w64"
  2528. # endif
  2529. #endif
  2530. #if 0
  2531. #elif !defined(__LZO_LIBC_OVERRIDE)
  2532. #if (LZO_LIBC_NAKED)
  2533. # define LZO_INFO_LIBC "naked"
  2534. #elif (LZO_LIBC_FREESTANDING)
  2535. # define LZO_INFO_LIBC "freestanding"
  2536. #elif (LZO_LIBC_MOSTLY_FREESTANDING)
  2537. # define LZO_INFO_LIBC "mfreestanding"
  2538. #elif (LZO_LIBC_ISOC90)
  2539. # define LZO_INFO_LIBC "isoc90"
  2540. #elif (LZO_LIBC_ISOC99)
  2541. # define LZO_INFO_LIBC "isoc99"
  2542. #elif (LZO_CC_ARMCC_ARMCC) && defined(__ARMCLIB_VERSION)
  2543. # define LZO_LIBC_ISOC90 1
  2544. # define LZO_INFO_LIBC "isoc90"
  2545. #elif defined(__dietlibc__)
  2546. # define LZO_LIBC_DIETLIBC 1
  2547. # define LZO_INFO_LIBC "dietlibc"
  2548. #elif defined(_NEWLIB_VERSION)
  2549. # define LZO_LIBC_NEWLIB 1
  2550. # define LZO_INFO_LIBC "newlib"
  2551. #elif defined(__UCLIBC__) && defined(__UCLIBC_MAJOR__) && defined(__UCLIBC_MINOR__)
  2552. # if defined(__UCLIBC_SUBLEVEL__)
  2553. # define LZO_LIBC_UCLIBC (__UCLIBC_MAJOR__ * 0x10000L + (__UCLIBC_MINOR__-0) * 0x100 + (__UCLIBC_SUBLEVEL__-0))
  2554. # else
  2555. # define LZO_LIBC_UCLIBC 0x00090bL
  2556. # endif
  2557. # define LZO_INFO_LIBC "uc" "libc"
  2558. #elif defined(__GLIBC__) && defined(__GLIBC_MINOR__)
  2559. # define LZO_LIBC_GLIBC (__GLIBC__ * 0x10000L + (__GLIBC_MINOR__-0) * 0x100)
  2560. # define LZO_INFO_LIBC "glibc"
  2561. #elif (LZO_CC_MWERKS) && defined(__MSL__)
  2562. # define LZO_LIBC_MSL __MSL__
  2563. # define LZO_INFO_LIBC "msl"
  2564. #elif 1 && defined(__IAR_SYSTEMS_ICC__)
  2565. # define LZO_LIBC_ISOC90 1
  2566. # define LZO_INFO_LIBC "isoc90"
  2567. #else
  2568. # define LZO_LIBC_DEFAULT 1
  2569. # define LZO_INFO_LIBC "default"
  2570. #endif
  2571. #endif
  2572. #if (LZO_ARCH_I386 && (LZO_OS_DOS32 || LZO_OS_WIN32) && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC))
  2573. # define LZO_ASM_SYNTAX_MSC 1
  2574. #elif (LZO_OS_WIN64 && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC))
  2575. #elif (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC == 0x011f00ul))
  2576. #elif (LZO_ARCH_I386 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE))
  2577. # define LZO_ASM_SYNTAX_GNUC 1
  2578. #elif (LZO_ARCH_AMD64 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE))
  2579. # define LZO_ASM_SYNTAX_GNUC 1
  2580. #elif (LZO_CC_GNUC)
  2581. # define LZO_ASM_SYNTAX_GNUC 1
  2582. #endif
  2583. #if (LZO_ASM_SYNTAX_GNUC)
  2584. #if (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC < 0x020000ul))
  2585. # define __LZO_ASM_CLOBBER "ax"
  2586. # define __LZO_ASM_CLOBBER_LIST_CC /*empty*/
  2587. # define __LZO_ASM_CLOBBER_LIST_CC_MEMORY /*empty*/
  2588. # define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/
  2589. #elif (LZO_CC_INTELC && (__INTEL_COMPILER < 1000))
  2590. # define __LZO_ASM_CLOBBER "memory"
  2591. # define __LZO_ASM_CLOBBER_LIST_CC /*empty*/
  2592. # define __LZO_ASM_CLOBBER_LIST_CC_MEMORY : "memory"
  2593. # define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/
  2594. #else
  2595. # define __LZO_ASM_CLOBBER "cc", "memory"
  2596. # define __LZO_ASM_CLOBBER_LIST_CC : "cc"
  2597. # define __LZO_ASM_CLOBBER_LIST_CC_MEMORY : "cc", "memory"
  2598. # define __LZO_ASM_CLOBBER_LIST_EMPTY /*empty*/
  2599. #endif
  2600. #endif
  2601. #if (LZO_ARCH_ALPHA)
  2602. # define LZO_OPT_AVOID_UINT_INDEX 1
  2603. #elif (LZO_ARCH_AMD64)
  2604. # define LZO_OPT_AVOID_INT_INDEX 1
  2605. # define LZO_OPT_AVOID_UINT_INDEX 1
  2606. # ifndef LZO_OPT_UNALIGNED16
  2607. # define LZO_OPT_UNALIGNED16 1
  2608. # endif
  2609. # ifndef LZO_OPT_UNALIGNED32
  2610. # define LZO_OPT_UNALIGNED32 1
  2611. # endif
  2612. # ifndef LZO_OPT_UNALIGNED64
  2613. # define LZO_OPT_UNALIGNED64 1
  2614. # endif
  2615. #elif (LZO_ARCH_ARM)
  2616. # if defined(__ARM_FEATURE_UNALIGNED)
  2617. # if ((__ARM_FEATURE_UNALIGNED)+0)
  2618. # ifndef LZO_OPT_UNALIGNED16
  2619. # define LZO_OPT_UNALIGNED16 1
  2620. # endif
  2621. # ifndef LZO_OPT_UNALIGNED32
  2622. # define LZO_OPT_UNALIGNED32 1
  2623. # endif
  2624. # endif
  2625. # elif 1 && (LZO_ARCH_ARM_THUMB2)
  2626. # ifndef LZO_OPT_UNALIGNED16
  2627. # define LZO_OPT_UNALIGNED16 1
  2628. # endif
  2629. # ifndef LZO_OPT_UNALIGNED32
  2630. # define LZO_OPT_UNALIGNED32 1
  2631. # endif
  2632. # elif 1 && defined(__ARM_ARCH) && ((__ARM_ARCH)+0 >= 7)
  2633. # ifndef LZO_OPT_UNALIGNED16
  2634. # define LZO_OPT_UNALIGNED16 1
  2635. # endif
  2636. # ifndef LZO_OPT_UNALIGNED32
  2637. # define LZO_OPT_UNALIGNED32 1
  2638. # endif
  2639. # elif 1 && defined(__TARGET_ARCH_ARM) && ((__TARGET_ARCH_ARM)+0 >= 7)
  2640. # ifndef LZO_OPT_UNALIGNED16
  2641. # define LZO_OPT_UNALIGNED16 1
  2642. # endif
  2643. # ifndef LZO_OPT_UNALIGNED32
  2644. # define LZO_OPT_UNALIGNED32 1
  2645. # endif
  2646. # elif 1 && defined(__TARGET_ARCH_ARM) && ((__TARGET_ARCH_ARM)+0 >= 6) && (defined(__TARGET_PROFILE_A) || defined(__TARGET_PROFILE_R))
  2647. # ifndef LZO_OPT_UNALIGNED16
  2648. # define LZO_OPT_UNALIGNED16 1
  2649. # endif
  2650. # ifndef LZO_OPT_UNALIGNED32
  2651. # define LZO_OPT_UNALIGNED32 1
  2652. # endif
  2653. # elif 1 && defined(_MSC_VER) && defined(_M_ARM) && ((_M_ARM)+0 >= 7)
  2654. # ifndef LZO_OPT_UNALIGNED16
  2655. # define LZO_OPT_UNALIGNED16 1
  2656. # endif
  2657. # ifndef LZO_OPT_UNALIGNED32
  2658. # define LZO_OPT_UNALIGNED32 1
  2659. # endif
  2660. # endif
  2661. #elif (LZO_ARCH_ARM64)
  2662. # ifndef LZO_OPT_UNALIGNED16
  2663. # define LZO_OPT_UNALIGNED16 1
  2664. # endif
  2665. # ifndef LZO_OPT_UNALIGNED32
  2666. # define LZO_OPT_UNALIGNED32 1
  2667. # endif
  2668. # ifndef LZO_OPT_UNALIGNED64
  2669. # define LZO_OPT_UNALIGNED64 1
  2670. # endif
  2671. #elif (LZO_ARCH_CRIS)
  2672. # ifndef LZO_OPT_UNALIGNED16
  2673. # define LZO_OPT_UNALIGNED16 1
  2674. # endif
  2675. # ifndef LZO_OPT_UNALIGNED32
  2676. # define LZO_OPT_UNALIGNED32 1
  2677. # endif
  2678. #elif (LZO_ARCH_I386)
  2679. # ifndef LZO_OPT_UNALIGNED16
  2680. # define LZO_OPT_UNALIGNED16 1
  2681. # endif
  2682. # ifndef LZO_OPT_UNALIGNED32
  2683. # define LZO_OPT_UNALIGNED32 1
  2684. # endif
  2685. #elif (LZO_ARCH_IA64)
  2686. # define LZO_OPT_AVOID_INT_INDEX 1
  2687. # define LZO_OPT_AVOID_UINT_INDEX 1
  2688. # define LZO_OPT_PREFER_POSTINC 1
  2689. #elif (LZO_ARCH_M68K)
  2690. # define LZO_OPT_PREFER_POSTINC 1
  2691. # define LZO_OPT_PREFER_PREDEC 1
  2692. # if defined(__mc68020__) && !defined(__mcoldfire__)
  2693. # ifndef LZO_OPT_UNALIGNED16
  2694. # define LZO_OPT_UNALIGNED16 1
  2695. # endif
  2696. # ifndef LZO_OPT_UNALIGNED32
  2697. # define LZO_OPT_UNALIGNED32 1
  2698. # endif
  2699. # endif
  2700. #elif (LZO_ARCH_MIPS)
  2701. # define LZO_OPT_AVOID_UINT_INDEX 1
  2702. #elif (LZO_ARCH_POWERPC)
  2703. # define LZO_OPT_PREFER_PREINC 1
  2704. # define LZO_OPT_PREFER_PREDEC 1
  2705. # if (LZO_ABI_BIG_ENDIAN) || (LZO_WORDSIZE == 8)
  2706. # ifndef LZO_OPT_UNALIGNED16
  2707. # define LZO_OPT_UNALIGNED16 1
  2708. # endif
  2709. # ifndef LZO_OPT_UNALIGNED32
  2710. # define LZO_OPT_UNALIGNED32 1
  2711. # endif
  2712. # if (LZO_WORDSIZE == 8)
  2713. # ifndef LZO_OPT_UNALIGNED64
  2714. # define LZO_OPT_UNALIGNED64 1
  2715. # endif
  2716. # endif
  2717. # endif
  2718. #elif (LZO_ARCH_RISCV)
  2719. # define LZO_OPT_AVOID_UINT_INDEX 1
  2720. # ifndef LZO_OPT_UNALIGNED16
  2721. # define LZO_OPT_UNALIGNED16 1
  2722. # endif
  2723. # ifndef LZO_OPT_UNALIGNED32
  2724. # define LZO_OPT_UNALIGNED32 1
  2725. # endif
  2726. # if (LZO_WORDSIZE == 8)
  2727. # ifndef LZO_OPT_UNALIGNED64
  2728. # define LZO_OPT_UNALIGNED64 1
  2729. # endif
  2730. # endif
  2731. #elif (LZO_ARCH_S390)
  2732. # ifndef LZO_OPT_UNALIGNED16
  2733. # define LZO_OPT_UNALIGNED16 1
  2734. # endif
  2735. # ifndef LZO_OPT_UNALIGNED32
  2736. # define LZO_OPT_UNALIGNED32 1
  2737. # endif
  2738. # if (LZO_WORDSIZE == 8)
  2739. # ifndef LZO_OPT_UNALIGNED64
  2740. # define LZO_OPT_UNALIGNED64 1
  2741. # endif
  2742. # endif
  2743. #elif (LZO_ARCH_SH)
  2744. # define LZO_OPT_PREFER_POSTINC 1
  2745. # define LZO_OPT_PREFER_PREDEC 1
  2746. #endif
  2747. #ifndef LZO_CFG_NO_INLINE_ASM
  2748. #if (LZO_ABI_NEUTRAL_ENDIAN) || (LZO_ARCH_GENERIC)
  2749. # define LZO_CFG_NO_INLINE_ASM 1
  2750. #elif (LZO_CC_LLVM)
  2751. # define LZO_CFG_NO_INLINE_ASM 1
  2752. #endif
  2753. #endif
  2754. #if (LZO_CFG_NO_INLINE_ASM)
  2755. # undef LZO_ASM_SYNTAX_MSC
  2756. # undef LZO_ASM_SYNTAX_GNUC
  2757. # undef __LZO_ASM_CLOBBER
  2758. # undef __LZO_ASM_CLOBBER_LIST_CC
  2759. # undef __LZO_ASM_CLOBBER_LIST_CC_MEMORY
  2760. # undef __LZO_ASM_CLOBBER_LIST_EMPTY
  2761. #endif
  2762. #ifndef LZO_CFG_NO_UNALIGNED
  2763. #if (LZO_ABI_NEUTRAL_ENDIAN) || (LZO_ARCH_GENERIC)
  2764. # define LZO_CFG_NO_UNALIGNED 1
  2765. #endif
  2766. #endif
  2767. #if (LZO_CFG_NO_UNALIGNED)
  2768. # undef LZO_OPT_UNALIGNED16
  2769. # undef LZO_OPT_UNALIGNED32
  2770. # undef LZO_OPT_UNALIGNED64
  2771. #endif
  2772. #if defined(__LZO_INFOSTR_MM)
  2773. #elif (LZO_MM_FLAT) && (defined(__LZO_INFOSTR_PM) || defined(LZO_INFO_ABI_PM))
  2774. # define __LZO_INFOSTR_MM ""
  2775. #elif defined(LZO_INFO_MM)
  2776. # define __LZO_INFOSTR_MM "." LZO_INFO_MM
  2777. #else
  2778. # define __LZO_INFOSTR_MM ""
  2779. #endif
  2780. #if defined(__LZO_INFOSTR_PM)
  2781. #elif defined(LZO_INFO_ABI_PM)
  2782. # define __LZO_INFOSTR_PM "." LZO_INFO_ABI_PM
  2783. #else
  2784. # define __LZO_INFOSTR_PM ""
  2785. #endif
  2786. #if defined(__LZO_INFOSTR_ENDIAN)
  2787. #elif defined(LZO_INFO_ABI_ENDIAN)
  2788. # define __LZO_INFOSTR_ENDIAN "." LZO_INFO_ABI_ENDIAN
  2789. #else
  2790. # define __LZO_INFOSTR_ENDIAN ""
  2791. #endif
  2792. #if defined(__LZO_INFOSTR_OSNAME)
  2793. #elif defined(LZO_INFO_OS_CONSOLE)
  2794. # define __LZO_INFOSTR_OSNAME LZO_INFO_OS "." LZO_INFO_OS_CONSOLE
  2795. #elif defined(LZO_INFO_OS_POSIX)
  2796. # define __LZO_INFOSTR_OSNAME LZO_INFO_OS "." LZO_INFO_OS_POSIX
  2797. #else
  2798. # define __LZO_INFOSTR_OSNAME LZO_INFO_OS
  2799. #endif
  2800. #if defined(__LZO_INFOSTR_LIBC)
  2801. #elif defined(LZO_INFO_LIBC)
  2802. # define __LZO_INFOSTR_LIBC "." LZO_INFO_LIBC
  2803. #else
  2804. # define __LZO_INFOSTR_LIBC ""
  2805. #endif
  2806. #if defined(__LZO_INFOSTR_CCVER)
  2807. #elif defined(LZO_INFO_CCVER)
  2808. # define __LZO_INFOSTR_CCVER " " LZO_INFO_CCVER
  2809. #else
  2810. # define __LZO_INFOSTR_CCVER ""
  2811. #endif
  2812. #define LZO_INFO_STRING \
  2813. LZO_INFO_ARCH __LZO_INFOSTR_MM __LZO_INFOSTR_PM __LZO_INFOSTR_ENDIAN \
  2814. " " __LZO_INFOSTR_OSNAME __LZO_INFOSTR_LIBC " " LZO_INFO_CC __LZO_INFOSTR_CCVER
  2815. #if !(LZO_CFG_SKIP_LZO_TYPES)
  2816. #if (!(LZO_SIZEOF_SHORT+0 > 0 && LZO_SIZEOF_INT+0 > 0 && LZO_SIZEOF_LONG+0 > 0))
  2817. # error "missing defines for sizes"
  2818. #endif
  2819. #if (!(LZO_SIZEOF_PTRDIFF_T+0 > 0 && LZO_SIZEOF_SIZE_T+0 > 0 && LZO_SIZEOF_VOID_P+0 > 0))
  2820. # error "missing defines for sizes"
  2821. #endif
  2822. #define LZO_TYPEOF_CHAR 1u
  2823. #define LZO_TYPEOF_SHORT 2u
  2824. #define LZO_TYPEOF_INT 3u
  2825. #define LZO_TYPEOF_LONG 4u
  2826. #define LZO_TYPEOF_LONG_LONG 5u
  2827. #define LZO_TYPEOF___INT8 17u
  2828. #define LZO_TYPEOF___INT16 18u
  2829. #define LZO_TYPEOF___INT32 19u
  2830. #define LZO_TYPEOF___INT64 20u
  2831. #define LZO_TYPEOF___INT128 21u
  2832. #define LZO_TYPEOF___INT256 22u
  2833. #define LZO_TYPEOF___MODE_QI 33u
  2834. #define LZO_TYPEOF___MODE_HI 34u
  2835. #define LZO_TYPEOF___MODE_SI 35u
  2836. #define LZO_TYPEOF___MODE_DI 36u
  2837. #define LZO_TYPEOF___MODE_TI 37u
  2838. #define LZO_TYPEOF_CHAR_P 129u
  2839. #if !defined(lzo_llong_t)
  2840. #if (LZO_SIZEOF_LONG_LONG+0 > 0)
  2841. # if !(LZO_LANG_ASSEMBLER)
  2842. __lzo_gnuc_extension__ typedef long long lzo_llong_t__;
  2843. __lzo_gnuc_extension__ typedef unsigned long long lzo_ullong_t__;
  2844. # endif
  2845. # define lzo_llong_t lzo_llong_t__
  2846. # define lzo_ullong_t lzo_ullong_t__
  2847. #endif
  2848. #endif
  2849. #if !defined(lzo_int16e_t)
  2850. #if (LZO_CFG_PREFER_TYPEOF_ACC_INT16E_T == LZO_TYPEOF_SHORT) && (LZO_SIZEOF_SHORT != 2)
  2851. # undef LZO_CFG_PREFER_TYPEOF_ACC_INT16E_T
  2852. #endif
  2853. #if (LZO_SIZEOF_LONG == 2) && !(LZO_CFG_PREFER_TYPEOF_ACC_INT16E_T == LZO_TYPEOF_SHORT)
  2854. # define lzo_int16e_t long
  2855. # define lzo_uint16e_t unsigned long
  2856. # define LZO_TYPEOF_LZO_INT16E_T LZO_TYPEOF_LONG
  2857. #elif (LZO_SIZEOF_INT == 2) && !(LZO_CFG_PREFER_TYPEOF_ACC_INT16E_T == LZO_TYPEOF_SHORT)
  2858. # define lzo_int16e_t int
  2859. # define lzo_uint16e_t unsigned int
  2860. # define LZO_TYPEOF_LZO_INT16E_T LZO_TYPEOF_INT
  2861. #elif (LZO_SIZEOF_SHORT == 2)
  2862. # define lzo_int16e_t short int
  2863. # define lzo_uint16e_t unsigned short int
  2864. # define LZO_TYPEOF_LZO_INT16E_T LZO_TYPEOF_SHORT
  2865. #elif 1 && !(LZO_CFG_TYPE_NO_MODE_HI) && (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x025f00ul) || LZO_CC_LLVM)
  2866. # if !(LZO_LANG_ASSEMBLER)
  2867. typedef int lzo_int16e_hi_t__ __attribute__((__mode__(__HI__)));
  2868. typedef unsigned int lzo_uint16e_hi_t__ __attribute__((__mode__(__HI__)));
  2869. # endif
  2870. # define lzo_int16e_t lzo_int16e_hi_t__
  2871. # define lzo_uint16e_t lzo_uint16e_hi_t__
  2872. # define LZO_TYPEOF_LZO_INT16E_T LZO_TYPEOF___MODE_HI
  2873. #elif (LZO_SIZEOF___INT16 == 2)
  2874. # define lzo_int16e_t __int16
  2875. # define lzo_uint16e_t unsigned __int16
  2876. # define LZO_TYPEOF_LZO_INT16E_T LZO_TYPEOF___INT16
  2877. #else
  2878. #endif
  2879. #endif
  2880. #if defined(lzo_int16e_t)
  2881. # define LZO_SIZEOF_LZO_INT16E_T 2
  2882. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16e_t) == 2)
  2883. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16e_t) == LZO_SIZEOF_LZO_INT16E_T)
  2884. #endif
  2885. #if !defined(lzo_int32e_t)
  2886. #if (LZO_CFG_PREFER_TYPEOF_ACC_INT32E_T == LZO_TYPEOF_INT) && (LZO_SIZEOF_INT != 4)
  2887. # undef LZO_CFG_PREFER_TYPEOF_ACC_INT32E_T
  2888. #endif
  2889. #if (LZO_SIZEOF_LONG == 4) && !(LZO_CFG_PREFER_TYPEOF_ACC_INT32E_T == LZO_TYPEOF_INT)
  2890. # define lzo_int32e_t long int
  2891. # define lzo_uint32e_t unsigned long int
  2892. # define LZO_TYPEOF_LZO_INT32E_T LZO_TYPEOF_LONG
  2893. #elif (LZO_SIZEOF_INT == 4)
  2894. # define lzo_int32e_t int
  2895. # define lzo_uint32e_t unsigned int
  2896. # define LZO_TYPEOF_LZO_INT32E_T LZO_TYPEOF_INT
  2897. #elif (LZO_SIZEOF_SHORT == 4)
  2898. # define lzo_int32e_t short int
  2899. # define lzo_uint32e_t unsigned short int
  2900. # define LZO_TYPEOF_LZO_INT32E_T LZO_TYPEOF_SHORT
  2901. #elif (LZO_SIZEOF_LONG_LONG == 4)
  2902. # define lzo_int32e_t lzo_llong_t
  2903. # define lzo_uint32e_t lzo_ullong_t
  2904. # define LZO_TYPEOF_LZO_INT32E_T LZO_TYPEOF_LONG_LONG
  2905. #elif 1 && !(LZO_CFG_TYPE_NO_MODE_SI) && (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x025f00ul) || LZO_CC_LLVM) && (__INT_MAX__+0 > 2147483647L)
  2906. # if !(LZO_LANG_ASSEMBLER)
  2907. typedef int lzo_int32e_si_t__ __attribute__((__mode__(__SI__)));
  2908. typedef unsigned int lzo_uint32e_si_t__ __attribute__((__mode__(__SI__)));
  2909. # endif
  2910. # define lzo_int32e_t lzo_int32e_si_t__
  2911. # define lzo_uint32e_t lzo_uint32e_si_t__
  2912. # define LZO_TYPEOF_LZO_INT32E_T LZO_TYPEOF___MODE_SI
  2913. #elif 1 && !(LZO_CFG_TYPE_NO_MODE_SI) && (LZO_CC_GNUC >= 0x025f00ul) && defined(__AVR__) && (__LONG_MAX__+0 == 32767L)
  2914. # if !(LZO_LANG_ASSEMBLER)
  2915. typedef int lzo_int32e_si_t__ __attribute__((__mode__(__SI__)));
  2916. typedef unsigned int lzo_uint32e_si_t__ __attribute__((__mode__(__SI__)));
  2917. # endif
  2918. # define lzo_int32e_t lzo_int32e_si_t__
  2919. # define lzo_uint32e_t lzo_uint32e_si_t__
  2920. # define LZO_INT32_C(c) (c##LL)
  2921. # define LZO_UINT32_C(c) (c##ULL)
  2922. # define LZO_TYPEOF_LZO_INT32E_T LZO_TYPEOF___MODE_SI
  2923. #elif (LZO_SIZEOF___INT32 == 4)
  2924. # define lzo_int32e_t __int32
  2925. # define lzo_uint32e_t unsigned __int32
  2926. # define LZO_TYPEOF_LZO_INT32E_T LZO_TYPEOF___INT32
  2927. #else
  2928. #endif
  2929. #endif
  2930. #if defined(lzo_int32e_t)
  2931. # define LZO_SIZEOF_LZO_INT32E_T 4
  2932. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32e_t) == 4)
  2933. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32e_t) == LZO_SIZEOF_LZO_INT32E_T)
  2934. #endif
  2935. #if !defined(lzo_int64e_t)
  2936. #if (LZO_SIZEOF___INT64 == 8)
  2937. # if (LZO_CC_BORLANDC) && !defined(LZO_CFG_PREFER_TYPEOF_ACC_INT64E_T)
  2938. # define LZO_CFG_PREFER_TYPEOF_ACC_INT64E_T LZO_TYPEOF___INT64
  2939. # endif
  2940. #endif
  2941. #if (LZO_CFG_PREFER_TYPEOF_ACC_INT64E_T == LZO_TYPEOF_LONG_LONG) && (LZO_SIZEOF_LONG_LONG != 8)
  2942. # undef LZO_CFG_PREFER_TYPEOF_ACC_INT64E_T
  2943. #endif
  2944. #if (LZO_CFG_PREFER_TYPEOF_ACC_INT64E_T == LZO_TYPEOF___INT64) && (LZO_SIZEOF___INT64 != 8)
  2945. # undef LZO_CFG_PREFER_TYPEOF_ACC_INT64E_T
  2946. #endif
  2947. #if (LZO_SIZEOF_INT == 8) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG)
  2948. # define lzo_int64e_t int
  2949. # define lzo_uint64e_t unsigned int
  2950. # define LZO_TYPEOF_LZO_INT64E_T LZO_TYPEOF_INT
  2951. #elif (LZO_SIZEOF_LONG == 8) && !(LZO_CFG_PREFER_TYPEOF_ACC_INT64E_T == LZO_TYPEOF_LONG_LONG) && !(LZO_CFG_PREFER_TYPEOF_ACC_INT64E_T == LZO_TYPEOF___INT64)
  2952. # define lzo_int64e_t long int
  2953. # define lzo_uint64e_t unsigned long int
  2954. # define LZO_TYPEOF_LZO_INT64E_T LZO_TYPEOF_LONG
  2955. #elif (LZO_SIZEOF_LONG_LONG == 8) && !(LZO_CFG_PREFER_TYPEOF_ACC_INT64E_T == LZO_TYPEOF___INT64)
  2956. # define lzo_int64e_t lzo_llong_t
  2957. # define lzo_uint64e_t lzo_ullong_t
  2958. # define LZO_TYPEOF_LZO_INT64E_T LZO_TYPEOF_LONG_LONG
  2959. # if (LZO_CC_BORLANDC)
  2960. # define LZO_INT64_C(c) ((c) + 0ll)
  2961. # define LZO_UINT64_C(c) ((c) + 0ull)
  2962. # elif 0
  2963. # define LZO_INT64_C(c) (__lzo_gnuc_extension__ (c##LL))
  2964. # define LZO_UINT64_C(c) (__lzo_gnuc_extension__ (c##ULL))
  2965. # else
  2966. # define LZO_INT64_C(c) (c##LL)
  2967. # define LZO_UINT64_C(c) (c##ULL)
  2968. # endif
  2969. #elif (LZO_SIZEOF___INT64 == 8)
  2970. # define lzo_int64e_t __int64
  2971. # define lzo_uint64e_t unsigned __int64
  2972. # define LZO_TYPEOF_LZO_INT64E_T LZO_TYPEOF___INT64
  2973. # if (LZO_CC_BORLANDC)
  2974. # define LZO_INT64_C(c) ((c) + 0i64)
  2975. # define LZO_UINT64_C(c) ((c) + 0ui64)
  2976. # else
  2977. # define LZO_INT64_C(c) (c##i64)
  2978. # define LZO_UINT64_C(c) (c##ui64)
  2979. # endif
  2980. #else
  2981. #endif
  2982. #endif
  2983. #if defined(lzo_int64e_t)
  2984. # define LZO_SIZEOF_LZO_INT64E_T 8
  2985. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64e_t) == 8)
  2986. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64e_t) == LZO_SIZEOF_LZO_INT64E_T)
  2987. #endif
  2988. #if !defined(lzo_int32l_t)
  2989. #if defined(lzo_int32e_t)
  2990. # define lzo_int32l_t lzo_int32e_t
  2991. # define lzo_uint32l_t lzo_uint32e_t
  2992. # define LZO_SIZEOF_LZO_INT32L_T LZO_SIZEOF_LZO_INT32E_T
  2993. # define LZO_TYPEOF_LZO_INT32L_T LZO_TYPEOF_LZO_INT32E_T
  2994. #elif (LZO_SIZEOF_INT >= 4) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG)
  2995. # define lzo_int32l_t int
  2996. # define lzo_uint32l_t unsigned int
  2997. # define LZO_SIZEOF_LZO_INT32L_T LZO_SIZEOF_INT
  2998. # define LZO_TYPEOF_LZO_INT32L_T LZO_SIZEOF_INT
  2999. #elif (LZO_SIZEOF_LONG >= 4)
  3000. # define lzo_int32l_t long int
  3001. # define lzo_uint32l_t unsigned long int
  3002. # define LZO_SIZEOF_LZO_INT32L_T LZO_SIZEOF_LONG
  3003. # define LZO_TYPEOF_LZO_INT32L_T LZO_SIZEOF_LONG
  3004. #else
  3005. # error "lzo_int32l_t"
  3006. #endif
  3007. #endif
  3008. #if 1
  3009. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32l_t) >= 4)
  3010. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32l_t) == LZO_SIZEOF_LZO_INT32L_T)
  3011. #endif
  3012. #if !defined(lzo_int64l_t)
  3013. #if defined(lzo_int64e_t)
  3014. # define lzo_int64l_t lzo_int64e_t
  3015. # define lzo_uint64l_t lzo_uint64e_t
  3016. # define LZO_SIZEOF_LZO_INT64L_T LZO_SIZEOF_LZO_INT64E_T
  3017. # define LZO_TYPEOF_LZO_INT64L_T LZO_TYPEOF_LZO_INT64E_T
  3018. #else
  3019. #endif
  3020. #endif
  3021. #if defined(lzo_int64l_t)
  3022. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64l_t) >= 8)
  3023. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64l_t) == LZO_SIZEOF_LZO_INT64L_T)
  3024. #endif
  3025. #if !defined(lzo_int32f_t)
  3026. #if (LZO_SIZEOF_SIZE_T >= 8)
  3027. # define lzo_int32f_t lzo_int64l_t
  3028. # define lzo_uint32f_t lzo_uint64l_t
  3029. # define LZO_SIZEOF_LZO_INT32F_T LZO_SIZEOF_LZO_INT64L_T
  3030. # define LZO_TYPEOF_LZO_INT32F_T LZO_TYPEOF_LZO_INT64L_T
  3031. #else
  3032. # define lzo_int32f_t lzo_int32l_t
  3033. # define lzo_uint32f_t lzo_uint32l_t
  3034. # define LZO_SIZEOF_LZO_INT32F_T LZO_SIZEOF_LZO_INT32L_T
  3035. # define LZO_TYPEOF_LZO_INT32F_T LZO_TYPEOF_LZO_INT32L_T
  3036. #endif
  3037. #endif
  3038. #if 1
  3039. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32f_t) >= 4)
  3040. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32f_t) == LZO_SIZEOF_LZO_INT32F_T)
  3041. #endif
  3042. #if !defined(lzo_int64f_t)
  3043. #if defined(lzo_int64l_t)
  3044. # define lzo_int64f_t lzo_int64l_t
  3045. # define lzo_uint64f_t lzo_uint64l_t
  3046. # define LZO_SIZEOF_LZO_INT64F_T LZO_SIZEOF_LZO_INT64L_T
  3047. # define LZO_TYPEOF_LZO_INT64F_T LZO_TYPEOF_LZO_INT64L_T
  3048. #else
  3049. #endif
  3050. #endif
  3051. #if defined(lzo_int64f_t)
  3052. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64f_t) >= 8)
  3053. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64f_t) == LZO_SIZEOF_LZO_INT64F_T)
  3054. #endif
  3055. #if !defined(lzo_intptr_t)
  3056. #if 1 && (LZO_OS_OS400 && (LZO_SIZEOF_VOID_P == 16))
  3057. # define __LZO_INTPTR_T_IS_POINTER 1
  3058. # if !(LZO_LANG_ASSEMBLER)
  3059. typedef char * lzo_intptr_t;
  3060. typedef char * lzo_uintptr_t;
  3061. # endif
  3062. # define lzo_intptr_t lzo_intptr_t
  3063. # define lzo_uintptr_t lzo_uintptr_t
  3064. # define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_VOID_P
  3065. # define LZO_TYPEOF_LZO_INTPTR_T LZO_TYPEOF_CHAR_P
  3066. #elif (LZO_CC_MSC && (_MSC_VER >= 1300) && (LZO_SIZEOF_VOID_P == 4) && (LZO_SIZEOF_INT == 4))
  3067. # if !(LZO_LANG_ASSEMBLER)
  3068. typedef __w64 int lzo_intptr_t;
  3069. typedef __w64 unsigned int lzo_uintptr_t;
  3070. # endif
  3071. # define lzo_intptr_t lzo_intptr_t
  3072. # define lzo_uintptr_t lzo_uintptr_t
  3073. # define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_INT
  3074. # define LZO_TYPEOF_LZO_INTPTR_T LZO_TYPEOF_INT
  3075. #elif (LZO_SIZEOF_SHORT == LZO_SIZEOF_VOID_P) && (LZO_SIZEOF_INT > LZO_SIZEOF_VOID_P)
  3076. # define lzo_intptr_t short
  3077. # define lzo_uintptr_t unsigned short
  3078. # define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_SHORT
  3079. # define LZO_TYPEOF_LZO_INTPTR_T LZO_TYPEOF_SHORT
  3080. #elif (LZO_SIZEOF_INT >= LZO_SIZEOF_VOID_P) && (LZO_SIZEOF_INT < LZO_SIZEOF_LONG)
  3081. # define lzo_intptr_t int
  3082. # define lzo_uintptr_t unsigned int
  3083. # define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_INT
  3084. # define LZO_TYPEOF_LZO_INTPTR_T LZO_TYPEOF_INT
  3085. #elif (LZO_SIZEOF_LONG >= LZO_SIZEOF_VOID_P)
  3086. # define lzo_intptr_t long
  3087. # define lzo_uintptr_t unsigned long
  3088. # define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_LONG
  3089. # define LZO_TYPEOF_LZO_INTPTR_T LZO_TYPEOF_LONG
  3090. #elif (LZO_SIZEOF_LZO_INT64L_T >= LZO_SIZEOF_VOID_P)
  3091. # define lzo_intptr_t lzo_int64l_t
  3092. # define lzo_uintptr_t lzo_uint64l_t
  3093. # define LZO_SIZEOF_LZO_INTPTR_T LZO_SIZEOF_LZO_INT64L_T
  3094. # define LZO_TYPEOF_LZO_INTPTR_T LZO_TYPEOF_LZO_INT64L_T
  3095. #else
  3096. # error "lzo_intptr_t"
  3097. #endif
  3098. #endif
  3099. #if 1
  3100. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_intptr_t) >= sizeof(void *))
  3101. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_intptr_t) == sizeof(lzo_uintptr_t))
  3102. #endif
  3103. #if !defined(lzo_word_t)
  3104. #if defined(LZO_WORDSIZE) && (LZO_WORDSIZE+0 > 0)
  3105. #if (LZO_WORDSIZE == LZO_SIZEOF_LZO_INTPTR_T) && !(__LZO_INTPTR_T_IS_POINTER)
  3106. # define lzo_word_t lzo_uintptr_t
  3107. # define lzo_sword_t lzo_intptr_t
  3108. # define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_LZO_INTPTR_T
  3109. # define LZO_TYPEOF_LZO_WORD_T LZO_TYPEOF_LZO_INTPTR_T
  3110. #elif (LZO_WORDSIZE == LZO_SIZEOF_LONG)
  3111. # define lzo_word_t unsigned long
  3112. # define lzo_sword_t long
  3113. # define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_LONG
  3114. # define LZO_TYPEOF_LZO_WORD_T LZO_TYPEOF_LONG
  3115. #elif (LZO_WORDSIZE == LZO_SIZEOF_INT)
  3116. # define lzo_word_t unsigned int
  3117. # define lzo_sword_t int
  3118. # define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_INT
  3119. # define LZO_TYPEOF_LZO_WORD_T LZO_TYPEOF_INT
  3120. #elif (LZO_WORDSIZE == LZO_SIZEOF_SHORT)
  3121. # define lzo_word_t unsigned short
  3122. # define lzo_sword_t short
  3123. # define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_SHORT
  3124. # define LZO_TYPEOF_LZO_WORD_T LZO_TYPEOF_SHORT
  3125. #elif (LZO_WORDSIZE == 1)
  3126. # define lzo_word_t unsigned char
  3127. # define lzo_sword_t signed char
  3128. # define LZO_SIZEOF_LZO_WORD_T 1
  3129. # define LZO_TYPEOF_LZO_WORD_T LZO_TYPEOF_CHAR
  3130. #elif (LZO_WORDSIZE == LZO_SIZEOF_LZO_INT64L_T)
  3131. # define lzo_word_t lzo_uint64l_t
  3132. # define lzo_sword_t lzo_int64l_t
  3133. # define LZO_SIZEOF_LZO_WORD_T LZO_SIZEOF_LZO_INT64L_T
  3134. # define LZO_TYPEOF_LZO_WORD_T LZO_SIZEOF_LZO_INT64L_T
  3135. #elif (LZO_ARCH_SPU) && (LZO_CC_GNUC)
  3136. #if 0
  3137. # if !(LZO_LANG_ASSEMBLER)
  3138. typedef unsigned lzo_word_t __attribute__((__mode__(__V16QI__)));
  3139. typedef int lzo_sword_t __attribute__((__mode__(__V16QI__)));
  3140. # endif
  3141. # define lzo_word_t lzo_word_t
  3142. # define lzo_sword_t lzo_sword_t
  3143. # define LZO_SIZEOF_LZO_WORD_T 16
  3144. # define LZO_TYPEOF_LZO_WORD_T LZO_TYPEOF___MODE_V16QI
  3145. #endif
  3146. #else
  3147. # error "lzo_word_t"
  3148. #endif
  3149. #endif
  3150. #endif
  3151. #if 1 && defined(lzo_word_t)
  3152. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_word_t) == LZO_WORDSIZE)
  3153. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_sword_t) == LZO_WORDSIZE)
  3154. #endif
  3155. #if 1
  3156. #define lzo_int8_t signed char
  3157. #define lzo_uint8_t unsigned char
  3158. #define LZO_SIZEOF_LZO_INT8_T 1
  3159. #define LZO_TYPEOF_LZO_INT8_T LZO_TYPEOF_CHAR
  3160. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int8_t) == 1)
  3161. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int8_t) == sizeof(lzo_uint8_t))
  3162. #endif
  3163. #if defined(lzo_int16e_t)
  3164. #define lzo_int16_t lzo_int16e_t
  3165. #define lzo_uint16_t lzo_uint16e_t
  3166. #define LZO_SIZEOF_LZO_INT16_T LZO_SIZEOF_LZO_INT16E_T
  3167. #define LZO_TYPEOF_LZO_INT16_T LZO_TYPEOF_LZO_INT16E_T
  3168. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16_t) == 2)
  3169. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16_t) == sizeof(lzo_uint16_t))
  3170. #endif
  3171. #if defined(lzo_int32e_t)
  3172. #define lzo_int32_t lzo_int32e_t
  3173. #define lzo_uint32_t lzo_uint32e_t
  3174. #define LZO_SIZEOF_LZO_INT32_T LZO_SIZEOF_LZO_INT32E_T
  3175. #define LZO_TYPEOF_LZO_INT32_T LZO_TYPEOF_LZO_INT32E_T
  3176. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32_t) == 4)
  3177. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32_t) == sizeof(lzo_uint32_t))
  3178. #endif
  3179. #if defined(lzo_int64e_t)
  3180. #define lzo_int64_t lzo_int64e_t
  3181. #define lzo_uint64_t lzo_uint64e_t
  3182. #define LZO_SIZEOF_LZO_INT64_T LZO_SIZEOF_LZO_INT64E_T
  3183. #define LZO_TYPEOF_LZO_INT64_T LZO_TYPEOF_LZO_INT64E_T
  3184. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64_t) == 8)
  3185. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64_t) == sizeof(lzo_uint64_t))
  3186. #endif
  3187. #if 1
  3188. #define lzo_int_least32_t lzo_int32l_t
  3189. #define lzo_uint_least32_t lzo_uint32l_t
  3190. #define LZO_SIZEOF_LZO_INT_LEAST32_T LZO_SIZEOF_LZO_INT32L_T
  3191. #define LZO_TYPEOF_LZO_INT_LEAST32_T LZO_TYPEOF_LZO_INT32L_T
  3192. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least32_t) >= 4)
  3193. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least32_t) == sizeof(lzo_uint_least32_t))
  3194. #endif
  3195. #if defined(lzo_int64l_t)
  3196. #define lzo_int_least64_t lzo_int64l_t
  3197. #define lzo_uint_least64_t lzo_uint64l_t
  3198. #define LZO_SIZEOF_LZO_INT_LEAST64_T LZO_SIZEOF_LZO_INT64L_T
  3199. #define LZO_TYPEOF_LZO_INT_LEAST64_T LZO_TYPEOF_LZO_INT64L_T
  3200. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least64_t) >= 8)
  3201. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_least64_t) == sizeof(lzo_uint_least64_t))
  3202. #endif
  3203. #if 1
  3204. #define lzo_int_fast32_t lzo_int32f_t
  3205. #define lzo_uint_fast32_t lzo_uint32f_t
  3206. #define LZO_SIZEOF_LZO_INT_FAST32_T LZO_SIZEOF_LZO_INT32F_T
  3207. #define LZO_TYPEOF_LZO_INT_FAST32_T LZO_TYPEOF_LZO_INT32F_T
  3208. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast32_t) >= 4)
  3209. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast32_t) == sizeof(lzo_uint_fast32_t))
  3210. #endif
  3211. #if defined(lzo_int64f_t)
  3212. #define lzo_int_fast64_t lzo_int64f_t
  3213. #define lzo_uint_fast64_t lzo_uint64f_t
  3214. #define LZO_SIZEOF_LZO_INT_FAST64_T LZO_SIZEOF_LZO_INT64F_T
  3215. #define LZO_TYPEOF_LZO_INT_FAST64_T LZO_TYPEOF_LZO_INT64F_T
  3216. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast64_t) >= 8)
  3217. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int_fast64_t) == sizeof(lzo_uint_fast64_t))
  3218. #endif
  3219. #if !defined(LZO_INT16_C)
  3220. # if (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_INT >= 2)
  3221. # define LZO_INT16_C(c) ((c) + 0)
  3222. # define LZO_UINT16_C(c) ((c) + 0U)
  3223. # elif (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_LONG >= 2)
  3224. # define LZO_INT16_C(c) ((c) + 0L)
  3225. # define LZO_UINT16_C(c) ((c) + 0UL)
  3226. # elif (LZO_SIZEOF_INT >= 2)
  3227. # define LZO_INT16_C(c) (c)
  3228. # define LZO_UINT16_C(c) (c##U)
  3229. # elif (LZO_SIZEOF_LONG >= 2)
  3230. # define LZO_INT16_C(c) (c##L)
  3231. # define LZO_UINT16_C(c) (c##UL)
  3232. # else
  3233. # error "LZO_INT16_C"
  3234. # endif
  3235. #endif
  3236. #if !defined(LZO_INT32_C)
  3237. # if (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_INT >= 4)
  3238. # define LZO_INT32_C(c) ((c) + 0)
  3239. # define LZO_UINT32_C(c) ((c) + 0U)
  3240. # elif (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_LONG >= 4)
  3241. # define LZO_INT32_C(c) ((c) + 0L)
  3242. # define LZO_UINT32_C(c) ((c) + 0UL)
  3243. # elif (LZO_SIZEOF_INT >= 4)
  3244. # define LZO_INT32_C(c) (c)
  3245. # define LZO_UINT32_C(c) (c##U)
  3246. # elif (LZO_SIZEOF_LONG >= 4)
  3247. # define LZO_INT32_C(c) (c##L)
  3248. # define LZO_UINT32_C(c) (c##UL)
  3249. # elif (LZO_SIZEOF_LONG_LONG >= 4)
  3250. # define LZO_INT32_C(c) (c##LL)
  3251. # define LZO_UINT32_C(c) (c##ULL)
  3252. # else
  3253. # error "LZO_INT32_C"
  3254. # endif
  3255. #endif
  3256. #if !defined(LZO_INT64_C) && defined(lzo_int64l_t)
  3257. # if (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_INT >= 8)
  3258. # define LZO_INT64_C(c) ((c) + 0)
  3259. # define LZO_UINT64_C(c) ((c) + 0U)
  3260. # elif (LZO_BROKEN_INTEGRAL_CONSTANTS) && (LZO_SIZEOF_LONG >= 8)
  3261. # define LZO_INT64_C(c) ((c) + 0L)
  3262. # define LZO_UINT64_C(c) ((c) + 0UL)
  3263. # elif (LZO_SIZEOF_INT >= 8)
  3264. # define LZO_INT64_C(c) (c)
  3265. # define LZO_UINT64_C(c) (c##U)
  3266. # elif (LZO_SIZEOF_LONG >= 8)
  3267. # define LZO_INT64_C(c) (c##L)
  3268. # define LZO_UINT64_C(c) (c##UL)
  3269. # else
  3270. # error "LZO_INT64_C"
  3271. # endif
  3272. #endif
  3273. #endif
  3274. #endif
  3275. #endif
  3276. #undef LZO_HAVE_CONFIG_H
  3277. #include "minilzo.h"
  3278. #if !defined(MINILZO_VERSION) || (MINILZO_VERSION != 0x20a0)
  3279. # error "version mismatch in miniLZO source files"
  3280. #endif
  3281. #ifdef MINILZO_HAVE_CONFIG_H
  3282. # define LZO_HAVE_CONFIG_H 1
  3283. #endif
  3284. #ifndef __LZO_CONF_H
  3285. #define __LZO_CONF_H 1
  3286. #if !defined(__LZO_IN_MINILZO)
  3287. #if defined(LZO_CFG_FREESTANDING) && (LZO_CFG_FREESTANDING)
  3288. # define LZO_LIBC_FREESTANDING 1
  3289. # define LZO_OS_FREESTANDING 1
  3290. #endif
  3291. #if defined(LZO_CFG_EXTRA_CONFIG_HEADER)
  3292. # include LZO_CFG_EXTRA_CONFIG_HEADER
  3293. #endif
  3294. #if defined(__LZOCONF_H) || defined(__LZOCONF_H_INCLUDED)
  3295. # error "include this file first"
  3296. #endif
  3297. #if defined(LZO_CFG_BUILD_DLL) && (LZO_CFG_BUILD_DLL+0) && !defined(__LZO_EXPORT1) && !defined(__LZO_EXPORT2) && 0
  3298. #ifndef __LZODEFS_H_INCLUDED
  3299. #if defined(LZO_HAVE_CONFIG_H)
  3300. # include <config.h>
  3301. #endif
  3302. #include <limits.h>
  3303. #include <stddef.h>
  3304. #include <lzo/lzodefs.h>
  3305. #endif
  3306. #endif
  3307. #include <lzo/lzoconf.h>
  3308. #if defined(LZO_CFG_EXTRA_CONFIG_HEADER2)
  3309. # include LZO_CFG_EXTRA_CONFIG_HEADER2
  3310. #endif
  3311. #endif
  3312. #if !defined(__LZOCONF_H_INCLUDED) || (LZO_VERSION+0 != 0x20a0)
  3313. # error "version mismatch"
  3314. #endif
  3315. #if (LZO_CC_MSC && (_MSC_VER >= 1000 && _MSC_VER < 1100))
  3316. # pragma warning(disable: 4702)
  3317. #endif
  3318. #if (LZO_CC_MSC && (_MSC_VER >= 1000))
  3319. # pragma warning(disable: 4127 4701)
  3320. # pragma warning(disable: 4514 4710 4711)
  3321. #endif
  3322. #if (LZO_CC_MSC && (_MSC_VER >= 1300))
  3323. # pragma warning(disable: 4820)
  3324. #endif
  3325. #if (LZO_CC_MSC && (_MSC_VER >= 1800))
  3326. # pragma warning(disable: 4746)
  3327. #endif
  3328. #if (LZO_CC_INTELC && (__INTEL_COMPILER >= 900))
  3329. # pragma warning(disable: 1684)
  3330. #endif
  3331. #if (LZO_CC_SUNPROC)
  3332. #if !defined(__cplusplus)
  3333. # pragma error_messages(off,E_END_OF_LOOP_CODE_NOT_REACHED)
  3334. # pragma error_messages(off,E_LOOP_NOT_ENTERED_AT_TOP)
  3335. # pragma error_messages(off,E_STATEMENT_NOT_REACHED)
  3336. #endif
  3337. #endif
  3338. #if !defined(__LZO_NOEXPORT1)
  3339. # define __LZO_NOEXPORT1 /*empty*/
  3340. #endif
  3341. #if !defined(__LZO_NOEXPORT2)
  3342. # define __LZO_NOEXPORT2 /*empty*/
  3343. #endif
  3344. #if 1
  3345. # define LZO_PUBLIC_DECL(r) LZO_EXTERN(r)
  3346. #endif
  3347. #if 1
  3348. # define LZO_PUBLIC_IMPL(r) LZO_PUBLIC(r)
  3349. #endif
  3350. #if !defined(LZO_LOCAL_DECL)
  3351. # define LZO_LOCAL_DECL(r) __LZO_EXTERN_C LZO_LOCAL_IMPL(r)
  3352. #endif
  3353. #if !defined(LZO_LOCAL_IMPL)
  3354. # define LZO_LOCAL_IMPL(r) __LZO_NOEXPORT1 r __LZO_NOEXPORT2 __LZO_CDECL
  3355. #endif
  3356. #if 1
  3357. # define LZO_STATIC_DECL(r) LZO_PRIVATE(r)
  3358. #endif
  3359. #if 1
  3360. # define LZO_STATIC_IMPL(r) LZO_PRIVATE(r)
  3361. #endif
  3362. #if defined(__LZO_IN_MINILZO) || (LZO_CFG_FREESTANDING)
  3363. #elif 1
  3364. # include <string.h>
  3365. #else
  3366. # define LZO_WANT_ACC_INCD_H 1
  3367. #endif
  3368. #if defined(LZO_HAVE_CONFIG_H)
  3369. # define LZO_CFG_NO_CONFIG_HEADER 1
  3370. #endif
  3371. #if 1 && !defined(LZO_CFG_FREESTANDING)
  3372. #if 1 && !defined(HAVE_STRING_H)
  3373. #define HAVE_STRING_H 1
  3374. #endif
  3375. #if 1 && !defined(HAVE_MEMCMP)
  3376. #define HAVE_MEMCMP 1
  3377. #endif
  3378. #if 1 && !defined(HAVE_MEMCPY)
  3379. #define HAVE_MEMCPY 1
  3380. #endif
  3381. #if 1 && !defined(HAVE_MEMMOVE)
  3382. #define HAVE_MEMMOVE 1
  3383. #endif
  3384. #if 1 && !defined(HAVE_MEMSET)
  3385. #define HAVE_MEMSET 1
  3386. #endif
  3387. #endif
  3388. #if 1 && defined(HAVE_STRING_H)
  3389. #include <string.h>
  3390. #endif
  3391. #if 1 || defined(lzo_int8_t) || defined(lzo_uint8_t)
  3392. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int8_t) == 1)
  3393. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint8_t) == 1)
  3394. #endif
  3395. #if 1 || defined(lzo_int16_t) || defined(lzo_uint16_t)
  3396. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int16_t) == 2)
  3397. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint16_t) == 2)
  3398. #endif
  3399. #if 1 || defined(lzo_int32_t) || defined(lzo_uint32_t)
  3400. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int32_t) == 4)
  3401. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint32_t) == 4)
  3402. #endif
  3403. #if defined(lzo_int64_t) || defined(lzo_uint64_t)
  3404. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_int64_t) == 8)
  3405. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint64_t) == 8)
  3406. #endif
  3407. #if (LZO_CFG_FREESTANDING)
  3408. # undef HAVE_MEMCMP
  3409. # undef HAVE_MEMCPY
  3410. # undef HAVE_MEMMOVE
  3411. # undef HAVE_MEMSET
  3412. #endif
  3413. #if !(HAVE_MEMCMP)
  3414. # undef memcmp
  3415. # define memcmp(a,b,c) lzo_memcmp(a,b,c)
  3416. #else
  3417. # undef lzo_memcmp
  3418. # define lzo_memcmp(a,b,c) memcmp(a,b,c)
  3419. #endif
  3420. #if !(HAVE_MEMCPY)
  3421. # undef memcpy
  3422. # define memcpy(a,b,c) lzo_memcpy(a,b,c)
  3423. #else
  3424. # undef lzo_memcpy
  3425. # define lzo_memcpy(a,b,c) memcpy(a,b,c)
  3426. #endif
  3427. #if !(HAVE_MEMMOVE)
  3428. # undef memmove
  3429. # define memmove(a,b,c) lzo_memmove(a,b,c)
  3430. #else
  3431. # undef lzo_memmove
  3432. # define lzo_memmove(a,b,c) memmove(a,b,c)
  3433. #endif
  3434. #if !(HAVE_MEMSET)
  3435. # undef memset
  3436. # define memset(a,b,c) lzo_memset(a,b,c)
  3437. #else
  3438. # undef lzo_memset
  3439. # define lzo_memset(a,b,c) memset(a,b,c)
  3440. #endif
  3441. #undef NDEBUG
  3442. #if (LZO_CFG_FREESTANDING)
  3443. # undef LZO_DEBUG
  3444. # define NDEBUG 1
  3445. # undef assert
  3446. # define assert(e) ((void)0)
  3447. #else
  3448. # if !defined(LZO_DEBUG)
  3449. # define NDEBUG 1
  3450. # endif
  3451. # include <assert.h>
  3452. #endif
  3453. #if 0 && defined(__BOUNDS_CHECKING_ON)
  3454. # include <unchecked.h>
  3455. #else
  3456. # define BOUNDS_CHECKING_OFF_DURING(stmt) stmt
  3457. # define BOUNDS_CHECKING_OFF_IN_EXPR(expr) (expr)
  3458. #endif
  3459. #if (LZO_CFG_PGO)
  3460. # undef __lzo_likely
  3461. # undef __lzo_unlikely
  3462. # define __lzo_likely(e) (e)
  3463. # define __lzo_unlikely(e) (e)
  3464. #endif
  3465. #undef _
  3466. #undef __
  3467. #undef ___
  3468. #undef ____
  3469. #undef _p0
  3470. #undef _p1
  3471. #undef _p2
  3472. #undef _p3
  3473. #undef _p4
  3474. #undef _s0
  3475. #undef _s1
  3476. #undef _s2
  3477. #undef _s3
  3478. #undef _s4
  3479. #undef _ww
  3480. #if 1
  3481. # define LZO_BYTE(x) ((unsigned char) (x))
  3482. #else
  3483. # define LZO_BYTE(x) ((unsigned char) ((x) & 0xff))
  3484. #endif
  3485. #define LZO_MAX(a,b) ((a) >= (b) ? (a) : (b))
  3486. #define LZO_MIN(a,b) ((a) <= (b) ? (a) : (b))
  3487. #define LZO_MAX3(a,b,c) ((a) >= (b) ? LZO_MAX(a,c) : LZO_MAX(b,c))
  3488. #define LZO_MIN3(a,b,c) ((a) <= (b) ? LZO_MIN(a,c) : LZO_MIN(b,c))
  3489. #define lzo_sizeof(type) ((lzo_uint) (sizeof(type)))
  3490. #define LZO_HIGH(array) ((lzo_uint) (sizeof(array)/sizeof(*(array))))
  3491. #define LZO_SIZE(bits) (1u << (bits))
  3492. #define LZO_MASK(bits) (LZO_SIZE(bits) - 1)
  3493. #define LZO_USIZE(bits) ((lzo_uint) 1 << (bits))
  3494. #define LZO_UMASK(bits) (LZO_USIZE(bits) - 1)
  3495. #if !defined(DMUL)
  3496. #if 0
  3497. # define DMUL(a,b) ((lzo_xint) ((lzo_uint32_t)(a) * (lzo_uint32_t)(b)))
  3498. #else
  3499. # define DMUL(a,b) ((lzo_xint) ((a) * (b)))
  3500. #endif
  3501. #endif
  3502. #ifndef __LZO_FUNC_H
  3503. #define __LZO_FUNC_H 1
  3504. #if !defined(LZO_BITOPS_USE_ASM_BITSCAN) && !defined(LZO_BITOPS_USE_GNUC_BITSCAN) && !defined(LZO_BITOPS_USE_MSC_BITSCAN)
  3505. #if 1 && (LZO_ARCH_AMD64) && (LZO_CC_GNUC && (LZO_CC_GNUC < 0x040000ul)) && (LZO_ASM_SYNTAX_GNUC)
  3506. #define LZO_BITOPS_USE_ASM_BITSCAN 1
  3507. #elif (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x030400ul) || (LZO_CC_INTELC_GNUC && (__INTEL_COMPILER >= 1000)) || (LZO_CC_LLVM && (!defined(__llvm_tools_version__) || (__llvm_tools_version__+0 >= 0x010500ul))))
  3508. #define LZO_BITOPS_USE_GNUC_BITSCAN 1
  3509. #elif (LZO_OS_WIN32 || LZO_OS_WIN64) && ((LZO_CC_INTELC_MSC && (__INTEL_COMPILER >= 1010)) || (LZO_CC_MSC && (_MSC_VER >= 1400)))
  3510. #define LZO_BITOPS_USE_MSC_BITSCAN 1
  3511. #if (LZO_CC_MSC) && (LZO_ARCH_AMD64 || LZO_ARCH_I386)
  3512. #include <intrin.h>
  3513. #endif
  3514. #if (LZO_CC_MSC) && (LZO_ARCH_AMD64 || LZO_ARCH_I386)
  3515. #pragma intrinsic(_BitScanReverse)
  3516. #pragma intrinsic(_BitScanForward)
  3517. #endif
  3518. #if (LZO_CC_MSC) && (LZO_ARCH_AMD64)
  3519. #pragma intrinsic(_BitScanReverse64)
  3520. #pragma intrinsic(_BitScanForward64)
  3521. #endif
  3522. #endif
  3523. #endif
  3524. __lzo_static_forceinline unsigned lzo_bitops_ctlz32_func(lzo_uint32_t v)
  3525. {
  3526. #if (LZO_BITOPS_USE_MSC_BITSCAN) && (LZO_ARCH_AMD64 || LZO_ARCH_I386)
  3527. unsigned long r; (void) _BitScanReverse(&r, v); return (unsigned) r ^ 31;
  3528. #define lzo_bitops_ctlz32(v) lzo_bitops_ctlz32_func(v)
  3529. #elif (LZO_BITOPS_USE_ASM_BITSCAN) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) && (LZO_ASM_SYNTAX_GNUC)
  3530. lzo_uint32_t r;
  3531. __asm__("bsr %1,%0" : "=r" (r) : "rm" (v) __LZO_ASM_CLOBBER_LIST_CC);
  3532. return (unsigned) r ^ 31;
  3533. #define lzo_bitops_ctlz32(v) lzo_bitops_ctlz32_func(v)
  3534. #elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_INT == 4)
  3535. unsigned r; r = (unsigned) __builtin_clz(v); return r;
  3536. #define lzo_bitops_ctlz32(v) ((unsigned) __builtin_clz(v))
  3537. #elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_LONG == 8) && (LZO_WORDSIZE >= 8)
  3538. unsigned r; r = (unsigned) __builtin_clzl(v); return r ^ 32;
  3539. #define lzo_bitops_ctlz32(v) (((unsigned) __builtin_clzl(v)) ^ 32)
  3540. #else
  3541. LZO_UNUSED(v); return 0;
  3542. #endif
  3543. }
  3544. #if defined(lzo_uint64_t)
  3545. __lzo_static_forceinline unsigned lzo_bitops_ctlz64_func(lzo_uint64_t v)
  3546. {
  3547. #if (LZO_BITOPS_USE_MSC_BITSCAN) && (LZO_ARCH_AMD64)
  3548. unsigned long r; (void) _BitScanReverse64(&r, v); return (unsigned) r ^ 63;
  3549. #define lzo_bitops_ctlz64(v) lzo_bitops_ctlz64_func(v)
  3550. #elif (LZO_BITOPS_USE_ASM_BITSCAN) && (LZO_ARCH_AMD64) && (LZO_ASM_SYNTAX_GNUC)
  3551. lzo_uint64_t r;
  3552. __asm__("bsr %1,%0" : "=r" (r) : "rm" (v) __LZO_ASM_CLOBBER_LIST_CC);
  3553. return (unsigned) r ^ 63;
  3554. #define lzo_bitops_ctlz64(v) lzo_bitops_ctlz64_func(v)
  3555. #elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_LONG == 8) && (LZO_WORDSIZE >= 8)
  3556. unsigned r; r = (unsigned) __builtin_clzl(v); return r;
  3557. #define lzo_bitops_ctlz64(v) ((unsigned) __builtin_clzl(v))
  3558. #elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_LONG_LONG == 8) && (LZO_WORDSIZE >= 8)
  3559. unsigned r; r = (unsigned) __builtin_clzll(v); return r;
  3560. #define lzo_bitops_ctlz64(v) ((unsigned) __builtin_clzll(v))
  3561. #else
  3562. LZO_UNUSED(v); return 0;
  3563. #endif
  3564. }
  3565. #endif
  3566. __lzo_static_forceinline unsigned lzo_bitops_cttz32_func(lzo_uint32_t v)
  3567. {
  3568. #if (LZO_BITOPS_USE_MSC_BITSCAN) && (LZO_ARCH_AMD64 || LZO_ARCH_I386)
  3569. unsigned long r; (void) _BitScanForward(&r, v); return (unsigned) r;
  3570. #define lzo_bitops_cttz32(v) lzo_bitops_cttz32_func(v)
  3571. #elif (LZO_BITOPS_USE_ASM_BITSCAN) && (LZO_ARCH_AMD64 || LZO_ARCH_I386) && (LZO_ASM_SYNTAX_GNUC)
  3572. lzo_uint32_t r;
  3573. __asm__("bsf %1,%0" : "=r" (r) : "rm" (v) __LZO_ASM_CLOBBER_LIST_CC);
  3574. return (unsigned) r;
  3575. #define lzo_bitops_cttz32(v) lzo_bitops_cttz32_func(v)
  3576. #elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_INT >= 4)
  3577. unsigned r; r = (unsigned) __builtin_ctz(v); return r;
  3578. #define lzo_bitops_cttz32(v) ((unsigned) __builtin_ctz(v))
  3579. #else
  3580. LZO_UNUSED(v); return 0;
  3581. #endif
  3582. }
  3583. #if defined(lzo_uint64_t)
  3584. __lzo_static_forceinline unsigned lzo_bitops_cttz64_func(lzo_uint64_t v)
  3585. {
  3586. #if (LZO_BITOPS_USE_MSC_BITSCAN) && (LZO_ARCH_AMD64)
  3587. unsigned long r; (void) _BitScanForward64(&r, v); return (unsigned) r;
  3588. #define lzo_bitops_cttz64(v) lzo_bitops_cttz64_func(v)
  3589. #elif (LZO_BITOPS_USE_ASM_BITSCAN) && (LZO_ARCH_AMD64) && (LZO_ASM_SYNTAX_GNUC)
  3590. lzo_uint64_t r;
  3591. __asm__("bsf %1,%0" : "=r" (r) : "rm" (v) __LZO_ASM_CLOBBER_LIST_CC);
  3592. return (unsigned) r;
  3593. #define lzo_bitops_cttz64(v) lzo_bitops_cttz64_func(v)
  3594. #elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_LONG >= 8) && (LZO_WORDSIZE >= 8)
  3595. unsigned r; r = (unsigned) __builtin_ctzl(v); return r;
  3596. #define lzo_bitops_cttz64(v) ((unsigned) __builtin_ctzl(v))
  3597. #elif (LZO_BITOPS_USE_GNUC_BITSCAN) && (LZO_SIZEOF_LONG_LONG >= 8) && (LZO_WORDSIZE >= 8)
  3598. unsigned r; r = (unsigned) __builtin_ctzll(v); return r;
  3599. #define lzo_bitops_cttz64(v) ((unsigned) __builtin_ctzll(v))
  3600. #else
  3601. LZO_UNUSED(v); return 0;
  3602. #endif
  3603. }
  3604. #endif
  3605. lzo_unused_funcs_impl(void, lzo_bitops_unused_funcs)(void)
  3606. {
  3607. LZO_UNUSED_FUNC(lzo_bitops_unused_funcs);
  3608. LZO_UNUSED_FUNC(lzo_bitops_ctlz32_func);
  3609. LZO_UNUSED_FUNC(lzo_bitops_cttz32_func);
  3610. #if defined(lzo_uint64_t)
  3611. LZO_UNUSED_FUNC(lzo_bitops_ctlz64_func);
  3612. LZO_UNUSED_FUNC(lzo_bitops_cttz64_func);
  3613. #endif
  3614. }
  3615. #if defined(__lzo_alignof) && !(LZO_CFG_NO_UNALIGNED)
  3616. #if !defined(lzo_memops_tcheck__) && 0
  3617. #define lzo_memops_tcheck__(t,a,b) ((void)0, sizeof(t) == (a) && __lzo_alignof(t) == (b))
  3618. #endif
  3619. #endif
  3620. #ifndef lzo_memops_TU0p
  3621. #define lzo_memops_TU0p void __LZO_MMODEL *
  3622. #endif
  3623. #ifndef lzo_memops_TU1p
  3624. #define lzo_memops_TU1p unsigned char __LZO_MMODEL *
  3625. #endif
  3626. #ifndef lzo_memops_TU2p
  3627. #if (LZO_OPT_UNALIGNED16)
  3628. typedef lzo_uint16_t __lzo_may_alias lzo_memops_TU2;
  3629. #define lzo_memops_TU2p volatile lzo_memops_TU2 *
  3630. #elif defined(__lzo_byte_struct)
  3631. __lzo_byte_struct(lzo_memops_TU2_struct,2)
  3632. typedef struct lzo_memops_TU2_struct lzo_memops_TU2;
  3633. #else
  3634. struct lzo_memops_TU2_struct { unsigned char a[2]; } __lzo_may_alias;
  3635. typedef struct lzo_memops_TU2_struct lzo_memops_TU2;
  3636. #endif
  3637. #ifndef lzo_memops_TU2p
  3638. #define lzo_memops_TU2p lzo_memops_TU2 *
  3639. #endif
  3640. #endif
  3641. #ifndef lzo_memops_TU4p
  3642. #if (LZO_OPT_UNALIGNED32)
  3643. typedef lzo_uint32_t __lzo_may_alias lzo_memops_TU4;
  3644. #define lzo_memops_TU4p volatile lzo_memops_TU4 __LZO_MMODEL *
  3645. #elif defined(__lzo_byte_struct)
  3646. __lzo_byte_struct(lzo_memops_TU4_struct,4)
  3647. typedef struct lzo_memops_TU4_struct lzo_memops_TU4;
  3648. #else
  3649. struct lzo_memops_TU4_struct { unsigned char a[4]; } __lzo_may_alias;
  3650. typedef struct lzo_memops_TU4_struct lzo_memops_TU4;
  3651. #endif
  3652. #ifndef lzo_memops_TU4p
  3653. #define lzo_memops_TU4p lzo_memops_TU4 __LZO_MMODEL *
  3654. #endif
  3655. #endif
  3656. #ifndef lzo_memops_TU8p
  3657. #if (LZO_OPT_UNALIGNED64)
  3658. typedef lzo_uint64_t __lzo_may_alias lzo_memops_TU8;
  3659. #define lzo_memops_TU8p volatile lzo_memops_TU8 __LZO_MMODEL *
  3660. #elif defined(__lzo_byte_struct)
  3661. __lzo_byte_struct(lzo_memops_TU8_struct,8)
  3662. typedef struct lzo_memops_TU8_struct lzo_memops_TU8;
  3663. #else
  3664. struct lzo_memops_TU8_struct { unsigned char a[8]; } __lzo_may_alias;
  3665. typedef struct lzo_memops_TU8_struct lzo_memops_TU8;
  3666. #endif
  3667. #ifndef lzo_memops_TU8p
  3668. #define lzo_memops_TU8p lzo_memops_TU8 __LZO_MMODEL *
  3669. #endif
  3670. #endif
  3671. #ifndef lzo_memops_set_TU1p
  3672. #define lzo_memops_set_TU1p volatile lzo_memops_TU1p
  3673. #endif
  3674. #ifndef lzo_memops_move_TU1p
  3675. #define lzo_memops_move_TU1p lzo_memops_TU1p
  3676. #endif
  3677. #define LZO_MEMOPS_SET1(dd,cc) \
  3678. LZO_BLOCK_BEGIN \
  3679. lzo_memops_set_TU1p d__1 = (lzo_memops_set_TU1p) (lzo_memops_TU0p) (dd); \
  3680. d__1[0] = LZO_BYTE(cc); \
  3681. LZO_BLOCK_END
  3682. #define LZO_MEMOPS_SET2(dd,cc) \
  3683. LZO_BLOCK_BEGIN \
  3684. lzo_memops_set_TU1p d__2 = (lzo_memops_set_TU1p) (lzo_memops_TU0p) (dd); \
  3685. d__2[0] = LZO_BYTE(cc); d__2[1] = LZO_BYTE(cc); \
  3686. LZO_BLOCK_END
  3687. #define LZO_MEMOPS_SET3(dd,cc) \
  3688. LZO_BLOCK_BEGIN \
  3689. lzo_memops_set_TU1p d__3 = (lzo_memops_set_TU1p) (lzo_memops_TU0p) (dd); \
  3690. d__3[0] = LZO_BYTE(cc); d__3[1] = LZO_BYTE(cc); d__3[2] = LZO_BYTE(cc); \
  3691. LZO_BLOCK_END
  3692. #define LZO_MEMOPS_SET4(dd,cc) \
  3693. LZO_BLOCK_BEGIN \
  3694. lzo_memops_set_TU1p d__4 = (lzo_memops_set_TU1p) (lzo_memops_TU0p) (dd); \
  3695. d__4[0] = LZO_BYTE(cc); d__4[1] = LZO_BYTE(cc); d__4[2] = LZO_BYTE(cc); d__4[3] = LZO_BYTE(cc); \
  3696. LZO_BLOCK_END
  3697. #define LZO_MEMOPS_MOVE1(dd,ss) \
  3698. LZO_BLOCK_BEGIN \
  3699. lzo_memops_move_TU1p d__1 = (lzo_memops_move_TU1p) (lzo_memops_TU0p) (dd); \
  3700. const lzo_memops_move_TU1p s__1 = (const lzo_memops_move_TU1p) (const lzo_memops_TU0p) (ss); \
  3701. d__1[0] = s__1[0]; \
  3702. LZO_BLOCK_END
  3703. #define LZO_MEMOPS_MOVE2(dd,ss) \
  3704. LZO_BLOCK_BEGIN \
  3705. lzo_memops_move_TU1p d__2 = (lzo_memops_move_TU1p) (lzo_memops_TU0p) (dd); \
  3706. const lzo_memops_move_TU1p s__2 = (const lzo_memops_move_TU1p) (const lzo_memops_TU0p) (ss); \
  3707. d__2[0] = s__2[0]; d__2[1] = s__2[1]; \
  3708. LZO_BLOCK_END
  3709. #define LZO_MEMOPS_MOVE3(dd,ss) \
  3710. LZO_BLOCK_BEGIN \
  3711. lzo_memops_move_TU1p d__3 = (lzo_memops_move_TU1p) (lzo_memops_TU0p) (dd); \
  3712. const lzo_memops_move_TU1p s__3 = (const lzo_memops_move_TU1p) (const lzo_memops_TU0p) (ss); \
  3713. d__3[0] = s__3[0]; d__3[1] = s__3[1]; d__3[2] = s__3[2]; \
  3714. LZO_BLOCK_END
  3715. #define LZO_MEMOPS_MOVE4(dd,ss) \
  3716. LZO_BLOCK_BEGIN \
  3717. lzo_memops_move_TU1p d__4 = (lzo_memops_move_TU1p) (lzo_memops_TU0p) (dd); \
  3718. const lzo_memops_move_TU1p s__4 = (const lzo_memops_move_TU1p) (const lzo_memops_TU0p) (ss); \
  3719. d__4[0] = s__4[0]; d__4[1] = s__4[1]; d__4[2] = s__4[2]; d__4[3] = s__4[3]; \
  3720. LZO_BLOCK_END
  3721. #define LZO_MEMOPS_MOVE8(dd,ss) \
  3722. LZO_BLOCK_BEGIN \
  3723. lzo_memops_move_TU1p d__8 = (lzo_memops_move_TU1p) (lzo_memops_TU0p) (dd); \
  3724. const lzo_memops_move_TU1p s__8 = (const lzo_memops_move_TU1p) (const lzo_memops_TU0p) (ss); \
  3725. d__8[0] = s__8[0]; d__8[1] = s__8[1]; d__8[2] = s__8[2]; d__8[3] = s__8[3]; \
  3726. d__8[4] = s__8[4]; d__8[5] = s__8[5]; d__8[6] = s__8[6]; d__8[7] = s__8[7]; \
  3727. LZO_BLOCK_END
  3728. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU1p)0)==1)
  3729. #define LZO_MEMOPS_COPY1(dd,ss) LZO_MEMOPS_MOVE1(dd,ss)
  3730. #if (LZO_OPT_UNALIGNED16)
  3731. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU2p)0)==2)
  3732. #define LZO_MEMOPS_COPY2(dd,ss) \
  3733. * (lzo_memops_TU2p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU2p) (const lzo_memops_TU0p) (ss)
  3734. #elif defined(lzo_memops_tcheck__)
  3735. #define LZO_MEMOPS_COPY2(dd,ss) \
  3736. LZO_BLOCK_BEGIN if (lzo_memops_tcheck__(lzo_memops_TU2,2,1)) { \
  3737. * (lzo_memops_TU2p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU2p) (const lzo_memops_TU0p) (ss); \
  3738. } else { LZO_MEMOPS_MOVE2(dd,ss); } LZO_BLOCK_END
  3739. #else
  3740. #define LZO_MEMOPS_COPY2(dd,ss) LZO_MEMOPS_MOVE2(dd,ss)
  3741. #endif
  3742. #if (LZO_OPT_UNALIGNED32)
  3743. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU4p)0)==4)
  3744. #define LZO_MEMOPS_COPY4(dd,ss) \
  3745. * (lzo_memops_TU4p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU4p) (const lzo_memops_TU0p) (ss)
  3746. #elif defined(lzo_memops_tcheck__)
  3747. #define LZO_MEMOPS_COPY4(dd,ss) \
  3748. LZO_BLOCK_BEGIN if (lzo_memops_tcheck__(lzo_memops_TU4,4,1)) { \
  3749. * (lzo_memops_TU4p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU4p) (const lzo_memops_TU0p) (ss); \
  3750. } else { LZO_MEMOPS_MOVE4(dd,ss); } LZO_BLOCK_END
  3751. #else
  3752. #define LZO_MEMOPS_COPY4(dd,ss) LZO_MEMOPS_MOVE4(dd,ss)
  3753. #endif
  3754. #if (LZO_WORDSIZE != 8)
  3755. #define LZO_MEMOPS_COPY8(dd,ss) \
  3756. LZO_BLOCK_BEGIN LZO_MEMOPS_COPY4(dd,ss); LZO_MEMOPS_COPY4((lzo_memops_TU1p)(lzo_memops_TU0p)(dd)+4,(const lzo_memops_TU1p)(const lzo_memops_TU0p)(ss)+4); LZO_BLOCK_END
  3757. #else
  3758. #if (LZO_OPT_UNALIGNED64)
  3759. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU8p)0)==8)
  3760. #define LZO_MEMOPS_COPY8(dd,ss) \
  3761. * (lzo_memops_TU8p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU8p) (const lzo_memops_TU0p) (ss)
  3762. #elif (LZO_OPT_UNALIGNED32)
  3763. #define LZO_MEMOPS_COPY8(dd,ss) \
  3764. LZO_BLOCK_BEGIN LZO_MEMOPS_COPY4(dd,ss); LZO_MEMOPS_COPY4((lzo_memops_TU1p)(lzo_memops_TU0p)(dd)+4,(const lzo_memops_TU1p)(const lzo_memops_TU0p)(ss)+4); LZO_BLOCK_END
  3765. #elif defined(lzo_memops_tcheck__)
  3766. #define LZO_MEMOPS_COPY8(dd,ss) \
  3767. LZO_BLOCK_BEGIN if (lzo_memops_tcheck__(lzo_memops_TU8,8,1)) { \
  3768. * (lzo_memops_TU8p) (lzo_memops_TU0p) (dd) = * (const lzo_memops_TU8p) (const lzo_memops_TU0p) (ss); \
  3769. } else { LZO_MEMOPS_MOVE8(dd,ss); } LZO_BLOCK_END
  3770. #else
  3771. #define LZO_MEMOPS_COPY8(dd,ss) LZO_MEMOPS_MOVE8(dd,ss)
  3772. #endif
  3773. #endif
  3774. #define LZO_MEMOPS_COPYN(dd,ss,nn) \
  3775. LZO_BLOCK_BEGIN \
  3776. lzo_memops_TU1p d__n = (lzo_memops_TU1p) (lzo_memops_TU0p) (dd); \
  3777. const lzo_memops_TU1p s__n = (const lzo_memops_TU1p) (const lzo_memops_TU0p) (ss); \
  3778. lzo_uint n__n = (nn); \
  3779. while ((void)0, n__n >= 8) { LZO_MEMOPS_COPY8(d__n, s__n); d__n += 8; s__n += 8; n__n -= 8; } \
  3780. if ((void)0, n__n >= 4) { LZO_MEMOPS_COPY4(d__n, s__n); d__n += 4; s__n += 4; n__n -= 4; } \
  3781. if ((void)0, n__n > 0) do { *d__n++ = *s__n++; } while (--n__n > 0); \
  3782. LZO_BLOCK_END
  3783. __lzo_static_forceinline lzo_uint16_t lzo_memops_get_le16(const lzo_voidp ss)
  3784. {
  3785. lzo_uint16_t v;
  3786. #if (LZO_ABI_LITTLE_ENDIAN)
  3787. LZO_MEMOPS_COPY2(&v, ss);
  3788. #elif (LZO_OPT_UNALIGNED16 && LZO_ARCH_POWERPC && LZO_ABI_BIG_ENDIAN) && (LZO_ASM_SYNTAX_GNUC)
  3789. const lzo_memops_TU2p s = (const lzo_memops_TU2p) ss;
  3790. unsigned long vv;
  3791. __asm__("lhbrx %0,0,%1" : "=r" (vv) : "r" (s), "m" (*s));
  3792. v = (lzo_uint16_t) vv;
  3793. #else
  3794. const lzo_memops_TU1p s = (const lzo_memops_TU1p) ss;
  3795. v = (lzo_uint16_t) (((lzo_uint16_t)s[0]) | ((lzo_uint16_t)s[1] << 8));
  3796. #endif
  3797. return v;
  3798. }
  3799. #if (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN)
  3800. #define LZO_MEMOPS_GET_LE16(ss) (* (const lzo_memops_TU2p) (const lzo_memops_TU0p) (ss))
  3801. #else
  3802. #define LZO_MEMOPS_GET_LE16(ss) lzo_memops_get_le16(ss)
  3803. #endif
  3804. __lzo_static_forceinline lzo_uint32_t lzo_memops_get_le32(const lzo_voidp ss)
  3805. {
  3806. lzo_uint32_t v;
  3807. #if (LZO_ABI_LITTLE_ENDIAN)
  3808. LZO_MEMOPS_COPY4(&v, ss);
  3809. #elif (LZO_OPT_UNALIGNED32 && LZO_ARCH_POWERPC && LZO_ABI_BIG_ENDIAN) && (LZO_ASM_SYNTAX_GNUC)
  3810. const lzo_memops_TU4p s = (const lzo_memops_TU4p) ss;
  3811. unsigned long vv;
  3812. __asm__("lwbrx %0,0,%1" : "=r" (vv) : "r" (s), "m" (*s));
  3813. v = (lzo_uint32_t) vv;
  3814. #else
  3815. const lzo_memops_TU1p s = (const lzo_memops_TU1p) ss;
  3816. v = (lzo_uint32_t) (((lzo_uint32_t)s[0]) | ((lzo_uint32_t)s[1] << 8) | ((lzo_uint32_t)s[2] << 16) | ((lzo_uint32_t)s[3] << 24));
  3817. #endif
  3818. return v;
  3819. }
  3820. #if (LZO_OPT_UNALIGNED32) && (LZO_ABI_LITTLE_ENDIAN)
  3821. #define LZO_MEMOPS_GET_LE32(ss) (* (const lzo_memops_TU4p) (const lzo_memops_TU0p) (ss))
  3822. #else
  3823. #define LZO_MEMOPS_GET_LE32(ss) lzo_memops_get_le32(ss)
  3824. #endif
  3825. #if (LZO_OPT_UNALIGNED64) && (LZO_ABI_LITTLE_ENDIAN)
  3826. #define LZO_MEMOPS_GET_LE64(ss) (* (const lzo_memops_TU8p) (const lzo_memops_TU0p) (ss))
  3827. #endif
  3828. __lzo_static_forceinline lzo_uint16_t lzo_memops_get_ne16(const lzo_voidp ss)
  3829. {
  3830. lzo_uint16_t v;
  3831. LZO_MEMOPS_COPY2(&v, ss);
  3832. return v;
  3833. }
  3834. #if (LZO_OPT_UNALIGNED16)
  3835. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU2p)0)==2)
  3836. #define LZO_MEMOPS_GET_NE16(ss) (* (const lzo_memops_TU2p) (const lzo_memops_TU0p) (ss))
  3837. #else
  3838. #define LZO_MEMOPS_GET_NE16(ss) lzo_memops_get_ne16(ss)
  3839. #endif
  3840. __lzo_static_forceinline lzo_uint32_t lzo_memops_get_ne32(const lzo_voidp ss)
  3841. {
  3842. lzo_uint32_t v;
  3843. LZO_MEMOPS_COPY4(&v, ss);
  3844. return v;
  3845. }
  3846. #if (LZO_OPT_UNALIGNED32)
  3847. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU4p)0)==4)
  3848. #define LZO_MEMOPS_GET_NE32(ss) (* (const lzo_memops_TU4p) (const lzo_memops_TU0p) (ss))
  3849. #else
  3850. #define LZO_MEMOPS_GET_NE32(ss) lzo_memops_get_ne32(ss)
  3851. #endif
  3852. #if (LZO_OPT_UNALIGNED64)
  3853. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(*(lzo_memops_TU8p)0)==8)
  3854. #define LZO_MEMOPS_GET_NE64(ss) (* (const lzo_memops_TU8p) (const lzo_memops_TU0p) (ss))
  3855. #endif
  3856. __lzo_static_forceinline void lzo_memops_put_le16(lzo_voidp dd, lzo_uint16_t vv)
  3857. {
  3858. #if (LZO_ABI_LITTLE_ENDIAN)
  3859. LZO_MEMOPS_COPY2(dd, &vv);
  3860. #elif (LZO_OPT_UNALIGNED16 && LZO_ARCH_POWERPC && LZO_ABI_BIG_ENDIAN) && (LZO_ASM_SYNTAX_GNUC)
  3861. lzo_memops_TU2p d = (lzo_memops_TU2p) dd;
  3862. unsigned long v = vv;
  3863. __asm__("sthbrx %2,0,%1" : "=m" (*d) : "r" (d), "r" (v));
  3864. #else
  3865. lzo_memops_TU1p d = (lzo_memops_TU1p) dd;
  3866. d[0] = LZO_BYTE((vv ) & 0xff);
  3867. d[1] = LZO_BYTE((vv >> 8) & 0xff);
  3868. #endif
  3869. }
  3870. #if (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN)
  3871. #define LZO_MEMOPS_PUT_LE16(dd,vv) (* (lzo_memops_TU2p) (lzo_memops_TU0p) (dd) = (vv))
  3872. #else
  3873. #define LZO_MEMOPS_PUT_LE16(dd,vv) lzo_memops_put_le16(dd,vv)
  3874. #endif
  3875. __lzo_static_forceinline void lzo_memops_put_le32(lzo_voidp dd, lzo_uint32_t vv)
  3876. {
  3877. #if (LZO_ABI_LITTLE_ENDIAN)
  3878. LZO_MEMOPS_COPY4(dd, &vv);
  3879. #elif (LZO_OPT_UNALIGNED32 && LZO_ARCH_POWERPC && LZO_ABI_BIG_ENDIAN) && (LZO_ASM_SYNTAX_GNUC)
  3880. lzo_memops_TU4p d = (lzo_memops_TU4p) dd;
  3881. unsigned long v = vv;
  3882. __asm__("stwbrx %2,0,%1" : "=m" (*d) : "r" (d), "r" (v));
  3883. #else
  3884. lzo_memops_TU1p d = (lzo_memops_TU1p) dd;
  3885. d[0] = LZO_BYTE((vv ) & 0xff);
  3886. d[1] = LZO_BYTE((vv >> 8) & 0xff);
  3887. d[2] = LZO_BYTE((vv >> 16) & 0xff);
  3888. d[3] = LZO_BYTE((vv >> 24) & 0xff);
  3889. #endif
  3890. }
  3891. #if (LZO_OPT_UNALIGNED32) && (LZO_ABI_LITTLE_ENDIAN)
  3892. #define LZO_MEMOPS_PUT_LE32(dd,vv) (* (lzo_memops_TU4p) (lzo_memops_TU0p) (dd) = (vv))
  3893. #else
  3894. #define LZO_MEMOPS_PUT_LE32(dd,vv) lzo_memops_put_le32(dd,vv)
  3895. #endif
  3896. __lzo_static_forceinline void lzo_memops_put_ne16(lzo_voidp dd, lzo_uint16_t vv)
  3897. {
  3898. LZO_MEMOPS_COPY2(dd, &vv);
  3899. }
  3900. #if (LZO_OPT_UNALIGNED16)
  3901. #define LZO_MEMOPS_PUT_NE16(dd,vv) (* (lzo_memops_TU2p) (lzo_memops_TU0p) (dd) = (vv))
  3902. #else
  3903. #define LZO_MEMOPS_PUT_NE16(dd,vv) lzo_memops_put_ne16(dd,vv)
  3904. #endif
  3905. __lzo_static_forceinline void lzo_memops_put_ne32(lzo_voidp dd, lzo_uint32_t vv)
  3906. {
  3907. LZO_MEMOPS_COPY4(dd, &vv);
  3908. }
  3909. #if (LZO_OPT_UNALIGNED32)
  3910. #define LZO_MEMOPS_PUT_NE32(dd,vv) (* (lzo_memops_TU4p) (lzo_memops_TU0p) (dd) = (vv))
  3911. #else
  3912. #define LZO_MEMOPS_PUT_NE32(dd,vv) lzo_memops_put_ne32(dd,vv)
  3913. #endif
  3914. lzo_unused_funcs_impl(void, lzo_memops_unused_funcs)(void)
  3915. {
  3916. LZO_UNUSED_FUNC(lzo_memops_unused_funcs);
  3917. LZO_UNUSED_FUNC(lzo_memops_get_le16);
  3918. LZO_UNUSED_FUNC(lzo_memops_get_le32);
  3919. LZO_UNUSED_FUNC(lzo_memops_get_ne16);
  3920. LZO_UNUSED_FUNC(lzo_memops_get_ne32);
  3921. LZO_UNUSED_FUNC(lzo_memops_put_le16);
  3922. LZO_UNUSED_FUNC(lzo_memops_put_le32);
  3923. LZO_UNUSED_FUNC(lzo_memops_put_ne16);
  3924. LZO_UNUSED_FUNC(lzo_memops_put_ne32);
  3925. }
  3926. #endif
  3927. #ifndef UA_SET1
  3928. #define UA_SET1 LZO_MEMOPS_SET1
  3929. #endif
  3930. #ifndef UA_SET2
  3931. #define UA_SET2 LZO_MEMOPS_SET2
  3932. #endif
  3933. #ifndef UA_SET3
  3934. #define UA_SET3 LZO_MEMOPS_SET3
  3935. #endif
  3936. #ifndef UA_SET4
  3937. #define UA_SET4 LZO_MEMOPS_SET4
  3938. #endif
  3939. #ifndef UA_MOVE1
  3940. #define UA_MOVE1 LZO_MEMOPS_MOVE1
  3941. #endif
  3942. #ifndef UA_MOVE2
  3943. #define UA_MOVE2 LZO_MEMOPS_MOVE2
  3944. #endif
  3945. #ifndef UA_MOVE3
  3946. #define UA_MOVE3 LZO_MEMOPS_MOVE3
  3947. #endif
  3948. #ifndef UA_MOVE4
  3949. #define UA_MOVE4 LZO_MEMOPS_MOVE4
  3950. #endif
  3951. #ifndef UA_MOVE8
  3952. #define UA_MOVE8 LZO_MEMOPS_MOVE8
  3953. #endif
  3954. #ifndef UA_COPY1
  3955. #define UA_COPY1 LZO_MEMOPS_COPY1
  3956. #endif
  3957. #ifndef UA_COPY2
  3958. #define UA_COPY2 LZO_MEMOPS_COPY2
  3959. #endif
  3960. #ifndef UA_COPY3
  3961. #define UA_COPY3 LZO_MEMOPS_COPY3
  3962. #endif
  3963. #ifndef UA_COPY4
  3964. #define UA_COPY4 LZO_MEMOPS_COPY4
  3965. #endif
  3966. #ifndef UA_COPY8
  3967. #define UA_COPY8 LZO_MEMOPS_COPY8
  3968. #endif
  3969. #ifndef UA_COPYN
  3970. #define UA_COPYN LZO_MEMOPS_COPYN
  3971. #endif
  3972. #ifndef UA_COPYN_X
  3973. #define UA_COPYN_X LZO_MEMOPS_COPYN
  3974. #endif
  3975. #ifndef UA_GET_LE16
  3976. #define UA_GET_LE16 LZO_MEMOPS_GET_LE16
  3977. #endif
  3978. #ifndef UA_GET_LE32
  3979. #define UA_GET_LE32 LZO_MEMOPS_GET_LE32
  3980. #endif
  3981. #ifdef LZO_MEMOPS_GET_LE64
  3982. #ifndef UA_GET_LE64
  3983. #define UA_GET_LE64 LZO_MEMOPS_GET_LE64
  3984. #endif
  3985. #endif
  3986. #ifndef UA_GET_NE16
  3987. #define UA_GET_NE16 LZO_MEMOPS_GET_NE16
  3988. #endif
  3989. #ifndef UA_GET_NE32
  3990. #define UA_GET_NE32 LZO_MEMOPS_GET_NE32
  3991. #endif
  3992. #ifdef LZO_MEMOPS_GET_NE64
  3993. #ifndef UA_GET_NE64
  3994. #define UA_GET_NE64 LZO_MEMOPS_GET_NE64
  3995. #endif
  3996. #endif
  3997. #ifndef UA_PUT_LE16
  3998. #define UA_PUT_LE16 LZO_MEMOPS_PUT_LE16
  3999. #endif
  4000. #ifndef UA_PUT_LE32
  4001. #define UA_PUT_LE32 LZO_MEMOPS_PUT_LE32
  4002. #endif
  4003. #ifndef UA_PUT_NE16
  4004. #define UA_PUT_NE16 LZO_MEMOPS_PUT_NE16
  4005. #endif
  4006. #ifndef UA_PUT_NE32
  4007. #define UA_PUT_NE32 LZO_MEMOPS_PUT_NE32
  4008. #endif
  4009. #define MEMCPY8_DS(dest,src,len) \
  4010. lzo_memcpy(dest,src,len); dest += len; src += len
  4011. #define BZERO8_PTR(s,l,n) \
  4012. lzo_memset((lzo_voidp)(s),0,(lzo_uint)(l)*(n))
  4013. #define MEMCPY_DS(dest,src,len) \
  4014. do *dest++ = *src++; while (--len > 0)
  4015. LZO_EXTERN(const lzo_bytep) lzo_copyright(void);
  4016. #ifndef __LZO_PTR_H
  4017. #define __LZO_PTR_H 1
  4018. #ifdef __cplusplus
  4019. extern "C" {
  4020. #endif
  4021. #if (LZO_ARCH_I086)
  4022. #error "LZO_ARCH_I086 is unsupported"
  4023. #elif (LZO_MM_PVP)
  4024. #error "LZO_MM_PVP is unsupported"
  4025. #else
  4026. #define PTR(a) ((lzo_uintptr_t) (a))
  4027. #define PTR_LINEAR(a) PTR(a)
  4028. #define PTR_ALIGNED_4(a) ((PTR_LINEAR(a) & 3) == 0)
  4029. #define PTR_ALIGNED_8(a) ((PTR_LINEAR(a) & 7) == 0)
  4030. #define PTR_ALIGNED2_4(a,b) (((PTR_LINEAR(a) | PTR_LINEAR(b)) & 3) == 0)
  4031. #define PTR_ALIGNED2_8(a,b) (((PTR_LINEAR(a) | PTR_LINEAR(b)) & 7) == 0)
  4032. #endif
  4033. #define PTR_LT(a,b) (PTR(a) < PTR(b))
  4034. #define PTR_GE(a,b) (PTR(a) >= PTR(b))
  4035. #define PTR_DIFF(a,b) (PTR(a) - PTR(b))
  4036. #define pd(a,b) ((lzo_uint) ((a)-(b)))
  4037. LZO_EXTERN(lzo_uintptr_t)
  4038. __lzo_ptr_linear(const lzo_voidp ptr);
  4039. typedef union
  4040. {
  4041. char a_char;
  4042. unsigned char a_uchar;
  4043. short a_short;
  4044. unsigned short a_ushort;
  4045. int a_int;
  4046. unsigned int a_uint;
  4047. long a_long;
  4048. unsigned long a_ulong;
  4049. lzo_int a_lzo_int;
  4050. lzo_uint a_lzo_uint;
  4051. lzo_xint a_lzo_xint;
  4052. lzo_int16_t a_lzo_int16_t;
  4053. lzo_uint16_t a_lzo_uint16_t;
  4054. lzo_int32_t a_lzo_int32_t;
  4055. lzo_uint32_t a_lzo_uint32_t;
  4056. #if defined(lzo_uint64_t)
  4057. lzo_int64_t a_lzo_int64_t;
  4058. lzo_uint64_t a_lzo_uint64_t;
  4059. #endif
  4060. size_t a_size_t;
  4061. ptrdiff_t a_ptrdiff_t;
  4062. lzo_uintptr_t a_lzo_uintptr_t;
  4063. void * a_void_p;
  4064. char * a_char_p;
  4065. unsigned char * a_uchar_p;
  4066. const void * a_c_void_p;
  4067. const char * a_c_char_p;
  4068. const unsigned char * a_c_uchar_p;
  4069. lzo_voidp a_lzo_voidp;
  4070. lzo_bytep a_lzo_bytep;
  4071. const lzo_voidp a_c_lzo_voidp;
  4072. const lzo_bytep a_c_lzo_bytep;
  4073. }
  4074. lzo_full_align_t;
  4075. #ifdef __cplusplus
  4076. }
  4077. #endif
  4078. #endif
  4079. #ifndef LZO_DETERMINISTIC
  4080. #define LZO_DETERMINISTIC 1
  4081. #endif
  4082. #ifndef LZO_DICT_USE_PTR
  4083. #define LZO_DICT_USE_PTR 1
  4084. #endif
  4085. #if (LZO_DICT_USE_PTR)
  4086. # define lzo_dict_t const lzo_bytep
  4087. # define lzo_dict_p lzo_dict_t *
  4088. #else
  4089. # define lzo_dict_t lzo_uint
  4090. # define lzo_dict_p lzo_dict_t *
  4091. #endif
  4092. #endif
  4093. #if !defined(MINILZO_CFG_SKIP_LZO_PTR)
  4094. LZO_PUBLIC(lzo_uintptr_t)
  4095. __lzo_ptr_linear(const lzo_voidp ptr)
  4096. {
  4097. lzo_uintptr_t p;
  4098. #if (LZO_ARCH_I086)
  4099. #error "LZO_ARCH_I086 is unsupported"
  4100. #elif (LZO_MM_PVP)
  4101. #error "LZO_MM_PVP is unsupported"
  4102. #else
  4103. p = (lzo_uintptr_t) PTR_LINEAR(ptr);
  4104. #endif
  4105. return p;
  4106. }
  4107. LZO_PUBLIC(unsigned)
  4108. __lzo_align_gap(const lzo_voidp ptr, lzo_uint size)
  4109. {
  4110. #if (__LZO_UINTPTR_T_IS_POINTER)
  4111. #error "__LZO_UINTPTR_T_IS_POINTER is unsupported"
  4112. #else
  4113. lzo_uintptr_t p, n;
  4114. if (size < 2) return 0;
  4115. p = __lzo_ptr_linear(ptr);
  4116. #if 0
  4117. n = (((p + size - 1) / size) * size) - p;
  4118. #else
  4119. if ((size & (size - 1)) != 0)
  4120. return 0;
  4121. n = size; n = ((p + n - 1) & ~(n - 1)) - p;
  4122. #endif
  4123. #endif
  4124. assert((long)n >= 0);
  4125. assert(n <= size);
  4126. return (unsigned)n;
  4127. }
  4128. #endif
  4129. #if !defined(MINILZO_CFG_SKIP_LZO_UTIL)
  4130. /* If you use the LZO library in a product, I would appreciate that you
  4131. * keep this copyright string in the executable of your product.
  4132. */
  4133. static const char lzo_copyright_[] =
  4134. #if !defined(__LZO_IN_MINLZO)
  4135. LZO_VERSION_STRING;
  4136. #else
  4137. "\r\n\n"
  4138. "LZO data compression library.\n"
  4139. "$Copyright: LZO Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer\n"
  4140. "<markus@oberhumer.com>\n"
  4141. "http://www.oberhumer.com $\n\n"
  4142. "$Id: LZO version: v" LZO_VERSION_STRING ", " LZO_VERSION_DATE " $\n"
  4143. "$Info: " LZO_INFO_STRING " $\n";
  4144. #endif
  4145. static const char lzo_version_string_[] = LZO_VERSION_STRING;
  4146. static const char lzo_version_date_[] = LZO_VERSION_DATE;
  4147. LZO_PUBLIC(const lzo_bytep)
  4148. lzo_copyright(void)
  4149. {
  4150. return (const lzo_bytep) lzo_copyright_;
  4151. }
  4152. LZO_PUBLIC(unsigned)
  4153. lzo_version(void)
  4154. {
  4155. return LZO_VERSION;
  4156. }
  4157. LZO_PUBLIC(const char *)
  4158. lzo_version_string(void)
  4159. {
  4160. return lzo_version_string_;
  4161. }
  4162. LZO_PUBLIC(const char *)
  4163. lzo_version_date(void)
  4164. {
  4165. return lzo_version_date_;
  4166. }
  4167. LZO_PUBLIC(const lzo_charp)
  4168. _lzo_version_string(void)
  4169. {
  4170. return lzo_version_string_;
  4171. }
  4172. LZO_PUBLIC(const lzo_charp)
  4173. _lzo_version_date(void)
  4174. {
  4175. return lzo_version_date_;
  4176. }
  4177. #define LZO_BASE 65521u
  4178. #define LZO_NMAX 5552
  4179. #define LZO_DO1(buf,i) s1 += buf[i]; s2 += s1
  4180. #define LZO_DO2(buf,i) LZO_DO1(buf,i); LZO_DO1(buf,i+1)
  4181. #define LZO_DO4(buf,i) LZO_DO2(buf,i); LZO_DO2(buf,i+2)
  4182. #define LZO_DO8(buf,i) LZO_DO4(buf,i); LZO_DO4(buf,i+4)
  4183. #define LZO_DO16(buf,i) LZO_DO8(buf,i); LZO_DO8(buf,i+8)
  4184. LZO_PUBLIC(lzo_uint32_t)
  4185. lzo_adler32(lzo_uint32_t adler, const lzo_bytep buf, lzo_uint len)
  4186. {
  4187. lzo_uint32_t s1 = adler & 0xffff;
  4188. lzo_uint32_t s2 = (adler >> 16) & 0xffff;
  4189. unsigned k;
  4190. if (buf == NULL)
  4191. return 1;
  4192. while (len > 0)
  4193. {
  4194. k = len < LZO_NMAX ? (unsigned) len : LZO_NMAX;
  4195. len -= k;
  4196. if (k >= 16) do
  4197. {
  4198. LZO_DO16(buf,0);
  4199. buf += 16;
  4200. k -= 16;
  4201. } while (k >= 16);
  4202. if (k != 0) do
  4203. {
  4204. s1 += *buf++;
  4205. s2 += s1;
  4206. } while (--k > 0);
  4207. s1 %= LZO_BASE;
  4208. s2 %= LZO_BASE;
  4209. }
  4210. return (s2 << 16) | s1;
  4211. }
  4212. #undef LZO_DO1
  4213. #undef LZO_DO2
  4214. #undef LZO_DO4
  4215. #undef LZO_DO8
  4216. #undef LZO_DO16
  4217. #endif
  4218. #if !defined(MINILZO_CFG_SKIP_LZO_STRING)
  4219. #undef lzo_memcmp
  4220. #undef lzo_memcpy
  4221. #undef lzo_memmove
  4222. #undef lzo_memset
  4223. #if !defined(__LZO_MMODEL_HUGE)
  4224. # undef LZO_HAVE_MM_HUGE_PTR
  4225. #endif
  4226. #define lzo_hsize_t lzo_uint
  4227. #define lzo_hvoid_p lzo_voidp
  4228. #define lzo_hbyte_p lzo_bytep
  4229. #define LZOLIB_PUBLIC(r,f) LZO_PUBLIC(r) f
  4230. #define lzo_hmemcmp lzo_memcmp
  4231. #define lzo_hmemcpy lzo_memcpy
  4232. #define lzo_hmemmove lzo_memmove
  4233. #define lzo_hmemset lzo_memset
  4234. #define __LZOLIB_HMEMCPY_CH_INCLUDED 1
  4235. #if !defined(LZOLIB_PUBLIC)
  4236. # define LZOLIB_PUBLIC(r,f) r __LZOLIB_FUNCNAME(f)
  4237. #endif
  4238. LZOLIB_PUBLIC(int, lzo_hmemcmp) (const lzo_hvoid_p s1, const lzo_hvoid_p s2, lzo_hsize_t len)
  4239. {
  4240. #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMCMP)
  4241. const lzo_hbyte_p p1 = LZO_STATIC_CAST(const lzo_hbyte_p, s1);
  4242. const lzo_hbyte_p p2 = LZO_STATIC_CAST(const lzo_hbyte_p, s2);
  4243. if __lzo_likely(len > 0) do
  4244. {
  4245. int d = *p1 - *p2;
  4246. if (d != 0)
  4247. return d;
  4248. p1++; p2++;
  4249. } while __lzo_likely(--len > 0);
  4250. return 0;
  4251. #else
  4252. return memcmp(s1, s2, len);
  4253. #endif
  4254. }
  4255. LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemcpy) (lzo_hvoid_p dest, const lzo_hvoid_p src, lzo_hsize_t len)
  4256. {
  4257. #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMCPY)
  4258. lzo_hbyte_p p1 = LZO_STATIC_CAST(lzo_hbyte_p, dest);
  4259. const lzo_hbyte_p p2 = LZO_STATIC_CAST(const lzo_hbyte_p, src);
  4260. if (!(len > 0) || p1 == p2)
  4261. return dest;
  4262. do
  4263. *p1++ = *p2++;
  4264. while __lzo_likely(--len > 0);
  4265. return dest;
  4266. #else
  4267. return memcpy(dest, src, len);
  4268. #endif
  4269. }
  4270. LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemmove) (lzo_hvoid_p dest, const lzo_hvoid_p src, lzo_hsize_t len)
  4271. {
  4272. #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMMOVE)
  4273. lzo_hbyte_p p1 = LZO_STATIC_CAST(lzo_hbyte_p, dest);
  4274. const lzo_hbyte_p p2 = LZO_STATIC_CAST(const lzo_hbyte_p, src);
  4275. if (!(len > 0) || p1 == p2)
  4276. return dest;
  4277. if (p1 < p2)
  4278. {
  4279. do
  4280. *p1++ = *p2++;
  4281. while __lzo_likely(--len > 0);
  4282. }
  4283. else
  4284. {
  4285. p1 += len;
  4286. p2 += len;
  4287. do
  4288. *--p1 = *--p2;
  4289. while __lzo_likely(--len > 0);
  4290. }
  4291. return dest;
  4292. #else
  4293. return memmove(dest, src, len);
  4294. #endif
  4295. }
  4296. LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemset) (lzo_hvoid_p s, int cc, lzo_hsize_t len)
  4297. {
  4298. #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMSET)
  4299. lzo_hbyte_p p = LZO_STATIC_CAST(lzo_hbyte_p, s);
  4300. unsigned char c = LZO_ITRUNC(unsigned char, cc);
  4301. if __lzo_likely(len > 0) do
  4302. *p++ = c;
  4303. while __lzo_likely(--len > 0);
  4304. return s;
  4305. #else
  4306. return memset(s, cc, len);
  4307. #endif
  4308. }
  4309. #undef LZOLIB_PUBLIC
  4310. #endif
  4311. #if !defined(MINILZO_CFG_SKIP_LZO_INIT)
  4312. #if !defined(__LZO_IN_MINILZO)
  4313. #define LZO_WANT_ACC_CHK_CH 1
  4314. #undef LZOCHK_ASSERT
  4315. LZOCHK_ASSERT((LZO_UINT32_C(1) << (int)(8*sizeof(LZO_UINT32_C(1))-1)) > 0)
  4316. LZOCHK_ASSERT_IS_SIGNED_T(lzo_int)
  4317. LZOCHK_ASSERT_IS_UNSIGNED_T(lzo_uint)
  4318. #if !(__LZO_UINTPTR_T_IS_POINTER)
  4319. LZOCHK_ASSERT_IS_UNSIGNED_T(lzo_uintptr_t)
  4320. #endif
  4321. LZOCHK_ASSERT(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp))
  4322. LZOCHK_ASSERT_IS_UNSIGNED_T(lzo_xint)
  4323. #endif
  4324. #undef LZOCHK_ASSERT
  4325. union lzo_config_check_union {
  4326. lzo_uint a[2];
  4327. unsigned char b[2*LZO_MAX(8,sizeof(lzo_uint))];
  4328. #if defined(lzo_uint64_t)
  4329. lzo_uint64_t c[2];
  4330. #endif
  4331. };
  4332. #if 0
  4333. #define u2p(ptr,off) ((lzo_voidp) (((lzo_bytep)(lzo_voidp)(ptr)) + (off)))
  4334. #else
  4335. static __lzo_noinline lzo_voidp u2p(lzo_voidp ptr, lzo_uint off)
  4336. {
  4337. return (lzo_voidp) ((lzo_bytep) ptr + off);
  4338. }
  4339. #endif
  4340. LZO_PUBLIC(int)
  4341. _lzo_config_check(void)
  4342. {
  4343. #if (LZO_CC_CLANG && (LZO_CC_CLANG >= 0x030100ul && LZO_CC_CLANG < 0x030300ul))
  4344. # if 0
  4345. volatile
  4346. # endif
  4347. #endif
  4348. union lzo_config_check_union u;
  4349. lzo_voidp p;
  4350. unsigned r = 1;
  4351. u.a[0] = u.a[1] = 0;
  4352. p = u2p(&u, 0);
  4353. r &= ((* (lzo_bytep) p) == 0);
  4354. #if !(LZO_CFG_NO_CONFIG_CHECK)
  4355. #if (LZO_ABI_BIG_ENDIAN)
  4356. u.a[0] = u.a[1] = 0; u.b[sizeof(lzo_uint) - 1] = 128;
  4357. p = u2p(&u, 0);
  4358. r &= ((* (lzo_uintp) p) == 128);
  4359. #endif
  4360. #if (LZO_ABI_LITTLE_ENDIAN)
  4361. u.a[0] = u.a[1] = 0; u.b[0] = 128;
  4362. p = u2p(&u, 0);
  4363. r &= ((* (lzo_uintp) p) == 128);
  4364. #endif
  4365. u.a[0] = u.a[1] = 0;
  4366. u.b[0] = 1; u.b[3] = 2;
  4367. p = u2p(&u, 1);
  4368. r &= UA_GET_NE16(p) == 0;
  4369. r &= UA_GET_LE16(p) == 0;
  4370. u.b[1] = 128;
  4371. r &= UA_GET_LE16(p) == 128;
  4372. u.b[2] = 129;
  4373. r &= UA_GET_LE16(p) == LZO_UINT16_C(0x8180);
  4374. #if (LZO_ABI_BIG_ENDIAN)
  4375. r &= UA_GET_NE16(p) == LZO_UINT16_C(0x8081);
  4376. #endif
  4377. #if (LZO_ABI_LITTLE_ENDIAN)
  4378. r &= UA_GET_NE16(p) == LZO_UINT16_C(0x8180);
  4379. #endif
  4380. u.a[0] = u.a[1] = 0;
  4381. u.b[0] = 3; u.b[5] = 4;
  4382. p = u2p(&u, 1);
  4383. r &= UA_GET_NE32(p) == 0;
  4384. r &= UA_GET_LE32(p) == 0;
  4385. u.b[1] = 128;
  4386. r &= UA_GET_LE32(p) == 128;
  4387. u.b[2] = 129; u.b[3] = 130; u.b[4] = 131;
  4388. r &= UA_GET_LE32(p) == LZO_UINT32_C(0x83828180);
  4389. #if (LZO_ABI_BIG_ENDIAN)
  4390. r &= UA_GET_NE32(p) == LZO_UINT32_C(0x80818283);
  4391. #endif
  4392. #if (LZO_ABI_LITTLE_ENDIAN)
  4393. r &= UA_GET_NE32(p) == LZO_UINT32_C(0x83828180);
  4394. #endif
  4395. #if defined(UA_GET_NE64)
  4396. u.c[0] = u.c[1] = 0;
  4397. u.b[0] = 5; u.b[9] = 6;
  4398. p = u2p(&u, 1);
  4399. u.c[0] = u.c[1] = 0;
  4400. r &= UA_GET_NE64(p) == 0;
  4401. #if defined(UA_GET_LE64)
  4402. r &= UA_GET_LE64(p) == 0;
  4403. u.b[1] = 128;
  4404. r &= UA_GET_LE64(p) == 128;
  4405. #endif
  4406. #endif
  4407. #if defined(lzo_bitops_ctlz32)
  4408. { unsigned i = 0; lzo_uint32_t v;
  4409. for (v = 1; v != 0 && r == 1; v <<= 1, i++) {
  4410. r &= lzo_bitops_ctlz32(v) == 31 - i;
  4411. r &= lzo_bitops_ctlz32_func(v) == 31 - i;
  4412. }}
  4413. #endif
  4414. #if defined(lzo_bitops_ctlz64)
  4415. { unsigned i = 0; lzo_uint64_t v;
  4416. for (v = 1; v != 0 && r == 1; v <<= 1, i++) {
  4417. r &= lzo_bitops_ctlz64(v) == 63 - i;
  4418. r &= lzo_bitops_ctlz64_func(v) == 63 - i;
  4419. }}
  4420. #endif
  4421. #if defined(lzo_bitops_cttz32)
  4422. { unsigned i = 0; lzo_uint32_t v;
  4423. for (v = 1; v != 0 && r == 1; v <<= 1, i++) {
  4424. r &= lzo_bitops_cttz32(v) == i;
  4425. r &= lzo_bitops_cttz32_func(v) == i;
  4426. }}
  4427. #endif
  4428. #if defined(lzo_bitops_cttz64)
  4429. { unsigned i = 0; lzo_uint64_t v;
  4430. for (v = 1; v != 0 && r == 1; v <<= 1, i++) {
  4431. r &= lzo_bitops_cttz64(v) == i;
  4432. r &= lzo_bitops_cttz64_func(v) == i;
  4433. }}
  4434. #endif
  4435. #endif
  4436. LZO_UNUSED_FUNC(lzo_bitops_unused_funcs);
  4437. return r == 1 ? LZO_E_OK : LZO_E_ERROR;
  4438. }
  4439. LZO_PUBLIC(int)
  4440. __lzo_init_v2(unsigned v, int s1, int s2, int s3, int s4, int s5,
  4441. int s6, int s7, int s8, int s9)
  4442. {
  4443. int r;
  4444. #if defined(__LZO_IN_MINILZO)
  4445. #elif (LZO_CC_MSC && ((_MSC_VER) < 700))
  4446. #else
  4447. #define LZO_WANT_ACC_CHK_CH 1
  4448. #undef LZOCHK_ASSERT
  4449. #define LZOCHK_ASSERT(expr) LZO_COMPILE_TIME_ASSERT(expr)
  4450. #endif
  4451. #undef LZOCHK_ASSERT
  4452. if (v == 0)
  4453. return LZO_E_ERROR;
  4454. r = (s1 == -1 || s1 == (int) sizeof(short)) &&
  4455. (s2 == -1 || s2 == (int) sizeof(int)) &&
  4456. (s3 == -1 || s3 == (int) sizeof(long)) &&
  4457. (s4 == -1 || s4 == (int) sizeof(lzo_uint32_t)) &&
  4458. (s5 == -1 || s5 == (int) sizeof(lzo_uint)) &&
  4459. (s6 == -1 || s6 == (int) lzo_sizeof_dict_t) &&
  4460. (s7 == -1 || s7 == (int) sizeof(char *)) &&
  4461. (s8 == -1 || s8 == (int) sizeof(lzo_voidp)) &&
  4462. (s9 == -1 || s9 == (int) sizeof(lzo_callback_t));
  4463. if (!r)
  4464. return LZO_E_ERROR;
  4465. r = _lzo_config_check();
  4466. if (r != LZO_E_OK)
  4467. return r;
  4468. return r;
  4469. }
  4470. #if !defined(__LZO_IN_MINILZO)
  4471. #if (LZO_OS_WIN16 && LZO_CC_WATCOMC) && defined(__SW_BD)
  4472. #if 0
  4473. BOOL FAR PASCAL LibMain ( HANDLE hInstance, WORD wDataSegment,
  4474. WORD wHeapSize, LPSTR lpszCmdLine )
  4475. #else
  4476. int __far __pascal LibMain ( int a, short b, short c, long d )
  4477. #endif
  4478. {
  4479. LZO_UNUSED(a); LZO_UNUSED(b); LZO_UNUSED(c); LZO_UNUSED(d);
  4480. return 1;
  4481. }
  4482. #endif
  4483. #endif
  4484. #endif
  4485. #define LZO1X 1
  4486. #define LZO_EOF_CODE 1
  4487. #define M2_MAX_OFFSET 0x0800
  4488. #if !defined(MINILZO_CFG_SKIP_LZO1X_1_COMPRESS)
  4489. #if 1 && defined(UA_GET_LE32)
  4490. #undef LZO_DICT_USE_PTR
  4491. #define LZO_DICT_USE_PTR 0
  4492. #undef lzo_dict_t
  4493. #define lzo_dict_t lzo_uint16_t
  4494. #endif
  4495. #define LZO_NEED_DICT_H 1
  4496. #ifndef D_BITS
  4497. #define D_BITS 14
  4498. #endif
  4499. #define D_INDEX1(d,p) d = DM(DMUL(0x21,DX3(p,5,5,6)) >> 5)
  4500. #define D_INDEX2(d,p) d = (d & (D_MASK & 0x7ff)) ^ (D_HIGH | 0x1f)
  4501. #if 1
  4502. #define DINDEX(dv,p) DM(((DMUL(0x1824429d,dv)) >> (32-D_BITS)))
  4503. #else
  4504. #define DINDEX(dv,p) DM((dv) + ((dv) >> (32-D_BITS)))
  4505. #endif
  4506. #ifndef __LZO_CONFIG1X_H
  4507. #define __LZO_CONFIG1X_H 1
  4508. #if !defined(LZO1X) && !defined(LZO1Y) && !defined(LZO1Z)
  4509. # define LZO1X 1
  4510. #endif
  4511. #if !defined(__LZO_IN_MINILZO)
  4512. #include <lzo/lzo1x.h>
  4513. #endif
  4514. #ifndef LZO_EOF_CODE
  4515. #define LZO_EOF_CODE 1
  4516. #endif
  4517. #undef LZO_DETERMINISTIC
  4518. #define M1_MAX_OFFSET 0x0400
  4519. #ifndef M2_MAX_OFFSET
  4520. #define M2_MAX_OFFSET 0x0800
  4521. #endif
  4522. #define M3_MAX_OFFSET 0x4000
  4523. #define M4_MAX_OFFSET 0xbfff
  4524. #define MX_MAX_OFFSET (M1_MAX_OFFSET + M2_MAX_OFFSET)
  4525. #define M1_MIN_LEN 2
  4526. #define M1_MAX_LEN 2
  4527. #define M2_MIN_LEN 3
  4528. #ifndef M2_MAX_LEN
  4529. #define M2_MAX_LEN 8
  4530. #endif
  4531. #define M3_MIN_LEN 3
  4532. #define M3_MAX_LEN 33
  4533. #define M4_MIN_LEN 3
  4534. #define M4_MAX_LEN 9
  4535. #define M1_MARKER 0
  4536. #define M2_MARKER 64
  4537. #define M3_MARKER 32
  4538. #define M4_MARKER 16
  4539. #ifndef MIN_LOOKAHEAD
  4540. #define MIN_LOOKAHEAD (M2_MAX_LEN + 1)
  4541. #endif
  4542. #if defined(LZO_NEED_DICT_H)
  4543. #ifndef LZO_HASH
  4544. #define LZO_HASH LZO_HASH_LZO_INCREMENTAL_B
  4545. #endif
  4546. #define DL_MIN_LEN M2_MIN_LEN
  4547. #ifndef __LZO_DICT_H
  4548. #define __LZO_DICT_H 1
  4549. #ifdef __cplusplus
  4550. extern "C" {
  4551. #endif
  4552. #if !defined(D_BITS) && defined(DBITS)
  4553. # define D_BITS DBITS
  4554. #endif
  4555. #if !defined(D_BITS)
  4556. # error "D_BITS is not defined"
  4557. #endif
  4558. #if (D_BITS < 16)
  4559. # define D_SIZE LZO_SIZE(D_BITS)
  4560. # define D_MASK LZO_MASK(D_BITS)
  4561. #else
  4562. # define D_SIZE LZO_USIZE(D_BITS)
  4563. # define D_MASK LZO_UMASK(D_BITS)
  4564. #endif
  4565. #define D_HIGH ((D_MASK >> 1) + 1)
  4566. #if !defined(DD_BITS)
  4567. # define DD_BITS 0
  4568. #endif
  4569. #define DD_SIZE LZO_SIZE(DD_BITS)
  4570. #define DD_MASK LZO_MASK(DD_BITS)
  4571. #if !defined(DL_BITS)
  4572. # define DL_BITS (D_BITS - DD_BITS)
  4573. #endif
  4574. #if (DL_BITS < 16)
  4575. # define DL_SIZE LZO_SIZE(DL_BITS)
  4576. # define DL_MASK LZO_MASK(DL_BITS)
  4577. #else
  4578. # define DL_SIZE LZO_USIZE(DL_BITS)
  4579. # define DL_MASK LZO_UMASK(DL_BITS)
  4580. #endif
  4581. #if (D_BITS != DL_BITS + DD_BITS)
  4582. # error "D_BITS does not match"
  4583. #endif
  4584. #if (D_BITS < 6 || D_BITS > 18)
  4585. # error "invalid D_BITS"
  4586. #endif
  4587. #if (DL_BITS < 6 || DL_BITS > 20)
  4588. # error "invalid DL_BITS"
  4589. #endif
  4590. #if (DD_BITS < 0 || DD_BITS > 6)
  4591. # error "invalid DD_BITS"
  4592. #endif
  4593. #if !defined(DL_MIN_LEN)
  4594. # define DL_MIN_LEN 3
  4595. #endif
  4596. #if !defined(DL_SHIFT)
  4597. # define DL_SHIFT ((DL_BITS + (DL_MIN_LEN - 1)) / DL_MIN_LEN)
  4598. #endif
  4599. #define LZO_HASH_GZIP 1
  4600. #define LZO_HASH_GZIP_INCREMENTAL 2
  4601. #define LZO_HASH_LZO_INCREMENTAL_A 3
  4602. #define LZO_HASH_LZO_INCREMENTAL_B 4
  4603. #if !defined(LZO_HASH)
  4604. # error "choose a hashing strategy"
  4605. #endif
  4606. #undef DM
  4607. #undef DX
  4608. #if (DL_MIN_LEN == 3)
  4609. # define _DV2_A(p,shift1,shift2) \
  4610. (((( (lzo_xint)((p)[0]) << shift1) ^ (p)[1]) << shift2) ^ (p)[2])
  4611. # define _DV2_B(p,shift1,shift2) \
  4612. (((( (lzo_xint)((p)[2]) << shift1) ^ (p)[1]) << shift2) ^ (p)[0])
  4613. # define _DV3_B(p,shift1,shift2,shift3) \
  4614. ((_DV2_B((p)+1,shift1,shift2) << (shift3)) ^ (p)[0])
  4615. #elif (DL_MIN_LEN == 2)
  4616. # define _DV2_A(p,shift1,shift2) \
  4617. (( (lzo_xint)(p[0]) << shift1) ^ p[1])
  4618. # define _DV2_B(p,shift1,shift2) \
  4619. (( (lzo_xint)(p[1]) << shift1) ^ p[2])
  4620. #else
  4621. # error "invalid DL_MIN_LEN"
  4622. #endif
  4623. #define _DV_A(p,shift) _DV2_A(p,shift,shift)
  4624. #define _DV_B(p,shift) _DV2_B(p,shift,shift)
  4625. #define DA2(p,s1,s2) \
  4626. (((((lzo_xint)((p)[2]) << (s2)) + (p)[1]) << (s1)) + (p)[0])
  4627. #define DS2(p,s1,s2) \
  4628. (((((lzo_xint)((p)[2]) << (s2)) - (p)[1]) << (s1)) - (p)[0])
  4629. #define DX2(p,s1,s2) \
  4630. (((((lzo_xint)((p)[2]) << (s2)) ^ (p)[1]) << (s1)) ^ (p)[0])
  4631. #define DA3(p,s1,s2,s3) ((DA2((p)+1,s2,s3) << (s1)) + (p)[0])
  4632. #define DS3(p,s1,s2,s3) ((DS2((p)+1,s2,s3) << (s1)) - (p)[0])
  4633. #define DX3(p,s1,s2,s3) ((DX2((p)+1,s2,s3) << (s1)) ^ (p)[0])
  4634. #define DMS(v,s) ((lzo_uint) (((v) & (D_MASK >> (s))) << (s)))
  4635. #define DM(v) DMS(v,0)
  4636. #if (LZO_HASH == LZO_HASH_GZIP)
  4637. # define _DINDEX(dv,p) (_DV_A((p),DL_SHIFT))
  4638. #elif (LZO_HASH == LZO_HASH_GZIP_INCREMENTAL)
  4639. # define __LZO_HASH_INCREMENTAL 1
  4640. # define DVAL_FIRST(dv,p) dv = _DV_A((p),DL_SHIFT)
  4641. # define DVAL_NEXT(dv,p) dv = (((dv) << DL_SHIFT) ^ p[2])
  4642. # define _DINDEX(dv,p) (dv)
  4643. # define DVAL_LOOKAHEAD DL_MIN_LEN
  4644. #elif (LZO_HASH == LZO_HASH_LZO_INCREMENTAL_A)
  4645. # define __LZO_HASH_INCREMENTAL 1
  4646. # define DVAL_FIRST(dv,p) dv = _DV_A((p),5)
  4647. # define DVAL_NEXT(dv,p) \
  4648. dv ^= (lzo_xint)(p[-1]) << (2*5); dv = (((dv) << 5) ^ p[2])
  4649. # define _DINDEX(dv,p) ((DMUL(0x9f5f,dv)) >> 5)
  4650. # define DVAL_LOOKAHEAD DL_MIN_LEN
  4651. #elif (LZO_HASH == LZO_HASH_LZO_INCREMENTAL_B)
  4652. # define __LZO_HASH_INCREMENTAL 1
  4653. # define DVAL_FIRST(dv,p) dv = _DV_B((p),5)
  4654. # define DVAL_NEXT(dv,p) \
  4655. dv ^= p[-1]; dv = (((dv) >> 5) ^ ((lzo_xint)(p[2]) << (2*5)))
  4656. # define _DINDEX(dv,p) ((DMUL(0x9f5f,dv)) >> 5)
  4657. # define DVAL_LOOKAHEAD DL_MIN_LEN
  4658. #else
  4659. # error "choose a hashing strategy"
  4660. #endif
  4661. #ifndef DINDEX
  4662. #define DINDEX(dv,p) ((lzo_uint)((_DINDEX(dv,p)) & DL_MASK) << DD_BITS)
  4663. #endif
  4664. #if !defined(DINDEX1) && defined(D_INDEX1)
  4665. #define DINDEX1 D_INDEX1
  4666. #endif
  4667. #if !defined(DINDEX2) && defined(D_INDEX2)
  4668. #define DINDEX2 D_INDEX2
  4669. #endif
  4670. #if !defined(__LZO_HASH_INCREMENTAL)
  4671. # define DVAL_FIRST(dv,p) ((void) 0)
  4672. # define DVAL_NEXT(dv,p) ((void) 0)
  4673. # define DVAL_LOOKAHEAD 0
  4674. #endif
  4675. #if !defined(DVAL_ASSERT)
  4676. #if defined(__LZO_HASH_INCREMENTAL) && !defined(NDEBUG)
  4677. #if 1 && (LZO_CC_ARMCC_GNUC || LZO_CC_CLANG || (LZO_CC_GNUC >= 0x020700ul) || LZO_CC_INTELC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI)
  4678. static void __attribute__((__unused__))
  4679. #else
  4680. static void
  4681. #endif
  4682. DVAL_ASSERT(lzo_xint dv, const lzo_bytep p)
  4683. {
  4684. lzo_xint df;
  4685. DVAL_FIRST(df,(p));
  4686. assert(DINDEX(dv,p) == DINDEX(df,p));
  4687. }
  4688. #else
  4689. # define DVAL_ASSERT(dv,p) ((void) 0)
  4690. #endif
  4691. #endif
  4692. #if (LZO_DICT_USE_PTR)
  4693. # define DENTRY(p,in) (p)
  4694. # define GINDEX(m_pos,m_off,dict,dindex,in) m_pos = dict[dindex]
  4695. #else
  4696. # define DENTRY(p,in) ((lzo_dict_t) pd(p, in))
  4697. # define GINDEX(m_pos,m_off,dict,dindex,in) m_off = dict[dindex]
  4698. #endif
  4699. #if (DD_BITS == 0)
  4700. # define UPDATE_D(dict,drun,dv,p,in) dict[ DINDEX(dv,p) ] = DENTRY(p,in)
  4701. # define UPDATE_I(dict,drun,index,p,in) dict[index] = DENTRY(p,in)
  4702. # define UPDATE_P(ptr,drun,p,in) (ptr)[0] = DENTRY(p,in)
  4703. #else
  4704. # define UPDATE_D(dict,drun,dv,p,in) \
  4705. dict[ DINDEX(dv,p) + drun++ ] = DENTRY(p,in); drun &= DD_MASK
  4706. # define UPDATE_I(dict,drun,index,p,in) \
  4707. dict[ (index) + drun++ ] = DENTRY(p,in); drun &= DD_MASK
  4708. # define UPDATE_P(ptr,drun,p,in) \
  4709. (ptr) [ drun++ ] = DENTRY(p,in); drun &= DD_MASK
  4710. #endif
  4711. #if (LZO_DICT_USE_PTR)
  4712. #define LZO_CHECK_MPOS_DET(m_pos,m_off,in,ip,max_offset) \
  4713. (m_pos == NULL || (m_off = pd(ip, m_pos)) > max_offset)
  4714. #define LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,max_offset) \
  4715. (BOUNDS_CHECKING_OFF_IN_EXPR(( \
  4716. m_pos = ip - (lzo_uint) PTR_DIFF(ip,m_pos), \
  4717. PTR_LT(m_pos,in) || \
  4718. (m_off = (lzo_uint) PTR_DIFF(ip,m_pos)) == 0 || \
  4719. m_off > max_offset )))
  4720. #else
  4721. #define LZO_CHECK_MPOS_DET(m_pos,m_off,in,ip,max_offset) \
  4722. (m_off == 0 || \
  4723. ((m_off = pd(ip, in) - m_off) > max_offset) || \
  4724. (m_pos = (ip) - (m_off), 0) )
  4725. #define LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,max_offset) \
  4726. (pd(ip, in) <= m_off || \
  4727. ((m_off = pd(ip, in) - m_off) > max_offset) || \
  4728. (m_pos = (ip) - (m_off), 0) )
  4729. #endif
  4730. #if (LZO_DETERMINISTIC)
  4731. # define LZO_CHECK_MPOS LZO_CHECK_MPOS_DET
  4732. #else
  4733. # define LZO_CHECK_MPOS LZO_CHECK_MPOS_NON_DET
  4734. #endif
  4735. #ifdef __cplusplus
  4736. }
  4737. #endif
  4738. #endif
  4739. #endif
  4740. #endif
  4741. #define LZO_DETERMINISTIC !(LZO_DICT_USE_PTR)
  4742. #ifndef DO_COMPRESS
  4743. #define DO_COMPRESS lzo1x_1_compress
  4744. #endif
  4745. #if 1 && defined(DO_COMPRESS) && !defined(do_compress)
  4746. # define do_compress LZO_PP_ECONCAT2(DO_COMPRESS,_core)
  4747. #endif
  4748. static __lzo_noinline lzo_uint
  4749. do_compress ( const lzo_bytep in , lzo_uint in_len,
  4750. lzo_bytep out, lzo_uintp out_len,
  4751. lzo_uint ti, lzo_voidp wrkmem)
  4752. {
  4753. const lzo_bytep ip;
  4754. lzo_bytep op;
  4755. const lzo_bytep const in_end = in + in_len;
  4756. const lzo_bytep const ip_end = in + in_len - 20;
  4757. const lzo_bytep ii;
  4758. lzo_dict_p const dict = (lzo_dict_p) wrkmem;
  4759. op = out;
  4760. ip = in;
  4761. ii = ip;
  4762. ip += ti < 4 ? 4 - ti : 0;
  4763. for (;;)
  4764. {
  4765. const lzo_bytep m_pos;
  4766. #if !(LZO_DETERMINISTIC)
  4767. LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
  4768. lzo_uint m_len;
  4769. lzo_uint dindex;
  4770. next:
  4771. if __lzo_unlikely(ip >= ip_end)
  4772. break;
  4773. DINDEX1(dindex,ip);
  4774. GINDEX(m_pos,m_off,dict,dindex,in);
  4775. if (LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,M4_MAX_OFFSET))
  4776. goto literal;
  4777. #if 1
  4778. if (m_off <= M2_MAX_OFFSET || m_pos[3] == ip[3])
  4779. goto try_match;
  4780. DINDEX2(dindex,ip);
  4781. #endif
  4782. GINDEX(m_pos,m_off,dict,dindex,in);
  4783. if (LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,M4_MAX_OFFSET))
  4784. goto literal;
  4785. if (m_off <= M2_MAX_OFFSET || m_pos[3] == ip[3])
  4786. goto try_match;
  4787. goto literal;
  4788. try_match:
  4789. #if (LZO_OPT_UNALIGNED32)
  4790. if (UA_GET_NE32(m_pos) != UA_GET_NE32(ip))
  4791. #else
  4792. if (m_pos[0] != ip[0] || m_pos[1] != ip[1] || m_pos[2] != ip[2] || m_pos[3] != ip[3])
  4793. #endif
  4794. {
  4795. literal:
  4796. UPDATE_I(dict,0,dindex,ip,in);
  4797. ip += 1 + ((ip - ii) >> 5);
  4798. continue;
  4799. }
  4800. UPDATE_I(dict,0,dindex,ip,in);
  4801. #else
  4802. lzo_uint m_off;
  4803. lzo_uint m_len;
  4804. {
  4805. lzo_uint32_t dv;
  4806. lzo_uint dindex;
  4807. literal:
  4808. ip += 1 + ((ip - ii) >> 5);
  4809. next:
  4810. if __lzo_unlikely(ip >= ip_end)
  4811. break;
  4812. dv = UA_GET_LE32(ip);
  4813. dindex = DINDEX(dv,ip);
  4814. GINDEX(m_off,m_pos,in+dict,dindex,in);
  4815. UPDATE_I(dict,0,dindex,ip,in);
  4816. if __lzo_unlikely(dv != UA_GET_LE32(m_pos))
  4817. goto literal;
  4818. }
  4819. #endif
  4820. ii -= ti; ti = 0;
  4821. {
  4822. lzo_uint t = pd(ip,ii);
  4823. if (t != 0)
  4824. {
  4825. if (t <= 3)
  4826. {
  4827. op[-2] = LZO_BYTE(op[-2] | t);
  4828. #if (LZO_OPT_UNALIGNED32)
  4829. UA_COPY4(op, ii);
  4830. op += t;
  4831. #else
  4832. { do *op++ = *ii++; while (--t > 0); }
  4833. #endif
  4834. }
  4835. #if (LZO_OPT_UNALIGNED32) || (LZO_OPT_UNALIGNED64)
  4836. else if (t <= 16)
  4837. {
  4838. *op++ = LZO_BYTE(t - 3);
  4839. UA_COPY8(op, ii);
  4840. UA_COPY8(op+8, ii+8);
  4841. op += t;
  4842. }
  4843. #endif
  4844. else
  4845. {
  4846. if (t <= 18)
  4847. *op++ = LZO_BYTE(t - 3);
  4848. else
  4849. {
  4850. lzo_uint tt = t - 18;
  4851. *op++ = 0;
  4852. while __lzo_unlikely(tt > 255)
  4853. {
  4854. tt -= 255;
  4855. UA_SET1(op, 0);
  4856. op++;
  4857. }
  4858. assert(tt > 0);
  4859. *op++ = LZO_BYTE(tt);
  4860. }
  4861. #if (LZO_OPT_UNALIGNED32) || (LZO_OPT_UNALIGNED64)
  4862. do {
  4863. UA_COPY8(op, ii);
  4864. UA_COPY8(op+8, ii+8);
  4865. op += 16; ii += 16; t -= 16;
  4866. } while (t >= 16); if (t > 0)
  4867. #endif
  4868. { do *op++ = *ii++; while (--t > 0); }
  4869. }
  4870. }
  4871. }
  4872. m_len = 4;
  4873. {
  4874. #if (LZO_OPT_UNALIGNED64)
  4875. lzo_uint64_t v;
  4876. v = UA_GET_NE64(ip + m_len) ^ UA_GET_NE64(m_pos + m_len);
  4877. if __lzo_unlikely(v == 0) {
  4878. do {
  4879. m_len += 8;
  4880. v = UA_GET_NE64(ip + m_len) ^ UA_GET_NE64(m_pos + m_len);
  4881. if __lzo_unlikely(ip + m_len >= ip_end)
  4882. goto m_len_done;
  4883. } while (v == 0);
  4884. }
  4885. #if (LZO_ABI_BIG_ENDIAN) && defined(lzo_bitops_ctlz64)
  4886. m_len += lzo_bitops_ctlz64(v) / CHAR_BIT;
  4887. #elif (LZO_ABI_BIG_ENDIAN)
  4888. if ((v >> (64 - CHAR_BIT)) == 0) do {
  4889. v <<= CHAR_BIT;
  4890. m_len += 1;
  4891. } while ((v >> (64 - CHAR_BIT)) == 0);
  4892. #elif (LZO_ABI_LITTLE_ENDIAN) && defined(lzo_bitops_cttz64)
  4893. m_len += lzo_bitops_cttz64(v) / CHAR_BIT;
  4894. #elif (LZO_ABI_LITTLE_ENDIAN)
  4895. if ((v & UCHAR_MAX) == 0) do {
  4896. v >>= CHAR_BIT;
  4897. m_len += 1;
  4898. } while ((v & UCHAR_MAX) == 0);
  4899. #else
  4900. if (ip[m_len] == m_pos[m_len]) do {
  4901. m_len += 1;
  4902. } while (ip[m_len] == m_pos[m_len]);
  4903. #endif
  4904. #elif (LZO_OPT_UNALIGNED32)
  4905. lzo_uint32_t v;
  4906. v = UA_GET_NE32(ip + m_len) ^ UA_GET_NE32(m_pos + m_len);
  4907. if __lzo_unlikely(v == 0) {
  4908. do {
  4909. m_len += 4;
  4910. v = UA_GET_NE32(ip + m_len) ^ UA_GET_NE32(m_pos + m_len);
  4911. if (v != 0)
  4912. break;
  4913. m_len += 4;
  4914. v = UA_GET_NE32(ip + m_len) ^ UA_GET_NE32(m_pos + m_len);
  4915. if __lzo_unlikely(ip + m_len >= ip_end)
  4916. goto m_len_done;
  4917. } while (v == 0);
  4918. }
  4919. #if (LZO_ABI_BIG_ENDIAN) && defined(lzo_bitops_ctlz32)
  4920. m_len += lzo_bitops_ctlz32(v) / CHAR_BIT;
  4921. #elif (LZO_ABI_BIG_ENDIAN)
  4922. if ((v >> (32 - CHAR_BIT)) == 0) do {
  4923. v <<= CHAR_BIT;
  4924. m_len += 1;
  4925. } while ((v >> (32 - CHAR_BIT)) == 0);
  4926. #elif (LZO_ABI_LITTLE_ENDIAN) && defined(lzo_bitops_cttz32)
  4927. m_len += lzo_bitops_cttz32(v) / CHAR_BIT;
  4928. #elif (LZO_ABI_LITTLE_ENDIAN)
  4929. if ((v & UCHAR_MAX) == 0) do {
  4930. v >>= CHAR_BIT;
  4931. m_len += 1;
  4932. } while ((v & UCHAR_MAX) == 0);
  4933. #else
  4934. if (ip[m_len] == m_pos[m_len]) do {
  4935. m_len += 1;
  4936. } while (ip[m_len] == m_pos[m_len]);
  4937. #endif
  4938. #else
  4939. if __lzo_unlikely(ip[m_len] == m_pos[m_len]) {
  4940. do {
  4941. m_len += 1;
  4942. if (ip[m_len] != m_pos[m_len])
  4943. break;
  4944. m_len += 1;
  4945. if (ip[m_len] != m_pos[m_len])
  4946. break;
  4947. m_len += 1;
  4948. if (ip[m_len] != m_pos[m_len])
  4949. break;
  4950. m_len += 1;
  4951. if (ip[m_len] != m_pos[m_len])
  4952. break;
  4953. m_len += 1;
  4954. if (ip[m_len] != m_pos[m_len])
  4955. break;
  4956. m_len += 1;
  4957. if (ip[m_len] != m_pos[m_len])
  4958. break;
  4959. m_len += 1;
  4960. if (ip[m_len] != m_pos[m_len])
  4961. break;
  4962. m_len += 1;
  4963. if __lzo_unlikely(ip + m_len >= ip_end)
  4964. goto m_len_done;
  4965. } while (ip[m_len] == m_pos[m_len]);
  4966. }
  4967. #endif
  4968. }
  4969. m_len_done:
  4970. m_off = pd(ip,m_pos);
  4971. ip += m_len;
  4972. ii = ip;
  4973. if (m_len <= M2_MAX_LEN && m_off <= M2_MAX_OFFSET)
  4974. {
  4975. m_off -= 1;
  4976. #if defined(LZO1X)
  4977. *op++ = LZO_BYTE(((m_len - 1) << 5) | ((m_off & 7) << 2));
  4978. *op++ = LZO_BYTE(m_off >> 3);
  4979. #elif defined(LZO1Y)
  4980. *op++ = LZO_BYTE(((m_len + 1) << 4) | ((m_off & 3) << 2));
  4981. *op++ = LZO_BYTE(m_off >> 2);
  4982. #endif
  4983. }
  4984. else if (m_off <= M3_MAX_OFFSET)
  4985. {
  4986. m_off -= 1;
  4987. if (m_len <= M3_MAX_LEN)
  4988. *op++ = LZO_BYTE(M3_MARKER | (m_len - 2));
  4989. else
  4990. {
  4991. m_len -= M3_MAX_LEN;
  4992. *op++ = M3_MARKER | 0;
  4993. while __lzo_unlikely(m_len > 255)
  4994. {
  4995. m_len -= 255;
  4996. UA_SET1(op, 0);
  4997. op++;
  4998. }
  4999. *op++ = LZO_BYTE(m_len);
  5000. }
  5001. *op++ = LZO_BYTE(m_off << 2);
  5002. *op++ = LZO_BYTE(m_off >> 6);
  5003. }
  5004. else
  5005. {
  5006. m_off -= 0x4000;
  5007. if (m_len <= M4_MAX_LEN)
  5008. *op++ = LZO_BYTE(M4_MARKER | ((m_off >> 11) & 8) | (m_len - 2));
  5009. else
  5010. {
  5011. m_len -= M4_MAX_LEN;
  5012. *op++ = LZO_BYTE(M4_MARKER | ((m_off >> 11) & 8));
  5013. while __lzo_unlikely(m_len > 255)
  5014. {
  5015. m_len -= 255;
  5016. UA_SET1(op, 0);
  5017. op++;
  5018. }
  5019. *op++ = LZO_BYTE(m_len);
  5020. }
  5021. *op++ = LZO_BYTE(m_off << 2);
  5022. *op++ = LZO_BYTE(m_off >> 6);
  5023. }
  5024. goto next;
  5025. }
  5026. *out_len = pd(op, out);
  5027. return pd(in_end,ii-ti);
  5028. }
  5029. LZO_PUBLIC(int)
  5030. DO_COMPRESS ( const lzo_bytep in , lzo_uint in_len,
  5031. lzo_bytep out, lzo_uintp out_len,
  5032. lzo_voidp wrkmem )
  5033. {
  5034. const lzo_bytep ip = in;
  5035. lzo_bytep op = out;
  5036. lzo_uint l = in_len;
  5037. lzo_uint t = 0;
  5038. while (l > 20)
  5039. {
  5040. lzo_uint ll = l;
  5041. lzo_uintptr_t ll_end;
  5042. #if 0 || (LZO_DETERMINISTIC)
  5043. ll = LZO_MIN(ll, 49152);
  5044. #endif
  5045. ll_end = (lzo_uintptr_t)ip + ll;
  5046. if ((ll_end + ((t + ll) >> 5)) <= ll_end || (const lzo_bytep)(ll_end + ((t + ll) >> 5)) <= ip + ll)
  5047. break;
  5048. #if (LZO_DETERMINISTIC)
  5049. lzo_memset(wrkmem, 0, ((lzo_uint)1 << D_BITS) * sizeof(lzo_dict_t));
  5050. #endif
  5051. t = do_compress(ip,ll,op,out_len,t,wrkmem);
  5052. ip += ll;
  5053. op += *out_len;
  5054. l -= ll;
  5055. }
  5056. t += l;
  5057. if (t > 0)
  5058. {
  5059. const lzo_bytep ii = in + in_len - t;
  5060. if (op == out && t <= 238)
  5061. *op++ = LZO_BYTE(17 + t);
  5062. else if (t <= 3)
  5063. op[-2] = LZO_BYTE(op[-2] | t);
  5064. else if (t <= 18)
  5065. *op++ = LZO_BYTE(t - 3);
  5066. else
  5067. {
  5068. lzo_uint tt = t - 18;
  5069. *op++ = 0;
  5070. while (tt > 255)
  5071. {
  5072. tt -= 255;
  5073. UA_SET1(op, 0);
  5074. op++;
  5075. }
  5076. assert(tt > 0);
  5077. *op++ = LZO_BYTE(tt);
  5078. }
  5079. UA_COPYN(op, ii, t);
  5080. op += t;
  5081. }
  5082. *op++ = M4_MARKER | 1;
  5083. *op++ = 0;
  5084. *op++ = 0;
  5085. *out_len = pd(op, out);
  5086. return LZO_E_OK;
  5087. }
  5088. #endif
  5089. #undef do_compress
  5090. #undef DO_COMPRESS
  5091. #undef LZO_HASH
  5092. #undef LZO_TEST_OVERRUN
  5093. #undef DO_DECOMPRESS
  5094. #define DO_DECOMPRESS lzo1x_decompress
  5095. #if !defined(MINILZO_CFG_SKIP_LZO1X_DECOMPRESS)
  5096. #if defined(LZO_TEST_OVERRUN)
  5097. # if !defined(LZO_TEST_OVERRUN_INPUT)
  5098. # define LZO_TEST_OVERRUN_INPUT 2
  5099. # endif
  5100. # if !defined(LZO_TEST_OVERRUN_OUTPUT)
  5101. # define LZO_TEST_OVERRUN_OUTPUT 2
  5102. # endif
  5103. # if !defined(LZO_TEST_OVERRUN_LOOKBEHIND)
  5104. # define LZO_TEST_OVERRUN_LOOKBEHIND 1
  5105. # endif
  5106. #endif
  5107. #undef TEST_IP
  5108. #undef TEST_OP
  5109. #undef TEST_IP_AND_TEST_OP
  5110. #undef TEST_LB
  5111. #undef TEST_LBO
  5112. #undef NEED_IP
  5113. #undef NEED_OP
  5114. #undef TEST_IV
  5115. #undef TEST_OV
  5116. #undef HAVE_TEST_IP
  5117. #undef HAVE_TEST_OP
  5118. #undef HAVE_NEED_IP
  5119. #undef HAVE_NEED_OP
  5120. #undef HAVE_ANY_IP
  5121. #undef HAVE_ANY_OP
  5122. #if defined(LZO_TEST_OVERRUN_INPUT)
  5123. # if (LZO_TEST_OVERRUN_INPUT >= 1)
  5124. # define TEST_IP (ip < ip_end)
  5125. # endif
  5126. # if (LZO_TEST_OVERRUN_INPUT >= 2)
  5127. # define NEED_IP(x) \
  5128. if ((lzo_uint)(ip_end - ip) < (lzo_uint)(x)) goto input_overrun
  5129. # define TEST_IV(x) if ((x) > (lzo_uint)0 - (511)) goto input_overrun
  5130. # endif
  5131. #endif
  5132. #if defined(LZO_TEST_OVERRUN_OUTPUT)
  5133. # if (LZO_TEST_OVERRUN_OUTPUT >= 1)
  5134. # define TEST_OP (op <= op_end)
  5135. # endif
  5136. # if (LZO_TEST_OVERRUN_OUTPUT >= 2)
  5137. # undef TEST_OP
  5138. # define NEED_OP(x) \
  5139. if ((lzo_uint)(op_end - op) < (lzo_uint)(x)) goto output_overrun
  5140. # define TEST_OV(x) if ((x) > (lzo_uint)0 - (511)) goto output_overrun
  5141. # endif
  5142. #endif
  5143. #if defined(LZO_TEST_OVERRUN_LOOKBEHIND)
  5144. # define TEST_LB(m_pos) if (PTR_LT(m_pos,out) || PTR_GE(m_pos,op)) goto lookbehind_overrun
  5145. # define TEST_LBO(m_pos,o) if (PTR_LT(m_pos,out) || PTR_GE(m_pos,op-(o))) goto lookbehind_overrun
  5146. #else
  5147. # define TEST_LB(m_pos) ((void) 0)
  5148. # define TEST_LBO(m_pos,o) ((void) 0)
  5149. #endif
  5150. #if !defined(LZO_EOF_CODE) && !defined(TEST_IP)
  5151. # define TEST_IP (ip < ip_end)
  5152. #endif
  5153. #if defined(TEST_IP)
  5154. # define HAVE_TEST_IP 1
  5155. #else
  5156. # define TEST_IP 1
  5157. #endif
  5158. #if defined(TEST_OP)
  5159. # define HAVE_TEST_OP 1
  5160. #else
  5161. # define TEST_OP 1
  5162. #endif
  5163. #if defined(HAVE_TEST_IP) && defined(HAVE_TEST_OP)
  5164. # define TEST_IP_AND_TEST_OP (TEST_IP && TEST_OP)
  5165. #elif defined(HAVE_TEST_IP)
  5166. # define TEST_IP_AND_TEST_OP TEST_IP
  5167. #elif defined(HAVE_TEST_OP)
  5168. # define TEST_IP_AND_TEST_OP TEST_OP
  5169. #else
  5170. # define TEST_IP_AND_TEST_OP 1
  5171. #endif
  5172. #if defined(NEED_IP)
  5173. # define HAVE_NEED_IP 1
  5174. #else
  5175. # define NEED_IP(x) ((void) 0)
  5176. # define TEST_IV(x) ((void) 0)
  5177. #endif
  5178. #if defined(NEED_OP)
  5179. # define HAVE_NEED_OP 1
  5180. #else
  5181. # define NEED_OP(x) ((void) 0)
  5182. # define TEST_OV(x) ((void) 0)
  5183. #endif
  5184. #if defined(HAVE_TEST_IP) || defined(HAVE_NEED_IP)
  5185. # define HAVE_ANY_IP 1
  5186. #endif
  5187. #if defined(HAVE_TEST_OP) || defined(HAVE_NEED_OP)
  5188. # define HAVE_ANY_OP 1
  5189. #endif
  5190. #if defined(DO_DECOMPRESS)
  5191. LZO_PUBLIC(int)
  5192. DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len,
  5193. lzo_bytep out, lzo_uintp out_len,
  5194. lzo_voidp wrkmem )
  5195. #endif
  5196. {
  5197. lzo_bytep op;
  5198. const lzo_bytep ip;
  5199. lzo_uint t;
  5200. #if defined(COPY_DICT)
  5201. lzo_uint m_off;
  5202. const lzo_bytep dict_end;
  5203. #else
  5204. const lzo_bytep m_pos;
  5205. #endif
  5206. const lzo_bytep const ip_end = in + in_len;
  5207. #if defined(HAVE_ANY_OP)
  5208. lzo_bytep const op_end = out + *out_len;
  5209. #endif
  5210. #if defined(LZO1Z)
  5211. lzo_uint last_m_off = 0;
  5212. #endif
  5213. LZO_UNUSED(wrkmem);
  5214. #if defined(COPY_DICT)
  5215. if (dict)
  5216. {
  5217. if (dict_len > M4_MAX_OFFSET)
  5218. {
  5219. dict += dict_len - M4_MAX_OFFSET;
  5220. dict_len = M4_MAX_OFFSET;
  5221. }
  5222. dict_end = dict + dict_len;
  5223. }
  5224. else
  5225. {
  5226. dict_len = 0;
  5227. dict_end = NULL;
  5228. }
  5229. #endif
  5230. *out_len = 0;
  5231. op = out;
  5232. ip = in;
  5233. NEED_IP(1);
  5234. if (*ip > 17)
  5235. {
  5236. t = *ip++ - 17;
  5237. if (t < 4)
  5238. goto match_next;
  5239. assert(t > 0); NEED_OP(t); NEED_IP(t+3);
  5240. do *op++ = *ip++; while (--t > 0);
  5241. goto first_literal_run;
  5242. }
  5243. for (;;)
  5244. {
  5245. NEED_IP(3);
  5246. t = *ip++;
  5247. if (t >= 16)
  5248. goto match;
  5249. if (t == 0)
  5250. {
  5251. while (*ip == 0)
  5252. {
  5253. t += 255;
  5254. ip++;
  5255. TEST_IV(t);
  5256. NEED_IP(1);
  5257. }
  5258. t += 15 + *ip++;
  5259. }
  5260. assert(t > 0); NEED_OP(t+3); NEED_IP(t+6);
  5261. #if (LZO_OPT_UNALIGNED64) && (LZO_OPT_UNALIGNED32)
  5262. t += 3;
  5263. if (t >= 8) do
  5264. {
  5265. UA_COPY8(op,ip);
  5266. op += 8; ip += 8; t -= 8;
  5267. } while (t >= 8);
  5268. if (t >= 4)
  5269. {
  5270. UA_COPY4(op,ip);
  5271. op += 4; ip += 4; t -= 4;
  5272. }
  5273. if (t > 0)
  5274. {
  5275. *op++ = *ip++;
  5276. if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } }
  5277. }
  5278. #elif (LZO_OPT_UNALIGNED32) || (LZO_ALIGNED_OK_4)
  5279. #if !(LZO_OPT_UNALIGNED32)
  5280. if (PTR_ALIGNED2_4(op,ip))
  5281. {
  5282. #endif
  5283. UA_COPY4(op,ip);
  5284. op += 4; ip += 4;
  5285. if (--t > 0)
  5286. {
  5287. if (t >= 4)
  5288. {
  5289. do {
  5290. UA_COPY4(op,ip);
  5291. op += 4; ip += 4; t -= 4;
  5292. } while (t >= 4);
  5293. if (t > 0) do *op++ = *ip++; while (--t > 0);
  5294. }
  5295. else
  5296. do *op++ = *ip++; while (--t > 0);
  5297. }
  5298. #if !(LZO_OPT_UNALIGNED32)
  5299. }
  5300. else
  5301. #endif
  5302. #endif
  5303. #if !(LZO_OPT_UNALIGNED32)
  5304. {
  5305. *op++ = *ip++; *op++ = *ip++; *op++ = *ip++;
  5306. do *op++ = *ip++; while (--t > 0);
  5307. }
  5308. #endif
  5309. first_literal_run:
  5310. t = *ip++;
  5311. if (t >= 16)
  5312. goto match;
  5313. #if defined(COPY_DICT)
  5314. #if defined(LZO1Z)
  5315. m_off = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2);
  5316. last_m_off = m_off;
  5317. #else
  5318. m_off = (1 + M2_MAX_OFFSET) + (t >> 2) + (*ip++ << 2);
  5319. #endif
  5320. NEED_OP(3);
  5321. t = 3; COPY_DICT(t,m_off)
  5322. #else
  5323. #if defined(LZO1Z)
  5324. t = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2);
  5325. m_pos = op - t;
  5326. last_m_off = t;
  5327. #else
  5328. m_pos = op - (1 + M2_MAX_OFFSET);
  5329. m_pos -= t >> 2;
  5330. m_pos -= *ip++ << 2;
  5331. #endif
  5332. TEST_LB(m_pos); NEED_OP(3);
  5333. *op++ = *m_pos++; *op++ = *m_pos++; *op++ = *m_pos;
  5334. #endif
  5335. goto match_done;
  5336. for (;;) {
  5337. match:
  5338. if (t >= 64)
  5339. {
  5340. #if defined(COPY_DICT)
  5341. #if defined(LZO1X)
  5342. m_off = 1 + ((t >> 2) & 7) + (*ip++ << 3);
  5343. t = (t >> 5) - 1;
  5344. #elif defined(LZO1Y)
  5345. m_off = 1 + ((t >> 2) & 3) + (*ip++ << 2);
  5346. t = (t >> 4) - 3;
  5347. #elif defined(LZO1Z)
  5348. m_off = t & 0x1f;
  5349. if (m_off >= 0x1c)
  5350. m_off = last_m_off;
  5351. else
  5352. {
  5353. m_off = 1 + (m_off << 6) + (*ip++ >> 2);
  5354. last_m_off = m_off;
  5355. }
  5356. t = (t >> 5) - 1;
  5357. #endif
  5358. #else
  5359. #if defined(LZO1X)
  5360. m_pos = op - 1;
  5361. m_pos -= (t >> 2) & 7;
  5362. m_pos -= *ip++ << 3;
  5363. t = (t >> 5) - 1;
  5364. #elif defined(LZO1Y)
  5365. m_pos = op - 1;
  5366. m_pos -= (t >> 2) & 3;
  5367. m_pos -= *ip++ << 2;
  5368. t = (t >> 4) - 3;
  5369. #elif defined(LZO1Z)
  5370. {
  5371. lzo_uint off = t & 0x1f;
  5372. m_pos = op;
  5373. if (off >= 0x1c)
  5374. {
  5375. assert(last_m_off > 0);
  5376. m_pos -= last_m_off;
  5377. }
  5378. else
  5379. {
  5380. off = 1 + (off << 6) + (*ip++ >> 2);
  5381. m_pos -= off;
  5382. last_m_off = off;
  5383. }
  5384. }
  5385. t = (t >> 5) - 1;
  5386. #endif
  5387. TEST_LB(m_pos); assert(t > 0); NEED_OP(t+3-1);
  5388. goto copy_match;
  5389. #endif
  5390. }
  5391. else if (t >= 32)
  5392. {
  5393. t &= 31;
  5394. if (t == 0)
  5395. {
  5396. while (*ip == 0)
  5397. {
  5398. t += 255;
  5399. ip++;
  5400. TEST_OV(t);
  5401. NEED_IP(1);
  5402. }
  5403. t += 31 + *ip++;
  5404. NEED_IP(2);
  5405. }
  5406. #if defined(COPY_DICT)
  5407. #if defined(LZO1Z)
  5408. m_off = 1 + (ip[0] << 6) + (ip[1] >> 2);
  5409. last_m_off = m_off;
  5410. #else
  5411. m_off = 1 + (ip[0] >> 2) + (ip[1] << 6);
  5412. #endif
  5413. #else
  5414. #if defined(LZO1Z)
  5415. {
  5416. lzo_uint off = 1 + (ip[0] << 6) + (ip[1] >> 2);
  5417. m_pos = op - off;
  5418. last_m_off = off;
  5419. }
  5420. #elif (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN)
  5421. m_pos = op - 1;
  5422. m_pos -= UA_GET_LE16(ip) >> 2;
  5423. #else
  5424. m_pos = op - 1;
  5425. m_pos -= (ip[0] >> 2) + (ip[1] << 6);
  5426. #endif
  5427. #endif
  5428. ip += 2;
  5429. }
  5430. else if (t >= 16)
  5431. {
  5432. #if defined(COPY_DICT)
  5433. m_off = (t & 8) << 11;
  5434. #else
  5435. m_pos = op;
  5436. m_pos -= (t & 8) << 11;
  5437. #endif
  5438. t &= 7;
  5439. if (t == 0)
  5440. {
  5441. while (*ip == 0)
  5442. {
  5443. t += 255;
  5444. ip++;
  5445. TEST_OV(t);
  5446. NEED_IP(1);
  5447. }
  5448. t += 7 + *ip++;
  5449. NEED_IP(2);
  5450. }
  5451. #if defined(COPY_DICT)
  5452. #if defined(LZO1Z)
  5453. m_off += (ip[0] << 6) + (ip[1] >> 2);
  5454. #else
  5455. m_off += (ip[0] >> 2) + (ip[1] << 6);
  5456. #endif
  5457. ip += 2;
  5458. if (m_off == 0)
  5459. goto eof_found;
  5460. m_off += 0x4000;
  5461. #if defined(LZO1Z)
  5462. last_m_off = m_off;
  5463. #endif
  5464. #else
  5465. #if defined(LZO1Z)
  5466. m_pos -= (ip[0] << 6) + (ip[1] >> 2);
  5467. #elif (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN)
  5468. m_pos -= UA_GET_LE16(ip) >> 2;
  5469. #else
  5470. m_pos -= (ip[0] >> 2) + (ip[1] << 6);
  5471. #endif
  5472. ip += 2;
  5473. if (m_pos == op)
  5474. goto eof_found;
  5475. m_pos -= 0x4000;
  5476. #if defined(LZO1Z)
  5477. last_m_off = pd((const lzo_bytep)op, m_pos);
  5478. #endif
  5479. #endif
  5480. }
  5481. else
  5482. {
  5483. #if defined(COPY_DICT)
  5484. #if defined(LZO1Z)
  5485. m_off = 1 + (t << 6) + (*ip++ >> 2);
  5486. last_m_off = m_off;
  5487. #else
  5488. m_off = 1 + (t >> 2) + (*ip++ << 2);
  5489. #endif
  5490. NEED_OP(2);
  5491. t = 2; COPY_DICT(t,m_off)
  5492. #else
  5493. #if defined(LZO1Z)
  5494. t = 1 + (t << 6) + (*ip++ >> 2);
  5495. m_pos = op - t;
  5496. last_m_off = t;
  5497. #else
  5498. m_pos = op - 1;
  5499. m_pos -= t >> 2;
  5500. m_pos -= *ip++ << 2;
  5501. #endif
  5502. TEST_LB(m_pos); NEED_OP(2);
  5503. *op++ = *m_pos++; *op++ = *m_pos;
  5504. #endif
  5505. goto match_done;
  5506. }
  5507. #if defined(COPY_DICT)
  5508. NEED_OP(t+3-1);
  5509. t += 3-1; COPY_DICT(t,m_off)
  5510. #else
  5511. TEST_LB(m_pos); assert(t > 0); NEED_OP(t+3-1);
  5512. #if (LZO_OPT_UNALIGNED64) && (LZO_OPT_UNALIGNED32)
  5513. if (op - m_pos >= 8)
  5514. {
  5515. t += (3 - 1);
  5516. if (t >= 8) do
  5517. {
  5518. UA_COPY8(op,m_pos);
  5519. op += 8; m_pos += 8; t -= 8;
  5520. } while (t >= 8);
  5521. if (t >= 4)
  5522. {
  5523. UA_COPY4(op,m_pos);
  5524. op += 4; m_pos += 4; t -= 4;
  5525. }
  5526. if (t > 0)
  5527. {
  5528. *op++ = m_pos[0];
  5529. if (t > 1) { *op++ = m_pos[1]; if (t > 2) { *op++ = m_pos[2]; } }
  5530. }
  5531. }
  5532. else
  5533. #elif (LZO_OPT_UNALIGNED32) || (LZO_ALIGNED_OK_4)
  5534. #if !(LZO_OPT_UNALIGNED32)
  5535. if (t >= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op,m_pos))
  5536. {
  5537. assert((op - m_pos) >= 4);
  5538. #else
  5539. if (t >= 2 * 4 - (3 - 1) && (op - m_pos) >= 4)
  5540. {
  5541. #endif
  5542. UA_COPY4(op,m_pos);
  5543. op += 4; m_pos += 4; t -= 4 - (3 - 1);
  5544. do {
  5545. UA_COPY4(op,m_pos);
  5546. op += 4; m_pos += 4; t -= 4;
  5547. } while (t >= 4);
  5548. if (t > 0) do *op++ = *m_pos++; while (--t > 0);
  5549. }
  5550. else
  5551. #endif
  5552. {
  5553. copy_match:
  5554. *op++ = *m_pos++; *op++ = *m_pos++;
  5555. do *op++ = *m_pos++; while (--t > 0);
  5556. }
  5557. #endif
  5558. match_done:
  5559. #if defined(LZO1Z)
  5560. t = ip[-1] & 3;
  5561. #else
  5562. t = ip[-2] & 3;
  5563. #endif
  5564. if (t == 0)
  5565. break;
  5566. match_next:
  5567. assert(t > 0); assert(t < 4); NEED_OP(t); NEED_IP(t+3);
  5568. #if 0
  5569. do *op++ = *ip++; while (--t > 0);
  5570. #else
  5571. *op++ = *ip++;
  5572. if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } }
  5573. #endif
  5574. t = *ip++;
  5575. }
  5576. }
  5577. eof_found:
  5578. *out_len = pd(op, out);
  5579. return (ip == ip_end ? LZO_E_OK :
  5580. (ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN));
  5581. #if defined(HAVE_NEED_IP)
  5582. input_overrun:
  5583. *out_len = pd(op, out);
  5584. return LZO_E_INPUT_OVERRUN;
  5585. #endif
  5586. #if defined(HAVE_NEED_OP)
  5587. output_overrun:
  5588. *out_len = pd(op, out);
  5589. return LZO_E_OUTPUT_OVERRUN;
  5590. #endif
  5591. #if defined(LZO_TEST_OVERRUN_LOOKBEHIND)
  5592. lookbehind_overrun:
  5593. *out_len = pd(op, out);
  5594. return LZO_E_LOOKBEHIND_OVERRUN;
  5595. #endif
  5596. }
  5597. #endif
  5598. #define LZO_TEST_OVERRUN 1
  5599. #undef DO_DECOMPRESS
  5600. #define DO_DECOMPRESS lzo1x_decompress_safe
  5601. #if !defined(MINILZO_CFG_SKIP_LZO1X_DECOMPRESS_SAFE)
  5602. #if defined(LZO_TEST_OVERRUN)
  5603. # if !defined(LZO_TEST_OVERRUN_INPUT)
  5604. # define LZO_TEST_OVERRUN_INPUT 2
  5605. # endif
  5606. # if !defined(LZO_TEST_OVERRUN_OUTPUT)
  5607. # define LZO_TEST_OVERRUN_OUTPUT 2
  5608. # endif
  5609. # if !defined(LZO_TEST_OVERRUN_LOOKBEHIND)
  5610. # define LZO_TEST_OVERRUN_LOOKBEHIND 1
  5611. # endif
  5612. #endif
  5613. #undef TEST_IP
  5614. #undef TEST_OP
  5615. #undef TEST_IP_AND_TEST_OP
  5616. #undef TEST_LB
  5617. #undef TEST_LBO
  5618. #undef NEED_IP
  5619. #undef NEED_OP
  5620. #undef TEST_IV
  5621. #undef TEST_OV
  5622. #undef HAVE_TEST_IP
  5623. #undef HAVE_TEST_OP
  5624. #undef HAVE_NEED_IP
  5625. #undef HAVE_NEED_OP
  5626. #undef HAVE_ANY_IP
  5627. #undef HAVE_ANY_OP
  5628. #if defined(LZO_TEST_OVERRUN_INPUT)
  5629. # if (LZO_TEST_OVERRUN_INPUT >= 1)
  5630. # define TEST_IP (ip < ip_end)
  5631. # endif
  5632. # if (LZO_TEST_OVERRUN_INPUT >= 2)
  5633. # define NEED_IP(x) \
  5634. if ((lzo_uint)(ip_end - ip) < (lzo_uint)(x)) goto input_overrun
  5635. # define TEST_IV(x) if ((x) > (lzo_uint)0 - (511)) goto input_overrun
  5636. # endif
  5637. #endif
  5638. #if defined(LZO_TEST_OVERRUN_OUTPUT)
  5639. # if (LZO_TEST_OVERRUN_OUTPUT >= 1)
  5640. # define TEST_OP (op <= op_end)
  5641. # endif
  5642. # if (LZO_TEST_OVERRUN_OUTPUT >= 2)
  5643. # undef TEST_OP
  5644. # define NEED_OP(x) \
  5645. if ((lzo_uint)(op_end - op) < (lzo_uint)(x)) goto output_overrun
  5646. # define TEST_OV(x) if ((x) > (lzo_uint)0 - (511)) goto output_overrun
  5647. # endif
  5648. #endif
  5649. #if defined(LZO_TEST_OVERRUN_LOOKBEHIND)
  5650. # define TEST_LB(m_pos) if (PTR_LT(m_pos,out) || PTR_GE(m_pos,op)) goto lookbehind_overrun
  5651. # define TEST_LBO(m_pos,o) if (PTR_LT(m_pos,out) || PTR_GE(m_pos,op-(o))) goto lookbehind_overrun
  5652. #else
  5653. # define TEST_LB(m_pos) ((void) 0)
  5654. # define TEST_LBO(m_pos,o) ((void) 0)
  5655. #endif
  5656. #if !defined(LZO_EOF_CODE) && !defined(TEST_IP)
  5657. # define TEST_IP (ip < ip_end)
  5658. #endif
  5659. #if defined(TEST_IP)
  5660. # define HAVE_TEST_IP 1
  5661. #else
  5662. # define TEST_IP 1
  5663. #endif
  5664. #if defined(TEST_OP)
  5665. # define HAVE_TEST_OP 1
  5666. #else
  5667. # define TEST_OP 1
  5668. #endif
  5669. #if defined(HAVE_TEST_IP) && defined(HAVE_TEST_OP)
  5670. # define TEST_IP_AND_TEST_OP (TEST_IP && TEST_OP)
  5671. #elif defined(HAVE_TEST_IP)
  5672. # define TEST_IP_AND_TEST_OP TEST_IP
  5673. #elif defined(HAVE_TEST_OP)
  5674. # define TEST_IP_AND_TEST_OP TEST_OP
  5675. #else
  5676. # define TEST_IP_AND_TEST_OP 1
  5677. #endif
  5678. #if defined(NEED_IP)
  5679. # define HAVE_NEED_IP 1
  5680. #else
  5681. # define NEED_IP(x) ((void) 0)
  5682. # define TEST_IV(x) ((void) 0)
  5683. #endif
  5684. #if defined(NEED_OP)
  5685. # define HAVE_NEED_OP 1
  5686. #else
  5687. # define NEED_OP(x) ((void) 0)
  5688. # define TEST_OV(x) ((void) 0)
  5689. #endif
  5690. #if defined(HAVE_TEST_IP) || defined(HAVE_NEED_IP)
  5691. # define HAVE_ANY_IP 1
  5692. #endif
  5693. #if defined(HAVE_TEST_OP) || defined(HAVE_NEED_OP)
  5694. # define HAVE_ANY_OP 1
  5695. #endif
  5696. #if defined(DO_DECOMPRESS)
  5697. LZO_PUBLIC(int)
  5698. DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len,
  5699. lzo_bytep out, lzo_uintp out_len,
  5700. lzo_voidp wrkmem )
  5701. #endif
  5702. {
  5703. lzo_bytep op;
  5704. const lzo_bytep ip;
  5705. lzo_uint t;
  5706. #if defined(COPY_DICT)
  5707. lzo_uint m_off;
  5708. const lzo_bytep dict_end;
  5709. #else
  5710. const lzo_bytep m_pos;
  5711. #endif
  5712. const lzo_bytep const ip_end = in + in_len;
  5713. #if defined(HAVE_ANY_OP)
  5714. lzo_bytep const op_end = out + *out_len;
  5715. #endif
  5716. #if defined(LZO1Z)
  5717. lzo_uint last_m_off = 0;
  5718. #endif
  5719. LZO_UNUSED(wrkmem);
  5720. #if defined(COPY_DICT)
  5721. if (dict)
  5722. {
  5723. if (dict_len > M4_MAX_OFFSET)
  5724. {
  5725. dict += dict_len - M4_MAX_OFFSET;
  5726. dict_len = M4_MAX_OFFSET;
  5727. }
  5728. dict_end = dict + dict_len;
  5729. }
  5730. else
  5731. {
  5732. dict_len = 0;
  5733. dict_end = NULL;
  5734. }
  5735. #endif
  5736. *out_len = 0;
  5737. op = out;
  5738. ip = in;
  5739. NEED_IP(1);
  5740. if (*ip > 17)
  5741. {
  5742. t = *ip++ - 17;
  5743. if (t < 4)
  5744. goto match_next;
  5745. assert(t > 0); NEED_OP(t); NEED_IP(t+3);
  5746. do *op++ = *ip++; while (--t > 0);
  5747. goto first_literal_run;
  5748. }
  5749. for (;;)
  5750. {
  5751. NEED_IP(3);
  5752. t = *ip++;
  5753. if (t >= 16)
  5754. goto match;
  5755. if (t == 0)
  5756. {
  5757. while (*ip == 0)
  5758. {
  5759. t += 255;
  5760. ip++;
  5761. TEST_IV(t);
  5762. NEED_IP(1);
  5763. }
  5764. t += 15 + *ip++;
  5765. }
  5766. assert(t > 0); NEED_OP(t+3); NEED_IP(t+6);
  5767. #if (LZO_OPT_UNALIGNED64) && (LZO_OPT_UNALIGNED32)
  5768. t += 3;
  5769. if (t >= 8) do
  5770. {
  5771. UA_COPY8(op,ip);
  5772. op += 8; ip += 8; t -= 8;
  5773. } while (t >= 8);
  5774. if (t >= 4)
  5775. {
  5776. UA_COPY4(op,ip);
  5777. op += 4; ip += 4; t -= 4;
  5778. }
  5779. if (t > 0)
  5780. {
  5781. *op++ = *ip++;
  5782. if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } }
  5783. }
  5784. #elif (LZO_OPT_UNALIGNED32) || (LZO_ALIGNED_OK_4)
  5785. #if !(LZO_OPT_UNALIGNED32)
  5786. if (PTR_ALIGNED2_4(op,ip))
  5787. {
  5788. #endif
  5789. UA_COPY4(op,ip);
  5790. op += 4; ip += 4;
  5791. if (--t > 0)
  5792. {
  5793. if (t >= 4)
  5794. {
  5795. do {
  5796. UA_COPY4(op,ip);
  5797. op += 4; ip += 4; t -= 4;
  5798. } while (t >= 4);
  5799. if (t > 0) do *op++ = *ip++; while (--t > 0);
  5800. }
  5801. else
  5802. do *op++ = *ip++; while (--t > 0);
  5803. }
  5804. #if !(LZO_OPT_UNALIGNED32)
  5805. }
  5806. else
  5807. #endif
  5808. #endif
  5809. #if !(LZO_OPT_UNALIGNED32)
  5810. {
  5811. *op++ = *ip++; *op++ = *ip++; *op++ = *ip++;
  5812. do *op++ = *ip++; while (--t > 0);
  5813. }
  5814. #endif
  5815. first_literal_run:
  5816. t = *ip++;
  5817. if (t >= 16)
  5818. goto match;
  5819. #if defined(COPY_DICT)
  5820. #if defined(LZO1Z)
  5821. m_off = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2);
  5822. last_m_off = m_off;
  5823. #else
  5824. m_off = (1 + M2_MAX_OFFSET) + (t >> 2) + (*ip++ << 2);
  5825. #endif
  5826. NEED_OP(3);
  5827. t = 3; COPY_DICT(t,m_off)
  5828. #else
  5829. #if defined(LZO1Z)
  5830. t = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2);
  5831. m_pos = op - t;
  5832. last_m_off = t;
  5833. #else
  5834. m_pos = op - (1 + M2_MAX_OFFSET);
  5835. m_pos -= t >> 2;
  5836. m_pos -= *ip++ << 2;
  5837. #endif
  5838. TEST_LB(m_pos); NEED_OP(3);
  5839. *op++ = *m_pos++; *op++ = *m_pos++; *op++ = *m_pos;
  5840. #endif
  5841. goto match_done;
  5842. for (;;) {
  5843. match:
  5844. if (t >= 64)
  5845. {
  5846. #if defined(COPY_DICT)
  5847. #if defined(LZO1X)
  5848. m_off = 1 + ((t >> 2) & 7) + (*ip++ << 3);
  5849. t = (t >> 5) - 1;
  5850. #elif defined(LZO1Y)
  5851. m_off = 1 + ((t >> 2) & 3) + (*ip++ << 2);
  5852. t = (t >> 4) - 3;
  5853. #elif defined(LZO1Z)
  5854. m_off = t & 0x1f;
  5855. if (m_off >= 0x1c)
  5856. m_off = last_m_off;
  5857. else
  5858. {
  5859. m_off = 1 + (m_off << 6) + (*ip++ >> 2);
  5860. last_m_off = m_off;
  5861. }
  5862. t = (t >> 5) - 1;
  5863. #endif
  5864. #else
  5865. #if defined(LZO1X)
  5866. m_pos = op - 1;
  5867. m_pos -= (t >> 2) & 7;
  5868. m_pos -= *ip++ << 3;
  5869. t = (t >> 5) - 1;
  5870. #elif defined(LZO1Y)
  5871. m_pos = op - 1;
  5872. m_pos -= (t >> 2) & 3;
  5873. m_pos -= *ip++ << 2;
  5874. t = (t >> 4) - 3;
  5875. #elif defined(LZO1Z)
  5876. {
  5877. lzo_uint off = t & 0x1f;
  5878. m_pos = op;
  5879. if (off >= 0x1c)
  5880. {
  5881. assert(last_m_off > 0);
  5882. m_pos -= last_m_off;
  5883. }
  5884. else
  5885. {
  5886. off = 1 + (off << 6) + (*ip++ >> 2);
  5887. m_pos -= off;
  5888. last_m_off = off;
  5889. }
  5890. }
  5891. t = (t >> 5) - 1;
  5892. #endif
  5893. TEST_LB(m_pos); assert(t > 0); NEED_OP(t+3-1);
  5894. goto copy_match;
  5895. #endif
  5896. }
  5897. else if (t >= 32)
  5898. {
  5899. t &= 31;
  5900. if (t == 0)
  5901. {
  5902. while (*ip == 0)
  5903. {
  5904. t += 255;
  5905. ip++;
  5906. TEST_OV(t);
  5907. NEED_IP(1);
  5908. }
  5909. t += 31 + *ip++;
  5910. NEED_IP(2);
  5911. }
  5912. #if defined(COPY_DICT)
  5913. #if defined(LZO1Z)
  5914. m_off = 1 + (ip[0] << 6) + (ip[1] >> 2);
  5915. last_m_off = m_off;
  5916. #else
  5917. m_off = 1 + (ip[0] >> 2) + (ip[1] << 6);
  5918. #endif
  5919. #else
  5920. #if defined(LZO1Z)
  5921. {
  5922. lzo_uint off = 1 + (ip[0] << 6) + (ip[1] >> 2);
  5923. m_pos = op - off;
  5924. last_m_off = off;
  5925. }
  5926. #elif (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN)
  5927. m_pos = op - 1;
  5928. m_pos -= UA_GET_LE16(ip) >> 2;
  5929. #else
  5930. m_pos = op - 1;
  5931. m_pos -= (ip[0] >> 2) + (ip[1] << 6);
  5932. #endif
  5933. #endif
  5934. ip += 2;
  5935. }
  5936. else if (t >= 16)
  5937. {
  5938. #if defined(COPY_DICT)
  5939. m_off = (t & 8) << 11;
  5940. #else
  5941. m_pos = op;
  5942. m_pos -= (t & 8) << 11;
  5943. #endif
  5944. t &= 7;
  5945. if (t == 0)
  5946. {
  5947. while (*ip == 0)
  5948. {
  5949. t += 255;
  5950. ip++;
  5951. TEST_OV(t);
  5952. NEED_IP(1);
  5953. }
  5954. t += 7 + *ip++;
  5955. NEED_IP(2);
  5956. }
  5957. #if defined(COPY_DICT)
  5958. #if defined(LZO1Z)
  5959. m_off += (ip[0] << 6) + (ip[1] >> 2);
  5960. #else
  5961. m_off += (ip[0] >> 2) + (ip[1] << 6);
  5962. #endif
  5963. ip += 2;
  5964. if (m_off == 0)
  5965. goto eof_found;
  5966. m_off += 0x4000;
  5967. #if defined(LZO1Z)
  5968. last_m_off = m_off;
  5969. #endif
  5970. #else
  5971. #if defined(LZO1Z)
  5972. m_pos -= (ip[0] << 6) + (ip[1] >> 2);
  5973. #elif (LZO_OPT_UNALIGNED16) && (LZO_ABI_LITTLE_ENDIAN)
  5974. m_pos -= UA_GET_LE16(ip) >> 2;
  5975. #else
  5976. m_pos -= (ip[0] >> 2) + (ip[1] << 6);
  5977. #endif
  5978. ip += 2;
  5979. if (m_pos == op)
  5980. goto eof_found;
  5981. m_pos -= 0x4000;
  5982. #if defined(LZO1Z)
  5983. last_m_off = pd((const lzo_bytep)op, m_pos);
  5984. #endif
  5985. #endif
  5986. }
  5987. else
  5988. {
  5989. #if defined(COPY_DICT)
  5990. #if defined(LZO1Z)
  5991. m_off = 1 + (t << 6) + (*ip++ >> 2);
  5992. last_m_off = m_off;
  5993. #else
  5994. m_off = 1 + (t >> 2) + (*ip++ << 2);
  5995. #endif
  5996. NEED_OP(2);
  5997. t = 2; COPY_DICT(t,m_off)
  5998. #else
  5999. #if defined(LZO1Z)
  6000. t = 1 + (t << 6) + (*ip++ >> 2);
  6001. m_pos = op - t;
  6002. last_m_off = t;
  6003. #else
  6004. m_pos = op - 1;
  6005. m_pos -= t >> 2;
  6006. m_pos -= *ip++ << 2;
  6007. #endif
  6008. TEST_LB(m_pos); NEED_OP(2);
  6009. *op++ = *m_pos++; *op++ = *m_pos;
  6010. #endif
  6011. goto match_done;
  6012. }
  6013. #if defined(COPY_DICT)
  6014. NEED_OP(t+3-1);
  6015. t += 3-1; COPY_DICT(t,m_off)
  6016. #else
  6017. TEST_LB(m_pos); assert(t > 0); NEED_OP(t+3-1);
  6018. #if (LZO_OPT_UNALIGNED64) && (LZO_OPT_UNALIGNED32)
  6019. if (op - m_pos >= 8)
  6020. {
  6021. t += (3 - 1);
  6022. if (t >= 8) do
  6023. {
  6024. UA_COPY8(op,m_pos);
  6025. op += 8; m_pos += 8; t -= 8;
  6026. } while (t >= 8);
  6027. if (t >= 4)
  6028. {
  6029. UA_COPY4(op,m_pos);
  6030. op += 4; m_pos += 4; t -= 4;
  6031. }
  6032. if (t > 0)
  6033. {
  6034. *op++ = m_pos[0];
  6035. if (t > 1) { *op++ = m_pos[1]; if (t > 2) { *op++ = m_pos[2]; } }
  6036. }
  6037. }
  6038. else
  6039. #elif (LZO_OPT_UNALIGNED32) || (LZO_ALIGNED_OK_4)
  6040. #if !(LZO_OPT_UNALIGNED32)
  6041. if (t >= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op,m_pos))
  6042. {
  6043. assert((op - m_pos) >= 4);
  6044. #else
  6045. if (t >= 2 * 4 - (3 - 1) && (op - m_pos) >= 4)
  6046. {
  6047. #endif
  6048. UA_COPY4(op,m_pos);
  6049. op += 4; m_pos += 4; t -= 4 - (3 - 1);
  6050. do {
  6051. UA_COPY4(op,m_pos);
  6052. op += 4; m_pos += 4; t -= 4;
  6053. } while (t >= 4);
  6054. if (t > 0) do *op++ = *m_pos++; while (--t > 0);
  6055. }
  6056. else
  6057. #endif
  6058. {
  6059. copy_match:
  6060. *op++ = *m_pos++; *op++ = *m_pos++;
  6061. do *op++ = *m_pos++; while (--t > 0);
  6062. }
  6063. #endif
  6064. match_done:
  6065. #if defined(LZO1Z)
  6066. t = ip[-1] & 3;
  6067. #else
  6068. t = ip[-2] & 3;
  6069. #endif
  6070. if (t == 0)
  6071. break;
  6072. match_next:
  6073. assert(t > 0); assert(t < 4); NEED_OP(t); NEED_IP(t+3);
  6074. #if 0
  6075. do *op++ = *ip++; while (--t > 0);
  6076. #else
  6077. *op++ = *ip++;
  6078. if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } }
  6079. #endif
  6080. t = *ip++;
  6081. }
  6082. }
  6083. eof_found:
  6084. *out_len = pd(op, out);
  6085. return (ip == ip_end ? LZO_E_OK :
  6086. (ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN));
  6087. #if defined(HAVE_NEED_IP)
  6088. input_overrun:
  6089. *out_len = pd(op, out);
  6090. return LZO_E_INPUT_OVERRUN;
  6091. #endif
  6092. #if defined(HAVE_NEED_OP)
  6093. output_overrun:
  6094. *out_len = pd(op, out);
  6095. return LZO_E_OUTPUT_OVERRUN;
  6096. #endif
  6097. #if defined(LZO_TEST_OVERRUN_LOOKBEHIND)
  6098. lookbehind_overrun:
  6099. *out_len = pd(op, out);
  6100. return LZO_E_LOOKBEHIND_OVERRUN;
  6101. #endif
  6102. }
  6103. #endif
  6104. /***** End of minilzo.c *****/