Skip to content

Commit

Permalink
Merge pull request #895 from benpicco/oonf_fix
Browse files Browse the repository at this point in the history
make: don't ignore failures in for loops, fix build with make 4.0 and minor cleanups
  • Loading branch information
benpicco committed Mar 19, 2014
2 parents e6d8c6b + 633f65c commit 872ce5f
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 55 deletions.
58 changes: 29 additions & 29 deletions pkg/oonf_api/0001-add-RIOT-support.patch
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ index 0000000..cf66baa
+
+all:
+ mkdir -p $(BINDIR)
+ @for i in $(DIRS) ; do $(MAKE) -C $$i ; done ;
+ @for i in $(DIRS) ; do $(MAKE) -C $$i || exit 1; done ;
+
+clean:
diff --git a/external/regex/Makefile b/external/regex/Makefile
Expand Down Expand Up @@ -83,15 +83,15 @@ index 77c519b..e09c0c9 100644
@@ -51,6 +51,12 @@
#include <winsock2.h>
#endif

+#ifdef RIOT
+int getpagesize(void) {
+ return 512;
+}
+#endif
+
#include "common/autobuf.h"

/**
diff --git a/src-api/common/common_types.h b/src-api/common/common_types.h
index c90cf46..54ce281 100644
Expand All @@ -116,7 +116,7 @@ index 103c88f..6ea603d 100644
@@ -48,7 +48,7 @@
#include "common/common_types.h"
#include "common/daemonize.h"

-#ifndef WIN32
+#if (!defined(_WIN32)) && (!defined(RIOT))
/**
Expand All @@ -138,7 +138,7 @@ index dedab2c..fdc3e82 100644
+#include "inet_pton.h"
+#define DONT_HAVE_SIN6_SCOPE_ID
+#endif

#include "common/common_types.h"
#include "common/string.h"
@@ -175,12 +182,12 @@ netaddr_to_binary(void *dst, const struct netaddr *src, size_t len) {
Expand All @@ -165,14 +165,14 @@ index dedab2c..fdc3e82 100644
+ dst->_type = (uint8_t)src->std.sin6_family;
return 0;
}

@@ -204,12 +211,12 @@ netaddr_from_socket(struct netaddr *dst, const union netaddr_socket *src) {
int
netaddr_to_socket(union netaddr_socket *dst, const struct netaddr *src) {
/* copy address type */
- dst->std.sa_family = src->_type;
+ dst->std.sin6_family = src->_type;

switch (src->_type) {
case AF_INET:
/* ipv4 */
Expand All @@ -183,13 +183,13 @@ index dedab2c..fdc3e82 100644
/* ipv6 */
@@ -221,7 +228,7 @@ netaddr_to_socket(union netaddr_socket *dst, const struct netaddr *src) {
}

/* copy address type */
- dst->std.sa_family= src->_type;
+ dst->std.sin6_family= src->_type;
return 0;
}

