minilzo.c 138 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579
  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) 2011 Markus Franz Xaver Johannes Oberhumer
  4. Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer
  5. Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer
  6. Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer
  7. Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer
  8. Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer
  9. Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer
  10. Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer
  11. Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer
  12. Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer
  13. Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer
  14. Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
  15. Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
  16. Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
  17. Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
  18. Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
  19. All Rights Reserved.
  20. The LZO library is free software; you can redistribute it and/or
  21. modify it under the terms of the GNU General Public License as
  22. published by the Free Software Foundation; either version 2 of
  23. the License, or (at your option) any later version.
  24. The LZO library is distributed in the hope that it will be useful,
  25. but WITHOUT ANY WARRANTY; without even the implied warranty of
  26. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  27. GNU General Public License for more details.
  28. You should have received a copy of the GNU General Public License
  29. along with the LZO library; see the file COPYING.
  30. If not, write to the Free Software Foundation, Inc.,
  31. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  32. Markus F.X.J. Oberhumer
  33. <markus@oberhumer.com>
  34. http://www.oberhumer.com/opensource/lzo/
  35. */
  36. /*
  37. * NOTE:
  38. * the full LZO package can be found at
  39. * http://www.oberhumer.com/opensource/lzo/
  40. */
  41. #define __LZO_IN_MINILZO 1
  42. #if defined(LZO_CFG_FREESTANDING)
  43. # undef MINILZO_HAVE_CONFIG_H
  44. # define LZO_LIBC_FREESTANDING 1
  45. # define LZO_OS_FREESTANDING 1
  46. #endif
  47. #ifdef MINILZO_HAVE_CONFIG_H
  48. # include <config.h>
  49. #endif
  50. #include <limits.h>
  51. #include <stddef.h>
  52. #if defined(MINILZO_CFG_USE_INTERNAL_LZODEFS)
  53. #ifndef __LZODEFS_H_INCLUDED
  54. #define __LZODEFS_H_INCLUDED 1
  55. #if defined(__CYGWIN32__) && !defined(__CYGWIN__)
  56. # define __CYGWIN__ __CYGWIN32__
  57. #endif
  58. #if defined(__IBMCPP__) && !defined(__IBMC__)
  59. # define __IBMC__ __IBMCPP__
  60. #endif
  61. #if defined(__ICL) && defined(_WIN32) && !defined(__INTEL_COMPILER)
  62. # define __INTEL_COMPILER __ICL
  63. #endif
  64. #if 1 && defined(__INTERIX) && defined(__GNUC__) && !defined(_ALL_SOURCE)
  65. # define _ALL_SOURCE 1
  66. #endif
  67. #if defined(__mips__) && defined(__R5900__)
  68. # if !defined(__LONG_MAX__)
  69. # define __LONG_MAX__ 9223372036854775807L
  70. # endif
  71. #endif
  72. #if defined(__INTEL_COMPILER) && defined(__linux__)
  73. # pragma warning(disable: 193)
  74. #endif
  75. #if defined(__KEIL__) && defined(__C166__)
  76. # pragma warning disable = 322
  77. #elif 0 && defined(__C251__)
  78. # pragma warning disable = 322
  79. #endif
  80. #if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__)
  81. # if (_MSC_VER >= 1300)
  82. # pragma warning(disable: 4668)
  83. # endif
  84. #endif
  85. #if 0 && defined(__WATCOMC__)
  86. # if (__WATCOMC__ >= 1050) && (__WATCOMC__ < 1060)
  87. # pragma warning 203 9
  88. # endif
  89. #endif
  90. #if defined(__BORLANDC__) && defined(__MSDOS__) && !defined(__FLAT__)
  91. # pragma option -h
  92. #endif
  93. #if 0
  94. #define LZO_0xffffL 0xfffful
  95. #define LZO_0xffffffffL 0xfffffffful
  96. #else
  97. #define LZO_0xffffL 65535ul
  98. #define LZO_0xffffffffL 4294967295ul
  99. #endif
  100. #if (LZO_0xffffL == LZO_0xffffffffL)
  101. # error "your preprocessor is broken 1"
  102. #endif
  103. #if (16ul * 16384ul != 262144ul)
  104. # error "your preprocessor is broken 2"
  105. #endif
  106. #if 0
  107. #if (32767 >= 4294967295ul)
  108. # error "your preprocessor is broken 3"
  109. #endif
  110. #if (65535u >= 4294967295ul)
  111. # error "your preprocessor is broken 4"
  112. #endif
  113. #endif
  114. #if (UINT_MAX == LZO_0xffffL)
  115. #if defined(__ZTC__) && defined(__I86__) && !defined(__OS2__)
  116. # if !defined(MSDOS)
  117. # define MSDOS 1
  118. # endif
  119. # if !defined(_MSDOS)
  120. # define _MSDOS 1
  121. # endif
  122. #elif 0 && defined(__VERSION) && defined(MB_LEN_MAX)
  123. # if (__VERSION == 520) && (MB_LEN_MAX == 1)
  124. # if !defined(__AZTEC_C__)
  125. # define __AZTEC_C__ __VERSION
  126. # endif
  127. # if !defined(__DOS__)
  128. # define __DOS__ 1
  129. # endif
  130. # endif
  131. #endif
  132. #endif
  133. #if defined(_MSC_VER) && defined(M_I86HM) && (UINT_MAX == LZO_0xffffL)
  134. # define ptrdiff_t long
  135. # define _PTRDIFF_T_DEFINED 1
  136. #endif
  137. #if (UINT_MAX == LZO_0xffffL)
  138. # undef __LZO_RENAME_A
  139. # undef __LZO_RENAME_B
  140. # if defined(__AZTEC_C__) && defined(__DOS__)
  141. # define __LZO_RENAME_A 1
  142. # elif defined(_MSC_VER) && defined(MSDOS)
  143. # if (_MSC_VER < 600)
  144. # define __LZO_RENAME_A 1
  145. # elif (_MSC_VER < 700)
  146. # define __LZO_RENAME_B 1
  147. # endif
  148. # elif defined(__TSC__) && defined(__OS2__)
  149. # define __LZO_RENAME_A 1
  150. # elif defined(__MSDOS__) && defined(__TURBOC__) && (__TURBOC__ < 0x0410)
  151. # define __LZO_RENAME_A 1
  152. # elif defined(__PACIFIC__) && defined(DOS)
  153. # if !defined(__far)
  154. # define __far far
  155. # endif
  156. # if !defined(__near)
  157. # define __near near
  158. # endif
  159. # endif
  160. # if defined(__LZO_RENAME_A)
  161. # if !defined(__cdecl)
  162. # define __cdecl cdecl
  163. # endif
  164. # if !defined(__far)
  165. # define __far far
  166. # endif
  167. # if !defined(__huge)
  168. # define __huge huge
  169. # endif
  170. # if !defined(__near)
  171. # define __near near
  172. # endif
  173. # if !defined(__pascal)
  174. # define __pascal pascal
  175. # endif
  176. # if !defined(__huge)
  177. # define __huge huge
  178. # endif
  179. # elif defined(__LZO_RENAME_B)
  180. # if !defined(__cdecl)
  181. # define __cdecl _cdecl
  182. # endif
  183. # if !defined(__far)
  184. # define __far _far
  185. # endif
  186. # if !defined(__huge)
  187. # define __huge _huge
  188. # endif
  189. # if !defined(__near)
  190. # define __near _near
  191. # endif
  192. # if !defined(__pascal)
  193. # define __pascal _pascal
  194. # endif
  195. # elif (defined(__PUREC__) || defined(__TURBOC__)) && defined(__TOS__)
  196. # if !defined(__cdecl)
  197. # define __cdecl cdecl
  198. # endif
  199. # if !defined(__pascal)
  200. # define __pascal pascal
  201. # endif
  202. # endif
  203. # undef __LZO_RENAME_A
  204. # undef __LZO_RENAME_B
  205. #endif
  206. #if (UINT_MAX == LZO_0xffffL)
  207. #if defined(__AZTEC_C__) && defined(__DOS__)
  208. # define LZO_BROKEN_CDECL_ALT_SYNTAX 1
  209. #elif defined(_MSC_VER) && defined(MSDOS)
  210. # if (_MSC_VER < 600)
  211. # define LZO_BROKEN_INTEGRAL_CONSTANTS 1
  212. # endif
  213. # if (_MSC_VER < 700)
  214. # define LZO_BROKEN_INTEGRAL_PROMOTION 1
  215. # define LZO_BROKEN_SIZEOF 1
  216. # endif
  217. #elif defined(__PACIFIC__) && defined(DOS)
  218. # define LZO_BROKEN_INTEGRAL_CONSTANTS 1
  219. #elif defined(__TURBOC__) && defined(__MSDOS__)
  220. # if (__TURBOC__ < 0x0150)
  221. # define LZO_BROKEN_CDECL_ALT_SYNTAX 1
  222. # define LZO_BROKEN_INTEGRAL_CONSTANTS 1
  223. # define LZO_BROKEN_INTEGRAL_PROMOTION 1
  224. # endif
  225. # if (__TURBOC__ < 0x0200)
  226. # define LZO_BROKEN_SIZEOF 1
  227. # endif
  228. # if (__TURBOC__ < 0x0400) && defined(__cplusplus)
  229. # define LZO_BROKEN_CDECL_ALT_SYNTAX 1
  230. # endif
  231. #elif (defined(__PUREC__) || defined(__TURBOC__)) && defined(__TOS__)
  232. # define LZO_BROKEN_CDECL_ALT_SYNTAX 1
  233. # define LZO_BROKEN_SIZEOF 1
  234. #endif
  235. #endif
  236. #if defined(__WATCOMC__) && (__WATCOMC__ < 900)
  237. # define LZO_BROKEN_INTEGRAL_CONSTANTS 1
  238. #endif
  239. #if defined(_CRAY) && defined(_CRAY1)
  240. # define LZO_BROKEN_SIGNED_RIGHT_SHIFT 1
  241. #endif
  242. #define LZO_PP_STRINGIZE(x) #x
  243. #define LZO_PP_MACRO_EXPAND(x) LZO_PP_STRINGIZE(x)
  244. #define LZO_PP_CONCAT2(a,b) a ## b
  245. #define LZO_PP_CONCAT3(a,b,c) a ## b ## c
  246. #define LZO_PP_CONCAT4(a,b,c,d) a ## b ## c ## d
  247. #define LZO_PP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e
  248. #define LZO_PP_ECONCAT2(a,b) LZO_PP_CONCAT2(a,b)
  249. #define LZO_PP_ECONCAT3(a,b,c) LZO_PP_CONCAT3(a,b,c)
  250. #define LZO_PP_ECONCAT4(a,b,c,d) LZO_PP_CONCAT4(a,b,c,d)
  251. #define LZO_PP_ECONCAT5(a,b,c,d,e) LZO_PP_CONCAT5(a,b,c,d,e)
  252. #if 1
  253. #define LZO_CPP_STRINGIZE(x) #x
  254. #define LZO_CPP_MACRO_EXPAND(x) LZO_CPP_STRINGIZE(x)
  255. #define LZO_CPP_CONCAT2(a,b) a ## b
  256. #define LZO_CPP_CONCAT3(a,b,c) a ## b ## c
  257. #define LZO_CPP_CONCAT4(a,b,c,d) a ## b ## c ## d
  258. #define LZO_CPP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e
  259. #define LZO_CPP_ECONCAT2(a,b) LZO_CPP_CONCAT2(a,b)
  260. #define LZO_CPP_ECONCAT3(a,b,c) LZO_CPP_CONCAT3(a,b,c)
  261. #define LZO_CPP_ECONCAT4(a,b,c,d) LZO_CPP_CONCAT4(a,b,c,d)
  262. #define LZO_CPP_ECONCAT5(a,b,c,d,e) LZO_CPP_CONCAT5(a,b,c,d,e)
  263. #endif
  264. #define __LZO_MASK_GEN(o,b) (((((o) << ((b)-1)) - (o)) << 1) + (o))
  265. #if 1 && defined(__cplusplus)
  266. # if !defined(__STDC_CONSTANT_MACROS)
  267. # define __STDC_CONSTANT_MACROS 1
  268. # endif
  269. # if !defined(__STDC_LIMIT_MACROS)
  270. # define __STDC_LIMIT_MACROS 1
  271. # endif
  272. #endif
  273. #if defined(__cplusplus)
  274. # define LZO_EXTERN_C extern "C"
  275. #else
  276. # define LZO_EXTERN_C extern
  277. #endif
  278. #if !defined(__LZO_OS_OVERRIDE)
  279. #if (LZO_OS_FREESTANDING)
  280. # define LZO_INFO_OS "freestanding"
  281. #elif (LZO_OS_EMBEDDED)
  282. # define LZO_INFO_OS "embedded"
  283. #elif 1 && defined(__IAR_SYSTEMS_ICC__)
  284. # define LZO_OS_EMBEDDED 1
  285. # define LZO_INFO_OS "embedded"
  286. #elif defined(__CYGWIN__) && defined(__GNUC__)
  287. # define LZO_OS_CYGWIN 1
  288. # define LZO_INFO_OS "cygwin"
  289. #elif defined(__EMX__) && defined(__GNUC__)
  290. # define LZO_OS_EMX 1
  291. # define LZO_INFO_OS "emx"
  292. #elif defined(__BEOS__)
  293. # define LZO_OS_BEOS 1
  294. # define LZO_INFO_OS "beos"
  295. #elif defined(__Lynx__)
  296. # define LZO_OS_LYNXOS 1
  297. # define LZO_INFO_OS "lynxos"
  298. #elif defined(__OS400__)
  299. # define LZO_OS_OS400 1
  300. # define LZO_INFO_OS "os400"
  301. #elif defined(__QNX__)
  302. # define LZO_OS_QNX 1
  303. # define LZO_INFO_OS "qnx"
  304. #elif defined(__BORLANDC__) && defined(__DPMI32__) && (__BORLANDC__ >= 0x0460)
  305. # define LZO_OS_DOS32 1
  306. # define LZO_INFO_OS "dos32"
  307. #elif defined(__BORLANDC__) && defined(__DPMI16__)
  308. # define LZO_OS_DOS16 1
  309. # define LZO_INFO_OS "dos16"
  310. #elif defined(__ZTC__) && defined(DOS386)
  311. # define LZO_OS_DOS32 1
  312. # define LZO_INFO_OS "dos32"
  313. #elif defined(__OS2__) || defined(__OS2V2__)
  314. # if (UINT_MAX == LZO_0xffffL)
  315. # define LZO_OS_OS216 1
  316. # define LZO_INFO_OS "os216"
  317. # elif (UINT_MAX == LZO_0xffffffffL)
  318. # define LZO_OS_OS2 1
  319. # define LZO_INFO_OS "os2"
  320. # else
  321. # error "check your limits.h header"
  322. # endif
  323. #elif defined(__WIN64__) || defined(_WIN64) || defined(WIN64)
  324. # define LZO_OS_WIN64 1
  325. # define LZO_INFO_OS "win64"
  326. #elif defined(__WIN32__) || defined(_WIN32) || defined(WIN32) || defined(__WINDOWS_386__)
  327. # define LZO_OS_WIN32 1
  328. # define LZO_INFO_OS "win32"
  329. #elif defined(__MWERKS__) && defined(__INTEL__)
  330. # define LZO_OS_WIN32 1
  331. # define LZO_INFO_OS "win32"
  332. #elif defined(__WINDOWS__) || defined(_WINDOWS) || defined(_Windows)
  333. # if (UINT_MAX == LZO_0xffffL)
  334. # define LZO_OS_WIN16 1
  335. # define LZO_INFO_OS "win16"
  336. # elif (UINT_MAX == LZO_0xffffffffL)
  337. # define LZO_OS_WIN32 1
  338. # define LZO_INFO_OS "win32"
  339. # else
  340. # error "check your limits.h header"
  341. # endif
  342. #elif defined(__DOS__) || defined(__MSDOS__) || defined(_MSDOS) || defined(MSDOS) || (defined(__PACIFIC__) && defined(DOS))
  343. # if (UINT_MAX == LZO_0xffffL)
  344. # define LZO_OS_DOS16 1
  345. # define LZO_INFO_OS "dos16"
  346. # elif (UINT_MAX == LZO_0xffffffffL)
  347. # define LZO_OS_DOS32 1
  348. # define LZO_INFO_OS "dos32"
  349. # else
  350. # error "check your limits.h header"
  351. # endif
  352. #elif defined(__WATCOMC__)
  353. # if defined(__NT__) && (UINT_MAX == LZO_0xffffL)
  354. # define LZO_OS_DOS16 1
  355. # define LZO_INFO_OS "dos16"
  356. # elif defined(__NT__) && (__WATCOMC__ < 1100)
  357. # define LZO_OS_WIN32 1
  358. # define LZO_INFO_OS "win32"
  359. # elif defined(__linux__) || defined(__LINUX__)
  360. # define LZO_OS_POSIX 1
  361. # define LZO_INFO_OS "posix"
  362. # else
  363. # error "please specify a target using the -bt compiler option"
  364. # endif
  365. #elif defined(__palmos__)
  366. # define LZO_OS_PALMOS 1
  367. # define LZO_INFO_OS "palmos"
  368. #elif defined(__TOS__) || defined(__atarist__)
  369. # define LZO_OS_TOS 1
  370. # define LZO_INFO_OS "tos"
  371. #elif defined(macintosh) && !defined(__ppc__)
  372. # define LZO_OS_MACCLASSIC 1
  373. # define LZO_INFO_OS "macclassic"
  374. #elif defined(__VMS)
  375. # define LZO_OS_VMS 1
  376. # define LZO_INFO_OS "vms"
  377. #elif ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__))
  378. # define LZO_OS_CONSOLE 1
  379. # define LZO_OS_CONSOLE_PS2 1
  380. # define LZO_INFO_OS "console"
  381. # define LZO_INFO_OS_CONSOLE "ps2"
  382. #elif (defined(__mips__) && defined(__psp__))
  383. # define LZO_OS_CONSOLE 1
  384. # define LZO_OS_CONSOLE_PSP 1
  385. # define LZO_INFO_OS "console"
  386. # define LZO_INFO_OS_CONSOLE "psp"
  387. #else
  388. # define LZO_OS_POSIX 1
  389. # define LZO_INFO_OS "posix"
  390. #endif
  391. #if (LZO_OS_POSIX)
  392. # if defined(_AIX) || defined(__AIX__) || defined(__aix__)
  393. # define LZO_OS_POSIX_AIX 1
  394. # define LZO_INFO_OS_POSIX "aix"
  395. # elif defined(__FreeBSD__)
  396. # define LZO_OS_POSIX_FREEBSD 1
  397. # define LZO_INFO_OS_POSIX "freebsd"
  398. # elif defined(__hpux__) || defined(__hpux)
  399. # define LZO_OS_POSIX_HPUX 1
  400. # define LZO_INFO_OS_POSIX "hpux"
  401. # elif defined(__INTERIX)
  402. # define LZO_OS_POSIX_INTERIX 1
  403. # define LZO_INFO_OS_POSIX "interix"
  404. # elif defined(__IRIX__) || defined(__irix__)
  405. # define LZO_OS_POSIX_IRIX 1
  406. # define LZO_INFO_OS_POSIX "irix"
  407. # elif defined(__linux__) || defined(__linux) || defined(__LINUX__)
  408. # define LZO_OS_POSIX_LINUX 1
  409. # define LZO_INFO_OS_POSIX "linux"
  410. # elif defined(__APPLE__) || defined(__MACOS__)
  411. # define LZO_OS_POSIX_MACOSX 1
  412. # define LZO_INFO_OS_POSIX "macosx"
  413. # elif defined(__minix__) || defined(__minix)
  414. # define LZO_OS_POSIX_MINIX 1
  415. # define LZO_INFO_OS_POSIX "minix"
  416. # elif defined(__NetBSD__)
  417. # define LZO_OS_POSIX_NETBSD 1
  418. # define LZO_INFO_OS_POSIX "netbsd"
  419. # elif defined(__OpenBSD__)
  420. # define LZO_OS_POSIX_OPENBSD 1
  421. # define LZO_INFO_OS_POSIX "openbsd"
  422. # elif defined(__osf__)
  423. # define LZO_OS_POSIX_OSF 1
  424. # define LZO_INFO_OS_POSIX "osf"
  425. # elif defined(__solaris__) || defined(__sun)
  426. # if defined(__SVR4) || defined(__svr4__)
  427. # define LZO_OS_POSIX_SOLARIS 1
  428. # define LZO_INFO_OS_POSIX "solaris"
  429. # else
  430. # define LZO_OS_POSIX_SUNOS 1
  431. # define LZO_INFO_OS_POSIX "sunos"
  432. # endif
  433. # elif defined(__ultrix__) || defined(__ultrix)
  434. # define LZO_OS_POSIX_ULTRIX 1
  435. # define LZO_INFO_OS_POSIX "ultrix"
  436. # elif defined(_UNICOS)
  437. # define LZO_OS_POSIX_UNICOS 1
  438. # define LZO_INFO_OS_POSIX "unicos"
  439. # else
  440. # define LZO_OS_POSIX_UNKNOWN 1
  441. # define LZO_INFO_OS_POSIX "unknown"
  442. # endif
  443. #endif
  444. #endif
  445. #if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16)
  446. # if (UINT_MAX != LZO_0xffffL)
  447. # error "this should not happen"
  448. # endif
  449. # if (ULONG_MAX != LZO_0xffffffffL)
  450. # error "this should not happen"
  451. # endif
  452. #endif
  453. #if (LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_WIN32 || LZO_OS_WIN64)
  454. # if (UINT_MAX != LZO_0xffffffffL)
  455. # error "this should not happen"
  456. # endif
  457. # if (ULONG_MAX != LZO_0xffffffffL)
  458. # error "this should not happen"
  459. # endif
  460. #endif
  461. #if defined(CIL) && defined(_GNUCC) && defined(__GNUC__)
  462. # define LZO_CC_CILLY 1
  463. # define LZO_INFO_CC "Cilly"
  464. # if defined(__CILLY__)
  465. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__CILLY__)
  466. # else
  467. # define LZO_INFO_CCVER "unknown"
  468. # endif
  469. #elif 0 && defined(SDCC) && defined(__VERSION__) && !defined(__GNUC__)
  470. # define LZO_CC_SDCC 1
  471. # define LZO_INFO_CC "sdcc"
  472. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(SDCC)
  473. #elif defined(__PATHSCALE__) && defined(__PATHCC_PATCHLEVEL__)
  474. # define LZO_CC_PATHSCALE (__PATHCC__ * 0x10000L + __PATHCC_MINOR__ * 0x100 + __PATHCC_PATCHLEVEL__)
  475. # define LZO_INFO_CC "Pathscale C"
  476. # define LZO_INFO_CCVER __PATHSCALE__
  477. #elif defined(__INTEL_COMPILER)
  478. # define LZO_CC_INTELC 1
  479. # define LZO_INFO_CC "Intel C"
  480. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__INTEL_COMPILER)
  481. # if defined(_WIN32) || defined(_WIN64)
  482. # define LZO_CC_SYNTAX_MSC 1
  483. # else
  484. # define LZO_CC_SYNTAX_GNUC 1
  485. # endif
  486. #elif defined(__POCC__) && defined(_WIN32)
  487. # define LZO_CC_PELLESC 1
  488. # define LZO_INFO_CC "Pelles C"
  489. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__POCC__)
  490. #elif defined(__clang__) && defined(__llvm__) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__)
  491. # if defined(__GNUC_PATCHLEVEL__)
  492. # define LZO_CC_CLANG_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__)
  493. # else
  494. # define LZO_CC_CLANG_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100)
  495. # endif
  496. # if defined(__clang_major__) && defined(__clang_minor__) && defined(__clang_patchlevel__)
  497. # define LZO_CC_CLANG_CLANG (__clang_major__ * 0x10000L + __clang_minor__ * 0x100 + __clang_patchlevel__)
  498. # else
  499. # define LZO_CC_CLANG_CLANG 0x010000L
  500. # endif
  501. # define LZO_CC_CLANG LZO_CC_CLANG_GNUC
  502. # define LZO_INFO_CC "clang"
  503. # define LZO_INFO_CCVER __VERSION__
  504. #elif defined(__llvm__) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__)
  505. # if defined(__GNUC_PATCHLEVEL__)
  506. # define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__)
  507. # else
  508. # define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100)
  509. # endif
  510. # define LZO_CC_LLVM LZO_CC_LLVM_GNUC
  511. # define LZO_INFO_CC "llvm-gcc"
  512. # define LZO_INFO_CCVER __VERSION__
  513. #elif defined(__GNUC__) && defined(__VERSION__)
  514. # if defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__)
  515. # define LZO_CC_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__)
  516. # elif defined(__GNUC_MINOR__)
  517. # define LZO_CC_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100)
  518. # else
  519. # define LZO_CC_GNUC (__GNUC__ * 0x10000L)
  520. # endif
  521. # define LZO_INFO_CC "gcc"
  522. # define LZO_INFO_CCVER __VERSION__
  523. #elif defined(__ACK__) && defined(_ACK)
  524. # define LZO_CC_ACK 1
  525. # define LZO_INFO_CC "Amsterdam Compiler Kit C"
  526. # define LZO_INFO_CCVER "unknown"
  527. #elif defined(__AZTEC_C__)
  528. # define LZO_CC_AZTECC 1
  529. # define LZO_INFO_CC "Aztec C"
  530. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__AZTEC_C__)
  531. #elif defined(__CODEGEARC__)
  532. # define LZO_CC_CODEGEARC 1
  533. # define LZO_INFO_CC "CodeGear C"
  534. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__CODEGEARC__)
  535. #elif defined(__BORLANDC__)
  536. # define LZO_CC_BORLANDC 1
  537. # define LZO_INFO_CC "Borland C"
  538. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__BORLANDC__)
  539. #elif defined(_CRAYC) && defined(_RELEASE)
  540. # define LZO_CC_CRAYC 1
  541. # define LZO_INFO_CC "Cray C"
  542. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_RELEASE)
  543. #elif defined(__DMC__) && defined(__SC__)
  544. # define LZO_CC_DMC 1
  545. # define LZO_INFO_CC "Digital Mars C"
  546. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__DMC__)
  547. #elif defined(__DECC)
  548. # define LZO_CC_DECC 1
  549. # define LZO_INFO_CC "DEC C"
  550. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__DECC)
  551. #elif defined(__HIGHC__)
  552. # define LZO_CC_HIGHC 1
  553. # define LZO_INFO_CC "MetaWare High C"
  554. # define LZO_INFO_CCVER "unknown"
  555. #elif defined(__IAR_SYSTEMS_ICC__)
  556. # define LZO_CC_IARC 1
  557. # define LZO_INFO_CC "IAR C"
  558. # if defined(__VER__)
  559. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__VER__)
  560. # else
  561. # define LZO_INFO_CCVER "unknown"
  562. # endif
  563. #elif defined(__IBMC__)
  564. # define LZO_CC_IBMC 1
  565. # define LZO_INFO_CC "IBM C"
  566. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__IBMC__)
  567. #elif defined(__KEIL__) && defined(__C166__)
  568. # define LZO_CC_KEILC 1
  569. # define LZO_INFO_CC "Keil C"
  570. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__C166__)
  571. #elif defined(__LCC__) && defined(_WIN32) && defined(__LCCOPTIMLEVEL)
  572. # define LZO_CC_LCCWIN32 1
  573. # define LZO_INFO_CC "lcc-win32"
  574. # define LZO_INFO_CCVER "unknown"
  575. #elif defined(__LCC__)
  576. # define LZO_CC_LCC 1
  577. # define LZO_INFO_CC "lcc"
  578. # if defined(__LCC_VERSION__)
  579. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__LCC_VERSION__)
  580. # else
  581. # define LZO_INFO_CCVER "unknown"
  582. # endif
  583. #elif defined(_MSC_VER)
  584. # define LZO_CC_MSC 1
  585. # define LZO_INFO_CC "Microsoft C"
  586. # if defined(_MSC_FULL_VER)
  587. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) "." LZO_PP_MACRO_EXPAND(_MSC_FULL_VER)
  588. # else
  589. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER)
  590. # endif
  591. #elif defined(__MWERKS__)
  592. # define LZO_CC_MWERKS 1
  593. # define LZO_INFO_CC "Metrowerks C"
  594. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__MWERKS__)
  595. #elif (defined(__NDPC__) || defined(__NDPX__)) && defined(__i386)
  596. # define LZO_CC_NDPC 1
  597. # define LZO_INFO_CC "Microway NDP C"
  598. # define LZO_INFO_CCVER "unknown"
  599. #elif defined(__PACIFIC__)
  600. # define LZO_CC_PACIFICC 1
  601. # define LZO_INFO_CC "Pacific C"
  602. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PACIFIC__)
  603. #elif defined(__PGI) && (defined(__linux__) || defined(__WIN32__))
  604. # define LZO_CC_PGI 1
  605. # define LZO_INFO_CC "Portland Group PGI C"
  606. # define LZO_INFO_CCVER "unknown"
  607. #elif defined(__PUREC__) && defined(__TOS__)
  608. # define LZO_CC_PUREC 1
  609. # define LZO_INFO_CC "Pure C"
  610. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PUREC__)
  611. #elif defined(__SC__) && defined(__ZTC__)
  612. # define LZO_CC_SYMANTECC 1
  613. # define LZO_INFO_CC "Symantec C"
  614. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SC__)
  615. #elif defined(__SUNPRO_C)
  616. # define LZO_INFO_CC "SunPro C"
  617. # if ((__SUNPRO_C)+0 > 0)
  618. # define LZO_CC_SUNPROC __SUNPRO_C
  619. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_C)
  620. # else
  621. # define LZO_CC_SUNPROC 1
  622. # define LZO_INFO_CCVER "unknown"
  623. # endif
  624. #elif defined(__SUNPRO_CC)
  625. # define LZO_INFO_CC "SunPro C"
  626. # if ((__SUNPRO_CC)+0 > 0)
  627. # define LZO_CC_SUNPROC __SUNPRO_CC
  628. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_CC)
  629. # else
  630. # define LZO_CC_SUNPROC 1
  631. # define LZO_INFO_CCVER "unknown"
  632. # endif
  633. #elif defined(__TINYC__)
  634. # define LZO_CC_TINYC 1
  635. # define LZO_INFO_CC "Tiny C"
  636. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__TINYC__)
  637. #elif defined(__TSC__)
  638. # define LZO_CC_TOPSPEEDC 1
  639. # define LZO_INFO_CC "TopSpeed C"
  640. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__TSC__)
  641. #elif defined(__WATCOMC__)
  642. # define LZO_CC_WATCOMC 1
  643. # define LZO_INFO_CC "Watcom C"
  644. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__WATCOMC__)
  645. #elif defined(__TURBOC__)
  646. # define LZO_CC_TURBOC 1
  647. # define LZO_INFO_CC "Turbo C"
  648. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__TURBOC__)
  649. #elif defined(__ZTC__)
  650. # define LZO_CC_ZORTECHC 1
  651. # define LZO_INFO_CC "Zortech C"
  652. # if (__ZTC__ == 0x310)
  653. # define LZO_INFO_CCVER "0x310"
  654. # else
  655. # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__ZTC__)
  656. # endif
  657. #else
  658. # define LZO_CC_UNKNOWN 1
  659. # define LZO_INFO_CC "unknown"
  660. # define LZO_INFO_CCVER "unknown"
  661. #endif
  662. #if 0 && (LZO_CC_MSC && (_MSC_VER >= 1200)) && !defined(_MSC_FULL_VER)
  663. # error "LZO_CC_MSC: _MSC_FULL_VER is not defined"
  664. #endif
  665. #if !defined(__LZO_ARCH_OVERRIDE) && !(LZO_ARCH_GENERIC) && defined(_CRAY)
  666. # if (UINT_MAX > LZO_0xffffffffL) && defined(_CRAY)
  667. # if defined(_CRAYMPP) || defined(_CRAYT3D) || defined(_CRAYT3E)
  668. # define LZO_ARCH_CRAY_MPP 1
  669. # elif defined(_CRAY1)
  670. # define LZO_ARCH_CRAY_PVP 1
  671. # endif
  672. # endif
  673. #endif
  674. #if !defined(__LZO_ARCH_OVERRIDE)
  675. #if (LZO_ARCH_GENERIC)
  676. # define LZO_INFO_ARCH "generic"
  677. #elif (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16)
  678. # define LZO_ARCH_I086 1
  679. # define LZO_ARCH_IA16 1
  680. # define LZO_INFO_ARCH "i086"
  681. #elif defined(__alpha__) || defined(__alpha) || defined(_M_ALPHA)
  682. # define LZO_ARCH_ALPHA 1
  683. # define LZO_INFO_ARCH "alpha"
  684. #elif (LZO_ARCH_CRAY_MPP) && (defined(_CRAYT3D) || defined(_CRAYT3E))
  685. # define LZO_ARCH_ALPHA 1
  686. # define LZO_INFO_ARCH "alpha"
  687. #elif defined(__amd64__) || defined(__x86_64__) || defined(_M_AMD64)
  688. # define LZO_ARCH_AMD64 1
  689. # define LZO_INFO_ARCH "amd64"
  690. #elif defined(__thumb__) || (defined(_M_ARM) && defined(_M_THUMB))
  691. # define LZO_ARCH_ARM 1
  692. # define LZO_ARCH_ARM_THUMB 1
  693. # define LZO_INFO_ARCH "arm_thumb"
  694. #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCARM__)
  695. # define LZO_ARCH_ARM 1
  696. # if defined(__CPU_MODE__) && ((__CPU_MODE__)+0 == 1)
  697. # define LZO_ARCH_ARM_THUMB 1
  698. # define LZO_INFO_ARCH "arm_thumb"
  699. # elif defined(__CPU_MODE__) && ((__CPU_MODE__)+0 == 2)
  700. # define LZO_INFO_ARCH "arm"
  701. # else
  702. # define LZO_INFO_ARCH "arm"
  703. # endif
  704. #elif defined(__arm__) || defined(_M_ARM)
  705. # define LZO_ARCH_ARM 1
  706. # define LZO_INFO_ARCH "arm"
  707. #elif (UINT_MAX <= LZO_0xffffL) && defined(__AVR__)
  708. # define LZO_ARCH_AVR 1
  709. # define LZO_INFO_ARCH "avr"
  710. #elif defined(__avr32__) || defined(__AVR32__)
  711. # define LZO_ARCH_AVR32 1
  712. # define LZO_INFO_ARCH "avr32"
  713. #elif defined(__bfin__)
  714. # define LZO_ARCH_BLACKFIN 1
  715. # define LZO_INFO_ARCH "blackfin"
  716. #elif (UINT_MAX == LZO_0xffffL) && defined(__C166__)
  717. # define LZO_ARCH_C166 1
  718. # define LZO_INFO_ARCH "c166"
  719. #elif defined(__cris__)
  720. # define LZO_ARCH_CRIS 1
  721. # define LZO_INFO_ARCH "cris"
  722. #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCEZ80__)
  723. # define LZO_ARCH_EZ80 1
  724. # define LZO_INFO_ARCH "ez80"
  725. #elif defined(__H8300__) || defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__)
  726. # define LZO_ARCH_H8300 1
  727. # define LZO_INFO_ARCH "h8300"
  728. #elif defined(__hppa__) || defined(__hppa)
  729. # define LZO_ARCH_HPPA 1
  730. # define LZO_INFO_ARCH "hppa"
  731. #elif defined(__386__) || defined(__i386__) || defined(__i386) || defined(_M_IX86) || defined(_M_I386)
  732. # define LZO_ARCH_I386 1
  733. # define LZO_ARCH_IA32 1
  734. # define LZO_INFO_ARCH "i386"
  735. #elif (LZO_CC_ZORTECHC && defined(__I86__))
  736. # define LZO_ARCH_I386 1
  737. # define LZO_ARCH_IA32 1
  738. # define LZO_INFO_ARCH "i386"
  739. #elif (LZO_OS_DOS32 && LZO_CC_HIGHC) && defined(_I386)
  740. # define LZO_ARCH_I386 1
  741. # define LZO_ARCH_IA32 1
  742. # define LZO_INFO_ARCH "i386"
  743. #elif defined(__ia64__) || defined(__ia64) || defined(_M_IA64)
  744. # define LZO_ARCH_IA64 1
  745. # define LZO_INFO_ARCH "ia64"
  746. #elif (UINT_MAX == LZO_0xffffL) && defined(__m32c__)
  747. # define LZO_ARCH_M16C 1
  748. # define LZO_INFO_ARCH "m16c"
  749. #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCM16C__)
  750. # define LZO_ARCH_M16C 1
  751. # define LZO_INFO_ARCH "m16c"
  752. #elif defined(__m32r__)
  753. # define LZO_ARCH_M32R 1
  754. # define LZO_INFO_ARCH "m32r"
  755. #elif (LZO_OS_TOS) || defined(__m68k__) || defined(__m68000__) || defined(__mc68000__) || defined(__mc68020__) || defined(_M_M68K)
  756. # define LZO_ARCH_M68K 1
  757. # define LZO_INFO_ARCH "m68k"
  758. #elif (UINT_MAX == LZO_0xffffL) && defined(__C251__)
  759. # define LZO_ARCH_MCS251 1
  760. # define LZO_INFO_ARCH "mcs251"
  761. #elif (UINT_MAX == LZO_0xffffL) && defined(__C51__)
  762. # define LZO_ARCH_MCS51 1
  763. # define LZO_INFO_ARCH "mcs51"
  764. #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICC8051__)
  765. # define LZO_ARCH_MCS51 1
  766. # define LZO_INFO_ARCH "mcs51"
  767. #elif defined(__mips__) || defined(__mips) || defined(_MIPS_ARCH) || defined(_M_MRX000)
  768. # define LZO_ARCH_MIPS 1
  769. # define LZO_INFO_ARCH "mips"
  770. #elif (UINT_MAX == LZO_0xffffL) && defined(__MSP430__)
  771. # define LZO_ARCH_MSP430 1
  772. # define LZO_INFO_ARCH "msp430"
  773. #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICC430__)
  774. # define LZO_ARCH_MSP430 1
  775. # define LZO_INFO_ARCH "msp430"
  776. #elif defined(__powerpc__) || defined(__powerpc) || defined(__ppc__) || defined(__PPC__) || defined(_M_PPC) || defined(_ARCH_PPC) || defined(_ARCH_PWR)
  777. # define LZO_ARCH_POWERPC 1
  778. # define LZO_INFO_ARCH "powerpc"
  779. #elif defined(__s390__) || defined(__s390) || defined(__s390x__) || defined(__s390x)
  780. # define LZO_ARCH_S390 1
  781. # define LZO_INFO_ARCH "s390"
  782. #elif defined(__sh__) || defined(_M_SH)
  783. # define LZO_ARCH_SH 1
  784. # define LZO_INFO_ARCH "sh"
  785. #elif defined(__sparc__) || defined(__sparc) || defined(__sparcv8)
  786. # define LZO_ARCH_SPARC 1
  787. # define LZO_INFO_ARCH "sparc"
  788. #elif defined(__SPU__)
  789. # define LZO_ARCH_SPU 1
  790. # define LZO_INFO_ARCH "spu"
  791. #elif (UINT_MAX == LZO_0xffffL) && defined(__z80)
  792. # define LZO_ARCH_Z80 1
  793. # define LZO_INFO_ARCH "z80"
  794. #elif (LZO_ARCH_CRAY_PVP)
  795. # if defined(_CRAYSV1)
  796. # define LZO_ARCH_CRAY_SV1 1
  797. # define LZO_INFO_ARCH "cray_sv1"
  798. # elif (_ADDR64)
  799. # define LZO_ARCH_CRAY_T90 1
  800. # define LZO_INFO_ARCH "cray_t90"
  801. # elif (_ADDR32)
  802. # define LZO_ARCH_CRAY_YMP 1
  803. # define LZO_INFO_ARCH "cray_ymp"
  804. # else
  805. # define LZO_ARCH_CRAY_XMP 1
  806. # define LZO_INFO_ARCH "cray_xmp"
  807. # endif
  808. #else
  809. # define LZO_ARCH_UNKNOWN 1
  810. # define LZO_INFO_ARCH "unknown"
  811. #endif
  812. #endif
  813. #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_DOS32 || LZO_OS_OS2)
  814. # error "FIXME - missing define for CPU architecture"
  815. #endif
  816. #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN32)
  817. # error "FIXME - missing WIN32 define for CPU architecture"
  818. #endif
  819. #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN64)
  820. # error "FIXME - missing WIN64 define for CPU architecture"
  821. #endif
  822. #if (LZO_OS_OS216 || LZO_OS_WIN16)
  823. # define LZO_ARCH_I086PM 1
  824. # define LZO_ARCH_IA16PM 1
  825. #elif 1 && (LZO_OS_DOS16 && defined(BLX286))
  826. # define LZO_ARCH_I086PM 1
  827. # define LZO_ARCH_IA16PM 1
  828. #elif 1 && (LZO_OS_DOS16 && defined(DOSX286))
  829. # define LZO_ARCH_I086PM 1
  830. # define LZO_ARCH_IA16PM 1
  831. #elif 1 && (LZO_OS_DOS16 && LZO_CC_BORLANDC && defined(__DPMI16__))
  832. # define LZO_ARCH_I086PM 1
  833. # define LZO_ARCH_IA16PM 1
  834. #endif
  835. #if (LZO_ARCH_ARM_THUMB) && !(LZO_ARCH_ARM)
  836. # error "this should not happen"
  837. #endif
  838. #if (LZO_ARCH_I086PM) && !(LZO_ARCH_I086)
  839. # error "this should not happen"
  840. #endif
  841. #if (LZO_ARCH_I086)
  842. # if (UINT_MAX != LZO_0xffffL)
  843. # error "this should not happen"
  844. # endif
  845. # if (ULONG_MAX != LZO_0xffffffffL)
  846. # error "this should not happen"
  847. # endif
  848. #endif
  849. #if (LZO_ARCH_I386)
  850. # if (UINT_MAX != LZO_0xffffL) && defined(__i386_int16__)
  851. # error "this should not happen"
  852. # endif
  853. # if (UINT_MAX != LZO_0xffffffffL) && !defined(__i386_int16__)
  854. # error "this should not happen"
  855. # endif
  856. # if (ULONG_MAX != LZO_0xffffffffL)
  857. # error "this should not happen"
  858. # endif
  859. #endif
  860. #if !defined(__LZO_MM_OVERRIDE)
  861. #if (LZO_ARCH_I086)
  862. #if (UINT_MAX != LZO_0xffffL)
  863. # error "this should not happen"
  864. #endif
  865. #if defined(__TINY__) || defined(M_I86TM) || defined(_M_I86TM)
  866. # define LZO_MM_TINY 1
  867. #elif defined(__HUGE__) || defined(_HUGE_) || defined(M_I86HM) || defined(_M_I86HM)
  868. # define LZO_MM_HUGE 1
  869. #elif defined(__SMALL__) || defined(M_I86SM) || defined(_M_I86SM) || defined(SMALL_MODEL)
  870. # define LZO_MM_SMALL 1
  871. #elif defined(__MEDIUM__) || defined(M_I86MM) || defined(_M_I86MM)
  872. # define LZO_MM_MEDIUM 1
  873. #elif defined(__COMPACT__) || defined(M_I86CM) || defined(_M_I86CM)
  874. # define LZO_MM_COMPACT 1
  875. #elif defined(__LARGE__) || defined(M_I86LM) || defined(_M_I86LM) || defined(LARGE_MODEL)
  876. # define LZO_MM_LARGE 1
  877. #elif (LZO_CC_AZTECC)
  878. # if defined(_LARGE_CODE) && defined(_LARGE_DATA)
  879. # define LZO_MM_LARGE 1
  880. # elif defined(_LARGE_CODE)
  881. # define LZO_MM_MEDIUM 1
  882. # elif defined(_LARGE_DATA)
  883. # define LZO_MM_COMPACT 1
  884. # else
  885. # define LZO_MM_SMALL 1
  886. # endif
  887. #elif (LZO_CC_ZORTECHC && defined(__VCM__))
  888. # define LZO_MM_LARGE 1
  889. #else
  890. # error "unknown memory model"
  891. #endif
  892. #if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16)
  893. #define LZO_HAVE_MM_HUGE_PTR 1
  894. #define LZO_HAVE_MM_HUGE_ARRAY 1
  895. #if (LZO_MM_TINY)
  896. # undef LZO_HAVE_MM_HUGE_ARRAY
  897. #endif
  898. #if (LZO_CC_AZTECC || LZO_CC_PACIFICC || LZO_CC_ZORTECHC)
  899. # undef LZO_HAVE_MM_HUGE_PTR
  900. # undef LZO_HAVE_MM_HUGE_ARRAY
  901. #elif (LZO_CC_DMC || LZO_CC_SYMANTECC)
  902. # undef LZO_HAVE_MM_HUGE_ARRAY
  903. #elif (LZO_CC_MSC && defined(_QC))
  904. # undef LZO_HAVE_MM_HUGE_ARRAY
  905. # if (_MSC_VER < 600)
  906. # undef LZO_HAVE_MM_HUGE_PTR
  907. # endif
  908. #elif (LZO_CC_TURBOC && (__TURBOC__ < 0x0295))
  909. # undef LZO_HAVE_MM_HUGE_ARRAY
  910. #endif
  911. #if (LZO_ARCH_I086PM) && !(LZO_HAVE_MM_HUGE_PTR)
  912. # if (LZO_OS_DOS16)
  913. # error "this should not happen"
  914. # elif (LZO_CC_ZORTECHC)
  915. # else
  916. # error "this should not happen"
  917. # endif
  918. #endif
  919. #ifdef __cplusplus
  920. extern "C" {
  921. #endif
  922. #if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0200))
  923. extern void __near __cdecl _AHSHIFT(void);
  924. # define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT)
  925. #elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC)
  926. extern void __near __cdecl _AHSHIFT(void);
  927. # define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT)
  928. #elif (LZO_CC_MSC || LZO_CC_TOPSPEEDC)
  929. extern void __near __cdecl _AHSHIFT(void);
  930. # define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT)
  931. #elif (LZO_CC_TURBOC && (__TURBOC__ >= 0x0295))
  932. extern void __near __cdecl _AHSHIFT(void);
  933. # define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT)
  934. #elif ((LZO_CC_AZTECC || LZO_CC_PACIFICC || LZO_CC_TURBOC) && LZO_OS_DOS16)
  935. # define LZO_MM_AHSHIFT 12
  936. #elif (LZO_CC_WATCOMC)
  937. extern unsigned char _HShift;
  938. # define LZO_MM_AHSHIFT ((unsigned) _HShift)
  939. #else
  940. # error "FIXME - implement LZO_MM_AHSHIFT"
  941. #endif
  942. #ifdef __cplusplus
  943. }
  944. #endif
  945. #endif
  946. #elif (LZO_ARCH_C166)
  947. #if !defined(__MODEL__)
  948. # error "FIXME - C166 __MODEL__"
  949. #elif ((__MODEL__) == 0)
  950. # define LZO_MM_SMALL 1
  951. #elif ((__MODEL__) == 1)
  952. # define LZO_MM_SMALL 1
  953. #elif ((__MODEL__) == 2)
  954. # define LZO_MM_LARGE 1
  955. #elif ((__MODEL__) == 3)
  956. # define LZO_MM_TINY 1
  957. #elif ((__MODEL__) == 4)
  958. # define LZO_MM_XTINY 1
  959. #elif ((__MODEL__) == 5)
  960. # define LZO_MM_XSMALL 1
  961. #else
  962. # error "FIXME - C166 __MODEL__"
  963. #endif
  964. #elif (LZO_ARCH_MCS251)
  965. #if !defined(__MODEL__)
  966. # error "FIXME - MCS251 __MODEL__"
  967. #elif ((__MODEL__) == 0)
  968. # define LZO_MM_SMALL 1
  969. #elif ((__MODEL__) == 2)
  970. # define LZO_MM_LARGE 1
  971. #elif ((__MODEL__) == 3)
  972. # define LZO_MM_TINY 1
  973. #elif ((__MODEL__) == 4)
  974. # define LZO_MM_XTINY 1
  975. #elif ((__MODEL__) == 5)
  976. # define LZO_MM_XSMALL 1
  977. #else
  978. # error "FIXME - MCS251 __MODEL__"
  979. #endif
  980. #elif (LZO_ARCH_MCS51)
  981. #if !defined(__MODEL__)
  982. # error "FIXME - MCS51 __MODEL__"
  983. #elif ((__MODEL__) == 1)
  984. # define LZO_MM_SMALL 1
  985. #elif ((__MODEL__) == 2)
  986. # define LZO_MM_LARGE 1
  987. #elif ((__MODEL__) == 3)
  988. # define LZO_MM_TINY 1
  989. #elif ((__MODEL__) == 4)
  990. # define LZO_MM_XTINY 1
  991. #elif ((__MODEL__) == 5)
  992. # define LZO_MM_XSMALL 1
  993. #else
  994. # error "FIXME - MCS51 __MODEL__"
  995. #endif
  996. #elif (LZO_ARCH_CRAY_PVP)
  997. # define LZO_MM_PVP 1
  998. #else
  999. # define LZO_MM_FLAT 1
  1000. #endif
  1001. #if (LZO_MM_COMPACT)
  1002. # define LZO_INFO_MM "compact"
  1003. #elif (LZO_MM_FLAT)
  1004. # define LZO_INFO_MM "flat"
  1005. #elif (LZO_MM_HUGE)
  1006. # define LZO_INFO_MM "huge"
  1007. #elif (LZO_MM_LARGE)
  1008. # define LZO_INFO_MM "large"
  1009. #elif (LZO_MM_MEDIUM)
  1010. # define LZO_INFO_MM "medium"
  1011. #elif (LZO_MM_PVP)
  1012. # define LZO_INFO_MM "pvp"
  1013. #elif (LZO_MM_SMALL)
  1014. # define LZO_INFO_MM "small"
  1015. #elif (LZO_MM_TINY)
  1016. # define LZO_INFO_MM "tiny"
  1017. #else
  1018. # error "unknown memory model"
  1019. #endif
  1020. #endif
  1021. #if defined(SIZEOF_SHORT)
  1022. # define LZO_SIZEOF_SHORT (SIZEOF_SHORT)
  1023. #endif
  1024. #if defined(SIZEOF_INT)
  1025. # define LZO_SIZEOF_INT (SIZEOF_INT)
  1026. #endif
  1027. #if defined(SIZEOF_LONG)
  1028. # define LZO_SIZEOF_LONG (SIZEOF_LONG)
  1029. #endif
  1030. #if defined(SIZEOF_LONG_LONG)
  1031. # define LZO_SIZEOF_LONG_LONG (SIZEOF_LONG_LONG)
  1032. #endif
  1033. #if defined(SIZEOF___INT16)
  1034. # define LZO_SIZEOF___INT16 (SIZEOF___INT16)
  1035. #endif
  1036. #if defined(SIZEOF___INT32)
  1037. # define LZO_SIZEOF___INT32 (SIZEOF___INT32)
  1038. #endif
  1039. #if defined(SIZEOF___INT64)
  1040. # define LZO_SIZEOF___INT64 (SIZEOF___INT64)
  1041. #endif
  1042. #if defined(SIZEOF_VOID_P)
  1043. # define LZO_SIZEOF_VOID_P (SIZEOF_VOID_P)
  1044. #endif
  1045. #if defined(SIZEOF_SIZE_T)
  1046. # define LZO_SIZEOF_SIZE_T (SIZEOF_SIZE_T)
  1047. #endif
  1048. #if defined(SIZEOF_PTRDIFF_T)
  1049. # define LZO_SIZEOF_PTRDIFF_T (SIZEOF_PTRDIFF_T)
  1050. #endif
  1051. #define __LZO_LSR(x,b) (((x)+0ul) >> (b))
  1052. #if !defined(LZO_SIZEOF_SHORT)
  1053. # if (LZO_ARCH_CRAY_PVP)
  1054. # define LZO_SIZEOF_SHORT 8
  1055. # elif (USHRT_MAX == LZO_0xffffL)
  1056. # define LZO_SIZEOF_SHORT 2
  1057. # elif (__LZO_LSR(USHRT_MAX,7) == 1)
  1058. # define LZO_SIZEOF_SHORT 1
  1059. # elif (__LZO_LSR(USHRT_MAX,15) == 1)
  1060. # define LZO_SIZEOF_SHORT 2
  1061. # elif (__LZO_LSR(USHRT_MAX,31) == 1)
  1062. # define LZO_SIZEOF_SHORT 4
  1063. # elif (__LZO_LSR(USHRT_MAX,63) == 1)
  1064. # define LZO_SIZEOF_SHORT 8
  1065. # elif (__LZO_LSR(USHRT_MAX,127) == 1)
  1066. # define LZO_SIZEOF_SHORT 16
  1067. # else
  1068. # error "LZO_SIZEOF_SHORT"
  1069. # endif
  1070. #endif
  1071. #if !defined(LZO_SIZEOF_INT)
  1072. # if (LZO_ARCH_CRAY_PVP)
  1073. # define LZO_SIZEOF_INT 8
  1074. # elif (UINT_MAX == LZO_0xffffL)
  1075. # define LZO_SIZEOF_INT 2
  1076. # elif (UINT_MAX == LZO_0xffffffffL)
  1077. # define LZO_SIZEOF_INT 4
  1078. # elif (__LZO_LSR(UINT_MAX,7) == 1)
  1079. # define LZO_SIZEOF_INT 1
  1080. # elif (__LZO_LSR(UINT_MAX,15) == 1)
  1081. # define LZO_SIZEOF_INT 2
  1082. # elif (__LZO_LSR(UINT_MAX,31) == 1)
  1083. # define LZO_SIZEOF_INT 4
  1084. # elif (__LZO_LSR(UINT_MAX,63) == 1)
  1085. # define LZO_SIZEOF_INT 8
  1086. # elif (__LZO_LSR(UINT_MAX,127) == 1)
  1087. # define LZO_SIZEOF_INT 16
  1088. # else
  1089. # error "LZO_SIZEOF_INT"
  1090. # endif
  1091. #endif
  1092. #if !defined(LZO_SIZEOF_LONG)
  1093. # if (ULONG_MAX == LZO_0xffffffffL)
  1094. # define LZO_SIZEOF_LONG 4
  1095. # elif (__LZO_LSR(ULONG_MAX,7) == 1)
  1096. # define LZO_SIZEOF_LONG 1
  1097. # elif (__LZO_LSR(ULONG_MAX,15) == 1)
  1098. # define LZO_SIZEOF_LONG 2
  1099. # elif (__LZO_LSR(ULONG_MAX,31) == 1)
  1100. # define LZO_SIZEOF_LONG 4
  1101. # elif (__LZO_LSR(ULONG_MAX,63) == 1)
  1102. # define LZO_SIZEOF_LONG 8
  1103. # elif (__LZO_LSR(ULONG_MAX,127) == 1)
  1104. # define LZO_SIZEOF_LONG 16
  1105. # else
  1106. # error "LZO_SIZEOF_LONG"
  1107. # endif
  1108. #endif
  1109. #if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64)
  1110. #if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8)
  1111. # if defined(__LONG_MAX__) && defined(__LONG_LONG_MAX__)
  1112. # if (LZO_CC_GNUC >= 0x030300ul)
  1113. # if ((__LONG_MAX__)+0 == (__LONG_LONG_MAX__)+0)
  1114. # define LZO_SIZEOF_LONG_LONG LZO_SIZEOF_LONG
  1115. # elif (__LZO_LSR(__LONG_LONG_MAX__,30) == 1)
  1116. # define LZO_SIZEOF_LONG_LONG 4
  1117. # endif
  1118. # endif
  1119. # endif
  1120. #endif
  1121. #endif
  1122. #if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64)
  1123. #if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8)
  1124. #if (LZO_ARCH_I086 && LZO_CC_DMC)
  1125. #elif (LZO_CC_CILLY) && defined(__GNUC__)
  1126. # define LZO_SIZEOF_LONG_LONG 8
  1127. #elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE)
  1128. # define LZO_SIZEOF_LONG_LONG 8
  1129. #elif ((LZO_OS_WIN32 || LZO_OS_WIN64 || defined(_WIN32)) && LZO_CC_MSC && (_MSC_VER >= 1400))
  1130. # define LZO_SIZEOF_LONG_LONG 8
  1131. #elif (LZO_OS_WIN64 || defined(_WIN64))
  1132. # define LZO_SIZEOF___INT64 8
  1133. #elif (LZO_ARCH_I386 && (LZO_CC_DMC))
  1134. # define LZO_SIZEOF_LONG_LONG 8
  1135. #elif (LZO_ARCH_I386 && (LZO_CC_SYMANTECC && (__SC__ >= 0x700)))
  1136. # define LZO_SIZEOF_LONG_LONG 8
  1137. #elif (LZO_ARCH_I386 && (LZO_CC_INTELC && defined(__linux__)))
  1138. # define LZO_SIZEOF_LONG_LONG 8
  1139. #elif (LZO_ARCH_I386 && (LZO_CC_MWERKS || LZO_CC_PELLESC || LZO_CC_PGI || LZO_CC_SUNPROC))
  1140. # define LZO_SIZEOF_LONG_LONG 8
  1141. #elif (LZO_ARCH_I386 && (LZO_CC_INTELC || LZO_CC_MSC))
  1142. # define LZO_SIZEOF___INT64 8
  1143. #elif ((LZO_OS_WIN32 || defined(_WIN32)) && (LZO_CC_MSC))
  1144. # define LZO_SIZEOF___INT64 8
  1145. #elif (LZO_ARCH_I386 && (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0520)))
  1146. # define LZO_SIZEOF___INT64 8
  1147. #elif (LZO_ARCH_I386 && (LZO_CC_WATCOMC && (__WATCOMC__ >= 1100)))
  1148. # define LZO_SIZEOF___INT64 8
  1149. #elif (LZO_CC_WATCOMC && defined(_INTEGRAL_MAX_BITS) && (_INTEGRAL_MAX_BITS == 64))
  1150. # define LZO_SIZEOF___INT64 8
  1151. #elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__)
  1152. # define LZO_SIZEOF_LONG_LONG 8
  1153. #elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64)
  1154. # define LZO_SIZEOF_LONG_LONG 8
  1155. #elif (LZO_CC_SDCC) && (LZO_SIZEOF_INT == 2)
  1156. #elif 1 && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
  1157. # define LZO_SIZEOF_LONG_LONG 8
  1158. #endif
  1159. #endif
  1160. #endif
  1161. #if defined(__cplusplus) && (LZO_CC_GNUC)
  1162. # if (LZO_CC_GNUC < 0x020800ul)
  1163. # undef LZO_SIZEOF_LONG_LONG
  1164. # endif
  1165. #endif
  1166. #if (LZO_CFG_NO_LONG_LONG) || defined(__NO_LONG_LONG)
  1167. # undef LZO_SIZEOF_LONG_LONG
  1168. #endif
  1169. #if !defined(LZO_SIZEOF_VOID_P)
  1170. #if (LZO_ARCH_I086)
  1171. # define __LZO_WORDSIZE 2
  1172. # if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM)
  1173. # define LZO_SIZEOF_VOID_P 2
  1174. # elif (LZO_MM_COMPACT || LZO_MM_LARGE || LZO_MM_HUGE)
  1175. # define LZO_SIZEOF_VOID_P 4
  1176. # else
  1177. # error "LZO_MM"
  1178. # endif
  1179. #elif (LZO_ARCH_AVR || LZO_ARCH_Z80)
  1180. # define __LZO_WORDSIZE 1
  1181. # define LZO_SIZEOF_VOID_P 2
  1182. #elif (LZO_ARCH_C166 || LZO_ARCH_MCS51 || LZO_ARCH_MCS251 || LZO_ARCH_MSP430)
  1183. # define LZO_SIZEOF_VOID_P 2
  1184. #elif (LZO_ARCH_H8300)
  1185. # if defined(__NORMAL_MODE__)
  1186. # define __LZO_WORDSIZE 4
  1187. # define LZO_SIZEOF_VOID_P 2
  1188. # elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__)
  1189. # define __LZO_WORDSIZE 4
  1190. # define LZO_SIZEOF_VOID_P 4
  1191. # else
  1192. # define __LZO_WORDSIZE 2
  1193. # define LZO_SIZEOF_VOID_P 2
  1194. # endif
  1195. # if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x040000ul)) && (LZO_SIZEOF_INT == 4)
  1196. # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_INT
  1197. # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_INT
  1198. # endif
  1199. #elif (LZO_ARCH_M16C)
  1200. # define __LZO_WORDSIZE 2
  1201. # if defined(__m32c_cpu__) || defined(__m32cm_cpu__)
  1202. # define LZO_SIZEOF_VOID_P 4
  1203. # else
  1204. # define LZO_SIZEOF_VOID_P 2
  1205. # endif
  1206. #elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__))
  1207. # define __LZO_WORDSIZE 8
  1208. # define LZO_SIZEOF_VOID_P 4
  1209. #elif defined(__LLP64__) || defined(__LLP64) || defined(_LLP64) || defined(_WIN64)
  1210. # define __LZO_WORDSIZE 8
  1211. # define LZO_SIZEOF_VOID_P 8
  1212. #elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__)
  1213. # define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG
  1214. # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG
  1215. # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG
  1216. #elif (LZO_OS_OS400 || defined(__OS400__))
  1217. # define __LZO_WORDSIZE LZO_SIZEOF_LONG
  1218. # define LZO_SIZEOF_VOID_P 16
  1219. # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG
  1220. # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG
  1221. #elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64)
  1222. # define LZO_SIZEOF_VOID_P 8
  1223. # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG
  1224. # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG
  1225. #elif (LZO_ARCH_SPU)
  1226. # if 0
  1227. # define __LZO_WORDSIZE 16
  1228. # endif
  1229. # define LZO_SIZEOF_VOID_P 4
  1230. #else
  1231. # define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG
  1232. #endif
  1233. #endif
  1234. #if !defined(LZO_WORDSIZE)
  1235. # if defined(__LZO_WORDSIZE)
  1236. # define LZO_WORDSIZE __LZO_WORDSIZE
  1237. # else
  1238. # define LZO_WORDSIZE LZO_SIZEOF_VOID_P
  1239. # endif
  1240. #endif
  1241. #if !defined(LZO_SIZEOF_SIZE_T)
  1242. #if (LZO_ARCH_I086 || LZO_ARCH_M16C)
  1243. # define LZO_SIZEOF_SIZE_T 2
  1244. #else
  1245. # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_VOID_P
  1246. #endif
  1247. #endif
  1248. #if !defined(LZO_SIZEOF_PTRDIFF_T)
  1249. #if (LZO_ARCH_I086)
  1250. # if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM || LZO_MM_HUGE)
  1251. # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_VOID_P
  1252. # elif (LZO_MM_COMPACT || LZO_MM_LARGE)
  1253. # if (LZO_CC_BORLANDC || LZO_CC_TURBOC)
  1254. # define LZO_SIZEOF_PTRDIFF_T 4
  1255. # else
  1256. # define LZO_SIZEOF_PTRDIFF_T 2
  1257. # endif
  1258. # else
  1259. # error "LZO_MM"
  1260. # endif
  1261. #else
  1262. # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_SIZE_T
  1263. #endif
  1264. #endif
  1265. #if (LZO_ABI_NEUTRAL_ENDIAN)
  1266. # undef LZO_ABI_BIG_ENDIAN
  1267. # undef LZO_ABI_LITTLE_ENDIAN
  1268. #elif !(LZO_ABI_BIG_ENDIAN) && !(LZO_ABI_LITTLE_ENDIAN)
  1269. #if (LZO_ARCH_ALPHA) && (LZO_ARCH_CRAY_MPP)
  1270. # define LZO_ABI_BIG_ENDIAN 1
  1271. #elif (LZO_ARCH_IA64) && (LZO_OS_POSIX_LINUX || LZO_OS_WIN64)
  1272. # define LZO_ABI_LITTLE_ENDIAN 1
  1273. #elif (LZO_ARCH_ALPHA || LZO_ARCH_AMD64 || LZO_ARCH_BLACKFIN || LZO_ARCH_CRIS || LZO_ARCH_I086 || LZO_ARCH_I386 || LZO_ARCH_MSP430)
  1274. # define LZO_ABI_LITTLE_ENDIAN 1
  1275. #elif (LZO_ARCH_AVR32 || LZO_ARCH_M68K || LZO_ARCH_S390)
  1276. # define LZO_ABI_BIG_ENDIAN 1
  1277. #elif 1 && defined(__IAR_SYSTEMS_ICC__) && defined(__LITTLE_ENDIAN__)
  1278. # if (__LITTLE_ENDIAN__ == 1)
  1279. # define LZO_ABI_LITTLE_ENDIAN 1
  1280. # else
  1281. # define LZO_ABI_BIG_ENDIAN 1
  1282. # endif
  1283. #elif 1 && defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__)
  1284. # define LZO_ABI_BIG_ENDIAN 1
  1285. #elif 1 && defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)
  1286. # define LZO_ABI_LITTLE_ENDIAN 1
  1287. #elif 1 && (LZO_ARCH_ARM) && defined(__ARMEB__) && !defined(__ARMEL__)
  1288. # define LZO_ABI_BIG_ENDIAN 1
  1289. #elif 1 && (LZO_ARCH_ARM) && defined(__ARMEL__) && !defined(__ARMEB__)
  1290. # define LZO_ABI_LITTLE_ENDIAN 1
  1291. #elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEB__) && !defined(__MIPSEL__)
  1292. # define LZO_ABI_BIG_ENDIAN 1
  1293. #elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEL__) && !defined(__MIPSEB__)
  1294. # define LZO_ABI_LITTLE_ENDIAN 1
  1295. #endif
  1296. #endif
  1297. #if (LZO_ABI_BIG_ENDIAN) && (LZO_ABI_LITTLE_ENDIAN)
  1298. # error "this should not happen"
  1299. #endif
  1300. #if (LZO_ABI_BIG_ENDIAN)
  1301. # define LZO_INFO_ABI_ENDIAN "be"
  1302. #elif (LZO_ABI_LITTLE_ENDIAN)
  1303. # define LZO_INFO_ABI_ENDIAN "le"
  1304. #elif (LZO_ABI_NEUTRAL_ENDIAN)
  1305. # define LZO_INFO_ABI_ENDIAN "neutral"
  1306. #endif
  1307. #if (LZO_SIZEOF_INT == 1 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2)
  1308. # define LZO_ABI_I8LP16 1
  1309. # define LZO_INFO_ABI_PM "i8lp16"
  1310. #elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2)
  1311. # define LZO_ABI_ILP16 1
  1312. # define LZO_INFO_ABI_PM "ilp16"
  1313. #elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4)
  1314. # define LZO_ABI_ILP32 1
  1315. # define LZO_INFO_ABI_PM "ilp32"
  1316. #elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 8 && LZO_SIZEOF_SIZE_T == 8)
  1317. # define LZO_ABI_LLP64 1
  1318. # define LZO_INFO_ABI_PM "llp64"
  1319. #elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8)
  1320. # define LZO_ABI_LP64 1
  1321. # define LZO_INFO_ABI_PM "lp64"
  1322. #elif (LZO_SIZEOF_INT == 8 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8)
  1323. # define LZO_ABI_ILP64 1
  1324. # define LZO_INFO_ABI_PM "ilp64"
  1325. #elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 4)
  1326. # define LZO_ABI_IP32L64 1
  1327. # define LZO_INFO_ABI_PM "ip32l64"
  1328. #endif
  1329. #if !defined(__LZO_LIBC_OVERRIDE)
  1330. #if (LZO_LIBC_NAKED)
  1331. # define LZO_INFO_LIBC "naked"
  1332. #elif (LZO_LIBC_FREESTANDING)
  1333. # define LZO_INFO_LIBC "freestanding"
  1334. #elif (LZO_LIBC_MOSTLY_FREESTANDING)
  1335. # define LZO_INFO_LIBC "mfreestanding"
  1336. #elif (LZO_LIBC_ISOC90)
  1337. # define LZO_INFO_LIBC "isoc90"
  1338. #elif (LZO_LIBC_ISOC99)
  1339. # define LZO_INFO_LIBC "isoc99"
  1340. #elif defined(__dietlibc__)
  1341. # define LZO_LIBC_DIETLIBC 1
  1342. # define LZO_INFO_LIBC "dietlibc"
  1343. #elif defined(_NEWLIB_VERSION)
  1344. # define LZO_LIBC_NEWLIB 1
  1345. # define LZO_INFO_LIBC "newlib"
  1346. #elif defined(__UCLIBC__) && defined(__UCLIBC_MAJOR__) && defined(__UCLIBC_MINOR__)
  1347. # if defined(__UCLIBC_SUBLEVEL__)
  1348. # define LZO_LIBC_UCLIBC (__UCLIBC_MAJOR__ * 0x10000L + __UCLIBC_MINOR__ * 0x100 + __UCLIBC_SUBLEVEL__)
  1349. # else
  1350. # define LZO_LIBC_UCLIBC 0x00090bL
  1351. # endif
  1352. # define LZO_INFO_LIBC "uclibc"
  1353. #elif defined(__GLIBC__) && defined(__GLIBC_MINOR__)
  1354. # define LZO_LIBC_GLIBC (__GLIBC__ * 0x10000L + __GLIBC_MINOR__ * 0x100)
  1355. # define LZO_INFO_LIBC "glibc"
  1356. #elif (LZO_CC_MWERKS) && defined(__MSL__)
  1357. # define LZO_LIBC_MSL __MSL__
  1358. # define LZO_INFO_LIBC "msl"
  1359. #elif 1 && defined(__IAR_SYSTEMS_ICC__)
  1360. # define LZO_LIBC_ISOC90 1
  1361. # define LZO_INFO_LIBC "isoc90"
  1362. #else
  1363. # define LZO_LIBC_DEFAULT 1
  1364. # define LZO_INFO_LIBC "default"
  1365. #endif
  1366. #endif
  1367. #if !defined(__lzo_gnuc_extension__)
  1368. #if (LZO_CC_GNUC >= 0x020800ul)
  1369. # define __lzo_gnuc_extension__ __extension__
  1370. #elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
  1371. # define __lzo_gnuc_extension__ __extension__
  1372. #else
  1373. # define __lzo_gnuc_extension__ /*empty*/
  1374. #endif
  1375. #endif
  1376. #if !defined(__lzo_ua_volatile)
  1377. # define __lzo_ua_volatile volatile
  1378. #endif
  1379. #if !defined(__lzo_alignof)
  1380. #if (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI)
  1381. # define __lzo_alignof(e) __alignof__(e)
  1382. #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 700))
  1383. # define __lzo_alignof(e) __alignof__(e)
  1384. #elif (LZO_CC_MSC && (_MSC_VER >= 1300))
  1385. # define __lzo_alignof(e) __alignof(e)
  1386. #elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100))
  1387. # define __lzo_alignof(e) __alignof__(e)
  1388. #endif
  1389. #endif
  1390. #if defined(__lzo_alignof)
  1391. # define __lzo_HAVE_alignof 1
  1392. #endif
  1393. #if !defined(__lzo_constructor)
  1394. #if (LZO_CC_GNUC >= 0x030400ul)
  1395. # define __lzo_constructor __attribute__((__constructor__,__used__))
  1396. #elif (LZO_CC_GNUC >= 0x020700ul)
  1397. # define __lzo_constructor __attribute__((__constructor__))
  1398. #elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
  1399. # define __lzo_constructor __attribute__((__constructor__))
  1400. #endif
  1401. #endif
  1402. #if defined(__lzo_constructor)
  1403. # define __lzo_HAVE_constructor 1
  1404. #endif
  1405. #if !defined(__lzo_destructor)
  1406. #if (LZO_CC_GNUC >= 0x030400ul)
  1407. # define __lzo_destructor __attribute__((__destructor__,__used__))
  1408. #elif (LZO_CC_GNUC >= 0x020700ul)
  1409. # define __lzo_destructor __attribute__((__destructor__))
  1410. #elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
  1411. # define __lzo_destructor __attribute__((__destructor__))
  1412. #endif
  1413. #endif
  1414. #if defined(__lzo_destructor)
  1415. # define __lzo_HAVE_destructor 1
  1416. #endif
  1417. #if (__lzo_HAVE_destructor) && !(__lzo_HAVE_constructor)
  1418. # error "this should not happen"
  1419. #endif
  1420. #if !defined(__lzo_inline)
  1421. #if (LZO_CC_TURBOC && (__TURBOC__ <= 0x0295))
  1422. #elif defined(__cplusplus)
  1423. # define __lzo_inline inline
  1424. #elif (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0550))
  1425. # define __lzo_inline __inline
  1426. #elif (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI)
  1427. # define __lzo_inline __inline__
  1428. #elif (LZO_CC_DMC)
  1429. # define __lzo_inline __inline
  1430. #elif (LZO_CC_INTELC)
  1431. # define __lzo_inline __inline
  1432. #elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x2405))
  1433. # define __lzo_inline __inline
  1434. #elif (LZO_CC_MSC && (_MSC_VER >= 900))
  1435. # define __lzo_inline __inline
  1436. #elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100))
  1437. # define __lzo_inline __inline__
  1438. #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
  1439. # define __lzo_inline inline
  1440. #endif
  1441. #endif
  1442. #if defined(__lzo_inline)
  1443. # define __lzo_HAVE_inline 1
  1444. #else
  1445. # define __lzo_inline /*empty*/
  1446. #endif
  1447. #if !defined(__lzo_forceinline)
  1448. #if (LZO_CC_GNUC >= 0x030200ul)
  1449. # define __lzo_forceinline __inline__ __attribute__((__always_inline__))
  1450. #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC)
  1451. # define __lzo_forceinline __forceinline
  1452. #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800) && LZO_CC_SYNTAX_GNUC)
  1453. # define __lzo_forceinline __inline__ __attribute__((__always_inline__))
  1454. #elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
  1455. # define __lzo_forceinline __inline__ __attribute__((__always_inline__))
  1456. #elif (LZO_CC_MSC && (_MSC_VER >= 1200))
  1457. # define __lzo_forceinline __forceinline
  1458. #elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100))
  1459. # define __lzo_forceinline __inline__ __attribute__((__always_inline__))
  1460. #endif
  1461. #endif
  1462. #if defined(__lzo_forceinline)
  1463. # define __lzo_HAVE_forceinline 1
  1464. #else
  1465. # define __lzo_forceinline /*empty*/
  1466. #endif
  1467. #if !defined(__lzo_noinline)
  1468. #if 1 && (LZO_ARCH_I386) && (LZO_CC_GNUC >= 0x040000ul) && (LZO_CC_GNUC < 0x040003ul)
  1469. # define __lzo_noinline __attribute__((__noinline__,__used__))
  1470. #elif (LZO_CC_GNUC >= 0x030200ul)
  1471. # define __lzo_noinline __attribute__((__noinline__))
  1472. #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_MSC)
  1473. # define __lzo_noinline __declspec(noinline)
  1474. #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800) && LZO_CC_SYNTAX_GNUC)
  1475. # define __lzo_noinline __attribute__((__noinline__))
  1476. #elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
  1477. # define __lzo_noinline __attribute__((__noinline__))
  1478. #elif (LZO_CC_MSC && (_MSC_VER >= 1300))
  1479. # define __lzo_noinline __declspec(noinline)
  1480. #elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x3200) && (LZO_OS_WIN32 || LZO_OS_WIN64))
  1481. # if defined(__cplusplus)
  1482. # else
  1483. # define __lzo_noinline __declspec(noinline)
  1484. # endif
  1485. #elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100))
  1486. # define __lzo_noinline __attribute__((__noinline__))
  1487. #endif
  1488. #endif
  1489. #if defined(__lzo_noinline)
  1490. # define __lzo_HAVE_noinline 1
  1491. #else
  1492. # define __lzo_noinline /*empty*/
  1493. #endif
  1494. #if (__lzo_HAVE_forceinline || __lzo_HAVE_noinline) && !(__lzo_HAVE_inline)
  1495. # error "this should not happen"
  1496. #endif
  1497. #if !defined(__lzo_noreturn)
  1498. #if (LZO_CC_GNUC >= 0x020700ul)
  1499. # define __lzo_noreturn __attribute__((__noreturn__))
  1500. #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC)
  1501. # define __lzo_noreturn __declspec(noreturn)
  1502. #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_GNUC)
  1503. # define __lzo_noreturn __attribute__((__noreturn__))
  1504. #elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
  1505. # define __lzo_noreturn __attribute__((__noreturn__))
  1506. #elif (LZO_CC_MSC && (_MSC_VER >= 1200))
  1507. # define __lzo_noreturn __declspec(noreturn)
  1508. #endif
  1509. #endif
  1510. #if defined(__lzo_noreturn)
  1511. # define __lzo_HAVE_noreturn 1
  1512. #else
  1513. # define __lzo_noreturn /*empty*/
  1514. #endif
  1515. #if !defined(__lzo_nothrow)
  1516. #if (LZO_CC_GNUC >= 0x030300ul)
  1517. # define __lzo_nothrow __attribute__((__nothrow__))
  1518. #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) && defined(__cplusplus)
  1519. # define __lzo_nothrow __declspec(nothrow)
  1520. #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 900) && LZO_CC_SYNTAX_GNUC)
  1521. # define __lzo_nothrow __attribute__((__nothrow__))
  1522. #elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
  1523. # define __lzo_nothrow __attribute__((__nothrow__))
  1524. #elif (LZO_CC_MSC && (_MSC_VER >= 1200)) && defined(__cplusplus)
  1525. # define __lzo_nothrow __declspec(nothrow)
  1526. #endif
  1527. #endif
  1528. #if defined(__lzo_nothrow)
  1529. # define __lzo_HAVE_nothrow 1
  1530. #else
  1531. # define __lzo_nothrow /*empty*/
  1532. #endif
  1533. #if !defined(__lzo_restrict)
  1534. #if (LZO_CC_GNUC >= 0x030400ul)
  1535. # define __lzo_restrict __restrict__
  1536. #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_GNUC)
  1537. # define __lzo_restrict __restrict__
  1538. #elif (LZO_CC_CLANG || LZO_CC_LLVM)
  1539. # define __lzo_restrict __restrict__
  1540. #elif (LZO_CC_MSC && (_MSC_VER >= 1400))
  1541. # define __lzo_restrict __restrict
  1542. #endif
  1543. #endif
  1544. #if defined(__lzo_restrict)
  1545. # define __lzo_HAVE_restrict 1
  1546. #else
  1547. # define __lzo_restrict /*empty*/
  1548. #endif
  1549. #if !defined(__lzo_likely) && !defined(__lzo_unlikely)
  1550. #if (LZO_CC_GNUC >= 0x030200ul)
  1551. # define __lzo_likely(e) (__builtin_expect(!!(e),1))
  1552. # define __lzo_unlikely(e) (__builtin_expect(!!(e),0))
  1553. #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800))
  1554. # define __lzo_likely(e) (__builtin_expect(!!(e),1))
  1555. # define __lzo_unlikely(e) (__builtin_expect(!!(e),0))
  1556. #elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
  1557. # define __lzo_likely(e) (__builtin_expect(!!(e),1))
  1558. # define __lzo_unlikely(e) (__builtin_expect(!!(e),0))
  1559. #endif
  1560. #endif
  1561. #if defined(__lzo_likely)
  1562. # define __lzo_HAVE_likely 1
  1563. #else
  1564. # define __lzo_likely(e) (e)
  1565. #endif
  1566. #if defined(__lzo_unlikely)
  1567. # define __lzo_HAVE_unlikely 1
  1568. #else
  1569. # define __lzo_unlikely(e) (e)
  1570. #endif
  1571. #if !defined(LZO_UNUSED)
  1572. # if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600))
  1573. # define LZO_UNUSED(var) ((void) &var)
  1574. # elif (LZO_CC_BORLANDC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PELLESC || LZO_CC_TURBOC)
  1575. # define LZO_UNUSED(var) if (&var) ; else
  1576. # elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE)
  1577. # define LZO_UNUSED(var) ((void) var)
  1578. # elif (LZO_CC_MSC && (_MSC_VER < 900))
  1579. # define LZO_UNUSED(var) if (&var) ; else
  1580. # elif (LZO_CC_KEILC)
  1581. # define LZO_UNUSED(var) {extern int __lzo_unused[1-2*!(sizeof(var)>0)];}
  1582. # elif (LZO_CC_PACIFICC)
  1583. # define LZO_UNUSED(var) ((void) sizeof(var))
  1584. # elif (LZO_CC_WATCOMC) && defined(__cplusplus)
  1585. # define LZO_UNUSED(var) ((void) var)
  1586. # else
  1587. # define LZO_UNUSED(var) ((void) &var)
  1588. # endif
  1589. #endif
  1590. #if !defined(LZO_UNUSED_FUNC)
  1591. # if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600))
  1592. # define LZO_UNUSED_FUNC(func) ((void) func)
  1593. # elif (LZO_CC_BORLANDC || LZO_CC_NDPC || LZO_CC_TURBOC)
  1594. # define LZO_UNUSED_FUNC(func) if (func) ; else
  1595. # elif (LZO_CC_CLANG || LZO_CC_LLVM)
  1596. # define LZO_UNUSED_FUNC(func) ((void) &func)
  1597. # elif (LZO_CC_MSC && (_MSC_VER < 900))
  1598. # define LZO_UNUSED_FUNC(func) if (func) ; else
  1599. # elif (LZO_CC_MSC)
  1600. # define LZO_UNUSED_FUNC(func) ((void) &func)
  1601. # elif (LZO_CC_KEILC || LZO_CC_PELLESC)
  1602. # define LZO_UNUSED_FUNC(func) {extern int __lzo_unused[1-2*!(sizeof((int)func)>0)];}
  1603. # else
  1604. # define LZO_UNUSED_FUNC(func) ((void) func)
  1605. # endif
  1606. #endif
  1607. #if !defined(LZO_UNUSED_LABEL)
  1608. # if (LZO_CC_WATCOMC) && defined(__cplusplus)
  1609. # define LZO_UNUSED_LABEL(l) switch(0) case 1:goto l
  1610. # elif (LZO_CC_CLANG || LZO_CC_INTELC || LZO_CC_WATCOMC)
  1611. # define LZO_UNUSED_LABEL(l) if (0) goto l
  1612. # else
  1613. # define LZO_UNUSED_LABEL(l) switch(0) case 1:goto l
  1614. # endif
  1615. #endif
  1616. #if !defined(LZO_DEFINE_UNINITIALIZED_VAR)
  1617. # if 0
  1618. # define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var
  1619. # elif 0 && (LZO_CC_GNUC)
  1620. # define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = var
  1621. # else
  1622. # define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = init
  1623. # endif
  1624. #endif
  1625. #if !defined(LZO_UNCONST_CAST)
  1626. # if 0 && defined(__cplusplus)
  1627. # define LZO_UNCONST_CAST(t,e) (const_cast<t> (e))
  1628. # elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE)
  1629. # define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((char *) ((lzo_uintptr_t) ((const void *) (e))))))
  1630. # else
  1631. # define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((char *) ((const void *) (e)))))
  1632. # endif
  1633. #endif
  1634. #if !defined(LZO_COMPILE_TIME_ASSERT_HEADER)
  1635. # if (LZO_CC_AZTECC || LZO_CC_ZORTECHC)
  1636. # define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-!(e)];
  1637. # elif (LZO_CC_DMC || LZO_CC_SYMANTECC)
  1638. # define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1u-2*!(e)];
  1639. # elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295))
  1640. # define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-!(e)];
  1641. # else
  1642. # define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-2*!(e)];
  1643. # endif
  1644. #endif
  1645. #if !defined(LZO_COMPILE_TIME_ASSERT)
  1646. # if (LZO_CC_AZTECC)
  1647. # define LZO_COMPILE_TIME_ASSERT(e) {typedef int __lzo_cta_t[1-!(e)];}
  1648. # elif (LZO_CC_DMC || LZO_CC_PACIFICC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC)
  1649. # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break;
  1650. # elif (LZO_CC_MSC && (_MSC_VER < 900))
  1651. # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break;
  1652. # elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295))
  1653. # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break;
  1654. # else
  1655. # define LZO_COMPILE_TIME_ASSERT(e) {typedef int __lzo_cta_t[1-2*!(e)];}
  1656. # endif
  1657. #endif
  1658. #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)
  1659. # if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC)
  1660. # elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC)
  1661. # define __lzo_cdecl __cdecl
  1662. # define __lzo_cdecl_atexit /*empty*/
  1663. # define __lzo_cdecl_main __cdecl
  1664. # if (LZO_OS_OS2 && (LZO_CC_DMC || LZO_CC_SYMANTECC))
  1665. # define __lzo_cdecl_qsort __pascal
  1666. # elif (LZO_OS_OS2 && (LZO_CC_ZORTECHC))
  1667. # define __lzo_cdecl_qsort _stdcall
  1668. # else
  1669. # define __lzo_cdecl_qsort __cdecl
  1670. # endif
  1671. # elif (LZO_CC_WATCOMC)
  1672. # define __lzo_cdecl __cdecl
  1673. # else
  1674. # define __lzo_cdecl __cdecl
  1675. # define __lzo_cdecl_atexit __cdecl
  1676. # define __lzo_cdecl_main __cdecl
  1677. # define __lzo_cdecl_qsort __cdecl
  1678. # endif
  1679. # if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC || LZO_CC_WATCOMC)
  1680. # elif (LZO_OS_OS2 && (LZO_CC_DMC || LZO_CC_SYMANTECC))
  1681. # define __lzo_cdecl_sighandler __pascal
  1682. # elif (LZO_OS_OS2 && (LZO_CC_ZORTECHC))
  1683. # define __lzo_cdecl_sighandler _stdcall
  1684. # elif (LZO_CC_MSC && (_MSC_VER >= 1400)) && defined(_M_CEE_PURE)
  1685. # define __lzo_cdecl_sighandler __clrcall
  1686. # elif (LZO_CC_MSC && (_MSC_VER >= 600 && _MSC_VER < 700))
  1687. # if defined(_DLL)
  1688. # define __lzo_cdecl_sighandler _far _cdecl _loadds
  1689. # elif defined(_MT)
  1690. # define __lzo_cdecl_sighandler _far _cdecl
  1691. # else
  1692. # define __lzo_cdecl_sighandler _cdecl
  1693. # endif
  1694. # else
  1695. # define __lzo_cdecl_sighandler __cdecl
  1696. # endif
  1697. #elif (LZO_ARCH_I386) && (LZO_CC_WATCOMC)
  1698. # define __lzo_cdecl __cdecl
  1699. #elif (LZO_ARCH_M68K && LZO_OS_TOS && (LZO_CC_PUREC || LZO_CC_TURBOC))
  1700. # define __lzo_cdecl cdecl
  1701. #endif
  1702. #if !defined(__lzo_cdecl)
  1703. # define __lzo_cdecl /*empty*/
  1704. #endif
  1705. #if !defined(__lzo_cdecl_atexit)
  1706. # define __lzo_cdecl_atexit /*empty*/
  1707. #endif
  1708. #if !defined(__lzo_cdecl_main)
  1709. # define __lzo_cdecl_main /*empty*/
  1710. #endif
  1711. #if !defined(__lzo_cdecl_qsort)
  1712. # define __lzo_cdecl_qsort /*empty*/
  1713. #endif
  1714. #if !defined(__lzo_cdecl_sighandler)
  1715. # define __lzo_cdecl_sighandler /*empty*/
  1716. #endif
  1717. #if !defined(__lzo_cdecl_va)
  1718. # define __lzo_cdecl_va __lzo_cdecl
  1719. #endif
  1720. #if !(LZO_CFG_NO_WINDOWS_H)
  1721. #if (LZO_OS_CYGWIN || (LZO_OS_EMX && defined(__RSXNT__)) || LZO_OS_WIN32 || LZO_OS_WIN64)
  1722. # if (LZO_CC_WATCOMC && (__WATCOMC__ < 1000))
  1723. # elif (LZO_OS_WIN32 && LZO_CC_GNUC) && defined(__PW32__)
  1724. # elif ((LZO_OS_CYGWIN || defined(__MINGW32__)) && (LZO_CC_GNUC && (LZO_CC_GNUC < 0x025f00ul)))
  1725. # else
  1726. # define LZO_HAVE_WINDOWS_H 1
  1727. # endif
  1728. #endif
  1729. #endif
  1730. #if (LZO_ARCH_ALPHA)
  1731. # define LZO_OPT_AVOID_UINT_INDEX 1
  1732. # define LZO_OPT_AVOID_SHORT 1
  1733. # define LZO_OPT_AVOID_USHORT 1
  1734. #elif (LZO_ARCH_AMD64)
  1735. # define LZO_OPT_AVOID_INT_INDEX 1
  1736. # define LZO_OPT_AVOID_UINT_INDEX 1
  1737. # define LZO_OPT_UNALIGNED16 1
  1738. # define LZO_OPT_UNALIGNED32 1
  1739. # define LZO_OPT_UNALIGNED64 1
  1740. #elif (LZO_ARCH_ARM && LZO_ARCH_ARM_THUMB)
  1741. #elif (LZO_ARCH_ARM)
  1742. # define LZO_OPT_AVOID_SHORT 1
  1743. # define LZO_OPT_AVOID_USHORT 1
  1744. #elif (LZO_ARCH_CRIS)
  1745. # define LZO_OPT_UNALIGNED16 1
  1746. # define LZO_OPT_UNALIGNED32 1
  1747. #elif (LZO_ARCH_I386)
  1748. # define LZO_OPT_UNALIGNED16 1
  1749. # define LZO_OPT_UNALIGNED32 1
  1750. #elif (LZO_ARCH_IA64)
  1751. # define LZO_OPT_AVOID_INT_INDEX 1
  1752. # define LZO_OPT_AVOID_UINT_INDEX 1
  1753. # define LZO_OPT_PREFER_POSTINC 1
  1754. #elif (LZO_ARCH_M68K)
  1755. # define LZO_OPT_PREFER_POSTINC 1
  1756. # define LZO_OPT_PREFER_PREDEC 1
  1757. # if defined(__mc68020__) && !defined(__mcoldfire__)
  1758. # define LZO_OPT_UNALIGNED16 1
  1759. # define LZO_OPT_UNALIGNED32 1
  1760. # endif
  1761. #elif (LZO_ARCH_MIPS)
  1762. # define LZO_OPT_AVOID_UINT_INDEX 1
  1763. #elif (LZO_ARCH_POWERPC)
  1764. # define LZO_OPT_PREFER_PREINC 1
  1765. # define LZO_OPT_PREFER_PREDEC 1
  1766. # if (LZO_ABI_BIG_ENDIAN)
  1767. # define LZO_OPT_UNALIGNED16 1
  1768. # define LZO_OPT_UNALIGNED32 1
  1769. # endif
  1770. #elif (LZO_ARCH_S390)
  1771. # define LZO_OPT_UNALIGNED16 1
  1772. # define LZO_OPT_UNALIGNED32 1
  1773. # if (LZO_SIZEOF_SIZE_T == 8)
  1774. # define LZO_OPT_UNALIGNED64 1
  1775. # endif
  1776. #elif (LZO_ARCH_SH)
  1777. # define LZO_OPT_PREFER_POSTINC 1
  1778. # define LZO_OPT_PREFER_PREDEC 1
  1779. #endif
  1780. #ifndef LZO_CFG_NO_INLINE_ASM
  1781. #if (LZO_CC_LLVM)
  1782. # define LZO_CFG_NO_INLINE_ASM 1
  1783. #endif
  1784. #endif
  1785. #ifndef LZO_CFG_NO_UNALIGNED
  1786. #if (LZO_ABI_NEUTRAL_ENDIAN) || (LZO_ARCH_GENERIC)
  1787. # define LZO_CFG_NO_UNALIGNED 1
  1788. #endif
  1789. #endif
  1790. #if (LZO_CFG_NO_UNALIGNED)
  1791. # undef LZO_OPT_UNALIGNED16
  1792. # undef LZO_OPT_UNALIGNED32
  1793. # undef LZO_OPT_UNALIGNED64
  1794. #endif
  1795. #if (LZO_CFG_NO_INLINE_ASM)
  1796. #elif (LZO_ARCH_I386 && (LZO_OS_DOS32 || LZO_OS_WIN32) && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC))
  1797. # define LZO_ASM_SYNTAX_MSC 1
  1798. #elif (LZO_OS_WIN64 && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC))
  1799. #elif (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC == 0x011f00ul))
  1800. #elif (LZO_ARCH_I386 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE))
  1801. # define LZO_ASM_SYNTAX_GNUC 1
  1802. #elif (LZO_ARCH_AMD64 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE))
  1803. # define LZO_ASM_SYNTAX_GNUC 1
  1804. #endif
  1805. #if (LZO_ASM_SYNTAX_GNUC)
  1806. #if (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC < 0x020000ul))
  1807. # define __LZO_ASM_CLOBBER "ax"
  1808. #elif (LZO_CC_INTELC)
  1809. # define __LZO_ASM_CLOBBER "memory"
  1810. #else
  1811. # define __LZO_ASM_CLOBBER "cc", "memory"
  1812. #endif
  1813. #endif
  1814. #if defined(__LZO_INFOSTR_MM)
  1815. #elif (LZO_MM_FLAT) && (defined(__LZO_INFOSTR_PM) || defined(LZO_INFO_ABI_PM))
  1816. # define __LZO_INFOSTR_MM ""
  1817. #elif defined(LZO_INFO_MM)
  1818. # define __LZO_INFOSTR_MM "." LZO_INFO_MM
  1819. #else
  1820. # define __LZO_INFOSTR_MM ""
  1821. #endif
  1822. #if defined(__LZO_INFOSTR_PM)
  1823. #elif defined(LZO_INFO_ABI_PM)
  1824. # define __LZO_INFOSTR_PM "." LZO_INFO_ABI_PM
  1825. #else
  1826. # define __LZO_INFOSTR_PM ""
  1827. #endif
  1828. #if defined(__LZO_INFOSTR_ENDIAN)
  1829. #elif defined(LZO_INFO_ABI_ENDIAN)
  1830. # define __LZO_INFOSTR_ENDIAN "." LZO_INFO_ABI_ENDIAN
  1831. #else
  1832. # define __LZO_INFOSTR_ENDIAN ""
  1833. #endif
  1834. #if defined(__LZO_INFOSTR_OSNAME)
  1835. #elif defined(LZO_INFO_OS_CONSOLE)
  1836. # define __LZO_INFOSTR_OSNAME LZO_INFO_OS "." LZO_INFO_OS_CONSOLE
  1837. #elif defined(LZO_INFO_OS_POSIX)
  1838. # define __LZO_INFOSTR_OSNAME LZO_INFO_OS "." LZO_INFO_OS_POSIX
  1839. #else
  1840. # define __LZO_INFOSTR_OSNAME LZO_INFO_OS
  1841. #endif
  1842. #if defined(__LZO_INFOSTR_LIBC)
  1843. #elif defined(LZO_INFO_LIBC)
  1844. # define __LZO_INFOSTR_LIBC "." LZO_INFO_LIBC
  1845. #else
  1846. # define __LZO_INFOSTR_LIBC ""
  1847. #endif
  1848. #if defined(__LZO_INFOSTR_CCVER)
  1849. #elif defined(LZO_INFO_CCVER)
  1850. # define __LZO_INFOSTR_CCVER " " LZO_INFO_CCVER
  1851. #else
  1852. # define __LZO_INFOSTR_CCVER ""
  1853. #endif
  1854. #define LZO_INFO_STRING \
  1855. LZO_INFO_ARCH __LZO_INFOSTR_MM __LZO_INFOSTR_PM __LZO_INFOSTR_ENDIAN \
  1856. " " __LZO_INFOSTR_OSNAME __LZO_INFOSTR_LIBC " " LZO_INFO_CC __LZO_INFOSTR_CCVER
  1857. #endif
  1858. #endif
  1859. #undef LZO_HAVE_CONFIG_H
  1860. #include "minilzo.h"
  1861. #if !defined(MINILZO_VERSION) || (MINILZO_VERSION != 0x2060)
  1862. # error "version mismatch in miniLZO source files"
  1863. #endif
  1864. #ifdef MINILZO_HAVE_CONFIG_H
  1865. # define LZO_HAVE_CONFIG_H 1
  1866. #endif
  1867. #ifndef __LZO_CONF_H
  1868. #define __LZO_CONF_H 1
  1869. #if !defined(__LZO_IN_MINILZO)
  1870. #if (LZO_CFG_FREESTANDING)
  1871. # define LZO_LIBC_FREESTANDING 1
  1872. # define LZO_OS_FREESTANDING 1
  1873. # define ACC_LIBC_FREESTANDING 1
  1874. # define ACC_OS_FREESTANDING 1
  1875. #endif
  1876. #if (LZO_CFG_NO_UNALIGNED)
  1877. # define ACC_CFG_NO_UNALIGNED 1
  1878. #endif
  1879. #if (LZO_ARCH_GENERIC)
  1880. # define ACC_ARCH_GENERIC 1
  1881. #endif
  1882. #if (LZO_ABI_NEUTRAL_ENDIAN)
  1883. # define ACC_ABI_NEUTRAL_ENDIAN 1
  1884. #endif
  1885. #if (LZO_HAVE_CONFIG_H)
  1886. # define ACC_CONFIG_NO_HEADER 1
  1887. #endif
  1888. #if defined(LZO_CFG_EXTRA_CONFIG_HEADER)
  1889. # include LZO_CFG_EXTRA_CONFIG_HEADER
  1890. #endif
  1891. #if defined(__LZOCONF_H) || defined(__LZOCONF_H_INCLUDED)
  1892. # error "include this file first"
  1893. #endif
  1894. #include "lzo/lzoconf.h"
  1895. #endif
  1896. #if (LZO_VERSION < 0x02000) || !defined(__LZOCONF_H_INCLUDED)
  1897. # error "version mismatch"
  1898. #endif
  1899. #if (LZO_CC_BORLANDC && LZO_ARCH_I086)
  1900. # pragma option -h
  1901. #endif
  1902. #if (LZO_CC_MSC && (_MSC_VER >= 1000))
  1903. # pragma warning(disable: 4127 4701)
  1904. #endif
  1905. #if (LZO_CC_MSC && (_MSC_VER >= 1300))
  1906. # pragma warning(disable: 4820)
  1907. # pragma warning(disable: 4514 4710 4711)
  1908. #endif
  1909. #if (LZO_CC_SUNPROC)
  1910. #if !defined(__cplusplus)
  1911. # pragma error_messages(off,E_END_OF_LOOP_CODE_NOT_REACHED)
  1912. # pragma error_messages(off,E_LOOP_NOT_ENTERED_AT_TOP)
  1913. # pragma error_messages(off,E_STATEMENT_NOT_REACHED)
  1914. #endif
  1915. #endif
  1916. #if (__LZO_MMODEL_HUGE) && !(LZO_HAVE_MM_HUGE_PTR)
  1917. # error "this should not happen - check defines for __huge"
  1918. #endif
  1919. #if defined(__LZO_IN_MINILZO) || defined(LZO_CFG_FREESTANDING)
  1920. #elif (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16)
  1921. # define ACC_WANT_ACC_INCD_H 1
  1922. # define ACC_WANT_ACC_INCE_H 1
  1923. # define ACC_WANT_ACC_INCI_H 1
  1924. #elif 1
  1925. # include <string.h>
  1926. #else
  1927. # define ACC_WANT_ACC_INCD_H 1
  1928. #endif
  1929. #if (LZO_ARCH_I086)
  1930. # define ACC_MM_AHSHIFT LZO_MM_AHSHIFT
  1931. # define ACC_PTR_FP_OFF(x) (((const unsigned __far*)&(x))[0])
  1932. # define ACC_PTR_FP_SEG(x) (((const unsigned __far*)&(x))[1])
  1933. # define ACC_PTR_MK_FP(s,o) ((void __far*)(((unsigned long)(s)<<16)+(unsigned)(o)))
  1934. #endif
  1935. #if !defined(lzo_uintptr_t)
  1936. # if defined(__LZO_MMODEL_HUGE)
  1937. # define lzo_uintptr_t unsigned long
  1938. # elif 1 && defined(LZO_OS_OS400) && (LZO_SIZEOF_VOID_P == 16)
  1939. # define __LZO_UINTPTR_T_IS_POINTER 1
  1940. typedef char* lzo_uintptr_t;
  1941. # define lzo_uintptr_t lzo_uintptr_t
  1942. # elif (LZO_SIZEOF_SIZE_T == LZO_SIZEOF_VOID_P)
  1943. # define lzo_uintptr_t size_t
  1944. # elif (LZO_SIZEOF_LONG == LZO_SIZEOF_VOID_P)
  1945. # define lzo_uintptr_t unsigned long
  1946. # elif (LZO_SIZEOF_INT == LZO_SIZEOF_VOID_P)
  1947. # define lzo_uintptr_t unsigned int
  1948. # elif (LZO_SIZEOF_LONG_LONG == LZO_SIZEOF_VOID_P)
  1949. # define lzo_uintptr_t unsigned long long
  1950. # else
  1951. # define lzo_uintptr_t size_t
  1952. # endif
  1953. #endif
  1954. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp))
  1955. #if 1 && !defined(LZO_CFG_FREESTANDING)
  1956. #if 1 && !defined(HAVE_STRING_H)
  1957. #define HAVE_STRING_H 1
  1958. #endif
  1959. #if 1 && !defined(HAVE_MEMCMP)
  1960. #define HAVE_MEMCMP 1
  1961. #endif
  1962. #if 1 && !defined(HAVE_MEMCPY)
  1963. #define HAVE_MEMCPY 1
  1964. #endif
  1965. #if 1 && !defined(HAVE_MEMMOVE)
  1966. #define HAVE_MEMMOVE 1
  1967. #endif
  1968. #if 1 && !defined(HAVE_MEMSET)
  1969. #define HAVE_MEMSET 1
  1970. #endif
  1971. #endif
  1972. #if 1 && defined(HAVE_STRING_H)
  1973. #include <string.h>
  1974. #endif
  1975. #if (LZO_CFG_FREESTANDING)
  1976. # undef HAVE_MEMCMP
  1977. # undef HAVE_MEMCPY
  1978. # undef HAVE_MEMMOVE
  1979. # undef HAVE_MEMSET
  1980. #endif
  1981. #if !(HAVE_MEMCMP)
  1982. # undef memcmp
  1983. # define memcmp(a,b,c) lzo_memcmp(a,b,c)
  1984. #elif !(__LZO_MMODEL_HUGE)
  1985. # undef lzo_memcmp
  1986. # define lzo_memcmp(a,b,c) memcmp(a,b,c)
  1987. #endif
  1988. #if !(HAVE_MEMCPY)
  1989. # undef memcpy
  1990. # define memcpy(a,b,c) lzo_memcpy(a,b,c)
  1991. #elif !(__LZO_MMODEL_HUGE)
  1992. # undef lzo_memcpy
  1993. # define lzo_memcpy(a,b,c) memcpy(a,b,c)
  1994. #endif
  1995. #if !(HAVE_MEMMOVE)
  1996. # undef memmove
  1997. # define memmove(a,b,c) lzo_memmove(a,b,c)
  1998. #elif !(__LZO_MMODEL_HUGE)
  1999. # undef lzo_memmove
  2000. # define lzo_memmove(a,b,c) memmove(a,b,c)
  2001. #endif
  2002. #if !(HAVE_MEMSET)
  2003. # undef memset
  2004. # define memset(a,b,c) lzo_memset(a,b,c)
  2005. #elif !(__LZO_MMODEL_HUGE)
  2006. # undef lzo_memset
  2007. # define lzo_memset(a,b,c) memset(a,b,c)
  2008. #endif
  2009. #undef NDEBUG
  2010. #if (LZO_CFG_FREESTANDING)
  2011. # undef LZO_DEBUG
  2012. # define NDEBUG 1
  2013. # undef assert
  2014. # define assert(e) ((void)0)
  2015. #else
  2016. # if !defined(LZO_DEBUG)
  2017. # define NDEBUG 1
  2018. # endif
  2019. # include <assert.h>
  2020. #endif
  2021. #if 0 && defined(__BOUNDS_CHECKING_ON)
  2022. # include <unchecked.h>
  2023. #else
  2024. # define BOUNDS_CHECKING_OFF_DURING(stmt) stmt
  2025. # define BOUNDS_CHECKING_OFF_IN_EXPR(expr) (expr)
  2026. #endif
  2027. #if !defined(__lzo_inline)
  2028. # define __lzo_inline /*empty*/
  2029. #endif
  2030. #if !defined(__lzo_forceinline)
  2031. # define __lzo_forceinline /*empty*/
  2032. #endif
  2033. #if !defined(__lzo_noinline)
  2034. # define __lzo_noinline /*empty*/
  2035. #endif
  2036. #if (LZO_CFG_PGO)
  2037. # undef __acc_likely
  2038. # undef __acc_unlikely
  2039. # undef __lzo_likely
  2040. # undef __lzo_unlikely
  2041. # define __acc_likely(e) (e)
  2042. # define __acc_unlikely(e) (e)
  2043. # define __lzo_likely(e) (e)
  2044. # define __lzo_unlikely(e) (e)
  2045. #endif
  2046. #if 1
  2047. # define LZO_BYTE(x) ((unsigned char) (x))
  2048. #else
  2049. # define LZO_BYTE(x) ((unsigned char) ((x) & 0xff))
  2050. #endif
  2051. #define LZO_MAX(a,b) ((a) >= (b) ? (a) : (b))
  2052. #define LZO_MIN(a,b) ((a) <= (b) ? (a) : (b))
  2053. #define LZO_MAX3(a,b,c) ((a) >= (b) ? LZO_MAX(a,c) : LZO_MAX(b,c))
  2054. #define LZO_MIN3(a,b,c) ((a) <= (b) ? LZO_MIN(a,c) : LZO_MIN(b,c))
  2055. #define lzo_sizeof(type) ((lzo_uint) (sizeof(type)))
  2056. #define LZO_HIGH(array) ((lzo_uint) (sizeof(array)/sizeof(*(array))))
  2057. #define LZO_SIZE(bits) (1u << (bits))
  2058. #define LZO_MASK(bits) (LZO_SIZE(bits) - 1)
  2059. #define LZO_LSIZE(bits) (1ul << (bits))
  2060. #define LZO_LMASK(bits) (LZO_LSIZE(bits) - 1)
  2061. #define LZO_USIZE(bits) ((lzo_uint) 1 << (bits))
  2062. #define LZO_UMASK(bits) (LZO_USIZE(bits) - 1)
  2063. #if !defined(DMUL)
  2064. #if 0
  2065. # define DMUL(a,b) ((lzo_xint) ((lzo_uint32)(a) * (lzo_uint32)(b)))
  2066. #else
  2067. # define DMUL(a,b) ((lzo_xint) ((a) * (b)))
  2068. #endif
  2069. #endif
  2070. #if 1 && (LZO_ARCH_AMD64 || LZO_ARCH_I386 || LZO_ARCH_POWERPC)
  2071. # if (LZO_SIZEOF_SHORT == 2)
  2072. # define LZO_UNALIGNED_OK_2 1
  2073. # endif
  2074. # if (LZO_SIZEOF_INT == 4)
  2075. # define LZO_UNALIGNED_OK_4 1
  2076. # endif
  2077. #endif
  2078. #if 1 && (LZO_ARCH_AMD64)
  2079. # if defined(LZO_UINT64_MAX)
  2080. # define LZO_UNALIGNED_OK_8 1
  2081. # endif
  2082. #endif
  2083. #if (LZO_CFG_NO_UNALIGNED)
  2084. # undef LZO_UNALIGNED_OK_2
  2085. # undef LZO_UNALIGNED_OK_4
  2086. # undef LZO_UNALIGNED_OK_8
  2087. #endif
  2088. #undef UA_GET16
  2089. #undef UA_SET16
  2090. #undef UA_COPY16
  2091. #undef UA_GET32
  2092. #undef UA_SET32
  2093. #undef UA_COPY32
  2094. #undef UA_GET64
  2095. #undef UA_SET64
  2096. #undef UA_COPY64
  2097. #if defined(LZO_UNALIGNED_OK_2)
  2098. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(unsigned short) == 2)
  2099. # if 1 && defined(ACC_UA_COPY16)
  2100. # define UA_GET16 ACC_UA_GET16
  2101. # define UA_SET16 ACC_UA_SET16
  2102. # define UA_COPY16 ACC_UA_COPY16
  2103. # else
  2104. # define UA_GET16(p) (* (__lzo_ua_volatile const lzo_ushortp) (__lzo_ua_volatile const lzo_voidp) (p))
  2105. # define UA_SET16(p,v) ((* (__lzo_ua_volatile lzo_ushortp) (__lzo_ua_volatile lzo_voidp) (p)) = (unsigned short) (v))
  2106. # define UA_COPY16(d,s) UA_SET16(d, UA_GET16(s))
  2107. # endif
  2108. #endif
  2109. #if defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4)
  2110. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint32) == 4)
  2111. # if 1 && defined(ACC_UA_COPY32)
  2112. # define UA_GET32 ACC_UA_GET32
  2113. # define UA_SET32 ACC_UA_SET32
  2114. # define UA_COPY32 ACC_UA_COPY32
  2115. # else
  2116. # define UA_GET32(p) (* (__lzo_ua_volatile const lzo_uint32p) (__lzo_ua_volatile const lzo_voidp) (p))
  2117. # define UA_SET32(p,v) ((* (__lzo_ua_volatile lzo_uint32p) (__lzo_ua_volatile lzo_voidp) (p)) = (lzo_uint32) (v))
  2118. # define UA_COPY32(d,s) UA_SET32(d, UA_GET32(s))
  2119. # endif
  2120. #endif
  2121. #if defined(LZO_UNALIGNED_OK_8)
  2122. LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint64) == 8)
  2123. # if 1 && defined(ACC_UA_COPY64)
  2124. # define UA_GET64 ACC_UA_GET64
  2125. # define UA_SET64 ACC_UA_SET64
  2126. # define UA_COPY64 ACC_UA_COPY64
  2127. # else
  2128. # define UA_GET64(p) (* (__lzo_ua_volatile const lzo_uint64p) (__lzo_ua_volatile const lzo_voidp) (p))
  2129. # define UA_SET64(p,v) ((* (__lzo_ua_volatile lzo_uint64p) (__lzo_ua_volatile lzo_voidp) (p)) = (lzo_uint64) (v))
  2130. # define UA_COPY64(d,s) UA_SET64(d, UA_GET64(s))
  2131. # endif
  2132. #endif
  2133. #define MEMCPY8_DS(dest,src,len) \
  2134. lzo_memcpy(dest,src,len); dest += len; src += len
  2135. #define BZERO8_PTR(s,l,n) \
  2136. lzo_memset((lzo_voidp)(s),0,(lzo_uint)(l)*(n))
  2137. #define MEMCPY_DS(dest,src,len) \
  2138. do *dest++ = *src++; while (--len > 0)
  2139. LZO_EXTERN(const lzo_bytep) lzo_copyright(void);
  2140. #ifndef __LZO_PTR_H
  2141. #define __LZO_PTR_H 1
  2142. #ifdef __cplusplus
  2143. extern "C" {
  2144. #endif
  2145. #if !defined(lzo_uintptr_t)
  2146. # if (__LZO_MMODEL_HUGE)
  2147. # define lzo_uintptr_t unsigned long
  2148. # else
  2149. # define lzo_uintptr_t acc_uintptr_t
  2150. # ifdef __ACC_INTPTR_T_IS_POINTER
  2151. # define __LZO_UINTPTR_T_IS_POINTER 1
  2152. # endif
  2153. # endif
  2154. #endif
  2155. #if (LZO_ARCH_I086)
  2156. #define PTR(a) ((lzo_bytep) (a))
  2157. #define PTR_ALIGNED_4(a) ((ACC_PTR_FP_OFF(a) & 3) == 0)
  2158. #define PTR_ALIGNED2_4(a,b) (((ACC_PTR_FP_OFF(a) | ACC_PTR_FP_OFF(b)) & 3) == 0)
  2159. #elif (LZO_MM_PVP)
  2160. #define PTR(a) ((lzo_bytep) (a))
  2161. #define PTR_ALIGNED_8(a) ((((lzo_uintptr_t)(a)) >> 61) == 0)
  2162. #define PTR_ALIGNED2_8(a,b) ((((lzo_uintptr_t)(a)|(lzo_uintptr_t)(b)) >> 61) == 0)
  2163. #else
  2164. #define PTR(a) ((lzo_uintptr_t) (a))
  2165. #define PTR_LINEAR(a) PTR(a)
  2166. #define PTR_ALIGNED_4(a) ((PTR_LINEAR(a) & 3) == 0)
  2167. #define PTR_ALIGNED_8(a) ((PTR_LINEAR(a) & 7) == 0)
  2168. #define PTR_ALIGNED2_4(a,b) (((PTR_LINEAR(a) | PTR_LINEAR(b)) & 3) == 0)
  2169. #define PTR_ALIGNED2_8(a,b) (((PTR_LINEAR(a) | PTR_LINEAR(b)) & 7) == 0)
  2170. #endif
  2171. #define PTR_LT(a,b) (PTR(a) < PTR(b))
  2172. #define PTR_GE(a,b) (PTR(a) >= PTR(b))
  2173. #define PTR_DIFF(a,b) (PTR(a) - PTR(b))
  2174. #define pd(a,b) ((lzo_uint) ((a)-(b)))
  2175. LZO_EXTERN(lzo_uintptr_t)
  2176. __lzo_ptr_linear(const lzo_voidp ptr);
  2177. typedef union
  2178. {
  2179. char a_char;
  2180. unsigned char a_uchar;
  2181. short a_short;
  2182. unsigned short a_ushort;
  2183. int a_int;
  2184. unsigned int a_uint;
  2185. long a_long;
  2186. unsigned long a_ulong;
  2187. lzo_int a_lzo_int;
  2188. lzo_uint a_lzo_uint;
  2189. lzo_int32 a_lzo_int32;
  2190. lzo_uint32 a_lzo_uint32;
  2191. #if defined(LZO_UINT64_MAX)
  2192. lzo_int64 a_lzo_int64;
  2193. lzo_uint64 a_lzo_uint64;
  2194. #endif
  2195. ptrdiff_t a_ptrdiff_t;
  2196. lzo_uintptr_t a_lzo_uintptr_t;
  2197. lzo_voidp a_lzo_voidp;
  2198. void * a_void_p;
  2199. lzo_bytep a_lzo_bytep;
  2200. lzo_bytepp a_lzo_bytepp;
  2201. lzo_uintp a_lzo_uintp;
  2202. lzo_uint * a_lzo_uint_p;
  2203. lzo_uint32p a_lzo_uint32p;
  2204. lzo_uint32 * a_lzo_uint32_p;
  2205. unsigned char * a_uchar_p;
  2206. char * a_char_p;
  2207. }
  2208. lzo_full_align_t;
  2209. #ifdef __cplusplus
  2210. }
  2211. #endif
  2212. #endif
  2213. #ifndef LZO_DETERMINISTIC
  2214. #define LZO_DETERMINISTIC 1
  2215. #endif
  2216. #ifndef LZO_DICT_USE_PTR
  2217. #define LZO_DICT_USE_PTR 1
  2218. #if 0 && (LZO_ARCH_I086)
  2219. # undef LZO_DICT_USE_PTR
  2220. # define LZO_DICT_USE_PTR 0
  2221. #endif
  2222. #endif
  2223. #if (LZO_DICT_USE_PTR)
  2224. # define lzo_dict_t const lzo_bytep
  2225. # define lzo_dict_p lzo_dict_t __LZO_MMODEL *
  2226. #else
  2227. # define lzo_dict_t lzo_uint
  2228. # define lzo_dict_p lzo_dict_t __LZO_MMODEL *
  2229. #endif
  2230. #endif
  2231. #if !defined(MINILZO_CFG_SKIP_LZO_PTR)
  2232. LZO_PUBLIC(lzo_uintptr_t)
  2233. __lzo_ptr_linear(const lzo_voidp ptr)
  2234. {
  2235. lzo_uintptr_t p;
  2236. #if (LZO_ARCH_I086)
  2237. p = (((lzo_uintptr_t)(ACC_PTR_FP_SEG(ptr))) << (16 - ACC_MM_AHSHIFT)) + (ACC_PTR_FP_OFF(ptr));
  2238. #elif (LZO_MM_PVP)
  2239. p = (lzo_uintptr_t) (ptr);
  2240. p = (p << 3) | (p >> 61);
  2241. #else
  2242. p = (lzo_uintptr_t) PTR_LINEAR(ptr);
  2243. #endif
  2244. return p;
  2245. }
  2246. LZO_PUBLIC(unsigned)
  2247. __lzo_align_gap(const lzo_voidp ptr, lzo_uint size)
  2248. {
  2249. #if defined(__LZO_UINTPTR_T_IS_POINTER)
  2250. size_t n = (size_t) ptr;
  2251. n = (((n + size - 1) / size) * size) - n;
  2252. #else
  2253. lzo_uintptr_t p, n;
  2254. p = __lzo_ptr_linear(ptr);
  2255. n = (((p + size - 1) / size) * size) - p;
  2256. #endif
  2257. assert(size > 0);
  2258. assert((long)n >= 0);
  2259. assert(n <= size);
  2260. return (unsigned)n;
  2261. }
  2262. #endif
  2263. #if !defined(MINILZO_CFG_SKIP_LZO_UTIL)
  2264. /* If you use the LZO library in a product, I would appreciate that you
  2265. * keep this copyright string in the executable of your product.
  2266. */
  2267. static const char __lzo_copyright[] =
  2268. #if !defined(__LZO_IN_MINLZO)
  2269. LZO_VERSION_STRING;
  2270. #else
  2271. "\r\n\n"
  2272. "LZO data compression library.\n"
  2273. "$Copyright: LZO Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer\n"
  2274. "<markus@oberhumer.com>\n"
  2275. "http://www.oberhumer.com $\n\n"
  2276. "$Id: LZO version: v" LZO_VERSION_STRING ", " LZO_VERSION_DATE " $\n"
  2277. "$Info: " LZO_INFO_STRING " $\n";
  2278. #endif
  2279. LZO_PUBLIC(const lzo_bytep)
  2280. lzo_copyright(void)
  2281. {
  2282. #if (LZO_OS_DOS16 && LZO_CC_TURBOC)
  2283. return (lzo_voidp) __lzo_copyright;
  2284. #else
  2285. return (const lzo_bytep) __lzo_copyright;
  2286. #endif
  2287. }
  2288. LZO_PUBLIC(unsigned)
  2289. lzo_version(void)
  2290. {
  2291. return LZO_VERSION;
  2292. }
  2293. LZO_PUBLIC(const char *)
  2294. lzo_version_string(void)
  2295. {
  2296. return LZO_VERSION_STRING;
  2297. }
  2298. LZO_PUBLIC(const char *)
  2299. lzo_version_date(void)
  2300. {
  2301. return LZO_VERSION_DATE;
  2302. }
  2303. LZO_PUBLIC(const lzo_charp)
  2304. _lzo_version_string(void)
  2305. {
  2306. return LZO_VERSION_STRING;
  2307. }
  2308. LZO_PUBLIC(const lzo_charp)
  2309. _lzo_version_date(void)
  2310. {
  2311. return LZO_VERSION_DATE;
  2312. }
  2313. #define LZO_BASE 65521u
  2314. #define LZO_NMAX 5552
  2315. #define LZO_DO1(buf,i) s1 += buf[i]; s2 += s1
  2316. #define LZO_DO2(buf,i) LZO_DO1(buf,i); LZO_DO1(buf,i+1);
  2317. #define LZO_DO4(buf,i) LZO_DO2(buf,i); LZO_DO2(buf,i+2);
  2318. #define LZO_DO8(buf,i) LZO_DO4(buf,i); LZO_DO4(buf,i+4);
  2319. #define LZO_DO16(buf,i) LZO_DO8(buf,i); LZO_DO8(buf,i+8);
  2320. LZO_PUBLIC(lzo_uint32)
  2321. lzo_adler32(lzo_uint32 adler, const lzo_bytep buf, lzo_uint len)
  2322. {
  2323. lzo_uint32 s1 = adler & 0xffff;
  2324. lzo_uint32 s2 = (adler >> 16) & 0xffff;
  2325. unsigned k;
  2326. if (buf == NULL)
  2327. return 1;
  2328. while (len > 0)
  2329. {
  2330. k = len < LZO_NMAX ? (unsigned) len : LZO_NMAX;
  2331. len -= k;
  2332. if (k >= 16) do
  2333. {
  2334. LZO_DO16(buf,0);
  2335. buf += 16;
  2336. k -= 16;
  2337. } while (k >= 16);
  2338. if (k != 0) do
  2339. {
  2340. s1 += *buf++;
  2341. s2 += s1;
  2342. } while (--k > 0);
  2343. s1 %= LZO_BASE;
  2344. s2 %= LZO_BASE;
  2345. }
  2346. return (s2 << 16) | s1;
  2347. }
  2348. #undef LZO_DO1
  2349. #undef LZO_DO2
  2350. #undef LZO_DO4
  2351. #undef LZO_DO8
  2352. #undef LZO_DO16
  2353. #endif
  2354. #if !defined(MINILZO_CFG_SKIP_LZO_STRING)
  2355. #undef lzo_memcmp
  2356. #undef lzo_memcpy
  2357. #undef lzo_memmove
  2358. #undef lzo_memset
  2359. #if !defined(__LZO_MMODEL_HUGE)
  2360. # undef LZO_HAVE_MM_HUGE_PTR
  2361. #endif
  2362. #define lzo_hsize_t lzo_uint
  2363. #define lzo_hvoid_p lzo_voidp
  2364. #define lzo_hbyte_p lzo_bytep
  2365. #define LZOLIB_PUBLIC(r,f) LZO_PUBLIC(r) f
  2366. #define lzo_hmemcmp lzo_memcmp
  2367. #define lzo_hmemcpy lzo_memcpy
  2368. #define lzo_hmemmove lzo_memmove
  2369. #define lzo_hmemset lzo_memset
  2370. #define __LZOLIB_HMEMCPY_CH_INCLUDED 1
  2371. #if !defined(LZOLIB_PUBLIC)
  2372. # define LZOLIB_PUBLIC(r,f) r __LZOLIB_FUNCNAME(f)
  2373. #endif
  2374. LZOLIB_PUBLIC(int, lzo_hmemcmp) (const lzo_hvoid_p s1, const lzo_hvoid_p s2, lzo_hsize_t len)
  2375. {
  2376. #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMCMP)
  2377. const lzo_hbyte_p p1 = (const lzo_hbyte_p) s1;
  2378. const lzo_hbyte_p p2 = (const lzo_hbyte_p) s2;
  2379. if __lzo_likely(len > 0) do
  2380. {
  2381. int d = *p1 - *p2;
  2382. if (d != 0)
  2383. return d;
  2384. p1++; p2++;
  2385. } while __lzo_likely(--len > 0);
  2386. return 0;
  2387. #else
  2388. return memcmp(s1, s2, len);
  2389. #endif
  2390. }
  2391. LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemcpy) (lzo_hvoid_p dest, const lzo_hvoid_p src, lzo_hsize_t len)
  2392. {
  2393. #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMCPY)
  2394. lzo_hbyte_p p1 = (lzo_hbyte_p) dest;
  2395. const lzo_hbyte_p p2 = (const lzo_hbyte_p) src;
  2396. if (!(len > 0) || p1 == p2)
  2397. return dest;
  2398. do
  2399. *p1++ = *p2++;
  2400. while __lzo_likely(--len > 0);
  2401. return dest;
  2402. #else
  2403. return memcpy(dest, src, len);
  2404. #endif
  2405. }
  2406. LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemmove) (lzo_hvoid_p dest, const lzo_hvoid_p src, lzo_hsize_t len)
  2407. {
  2408. #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMMOVE)
  2409. lzo_hbyte_p p1 = (lzo_hbyte_p) dest;
  2410. const lzo_hbyte_p p2 = (const lzo_hbyte_p) src;
  2411. if (!(len > 0) || p1 == p2)
  2412. return dest;
  2413. if (p1 < p2)
  2414. {
  2415. do
  2416. *p1++ = *p2++;
  2417. while __lzo_likely(--len > 0);
  2418. }
  2419. else
  2420. {
  2421. p1 += len;
  2422. p2 += len;
  2423. do
  2424. *--p1 = *--p2;
  2425. while __lzo_likely(--len > 0);
  2426. }
  2427. return dest;
  2428. #else
  2429. return memmove(dest, src, len);
  2430. #endif
  2431. }
  2432. LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemset) (lzo_hvoid_p s, int c, lzo_hsize_t len)
  2433. {
  2434. #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMSET)
  2435. lzo_hbyte_p p = (lzo_hbyte_p) s;
  2436. if __lzo_likely(len > 0) do
  2437. *p++ = (unsigned char) c;
  2438. while __lzo_likely(--len > 0);
  2439. return s;
  2440. #else
  2441. return memset(s, c, len);
  2442. #endif
  2443. }
  2444. #undef LZOLIB_PUBLIC
  2445. #endif
  2446. #if !defined(MINILZO_CFG_SKIP_LZO_INIT)
  2447. #if !defined(__LZO_IN_MINILZO)
  2448. #define ACC_WANT_ACC_CHK_CH 1
  2449. #undef ACCCHK_ASSERT
  2450. ACCCHK_ASSERT_IS_SIGNED_T(lzo_int)
  2451. ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uint)
  2452. ACCCHK_ASSERT_IS_SIGNED_T(lzo_int32)
  2453. ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uint32)
  2454. ACCCHK_ASSERT((LZO_UINT32_C(1) << (int)(8*sizeof(LZO_UINT32_C(1))-1)) > 0)
  2455. ACCCHK_ASSERT(sizeof(lzo_uint32) >= 4)
  2456. #if defined(LZO_UINT64_MAX)
  2457. ACCCHK_ASSERT(sizeof(lzo_uint64) == 8)
  2458. ACCCHK_ASSERT_IS_SIGNED_T(lzo_int64)
  2459. ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uint64)
  2460. #endif
  2461. #if !defined(__LZO_UINTPTR_T_IS_POINTER)
  2462. ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uintptr_t)
  2463. #endif
  2464. ACCCHK_ASSERT(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp))
  2465. ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_xint)
  2466. ACCCHK_ASSERT(sizeof(lzo_xint) >= sizeof(lzo_uint32))
  2467. ACCCHK_ASSERT(sizeof(lzo_xint) >= sizeof(lzo_uint))
  2468. ACCCHK_ASSERT(sizeof(lzo_xint) == sizeof(lzo_uint32) || sizeof(lzo_xint) == sizeof(lzo_uint))
  2469. #endif
  2470. #undef ACCCHK_ASSERT
  2471. #define WANT_lzo_bitops_clz32 1
  2472. #define WANT_lzo_bitops_clz64 1
  2473. #define WANT_lzo_bitops_ctz32 1
  2474. #define WANT_lzo_bitops_ctz64 1
  2475. #if (defined(_WIN32) || defined(_WIN64)) && ((LZO_CC_INTELC && (__INTEL_COMPILER >= 1000)) || (LZO_CC_MSC && (_MSC_VER >= 1400)))
  2476. #include <intrin.h>
  2477. #if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32) && 0
  2478. #pragma intrinsic(_BitScanReverse)
  2479. static __lzo_inline unsigned lzo_bitops_clz32(lzo_uint32 v)
  2480. {
  2481. unsigned long r;
  2482. (void) _BitScanReverse(&r, v);
  2483. return (unsigned) r;
  2484. }
  2485. #define lzo_bitops_clz32 lzo_bitops_clz32
  2486. #endif
  2487. #if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX) && 0
  2488. #pragma intrinsic(_BitScanReverse64)
  2489. static __lzo_inline unsigned lzo_bitops_clz64(lzo_uint64 v)
  2490. {
  2491. unsigned long r;
  2492. (void) _BitScanReverse64(&r, v);
  2493. return (unsigned) r;
  2494. }
  2495. #define lzo_bitops_clz64 lzo_bitops_clz64
  2496. #endif
  2497. #if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32)
  2498. #pragma intrinsic(_BitScanForward)
  2499. static __lzo_inline unsigned lzo_bitops_ctz32(lzo_uint32 v)
  2500. {
  2501. unsigned long r;
  2502. (void) _BitScanForward(&r, v);
  2503. return (unsigned) r;
  2504. }
  2505. #define lzo_bitops_ctz32 lzo_bitops_ctz32
  2506. #endif
  2507. #if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX)
  2508. #pragma intrinsic(_BitScanForward64)
  2509. static __lzo_inline unsigned lzo_bitops_ctz64(lzo_uint64 v)
  2510. {
  2511. unsigned long r;
  2512. (void) _BitScanForward64(&r, v);
  2513. return (unsigned) r;
  2514. }
  2515. #define lzo_bitops_ctz64 lzo_bitops_ctz64
  2516. #endif
  2517. #elif (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x030400ul) || (LZO_CC_INTELC && (__INTEL_COMPILER >= 1000)) || (LZO_CC_LLVM && (!defined(__llvm_tools_version__) || (__llvm_tools_version__+0 >= 0x010500ul))))
  2518. #if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32)
  2519. #define lzo_bitops_clz32(v) ((unsigned) __builtin_clz(v))
  2520. #endif
  2521. #if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX)
  2522. #define lzo_bitops_clz64(v) ((unsigned) __builtin_clzll(v))
  2523. #endif
  2524. #if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32)
  2525. #define lzo_bitops_ctz32(v) ((unsigned) __builtin_ctz(v))
  2526. #endif
  2527. #if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX)
  2528. #define lzo_bitops_ctz64(v) ((unsigned) __builtin_ctzll(v))
  2529. #endif
  2530. #if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount32)
  2531. #define lzo_bitops_popcount32(v) ((unsigned) __builtin_popcount(v))
  2532. #endif
  2533. #if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount64) && defined(LZO_UINT64_MAX)
  2534. #define lzo_bitops_popcount64(v) ((unsigned) __builtin_popcountll(v))
  2535. #endif
  2536. #endif
  2537. #if 0
  2538. #define u2p(ptr,off) ((lzo_voidp) (((lzo_bytep)(lzo_voidp)(ptr)) + (off)))
  2539. #else
  2540. static __lzo_noinline lzo_voidp u2p(lzo_voidp ptr, lzo_uint off)
  2541. {
  2542. return (lzo_voidp) ((lzo_bytep) ptr + off);
  2543. }
  2544. #endif
  2545. LZO_PUBLIC(int)
  2546. _lzo_config_check(void)
  2547. {
  2548. lzo_bool r = 1;
  2549. union {
  2550. lzo_xint a[2]; unsigned char b[2*LZO_MAX(8,sizeof(lzo_xint))];
  2551. #if defined(LZO_UNALIGNED_OK_8)
  2552. lzo_uint64 c[2];
  2553. #endif
  2554. unsigned short x[2]; lzo_uint32 y[2]; lzo_uint z[2];
  2555. } u;
  2556. lzo_voidp p;
  2557. u.a[0] = u.a[1] = 0;
  2558. p = u2p(&u, 0);
  2559. r &= ((* (lzo_bytep) p) == 0);
  2560. #if !defined(LZO_CFG_NO_CONFIG_CHECK)
  2561. #if defined(LZO_ABI_BIG_ENDIAN)
  2562. u.a[0] = u.a[1] = 0; u.b[sizeof(lzo_uint) - 1] = 128;
  2563. p = u2p(&u, 0);
  2564. r &= ((* (lzo_uintp) p) == 128);
  2565. #endif
  2566. #if defined(LZO_ABI_LITTLE_ENDIAN)
  2567. u.a[0] = u.a[1] = 0; u.b[0] = 128;
  2568. p = u2p(&u, 0);
  2569. r &= ((* (lzo_uintp) p) == 128);
  2570. #endif
  2571. #if defined(LZO_UNALIGNED_OK_2)
  2572. u.a[0] = u.a[1] = 0;
  2573. u.b[0] = 1; u.b[sizeof(unsigned short) + 1] = 2;
  2574. p = u2p(&u, 1);
  2575. r &= ((* (lzo_ushortp) p) == 0);
  2576. #endif
  2577. #if defined(LZO_UNALIGNED_OK_4)
  2578. u.a[0] = u.a[1] = 0;
  2579. u.b[0] = 3; u.b[sizeof(lzo_uint32) + 1] = 4;
  2580. p = u2p(&u, 1);
  2581. r &= ((* (lzo_uint32p) p) == 0);
  2582. #endif
  2583. #if defined(LZO_UNALIGNED_OK_8)
  2584. u.c[0] = u.c[1] = 0;
  2585. u.b[0] = 5; u.b[sizeof(lzo_uint64) + 1] = 6;
  2586. p = u2p(&u, 1);
  2587. r &= ((* (lzo_uint64p) p) == 0);
  2588. #endif
  2589. #if defined(lzo_bitops_clz32)
  2590. { unsigned i; lzo_uint32 v = 1;
  2591. for (i = 0; i < 32; i++, v <<= 1)
  2592. r &= lzo_bitops_clz32(v) == 31 - i;
  2593. }
  2594. #endif
  2595. #if defined(lzo_bitops_clz64)
  2596. { unsigned i; lzo_uint64 v = 1;
  2597. for (i = 0; i < 64; i++, v <<= 1)
  2598. r &= lzo_bitops_clz64(v) == 63 - i;
  2599. }
  2600. #endif
  2601. #if defined(lzo_bitops_ctz32)
  2602. { unsigned i; lzo_uint32 v = 1;
  2603. for (i = 0; i < 32; i++, v <<= 1)
  2604. r &= lzo_bitops_ctz32(v) == i;
  2605. }
  2606. #endif
  2607. #if defined(lzo_bitops_ctz64)
  2608. { unsigned i; lzo_uint64 v = 1;
  2609. for (i = 0; i < 64; i++, v <<= 1)
  2610. r &= lzo_bitops_ctz64(v) == i;
  2611. }
  2612. #endif
  2613. #endif
  2614. return r == 1 ? LZO_E_OK : LZO_E_ERROR;
  2615. }
  2616. LZO_PUBLIC(int)
  2617. __lzo_init_v2(unsigned v, int s1, int s2, int s3, int s4, int s5,
  2618. int s6, int s7, int s8, int s9)
  2619. {
  2620. int r;
  2621. #if defined(__LZO_IN_MINILZO)
  2622. #elif (LZO_CC_MSC && ((_MSC_VER) < 700))
  2623. #else
  2624. #define ACC_WANT_ACC_CHK_CH 1
  2625. #undef ACCCHK_ASSERT
  2626. #define ACCCHK_ASSERT(expr) LZO_COMPILE_TIME_ASSERT(expr)
  2627. #endif
  2628. #undef ACCCHK_ASSERT
  2629. if (v == 0)
  2630. return LZO_E_ERROR;
  2631. r = (s1 == -1 || s1 == (int) sizeof(short)) &&
  2632. (s2 == -1 || s2 == (int) sizeof(int)) &&
  2633. (s3 == -1 || s3 == (int) sizeof(long)) &&
  2634. (s4 == -1 || s4 == (int) sizeof(lzo_uint32)) &&
  2635. (s5 == -1 || s5 == (int) sizeof(lzo_uint)) &&
  2636. (s6 == -1 || s6 == (int) lzo_sizeof_dict_t) &&
  2637. (s7 == -1 || s7 == (int) sizeof(char *)) &&
  2638. (s8 == -1 || s8 == (int) sizeof(lzo_voidp)) &&
  2639. (s9 == -1 || s9 == (int) sizeof(lzo_callback_t));
  2640. if (!r)
  2641. return LZO_E_ERROR;
  2642. r = _lzo_config_check();
  2643. if (r != LZO_E_OK)
  2644. return r;
  2645. return r;
  2646. }
  2647. #if !defined(__LZO_IN_MINILZO)
  2648. #if (LZO_OS_WIN16 && LZO_CC_WATCOMC) && defined(__SW_BD)
  2649. #if 0
  2650. BOOL FAR PASCAL LibMain ( HANDLE hInstance, WORD wDataSegment,
  2651. WORD wHeapSize, LPSTR lpszCmdLine )
  2652. #else
  2653. int __far __pascal LibMain ( int a, short b, short c, long d )
  2654. #endif
  2655. {
  2656. LZO_UNUSED(a); LZO_UNUSED(b); LZO_UNUSED(c); LZO_UNUSED(d);
  2657. return 1;
  2658. }
  2659. #endif
  2660. #endif
  2661. #endif
  2662. #define LZO1X 1
  2663. #define LZO_EOF_CODE 1
  2664. #define M2_MAX_OFFSET 0x0800
  2665. #if !defined(MINILZO_CFG_SKIP_LZO1X_1_COMPRESS)
  2666. #if 1 && defined(UA_GET32)
  2667. #undef LZO_DICT_USE_PTR
  2668. #define LZO_DICT_USE_PTR 0
  2669. #undef lzo_dict_t
  2670. #define lzo_dict_t unsigned short
  2671. #endif
  2672. #define LZO_NEED_DICT_H 1
  2673. #ifndef D_BITS
  2674. #define D_BITS 14
  2675. #endif
  2676. #define D_INDEX1(d,p) d = DM(DMUL(0x21,DX3(p,5,5,6)) >> 5)
  2677. #define D_INDEX2(d,p) d = (d & (D_MASK & 0x7ff)) ^ (D_HIGH | 0x1f)
  2678. #if 1
  2679. #define DINDEX(dv,p) DM(((DMUL(0x1824429d,dv)) >> (32-D_BITS)))
  2680. #else
  2681. #define DINDEX(dv,p) DM((dv) + ((dv) >> (32-D_BITS)))
  2682. #endif
  2683. #ifndef __LZO_CONFIG1X_H
  2684. #define __LZO_CONFIG1X_H 1
  2685. #if !defined(LZO1X) && !defined(LZO1Y) && !defined(LZO1Z)
  2686. # define LZO1X 1
  2687. #endif
  2688. #if !defined(__LZO_IN_MINILZO)
  2689. #include "lzo/lzo1x.h"
  2690. #endif
  2691. #ifndef LZO_EOF_CODE
  2692. #define LZO_EOF_CODE 1
  2693. #endif
  2694. #undef LZO_DETERMINISTIC
  2695. #define M1_MAX_OFFSET 0x0400
  2696. #ifndef M2_MAX_OFFSET
  2697. #define M2_MAX_OFFSET 0x0800
  2698. #endif
  2699. #define M3_MAX_OFFSET 0x4000
  2700. #define M4_MAX_OFFSET 0xbfff
  2701. #define MX_MAX_OFFSET (M1_MAX_OFFSET + M2_MAX_OFFSET)
  2702. #define M1_MIN_LEN 2
  2703. #define M1_MAX_LEN 2
  2704. #define M2_MIN_LEN 3
  2705. #ifndef M2_MAX_LEN
  2706. #define M2_MAX_LEN 8
  2707. #endif
  2708. #define M3_MIN_LEN 3
  2709. #define M3_MAX_LEN 33
  2710. #define M4_MIN_LEN 3
  2711. #define M4_MAX_LEN 9
  2712. #define M1_MARKER 0
  2713. #define M2_MARKER 64
  2714. #define M3_MARKER 32
  2715. #define M4_MARKER 16
  2716. #ifndef MIN_LOOKAHEAD
  2717. #define MIN_LOOKAHEAD (M2_MAX_LEN + 1)
  2718. #endif
  2719. #if defined(LZO_NEED_DICT_H)
  2720. #ifndef LZO_HASH
  2721. #define LZO_HASH LZO_HASH_LZO_INCREMENTAL_B
  2722. #endif
  2723. #define DL_MIN_LEN M2_MIN_LEN
  2724. #ifndef __LZO_DICT_H
  2725. #define __LZO_DICT_H 1
  2726. #ifdef __cplusplus
  2727. extern "C" {
  2728. #endif
  2729. #if !defined(D_BITS) && defined(DBITS)
  2730. # define D_BITS DBITS
  2731. #endif
  2732. #if !defined(D_BITS)
  2733. # error "D_BITS is not defined"
  2734. #endif
  2735. #if (D_BITS < 16)
  2736. # define D_SIZE LZO_SIZE(D_BITS)
  2737. # define D_MASK LZO_MASK(D_BITS)
  2738. #else
  2739. # define D_SIZE LZO_USIZE(D_BITS)
  2740. # define D_MASK LZO_UMASK(D_BITS)
  2741. #endif
  2742. #define D_HIGH ((D_MASK >> 1) + 1)
  2743. #if !defined(DD_BITS)
  2744. # define DD_BITS 0
  2745. #endif
  2746. #define DD_SIZE LZO_SIZE(DD_BITS)
  2747. #define DD_MASK LZO_MASK(DD_BITS)
  2748. #if !defined(DL_BITS)
  2749. # define DL_BITS (D_BITS - DD_BITS)
  2750. #endif
  2751. #if (DL_BITS < 16)
  2752. # define DL_SIZE LZO_SIZE(DL_BITS)
  2753. # define DL_MASK LZO_MASK(DL_BITS)
  2754. #else
  2755. # define DL_SIZE LZO_USIZE(DL_BITS)
  2756. # define DL_MASK LZO_UMASK(DL_BITS)
  2757. #endif
  2758. #if (D_BITS != DL_BITS + DD_BITS)
  2759. # error "D_BITS does not match"
  2760. #endif
  2761. #if (D_BITS < 6 || D_BITS > 18)
  2762. # error "invalid D_BITS"
  2763. #endif
  2764. #if (DL_BITS < 6 || DL_BITS > 20)
  2765. # error "invalid DL_BITS"
  2766. #endif
  2767. #if (DD_BITS < 0 || DD_BITS > 6)
  2768. # error "invalid DD_BITS"
  2769. #endif
  2770. #if !defined(DL_MIN_LEN)
  2771. # define DL_MIN_LEN 3
  2772. #endif
  2773. #if !defined(DL_SHIFT)
  2774. # define DL_SHIFT ((DL_BITS + (DL_MIN_LEN - 1)) / DL_MIN_LEN)
  2775. #endif
  2776. #define LZO_HASH_GZIP 1
  2777. #define LZO_HASH_GZIP_INCREMENTAL 2
  2778. #define LZO_HASH_LZO_INCREMENTAL_A 3
  2779. #define LZO_HASH_LZO_INCREMENTAL_B 4
  2780. #if !defined(LZO_HASH)
  2781. # error "choose a hashing strategy"
  2782. #endif
  2783. #undef DM
  2784. #undef DX
  2785. #if (DL_MIN_LEN == 3)
  2786. # define _DV2_A(p,shift1,shift2) \
  2787. (((( (lzo_xint)((p)[0]) << shift1) ^ (p)[1]) << shift2) ^ (p)[2])
  2788. # define _DV2_B(p,shift1,shift2) \
  2789. (((( (lzo_xint)((p)[2]) << shift1) ^ (p)[1]) << shift2) ^ (p)[0])
  2790. # define _DV3_B(p,shift1,shift2,shift3) \
  2791. ((_DV2_B((p)+1,shift1,shift2) << (shift3)) ^ (p)[0])
  2792. #elif (DL_MIN_LEN == 2)
  2793. # define _DV2_A(p,shift1,shift2) \
  2794. (( (lzo_xint)(p[0]) << shift1) ^ p[1])
  2795. # define _DV2_B(p,shift1,shift2) \
  2796. (( (lzo_xint)(p[1]) << shift1) ^ p[2])
  2797. #else
  2798. # error "invalid DL_MIN_LEN"
  2799. #endif
  2800. #define _DV_A(p,shift) _DV2_A(p,shift,shift)
  2801. #define _DV_B(p,shift) _DV2_B(p,shift,shift)
  2802. #define DA2(p,s1,s2) \
  2803. (((((lzo_xint)((p)[2]) << (s2)) + (p)[1]) << (s1)) + (p)[0])
  2804. #define DS2(p,s1,s2) \
  2805. (((((lzo_xint)((p)[2]) << (s2)) - (p)[1]) << (s1)) - (p)[0])
  2806. #define DX2(p,s1,s2) \
  2807. (((((lzo_xint)((p)[2]) << (s2)) ^ (p)[1]) << (s1)) ^ (p)[0])
  2808. #define DA3(p,s1,s2,s3) ((DA2((p)+1,s2,s3) << (s1)) + (p)[0])
  2809. #define DS3(p,s1,s2,s3) ((DS2((p)+1,s2,s3) << (s1)) - (p)[0])
  2810. #define DX3(p,s1,s2,s3) ((DX2((p)+1,s2,s3) << (s1)) ^ (p)[0])
  2811. #define DMS(v,s) ((lzo_uint) (((v) & (D_MASK >> (s))) << (s)))
  2812. #define DM(v) DMS(v,0)
  2813. #if (LZO_HASH == LZO_HASH_GZIP)
  2814. # define _DINDEX(dv,p) (_DV_A((p),DL_SHIFT))
  2815. #elif (LZO_HASH == LZO_HASH_GZIP_INCREMENTAL)
  2816. # define __LZO_HASH_INCREMENTAL 1
  2817. # define DVAL_FIRST(dv,p) dv = _DV_A((p),DL_SHIFT)
  2818. # define DVAL_NEXT(dv,p) dv = (((dv) << DL_SHIFT) ^ p[2])
  2819. # define _DINDEX(dv,p) (dv)
  2820. # define DVAL_LOOKAHEAD DL_MIN_LEN
  2821. #elif (LZO_HASH == LZO_HASH_LZO_INCREMENTAL_A)
  2822. # define __LZO_HASH_INCREMENTAL 1
  2823. # define DVAL_FIRST(dv,p) dv = _DV_A((p),5)
  2824. # define DVAL_NEXT(dv,p) \
  2825. dv ^= (lzo_xint)(p[-1]) << (2*5); dv = (((dv) << 5) ^ p[2])
  2826. # define _DINDEX(dv,p) ((DMUL(0x9f5f,dv)) >> 5)
  2827. # define DVAL_LOOKAHEAD DL_MIN_LEN
  2828. #elif (LZO_HASH == LZO_HASH_LZO_INCREMENTAL_B)
  2829. # define __LZO_HASH_INCREMENTAL 1
  2830. # define DVAL_FIRST(dv,p) dv = _DV_B((p),5)
  2831. # define DVAL_NEXT(dv,p) \
  2832. dv ^= p[-1]; dv = (((dv) >> 5) ^ ((lzo_xint)(p[2]) << (2*5)))
  2833. # define _DINDEX(dv,p) ((DMUL(0x9f5f,dv)) >> 5)
  2834. # define DVAL_LOOKAHEAD DL_MIN_LEN
  2835. #else
  2836. # error "choose a hashing strategy"
  2837. #endif
  2838. #ifndef DINDEX
  2839. #define DINDEX(dv,p) ((lzo_uint)((_DINDEX(dv,p)) & DL_MASK) << DD_BITS)
  2840. #endif
  2841. #if !defined(DINDEX1) && defined(D_INDEX1)
  2842. #define DINDEX1 D_INDEX1
  2843. #endif
  2844. #if !defined(DINDEX2) && defined(D_INDEX2)
  2845. #define DINDEX2 D_INDEX2
  2846. #endif
  2847. #if !defined(__LZO_HASH_INCREMENTAL)
  2848. # define DVAL_FIRST(dv,p) ((void) 0)
  2849. # define DVAL_NEXT(dv,p) ((void) 0)
  2850. # define DVAL_LOOKAHEAD 0
  2851. #endif
  2852. #if !defined(DVAL_ASSERT)
  2853. #if defined(__LZO_HASH_INCREMENTAL) && !defined(NDEBUG)
  2854. #if (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x020700ul) || LZO_CC_LLVM)
  2855. static void __attribute__((__unused__))
  2856. #else
  2857. static void
  2858. #endif
  2859. DVAL_ASSERT(lzo_xint dv, const lzo_bytep p)
  2860. {
  2861. lzo_xint df;
  2862. DVAL_FIRST(df,(p));
  2863. assert(DINDEX(dv,p) == DINDEX(df,p));
  2864. }
  2865. #else
  2866. # define DVAL_ASSERT(dv,p) ((void) 0)
  2867. #endif
  2868. #endif
  2869. #if (LZO_DICT_USE_PTR)
  2870. # define DENTRY(p,in) (p)
  2871. # define GINDEX(m_pos,m_off,dict,dindex,in) m_pos = dict[dindex]
  2872. #else
  2873. # define DENTRY(p,in) ((lzo_dict_t) pd(p, in))
  2874. # define GINDEX(m_pos,m_off,dict,dindex,in) m_off = dict[dindex]
  2875. #endif
  2876. #if (DD_BITS == 0)
  2877. # define UPDATE_D(dict,drun,dv,p,in) dict[ DINDEX(dv,p) ] = DENTRY(p,in)
  2878. # define UPDATE_I(dict,drun,index,p,in) dict[index] = DENTRY(p,in)
  2879. # define UPDATE_P(ptr,drun,p,in) (ptr)[0] = DENTRY(p,in)
  2880. #else
  2881. # define UPDATE_D(dict,drun,dv,p,in) \
  2882. dict[ DINDEX(dv,p) + drun++ ] = DENTRY(p,in); drun &= DD_MASK
  2883. # define UPDATE_I(dict,drun,index,p,in) \
  2884. dict[ (index) + drun++ ] = DENTRY(p,in); drun &= DD_MASK
  2885. # define UPDATE_P(ptr,drun,p,in) \
  2886. (ptr) [ drun++ ] = DENTRY(p,in); drun &= DD_MASK
  2887. #endif
  2888. #if (LZO_DICT_USE_PTR)
  2889. #define LZO_CHECK_MPOS_DET(m_pos,m_off,in,ip,max_offset) \
  2890. (m_pos == NULL || (m_off = pd(ip, m_pos)) > max_offset)
  2891. #define LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,max_offset) \
  2892. (BOUNDS_CHECKING_OFF_IN_EXPR(( \
  2893. m_pos = ip - (lzo_uint) PTR_DIFF(ip,m_pos), \
  2894. PTR_LT(m_pos,in) || \
  2895. (m_off = (lzo_uint) PTR_DIFF(ip,m_pos)) == 0 || \
  2896. m_off > max_offset )))
  2897. #else
  2898. #define LZO_CHECK_MPOS_DET(m_pos,m_off,in,ip,max_offset) \
  2899. (m_off == 0 || \
  2900. ((m_off = pd(ip, in) - m_off) > max_offset) || \
  2901. (m_pos = (ip) - (m_off), 0) )
  2902. #define LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,max_offset) \
  2903. (pd(ip, in) <= m_off || \
  2904. ((m_off = pd(ip, in) - m_off) > max_offset) || \
  2905. (m_pos = (ip) - (m_off), 0) )
  2906. #endif
  2907. #if (LZO_DETERMINISTIC)
  2908. # define LZO_CHECK_MPOS LZO_CHECK_MPOS_DET
  2909. #else
  2910. # define LZO_CHECK_MPOS LZO_CHECK_MPOS_NON_DET
  2911. #endif
  2912. #ifdef __cplusplus
  2913. }
  2914. #endif
  2915. #endif
  2916. #endif
  2917. #endif
  2918. #define LZO_DETERMINISTIC !(LZO_DICT_USE_PTR)
  2919. #ifndef DO_COMPRESS
  2920. #define DO_COMPRESS lzo1x_1_compress
  2921. #endif
  2922. #if 1 && defined(DO_COMPRESS) && !defined(do_compress)
  2923. # define do_compress LZO_CPP_ECONCAT2(DO_COMPRESS,_core)
  2924. #endif
  2925. #if defined(UA_GET64) && (LZO_ABI_BIG_ENDIAN)
  2926. # define WANT_lzo_bitops_clz64 1
  2927. #elif defined(UA_GET64) && (LZO_ABI_LITTLE_ENDIAN)
  2928. # define WANT_lzo_bitops_ctz64 1
  2929. #elif defined(UA_GET32) && (LZO_ABI_BIG_ENDIAN)
  2930. # define WANT_lzo_bitops_clz32 1
  2931. #elif defined(UA_GET32) && (LZO_ABI_LITTLE_ENDIAN)
  2932. # define WANT_lzo_bitops_ctz32 1
  2933. #endif
  2934. #if (defined(_WIN32) || defined(_WIN64)) && ((LZO_CC_INTELC && (__INTEL_COMPILER >= 1000)) || (LZO_CC_MSC && (_MSC_VER >= 1400)))
  2935. #include <intrin.h>
  2936. #if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32) && 0
  2937. #pragma intrinsic(_BitScanReverse)
  2938. static __lzo_inline unsigned lzo_bitops_clz32(lzo_uint32 v)
  2939. {
  2940. unsigned long r;
  2941. (void) _BitScanReverse(&r, v);
  2942. return (unsigned) r;
  2943. }
  2944. #define lzo_bitops_clz32 lzo_bitops_clz32
  2945. #endif
  2946. #if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX) && 0
  2947. #pragma intrinsic(_BitScanReverse64)
  2948. static __lzo_inline unsigned lzo_bitops_clz64(lzo_uint64 v)
  2949. {
  2950. unsigned long r;
  2951. (void) _BitScanReverse64(&r, v);
  2952. return (unsigned) r;
  2953. }
  2954. #define lzo_bitops_clz64 lzo_bitops_clz64
  2955. #endif
  2956. #if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32)
  2957. #pragma intrinsic(_BitScanForward)
  2958. static __lzo_inline unsigned lzo_bitops_ctz32(lzo_uint32 v)
  2959. {
  2960. unsigned long r;
  2961. (void) _BitScanForward(&r, v);
  2962. return (unsigned) r;
  2963. }
  2964. #define lzo_bitops_ctz32 lzo_bitops_ctz32
  2965. #endif
  2966. #if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX)
  2967. #pragma intrinsic(_BitScanForward64)
  2968. static __lzo_inline unsigned lzo_bitops_ctz64(lzo_uint64 v)
  2969. {
  2970. unsigned long r;
  2971. (void) _BitScanForward64(&r, v);
  2972. return (unsigned) r;
  2973. }
  2974. #define lzo_bitops_ctz64 lzo_bitops_ctz64
  2975. #endif
  2976. #elif (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x030400ul) || (LZO_CC_INTELC && (__INTEL_COMPILER >= 1000)) || (LZO_CC_LLVM && (!defined(__llvm_tools_version__) || (__llvm_tools_version__+0 >= 0x010500ul))))
  2977. #if !defined(lzo_bitops_clz32) && defined(WANT_lzo_bitops_clz32)
  2978. #define lzo_bitops_clz32(v) ((unsigned) __builtin_clz(v))
  2979. #endif
  2980. #if !defined(lzo_bitops_clz64) && defined(WANT_lzo_bitops_clz64) && defined(LZO_UINT64_MAX)
  2981. #define lzo_bitops_clz64(v) ((unsigned) __builtin_clzll(v))
  2982. #endif
  2983. #if !defined(lzo_bitops_ctz32) && defined(WANT_lzo_bitops_ctz32)
  2984. #define lzo_bitops_ctz32(v) ((unsigned) __builtin_ctz(v))
  2985. #endif
  2986. #if !defined(lzo_bitops_ctz64) && defined(WANT_lzo_bitops_ctz64) && defined(LZO_UINT64_MAX)
  2987. #define lzo_bitops_ctz64(v) ((unsigned) __builtin_ctzll(v))
  2988. #endif
  2989. #if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount32)
  2990. #define lzo_bitops_popcount32(v) ((unsigned) __builtin_popcount(v))
  2991. #endif
  2992. #if !defined(lzo_bitops_popcount32) && defined(WANT_lzo_bitops_popcount64) && defined(LZO_UINT64_MAX)
  2993. #define lzo_bitops_popcount64(v) ((unsigned) __builtin_popcountll(v))
  2994. #endif
  2995. #endif
  2996. static __lzo_noinline lzo_uint
  2997. do_compress ( const lzo_bytep in , lzo_uint in_len,
  2998. lzo_bytep out, lzo_uintp out_len,
  2999. lzo_uint ti, lzo_voidp wrkmem)
  3000. {
  3001. register const lzo_bytep ip;
  3002. lzo_bytep op;
  3003. const lzo_bytep const in_end = in + in_len;
  3004. const lzo_bytep const ip_end = in + in_len - 20;
  3005. const lzo_bytep ii;
  3006. lzo_dict_p const dict = (lzo_dict_p) wrkmem;
  3007. op = out;
  3008. ip = in;
  3009. ii = ip;
  3010. ip += ti < 4 ? 4 - ti : 0;
  3011. for (;;)
  3012. {
  3013. const lzo_bytep m_pos;
  3014. #if !(LZO_DETERMINISTIC)
  3015. LZO_DEFINE_UNINITIALIZED_VAR(lzo_uint, m_off, 0);
  3016. lzo_uint m_len;
  3017. lzo_uint dindex;
  3018. next:
  3019. if __lzo_unlikely(ip >= ip_end)
  3020. break;
  3021. DINDEX1(dindex,ip);
  3022. GINDEX(m_pos,m_off,dict,dindex,in);
  3023. if (LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,M4_MAX_OFFSET))
  3024. goto literal;
  3025. #if 1
  3026. if (m_off <= M2_MAX_OFFSET || m_pos[3] == ip[3])
  3027. goto try_match;
  3028. DINDEX2(dindex,ip);
  3029. #endif
  3030. GINDEX(m_pos,m_off,dict,dindex,in);
  3031. if (LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,M4_MAX_OFFSET))
  3032. goto literal;
  3033. if (m_off <= M2_MAX_OFFSET || m_pos[3] == ip[3])
  3034. goto try_match;
  3035. goto literal;
  3036. try_match:
  3037. #if defined(UA_GET32)
  3038. if (UA_GET32(m_pos) != UA_GET32(ip))
  3039. #else
  3040. if (m_pos[0] != ip[0] || m_pos[1] != ip[1] || m_pos[2] != ip[2] || m_pos[3] != ip[3])
  3041. #endif
  3042. {
  3043. literal:
  3044. UPDATE_I(dict,0,dindex,ip,in);
  3045. ip += 1 + ((ip - ii) >> 5);
  3046. continue;
  3047. }
  3048. UPDATE_I(dict,0,dindex,ip,in);
  3049. #else
  3050. lzo_uint m_off;
  3051. lzo_uint m_len;
  3052. {
  3053. lzo_uint32 dv;
  3054. lzo_uint dindex;
  3055. literal:
  3056. ip += 1 + ((ip - ii) >> 5);
  3057. next:
  3058. if __lzo_unlikely(ip >= ip_end)
  3059. break;
  3060. dv = UA_GET32(ip);
  3061. dindex = DINDEX(dv,ip);
  3062. GINDEX(m_off,m_pos,in+dict,dindex,in);
  3063. UPDATE_I(dict,0,dindex,ip,in);
  3064. if __lzo_unlikely(dv != UA_GET32(m_pos))
  3065. goto literal;
  3066. }
  3067. #endif
  3068. ii -= ti; ti = 0;
  3069. {
  3070. register lzo_uint t = pd(ip,ii);
  3071. if (t != 0)
  3072. {
  3073. if (t <= 3)
  3074. {
  3075. op[-2] |= LZO_BYTE(t);
  3076. #if defined(UA_COPY32)
  3077. UA_COPY32(op, ii);
  3078. op += t;
  3079. #else
  3080. { do *op++ = *ii++; while (--t > 0); }
  3081. #endif
  3082. }
  3083. #if defined(UA_COPY32) || defined(UA_COPY64)
  3084. else if (t <= 16)
  3085. {
  3086. *op++ = LZO_BYTE(t - 3);
  3087. #if defined(UA_COPY64)
  3088. UA_COPY64(op, ii);
  3089. UA_COPY64(op+8, ii+8);
  3090. #else
  3091. UA_COPY32(op, ii);
  3092. UA_COPY32(op+4, ii+4);
  3093. UA_COPY32(op+8, ii+8);
  3094. UA_COPY32(op+12, ii+12);
  3095. #endif
  3096. op += t;
  3097. }
  3098. #endif
  3099. else
  3100. {
  3101. if (t <= 18)
  3102. *op++ = LZO_BYTE(t - 3);
  3103. else
  3104. {
  3105. register lzo_uint tt = t - 18;
  3106. *op++ = 0;
  3107. while __lzo_unlikely(tt > 255)
  3108. {
  3109. tt -= 255;
  3110. #if 1 && (LZO_CC_MSC && (_MSC_VER >= 1400))
  3111. * (volatile unsigned char *) op++ = 0;
  3112. #else
  3113. *op++ = 0;
  3114. #endif
  3115. }
  3116. assert(tt > 0);
  3117. *op++ = LZO_BYTE(tt);
  3118. }
  3119. #if defined(UA_COPY32) || defined(UA_COPY64)
  3120. do {
  3121. #if defined(UA_COPY64)
  3122. UA_COPY64(op, ii);
  3123. UA_COPY64(op+8, ii+8);
  3124. #else
  3125. UA_COPY32(op, ii);
  3126. UA_COPY32(op+4, ii+4);
  3127. UA_COPY32(op+8, ii+8);
  3128. UA_COPY32(op+12, ii+12);
  3129. #endif
  3130. op += 16; ii += 16; t -= 16;
  3131. } while (t >= 16); if (t > 0)
  3132. #endif
  3133. { do *op++ = *ii++; while (--t > 0); }
  3134. }
  3135. }
  3136. }
  3137. m_len = 4;
  3138. {
  3139. #if defined(UA_GET64)
  3140. lzo_uint64 v;
  3141. v = UA_GET64(ip + m_len) ^ UA_GET64(m_pos + m_len);
  3142. if __lzo_unlikely(v == 0) {
  3143. do {
  3144. m_len += 8;
  3145. v = UA_GET64(ip + m_len) ^ UA_GET64(m_pos + m_len);
  3146. if __lzo_unlikely(ip + m_len >= ip_end)
  3147. goto m_len_done;
  3148. } while (v == 0);
  3149. }
  3150. #if (LZO_ABI_BIG_ENDIAN) && defined(lzo_bitops_clz64)
  3151. m_len += lzo_bitops_clz64(v) / CHAR_BIT;
  3152. #elif (LZO_ABI_BIG_ENDIAN)
  3153. if ((v >> (64 - CHAR_BIT)) == 0) do {
  3154. v <<= CHAR_BIT;
  3155. m_len += 1;
  3156. } while ((v >> (64 - CHAR_BIT)) == 0);
  3157. #elif (LZO_ABI_LITTLE_ENDIAN) && defined(lzo_bitops_ctz64)
  3158. m_len += lzo_bitops_ctz64(v) / CHAR_BIT;
  3159. #elif (LZO_ABI_LITTLE_ENDIAN)
  3160. if ((v & UCHAR_MAX) == 0) do {
  3161. v >>= CHAR_BIT;
  3162. m_len += 1;
  3163. } while ((v & UCHAR_MAX) == 0);
  3164. #else
  3165. if (ip[m_len] == m_pos[m_len]) do {
  3166. m_len += 1;
  3167. } while (ip[m_len] == m_pos[m_len]);
  3168. #endif
  3169. #elif defined(UA_GET32)
  3170. lzo_uint32 v;
  3171. v = UA_GET32(ip + m_len) ^ UA_GET32(m_pos + m_len);
  3172. if __lzo_unlikely(v == 0) {
  3173. do {
  3174. m_len += 4;
  3175. v = UA_GET32(ip + m_len) ^ UA_GET32(m_pos + m_len);
  3176. if __lzo_unlikely(ip + m_len >= ip_end)
  3177. goto m_len_done;
  3178. } while (v == 0);
  3179. }
  3180. #if (LZO_ABI_BIG_ENDIAN) && defined(lzo_bitops_clz32)
  3181. m_len += lzo_bitops_clz32(v) / CHAR_BIT;
  3182. #elif (LZO_ABI_BIG_ENDIAN)
  3183. if ((v >> (32 - CHAR_BIT)) == 0) do {
  3184. v <<= CHAR_BIT;
  3185. m_len += 1;
  3186. } while ((v >> (32 - CHAR_BIT)) == 0);
  3187. #elif (LZO_ABI_LITTLE_ENDIAN) && defined(lzo_bitops_ctz32)
  3188. m_len += lzo_bitops_ctz32(v) / CHAR_BIT;
  3189. #elif (LZO_ABI_LITTLE_ENDIAN)
  3190. if ((v & UCHAR_MAX) == 0) do {
  3191. v >>= CHAR_BIT;
  3192. m_len += 1;
  3193. } while ((v & UCHAR_MAX) == 0);
  3194. #else
  3195. if (ip[m_len] == m_pos[m_len]) do {
  3196. m_len += 1;
  3197. } while (ip[m_len] == m_pos[m_len]);
  3198. #endif
  3199. #else
  3200. if __lzo_unlikely(ip[m_len] == m_pos[m_len]) {
  3201. do {
  3202. m_len += 1;
  3203. if __lzo_unlikely(ip + m_len >= ip_end)
  3204. goto m_len_done;
  3205. } while (ip[m_len] == m_pos[m_len]);
  3206. }
  3207. #endif
  3208. }
  3209. m_len_done:
  3210. m_off = pd(ip,m_pos);
  3211. ip += m_len;
  3212. ii = ip;
  3213. if (m_len <= M2_MAX_LEN && m_off <= M2_MAX_OFFSET)
  3214. {
  3215. m_off -= 1;
  3216. #if defined(LZO1X)
  3217. *op++ = LZO_BYTE(((m_len - 1) << 5) | ((m_off & 7) << 2));
  3218. *op++ = LZO_BYTE(m_off >> 3);
  3219. #elif defined(LZO1Y)
  3220. *op++ = LZO_BYTE(((m_len + 1) << 4) | ((m_off & 3) << 2));
  3221. *op++ = LZO_BYTE(m_off >> 2);
  3222. #endif
  3223. }
  3224. else if (m_off <= M3_MAX_OFFSET)
  3225. {
  3226. m_off -= 1;
  3227. if (m_len <= M3_MAX_LEN)
  3228. *op++ = LZO_BYTE(M3_MARKER | (m_len - 2));
  3229. else
  3230. {
  3231. m_len -= M3_MAX_LEN;
  3232. *op++ = M3_MARKER | 0;
  3233. while __lzo_unlikely(m_len > 255)
  3234. {
  3235. m_len -= 255;
  3236. #if 1 && (LZO_CC_MSC && (_MSC_VER >= 1400))
  3237. * (volatile unsigned char *) op++ = 0;
  3238. #else
  3239. *op++ = 0;
  3240. #endif
  3241. }
  3242. *op++ = LZO_BYTE(m_len);
  3243. }
  3244. *op++ = LZO_BYTE(m_off << 2);
  3245. *op++ = LZO_BYTE(m_off >> 6);
  3246. }
  3247. else
  3248. {
  3249. m_off -= 0x4000;
  3250. if (m_len <= M4_MAX_LEN)
  3251. *op++ = LZO_BYTE(M4_MARKER | ((m_off >> 11) & 8) | (m_len - 2));
  3252. else
  3253. {
  3254. m_len -= M4_MAX_LEN;
  3255. *op++ = LZO_BYTE(M4_MARKER | ((m_off >> 11) & 8));
  3256. while __lzo_unlikely(m_len > 255)
  3257. {
  3258. m_len -= 255;
  3259. #if 1 && (LZO_CC_MSC && (_MSC_VER >= 1400))
  3260. * (volatile unsigned char *) op++ = 0;
  3261. #else
  3262. *op++ = 0;
  3263. #endif
  3264. }
  3265. *op++ = LZO_BYTE(m_len);
  3266. }
  3267. *op++ = LZO_BYTE(m_off << 2);
  3268. *op++ = LZO_BYTE(m_off >> 6);
  3269. }
  3270. goto next;
  3271. }
  3272. *out_len = pd(op, out);
  3273. return pd(in_end,ii-ti);
  3274. }
  3275. LZO_PUBLIC(int)
  3276. DO_COMPRESS ( const lzo_bytep in , lzo_uint in_len,
  3277. lzo_bytep out, lzo_uintp out_len,
  3278. lzo_voidp wrkmem )
  3279. {
  3280. const lzo_bytep ip = in;
  3281. lzo_bytep op = out;
  3282. lzo_uint l = in_len;
  3283. lzo_uint t = 0;
  3284. while (l > 20)
  3285. {
  3286. lzo_uint ll = l;
  3287. lzo_uintptr_t ll_end;
  3288. #if 0 || (LZO_DETERMINISTIC)
  3289. ll = LZO_MIN(ll, 49152);
  3290. #endif
  3291. ll_end = (lzo_uintptr_t)ip + ll;
  3292. if ((ll_end + ((t + ll) >> 5)) <= ll_end || (const lzo_bytep)(ll_end + ((t + ll) >> 5)) <= ip + ll)
  3293. break;
  3294. #if (LZO_DETERMINISTIC)
  3295. lzo_memset(wrkmem, 0, ((lzo_uint)1 << D_BITS) * sizeof(lzo_dict_t));
  3296. #endif
  3297. t = do_compress(ip,ll,op,out_len,t,wrkmem);
  3298. ip += ll;
  3299. op += *out_len;
  3300. l -= ll;
  3301. }
  3302. t += l;
  3303. if (t > 0)
  3304. {
  3305. const lzo_bytep ii = in + in_len - t;
  3306. if (op == out && t <= 238)
  3307. *op++ = LZO_BYTE(17 + t);
  3308. else if (t <= 3)
  3309. op[-2] |= LZO_BYTE(t);
  3310. else if (t <= 18)
  3311. *op++ = LZO_BYTE(t - 3);
  3312. else
  3313. {
  3314. lzo_uint tt = t - 18;
  3315. *op++ = 0;
  3316. while (tt > 255)
  3317. {
  3318. tt -= 255;
  3319. #if 1 && (LZO_CC_MSC && (_MSC_VER >= 1400))
  3320. * (volatile unsigned char *) op++ = 0;
  3321. #else
  3322. *op++ = 0;
  3323. #endif
  3324. }
  3325. assert(tt > 0);
  3326. *op++ = LZO_BYTE(tt);
  3327. }
  3328. do *op++ = *ii++; while (--t > 0);
  3329. }
  3330. *op++ = M4_MARKER | 1;
  3331. *op++ = 0;
  3332. *op++ = 0;
  3333. *out_len = pd(op, out);
  3334. return LZO_E_OK;
  3335. }
  3336. #endif
  3337. #undef do_compress
  3338. #undef DO_COMPRESS
  3339. #undef LZO_HASH
  3340. #undef LZO_TEST_OVERRUN
  3341. #undef DO_DECOMPRESS
  3342. #define DO_DECOMPRESS lzo1x_decompress
  3343. #if !defined(MINILZO_CFG_SKIP_LZO1X_DECOMPRESS)
  3344. #if defined(LZO_TEST_OVERRUN)
  3345. # if !defined(LZO_TEST_OVERRUN_INPUT)
  3346. # define LZO_TEST_OVERRUN_INPUT 2
  3347. # endif
  3348. # if !defined(LZO_TEST_OVERRUN_OUTPUT)
  3349. # define LZO_TEST_OVERRUN_OUTPUT 2
  3350. # endif
  3351. # if !defined(LZO_TEST_OVERRUN_LOOKBEHIND)
  3352. # define LZO_TEST_OVERRUN_LOOKBEHIND 1
  3353. # endif
  3354. #endif
  3355. #undef TEST_IP
  3356. #undef TEST_OP
  3357. #undef TEST_LB
  3358. #undef TEST_LBO
  3359. #undef NEED_IP
  3360. #undef NEED_OP
  3361. #undef HAVE_TEST_IP
  3362. #undef HAVE_TEST_OP
  3363. #undef HAVE_NEED_IP
  3364. #undef HAVE_NEED_OP
  3365. #undef HAVE_ANY_IP
  3366. #undef HAVE_ANY_OP
  3367. #if defined(LZO_TEST_OVERRUN_INPUT)
  3368. # if (LZO_TEST_OVERRUN_INPUT >= 1)
  3369. # define TEST_IP (ip < ip_end)
  3370. # endif
  3371. # if (LZO_TEST_OVERRUN_INPUT >= 2)
  3372. # define NEED_IP(x) \
  3373. if ((lzo_uint)(ip_end - ip) < (lzo_uint)(x)) goto input_overrun
  3374. # endif
  3375. #endif
  3376. #if defined(LZO_TEST_OVERRUN_OUTPUT)
  3377. # if (LZO_TEST_OVERRUN_OUTPUT >= 1)
  3378. # define TEST_OP (op <= op_end)
  3379. # endif
  3380. # if (LZO_TEST_OVERRUN_OUTPUT >= 2)
  3381. # undef TEST_OP
  3382. # define NEED_OP(x) \
  3383. if ((lzo_uint)(op_end - op) < (lzo_uint)(x)) goto output_overrun
  3384. # endif
  3385. #endif
  3386. #if defined(LZO_TEST_OVERRUN_LOOKBEHIND)
  3387. # define TEST_LB(m_pos) if (m_pos < out || m_pos >= op) goto lookbehind_overrun
  3388. # define TEST_LBO(m_pos,o) if (m_pos < out || m_pos >= op - (o)) goto lookbehind_overrun
  3389. #else
  3390. # define TEST_LB(m_pos) ((void) 0)
  3391. # define TEST_LBO(m_pos,o) ((void) 0)
  3392. #endif
  3393. #if !defined(LZO_EOF_CODE) && !defined(TEST_IP)
  3394. # define TEST_IP (ip < ip_end)
  3395. #endif
  3396. #if defined(TEST_IP)
  3397. # define HAVE_TEST_IP 1
  3398. #else
  3399. # define TEST_IP 1
  3400. #endif
  3401. #if defined(TEST_OP)
  3402. # define HAVE_TEST_OP 1
  3403. #else
  3404. # define TEST_OP 1
  3405. #endif
  3406. #if defined(NEED_IP)
  3407. # define HAVE_NEED_IP 1
  3408. #else
  3409. # define NEED_IP(x) ((void) 0)
  3410. #endif
  3411. #if defined(NEED_OP)
  3412. # define HAVE_NEED_OP 1
  3413. #else
  3414. # define NEED_OP(x) ((void) 0)
  3415. #endif
  3416. #if defined(HAVE_TEST_IP) || defined(HAVE_NEED_IP)
  3417. # define HAVE_ANY_IP 1
  3418. #endif
  3419. #if defined(HAVE_TEST_OP) || defined(HAVE_NEED_OP)
  3420. # define HAVE_ANY_OP 1
  3421. #endif
  3422. #if defined(DO_DECOMPRESS)
  3423. LZO_PUBLIC(int)
  3424. DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len,
  3425. lzo_bytep out, lzo_uintp out_len,
  3426. lzo_voidp wrkmem )
  3427. #endif
  3428. {
  3429. register lzo_bytep op;
  3430. register const lzo_bytep ip;
  3431. register lzo_uint t;
  3432. #if defined(COPY_DICT)
  3433. lzo_uint m_off;
  3434. const lzo_bytep dict_end;
  3435. #else
  3436. register const lzo_bytep m_pos;
  3437. #endif
  3438. const lzo_bytep const ip_end = in + in_len;
  3439. #if defined(HAVE_ANY_OP)
  3440. lzo_bytep const op_end = out + *out_len;
  3441. #endif
  3442. #if defined(LZO1Z)
  3443. lzo_uint last_m_off = 0;
  3444. #endif
  3445. LZO_UNUSED(wrkmem);
  3446. #if defined(COPY_DICT)
  3447. if (dict)
  3448. {
  3449. if (dict_len > M4_MAX_OFFSET)
  3450. {
  3451. dict += dict_len - M4_MAX_OFFSET;
  3452. dict_len = M4_MAX_OFFSET;
  3453. }
  3454. dict_end = dict + dict_len;
  3455. }
  3456. else
  3457. {
  3458. dict_len = 0;
  3459. dict_end = NULL;
  3460. }
  3461. #endif
  3462. *out_len = 0;
  3463. op = out;
  3464. ip = in;
  3465. if (*ip > 17)
  3466. {
  3467. t = *ip++ - 17;
  3468. if (t < 4)
  3469. goto match_next;
  3470. assert(t > 0); NEED_OP(t); NEED_IP(t+1);
  3471. do *op++ = *ip++; while (--t > 0);
  3472. goto first_literal_run;
  3473. }
  3474. while (TEST_IP && TEST_OP)
  3475. {
  3476. t = *ip++;
  3477. if (t >= 16)
  3478. goto match;
  3479. if (t == 0)
  3480. {
  3481. NEED_IP(1);
  3482. while (*ip == 0)
  3483. {
  3484. t += 255;
  3485. ip++;
  3486. NEED_IP(1);
  3487. }
  3488. t += 15 + *ip++;
  3489. }
  3490. assert(t > 0); NEED_OP(t+3); NEED_IP(t+4);
  3491. #if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4)
  3492. t += 3;
  3493. if (t >= 8) do
  3494. {
  3495. UA_COPY64(op,ip);
  3496. op += 8; ip += 8; t -= 8;
  3497. } while (t >= 8);
  3498. if (t >= 4)
  3499. {
  3500. UA_COPY32(op,ip);
  3501. op += 4; ip += 4; t -= 4;
  3502. }
  3503. if (t > 0)
  3504. {
  3505. *op++ = *ip++;
  3506. if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } }
  3507. }
  3508. #elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4)
  3509. #if !defined(LZO_UNALIGNED_OK_4)
  3510. if (PTR_ALIGNED2_4(op,ip))
  3511. {
  3512. #endif
  3513. UA_COPY32(op,ip);
  3514. op += 4; ip += 4;
  3515. if (--t > 0)
  3516. {
  3517. if (t >= 4)
  3518. {
  3519. do {
  3520. UA_COPY32(op,ip);
  3521. op += 4; ip += 4; t -= 4;
  3522. } while (t >= 4);
  3523. if (t > 0) do *op++ = *ip++; while (--t > 0);
  3524. }
  3525. else
  3526. do *op++ = *ip++; while (--t > 0);
  3527. }
  3528. #if !defined(LZO_UNALIGNED_OK_4)
  3529. }
  3530. else
  3531. #endif
  3532. #endif
  3533. #if !defined(LZO_UNALIGNED_OK_4) && !defined(LZO_UNALIGNED_OK_8)
  3534. {
  3535. *op++ = *ip++; *op++ = *ip++; *op++ = *ip++;
  3536. do *op++ = *ip++; while (--t > 0);
  3537. }
  3538. #endif
  3539. first_literal_run:
  3540. t = *ip++;
  3541. if (t >= 16)
  3542. goto match;
  3543. #if defined(COPY_DICT)
  3544. #if defined(LZO1Z)
  3545. m_off = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2);
  3546. last_m_off = m_off;
  3547. #else
  3548. m_off = (1 + M2_MAX_OFFSET) + (t >> 2) + (*ip++ << 2);
  3549. #endif
  3550. NEED_OP(3);
  3551. t = 3; COPY_DICT(t,m_off)
  3552. #else
  3553. #if defined(LZO1Z)
  3554. t = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2);
  3555. m_pos = op - t;
  3556. last_m_off = t;
  3557. #else
  3558. m_pos = op - (1 + M2_MAX_OFFSET);
  3559. m_pos -= t >> 2;
  3560. m_pos -= *ip++ << 2;
  3561. #endif
  3562. TEST_LB(m_pos); NEED_OP(3);
  3563. *op++ = *m_pos++; *op++ = *m_pos++; *op++ = *m_pos;
  3564. #endif
  3565. goto match_done;
  3566. do {
  3567. match:
  3568. if (t >= 64)
  3569. {
  3570. #if defined(COPY_DICT)
  3571. #if defined(LZO1X)
  3572. m_off = 1 + ((t >> 2) & 7) + (*ip++ << 3);
  3573. t = (t >> 5) - 1;
  3574. #elif defined(LZO1Y)
  3575. m_off = 1 + ((t >> 2) & 3) + (*ip++ << 2);
  3576. t = (t >> 4) - 3;
  3577. #elif defined(LZO1Z)
  3578. m_off = t & 0x1f;
  3579. if (m_off >= 0x1c)
  3580. m_off = last_m_off;
  3581. else
  3582. {
  3583. m_off = 1 + (m_off << 6) + (*ip++ >> 2);
  3584. last_m_off = m_off;
  3585. }
  3586. t = (t >> 5) - 1;
  3587. #endif
  3588. #else
  3589. #if defined(LZO1X)
  3590. m_pos = op - 1;
  3591. m_pos -= (t >> 2) & 7;
  3592. m_pos -= *ip++ << 3;
  3593. t = (t >> 5) - 1;
  3594. #elif defined(LZO1Y)
  3595. m_pos = op - 1;
  3596. m_pos -= (t >> 2) & 3;
  3597. m_pos -= *ip++ << 2;
  3598. t = (t >> 4) - 3;
  3599. #elif defined(LZO1Z)
  3600. {
  3601. lzo_uint off = t & 0x1f;
  3602. m_pos = op;
  3603. if (off >= 0x1c)
  3604. {
  3605. assert(last_m_off > 0);
  3606. m_pos -= last_m_off;
  3607. }
  3608. else
  3609. {
  3610. off = 1 + (off << 6) + (*ip++ >> 2);
  3611. m_pos -= off;
  3612. last_m_off = off;
  3613. }
  3614. }
  3615. t = (t >> 5) - 1;
  3616. #endif
  3617. TEST_LB(m_pos); assert(t > 0); NEED_OP(t+3-1);
  3618. goto copy_match;
  3619. #endif
  3620. }
  3621. else if (t >= 32)
  3622. {
  3623. t &= 31;
  3624. if (t == 0)
  3625. {
  3626. NEED_IP(1);
  3627. while (*ip == 0)
  3628. {
  3629. t += 255;
  3630. ip++;
  3631. NEED_IP(1);
  3632. }
  3633. t += 31 + *ip++;
  3634. }
  3635. #if defined(COPY_DICT)
  3636. #if defined(LZO1Z)
  3637. m_off = 1 + (ip[0] << 6) + (ip[1] >> 2);
  3638. last_m_off = m_off;
  3639. #else
  3640. m_off = 1 + (ip[0] >> 2) + (ip[1] << 6);
  3641. #endif
  3642. #else
  3643. #if defined(LZO1Z)
  3644. {
  3645. lzo_uint off = 1 + (ip[0] << 6) + (ip[1] >> 2);
  3646. m_pos = op - off;
  3647. last_m_off = off;
  3648. }
  3649. #elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN)
  3650. m_pos = op - 1;
  3651. m_pos -= UA_GET16(ip) >> 2;
  3652. #else
  3653. m_pos = op - 1;
  3654. m_pos -= (ip[0] >> 2) + (ip[1] << 6);
  3655. #endif
  3656. #endif
  3657. ip += 2;
  3658. }
  3659. else if (t >= 16)
  3660. {
  3661. #if defined(COPY_DICT)
  3662. m_off = (t & 8) << 11;
  3663. #else
  3664. m_pos = op;
  3665. m_pos -= (t & 8) << 11;
  3666. #endif
  3667. t &= 7;
  3668. if (t == 0)
  3669. {
  3670. NEED_IP(1);
  3671. while (*ip == 0)
  3672. {
  3673. t += 255;
  3674. ip++;
  3675. NEED_IP(1);
  3676. }
  3677. t += 7 + *ip++;
  3678. }
  3679. #if defined(COPY_DICT)
  3680. #if defined(LZO1Z)
  3681. m_off += (ip[0] << 6) + (ip[1] >> 2);
  3682. #else
  3683. m_off += (ip[0] >> 2) + (ip[1] << 6);
  3684. #endif
  3685. ip += 2;
  3686. if (m_off == 0)
  3687. goto eof_found;
  3688. m_off += 0x4000;
  3689. #if defined(LZO1Z)
  3690. last_m_off = m_off;
  3691. #endif
  3692. #else
  3693. #if defined(LZO1Z)
  3694. m_pos -= (ip[0] << 6) + (ip[1] >> 2);
  3695. #elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN)
  3696. m_pos -= UA_GET16(ip) >> 2;
  3697. #else
  3698. m_pos -= (ip[0] >> 2) + (ip[1] << 6);
  3699. #endif
  3700. ip += 2;
  3701. if (m_pos == op)
  3702. goto eof_found;
  3703. m_pos -= 0x4000;
  3704. #if defined(LZO1Z)
  3705. last_m_off = pd((const lzo_bytep)op, m_pos);
  3706. #endif
  3707. #endif
  3708. }
  3709. else
  3710. {
  3711. #if defined(COPY_DICT)
  3712. #if defined(LZO1Z)
  3713. m_off = 1 + (t << 6) + (*ip++ >> 2);
  3714. last_m_off = m_off;
  3715. #else
  3716. m_off = 1 + (t >> 2) + (*ip++ << 2);
  3717. #endif
  3718. NEED_OP(2);
  3719. t = 2; COPY_DICT(t,m_off)
  3720. #else
  3721. #if defined(LZO1Z)
  3722. t = 1 + (t << 6) + (*ip++ >> 2);
  3723. m_pos = op - t;
  3724. last_m_off = t;
  3725. #else
  3726. m_pos = op - 1;
  3727. m_pos -= t >> 2;
  3728. m_pos -= *ip++ << 2;
  3729. #endif
  3730. TEST_LB(m_pos); NEED_OP(2);
  3731. *op++ = *m_pos++; *op++ = *m_pos;
  3732. #endif
  3733. goto match_done;
  3734. }
  3735. #if defined(COPY_DICT)
  3736. NEED_OP(t+3-1);
  3737. t += 3-1; COPY_DICT(t,m_off)
  3738. #else
  3739. TEST_LB(m_pos); assert(t > 0); NEED_OP(t+3-1);
  3740. #if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4)
  3741. if (op - m_pos >= 8)
  3742. {
  3743. t += (3 - 1);
  3744. if (t >= 8) do
  3745. {
  3746. UA_COPY64(op,m_pos);
  3747. op += 8; m_pos += 8; t -= 8;
  3748. } while (t >= 8);
  3749. if (t >= 4)
  3750. {
  3751. UA_COPY32(op,m_pos);
  3752. op += 4; m_pos += 4; t -= 4;
  3753. }
  3754. if (t > 0)
  3755. {
  3756. *op++ = m_pos[0];
  3757. if (t > 1) { *op++ = m_pos[1]; if (t > 2) { *op++ = m_pos[2]; } }
  3758. }
  3759. }
  3760. else
  3761. #elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4)
  3762. #if !defined(LZO_UNALIGNED_OK_4)
  3763. if (t >= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op,m_pos))
  3764. {
  3765. assert((op - m_pos) >= 4);
  3766. #else
  3767. if (t >= 2 * 4 - (3 - 1) && (op - m_pos) >= 4)
  3768. {
  3769. #endif
  3770. UA_COPY32(op,m_pos);
  3771. op += 4; m_pos += 4; t -= 4 - (3 - 1);
  3772. do {
  3773. UA_COPY32(op,m_pos);
  3774. op += 4; m_pos += 4; t -= 4;
  3775. } while (t >= 4);
  3776. if (t > 0) do *op++ = *m_pos++; while (--t > 0);
  3777. }
  3778. else
  3779. #endif
  3780. {
  3781. copy_match:
  3782. *op++ = *m_pos++; *op++ = *m_pos++;
  3783. do *op++ = *m_pos++; while (--t > 0);
  3784. }
  3785. #endif
  3786. match_done:
  3787. #if defined(LZO1Z)
  3788. t = ip[-1] & 3;
  3789. #else
  3790. t = ip[-2] & 3;
  3791. #endif
  3792. if (t == 0)
  3793. break;
  3794. match_next:
  3795. assert(t > 0); assert(t < 4); NEED_OP(t); NEED_IP(t+1);
  3796. #if 0
  3797. do *op++ = *ip++; while (--t > 0);
  3798. #else
  3799. *op++ = *ip++;
  3800. if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } }
  3801. #endif
  3802. t = *ip++;
  3803. } while (TEST_IP && TEST_OP);
  3804. }
  3805. #if defined(HAVE_TEST_IP) || defined(HAVE_TEST_OP)
  3806. *out_len = pd(op, out);
  3807. return LZO_E_EOF_NOT_FOUND;
  3808. #endif
  3809. eof_found:
  3810. assert(t == 1);
  3811. *out_len = pd(op, out);
  3812. return (ip == ip_end ? LZO_E_OK :
  3813. (ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN));
  3814. #if defined(HAVE_NEED_IP)
  3815. input_overrun:
  3816. *out_len = pd(op, out);
  3817. return LZO_E_INPUT_OVERRUN;
  3818. #endif
  3819. #if defined(HAVE_NEED_OP)
  3820. output_overrun:
  3821. *out_len = pd(op, out);
  3822. return LZO_E_OUTPUT_OVERRUN;
  3823. #endif
  3824. #if defined(LZO_TEST_OVERRUN_LOOKBEHIND)
  3825. lookbehind_overrun:
  3826. *out_len = pd(op, out);
  3827. return LZO_E_LOOKBEHIND_OVERRUN;
  3828. #endif
  3829. }
  3830. #endif
  3831. #define LZO_TEST_OVERRUN 1
  3832. #undef DO_DECOMPRESS
  3833. #define DO_DECOMPRESS lzo1x_decompress_safe
  3834. #if !defined(MINILZO_CFG_SKIP_LZO1X_DECOMPRESS_SAFE)
  3835. #if defined(LZO_TEST_OVERRUN)
  3836. # if !defined(LZO_TEST_OVERRUN_INPUT)
  3837. # define LZO_TEST_OVERRUN_INPUT 2
  3838. # endif
  3839. # if !defined(LZO_TEST_OVERRUN_OUTPUT)
  3840. # define LZO_TEST_OVERRUN_OUTPUT 2
  3841. # endif
  3842. # if !defined(LZO_TEST_OVERRUN_LOOKBEHIND)
  3843. # define LZO_TEST_OVERRUN_LOOKBEHIND 1
  3844. # endif
  3845. #endif
  3846. #undef TEST_IP
  3847. #undef TEST_OP
  3848. #undef TEST_LB
  3849. #undef TEST_LBO
  3850. #undef NEED_IP
  3851. #undef NEED_OP
  3852. #undef HAVE_TEST_IP
  3853. #undef HAVE_TEST_OP
  3854. #undef HAVE_NEED_IP
  3855. #undef HAVE_NEED_OP
  3856. #undef HAVE_ANY_IP
  3857. #undef HAVE_ANY_OP
  3858. #if defined(LZO_TEST_OVERRUN_INPUT)
  3859. # if (LZO_TEST_OVERRUN_INPUT >= 1)
  3860. # define TEST_IP (ip < ip_end)
  3861. # endif
  3862. # if (LZO_TEST_OVERRUN_INPUT >= 2)
  3863. # define NEED_IP(x) \
  3864. if ((lzo_uint)(ip_end - ip) < (lzo_uint)(x)) goto input_overrun
  3865. # endif
  3866. #endif
  3867. #if defined(LZO_TEST_OVERRUN_OUTPUT)
  3868. # if (LZO_TEST_OVERRUN_OUTPUT >= 1)
  3869. # define TEST_OP (op <= op_end)
  3870. # endif
  3871. # if (LZO_TEST_OVERRUN_OUTPUT >= 2)
  3872. # undef TEST_OP
  3873. # define NEED_OP(x) \
  3874. if ((lzo_uint)(op_end - op) < (lzo_uint)(x)) goto output_overrun
  3875. # endif
  3876. #endif
  3877. #if defined(LZO_TEST_OVERRUN_LOOKBEHIND)
  3878. # define TEST_LB(m_pos) if (m_pos < out || m_pos >= op) goto lookbehind_overrun
  3879. # define TEST_LBO(m_pos,o) if (m_pos < out || m_pos >= op - (o)) goto lookbehind_overrun
  3880. #else
  3881. # define TEST_LB(m_pos) ((void) 0)
  3882. # define TEST_LBO(m_pos,o) ((void) 0)
  3883. #endif
  3884. #if !defined(LZO_EOF_CODE) && !defined(TEST_IP)
  3885. # define TEST_IP (ip < ip_end)
  3886. #endif
  3887. #if defined(TEST_IP)
  3888. # define HAVE_TEST_IP 1
  3889. #else
  3890. # define TEST_IP 1
  3891. #endif
  3892. #if defined(TEST_OP)
  3893. # define HAVE_TEST_OP 1
  3894. #else
  3895. # define TEST_OP 1
  3896. #endif
  3897. #if defined(NEED_IP)
  3898. # define HAVE_NEED_IP 1
  3899. #else
  3900. # define NEED_IP(x) ((void) 0)
  3901. #endif
  3902. #if defined(NEED_OP)
  3903. # define HAVE_NEED_OP 1
  3904. #else
  3905. # define NEED_OP(x) ((void) 0)
  3906. #endif
  3907. #if defined(HAVE_TEST_IP) || defined(HAVE_NEED_IP)
  3908. # define HAVE_ANY_IP 1
  3909. #endif
  3910. #if defined(HAVE_TEST_OP) || defined(HAVE_NEED_OP)
  3911. # define HAVE_ANY_OP 1
  3912. #endif
  3913. #if defined(DO_DECOMPRESS)
  3914. LZO_PUBLIC(int)
  3915. DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len,
  3916. lzo_bytep out, lzo_uintp out_len,
  3917. lzo_voidp wrkmem )
  3918. #endif
  3919. {
  3920. register lzo_bytep op;
  3921. register const lzo_bytep ip;
  3922. register lzo_uint t;
  3923. #if defined(COPY_DICT)
  3924. lzo_uint m_off;
  3925. const lzo_bytep dict_end;
  3926. #else
  3927. register const lzo_bytep m_pos;
  3928. #endif
  3929. const lzo_bytep const ip_end = in + in_len;
  3930. #if defined(HAVE_ANY_OP)
  3931. lzo_bytep const op_end = out + *out_len;
  3932. #endif
  3933. #if defined(LZO1Z)
  3934. lzo_uint last_m_off = 0;
  3935. #endif
  3936. LZO_UNUSED(wrkmem);
  3937. #if defined(COPY_DICT)
  3938. if (dict)
  3939. {
  3940. if (dict_len > M4_MAX_OFFSET)
  3941. {
  3942. dict += dict_len - M4_MAX_OFFSET;
  3943. dict_len = M4_MAX_OFFSET;
  3944. }
  3945. dict_end = dict + dict_len;
  3946. }
  3947. else
  3948. {
  3949. dict_len = 0;
  3950. dict_end = NULL;
  3951. }
  3952. #endif
  3953. *out_len = 0;
  3954. op = out;
  3955. ip = in;
  3956. if (*ip > 17)
  3957. {
  3958. t = *ip++ - 17;
  3959. if (t < 4)
  3960. goto match_next;
  3961. assert(t > 0); NEED_OP(t); NEED_IP(t+1);
  3962. do *op++ = *ip++; while (--t > 0);
  3963. goto first_literal_run;
  3964. }
  3965. while (TEST_IP && TEST_OP)
  3966. {
  3967. t = *ip++;
  3968. if (t >= 16)
  3969. goto match;
  3970. if (t == 0)
  3971. {
  3972. NEED_IP(1);
  3973. while (*ip == 0)
  3974. {
  3975. t += 255;
  3976. ip++;
  3977. NEED_IP(1);
  3978. }
  3979. t += 15 + *ip++;
  3980. }
  3981. assert(t > 0); NEED_OP(t+3); NEED_IP(t+4);
  3982. #if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4)
  3983. t += 3;
  3984. if (t >= 8) do
  3985. {
  3986. UA_COPY64(op,ip);
  3987. op += 8; ip += 8; t -= 8;
  3988. } while (t >= 8);
  3989. if (t >= 4)
  3990. {
  3991. UA_COPY32(op,ip);
  3992. op += 4; ip += 4; t -= 4;
  3993. }
  3994. if (t > 0)
  3995. {
  3996. *op++ = *ip++;
  3997. if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } }
  3998. }
  3999. #elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4)
  4000. #if !defined(LZO_UNALIGNED_OK_4)
  4001. if (PTR_ALIGNED2_4(op,ip))
  4002. {
  4003. #endif
  4004. UA_COPY32(op,ip);
  4005. op += 4; ip += 4;
  4006. if (--t > 0)
  4007. {
  4008. if (t >= 4)
  4009. {
  4010. do {
  4011. UA_COPY32(op,ip);
  4012. op += 4; ip += 4; t -= 4;
  4013. } while (t >= 4);
  4014. if (t > 0) do *op++ = *ip++; while (--t > 0);
  4015. }
  4016. else
  4017. do *op++ = *ip++; while (--t > 0);
  4018. }
  4019. #if !defined(LZO_UNALIGNED_OK_4)
  4020. }
  4021. else
  4022. #endif
  4023. #endif
  4024. #if !defined(LZO_UNALIGNED_OK_4) && !defined(LZO_UNALIGNED_OK_8)
  4025. {
  4026. *op++ = *ip++; *op++ = *ip++; *op++ = *ip++;
  4027. do *op++ = *ip++; while (--t > 0);
  4028. }
  4029. #endif
  4030. first_literal_run:
  4031. t = *ip++;
  4032. if (t >= 16)
  4033. goto match;
  4034. #if defined(COPY_DICT)
  4035. #if defined(LZO1Z)
  4036. m_off = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2);
  4037. last_m_off = m_off;
  4038. #else
  4039. m_off = (1 + M2_MAX_OFFSET) + (t >> 2) + (*ip++ << 2);
  4040. #endif
  4041. NEED_OP(3);
  4042. t = 3; COPY_DICT(t,m_off)
  4043. #else
  4044. #if defined(LZO1Z)
  4045. t = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2);
  4046. m_pos = op - t;
  4047. last_m_off = t;
  4048. #else
  4049. m_pos = op - (1 + M2_MAX_OFFSET);
  4050. m_pos -= t >> 2;
  4051. m_pos -= *ip++ << 2;
  4052. #endif
  4053. TEST_LB(m_pos); NEED_OP(3);
  4054. *op++ = *m_pos++; *op++ = *m_pos++; *op++ = *m_pos;
  4055. #endif
  4056. goto match_done;
  4057. do {
  4058. match:
  4059. if (t >= 64)
  4060. {
  4061. #if defined(COPY_DICT)
  4062. #if defined(LZO1X)
  4063. m_off = 1 + ((t >> 2) & 7) + (*ip++ << 3);
  4064. t = (t >> 5) - 1;
  4065. #elif defined(LZO1Y)
  4066. m_off = 1 + ((t >> 2) & 3) + (*ip++ << 2);
  4067. t = (t >> 4) - 3;
  4068. #elif defined(LZO1Z)
  4069. m_off = t & 0x1f;
  4070. if (m_off >= 0x1c)
  4071. m_off = last_m_off;
  4072. else
  4073. {
  4074. m_off = 1 + (m_off << 6) + (*ip++ >> 2);
  4075. last_m_off = m_off;
  4076. }
  4077. t = (t >> 5) - 1;
  4078. #endif
  4079. #else
  4080. #if defined(LZO1X)
  4081. m_pos = op - 1;
  4082. m_pos -= (t >> 2) & 7;
  4083. m_pos -= *ip++ << 3;
  4084. t = (t >> 5) - 1;
  4085. #elif defined(LZO1Y)
  4086. m_pos = op - 1;
  4087. m_pos -= (t >> 2) & 3;
  4088. m_pos -= *ip++ << 2;
  4089. t = (t >> 4) - 3;
  4090. #elif defined(LZO1Z)
  4091. {
  4092. lzo_uint off = t & 0x1f;
  4093. m_pos = op;
  4094. if (off >= 0x1c)
  4095. {
  4096. assert(last_m_off > 0);
  4097. m_pos -= last_m_off;
  4098. }
  4099. else
  4100. {
  4101. off = 1 + (off << 6) + (*ip++ >> 2);
  4102. m_pos -= off;
  4103. last_m_off = off;
  4104. }
  4105. }
  4106. t = (t >> 5) - 1;
  4107. #endif
  4108. TEST_LB(m_pos); assert(t > 0); NEED_OP(t+3-1);
  4109. goto copy_match;
  4110. #endif
  4111. }
  4112. else if (t >= 32)
  4113. {
  4114. t &= 31;
  4115. if (t == 0)
  4116. {
  4117. NEED_IP(1);
  4118. while (*ip == 0)
  4119. {
  4120. t += 255;
  4121. ip++;
  4122. NEED_IP(1);
  4123. }
  4124. t += 31 + *ip++;
  4125. }
  4126. #if defined(COPY_DICT)
  4127. #if defined(LZO1Z)
  4128. m_off = 1 + (ip[0] << 6) + (ip[1] >> 2);
  4129. last_m_off = m_off;
  4130. #else
  4131. m_off = 1 + (ip[0] >> 2) + (ip[1] << 6);
  4132. #endif
  4133. #else
  4134. #if defined(LZO1Z)
  4135. {
  4136. lzo_uint off = 1 + (ip[0] << 6) + (ip[1] >> 2);
  4137. m_pos = op - off;
  4138. last_m_off = off;
  4139. }
  4140. #elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN)
  4141. m_pos = op - 1;
  4142. m_pos -= UA_GET16(ip) >> 2;
  4143. #else
  4144. m_pos = op - 1;
  4145. m_pos -= (ip[0] >> 2) + (ip[1] << 6);
  4146. #endif
  4147. #endif
  4148. ip += 2;
  4149. }
  4150. else if (t >= 16)
  4151. {
  4152. #if defined(COPY_DICT)
  4153. m_off = (t & 8) << 11;
  4154. #else
  4155. m_pos = op;
  4156. m_pos -= (t & 8) << 11;
  4157. #endif
  4158. t &= 7;
  4159. if (t == 0)
  4160. {
  4161. NEED_IP(1);
  4162. while (*ip == 0)
  4163. {
  4164. t += 255;
  4165. ip++;
  4166. NEED_IP(1);
  4167. }
  4168. t += 7 + *ip++;
  4169. }
  4170. #if defined(COPY_DICT)
  4171. #if defined(LZO1Z)
  4172. m_off += (ip[0] << 6) + (ip[1] >> 2);
  4173. #else
  4174. m_off += (ip[0] >> 2) + (ip[1] << 6);
  4175. #endif
  4176. ip += 2;
  4177. if (m_off == 0)
  4178. goto eof_found;
  4179. m_off += 0x4000;
  4180. #if defined(LZO1Z)
  4181. last_m_off = m_off;
  4182. #endif
  4183. #else
  4184. #if defined(LZO1Z)
  4185. m_pos -= (ip[0] << 6) + (ip[1] >> 2);
  4186. #elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN)
  4187. m_pos -= UA_GET16(ip) >> 2;
  4188. #else
  4189. m_pos -= (ip[0] >> 2) + (ip[1] << 6);
  4190. #endif
  4191. ip += 2;
  4192. if (m_pos == op)
  4193. goto eof_found;
  4194. m_pos -= 0x4000;
  4195. #if defined(LZO1Z)
  4196. last_m_off = pd((const lzo_bytep)op, m_pos);
  4197. #endif
  4198. #endif
  4199. }
  4200. else
  4201. {
  4202. #if defined(COPY_DICT)
  4203. #if defined(LZO1Z)
  4204. m_off = 1 + (t << 6) + (*ip++ >> 2);
  4205. last_m_off = m_off;
  4206. #else
  4207. m_off = 1 + (t >> 2) + (*ip++ << 2);
  4208. #endif
  4209. NEED_OP(2);
  4210. t = 2; COPY_DICT(t,m_off)
  4211. #else
  4212. #if defined(LZO1Z)
  4213. t = 1 + (t << 6) + (*ip++ >> 2);
  4214. m_pos = op - t;
  4215. last_m_off = t;
  4216. #else
  4217. m_pos = op - 1;
  4218. m_pos -= t >> 2;
  4219. m_pos -= *ip++ << 2;
  4220. #endif
  4221. TEST_LB(m_pos); NEED_OP(2);
  4222. *op++ = *m_pos++; *op++ = *m_pos;
  4223. #endif
  4224. goto match_done;
  4225. }
  4226. #if defined(COPY_DICT)
  4227. NEED_OP(t+3-1);
  4228. t += 3-1; COPY_DICT(t,m_off)
  4229. #else
  4230. TEST_LB(m_pos); assert(t > 0); NEED_OP(t+3-1);
  4231. #if defined(LZO_UNALIGNED_OK_8) && defined(LZO_UNALIGNED_OK_4)
  4232. if (op - m_pos >= 8)
  4233. {
  4234. t += (3 - 1);
  4235. if (t >= 8) do
  4236. {
  4237. UA_COPY64(op,m_pos);
  4238. op += 8; m_pos += 8; t -= 8;
  4239. } while (t >= 8);
  4240. if (t >= 4)
  4241. {
  4242. UA_COPY32(op,m_pos);
  4243. op += 4; m_pos += 4; t -= 4;
  4244. }
  4245. if (t > 0)
  4246. {
  4247. *op++ = m_pos[0];
  4248. if (t > 1) { *op++ = m_pos[1]; if (t > 2) { *op++ = m_pos[2]; } }
  4249. }
  4250. }
  4251. else
  4252. #elif defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4)
  4253. #if !defined(LZO_UNALIGNED_OK_4)
  4254. if (t >= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op,m_pos))
  4255. {
  4256. assert((op - m_pos) >= 4);
  4257. #else
  4258. if (t >= 2 * 4 - (3 - 1) && (op - m_pos) >= 4)
  4259. {
  4260. #endif
  4261. UA_COPY32(op,m_pos);
  4262. op += 4; m_pos += 4; t -= 4 - (3 - 1);
  4263. do {
  4264. UA_COPY32(op,m_pos);
  4265. op += 4; m_pos += 4; t -= 4;
  4266. } while (t >= 4);
  4267. if (t > 0) do *op++ = *m_pos++; while (--t > 0);
  4268. }
  4269. else
  4270. #endif
  4271. {
  4272. copy_match:
  4273. *op++ = *m_pos++; *op++ = *m_pos++;
  4274. do *op++ = *m_pos++; while (--t > 0);
  4275. }
  4276. #endif
  4277. match_done:
  4278. #if defined(LZO1Z)
  4279. t = ip[-1] & 3;
  4280. #else
  4281. t = ip[-2] & 3;
  4282. #endif
  4283. if (t == 0)
  4284. break;
  4285. match_next:
  4286. assert(t > 0); assert(t < 4); NEED_OP(t); NEED_IP(t+1);
  4287. #if 0
  4288. do *op++ = *ip++; while (--t > 0);
  4289. #else
  4290. *op++ = *ip++;
  4291. if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } }
  4292. #endif
  4293. t = *ip++;
  4294. } while (TEST_IP && TEST_OP);
  4295. }
  4296. #if defined(HAVE_TEST_IP) || defined(HAVE_TEST_OP)
  4297. *out_len = pd(op, out);
  4298. return LZO_E_EOF_NOT_FOUND;
  4299. #endif
  4300. eof_found:
  4301. assert(t == 1);
  4302. *out_len = pd(op, out);
  4303. return (ip == ip_end ? LZO_E_OK :
  4304. (ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN));
  4305. #if defined(HAVE_NEED_IP)
  4306. input_overrun:
  4307. *out_len = pd(op, out);
  4308. return LZO_E_INPUT_OVERRUN;
  4309. #endif
  4310. #if defined(HAVE_NEED_OP)
  4311. output_overrun:
  4312. *out_len = pd(op, out);
  4313. return LZO_E_OUTPUT_OVERRUN;
  4314. #endif
  4315. #if defined(LZO_TEST_OVERRUN_LOOKBEHIND)
  4316. lookbehind_overrun:
  4317. *out_len = pd(op, out);
  4318. return LZO_E_LOOKBEHIND_OVERRUN;
  4319. #endif
  4320. }
  4321. #endif
  4322. /***** End of minilzo.c *****/