diff --git a/SystemInformation.cxx b/SystemInformation.cxx
index 9ac30bc7c7649da2bb233cd8f2af781ea96a8353..c679c48ddb003173b4e1efb5d2316424db9aac73 100644
--- a/SystemInformation.cxx
+++ b/SystemInformation.cxx
@@ -5131,7 +5131,11 @@ bool SystemInformationImplementation::QueryBSDProcessor()
   defined(__DragonFly__)
   int k;
   size_t sz = sizeof(k);
+#  ifdef HW_NCPUONLINE
+  int ctrl[2] = { CTL_HW, HW_NCPUONLINE };
+#  else
   int ctrl[2] = { CTL_HW, HW_NCPU };
+#  endif
 
   if (sysctl(ctrl, 2, &k, &sz, nullptr, 0) != 0) {
     return false;