fnv1.inc 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  1. /**--------------------------------------------------------------------------**\
  2. ========================================
  3. y_stringhash - Fast string comparisons
  4. ========================================
  5. Description:
  6. Allows you to hash strings at compile time to use them in a switch.
  7. Legal:
  8. Version: MPL 1.1
  9. The contents of this file are subject to the Mozilla Public License Version
  10. 1.1 (the "License"); you may not use this file except in compliance with
  11. the License. You may obtain a copy of the License at
  12. http://www.mozilla.org/MPL/
  13. Software distributed under the License is distributed on an "AS IS" basis,
  14. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  15. for the specific language governing rights and limitations under the
  16. License.
  17. The Original Code is the YSI stringhash include.
  18. The Initial Developer of the Original Code is Alex "Y_Less" Cole.
  19. Portions created by the Initial Developer are Copyright (C) 2011
  20. the Initial Developer. All Rights Reserved.
  21. Contributors:
  22. ZeeX, koolk, JoeBullet/Google63, g_aSlice/Slice
  23. Thanks:
  24. JoeBullet/Google63 - Handy arbitrary ASM jump code using SCTRL.
  25. ZeeX - Very productive conversations.
  26. koolk - IsPlayerinAreaEx code.
  27. TheAlpha - Danish translation.
  28. breadfish - German translation.
  29. Fireburn - Dutch translation.
  30. yom - French translation.
  31. 50p - Polish translation.
  32. Zamaroht - Spanish translation.
  33. Dracoblue, sintax, mabako, Xtreme, other coders - Producing other modes
  34. for me to strive to better.
  35. Pixels^ - Running XScripters where the idea was born.
  36. Matite - Pestering me to release it and using it.
  37. Very special thanks to:
  38. Thiadmer - PAWN, whose limits continue to amaze me!
  39. Kye/Kalcor - SA:MP.
  40. SA:MP Team past, present and future - SA:MP.
  41. Version:
  42. 2.0
  43. Changelog:
  44. 06/03/11:
  45. Changed the order of some letters to better support numbers in _I.
  46. 01/03/11:
  47. Rewrote compile-time hashes to not require commas.
  48. 25/10/10:
  49. Updated comments.
  50. Added to YSI 1.0.
  51. Added FNV1 and FNV1a hashes to avoid collisions.
  52. 19/08/10:
  53. First version.
  54. Functions:
  55. stock:
  56. YHash - Generate a string hash at run time.
  57. Definitions:
  58. _H - Generate a string hash at compile time.
  59. _I - Generate a case insensitive string hash at compile time.
  60. \**--------------------------------------------------------------------------**/
  61. /*
  62. 888b 88 ,ad8888ba, 88
  63. 8888b 88 d8"' `"8b 88
  64. 88 `8b 88 d8' 88
  65. 88 `8b 88 ,adPPYba, 8b db d8 88 ,adPPYYba, ,adPPYba, ,adPPYba, ,adPPYb,88
  66. 88 `8b 88 a8P_____88 `8b d88b d8' 88 "" `Y8 I8[ "" a8P_____88 a8" `Y88
  67. 88 `8b 88 8PP""""""" `8b d8'`8b d8' Y8, ,adPPPPP88 `"Y8ba, 8PP""""""" 8b 88
  68. 88 `8888 "8b, ,aa `8bd8' `8bd8' Y8a. .a8P 88, ,88 aa ]8I "8b, ,aa "8a, ,d88
  69. 88 `888 `"Ybbd8"' YP YP `"Y8888Y"' `"8bbdP"Y8 `"YbbdP"' `"Ybbd8"' `"8bbdP"Y8
  70. */
  71. // =============================
  72. // New syntax (case sensitive)
  73. // =============================
  74. #define hg:%9()
  75. #define H_Dg(%0,%5,%1,%6) hg:H_Ng%5(%0)H_Sg:%6]hg:@G%5:H_Ng%5(%1)
  76. #define H_Sg:%6]%7|||%8||| %7|||(%8*16777619^%6)|||
  77. #define H_Eg:|||%0||| %0
  78. // Test for the current character.
  79. #define @Ga:H_Nga(%1a%0)%7||| H_Dg(%1,a,%0,97)%7|||
  80. #define @Gb:H_Ngb(%1b%0)%7||| H_Dg(%1,b,%0,98)%7|||
  81. #define @Gc:H_Ngc(%1c%0)%7||| H_Dg(%1,c,%0,99)%7|||
  82. #define @Gd:H_Ngd(%1d%0)%7||| H_Dg(%1,d,%0,100)%7|||
  83. #define @Ge:H_Nge(%1e%0)%7||| H_Dg(%1,e,%0,101)%7|||
  84. #define @Gf:H_Ngf(%1f%0)%7||| H_Dg(%1,f,%0,102)%7|||
  85. #define @Gg:H_Ngg(%1g%0)%7||| H_Dg(%1,g,%0,103)%7|||
  86. #define @Gh:H_Ngh(%1h%0)%7||| H_Dg(%1,h,%0,104)%7|||
  87. #define @Gi:H_Ngi(%1i%0)%7||| H_Dg(%1,i,%0,105)%7|||
  88. #define @Gj:H_Ngj(%1j%0)%7||| H_Dg(%1,j,%0,106)%7|||
  89. #define @Gk:H_Ngk(%1k%0)%7||| H_Dg(%1,k,%0,107)%7|||
  90. #define @Gl:H_Ngl(%1l%0)%7||| H_Dg(%1,l,%0,108)%7|||
  91. #define @Gm:H_Ngm(%1m%0)%7||| H_Dg(%1,m,%0,109)%7|||
  92. #define @Gn:H_Ngn(%1n%0)%7||| H_Dg(%1,n,%0,110)%7|||
  93. #define @Go:H_Ngo(%1o%0)%7||| H_Dg(%1,o,%0,111)%7|||
  94. #define @Gp:H_Ngp(%1p%0)%7||| H_Dg(%1,p,%0,112)%7|||
  95. #define @Gq:H_Ngq(%1q%0)%7||| H_Dg(%1,q,%0,113)%7|||
  96. #define @Gr:H_Ngr(%1r%0)%7||| H_Dg(%1,r,%0,114)%7|||
  97. #define @Gs:H_Ngs(%1s%0)%7||| H_Dg(%1,s,%0,115)%7|||
  98. #define @Gt:H_Ngt(%1t%0)%7||| H_Dg(%1,t,%0,116)%7|||
  99. #define @Gu:H_Ngu(%1u%0)%7||| H_Dg(%1,u,%0,117)%7|||
  100. #define @Gv:H_Ngv(%1v%0)%7||| H_Dg(%1,v,%0,118)%7|||
  101. #define @Gw:H_Ngw(%1w%0)%7||| H_Dg(%1,w,%0,119)%7|||
  102. #define @Gx:H_Ngx(%1x%0)%7||| H_Dg(%1,x,%0,120)%7|||
  103. #define @Gy:H_Ngy(%1y%0)%7||| H_Dg(%1,y,%0,121)%7|||
  104. #define @Gz:H_Ngz(%1z%0)%7||| H_Dg(%1,z,%0,122)%7|||
  105. #define @GA:H_NgA(%1A%0)%7||| H_Dg(%1,A,%0,65)%7|||
  106. #define @GB:H_NgB(%1B%0)%7||| H_Dg(%1,B,%0,66)%7|||
  107. #define @GC:H_NgC(%1C%0)%7||| H_Dg(%1,C,%0,67)%7|||
  108. #define @GD:H_NgD(%1D%0)%7||| H_Dg(%1,D,%0,68)%7|||
  109. #define @GE:H_NgE(%1E%0)%7||| H_Dg(%1,E,%0,69)%7|||
  110. #define @GF:H_NgF(%1F%0)%7||| H_Dg(%1,F,%0,70)%7|||
  111. #define @GG:H_NgG(%1G%0)%7||| H_Dg(%1,G,%0,71)%7|||
  112. #define @GH:H_NgH(%1H%0)%7||| H_Dg(%1,H,%0,72)%7|||
  113. #define @GI:H_NgI(%1I%0)%7||| H_Dg(%1,I,%0,73)%7|||
  114. #define @GJ:H_NgJ(%1J%0)%7||| H_Dg(%1,J,%0,74)%7|||
  115. #define @GK:H_NgK(%1K%0)%7||| H_Dg(%1,K,%0,75)%7|||
  116. #define @GL:H_NgL(%1L%0)%7||| H_Dg(%1,L,%0,76)%7|||
  117. #define @GM:H_NgM(%1M%0)%7||| H_Dg(%1,M,%0,77)%7|||
  118. #define @GN:H_NgN(%1N%0)%7||| H_Dg(%1,N,%0,78)%7|||
  119. #define @GO:H_NgO(%1O%0)%7||| H_Dg(%1,O,%0,79)%7|||
  120. #define @GP:H_NgP(%1P%0)%7||| H_Dg(%1,P,%0,80)%7|||
  121. #define @GQ:H_NgQ(%1Q%0)%7||| H_Dg(%1,Q,%0,81)%7|||
  122. #define @GR:H_NgR(%1R%0)%7||| H_Dg(%1,R,%0,82)%7|||
  123. #define @GS:H_NgS(%1S%0)%7||| H_Dg(%1,S,%0,83)%7|||
  124. #define @GT:H_NgT(%1T%0)%7||| H_Dg(%1,T,%0,84)%7|||
  125. #define @GU:H_NgU(%1U%0)%7||| H_Dg(%1,U,%0,85)%7|||
  126. #define @GV:H_NgV(%1V%0)%7||| H_Dg(%1,V,%0,86)%7|||
  127. #define @GW:H_NgW(%1W%0)%7||| H_Dg(%1,W,%0,87)%7|||
  128. #define @GX:H_NgX(%1X%0)%7||| H_Dg(%1,X,%0,88)%7|||
  129. #define @GY:H_NgY(%1Y%0)%7||| H_Dg(%1,Y,%0,89)%7|||
  130. #define @GZ:H_NgZ(%1Z%0)%7||| H_Dg(%1,Z,%0,90)%7|||
  131. #define @G0:H_Ng0(%10%0)%7||| H_Dg(%1,0,%0,48)%7|||
  132. #define @G1:H_Ng1(%11%0)%7||| H_Dg(%1,1,%0,49)%7|||
  133. #define @G2:H_Ng2(%12%0)%7||| H_Dg(%1,2,%0,50)%7|||
  134. #define @G3:H_Ng3(%13%0)%7||| H_Dg(%1,3,%0,51)%7|||
  135. #define @G4:H_Ng4(%14%0)%7||| H_Dg(%1,4,%0,52)%7|||
  136. #define @G5:H_Ng5(%15%0)%7||| H_Dg(%1,5,%0,53)%7|||
  137. #define @G6:H_Ng6(%16%0)%7||| H_Dg(%1,6,%0,54)%7|||
  138. #define @G7:H_Ng7(%17%0)%7||| H_Dg(%1,7,%0,55)%7|||
  139. #define @G8:H_Ng8(%18%0)%7||| H_Dg(%1,8,%0,56)%7|||
  140. #define @G9:H_Ng9(%19%0)%7||| H_Dg(%1,9,%0,57)%7|||
  141. #define @G_:H_Ng_(%1,_%0)%7||| H_Dg(%1,_,%0,95)%7|||
  142. //#define hg@:H_Sg(@%0,%1)%7||| H_Dg(%0)%7|||
  143. // Find the next character to test.
  144. #define H_Nga(%0) @Gb:H_Ngb(%0)
  145. #define H_Ngb(%0) @Gc:H_Ngc(%0)
  146. #define H_Ngc(%0) @Gd:H_Ngd(%0)
  147. #define H_Ngd(%0) @Ge:H_Nge(%0)
  148. #define H_Nge(%0) @Gf:H_Ngf(%0)
  149. #define H_Ngf(%0) @Gg:H_Ngg(%0)
  150. #define H_Ngg(%0) @Gh:H_Ngh(%0)
  151. #define H_Ngh(%0) @Gi:H_Ngi(%0)
  152. #define H_Ngi(%0) @Gj:H_Ngj(%0)
  153. #define H_Ngj(%0) @Gk:H_Ngk(%0)
  154. #define H_Ngk(%0) @Gl:H_Ngl(%0)
  155. #define H_Ngl(%0) @Gm:H_Ngm(%0)
  156. #define H_Ngm(%0) @Gn:H_Ngn(%0)
  157. #define H_Ngn(%0) @Go:H_Ngo(%0)
  158. #define H_Ngo(%0) @Gp:H_Ngp(%0)
  159. #define H_Ngp(%0) @Gq:H_Ngq(%0)
  160. #define H_Ngq(%0) @Gr:H_Ngr(%0)
  161. #define H_Ngr(%0) @Gs:H_Ngs(%0)
  162. #define H_Ngs(%0) @Gt:H_Ngt(%0)
  163. #define H_Ngt(%0) @Gu:H_Ngu(%0)
  164. #define H_Ngu(%0) @Gv:H_Ngv(%0)
  165. #define H_Ngv(%0) @Gw:H_Ngw(%0)
  166. #define H_Ngw(%0) @Gx:H_Ngx(%0)
  167. #define H_Ngx(%0) @Gy:H_Ngy(%0)
  168. #define H_Ngy(%0) @Gz:H_Ngz(%0)
  169. #define H_Ngz(%0) @G0:H_Ng0(%0)
  170. #define H_NgA(%0) @GB:H_NgB(%0)
  171. #define H_NgB(%0) @GC:H_NgC(%0)
  172. #define H_NgC(%0) @GD:H_NgD(%0)
  173. #define H_NgD(%0) @GE:H_NgE(%0)
  174. #define H_NgE(%0) @GF:H_NgF(%0)
  175. #define H_NgF(%0) @GG:H_NgG(%0)
  176. #define H_NgG(%0) @GH:H_NgH(%0)
  177. #define H_NgH(%0) @GI:H_NgI(%0)
  178. #define H_NgI(%0) @GJ:H_NgJ(%0)
  179. #define H_NgJ(%0) @GK:H_NgK(%0)
  180. #define H_NgK(%0) @GL:H_NgL(%0)
  181. #define H_NgL(%0) @GM:H_NgM(%0)
  182. #define H_NgM(%0) @GN:H_NgN(%0)
  183. #define H_NgN(%0) @GO:H_NgO(%0)
  184. #define H_NgO(%0) @GP:H_NgP(%0)
  185. #define H_NgP(%0) @GQ:H_NgQ(%0)
  186. #define H_NgQ(%0) @GR:H_NgR(%0)
  187. #define H_NgR(%0) @GS:H_NgS(%0)
  188. #define H_NgS(%0) @GT:H_NgT(%0)
  189. #define H_NgT(%0) @GU:H_NgU(%0)
  190. #define H_NgU(%0) @GV:H_NgV(%0)
  191. #define H_NgV(%0) @GW:H_NgW(%0)
  192. #define H_NgW(%0) @GX:H_NgX(%0)
  193. #define H_NgX(%0) @GY:H_NgY(%0)
  194. #define H_NgY(%0) @GZ:H_NgZ(%0)
  195. #define H_NgZ(%0) H_Eg:H_Rg
  196. #define H_Ng0(%0) @G1:H_Ng1(%0)
  197. #define H_Ng1(%0) @G2:H_Ng2(%0)
  198. #define H_Ng2(%0) @G3:H_Ng3(%0)
  199. #define H_Ng3(%0) @G4:H_Ng4(%0)
  200. #define H_Ng4(%0) @G5:H_Ng5(%0)
  201. #define H_Ng5(%0) @G6:H_Ng6(%0)
  202. #define H_Ng6(%0) @G7:H_Ng7(%0)
  203. #define H_Ng7(%0) @G8:H_Ng8(%0)
  204. #define H_Ng8(%0) @G9:H_Ng9(%0)
  205. #define H_Ng9(%0) @G_:H_Ng_(%0)
  206. #define H_Ng_(%0) @GA:H_NgA(%0)
  207. /*
  208. 888b 88 88
  209. 8888b 88 88
  210. 88 `8b 88 88
  211. 88 `8b 88 ,adPPYba, 8b db d8 88 ,adPPYb,d8 8b,dPPYba, ,adPPYba, 8b,dPPYba, ,adPPYba,
  212. 88 `8b 88 a8P_____88 `8b d88b d8' 88 a8" `Y88 88P' `"8a a8" "8a 88P' "Y8 a8P_____88
  213. 88 `8b 88 8PP""""""" `8b d8'`8b d8' 88 8b 88 88 88 8b d8 88 8PP"""""""
  214. 88 `8888 "8b, ,aa `8bd8' `8bd8' 88 "8a, ,d88 88 88 "8a, ,a8" 88 "8b, ,aa
  215. 88 `888 `"Ybbd8"' YP YP 88 `"YbbdP"Y8 88 88 `"YbbdP"' 88 `"Ybbd8"'
  216. aa, ,88
  217. "Y8bbdP"
  218. */
  219. // ===============================
  220. // New syntax (case insensitive)
  221. // ===============================
  222. #define hf:%9()
  223. #define H_Df(%0,%5,%1,%6) hf:H_Nf%5(%0)H_Sf:%6]hf:@F%5:H_Nf%5(%1)
  224. #define H_Sf:%6]%7|||%8||| %7|||(%8*16777619^%6)|||
  225. #define H_Ef:|||%0||| %0
  226. // Test for the current character.
  227. #define @Fa:H_Nfa(%1a%0)%7||| H_Df(%1,a,%0,65)%7|||
  228. #define @Fb:H_Nfb(%1b%0)%7||| H_Df(%1,b,%0,66)%7|||
  229. #define @Fc:H_Nfc(%1c%0)%7||| H_Df(%1,c,%0,67)%7|||
  230. #define @Fd:H_Nfd(%1d%0)%7||| H_Df(%1,d,%0,68)%7|||
  231. #define @Fe:H_Nfe(%1e%0)%7||| H_Df(%1,e,%0,69)%7|||
  232. #define @Ff:H_Nff(%1f%0)%7||| H_Df(%1,f,%0,70)%7|||
  233. #define @Fg:H_Nfg(%1g%0)%7||| H_Df(%1,g,%0,71)%7|||
  234. #define @Fh:H_Nfh(%1h%0)%7||| H_Df(%1,h,%0,72)%7|||
  235. #define @Fi:H_Nfi(%1i%0)%7||| H_Df(%1,i,%0,73)%7|||
  236. #define @Fj:H_Nfj(%1j%0)%7||| H_Df(%1,j,%0,74)%7|||
  237. #define @Fk:H_Nfk(%1k%0)%7||| H_Df(%1,k,%0,75)%7|||
  238. #define @Fl:H_Nfl(%1l%0)%7||| H_Df(%1,l,%0,76)%7|||
  239. #define @Fm:H_Nfm(%1m%0)%7||| H_Df(%1,m,%0,77)%7|||
  240. #define @Fn:H_Nfn(%1n%0)%7||| H_Df(%1,n,%0,78)%7|||
  241. #define @Fo:H_Nfo(%1o%0)%7||| H_Df(%1,o,%0,79)%7|||
  242. #define @Fp:H_Nfp(%1p%0)%7||| H_Df(%1,p,%0,80)%7|||
  243. #define @Fq:H_Nfq(%1q%0)%7||| H_Df(%1,q,%0,81)%7|||
  244. #define @Fr:H_Nfr(%1r%0)%7||| H_Df(%1,r,%0,82)%7|||
  245. #define @Fs:H_Nfs(%1s%0)%7||| H_Df(%1,s,%0,83)%7|||
  246. #define @Ft:H_Nft(%1t%0)%7||| H_Df(%1,t,%0,84)%7|||
  247. #define @Fu:H_Nfu(%1u%0)%7||| H_Df(%1,u,%0,85)%7|||
  248. #define @Fv:H_Nfv(%1v%0)%7||| H_Df(%1,v,%0,86)%7|||
  249. #define @Fw:H_Nfw(%1w%0)%7||| H_Df(%1,w,%0,87)%7|||
  250. #define @Fx:H_Nfx(%1x%0)%7||| H_Df(%1,x,%0,88)%7|||
  251. #define @Fy:H_Nfy(%1y%0)%7||| H_Df(%1,y,%0,89)%7|||
  252. #define @Fz:H_Nfz(%1z%0)%7||| H_Df(%1,z,%0,90)%7|||
  253. #define @FA:H_NfA(%1A%0)%7||| H_Df(%1,A,%0,65)%7|||
  254. #define @FB:H_NfB(%1B%0)%7||| H_Df(%1,B,%0,66)%7|||
  255. #define @FC:H_NfC(%1C%0)%7||| H_Df(%1,C,%0,67)%7|||
  256. #define @FD:H_NfD(%1D%0)%7||| H_Df(%1,D,%0,68)%7|||
  257. #define @FE:H_NfE(%1E%0)%7||| H_Df(%1,E,%0,69)%7|||
  258. #define @FF:H_NfF(%1F%0)%7||| H_Df(%1,F,%0,70)%7|||
  259. #define @FG:H_NfG(%1G%0)%7||| H_Df(%1,G,%0,71)%7|||
  260. #define @FH:H_NfH(%1H%0)%7||| H_Df(%1,H,%0,72)%7|||
  261. #define @FI:H_NfI(%1I%0)%7||| H_Df(%1,I,%0,73)%7|||
  262. #define @FJ:H_NfJ(%1J%0)%7||| H_Df(%1,J,%0,74)%7|||
  263. #define @FK:H_NfK(%1K%0)%7||| H_Df(%1,K,%0,75)%7|||
  264. #define @FL:H_NfL(%1L%0)%7||| H_Df(%1,L,%0,76)%7|||
  265. #define @FM:H_NfM(%1M%0)%7||| H_Df(%1,M,%0,77)%7|||
  266. #define @FN:H_NfN(%1N%0)%7||| H_Df(%1,N,%0,78)%7|||
  267. #define @FO:H_NfO(%1O%0)%7||| H_Df(%1,O,%0,79)%7|||
  268. #define @FP:H_NfP(%1P%0)%7||| H_Df(%1,P,%0,80)%7|||
  269. #define @FQ:H_NfQ(%1Q%0)%7||| H_Df(%1,Q,%0,81)%7|||
  270. #define @FR:H_NfR(%1R%0)%7||| H_Df(%1,R,%0,82)%7|||
  271. #define @FS:H_NfS(%1S%0)%7||| H_Df(%1,S,%0,83)%7|||
  272. #define @FT:H_NfT(%1T%0)%7||| H_Df(%1,T,%0,84)%7|||
  273. #define @FU:H_NfU(%1U%0)%7||| H_Df(%1,U,%0,85)%7|||
  274. #define @FV:H_NfV(%1V%0)%7||| H_Df(%1,V,%0,86)%7|||
  275. #define @FW:H_NfW(%1W%0)%7||| H_Df(%1,W,%0,87)%7|||
  276. #define @FX:H_NfX(%1X%0)%7||| H_Df(%1,X,%0,88)%7|||
  277. #define @FY:H_NfY(%1Y%0)%7||| H_Df(%1,Y,%0,89)%7|||
  278. #define @FZ:H_NfZ(%1Z%0)%7||| H_Df(%1,Z,%0,90)%7|||
  279. #define @F0:H_Nf0(%10%0)%7||| H_Df(%1,0,%0,48)%7|||
  280. #define @F1:H_Nf1(%11%0)%7||| H_Df(%1,1,%0,49)%7|||
  281. #define @F2:H_Nf2(%12%0)%7||| H_Df(%1,2,%0,50)%7|||
  282. #define @F3:H_Nf3(%13%0)%7||| H_Df(%1,3,%0,51)%7|||
  283. #define @F4:H_Nf4(%14%0)%7||| H_Df(%1,4,%0,52)%7|||
  284. #define @F5:H_Nf5(%15%0)%7||| H_Df(%1,5,%0,53)%7|||
  285. #define @F6:H_Nf6(%16%0)%7||| H_Df(%1,6,%0,54)%7|||
  286. #define @F7:H_Nf7(%17%0)%7||| H_Df(%1,7,%0,55)%7|||
  287. #define @F8:H_Nf8(%18%0)%7||| H_Df(%1,8,%0,56)%7|||
  288. #define @F9:H_Nf9(%19%0)%7||| H_Df(%1,9,%0,57)%7|||
  289. #define @F_:H_Nf_(%1_%0)%7||| H_Df(%1,_,%0,95)%7|||
  290. //#define hf@:H_Sf(@%0,%1)%7||| H_Df(%0)%7|||
  291. // Find the next character to test.
  292. #define H_Nfa(%0) @Fb:H_Nfb(%0)
  293. #define H_Nfb(%0) @Fc:H_Nfc(%0)
  294. #define H_Nfc(%0) @Fd:H_Nfd(%0)
  295. #define H_Nfd(%0) @Fe:H_Nfe(%0)
  296. #define H_Nfe(%0) @Ff:H_Nff(%0)
  297. #define H_Nff(%0) @Fg:H_Nfg(%0)
  298. #define H_Nfg(%0) @Fh:H_Nfh(%0)
  299. #define H_Nfh(%0) @Fi:H_Nfi(%0)
  300. #define H_Nfi(%0) @Fj:H_Nfj(%0)
  301. #define H_Nfj(%0) @Fk:H_Nfk(%0)
  302. #define H_Nfk(%0) @Fl:H_Nfl(%0)
  303. #define H_Nfl(%0) @Fm:H_Nfm(%0)
  304. #define H_Nfm(%0) @Fn:H_Nfn(%0)
  305. #define H_Nfn(%0) @Fo:H_Nfo(%0)
  306. #define H_Nfo(%0) @Fp:H_Nfp(%0)
  307. #define H_Nfp(%0) @Fq:H_Nfq(%0)
  308. #define H_Nfq(%0) @Fr:H_Nfr(%0)
  309. #define H_Nfr(%0) @Fs:H_Nfs(%0)
  310. #define H_Nfs(%0) @Ft:H_Nft(%0)
  311. #define H_Nft(%0) @Fu:H_Nfu(%0)
  312. #define H_Nfu(%0) @Fv:H_Nfv(%0)
  313. #define H_Nfv(%0) @Fw:H_Nfw(%0)
  314. #define H_Nfw(%0) @Fx:H_Nfx(%0)
  315. #define H_Nfx(%0) @Fy:H_Nfy(%0)
  316. #define H_Nfy(%0) @Fz:H_Nfz(%0)
  317. #define H_Nfz(%0) @F0:H_Nf0(%0)
  318. #define H_NfA(%0) @FB:H_NfB(%0)
  319. #define H_NfB(%0) @FC:H_NfC(%0)
  320. #define H_NfC(%0) @FD:H_NfD(%0)
  321. #define H_NfD(%0) @FE:H_NfE(%0)
  322. #define H_NfE(%0) @FF:H_NfF(%0)
  323. #define H_NfF(%0) @FG:H_NfG(%0)
  324. #define H_NfG(%0) @FH:H_NfH(%0)
  325. #define H_NfH(%0) @FI:H_NfI(%0)
  326. #define H_NfI(%0) @FJ:H_NfJ(%0)
  327. #define H_NfJ(%0) @FK:H_NfK(%0)
  328. #define H_NfK(%0) @FL:H_NfL(%0)
  329. #define H_NfL(%0) @FM:H_NfM(%0)
  330. #define H_NfM(%0) @FN:H_NfN(%0)
  331. #define H_NfN(%0) @FO:H_NfO(%0)
  332. #define H_NfO(%0) @FP:H_NfP(%0)
  333. #define H_NfP(%0) @FQ:H_NfQ(%0)
  334. #define H_NfQ(%0) @FR:H_NfR(%0)
  335. #define H_NfR(%0) @FS:H_NfS(%0)
  336. #define H_NfS(%0) @FT:H_NfT(%0)
  337. #define H_NfT(%0) @FU:H_NfU(%0)
  338. #define H_NfU(%0) @FV:H_NfV(%0)
  339. #define H_NfV(%0) @FW:H_NfW(%0)
  340. #define H_NfW(%0) @FX:H_NfX(%0)
  341. #define H_NfX(%0) @FY:H_NfY(%0)
  342. #define H_NfY(%0) @FZ:H_NfZ(%0)
  343. #define H_NfZ(%0) H_Ef:H_Rf
  344. #define H_Nf0(%0) @F1:H_Nf1(%0)
  345. #define H_Nf1(%0) @F2:H_Nf2(%0)
  346. #define H_Nf2(%0) @F3:H_Nf3(%0)
  347. #define H_Nf3(%0) @F4:H_Nf4(%0)
  348. #define H_Nf4(%0) @F5:H_Nf5(%0)
  349. #define H_Nf5(%0) @F6:H_Nf6(%0)
  350. #define H_Nf6(%0) @F7:H_Nf7(%0)
  351. #define H_Nf7(%0) @F8:H_Nf8(%0)
  352. #define H_Nf8(%0) @F9:H_Nf9(%0)
  353. #define H_Nf9(%0) @F_:H_Nf_(%0)
  354. #define H_Nf_(%0) @FA:H_NfA(%0)
  355. /*
  356. ,ad8888ba, 88 88 ,ad8888ba, 88
  357. d8"' `"8b 88 88 d8"' `"8b 88
  358. d8' `8b 88 88 d8' 88
  359. 88 88 88 ,adPPYb,88 88 ,adPPYYba, ,adPPYba, ,adPPYba, ,adPPYb,88
  360. 88 88 88 a8" `Y88 88 "" `Y8 I8[ "" a8P_____88 a8" `Y88
  361. Y8, ,8P 88 8b 88 Y8, ,adPPPPP88 `"Y8ba, 8PP""""""" 8b 88
  362. Y8a. .a8P 88 "8a, ,d88 Y8a. .a8P 88, ,88 aa ]8I "8b, ,aa "8a, ,d88
  363. `"Y8888Y"' 88 `"8bbdP"Y8 `"Y8888Y"' `"8bbdP"Y8 `"YbbdP"' `"Ybbd8"' `"8bbdP"Y8
  364. */
  365. // =============================
  366. // Old syntax (case sensitive)
  367. // =============================
  368. // Signify the end with two "@" symbols.
  369. #define HASH@fnv1(%0) _REHASH@f(%0,@,@)
  370. // Internal call.
  371. #define _REHASH@f(%0,%1) _HASH@f_%0(%1,)(2166136261)
  372. // The bit that actually does the work.
  373. #define _DOHASH@f(%0,%1,%2)(%8) _HASH@f_%1(%2)((%8*16777619^%0))
  374. // Space.
  375. #define _HASH@f_(%0)(%8) _DOHASH@f(32,%0)(%8)
  376. // Numbers.
  377. #define _HASH@f_0(%0)(%8) _DOHASH@f(48,%0)(%8)
  378. #define _HASH@f_1(%0)(%8) _DOHASH@f(49,%0)(%8)
  379. #define _HASH@f_2(%0)(%8) _DOHASH@f(50,%0)(%8)
  380. #define _HASH@f_3(%0)(%8) _DOHASH@f(51,%0)(%8)
  381. #define _HASH@f_4(%0)(%8) _DOHASH@f(52,%0)(%8)
  382. #define _HASH@f_5(%0)(%8) _DOHASH@f(53,%0)(%8)
  383. #define _HASH@f_6(%0)(%8) _DOHASH@f(54,%0)(%8)
  384. #define _HASH@f_7(%0)(%8) _DOHASH@f(55,%0)(%8)
  385. #define _HASH@f_8(%0)(%8) _DOHASH@f(56,%0)(%8)
  386. #define _HASH@f_9(%0)(%8) _DOHASH@f(57,%0)(%8)
  387. // Upper case letters.
  388. #define _HASH@f_A(%0)(%8) _DOHASH@f(65,%0)(%8)
  389. #define _HASH@f_B(%0)(%8) _DOHASH@f(66,%0)(%8)
  390. #define _HASH@f_C(%0)(%8) _DOHASH@f(67,%0)(%8)
  391. #define _HASH@f_D(%0)(%8) _DOHASH@f(68,%0)(%8)
  392. #define _HASH@f_E(%0)(%8) _DOHASH@f(69,%0)(%8)
  393. #define _HASH@f_F(%0)(%8) _DOHASH@f(70,%0)(%8)
  394. #define _HASH@f_G(%0)(%8) _DOHASH@f(71,%0)(%8)
  395. #define _HASH@f_H(%0)(%8) _DOHASH@f(72,%0)(%8)
  396. #define _HASH@f_I(%0)(%8) _DOHASH@f(73,%0)(%8)
  397. #define _HASH@f_J(%0)(%8) _DOHASH@f(74,%0)(%8)
  398. #define _HASH@f_K(%0)(%8) _DOHASH@f(75,%0)(%8)
  399. #define _HASH@f_L(%0)(%8) _DOHASH@f(76,%0)(%8)
  400. #define _HASH@f_M(%0)(%8) _DOHASH@f(77,%0)(%8)
  401. #define _HASH@f_N(%0)(%8) _DOHASH@f(78,%0)(%8)
  402. #define _HASH@f_O(%0)(%8) _DOHASH@f(79,%0)(%8)
  403. #define _HASH@f_P(%0)(%8) _DOHASH@f(80,%0)(%8)
  404. #define _HASH@f_Q(%0)(%8) _DOHASH@f(81,%0)(%8)
  405. #define _HASH@f_R(%0)(%8) _DOHASH@f(82,%0)(%8)
  406. #define _HASH@f_S(%0)(%8) _DOHASH@f(83,%0)(%8)
  407. #define _HASH@f_T(%0)(%8) _DOHASH@f(84,%0)(%8)
  408. #define _HASH@f_U(%0)(%8) _DOHASH@f(85,%0)(%8)
  409. #define _HASH@f_V(%0)(%8) _DOHASH@f(86,%0)(%8)
  410. #define _HASH@f_W(%0)(%8) _DOHASH@f(87,%0)(%8)
  411. #define _HASH@f_X(%0)(%8) _DOHASH@f(88,%0)(%8)
  412. #define _HASH@f_Y(%0)(%8) _DOHASH@f(89,%0)(%8)
  413. #define _HASH@f_Z(%0)(%8) _DOHASH@f(90,%0)(%8)
  414. // Underscore.
  415. #define _HASH@f__(%0)(%8) _DOHASH@f(95,%0)(%8)
  416. // Lower case letters.
  417. #define _HASH@f_a(%0)(%8) _DOHASH@f(97,%0)(%8)
  418. #define _HASH@f_b(%0)(%8) _DOHASH@f(98,%0)(%8)
  419. #define _HASH@f_c(%0)(%8) _DOHASH@f(99,%0)(%8)
  420. #define _HASH@f_d(%0)(%8) _DOHASH@f(100,%0)(%8)
  421. #define _HASH@f_e(%0)(%8) _DOHASH@f(101,%0)(%8)
  422. #define _HASH@f_f(%0)(%8) _DOHASH@f(102,%0)(%8)
  423. #define _HASH@f_g(%0)(%8) _DOHASH@f(103,%0)(%8)
  424. #define _HASH@f_h(%0)(%8) _DOHASH@f(104,%0)(%8)
  425. #define _HASH@f_i(%0)(%8) _DOHASH@f(105,%0)(%8)
  426. #define _HASH@f_j(%0)(%8) _DOHASH@f(106,%0)(%8)
  427. #define _HASH@f_k(%0)(%8) _DOHASH@f(107,%0)(%8)
  428. #define _HASH@f_l(%0)(%8) _DOHASH@f(108,%0)(%8)
  429. #define _HASH@f_m(%0)(%8) _DOHASH@f(109,%0)(%8)
  430. #define _HASH@f_n(%0)(%8) _DOHASH@f(110,%0)(%8)
  431. #define _HASH@f_o(%0)(%8) _DOHASH@f(111,%0)(%8)
  432. #define _HASH@f_p(%0)(%8) _DOHASH@f(112,%0)(%8)
  433. #define _HASH@f_q(%0)(%8) _DOHASH@f(113,%0)(%8)
  434. #define _HASH@f_r(%0)(%8) _DOHASH@f(114,%0)(%8)
  435. #define _HASH@f_s(%0)(%8) _DOHASH@f(115,%0)(%8)
  436. #define _HASH@f_t(%0)(%8) _DOHASH@f(116,%0)(%8)
  437. #define _HASH@f_u(%0)(%8) _DOHASH@f(117,%0)(%8)
  438. #define _HASH@f_v(%0)(%8) _DOHASH@f(118,%0)(%8)
  439. #define _HASH@f_w(%0)(%8) _DOHASH@f(119,%0)(%8)
  440. #define _HASH@f_x(%0)(%8) _DOHASH@f(120,%0)(%8)
  441. #define _HASH@f_y(%0)(%8) _DOHASH@f(121,%0)(%8)
  442. #define _HASH@f_z(%0)(%8) _DOHASH@f(122,%0)(%8)
  443. // String end.
  444. #define _HASH@f_@(%0)(%8) %8
  445. /*
  446. ,ad8888ba, 88 88 88
  447. d8"' `"8b 88 88 88
  448. d8' `8b 88 88 88
  449. 88 88 88 ,adPPYb,88 88 ,adPPYb,d8 8b,dPPYba, ,adPPYba, 8b,dPPYba, ,adPPYba,
  450. 88 88 88 a8" `Y88 88 a8" `Y88 88P' `"8a a8" "8a 88P' "Y8 a8P_____88
  451. Y8, ,8P 88 8b 88 88 8b 88 88 88 8b d8 88 8PP"""""""
  452. Y8a. .a8P 88 "8a, ,d88 88 "8a, ,d88 88 88 "8a, ,a8" 88 "8b, ,aa
  453. `"Y8888Y"' 88 `"8bbdP"Y8 88 `"YbbdP"Y8 88 88 `"YbbdP"' 88 `"Ybbd8"'
  454. aa, ,88
  455. "Y8bbdP"
  456. */
  457. // ===============================
  458. // Old syntax (case insensitive)
  459. // ===============================
  460. // Signify the end with two "@" symbols.
  461. #define HASHi@fnv1(%0) _REHASH@if(%0,@,@)
  462. // Internal call.
  463. #define _REHASH@if(%0,%1) _HASH@if_%0(%1,)(2166136261)
  464. // The bit that actually does the work.
  465. #define _DOHASH@if(%0,%1,%2)(%8) _HASH@if_%1(%2)((%8*16777619^%0))
  466. // Space.
  467. #define _HASH@if_(%0)(%8) _DOHASH@if(32,%0)(%8)
  468. // Numbers.
  469. #define _HASH@if_0(%0)(%8) _DOHASH@if(48,%0)(%8)
  470. #define _HASH@if_1(%0)(%8) _DOHASH@if(49,%0)(%8)
  471. #define _HASH@if_2(%0)(%8) _DOHASH@if(50,%0)(%8)
  472. #define _HASH@if_3(%0)(%8) _DOHASH@if(51,%0)(%8)
  473. #define _HASH@if_4(%0)(%8) _DOHASH@if(52,%0)(%8)
  474. #define _HASH@if_5(%0)(%8) _DOHASH@if(53,%0)(%8)
  475. #define _HASH@if_6(%0)(%8) _DOHASH@if(54,%0)(%8)
  476. #define _HASH@if_7(%0)(%8) _DOHASH@if(55,%0)(%8)
  477. #define _HASH@if_8(%0)(%8) _DOHASH@if(56,%0)(%8)
  478. #define _HASH@if_9(%0)(%8) _DOHASH@if(57,%0)(%8)
  479. // Upper case letters.
  480. #define _HASH@if_A(%0)(%8) _DOHASH@if(65,%0)(%8)
  481. #define _HASH@if_B(%0)(%8) _DOHASH@if(66,%0)(%8)
  482. #define _HASH@if_C(%0)(%8) _DOHASH@if(67,%0)(%8)
  483. #define _HASH@if_D(%0)(%8) _DOHASH@if(68,%0)(%8)
  484. #define _HASH@if_E(%0)(%8) _DOHASH@if(69,%0)(%8)
  485. #define _HASH@if_F(%0)(%8) _DOHASH@if(70,%0)(%8)
  486. #define _HASH@if_G(%0)(%8) _DOHASH@if(71,%0)(%8)
  487. #define _HASH@if_H(%0)(%8) _DOHASH@if(72,%0)(%8)
  488. #define _HASH@if_I(%0)(%8) _DOHASH@if(73,%0)(%8)
  489. #define _HASH@if_J(%0)(%8) _DOHASH@if(74,%0)(%8)
  490. #define _HASH@if_K(%0)(%8) _DOHASH@if(75,%0)(%8)
  491. #define _HASH@if_L(%0)(%8) _DOHASH@if(76,%0)(%8)
  492. #define _HASH@if_M(%0)(%8) _DOHASH@if(77,%0)(%8)
  493. #define _HASH@if_N(%0)(%8) _DOHASH@if(78,%0)(%8)
  494. #define _HASH@if_O(%0)(%8) _DOHASH@if(79,%0)(%8)
  495. #define _HASH@if_P(%0)(%8) _DOHASH@if(80,%0)(%8)
  496. #define _HASH@if_Q(%0)(%8) _DOHASH@if(81,%0)(%8)
  497. #define _HASH@if_R(%0)(%8) _DOHASH@if(82,%0)(%8)
  498. #define _HASH@if_S(%0)(%8) _DOHASH@if(83,%0)(%8)
  499. #define _HASH@if_T(%0)(%8) _DOHASH@if(84,%0)(%8)
  500. #define _HASH@if_U(%0)(%8) _DOHASH@if(85,%0)(%8)
  501. #define _HASH@if_V(%0)(%8) _DOHASH@if(86,%0)(%8)
  502. #define _HASH@if_W(%0)(%8) _DOHASH@if(87,%0)(%8)
  503. #define _HASH@if_X(%0)(%8) _DOHASH@if(88,%0)(%8)
  504. #define _HASH@if_Y(%0)(%8) _DOHASH@if(89,%0)(%8)
  505. #define _HASH@if_Z(%0)(%8) _DOHASH@if(90,%0)(%8)
  506. // Underscore.
  507. #define _HASH@if__(%0)(%8) _DOHASH@if(95,%0)(%8)
  508. // Lower case letters.
  509. #define _HASH@if_a(%0)(%8) _DOHASH@if(65,%0)(%8)
  510. #define _HASH@if_b(%0)(%8) _DOHASH@if(66,%0)(%8)
  511. #define _HASH@if_c(%0)(%8) _DOHASH@if(67,%0)(%8)
  512. #define _HASH@if_d(%0)(%8) _DOHASH@if(68,%0)(%8)
  513. #define _HASH@if_e(%0)(%8) _DOHASH@if(69,%0)(%8)
  514. #define _HASH@if_f(%0)(%8) _DOHASH@if(70,%0)(%8)
  515. #define _HASH@if_g(%0)(%8) _DOHASH@if(71,%0)(%8)
  516. #define _HASH@if_h(%0)(%8) _DOHASH@if(72,%0)(%8)
  517. #define _HASH@if_i(%0)(%8) _DOHASH@if(73,%0)(%8)
  518. #define _HASH@if_j(%0)(%8) _DOHASH@if(74,%0)(%8)
  519. #define _HASH@if_k(%0)(%8) _DOHASH@if(75,%0)(%8)
  520. #define _HASH@if_l(%0)(%8) _DOHASH@if(76,%0)(%8)
  521. #define _HASH@if_m(%0)(%8) _DOHASH@if(77,%0)(%8)
  522. #define _HASH@if_n(%0)(%8) _DOHASH@if(78,%0)(%8)
  523. #define _HASH@if_o(%0)(%8) _DOHASH@if(79,%0)(%8)
  524. #define _HASH@if_p(%0)(%8) _DOHASH@if(80,%0)(%8)
  525. #define _HASH@if_q(%0)(%8) _DOHASH@if(81,%0)(%8)
  526. #define _HASH@if_r(%0)(%8) _DOHASH@if(82,%0)(%8)
  527. #define _HASH@if_s(%0)(%8) _DOHASH@if(83,%0)(%8)
  528. #define _HASH@if_t(%0)(%8) _DOHASH@if(84,%0)(%8)
  529. #define _HASH@if_u(%0)(%8) _DOHASH@if(85,%0)(%8)
  530. #define _HASH@if_v(%0)(%8) _DOHASH@if(86,%0)(%8)
  531. #define _HASH@if_w(%0)(%8) _DOHASH@if(87,%0)(%8)
  532. #define _HASH@if_x(%0)(%8) _DOHASH@if(88,%0)(%8)
  533. #define _HASH@if_y(%0)(%8) _DOHASH@if(89,%0)(%8)
  534. #define _HASH@if_z(%0)(%8) _DOHASH@if(90,%0)(%8)
  535. // String end.
  536. #define _HASH@if_@(%0)(%8) %8