aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2008-11-19 20:46:52 +0200
committerLasse Collin <lasse.collin@tukaani.org>2008-11-19 20:46:52 +0200
commite114502b2bc371e4a45449832cb69be036360722 (patch)
tree449c41d0408f99926de202611091747f1fbe2f85 /src/common
parentFixed the test that should have been fixed as part (diff)
downloadxz-e114502b2bc371e4a45449832cb69be036360722.tar.xz
Oh well, big messy commit again. Some highlights:
- Updated to the latest, probably final file format version. - Command line tool reworked to not use threads anymore. Threading will probably go into liblzma anyway. - Memory usage limit is now about 30 % for uncompression and about 90 % for compression. - Progress indicator with --verbose - Simplified --help and full --long-help - Upgraded to the last LGPLv2.1+ getopt_long from gnulib. - Some bug fixes
Diffstat (limited to '')
-rw-r--r--src/common/bswap.h15
-rw-r--r--src/common/physmem.h4
-rw-r--r--src/common/sysdefs.h12
3 files changed, 17 insertions, 14 deletions
diff --git a/src/common/bswap.h b/src/common/bswap.h
index 8f82a8f4..f5cb8345 100644
--- a/src/common/bswap.h
+++ b/src/common/bswap.h
@@ -16,20 +16,29 @@
// NOTE: We assume that config.h is already #included.
-// byteswap.h is a GNU extension. It contains inline assembly versions
-// for byteswapping. When byteswap.h is not available, we use generic code.
+// At least glibc has byteswap.h which contains inline assembly code for
+// byteswapping. Some systems have byteswap.h but lack one or more of the
+// bswap_xx macros/functions, which is why we check them separately even
+// if byteswap.h is available.
+
#ifdef HAVE_BYTESWAP_H
# include <byteswap.h>
-#else
+#endif
+
+#ifndef HAVE_BSWAP_16
# define bswap_16(num) \
(((num) << 8) | ((num) >> 8))
+#endif
+#ifndef HAVE_BSWAP_32
# define bswap_32(num) \
( (((num) << 24) ) \
| (((num) << 8) & UINT32_C(0x00FF0000)) \
| (((num) >> 8) & UINT32_C(0x0000FF00)) \
| (((num) >> 24) ) )
+#endif
+#ifndef HAVE_BSWAP_64
# define bswap_64(num) \
( (((num) << 56) ) \
| (((num) << 40) & UINT64_C(0x00FF000000000000)) \
diff --git a/src/common/physmem.h b/src/common/physmem.h
index 597227ac..04a7ab4b 100644
--- a/src/common/physmem.h
+++ b/src/common/physmem.h
@@ -23,6 +23,10 @@
# endif
#endif
+#if defined(HAVE_PHYSMEM_SYSCONF) || defined(HAVE_NCPU_SYSCONF)
+# include <unistd.h>
+#endif
+
/// \brief Get the amount of physical memory in bytes
///
diff --git a/src/common/sysdefs.h b/src/common/sysdefs.h
index 7f935f67..47a49fde 100644
--- a/src/common/sysdefs.h
+++ b/src/common/sysdefs.h
@@ -111,6 +111,7 @@
#endif
#include <stdlib.h>
+#include <assert.h>
// Pre-C99 systems lack stdbool.h. All the code in LZMA Utils must be written
// so that it works with fake bool type, for example:
@@ -134,17 +135,6 @@ typedef unsigned char _Bool;
# define __bool_true_false_are_defined 1
#endif
-#ifdef HAVE_ASSERT_H
-# include <assert.h>
-#else
-# ifdef NDEBUG
-# define assert(x)
-# else
- // TODO: Pretty bad assert macro.
-# define assert(x) (!(x) && abort())
-# endif
-#endif
-
// string.h should be enough but let's include strings.h and memory.h too if
// they exists, since that shouldn't do any harm, but may improve portability.
#ifdef HAVE_STRING_H