lib: iterator auto-seeking: handle intersecting discarded items messages
[babeltrace.git] / include / babeltrace / babeltrace-internal.h
index 583d949ca2ebe72d4f9874cf074affd5ec7527b3..981f84b186910cd7145fe04cb93c30805752e36c 100644 (file)
@@ -2,8 +2,6 @@
 #define _BABELTRACE_INTERNAL_H
 
 /*
- * babeltrace/babeltrace-internal.h
- *
  * Copyright 2012 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -28,6 +26,7 @@
 #include <glib.h>
 #include <stdint.h>
 #include <stdlib.h>
+#include <stdbool.h>
 #include <errno.h>
 #include <babeltrace/compat/string-internal.h>
 #include <babeltrace/types.h>
        ((type) (a) > (type) (b) ? (type) (a) : (type) (b))
 #endif
 
+static inline
+bool bt_safe_to_mul_int64(int64_t a, int64_t b)
+{
+       if (a == 0 || b == 0) {
+               return true;
+       }
+
+       return a < INT64_MAX / b;
+}
+
+static inline
+bool bt_safe_to_mul_uint64(uint64_t a, uint64_t b)
+{
+       if (a == 0 || b == 0) {
+               return true;
+       }
+
+       return a < UINT64_MAX / b;
+}
+
+static inline
+bool bt_safe_to_add_int64(int64_t a, int64_t b)
+{
+       return a <= INT64_MAX - b;
+}
+
+static inline
+bool bt_safe_to_add_uint64(uint64_t a, uint64_t b)
+{
+       return a <= UINT64_MAX - b;
+}
+
 /*
  * Memory allocation zeroed
  */
 
 #define TOSTRING(x)    __STRINGIFY(x)
 
+#define BT_UNUSED      __attribute__((unused))
+
 #endif
This page took 0.023237 seconds and 4 git commands to generate.