summaryrefslogtreecommitdiff
path: root/include/compat.h
AgeCommit message (Collapse)Author
2020-05-07Fix compilation on GCC4 and belowBrandon Maier
When compiling with GCC4 the following error occurs. > lib/util/rbtree.c:140: undefined reference to `__builtin_uaddl_overflow' This is because __builtin_uaddl_overflow() and the other __builtin_u{add,mul}{,l,ll}_overflow() functions are only defined in GNUC < 5 for Clang. When using GCC4 and below they are not defined. Since the SZ_ADD_OV and SZ_MUL_OV are only used to check 'size_t' type values. And overflow on add and multiply of unsigned types is defined behaviour (C Standard 6.2.5 paragraph 9). It's simple to write overflow functions for this specific case. These are based on the overflow wrappers from the SEI CERT C Standard INT30-C. [1] https://gcc.gnu.org/gcc-5/changes.html Signed-off-by: Brandon Maier <brandon.maier@rockwellcollins.com>
2020-03-10Fix the printf format specifies (again)David Oberhollenzer
The PRIu64 et al are missing a "%" sign in front. Fixes: aaf7e68c75a907c3c08e83dfd2972665a0f1c1a3 Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2020-03-01Fix printf format specifies for sqfs_u64David Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-12-31Include sys/sysmacros.h on any GNU libc platformPino Toscano
sys/sysmacros.h is an implementation of GNU libc, so include it unconditionally when that libc is used. Signed-off-by: Pino Toscano <toscano.pino@tiscali.it>
2019-11-25Cleanup: remove what is left of libutilDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-25Cleanup: move overflow safe alloc code into libsquashfsDavid Oberhollenzer
There were only a hand full of instances outside libsquashfs that used the alloc code. In most cases, the thing allocated hat its size derived from something already in memory anyway, so it is safe to assume its size fits into a size_t. At the same time, the opencoded Windows path conversion functions are all unified into a single helper function. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-23Fix various data type problemsDavid Oberhollenzer
- Make sure the mockup constant for AT_FDCWD is actualy an int - Don't use %lld printf format specified, mscrt doesn't have that - On 64 bit windows, use %I64u format specified for size_t - Seperate the overflow macro stuff from the form specifier stuff - Move the whole thing to compat.h and clean it up a little so it becomes readable. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-23Add windows implementation for chdir in libcompatDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-23Move some unix header inclusions to compat.hDavid Oberhollenzer
In most cases, including unistd.h and fcntl.h was a left over anyway. In the cases where it was not, move it to compat.h. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-22Add fchownat/fchmodat mockups to libcompat for WindowsDavid Oberhollenzer
Not pretty, but definitely prettier than #ifdef hell. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-11-22Cleanup: move all the compatibillity fluff to a dedicated "libcompat"David Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-10-07Cleanup: move libutil related headers to "util" sub directoryDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2019-09-27Add a header for platform compatibillity fluffDavid Oberhollenzer
- We don't have "endian.h" everywhere. On some BSDs its in sys and on some BSDs the macros have different names. - We definitely don't have sysmacros.h on non-Unix-like systems. - Likewise for sys/types.h, sys/stat.h and their contents. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>