Do not use `bool` type; use new `bt_bool` instead
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 11 May 2017 21:12:46 +0000 (17:12 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sun, 28 May 2017 16:57:42 +0000 (12:57 -0400)
There are possible ABI incompatibilities between C99's `bool` (`_Bool`)
type and C++'s `bool` type, and also between different compilers. For
this reason we choose to use our own boolean type, `bt_bool`, which is
defined as `int`. `BT_FALSE` and `BT_TRUE` are our own definitions for
false and true.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
60 files changed:
cli/babeltrace-cfg.h
cli/babeltrace.c
doc/api/Doxyfile.in
include/Makefile.am
include/babeltrace/babeltrace-internal.h
include/babeltrace/babeltrace.h
include/babeltrace/common-internal.h
include/babeltrace/ctf-ir/clock-class-internal.h
include/babeltrace/ctf-ir/clock-class.h
include/babeltrace/ctf-ir/field-types-internal.h
include/babeltrace/ctf-ir/fields-internal.h
include/babeltrace/ctf-ir/trace-internal.h
include/babeltrace/ctf-ir/trace.h
include/babeltrace/ctf-writer/serialize-internal.h
include/babeltrace/graph/clock-class-priority-map-internal.h
include/babeltrace/graph/component-class-internal.h
include/babeltrace/graph/component-class.h
include/babeltrace/graph/component-internal.h
include/babeltrace/graph/component.h
include/babeltrace/graph/notification-heap.h
include/babeltrace/graph/notification-internal.h
include/babeltrace/graph/notification-iterator-internal.h
include/babeltrace/graph/port.h
include/babeltrace/plugin/plugin-internal.h
include/babeltrace/plugin/plugin-so-internal.h
include/babeltrace/plugin/plugin.h
include/babeltrace/types.h [new file with mode: 0644]
include/babeltrace/values.h
lib/babeltrace.c
lib/ctf-ir/clock-class.c
lib/ctf-ir/event-class.c
lib/ctf-ir/field-types.c
lib/ctf-ir/fields.c
lib/ctf-ir/resolve.c
lib/ctf-ir/stream.c
lib/ctf-ir/trace.c
lib/ctf-writer/serialize.c
lib/ctf-writer/writer.c
lib/graph/component-class.c
lib/graph/component.c
lib/graph/graph.c
lib/graph/iterator.c
lib/graph/notification/event.c
lib/plugin/plugin-so.c
lib/plugin/plugin.c
lib/values.c
plugins/ctf/common/metadata/visitor-generate-ir.c
plugins/ctf/fs-src/fs.c
plugins/ctf/fs-src/fs.h
plugins/lttng-utils/plugin.c
plugins/text/pretty/pretty.c
plugins/utils/muxer/muxer.c
plugins/utils/trimmer/trimmer.c
tests/lib/test_bt_ctf_field_type_validation.c
tests/lib/test_bt_notification_heap.c
tests/lib/test_bt_notification_iterator.c
tests/lib/test_bt_values.c
tests/lib/test_ir_visit.c
tests/lib/test_plugin.c
tests/plugins/test-utils-muxer.c

index ca84ae3fdd721bc01334ab8f3bbbf29e0e63b082..8723129587918c155a95993930441773428ebf14 100644 (file)
@@ -27,6 +27,7 @@
 
 #include <stdlib.h>
 #include <stdint.h>
+#include <stdbool.h>
 #include <babeltrace/values.h>
 #include <babeltrace/ref.h>
 #include <babeltrace/object-internal.h>
index ba8473af3a02c7ea3fd6aa614fb98b9db50b5782..f42b563e2a943f841f22b127424dfb7f61e7fd04 100644 (file)
@@ -218,7 +218,7 @@ struct print_map_value_data {
 };
 
 static
-bool print_map_value(const char *key, struct bt_value *object, void *data)
+bt_bool print_map_value(const char *key, struct bt_value *object, void *data)
 {
        struct print_map_value_data *print_map_value_data = data;
 
@@ -244,13 +244,13 @@ bool print_map_value(const char *key, struct bt_value *object, void *data)
 
        print_value_rec(print_map_value_data->fp, object,
                print_map_value_data->indent + 2);
-       return true;
+       return BT_TRUE;
 }
 
 static
 void print_value_rec(FILE *fp, struct bt_value *value, size_t indent)
 {
-       bool bool_val;
+       bt_bool bool_val;
        int64_t int_val;
        double dbl_val;
        const char *str_val;
index adb2a564afc2257dee346e5817d79524793cae65..7a82c1cfc350c1bd2ce121aa27918c90df32c5b1 100644 (file)
@@ -147,6 +147,7 @@ INPUT                  = "@top_srcdir@/include/babeltrace/ctf-ir" \
                          "@top_srcdir@/include/babeltrace/ref.h" \
                          "@top_srcdir@/include/babeltrace/values.h" \
                          "@top_srcdir@/include/babeltrace/logging.h" \
+                         "@top_srcdir@/include/babeltrace/types.h" \
                          "@srcdir@/dox/main-page.dox" \
                          "@srcdir@/dox/includes-build.dox" \
                          "@srcdir@/dox/write-plugin.dox" \
index 124dce7eee90ba6b878b7bf02806fd6a54e0fdbf..cdf7fb00c1ddaea2520e7a5f9008d32e0fb17c0f 100644 (file)
@@ -4,7 +4,8 @@ babeltraceinclude_HEADERS = \
        babeltrace/values.h \
        babeltrace/ref.h \
        babeltrace/logging.h \
-       babeltrace/version.h
+       babeltrace/version.h \
+       babeltrace/types.h
 
 # Legacy API (for CTF writer)
 babeltracectfinclude_HEADERS = \
index 917e3f5d62058baf6f9f957aecac72f89f9d29a6..18ed309f86dc1823fcfecd0d32023d2ce1aa46d0 100644 (file)
 #include <stdint.h>
 #include <stdlib.h>
 #include <errno.h>
-#include <stdbool.h>
 #include <babeltrace/compat/string-internal.h>
+#include <babeltrace/types.h>
 
 #define PERROR_BUFLEN  200
 
-extern bool babeltrace_verbose, babeltrace_debug;
+extern bt_bool babeltrace_verbose, babeltrace_debug;
 
 #define printf_verbose(fmt, args...)                                   \
        do {                                                            \
index da6d03e90260e2d879a2885048ee5c7bb1075214..36f1b3839c94c68c974b1654298ef730eb9f7255 100644 (file)
@@ -28,6 +28,7 @@
 /* Core API */
 #include <babeltrace/logging.h>
 #include <babeltrace/ref.h>
+#include <babeltrace/types.h>
 #include <babeltrace/values.h>
 #include <babeltrace/version.h>
 
index 6cd15b8e573df85b7a9f2d8a53183a923715c6f4..fd8b12e3e862c17c10dce901b16c38fc0c1d152e 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef BABELTRACE_COMMON_INTERNAL_H
 #define BABELTRACE_COMMON_INTERNAL_H
 
+#include <stdbool.h>
 #include <babeltrace/babeltrace-internal.h>
 
 #define BT_COMMON_COLOR_RESET              "\033[0m"
index 0d7d89174c6e1ce9f0532fb62131099dc7723487..d68796e7d15cc82324b35488510add9b5ca4d068 100644 (file)
@@ -31,8 +31,9 @@
 #include <babeltrace/ctf-ir/trace-internal.h>
 #include <babeltrace/object-internal.h>
 #include <babeltrace/babeltrace-internal.h>
-#include <glib.h>
 #include <babeltrace/compat/uuid-internal.h>
+#include <babeltrace/types.h>
+#include <glib.h>
 
 struct bt_ctf_clock_class {
        struct bt_object base;
@@ -67,6 +68,6 @@ void bt_ctf_clock_class_serialize(struct bt_ctf_clock_class *clock_class,
                struct metadata_context *context);
 
 BT_HIDDEN
-bool bt_ctf_clock_class_is_valid(struct bt_ctf_clock_class *clock_class);
+bt_bool bt_ctf_clock_class_is_valid(struct bt_ctf_clock_class *clock_class);
 
 #endif /* BABELTRACE_CTF_IR_CLOCK_CLASS_INTERNAL_H */
index 223d59f683d9876e44ffbb6a943a012df6f508ce..3f461aa10765d54b424b03f156136091afb4bfbc 100644 (file)
@@ -32,6 +32,7 @@
  */
 
 #include <stdint.h>
+#include <babeltrace/types.h>
 
 #ifdef __cplusplus
 extern "C" {
index f54e859bb56c8dc8d2f8444a48e041805e2770b1..2b860405225f9502d58db8b90cfc5195f98bb86f 100644 (file)
@@ -35,6 +35,7 @@
 #include <babeltrace/ctf-ir/clock-class.h>
 #include <babeltrace/babeltrace-internal.h>
 #include <babeltrace/object-internal.h>
+#include <babeltrace/types.h>
 #include <glib.h>
 
 typedef void (*type_freeze_func)(struct bt_ctf_field_type *);
@@ -65,7 +66,7 @@ struct bt_ctf_field_type_integer {
        struct bt_ctf_field_type parent;
        struct bt_ctf_clock_class *mapped_clock;
        enum bt_ctf_byte_order user_byte_order;
-       bool is_signed;
+       bt_bool is_signed;
        unsigned int size;
        enum bt_ctf_integer_base base;
        enum bt_ctf_string_encoding encoding;
@@ -89,7 +90,7 @@ struct bt_ctf_field_type_enumeration {
        struct bt_ctf_field_type *container;
        GPtrArray *entries; /* Array of ptrs to struct enumeration_mapping */
        /* Only set during validation. */
-       bool has_overlapping_ranges;
+       bt_bool has_overlapping_ranges;
 };
 
 enum bt_ctf_field_type_enumeration_mapping_iterator_type {
index 75769fdf9bd3f6277d387127f768eadb9f2bfc88..b7375a459f226af7aecdc08927fe0274ae08dae4 100644 (file)
@@ -31,6 +31,7 @@
 #include <babeltrace/ctf-writer/event-fields.h>
 #include <babeltrace/object-internal.h>
 #include <babeltrace/babeltrace-internal.h>
+#include <babeltrace/types.h>
 #include <stdint.h>
 #include <glib.h>
 
@@ -106,6 +107,6 @@ BT_HIDDEN
 void bt_ctf_field_freeze(struct bt_ctf_field *field);
 
 BT_HIDDEN
-bool bt_ctf_field_is_set(struct bt_ctf_field *field);
+bt_bool bt_ctf_field_is_set(struct bt_ctf_field *field);
 
 #endif /* BABELTRACE_CTF_IR_FIELDS_INTERNAL_H */
index f49e85bc1d09d7f7dbf1d013a8bda0ebeaf43c54..b468379aa2a19e9d33d8e0b5fef164933d6b1d3d 100644 (file)
@@ -33,6 +33,7 @@
 #include <babeltrace/object-internal.h>
 #include <babeltrace/babeltrace-internal.h>
 #include <babeltrace/values.h>
+#include <babeltrace/types.h>
 #include <glib.h>
 #include <sys/types.h>
 #include <uuid/uuid.h>
@@ -52,7 +53,7 @@ struct bt_ctf_trace {
        GString *name;
        int frozen;
        uuid_t uuid;
-       bool uuid_set;
+       bt_bool uuid_set;
        enum bt_ctf_byte_order native_byte_order;
        struct bt_value *environment;
        GPtrArray *clocks; /* Array of pointers to bt_ctf_clock_class */
@@ -68,7 +69,7 @@ struct bt_ctf_trace {
         */
        int valid;
        GPtrArray *listeners; /* Array of struct listener_wrapper */
-       bool is_static;
+       bt_bool is_static;
 };
 
 struct metadata_context {
@@ -88,7 +89,7 @@ int bt_ctf_trace_object_modification(struct bt_ctf_object *object,
                void *trace_ptr);
 
 BT_HIDDEN
-bool bt_ctf_trace_has_clock_class(struct bt_ctf_trace *trace,
+bt_bool bt_ctf_trace_has_clock_class(struct bt_ctf_trace *trace,
                struct bt_ctf_clock_class *clock_class);
 
 /**
index f358422591c3cb8f32d4a6d14a4df3695cb48341..e6a3bc47f779799be7ccc54cc8f81195860a0715 100644 (file)
@@ -34,6 +34,7 @@
 #include <babeltrace/ctf-ir/visitor.h>
 #include <babeltrace/values.h>
 #include <babeltrace/graph/notification.h>
+#include <babeltrace/types.h>
 #include <stdint.h>
 
 #ifdef __cplusplus
@@ -811,15 +812,15 @@ It is guaranteed that a static trace class will never contain new
 streams, stream classes, or clock classes. A static class is always
 frozen.
 
-This function returns \c true if bt_ctf_trace_set_is_static() was
+This function returns #BT_TRUE if bt_ctf_trace_set_is_static() was
 previously called on it.
 
 @param[in] trace_class Trace class to check.
-@returns               \c true if \p trace_class is static,
+@returns               #BT_TRUE if \p trace_class is static,
 
 @sa bt_ctf_trace_set_is_static(): Makes a trace class static.
 */
-extern bool bt_ctf_trace_is_static(struct bt_ctf_trace *trace_class);
+extern bt_bool bt_ctf_trace_is_static(struct bt_ctf_trace *trace_class);
 
 /**
 @brief Makes the CTF IR trace class \p trace_class static.
index 6095ae646da6d54df0fc393f89b83c2b86ebb10c..6471993c23a5c739c5e3e1b87c1446fb46c354d3 100644 (file)
@@ -37,6 +37,7 @@
 #include <babeltrace/ctf-ir/fields-internal.h>
 #include <babeltrace/align-internal.h>
 #include <babeltrace/mmap-align-internal.h>
+#include <babeltrace/types.h>
 
 struct bt_ctf_stream_pos {
        int fd;
@@ -130,7 +131,7 @@ int bt_ctf_stream_pos_init(struct bt_ctf_stream_pos *pos,
                pos->flags = MAP_SHARED;
                break;
        default:
-               assert(false);
+               assert(BT_FALSE);
        }
 
        return 0;
index 049421458c0d7b64d551adff169e157b31a316f1..89ba1c9dfc620bdfd8ac41697499fb4431679021 100644 (file)
 
 #include <stdint.h>
 #include <stddef.h>
-#include <stdbool.h>
 #include <assert.h>
 #include <babeltrace/ctf-ir/clock-class.h>
 #include <babeltrace/object-internal.h>
+#include <babeltrace/types.h>
 #include <glib.h>
 
 struct bt_clock_class_priority_map {
@@ -46,7 +46,7 @@ struct bt_clock_class_priority_map {
        /* Clock class (weak) with the currently highest priority */
        struct bt_ctf_clock_class *highest_prio_cc;
 
-       bool frozen;
+       bt_bool frozen;
 };
 
 static inline
@@ -54,7 +54,7 @@ void bt_clock_class_priority_map_freeze(
                struct bt_clock_class_priority_map *cc_prio_map)
 {
        assert(cc_prio_map);
-       cc_prio_map->frozen = true;
+       cc_prio_map->frozen = BT_TRUE;
 }
 
 #endif /* BABELTRACE_GRAPH_CLOCK_CLASS_PRIORITY_MAP_INTERNAL_H */
index 5f84dcd4edfe26de2bdeac332876c4ae3ec962a8..03314845d9f3536493fbec9606898cca86a3737b 100644 (file)
@@ -35,7 +35,7 @@
 #include <babeltrace/graph/component-class-sink.h>
 #include <babeltrace/babeltrace-internal.h>
 #include <babeltrace/object-internal.h>
-#include <stdbool.h>
+#include <babeltrace/types.h>
 #include <glib.h>
 
 struct bt_component_class;
@@ -64,7 +64,7 @@ struct bt_component_class {
        } methods;
        /* Array of struct bt_component_class_destroy_listener */
        GArray *destroy_listeners;
-       bool frozen;
+       bt_bool frozen;
 };
 
 struct bt_component_class_iterator_methods {
index e30c329cf894f4f6d295e7c2c623339e8c388173..c98088b1069dc7e152146195d9633c70b6166323 100644 (file)
@@ -26,9 +26,9 @@
  */
 
 #include <stdint.h>
-#include <stdbool.h>
 #include <babeltrace/graph/component-status.h>
 #include <babeltrace/graph/notification-iterator.h>
+#include <babeltrace/types.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -172,21 +172,21 @@ extern enum bt_component_class_type bt_component_class_get_type(
                struct bt_component_class *component_class);
 
 static inline
-bool bt_component_class_is_source(struct bt_component_class *component_class)
+bt_bool bt_component_class_is_source(struct bt_component_class *component_class)
 {
        return bt_component_class_get_type(component_class) ==
                BT_COMPONENT_CLASS_TYPE_SOURCE;
 }
 
 static inline
-bool bt_component_class_is_filter(struct bt_component_class *component_class)
+bt_bool bt_component_class_is_filter(struct bt_component_class *component_class)
 {
        return bt_component_class_get_type(component_class) ==
                BT_COMPONENT_CLASS_TYPE_FILTER;
 }
 
 static inline
-bool bt_component_class_is_sink(struct bt_component_class *component_class)
+bt_bool bt_component_class_is_sink(struct bt_component_class *component_class)
 {
        return bt_component_class_get_type(component_class) ==
                BT_COMPONENT_CLASS_TYPE_SINK;
index fe55a601ff3f6678b6b211d155a32aa02e7abc92..eaa77339b13deaf263474a03fd636056b8d6a6cb 100644 (file)
@@ -32,6 +32,7 @@
 #include <babeltrace/graph/component-class-internal.h>
 #include <babeltrace/graph/port-internal.h>
 #include <babeltrace/object-internal.h>
+#include <babeltrace/types.h>
 #include <glib.h>
 #include <stdio.h>
 
@@ -61,7 +62,7 @@ struct bt_component {
         * Used to protect operations which may only be used during
         * a component's initialization.
         */
-       bool initializing;
+       bt_bool initializing;
 
        /* Input and output ports (weak references) */
        GPtrArray *input_ports;
index 975c10e326886b963117590f9ae5434677bce4ef..31fde560a59edb9fe0d83595e3f778b123ec8c18 100644 (file)
@@ -31,7 +31,7 @@
 #include <babeltrace/graph/component-class.h>
 #include <babeltrace/graph/notification-iterator.h>
 #include <babeltrace/values.h>
-#include <stdbool.h>
+#include <babeltrace/types.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -80,21 +80,21 @@ extern enum bt_component_class_type bt_component_get_class_type(
                struct bt_component *component);
 
 static inline
-bool bt_component_is_source(struct bt_component *component)
+bt_bool bt_component_is_source(struct bt_component *component)
 {
        return bt_component_get_class_type(component) ==
                BT_COMPONENT_CLASS_TYPE_SOURCE;
 }
 
 static inline
-bool bt_component_is_filter(struct bt_component *component)
+bt_bool bt_component_is_filter(struct bt_component *component)
 {
        return bt_component_get_class_type(component) ==
                BT_COMPONENT_CLASS_TYPE_FILTER;
 }
 
 static inline
-bool bt_component_is_sink(struct bt_component *component)
+bt_bool bt_component_is_sink(struct bt_component *component)
 {
        return bt_component_get_class_type(component) ==
                BT_COMPONENT_CLASS_TYPE_SINK;
index 8eb2f7f80b96a962353692811a5512809763c9a4..51f2b3151e829286c5e9bd5d57503d685da62b35 100644 (file)
@@ -27,9 +27,9 @@
  */
 
 #include <stddef.h>
-#include <stdbool.h>
 #include <babeltrace/graph/notification.h>
 #include <babeltrace/babeltrace-internal.h>
+#include <babeltrace/types.h>
 
 /**
  * bt_notification_time_compare - Compare two notifications' timestamps
@@ -40,7 +40,7 @@
  * used to order the notifications. This criterion shall ensure a consistent
  * ordering over multiple runs.
  */
-typedef bool (*bt_notification_time_compare_func)(
+typedef bt_bool (*bt_notification_time_compare_func)(
                struct bt_notification *a, struct bt_notification *b,
                void *user_data);
 
index 01eb59670cc3fb89802df7eb180c2b0f21c5b97e..e13f660cf419b25bb427a56f9d49f1f823fbabc3 100644 (file)
  * SOFTWARE.
  */
 
-#include <stdbool.h>
 #include <babeltrace/ref-internal.h>
 #include <babeltrace/babeltrace-internal.h>
 #include <babeltrace/object-internal.h>
 #include <babeltrace/graph/notification.h>
 #include <babeltrace/ctf-ir/stream.h>
+#include <babeltrace/types.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -45,7 +45,7 @@ struct bt_notification {
        struct bt_object base;
        enum bt_notification_type type;
        get_stream_func get_stream;
-       bool frozen;
+       bt_bool frozen;
 };
 
 BT_HIDDEN
@@ -56,7 +56,7 @@ void bt_notification_init(struct bt_notification *notification,
 BT_HIDDEN
 static inline void bt_notification_freeze(struct bt_notification *notification)
 {
-       notification->frozen = true;
+       notification->frozen = BT_TRUE;
 }
 
 #ifdef __cplusplus
index 90a8ee4760ddff7ea1842bdc9449773dd31979df..e1f9f211a6817e8adc9ef2bac66cc97ef690432a 100644 (file)
@@ -32,6 +32,7 @@
 #include <babeltrace/graph/notification.h>
 #include <babeltrace/graph/notification-iterator.h>
 #include <babeltrace/graph/private-notification-iterator.h>
+#include <babeltrace/types.h>
 
 struct bt_port;
 
@@ -85,7 +86,7 @@ struct bt_notification_iterator {
         */
        uint32_t subscription_mask;
 
-       bool is_ended;
+       bt_bool is_ended;
        void *user_data;
 };
 
index 7569961b8bd585f2be3385d7d9c39c32ea28c7e0..069daba1589dbdf95dfeb38a01eceede4322c4ad 100644 (file)
@@ -28,7 +28,7 @@
  */
 
 #include <stdint.h>
-#include <stdbool.h>
+#include <babeltrace/types.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -58,13 +58,13 @@ extern int bt_port_disconnect(struct bt_port *port);
 extern int bt_port_is_connected(struct bt_port *port);
 
 static inline
-bool bt_port_is_input(struct bt_port *port)
+bt_bool bt_port_is_input(struct bt_port *port)
 {
        return bt_port_get_type(port) == BT_PORT_TYPE_INPUT;
 }
 
 static inline
-bool bt_port_is_output(struct bt_port *port)
+bt_bool bt_port_is_output(struct bt_port *port)
 {
        return bt_port_get_type(port) == BT_PORT_TYPE_OUTPUT;
 }
index 7b38a2d3d219ffcceed302fe7dd0e3a7b06d506f..539fe1413c89c432db32779d8be4af5f2879c34e 100644 (file)
@@ -30,7 +30,7 @@
 #include <babeltrace/babeltrace-internal.h>
 #include <babeltrace/plugin/plugin-dev.h>
 #include <babeltrace/object-internal.h>
-#include <stdbool.h>
+#include <babeltrace/types.h>
 #include <glib.h>
 
 enum bt_plugin_type {
@@ -41,7 +41,7 @@ enum bt_plugin_type {
 struct bt_plugin {
        struct bt_object base;
        enum bt_plugin_type type;
-       bool frozen;
+       bt_bool frozen;
 
        /* Array of pointers to bt_component_class (owned by this) */
        GPtrArray *comp_classes;
@@ -59,12 +59,12 @@ struct bt_plugin {
                        unsigned int patch;
                        GString *extra;
                } version;
-               bool path_set;
-               bool name_set;
-               bool author_set;
-               bool license_set;
-               bool description_set;
-               bool version_set;
+               bt_bool path_set;
+               bt_bool name_set;
+               bt_bool author_set;
+               bt_bool license_set;
+               bt_bool description_set;
+               bt_bool version_set;
        } info;
 
        /* Value depends on the specific plugin type */
@@ -188,7 +188,7 @@ void bt_plugin_set_path(struct bt_plugin *plugin, const char *path)
        assert(plugin);
        assert(path);
        g_string_assign(plugin->info.path, path);
-       plugin->info.path_set = true;
+       plugin->info.path_set = BT_TRUE;
 }
 
 static inline
@@ -197,7 +197,7 @@ void bt_plugin_set_name(struct bt_plugin *plugin, const char *name)
        assert(plugin);
        assert(name);
        g_string_assign(plugin->info.name, name);
-       plugin->info.name_set = true;
+       plugin->info.name_set = BT_TRUE;
 }
 
 static inline
@@ -207,7 +207,7 @@ void bt_plugin_set_description(struct bt_plugin *plugin,
        assert(plugin);
        assert(description);
        g_string_assign(plugin->info.description, description);
-       plugin->info.description_set = true;
+       plugin->info.description_set = BT_TRUE;
 }
 
 static inline
@@ -216,7 +216,7 @@ void bt_plugin_set_author(struct bt_plugin *plugin, const char *author)
        assert(plugin);
        assert(author);
        g_string_assign(plugin->info.author, author);
-       plugin->info.author_set = true;
+       plugin->info.author_set = BT_TRUE;
 }
 
 static inline
@@ -225,7 +225,7 @@ void bt_plugin_set_license(struct bt_plugin *plugin, const char *license)
        assert(plugin);
        assert(license);
        g_string_assign(plugin->info.license, license);
-       plugin->info.license_set = true;
+       plugin->info.license_set = BT_TRUE;
 }
 
 static inline
@@ -241,14 +241,14 @@ void bt_plugin_set_version(struct bt_plugin *plugin, unsigned int major,
                g_string_assign(plugin->info.version.extra, extra);
        }
 
-       plugin->info.version_set = true;
+       plugin->info.version_set = BT_TRUE;
 }
 
 static inline
 void bt_plugin_freeze(struct bt_plugin *plugin)
 {
        assert(plugin);
-       plugin->frozen = true;
+       plugin->frozen = BT_TRUE;
 }
 
 static
index 9c511769220656c6bb3796af58b0370357f7170b..07df7422eea6b8b390476630e81fd3bf18414d4b 100644 (file)
@@ -30,6 +30,7 @@
 
 #include <glib.h>
 #include <gmodule.h>
+#include <babeltrace/types.h>
 
 struct bt_plugin;
 struct bt_component_class;
@@ -40,7 +41,7 @@ struct bt_plugin_so_shared_lib_handle {
        GModule *module;
 
        /* True if initialization function was called */
-       bool init_called;
+       bt_bool init_called;
        bt_plugin_exit_func exit;
 };
 
index 1738c27df0d2e29b3b4e6bf6dc046aa7bbf78d7f..b9be67436b08bd386ab30f6f3fb9b840e6f78394 100644 (file)
@@ -30,8 +30,8 @@
 
 #include <stdint.h>
 #include <stddef.h>
-#include <stdbool.h>
 #include <babeltrace/graph/component-class.h>
+#include <babeltrace/types.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -62,7 +62,7 @@ extern struct bt_component_class *bt_plugin_find_component_class(
 extern struct bt_plugin_set *bt_plugin_create_all_from_file(const char *path);
 
 extern struct bt_plugin_set *bt_plugin_create_all_from_dir(const char *path,
-               bool recurse);
+               bt_bool recurse);
 
 extern struct bt_plugin_set *bt_plugin_create_all_from_static(void);
 
diff --git a/include/babeltrace/types.h b/include/babeltrace/types.h
new file mode 100644 (file)
index 0000000..f0bf0f1
--- /dev/null
@@ -0,0 +1,81 @@
+#ifndef BABELTRACE_TYPES_H
+#define BABELTRACE_TYPES_H
+
+/*
+ * Copyright (c) 2017 Philippe Proulx <pproulx@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+@defgroup ctypes Babeltrace C types
+@ingroup apiref
+@brief Babeltrace C types.
+
+@code
+#include <babeltrace/types.h>
+@endcode
+
+This header contains custom type definitions used across the library.
+
+@file
+@brief Babeltrace C types.
+@sa ctypes
+
+@addtogroup ctypes
+@{
+*/
+
+/// False boolean value for the #bt_bool type.
+#define BT_FALSE       0
+
+/// True boolean value for the #bt_bool type.
+#define BT_TRUE                1
+
+/**
+@brief Babeltrace's boolean type.
+
+Use only the #BT_FALSE and #BT_TRUE definitions for #bt_bool parameters.
+It is guaranteed that the library functions which return a #bt_bool
+value return either #BT_FALSE or #BT_TRUE.
+
+You can always test the truthness of a #bt_bool value directly, without
+comparing it to #BT_TRUE directly:
+
+@code
+bt_bool ret = bt_some_function(...);
+
+if (ret) {
+       // ret is true
+}
+@endcode
+*/
+typedef int bt_bool;
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* BABELTRACE_TYPES_H */
index b0544ec23937d46436eed21caeb86f972ab1754b..d4a2214b1f35ff355ceeebadefa0f33a381c3c23 100644 (file)
@@ -27,9 +27,9 @@
  */
 
 #include <stdint.h>
-#include <stdbool.h>
 #include <stddef.h>
 #include <babeltrace/ref.h>
+#include <babeltrace/types.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -235,7 +235,7 @@ enum bt_value_type {
        /// Null value object.
        BT_VALUE_TYPE_NULL =            0,
 
-       /// Boolean value object (holds \c true or \c false).
+       /// Boolean value object (holds #BT_TRUE or #BT_FALSE).
        BT_VALUE_TYPE_BOOL =            1,
 
        /// Integer value object (holds a signed 64-bit integer raw value).
@@ -292,7 +292,7 @@ An alternative to calling this function is to directly compare the value
 object pointer to the \ref bt_value_null variable.
 
 @param[in] object      Value object to check.
-@returns               \c true if \p object is the null value object.
+@returns               #BT_TRUE if \p object is the null value object.
 
 @prenotnull{object}
 @postrefcountsame{object}
@@ -300,7 +300,7 @@ object pointer to the \ref bt_value_null variable.
 @sa bt_value_get_type(): Returns the type of a given value object.
 */
 static inline
-bool bt_value_is_null(const struct bt_value *object)
+bt_bool bt_value_is_null(const struct bt_value *object)
 {
        return bt_value_get_type(object) == BT_VALUE_TYPE_NULL;
 }
@@ -310,7 +310,7 @@ bool bt_value_is_null(const struct bt_value *object)
        value object.
 
 @param[in] object      Value object to check.
-@returns               \c true if \p object is a boolean value object.
+@returns               #BT_TRUE if \p object is a boolean value object.
 
 @prenotnull{object}
 @postrefcountsame{object}
@@ -318,7 +318,7 @@ bool bt_value_is_null(const struct bt_value *object)
 @sa bt_value_get_type(): Returns the type of a given value object.
 */
 static inline
-bool bt_value_is_bool(const struct bt_value *object)
+bt_bool bt_value_is_bool(const struct bt_value *object)
 {
        return bt_value_get_type(object) == BT_VALUE_TYPE_BOOL;
 }
@@ -328,12 +328,12 @@ bool bt_value_is_bool(const struct bt_value *object)
        value object.
 
 @param[in] object      Value object to check.
-@returns               \c true if \p object is an integer value object.
+@returns               #BT_TRUE if \p object is an integer value object.
 
 @sa bt_value_get_type(): Returns the type of a given value object.
 */
 static inline
-bool bt_value_is_integer(const struct bt_value *object)
+bt_bool bt_value_is_integer(const struct bt_value *object)
 {
        return bt_value_get_type(object) == BT_VALUE_TYPE_INTEGER;
 }
@@ -343,7 +343,7 @@ bool bt_value_is_integer(const struct bt_value *object)
        point number value object.
 
 @param[in] object      Value object to check.
-@returns               \c true if \p object is a floating point
+@returns               #BT_TRUE if \p object is a floating point
                        number value object.
 
 @prenotnull{object}
@@ -352,7 +352,7 @@ bool bt_value_is_integer(const struct bt_value *object)
 @sa bt_value_get_type(): Returns the type of a given value object.
 */
 static inline
-bool bt_value_is_float(const struct bt_value *object)
+bt_bool bt_value_is_float(const struct bt_value *object)
 {
        return bt_value_get_type(object) == BT_VALUE_TYPE_FLOAT;
 }
@@ -362,7 +362,7 @@ bool bt_value_is_float(const struct bt_value *object)
        value object.
 
 @param[in] object      Value object to check.
-@returns               \c true if \p object is a string value object.
+@returns               #BT_TRUE if \p object is a string value object.
 
 @prenotnull{object}
 @postrefcountsame{object}
@@ -370,7 +370,7 @@ bool bt_value_is_float(const struct bt_value *object)
 @sa bt_value_get_type(): Returns the type of a given value object.
 */
 static inline
-bool bt_value_is_string(const struct bt_value *object)
+bt_bool bt_value_is_string(const struct bt_value *object)
 {
        return bt_value_get_type(object) == BT_VALUE_TYPE_STRING;
 }
@@ -380,7 +380,7 @@ bool bt_value_is_string(const struct bt_value *object)
        value object.
 
 @param[in] object      Value object to check.
-@returns               \c true if \p object is an array value object.
+@returns               #BT_TRUE if \p object is an array value object.
 
 @prenotnull{object}
 @postrefcountsame{object}
@@ -388,7 +388,7 @@ bool bt_value_is_string(const struct bt_value *object)
 @sa bt_value_get_type(): Returns the type of a given value object.
 */
 static inline
-bool bt_value_is_array(const struct bt_value *object)
+bt_bool bt_value_is_array(const struct bt_value *object)
 {
        return bt_value_get_type(object) == BT_VALUE_TYPE_ARRAY;
 }
@@ -398,7 +398,7 @@ bool bt_value_is_array(const struct bt_value *object)
        object.
 
 @param[in] object      Value object to check.
-@returns               \c true if \p object is a map value object.
+@returns               #BT_TRUE if \p object is a map value object.
 
 @prenotnull{object}
 @postrefcountsame{object}
@@ -406,7 +406,7 @@ bool bt_value_is_array(const struct bt_value *object)
 @sa bt_value_get_type(): Returns the type of a given value object.
 */
 static inline
-bool bt_value_is_map(const struct bt_value *object)
+bt_bool bt_value_is_map(const struct bt_value *object)
 {
        return bt_value_get_type(object) == BT_VALUE_TYPE_MAP;
 }
@@ -451,12 +451,12 @@ extern enum bt_value_status bt_value_freeze(struct bt_value *object);
 @brief Returns whether or not the value object \p object is frozen.
 
 @param[in] object      Value object to check.
-@returns               \c true if \p object is frozen.
+@returns               #BT_TRUE if \p object is frozen.
 
 @prenotnull{object}
 @postrefcountsame{object}
 */
-extern bool bt_value_is_frozen(const struct bt_value *object);
+extern bt_bool bt_value_is_frozen(const struct bt_value *object);
 
 /**
 @brief Creates a \em deep copy of the value object \p object.
@@ -477,19 +477,19 @@ extern struct bt_value *bt_value_copy(const struct bt_value *object);
 
 /**
 @brief Recursively compares the value objects \p object_a and
-       \p object_b and returns \c true if they have the same
+       \p object_b and returns #BT_TRUE if they have the same
        \em content (raw values).
 
 @param[in] object_a    Value object A to compare to \p object_b.
 @param[in] object_b    Value object B to compare to \p object_a.
-@returns               \c true if \p object_a and \p object_b have the
-                       same \em content, or \c false if they differ
+@returns               #BT_TRUE if \p object_a and \p object_b have the
+                       same \em content, or #BT_FALSE if they differ
                        or on error.
 
 @postrefcountsame{object_a}
 @postrefcountsame{object_b}
 */
-extern bool bt_value_compare(const struct bt_value *object_a,
+extern bt_bool bt_value_compare(const struct bt_value *object_a,
                const struct bt_value *object_b);
 
 /** @} */
@@ -502,7 +502,7 @@ extern bool bt_value_compare(const struct bt_value *object_a,
 /**
 @brief Creates a default boolean value object.
 
-The created boolean value object's initial raw value is \c false.
+The created boolean value object's initial raw value is #BT_FALSE.
 
 @returns       Created boolean value object on success, or \c NULL
                on error.
@@ -526,7 +526,7 @@ extern struct bt_value *bt_value_bool_create(void);
 
 @sa bt_value_bool_create(): Creates a default boolean value object.
 */
-extern struct bt_value *bt_value_bool_create_init(bool val);
+extern struct bt_value *bt_value_bool_create_init(bt_bool val);
 
 /**
 @brief Returns the boolean raw value of the boolean value object
@@ -545,7 +545,7 @@ extern struct bt_value *bt_value_bool_create_init(bool val);
 @sa bt_value_bool_set(): Sets the raw value of a boolean value object.
 */
 extern enum bt_value_status bt_value_bool_get(
-               const struct bt_value *bool_obj, bool *val);
+               const struct bt_value *bool_obj, bt_bool *val);
 
 /**
 @brief Sets the boolean raw value of the boolean value object
@@ -565,7 +565,7 @@ extern enum bt_value_status bt_value_bool_get(
        value object.
 */
 extern enum bt_value_status bt_value_bool_set(struct bt_value *bool_obj,
-               bool val);
+               bt_bool val);
 
 /** @} */
 
@@ -850,7 +850,7 @@ extern int64_t bt_value_array_size(const struct bt_value *array_obj);
        is empty.
 
 @param[in] array_obj   Array value object to check.
-@returns               \c true if \p array_obj is empty.
+@returns               #BT_TRUE if \p array_obj is empty.
 
 @prenotnull{array_obj}
 @pre \p array_obj is an array value object.
@@ -859,7 +859,7 @@ extern int64_t bt_value_array_size(const struct bt_value *array_obj);
 @sa bt_value_array_size(): Returns the size of a given array value
        object.
 */
-extern bool bt_value_array_is_empty(const struct bt_value *array_obj);
+extern bt_bool bt_value_array_is_empty(const struct bt_value *array_obj);
 
 /**
 @brief Returns the value object contained in the array value object
@@ -934,7 +934,7 @@ value object before appending it.
        array value object.
 */
 extern enum bt_value_status bt_value_array_append_bool(
-               struct bt_value *array_obj, bool val);
+               struct bt_value *array_obj, bt_bool val);
 
 /**
 @brief Appends the integer raw value \p val to the array value object
@@ -1117,7 +1117,7 @@ extern int64_t bt_value_map_size(const struct bt_value *map_obj);
 @brief Checks whether or not the map value object \p map_obj is empty.
 
 @param[in] map_obj     Map value object to check.
-@returns               \c true if \p map_obj is empty.
+@returns               #BT_TRUE if \p map_obj is empty.
 
 @prenotnull{map_obj}
 @pre \p map_obj is a map value object.
@@ -1125,7 +1125,7 @@ extern int64_t bt_value_map_size(const struct bt_value *map_obj);
 
 @sa bt_value_map_size(): Returns the size of a given map value object.
 */
-extern bool bt_value_map_is_empty(const struct bt_value *map_obj);
+extern bt_bool bt_value_map_is_empty(const struct bt_value *map_obj);
 
 /**
 @brief Returns the value object associated with the key \p key within
@@ -1152,20 +1152,20 @@ extern struct bt_value *bt_value_map_get(const struct bt_value *map_obj,
 \p object is a <em>weak reference</em>: you \em must pass it to bt_get()
 if you need to keep a reference after this function returns.
 
-This function \em must return \c true to continue the map value object
-traversal, or \c false to break it.
+This function \em must return #BT_TRUE to continue the map value object
+traversal, or #BT_FALSE to break it.
 
 @param[in] key         Key of map entry.
 @param[in] object      Value object of map entry (weak reference).
 @param[in] data                User data.
-@returns               \c true to continue the loop, or \c false to break it.
+@returns               #BT_TRUE to continue the loop, or #BT_FALSE to break it.
 
 @prenotnull{key}
 @prenotnull{object}
 @post The reference count of \p object is not lesser than what it is
        when the function is called.
 */
-typedef bool (* bt_value_map_foreach_cb)(const char *key,
+typedef bt_bool (* bt_value_map_foreach_cb)(const char *key,
        struct bt_value *object, void *data);
 
 /**
@@ -1179,8 +1179,8 @@ reference after the user function returns.
 The key passed to the user function is only valid in the scope of
 this user function call.
 
-The user function \em must return \c true to continue the traversal of
-\p map_obj, or \c false to break it.
+The user function \em must return #BT_TRUE to continue the traversal of
+\p map_obj, or #BT_FALSE to break it.
 
 @param[in] map_obj     Map value object on which to iterate.
 @param[in] cb          User function to call back.
@@ -1205,8 +1205,8 @@ extern enum bt_value_status bt_value_map_foreach(
 
 @param[in] map_obj     Map value object to check.
 @param[in] key         Key to check.
-@returns               \c true if \p map_obj has an entry mapped to the
-                       key \p key, or \c false if it does not or
+@returns               #BT_TRUE if \p map_obj has an entry mapped to the
+                       key \p key, or #BT_FALSE if it does not or
                        on error.
 
 @prenotnull{map_obj}
@@ -1214,7 +1214,7 @@ extern enum bt_value_status bt_value_map_foreach(
 @pre \p map_obj is a map value object.
 @postrefcountsame{map_obj}
 */
-extern bool bt_value_map_has_key(const struct bt_value *map_obj,
+extern bt_bool bt_value_map_has_key(const struct bt_value *map_obj,
                const char *key);
 
 /**
@@ -1287,7 +1287,7 @@ On success, \p key is copied.
        value object.
 */
 extern enum bt_value_status bt_value_map_insert_bool(
-               struct bt_value *map_obj, const char *key, bool val);
+               struct bt_value *map_obj, const char *key, bt_bool val);
 
 /**
 @brief Inserts the integer raw value \p val mapped to the key \p key
index 090fc3bc5039b5df52958a54363e8fed33d2a244..2b675eb299d4eb18a7efd5b6853ae70fe97aa43e 100644 (file)
  */
 
 #include <babeltrace/babeltrace.h>
+#include <babeltrace/types.h>
 #include <stdlib.h>
-#include <stdbool.h>
 
-bool babeltrace_verbose, babeltrace_debug;
+bt_bool babeltrace_verbose, babeltrace_debug;
 
 static
 void __attribute__((constructor)) init_babeltrace_lib(void)
 {
        if (getenv("BABELTRACE_VERBOSE"))
-               babeltrace_verbose = 1;
+               babeltrace_verbose = BT_TRUE;
        if (getenv("BABELTRACE_DEBUG"))
-               babeltrace_debug = 1;
+               babeltrace_debug = BT_TRUE;
 }
 
 int bt_version_get_major(void)
index eca2c2647a0a633b6c1bc6782b53e036c335b44c..0c27f1ad8493b2ecd1201da5b7497137e44754f3 100644 (file)
@@ -31,6 +31,7 @@
 #include <babeltrace/ref.h>
 #include <babeltrace/object-internal.h>
 #include <babeltrace/compiler-internal.h>
+#include <babeltrace/types.h>
 #include <inttypes.h>
 
 #define BT_LOG_TAG "CLOCK-CLASS"
@@ -40,7 +41,7 @@ static
 void bt_ctf_clock_class_destroy(struct bt_object *obj);
 
 BT_HIDDEN
-bool bt_ctf_clock_class_is_valid(struct bt_ctf_clock_class *clock_class)
+bt_bool bt_ctf_clock_class_is_valid(struct bt_ctf_clock_class *clock_class)
 {
        return clock_class && clock_class->name;
 }
index 8dc4619de4a338d924b486c3907d284bb9f7e4a5..49cca8c6ccc5a64a2b3dca8e257693a60164c2f2 100644 (file)
@@ -39,6 +39,7 @@
 #include <babeltrace/ctf-ir/attributes-internal.h>
 #include <babeltrace/compiler-internal.h>
 #include <babeltrace/endian-internal.h>
+#include <babeltrace/types.h>
 #include <inttypes.h>
 
 static
@@ -656,7 +657,7 @@ int bt_ctf_event_class_serialize(struct bt_ctf_event_class *event_class,
 
                default:
                        /* should never happen */
-                       assert(false);
+                       assert(BT_FALSE);
                        break;
                }
 
index 3ce3758b8b5030ac2e94b777ce4cec1badfbbf4a..6f46f2cb70ce45a7dea9d786c8752c71507f49a6 100644 (file)
@@ -356,7 +356,7 @@ gint compare_enumeration_mappings_unsigned(struct enumeration_mapping **a,
 }
 
 static
-void bt_ctf_field_type_init(struct bt_ctf_field_type *type, bool init_bo)
+void bt_ctf_field_type_init(struct bt_ctf_field_type *type, bt_bool init_bo)
 {
        assert(type && (type->id > BT_CTF_FIELD_TYPE_ID_UNKNOWN) &&
                (type->id < BT_CTF_NR_TYPE_IDS));
@@ -491,7 +491,7 @@ void set_enumeration_range_overlap(
                                                        <= mapping[1]->range_end._signed
                                                && mapping[0]->range_end._signed
                                                        >= mapping[1]->range_start._signed) {
-                                       enumeration_type->has_overlapping_ranges = true;
+                                       enumeration_type->has_overlapping_ranges = BT_TRUE;
                                        return;
                                }
                        } else {
@@ -499,7 +499,7 @@ void set_enumeration_range_overlap(
                                                        <= mapping[1]->range_end._unsigned
                                                && mapping[0]->range_end._unsigned
                                                        >= mapping[1]->range_start._unsigned) {
-                                       enumeration_type->has_overlapping_ranges = true;
+                                       enumeration_type->has_overlapping_ranges = BT_TRUE;
                                        return;
                                }
                        }
@@ -620,7 +620,7 @@ end:
 }
 
 static
-bool bt_ctf_field_type_enumeration_has_overlapping_ranges(
+bt_bool bt_ctf_field_type_enumeration_has_overlapping_ranges(
                struct bt_ctf_field_type_enumeration *enumeration_type)
 {
        if (!enumeration_type->parent.frozen) {
index 28a5e9375a883e5e40db47e4babd25c2e1c02bc1..5223d778ffbcda1101726d3a96ed8e1d7f36acde 100644 (file)
@@ -164,17 +164,17 @@ static
 void bt_ctf_field_sequence_freeze(struct bt_ctf_field *);
 
 static
-bool bt_ctf_field_generic_is_set(struct bt_ctf_field *);
+bt_bool bt_ctf_field_generic_is_set(struct bt_ctf_field *);
 static
-bool bt_ctf_field_structure_is_set(struct bt_ctf_field *);
+bt_bool bt_ctf_field_structure_is_set(struct bt_ctf_field *);
 static
-bool bt_ctf_field_variant_is_set(struct bt_ctf_field *);
+bt_bool bt_ctf_field_variant_is_set(struct bt_ctf_field *);
 static
-bool bt_ctf_field_enumeration_is_set(struct bt_ctf_field *);
+bt_bool bt_ctf_field_enumeration_is_set(struct bt_ctf_field *);
 static
-bool bt_ctf_field_array_is_set(struct bt_ctf_field *);
+bt_bool bt_ctf_field_array_is_set(struct bt_ctf_field *);
 static
-bool bt_ctf_field_sequence_is_set(struct bt_ctf_field *);
+bt_bool bt_ctf_field_sequence_is_set(struct bt_ctf_field *);
 
 static
 int increase_packet_size(struct bt_ctf_stream_pos *pos);
@@ -270,7 +270,7 @@ void (* const field_freeze_funcs[])(struct bt_ctf_field *) = {
 };
 
 static
-bool (* const field_is_set_funcs[])(struct bt_ctf_field *) = {
+bt_bool (* const field_is_set_funcs[])(struct bt_ctf_field *) = {
        [BT_CTF_FIELD_TYPE_ID_INTEGER] = bt_ctf_field_generic_is_set,
        [BT_CTF_FIELD_TYPE_ID_ENUM] = bt_ctf_field_enumeration_is_set,
        [BT_CTF_FIELD_TYPE_ID_FLOAT] = bt_ctf_field_generic_is_set,
@@ -1269,9 +1269,9 @@ end:
 
 
 BT_HIDDEN
-bool bt_ctf_field_is_set(struct bt_ctf_field *field)
+bt_bool bt_ctf_field_is_set(struct bt_ctf_field *field)
 {
-       bool is_set = false;
+       bt_bool is_set = BT_FALSE;
        enum bt_ctf_field_type_id type_id;
 
        if (!field) {
@@ -2423,15 +2423,15 @@ end:
 }
 
 static
-bool bt_ctf_field_generic_is_set(struct bt_ctf_field *field)
+bt_bool bt_ctf_field_generic_is_set(struct bt_ctf_field *field)
 {
        return field && field->payload_set;
 }
 
 static
-bool bt_ctf_field_enumeration_is_set(struct bt_ctf_field *field)
+bt_bool bt_ctf_field_enumeration_is_set(struct bt_ctf_field *field)
 {
-       bool is_set = false;
+       bt_bool is_set = BT_FALSE;
        struct bt_ctf_field_enumeration *enumeration;
 
        if (!field) {
@@ -2450,9 +2450,9 @@ end:
 }
 
 static
-bool bt_ctf_field_structure_is_set(struct bt_ctf_field *field)
+bt_bool bt_ctf_field_structure_is_set(struct bt_ctf_field *field)
 {
-       bool is_set = false;
+       bt_bool is_set = BT_FALSE;
        size_t i;
        struct bt_ctf_field_structure *structure;
 
@@ -2472,9 +2472,9 @@ end:
 }
 
 static
-bool bt_ctf_field_variant_is_set(struct bt_ctf_field *field)
+bt_bool bt_ctf_field_variant_is_set(struct bt_ctf_field *field)
 {
-       bool is_set = false;
+       bt_bool is_set = BT_FALSE;
        struct bt_ctf_field_variant *variant;
 
        if (!field) {
@@ -2488,10 +2488,10 @@ end:
 }
 
 static
-bool bt_ctf_field_array_is_set(struct bt_ctf_field *field)
+bt_bool bt_ctf_field_array_is_set(struct bt_ctf_field *field)
 {
        size_t i;
-       bool is_set = false;
+       bt_bool is_set = BT_FALSE;
        struct bt_ctf_field_array *array;
 
        if (!field) {
@@ -2510,10 +2510,10 @@ end:
 }
 
 static
-bool bt_ctf_field_sequence_is_set(struct bt_ctf_field *field)
+bt_bool bt_ctf_field_sequence_is_set(struct bt_ctf_field *field)
 {
        size_t i;
-       bool is_set = false;
+       bt_bool is_set = BT_FALSE;
        struct bt_ctf_field_sequence *sequence;
 
        if (!field) {
index f72652ef0c59e486f722f86afb65d1c24e6bb357..2ab457ab8f3dfdba226a7f98f786f67554349fc0 100644 (file)
@@ -38,6 +38,7 @@
 #include <babeltrace/ref.h>
 #include <babeltrace/babeltrace-internal.h>
 #include <babeltrace/values.h>
+#include <babeltrace/types.h>
 #include <limits.h>
 #include <glib.h>
 
@@ -170,7 +171,7 @@ end:
  * Checks whether or not `stack` is empty.
  */
 static
-bool type_stack_empty(type_stack *stack)
+bt_bool type_stack_empty(type_stack *stack)
 {
        return stack->len == 0;
 }
@@ -384,7 +385,7 @@ int ptokens_to_field_path(GList *ptokens, struct bt_ctf_field_path *field_path,
 {
        int ret = 0;
        GList *cur_ptoken = ptokens;
-       bool first_level_done = false;
+       bt_bool first_level_done = BT_FALSE;
 
        /* Get our own reference */
        bt_get(type);
@@ -422,7 +423,7 @@ int ptokens_to_field_path(GList *ptokens, struct bt_ctf_field_path *field_path,
 
                        /* Next path token */
                        cur_ptoken = g_list_next(cur_ptoken);
-                       first_level_done = true;
+                       first_level_done = BT_TRUE;
                }
 
                /* Create new field path entry */
@@ -527,7 +528,7 @@ int relative_ptokens_to_field_path(GList *ptokens,
                        int tail_field_path_len =
                                tail_field_path->indexes->len;
 
-                       while (true) {
+                       while (BT_TRUE) {
                                struct bt_ctf_field_type *cur_type =
                                        type_stack_at(ctx->type_stack, i)->type;
                                int index = type_stack_at(
@@ -764,7 +765,7 @@ int get_field_paths_lca_index(struct bt_ctf_field_path *field_path1,
        field_path1_len = field_path1->indexes->len;
        field_path2_len = field_path2->indexes->len;
 
-       while (true) {
+       while (BT_TRUE) {
                int target_index, ctx_index;
 
                if (lca_index == field_path2_len ||
@@ -893,7 +894,7 @@ int validate_target_field_path(struct bt_ctf_field_path *target_field_path,
                        goto end;
                }
        } else {
-               assert(false);
+               assert(BT_FALSE);
        }
 
 end:
@@ -927,7 +928,7 @@ int resolve_sequence_or_variant_type(struct bt_ctf_field_type *type,
                        bt_ctf_field_type_variant_get_tag_name(type);
                break;
        default:
-               assert(false);
+               assert(BT_FALSE);
                ret = -1;
                goto end;
        }
@@ -980,7 +981,7 @@ int resolve_sequence_or_variant_type(struct bt_ctf_field_type *type,
                        goto end;
                }
        } else {
-               assert(false);
+               assert(BT_FALSE);
        }
 
 end:
index 84d7c6840ba1b6ba48694a59f5910b9b79ffdd99..67b6ea3b92a1841f9a0e5f65a1a3e8bba72c28b0 100644 (file)
@@ -919,13 +919,13 @@ int bt_ctf_stream_flush(struct bt_ctf_stream *stream)
        struct bt_ctf_stream_pos packet_context_pos;
        struct bt_ctf_trace *trace;
        enum bt_ctf_byte_order native_byte_order;
-       bool empty_packet;
+       bt_bool empty_packet;
        uint64_t packet_size_bits;
        struct {
-               bool timestamp_begin;
-               bool timestamp_end;
-               bool content_size;
-               bool packet_size;
+               bt_bool timestamp_begin;
+               bt_bool timestamp_end;
+               bt_bool content_size;
+               bt_bool packet_size;
        } auto_set_fields = { 0 };
 
        if (!stream || stream->pos.fd < 0) {
@@ -1201,7 +1201,7 @@ void bt_ctf_stream_destroy(struct bt_object *obj)
 
 static
 int _set_structure_field_integer(struct bt_ctf_field *structure, char *name,
-               uint64_t value, bool force)
+               uint64_t value, bt_bool force)
 {
        int ret = 0;
        struct bt_ctf_field_type *field_type = NULL;
@@ -1253,7 +1253,7 @@ static
 int set_structure_field_integer(struct bt_ctf_field *structure, char *name,
                uint64_t value)
 {
-       return _set_structure_field_integer(structure, name, value, true);
+       return _set_structure_field_integer(structure, name, value, BT_TRUE);
 }
 
 /*
@@ -1266,7 +1266,7 @@ static
 int try_set_structure_field_integer(struct bt_ctf_field *structure, char *name,
                uint64_t value)
 {
-       return _set_structure_field_integer(structure, name, value, false);
+       return _set_structure_field_integer(structure, name, value, BT_FALSE);
 }
 
 const char *bt_ctf_stream_get_name(struct bt_ctf_stream *stream)
index ba18eab8de35525873fcafe061438570e2718c43..d36d49816e147e11733093f00b50280f66a76fa7 100644 (file)
@@ -43,6 +43,7 @@
 #include <babeltrace/compiler-internal.h>
 #include <babeltrace/values.h>
 #include <babeltrace/ref.h>
+#include <babeltrace/types.h>
 #include <babeltrace/endian-internal.h>
 #include <inttypes.h>
 #include <stdint.h>
@@ -175,7 +176,7 @@ int bt_ctf_trace_set_uuid(struct bt_ctf_trace *trace, const unsigned char *uuid)
        }
 
        memcpy(trace->uuid, uuid, sizeof(uuid_t));
-       trace->uuid_set = true;
+       trace->uuid_set = BT_TRUE;
 
 end:
        return ret;
@@ -867,7 +868,7 @@ end:
 }
 
 BT_HIDDEN
-bool bt_ctf_trace_has_clock_class(struct bt_ctf_trace *trace,
+bt_bool bt_ctf_trace_has_clock_class(struct bt_ctf_trace *trace,
                struct bt_ctf_clock_class *clock_class)
 {
        struct search_query query = { .value = clock_class, .found = 0 };
@@ -895,7 +896,7 @@ const char *get_byte_order_string(enum bt_ctf_byte_order byte_order)
                string = "native";
                break;
        default:
-               assert(false);
+               assert(BT_FALSE);
        }
 
        return string;
@@ -1292,9 +1293,9 @@ void bt_ctf_trace_freeze(struct bt_ctf_trace *trace)
        trace->frozen = 1;
 }
 
-bool bt_ctf_trace_is_static(struct bt_ctf_trace *trace)
+bt_bool bt_ctf_trace_is_static(struct bt_ctf_trace *trace)
 {
-       bool is_static = false;
+       bt_bool is_static = BT_FALSE;
 
        if (!trace) {
                goto end;
@@ -1315,7 +1316,7 @@ int bt_ctf_trace_set_is_static(struct bt_ctf_trace *trace)
                goto end;
        }
 
-       trace->is_static = true;
+       trace->is_static = BT_TRUE;
        bt_ctf_trace_freeze(trace);
 
 end:
index e0239f65e844c77bbe0406566f1fdc1ee81dc837..e2fa56d79bb85fb33376656b27bb0794b4881d35 100644 (file)
@@ -30,7 +30,6 @@
 
 #include <stdio.h>
 #include <stdint.h>
-#include <stdbool.h>
 #include <babeltrace/ctf-ir/field-types.h>
 #include <babeltrace/ctf-ir/field-types-internal.h>
 #include <babeltrace/ctf-ir/fields.h>
@@ -41,6 +40,7 @@
 #include <babeltrace/endian-internal.h>
 #include <babeltrace/bitfield-internal.h>
 #include <babeltrace/compat/fcntl-internal.h>
+#include <babeltrace/types.h>
 #include <glib.h>
 
 #if (FLT_RADIX != 2)
@@ -60,9 +60,9 @@ union intval {
 static
 int aligned_integer_write(struct bt_ctf_stream_pos *pos,
                union intval value, unsigned int alignment, unsigned int size,
-               bool is_signed, enum bt_ctf_byte_order byte_order)
+               bt_bool is_signed, enum bt_ctf_byte_order byte_order)
 {
-       bool rbo = (byte_order != BT_CTF_MY_BYTE_ORDER); /* reverse byte order */
+       bt_bool rbo = (byte_order != BT_CTF_MY_BYTE_ORDER); /* reverse byte order */
 
        if (!bt_ctf_stream_pos_align(pos, alignment))
                return -EFAULT;
@@ -108,7 +108,7 @@ int aligned_integer_write(struct bt_ctf_stream_pos *pos,
                        break;
                }
                default:
-                       assert(false);
+                       assert(BT_FALSE);
                }
        } else {
                switch (size) {
@@ -147,7 +147,7 @@ int aligned_integer_write(struct bt_ctf_stream_pos *pos,
                        break;
                }
                default:
-                       assert(false);
+                       assert(BT_FALSE);
                }
        }
 
@@ -158,7 +158,7 @@ int aligned_integer_write(struct bt_ctf_stream_pos *pos,
 
 static
 int integer_write(struct bt_ctf_stream_pos *pos, union intval value,
-       unsigned int alignment, unsigned int size, bool is_signed,
+       unsigned int alignment, unsigned int size, bt_bool is_signed,
        enum bt_ctf_byte_order byte_order)
 {
        if (!(alignment % CHAR_BIT)
@@ -259,7 +259,7 @@ int bt_ctf_field_floating_point_write(
                return -EINVAL;
        }
 
-       return integer_write(pos, value, type->alignment, size, false,
+       return integer_write(pos, value, type->alignment, size, BT_FALSE,
                byte_order);
 }
 
@@ -275,7 +275,7 @@ void bt_ctf_stream_pos_packet_seek(struct bt_ctf_stream_pos *pos, size_t index,
                /* unmap old base */
                ret = munmap_align(pos->base_mma);
                if (ret) {
-                       assert(false);
+                       assert(BT_FALSE);
                }
                pos->base_mma = NULL;
        }
@@ -295,6 +295,6 @@ void bt_ctf_stream_pos_packet_seek(struct bt_ctf_stream_pos *pos, size_t index,
        pos->base_mma = mmap_align(pos->packet_size / CHAR_BIT, pos->prot,
                pos->flags, pos->fd, pos->mmap_offset);
        if (pos->base_mma == MAP_FAILED) {
-               assert(false);
+               assert(BT_FALSE);
        }
 }
index 6c4bbded741cd8487a7d4aa8ea2a280d935c7596..c005993be3ffea9937f05f32d3880ea1fe6fc111 100644 (file)
@@ -217,7 +217,7 @@ struct bt_ctf_stream *bt_ctf_writer_create_stream(struct bt_ctf_writer *writer,
 {
        struct bt_ctf_stream *stream = NULL;
        int stream_class_count;
-       bool stream_class_found = false;
+       bt_bool stream_class_found = BT_FALSE;
        int i;
 
        if (!writer || !stream_class) {
@@ -236,7 +236,7 @@ struct bt_ctf_stream *bt_ctf_writer_create_stream(struct bt_ctf_writer *writer,
                                writer->trace, i);
 
                if (existing_stream_class == stream_class) {
-                       stream_class_found = true;
+                       stream_class_found = BT_TRUE;
                }
 
                BT_PUT(existing_stream_class);
index b438f10430b4366141ddaa12c26c3fa74ec96303..b4613a23c52a47e250f68bcb25ed448fa813edef 100644 (file)
@@ -29,7 +29,7 @@
 #include <babeltrace/compiler-internal.h>
 #include <babeltrace/graph/component-class-internal.h>
 #include <babeltrace/ref.h>
-#include <stdbool.h>
+#include <babeltrace/types.h>
 #include <glib.h>
 
 static
@@ -529,7 +529,7 @@ int bt_component_class_freeze(
                goto end;
        }
 
-       component_class->frozen = true;
+       component_class->frozen = BT_TRUE;
 
 end:
        return ret;
index c4f26a8989c6d78e0914ecc016eda6f746c2c811..c541985b3326b52f374829f877ba162f3aa835db 100644 (file)
@@ -41,6 +41,7 @@
 #include <babeltrace/babeltrace-internal.h>
 #include <babeltrace/compiler-internal.h>
 #include <babeltrace/ref.h>
+#include <babeltrace/types.h>
 #include <stdint.h>
 
 static
@@ -272,20 +273,20 @@ struct bt_component *bt_component_create_with_init_method_data(
                goto end;
        }
 
-       component->initializing = true;
+       component->initializing = BT_TRUE;
 
        if (component_class->methods.init) {
                ret = component_class->methods.init(
                        bt_private_component_from_component(component), params,
                        init_method_data);
-               component->initializing = false;
+               component->initializing = BT_FALSE;
                if (ret != BT_COMPONENT_STATUS_OK) {
                        BT_PUT(component);
                        goto end;
                }
        }
 
-       component->initializing = false;
+       component->initializing = BT_FALSE;
        ret = component_validation_funcs[type](component);
        if (ret != BT_COMPONENT_STATUS_OK) {
                BT_PUT(component);
index 35ccde70b75b259be63842247c4912db4d00e6cc..8e4dbf68740455950360cd8a590258b71e9fdc93 100644 (file)
@@ -34,6 +34,7 @@
 #include <babeltrace/graph/component-filter.h>
 #include <babeltrace/graph/port.h>
 #include <babeltrace/compiler-internal.h>
+#include <babeltrace/types.h>
 #include <unistd.h>
 #include <glib.h>
 
@@ -155,8 +156,8 @@ struct bt_connection *bt_graph_connect_ports(struct bt_graph *graph,
        struct bt_component *upstream_component = NULL;
        struct bt_component *downstream_component = NULL;
        enum bt_component_status component_status;
-       bool upstream_was_already_in_graph;
-       bool downstream_was_already_in_graph;
+       bt_bool upstream_was_already_in_graph;
+       bt_bool downstream_was_already_in_graph;
 
        if (!graph || !upstream_port || !downstream_port) {
                goto end;
@@ -324,7 +325,7 @@ enum bt_component_status get_component_port_counts(
                }
                break;
        default:
-               assert(false);
+               assert(BT_FALSE);
                break;
        }
        ret = BT_COMPONENT_STATUS_OK;
index c76293a972baac05b618233390dba0d8c0c3a7ef..36098200d2213527075857f902ad9295d919d772 100644 (file)
 #include <babeltrace/graph/notification-stream.h>
 #include <babeltrace/graph/notification-stream-internal.h>
 #include <babeltrace/graph/port.h>
+#include <babeltrace/types.h>
 #include <stdint.h>
 
 struct stream_state {
        struct bt_ctf_stream *stream; /* owned by this */
        struct bt_ctf_packet *cur_packet; /* owned by this */
-       bool is_ended;
+       bt_bool is_ended;
 };
 
 enum action_type {
@@ -141,7 +142,7 @@ void destroy_action(struct action *action)
        case ACTION_TYPE_SET_STREAM_STATE_IS_ENDED:
                break;
        default:
-               assert(false);
+               assert(BT_FALSE);
        }
 }
 
@@ -219,7 +220,7 @@ void apply_actions(struct bt_notification_iterator *iterator)
                        bt_ctf_stream_add_destroy_listener(
                                action->payload.set_stream_state_is_ended.stream_state->stream,
                                stream_destroy_listener, iterator);
-                       action->payload.set_stream_state_is_ended.stream_state->is_ended = true;
+                       action->payload.set_stream_state_is_ended.stream_state->is_ended = BT_TRUE;
                        BT_PUT(action->payload.set_stream_state_is_ended.stream_state->stream);
                        break;
                case ACTION_TYPE_SET_STREAM_STATE_CUR_PACKET:
@@ -228,7 +229,7 @@ void apply_actions(struct bt_notification_iterator *iterator)
                                action->payload.set_stream_state_cur_packet.packet);
                        break;
                default:
-                       assert(false);
+                       assert(BT_FALSE);
                }
        }
 
@@ -543,19 +544,19 @@ bt_notification_iterator_notif_type_from_notif_type(
                iter_notif_type = BT_NOTIFICATION_ITERATOR_NOTIF_TYPE_PACKET_END;
                break;
        default:
-               assert(false);
+               assert(BT_FALSE);
        }
 
        return iter_notif_type;
 }
 
 static
-bool validate_notification(struct bt_notification_iterator *iterator,
+bt_bool validate_notification(struct bt_notification_iterator *iterator,
                struct bt_notification *notif,
                struct bt_ctf_stream *notif_stream,
                struct bt_ctf_packet *notif_packet)
 {
-       bool is_valid = true;
+       bt_bool is_valid = BT_TRUE;
        struct stream_state *stream_state;
        struct bt_port *stream_comp_cur_port;
 
@@ -589,7 +590,7 @@ bool validate_notification(struct bt_notification_iterator *iterator,
                         * bad: the API guarantees that it can never
                         * happen.
                         */
-                       is_valid = false;
+                       is_valid = BT_FALSE;
                        goto end;
                }
 
@@ -607,7 +608,7 @@ bool validate_notification(struct bt_notification_iterator *iterator,
                         * bad: the API guarantees that it can never
                         * happen.
                         */
-                       is_valid = false;
+                       is_valid = BT_FALSE;
                        goto end;
                }
 
@@ -618,12 +619,12 @@ bool validate_notification(struct bt_notification_iterator *iterator,
                         * we already returned a "stream begin"
                         * notification: this is an invalid duplicate.
                         */
-                       is_valid = false;
+                       is_valid = BT_FALSE;
                        goto end;
                case BT_NOTIFICATION_TYPE_PACKET_BEGIN:
                        if (notif_packet == stream_state->cur_packet) {
                                /* Duplicate "packet begin" notification */
-                               is_valid = false;
+                               is_valid = BT_FALSE;
                                goto end;
                        }
                        break;
@@ -637,14 +638,14 @@ end:
 }
 
 static
-bool is_subscribed_to_notification_type(struct bt_notification_iterator *iterator,
+bt_bool is_subscribed_to_notification_type(struct bt_notification_iterator *iterator,
                enum bt_notification_type notif_type)
 {
        uint32_t iter_notif_type =
                (uint32_t) bt_notification_iterator_notif_type_from_notif_type(
                        notif_type);
 
-       return (iter_notif_type & iterator->subscription_mask) ? true : false;
+       return (iter_notif_type & iterator->subscription_mask) ? BT_TRUE : BT_FALSE;
 }
 
 static
@@ -1290,7 +1291,7 @@ enum bt_notification_iterator_status ensure_queue_has_notifications(
                break;
        }
        default:
-               assert(false);
+               assert(BT_FALSE);
                break;
        }
 
@@ -1319,7 +1320,7 @@ enum bt_notification_iterator_status ensure_queue_has_notifications(
                                status = BT_NOTIFICATION_ITERATOR_STATUS_END;
                        }
 
-                       iterator->is_ended = true;
+                       iterator->is_ended = BT_TRUE;
                        goto end;
                case BT_NOTIFICATION_ITERATOR_STATUS_AGAIN:
                        status = BT_NOTIFICATION_ITERATOR_STATUS_AGAIN;
@@ -1345,7 +1346,7 @@ enum bt_notification_iterator_status ensure_queue_has_notifications(
                        break;
                default:
                        /* Unknown non-error status */
-                       assert(false);
+                       assert(BT_FALSE);
                }
        }
 
index 8d9d6f3da9a26c4bba7205ab2de330c1e2a6740f..8e5d672493d8482f41a34d6ba96d90483d7a2e8e 100644 (file)
@@ -33,6 +33,7 @@
 #include <babeltrace/graph/clock-class-priority-map.h>
 #include <babeltrace/graph/clock-class-priority-map-internal.h>
 #include <babeltrace/graph/notification-event-internal.h>
+#include <babeltrace/types.h>
 
 static
 void bt_notification_event_destroy(struct bt_object *obj)
@@ -46,7 +47,7 @@ void bt_notification_event_destroy(struct bt_object *obj)
 }
 
 static
-bool validate_clock_classes(struct bt_notification_event *notif)
+bt_bool validate_clock_classes(struct bt_notification_event *notif)
 {
        /*
         * For each clock class found in the notification's clock class
@@ -54,7 +55,7 @@ bool validate_clock_classes(struct bt_notification_event *notif)
         * this clock class. Also make sure that those clock classes
         * are part of the trace to which the event belongs.
         */
-       bool is_valid = true;
+       bt_bool is_valid = BT_TRUE;
        int trace_cc_count;
        int cc_prio_map_cc_count;
        size_t cc_prio_map_cc_i, trace_cc_i;
@@ -81,13 +82,13 @@ bool validate_clock_classes(struct bt_notification_event *notif)
                        bt_clock_class_priority_map_get_clock_class_by_index(
                                notif->cc_prio_map, cc_prio_map_cc_i);
                struct bt_ctf_clock_value *clock_value;
-               bool found_in_trace = false;
+               bt_bool found_in_trace = BT_FALSE;
 
                assert(clock_class);
                clock_value = bt_ctf_event_get_clock_value(notif->event,
                        clock_class);
                if (!clock_value) {
-                       is_valid = false;
+                       is_valid = BT_FALSE;
                        goto end;
                }
 
@@ -102,7 +103,7 @@ bool validate_clock_classes(struct bt_notification_event *notif)
                        assert(trace_clock_class);
 
                        if (trace_clock_class == clock_class) {
-                               found_in_trace = true;
+                               found_in_trace = BT_TRUE;
                                break;
                        }
                }
@@ -110,7 +111,7 @@ bool validate_clock_classes(struct bt_notification_event *notif)
                bt_put(clock_class);
 
                if (!found_in_trace) {
-                       is_valid = false;
+                       is_valid = BT_FALSE;
                        goto end;
                }
        }
index 7b152e2ce606568bcd4fa08eb82956b2d40a7c90..ab2f486078e9930b18416df0150e55270c313adf 100644 (file)
@@ -34,8 +34,8 @@
 #include <babeltrace/plugin/plugin-dev.h>
 #include <babeltrace/plugin/plugin-internal.h>
 #include <babeltrace/graph/component-class-internal.h>
+#include <babeltrace/types.h>
 #include <string.h>
-#include <stdbool.h>
 #include <glib.h>
 #include <gmodule.h>
 
@@ -431,7 +431,7 @@ enum bt_plugin_status bt_plugin_so_init(
                }
        }
 
-       spec->shared_lib_handle->init_called = true;
+       spec->shared_lib_handle->init_called = BT_TRUE;
 
        /* Add described component classes to plugin */
        for (i = 0; i < comp_class_full_descriptors->len; i++) {
@@ -621,7 +621,7 @@ enum bt_plugin_status bt_plugin_so_init(
                case BT_COMPONENT_CLASS_TYPE_SINK:
                        break;
                default:
-                       assert(false);
+                       assert(BT_FALSE);
                        break;
                }
 
@@ -813,7 +813,7 @@ struct bt_plugin_set *bt_plugin_so_create_all_from_file(const char *path)
        struct __bt_plugin_component_class_descriptor const * const *cc_descriptors_end = NULL;
        struct __bt_plugin_component_class_descriptor_attribute const * const *cc_descr_attrs_begin = NULL;
        struct __bt_plugin_component_class_descriptor_attribute const * const *cc_descr_attrs_end = NULL;
-       bool is_libtool_wrapper = false, is_shared_object = false;
+       bt_bool is_libtool_wrapper = BT_FALSE, is_shared_object = BT_FALSE;
        struct bt_plugin_so_shared_lib_handle *shared_lib_handle = NULL;
 
        if (!path) {
index 4a36fd697c1ef30bf2d8d866cfa4e3bcc9972793..d219fe893bfe5762afa2823a3aafa6b8395fb69e 100644 (file)
@@ -33,6 +33,7 @@
 #include <babeltrace/common-internal.h>
 #include <babeltrace/plugin/plugin-internal.h>
 #include <babeltrace/plugin/plugin-so-internal.h>
+#include <babeltrace/types.h>
 #include <glib.h>
 #include <unistd.h>
 #include <stdlib.h>
@@ -222,7 +223,7 @@ struct bt_plugin *bt_plugin_find(const char *plugin_name)
                printf_verbose("Trying to load plugins from directory `%s`\n",
                        dir->str);
                BT_PUT(plugin_set);
-               plugin_set = bt_plugin_create_all_from_dir(dir->str, false);
+               plugin_set = bt_plugin_create_all_from_dir(dir->str, BT_FALSE);
                if (!plugin_set) {
                        continue;
                }
@@ -308,7 +309,7 @@ struct dirent *alloc_dirent(const char *path)
 static
 enum bt_plugin_status bt_plugin_create_append_all_from_dir(
                struct bt_plugin_set *plugin_set, const char *path,
-               bool recurse)
+               bt_bool recurse)
 {
        DIR *directory = NULL;
        struct dirent *entry = NULL, *result = NULL;
@@ -382,7 +383,7 @@ enum bt_plugin_status bt_plugin_create_append_all_from_dir(
 
                if (S_ISDIR(st.st_mode) && recurse) {
                        ret = bt_plugin_create_append_all_from_dir(plugin_set,
-                               file_path, true);
+                               file_path, BT_TRUE);
                        if (ret < 0) {
                                goto end;
                        }
@@ -421,7 +422,7 @@ end:
 }
 
 struct bt_plugin_set *bt_plugin_create_all_from_dir(const char *path,
-               bool recurse)
+               bt_bool recurse)
 {
        struct bt_plugin_set *plugin_set;
        enum bt_plugin_status status;
index 8c9429636eed8ae710cfd0cec582983f69f0199d..abe36fd23ba477476ea36969ba86d2efc828dfa6 100644 (file)
@@ -35,6 +35,7 @@
 #include <babeltrace/ref.h>
 #include <babeltrace/values.h>
 #include <babeltrace/compat/glib-internal.h>
+#include <babeltrace/types.h>
 
 #define BT_LOG_TAG "VALUES"
 #include <babeltrace/lib-logging-internal.h>
@@ -50,7 +51,7 @@
 struct bt_value {
        struct bt_object base;
        enum bt_value_type type;
-       bool is_frozen;
+       bt_bool is_frozen;
 };
 
 static
@@ -64,14 +65,14 @@ struct bt_value bt_value_null_instance = {
                .parent = NULL,
        },
        .type = BT_VALUE_TYPE_NULL,
-       .is_frozen = true,
+       .is_frozen = BT_TRUE,
 };
 
 struct bt_value *bt_value_null = &bt_value_null_instance;
 
 struct bt_value_bool {
        struct bt_value base;
-       bool value;
+       bt_bool value;
 };
 
 struct bt_value_integer {
@@ -292,19 +293,19 @@ struct bt_value *(* const copy_funcs[])(const struct bt_value *) = {
 };
 
 static
-bool bt_value_null_compare(const struct bt_value *object_a,
+bt_bool bt_value_null_compare(const struct bt_value *object_a,
                const struct bt_value *object_b)
 {
        /*
-        * Always true since bt_value_compare() already checks if both
+        * Always BT_TRUE since bt_value_compare() already checks if both
         * object_a and object_b have the same type, and in the case of
         * null value objects, they're always the same if it is so.
         */
-       return true;
+       return BT_TRUE;
 }
 
 static
-bool bt_value_bool_compare(const struct bt_value *object_a,
+bt_bool bt_value_bool_compare(const struct bt_value *object_a,
                const struct bt_value *object_b)
 {
        return BT_VALUE_TO_BOOL(object_a)->value ==
@@ -312,7 +313,7 @@ bool bt_value_bool_compare(const struct bt_value *object_a,
 }
 
 static
-bool bt_value_integer_compare(const struct bt_value *object_a,
+bt_bool bt_value_integer_compare(const struct bt_value *object_a,
                const struct bt_value *object_b)
 {
        return BT_VALUE_TO_INTEGER(object_a)->value ==
@@ -320,7 +321,7 @@ bool bt_value_integer_compare(const struct bt_value *object_a,
 }
 
 static
-bool bt_value_float_compare(const struct bt_value *object_a,
+bt_bool bt_value_float_compare(const struct bt_value *object_a,
                const struct bt_value *object_b)
 {
        return BT_VALUE_TO_FLOAT(object_a)->value ==
@@ -328,7 +329,7 @@ bool bt_value_float_compare(const struct bt_value *object_a,
 }
 
 static
-bool bt_value_string_compare(const struct bt_value *object_a,
+bt_bool bt_value_string_compare(const struct bt_value *object_a,
                const struct bt_value *object_b)
 {
        return !strcmp(BT_VALUE_TO_STRING(object_a)->gstr->str,
@@ -336,11 +337,11 @@ bool bt_value_string_compare(const struct bt_value *object_a,
 }
 
 static
-bool bt_value_array_compare(const struct bt_value *object_a,
+bt_bool bt_value_array_compare(const struct bt_value *object_a,
                const struct bt_value *object_b)
 {
        int i;
-       bool ret = true;
+       bt_bool ret = BT_TRUE;
        const struct bt_value_array *array_obj_a =
                BT_VALUE_TO_ARRAY(object_a);
 
@@ -351,7 +352,7 @@ bool bt_value_array_compare(const struct bt_value *object_a,
                        object_a, object_b,
                        bt_value_array_size(object_a),
                        bt_value_array_size(object_b));
-               ret = false;
+               ret = BT_FALSE;
                goto end;
        }
 
@@ -368,7 +369,7 @@ bool bt_value_array_compare(const struct bt_value *object_a,
                                element_obj_a, element_obj_b, index);
                        BT_PUT(element_obj_a);
                        BT_PUT(element_obj_b);
-                       ret = false;
+                       ret = BT_FALSE;
                        goto end;
                }
 
@@ -381,10 +382,10 @@ end:
 }
 
 static
-bool bt_value_map_compare(const struct bt_value *object_a,
+bt_bool bt_value_map_compare(const struct bt_value *object_a,
                const struct bt_value *object_b)
 {
-       bool ret = true;
+       bt_bool ret = BT_TRUE;
        GHashTableIter iter;
        gpointer key, element_obj_a;
        const struct bt_value_map *map_obj_a = BT_VALUE_TO_MAP(object_a);
@@ -396,7 +397,7 @@ bool bt_value_map_compare(const struct bt_value *object_a,
                        object_a, object_b,
                        bt_value_map_size(object_a),
                        bt_value_map_size(object_b));
-               ret = false;
+               ret = BT_FALSE;
                goto end;
        }
 
@@ -413,7 +414,7 @@ bool bt_value_map_compare(const struct bt_value *object_a,
                                "value-a-addr=%p, value-b-addr=%p, key=\"%s\"",
                                element_obj_a, element_obj_b, key_str);
                        BT_PUT(element_obj_b);
-                       ret = false;
+                       ret = BT_FALSE;
                        goto end;
                }
 
@@ -425,7 +426,7 @@ end:
 }
 
 static
-bool (* const compare_funcs[])(const struct bt_value *,
+bt_bool (* const compare_funcs[])(const struct bt_value *,
                const struct bt_value *) = {
        [BT_VALUE_TYPE_NULL] =          bt_value_null_compare,
        [BT_VALUE_TYPE_BOOL] =          bt_value_bool_compare,
@@ -442,7 +443,7 @@ void bt_value_null_freeze(struct bt_value *object)
 
 void bt_value_generic_freeze(struct bt_value *object)
 {
-       object->is_frozen = true;
+       object->is_frozen = BT_TRUE;
 }
 
 void bt_value_array_freeze(struct bt_value *object)
@@ -530,7 +531,7 @@ end:
        return ret;
 }
 
-bool bt_value_is_frozen(const struct bt_value *object)
+bt_bool bt_value_is_frozen(const struct bt_value *object)
 {
        return object && object->is_frozen;
 }
@@ -551,12 +552,12 @@ struct bt_value bt_value_create_base(enum bt_value_type type)
        struct bt_value base;
 
        base.type = type;
-       base.is_frozen = false;
+       base.is_frozen = BT_FALSE;
        bt_object_init(&base, bt_value_destroy);
        return base;
 }
 
-struct bt_value *bt_value_bool_create_init(bool val)
+struct bt_value *bt_value_bool_create_init(bt_bool val)
 {
        struct bt_value_bool *bool_obj;
 
@@ -578,7 +579,7 @@ end:
 
 struct bt_value *bt_value_bool_create(void)
 {
-       return bt_value_bool_create_init(false);
+       return bt_value_bool_create_init(BT_FALSE);
 }
 
 struct bt_value *bt_value_integer_create_init(int64_t val)
@@ -733,7 +734,7 @@ end:
 }
 
 enum bt_value_status bt_value_bool_get(const struct bt_value *bool_obj,
-               bool *val)
+               bt_bool *val)
 {
        enum bt_value_status ret = BT_VALUE_STATUS_OK;
        struct bt_value_bool *typed_bool_obj = BT_VALUE_TO_BOOL(bool_obj);
@@ -759,7 +760,7 @@ end:
        return ret;
 }
 
-enum bt_value_status bt_value_bool_set(struct bt_value *bool_obj, bool val)
+enum bt_value_status bt_value_bool_set(struct bt_value *bool_obj, bt_bool val)
 {
        enum bt_value_status ret = BT_VALUE_STATUS_OK;
        struct bt_value_bool *typed_bool_obj = BT_VALUE_TO_BOOL(bool_obj);
@@ -1008,7 +1009,7 @@ end:
        return ret;
 }
 
-bool bt_value_array_is_empty(const struct bt_value *array_obj)
+bt_bool bt_value_array_is_empty(const struct bt_value *array_obj)
 {
        return bt_value_array_size(array_obj) == 0;
 }
@@ -1089,7 +1090,7 @@ end:
 }
 
 enum bt_value_status bt_value_array_append_bool(struct bt_value *array_obj,
-               bool val)
+               bt_bool val)
 {
        enum bt_value_status ret;
        struct bt_value *bool_obj = NULL;
@@ -1231,7 +1232,7 @@ end:
        return ret;
 }
 
-bool bt_value_map_is_empty(const struct bt_value *map_obj)
+bt_bool bt_value_map_is_empty(const struct bt_value *map_obj)
 {
        return bt_value_map_size(map_obj) == 0;
 }
@@ -1268,23 +1269,23 @@ end:
        return ret;
 }
 
-bool bt_value_map_has_key(const struct bt_value *map_obj, const char *key)
+bt_bool bt_value_map_has_key(const struct bt_value *map_obj, const char *key)
 {
-       bool ret;
+       bt_bool ret;
        GQuark quark;
        struct bt_value_map *typed_map_obj = BT_VALUE_TO_MAP(map_obj);
 
        if (!map_obj || !key) {
                BT_LOGW("Invalid parameter: value object or key is NULL: "
                        "value-addr=%p, key-addr=%p", map_obj, key);
-               ret = false;
+               ret = BT_FALSE;
                goto end;
        }
 
        if (!bt_value_is_map(map_obj)) {
                BT_LOGW("Invalid parameter: value is not a map value: addr=%p, "
                        "type=%d", map_obj, map_obj->type);
-               ret = false;
+               ret = BT_FALSE;
                goto end;
        }
 
@@ -1338,7 +1339,7 @@ end:
 }
 
 enum bt_value_status bt_value_map_insert_bool(struct bt_value *map_obj,
-               const char *key, bool val)
+               const char *key, bt_bool val)
 {
        enum bt_value_status ret;
        struct bt_value *bool_obj = NULL;
@@ -1451,14 +1452,14 @@ end:
 
 struct extend_map_element_data {
        struct bt_value *extended_obj;
-       bool got_error;
+       bt_bool got_error;
 };
 
 static
-bool extend_map_element(const char *key,
+bt_bool extend_map_element(const char *key,
                struct bt_value *extension_obj_elem, void *data)
 {
-       bool ret = true;
+       bt_bool ret = BT_TRUE;
 
        struct extend_map_element_data *extend_data = data;
 
@@ -1479,8 +1480,8 @@ bool extend_map_element(const char *key,
        goto end;
 
 error:
-       ret = false;
-       extend_data->got_error = true;
+       ret = BT_FALSE;
+       extend_data->got_error = BT_TRUE;
 
 end:
        BT_PUT(extension_obj_elem_copy);
@@ -1575,10 +1576,10 @@ end:
        return copy_obj;
 }
 
-bool bt_value_compare(const struct bt_value *object_a,
+bt_bool bt_value_compare(const struct bt_value *object_a,
        const struct bt_value *object_b)
 {
-       bool ret = false;
+       bt_bool ret = BT_FALSE;
 
        if (!object_a || !object_b) {
                BT_LOGW("Invalid parameter: value A or value B is NULL: "
index b6d9fc26f058cce7d3cf0ed85e5149ae25488f84..01177f795bc865df1ecf198b0e3681fbac5c7b88 100644 (file)
@@ -30,6 +30,7 @@
 #include <stdio.h>
 #include <unistd.h>
 #include <string.h>
+#include <stdbool.h>
 #include <stdlib.h>
 #include <ctype.h>
 #include <assert.h>
index 2abd9b57cc02aa77e17a3653a9afeab08ed02dcb..a20e7d6c1b21a84e111a86070fb5e8c9586460d5 100644 (file)
@@ -38,6 +38,7 @@
 #include <plugins-common.h>
 #include <glib.h>
 #include <assert.h>
+#include <stdbool.h>
 #include <unistd.h>
 #include "fs.h"
 #include "metadata.h"
index 4619e79b6ff129280fc3e163d6cc113e347727ac..acc14a1a674bb60c0c32cf4ee798097f6df4533a 100644 (file)
@@ -28,6 +28,7 @@
  * SOFTWARE.
  */
 
+#include <stdbool.h>
 #include <babeltrace/babeltrace-internal.h>
 #include <babeltrace/graph/component.h>
 #include <babeltrace/graph/clock-class-priority-map.h>
index e7cffbd1c57ff0e019a976fef99ee4ef7f4c7fa9..2578dd967aea0a3264a21682b9b6240b283c8962 100644 (file)
@@ -419,14 +419,17 @@ enum bt_component_status init_from_params(
         value = bt_value_map_get(params, "full-path");
        if (value) {
                enum bt_value_status value_ret;
+               bt_bool bool_val;
 
                value_ret = bt_value_bool_get(value,
-                               &debug_info_component->arg_full_path);
+                               &bool_val);
                if (value_ret) {
                        ret = BT_COMPONENT_STATUS_INVALID;
                        printf_error("Failed to retrieve full-path value. "
                                        "Expecting a boolean");
                }
+
+               debug_info_component->arg_full_path = bool_val;
        }
        bt_put(value);
        if (ret != BT_COMPONENT_STATUS_OK) {
index 043ba4fc5d265a5123a269fdedc6a81b0fc4a9cb..ece1f1e6e46db945709a8ce14651c01e1f2ed8d6 100644 (file)
@@ -235,7 +235,7 @@ end:
 }
 
 static
-bool check_param_exists(const char *key, struct bt_value *object, void *data)
+bt_bool check_param_exists(const char *key, struct bt_value *object, void *data)
 {
        struct pretty_component *pretty = data;
        struct bt_value *plugin_opt_map = pretty->plugin_opt_map;
@@ -244,7 +244,7 @@ bool check_param_exists(const char *key, struct bt_value *object, void *data)
                fprintf(pretty->err,
                        "[warning] Parameter \"%s\" unknown to \"text.pretty\" sink component\n", key);
        }
-       return true;
+       return BT_TRUE;
 }
 
 static
@@ -287,12 +287,13 @@ enum bt_component_status apply_one_bool(const char *key,
        enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
        struct bt_value *value = NULL;
        enum bt_value_status status;
+       bt_bool bool_val;
 
        value = bt_value_map_get(params, key);
        if (!value) {
                goto end;
        }
-       status = bt_value_bool_get(value, option);
+       status = bt_value_bool_get(value, &bool_val);
        switch (status) {
        case BT_VALUE_STATUS_OK:
                break;
@@ -300,6 +301,7 @@ enum bt_component_status apply_one_bool(const char *key,
                ret = BT_COMPONENT_STATUS_ERROR;
                goto end;
        }
+       *option = (bool) bool_val;
        if (found) {
                *found = true;
        }
index b98a74e02bbe47716bc888d4f0c539b3dfb43d01..67ba0a99421b805e61ff149c90115df30c60b50d 100644 (file)
@@ -39,6 +39,7 @@
 #include <babeltrace/graph/private-port.h>
 #include <plugins-common.h>
 #include <glib.h>
+#include <stdbool.h>
 #include <assert.h>
 
 #define IGNORE_ABSOLUTE_PARAM_NAME     "ignore-absolute"
@@ -246,6 +247,7 @@ int configure_muxer_comp(struct muxer_comp *muxer_comp, struct bt_value *params)
        struct bt_value *real_params = NULL;
        struct bt_value *ignore_absolute = NULL;
        int ret = 0;
+       bt_bool bool_val;
 
        default_params = get_default_params();
        if (!default_params) {
@@ -263,10 +265,12 @@ int configure_muxer_comp(struct muxer_comp *muxer_comp, struct bt_value *params)
                goto error;
        }
 
-       if (bt_value_bool_get(ignore_absolute, &muxer_comp->ignore_absolute)) {
+       if (bt_value_bool_get(ignore_absolute, &bool_val)) {
                goto error;
        }
 
+       muxer_comp->ignore_absolute = (bool) bool_val;
+
        goto end;
 
 error:
index 8ec1332fb0b09f2e9935df6c421d0d13448ff314..b938bd51f5932d9582092921a9818a78b6db7c84 100644 (file)
@@ -84,7 +84,7 @@ void finalize_trimmer(struct bt_private_component *component)
  */
 static
 int timestamp_from_arg(const char *arg, struct trimmer *trimmer,
-               struct trimmer_bound *result_bound, bool gmt)
+               struct trimmer_bound *result_bound, bt_bool gmt)
 {
        int ret;
        int64_t value;
@@ -292,7 +292,7 @@ enum bt_component_status init_from_params(struct trimmer *trimmer,
                struct bt_value *params)
 {
        struct bt_value *value = NULL;
-       bool gmt = false;
+       bt_bool gmt = BT_FALSE;
        enum bt_component_status ret = BT_COMPONENT_STATUS_OK;
 
        assert(params);
index 1448566cab5acad5841d43266b70734032a3088a..dd1ed7b6cd58ecc1e4defe8a248b89d49f75841d 100644 (file)
@@ -26,6 +26,7 @@
 #include <babeltrace/ctf-ir/stream-class.h>
 #include <babeltrace/ctf-ir/trace.h>
 #include <assert.h>
+#include <stdbool.h>
 #include <string.h>
 #include <stdarg.h>
 #include <glib.h>
index 3bffb71127f47be29c8d12030b4f714de7095bec..d4767b1b93f5e7b0401777079756373480e615c0 100644 (file)
@@ -20,7 +20,6 @@
  */
 
 #include "tap/tap.h"
-#include <stdbool.h>
 #include <stdlib.h>
 #include <babeltrace/compiler-internal.h>
 #include <babeltrace/ref.h>
@@ -71,7 +70,7 @@ error:
 }
 
 static
-bool compare_notifications(struct bt_notification *a, struct bt_notification *b,
+bt_bool compare_notifications(struct bt_notification *a, struct bt_notification *b,
                void *unused)
 {
        uint64_t val_a = ((struct dummy_notification *) a)->value;
index 99664498b3df718a607c7ff3feb779042ba027d0..656d84ac7d965ef234f9974354b9a4f44b3e5ca0 100644 (file)
@@ -18,6 +18,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdint.h>
+#include <stdbool.h>
 #include <inttypes.h>
 #include <string.h>
 #include <assert.h>
index 5f93a6797e4e370f79ec3e1cf5c834ca22ea715b..e56af8024fb9d970d3b37c745b09d9cb460c5a19 100644 (file)
@@ -51,18 +51,18 @@ static
 void test_bool(void)
 {
        int ret;
-       bool value;
+       bt_bool value;
        struct bt_value *obj;
 
        obj = bt_value_bool_create();
        ok(obj && bt_value_is_bool(obj),
                "bt_value_bool_create() returns a boolean value object");
 
-       value = true;
+       value = BT_TRUE;
        ret = bt_value_bool_get(obj, &value);
-       ok(!ret && !value, "default boolean value object value is false");
+       ok(!ret && !value, "default boolean value object value is BT_FALSE");
 
-       ret = bt_value_bool_set(NULL, true);
+       ret = bt_value_bool_set(NULL, BT_TRUE);
        ok(ret == BT_VALUE_STATUS_INVAL,
                "bt_value_bool_set() fails with an value object set to NULL");
        ret = bt_value_bool_get(NULL, &value);
@@ -72,8 +72,8 @@ void test_bool(void)
        ok(ret == BT_VALUE_STATUS_INVAL,
                "bt_value_bool_get() fails with a return value set to NULL");
 
-       assert(!bt_value_bool_set(obj, false));
-       ret = bt_value_bool_set(obj, true);
+       assert(!bt_value_bool_set(obj, BT_FALSE));
+       ret = bt_value_bool_set(obj, BT_TRUE);
        ok(!ret, "bt_value_bool_set() succeeds");
        ret = bt_value_bool_get(obj, &value);
        ok(!ret && value, "bt_value_bool_set() works");
@@ -81,8 +81,8 @@ void test_bool(void)
        BT_PUT(obj);
        pass("putting an existing boolean value object does not cause a crash")
 
-       value = false;
-       obj = bt_value_bool_create_init(true);
+       value = BT_FALSE;
+       obj = bt_value_bool_create_init(BT_TRUE);
        ok(obj && bt_value_is_bool(obj),
                "bt_value_bool_create_init() returns a boolean value object");
        ret = bt_value_bool_get(obj, &value);
@@ -90,9 +90,9 @@ void test_bool(void)
                "bt_value_bool_create_init() sets the appropriate initial value");
 
        assert(!bt_value_freeze(obj));
-       ok(bt_value_bool_set(obj, false) == BT_VALUE_STATUS_FROZEN,
+       ok(bt_value_bool_set(obj, BT_FALSE) == BT_VALUE_STATUS_FROZEN,
                "bt_value_bool_set() cannot be called on a frozen boolean value object");
-       value = false;
+       value = BT_FALSE;
        ret = bt_value_bool_get(obj, &value);
        ok(!ret && value,
                "bt_value_bool_set() does not alter a frozen floating point number value object");
@@ -264,7 +264,7 @@ static
 void test_array(void)
 {
        int ret;
-       bool bool_value;
+       bt_bool bool_value;
        int64_t int_value;
        double float_value;
        struct bt_value *obj;
@@ -274,8 +274,8 @@ void test_array(void)
        array_obj = bt_value_array_create();
        ok(array_obj && bt_value_is_array(array_obj),
                "bt_value_array_create() returns an array value object");
-       ok(bt_value_array_is_empty(NULL) == false,
-               "bt_value_array_is_empty() returns false with an value object set to NULL");
+       ok(bt_value_array_is_empty(NULL) == BT_FALSE,
+               "bt_value_array_is_empty() returns BT_FALSE with an value object set to NULL");
        ok(bt_value_array_is_empty(array_obj),
                "initial array value object size is 0");
        ok(bt_value_array_size(NULL) == BT_VALUE_STATUS_INVAL,
@@ -293,7 +293,7 @@ void test_array(void)
        obj = bt_value_float_create_init(-17.45);
        ret |= bt_value_array_append(array_obj, obj);
        BT_PUT(obj);
-       obj = bt_value_bool_create_init(true);
+       obj = bt_value_bool_create_init(BT_TRUE);
        ret |= bt_value_array_append(array_obj, obj);
        BT_PUT(obj);
        ret |= bt_value_array_append(array_obj, bt_value_null);
@@ -356,9 +356,9 @@ void test_array(void)
                "bt_value_array_set() inserts an value object with the appropriate value");
        BT_PUT(obj);
 
-       ret = bt_value_array_append_bool(array_obj, false);
+       ret = bt_value_array_append_bool(array_obj, BT_FALSE);
        ok(!ret, "bt_value_array_append_bool() succeeds");
-       ok(bt_value_array_append_bool(NULL, true) == BT_VALUE_STATUS_INVAL,
+       ok(bt_value_array_append_bool(NULL, BT_TRUE) == BT_VALUE_STATUS_INVAL,
                "bt_value_array_append_bool() fails with an array value object set to NULL");
        ret = bt_value_array_append_integer(array_obj, 98765);
        ok(!ret, "bt_value_array_append_integer() succeeds");
@@ -434,7 +434,7 @@ void test_array(void)
        ok(bt_value_array_append(array_obj, bt_value_null) ==
                BT_VALUE_STATUS_FROZEN,
                "bt_value_array_append() fails with a frozen array value object");
-       ok(bt_value_array_append_bool(array_obj, false) ==
+       ok(bt_value_array_append_bool(array_obj, BT_FALSE) ==
                BT_VALUE_STATUS_FROZEN,
                "bt_value_array_append_bool() fails with a frozen array value object");
        ok(bt_value_array_append_integer(array_obj, 23) ==
@@ -469,54 +469,54 @@ void test_array(void)
 }
 
 static
-bool test_map_foreach_cb_count(const char *key, struct bt_value *object,
+bt_bool test_map_foreach_cb_count(const char *key, struct bt_value *object,
        void *data)
 {
        int *count = data;
 
        if (*count == 3) {
-               return false;
+               return BT_FALSE;
        }
 
        (*count)++;
 
-       return true;
+       return BT_TRUE;
 }
 
 struct map_foreach_checklist {
-       bool bool1;
-       bool int1;
-       bool float1;
-       bool null1;
-       bool bool2;
-       bool int2;
-       bool float2;
-       bool string2;
-       bool array2;
-       bool map2;
+       bt_bool bool1;
+       bt_bool int1;
+       bt_bool float1;
+       bt_bool null1;
+       bt_bool bool2;
+       bt_bool int2;
+       bt_bool float2;
+       bt_bool string2;
+       bt_bool array2;
+       bt_bool map2;
 };
 
 static
-bool test_map_foreach_cb_check(const char *key, struct bt_value *object,
+bt_bool test_map_foreach_cb_check(const char *key, struct bt_value *object,
        void *data)
 {
        int ret;
        struct map_foreach_checklist *checklist = data;
 
-       if (!strcmp(key, "bool")) {
+       if (!strcmp(key, "bt_bool")) {
                if (checklist->bool1) {
-                       fail("test_map_foreach_cb_check(): duplicate key \"bool\"");
+                       fail("test_map_foreach_cb_check(): duplicate key \"bt_bool\"");
                } else {
-                       bool val = false;
+                       bt_bool val = BT_FALSE;
 
                        ret = bt_value_bool_get(object, &val);
-                       ok(!ret, "test_map_foreach_cb_check(): success getting \"bool\" value");
+                       ok(!ret, "test_map_foreach_cb_check(): success getting \"bt_bool\" value");
 
                        if (val) {
-                               pass("test_map_foreach_cb_check(): \"bool\" value object has the right value");
-                               checklist->bool1 = true;
+                               pass("test_map_foreach_cb_check(): \"bt_bool\" value object has the right value");
+                               checklist->bool1 = BT_TRUE;
                        } else {
-                               fail("test_map_foreach_cb_check(): \"bool\" value object has the wrong value");
+                               fail("test_map_foreach_cb_check(): \"bt_bool\" value object has the wrong value");
                        }
                }
        } else if (!strcmp(key, "int")) {
@@ -530,7 +530,7 @@ bool test_map_foreach_cb_check(const char *key, struct bt_value *object,
 
                        if (val == 19457) {
                                pass("test_map_foreach_cb_check(): \"int\" value object has the right value");
-                               checklist->int1 = true;
+                               checklist->int1 = BT_TRUE;
                        } else {
                                fail("test_map_foreach_cb_check(): \"int\" value object has the wrong value");
                        }
@@ -546,30 +546,30 @@ bool test_map_foreach_cb_check(const char *key, struct bt_value *object,
 
                        if (val == 5.444) {
                                pass("test_map_foreach_cb_check(): \"float\" value object has the right value");
-                               checklist->float1 = true;
+                               checklist->float1 = BT_TRUE;
                        } else {
                                fail("test_map_foreach_cb_check(): \"float\" value object has the wrong value");
                        }
                }
        } else if (!strcmp(key, "null")) {
                if (checklist->null1) {
-                       fail("test_map_foreach_cb_check(): duplicate key \"bool\"");
+                       fail("test_map_foreach_cb_check(): duplicate key \"bt_bool\"");
                } else {
                        ok(bt_value_is_null(object), "test_map_foreach_cb_check(): success getting \"null\" value object");
-                       checklist->null1 = true;
+                       checklist->null1 = BT_TRUE;
                }
        } else if (!strcmp(key, "bool2")) {
                if (checklist->bool2) {
                        fail("test_map_foreach_cb_check(): duplicate key \"bool2\"");
                } else {
-                       bool val = false;
+                       bt_bool val = BT_FALSE;
 
                        ret = bt_value_bool_get(object, &val);
                        ok(!ret, "test_map_foreach_cb_check(): success getting \"bool2\" value");
 
                        if (val) {
                                pass("test_map_foreach_cb_check(): \"bool2\" value object has the right value");
-                               checklist->bool2 = true;
+                               checklist->bool2 = BT_TRUE;
                        } else {
                                fail("test_map_foreach_cb_check(): \"bool2\" value object has the wrong value");
                        }
@@ -585,7 +585,7 @@ bool test_map_foreach_cb_check(const char *key, struct bt_value *object,
 
                        if (val == 98765) {
                                pass("test_map_foreach_cb_check(): \"int2\" value object has the right value");
-                               checklist->int2 = true;
+                               checklist->int2 = BT_TRUE;
                        } else {
                                fail("test_map_foreach_cb_check(): \"int2\" value object has the wrong value");
                        }
@@ -601,7 +601,7 @@ bool test_map_foreach_cb_check(const char *key, struct bt_value *object,
 
                        if (val == -49.0001) {
                                pass("test_map_foreach_cb_check(): \"float2\" value object has the right value");
-                               checklist->float2 = true;
+                               checklist->float2 = BT_TRUE;
                        } else {
                                fail("test_map_foreach_cb_check(): \"float2\" value object has the wrong value");
                        }
@@ -617,7 +617,7 @@ bool test_map_foreach_cb_check(const char *key, struct bt_value *object,
 
                        if (val && !strcmp(val, "bt_value")) {
                                pass("test_map_foreach_cb_check(): \"string2\" value object has the right value");
-                               checklist->string2 = true;
+                               checklist->string2 = BT_TRUE;
                        } else {
                                fail("test_map_foreach_cb_check(): \"string2\" value object has the wrong value");
                        }
@@ -629,7 +629,7 @@ bool test_map_foreach_cb_check(const char *key, struct bt_value *object,
                        ok(bt_value_is_array(object), "test_map_foreach_cb_check(): success getting \"array2\" value object");
                        ok(bt_value_array_is_empty(object),
                                "test_map_foreach_cb_check(): \"array2\" value object is empty");
-                       checklist->array2 = true;
+                       checklist->array2 = BT_TRUE;
                }
        } else if (!strcmp(key, "map2")) {
                if (checklist->map2) {
@@ -638,13 +638,13 @@ bool test_map_foreach_cb_check(const char *key, struct bt_value *object,
                        ok(bt_value_is_map(object), "test_map_foreach_cb_check(): success getting \"map2\" value object");
                        ok(bt_value_map_is_empty(object),
                                "test_map_foreach_cb_check(): \"map2\" value object is empty");
-                       checklist->map2 = true;
+                       checklist->map2 = BT_TRUE;
                }
        } else {
                fail("test_map_foreach_cb_check(): unknown map key \"%s\"", key);
        }
 
-       return true;
+       return BT_TRUE;
 }
 
 static
@@ -652,7 +652,7 @@ void test_map(void)
 {
        int ret;
        int count = 0;
-       bool bool_value;
+       bt_bool bool_value;
        int64_t int_value;
        double float_value;
        struct bt_value *obj;
@@ -684,21 +684,21 @@ void test_map(void)
        ret |= bt_value_map_insert(map_obj, "float", obj);
        BT_PUT(obj);
        obj = bt_value_bool_create();
-       ret |= bt_value_map_insert(map_obj, "bool", obj);
+       ret |= bt_value_map_insert(map_obj, "bt_bool", obj);
        BT_PUT(obj);
        ret |= bt_value_map_insert(map_obj, "null", bt_value_null);
        ok(!ret, "bt_value_map_insert() succeeds");
        ok(bt_value_map_size(map_obj) == 4,
                "inserting an element into a map value object increment its size");
 
-       obj = bt_value_bool_create_init(true);
-       ret = bt_value_map_insert(map_obj, "bool", obj);
+       obj = bt_value_bool_create_init(BT_TRUE);
+       ret = bt_value_map_insert(map_obj, "bt_bool", obj);
        BT_PUT(obj);
        ok(!ret, "bt_value_map_insert() accepts an existing key");
 
        obj = bt_value_map_get(map_obj, NULL);
        ok(!obj, "bt_value_map_get() fails with a key set to NULL");
-       obj = bt_value_map_get(NULL, "bool");
+       obj = bt_value_map_get(NULL, "bt_bool");
        ok(!obj, "bt_value_map_get() fails with a map value object set to NULL");
 
        obj = bt_value_map_get(map_obj, "life");
@@ -720,7 +720,7 @@ void test_map(void)
        obj = bt_value_map_get(map_obj, "null");
        ok(obj && bt_value_is_null(obj),
                "bt_value_map_get() returns an value object with the appropriate type (null)");
-       obj = bt_value_map_get(map_obj, "bool");
+       obj = bt_value_map_get(map_obj, "bt_bool");
        ok(obj && bt_value_is_bool(obj),
                "bt_value_map_get() returns an value object with the appropriate type (boolean)");
        ret = bt_value_bool_get(obj, &bool_value);
@@ -728,9 +728,9 @@ void test_map(void)
                "bt_value_map_get() returns an value object with the appropriate value (boolean)");
        BT_PUT(obj);
 
-       ret = bt_value_map_insert_bool(map_obj, "bool2", true);
+       ret = bt_value_map_insert_bool(map_obj, "bool2", BT_TRUE);
        ok(!ret, "bt_value_map_insert_bool() succeeds");
-       ok(bt_value_map_insert_bool(NULL, "bool2", false) ==
+       ok(bt_value_map_insert_bool(NULL, "bool2", BT_FALSE) ==
                BT_VALUE_STATUS_INVAL,
                "bt_value_map_insert_bool() fails with a map value object set to NULL");
        ret = bt_value_map_insert_integer(map_obj, "int2", 98765);
@@ -762,8 +762,8 @@ void test_map(void)
 
        ok(!bt_value_map_has_key(map_obj, "hello"),
                "map value object does not have key \"hello\"");
-       ok(bt_value_map_has_key(map_obj, "bool"),
-               "map value object has key \"bool\"");
+       ok(bt_value_map_has_key(map_obj, "bt_bool"),
+               "map value object has key \"bt_bool\"");
        ok(bt_value_map_has_key(map_obj, "int"),
                "map value object has key \"int\"");
        ok(bt_value_map_has_key(map_obj, "float"),
@@ -791,7 +791,7 @@ void test_map(void)
                "bt_value_map_foreach() fails with a user function set to NULL");
        ret = bt_value_map_foreach(map_obj, test_map_foreach_cb_count, &count);
        ok(ret == BT_VALUE_STATUS_CANCELLED && count == 3,
-               "bt_value_map_foreach() breaks the loop when the user function returns false");
+               "bt_value_map_foreach() breaks the loop when the user function returns BT_FALSE");
 
        memset(&checklist, 0, sizeof(checklist));
        ret = bt_value_map_foreach(map_obj, test_map_foreach_cb_check,
@@ -808,7 +808,7 @@ void test_map(void)
        ok(bt_value_map_insert(map_obj, "allo", bt_value_null) ==
                BT_VALUE_STATUS_FROZEN,
                "bt_value_map_insert() fails with a frozen map value object");
-       ok(bt_value_map_insert_bool(map_obj, "duh", false) ==
+       ok(bt_value_map_insert_bool(map_obj, "duh", BT_FALSE) ==
                BT_VALUE_STATUS_FROZEN,
                "bt_value_map_insert_bool() fails with a frozen array value object");
        ok(bt_value_map_insert_integer(map_obj, "duh", 23) ==
@@ -859,17 +859,17 @@ void test_compare_null(void)
 static
 void test_compare_bool(void)
 {
-       struct bt_value *bool1 = bt_value_bool_create_init(false);
-       struct bt_value *bool2 = bt_value_bool_create_init(true);
-       struct bt_value *bool3 = bt_value_bool_create_init(false);
+       struct bt_value *bool1 = bt_value_bool_create_init(BT_FALSE);
+       struct bt_value *bool2 = bt_value_bool_create_init(BT_TRUE);
+       struct bt_value *bool3 = bt_value_bool_create_init(BT_FALSE);
 
        assert(bool1 && bool2 && bool3);
        ok(!bt_value_compare(bt_value_null, bool1),
-               "cannot compare null value object and bool value object");
+               "cannot compare null value object and bt_bool value object");
        ok(!bt_value_compare(bool1, bool2),
-               "integer value objects are not equivalent (false and true)");
+               "boolean value objects are not equivalent (BT_FALSE and BT_TRUE)");
        ok(bt_value_compare(bool1, bool3),
-               "integer value objects are equivalent (false and false)");
+               "boolean value objects are equivalent (BT_FALSE and BT_FALSE)");
 
        BT_PUT(bool1);
        BT_PUT(bool2);
@@ -952,13 +952,13 @@ void test_compare_array(void)
 
        assert(!bt_value_array_append_integer(array1, 23));
        assert(!bt_value_array_append_float(array1, 14.2));
-       assert(!bt_value_array_append_bool(array1, false));
+       assert(!bt_value_array_append_bool(array1, BT_FALSE));
        assert(!bt_value_array_append_float(array2, 14.2));
        assert(!bt_value_array_append_integer(array2, 23));
-       assert(!bt_value_array_append_bool(array2, false));
+       assert(!bt_value_array_append_bool(array2, BT_FALSE));
        assert(!bt_value_array_append_integer(array3, 23));
        assert(!bt_value_array_append_float(array3, 14.2));
-       assert(!bt_value_array_append_bool(array3, false));
+       assert(!bt_value_array_append_bool(array3, BT_FALSE));
        assert(bt_value_array_size(array1) == 3);
        assert(bt_value_array_size(array2) == 3);
        assert(bt_value_array_size(array3) == 3);
@@ -966,9 +966,9 @@ void test_compare_array(void)
        ok(!bt_value_compare(bt_value_null, array1),
                "cannot compare null value object and array value object");
        ok(!bt_value_compare(array1, array2),
-               "array value objects are not equivalent ([23, 14.2, false] and [14.2, 23, false])");
+               "array value objects are not equivalent ([23, 14.2, BT_FALSE] and [14.2, 23, BT_FALSE])");
        ok(bt_value_compare(array1, array3),
-               "array value objects are equivalent ([23, 14.2, false] and [23, 14.2, false])");
+               "array value objects are equivalent ([23, 14.2, BT_FALSE] and [23, 14.2, BT_FALSE])");
 
        BT_PUT(array1);
        BT_PUT(array2);
@@ -989,11 +989,11 @@ void test_compare_map(void)
 
        assert(!bt_value_map_insert_integer(map1, "one", 23));
        assert(!bt_value_map_insert_float(map1, "two", 14.2));
-       assert(!bt_value_map_insert_bool(map1, "three", false));
+       assert(!bt_value_map_insert_bool(map1, "three", BT_FALSE));
        assert(!bt_value_map_insert_float(map2, "one", 14.2));
        assert(!bt_value_map_insert_integer(map2, "two", 23));
-       assert(!bt_value_map_insert_bool(map2, "three", false));
-       assert(!bt_value_map_insert_bool(map3, "three", false));
+       assert(!bt_value_map_insert_bool(map2, "three", BT_FALSE));
+       assert(!bt_value_map_insert_bool(map3, "three", BT_FALSE));
        assert(!bt_value_map_insert_integer(map3, "one", 23));
        assert(!bt_value_map_insert_float(map3, "two", 14.2));
        assert(bt_value_map_size(map1) == 3);
@@ -1031,7 +1031,7 @@ void test_copy(void)
        /*
         * Here's the deal here. If we make sure that each value object
         * of our deep copy has a different address than its source,
-        * and that bt_value_compare() returns true for the top-level
+        * and that bt_value_compare() returns BT_TRUE for the top-level
         * value object, taking into account that we test the correctness of
         * bt_value_compare() elsewhere, then the deep copy is a
         * success.
@@ -1044,7 +1044,7 @@ void test_copy(void)
        struct bt_value *array_obj, *array_copy_obj;
        struct bt_value *map_obj, *map_copy_obj;
 
-       bool_obj = bt_value_bool_create_init(true);
+       bool_obj = bt_value_bool_create_init(BT_TRUE);
        integer_obj = bt_value_integer_create_init(23);
        float_obj = bt_value_float_create_init(-3.1416);
        string_obj = bt_value_string_create_init("test");
@@ -1079,7 +1079,7 @@ void test_copy(void)
                "bt_value_copy() returns a different pointer (array)");
        bool_copy_obj = bt_value_array_get(array_copy_obj, 0);
        ok(bool_copy_obj != bool_obj,
-               "bt_value_copy() returns a different pointer (bool)");
+               "bt_value_copy() returns a different pointer (bt_bool)");
        integer_copy_obj = bt_value_array_get(array_copy_obj, 1);
        ok(integer_copy_obj != integer_obj,
                "bt_value_copy() returns a different pointer (integer)");
@@ -1108,12 +1108,12 @@ void test_copy(void)
 }
 
 static
-bool compare_map_elements(struct bt_value *map_a, struct bt_value *map_b,
+bt_bool compare_map_elements(struct bt_value *map_a, struct bt_value *map_b,
                const char *key)
 {
        struct bt_value *elem_a = NULL;
        struct bt_value *elem_b = NULL;
-       bool equal;
+       bt_bool equal;
 
        elem_a = bt_value_map_get(map_a, key);
        elem_b = bt_value_map_get(map_b, key);
@@ -1136,15 +1136,15 @@ void test_extend(void)
        assert(base_map);
        assert(extension_map);
        assert(array);
-       status = bt_value_map_insert_bool(base_map, "file", true);
+       status = bt_value_map_insert_bool(base_map, "file", BT_TRUE);
        assert(status == BT_VALUE_STATUS_OK);
-       status = bt_value_map_insert_bool(base_map, "edit", false);
+       status = bt_value_map_insert_bool(base_map, "edit", BT_FALSE);
        assert(status == BT_VALUE_STATUS_OK);
        status = bt_value_map_insert_integer(base_map, "selection", 17);
        assert(status == BT_VALUE_STATUS_OK);
        status = bt_value_map_insert_integer(base_map, "find", -34);
        assert(status == BT_VALUE_STATUS_OK);
-       status = bt_value_map_insert_bool(extension_map, "edit", true);
+       status = bt_value_map_insert_bool(extension_map, "edit", BT_TRUE);
        assert(status == BT_VALUE_STATUS_OK);
        status = bt_value_map_insert_integer(extension_map, "find", 101);
        assert(status == BT_VALUE_STATUS_OK);
@@ -1219,12 +1219,12 @@ void test_freeze(void)
        obj = bt_value_integer_create();
        assert(obj);
        ok(!bt_value_is_frozen(obj),
-               "bt_value_is_frozen() returns false with a fresh value object");
+               "bt_value_is_frozen() returns BT_FALSE with a fresh value object");
        assert(!bt_value_freeze(obj));
        ok(!bt_value_freeze(obj),
                "bt_value_freeze() passes with a frozen value object");
        ok(bt_value_is_frozen(obj),
-               "bt_value_is_frozen() returns true with a frozen value object");
+               "bt_value_is_frozen() returns BT_TRUE with a frozen value object");
 
        BT_PUT(obj);
 }
index 68534812af130e9d7b56b0988b687c2db08e1629..2c06fed899c354b5a5d80ec3f37ffc14705adccd 100644 (file)
@@ -26,6 +26,7 @@
 #include <babeltrace/ctf-ir/trace.h>
 #include <babeltrace/ctf-ir/visitor.h>
 #include <stdlib.h>
+#include <stdbool.h>
 #include <string.h>
 #include <assert.h>
 
index a256b7cbcb958ed07c566044d7f22949a3823454..603eb29bc79ed6b79baa416ee43d48ec62f8538b 100644 (file)
@@ -70,7 +70,7 @@ static void test_invalid(const char *plugin_dir)
 
        ok(!bt_plugin_create_all_from_file(NULL),
                "bt_plugin_create_all_from_file() handles NULL correctly");
-       ok(!bt_plugin_create_all_from_dir(NULL, false),
+       ok(!bt_plugin_create_all_from_dir(NULL, BT_FALSE),
                "bt_plugin_create_all_from_dir() handles NULL correctly");
        ok(!bt_plugin_get_name(NULL),
                "bt_plugin_get_name() handles NULL correctly");
@@ -245,11 +245,11 @@ static void test_create_all_from_dir(const char *plugin_dir)
 
        diag("create from all test below");
 
-       plugin_set = bt_plugin_create_all_from_dir(NON_EXISTING_PATH, false);
+       plugin_set = bt_plugin_create_all_from_dir(NON_EXISTING_PATH, BT_FALSE);
        ok(!plugin_set,
                "bt_plugin_create_all_from_dir() fails with an invalid path");
 
-       plugin_set = bt_plugin_create_all_from_dir(plugin_dir, false);
+       plugin_set = bt_plugin_create_all_from_dir(plugin_dir, BT_FALSE);
        ok(plugin_set, "bt_plugin_create_all_from_dir() succeeds with a valid path");
 
        /* 2 or 4, if `.la` files are considered or not */
index 2fd584c921dd3a32dfbb3e4d4def9074d7fdcd74..f5eac77c29b831e04ae84d7967c8ef56c5b1815b 100644 (file)
@@ -18,6 +18,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdint.h>
+#include <stdbool.h>
 #include <inttypes.h>
 #include <string.h>
 #include <assert.h>
This page took 0.084162 seconds and 4 git commands to generate.