|
|
# --- SDE-COPYRIGHT-NOTE-BEGIN --- # This copyright note is auto-generated by ./scripts/Create-CopyPatch. # # Filename: package/.../util-linux/0001-replace-container_of.patch # Copyright (C) 2013 The OpenSDE Project # # More information can be found in the files COPYING and README. # # This patch file is dual-licensed. It is available under the license the # patched project is licensed under, as long as it is an OpenSource license # as defined at http://www.opensource.org/ (e.g. BSD, X11) or 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. # --- SDE-COPYRIGHT-NOTE-END ---
This patch is fixing build issues by using a more simple but reasonable container_of function without abusing __typeof__. Besides that it is removing code duplication because the list_entry function macro is the same as container_of.
Without the patch we are getting following error: ------------------------------------------------------------------------------
sys-utils/prlimit.c: In function 'show_limits': sys-utils/prlimit.c:299:25: error: expected declaration specifiers or '...' before '(' token sys-utils/prlimit.c:299:25: error: '__mptr' undeclared (first use in this function) sys-utils/prlimit.c:299:25: note: each undeclared identifier is reported only once for each function it appears in sys-utils/prlimit.c: In function 'do_prlimit': sys-utils/prlimit.c:336:25: error: expected declaration specifiers or '...' before '(' token sys-utils/prlimit.c:336:25: error: '__mptr' undeclared (first use in this function ------------------------------------------------------------------------------
--- util-linux-2.23.2/include/c.h.orig 2013-08-27 10:32:00.890399403 +0200
+++ util-linux-2.23.2/include/c.h 2013-08-27 10:41:56.872040920 +0200
@@ -115,9 +115,8 @@
#endif #ifndef container_of -#define container_of(ptr, type, member) ({ \
- const __typeof__( ((type *)0)->member ) *__mptr = (ptr); \
- (type *)( (char *)__mptr - offsetof(type,member) );})
+#define container_of(ptr, type, member) \
+ ((type *)((char *)(ptr) - offsetof(type, member)))
#endif #ifndef HAVE_PROGRAM_INVOCATION_SHORT_NAME --- util-linux-2.23.2/include/list.h.orig 2013-08-27 10:35:19.025606381 +0200
+++ util-linux-2.23.2/include/list.h 2013-08-27 10:36:09.172435338 +0200
@@ -166,10 +166,7 @@
* @type: the type of the struct this is embedded in. * @member: the name of the list_struct within the struct. */ -#define list_entry(ptr, type, member) ({ \
- const typeof( ((type *)0)->member ) *__mptr = (ptr); \
- (type *)( (char *)__mptr - offsetof(type,member) );})
-
+#define list_entry container_of
#define list_first_entry(head, type, member) \ ((head) && (head)->next != (head) ? list_entry((head)->next, type, member) : NULL)
|