openssl_shim.c \
openssl_shim.h \
os.c \
+ os_p.h \
parseint.c \
pool.c \
portset.c \
/*! \file isc/os.h */
#include <isc/lang.h>
+#include <isc/types.h>
ISC_LANG_BEGINDECLS
+/*%<
+ * Hardcode the L1 cacheline size of the CPU to 64, this is checked in
+ * the os.c library constructor if operating system provide means to
+ * get the L1 cacheline size using sysconf().
+ */
+#define ISC_OS_CACHELINE_SIZE 64
+
unsigned int
isc_os_ncpus(void);
/*%<
#include "config.h"
#include "mem_p.h"
+#include "os_p.h"
#include "tls_p.h"
#include "trampoline_p.h"
void
isc__initialize(void) {
+ isc__os_initialize();
isc__mem_initialize();
isc__tls_initialize();
isc__trampoline_initialize();
isc__trampoline_shutdown();
isc__tls_shutdown();
isc__mem_shutdown();
+ isc__os_shutdown();
}
* information regarding copyright ownership.
*/
-#include <isc/once.h>
+#include <inttypes.h>
+
#include <isc/os.h>
+#include <isc/types.h>
#include <isc/util.h>
-static isc_once_t ncpus_once = ISC_ONCE_INIT;
-static unsigned int ncpus = 0;
+#include "os_p.h"
+
+static unsigned int isc__os_ncpus = 0;
#ifdef HAVE_SYSCONF
static void
ncpus_initialize(void) {
#if defined(HAVE_SYSCONF)
- ncpus = sysconf_ncpus();
+ isc__os_ncpus = sysconf_ncpus();
#endif /* if defined(HAVE_SYSCONF) */
#if defined(HAVE_SYS_SYSCTL_H) && defined(HAVE_SYSCTLBYNAME)
- if (ncpus <= 0) {
- ncpus = sysctl_ncpus();
+ if (isc__os_ncpus <= 0) {
+ isc__os_ncpus = sysctl_ncpus();
}
#endif /* if defined(HAVE_SYS_SYSCTL_H) && defined(HAVE_SYSCTLBYNAME) */
- if (ncpus <= 0) {
- ncpus = 1;
+ if (isc__os_ncpus == 0) {
+ isc__os_ncpus = 1;
}
}
unsigned int
isc_os_ncpus(void) {
- isc_result_t result = isc_once_do(&ncpus_once, ncpus_initialize);
- RUNTIME_CHECK(result == ISC_R_SUCCESS);
- INSIST(ncpus > 0);
+ return (isc__os_ncpus);
+}
+
+void
+isc__os_initialize(void) {
+ ncpus_initialize();
+#if defined(HAVE_SYSCONF) && defined(_SC_LEVEL1_DCACHE_LINESIZE)
+ long s = sysconf(_SC_LEVEL1_DCACHE_LINESIZE);
+ RUNTIME_CHECK((size_t)s == (size_t)ISC_OS_CACHELINE_SIZE);
+#endif
+}
- return (ncpus);
+void
+isc__os_shutdown(void) {
+ /* empty, but defined for completeness */;
}
--- /dev/null
+/*
+ * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, you can obtain one at https://mozilla.org/MPL/2.0/.
+ *
+ * See the COPYRIGHT file distributed with this work for additional
+ * information regarding copyright ownership.
+ */
+
+#pragma once
+
+#include <stdio.h>
+
+#include <isc/os.h>
+
+/*! \file */
+
+void
+isc__os_initialize(void);
+
+void
+isc__os_shutdown(void);
./lib/isc/openssl_shim.c C 2018,2019,2020,2021,2022
./lib/isc/openssl_shim.h C 2020,2021,2022
./lib/isc/os.c C 2000,2001,2004,2005,2007,2016,2018,2019,2020,2021,2022
+./lib/isc/os_p.h C 2022
./lib/isc/parseint.c C 2001,2002,2003,2004,2005,2007,2012,2016,2018,2019,2020,2021,2022
./lib/isc/pool.c C 2013,2015,2016,2018,2019,2020,2021,2022
./lib/isc/portset.c C 2008,2016,2017,2018,2019,2020,2021,2022