Skip to contentSkip to conversation

sandbox-unaligned: better usement of ifdef

PATCH Applied Alexander Aring 2 participants 4 messages Sep 11, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 sandbox-unaligned: better usement of ifdef

GCC versions below 4.6 don't set __BYTE_ORDER__ with __ORDER_LITTLE_ENDIAN__. So it's better to use __BYTE_ORDER and __LITTLE_ENDIAN instead.

---
 arch/sandbox/include/asm/unaligned.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sandbox/include/asm/unaligned.h +1 -1
index 07c1ae4..d02da6e 100644
@@ -8,7 +8,7 @@
 #include <linux/unaligned/access_ok.h>
 #include <linux/unaligned/generic.h>
 
-#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+#if __BYTE_ORDER == __LITTLE_ENDIAN
 #define get_unaligned __get_unaligned_le
 #define put_unaligned __put_unaligned_le
 #else
Signature · 7 lines
1.7.12


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

PATCH 2/3 sandbox: fix posix_types

Fix setting of size_t ssize_t and ptrdiff_t for 32 bit and 64 bit systems.

---
 arch/sandbox/include/asm/posix_types.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
arch/sandbox/include/asm/posix_types.h +14 -0
index 4345141..6985b8e 100644
@@ -15,9 +15,23 @@ typedef int		__kernel_pid_t;
 typedef unsigned short	__kernel_ipc_pid_t;
 typedef unsigned short	__kernel_uid_t;
 typedef unsigned short	__kernel_gid_t;
+/*
+ * Most 32 bit architectures use "unsigned int" size_t,
+ * and all 64 bit architectures use "unsigned long" size_t.
+ *
+ * TODO: It's not clean to use __x86_64__ here. It's better
+ * to check on __BITS_PER_LONG here. But this is wrong set in
+ * arch/sandbox/include/asm/types.h.
+ */
+#ifdef __x86_64__
 typedef unsigned long	__kernel_size_t;
 typedef long		__kernel_ssize_t;
+typedef long		__kernel_ptrdiff_t;
+#else
+typedef unsigned int	__kernel_size_t;
+typedef int		__kernel_ssize_t;
 typedef int		__kernel_ptrdiff_t;
+#endif
 typedef long		__kernel_time_t;
 typedef long		__kernel_suseconds_t;
 typedef long		__kernel_clock_t;
Signature · 7 lines
1.7.12


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

PATCH 3/3 sandbox: add missed case statement

In reply to Alexander Aring

Add missed case statement to ignore 'i' parameter
in first getopt loop.

---
 arch/sandbox/os/common.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
arch/sandbox/os/common.c +7 -1
index e296574..d2aea38 100644
@@ -306,6 +306,8 @@ int main(int argc, char *argv[])
 		case 'm':
 			malloc_size = strtoul(optarg, NULL, 0);
 			break;
+		case 'i':
+			break;
 		case 'e':
 			sprintf(str, "env%d", envno);
 			ret = add_image(optarg, str);
@@ -343,7 +345,11 @@ int main(int argc, char *argv[])
 	}
 	mem_malloc_init(ram, ram + malloc_size - 1);
 
-	/* reset getopt */
+	/*
+	 * Reset getopt.
+	 * We need to run a second getopt to count -i parameters.
+	 * This is for /dev/fd# devices.
+	 */
 	optind = 1;
 
 	while (1) {
Signature · 7 lines
1.7.12


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Applied
#3 lore raw
In reply to Alexander Aring
Quoted 5 lines · Alexander Aring

GCC versions below 4.6 don't set __BYTE_ORDER__ with __ORDER_LITTLE_ENDIAN__. So it's better to use __BYTE_ORDER and __LITTLE_ENDIAN instead.

These fix some warnings on a 32bit sandbox build also for me.

Thanks, applied.

Sascha

Quoted 26 lines
---
 arch/sandbox/include/asm/unaligned.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sandbox/include/asm/unaligned.h +1 -1
index 07c1ae4..d02da6e 100644
@@ -8,7 +8,7 @@
 #include <linux/unaligned/access_ok.h>
 #include <linux/unaligned/generic.h>
 
-#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+#if __BYTE_ORDER == __LITTLE_ENDIAN
 #define get_unaligned __get_unaligned_le
 #define put_unaligned __put_unaligned_le
 #else
Signature · 7 lines
1.7.12


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox