• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* lzo_supp.h -- architecture, OS and compiler specific defines
2 
3    This file is part of the LZO real-time data compression library.
4 
5    Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer
6    All Rights Reserved.
7 
8    The LZO library is free software; you can redistribute it and/or
9    modify it under the terms of the GNU General Public License as
10    published by the Free Software Foundation; either version 2 of
11    the License, or (at your option) any later version.
12 
13    The LZO library is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17 
18    You should have received a copy of the GNU General Public License
19    along with the LZO library; see the file COPYING.
20    If not, write to the Free Software Foundation, Inc.,
21    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 
23    Markus F.X.J. Oberhumer
24    <markus@oberhumer.com>
25    http://www.oberhumer.com/opensource/lzo/
26  */
27 
28 
29 #ifndef __LZO_SUPP_H_INCLUDED
30 #define __LZO_SUPP_H_INCLUDED 1
31 #if (LZO_CFG_NO_CONFIG_HEADER)
32 #elif defined(LZO_CFG_CONFIG_HEADER)
33 #else
34 #if !(LZO_CFG_AUTO_NO_HEADERS)
35 #if (LZO_LIBC_NAKED)
36 #elif (LZO_LIBC_FREESTANDING)
37 #  define HAVE_LIMITS_H 1
38 #  define HAVE_STDARG_H 1
39 #  define HAVE_STDDEF_H 1
40 #elif (LZO_LIBC_MOSTLY_FREESTANDING)
41 #  define HAVE_LIMITS_H 1
42 #  define HAVE_SETJMP_H 1
43 #  define HAVE_STDARG_H 1
44 #  define HAVE_STDDEF_H 1
45 #  define HAVE_STDIO_H 1
46 #  define HAVE_STRING_H 1
47 #else
48 #define STDC_HEADERS 1
49 #define HAVE_ASSERT_H 1
50 #define HAVE_CTYPE_H 1
51 #define HAVE_DIRENT_H 1
52 #define HAVE_ERRNO_H 1
53 #define HAVE_FCNTL_H 1
54 #define HAVE_FLOAT_H 1
55 #define HAVE_LIMITS_H 1
56 #define HAVE_MALLOC_H 1
57 #define HAVE_MEMORY_H 1
58 #define HAVE_SETJMP_H 1
59 #define HAVE_SIGNAL_H 1
60 #define HAVE_STDARG_H 1
61 #define HAVE_STDDEF_H 1
62 #define HAVE_STDIO_H 1
63 #define HAVE_STDLIB_H 1
64 #define HAVE_STRING_H 1
65 #define HAVE_TIME_H 1
66 #define HAVE_UNISTD_H 1
67 #define HAVE_UTIME_H 1
68 #define HAVE_SYS_STAT_H 1
69 #define HAVE_SYS_TIME_H 1
70 #define HAVE_SYS_TYPES_H 1
71 #if (LZO_OS_POSIX)
72 #  if (LZO_OS_POSIX_AIX)
73 #    define HAVE_SYS_RESOURCE_H 1
74 #  elif (LZO_OS_POSIX_FREEBSD || LZO_OS_POSIX_MACOSX || LZO_OS_POSIX_NETBSD || LZO_OS_POSIX_OPENBSD)
75 #    define HAVE_STRINGS_H 1
76 #    undef HAVE_MALLOC_H
77 #  elif (LZO_OS_POSIX_HPUX || LZO_OS_POSIX_INTERIX)
78 #    define HAVE_ALLOCA_H 1
79 #  elif (LZO_OS_POSIX_MACOSX && LZO_LIBC_MSL)
80 #    undef HAVE_SYS_TIME_H
81 #    undef HAVE_SYS_TYPES_H
82 #  elif (LZO_OS_POSIX_SOLARIS || LZO_OS_POSIX_SUNOS)
83 #    define HAVE_ALLOCA_H 1
84 #  endif
85 #  if (LZO_LIBC_DIETLIBC || LZO_LIBC_GLIBC || LZO_LIBC_UCLIBC)
86 #    define HAVE_STRINGS_H 1
87 #    define HAVE_SYS_MMAN_H 1
88 #    define HAVE_SYS_RESOURCE_H 1
89 #    define HAVE_SYS_WAIT_H 1
90 #  endif
91 #  if (LZO_LIBC_NEWLIB)
92 #    undef HAVE_STRINGS_H
93 #  endif
94 #elif (LZO_OS_CYGWIN)
95 #  define HAVE_IO_H 1
96 #elif (LZO_OS_EMX)
97 #  define HAVE_ALLOCA_H 1
98 #  define HAVE_IO_H 1
99 #elif (LZO_ARCH_M68K && LZO_OS_TOS && LZO_CC_GNUC)
100 #  if !defined(__MINT__)
101 #    undef HAVE_MALLOC_H
102 #  endif
103 #elif (LZO_ARCH_M68K && LZO_OS_TOS && (LZO_CC_PUREC || LZO_CC_TURBOC))
104 #  undef HAVE_DIRENT_H
105 #  undef HAVE_FCNTL_H
106 #  undef HAVE_MALLOC_H
107 #  undef HAVE_MEMORY_H
108 #  undef HAVE_UNISTD_H
109 #  undef HAVE_UTIME_H
110 #  undef HAVE_SYS_STAT_H
111 #  undef HAVE_SYS_TIME_H
112 #  undef HAVE_SYS_TYPES_H
113 #endif
114 #if (LZO_OS_DOS16 || LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_OS216 || LZO_OS_WIN16 || LZO_OS_WIN32 || LZO_OS_WIN64)
115 #define HAVE_CONIO_H 1
116 #define HAVE_DIRECT_H 1
117 #define HAVE_DOS_H 1
118 #define HAVE_IO_H 1
119 #define HAVE_SHARE_H 1
120 #if (LZO_CC_AZTECC)
121 #  undef HAVE_CONIO_H
122 #  undef HAVE_DIRECT_H
123 #  undef HAVE_DIRENT_H
124 #  undef HAVE_MALLOC_H
125 #  undef HAVE_SHARE_H
126 #  undef HAVE_UNISTD_H
127 #  undef HAVE_UTIME_H
128 #  undef HAVE_SYS_STAT_H
129 #  undef HAVE_SYS_TIME_H
130 #  undef HAVE_SYS_TYPES_H
131 #elif (LZO_CC_BORLANDC)
132 #  undef HAVE_UNISTD_H
133 #  undef HAVE_SYS_TIME_H
134 #  if (LZO_OS_WIN32 || LZO_OS_WIN64)
135 #    undef HAVE_DIRENT_H
136 #  endif
137 #  if (__BORLANDC__ < 0x0400)
138 #    undef HAVE_DIRENT_H
139 #    undef HAVE_UTIME_H
140 #  endif
141 #elif (LZO_CC_DMC)
142 #  undef HAVE_DIRENT_H
143 #  undef HAVE_UNISTD_H
144 #  define HAVE_SYS_DIRENT_H 1
145 #elif (LZO_OS_DOS32 && LZO_CC_GNUC) && defined(__DJGPP__)
146 #elif (LZO_OS_DOS32 && LZO_CC_HIGHC)
147 #  define HAVE_ALLOCA_H 1
148 #  undef HAVE_DIRENT_H
149 #  undef HAVE_UNISTD_H
150 #elif (LZO_CC_IBMC && LZO_OS_OS2)
151 #  undef HAVE_DOS_H
152 #  undef HAVE_DIRENT_H
153 #  undef HAVE_UNISTD_H
154 #  undef HAVE_UTIME_H
155 #  undef HAVE_SYS_TIME_H
156 #  define HAVE_SYS_UTIME_H 1
157 #elif (LZO_CC_GHS || LZO_CC_INTELC || LZO_CC_MSC)
158 #  undef HAVE_DIRENT_H
159 #  undef HAVE_UNISTD_H
160 #  undef HAVE_UTIME_H
161 #  undef HAVE_SYS_TIME_H
162 #  define HAVE_SYS_UTIME_H 1
163 #elif (LZO_CC_LCCWIN32)
164 #  undef HAVE_DIRENT_H
165 #  undef HAVE_DOS_H
166 #  undef HAVE_UNISTD_H
167 #  undef HAVE_SYS_TIME_H
168 #elif (LZO_OS_WIN32 && LZO_CC_GNUC) && defined(__MINGW32__)
169 #  undef HAVE_UTIME_H
170 #  define HAVE_SYS_UTIME_H 1
171 #elif (LZO_OS_WIN32 && LZO_LIBC_MSL)
172 #  define HAVE_ALLOCA_H 1
173 #  undef HAVE_DOS_H
174 #  undef HAVE_SHARE_H
175 #  undef HAVE_SYS_TIME_H
176 #elif (LZO_CC_NDPC)
177 #  undef HAVE_DIRENT_H
178 #  undef HAVE_DOS_H
179 #  undef HAVE_UNISTD_H
180 #  undef HAVE_UTIME_H
181 #  undef HAVE_SYS_TIME_H
182 #elif (LZO_CC_PACIFICC)
183 #  undef HAVE_DIRECT_H
184 #  undef HAVE_DIRENT_H
185 #  undef HAVE_FCNTL_H
186 #  undef HAVE_IO_H
187 #  undef HAVE_MALLOC_H
188 #  undef HAVE_MEMORY_H
189 #  undef HAVE_SHARE_H
190 #  undef HAVE_UNISTD_H
191 #  undef HAVE_UTIME_H
192 #  undef HAVE_SYS_STAT_H
193 #  undef HAVE_SYS_TIME_H
194 #  undef HAVE_SYS_TYPES_H
195 #elif (LZO_OS_WIN32 && LZO_CC_PELLESC)
196 #  undef HAVE_DIRENT_H
197 #  undef HAVE_DOS_H
198 #  undef HAVE_MALLOC_H
199 #  undef HAVE_SHARE_H
200 #  undef HAVE_UNISTD_H
201 #  undef HAVE_UTIME_H
202 #  undef HAVE_SYS_TIME_H
203 #  if (__POCC__ < 280)
204 #  else
205 #    define HAVE_SYS_UTIME_H 1
206 #  endif
207 #elif (LZO_OS_WIN32 && LZO_CC_PGI) && defined(__MINGW32__)
208 #  undef HAVE_UTIME_H
209 #  define HAVE_SYS_UTIME_H 1
210 #elif (LZO_OS_WIN32 && LZO_CC_GNUC) && defined(__PW32__)
211 #elif (LZO_CC_SYMANTECC)
212 #  undef HAVE_DIRENT_H
213 #  undef HAVE_UNISTD_H
214 #  if (__SC__ < 0x700)
215 #    undef HAVE_UTIME_H
216 #    undef HAVE_SYS_TIME_H
217 #  endif
218 #elif (LZO_CC_TOPSPEEDC)
219 #  undef HAVE_DIRENT_H
220 #  undef HAVE_UNISTD_H
221 #  undef HAVE_UTIME_H
222 #  undef HAVE_SYS_STAT_H
223 #  undef HAVE_SYS_TIME_H
224 #  undef HAVE_SYS_TYPES_H
225 #elif (LZO_CC_TURBOC)
226 #  undef HAVE_UNISTD_H
227 #  undef HAVE_SYS_TIME_H
228 #  undef HAVE_SYS_TYPES_H
229 #  if (LZO_OS_WIN32 || LZO_OS_WIN64)
230 #    undef HAVE_DIRENT_H
231 #  endif
232 #  if (__TURBOC__ < 0x0200)
233 #    undef HAVE_SIGNAL_H
234 #  endif
235 #  if (__TURBOC__ < 0x0400)
236 #    undef HAVE_DIRECT_H
237 #    undef HAVE_DIRENT_H
238 #    undef HAVE_MALLOC_H
239 #    undef HAVE_MEMORY_H
240 #    undef HAVE_UTIME_H
241 #  endif
242 #elif (LZO_CC_WATCOMC)
243 #  undef HAVE_DIRENT_H
244 #  undef HAVE_UTIME_H
245 #  undef HAVE_SYS_TIME_H
246 #  define HAVE_SYS_UTIME_H 1
247 #  if (__WATCOMC__ < 950)
248 #    undef HAVE_UNISTD_H
249 #  endif
250 #elif (LZO_CC_ZORTECHC)
251 #  undef HAVE_DIRENT_H
252 #  undef HAVE_MEMORY_H
253 #  undef HAVE_UNISTD_H
254 #  undef HAVE_UTIME_H
255 #  undef HAVE_SYS_TIME_H
256 #endif
257 #endif
258 #if (LZO_OS_CONSOLE)
259 #  undef HAVE_DIRENT_H
260 #endif
261 #if (LZO_OS_EMBEDDED)
262 #  undef HAVE_DIRENT_H
263 #endif
264 #if (LZO_LIBC_ISOC90 || LZO_LIBC_ISOC99)
265 #  undef HAVE_DIRENT_H
266 #  undef HAVE_FCNTL_H
267 #  undef HAVE_MALLOC_H
268 #  undef HAVE_UNISTD_H
269 #  undef HAVE_UTIME_H
270 #  undef HAVE_SYS_STAT_H
271 #  undef HAVE_SYS_TIME_H
272 #  undef HAVE_SYS_TYPES_H
273 #endif
274 #if (LZO_LIBC_GLIBC >= 0x020100ul)
275 #  define HAVE_STDINT_H 1
276 #elif (LZO_LIBC_DIETLIBC)
277 #  undef HAVE_STDINT_H
278 #elif (LZO_LIBC_UCLIBC)
279 #  define HAVE_STDINT_H 1
280 #elif (LZO_CC_BORLANDC) && (__BORLANDC__ >= 0x560)
281 #  undef HAVE_STDINT_H
282 #elif (LZO_CC_DMC) && (__DMC__ >= 0x825)
283 #  define HAVE_STDINT_H 1
284 #endif
285 #if (HAVE_SYS_TIME_H && HAVE_TIME_H)
286 #  define TIME_WITH_SYS_TIME 1
287 #endif
288 #endif
289 #endif
290 #if !(LZO_CFG_AUTO_NO_FUNCTIONS)
291 #if (LZO_LIBC_NAKED)
292 #elif (LZO_LIBC_FREESTANDING)
293 #elif (LZO_LIBC_MOSTLY_FREESTANDING)
294 #  define HAVE_LONGJMP 1
295 #  define HAVE_MEMCMP 1
296 #  define HAVE_MEMCPY 1
297 #  define HAVE_MEMMOVE 1
298 #  define HAVE_MEMSET 1
299 #  define HAVE_SETJMP 1
300 #else
301 #define HAVE_ACCESS 1
302 #define HAVE_ALLOCA 1
303 #define HAVE_ATEXIT 1
304 #define HAVE_ATOI 1
305 #define HAVE_ATOL 1
306 #define HAVE_CHMOD 1
307 #define HAVE_CHOWN 1
308 #define HAVE_CTIME 1
309 #define HAVE_DIFFTIME 1
310 #define HAVE_FILENO 1
311 #define HAVE_FSTAT 1
312 #define HAVE_GETENV 1
313 #define HAVE_GETTIMEOFDAY 1
314 #define HAVE_GMTIME 1
315 #define HAVE_ISATTY 1
316 #define HAVE_LOCALTIME 1
317 #define HAVE_LONGJMP 1
318 #define HAVE_LSTAT 1
319 #define HAVE_MEMCMP 1
320 #define HAVE_MEMCPY 1
321 #define HAVE_MEMMOVE 1
322 #define HAVE_MEMSET 1
323 #define HAVE_MKDIR 1
324 #define HAVE_MKTIME 1
325 #define HAVE_QSORT 1
326 #define HAVE_RAISE 1
327 #define HAVE_RMDIR 1
328 #define HAVE_SETJMP 1
329 #define HAVE_SIGNAL 1
330 #define HAVE_SNPRINTF 1
331 #define HAVE_STAT 1
332 #define HAVE_STRCHR 1
333 #define HAVE_STRDUP 1
334 #define HAVE_STRERROR 1
335 #define HAVE_STRFTIME 1
336 #define HAVE_STRRCHR 1
337 #define HAVE_STRSTR 1
338 #define HAVE_TIME 1
339 #define HAVE_UMASK 1
340 #define HAVE_UTIME 1
341 #define HAVE_VSNPRINTF 1
342 #if (LZO_OS_BEOS || LZO_OS_CYGWIN || LZO_OS_POSIX || LZO_OS_QNX || LZO_OS_VMS)
343 #  define HAVE_STRCASECMP 1
344 #  define HAVE_STRNCASECMP 1
345 #elif (LZO_OS_WIN32 && LZO_CC_GNUC) && defined(__PW32__)
346 #  define HAVE_STRCASECMP 1
347 #  define HAVE_STRNCASECMP 1
348 #else
349 #  define HAVE_STRICMP 1
350 #  define HAVE_STRNICMP 1
351 #endif
352 #if (LZO_OS_POSIX)
353 #  if (LZO_OS_POSIX_AIX)
354 #    define HAVE_GETRUSAGE 1
355 #  elif (LZO_OS_POSIX_MACOSX && LZO_LIBC_MSL)
356 #    undef HAVE_CHOWN
357 #    undef HAVE_LSTAT
358 #  elif (LZO_OS_POSIX_UNICOS)
359 #    undef HAVE_ALLOCA
360 #    undef HAVE_SNPRINTF
361 #    undef HAVE_VSNPRINTF
362 #  endif
363 #  if (LZO_CC_TINYC)
364 #    undef HAVE_ALLOCA
365 #  endif
366 #  if (LZO_LIBC_DIETLIBC || LZO_LIBC_GLIBC || LZO_LIBC_UCLIBC)
367 #    define HAVE_GETRUSAGE 1
368 #    define HAVE_GETPAGESIZE 1
369 #    define HAVE_MMAP 1
370 #    define HAVE_MPROTECT 1
371 #    define HAVE_MUNMAP 1
372 #  endif
373 #elif (LZO_OS_CYGWIN)
374 #  if (LZO_CC_GNUC < 0x025a00ul)
375 #    undef HAVE_GETTIMEOFDAY
376 #    undef HAVE_LSTAT
377 #  endif
378 #  if (LZO_CC_GNUC < 0x025f00ul)
379 #    undef HAVE_SNPRINTF
380 #    undef HAVE_VSNPRINTF
381 #  endif
382 #elif (LZO_OS_EMX)
383 #  undef HAVE_CHOWN
384 #  undef HAVE_LSTAT
385 #elif (LZO_ARCH_M68K && LZO_OS_TOS && LZO_CC_GNUC)
386 #  if !defined(__MINT__)
387 #    undef HAVE_SNPRINTF
388 #    undef HAVE_VSNPRINTF
389 #  endif
390 #elif (LZO_ARCH_M68K && LZO_OS_TOS && (LZO_CC_PUREC || LZO_CC_TURBOC))
391 #  undef HAVE_ALLOCA
392 #  undef HAVE_ACCESS
393 #  undef HAVE_CHMOD
394 #  undef HAVE_CHOWN
395 #  undef HAVE_FSTAT
396 #  undef HAVE_GETTIMEOFDAY
397 #  undef HAVE_LSTAT
398 #  undef HAVE_SNPRINTF
399 #  undef HAVE_UMASK
400 #  undef HAVE_UTIME
401 #  undef HAVE_VSNPRINTF
402 #endif
403 #if (LZO_OS_DOS16 || LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_OS216 || LZO_OS_WIN16 || LZO_OS_WIN32 || LZO_OS_WIN64)
404 #undef HAVE_CHOWN
405 #undef HAVE_GETTIMEOFDAY
406 #undef HAVE_LSTAT
407 #undef HAVE_UMASK
408 #if (LZO_CC_AZTECC)
409 #  undef HAVE_ALLOCA
410 #  undef HAVE_DIFFTIME
411 #  undef HAVE_FSTAT
412 #  undef HAVE_STRDUP
413 #  undef HAVE_SNPRINTF
414 #  undef HAVE_UTIME
415 #  undef HAVE_VSNPRINTF
416 #elif (LZO_CC_BORLANDC)
417 #  if (__BORLANDC__ < 0x0400)
418 #    undef HAVE_ALLOCA
419 #    undef HAVE_UTIME
420 #  endif
421 #  if ((__BORLANDC__ < 0x0410) && LZO_OS_WIN16)
422 #    undef HAVE_ALLOCA
423 #  endif
424 #  if (__BORLANDC__ < 0x0550)
425 #    undef HAVE_SNPRINTF
426 #    undef HAVE_VSNPRINTF
427 #  endif
428 #elif (LZO_CC_DMC)
429 #  if (LZO_OS_WIN16)
430 #    undef HAVE_ALLOCA
431 #  endif
432 #  define snprintf _snprintf
433 #  define vsnprintf _vsnprintf
434 #elif (LZO_OS_DOS32 && LZO_CC_GNUC) && defined(__DJGPP__)
435 #  undef HAVE_SNPRINTF
436 #  undef HAVE_VSNPRINTF
437 #elif (LZO_OS_DOS32 && LZO_CC_HIGHC)
438 #  undef HAVE_SNPRINTF
439 #  undef HAVE_VSNPRINTF
440 #elif (LZO_CC_GHS)
441 #  undef HAVE_ALLOCA
442 #  ifndef snprintf
443 #  define snprintf _snprintf
444 #  endif
445 #  ifndef vsnprintf
446 #  define vsnprintf _vsnprintf
447 #  endif
448 #elif (LZO_CC_IBMC)
449 #  undef HAVE_SNPRINTF
450 #  undef HAVE_VSNPRINTF
451 #elif (LZO_CC_INTELC)
452 #  ifndef snprintf
453 #  define snprintf _snprintf
454 #  endif
455 #  ifndef vsnprintf
456 #  define vsnprintf _vsnprintf
457 #  endif
458 #elif (LZO_CC_LCCWIN32)
459 #  define utime _utime
460 #elif (LZO_CC_MSC)
461 #  if (_MSC_VER < 600)
462 #    undef HAVE_STRFTIME
463 #  endif
464 #  if (_MSC_VER < 700)
465 #    undef HAVE_SNPRINTF
466 #    undef HAVE_VSNPRINTF
467 #  elif (_MSC_VER < 1500)
468 #    ifndef snprintf
469 #    define snprintf _snprintf
470 #    endif
471 #    ifndef vsnprintf
472 #    define vsnprintf _vsnprintf
473 #    endif
474 #  else
475 #    ifndef snprintf
476 #    define snprintf _snprintf
477 #    endif
478 #  endif
479 #  if ((_MSC_VER < 800) && LZO_OS_WIN16)
480 #    undef HAVE_ALLOCA
481 #  endif
482 #  if (LZO_ARCH_I086) && defined(__cplusplus)
483 #    undef HAVE_LONGJMP
484 #    undef HAVE_SETJMP
485 #  endif
486 #elif (LZO_OS_WIN32 && LZO_CC_GNUC) && defined(__MINGW32__)
487 #  if (LZO_CC_GNUC < 0x025f00ul)
488 #    undef HAVE_SNPRINTF
489 #    undef HAVE_VSNPRINTF
490 #  else
491 #    define snprintf _snprintf
492 #    define vsnprintf _vsnprintf
493 #  endif
494 #elif (LZO_OS_WIN32 && LZO_LIBC_MSL)
495 #  if (__MSL__ < 0x8000ul)
496 #    undef HAVE_CHMOD
497 #  endif
498 #elif (LZO_CC_NDPC)
499 #  undef HAVE_ALLOCA
500 #  undef HAVE_SNPRINTF
501 #  undef HAVE_STRNICMP
502 #  undef HAVE_UTIME
503 #  undef HAVE_VSNPRINTF
504 #  if defined(__cplusplus)
505 #    undef HAVE_STAT
506 #  endif
507 #elif (LZO_CC_PACIFICC)
508 #  undef HAVE_ACCESS
509 #  undef HAVE_ALLOCA
510 #  undef HAVE_CHMOD
511 #  undef HAVE_DIFFTIME
512 #  undef HAVE_FSTAT
513 #  undef HAVE_MKTIME
514 #  undef HAVE_RAISE
515 #  undef HAVE_SNPRINTF
516 #  undef HAVE_STRFTIME
517 #  undef HAVE_UTIME
518 #  undef HAVE_VSNPRINTF
519 #elif (LZO_OS_WIN32 && LZO_CC_PELLESC)
520 #  if (__POCC__ < 280)
521 #    define alloca _alloca
522 #    undef HAVE_UTIME
523 #  endif
524 #elif (LZO_OS_WIN32 && LZO_CC_PGI) && defined(__MINGW32__)
525 #  define snprintf _snprintf
526 #  define vsnprintf _vsnprintf
527 #elif (LZO_OS_WIN32 && LZO_CC_GNUC) && defined(__PW32__)
528 #  undef HAVE_SNPRINTF
529 #  undef HAVE_VSNPRINTF
530 #elif (LZO_CC_SYMANTECC)
531 #  if (LZO_OS_WIN16 && (LZO_MM_MEDIUM || LZO_MM_LARGE || LZO_MM_HUGE))
532 #    undef HAVE_ALLOCA
533 #  endif
534 #  if (__SC__ < 0x600)
535 #    undef HAVE_SNPRINTF
536 #    undef HAVE_VSNPRINTF
537 #  else
538 #    define snprintf _snprintf
539 #    define vsnprintf _vsnprintf
540 #  endif
541 #  if (__SC__ < 0x700)
542 #    undef HAVE_DIFFTIME
543 #    undef HAVE_UTIME
544 #  endif
545 #elif (LZO_CC_TOPSPEEDC)
546 #  undef HAVE_SNPRINTF
547 #  undef HAVE_VSNPRINTF
548 #elif (LZO_CC_TURBOC)
549 #  undef HAVE_ALLOCA
550 #  undef HAVE_SNPRINTF
551 #  undef HAVE_VSNPRINTF
552 #  if (__TURBOC__ < 0x0200)
553 #    undef HAVE_RAISE
554 #    undef HAVE_SIGNAL
555 #  endif
556 #  if (__TURBOC__ < 0x0295)
557 #    undef HAVE_MKTIME
558 #    undef HAVE_STRFTIME
559 #  endif
560 #  if (__TURBOC__ < 0x0400)
561 #    undef HAVE_UTIME
562 #  endif
563 #elif (LZO_CC_WATCOMC)
564 #  if (__WATCOMC__ < 1100)
565 #    undef HAVE_SNPRINTF
566 #    undef HAVE_VSNPRINTF
567 #  elif (__WATCOMC__ < 1200)
568 #    define snprintf _snprintf
569 #    define vsnprintf _vsnprintf
570 #  endif
571 #elif (LZO_CC_ZORTECHC)
572 #  if (LZO_OS_WIN16 && (LZO_MM_MEDIUM || LZO_MM_LARGE || LZO_MM_HUGE))
573 #    undef HAVE_ALLOCA
574 #  endif
575 #  undef HAVE_DIFFTIME
576 #  undef HAVE_SNPRINTF
577 #  undef HAVE_UTIME
578 #  undef HAVE_VSNPRINTF
579 #endif
580 #endif
581 #if (LZO_OS_CONSOLE)
582 #  undef HAVE_ACCESS
583 #  undef HAVE_CHMOD
584 #  undef HAVE_CHOWN
585 #  undef HAVE_GETTIMEOFDAY
586 #  undef HAVE_LSTAT
587 #  undef HAVE_TIME
588 #  undef HAVE_UMASK
589 #  undef HAVE_UTIME
590 #endif
591 #if (LZO_LIBC_ISOC90 || LZO_LIBC_ISOC99)
592 #  undef HAVE_ACCESS
593 #  undef HAVE_CHMOD
594 #  undef HAVE_CHOWN
595 #  undef HAVE_FILENO
596 #  undef HAVE_FSTAT
597 #  undef HAVE_GETTIMEOFDAY
598 #  undef HAVE_LSTAT
599 #  undef HAVE_STAT
600 #  undef HAVE_UMASK
601 #  undef HAVE_UTIME
602 # if 1
603 #  undef HAVE_ALLOCA
604 #  undef HAVE_ISATTY
605 #  undef HAVE_MKDIR
606 #  undef HAVE_RMDIR
607 #  undef HAVE_STRDUP
608 #  undef HAVE_STRICMP
609 #  undef HAVE_STRNICMP
610 # endif
611 #endif
612 #endif
613 #endif
614 #if !(LZO_CFG_AUTO_NO_SIZES)
615 #if !defined(SIZEOF_SHORT) && defined(LZO_SIZEOF_SHORT)
616 #  define SIZEOF_SHORT          LZO_SIZEOF_SHORT
617 #endif
618 #if !defined(SIZEOF_INT) && defined(LZO_SIZEOF_INT)
619 #  define SIZEOF_INT            LZO_SIZEOF_INT
620 #endif
621 #if !defined(SIZEOF_LONG) && defined(LZO_SIZEOF_LONG)
622 #  define SIZEOF_LONG           LZO_SIZEOF_LONG
623 #endif
624 #if !defined(SIZEOF_LONG_LONG) && defined(LZO_SIZEOF_LONG_LONG)
625 #  define SIZEOF_LONG_LONG      LZO_SIZEOF_LONG_LONG
626 #endif
627 #if !defined(SIZEOF___INT32) && defined(LZO_SIZEOF___INT32)
628 #  define SIZEOF___INT32        LZO_SIZEOF___INT32
629 #endif
630 #if !defined(SIZEOF___INT64) && defined(LZO_SIZEOF___INT64)
631 #  define SIZEOF___INT64        LZO_SIZEOF___INT64
632 #endif
633 #if !defined(SIZEOF_VOID_P) && defined(LZO_SIZEOF_VOID_P)
634 #  define SIZEOF_VOID_P         LZO_SIZEOF_VOID_P
635 #endif
636 #if !defined(SIZEOF_SIZE_T) && defined(LZO_SIZEOF_SIZE_T)
637 #  define SIZEOF_SIZE_T         LZO_SIZEOF_SIZE_T
638 #endif
639 #if !defined(SIZEOF_PTRDIFF_T) && defined(LZO_SIZEOF_PTRDIFF_T)
640 #  define SIZEOF_PTRDIFF_T      LZO_SIZEOF_PTRDIFF_T
641 #endif
642 #endif
643 #if (HAVE_SIGNAL) && !defined(RETSIGTYPE)
644 #  define RETSIGTYPE void
645 #endif
646 #endif
647 #if !(LZO_CFG_SKIP_LZO_TYPES)
648 #if 1 && !defined(lzo_signo_t) && defined(__linux__) && defined(__dietlibc__) && (LZO_SIZEOF_INT != 4)
649 #  define lzo_signo_t               lzo_int32e_t
650 #endif
651 #if !defined(lzo_signo_t)
652 #  define lzo_signo_t               int
653 #endif
654 #if defined(__cplusplus)
655 extern "C" {
656 #endif
657 #if (LZO_BROKEN_CDECL_ALT_SYNTAX)
658 typedef void __lzo_cdecl_sighandler (*lzo_sighandler_t)(lzo_signo_t);
659 #elif defined(RETSIGTYPE)
660 typedef RETSIGTYPE (__lzo_cdecl_sighandler *lzo_sighandler_t)(lzo_signo_t);
661 #else
662 typedef void (__lzo_cdecl_sighandler *lzo_sighandler_t)(lzo_signo_t);
663 #endif
664 #if defined(__cplusplus)
665 }
666 #endif
667 #endif
668 #endif
669 #if defined(LZO_WANT_ACC_INCD_H)
670 #  undef LZO_WANT_ACC_INCD_H
671 #ifndef __LZO_INCD_H_INCLUDED
672 #define __LZO_INCD_H_INCLUDED 1
673 #if (LZO_LIBC_NAKED)
674 #ifndef __LZO_FALLBACK_STDDEF_H_INCLUDED
675 #define __LZO_FALLBACK_STDDEF_H_INCLUDED 1
676 #if defined(__PTRDIFF_TYPE__)
677 typedef __PTRDIFF_TYPE__ lzo_fallback_ptrdiff_t;
678 #elif defined(__MIPS_PSX2__)
679 typedef int lzo_fallback_ptrdiff_t;
680 #else
681 typedef long lzo_fallback_ptrdiff_t;
682 #endif
683 #if defined(__SIZE_TYPE__)
684 typedef __SIZE_TYPE__ lzo_fallback_size_t;
685 #elif defined(__MIPS_PSX2__)
686 typedef unsigned int lzo_fallback_size_t;
687 #else
688 typedef unsigned long lzo_fallback_size_t;
689 #endif
690 #if !defined(ptrdiff_t)
691 typedef lzo_fallback_ptrdiff_t ptrdiff_t;
692 #ifndef _PTRDIFF_T_DEFINED
693 #define _PTRDIFF_T_DEFINED 1
694 #endif
695 #endif
696 #if !defined(size_t)
697 typedef lzo_fallback_size_t size_t;
698 #ifndef _SIZE_T_DEFINED
699 #define _SIZE_T_DEFINED 1
700 #endif
701 #endif
702 #if !defined(__cplusplus) && !defined(wchar_t)
703 typedef unsigned short wchar_t;
704 #ifndef _WCHAR_T_DEFINED
705 #define _WCHAR_T_DEFINED 1
706 #endif
707 #endif
708 #ifndef NULL
709 #if defined(__cplusplus) && defined(__GNUC__) && (__GNUC__ >= 4)
710 #define NULL    __null
711 #elif defined(__cplusplus)
712 #define NULL    0
713 #else
714 #define NULL    ((void*)0)
715 #endif
716 #endif
717 #ifndef offsetof
718 #define offsetof(s,m)   ((size_t)((ptrdiff_t)&(((s*)0)->m)))
719 #endif
720 #endif
721 #elif (LZO_LIBC_FREESTANDING)
722 # if defined(HAVE_STDDEF_H) && (HAVE_STDDEF_H+0)
723 #  include <stddef.h>
724 # endif
725 # if defined(HAVE_STDINT_H) && (HAVE_STDINT_H+0)
726 #  include <stdint.h>
727 # endif
728 #elif (LZO_LIBC_MOSTLY_FREESTANDING)
729 # if defined(HAVE_STDIO_H) && (HAVE_STDIO_H+0)
730 #  include <stdio.h>
731 # endif
732 # if defined(HAVE_STDDEF_H) && (HAVE_STDDEF_H+0)
733 #  include <stddef.h>
734 # endif
735 # if defined(HAVE_STDINT_H) && (HAVE_STDINT_H+0)
736 #  include <stdint.h>
737 # endif
738 #else
739 #include <stdio.h>
740 #if defined(HAVE_TIME_H) && (HAVE_TIME_H+0) && defined(__MSL__) && defined(__cplusplus)
741 # include <time.h>
742 #endif
743 #if defined(HAVE_SYS_TYPES_H) && (HAVE_SYS_TYPES_H+0)
744 # include <sys/types.h>
745 #endif
746 #if defined(HAVE_SYS_STAT_H) && (HAVE_SYS_STAT_H+0)
747 # include <sys/stat.h>
748 #endif
749 #if defined(STDC_HEADERS) && (STDC_HEADERS+0)
750 # include <stdlib.h>
751 #elif defined(HAVE_STDLIB_H) && (HAVE_STDLIB_H+0)
752 # include <stdlib.h>
753 #endif
754 #include <stddef.h>
755 #if defined(HAVE_STRING_H) && (HAVE_STRING_H+0)
756 # if defined(STDC_HEADERS) && (STDC_HEADERS+0)
757 # elif defined(HAVE_MEMORY_H) && (HAVE_MEMORY_H+0)
758 #  include <memory.h>
759 # endif
760 # include <string.h>
761 #endif
762 #if defined(HAVE_STRINGS_H) && (HAVE_STRINGS_H+0)
763 # include <strings.h>
764 #endif
765 #if defined(HAVE_INTTYPES_H) && (HAVE_INTTYPES_H+0)
766 # include <inttypes.h>
767 #endif
768 #if defined(HAVE_STDINT_H) && (HAVE_STDINT_H+0)
769 # include <stdint.h>
770 #endif
771 #if defined(HAVE_UNISTD_H) && (HAVE_UNISTD_H+0)
772 # include <unistd.h>
773 #endif
774 #endif
775 #endif
776 #endif
777 #if defined(LZO_WANT_ACC_INCE_H)
778 #  undef LZO_WANT_ACC_INCE_H
779 #ifndef __LZO_INCE_H_INCLUDED
780 #define __LZO_INCE_H_INCLUDED 1
781 #if (LZO_LIBC_NAKED)
782 #elif (LZO_LIBC_FREESTANDING)
783 #elif (LZO_LIBC_MOSTLY_FREESTANDING)
784 #  if (HAVE_SETJMP_H)
785 #    include <setjmp.h>
786 #  endif
787 #else
788 #if (HAVE_STDARG_H)
789 #  include <stdarg.h>
790 #endif
791 #if (HAVE_CTYPE_H)
792 #  include <ctype.h>
793 #endif
794 #if (HAVE_ERRNO_H)
795 #  include <errno.h>
796 #endif
797 #if (HAVE_MALLOC_H)
798 #  include <malloc.h>
799 #endif
800 #if (HAVE_ALLOCA_H)
801 #  include <alloca.h>
802 #endif
803 #if (HAVE_FCNTL_H)
804 #  include <fcntl.h>
805 #endif
806 #if (HAVE_DIRENT_H)
807 #  include <dirent.h>
808 #endif
809 #if (HAVE_SETJMP_H)
810 #  include <setjmp.h>
811 #endif
812 #if (HAVE_SIGNAL_H)
813 #  include <signal.h>
814 #endif
815 #if (TIME_WITH_SYS_TIME)
816 #  include <sys/time.h>
817 #  include <time.h>
818 #elif (HAVE_TIME_H)
819 #  include <time.h>
820 #endif
821 #if (HAVE_UTIME_H)
822 #  include <utime.h>
823 #elif (HAVE_SYS_UTIME_H)
824 #  include <sys/utime.h>
825 #endif
826 #if (HAVE_IO_H)
827 #  include <io.h>
828 #endif
829 #if (HAVE_DOS_H)
830 #  include <dos.h>
831 #endif
832 #if (HAVE_DIRECT_H)
833 #  include <direct.h>
834 #endif
835 #if (HAVE_SHARE_H)
836 #  include <share.h>
837 #endif
838 #if (LZO_CC_NDPC)
839 #  include <os.h>
840 #endif
841 #if defined(__TOS__) && (defined(__PUREC__) || defined(__TURBOC__))
842 #  include <ext.h>
843 #endif
844 #endif
845 #endif
846 #endif
847 #if defined(LZO_WANT_ACC_INCI_H)
848 #  undef LZO_WANT_ACC_INCI_H
849 #ifndef __LZO_INCI_H_INCLUDED
850 #define __LZO_INCI_H_INCLUDED 1
851 #if (LZO_LIBC_NAKED)
852 #elif (LZO_LIBC_FREESTANDING)
853 #elif (LZO_LIBC_MOSTLY_FREESTANDING)
854 #else
855 #if (LZO_OS_TOS && (LZO_CC_PUREC || LZO_CC_TURBOC))
856 #  include <tos.h>
857 #elif (LZO_HAVE_WINDOWS_H)
858 #  if 1 && !defined(WIN32_LEAN_AND_MEAN)
859 #    define WIN32_LEAN_AND_MEAN 1
860 #  endif
861 #  if 1 && !defined(_WIN32_WINNT)
862 #    define _WIN32_WINNT 0x0400
863 #  endif
864 #  include <windows.h>
865 #  if (LZO_CC_BORLANDC || LZO_CC_TURBOC)
866 #    include <dir.h>
867 #  endif
868 #elif (LZO_OS_DOS16 || LZO_OS_DOS32 || LZO_OS_WIN16)
869 #  if (LZO_CC_AZTECC)
870 #    include <model.h>
871 #    include <stat.h>
872 #  elif (LZO_CC_BORLANDC || LZO_CC_TURBOC)
873 #    include <alloc.h>
874 #    include <dir.h>
875 #  elif (LZO_OS_DOS32 && LZO_CC_GNUC) && defined(__DJGPP__)
876 #    include <sys/exceptn.h>
877 #  elif (LZO_CC_PACIFICC)
878 #    include <unixio.h>
879 #    include <stat.h>
880 #    include <sys.h>
881 #  elif (LZO_CC_WATCOMC)
882 #    include <i86.h>
883 #  endif
884 #elif (LZO_OS_OS216)
885 #  if (LZO_CC_WATCOMC)
886 #    include <i86.h>
887 #  endif
888 #endif
889 #if (HAVE_SYS_MMAN_H)
890 #  include <sys/mman.h>
891 #endif
892 #if (HAVE_SYS_RESOURCE_H)
893 #  include <sys/resource.h>
894 #endif
895 #if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16)
896 #  if defined(FP_OFF)
897 #    define LZO_PTR_FP_OFF(x)   FP_OFF(x)
898 #  elif defined(_FP_OFF)
899 #    define LZO_PTR_FP_OFF(x)   _FP_OFF(x)
900 #  else
901 #    define LZO_PTR_FP_OFF(x)   (((const unsigned __far*)&(x))[0])
902 #  endif
903 #  if defined(FP_SEG)
904 #    define LZO_PTR_FP_SEG(x)   FP_SEG(x)
905 #  elif defined(_FP_SEG)
906 #    define LZO_PTR_FP_SEG(x)   _FP_SEG(x)
907 #  else
908 #    define LZO_PTR_FP_SEG(x)   (((const unsigned __far*)&(x))[1])
909 #  endif
910 #  if defined(MK_FP)
911 #    define LZO_PTR_MK_FP(s,o)  MK_FP(s,o)
912 #  elif defined(_MK_FP)
913 #    define LZO_PTR_MK_FP(s,o)  _MK_FP(s,o)
914 #  else
915 #    define LZO_PTR_MK_FP(s,o)  ((void __far*)(((unsigned long)(s)<<16)+(unsigned)(o)))
916 #  endif
917 #  if 0
918 #    undef LZO_PTR_FP_OFF
919 #    undef LZO_PTR_FP_SEG
920 #    undef LZO_PTR_MK_FP
921 #    define LZO_PTR_FP_OFF(x)   (((const unsigned __far*)&(x))[0])
922 #    define LZO_PTR_FP_SEG(x)   (((const unsigned __far*)&(x))[1])
923 #    define LZO_PTR_MK_FP(s,o)  ((void __far*)(((unsigned long)(s)<<16)+(unsigned)(o)))
924 #  endif
925 #endif
926 #endif
927 #endif
928 #endif
929 #if defined(LZO_WANT_ACC_LIB_H)
930 #  undef LZO_WANT_ACC_LIB_H
931 #ifndef __LZO_LIB_H_INCLUDED
932 #define __LZO_LIB_H_INCLUDED 1
933 #if !defined(__LZOLIB_FUNCNAME)
934 #  define __LZOLIB_FUNCNAME(f)  f
935 #endif
936 #if !defined(LZOLIB_EXTERN)
937 #  define LZOLIB_EXTERN(r,f)                extern r __LZOLIB_FUNCNAME(f)
938 #endif
939 #if !defined(LZOLIB_EXTERN_NOINLINE)
940 #  if defined(__lzo_noinline)
941 #    define LZOLIB_EXTERN_NOINLINE(r,f)     extern __lzo_noinline r __LZOLIB_FUNCNAME(f)
942 #  else
943 #    define LZOLIB_EXTERN_NOINLINE(r,f)     extern r __LZOLIB_FUNCNAME(f)
944 #  endif
945 #endif
946 #if (LZO_SIZEOF_LONG > LZO_SIZEOF_VOID_P)
947 #  define lzolib_handle_t       long
948 #else
949 #  define lzolib_handle_t       lzo_intptr_t
950 #endif
951 #if 0
952 LZOLIB_EXTERN(int, lzo_ascii_digit)   (int);
953 LZOLIB_EXTERN(int, lzo_ascii_islower) (int);
954 LZOLIB_EXTERN(int, lzo_ascii_isupper) (int);
955 LZOLIB_EXTERN(int, lzo_ascii_tolower) (int);
956 LZOLIB_EXTERN(int, lzo_ascii_toupper) (int);
957 LZOLIB_EXTERN(int, lzo_ascii_utolower) (int);
958 LZOLIB_EXTERN(int, lzo_ascii_utoupper) (int);
959 #endif
960 #define lzo_ascii_isdigit(c)    ((LZO_ICAST(unsigned, c) - 48) < 10)
961 #define lzo_ascii_islower(c)    ((LZO_ICAST(unsigned, c) - 97) < 26)
962 #define lzo_ascii_isupper(c)    ((LZO_ICAST(unsigned, c) - 65) < 26)
963 #define lzo_ascii_tolower(c)    (LZO_ICAST(int, c) + (lzo_ascii_isupper(c) << 5))
964 #define lzo_ascii_toupper(c)    (LZO_ICAST(int, c) - (lzo_ascii_islower(c) << 5))
965 #define lzo_ascii_utolower(c)   lzo_ascii_tolower(LZO_ITRUNC(unsigned char, c))
966 #define lzo_ascii_utoupper(c)   lzo_ascii_toupper(LZO_ITRUNC(unsigned char, c))
967 #ifndef lzo_hsize_t
968 #if (LZO_HAVE_MM_HUGE_PTR)
969 #  define lzo_hsize_t   unsigned long
970 #  define lzo_hvoid_p   void __huge *
971 #  define lzo_hchar_p   char __huge *
972 #  define lzo_hchar_pp  char __huge * __huge *
973 #  define lzo_hbyte_p   unsigned char __huge *
974 #else
975 #  define lzo_hsize_t   size_t
976 #  define lzo_hvoid_p   void *
977 #  define lzo_hchar_p   char *
978 #  define lzo_hchar_pp  char **
979 #  define lzo_hbyte_p   unsigned char *
980 #endif
981 #endif
982 LZOLIB_EXTERN(lzo_hvoid_p, lzo_halloc) (lzo_hsize_t);
983 LZOLIB_EXTERN(void, lzo_hfree) (lzo_hvoid_p);
984 #if (LZO_OS_DOS16 || LZO_OS_OS216)
985 LZOLIB_EXTERN(void __far*, lzo_dos_alloc) (unsigned long);
986 LZOLIB_EXTERN(int, lzo_dos_free) (void __far*);
987 #endif
988 LZOLIB_EXTERN(int, lzo_hmemcmp) (const lzo_hvoid_p, const lzo_hvoid_p, lzo_hsize_t);
989 LZOLIB_EXTERN(lzo_hvoid_p, lzo_hmemcpy) (lzo_hvoid_p, const lzo_hvoid_p, lzo_hsize_t);
990 LZOLIB_EXTERN(lzo_hvoid_p, lzo_hmemmove) (lzo_hvoid_p, const lzo_hvoid_p, lzo_hsize_t);
991 LZOLIB_EXTERN(lzo_hvoid_p, lzo_hmemset) (lzo_hvoid_p, int, lzo_hsize_t);
992 LZOLIB_EXTERN(lzo_hsize_t, lzo_hstrlen) (const lzo_hchar_p);
993 LZOLIB_EXTERN(int, lzo_hstrcmp) (const lzo_hchar_p, const lzo_hchar_p);
994 LZOLIB_EXTERN(int, lzo_hstrncmp)(const lzo_hchar_p, const lzo_hchar_p, lzo_hsize_t);
995 LZOLIB_EXTERN(int, lzo_ascii_hstricmp) (const lzo_hchar_p, const lzo_hchar_p);
996 LZOLIB_EXTERN(int, lzo_ascii_hstrnicmp)(const lzo_hchar_p, const lzo_hchar_p, lzo_hsize_t);
997 LZOLIB_EXTERN(int, lzo_ascii_hmemicmp) (const lzo_hvoid_p, const lzo_hvoid_p, lzo_hsize_t);
998 LZOLIB_EXTERN(lzo_hchar_p, lzo_hstrstr) (const lzo_hchar_p, const lzo_hchar_p);
999 LZOLIB_EXTERN(lzo_hchar_p, lzo_ascii_hstristr) (const lzo_hchar_p, const lzo_hchar_p);
1000 LZOLIB_EXTERN(lzo_hvoid_p, lzo_hmemmem) (const lzo_hvoid_p, lzo_hsize_t, const lzo_hvoid_p, lzo_hsize_t);
1001 LZOLIB_EXTERN(lzo_hvoid_p, lzo_ascii_hmemimem) (const lzo_hvoid_p, lzo_hsize_t, const lzo_hvoid_p, lzo_hsize_t);
1002 LZOLIB_EXTERN(lzo_hchar_p, lzo_hstrcpy) (lzo_hchar_p, const lzo_hchar_p);
1003 LZOLIB_EXTERN(lzo_hchar_p, lzo_hstrcat) (lzo_hchar_p, const lzo_hchar_p);
1004 LZOLIB_EXTERN(lzo_hsize_t, lzo_hstrlcpy) (lzo_hchar_p, const lzo_hchar_p, lzo_hsize_t);
1005 LZOLIB_EXTERN(lzo_hsize_t, lzo_hstrlcat) (lzo_hchar_p, const lzo_hchar_p, lzo_hsize_t);
1006 LZOLIB_EXTERN(int, lzo_hstrscpy) (lzo_hchar_p, const lzo_hchar_p, lzo_hsize_t);
1007 LZOLIB_EXTERN(int, lzo_hstrscat) (lzo_hchar_p, const lzo_hchar_p, lzo_hsize_t);
1008 LZOLIB_EXTERN(lzo_hchar_p, lzo_hstrccpy) (lzo_hchar_p, const lzo_hchar_p, int);
1009 LZOLIB_EXTERN(lzo_hvoid_p, lzo_hmemccpy) (lzo_hvoid_p, const lzo_hvoid_p, int, lzo_hsize_t);
1010 LZOLIB_EXTERN(lzo_hchar_p, lzo_hstrchr)  (const lzo_hchar_p, int);
1011 LZOLIB_EXTERN(lzo_hchar_p, lzo_hstrrchr) (const lzo_hchar_p, int);
1012 LZOLIB_EXTERN(lzo_hchar_p, lzo_ascii_hstrichr) (const lzo_hchar_p, int);
1013 LZOLIB_EXTERN(lzo_hchar_p, lzo_ascii_hstrrichr) (const lzo_hchar_p, int);
1014 LZOLIB_EXTERN(lzo_hvoid_p, lzo_hmemchr)  (const lzo_hvoid_p, int, lzo_hsize_t);
1015 LZOLIB_EXTERN(lzo_hvoid_p, lzo_hmemrchr) (const lzo_hvoid_p, int, lzo_hsize_t);
1016 LZOLIB_EXTERN(lzo_hvoid_p, lzo_ascii_hmemichr) (const lzo_hvoid_p, int, lzo_hsize_t);
1017 LZOLIB_EXTERN(lzo_hvoid_p, lzo_ascii_hmemrichr) (const lzo_hvoid_p, int, lzo_hsize_t);
1018 LZOLIB_EXTERN(lzo_hsize_t, lzo_hstrspn)  (const lzo_hchar_p, const lzo_hchar_p);
1019 LZOLIB_EXTERN(lzo_hsize_t, lzo_hstrrspn) (const lzo_hchar_p, const lzo_hchar_p);
1020 LZOLIB_EXTERN(lzo_hsize_t, lzo_hstrcspn)  (const lzo_hchar_p, const lzo_hchar_p);
1021 LZOLIB_EXTERN(lzo_hsize_t, lzo_hstrrcspn) (const lzo_hchar_p, const lzo_hchar_p);
1022 LZOLIB_EXTERN(lzo_hchar_p, lzo_hstrpbrk)  (const lzo_hchar_p, const lzo_hchar_p);
1023 LZOLIB_EXTERN(lzo_hchar_p, lzo_hstrrpbrk) (const lzo_hchar_p, const lzo_hchar_p);
1024 LZOLIB_EXTERN(lzo_hchar_p, lzo_hstrsep)  (lzo_hchar_pp, const lzo_hchar_p);
1025 LZOLIB_EXTERN(lzo_hchar_p, lzo_hstrrsep) (lzo_hchar_pp, const lzo_hchar_p);
1026 LZOLIB_EXTERN(lzo_hchar_p, lzo_ascii_hstrlwr) (lzo_hchar_p);
1027 LZOLIB_EXTERN(lzo_hchar_p, lzo_ascii_hstrupr) (lzo_hchar_p);
1028 LZOLIB_EXTERN(lzo_hvoid_p, lzo_ascii_hmemlwr) (lzo_hvoid_p, lzo_hsize_t);
1029 LZOLIB_EXTERN(lzo_hvoid_p, lzo_ascii_hmemupr) (lzo_hvoid_p, lzo_hsize_t);
1030 LZOLIB_EXTERN(lzo_hsize_t, lzo_hfread) (void *, lzo_hvoid_p, lzo_hsize_t);
1031 LZOLIB_EXTERN(lzo_hsize_t, lzo_hfwrite) (void *, const lzo_hvoid_p, lzo_hsize_t);
1032 #if (LZO_HAVE_MM_HUGE_PTR)
1033 LZOLIB_EXTERN(long, lzo_hread) (int, lzo_hvoid_p, long);
1034 LZOLIB_EXTERN(long, lzo_hwrite) (int, const lzo_hvoid_p, long);
1035 #endif
1036 LZOLIB_EXTERN(long, lzo_safe_hread) (int, lzo_hvoid_p, long);
1037 LZOLIB_EXTERN(long, lzo_safe_hwrite) (int, const lzo_hvoid_p, long);
1038 LZOLIB_EXTERN(unsigned, lzo_ua_get_be16) (const lzo_hvoid_p);
1039 LZOLIB_EXTERN(lzo_uint32l_t, lzo_ua_get_be24) (const lzo_hvoid_p);
1040 LZOLIB_EXTERN(lzo_uint32l_t, lzo_ua_get_be32) (const lzo_hvoid_p);
1041 LZOLIB_EXTERN(void, lzo_ua_set_be16) (lzo_hvoid_p, unsigned);
1042 LZOLIB_EXTERN(void, lzo_ua_set_be24) (lzo_hvoid_p, lzo_uint32l_t);
1043 LZOLIB_EXTERN(void, lzo_ua_set_be32) (lzo_hvoid_p, lzo_uint32l_t);
1044 LZOLIB_EXTERN(unsigned, lzo_ua_get_le16) (const lzo_hvoid_p);
1045 LZOLIB_EXTERN(lzo_uint32l_t, lzo_ua_get_le24) (const lzo_hvoid_p);
1046 LZOLIB_EXTERN(lzo_uint32l_t, lzo_ua_get_le32) (const lzo_hvoid_p);
1047 LZOLIB_EXTERN(void, lzo_ua_set_le16) (lzo_hvoid_p, unsigned);
1048 LZOLIB_EXTERN(void, lzo_ua_set_le24) (lzo_hvoid_p, lzo_uint32l_t);
1049 LZOLIB_EXTERN(void, lzo_ua_set_le32) (lzo_hvoid_p, lzo_uint32l_t);
1050 #if defined(lzo_int64l_t)
1051 LZOLIB_EXTERN(lzo_uint64l_t, lzo_ua_get_be64) (const lzo_hvoid_p);
1052 LZOLIB_EXTERN(void, lzo_ua_set_be64) (lzo_hvoid_p, lzo_uint64l_t);
1053 LZOLIB_EXTERN(lzo_uint64l_t, lzo_ua_get_le64) (const lzo_hvoid_p);
1054 LZOLIB_EXTERN(void, lzo_ua_set_le64) (lzo_hvoid_p, lzo_uint64l_t);
1055 #endif
1056 LZOLIB_EXTERN_NOINLINE(short, lzo_vget_short) (short, int);
1057 LZOLIB_EXTERN_NOINLINE(int, lzo_vget_int) (int, int);
1058 LZOLIB_EXTERN_NOINLINE(long, lzo_vget_long) (long, int);
1059 #if defined(lzo_int64l_t)
1060 LZOLIB_EXTERN_NOINLINE(lzo_int64l_t, lzo_vget_lzo_int64l_t) (lzo_int64l_t, int);
1061 #endif
1062 LZOLIB_EXTERN_NOINLINE(lzo_hsize_t, lzo_vget_lzo_hsize_t) (lzo_hsize_t, int);
1063 #if !(LZO_CFG_NO_FLOAT)
1064 LZOLIB_EXTERN_NOINLINE(float, lzo_vget_float) (float, int);
1065 #endif
1066 #if !(LZO_CFG_NO_DOUBLE)
1067 LZOLIB_EXTERN_NOINLINE(double, lzo_vget_double) (double, int);
1068 #endif
1069 LZOLIB_EXTERN_NOINLINE(lzo_hvoid_p, lzo_vget_lzo_hvoid_p) (lzo_hvoid_p, int);
1070 LZOLIB_EXTERN_NOINLINE(const lzo_hvoid_p, lzo_vget_lzo_hvoid_cp) (const lzo_hvoid_p, int);
1071 #if !defined(LZO_FN_PATH_MAX)
1072 #if (LZO_OS_DOS16 || LZO_OS_WIN16)
1073 #  define LZO_FN_PATH_MAX   143
1074 #elif (LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_OS216 || LZO_OS_WIN32 || LZO_OS_WIN64)
1075 #  define LZO_FN_PATH_MAX   259
1076 #elif (LZO_OS_TOS)
1077 #  define LZO_FN_PATH_MAX   259
1078 #endif
1079 #endif
1080 #if !defined(LZO_FN_PATH_MAX)
1081 #  define LZO_FN_PATH_MAX   1023
1082 #endif
1083 #if !defined(LZO_FN_NAME_MAX)
1084 #if (LZO_OS_DOS16 || LZO_OS_WIN16)
1085 #  define LZO_FN_NAME_MAX   12
1086 #elif (LZO_ARCH_M68K && LZO_OS_TOS && (LZO_CC_PUREC || LZO_CC_TURBOC))
1087 #  define LZO_FN_NAME_MAX   12
1088 #elif (LZO_OS_DOS32 && LZO_CC_GNUC) && defined(__DJGPP__)
1089 #elif (LZO_OS_DOS32)
1090 #  define LZO_FN_NAME_MAX   12
1091 #endif
1092 #endif
1093 #if !defined(LZO_FN_NAME_MAX)
1094 #  define LZO_FN_NAME_MAX   LZO_FN_PATH_MAX
1095 #endif
1096 #define LZO_FNMATCH_NOESCAPE        1
1097 #define LZO_FNMATCH_PATHNAME        2
1098 #define LZO_FNMATCH_PATHSTAR        4
1099 #define LZO_FNMATCH_PERIOD          8
1100 #define LZO_FNMATCH_ASCII_CASEFOLD  16
1101 LZOLIB_EXTERN(int, lzo_fnmatch) (const lzo_hchar_p, const lzo_hchar_p, int);
1102 #undef __LZOLIB_USE_OPENDIR
1103 #if (HAVE_DIRENT_H || LZO_CC_WATCOMC)
1104 #  define __LZOLIB_USE_OPENDIR 1
1105 #  if (LZO_OS_DOS32 && defined(__BORLANDC__))
1106 #  elif (LZO_OS_DOS32 && LZO_CC_GNUC) && defined(__DJGPP__)
1107 #  elif (LZO_OS_OS2 || LZO_OS_OS216)
1108 #  elif (LZO_ARCH_M68K && LZO_OS_TOS && LZO_CC_GNUC)
1109 #  elif (LZO_OS_WIN32 && !(LZO_HAVE_WINDOWS_H))
1110 #  elif (LZO_OS_DOS16 || LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_OS216 || LZO_OS_TOS || LZO_OS_WIN16 || LZO_OS_WIN32 || LZO_OS_WIN64)
1111 #    undef __LZOLIB_USE_OPENDIR
1112 #  endif
1113 #endif
1114 typedef struct
1115 {
1116 #if defined(__LZOLIB_USE_OPENDIR)
1117     void* u_dirp;
1118 # if (LZO_CC_WATCOMC)
1119     unsigned short f_time;
1120     unsigned short f_date;
1121     unsigned long f_size;
1122 # endif
1123     char f_name[LZO_FN_NAME_MAX+1];
1124 #elif (LZO_OS_WIN32 || LZO_OS_WIN64)
1125     lzolib_handle_t u_handle;
1126     unsigned f_attr;
1127     unsigned f_size_low;
1128     unsigned f_size_high;
1129     char f_name[LZO_FN_NAME_MAX+1];
1130 #elif (LZO_OS_DOS16 || LZO_OS_DOS32 || LZO_OS_TOS || LZO_OS_WIN16)
1131     char u_dta[21];
1132     unsigned char f_attr;
1133     unsigned short f_time;
1134     unsigned short f_date;
1135     unsigned short f_size_low;
1136     unsigned short f_size_high;
1137     char f_name[LZO_FN_NAME_MAX+1];
1138     char u_dirp;
1139 #else
1140     void* u_dirp;
1141     char f_name[LZO_FN_NAME_MAX+1];
1142 #endif
1143 } lzo_dir_t;
1144 #ifndef lzo_dir_p
1145 #define lzo_dir_p lzo_dir_t *
1146 #endif
1147 LZOLIB_EXTERN(int, lzo_opendir)  (lzo_dir_p, const char*);
1148 LZOLIB_EXTERN(int, lzo_readdir)  (lzo_dir_p);
1149 LZOLIB_EXTERN(int, lzo_closedir) (lzo_dir_p);
1150 #if (LZO_CC_GNUC) && (defined(__CYGWIN__) || defined(__MINGW32__))
1151 #  define lzo_alloca(x)     __builtin_alloca((x))
1152 #elif (LZO_CC_GNUC) && (LZO_OS_CONSOLE_PS2)
1153 #  define lzo_alloca(x)     __builtin_alloca((x))
1154 #elif (LZO_CC_BORLANDC || LZO_CC_LCC) && defined(__linux__)
1155 #elif (HAVE_ALLOCA)
1156 #  define lzo_alloca(x)     LZO_STATIC_CAST(void *, alloca((x)))
1157 #endif
1158 #if (LZO_OS_DOS32 && LZO_CC_GNUC) && defined(__DJGPP__)
1159 #  define lzo_stackavail()  stackavail()
1160 #elif (LZO_ARCH_I086 && LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0410))
1161 #  define lzo_stackavail()  stackavail()
1162 #elif (LZO_ARCH_I086 && LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0400))
1163 #  if (LZO_OS_WIN16) && (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM)
1164 #  else
1165 #    define lzo_stackavail()  stackavail()
1166 #  endif
1167 #elif ((LZO_ARCH_I086 || LZO_ARCH_I386) && (LZO_CC_DMC || LZO_CC_SYMANTECC))
1168 #  define lzo_stackavail()  stackavail()
1169 #elif ((LZO_ARCH_I086) && LZO_CC_MSC && (_MSC_VER >= 700))
1170 #  define lzo_stackavail()  _stackavail()
1171 #elif ((LZO_ARCH_I086) && LZO_CC_MSC)
1172 #  define lzo_stackavail()  stackavail()
1173 #elif ((LZO_ARCH_I086 || LZO_ARCH_I386) && LZO_CC_TURBOC && (__TURBOC__ >= 0x0450))
1174 #  define lzo_stackavail()  stackavail()
1175 #elif (LZO_ARCH_I086 && LZO_CC_TURBOC && (__TURBOC__ >= 0x0400))
1176    LZO_EXTERN_C size_t __cdecl stackavail(void);
1177 #  define lzo_stackavail()  stackavail()
1178 #elif ((LZO_ARCH_I086 || LZO_ARCH_I386) && (LZO_CC_WATCOMC))
1179 #  define lzo_stackavail()  stackavail()
1180 #elif (LZO_ARCH_I086 && LZO_CC_ZORTECHC)
1181 #  define lzo_stackavail()  _chkstack()
1182 #endif
1183 LZOLIB_EXTERN(lzo_intptr_t, lzo_get_osfhandle) (int);
1184 LZOLIB_EXTERN(const char *, lzo_getenv) (const char *);
1185 LZOLIB_EXTERN(int, lzo_isatty) (int);
1186 LZOLIB_EXTERN(int, lzo_mkdir) (const char*, unsigned);
1187 LZOLIB_EXTERN(int, lzo_rmdir) (const char*);
1188 LZOLIB_EXTERN(int, lzo_response) (int*, char***);
1189 LZOLIB_EXTERN(int, lzo_set_binmode) (int, int);
1190 #if defined(lzo_int32e_t)
1191 LZOLIB_EXTERN(lzo_int32e_t, lzo_muldiv32s) (lzo_int32e_t, lzo_int32e_t, lzo_int32e_t);
1192 LZOLIB_EXTERN(lzo_uint32e_t, lzo_muldiv32u) (lzo_uint32e_t, lzo_uint32e_t, lzo_uint32e_t);
1193 #endif
1194 LZOLIB_EXTERN(void, lzo_wildargv) (int*, char***);
1195 LZOLIB_EXTERN_NOINLINE(void, lzo_debug_break) (void);
1196 LZOLIB_EXTERN_NOINLINE(void, lzo_debug_nop) (void);
1197 LZOLIB_EXTERN_NOINLINE(int, lzo_debug_align_check_query) (void);
1198 LZOLIB_EXTERN_NOINLINE(int, lzo_debug_align_check_enable) (int);
1199 LZOLIB_EXTERN_NOINLINE(unsigned, lzo_debug_running_on_qemu) (void);
1200 LZOLIB_EXTERN_NOINLINE(unsigned, lzo_debug_running_on_valgrind) (void);
1201 #if defined(lzo_int32e_t)
1202 LZOLIB_EXTERN(int, lzo_tsc_read) (lzo_uint32e_t*);
1203 #endif
1204 struct lzo_pclock_handle_t;
1205 struct lzo_pclock_t;
1206 typedef struct lzo_pclock_handle_t lzo_pclock_handle_t;
1207 typedef struct lzo_pclock_t lzo_pclock_t;
1208 #ifndef lzo_pclock_handle_p
1209 #define lzo_pclock_handle_p lzo_pclock_handle_t *
1210 #endif
1211 #ifndef lzo_pclock_p
1212 #define lzo_pclock_p lzo_pclock_t *
1213 #endif
1214 #define LZO_PCLOCK_REALTIME             0
1215 #define LZO_PCLOCK_MONOTONIC            1
1216 #define LZO_PCLOCK_PROCESS_CPUTIME_ID   2
1217 #define LZO_PCLOCK_THREAD_CPUTIME_ID    3
1218 typedef int (*lzo_pclock_gettime_t) (lzo_pclock_handle_p, lzo_pclock_p);
1219 struct lzo_pclock_handle_t {
1220     lzolib_handle_t h;
1221     int mode;
1222     int read_error;
1223     const char* name;
1224     lzo_pclock_gettime_t gettime;
1225 #if defined(lzo_int64l_t)
1226     lzo_uint64l_t ticks_base;
1227 #endif
1228 };
1229 struct lzo_pclock_t {
1230 #if defined(lzo_int64l_t)
1231     lzo_int64l_t tv_sec;
1232 #else
1233     lzo_int32l_t tv_sec_high;
1234     lzo_uint32l_t tv_sec_low;
1235 #endif
1236     lzo_uint32l_t tv_nsec;
1237 };
1238 LZOLIB_EXTERN(int, lzo_pclock_open)  (lzo_pclock_handle_p, int);
1239 LZOLIB_EXTERN(int, lzo_pclock_open_default) (lzo_pclock_handle_p);
1240 LZOLIB_EXTERN(int, lzo_pclock_close) (lzo_pclock_handle_p);
1241 LZOLIB_EXTERN(void, lzo_pclock_read) (lzo_pclock_handle_p, lzo_pclock_p);
1242 #if !(LZO_CFG_NO_DOUBLE)
1243 LZOLIB_EXTERN(double, lzo_pclock_get_elapsed) (lzo_pclock_handle_p, const lzo_pclock_p, const lzo_pclock_p);
1244 #endif
1245 LZOLIB_EXTERN(int, lzo_pclock_flush_cpu_cache) (lzo_pclock_handle_p, unsigned);
1246 struct lzo_getopt_t;
1247 typedef struct lzo_getopt_t lzo_getopt_t;
1248 #ifndef lzo_getopt_p
1249 #define lzo_getopt_p lzo_getopt_t *
1250 #endif
1251 struct lzo_getopt_longopt_t;
1252 typedef struct lzo_getopt_longopt_t lzo_getopt_longopt_t;
1253 #ifndef lzo_getopt_longopt_p
1254 #define lzo_getopt_longopt_p lzo_getopt_longopt_t *
1255 #endif
1256 struct lzo_getopt_longopt_t {
1257     const char* name;
1258     int has_arg;
1259     int* flag;
1260     int val;
1261 };
1262 typedef void (*lzo_getopt_opterr_t)(lzo_getopt_p, const char*, void *);
1263 struct lzo_getopt_t {
1264     void *user;
1265     const char *progname;
1266     int bad_option;
1267     char *optarg;
1268     lzo_getopt_opterr_t opterr;
1269     int optind;
1270     int optopt;
1271     int errcount;
1272     int argc; char** argv;
1273     int eof; int shortpos;
1274     int pending_rotate_first, pending_rotate_middle;
1275 };
1276 enum { LZO_GETOPT_NO_ARG, LZO_GETOPT_REQUIRED_ARG, LZO_GETOPT_OPTIONAL_ARG, LZO_GETOPT_EXACT_ARG = 0x10 };
1277 enum { LZO_GETOPT_PERMUTE, LZO_GETOPT_RETURN_IN_ORDER, LZO_GETOPT_REQUIRE_ORDER };
1278 LZOLIB_EXTERN(void, lzo_getopt_init) (lzo_getopt_p g,
1279                                       int start_argc, int argc, char** argv);
1280 LZOLIB_EXTERN(int, lzo_getopt) (lzo_getopt_p g,
1281                                 const char* shortopts,
1282                                 const lzo_getopt_longopt_p longopts,
1283                                 int* longind);
1284 typedef struct {
1285     lzo_uint32l_t seed;
1286 } lzo_rand31_t;
1287 #ifndef lzo_rand31_p
1288 #define lzo_rand31_p lzo_rand31_t *
1289 #endif
1290 LZOLIB_EXTERN(void, lzo_srand31) (lzo_rand31_p, lzo_uint32l_t);
1291 LZOLIB_EXTERN(lzo_uint32l_t, lzo_rand31) (lzo_rand31_p);
1292 #if defined(lzo_int64l_t)
1293 typedef struct {
1294     lzo_uint64l_t seed;
1295 } lzo_rand48_t;
1296 #ifndef lzo_rand48_p
1297 #define lzo_rand48_p lzo_rand48_t *
1298 #endif
1299 LZOLIB_EXTERN(void, lzo_srand48) (lzo_rand48_p, lzo_uint32l_t);
1300 LZOLIB_EXTERN(lzo_uint32l_t, lzo_rand48) (lzo_rand48_p);
1301 LZOLIB_EXTERN(lzo_uint32l_t, lzo_rand48_r32) (lzo_rand48_p);
1302 #endif
1303 #if defined(lzo_int64l_t)
1304 typedef struct {
1305     lzo_uint64l_t seed;
1306 } lzo_rand64_t;
1307 #ifndef lzo_rand64_p
1308 #define lzo_rand64_p lzo_rand64_t *
1309 #endif
1310 LZOLIB_EXTERN(void, lzo_srand64) (lzo_rand64_p, lzo_uint64l_t);
1311 LZOLIB_EXTERN(lzo_uint32l_t, lzo_rand64) (lzo_rand64_p);
1312 LZOLIB_EXTERN(lzo_uint32l_t, lzo_rand64_r32) (lzo_rand64_p);
1313 #endif
1314 typedef struct {
1315     unsigned n;
1316     lzo_uint32l_t s[624];
1317 } lzo_randmt_t;
1318 #ifndef lzo_randmt_p
1319 #define lzo_randmt_p lzo_randmt_t *
1320 #endif
1321 LZOLIB_EXTERN(void, lzo_srandmt) (lzo_randmt_p, lzo_uint32l_t);
1322 LZOLIB_EXTERN(lzo_uint32l_t, lzo_randmt) (lzo_randmt_p);
1323 LZOLIB_EXTERN(lzo_uint32l_t, lzo_randmt_r32) (lzo_randmt_p);
1324 #if defined(lzo_int64l_t)
1325 typedef struct {
1326     unsigned n;
1327     lzo_uint64l_t s[312];
1328 } lzo_randmt64_t;
1329 #ifndef lzo_randmt64_p
1330 #define lzo_randmt64_p lzo_randmt64_t *
1331 #endif
1332 LZOLIB_EXTERN(void, lzo_srandmt64) (lzo_randmt64_p, lzo_uint64l_t);
1333 LZOLIB_EXTERN(lzo_uint64l_t, lzo_randmt64_r64) (lzo_randmt64_p);
1334 #endif
1335 #define LZO_SPAWN_P_WAIT    0
1336 #define LZO_SPAWN_P_NOWAIT  1
1337 LZOLIB_EXTERN(int, lzo_spawnv)  (int mode, const char* fn, const char* const * argv);
1338 LZOLIB_EXTERN(int, lzo_spawnvp) (int mode, const char* fn, const char* const * argv);
1339 LZOLIB_EXTERN(int, lzo_spawnve) (int mode, const char* fn, const char* const * argv, const char * const envp);
1340 #endif
1341 #endif
1342 #if defined(LZO_WANT_ACC_CXX_H)
1343 #  undef LZO_WANT_ACC_CXX_H
1344 #ifndef __LZO_CXX_H_INCLUDED
1345 #define __LZO_CXX_H_INCLUDED 1
1346 #if defined(__cplusplus)
1347 #if defined(LZO_CXX_NOTHROW)
1348 #elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020800ul))
1349 #elif (LZO_CC_BORLANDC && (__BORLANDC__ < 0x0450))
1350 #elif (LZO_CC_GHS && !defined(__EXCEPTIONS))
1351 #elif (LZO_CC_HIGHC)
1352 #elif (LZO_CC_MSC && (_MSC_VER < 1100))
1353 #elif (LZO_CC_NDPC)
1354 #elif (LZO_CC_TURBOC)
1355 #elif (LZO_CC_WATCOMC && !defined(_CPPUNWIND))
1356 #elif (LZO_CC_ZORTECHC)
1357 #else
1358 #  define LZO_CXX_NOTHROW           throw()
1359 #endif
1360 #if !defined(LZO_CXX_NOTHROW)
1361 #  define LZO_CXX_NOTHROW           /*empty*/
1362 #endif
1363 #if defined(__LZO_CXX_DO_NEW)
1364 #elif (LZO_CC_GHS || LZO_CC_NDPC || LZO_CC_PGI)
1365 #  define __LZO_CXX_DO_NEW          { return 0; }
1366 #elif ((LZO_CC_BORLANDC || LZO_CC_TURBOC) && LZO_ARCH_I086)
1367 #  define __LZO_CXX_DO_NEW          { return 0; }
1368 #else
1369 #  define __LZO_CXX_DO_NEW          ;
1370 #endif
1371 #if defined(__LZO_CXX_DO_DELETE)
1372 #elif (LZO_CC_BORLANDC || LZO_CC_TURBOC)
1373 #  define __LZO_CXX_DO_DELETE       { }
1374 #else
1375 #  define __LZO_CXX_DO_DELETE       LZO_CXX_NOTHROW { }
1376 #endif
1377 #if (LZO_CC_BORLANDC && (__BORLANDC__ < 0x0450))
1378 #elif (LZO_CC_MSC && LZO_MM_HUGE)
1379 #  define LZO_CXX_DISABLE_NEW_DELETE private:
1380 #elif (LZO_CC_MSC && (_MSC_VER < 1100))
1381 #elif (LZO_CC_NDPC)
1382 #elif (LZO_CC_SYMANTECC || LZO_CC_ZORTECHC)
1383 #elif (LZO_CC_TURBOC)
1384 #elif (LZO_CC_WATCOMC && (__WATCOMC__ < 1100))
1385 #else
1386 #  define __LZO_CXX_HAVE_ARRAY_NEW 1
1387 #endif
1388 #if (__LZO_CXX_HAVE_ARRAY_NEW)
1389 #  define __LZO_CXX_HAVE_PLACEMENT_NEW 1
1390 #endif
1391 #if (__LZO_CXX_HAVE_PLACEMENT_NEW)
1392 #  if (LZO_CC_GNUC >= 0x030000ul)
1393 #    define __LZO_CXX_HAVE_PLACEMENT_DELETE 1
1394 #  elif (LZO_CC_INTELC)
1395 #    define __LZO_CXX_HAVE_PLACEMENT_DELETE 1
1396 #  elif (LZO_CC_MSC && (_MSC_VER >= 1200))
1397 #    define __LZO_CXX_HAVE_PLACEMENT_DELETE 1
1398 #  elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE)
1399 #    define __LZO_CXX_HAVE_PLACEMENT_DELETE 1
1400 #  elif (LZO_CC_PGI)
1401 #    define __LZO_CXX_HAVE_PLACEMENT_DELETE 1
1402 #  endif
1403 #endif
1404 #if defined(LZO_CXX_DISABLE_NEW_DELETE)
1405 #elif defined(new) || defined(delete)
1406 #  define LZO_CXX_DISABLE_NEW_DELETE private:
1407 #elif (LZO_CC_GNUC && (LZO_CC_GNUC < 0x025b00ul))
1408 #  define LZO_CXX_DISABLE_NEW_DELETE private:
1409 #elif  (LZO_CC_HIGHC)
1410 #  define LZO_CXX_DISABLE_NEW_DELETE private:
1411 #elif !(__LZO_CXX_HAVE_ARRAY_NEW)
1412 #  define LZO_CXX_DISABLE_NEW_DELETE \
1413         protected: static void operator delete(void*) __LZO_CXX_DO_DELETE \
1414         protected: static void* operator new(size_t) __LZO_CXX_DO_NEW \
1415         private:
1416 #else
1417 #  define LZO_CXX_DISABLE_NEW_DELETE \
1418         protected: static void operator delete(void*) __LZO_CXX_DO_DELETE \
1419                    static void operator delete[](void*) __LZO_CXX_DO_DELETE \
1420         private:   static void* operator new(size_t)  __LZO_CXX_DO_NEW \
1421                    static void* operator new[](size_t) __LZO_CXX_DO_NEW
1422 #endif
1423 #if defined(LZO_CXX_TRIGGER_FUNCTION)
1424 #else
1425 #  define LZO_CXX_TRIGGER_FUNCTION \
1426         protected: virtual const void* lzo_cxx_trigger_function() const; \
1427         private:
1428 #endif
1429 #if defined(LZO_CXX_TRIGGER_FUNCTION_IMPL)
1430 #else
1431 #  define LZO_CXX_TRIGGER_FUNCTION_IMPL(klass) \
1432         const void* klass::lzo_cxx_trigger_function() const { return LZO_STATIC_CAST(const void *, 0); }
1433 #endif
1434 #endif
1435 #endif
1436 #endif
1437 #if defined(LZO_WANT_ACC_CHK_CH)
1438 #  undef LZO_WANT_ACC_CHK_CH
1439 #if !defined(LZOCHK_ASSERT)
1440 #  define LZOCHK_ASSERT(expr)   LZO_COMPILE_TIME_ASSERT_HEADER(expr)
1441 #endif
1442 #if !defined(LZOCHK_ASSERT_SIGN_T)
1443 #  define LZOCHK_ASSERT_SIGN_T(type,relop) \
1444         LZOCHK_ASSERT( LZO_STATIC_CAST(type, -1)  relop  LZO_STATIC_CAST(type, 0)) \
1445         LZOCHK_ASSERT( LZO_STATIC_CAST(type, ~LZO_STATIC_CAST(type, 0)) relop  LZO_STATIC_CAST(type, 0)) \
1446         LZOCHK_ASSERT( LZO_STATIC_CAST(type, ~LZO_STATIC_CAST(type, 0)) ==     LZO_STATIC_CAST(type, -1))
1447 #endif
1448 #if !defined(LZOCHK_ASSERT_IS_SIGNED_T)
1449 #  define LZOCHK_ASSERT_IS_SIGNED_T(type)       LZOCHK_ASSERT_SIGN_T(type,<)
1450 #endif
1451 #if !defined(LZOCHK_ASSERT_IS_UNSIGNED_T)
1452 #  if (LZO_BROKEN_INTEGRAL_PROMOTION)
1453 #    define LZOCHK_ASSERT_IS_UNSIGNED_T(type) \
1454         LZOCHK_ASSERT( LZO_STATIC_CAST(type, -1) > LZO_STATIC_CAST(type, 0) )
1455 #  else
1456 #    define LZOCHK_ASSERT_IS_UNSIGNED_T(type)   LZOCHK_ASSERT_SIGN_T(type,>)
1457 #  endif
1458 #endif
1459 #if defined(LZOCHK_CFG_PEDANTIC)
1460 #if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0550) && (__BORLANDC__ < 0x0560))
1461 #  pragma option push -w-8055
1462 #elif (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0530) && (__BORLANDC__ < 0x0550))
1463 #  pragma option push -w-osh
1464 #endif
1465 #endif
1466 #if (LZO_0xffffffffL - LZO_UINT32_C(4294967294) != 1)
1467 #  error "preprocessor error"
1468 #endif
1469 #if (LZO_0xffffffffL - LZO_UINT32_C(0xfffffffd) != 2)
1470 #  error "preprocessor error"
1471 #endif
1472 #if +0
1473 #  error "preprocessor error"
1474 #endif
1475 #if -0
1476 #  error "preprocessor error"
1477 #endif
1478 #if +0 != 0
1479 #  error "preprocessor error"
1480 #endif
1481 #if -0 != 0
1482 #  error "preprocessor error"
1483 #endif
1484 #define LZOCHK_VAL  1
1485 #define LZOCHK_TMP1 LZOCHK_VAL
1486 #undef LZOCHK_VAL
1487 #define LZOCHK_VAL  2
1488 #define LZOCHK_TMP2 LZOCHK_VAL
1489 #if (LZOCHK_TMP1 != 2)
1490 #  error "preprocessor error 3a"
1491 #endif
1492 #if (LZOCHK_TMP2 != 2)
1493 #  error "preprocessor error 3b"
1494 #endif
1495 #undef LZOCHK_VAL
1496 #if (LZOCHK_TMP2)
1497 #  error "preprocessor error 3c"
1498 #endif
1499 #if (LZOCHK_TMP2 + 0 != 0)
1500 #  error "preprocessor error 3d"
1501 #endif
1502 #undef LZOCHK_TMP1
1503 #undef LZOCHK_TMP2
1504 #if 0 || defined(LZOCHK_CFG_PEDANTIC)
1505 #  if (LZO_ARCH_MIPS) && defined(_MIPS_SZINT)
1506     LZOCHK_ASSERT((_MIPS_SZINT) == 8 * sizeof(int))
1507 #  endif
1508 #  if (LZO_ARCH_MIPS) && defined(_MIPS_SZLONG)
1509     LZOCHK_ASSERT((_MIPS_SZLONG) == 8 * sizeof(long))
1510 #  endif
1511 #  if (LZO_ARCH_MIPS) && defined(_MIPS_SZPTR)
1512     LZOCHK_ASSERT((_MIPS_SZPTR) == 8 * sizeof(void *))
1513 #  endif
1514 #endif
1515     LZOCHK_ASSERT(1 == 1)
1516     LZOCHK_ASSERT(__LZO_MASK_GEN(1u,1) == 1)
1517     LZOCHK_ASSERT(__LZO_MASK_GEN(1u,2) == 3)
1518     LZOCHK_ASSERT(__LZO_MASK_GEN(1u,3) == 7)
1519     LZOCHK_ASSERT(__LZO_MASK_GEN(1u,8) == 255)
1520 #if (SIZEOF_INT >= 2)
1521     LZOCHK_ASSERT(__LZO_MASK_GEN(1,15) == 32767)
1522     LZOCHK_ASSERT(__LZO_MASK_GEN(1u,16) == 0xffffU)
1523     LZOCHK_ASSERT(__LZO_MASK_GEN(0u,16) == 0u)
1524 #else
1525     LZOCHK_ASSERT(__LZO_MASK_GEN(1ul,16) == 0xffffUL)
1526     LZOCHK_ASSERT(__LZO_MASK_GEN(0ul,16) == 0ul)
1527 #endif
1528 #if (SIZEOF_INT >= 4)
1529     LZOCHK_ASSERT(__LZO_MASK_GEN(1,31) == 2147483647)
1530     LZOCHK_ASSERT(__LZO_MASK_GEN(1u,32) == 0xffffffffU)
1531     LZOCHK_ASSERT(__LZO_MASK_GEN(0u,32) == 0u)
1532 #endif
1533 #if (SIZEOF_LONG >= 4)
1534     LZOCHK_ASSERT(__LZO_MASK_GEN(1ul,32) == 0xffffffffUL)
1535     LZOCHK_ASSERT(__LZO_MASK_GEN(0ul,32) == 0ul)
1536 #endif
1537 #if (SIZEOF_LONG >= 8)
1538     LZOCHK_ASSERT(__LZO_MASK_GEN(1ul,64) == 0xffffffffffffffffUL)
1539     LZOCHK_ASSERT(__LZO_MASK_GEN(0ul,64) == 0ul)
1540 #endif
1541 #if !(LZO_BROKEN_INTEGRAL_PROMOTION)
1542     LZOCHK_ASSERT(__LZO_MASK_GEN(1u,SIZEOF_INT*8) == ~0u)
1543     LZOCHK_ASSERT(__LZO_MASK_GEN(1ul,SIZEOF_LONG*8) == ~0ul)
1544 #endif
1545 #if 1
1546     LZOCHK_ASSERT(__LZO_MASK_GEN(0,0) == 0)
1547     LZOCHK_ASSERT(__LZO_MASK_GEN(1,0) == 0)
1548     LZOCHK_ASSERT(__LZO_MASK_GEN(2,0) == 0)
1549     LZOCHK_ASSERT(__LZO_MASK_GEN(4,0) == 0)
1550 #endif
1551 #if 1
1552     LZOCHK_ASSERT(__LZO_MASK_GEN(2,1) == 2)
1553     LZOCHK_ASSERT(__LZO_MASK_GEN(4,1) == 4)
1554     LZOCHK_ASSERT(__LZO_MASK_GEN(8,1) == 8)
1555     LZOCHK_ASSERT(__LZO_MASK_GEN(2,2) == 2+4)
1556     LZOCHK_ASSERT(__LZO_MASK_GEN(4,2) == 4+8)
1557     LZOCHK_ASSERT(__LZO_MASK_GEN(8,2) == 8+16)
1558     LZOCHK_ASSERT(__LZO_MASK_GEN(2,3) == 2+4+8)
1559     LZOCHK_ASSERT(__LZO_MASK_GEN(4,3) == 4+8+16)
1560     LZOCHK_ASSERT(__LZO_MASK_GEN(8,3) == 8+16+32)
1561     LZOCHK_ASSERT(__LZO_MASK_GEN(7,1) == 7)
1562     LZOCHK_ASSERT(__LZO_MASK_GEN(7,2) == 7+14)
1563     LZOCHK_ASSERT(__LZO_MASK_GEN(7,3) == 7+14+28)
1564 #endif
1565 #if !(LZO_BROKEN_SIGNED_RIGHT_SHIFT)
1566     LZOCHK_ASSERT(((-1) >> 7) == -1)
1567 #endif
1568     LZOCHK_ASSERT(((1)  >> 7) == 0)
1569 #if (LZO_CC_INTELC && (__INTEL_COMPILER >= 900))
1570 #  pragma warning(push)
1571 #  pragma warning(disable: 1025)
1572 #endif
1573     LZOCHK_ASSERT((~0l  & ~0)  == ~0l)
1574     LZOCHK_ASSERT((~0l  & ~0u) == ~0u)
1575     LZOCHK_ASSERT((~0ul & ~0)  == ~0ul)
1576     LZOCHK_ASSERT((~0ul & ~0u) == ~0u)
1577 #if defined(__MSDOS__) && defined(__TURBOC__) && (__TURBOC__ < 0x0150)
1578 #elif (SIZEOF_INT == 2)
1579     LZOCHK_ASSERT((~0l  & ~0u) == 0xffffU)
1580     LZOCHK_ASSERT((~0ul & ~0u) == 0xffffU)
1581 #elif (SIZEOF_INT == 4)
1582     LZOCHK_ASSERT((~0l  & ~0u) == 0xffffffffU)
1583     LZOCHK_ASSERT((~0ul & ~0u) == 0xffffffffU)
1584 #endif
1585 #if (LZO_CC_INTELC && (__INTEL_COMPILER >= 900))
1586 #  pragma warning(pop)
1587 #endif
1588     LZOCHK_ASSERT_IS_SIGNED_T(signed char)
1589     LZOCHK_ASSERT_IS_UNSIGNED_T(unsigned char)
1590     LZOCHK_ASSERT(sizeof(signed char) == sizeof(char))
1591     LZOCHK_ASSERT(sizeof(unsigned char) == sizeof(char))
1592     LZOCHK_ASSERT(sizeof(char) == 1)
1593 #if (LZO_CC_CILLY) && (!defined(__CILLY__) || (__CILLY__ < 0x010302L))
1594 #else
1595     LZOCHK_ASSERT(sizeof(char) == sizeof(LZO_STATIC_CAST(char, 0)))
1596 #endif
1597 #if defined(__cplusplus)
1598     LZOCHK_ASSERT(sizeof('\0') == sizeof(char))
1599 #else
1600 #  if (LZO_CC_DMC)
1601 #  else
1602     LZOCHK_ASSERT(sizeof('\0') == sizeof(int))
1603 #  endif
1604 #endif
1605 #if defined(__lzo_alignof)
1606     LZOCHK_ASSERT(__lzo_alignof(char) == 1)
1607     LZOCHK_ASSERT(__lzo_alignof(signed char) == 1)
1608     LZOCHK_ASSERT(__lzo_alignof(unsigned char) == 1)
1609 #if defined(lzo_int16e_t)
1610     LZOCHK_ASSERT(__lzo_alignof(lzo_int16e_t) >= 1)
1611     LZOCHK_ASSERT(__lzo_alignof(lzo_int16e_t) <= 2)
1612 #endif
1613 #if defined(lzo_int32e_t)
1614     LZOCHK_ASSERT(__lzo_alignof(lzo_int32e_t) >= 1)
1615     LZOCHK_ASSERT(__lzo_alignof(lzo_int32e_t) <= 4)
1616 #endif
1617 #endif
1618     LZOCHK_ASSERT_IS_SIGNED_T(short)
1619     LZOCHK_ASSERT_IS_UNSIGNED_T(unsigned short)
1620     LZOCHK_ASSERT(sizeof(short) == sizeof(unsigned short))
1621 #if !(LZO_ABI_I8LP16)
1622     LZOCHK_ASSERT(sizeof(short) >= 2)
1623 #endif
1624     LZOCHK_ASSERT(sizeof(short) >= sizeof(char))
1625 #if (LZO_CC_CILLY) && (!defined(__CILLY__) || (__CILLY__ < 0x010302L))
1626 #else
1627     LZOCHK_ASSERT(sizeof(short) == sizeof(LZO_STATIC_CAST(short, 0)))
1628 #endif
1629 #if (SIZEOF_SHORT > 0)
1630     LZOCHK_ASSERT(sizeof(short) == SIZEOF_SHORT)
1631 #endif
1632     LZOCHK_ASSERT_IS_SIGNED_T(int)
1633     LZOCHK_ASSERT_IS_UNSIGNED_T(unsigned int)
1634     LZOCHK_ASSERT(sizeof(int) == sizeof(unsigned int))
1635 #if !(LZO_ABI_I8LP16)
1636     LZOCHK_ASSERT(sizeof(int) >= 2)
1637 #endif
1638     LZOCHK_ASSERT(sizeof(int) >= sizeof(short))
1639     LZOCHK_ASSERT(sizeof(int) == sizeof(0))
1640     LZOCHK_ASSERT(sizeof(int) == sizeof(LZO_STATIC_CAST(int, 0)))
1641 #if (SIZEOF_INT > 0)
1642     LZOCHK_ASSERT(sizeof(int) == SIZEOF_INT)
1643 #endif
1644     LZOCHK_ASSERT(sizeof(0) == sizeof(int))
1645     LZOCHK_ASSERT_IS_SIGNED_T(long)
1646     LZOCHK_ASSERT_IS_UNSIGNED_T(unsigned long)
1647     LZOCHK_ASSERT(sizeof(long) == sizeof(unsigned long))
1648 #if !(LZO_ABI_I8LP16)
1649     LZOCHK_ASSERT(sizeof(long) >= 4)
1650 #endif
1651     LZOCHK_ASSERT(sizeof(long) >= sizeof(int))
1652     LZOCHK_ASSERT(sizeof(long) == sizeof(0L))
1653     LZOCHK_ASSERT(sizeof(long) == sizeof(LZO_STATIC_CAST(long, 0)))
1654 #if (SIZEOF_LONG > 0)
1655     LZOCHK_ASSERT(sizeof(long) == SIZEOF_LONG)
1656 #endif
1657     LZOCHK_ASSERT(sizeof(0L) == sizeof(long))
1658     LZOCHK_ASSERT_IS_UNSIGNED_T(size_t)
1659     LZOCHK_ASSERT(sizeof(size_t) >= sizeof(int))
1660     LZOCHK_ASSERT(sizeof(size_t) == sizeof(sizeof(0)))
1661 #if (SIZEOF_SIZE_T > 0)
1662     LZOCHK_ASSERT(sizeof(size_t) == SIZEOF_SIZE_T)
1663 #endif
1664     LZOCHK_ASSERT_IS_SIGNED_T(ptrdiff_t)
1665     LZOCHK_ASSERT(sizeof(ptrdiff_t) >= sizeof(int))
1666     LZOCHK_ASSERT(sizeof(ptrdiff_t) >= sizeof(size_t))
1667 #if !(LZO_BROKEN_SIZEOF)
1668     LZOCHK_ASSERT(sizeof(ptrdiff_t) == sizeof(LZO_STATIC_CAST(char*, 0) - LZO_STATIC_CAST(char*, 0)))
1669 # if (LZO_HAVE_MM_HUGE_PTR)
1670     LZOCHK_ASSERT(4 == sizeof(LZO_STATIC_CAST(char __huge*, 0) - LZO_STATIC_CAST(char __huge*, 0)))
1671 # endif
1672 #endif
1673 #if (SIZEOF_PTRDIFF_T > 0)
1674     LZOCHK_ASSERT(sizeof(ptrdiff_t) == SIZEOF_PTRDIFF_T)
1675 #endif
1676     LZOCHK_ASSERT(sizeof(void*) >= sizeof(char*))
1677 #if (SIZEOF_VOID_P > 0)
1678     LZOCHK_ASSERT(sizeof(void*) == SIZEOF_VOID_P)
1679     LZOCHK_ASSERT(sizeof(char*) == SIZEOF_VOID_P)
1680 #endif
1681 #if (LZO_HAVE_MM_HUGE_PTR)
1682     LZOCHK_ASSERT(4 == sizeof(void __huge*))
1683     LZOCHK_ASSERT(4 == sizeof(char __huge*))
1684 #endif
1685 #if (LZO_ABI_I8LP16)
1686     LZOCHK_ASSERT((((1u  <<  7) + 1) >>  7) == 1)
1687     LZOCHK_ASSERT((((1ul << 15) + 1) >> 15) == 1)
1688 #else
1689     LZOCHK_ASSERT((((1u  << 15) + 1) >> 15) == 1)
1690     LZOCHK_ASSERT((((1ul << 31) + 1) >> 31) == 1)
1691 #endif
1692 #if defined(LZOCHK_CFG_PEDANTIC)
1693 #if defined(__MSDOS__) && defined(__TURBOC__) && (__TURBOC__ < 0x0150)
1694 #else
1695     LZOCHK_ASSERT((1   << (8*SIZEOF_INT-1)) < 0)
1696 #endif
1697 #endif
1698     LZOCHK_ASSERT((1u  << (8*SIZEOF_INT-1)) > 0)
1699 #if defined(LZOCHK_CFG_PEDANTIC)
1700     LZOCHK_ASSERT((1l  << (8*SIZEOF_LONG-1)) < 0)
1701 #endif
1702     LZOCHK_ASSERT((1ul << (8*SIZEOF_LONG-1)) > 0)
1703 #if defined(lzo_int16e_t)
1704     LZOCHK_ASSERT(sizeof(lzo_int16e_t) == 2)
1705     LZOCHK_ASSERT(sizeof(lzo_int16e_t) == LZO_SIZEOF_LZO_INT16E_T)
1706     LZOCHK_ASSERT(sizeof(lzo_uint16e_t) == 2)
1707     LZOCHK_ASSERT(sizeof(lzo_int16e_t) == sizeof(lzo_uint16e_t))
1708     LZOCHK_ASSERT_IS_SIGNED_T(lzo_int16e_t)
1709     LZOCHK_ASSERT_IS_UNSIGNED_T(lzo_uint16e_t)
1710 #if defined(__MSDOS__) && defined(__TURBOC__) && (__TURBOC__ < 0x0150)
1711 #else
1712     LZOCHK_ASSERT((LZO_STATIC_CAST(lzo_uint16e_t, (~LZO_STATIC_CAST(lzo_uint16e_t,0ul))) >> 15) == 1)
1713 #endif
1714     LZOCHK_ASSERT( LZO_STATIC_CAST(lzo_int16e_t, (1 + ~LZO_STATIC_CAST(lzo_int16e_t, 0))) == 0)
1715 #if defined(LZOCHK_CFG_PEDANTIC)
1716     LZOCHK_ASSERT( LZO_STATIC_CAST(lzo_uint16e_t, (1 + ~LZO_STATIC_CAST(lzo_uint16e_t, 0))) == 0)
1717 #endif
1718 #endif
1719 #if defined(lzo_int32e_t)
1720     LZOCHK_ASSERT(sizeof(lzo_int32e_t) == 4)
1721     LZOCHK_ASSERT(sizeof(lzo_int32e_t) == LZO_SIZEOF_LZO_INT32E_T)
1722     LZOCHK_ASSERT(sizeof(lzo_uint32e_t) == 4)
1723     LZOCHK_ASSERT(sizeof(lzo_int32e_t) == sizeof(lzo_uint32e_t))
1724     LZOCHK_ASSERT_IS_SIGNED_T(lzo_int32e_t)
1725     LZOCHK_ASSERT(((( LZO_STATIC_CAST(lzo_int32e_t, 1) << 30) + 1) >> 30) == 1)
1726     LZOCHK_ASSERT_IS_UNSIGNED_T(lzo_uint32e_t)
1727     LZOCHK_ASSERT(((( LZO_STATIC_CAST(lzo_uint32e_t, 1) << 31) + 1) >> 31) == 1)
1728     LZOCHK_ASSERT((LZO_STATIC_CAST(lzo_uint32e_t, (~LZO_STATIC_CAST(lzo_uint32e_t, 0ul))) >> 31) == 1)
1729     LZOCHK_ASSERT( LZO_STATIC_CAST(lzo_int32e_t, (1 + ~LZO_STATIC_CAST(lzo_int32e_t, 0))) == 0)
1730 #if defined(LZOCHK_CFG_PEDANTIC)
1731     LZOCHK_ASSERT( LZO_STATIC_CAST(lzo_uint32e_t, (1 + ~LZO_STATIC_CAST(lzo_uint32e_t, 0))) == 0)
1732 #endif
1733 #endif
1734 #if defined(lzo_int32e_t)
1735     LZOCHK_ASSERT(sizeof(lzo_int32l_t) >= sizeof(lzo_int32e_t))
1736 #endif
1737     LZOCHK_ASSERT(sizeof(lzo_int32l_t) >= 4)
1738     LZOCHK_ASSERT(sizeof(lzo_int32l_t) == LZO_SIZEOF_LZO_INT32L_T)
1739     LZOCHK_ASSERT(sizeof(lzo_uint32l_t) >= 4)
1740     LZOCHK_ASSERT(sizeof(lzo_int32l_t) == sizeof(lzo_uint32l_t))
1741     LZOCHK_ASSERT_IS_SIGNED_T(lzo_int32l_t)
1742     LZOCHK_ASSERT(((( LZO_STATIC_CAST(lzo_int32l_t, 1) << 30) + 1) >> 30) == 1)
1743     LZOCHK_ASSERT_IS_UNSIGNED_T(lzo_uint32l_t)
1744     LZOCHK_ASSERT(((( LZO_STATIC_CAST(lzo_uint32l_t, 1) << 31) + 1) >> 31) == 1)
1745     LZOCHK_ASSERT(sizeof(lzo_int32f_t) >= sizeof(int))
1746 #if defined(lzo_int32e_t)
1747     LZOCHK_ASSERT(sizeof(lzo_int32f_t) >= sizeof(lzo_int32e_t))
1748 #endif
1749     LZOCHK_ASSERT(sizeof(lzo_int32f_t) >= sizeof(lzo_int32l_t))
1750     LZOCHK_ASSERT(sizeof(lzo_int32f_t) >= 4)
1751     LZOCHK_ASSERT(sizeof(lzo_int32f_t) >= sizeof(lzo_int32l_t))
1752     LZOCHK_ASSERT(sizeof(lzo_int32f_t) == LZO_SIZEOF_LZO_INT32F_T)
1753     LZOCHK_ASSERT(sizeof(lzo_uint32f_t) >= 4)
1754     LZOCHK_ASSERT(sizeof(lzo_uint32f_t) >= sizeof(lzo_uint32l_t))
1755     LZOCHK_ASSERT(sizeof(lzo_int32f_t) == sizeof(lzo_uint32f_t))
1756     LZOCHK_ASSERT_IS_SIGNED_T(lzo_int32f_t)
1757     LZOCHK_ASSERT(((( LZO_STATIC_CAST(lzo_int32f_t, 1) << 30) + 1) >> 30) == 1)
1758     LZOCHK_ASSERT_IS_UNSIGNED_T(lzo_uint32f_t)
1759     LZOCHK_ASSERT(((( LZO_STATIC_CAST(lzo_uint32f_t, 1) << 31) + 1) >> 31) == 1)
1760 #if defined(lzo_int64e_t)
1761     LZOCHK_ASSERT(sizeof(lzo_int64e_t) == 8)
1762     LZOCHK_ASSERT(sizeof(lzo_int64e_t) == LZO_SIZEOF_LZO_INT64E_T)
1763     LZOCHK_ASSERT(sizeof(lzo_uint64e_t) == 8)
1764     LZOCHK_ASSERT(sizeof(lzo_int64e_t) == sizeof(lzo_uint64e_t))
1765     LZOCHK_ASSERT_IS_SIGNED_T(lzo_int64e_t)
1766 #if (LZO_CC_BORLANDC && (__BORLANDC__ < 0x0530))
1767 #else
1768     LZOCHK_ASSERT_IS_UNSIGNED_T(lzo_uint64e_t)
1769 #endif
1770 #endif
1771 #if defined(lzo_int64l_t)
1772 #if defined(lzo_int64e_t)
1773     LZOCHK_ASSERT(sizeof(lzo_int64l_t) >= sizeof(lzo_int64e_t))
1774 #endif
1775     LZOCHK_ASSERT(sizeof(lzo_int64l_t) >= 8)
1776     LZOCHK_ASSERT(sizeof(lzo_int64l_t) == LZO_SIZEOF_LZO_INT64L_T)
1777     LZOCHK_ASSERT(sizeof(lzo_uint64l_t) >= 8)
1778     LZOCHK_ASSERT(sizeof(lzo_int64l_t) == sizeof(lzo_uint64l_t))
1779     LZOCHK_ASSERT_IS_SIGNED_T(lzo_int64l_t)
1780     LZOCHK_ASSERT(((( LZO_STATIC_CAST(lzo_int64l_t, 1) << 62) + 1) >> 62) == 1)
1781     LZOCHK_ASSERT(((( LZO_INT64_C(1) << 62) + 1) >> 62) == 1)
1782 #if (LZO_CC_BORLANDC && (__BORLANDC__ < 0x0530))
1783 #else
1784     LZOCHK_ASSERT_IS_UNSIGNED_T(lzo_uint64l_t)
1785     LZOCHK_ASSERT(LZO_UINT64_C(18446744073709551615)     > 0)
1786 #endif
1787     LZOCHK_ASSERT(((( LZO_STATIC_CAST(lzo_uint64l_t, 1) << 63) + 1) >> 63) == 1)
1788     LZOCHK_ASSERT(((( LZO_UINT64_C(1) << 63) + 1) >> 63) == 1)
1789 #if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020600ul))
1790     LZOCHK_ASSERT(LZO_INT64_C(9223372036854775807)       > LZO_INT64_C(0))
1791 #else
1792     LZOCHK_ASSERT(LZO_INT64_C(9223372036854775807)       > 0)
1793 #endif
1794     LZOCHK_ASSERT(LZO_INT64_C(-9223372036854775807) - 1  < 0)
1795     LZOCHK_ASSERT( LZO_INT64_C(9223372036854775807) % LZO_INT32_C(2147483629)  == 721)
1796     LZOCHK_ASSERT( LZO_INT64_C(9223372036854775807) % LZO_INT32_C(2147483647)  == 1)
1797     LZOCHK_ASSERT(LZO_UINT64_C(9223372036854775807) % LZO_UINT32_C(2147483629) == 721)
1798     LZOCHK_ASSERT(LZO_UINT64_C(9223372036854775807) % LZO_UINT32_C(2147483647) == 1)
1799 #endif
1800 #if defined(lzo_int64f_t)
1801 #if defined(lzo_int64e_t)
1802     LZOCHK_ASSERT(sizeof(lzo_int64f_t) >= sizeof(lzo_int64e_t))
1803 #endif
1804     LZOCHK_ASSERT(sizeof(lzo_int64f_t) >= sizeof(lzo_int64l_t))
1805     LZOCHK_ASSERT(sizeof(lzo_int64f_t) >= 8)
1806     LZOCHK_ASSERT(sizeof(lzo_int64f_t) >= sizeof(lzo_int64l_t))
1807     LZOCHK_ASSERT(sizeof(lzo_int64f_t) == LZO_SIZEOF_LZO_INT64F_T)
1808     LZOCHK_ASSERT(sizeof(lzo_uint64f_t) >= 8)
1809     LZOCHK_ASSERT(sizeof(lzo_uint64f_t) >= sizeof(lzo_uint64l_t))
1810     LZOCHK_ASSERT(sizeof(lzo_int64f_t) == sizeof(lzo_uint64f_t))
1811     LZOCHK_ASSERT_IS_SIGNED_T(lzo_int64f_t)
1812 #if (LZO_CC_BORLANDC && (__BORLANDC__ < 0x0530))
1813 #else
1814     LZOCHK_ASSERT_IS_UNSIGNED_T(lzo_uint64f_t)
1815 #endif
1816 #endif
1817 #if !defined(__LZO_INTPTR_T_IS_POINTER)
1818     LZOCHK_ASSERT_IS_SIGNED_T(lzo_intptr_t)
1819     LZOCHK_ASSERT_IS_UNSIGNED_T(lzo_uintptr_t)
1820 #endif
1821     LZOCHK_ASSERT(sizeof(lzo_intptr_t) >= sizeof(void *))
1822     LZOCHK_ASSERT(sizeof(lzo_intptr_t) == LZO_SIZEOF_LZO_INTPTR_T)
1823     LZOCHK_ASSERT(sizeof(lzo_intptr_t) == sizeof(lzo_uintptr_t))
1824 #if defined(lzo_word_t)
1825     LZOCHK_ASSERT(LZO_WORDSIZE == LZO_SIZEOF_LZO_WORD_T)
1826     LZOCHK_ASSERT_IS_UNSIGNED_T(lzo_word_t)
1827     LZOCHK_ASSERT_IS_SIGNED_T(lzo_sword_t)
1828     LZOCHK_ASSERT(sizeof(lzo_word_t) == LZO_SIZEOF_LZO_WORD_T)
1829     LZOCHK_ASSERT(sizeof(lzo_word_t) == sizeof(lzo_sword_t))
1830 #endif
1831     LZOCHK_ASSERT(sizeof(lzo_int8_t) == 1)
1832     LZOCHK_ASSERT(sizeof(lzo_uint8_t) == 1)
1833     LZOCHK_ASSERT(sizeof(lzo_int8_t) == sizeof(lzo_uint8_t))
1834     LZOCHK_ASSERT_IS_SIGNED_T(lzo_int8_t)
1835     LZOCHK_ASSERT_IS_UNSIGNED_T(lzo_uint8_t)
1836 #if defined(LZO_INT16_C)
1837     LZOCHK_ASSERT(sizeof(LZO_INT16_C(0)) >= 2)
1838     LZOCHK_ASSERT(sizeof(LZO_UINT16_C(0)) >= 2)
1839     LZOCHK_ASSERT((LZO_UINT16_C(0xffff) >> 15) == 1)
1840 #endif
1841 #if defined(LZO_INT32_C)
1842     LZOCHK_ASSERT(sizeof(LZO_INT32_C(0)) >= 4)
1843     LZOCHK_ASSERT(sizeof(LZO_UINT32_C(0)) >= 4)
1844     LZOCHK_ASSERT((LZO_UINT32_C(0xffffffff) >> 31) == 1)
1845 #endif
1846 #if defined(LZO_INT64_C)
1847 #if (LZO_CC_BORLANDC && (__BORLANDC__ < 0x0560))
1848 #else
1849     LZOCHK_ASSERT(sizeof(LZO_INT64_C(0)) >= 8)
1850     LZOCHK_ASSERT(sizeof(LZO_UINT64_C(0)) >= 8)
1851 #endif
1852     LZOCHK_ASSERT((LZO_UINT64_C(0xffffffffffffffff) >> 63) == 1)
1853     LZOCHK_ASSERT((LZO_UINT64_C(0xffffffffffffffff) & ~0)  == LZO_UINT64_C(0xffffffffffffffff))
1854     LZOCHK_ASSERT((LZO_UINT64_C(0xffffffffffffffff) & ~0l) == LZO_UINT64_C(0xffffffffffffffff))
1855 #if (SIZEOF_INT == 4)
1856 # if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020000ul))
1857 # else
1858     LZOCHK_ASSERT((LZO_UINT64_C(0xffffffffffffffff) & (~0u+0u)) == 0xffffffffu)
1859 # endif
1860 #endif
1861 #if (SIZEOF_LONG == 4)
1862 # if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x020000ul))
1863 # else
1864     LZOCHK_ASSERT((LZO_UINT64_C(0xffffffffffffffff) & (~0ul+0ul)) == 0xfffffffful)
1865 # endif
1866 #endif
1867 #endif
1868 #if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM)
1869     LZOCHK_ASSERT(sizeof(void*) == 2)
1870     LZOCHK_ASSERT(sizeof(ptrdiff_t) == 2)
1871 #elif (LZO_MM_COMPACT || LZO_MM_LARGE || LZO_MM_HUGE)
1872     LZOCHK_ASSERT(sizeof(void*) == 4)
1873 #endif
1874 #if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_COMPACT)
1875     LZOCHK_ASSERT(sizeof(void (*)(void)) == 2)
1876 #elif (LZO_MM_MEDIUM || LZO_MM_LARGE || LZO_MM_HUGE)
1877     LZOCHK_ASSERT(sizeof(void (*)(void)) == 4)
1878 #endif
1879 #if (LZO_ABI_ILP32)
1880     LZOCHK_ASSERT(sizeof(int) == 4)
1881     LZOCHK_ASSERT(sizeof(long) == 4)
1882     LZOCHK_ASSERT(sizeof(void*) == 4)
1883     LZOCHK_ASSERT(sizeof(ptrdiff_t) == sizeof(void*))
1884     LZOCHK_ASSERT(sizeof(size_t) == sizeof(void*))
1885     LZOCHK_ASSERT(sizeof(lzo_intptr_t) == sizeof(void *))
1886 #endif
1887 #if (LZO_ABI_ILP64)
1888     LZOCHK_ASSERT(sizeof(int) == 8)
1889     LZOCHK_ASSERT(sizeof(long) == 8)
1890     LZOCHK_ASSERT(sizeof(void*) == 8)
1891     LZOCHK_ASSERT(sizeof(ptrdiff_t) == sizeof(void*))
1892     LZOCHK_ASSERT(sizeof(size_t) == sizeof(void*))
1893     LZOCHK_ASSERT(sizeof(lzo_intptr_t) == sizeof(void *))
1894 #endif
1895 #if (LZO_ABI_IP32L64)
1896     LZOCHK_ASSERT(sizeof(int) == 4)
1897     LZOCHK_ASSERT(sizeof(long) == 8)
1898     LZOCHK_ASSERT(sizeof(void*) == 4)
1899     LZOCHK_ASSERT(sizeof(ptrdiff_t) == sizeof(void*))
1900     LZOCHK_ASSERT(sizeof(size_t) == sizeof(void*))
1901     LZOCHK_ASSERT(sizeof(lzo_intptr_t) == sizeof(void *))
1902 #endif
1903 #if (LZO_ABI_LLP64)
1904     LZOCHK_ASSERT(sizeof(int) == 4)
1905     LZOCHK_ASSERT(sizeof(long) == 4)
1906     LZOCHK_ASSERT(sizeof(void*) == 8)
1907     LZOCHK_ASSERT(sizeof(ptrdiff_t) == sizeof(void*))
1908     LZOCHK_ASSERT(sizeof(size_t) == sizeof(void*))
1909     LZOCHK_ASSERT(sizeof(lzo_intptr_t) == sizeof(void *))
1910 #endif
1911 #if (LZO_ABI_LP32)
1912     LZOCHK_ASSERT(sizeof(int) == 2)
1913     LZOCHK_ASSERT(sizeof(long) == 4)
1914     LZOCHK_ASSERT(sizeof(void*) == 4)
1915     LZOCHK_ASSERT(sizeof(lzo_intptr_t) == sizeof(void *))
1916 #endif
1917 #if (LZO_ABI_LP64)
1918     LZOCHK_ASSERT(sizeof(int) == 4)
1919     LZOCHK_ASSERT(sizeof(long) == 8)
1920     LZOCHK_ASSERT(sizeof(void*) == 8)
1921     LZOCHK_ASSERT(sizeof(ptrdiff_t) == sizeof(void*))
1922     LZOCHK_ASSERT(sizeof(size_t) == sizeof(void*))
1923     LZOCHK_ASSERT(sizeof(lzo_intptr_t) == sizeof(void *))
1924 #endif
1925 #if (LZO_ARCH_I086)
1926     LZOCHK_ASSERT(sizeof(size_t) == 2)
1927     LZOCHK_ASSERT(sizeof(lzo_intptr_t) == sizeof(void *))
1928 #elif (LZO_ARCH_I386 || LZO_ARCH_M68K)
1929     LZOCHK_ASSERT(sizeof(size_t) == 4)
1930     LZOCHK_ASSERT(sizeof(ptrdiff_t) == 4)
1931     LZOCHK_ASSERT(sizeof(lzo_intptr_t) == sizeof(void *))
1932 #endif
1933 #if (LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_WIN32)
1934     LZOCHK_ASSERT(sizeof(size_t) == 4)
1935     LZOCHK_ASSERT(sizeof(ptrdiff_t) == 4)
1936     LZOCHK_ASSERT(sizeof(void (*)(void)) == 4)
1937 #elif (LZO_OS_WIN64)
1938     LZOCHK_ASSERT(sizeof(size_t) == 8)
1939     LZOCHK_ASSERT(sizeof(ptrdiff_t) == 8)
1940     LZOCHK_ASSERT(sizeof(void (*)(void)) == 8)
1941 #endif
1942 #if (LZO_CC_NDPC)
1943 #elif (SIZEOF_INT > 1)
1944     LZOCHK_ASSERT( LZO_STATIC_CAST(int, LZO_STATIC_CAST(unsigned char, LZO_STATIC_CAST(signed char, -1))) == 255)
1945 #endif
1946 #if defined(LZOCHK_CFG_PEDANTIC)
1947 #if (LZO_CC_KEILC)
1948 #elif (LZO_CC_NDPC)
1949 #elif !(LZO_BROKEN_INTEGRAL_PROMOTION) && (SIZEOF_INT > 1)
1950     LZOCHK_ASSERT( ((LZO_STATIC_CAST(unsigned char, 128)) << LZO_STATIC_CAST(int, (8*sizeof(int)-8))) < 0)
1951 #endif
1952 #endif
1953 #if defined(LZOCHK_CFG_PEDANTIC)
1954 #if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0530) && (__BORLANDC__ < 0x0560))
1955 #  pragma option pop
1956 #endif
1957 #endif
1958 #endif
1959 #if defined(LZO_WANT_ACCLIB_VGET)
1960 #  undef LZO_WANT_ACCLIB_VGET
1961 #define __LZOLIB_VGET_CH_INCLUDED 1
1962 #if !defined(LZOLIB_PUBLIC)
1963 #  define LZOLIB_PUBLIC(r,f)                r __LZOLIB_FUNCNAME(f)
1964 #endif
1965 #if !defined(LZOLIB_PUBLIC_NOINLINE)
1966 #  if !defined(__lzo_noinline)
1967 #    define LZOLIB_PUBLIC_NOINLINE(r,f)     r __LZOLIB_FUNCNAME(f)
1968 #  elif (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x030400ul) || LZO_CC_LLVM)
1969 #    define LZOLIB_PUBLIC_NOINLINE(r,f)     __lzo_noinline __attribute__((__used__)) r __LZOLIB_FUNCNAME(f)
1970 #  else
1971 #    define LZOLIB_PUBLIC_NOINLINE(r,f)     __lzo_noinline r __LZOLIB_FUNCNAME(f)
1972 #  endif
1973 #endif
1974 extern void* volatile lzo_vget_ptr__;
1975 #if (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x030400ul) || LZO_CC_LLVM)
1976 void* volatile __attribute__((__used__)) lzo_vget_ptr__ = LZO_STATIC_CAST(void *, 0);
1977 #else
1978 void* volatile lzo_vget_ptr__ = LZO_STATIC_CAST(void *, 0);
1979 #endif
1980 #ifndef __LZOLIB_VGET_BODY
1981 #define __LZOLIB_VGET_BODY(T) \
1982     if __lzo_unlikely(lzo_vget_ptr__) { \
1983         typedef T __lzo_may_alias TT; \
1984         unsigned char e; expr &= 255; e = LZO_STATIC_CAST(unsigned char, expr); \
1985         * LZO_STATIC_CAST(TT *, lzo_vget_ptr__) = v; \
1986         * LZO_STATIC_CAST(unsigned char *, lzo_vget_ptr__) = e; \
1987         v = * LZO_STATIC_CAST(TT *, lzo_vget_ptr__); \
1988     } \
1989     return v;
1990 #endif
LZOLIB_PUBLIC_NOINLINE(short,lzo_vget_short)1991 LZOLIB_PUBLIC_NOINLINE(short, lzo_vget_short) (short v, int expr)
1992 {
1993     __LZOLIB_VGET_BODY(short)
1994 }
LZOLIB_PUBLIC_NOINLINE(int,lzo_vget_int)1995 LZOLIB_PUBLIC_NOINLINE(int, lzo_vget_int) (int v, int expr)
1996 {
1997     __LZOLIB_VGET_BODY(int)
1998 }
LZOLIB_PUBLIC_NOINLINE(long,lzo_vget_long)1999 LZOLIB_PUBLIC_NOINLINE(long, lzo_vget_long) (long v, int expr)
2000 {
2001     __LZOLIB_VGET_BODY(long)
2002 }
2003 #if defined(lzo_int64l_t)
LZOLIB_PUBLIC_NOINLINE(lzo_int64l_t,lzo_vget_lzo_int64l_t)2004 LZOLIB_PUBLIC_NOINLINE(lzo_int64l_t, lzo_vget_lzo_int64l_t) (lzo_int64l_t v, int expr)
2005 {
2006     __LZOLIB_VGET_BODY(lzo_int64l_t)
2007 }
2008 #endif
LZOLIB_PUBLIC_NOINLINE(lzo_hsize_t,lzo_vget_lzo_hsize_t)2009 LZOLIB_PUBLIC_NOINLINE(lzo_hsize_t, lzo_vget_lzo_hsize_t) (lzo_hsize_t v, int expr)
2010 {
2011     __LZOLIB_VGET_BODY(lzo_hsize_t)
2012 }
2013 #if !(LZO_CFG_NO_DOUBLE)
LZOLIB_PUBLIC_NOINLINE(double,lzo_vget_double)2014 LZOLIB_PUBLIC_NOINLINE(double, lzo_vget_double) (double v, int expr)
2015 {
2016     __LZOLIB_VGET_BODY(double)
2017 }
2018 #endif
LZOLIB_PUBLIC_NOINLINE(lzo_hvoid_p,lzo_vget_lzo_hvoid_p)2019 LZOLIB_PUBLIC_NOINLINE(lzo_hvoid_p, lzo_vget_lzo_hvoid_p) (lzo_hvoid_p v, int expr)
2020 {
2021     __LZOLIB_VGET_BODY(lzo_hvoid_p)
2022 }
2023 #if (LZO_ARCH_I086 && LZO_CC_TURBOC && (__TURBOC__ == 0x0295)) && !defined(__cplusplus)
LZOLIB_PUBLIC_NOINLINE(lzo_hvoid_p,lzo_vget_lzo_hvoid_cp)2024 LZOLIB_PUBLIC_NOINLINE(lzo_hvoid_p, lzo_vget_lzo_hvoid_cp) (const lzo_hvoid_p vv, int expr)
2025 {
2026     lzo_hvoid_p v = (lzo_hvoid_p) vv;
2027     __LZOLIB_VGET_BODY(lzo_hvoid_p)
2028 }
2029 #else
LZOLIB_PUBLIC_NOINLINE(const lzo_hvoid_p,lzo_vget_lzo_hvoid_cp)2030 LZOLIB_PUBLIC_NOINLINE(const lzo_hvoid_p, lzo_vget_lzo_hvoid_cp) (const lzo_hvoid_p v, int expr)
2031 {
2032     __LZOLIB_VGET_BODY(const lzo_hvoid_p)
2033 }
2034 #endif
2035 #endif
2036 #if defined(LZO_WANT_ACCLIB_HMEMCPY)
2037 #  undef LZO_WANT_ACCLIB_HMEMCPY
2038 #define __LZOLIB_HMEMCPY_CH_INCLUDED 1
2039 #if !defined(LZOLIB_PUBLIC)
2040 #  define LZOLIB_PUBLIC(r,f)    r __LZOLIB_FUNCNAME(f)
2041 #endif
LZOLIB_PUBLIC(int,lzo_hmemcmp)2042 LZOLIB_PUBLIC(int, lzo_hmemcmp) (const lzo_hvoid_p s1, const lzo_hvoid_p s2, lzo_hsize_t len)
2043 {
2044 #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMCMP)
2045     const lzo_hbyte_p p1 = LZO_STATIC_CAST(const lzo_hbyte_p, s1);
2046     const lzo_hbyte_p p2 = LZO_STATIC_CAST(const lzo_hbyte_p, s2);
2047     if __lzo_likely(len > 0) do
2048     {
2049         int d = *p1 - *p2;
2050         if (d != 0)
2051             return d;
2052         p1++; p2++;
2053     } while __lzo_likely(--len > 0);
2054     return 0;
2055 #else
2056     return memcmp(s1, s2, len);
2057 #endif
2058 }
LZOLIB_PUBLIC(lzo_hvoid_p,lzo_hmemcpy)2059 LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemcpy) (lzo_hvoid_p dest, const lzo_hvoid_p src, lzo_hsize_t len)
2060 {
2061 #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMCPY)
2062     lzo_hbyte_p p1 = LZO_STATIC_CAST(lzo_hbyte_p, dest);
2063     const lzo_hbyte_p p2 = LZO_STATIC_CAST(const lzo_hbyte_p, src);
2064     if (!(len > 0) || p1 == p2)
2065         return dest;
2066     do
2067         *p1++ = *p2++;
2068     while __lzo_likely(--len > 0);
2069     return dest;
2070 #else
2071     return memcpy(dest, src, len);
2072 #endif
2073 }
LZOLIB_PUBLIC(lzo_hvoid_p,lzo_hmemmove)2074 LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemmove) (lzo_hvoid_p dest, const lzo_hvoid_p src, lzo_hsize_t len)
2075 {
2076 #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMMOVE)
2077     lzo_hbyte_p p1 = LZO_STATIC_CAST(lzo_hbyte_p, dest);
2078     const lzo_hbyte_p p2 = LZO_STATIC_CAST(const lzo_hbyte_p, src);
2079     if (!(len > 0) || p1 == p2)
2080         return dest;
2081     if (p1 < p2)
2082     {
2083         do
2084             *p1++ = *p2++;
2085         while __lzo_likely(--len > 0);
2086     }
2087     else
2088     {
2089         p1 += len;
2090         p2 += len;
2091         do
2092             *--p1 = *--p2;
2093         while __lzo_likely(--len > 0);
2094     }
2095     return dest;
2096 #else
2097     return memmove(dest, src, len);
2098 #endif
2099 }
LZOLIB_PUBLIC(lzo_hvoid_p,lzo_hmemset)2100 LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemset) (lzo_hvoid_p s, int cc, lzo_hsize_t len)
2101 {
2102 #if (LZO_HAVE_MM_HUGE_PTR) || !(HAVE_MEMSET)
2103     lzo_hbyte_p p = LZO_STATIC_CAST(lzo_hbyte_p, s);
2104     unsigned char c = LZO_ITRUNC(unsigned char, cc);
2105     if __lzo_likely(len > 0) do
2106         *p++ = c;
2107     while __lzo_likely(--len > 0);
2108     return s;
2109 #else
2110     return memset(s, cc, len);
2111 #endif
2112 }
2113 #endif
2114 #if defined(LZO_WANT_ACCLIB_RAND)
2115 #  undef LZO_WANT_ACCLIB_RAND
2116 #define __LZOLIB_RAND_CH_INCLUDED 1
2117 #if !defined(LZOLIB_PUBLIC)
2118 #  define LZOLIB_PUBLIC(r,f)    r __LZOLIB_FUNCNAME(f)
2119 #endif
LZOLIB_PUBLIC(void,lzo_srand31)2120 LZOLIB_PUBLIC(void, lzo_srand31) (lzo_rand31_p r, lzo_uint32l_t seed)
2121 {
2122     r->seed = seed & LZO_UINT32_C(0xffffffff);
2123 }
LZOLIB_PUBLIC(lzo_uint32l_t,lzo_rand31)2124 LZOLIB_PUBLIC(lzo_uint32l_t, lzo_rand31) (lzo_rand31_p r)
2125 {
2126     r->seed = r->seed * LZO_UINT32_C(1103515245) + 12345;
2127     r->seed &= LZO_UINT32_C(0x7fffffff);
2128     return r->seed;
2129 }
2130 #if defined(lzo_int64l_t)
LZOLIB_PUBLIC(void,lzo_srand48)2131 LZOLIB_PUBLIC(void, lzo_srand48) (lzo_rand48_p r, lzo_uint32l_t seed)
2132 {
2133     r->seed = seed & LZO_UINT32_C(0xffffffff);
2134     r->seed <<= 16; r->seed |= 0x330e;
2135 }
LZOLIB_PUBLIC(lzo_uint32l_t,lzo_rand48)2136 LZOLIB_PUBLIC(lzo_uint32l_t, lzo_rand48) (lzo_rand48_p r)
2137 {
2138     lzo_uint64l_t a;
2139     r->seed = r->seed * LZO_UINT64_C(25214903917) + 11;
2140     r->seed &= LZO_UINT64_C(0xffffffffffff);
2141     a = r->seed >> 17;
2142     return LZO_STATIC_CAST(lzo_uint32l_t, a);
2143 }
LZOLIB_PUBLIC(lzo_uint32l_t,lzo_rand48_r32)2144 LZOLIB_PUBLIC(lzo_uint32l_t, lzo_rand48_r32) (lzo_rand48_p r)
2145 {
2146     lzo_uint64l_t a;
2147     r->seed = r->seed * LZO_UINT64_C(25214903917) + 11;
2148     r->seed &= LZO_UINT64_C(0xffffffffffff);
2149     a = r->seed >> 16;
2150     return LZO_STATIC_CAST(lzo_uint32l_t, a);
2151 }
2152 #endif
2153 #if defined(lzo_int64l_t)
LZOLIB_PUBLIC(void,lzo_srand64)2154 LZOLIB_PUBLIC(void, lzo_srand64) (lzo_rand64_p r, lzo_uint64l_t seed)
2155 {
2156     r->seed = seed & LZO_UINT64_C(0xffffffffffffffff);
2157 }
LZOLIB_PUBLIC(lzo_uint32l_t,lzo_rand64)2158 LZOLIB_PUBLIC(lzo_uint32l_t, lzo_rand64) (lzo_rand64_p r)
2159 {
2160     lzo_uint64l_t a;
2161     r->seed = r->seed * LZO_UINT64_C(6364136223846793005) + 1;
2162 #if (LZO_SIZEOF_LZO_INT64L_T > 8)
2163     r->seed &= LZO_UINT64_C(0xffffffffffffffff);
2164 #endif
2165     a = r->seed >> 33;
2166     return LZO_STATIC_CAST(lzo_uint32l_t, a);
2167 }
LZOLIB_PUBLIC(lzo_uint32l_t,lzo_rand64_r32)2168 LZOLIB_PUBLIC(lzo_uint32l_t, lzo_rand64_r32) (lzo_rand64_p r)
2169 {
2170     lzo_uint64l_t a;
2171     r->seed = r->seed * LZO_UINT64_C(6364136223846793005) + 1;
2172 #if (LZO_SIZEOF_LZO_INT64L_T > 8)
2173     r->seed &= LZO_UINT64_C(0xffffffffffffffff);
2174 #endif
2175     a = r->seed >> 32;
2176     return LZO_STATIC_CAST(lzo_uint32l_t, a);
2177 }
2178 #endif
LZOLIB_PUBLIC(void,lzo_srandmt)2179 LZOLIB_PUBLIC(void, lzo_srandmt) (lzo_randmt_p r, lzo_uint32l_t seed)
2180 {
2181     unsigned i = 0;
2182     do {
2183         r->s[i++] = (seed &= LZO_UINT32_C(0xffffffff));
2184         seed ^= seed >> 30;
2185         seed = seed * LZO_UINT32_C(0x6c078965) + i;
2186     } while (i != 624);
2187     r->n = i;
2188 }
LZOLIB_PUBLIC(lzo_uint32l_t,lzo_randmt)2189 LZOLIB_PUBLIC(lzo_uint32l_t, lzo_randmt) (lzo_randmt_p r)
2190 {
2191     return (__LZOLIB_FUNCNAME(lzo_randmt_r32)(r)) >> 1;
2192 }
LZOLIB_PUBLIC(lzo_uint32l_t,lzo_randmt_r32)2193 LZOLIB_PUBLIC(lzo_uint32l_t, lzo_randmt_r32) (lzo_randmt_p r)
2194 {
2195     lzo_uint32l_t v;
2196     if __lzo_unlikely(r->n == 624) {
2197         unsigned i = 0, j;
2198         r->n = 0;
2199         do {
2200             j = i - 623; if (LZO_STATIC_CAST(int, j) < 0) j += 624;
2201             v = (r->s[i] & LZO_UINT32_C(0x80000000)) ^ (r->s[j] & LZO_UINT32_C(0x7fffffff));
2202             j = i - 227; if (LZO_STATIC_CAST(int, j) < 0) j += 624;
2203             r->s[i] = r->s[j] ^ (v >> 1);
2204             if (v & 1) r->s[i] ^= LZO_UINT32_C(0x9908b0df);
2205         } while (++i != 624);
2206     }
2207     { unsigned i = r->n++; v = r->s[i]; }
2208     v ^= v >> 11; v ^= (v & LZO_UINT32_C(0x013a58ad)) << 7;
2209     v ^= (v & LZO_UINT32_C(0x0001df8c)) << 15; v ^= v >> 18;
2210     return v;
2211 }
2212 #if defined(lzo_int64l_t)
LZOLIB_PUBLIC(void,lzo_srandmt64)2213 LZOLIB_PUBLIC(void, lzo_srandmt64) (lzo_randmt64_p r, lzo_uint64l_t seed)
2214 {
2215     unsigned i = 0;
2216     do {
2217         r->s[i++] = (seed &= LZO_UINT64_C(0xffffffffffffffff));
2218         seed ^= seed >> 62;
2219         seed = seed * LZO_UINT64_C(0x5851f42d4c957f2d) + i;
2220     } while (i != 312);
2221     r->n = i;
2222 }
2223 #if 0
2224 LZOLIB_PUBLIC(lzo_uint32l_t, lzo_randmt64) (lzo_randmt64_p r)
2225 {
2226     lzo_uint64l_t v;
2227     v = (__LZOLIB_FUNCNAME(lzo_randmt64_r64)(r)) >> 33;
2228     return LZO_STATIC_CAST(lzo_uint32l_t, v);
2229 }
2230 #endif
LZOLIB_PUBLIC(lzo_uint64l_t,lzo_randmt64_r64)2231 LZOLIB_PUBLIC(lzo_uint64l_t, lzo_randmt64_r64) (lzo_randmt64_p r)
2232 {
2233     lzo_uint64l_t v;
2234     if __lzo_unlikely(r->n == 312) {
2235         unsigned i = 0, j;
2236         r->n = 0;
2237         do {
2238             j = i - 311; if (LZO_STATIC_CAST(int, j) < 0) j += 312;
2239             v = (r->s[i] & LZO_UINT64_C(0xffffffff80000000)) ^ (r->s[j] & LZO_UINT64_C(0x7fffffff));
2240             j = i - 156; if (LZO_STATIC_CAST(int, j) < 0) j += 312;
2241             r->s[i] = r->s[j] ^ (v >> 1);
2242             if (v & 1) r->s[i] ^= LZO_UINT64_C(0xb5026f5aa96619e9);
2243         } while (++i != 312);
2244     }
2245     { unsigned i = r->n++; v = r->s[i]; }
2246     v ^= (v & LZO_UINT64_C(0xaaaaaaaaa0000000)) >> 29;
2247     v ^= (v & LZO_UINT64_C(0x38eb3ffff6d3)) << 17;
2248     v ^= (v & LZO_UINT64_C(0x7ffbf77)) << 37;
2249     return v ^ (v >> 43);
2250 }
2251 #endif
2252 #endif
2253 #if defined(LZO_WANT_ACCLIB_RDTSC)
2254 #  undef LZO_WANT_ACCLIB_RDTSC
2255 #define __LZOLIB_RDTSC_CH_INCLUDED 1
2256 #if !defined(LZOLIB_PUBLIC)
2257 #  define LZOLIB_PUBLIC(r,f)    r __LZOLIB_FUNCNAME(f)
2258 #endif
2259 #if defined(lzo_int32e_t)
2260 #if (LZO_OS_WIN32 && LZO_CC_PELLESC && (__POCC__ >= 290))
2261 #  pragma warn(push)
2262 #  pragma warn(disable:2007)
2263 #endif
2264 #if (LZO_ARCH_AMD64 || LZO_ARCH_I386) && (LZO_ASM_SYNTAX_GNUC)
2265 #if (LZO_ARCH_AMD64 && LZO_CC_INTELC)
2266 #  define __LZOLIB_RDTSC_REGS   : : "c" (t) : "memory", "rax", "rdx"
2267 #elif (LZO_ARCH_AMD64)
2268 #  define __LZOLIB_RDTSC_REGS   : : "c" (t) : "cc", "memory", "rax", "rdx"
2269 #elif (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC < 0x020000ul))
2270 #  define __LZOLIB_RDTSC_REGS   : : "c" (t) : "ax", "dx"
2271 #elif (LZO_ARCH_I386 && LZO_CC_INTELC)
2272 #  define __LZOLIB_RDTSC_REGS   : : "c" (t) : "memory", "eax", "edx"
2273 #else
2274 #  define __LZOLIB_RDTSC_REGS   : : "c" (t) : "cc", "memory", "eax", "edx"
2275 #endif
2276 #endif
LZOLIB_PUBLIC(int,lzo_tsc_read)2277 LZOLIB_PUBLIC(int, lzo_tsc_read) (lzo_uint32e_t* t)
2278 {
2279 #if (LZO_ARCH_AMD64 || LZO_ARCH_I386) && (LZO_ASM_SYNTAX_GNUC)
2280     __asm__ __volatile__(
2281         "clc \n" ".byte 0x0f,0x31\n"
2282         "movl %%eax,(%0)\n" "movl %%edx,4(%0)\n"
2283         __LZOLIB_RDTSC_REGS
2284     );
2285     return 0;
2286 #elif (LZO_ARCH_I386) && (LZO_ASM_SYNTAX_MSC)
2287     LZO_UNUSED(t);
2288     __asm {
2289         mov ecx, t
2290         clc
2291 #  if (LZO_CC_MSC && (_MSC_VER < 1200))
2292         _emit 0x0f
2293         _emit 0x31
2294 #  else
2295         rdtsc
2296 #  endif
2297         mov [ecx], eax
2298         mov [ecx+4], edx
2299     }
2300     return 0;
2301 #else
2302     t[0] = t[1] = 0; return -1;
2303 #endif
2304 }
2305 #if (LZO_OS_WIN32 && LZO_CC_PELLESC && (__POCC__ >= 290))
2306 #  pragma warn(pop)
2307 #endif
2308 #endif
2309 #endif
2310 #if defined(LZO_WANT_ACCLIB_DOSALLOC)
2311 #  undef LZO_WANT_ACCLIB_DOSALLOC
2312 #define __LZOLIB_DOSALLOC_CH_INCLUDED 1
2313 #if !defined(LZOLIB_PUBLIC)
2314 #  define LZOLIB_PUBLIC(r,f)    r __LZOLIB_FUNCNAME(f)
2315 #endif
2316 #if (LZO_OS_OS216)
2317 LZO_EXTERN_C unsigned short __far __pascal DosAllocHuge(unsigned short, unsigned short, unsigned short __far *, unsigned short, unsigned short);
2318 LZO_EXTERN_C unsigned short __far __pascal DosFreeSeg(unsigned short);
2319 #endif
2320 #if (LZO_OS_DOS16 || LZO_OS_WIN16)
2321 #if !(LZO_CC_AZTECC)
LZOLIB_PUBLIC(void __far *,lzo_dos_alloc)2322 LZOLIB_PUBLIC(void __far*, lzo_dos_alloc) (unsigned long size)
2323 {
2324     void __far* p = 0;
2325     union REGS ri, ro;
2326     if ((long)size <= 0)
2327         return p;
2328     size = (size + 15) >> 4;
2329     if (size > 0xffffu)
2330         return p;
2331     ri.x.ax = 0x4800;
2332     ri.x.bx = (unsigned short) size;
2333     int86(0x21, &ri, &ro);
2334     if ((ro.x.cflag & 1) == 0)
2335         p = (void __far*) LZO_PTR_MK_FP(ro.x.ax, 0);
2336     return p;
2337 }
LZOLIB_PUBLIC(int,lzo_dos_free)2338 LZOLIB_PUBLIC(int, lzo_dos_free) (void __far* p)
2339 {
2340     union REGS ri, ro;
2341     struct SREGS rs;
2342     if (!p)
2343         return 0;
2344     if (LZO_PTR_FP_OFF(p) != 0)
2345         return -1;
2346     segread(&rs);
2347     ri.x.ax = 0x4900;
2348     rs.es = LZO_PTR_FP_SEG(p);
2349     int86x(0x21, &ri, &ro, &rs);
2350     if (ro.x.cflag & 1)
2351         return -1;
2352     return 0;
2353 }
2354 #endif
2355 #endif
2356 #if (LZO_OS_OS216)
LZOLIB_PUBLIC(void __far *,lzo_dos_alloc)2357 LZOLIB_PUBLIC(void __far*, lzo_dos_alloc) (unsigned long size)
2358 {
2359     void __far* p = 0;
2360     unsigned short sel = 0;
2361     if ((long)size <= 0)
2362         return p;
2363     if (DosAllocHuge((unsigned short)(size >> 16), (unsigned short)size, &sel, 0, 0) == 0)
2364         p = (void __far*) LZO_PTR_MK_FP(sel, 0);
2365     return p;
2366 }
LZOLIB_PUBLIC(int,lzo_dos_free)2367 LZOLIB_PUBLIC(int, lzo_dos_free) (void __far* p)
2368 {
2369     if (!p)
2370         return 0;
2371     if (LZO_PTR_FP_OFF(p) != 0)
2372         return -1;
2373     if (DosFreeSeg(LZO_PTR_FP_SEG(p)) != 0)
2374         return -1;
2375     return 0;
2376 }
2377 #endif
2378 #endif
2379 #if defined(LZO_WANT_ACCLIB_GETOPT)
2380 #  undef LZO_WANT_ACCLIB_GETOPT
2381 #define __LZOLIB_GETOPT_CH_INCLUDED 1
2382 #if !defined(LZOLIB_PUBLIC)
2383 #  define LZOLIB_PUBLIC(r,f)    r __LZOLIB_FUNCNAME(f)
2384 #endif
LZOLIB_PUBLIC(void,lzo_getopt_init)2385 LZOLIB_PUBLIC(void, lzo_getopt_init) (lzo_getopt_p g,
2386                                       int start_argc, int argc, char** argv)
2387 {
2388     memset(g, 0, sizeof(*g));
2389     g->optind = start_argc;
2390     g->argc = argc; g->argv = argv;
2391     g->optopt = -1;
2392 }
__LZOLIB_FUNCNAME(lzo_getopt_rotate)2393 static int __LZOLIB_FUNCNAME(lzo_getopt_rotate) (char** p, int first, int middle, int last)
2394 {
2395     int i = middle, n = middle - first;
2396     if (first >= middle || middle >= last) return 0;
2397     for (;;)
2398     {
2399         char* t = p[first]; p[first] = p[i]; p[i] = t;
2400         if (++first == middle)
2401         {
2402             if (++i == last) break;
2403             middle = i;
2404         }
2405         else if (++i == last)
2406             i = middle;
2407     }
2408     return n;
2409 }
__LZOLIB_FUNCNAME(lzo_getopt_perror)2410 static int __LZOLIB_FUNCNAME(lzo_getopt_perror) (lzo_getopt_p g, int ret, const char* f, ...)
2411 {
2412     if (g->opterr)
2413     {
2414 #if (HAVE_STDARG_H)
2415         struct { va_list ap; } s;
2416         va_start(s.ap, f);
2417         g->opterr(g, f, &s);
2418         va_end(s.ap);
2419 #else
2420         g->opterr(g, f, NULL);
2421 #endif
2422     }
2423     ++g->errcount;
2424     return ret;
2425 }
LZOLIB_PUBLIC(int,lzo_getopt)2426 LZOLIB_PUBLIC(int, lzo_getopt) (lzo_getopt_p g,
2427                                 const char* shortopts,
2428                                 const lzo_getopt_longopt_p longopts,
2429                                 int* longind)
2430 {
2431 #define pe  __LZOLIB_FUNCNAME(lzo_getopt_perror)
2432     int ordering = LZO_GETOPT_PERMUTE;
2433     int missing_arg_ret = g->bad_option;
2434     char* a;
2435     if (shortopts)
2436     {
2437         if (*shortopts == '-' || *shortopts == '+')
2438             ordering = *shortopts++ == '-' ? LZO_GETOPT_RETURN_IN_ORDER : LZO_GETOPT_REQUIRE_ORDER;
2439         if (*shortopts == ':')
2440             missing_arg_ret = *shortopts++;
2441     }
2442     g->optarg = NULL;
2443     if (g->optopt == -1)
2444         g->optopt = g->bad_option;
2445     if (longind)
2446         *longind = -1;
2447     if (g->eof)
2448         return -1;
2449     if (g->shortpos)
2450         goto lzo_label_next_shortopt;
2451     g->optind -= __LZOLIB_FUNCNAME(lzo_getopt_rotate)(g->argv, g->pending_rotate_first, g->pending_rotate_middle, g->optind);
2452     g->pending_rotate_first = g->pending_rotate_middle = g->optind;
2453     if (ordering == LZO_GETOPT_PERMUTE)
2454     {
2455         while (g->optind < g->argc && !(g->argv[g->optind][0] == '-' && g->argv[g->optind][1]))
2456             ++g->optind;
2457         g->pending_rotate_middle = g->optind;
2458     }
2459     if (g->optind >= g->argc)
2460     {
2461         g->optind = g->pending_rotate_first;
2462         goto lzo_label_eof;
2463     }
2464     a = g->argv[g->optind];
2465     if (a[0] == '-' && a[1] == '-')
2466     {
2467         size_t l = 0;
2468         const lzo_getopt_longopt_p o;
2469         const lzo_getopt_longopt_p o1 = NULL;
2470         const lzo_getopt_longopt_p o2 = NULL;
2471         int need_exact = 0;
2472         ++g->optind;
2473         if (!a[2])
2474             goto lzo_label_eof;
2475         for (a += 2; a[l] && a[l] != '=' && a[l] != '#'; )
2476             ++l;
2477         for (o = longopts; l && o && o->name; ++o)
2478         {
2479             if (strncmp(a, o->name, l) != 0)
2480                 continue;
2481             if (!o->name[l])
2482                 goto lzo_label_found_o;
2483             need_exact |= o->has_arg & LZO_GETOPT_EXACT_ARG;
2484             if (o1) o2 = o;
2485             else    o1 = o;
2486         }
2487         if (!o1 || need_exact)
2488             return pe(g, g->bad_option, "unrecognized option '--%s'", a);
2489         if (o2)
2490             return pe(g, g->bad_option, "option '--%s' is ambiguous (could be '--%s' or '--%s')", a, o1->name, o2->name);
2491         o = o1;
2492     lzo_label_found_o:
2493         a += l;
2494         switch (o->has_arg & 0x2f)
2495         {
2496         case LZO_GETOPT_OPTIONAL_ARG:
2497             if (a[0])
2498                 g->optarg = a + 1;
2499             break;
2500         case LZO_GETOPT_REQUIRED_ARG:
2501             if (a[0])
2502                 g->optarg = a + 1;
2503             else if (g->optind < g->argc)
2504                 g->optarg = g->argv[g->optind++];
2505             if (!g->optarg)
2506                 return pe(g, missing_arg_ret, "option '--%s' requires an argument", o->name);
2507             break;
2508         case LZO_GETOPT_REQUIRED_ARG | 0x20:
2509             if (a[0] && a[1])
2510                 g->optarg = a + 1;
2511             if (!g->optarg)
2512                 return pe(g, missing_arg_ret, "option '--%s=' requires an argument", o->name);
2513             break;
2514         default:
2515             if (a[0])
2516                 return pe(g, g->bad_option, "option '--%s' doesn't allow an argument", o->name);
2517             break;
2518         }
2519         if (longind)
2520             *longind = (int) (o - longopts);
2521         if (o->flag)
2522         {
2523             *o->flag = o->val;
2524             return 0;
2525         }
2526         return o->val;
2527     }
2528     if (a[0] == '-' && a[1])
2529     {
2530         unsigned char c;
2531         const char* s;
2532     lzo_label_next_shortopt:
2533         a = g->argv[g->optind] + ++g->shortpos;
2534         c = (unsigned char) *a++; s = NULL;
2535         if (c != ':' && shortopts)
2536             s = strchr(shortopts, c);
2537         if (!s || s[1] != ':')
2538         {
2539             if (!a[0])
2540                 ++g->optind, g->shortpos = 0;
2541             if (!s)
2542             {
2543                 g->optopt = c;
2544                 return pe(g, g->bad_option, "invalid option '-%c'", c);
2545             }
2546         }
2547         else
2548         {
2549             ++g->optind, g->shortpos = 0;
2550             if (a[0])
2551                 g->optarg = a;
2552             else if (s[2] != ':')
2553             {
2554                 if (g->optind < g->argc)
2555                     g->optarg = g->argv[g->optind++];
2556                 else
2557                 {
2558                     g->optopt = c;
2559                     return pe(g, missing_arg_ret, "option '-%c' requires an argument", c);
2560                 }
2561             }
2562         }
2563         return c;
2564     }
2565     if (ordering == LZO_GETOPT_RETURN_IN_ORDER)
2566     {
2567         ++g->optind;
2568         g->optarg = a;
2569         return 1;
2570     }
2571 lzo_label_eof:
2572     g->optind -= __LZOLIB_FUNCNAME(lzo_getopt_rotate)(g->argv, g->pending_rotate_first, g->pending_rotate_middle, g->optind);
2573     g->pending_rotate_first = g->pending_rotate_middle = g->optind;
2574     g->eof = 1;
2575     return -1;
2576 #undef pe
2577 }
2578 #endif
2579 #if defined(LZO_WANT_ACCLIB_HALLOC)
2580 #  undef LZO_WANT_ACCLIB_HALLOC
2581 #define __LZOLIB_HALLOC_CH_INCLUDED 1
2582 #if !defined(LZOLIB_PUBLIC)
2583 #  define LZOLIB_PUBLIC(r,f)    r __LZOLIB_FUNCNAME(f)
2584 #endif
2585 #if (LZO_HAVE_MM_HUGE_PTR)
2586 #if 1 && (LZO_OS_DOS16 && defined(BLX286))
2587 #  define __LZOLIB_HALLOC_USE_DAH 1
2588 #elif 1 && (LZO_OS_DOS16 && defined(DOSX286))
2589 #  define __LZOLIB_HALLOC_USE_DAH 1
2590 #elif 1 && (LZO_OS_OS216)
2591 #  define __LZOLIB_HALLOC_USE_DAH 1
2592 #elif 1 && (LZO_OS_WIN16)
2593 #  define __LZOLIB_HALLOC_USE_GA 1
2594 #elif 1 && (LZO_OS_DOS16) && (LZO_CC_BORLANDC) && defined(__DPMI16__)
2595 #  define __LZOLIB_HALLOC_USE_GA 1
2596 #endif
2597 #endif
2598 #if (__LZOLIB_HALLOC_USE_DAH)
2599 #if 0 && (LZO_OS_OS216)
2600 #include <os2.h>
2601 #else
2602 LZO_EXTERN_C unsigned short __far __pascal DosAllocHuge(unsigned short, unsigned short, unsigned short __far *, unsigned short, unsigned short);
2603 LZO_EXTERN_C unsigned short __far __pascal DosFreeSeg(unsigned short);
2604 #endif
2605 #endif
2606 #if (__LZOLIB_HALLOC_USE_GA)
2607 #if 0
2608 #define STRICT 1
2609 #include <windows.h>
2610 #else
2611 LZO_EXTERN_C const void __near* __far __pascal GlobalAlloc(unsigned, unsigned long);
2612 LZO_EXTERN_C const void __near* __far __pascal GlobalFree(const void __near*);
2613 LZO_EXTERN_C unsigned long __far __pascal GlobalHandle(unsigned);
2614 LZO_EXTERN_C void __far* __far __pascal GlobalLock(const void __near*);
2615 LZO_EXTERN_C int __far __pascal GlobalUnlock(const void __near*);
2616 #endif
2617 #endif
LZOLIB_PUBLIC(lzo_hvoid_p,lzo_halloc)2618 LZOLIB_PUBLIC(lzo_hvoid_p, lzo_halloc) (lzo_hsize_t size)
2619 {
2620     lzo_hvoid_p p = LZO_STATIC_CAST(lzo_hvoid_p, 0);
2621     if (!(size > 0))
2622         return p;
2623 #if 0 && defined(__palmos__)
2624     p = MemPtrNew(size);
2625 #elif !(LZO_HAVE_MM_HUGE_PTR)
2626     if (size < LZO_STATIC_CAST(size_t, -1))
2627         p = malloc(LZO_STATIC_CAST(size_t, size));
2628 #else
2629     if (LZO_STATIC_CAST(long, size) <= 0)
2630         return p;
2631 {
2632 #if (__LZOLIB_HALLOC_USE_DAH)
2633     unsigned short sel = 0;
2634     if (DosAllocHuge((unsigned short)(size >> 16), (unsigned short)size, &sel, 0, 0) == 0)
2635         p = (lzo_hvoid_p) LZO_PTR_MK_FP(sel, 0);
2636 #elif (__LZOLIB_HALLOC_USE_GA)
2637     const void __near* h = GlobalAlloc(2, size);
2638     if (h) {
2639         p = GlobalLock(h);
2640         if (p && LZO_PTR_FP_OFF(p) != 0) {
2641             GlobalUnlock(h);
2642             p = 0;
2643         }
2644         if (!p)
2645             GlobalFree(h);
2646     }
2647 #elif (LZO_CC_MSC && (_MSC_VER >= 700))
2648     p = _halloc(size, 1);
2649 #elif (LZO_CC_MSC || LZO_CC_WATCOMC)
2650     p = halloc(size, 1);
2651 #elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC)
2652     p = farmalloc(size);
2653 #elif (LZO_CC_BORLANDC || LZO_CC_TURBOC)
2654     p = farmalloc(size);
2655 #elif (LZO_CC_AZTECC)
2656     p = lmalloc(size);
2657 #else
2658     if (size < LZO_STATIC_CAST(size_t, -1))
2659         p = malloc((size_t) size);
2660 #endif
2661 }
2662 #endif
2663     return p;
2664 }
LZOLIB_PUBLIC(void,lzo_hfree)2665 LZOLIB_PUBLIC(void, lzo_hfree) (lzo_hvoid_p p)
2666 {
2667     if (!p)
2668         return;
2669 #if 0 && defined(__palmos__)
2670     MemPtrFree(p);
2671 #elif !(LZO_HAVE_MM_HUGE_PTR)
2672     free(p);
2673 #else
2674 #if (__LZOLIB_HALLOC_USE_DAH)
2675     if (LZO_PTR_FP_OFF(p) == 0)
2676         DosFreeSeg((unsigned short) LZO_PTR_FP_SEG(p));
2677 #elif (__LZOLIB_HALLOC_USE_GA)
2678     if (LZO_PTR_FP_OFF(p) == 0) {
2679         const void __near* h = (const void __near*) (unsigned) GlobalHandle(LZO_PTR_FP_SEG(p));
2680         if (h) {
2681             GlobalUnlock(h);
2682             GlobalFree(h);
2683         }
2684     }
2685 #elif (LZO_CC_MSC && (_MSC_VER >= 700))
2686     _hfree(p);
2687 #elif (LZO_CC_MSC || LZO_CC_WATCOMC)
2688     hfree(p);
2689 #elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC)
2690     farfree((void __far*) p);
2691 #elif (LZO_CC_BORLANDC || LZO_CC_TURBOC)
2692     farfree((void __far*) p);
2693 #elif (LZO_CC_AZTECC)
2694     lfree(p);
2695 #else
2696     free(p);
2697 #endif
2698 #endif
2699 }
2700 #endif
2701 #if defined(LZO_WANT_ACCLIB_HFREAD)
2702 #  undef LZO_WANT_ACCLIB_HFREAD
2703 #define __LZOLIB_HFREAD_CH_INCLUDED 1
2704 #if !defined(LZOLIB_PUBLIC)
2705 #  define LZOLIB_PUBLIC(r,f)    r __LZOLIB_FUNCNAME(f)
2706 #endif
LZOLIB_PUBLIC(lzo_hsize_t,lzo_hfread)2707 LZOLIB_PUBLIC(lzo_hsize_t, lzo_hfread) (void* vfp, lzo_hvoid_p buf, lzo_hsize_t size)
2708 {
2709     FILE* fp = LZO_STATIC_CAST(FILE *, vfp);
2710 #if (LZO_HAVE_MM_HUGE_PTR)
2711 #if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM)
2712 #define __LZOLIB_REQUIRE_HMEMCPY_CH 1
2713     unsigned char tmp[512];
2714     lzo_hsize_t l = 0;
2715     while (l < size)
2716     {
2717         size_t n = size - l > sizeof(tmp) ? sizeof(tmp) : (size_t) (size - l);
2718         n = fread(tmp, 1, n, fp);
2719         if (n == 0)
2720             break;
2721         __LZOLIB_FUNCNAME(lzo_hmemcpy)((lzo_hbyte_p)buf + l, tmp, (lzo_hsize_t)n);
2722         l += n;
2723     }
2724     return l;
2725 #elif (LZO_MM_COMPACT || LZO_MM_LARGE || LZO_MM_HUGE)
2726     lzo_hbyte_p b = (lzo_hbyte_p) buf;
2727     lzo_hsize_t l = 0;
2728     while (l < size)
2729     {
2730         size_t n;
2731         n = LZO_PTR_FP_OFF(b); n = (n <= 1) ? 0x8000u : (0u - n);
2732         if ((lzo_hsize_t) n > size - l)
2733             n = (size_t) (size - l);
2734         n = fread((void __far*)b, 1, n, fp);
2735         if (n == 0)
2736             break;
2737         b += n; l += n;
2738     }
2739     return l;
2740 #else
2741 #  error "unknown memory model"
2742 #endif
2743 #else
2744     return fread(buf, 1, size, fp);
2745 #endif
2746 }
LZOLIB_PUBLIC(lzo_hsize_t,lzo_hfwrite)2747 LZOLIB_PUBLIC(lzo_hsize_t, lzo_hfwrite) (void* vfp, const lzo_hvoid_p buf, lzo_hsize_t size)
2748 {
2749     FILE* fp = LZO_STATIC_CAST(FILE *, vfp);
2750 #if (LZO_HAVE_MM_HUGE_PTR)
2751 #if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM)
2752 #define __LZOLIB_REQUIRE_HMEMCPY_CH 1
2753     unsigned char tmp[512];
2754     lzo_hsize_t l = 0;
2755     while (l < size)
2756     {
2757         size_t n = size - l > sizeof(tmp) ? sizeof(tmp) : (size_t) (size - l);
2758         __LZOLIB_FUNCNAME(lzo_hmemcpy)(tmp, (const lzo_hbyte_p)buf + l, (lzo_hsize_t)n);
2759         n = fwrite(tmp, 1, n, fp);
2760         if (n == 0)
2761             break;
2762         l += n;
2763     }
2764     return l;
2765 #elif (LZO_MM_COMPACT || LZO_MM_LARGE || LZO_MM_HUGE)
2766     const lzo_hbyte_p b = (const lzo_hbyte_p) buf;
2767     lzo_hsize_t l = 0;
2768     while (l < size)
2769     {
2770         size_t n;
2771         n = LZO_PTR_FP_OFF(b); n = (n <= 1) ? 0x8000u : (0u - n);
2772         if ((lzo_hsize_t) n > size - l)
2773             n = (size_t) (size - l);
2774         n = fwrite((void __far*)b, 1, n, fp);
2775         if (n == 0)
2776             break;
2777         b += n; l += n;
2778     }
2779     return l;
2780 #else
2781 #  error "unknown memory model"
2782 #endif
2783 #else
2784     return fwrite(buf, 1, size, fp);
2785 #endif
2786 }
2787 #endif
2788 #if defined(LZO_WANT_ACCLIB_HSREAD)
2789 #  undef LZO_WANT_ACCLIB_HSREAD
2790 #define __LZOLIB_HSREAD_CH_INCLUDED 1
2791 #if !defined(LZOLIB_PUBLIC)
2792 #  define LZOLIB_PUBLIC(r,f)    r __LZOLIB_FUNCNAME(f)
2793 #endif
LZOLIB_PUBLIC(long,lzo_safe_hread)2794 LZOLIB_PUBLIC(long, lzo_safe_hread) (int fd, lzo_hvoid_p buf, long size)
2795 {
2796     lzo_hbyte_p b = (lzo_hbyte_p) buf;
2797     long l = 0;
2798     int saved_errno;
2799     saved_errno = errno;
2800     while (l < size)
2801     {
2802         long n = size - l;
2803 #if (LZO_HAVE_MM_HUGE_PTR)
2804 #  define __LZOLIB_REQUIRE_HREAD_CH 1
2805         errno = 0; n = lzo_hread(fd, b, n);
2806 #elif (LZO_OS_DOS32) && defined(__DJGPP__)
2807         errno = 0; n = _read(fd, b, n);
2808 #else
2809         errno = 0; n = read(fd, b, n);
2810 #endif
2811         if (n == 0)
2812             break;
2813         if (n < 0) {
2814 #if defined(EAGAIN)
2815             if (errno == (EAGAIN)) continue;
2816 #endif
2817 #if defined(EINTR)
2818             if (errno == (EINTR)) continue;
2819 #endif
2820             if (errno == 0) errno = 1;
2821             return l;
2822         }
2823         b += n; l += n;
2824     }
2825     errno = saved_errno;
2826     return l;
2827 }
LZOLIB_PUBLIC(long,lzo_safe_hwrite)2828 LZOLIB_PUBLIC(long, lzo_safe_hwrite) (int fd, const lzo_hvoid_p buf, long size)
2829 {
2830     const lzo_hbyte_p b = (const lzo_hbyte_p) buf;
2831     long l = 0;
2832     int saved_errno;
2833     saved_errno = errno;
2834     while (l < size)
2835     {
2836         long n = size - l;
2837 #if (LZO_HAVE_MM_HUGE_PTR)
2838 #  define __LZOLIB_REQUIRE_HREAD_CH 1
2839         errno = 0; n = lzo_hwrite(fd, b, n);
2840 #elif (LZO_OS_DOS32) && defined(__DJGPP__)
2841         errno = 0; n = _write(fd, b, n);
2842 #else
2843         errno = 0; n = write(fd, b, n);
2844 #endif
2845         if (n == 0)
2846             break;
2847         if (n < 0) {
2848 #if defined(EAGAIN)
2849             if (errno == (EAGAIN)) continue;
2850 #endif
2851 #if defined(EINTR)
2852             if (errno == (EINTR)) continue;
2853 #endif
2854             if (errno == 0) errno = 1;
2855             return l;
2856         }
2857         b += n; l += n;
2858     }
2859     errno = saved_errno;
2860     return l;
2861 }
2862 #endif
2863 #if defined(LZO_WANT_ACCLIB_PCLOCK)
2864 #  undef LZO_WANT_ACCLIB_PCLOCK
2865 #define __LZOLIB_PCLOCK_CH_INCLUDED 1
2866 #if !defined(LZOLIB_PUBLIC)
2867 #  define LZOLIB_PUBLIC(r,f)    r __LZOLIB_FUNCNAME(f)
2868 #endif
2869 #if 1 && (LZO_OS_POSIX_LINUX && LZO_ARCH_AMD64 && LZO_ASM_SYNTAX_GNUC)
2870 #ifndef lzo_pclock_syscall_clock_gettime
2871 #define lzo_pclock_syscall_clock_gettime lzo_pclock_syscall_clock_gettime
2872 #endif
lzo_pclock_syscall_clock_gettime(long clockid,struct timespec * ts)2873 __lzo_static_noinline long lzo_pclock_syscall_clock_gettime(long clockid, struct timespec *ts)
2874 {
2875     unsigned long r = 228;
2876     __asm__ __volatile__("syscall\n" : "=a" (r) : "0" (r), "D" (clockid), "S" (ts) __LZO_ASM_CLOBBER_LIST_CC_MEMORY);
2877     return LZO_ICAST(long, r);
2878 }
2879 #endif
2880 #if 1 && (LZO_OS_POSIX_LINUX && LZO_ARCH_I386 && LZO_ASM_SYNTAX_GNUC) && defined(lzo_int64l_t)
2881 #ifndef lzo_pclock_syscall_clock_gettime
2882 #define lzo_pclock_syscall_clock_gettime lzo_pclock_syscall_clock_gettime
2883 #endif
lzo_pclock_syscall_clock_gettime(long clockid,struct timespec * ts)2884 __lzo_static_noinline long lzo_pclock_syscall_clock_gettime(long clockid, struct timespec *ts)
2885 {
2886     unsigned long r = 265;
2887     __asm__ __volatile__("pushl %%ebx\n pushl %%edx\n popl %%ebx\n int $0x80\n popl %%ebx\n" : "=a" (r) : "0" (r), "d" (clockid), "c" (ts) __LZO_ASM_CLOBBER_LIST_CC_MEMORY);
2888     return LZO_ICAST(long, r);
2889 }
2890 #endif
2891 #if 0 && defined(lzo_pclock_syscall_clock_gettime)
2892 #ifndef lzo_pclock_read_clock_gettime_r_syscall
2893 #define lzo_pclock_read_clock_gettime_r_syscall lzo_pclock_read_clock_gettime_r_syscall
2894 #endif
2895 static int lzo_pclock_read_clock_gettime_r_syscall(lzo_pclock_handle_p h, lzo_pclock_p c)
2896 {
2897      struct timespec ts;
2898     if (lzo_pclock_syscall_clock_gettime(0, &ts) != 0)
2899         return -1;
2900     c->tv_sec = ts.tv_sec;
2901     c->tv_nsec = LZO_STATIC_CAST(lzo_uint32l_t, ts.tv_nsec);
2902     LZO_UNUSED(h); return 0;
2903 }
2904 #endif
2905 #if (HAVE_GETTIMEOFDAY)
2906 #ifndef lzo_pclock_read_gettimeofday
2907 #define lzo_pclock_read_gettimeofday lzo_pclock_read_gettimeofday
2908 #endif
lzo_pclock_read_gettimeofday(lzo_pclock_handle_p h,lzo_pclock_p c)2909 static int lzo_pclock_read_gettimeofday(lzo_pclock_handle_p h, lzo_pclock_p c)
2910 {
2911     struct timeval tv;
2912     if (gettimeofday(&tv, NULL) != 0)
2913         return -1;
2914 #if defined(lzo_int64l_t)
2915     c->tv_sec = tv.tv_sec;
2916 #else
2917     c->tv_sec_high = 0;
2918     c->tv_sec_low = tv.tv_sec;
2919 #endif
2920     c->tv_nsec = LZO_STATIC_CAST(lzo_uint32l_t, (tv.tv_usec * 1000u));
2921     LZO_UNUSED(h); return 0;
2922 }
2923 #endif
2924 #if defined(CLOCKS_PER_SEC) && !(LZO_CFG_NO_DOUBLE)
2925 #ifndef lzo_pclock_read_clock
2926 #define lzo_pclock_read_clock lzo_pclock_read_clock
2927 #endif
lzo_pclock_read_clock(lzo_pclock_handle_p h,lzo_pclock_p c)2928 static int lzo_pclock_read_clock(lzo_pclock_handle_p h, lzo_pclock_p c)
2929 {
2930     clock_t ticks;
2931     double secs;
2932 #if defined(lzo_int64l_t)
2933     lzo_uint64l_t nsecs;
2934     ticks = clock();
2935     secs = LZO_STATIC_CAST(double, ticks) / (CLOCKS_PER_SEC);
2936     nsecs = LZO_STATIC_CAST(lzo_uint64l_t, (secs * 1000000000.0));
2937     c->tv_sec = LZO_STATIC_CAST(lzo_int64l_t, (nsecs / 1000000000ul));
2938     nsecs = (nsecs % 1000000000ul);
2939     c->tv_nsec = LZO_STATIC_CAST(lzo_uint32l_t, nsecs);
2940 #else
2941     ticks = clock();
2942     secs = LZO_STATIC_CAST(double, ticks) / (CLOCKS_PER_SEC);
2943     c->tv_sec_high = 0;
2944     c->tv_sec_low = LZO_STATIC_CAST(lzo_uint32l_t, (secs + 0.5));
2945     c->tv_nsec = 0;
2946 #endif
2947     LZO_UNUSED(h); return 0;
2948 }
2949 #endif
2950 #if 1 && defined(lzo_pclock_syscall_clock_gettime)
2951 #ifndef lzo_pclock_read_clock_gettime_m_syscall
2952 #define lzo_pclock_read_clock_gettime_m_syscall lzo_pclock_read_clock_gettime_m_syscall
2953 #endif
lzo_pclock_read_clock_gettime_m_syscall(lzo_pclock_handle_p h,lzo_pclock_p c)2954 static int lzo_pclock_read_clock_gettime_m_syscall(lzo_pclock_handle_p h, lzo_pclock_p c)
2955 {
2956      struct timespec ts;
2957     if (lzo_pclock_syscall_clock_gettime(1, &ts) != 0)
2958         return -1;
2959     c->tv_sec = ts.tv_sec;
2960     c->tv_nsec = LZO_STATIC_CAST(lzo_uint32l_t, ts.tv_nsec);
2961     LZO_UNUSED(h); return 0;
2962 }
2963 #endif
2964 #if (LZO_OS_DOS32 && LZO_CC_GNUC) && defined(__DJGPP__) && defined(UCLOCKS_PER_SEC) && !(LZO_CFG_NO_DOUBLE)
2965 #ifndef lzo_pclock_read_uclock
2966 #define lzo_pclock_read_uclock lzo_pclock_read_uclock
2967 #endif
lzo_pclock_read_uclock(lzo_pclock_handle_p h,lzo_pclock_p c)2968 static int lzo_pclock_read_uclock(lzo_pclock_handle_p h, lzo_pclock_p c)
2969 {
2970     lzo_uint64l_t ticks;
2971     double secs;
2972     lzo_uint64l_t nsecs;
2973     ticks = uclock();
2974     secs = LZO_STATIC_CAST(double, ticks) / (UCLOCKS_PER_SEC);
2975     nsecs = LZO_STATIC_CAST(lzo_uint64l_t, (secs * 1000000000.0));
2976     c->tv_sec = nsecs / 1000000000ul;
2977     c->tv_nsec = LZO_STATIC_CAST(lzo_uint32l_t, (nsecs % 1000000000ul));
2978     LZO_UNUSED(h); return 0;
2979 }
2980 #endif
2981 #if 1 && (HAVE_CLOCK_GETTIME) && defined(CLOCK_PROCESS_CPUTIME_ID) && defined(lzo_int64l_t)
2982 #ifndef lzo_pclock_read_clock_gettime_p_libc
2983 #define lzo_pclock_read_clock_gettime_p_libc lzo_pclock_read_clock_gettime_p_libc
2984 #endif
lzo_pclock_read_clock_gettime_p_libc(lzo_pclock_handle_p h,lzo_pclock_p c)2985 static int lzo_pclock_read_clock_gettime_p_libc(lzo_pclock_handle_p h, lzo_pclock_p c)
2986 {
2987     struct timespec ts;
2988     if (clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts) != 0)
2989         return -1;
2990     c->tv_sec = ts.tv_sec;
2991     c->tv_nsec = LZO_STATIC_CAST(lzo_uint32l_t, ts.tv_nsec);
2992     LZO_UNUSED(h); return 0;
2993 }
2994 #endif
2995 #if 1 && defined(lzo_pclock_syscall_clock_gettime)
2996 #ifndef lzo_pclock_read_clock_gettime_p_syscall
2997 #define lzo_pclock_read_clock_gettime_p_syscall lzo_pclock_read_clock_gettime_p_syscall
2998 #endif
lzo_pclock_read_clock_gettime_p_syscall(lzo_pclock_handle_p h,lzo_pclock_p c)2999 static int lzo_pclock_read_clock_gettime_p_syscall(lzo_pclock_handle_p h, lzo_pclock_p c)
3000 {
3001      struct timespec ts;
3002     if (lzo_pclock_syscall_clock_gettime(2, &ts) != 0)
3003         return -1;
3004     c->tv_sec = ts.tv_sec;
3005     c->tv_nsec = LZO_STATIC_CAST(lzo_uint32l_t, ts.tv_nsec);
3006     LZO_UNUSED(h); return 0;
3007 }
3008 #endif
3009 #if (LZO_OS_CYGWIN || LZO_OS_WIN32 || LZO_OS_WIN64) && (LZO_HAVE_WINDOWS_H) && defined(lzo_int64l_t)
3010 #ifndef lzo_pclock_read_getprocesstimes
3011 #define lzo_pclock_read_getprocesstimes lzo_pclock_read_getprocesstimes
3012 #endif
lzo_pclock_read_getprocesstimes(lzo_pclock_handle_p h,lzo_pclock_p c)3013 static int lzo_pclock_read_getprocesstimes(lzo_pclock_handle_p h, lzo_pclock_p c)
3014 {
3015     FILETIME ct, et, kt, ut;
3016     lzo_uint64l_t ticks;
3017     if (GetProcessTimes(GetCurrentProcess(), &ct, &et, &kt, &ut) == 0)
3018         return -1;
3019     ticks = (LZO_STATIC_CAST(lzo_uint64l_t, ut.dwHighDateTime) << 32) | ut.dwLowDateTime;
3020     if __lzo_unlikely(h->ticks_base == 0)
3021         h->ticks_base = ticks;
3022     else
3023         ticks -= h->ticks_base;
3024     c->tv_sec = LZO_STATIC_CAST(lzo_int64l_t, (ticks / 10000000ul));
3025     ticks = (ticks % 10000000ul) * 100u;
3026     c->tv_nsec = LZO_STATIC_CAST(lzo_uint32l_t, ticks);
3027     LZO_UNUSED(h); return 0;
3028 }
3029 #endif
3030 #if (HAVE_GETRUSAGE) && defined(RUSAGE_SELF)
3031 #ifndef lzo_pclock_read_getrusage
3032 #define lzo_pclock_read_getrusage lzo_pclock_read_getrusage
3033 #endif
lzo_pclock_read_getrusage(lzo_pclock_handle_p h,lzo_pclock_p c)3034 static int lzo_pclock_read_getrusage(lzo_pclock_handle_p h, lzo_pclock_p c)
3035 {
3036     struct rusage ru;
3037     if (getrusage(RUSAGE_SELF, &ru) != 0)
3038         return -1;
3039 #if defined(lzo_int64l_t)
3040     c->tv_sec = ru.ru_utime.tv_sec;
3041 #else
3042     c->tv_sec_high = 0;
3043     c->tv_sec_low = ru.ru_utime.tv_sec;
3044 #endif
3045     c->tv_nsec = LZO_STATIC_CAST(lzo_uint32l_t, (ru.ru_utime.tv_usec * 1000u));
3046     LZO_UNUSED(h); return 0;
3047 }
3048 #endif
3049 #if 1 && (HAVE_CLOCK_GETTIME) && defined(CLOCK_THREAD_CPUTIME_ID) && defined(lzo_int64l_t)
3050 #ifndef lzo_pclock_read_clock_gettime_t_libc
3051 #define lzo_pclock_read_clock_gettime_t_libc lzo_pclock_read_clock_gettime_t_libc
3052 #endif
lzo_pclock_read_clock_gettime_t_libc(lzo_pclock_handle_p h,lzo_pclock_p c)3053 static int lzo_pclock_read_clock_gettime_t_libc(lzo_pclock_handle_p h, lzo_pclock_p c)
3054 {
3055     struct timespec ts;
3056     if (clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts) != 0)
3057         return -1;
3058     c->tv_sec = ts.tv_sec;
3059     c->tv_nsec = (lzo_uint32l_t) ts.tv_nsec;
3060     LZO_UNUSED(h); return 0;
3061 }
3062 #endif
3063 #if 1 && defined(lzo_pclock_syscall_clock_gettime)
3064 #ifndef lzo_pclock_read_clock_gettime_t_syscall
3065 #define lzo_pclock_read_clock_gettime_t_syscall lzo_pclock_read_clock_gettime_t_syscall
3066 #endif
lzo_pclock_read_clock_gettime_t_syscall(lzo_pclock_handle_p h,lzo_pclock_p c)3067 static int lzo_pclock_read_clock_gettime_t_syscall(lzo_pclock_handle_p h, lzo_pclock_p c)
3068 {
3069      struct timespec ts;
3070     if (lzo_pclock_syscall_clock_gettime(3, &ts) != 0)
3071         return -1;
3072     c->tv_sec = ts.tv_sec;
3073     c->tv_nsec = LZO_STATIC_CAST(lzo_uint32l_t, ts.tv_nsec);
3074     LZO_UNUSED(h); return 0;
3075 }
3076 #endif
3077 #if (LZO_OS_CYGWIN || LZO_OS_WIN32 || LZO_OS_WIN64) && (LZO_HAVE_WINDOWS_H) && defined(lzo_int64l_t)
3078 #ifndef lzo_pclock_read_getthreadtimes
3079 #define lzo_pclock_read_getthreadtimes lzo_pclock_read_getthreadtimes
3080 #endif
lzo_pclock_read_getthreadtimes(lzo_pclock_handle_p h,lzo_pclock_p c)3081 static int lzo_pclock_read_getthreadtimes(lzo_pclock_handle_p h, lzo_pclock_p c)
3082 {
3083     FILETIME ct, et, kt, ut;
3084     lzo_uint64l_t ticks;
3085     if (GetThreadTimes(GetCurrentThread(), &ct, &et, &kt, &ut) == 0)
3086         return -1;
3087     ticks = (LZO_STATIC_CAST(lzo_uint64l_t, ut.dwHighDateTime) << 32) | ut.dwLowDateTime;
3088     if __lzo_unlikely(h->ticks_base == 0)
3089         h->ticks_base = ticks;
3090     else
3091         ticks -= h->ticks_base;
3092     c->tv_sec = LZO_STATIC_CAST(lzo_int64l_t, (ticks / 10000000ul));
3093     ticks = (ticks % 10000000ul) * 100u;
3094     c->tv_nsec = LZO_STATIC_CAST(lzo_uint32l_t, ticks);
3095     LZO_UNUSED(h); return 0;
3096 }
3097 #endif
LZOLIB_PUBLIC(int,lzo_pclock_open)3098 LZOLIB_PUBLIC(int, lzo_pclock_open) (lzo_pclock_handle_p h, int mode)
3099 {
3100     lzo_pclock_t c;
3101     int i;
3102     h->h = LZO_STATIC_CAST(lzolib_handle_t, 0);
3103     h->mode = -1;
3104     h->read_error = 2;
3105     h->name = NULL;
3106     h->gettime = LZO_STATIC_CAST(lzo_pclock_gettime_t, 0);
3107 #if defined(lzo_int64l_t)
3108     h->ticks_base = 0;
3109 #endif
3110     switch (mode)
3111     {
3112     case LZO_PCLOCK_REALTIME:
3113 #     if defined(lzo_pclock_read_clock_gettime_r_syscall)
3114         if (lzo_pclock_read_clock_gettime_r_syscall(h, &c) == 0) {
3115             h->gettime = lzo_pclock_read_clock_gettime_r_syscall;
3116             h->name = "CLOCK_REALTIME/syscall";
3117             break;
3118         }
3119 #     endif
3120 #     if defined(lzo_pclock_read_gettimeofday)
3121         if (lzo_pclock_read_gettimeofday(h, &c) == 0) {
3122             h->gettime = lzo_pclock_read_gettimeofday;
3123             h->name = "gettimeofday";
3124             break;
3125         }
3126 #     endif
3127         break;
3128     case LZO_PCLOCK_MONOTONIC:
3129 #     if defined(lzo_pclock_read_clock_gettime_m_syscall)
3130         if (lzo_pclock_read_clock_gettime_m_syscall(h, &c) == 0) {
3131             h->gettime = lzo_pclock_read_clock_gettime_m_syscall;
3132             h->name = "CLOCK_MONOTONIC/syscall";
3133             break;
3134         }
3135 #     endif
3136 #     if defined(lzo_pclock_read_uclock)
3137         if (lzo_pclock_read_uclock(h, &c) == 0) {
3138             h->gettime = lzo_pclock_read_uclock;
3139             h->name = "uclock";
3140             break;
3141         }
3142 #     endif
3143 #     if defined(lzo_pclock_read_clock)
3144         if (lzo_pclock_read_clock(h, &c) == 0) {
3145             h->gettime = lzo_pclock_read_clock;
3146             h->name = "clock";
3147             break;
3148         }
3149 #     endif
3150         break;
3151     case LZO_PCLOCK_PROCESS_CPUTIME_ID:
3152 #     if defined(lzo_pclock_read_getprocesstimes)
3153         if (lzo_pclock_read_getprocesstimes(h, &c) == 0) {
3154             h->gettime = lzo_pclock_read_getprocesstimes;
3155             h->name = "GetProcessTimes";
3156             break;
3157         }
3158 #     endif
3159 #     if defined(lzo_pclock_read_clock_gettime_p_syscall)
3160         if (lzo_pclock_read_clock_gettime_p_syscall(h, &c) == 0) {
3161             h->gettime = lzo_pclock_read_clock_gettime_p_syscall;
3162             h->name = "CLOCK_PROCESS_CPUTIME_ID/syscall";
3163             break;
3164         }
3165 #     endif
3166 #     if defined(lzo_pclock_read_clock_gettime_p_libc)
3167         if (lzo_pclock_read_clock_gettime_p_libc(h, &c) == 0) {
3168             h->gettime = lzo_pclock_read_clock_gettime_p_libc;
3169             h->name = "CLOCK_PROCESS_CPUTIME_ID/libc";
3170             break;
3171         }
3172 #     endif
3173 #     if defined(lzo_pclock_read_getrusage)
3174         if (lzo_pclock_read_getrusage(h, &c) == 0) {
3175             h->gettime = lzo_pclock_read_getrusage;
3176             h->name = "getrusage";
3177             break;
3178         }
3179 #     endif
3180         break;
3181     case LZO_PCLOCK_THREAD_CPUTIME_ID:
3182 #     if defined(lzo_pclock_read_getthreadtimes)
3183         if (lzo_pclock_read_getthreadtimes(h, &c) == 0) {
3184             h->gettime = lzo_pclock_read_getthreadtimes;
3185             h->name = "GetThreadTimes";
3186         }
3187 #     endif
3188 #     if defined(lzo_pclock_read_clock_gettime_t_syscall)
3189         if (lzo_pclock_read_clock_gettime_t_syscall(h, &c) == 0) {
3190             h->gettime = lzo_pclock_read_clock_gettime_t_syscall;
3191             h->name = "CLOCK_THREAD_CPUTIME_ID/syscall";
3192             break;
3193         }
3194 #     endif
3195 #     if defined(lzo_pclock_read_clock_gettime_t_libc)
3196         if (lzo_pclock_read_clock_gettime_t_libc(h, &c) == 0) {
3197             h->gettime = lzo_pclock_read_clock_gettime_t_libc;
3198             h->name = "CLOCK_THREAD_CPUTIME_ID/libc";
3199             break;
3200         }
3201 #     endif
3202         break;
3203     }
3204     if (!h->gettime)
3205         return -1;
3206     if (!h->h)
3207         h->h = LZO_STATIC_CAST(lzolib_handle_t, 1);
3208     h->mode = mode;
3209     h->read_error = 0;
3210     if (!h->name)
3211         h->name = "unknown";
3212     for (i = 0; i < 10; i++) {
3213         __LZOLIB_FUNCNAME(lzo_pclock_read)(h, &c);
3214     }
3215     return 0;
3216 }
LZOLIB_PUBLIC(int,lzo_pclock_open_default)3217 LZOLIB_PUBLIC(int, lzo_pclock_open_default) (lzo_pclock_handle_p h)
3218 {
3219     if (__LZOLIB_FUNCNAME(lzo_pclock_open)(h, LZO_PCLOCK_PROCESS_CPUTIME_ID) == 0)
3220         return 0;
3221     if (__LZOLIB_FUNCNAME(lzo_pclock_open)(h, LZO_PCLOCK_MONOTONIC) == 0)
3222         return 0;
3223     if (__LZOLIB_FUNCNAME(lzo_pclock_open)(h, LZO_PCLOCK_REALTIME) == 0)
3224         return 0;
3225     if (__LZOLIB_FUNCNAME(lzo_pclock_open)(h, LZO_PCLOCK_THREAD_CPUTIME_ID) == 0)
3226         return 0;
3227     return -1;
3228 }
LZOLIB_PUBLIC(int,lzo_pclock_close)3229 LZOLIB_PUBLIC(int, lzo_pclock_close) (lzo_pclock_handle_p h)
3230 {
3231     h->h = LZO_STATIC_CAST(lzolib_handle_t, 0);
3232     h->mode = -1;
3233     h->name = NULL;
3234     h->gettime = LZO_STATIC_CAST(lzo_pclock_gettime_t, 0);
3235     return 0;
3236 }
LZOLIB_PUBLIC(void,lzo_pclock_read)3237 LZOLIB_PUBLIC(void, lzo_pclock_read) (lzo_pclock_handle_p h, lzo_pclock_p c)
3238 {
3239     if (h->gettime) {
3240         if (h->gettime(h, c) == 0)
3241             return;
3242     }
3243     h->read_error = 1;
3244 #if defined(lzo_int64l_t)
3245     c->tv_sec = 0;
3246 #else
3247     c->tv_sec_high = 0;
3248     c->tv_sec_low = 0;
3249 #endif
3250     c->tv_nsec = 0;
3251 }
3252 #if !(LZO_CFG_NO_DOUBLE)
LZOLIB_PUBLIC(double,lzo_pclock_get_elapsed)3253 LZOLIB_PUBLIC(double, lzo_pclock_get_elapsed) (lzo_pclock_handle_p h, const lzo_pclock_p start, const lzo_pclock_p stop)
3254 {
3255     if (!h->h) { h->mode = -1; return 0.0; }
3256     {
3257 #if 1 && (LZO_ARCH_I386 && LZO_CC_GNUC) && defined(__STRICT_ALIGNMENT__)
3258     float tstop, tstart;
3259     tstop  = LZO_STATIC_CAST(float, (stop->tv_sec  + stop->tv_nsec  / 1000000000.0));
3260     tstart = LZO_STATIC_CAST(float, (start->tv_sec + start->tv_nsec / 1000000000.0));
3261 #elif defined(lzo_int64l_t)
3262     double tstop, tstart;
3263 #if 1 && (LZO_CC_INTELC)
3264     { lzo_int64l_t a = stop->tv_sec; lzo_uint32l_t b = stop->tv_nsec;
3265     tstop = a + b / 1000000000.0; }
3266     { lzo_int64l_t a = start->tv_sec; lzo_uint32l_t b = start->tv_nsec;
3267     tstart = a + b / 1000000000.0; }
3268 #else
3269     tstop  = stop->tv_sec  + stop->tv_nsec  / 1000000000.0;
3270     tstart = start->tv_sec + start->tv_nsec / 1000000000.0;
3271 #endif
3272 #else
3273     double tstop, tstart;
3274     tstop  = stop->tv_sec_low  + stop->tv_nsec  / 1000000000.0;
3275     tstart = start->tv_sec_low + start->tv_nsec / 1000000000.0;
3276 #endif
3277     return tstop - tstart;
3278     }
3279 }
3280 #endif
LZOLIB_PUBLIC(int,lzo_pclock_flush_cpu_cache)3281 LZOLIB_PUBLIC(int, lzo_pclock_flush_cpu_cache) (lzo_pclock_handle_p h, unsigned flags)
3282 {
3283     LZO_UNUSED(h); LZO_UNUSED(flags);
3284     return -1;
3285 }
3286 #if defined(__LZOLIB_PCLOCK_NEED_WARN_POP)
3287 #  if (LZO_CC_MSC && (_MSC_VER >= 1200))
3288 #    pragma warning(pop)
3289 #  else
3290 #    error "__LZOLIB_PCLOCK_NEED_WARN_POP"
3291 #  endif
3292 #  undef __LZOLIB_PCLOCK_NEED_WARN_POP
3293 #endif
3294 #endif
3295 #if defined(LZO_WANT_ACCLIB_MISC)
3296 #  undef LZO_WANT_ACCLIB_MISC
3297 #define __LZOLIB_MISC_CH_INCLUDED 1
3298 #if !defined(LZOLIB_PUBLIC)
3299 #  define LZOLIB_PUBLIC(r,f)                r __LZOLIB_FUNCNAME(f)
3300 #endif
3301 #if !defined(LZOLIB_PUBLIC_NOINLINE)
3302 #  if !defined(__lzo_noinline)
3303 #    define LZOLIB_PUBLIC_NOINLINE(r,f)     r __LZOLIB_FUNCNAME(f)
3304 #  elif (LZO_CC_CLANG || (LZO_CC_GNUC >= 0x030400ul) || LZO_CC_LLVM)
3305 #    define LZOLIB_PUBLIC_NOINLINE(r,f)     __lzo_noinline __attribute__((__used__)) r __LZOLIB_FUNCNAME(f)
3306 #  else
3307 #    define LZOLIB_PUBLIC_NOINLINE(r,f)     __lzo_noinline r __LZOLIB_FUNCNAME(f)
3308 #  endif
3309 #endif
3310 #if (LZO_OS_WIN32 && LZO_CC_PELLESC && (__POCC__ >= 290))
3311 #  pragma warn(push)
3312 #  pragma warn(disable:2007)
3313 #endif
LZOLIB_PUBLIC(const char *,lzo_getenv)3314 LZOLIB_PUBLIC(const char *, lzo_getenv) (const char *s)
3315 {
3316 #if (HAVE_GETENV)
3317     return getenv(s);
3318 #else
3319     LZO_UNUSED(s); return LZO_STATIC_CAST(const char *, 0);
3320 #endif
3321 }
LZOLIB_PUBLIC(lzo_intptr_t,lzo_get_osfhandle)3322 LZOLIB_PUBLIC(lzo_intptr_t, lzo_get_osfhandle) (int fd)
3323 {
3324     if (fd < 0)
3325         return -1;
3326 #if (LZO_OS_CYGWIN)
3327     return get_osfhandle(fd);
3328 #elif (LZO_OS_EMX && defined(__RSXNT__))
3329     return -1;
3330 #elif (LZO_OS_WIN32 && LZO_CC_GNUC) && defined(__PW32__)
3331     return -1;
3332 #elif (LZO_OS_WIN32 || LZO_OS_WIN64)
3333 # if (LZO_CC_PELLESC && (__POCC__ < 280))
3334     return -1;
3335 # elif (LZO_CC_WATCOMC && (__WATCOMC__ < 1000))
3336     return -1;
3337 # elif (LZO_CC_WATCOMC && (__WATCOMC__ < 1100))
3338     return _os_handle(fd);
3339 # else
3340     return _get_osfhandle(fd);
3341 # endif
3342 #else
3343     return fd;
3344 #endif
3345 }
LZOLIB_PUBLIC(int,lzo_set_binmode)3346 LZOLIB_PUBLIC(int, lzo_set_binmode) (int fd, int binary)
3347 {
3348 #if (LZO_ARCH_M68K && LZO_OS_TOS && LZO_CC_GNUC) && defined(__MINT__)
3349     FILE* fp; int old_binary;
3350     if (fd == STDIN_FILENO) fp = stdin;
3351     else if (fd == STDOUT_FILENO) fp = stdout;
3352     else if (fd == STDERR_FILENO) fp = stderr;
3353     else return -1;
3354     old_binary = fp->__mode.__binary;
3355     __set_binmode(fp, binary ? 1 : 0);
3356     return old_binary ? 1 : 0;
3357 #elif (LZO_ARCH_M68K && LZO_OS_TOS)
3358     LZO_UNUSED(fd); LZO_UNUSED(binary);
3359     return -1;
3360 #elif (LZO_OS_DOS16 && (LZO_CC_AZTECC || LZO_CC_PACIFICC))
3361     LZO_UNUSED(fd); LZO_UNUSED(binary);
3362     return -1;
3363 #elif (LZO_OS_DOS32 && LZO_CC_GNUC) && defined(__DJGPP__)
3364     int r; unsigned old_flags = __djgpp_hwint_flags;
3365     LZO_COMPILE_TIME_ASSERT(O_BINARY > 0)
3366     LZO_COMPILE_TIME_ASSERT(O_TEXT > 0)
3367     if (fd < 0) return -1;
3368     r = setmode(fd, binary ? O_BINARY : O_TEXT);
3369     if ((old_flags & 1u) != (__djgpp_hwint_flags & 1u))
3370         __djgpp_set_ctrl_c(!(old_flags & 1));
3371     if (r == -1) return -1;
3372     return (r & O_TEXT) ? 0 : 1;
3373 #elif (LZO_OS_WIN32 && LZO_CC_GNUC) && defined(__PW32__)
3374     if (fd < 0) return -1;
3375     LZO_UNUSED(binary);
3376     return 1;
3377 #elif (LZO_OS_DOS32 && LZO_CC_HIGHC)
3378     FILE* fp; int r;
3379     if (fd == fileno(stdin)) fp = stdin;
3380     else if (fd == fileno(stdout)) fp = stdout;
3381     else if (fd == fileno(stderr)) fp = stderr;
3382     else return -1;
3383     r = _setmode(fp, binary ? _BINARY : _TEXT);
3384     if (r == -1) return -1;
3385     return (r & _BINARY) ? 1 : 0;
3386 #elif (LZO_OS_WIN32 && LZO_CC_MWERKS) && defined(__MSL__)
3387     LZO_UNUSED(fd); LZO_UNUSED(binary);
3388     return -1;
3389 #elif (LZO_OS_CYGWIN && (LZO_CC_GNUC < 0x025a00ul))
3390     LZO_UNUSED(fd); LZO_UNUSED(binary);
3391     return -1;
3392 #elif (LZO_OS_CYGWIN || LZO_OS_DOS16 || LZO_OS_DOS32 || LZO_OS_EMX || LZO_OS_OS2 || LZO_OS_OS216 || LZO_OS_WIN16 || LZO_OS_WIN32 || LZO_OS_WIN64)
3393     int r;
3394 #if !(LZO_CC_ZORTECHC)
3395     LZO_COMPILE_TIME_ASSERT(O_BINARY > 0)
3396 #endif
3397     LZO_COMPILE_TIME_ASSERT(O_TEXT > 0)
3398     if (fd < 0) return -1;
3399     r = setmode(fd, binary ? O_BINARY : O_TEXT);
3400     if (r == -1) return -1;
3401     return (r & O_TEXT) ? 0 : 1;
3402 #else
3403     if (fd < 0) return -1;
3404     LZO_UNUSED(binary);
3405     return 1;
3406 #endif
3407 }
LZOLIB_PUBLIC(int,lzo_isatty)3408 LZOLIB_PUBLIC(int, lzo_isatty) (int fd)
3409 {
3410     if (fd < 0)
3411         return 0;
3412 #if (LZO_OS_DOS16 && !(LZO_CC_AZTECC))
3413     {
3414         union REGS ri, ro;
3415         ri.x.ax = 0x4400; ri.x.bx = fd;
3416         int86(0x21, &ri, &ro);
3417         if ((ro.x.cflag & 1) == 0)
3418             if ((ro.x.ax & 0x83) != 0x83)
3419                 return 0;
3420     }
3421 #elif (LZO_OS_DOS32 && LZO_CC_WATCOMC)
3422     {
3423         union REGS ri, ro;
3424         ri.w.ax = 0x4400; ri.w.bx = LZO_STATIC_CAST(unsigned short, fd);
3425         int386(0x21, &ri, &ro);
3426         if ((ro.w.cflag & 1) == 0)
3427             if ((ro.w.ax & 0x83) != 0x83)
3428                 return 0;
3429     }
3430 #elif (LZO_HAVE_WINDOWS_H)
3431     {
3432         lzo_intptr_t h = __LZOLIB_FUNCNAME(lzo_get_osfhandle)(fd);
3433         LZO_COMPILE_TIME_ASSERT(sizeof(h) == sizeof(HANDLE))
3434         if (h != -1)
3435         {
3436             DWORD d = 0;
3437             if (GetConsoleMode(LZO_REINTERPRET_CAST(HANDLE, h), &d) == 0)
3438                 return 0;
3439         }
3440     }
3441 #endif
3442 #if (HAVE_ISATTY)
3443     return (isatty(fd)) ? 1 : 0;
3444 #else
3445     return 0;
3446 #endif
3447 }
LZOLIB_PUBLIC(int,lzo_mkdir)3448 LZOLIB_PUBLIC(int, lzo_mkdir) (const char* name, unsigned mode)
3449 {
3450 #if !(HAVE_MKDIR)
3451     LZO_UNUSED(name); LZO_UNUSED(mode);
3452     return -1;
3453 #elif (LZO_ARCH_M68K && LZO_OS_TOS && (LZO_CC_PUREC || LZO_CC_TURBOC))
3454     LZO_UNUSED(mode);
3455     return Dcreate(name);
3456 #elif (LZO_OS_DOS32 && LZO_CC_GNUC) && defined(__DJGPP__)
3457     return mkdir(name, mode);
3458 #elif (LZO_OS_WIN32 && LZO_CC_GNUC) && defined(__PW32__)
3459     return mkdir(name, mode);
3460 #elif ((LZO_OS_DOS16 || LZO_OS_DOS32) && (LZO_CC_HIGHC || LZO_CC_PACIFICC))
3461     LZO_UNUSED(mode);
3462     return mkdir(LZO_UNCONST_CAST(char *, name));
3463 #elif (LZO_OS_DOS16 || LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_OS216 || LZO_OS_WIN16 || LZO_OS_WIN32 || LZO_OS_WIN64)
3464     LZO_UNUSED(mode);
3465     return mkdir(name);
3466 #elif (LZO_CC_WATCOMC)
3467     return mkdir(name, LZO_STATIC_CAST(mode_t, mode));
3468 #else
3469     return mkdir(name, mode);
3470 #endif
3471 }
LZOLIB_PUBLIC(int,lzo_rmdir)3472 LZOLIB_PUBLIC(int, lzo_rmdir) (const char* name)
3473 {
3474 #if !(HAVE_RMDIR)
3475     LZO_UNUSED(name);
3476     return -1;
3477 #elif ((LZO_OS_DOS16 || LZO_OS_DOS32) && (LZO_CC_HIGHC || LZO_CC_PACIFICC))
3478     return rmdir(LZO_UNCONST_CAST(char *, name));
3479 #else
3480     return rmdir(name);
3481 #endif
3482 }
3483 #if defined(lzo_int32e_t)
LZOLIB_PUBLIC(lzo_int32e_t,lzo_muldiv32s)3484 LZOLIB_PUBLIC(lzo_int32e_t, lzo_muldiv32s) (lzo_int32e_t a, lzo_int32e_t b, lzo_int32e_t x)
3485 {
3486     lzo_int32e_t r = 0;
3487     if __lzo_likely(x != 0)
3488     {
3489 #if defined(lzo_int64l_t)
3490         lzo_int64l_t rr = (LZO_ICONV(lzo_int64l_t, a) * b) / x;
3491         r = LZO_ITRUNC(lzo_int32e_t, rr);
3492 #else
3493         LZO_UNUSED(a); LZO_UNUSED(b);
3494 #endif
3495     }
3496     return r;
3497 }
LZOLIB_PUBLIC(lzo_uint32e_t,lzo_muldiv32u)3498 LZOLIB_PUBLIC(lzo_uint32e_t, lzo_muldiv32u) (lzo_uint32e_t a, lzo_uint32e_t b, lzo_uint32e_t x)
3499 {
3500     lzo_uint32e_t r = 0;
3501     if __lzo_likely(x != 0)
3502     {
3503 #if defined(lzo_int64l_t)
3504         lzo_uint64l_t rr = (LZO_ICONV(lzo_uint64l_t, a) * b) / x;
3505         r = LZO_ITRUNC(lzo_uint32e_t, rr);
3506 #else
3507         LZO_UNUSED(a); LZO_UNUSED(b);
3508 #endif
3509     }
3510     return r;
3511 }
3512 #endif
3513 #if 0
3514 LZOLIB_PUBLIC_NOINLINE(int, lzo_syscall_clock_gettime) (int c)
3515 {
3516 }
3517 #endif
3518 #if (LZO_OS_WIN16)
3519 LZO_EXTERN_C void __far __pascal DebugBreak(void);
3520 #endif
LZOLIB_PUBLIC_NOINLINE(void,lzo_debug_break)3521 LZOLIB_PUBLIC_NOINLINE(void, lzo_debug_break) (void)
3522 {
3523 #if (LZO_OS_WIN16)
3524     DebugBreak();
3525 #elif (LZO_ARCH_I086)
3526 #elif (LZO_OS_WIN64) && (LZO_HAVE_WINDOWS_H)
3527     DebugBreak();
3528 #elif (LZO_ARCH_AMD64 || LZO_ARCH_I386) && (LZO_ASM_SYNTAX_GNUC)
3529     __asm__ __volatile__("int $3\n" : : __LZO_ASM_CLOBBER_LIST_CC_MEMORY);
3530 #elif (LZO_ARCH_I386) && (LZO_ASM_SYNTAX_MSC)
3531     __asm { int 3 }
3532 #elif (LZO_OS_WIN32) && (LZO_HAVE_WINDOWS_H)
3533     DebugBreak();
3534 #else
3535     volatile lzo_intptr_t a = -1;
3536     * LZO_STATIC_CAST(volatile unsigned long *, LZO_REINTERPRET_CAST(volatile void *, a)) = ~0ul;
3537 #endif
3538 }
LZOLIB_PUBLIC_NOINLINE(void,lzo_debug_nop)3539 LZOLIB_PUBLIC_NOINLINE(void, lzo_debug_nop) (void)
3540 {
3541 }
LZOLIB_PUBLIC_NOINLINE(int,lzo_debug_align_check_query)3542 LZOLIB_PUBLIC_NOINLINE(int, lzo_debug_align_check_query) (void)
3543 {
3544 #if (LZO_ARCH_AMD64 || LZO_ARCH_I386) && (LZO_ASM_SYNTAX_GNUC)
3545 # if (LZO_ARCH_AMD64)
3546     lzo_uint64e_t r = 0;
3547 # else
3548     size_t r = 0;
3549 # endif
3550     __asm__ __volatile__("pushf\n pop %0\n" : "=a" (r) : __LZO_ASM_CLOBBER_LIST_CC_MEMORY);
3551     return LZO_ICONV(int, (r >> 18) & 1);
3552 #elif (LZO_ARCH_I386) && (LZO_ASM_SYNTAX_MSC)
3553     unsigned long r;
3554     __asm {
3555         pushf
3556         pop eax
3557         mov r,eax
3558     }
3559     return LZO_ICONV(int, (r >> 18) & 1);
3560 #else
3561     return -1;
3562 #endif
3563 }
LZOLIB_PUBLIC_NOINLINE(int,lzo_debug_align_check_enable)3564 LZOLIB_PUBLIC_NOINLINE(int, lzo_debug_align_check_enable) (int v)
3565 {
3566 #if (LZO_ARCH_AMD64) && (LZO_ASM_SYNTAX_GNUC)
3567     if (v) {
3568         __asm__ __volatile__("pushf\n orl $262144,(%%rsp)\n popf\n" : : __LZO_ASM_CLOBBER_LIST_CC_MEMORY);
3569     } else {
3570         __asm__ __volatile__("pushf\n andl $-262145,(%%rsp)\n popf\n" : : __LZO_ASM_CLOBBER_LIST_CC_MEMORY);
3571     }
3572     return 0;
3573 #elif (LZO_ARCH_I386) && (LZO_ASM_SYNTAX_GNUC)
3574     if (v) {
3575         __asm__ __volatile__("pushf\n orl $262144,(%%esp)\n popf\n" : : __LZO_ASM_CLOBBER_LIST_CC_MEMORY);
3576     } else {
3577         __asm__ __volatile__("pushf\n andl $-262145,(%%esp)\n popf\n" : : __LZO_ASM_CLOBBER_LIST_CC_MEMORY);
3578     }
3579     return 0;
3580 #elif (LZO_ARCH_I386) && (LZO_ASM_SYNTAX_MSC)
3581     if (v) { __asm {
3582         pushf
3583         or dword ptr [esp],262144
3584         popf
3585     }} else { __asm {
3586         pushf
3587         and dword ptr [esp],-262145
3588         popf
3589     }}
3590     return 0;
3591 #else
3592     LZO_UNUSED(v); return -1;
3593 #endif
3594 }
LZOLIB_PUBLIC_NOINLINE(unsigned,lzo_debug_running_on_qemu)3595 LZOLIB_PUBLIC_NOINLINE(unsigned, lzo_debug_running_on_qemu) (void)
3596 {
3597     unsigned r = 0;
3598 #if (LZO_OS_POSIX_LINUX || LZO_OS_WIN32 || LZO_OS_WIN64)
3599     const char* p;
3600     p = __LZOLIB_FUNCNAME(lzo_getenv)(LZO_PP_STRINGIZE(LZO_ENV_RUNNING_ON_QEMU));
3601     if (p) {
3602         if (p[0] == 0) r = 0;
3603         else if ((p[0] >= '0' && p[0] <= '9') && p[1] == 0) r = LZO_ICAST(unsigned, p[0]) - '0';
3604         else r = 1;
3605     }
3606 #endif
3607     return r;
3608 }
LZOLIB_PUBLIC_NOINLINE(unsigned,lzo_debug_running_on_valgrind)3609 LZOLIB_PUBLIC_NOINLINE(unsigned, lzo_debug_running_on_valgrind) (void)
3610 {
3611 #if (LZO_ARCH_AMD64 && LZO_ABI_ILP32)
3612     return 0;
3613 #elif (LZO_ARCH_AMD64 || LZO_ARCH_I386) && (LZO_ASM_SYNTAX_GNUC)
3614     volatile size_t a[6];
3615     size_t r = 0;
3616     a[0] = 0x1001; a[1] = 0; a[2] = 0; a[3] = 0; a[4] = 0; a[5] = 0;
3617 #  if (LZO_ARCH_AMD64)
3618     __asm__ __volatile__(".byte 0x48,0xc1,0xc7,0x03,0x48,0xc1,0xc7,0x0d,0x48,0xc1,0xc7,0x3d,0x48,0xc1,0xc7,0x33,0x48,0x87,0xdb\n" : "=d" (r) : "a" (&a[0]), "d" (r) __LZO_ASM_CLOBBER_LIST_CC_MEMORY);
3619 #  elif (LZO_ARCH_I386)
3620     __asm__ __volatile__(".byte 0xc1,0xc7,0x03,0xc1,0xc7,0x0d,0xc1,0xc7,0x1d,0xc1,0xc7,0x13,0x87,0xdb\n" : "=d" (r) : "a" (&a[0]), "d" (r) __LZO_ASM_CLOBBER_LIST_CC_MEMORY);
3621 #  endif
3622     return LZO_ITRUNC(unsigned, r);
3623 #else
3624     return 0;
3625 #endif
3626 }
3627 #if (LZO_OS_WIN32 && LZO_CC_PELLESC && (__POCC__ >= 290))
3628 #  pragma warn(pop)
3629 #endif
3630 #endif
3631 #if defined(LZO_WANT_ACCLIB_WILDARGV)
3632 #  undef LZO_WANT_ACCLIB_WILDARGV
3633 #define __LZOLIB_WILDARGV_CH_INCLUDED 1
3634 #if !defined(LZOLIB_PUBLIC)
3635 #  define LZOLIB_PUBLIC(r,f)    r __LZOLIB_FUNCNAME(f)
3636 #endif
3637 #if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16)
3638 #if 0 && (LZO_CC_MSC)
3639 LZO_EXTERN_C int __lzo_cdecl __setargv(void);
3640 LZO_EXTERN_C int __lzo_cdecl _setargv(void);
3641 LZO_EXTERN_C int __lzo_cdecl _setargv(void) { return __setargv(); }
3642 #endif
3643 #endif
3644 #if (LZO_OS_WIN32 || LZO_OS_WIN64)
3645 #if (LZO_CC_INTELC || LZO_CC_MSC)
3646 LZO_EXTERN_C int __lzo_cdecl __setargv(void);
3647 LZO_EXTERN_C int __lzo_cdecl _setargv(void);
_setargv(void)3648 LZO_EXTERN_C int __lzo_cdecl _setargv(void) { return __setargv(); }
3649 #endif
3650 #endif
3651 #if (LZO_OS_EMX)
3652 #define __LZOLIB_HAVE_LZO_WILDARGV 1
LZOLIB_PUBLIC(void,lzo_wildargv)3653 LZOLIB_PUBLIC(void, lzo_wildargv) (int* argc, char*** argv)
3654 {
3655     if (argc && argv) {
3656         _response(argc, argv);
3657         _wildcard(argc, argv);
3658     }
3659 }
3660 #endif
3661 #if (LZO_OS_CONSOLE_PSP) && defined(__PSPSDK_DEBUG__)
3662 #define __LZOLIB_HAVE_LZO_WILDARGV 1
3663 LZO_EXTERN_C int lzo_psp_init_module(int*, char***, int);
LZOLIB_PUBLIC(void,lzo_wildargv)3664 LZOLIB_PUBLIC(void, lzo_wildargv) (int* argc, char*** argv)
3665 {
3666     lzo_psp_init_module(argc, argv, -1);
3667 }
3668 #endif
3669 #if !(__LZOLIB_HAVE_LZO_WILDARGV)
3670 #define __LZOLIB_HAVE_LZO_WILDARGV 1
LZOLIB_PUBLIC(void,lzo_wildargv)3671 LZOLIB_PUBLIC(void, lzo_wildargv) (int* argc, char*** argv)
3672 {
3673 #if 1 && (LZO_ARCH_I086PM)
3674     if (LZO_MM_AHSHIFT != 3) { exit(1); }
3675 #elif 1 && (LZO_ARCH_M68K && LZO_OS_TOS && LZO_CC_GNUC) && defined(__MINT__)
3676     __binmode(1);
3677     if (isatty(1)) __set_binmode(stdout, 0);
3678     if (isatty(2)) __set_binmode(stderr, 0);
3679 #endif
3680     LZO_UNUSED(argc); LZO_UNUSED(argv);
3681 }
3682 #endif
3683 #endif
3684 
3685 /* vim:set ts=4 sw=4 et: */
3686