]> git.ipfire.org Git - thirdparty/xz.git/commitdiff
liblzma: Add lzma_cputhreads().
authorLasse Collin <lasse.collin@tukaani.org>
Wed, 18 Jun 2014 19:04:24 +0000 (22:04 +0300)
committerLasse Collin <lasse.collin@tukaani.org>
Wed, 18 Jun 2014 19:04:24 +0000 (22:04 +0300)
src/liblzma/Makefile.am
src/liblzma/api/lzma/hardware.h
src/liblzma/common/Makefile.inc
src/liblzma/common/hardware_cputhreads.c [new file with mode: 0644]
src/liblzma/liblzma.map

index 9ad021a24c7033ea161baa572c12075a3430dc26..32134e8474cd709ad24e37d772eae0a775706060 100644 (file)
@@ -12,7 +12,7 @@ CLEANFILES =
 doc_DATA =
 
 lib_LTLIBRARIES = liblzma.la
-liblzma_la_SOURCES = $(top_srcdir)/src/common/tuklib_physmem.c
+liblzma_la_SOURCES =
 liblzma_la_CPPFLAGS = \
        -I$(top_srcdir)/src/liblzma/api \
        -I$(top_srcdir)/src/liblzma/common \
@@ -32,6 +32,12 @@ liblzma_la_LDFLAGS += \
        -Wl,--version-script=$(top_srcdir)/src/liblzma/liblzma.map
 endif
 
+liblzma_la_SOURCES += $(top_srcdir)/src/common/tuklib_physmem.c
+
+if COND_THREADS
+liblzma_la_SOURCES += $(top_srcdir)/src/common/tuklib_cpucores.c
+endif
+
 include $(srcdir)/common/Makefile.inc
 include $(srcdir)/check/Makefile.inc
 
index e7dd03c3e8ddb96a5ed34f868431acedf29f216d..5321d9af8e46d0caa86de68a71e899bd33f7e5ed 100644 (file)
  *              of RAM on the specific operating system.
  */
 extern LZMA_API(uint64_t) lzma_physmem(void) lzma_nothrow;
+
+
+/**
+ * \brief       Get the number of processor cores or threads
+ *
+ * This function may be useful when determining how many threads to use.
+ * If the hardware supports more than one thread per CPU core, the number
+ * of hardware threads is returned if that information is available.
+ *
+ * \brief       On success, the number of available CPU threads or cores is
+ *              returned. If this information isn't available or an error
+ *              occurs, zero is returned.
+ */
+extern LZMA_API(uint32_t) lzma_cputhreads(void) lzma_nothrow;
index 76432767616b24a40cf37619da76af80bc165b8a..8f54a97a60d47402b50aa266bde1ec14caf054e9 100644 (file)
@@ -44,6 +44,7 @@ liblzma_la_SOURCES += \
 
 if COND_THREADS
 liblzma_la_SOURCES += \
+       common/hardware_cputhreads.c \
        common/outqueue.c \
        common/outqueue.h \
        common/stream_encoder_mt.c
diff --git a/src/liblzma/common/hardware_cputhreads.c b/src/liblzma/common/hardware_cputhreads.c
new file mode 100644 (file)
index 0000000..f468366
--- /dev/null
@@ -0,0 +1,22 @@
+///////////////////////////////////////////////////////////////////////////////
+//
+/// \file       hardware_cputhreads.c
+/// \brief      Get the number of CPU threads or cores
+//
+//  Author:     Lasse Collin
+//
+//  This file has been put into the public domain.
+//  You can do whatever you want with this file.
+//
+///////////////////////////////////////////////////////////////////////////////
+
+#include "common.h"
+
+#include "tuklib_cpucores.h"
+
+
+extern LZMA_API(uint32_t)
+lzma_cputhreads(void)
+{
+       return tuklib_cpucores();
+}
index b5e125edb6fdaec0a9557566ce22318ce249841c..1a453e8e5aea7dd2c3e75dadbd13033698d52f90 100644 (file)
@@ -98,6 +98,7 @@ global:
 XZ_5.1.3alpha {
 global:
        lzma_block_uncomp_encode;
+       lzma_cputhreads;
        lzma_get_progress;
        lzma_stream_encoder_mt;
        lzma_stream_encoder_mt_memusage;