summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/modules/lib/osdlib_unix.cpp
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2025-01-13 05:43:09 +1100
committer Vas Crabb <vas@vastheman.com>2025-01-13 05:43:09 +1100
commitff92d10a0485717149b6cebc7122a3d545d48fd3 (patch)
tree735ea2a1959bcb92efa8f6b81fa72dc3494cdc38 /src/osd/modules/lib/osdlib_unix.cpp
parent43c5edd139178545db68a794bdd9ad57678098ad (diff)
osd: Added helper for getting CPU cache line size.
Diffstat (limited to 'src/osd/modules/lib/osdlib_unix.cpp')
-rw-r--r--src/osd/modules/lib/osdlib_unix.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/osd/modules/lib/osdlib_unix.cpp b/src/osd/modules/lib/osdlib_unix.cpp
index 20f6a9ab40c..36004580222 100644
--- a/src/osd/modules/lib/osdlib_unix.cpp
+++ b/src/osd/modules/lib/osdlib_unix.cpp
@@ -53,6 +53,7 @@ void osd_process_kill()
kill(getpid(), SIGKILL);
}
+
//============================================================
// osd_break_into_debugger
//============================================================
@@ -68,6 +69,31 @@ void osd_break_into_debugger(const char *message)
#endif
}
+
+//============================================================
+// osd_get_cache_line_size
+//============================================================
+
+std::pair<std::error_condition, unsigned> osd_get_cache_line_size() noexcept
+{
+#if defined(__linux__)
+ FILE *const f = std::fopen("/sys/devices/system/cpu/cpu0/cache/index0/coherency_line_size", "r");
+ if (!f)
+ return std::make_pair(std::error_condition(errno, std::generic_category()), 0U);
+
+ unsigned result = 0;
+ auto const cnt = std::fscanf(f, "%u", &result);
+ std::fclose(f);
+ if (1 == cnt)
+ return std::make_pair(std::error_condition(), result);
+ else
+ return std::make_pair(std::errc::io_error, 0U);
+#else // defined(__linux__)
+ return std::make_pair(std::errc::not_supported, 0U);
+#endif
+}
+
+
#ifdef SDLMAME_ANDROID
std::string osd_get_clipboard_text() noexcept
{