docs: Correct GitHub URLs in lttng-ust.3
[lttng-ust.git] / src / common / macros.h
index 308a1dfca696349832af3df107c22d808155f4bb..e8965b383cae3b25d0228d0778f79ca3487c6483 100644 (file)
@@ -8,9 +8,32 @@
 #define _UST_COMMON_MACROS_H
 
 #include <stdlib.h>
+#include <stdbool.h>
+#include <string.h>
 
 #include <lttng/ust-arch.h>
 
+/*
+ * calloc() does not always populate the page table for the allocated
+ * memory. Optionally enforce page table populate.
+ */
+static inline
+void *zmalloc_populate(size_t len, bool populate)
+       __attribute__((always_inline));
+static inline
+void *zmalloc_populate(size_t len, bool populate)
+{
+       if (populate) {
+               void *ret = malloc(len);
+               if (ret == NULL)
+                       return ret;
+               bzero(ret, len);
+               return ret;
+       } else {
+               return calloc(len, 1);
+       }
+}
+
 /*
  * Memory allocation zeroed
  */
@@ -20,7 +43,7 @@ void *zmalloc(size_t len)
 static inline
 void *zmalloc(size_t len)
 {
-       return calloc(len, 1);
+       return zmalloc_populate(len, false);
 }
 
 #define max_t(type, x, y)                              \
This page took 0.023311 seconds and 4 git commands to generate.