Aaron Durbin (adurbin@chromium.org) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/12784
-gerrit
commit 38a258e72245ef143ab17f008f5b894a23dd98a9 Author: Aaron Durbin adurbin@chromium.org Date: Tue Dec 15 17:49:12 2015 -0600
commonlib: prepare for cbfstool inclusion
Some of the files need to be adjusted so that they can be used both in cbfstool as well as coreboot proper. For coreboot, add a <sys/types.h> file such that proper types can be included from both the tools and coreboot. The other chanes are to accomodate stricter checking in cbfstool.
BUG=chrome-os-partner:48412 BUG=chromium:445938 BRANCH=None TEST=Built on glados including tools. Booted.
Change-Id: I771c6675c64b8837f775427721dd3300a8fa1bc0 Signed-off-by: Aaron Durbin adurbin@chromium.org --- src/commonlib/include/commonlib/helpers.h | 6 ++++++ src/commonlib/include/commonlib/region.h | 1 + src/commonlib/mem_pool.c | 2 +- src/commonlib/region.c | 14 ++++++++------ src/include/sys/types.h | 1 + 5 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/src/commonlib/include/commonlib/helpers.h b/src/commonlib/include/commonlib/helpers.h index 0e337c9..646a66f 100644 --- a/src/commonlib/include/commonlib/helpers.h +++ b/src/commonlib/include/commonlib/helpers.h @@ -2,7 +2,9 @@ #define COMMONLIB_HELPERS_H /* This file is for helpers for both coreboot firmware and its utilities. */
+#ifndef ARRAY_SIZE #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) +#endif
#define ALIGN(x,a) __ALIGN_MASK(x,(__typeof__(x))(a)-1UL) #define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask)) @@ -54,4 +56,8 @@ const __typeof__( ((type *)0)->member ) *__mptr = (ptr); \ (type *)( (char *)__mptr - offsetof(type,member) );})
+#ifndef __unused +#define __unused __attribute__((unused)) +#endif + #endif /* COMMONLIB_HELPERS_H */ diff --git a/src/commonlib/include/commonlib/region.h b/src/commonlib/include/commonlib/region.h index 35d48ad..a13c66c 100644 --- a/src/commonlib/include/commonlib/region.h +++ b/src/commonlib/include/commonlib/region.h @@ -16,6 +16,7 @@ #ifndef _REGION_H_ #define _REGION_H_
+#include <sys/types.h> #include <stdint.h> #include <stddef.h> #include <commonlib/mem_pool.h> diff --git a/src/commonlib/mem_pool.c b/src/commonlib/mem_pool.c index e42e9cb..cb3e726 100644 --- a/src/commonlib/mem_pool.c +++ b/src/commonlib/mem_pool.c @@ -13,8 +13,8 @@ * GNU General Public License for more details. */
+#include <commonlib/helpers.h> #include <commonlib/mem_pool.h> -#include <stdlib.h>
void *mem_pool_alloc(struct mem_pool *mp, size_t sz) { diff --git a/src/commonlib/region.c b/src/commonlib/region.c index 2cd273a..84b283b 100644 --- a/src/commonlib/region.c +++ b/src/commonlib/region.c @@ -13,6 +13,7 @@ * GNU General Public License for more details. */
+#include <commonlib/helpers.h> #include <commonlib/region.h> #include <string.h>
@@ -133,16 +134,17 @@ void mem_region_device_init(struct mem_region_device *mdev, void *base, }
static void *mdev_mmap(const struct region_device *rd, size_t offset, - size_t size) + size_t size __unused) { const struct mem_region_device *mdev;
- mdev = container_of(rd, typeof(*mdev), rdev); + mdev = container_of(rd, __typeof__(*mdev), rdev);
return &mdev->base[offset]; }
-static int mdev_munmap(const struct region_device *rd, void *mapping) +static int mdev_munmap(const struct region_device * rd __unused, + void *mapping __unused) { return 0; } @@ -152,7 +154,7 @@ static ssize_t mdev_readat(const struct region_device *rd, void *b, { const struct mem_region_device *mdev;
- mdev = container_of(rd, typeof(*mdev), rdev); + mdev = container_of(rd, __typeof__(*mdev), rdev);
memcpy(b, &mdev->base[offset], size);
@@ -177,7 +179,7 @@ void *mmap_helper_rdev_mmap(const struct region_device *rd, size_t offset, struct mmap_helper_region_device *mdev; void *mapping;
- mdev = container_of((void *)rd, typeof(*mdev), rdev); + mdev = container_of((void *)rd, __typeof__(*mdev), rdev);
mapping = mem_pool_alloc(&mdev->pool, size);
@@ -196,7 +198,7 @@ int mmap_helper_rdev_munmap(const struct region_device *rd, void *mapping) { struct mmap_helper_region_device *mdev;
- mdev = container_of((void *)rd, typeof(*mdev), rdev); + mdev = container_of((void *)rd, __typeof__(*mdev), rdev);
mem_pool_free(&mdev->pool, mapping);
diff --git a/src/include/sys/types.h b/src/include/sys/types.h new file mode 100644 index 0000000..fa95d57 --- /dev/null +++ b/src/include/sys/types.h @@ -0,0 +1 @@ +#include "../types.h"