DTC Patch for Cygwin

Matt Tyrlik tyrlik at us.ibm.com
Sat Sep 22 01:26:04 EST 2007


Changes required to compile DTC under Cygwin

===================================================================
--- dtc-org.orig/tests/supernode_atdepth_offset.c
+++ dtc-org/tests/supernode_atdepth_offset.c
@@ -63,8 +63,11 @@ int path_prefix(const char *path, int de
                return 1;

        p = path;
-       for (i = 0; i < depth; i++)
-               p = strchrnul(p+1, '/');
+       for (i = 0; i < depth; i++) {
+               p = strchr(p+1, '/');
+               if (!p)
+                       p = path + strlen(path);
+       }

        return p - path;
 }
Index: dtc-org/tests/testutils.c
===================================================================
--- dtc-org.orig/tests/testutils.c
+++ dtc-org/tests/testutils.c
@@ -52,10 +52,9 @@ static void sigint_handler(int signum, s
 void test_init(int argc, char *argv[])
 {
        int err;
-       struct sigaction sa_int = {
-               .sa_sigaction = sigint_handler,
-       };
+       struct sigaction sa_int;

+       sa_int.sa_sigaction = sigint_handler,
        test_name = argv[0];

        err = sigaction(SIGINT, &sa_int, NULL);
Index: dtc-org/tests/trees.S
===================================================================
--- dtc-org.orig/tests/trees.S
+++ dtc-org/tests/trees.S
@@ -17,10 +17,16 @@
        .byte   ((val) >> 8) & 0xff ; \
        .byte   (val) & 0xff

+#ifdef __CYGWIN__
+#define TREE_SYMBOL(tree)      __##tree
+#else
+#define TREE_SYMBOL(tree)      _##tree
+#endif
+
 #define TREE_HDR(tree) \
        .balign 4               ; \
-       .globl  _##tree         ; \
-_##tree:       \
+       .globl TREE_SYMBOL(tree); \
+TREE_SYMBOL(tree):     \
 tree:  \
        FDTLONG(FDT_MAGIC)      ; \
        FDTLONG(tree##_end - tree) ; \
Index: dtc-org/tests/tests.h
===================================================================
--- dtc-org.orig/tests/tests.h
+++ dtc-org/tests/tests.h
@@ -130,4 +130,15 @@ const void *check_getprop(void *fdt, int
 void *load_blob_arg(int argc, char *argv[]);
 void save_blob(const char *filename, void *blob);

+#ifndef GLIBC
+#define strndupa(my_str, my_len) \
+       ({ \
+               char *new_str=alloca((my_len) + 1); \
+               strncpy(new_str, my_str, my_len); \
+               new_str[my_len]='\0'; \
+               new_str; \
+       })
+
+#endif
+
 #endif /* _TESTS_H */


Matt Tyrlik
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ozlabs.org/pipermail/linuxppc-dev/attachments/20070921/8e89b12b/attachment.htm>


More information about the Linuxppc-dev mailing list