@@ -319,14 +326,16 @@ netaddr_socket_init(union netaddr_socket *combined, const struct netaddr *addr,
switch (addr->_type) {
case AF_INET:
Expand All @@ -204,21 +204,21 @@ index dedab2c..fdc3e82 100644
memcpy(&combined->v6.sin6_addr, addr->_addr, 16);
- combined->v6.sin6_port = htons(port);
+ combined->v6.sin6_port = HTONS(port);
+#ifndef DONT_HAVE_SIN6_SCOPE_ID
+#ifndef DONT_HAVE_SIN6_SCOPE_ID
combined->v6.sin6_scope_id = if_index;
+#endif
break;
default:
/* unknown address type */
@@ -334,7 +343,7 @@ netaddr_socket_init(union netaddr_socket *combined, const struct netaddr *addr,
}

/* copy address type */
- combined->std.sa_family = addr->_type;
+ combined->std.sin6_family = addr->_type;
return 0;
}

@@ -344,11 +353,11 @@ netaddr_socket_init(union netaddr_socket *combined, const struct netaddr *addr,
*/
uint16_t
Expand All @@ -237,7 +237,7 @@ index dedab2c..fdc3e82 100644
@@ -555,28 +564,31 @@ const char *
netaddr_socket_to_string(struct netaddr_str *dst, const union netaddr_socket *src) {
struct netaddr_str buf;

- if (src->std.sa_family == AF_INET) {
+ if (src->std.sin6_family == AF_INET) {
snprintf(dst->buf, sizeof(*dst), "%s:%d",
Expand All @@ -251,7 +251,7 @@ index dedab2c..fdc3e82 100644
+#ifndef DONT_HAVE_SIN6_SCOPE_ID
if (src->v6.sin6_scope_id) {
char scope_buf[IF_NAMESIZE];

snprintf(dst->buf, sizeof(*dst), "[%s]:%d%%%s",
inet_ntop(AF_INET6, &src->v6.sin6_addr, buf.buf, sizeof(buf)),
- ntohs(src->v6.sin6_port),
Expand All @@ -272,18 +272,18 @@ index dedab2c..fdc3e82 100644
- snprintf(dst->buf, sizeof(*dst), "\"Unknown socket type: %d\"", src->std.sa_family);
+ snprintf(dst->buf, sizeof(*dst), "\"Unknown socket type: %d\"", src->std.sin6_family);
}

return dst->buf;
@@ -622,13 +634,13 @@ int
netaddr_cmp_to_socket(const struct netaddr *a1, const union netaddr_socket *a2) {
int result = 0;

- result = (int)a1->_type - (int)a2->std.sa_family;
+ result = (int)a1->_type - (int)a2->std.sin6_family;
if (result) {
return result;
}

if (a1->_type == AF_INET) {
- result = memcmp(a1->_addr, &a2->v4.sin_addr, 4);
+ result = memcmp(a1->_addr, &a2->v4.sin6_addr, 4);
Expand Down Expand Up @@ -317,7 +317,7 @@ index dedab2c..fdc3e82 100644
return dst;
}
@@ -795,7 +807,7 @@ inet_pton(int af, const char *src, void *dst)

sock = (union netaddr_socket *)res->ai_addr;
if (af == AF_INET) {
- memcpy(dst, &sock->v4.sin_addr, 4);
Expand All @@ -327,11 +327,11 @@ index dedab2c..fdc3e82 100644
memcpy(dst, &sock->v6.sin6_addr, 16);
@@ -928,7 +940,7 @@ _subnetmask_to_prefixlen(const char *src) {
}

/* transform into host byte order */
- v4 = ntohl(v4);
+ v4 = NTOHL(v4);

shift = 0xffffffff;
for (len = 31; len >= 0; len--) {
diff --git a/src-api/common/netaddr.h b/src-api/common/netaddr.h
Expand All @@ -340,8 +340,8 @@ index 78fd5b4..cfba7a9 100644
+++ b/src-api/common/netaddr.h
@@ -43,18 +43,26 @@
#define NETADDR_H_


-#ifndef _WIN32
+#if (!defined(_WIN32)) && (!defined(RIOT))
#include <arpa/inet.h>
Expand All @@ -354,10 +354,10 @@ index 78fd5b4..cfba7a9 100644
+#ifdef _WIN32
#include <winsock2.h>
#include <ws2tcpip.h>

#define IF_NAMESIZE 16
#endif

+#ifdef RIOT
+#include "destiny/socket.h"
+#define INET_ADDRSTRLEN (16)
Expand All @@ -366,7 +366,7 @@ index 78fd5b4..cfba7a9 100644
+
#include <assert.h>
#include <string.h>

@@ -97,10 +105,10 @@ struct netaddr {
* to all variants without casting and compiler warnings.
*/
Expand All @@ -380,7 +380,7 @@ index 78fd5b4..cfba7a9 100644
+ sockaddr6_t std;
+ sockaddr6_t storage;
};

/**
@@ -337,7 +345,7 @@ netaddr_set_prefix_length(struct netaddr *n, uint8_t prefix_len) {
*/
Expand All @@ -389,7 +389,7 @@ index 78fd5b4..cfba7a9 100644
- return s->std.sa_family;
+ return s->std.sin6_family;
}

#endif /* NETADDR_H_ */
diff --git a/src-api/rfc5444/Makefile b/src-api/rfc5444/Makefile
new file mode 100644
Expand Down Expand Up @@ -472,9 +472,9 @@ index 4b3e04d..6b52f72 100644
#include <sys/socket.h>
#include <arpa/inet.h>
+#endif

#include "common/netaddr.h"
#include "rfc5444/rfc5444_reader.h"
--
--
1.8.3.2

24 changes: 12 additions & 12 deletions pkg/oonf_api/0002-port-tests-to-riot.patch
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ index 0000000..c286ad3
+####
+#### The Sample Filesystem Layout is:
+#### /this makefile
+#### ../../RIOT
+#### ../../RIOT
+#### ../../boards for board definitions (if you have one or more)
+####
+####
+
+# name of your project
+export PROJECT = %TESTNAME%
Expand All @@ -50,7 +50,7 @@ index 0000000..c286ad3
+
+export CFLAGS = -DRIOT -DOONF_LOG_INFO -DOONF_LOG_DEBUG_INFO
+
+## Modules to include.
+## Modules to include.
+
+USEMODULE += auto_init
+USEMODULE += config
Expand Down Expand Up @@ -95,17 +95,17 @@ index b5ee8c0..e4e5b26 100644
--- a/tests/common/test_common_avl.c
+++ b/tests/common/test_common_avl.c
@@ -816,17 +816,17 @@ static void random_delete(uint32_t *array, int count) {

/* insert/remove 1000's random numbers into tree and check if everything is okay */
static void test_random_insert(void) {
- uint32_t array[1000];
+ uint32_t array[100];
struct tree_element *e, *ptr;

srand(0);
START_TEST();
avl_init(&head, avl_comp_uint32, true);

- random_insert(array, 1000);
- random_delete(array, 500);
- random_insert(array, 400);
Expand All @@ -114,7 +114,7 @@ index b5ee8c0..e4e5b26 100644
+ random_delete(array, 50);
+ random_insert(array, 40);
+ random_delete(array, 60);

avl_remove_all_elements(&head, e, node, ptr) {
free(e);
diff --git a/tests/cunit/Makefile b/tests/cunit/Makefile
Expand All @@ -137,9 +137,9 @@ index 0000000..8a0452d
+####
+#### The Sample Filesystem Layout is:
+#### /this makefile
+#### ../../RIOT
+#### ../../RIOT
+#### ../../boards for board definitions (if you have one or more)
+####
+####
+
+# name of your project
+export PROJECT = %TESTNAME%
Expand All @@ -154,7 +154,7 @@ index 0000000..8a0452d
+
+export CFLAGS = -DRIOT -DOONF_LOG_INFO -DOONF_LOG_DEBUG_INFO
+
+## Modules to include.
+## Modules to include.
+
+USEMODULE += auto_init
+USEMODULE += config
Expand Down Expand Up @@ -200,7 +200,7 @@ index df203fd..29daff6 100644
+
#include <assert.h>
#include <stdio.h>
--

--
1.8.3.2

12 changes: 6 additions & 6 deletions pkg/oonf_api/0003-port-example-to-riot.patch
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ index 0000000..42f9a55
+####
+#### The Sample Filesystem Layout is:
+#### /this makefile
+#### ../../RIOT
+####
+#### ../../RIOT
+####
+
+# name of your project
+export PROJECT := $(shell basename $(CURDIR))
Expand All @@ -37,7 +37,7 @@ index 0000000..42f9a55
+
+export CFLAGS = -DRIOT -DOONF_LOG_INFO -DOONF_LOG_DEBUG_INFO
+
+## Modules to include.
+## Modules to include.
+
+USEMODULE += auto_init
+USEMODULE += config
Expand All @@ -60,7 +60,7 @@ index 9cca869..c786d19 100644
@@ -42,6 +42,11 @@
#include <string.h>
#include <stdio.h>

+#ifdef RIOT
+#include "net_help.h"
+#define ntohl(val) NTOHL(val)
Expand All @@ -76,7 +76,7 @@ index 59bb741..d05c48c 100644
@@ -42,6 +42,11 @@
#include <string.h>
#include <stdio.h>

+#ifdef RIOT
+#include "net_help.h"
+#define htonl(val) HTONL(val)
Expand All @@ -85,6 +85,6 @@ index 59bb741..d05c48c 100644
#include "common/common_types.h"
#include "common/netaddr.h"
#include "rfc5444/rfc5444_writer.h"
--
--
1.8.3.2

11 changes: 3 additions & 8 deletions pkg/oonf_api/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,13 @@ all: patch
make $(BINDIR)$(MODULE).a

patch: $(CURDIR)/$(PKG_NAME)/Makefile
# Dependancy might be changed accordingly though we think the Makefile
# will be the first thing you want to change
#
# Here might not happen anything besides dependancy checks

$(CURDIR)/$(PKG_NAME)/Makefile: $(CURDIR)/$(PKG_NAME)
# Here you apply your patch.
$(foreach patch,$(shell ls [0-9][0-9][0-9][0-9]*.patch),cd "$<" && git am "../$(patch)";)
$(foreach patch,$(shell ls [0-9][0-9][0-9][0-9]*.patch),cd "$<" && git am "../$(patch)" || { git am --abort; exit 1; };)

$(CURDIR)/$(PKG_NAME)/:
$(CURDIR)/$(PKG_NAME):
git clone $(PKG_URL) $@ && \
cd $@ && git checkout $(PKG_VERSION)
cd $@ && git reset --hard $(PKG_VERSION)

clean::
# Reset package to checkout state.
Expand Down

0 comments on commit 872ce5f

Please sign in to comment.