diff options
-rw-r--r-- | discover/boot.c | 2 | ||||
-rw-r--r-- | discover/grub2/builtins.c | 2 | ||||
-rw-r--r-- | discover/grub2/env.c | 2 | ||||
-rw-r--r-- | lib/Makefile.am | 3 | ||||
-rw-r--r-- | lib/array-size/array-size.h | 7 | ||||
-rw-r--r-- | lib/list/list.h | 12 | ||||
-rw-r--r-- | lib/pb-config/storage-test.c | 2 | ||||
-rw-r--r-- | lib/util/util.h | 34 | ||||
-rw-r--r-- | test/parser/test-grub2-save-env.c | 2 |
9 files changed, 43 insertions, 23 deletions
diff --git a/discover/boot.c b/discover/boot.c index 0237b0c..13dfe0c 100644 --- a/discover/boot.c +++ b/discover/boot.c @@ -9,13 +9,13 @@ #include <fcntl.h> #include <sys/types.h> -#include <array-size/array-size.h> #include <log/log.h> #include <pb-protocol/pb-protocol.h> #include <process/process.h> #include <system/system.h> #include <talloc/talloc.h> #include <url/url.h> +#include <util/util.h> #include "device-handler.h" #include "boot.h" diff --git a/discover/grub2/builtins.c b/discover/grub2/builtins.c index c218bc7..668ed93 100644 --- a/discover/grub2/builtins.c +++ b/discover/grub2/builtins.c @@ -5,7 +5,7 @@ #include <log/log.h> #include <types/types.h> #include <talloc/talloc.h> -#include <array-size/array-size.h> +#include <util/util.h> #include "grub2.h" diff --git a/discover/grub2/env.c b/discover/grub2/env.c index 90e9c69..c887c75 100644 --- a/discover/grub2/env.c +++ b/discover/grub2/env.c @@ -5,7 +5,7 @@ #include <log/log.h> #include <types/types.h> #include <talloc/talloc.h> -#include <array-size/array-size.h> +#include <util/util.h> #include <discover/parser.h> #include <discover/file.h> diff --git a/lib/Makefile.am b/lib/Makefile.am index f000a2f..b492d69 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -42,6 +42,7 @@ libpbcore_la_SOURCES = \ system/system.c \ system/system.h \ url/url.c \ - url/url.h + url/url.h \ + util/util.h MAINTAINERCLEANFILES = Makefile.in diff --git a/lib/array-size/array-size.h b/lib/array-size/array-size.h deleted file mode 100644 index 12d59f8..0000000 --- a/lib/array-size/array-size.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef ARRAY_SIZE_H -#define ARRAY_SIZE_H - -#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) - -#endif /* ARRAY_SIZE_H */ - diff --git a/lib/list/list.h b/lib/list/list.h index 0174b90..ad562e4 100644 --- a/lib/list/list.h +++ b/lib/list/list.h @@ -1,6 +1,8 @@ #ifndef _LIST_H #define _LIST_H +#include <util/util.h> + struct list_item { struct list_item *prev, *next; }; @@ -9,16 +11,6 @@ struct list { struct list_item head; }; -#ifndef container_of -#define container_of(_ptr, _type, _member) ({ \ - const typeof( ((_type *)0)->_member ) *__mptr = (_ptr); \ - (_type *)( (char *)__mptr - offsetof(_type,_member) );}) -#endif - -#ifndef offsetof -#define offsetof(_type, _member) ((size_t) &((_type *)0)->_member) -#endif - #define list_for_each(_list, _pos) \ for (_pos = (_list)->head.next; _pos != ((_list)->head); _pos = _pos->next) diff --git a/lib/pb-config/storage-test.c b/lib/pb-config/storage-test.c index 3ce58ef..e4a0e5a 100644 --- a/lib/pb-config/storage-test.c +++ b/lib/pb-config/storage-test.c @@ -4,7 +4,7 @@ #include <sys/types.h> #include <sys/wait.h> -#include <array-size/array-size.h> +#include <util/util.h> #include "pb-config.h" #include "storage.h" diff --git a/lib/util/util.h b/lib/util/util.h new file mode 100644 index 0000000..30b472d --- /dev/null +++ b/lib/util/util.h @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2013 IBM Corporation + * + * 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; version 2 of the License. + * + * 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 UTIL_H +#define UTIL_H + +#ifndef container_of +#define container_of(_ptr, _type, _member) ({ \ + const typeof( ((_type *)0)->_member ) *__mptr = (_ptr); \ + (_type *)( (char *)__mptr - offsetof(_type,_member) );}) +#endif + +#ifndef offsetof +#define offsetof(_type, _member) ((size_t) &((_type *)0)->_member) +#endif + +#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) + +#endif /* UTIL_H */ + diff --git a/test/parser/test-grub2-save-env.c b/test/parser/test-grub2-save-env.c index 826963e..7f15164 100644 --- a/test/parser/test-grub2-save-env.c +++ b/test/parser/test-grub2-save-env.c @@ -1,7 +1,7 @@ #include <string.h> -#include <array-size/array-size.h> +#include <util/util.h> #include <talloc/talloc.h> #include "parser-test.h" |