*/
#ifndef STRACE_LIST_H
-#define STRACE_LIST_H
+# define STRACE_LIST_H
/*
* struct list_item and related macros and functions provide an interface
* https://lwn.net/Articles/336255/
*/
-#include "macros.h"
+# include "macros.h"
struct list_item {
struct list_item *prev;
*
* @param l_ List head variable name.
*/
-#define EMPTY_LIST(l_) struct list_item l_ = { &l_, &l_ }
+# define EMPTY_LIST(l_) struct list_item l_ = { &l_, &l_ }
/** Initialise an empty list. */
static inline void
* @param type Type of the list's item.
* @param field Name of the field that holds the respective struct list_item.
*/
-#define list_elem(var, type, field) containerof((var), type, field)
+# define list_elem(var, type, field) containerof((var), type, field)
/**
* Get the first element in a list.
* @param type Type of the list's item.
* @param field Name of the field that holds the respective struct list_item.
*/
-#define list_head(head, type, field) \
+# define list_head(head, type, field) \
(list_is_empty(head) ? NULL : list_elem((head)->next, type, field))
/**
* Get the last element in a list.
* @param type Type of the list's item.
* @param field Name of the field that holds the respective struct list_item.
*/
-#define list_tail(head, type, field) \
+# define list_tail(head, type, field) \
(list_is_empty(head) ? NULL : list_elem((head)->prev, type, field))
/**
* @param var Pointer to a list item.
* @param field Name of the field that holds the respective struct list_item.
*/
-#define list_next(var, field) \
+# define list_next(var, field) \
list_elem((var)->field.next, typeof(*(var)), field)
/**
* Get the previous element in a list.
* @param var Pointer to a list item.
* @param field Name of the field that holds the respective struct list_item.
*/
-#define list_prev(var, field) \
+# define list_prev(var, field) \
list_elem((var)->field.prev, typeof(*(var)), field)
/**
* @param field_ Name of the field containing the respective struct list_item
* inside list items.
*/
-#define list_foreach(var_, head_, field_) \
+# define list_foreach(var_, head_, field_) \
for (var_ = list_elem((head_)->next, typeof(*var_), field_); \
&(var_->field_) != (head_); var_ = list_next(var_, field_))
* inside list items.
* @param _tmp Temporary variable for storing pointer to the next item.
*/
-#define list_foreach_safe(var_, head_, field_, _tmp) \
+# define list_foreach_safe(var_, head_, field_, _tmp) \
for (var_ = list_elem((head_)->next, typeof(*var_), field_), \
_tmp = list_elem((var_)->field_.next, typeof(*var_), field_); \
&var_->field_ != head_; var_ = _tmp, _tmp = list_next(_tmp, field_))
(offsetof(type_, member_) + sizeof(((type_ *)0)->member_))
# endif
-#ifndef cast_ptr
-# define cast_ptr(type_, var_) \
+# ifndef cast_ptr
+# define cast_ptr(type_, var_) \
((type_) (uintptr_t) (const volatile void *) (var_))
-#endif
+# endif
-#ifndef containerof
+# ifndef containerof
/**
* Return a pointer to a structure that contains the provided variable.
*
* @param member_ Name of the member field.
* @return Pointer to the container structure.
*/
-# define containerof(ptr_, struct_, member_) \
+# define containerof(ptr_, struct_, member_) \
cast_ptr(struct_ *, \
(const volatile char *) (ptr_) - offsetof(struct_, member_))
-#endif
+# endif
static inline bool
is_filled(const char *ptr, char fill, size_t size)
if (status[i] >= 0) {
printf("%d", status[i]);
} else {
-#if !XLAT_RAW
+# if !XLAT_RAW
errno = -status[i];
-#endif
-#if XLAT_RAW
+# endif
+# if XLAT_RAW
printf("%d", status[i]);
-#elif XLAT_VERBOSE
+# elif XLAT_VERBOSE
printf("%d /* -%s */", status[i], errno2name());
-#else
+# else
printf("-%s", errno2name());
-#endif
+# endif
}
}
printf("]");
} else {
print_status_array(status, count);
}
-#if XLAT_RAW
+# if XLAT_RAW
printf(", 0x2) = %s\n", errstr);
-#elif XLAT_VERBOSE
+# elif XLAT_VERBOSE
printf(", 0x2 /* MPOL_MF_MOVE */) = %s\n", errstr);
-#else /* XLAT_ABBREV */
+# else /* XLAT_ABBREV */
printf(", MPOL_MF_MOVE) = %s\n", errstr);
-#endif
+# endif
}
static void
printf("%p", status);
else
printf("[]");
-#if XLAT_RAW
+# if XLAT_RAW
printf(", 0x4) = %s\n", errstr);
-#elif XLAT_VERBOSE
+# elif XLAT_VERBOSE
printf(", 0x4 /* MPOL_MF_MOVE_ALL */) = %s\n", errstr);
-#else /* XLAT_ABBREV */
+# else /* XLAT_ABBREV */
printf(", MPOL_MF_MOVE_ALL) = %s\n", errstr);
-#endif
+# endif
}
int