summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/commonlib/include/commonlib/helpers.h6
-rw-r--r--src/commonlib/include/commonlib/region.h1
-rw-r--r--src/commonlib/mem_pool.c2
-rw-r--r--src/commonlib/region.c20
-rw-r--r--src/include/sys/types.h1
5 files changed, 20 insertions, 10 deletions
diff --git a/src/commonlib/include/commonlib/helpers.h b/src/commonlib/include/commonlib/helpers.h
index 0e337c9ce7..646a66f30d 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 35d48ade85..a13c66c316 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 e42e9cb3d5..cb3e726f25 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 2cd273a883..bfc5fc8471 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);
@@ -212,7 +214,7 @@ static void *xlate_mmap(const struct region_device *rd, size_t offset,
.size = size,
};
- xldev = container_of(rd, typeof(*xldev), rdev);
+ xldev = container_of(rd, __typeof__(*xldev), rdev);
if (!is_subregion(&xldev->sub_region, &req))
return NULL;
@@ -226,7 +228,7 @@ static int xlate_munmap(const struct region_device *rd, void *mapping)
{
const struct xlate_region_device *xldev;
- xldev = container_of(rd, typeof(*xldev), rdev);
+ xldev = container_of(rd, __typeof__(*xldev), rdev);
return rdev_munmap(xldev->access_dev, mapping);
}
@@ -240,7 +242,7 @@ static ssize_t xlate_readat(const struct region_device *rd, void *b,
};
const struct xlate_region_device *xldev;
- xldev = container_of(rd, typeof(*xldev), rdev);
+ xldev = container_of(rd, __typeof__(*xldev), rdev);
if (!is_subregion(&xldev->sub_region, &req))
return -1;
diff --git a/src/include/sys/types.h b/src/include/sys/types.h
new file mode 100644
index 0000000000..fa95d570b0
--- /dev/null
+++ b/src/include/sys/types.h
@@ -0,0 +1 @@
+#include "../types.h"