liblzma: Add lzma_cputhreads().

This commit is contained in:
Lasse Collin 2014-06-18 22:04:24 +03:00
parent 3ce3e79769
commit a115cc3748
5 changed files with 45 additions and 1 deletions

View File

@ -12,7 +12,7 @@ CLEANFILES =
doc_DATA = doc_DATA =
lib_LTLIBRARIES = liblzma.la lib_LTLIBRARIES = liblzma.la
liblzma_la_SOURCES = $(top_srcdir)/src/common/tuklib_physmem.c liblzma_la_SOURCES =
liblzma_la_CPPFLAGS = \ liblzma_la_CPPFLAGS = \
-I$(top_srcdir)/src/liblzma/api \ -I$(top_srcdir)/src/liblzma/api \
-I$(top_srcdir)/src/liblzma/common \ -I$(top_srcdir)/src/liblzma/common \
@ -32,6 +32,12 @@ liblzma_la_LDFLAGS += \
-Wl,--version-script=$(top_srcdir)/src/liblzma/liblzma.map -Wl,--version-script=$(top_srcdir)/src/liblzma/liblzma.map
endif 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)/common/Makefile.inc
include $(srcdir)/check/Makefile.inc include $(srcdir)/check/Makefile.inc

View File

@ -48,3 +48,17 @@
* of RAM on the specific operating system. * of RAM on the specific operating system.
*/ */
extern LZMA_API(uint64_t) lzma_physmem(void) lzma_nothrow; 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;

View File

@ -44,6 +44,7 @@ liblzma_la_SOURCES += \
if COND_THREADS if COND_THREADS
liblzma_la_SOURCES += \ liblzma_la_SOURCES += \
common/hardware_cputhreads.c \
common/outqueue.c \ common/outqueue.c \
common/outqueue.h \ common/outqueue.h \
common/stream_encoder_mt.c common/stream_encoder_mt.c

View File

@ -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();
}

View File

@ -98,6 +98,7 @@ global:
XZ_5.1.3alpha { XZ_5.1.3alpha {
global: global:
lzma_block_uncomp_encode; lzma_block_uncomp_encode;
lzma_cputhreads;
lzma_get_progress; lzma_get_progress;
lzma_stream_encoder_mt; lzma_stream_encoder_mt;
lzma_stream_encoder_mt_memusage; lzma_stream_encoder_mt_memusage;