Skip to content

Instantly share code, notes, and snippets.

@r7vme
Created January 25, 2021 21:40
Show Gist options
  • Save r7vme/997a9a2a270b97da0bc96379cd85390c to your computer and use it in GitHub Desktop.
Save r7vme/997a9a2a270b97da0bc96379cd85390c to your computer and use it in GitHub Desktop.
#include <sys/sysinfo.h>
#include <stdio.h>
#include <stdbool.h>
bool is_multicore_system(void) {
return (get_nprocs_conf() > 1) ? true : false;
}
// wrapper emulates single processor system
int __wrap_get_nprocs_conf() { return 1; }
int main(int argc, char *argv[])
{
is_multicore_system() ? printf("multicore system\n") : printf("singlecore system\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment