Refactor MakeCpusetFromCpus into realtime.h

It works without event_loop.  Also reuse it for some things in ipc_lib.

Change-Id: I520d254b6b27180b5e45bb43d63d425ca1db9e38
diff --git a/aos/realtime.h b/aos/realtime.h
index c695add..fb49cac 100644
--- a/aos/realtime.h
+++ b/aos/realtime.h
@@ -27,6 +27,16 @@
 // name can have a maximum of 16 characters.
 void SetCurrentThreadName(const std::string_view name);
 
+// Creates a cpu_set_t from a list of CPUs.
+inline cpu_set_t MakeCpusetFromCpus(std::initializer_list<int> cpus) {
+  cpu_set_t result;
+  CPU_ZERO(&result);
+  for (int cpu : cpus) {
+    CPU_SET(cpu, &result);
+  }
+  return result;
+}
+
 // Sets the current thread's scheduling affinity.
 void SetCurrentThreadAffinity(const cpu_set_t &cpuset);