19 Commits

Author SHA1 Message Date
Eric Biggers
fbada10aa9 prog_util: make it clear that posix_[fm]advise errors are ignored 2021-03-14 21:04:26 -07:00
Eric Biggers
7ba3155c17 programs: rename program_invocation_name to prog_invocation_name
Avoid confusion with the GNU extension 'program_invocation_name', which
is described by 'man 3 program_invocation_name'.  The GNU version isn't
supposed to be exposed without defining _GNU_SOURCE, which we don't in
any of the relevant files, but it's best to avoid any confusion.
2020-10-25 20:49:27 -07:00
Eric Biggers
4c92394eaa Support level 0, "no compression"
Some users may require a valid DEFLATE, zlib, or gzip stream but know
ahead of time that particular inputs are not compressible.  zlib
supports "level 0" for this use case.  Support this in libdeflate too.

Resolves https://github.com/ebiggers/libdeflate/issues/86
2020-10-10 22:31:15 -07:00
Eric Biggers
27d5a74f03 lib: add freestanding support
Allow building libdeflate without linking to any libc functions by using
'make FREESTANDING=1'.  When using such a library build, the user will
need to call libdeflate_set_memory_allocator() before anything else,
since malloc() and free() will be unavailable.

[Folded in fix from Ingvar Stepanyan to use -nostdlib, and made
 freestanding_tests() check that no libs are linked to.]

Update https://github.com/ebiggers/libdeflate/issues/62
2020-04-17 22:32:49 -07:00
Eric Biggers
740820bd66 programs: define begin_program()
In preparation for testing freestanding library builds, make all
programs call a function begin_program().
2020-04-17 21:28:49 -07:00
Eric Biggers
ce6a95f47b programs: add test_util
Move program utility functions that are used only by "test programs"
(i.e. not by gzip/gunzip) from prog_util.{c,h} into test_util.{c,h}.
This reduces the code that is compiled for the default build target,
which excludes the test programs.
2018-12-28 10:25:44 -06:00
Eric Biggers
a5a4822e2a prog_util: add guarded buffer allocator 2018-12-23 12:34:50 -06:00
Eric Biggers
dd1c157750 prog_util: add timer_KB_per_s() 2018-12-23 12:03:00 -06:00
Eric Biggers
6c26eb18ea prog_util: add ASSERT() macro 2018-12-23 12:03:00 -06:00
Eric Biggers
5cc0fc2bbd gzip, gunzip: add dumb support for reading from stdin
No streaming yet, but as a temporary solution just read the full file
contents.
2016-10-23 13:54:53 -07:00
Eric Biggers
3a7658d144 gzip, gunzip: avoid hanging when opening special files
This matches the behavior of GNU gzip.
2016-10-23 13:54:53 -07:00
Eric Biggers
f100a42c02 gzip, gunzip: require -f or -c to (de)compress symlink
This matches the behavior of GNU gzip.
2016-10-23 13:54:53 -07:00
Eric Biggers
e4029d1e70 gzip, gunzip: warning rather than error when output file already exists
This matches the behavior of GNU gzip.
2016-10-23 13:54:53 -07:00
Eric Biggers
2b047b097b gzip: allow compressing empty files 2016-10-23 13:54:52 -07:00
Eric Biggers
1cc88c6f86 prog_util: remove unused skip_bytes() function 2016-10-16 18:16:38 -07:00
Eric Biggers
e20e275081 prog_util: use QueryPerformanceCounter() on Windows
QueryPerformanceCounter() is much more accurate than
GetSystemTimeAsFileTime().

Also avoid converting into a specific time unit until the results need
to be displayed.  This is more efficient and avoids losing precision.
2016-10-16 14:20:18 -07:00
Eric Biggers
3992efa340 Update API to avoid naming collisions 2016-08-27 23:11:32 -07:00
Eric Biggers
94145eb14e programs: use sequential file access hints 2016-08-20 14:22:18 -07:00
Eric Biggers
f2c3a5b4e9 Various reorganization and cleanups
* Bring in common headers and program code from xpack project
* Move program code to programs/
* Move library code to lib/
* GNU89 and MSVC2010 compatibility
* Other changes
2016-05-21 15:38:15 -05:00