• Skip to sidebar navigation
  • Skip to content

Bitbucket

  • More
    ProjectsRepositories
  • Help
    • Online help
    • Learn Git
    • Welcome to Bitbucket
    • Keyboard shortcuts
  • Log In
Alexander Dahl
  1. Alexander Dahl

buildroot

Public
Actions
  • Clone
  • Compare

Learn more about cloning repositories

You have read-only access

Navigation
  • Source
  • Commits
  • Branches
  • All Branches Graph
  • Forks
  1. Alexander Dahl
  2. buildroot

Source

buildroot/package/android-tools/0006-fix-big-endian-build.patch
Yann E. MORINYann E. MORIN committed 6e8617f222418 Aug 2016
Raw file
Source viewDiff to previous
xxxxxxxxxx
 
1
Fix build on big endian systems
2
​
3
The usb_linux_client.c file defines cpu_to_le16/32 by using the C
4
library htole16/32 function calls. However, cpu_to_le16/32 are used
5
when initializing structures, i.e in a context where a function call
6
is not allowed.
7
​
8
It works fine on little endian systems because htole16/32 are defined
9
by the C library as no-ops. But on big-endian systems, they are
10
actually doing something, which might involve calling a function,
11
causing build failures.
12
​
13
To solve this, we simply open-code cpu_to_le16/32 in a way that allows
14
them to be used when initializing structures.
15
​
16
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
17
​
18
Index: b/core/adb/usb_linux_client.c
19
===================================================================
20
--- a/core/adb/usb_linux_client.c
21
+++ b/core/adb/usb_linux_client.c
22
@@ -34,8 +34,15 @@
23
 #define MAX_PACKET_SIZE_FS 64
24
 #define MAX_PACKET_SIZE_HS 512
25
 
26
-#define cpu_to_le16(x)  htole16(x)
27
-#define cpu_to_le32(x)  htole32(x)
28
+#if __BYTE_ORDER == __LITTLE_ENDIAN
29
+# define cpu_to_le16(x) (x)
30
+# define cpu_to_le32(x) (x)
31
+#else
32
+# define cpu_to_le16(x) ((((x) >> 8) & 0xffu) | (((x) & 0xffu) << 8))
33
+# define cpu_to_le32(x) \
34
+   ((((x) & 0xff000000u) >> 24) | (((x) & 0x00ff0000u) >>  8) | \
35
+    (((x) & 0x0000ff00u) <<  8) | (((x) & 0x000000ffu) << 24))
36
+#endif
37
 
38
 struct usb_handle
39
 {
40
Index: b/core/adbd/usb_linux_client.c
41
===================================================================
42
--- a/core/adbd/usb_linux_client.c
43
+++ b/core/adbd/usb_linux_client.c
44
@@ -34,8 +34,15 @@
45
 #define MAX_PACKET_SIZE_FS 64
46
 #define MAX_PACKET_SIZE_HS 512
47
 
48
-#define cpu_to_le16(x)  htole16(x)
49
-#define cpu_to_le32(x)  htole32(x)
50
+#if __BYTE_ORDER == __LITTLE_ENDIAN
51
+# define cpu_to_le16(x) (x)
52
+# define cpu_to_le32(x) (x)
53
+#else
54
+# define cpu_to_le16(x) ((((x) >> 8) & 0xffu) | (((x) & 0xffu) << 8))
55
+# define cpu_to_le32(x) \
56
+   ((((x) & 0xff000000u) >> 24) | (((x) & 0x00ff0000u) >>  8) | \
57
+    (((x) & 0x0000ff00u) <<  8) | (((x) & 0x000000ffu) << 24))
58
+#endif
59
 
60
 struct usb_handle
61
 {
  • Git repository management for enterprise teams powered by Atlassian Bitbucket
  • Atlassian Bitbucket v6.7.2
  • Documentation
  • Request a feature
  • About
  • Contact Atlassian
Atlassian

Everything looks good. We'll let you know here if there's anything you should know about.