#include <limits.h>
#include <stdbool.h>
#include <libgen.h>
-
-typedef struct filldir filldir_t;
+#include <urcu.h>
/* long and pointer must be either 32 bit or 64 bit */
#undef SIZEOF_LONG
/* Simplified from version in include/linux/overflow.h */
/*
- * * Compute a*b+c, returning SIZE_MAX on overflow. Internal helper for
- * * struct_size() below.
- * */
+ * Compute a*b+c, returning SIZE_MAX on overflow. Internal helper for
+ * struct_size() below.
+ */
static inline size_t __ab_c_size(size_t a, size_t b, size_t c)
{
return (a * b) + c;
sizeof(*(p)->member) + __must_be_array((p)->member), \
sizeof(*(p)))
+/**
+ * struct_size_t() - Calculate size of structure with trailing flexible array
+ * @type: structure type name.
+ * @member: Name of the array member.
+ * @count: Number of elements in the array.
+ *
+ * Calculates size of memory needed for structure @type followed by an
+ * array of @count number of @member elements. Prefer using struct_size()
+ * when possible instead, to keep calculations associated with a specific
+ * instance variable of type @type.
+ *
+ * Return: number of bytes needed or SIZE_MAX on overflow.
+ */
+#define struct_size_t(type, member, count) \
+ struct_size((type *)NULL, member, count)
+
+/*
+ * Add the pseudo keyword 'fallthrough' so case statement blocks
+ * must end with any of these keywords:
+ * break;
+ * fallthrough;
+ * continue;
+ * goto <label>;
+ * return [expression];
+ *
+ * gcc: https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html#Statement-Attributes
+ */
+#if defined __has_attribute
+# if __has_attribute(__fallthrough__)
+# define fallthrough __attribute__((__fallthrough__))
+# else
+# define fallthrough do {} while (0) /* fallthrough */
+# endif
+#else
+# define fallthrough do {} while (0) /* fallthrough */
+#endif
+
+/* Only needed for the kernel. */
+#define __init
+
+#ifdef __GNUC__
+#define __return_address __builtin_return_address(0)
+
+/*
+ * Return the address of a label. Use barrier() so that the optimizer
+ * won't reorder code to refactor the error jumpouts into a single
+ * return, which throws off the reported address.
+ */
+#define __this_address ({ __label__ __here; __here: barrier(); &&__here; })
+/* Optimization barrier */
+
+/* The "volatile" is due to gcc bugs */
+#define barrier() __asm__ __volatile__("": : :"memory")
+#endif
+
+/* Optimization barrier */
+#ifndef barrier
+# define barrier() __memory_barrier()
+#endif
+
#endif /* __XFS_PLATFORM_DEFS_H__ */