Skip to content

Commit

Permalink
add DUCKDB_NO_THREADS check
Browse files Browse the repository at this point in the history
  • Loading branch information
lnkuiper committed Nov 4, 2024
1 parent 961af3a commit c24736c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
22 changes: 22 additions & 0 deletions extension/jemalloc/include/malloc_ncpus.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//===----------------------------------------------------------------------===//
// DuckDB
//
// malloc_ncpus.h
//
//
//===----------------------------------------------------------------------===//

#ifndef MALLOC_NCPUS_H
#define MALLOC_NCPUS_H

#ifdef __cplusplus
extern "C" {
#endif

unsigned duckdb_malloc_ncpus();

#ifdef __cplusplus
}
#endif

#endif // MALLOC_NCPUS_H
4 changes: 4 additions & 0 deletions extension/jemalloc/jemalloc_extension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,11 @@ std::string JemallocExtension::Version() const {
extern "C" {

unsigned duckdb_malloc_ncpus() {
#ifdef DUCKDB_NO_THREADS
return 1
#else
return duckdb::NumericCast<unsigned>(std::thread::hardware_concurrency());
#endif
}

DUCKDB_EXTENSION_API void jemalloc_init(duckdb::DatabaseInstance &db) {
Expand Down

0 comments on commit c24736c

Please sign in to comment.