Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=0bcfeccb2c14614e36edb2e80fae16119ebcc1f5

commit 0bcfeccb2c14614e36edb2e80fae16119ebcc1f5
Author: Michel Hermier <[email protected]>
Date:   Fri Jun 7 12:43:10 2013 +0200

libflib: Add fstddef.h to add some extra macros (will be used by flist.h).

diff --git a/lib/libflib/flist.h b/lib/libflib/flist.h
index b53aecf..61897ad 100644
--- a/lib/libflib/flist.h
+++ b/lib/libflib/flist.h
@@ -22,9 +22,8 @@
#ifndef F_LIST_H
#define F_LIST_H

-#include <stddef.h>
-
#include <fcallbacks.h>
+#include <fstddef.h>

typedef struct FListItem FListItem;

diff --git a/lib/libflib/fstddef.h b/lib/libflib/fstddef.h
new file mode 100644
index 0000000..e1f9ab1
--- /dev/null
+++ b/lib/libflib/fstddef.h
@@ -0,0 +1,54 @@
+/*
+ *  fstddef.h
+ *
+ *  Copyright (c) 2013 by Michel Hermier <[email protected]>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ *  USA.
+ */
+#ifndef F_STDDEF_H
+#define F_STDDEF_H
+
+#include <stddef.h>
+
+#ifdef __GNUC__
+#define f_typecmp(type1, type2) \
+       __builtin_types_compatible_p (type1, type2)
+
+#define f_typeof(expr) \
+       __typeof__ (expr)
+
+#define f_static_if(cond, expr_if_true, expr_if_false) \
+       __builtin_choose_expr (cond, expr_if_true, expr_if_false)
+#else
+#warning Unsupported compiler
+#endif
+
+#define f_containerof(ptr, type, member) \
+       ((type *) ((char *)f_identity_cast (f_typeof (&((type *)0)->member), 
(ptr)) - offsetof (type, member)))
+
+#define f_identity_cast(type, expr) \
+       f_static_if (f_typecmp (type, f_typeof (expr)), \
+                       (expr), (void)0)
+
+#define f_static_assert(cond) \
+       (f_static_if (cond, 0, (void)0) == 0)
+
+#define f_type_assert(expr, type) \
+       f_static_assert (f_typecmp (f_typeof (expr), type))
+
+#endif /* F_STDDEF_H */
+
+/* vim: set ts=2 sw=2 noet: */
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to