minilzo.c 197 KB

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