mempool: cpu=-1 for init_func argument (global pool)
[librseq.git] / src / rseq-mempool.c
index 5823ae59be9e2cccff60c77ef00566c95b9c7b36..0c79e5a00ec57d79c7272931da4bcdd85f60deea 100644 (file)
@@ -465,14 +465,27 @@ struct rseq_mempool_range *rseq_mempool_range_create(struct rseq_mempool *pool)
                        goto error_alloc;
        }
        if (pool->attr.init_set) {
-               int cpu;
-
-               for (cpu = 0; cpu < pool->attr.max_nr_cpus; cpu++) {
+               switch (pool->attr.type) {
+               case MEMPOOL_TYPE_GLOBAL:
                        if (pool->attr.init_func(pool->attr.init_priv,
-                                       base + (pool->attr.stride * cpu),
-                                       pool->attr.stride, cpu)) {
+                                       base, pool->attr.stride, -1)) {
                                goto error_alloc;
                        }
+                       break;
+               case MEMPOOL_TYPE_PERCPU:
+               {
+                       int cpu;
+                       for (cpu = 0; cpu < pool->attr.max_nr_cpus; cpu++) {
+                               if (pool->attr.init_func(pool->attr.init_priv,
+                                               base + (pool->attr.stride * cpu),
+                                               pool->attr.stride, cpu)) {
+                                       goto error_alloc;
+                               }
+                       }
+                       break;
+               }
+               default:
+                       abort();
                }
        }
        return range;
This page took 0.024057 seconds and 4 git commands to generate.