From e7cff82c032f8788315a270c5ade6f7a3454c178 Mon Sep 17 00:00:00 2001 From: Fabian Nack Date: Fri, 28 Nov 2014 08:31:34 +0100 Subject: [PATCH] pkg/oonf_api: necessary oonf_api patches --- ...y-define-container_of-when-necessary.patch | 28 ++++++++++ pkg/oonf_api/0006-if_index-is-not-used.patch | 24 +++++++++ ...e-RIOT-s-container_of-implementation.patch | 44 +++++++++++++++ ...08-Dissolve-enum-into-single-defines.patch | 53 +++++++++++++++++++ pkg/oonf_api/0009-Add-missing-include.patch | 23 ++++++++ ...10-Change-index-of-array-from-0-to-1.patch | 24 +++++++++ 6 files changed, 196 insertions(+) create mode 100644 pkg/oonf_api/0005-only-define-container_of-when-necessary.patch create mode 100644 pkg/oonf_api/0006-if_index-is-not-used.patch create mode 100644 pkg/oonf_api/0007-Use-RIOT-s-container_of-implementation.patch create mode 100644 pkg/oonf_api/0008-Dissolve-enum-into-single-defines.patch create mode 100644 pkg/oonf_api/0009-Add-missing-include.patch create mode 100644 pkg/oonf_api/0010-Change-index-of-array-from-0-to-1.patch diff --git a/pkg/oonf_api/0005-only-define-container_of-when-necessary.patch b/pkg/oonf_api/0005-only-define-container_of-when-necessary.patch new file mode 100644 index 000000000..fd2d8e198 --- /dev/null +++ b/pkg/oonf_api/0005-only-define-container_of-when-necessary.patch @@ -0,0 +1,28 @@ +From d81d24b9d4c897c508799cb390b13cb018758709 Mon Sep 17 00:00:00 2001 +From: Benjamin Valentin +Date: Fri, 10 Oct 2014 02:05:01 +0200 +Subject: [PATCH] only define container_of when necessary + +--- + src-api/common/container_of.h | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/src-api/common/container_of.h b/src-api/common/container_of.h +index 9fd1893..fcb38fe 100644 +--- a/src-api/common/container_of.h ++++ b/src-api/common/container_of.h +@@ -58,10 +58,12 @@ + * @param member name of node inside struct + * @return pointer to surrounding struct + */ ++#ifndef container_of + #define container_of(ptr, type, member) ({ \ + const typeof(((type *)0)->member ) *__tempptr = (ptr); \ + (type *)((char *)__tempptr - offsetof(type,member)); \ + }) ++#endif + + /** + * Helper function for NULL safe container_of macro +-- +1.9.1 diff --git a/pkg/oonf_api/0006-if_index-is-not-used.patch b/pkg/oonf_api/0006-if_index-is-not-used.patch new file mode 100644 index 000000000..461c19464 --- /dev/null +++ b/pkg/oonf_api/0006-if_index-is-not-used.patch @@ -0,0 +1,24 @@ +From 40651f114bd6e1b4b2ebc89bdf8fb06d1243eb55 Mon Sep 17 00:00:00 2001 +From: Benjamin Valentin +Date: Fri, 10 Oct 2014 02:08:32 +0200 +Subject: [PATCH] if_index is not used + +--- + src-api/common/netaddr.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src-api/common/netaddr.c b/src-api/common/netaddr.c +index ed44341..fa528ca 100644 +--- a/src-api/common/netaddr.c ++++ b/src-api/common/netaddr.c +@@ -319,7 +319,7 @@ netaddr_create_host_bin(struct netaddr *host, const struct netaddr *netmask, + */ + int + netaddr_socket_init(union netaddr_socket *combined, const struct netaddr *addr, +- uint16_t port, unsigned if_index) { ++ uint16_t port, unsigned if_index __attribute__((unused))) { + /* initialize memory block */ + memset(combined, 0, sizeof(*combined)); + +-- +1.9.1 diff --git a/pkg/oonf_api/0007-Use-RIOT-s-container_of-implementation.patch b/pkg/oonf_api/0007-Use-RIOT-s-container_of-implementation.patch new file mode 100644 index 000000000..a57d4bab0 --- /dev/null +++ b/pkg/oonf_api/0007-Use-RIOT-s-container_of-implementation.patch @@ -0,0 +1,44 @@ +From b2ad2073ac282f1bc6315e47ffbd12c3f6a9ae1a Mon Sep 17 00:00:00 2001 +From: Hinnerk van Bruinehsen +Date: Wed, 29 Oct 2014 11:37:05 +0100 +Subject: [PATCH] Use RIOT's container_of implementation + +--- + src-api/common/container_of.h | 22 ++++++++++++++++++---- + 1 file changed, 18 insertions(+), 4 deletions(-) + +diff --git a/src-api/common/container_of.h b/src-api/common/container_of.h +index fcb38fe..b49d836 100644 +--- a/src-api/common/container_of.h ++++ b/src-api/common/container_of.h +@@ -59,10 +59,24 @@ + * @return pointer to surrounding struct + */ + #ifndef container_of +-#define container_of(ptr, type, member) ({ \ +- const typeof(((type *)0)->member ) *__tempptr = (ptr); \ +- (type *)((char *)__tempptr - offsetof(type,member)); \ +- }) ++#if __STDC_VERSION__ >= 201112L ++# define container_of(PTR, TYPE, MEMBER) \ ++ (_Generic((PTR), \ ++ const __typeof__ (((TYPE *) 0)->MEMBER) *: \ ++ ((TYPE *) ((char *) (PTR) - offsetof(TYPE, MEMBER))), \ ++ __typeof__ (((TYPE *) 0)->MEMBER) *: \ ++ ((TYPE *) ((char *) (PTR) - offsetof(TYPE, MEMBER))) \ ++ )) ++#elif defined __GNUC__ ++# define container_of(PTR, TYPE, MEMBER) \ ++ (__extension__ ({ \ ++ __extension__ const __typeof__ (((TYPE *) 0)->MEMBER) *__m____ = (PTR); \ ++ ((TYPE *) ((char *) __m____ - offsetof(TYPE, MEMBER))); \ ++ })) ++#else ++# define container_of(PTR, TYPE, MEMBER) \ ++ ((TYPE *) ((char *) (PTR) - offsetof(TYPE, MEMBER))) ++#endif + #endif + + /** +-- +2.1.2 diff --git a/pkg/oonf_api/0008-Dissolve-enum-into-single-defines.patch b/pkg/oonf_api/0008-Dissolve-enum-into-single-defines.patch new file mode 100644 index 000000000..4784dff02 --- /dev/null +++ b/pkg/oonf_api/0008-Dissolve-enum-into-single-defines.patch @@ -0,0 +1,53 @@ +From e590e6f26b115da34a943fd4ed6d4c93fd2c64d0 Mon Sep 17 00:00:00 2001 +From: Hinnerk van Bruinehsen +Date: Wed, 29 Oct 2014 12:05:11 +0100 +Subject: [PATCH] Dissolve enum into single defines + +--- + src-api/rfc5444/rfc5444.h | 26 ++++++++++++-------------- + 1 file changed, 12 insertions(+), 14 deletions(-) + +diff --git a/src-api/rfc5444/rfc5444.h b/src-api/rfc5444/rfc5444.h +index c5d6420..6b5576e 100644 +--- a/src-api/rfc5444/rfc5444.h ++++ b/src-api/rfc5444/rfc5444.h +@@ -43,25 +43,23 @@ + + #include "common/common_types.h" + +-enum { +- /* timetlv_max = 14 * 2^28 * 1000 / 1024 = 14000 << 18 = 3 670 016 000 ms */ +- RFC5444_TIMETLV_MAX = 0xdac00000, ++/* timetlv_max = 14 * 2^28 * 1000 / 1024 = 14000 << 18 = 3 670 016 000 ms */ ++#define RFC5444_TIMETLV_MAX 0xdac00000 + +- /* timetlv_min = 1000/1024 ms */ +- RFC5444_TIMETLV_MIN = 0x00000001, ++/* timetlv_min = 1000/1024 ms */ ++#define RFC5444_TIMETLV_MIN 0x00000001 + +- /* metric_max = 1<<24 - 256 */ +- RFC5444_METRIC_MAX = 0xffff00, ++/* metric_max = 1<<24 - 256 */ ++#define RFC5444_METRIC_MAX 0xffff00 + +- /* metric_min = 1 */ +- RFC5444_METRIC_MIN = 0x000001, ++/* metric_min = 1 */ ++#define RFC5444_METRIC_MIN 0x000001 + +- /* larger than possible metric value */ +- RFC5444_METRIC_INFINITE = 0xffffff, ++/* larger than possible metric value */ ++#define RFC5444_METRIC_INFINITE 0xffffff + +- /* infinite path cost */ +- RFC5444_METRIC_INFINITE_PATH = 0xffffffff, +-}; ++/* infinite path cost */ ++#define RFC5444_METRIC_INFINITE_PATH 0xffffffff + + EXPORT uint8_t rfc5444_timetlv_get_from_vector( + uint8_t *vector, size_t vector_length, uint8_t hopcount); +-- +2.1.2 diff --git a/pkg/oonf_api/0009-Add-missing-include.patch b/pkg/oonf_api/0009-Add-missing-include.patch new file mode 100644 index 000000000..6d799f91d --- /dev/null +++ b/pkg/oonf_api/0009-Add-missing-include.patch @@ -0,0 +1,23 @@ +From 21202804f26b194607a412476a96f03d3df30688 Mon Sep 17 00:00:00 2001 +From: Hinnerk van Bruinehsen +Date: Wed, 29 Oct 2014 12:11:29 +0100 +Subject: [PATCH 9/9] Add missing include + +--- + src-api/rfc5444/rfc5444_tlv_writer.h | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src-api/rfc5444/rfc5444_tlv_writer.h b/src-api/rfc5444/rfc5444_tlv_writer.h +index ace7313..8d0ce3a 100644 +--- a/src-api/rfc5444/rfc5444_tlv_writer.h ++++ b/src-api/rfc5444/rfc5444_tlv_writer.h +@@ -43,6 +43,7 @@ + #define RFC5444_TLV_WRITER_H_ + + #include "common/common_types.h" ++#include "rfc5444_context.h" + + struct rfc5444_tlv_writer_data { + uint8_t *buffer; +-- +2.1.2 diff --git a/pkg/oonf_api/0010-Change-index-of-array-from-0-to-1.patch b/pkg/oonf_api/0010-Change-index-of-array-from-0-to-1.patch new file mode 100644 index 000000000..71a22b868 --- /dev/null +++ b/pkg/oonf_api/0010-Change-index-of-array-from-0-to-1.patch @@ -0,0 +1,24 @@ +From 0ecbb8a8b896ac4aff57d94d678a4a95084a095c Mon Sep 17 00:00:00 2001 +From: Hinnerk van Bruinehsen +Date: Wed, 29 Oct 2014 12:13:27 +0100 +Subject: [PATCH 10/10] Change index of array from 0 to 1 + +--- + src-api/common/template.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src-api/common/template.h b/src-api/common/template.h +index d98fe77..7ca75a8 100644 +--- a/src-api/common/template.h ++++ b/src-api/common/template.h +@@ -64,7 +64,7 @@ struct abuf_template_storage_entry { + + struct abuf_template_storage { + size_t count; +- struct abuf_template_storage_entry indices[0]; ++ struct abuf_template_storage_entry indices[1]; + }; + + EXPORT struct abuf_template_storage *abuf_template_init ( +-- +2.1.2