--- /dev/null
+/*
+ * faultd
+ *
+ * Copyright © 2017 Samsung Electronics
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FAULTD_COMMON_H
+#define FAULTD_COMMON_H
+
+#include <stdlib.h>
+
+#define ARRAY_SIZE(a) (sizeof(a)/sizeof(*a))
+
+#ifndef offsetof
+#define offsetof(type, member) __builtin_offsetof (type, member)
+#endif /* offsetof */
+
+#ifndef container_of
+#define container_of(ptr, type, field) ({ \
+ const typeof(((type *)0)->field) *member = (ptr); \
+ (type *)( (char *)member - offsetof(type, field) ); \
+})
+#endif /* container_of */
+
+#define _cleanup_(x) __attribute__((cleanup(x)))
+
+static inline void freep(void *p)
+{
+ free(*(void**)p);
+}
+#define _cleanup_free_ _cleanup_(freep)
+
+#endif /* FAULTD_COMMON_H */