Upgrade to GCC 4.8 for Linux standalone build.
This patch modifies android-configure.sh to use the prebuilt 4.8
Linux host toolchain when available.
+ Fix a few sources to get rid of ugly compiler warnings.
Note: this works best with the following patch for the GPU
emulation libraries:
https://android-review.googlesource.com/#/c/92482/1
Change-Id: I7ae1c6cf2d58c2902affa36886bfa87956da622d
diff --git a/android-configure.sh b/android-configure.sh
index d28209a..65f08c5 100755
--- a/android-configure.sh
+++ b/android-configure.sh
@@ -104,11 +104,15 @@
fi
# On Linux, try to use our prebuilt toolchain to generate binaries
-# that are compatible with Ubuntu 8.04
+# that are compatible with Ubuntu 10.4
if [ -z "$CC" -a -z "$OPTION_CC" -a "$HOST_OS" = linux ] ; then
- PROBE_HOST_CC=`dirname $0`/../../prebuilts/gcc/linux-x86/host/x86_64-linux-glibc2.11-4.6/bin/x86_64-linux-gcc
- if [ ! -f "$PROBE_HOST_CC" ] ; then
- PROBE_HOST_CC=`dirname $0`/../../prebuilts/tools/gcc-sdk/gcc
+ PREBUILTS_HOST_GCC=$(dirname $0)/../../prebuilts/gcc/linux-x86/host
+ PROBE_HOST_CC=$PREBUILTS_HOST_GCC/x86_64-linux-glibc2.11-4.8/bin/x86_64-linux-gcc
+ if [ ! -f "$PROBE_HOST_CC" ]; then
+ PROBE_HOST_CC=$PREBUILTS_HOST_GCC/x86_64-linux-glibc2.11-4.6/bin/x86_64-linux-gcc
+ if [ ! -f "$PROBE_HOST_CC" ] ; then
+ PROBE_HOST_CC=$(dirname $0)/../../prebuilts/tools/gcc-sdk/gcc
+ fi
fi
if [ -f "$PROBE_HOST_CC" ] ; then
echo "Using prebuilt toolchain: $PROBE_HOST_CC"
diff --git a/distrib/elff/elff/dwarf_die.cc b/distrib/elff/elff/dwarf_die.cc
index 38280da..9d59c23 100644
--- a/distrib/elff/elff/dwarf_die.cc
+++ b/distrib/elff/elff/dwarf_die.cc
@@ -212,7 +212,7 @@
Elf_Xword low, high;
while (elf_file()->get_range<Elf_Xword>(off, &low, &high) &&
(low != 0 || high != 0)) {
- printf(" %08" FMT_I64 "X - %08" FMT_I64 "X\n",
+ printf(" %08llX - %08llX\n",
(unsigned long long)low, (unsigned long long)high);
off += 16;
}
diff --git a/distrib/elff/elff/elf_defs.h b/distrib/elff/elff/elf_defs.h
index 8ce8f73..acc586a 100644
--- a/distrib/elff/elff/elf_defs.h
+++ b/distrib/elff/elff/elf_defs.h
@@ -28,24 +28,18 @@
* p - Pointer to increment.
* n - Number of bytes to increment the pointer with.
*/
-#define INC_PTR(p, n) (reinterpret_cast<uint8_t*>(p) + (n))
+static inline uint8_t* INC_PTR(void* p, size_t n) {
+ return reinterpret_cast<uint8_t*>(p) + n;
+}
/* Increments a constant pointer by n bytes.
* Param:
* p - Pointer to increment.
* n - Number of bytes to increment the pointer with.
*/
-#define INC_CPTR(p, n) (reinterpret_cast<const uint8_t*>(p) + (n))
-
-/* Increments a pointer of a given type by n bytes.
- * Param:
- * T - Pointer type
- * p - Pointer to increment.
- * n - Number of bytes to increment the pointer with.
- */
-#define INC_PTR_T(T, p, n) \
- reinterpret_cast<T*> \
- (reinterpret_cast<uint8_t*>(p) + (n))
+static inline const uint8_t* INC_CPTR(const void* p, size_t n) {
+ return reinterpret_cast<const uint8_t*>(p) + n;
+}
/* Increments a constant pointer of a given type by n bytes.
* Param:
@@ -53,9 +47,19 @@
* p - Pointer to increment.
* n - Number of bytes to increment the pointer with.
*/
-#define INC_CPTR_T(T, p, n) \
- reinterpret_cast<const T*> \
- (reinterpret_cast<const uint8_t*>(p) + (n))
+template <typename T>
+static inline const T* INC_CPTR_T_INNER_TEMPLATE(const void* p, size_t n) {
+ union {
+ const void* p;
+ const uint8_t* p8;
+ const T* pt;
+ } u;
+ u.p = p;
+ u.p8 += n;
+ return u.pt;
+}
+
+#define INC_CPTR_T(T, p, n) INC_CPTR_T_INNER_TEMPLATE<T>(p, n)
/* Calculates number of entries in a static array.
* Param:
@@ -71,7 +75,7 @@
* T - Structure (or class) type.
* f - Name of a field (member variable) for this structure (or class).
*/
-#define ELFF_FIELD_OFFSET(T, f) ((size_t)(size_t*)&(((T *)0)->f))
+#define ELFF_FIELD_OFFSET(T, f) offsetof(T, f)
//=============================================================================
// Inline routines.
@@ -132,12 +136,4 @@
return get_byte(&tmp, 0) == 0xFF;
}
-/* Use in printf() statements to dump 64-bit values
- */
-#ifdef _WIN32
-# define FMT_I64 "I64"
-#else
-# define FMT_I64 "ll"
-#endif
-
#endif // ELFF_ELF_DEFS_H_
diff --git a/hw/net/ne2000.c b/hw/net/ne2000.c
index d4ca0d5..9f0dd0b 100644
--- a/hw/net/ne2000.c
+++ b/hw/net/ne2000.c
@@ -504,7 +504,7 @@
addr &= ~1; /* XXX: check exact behaviour if not even */
if (addr < 32 ||
(addr >= NE2000_PMEM_START && addr < NE2000_MEM_SIZE)) {
- *(uint16_t *)(s->mem + addr) = cpu_to_le16(val);
+ stw_le_p(s->mem + addr, val);
}
}
@@ -533,7 +533,7 @@
addr &= ~1; /* XXX: check exact behaviour if not even */
if (addr < 32 ||
(addr >= NE2000_PMEM_START && addr < NE2000_MEM_SIZE)) {
- return le16_to_cpu(*(uint16_t *)(s->mem + addr));
+ return lduw_le_p(s->mem + addr);
} else {
return 0xffff;
}
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index d8c5b22..80ab1f4 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -349,7 +349,7 @@
} else {
addr = 0x10 + region_num * 4;
}
- *(uint32_t *)(pci_dev->config + addr) = cpu_to_le32(type);
+ pci_set_long(pci_dev->config + addr, type);
}
static void pci_update_mappings(PCIDevice *d)
@@ -358,7 +358,7 @@
int cmd, i;
uint32_t last_addr, new_addr, config_ofs;
- cmd = le16_to_cpu(*(uint16_t *)(d->config + PCI_COMMAND));
+ cmd = pci_get_word(d->config + PCI_COMMAND);
for(i = 0; i < PCI_NUM_REGIONS; i++) {
r = &d->io_regions[i];
if (i == PCI_ROM_SLOT) {
@@ -369,8 +369,7 @@
if (r->size != 0) {
if (r->type & PCI_ADDRESS_SPACE_IO) {
if (cmd & PCI_COMMAND_IO) {
- new_addr = le32_to_cpu(*(uint32_t *)(d->config +
- config_ofs));
+ new_addr = pci_get_long(d->config + config_ofs);
new_addr = new_addr & ~(r->size - 1);
last_addr = new_addr + r->size - 1;
/* NOTE: we have only 64K ioports on PC */
@@ -383,8 +382,7 @@
}
} else {
if (cmd & PCI_COMMAND_MEMORY) {
- new_addr = le32_to_cpu(*(uint32_t *)(d->config +
- config_ofs));
+ new_addr = pci_get_long(d->config + config_ofs);
/* the ROM slot has a specific enable bit */
if (i == PCI_ROM_SLOT && !(new_addr & 1))
goto no_mem_map;
@@ -441,13 +439,13 @@
default:
case 4:
if (address <= 0xfc) {
- val = le32_to_cpu(*(uint32_t *)(d->config + address));
+ val = pci_get_long(d->config + address);
break;
}
/* fall through */
case 2:
if (address <= 0xfe) {
- val = le16_to_cpu(*(uint16_t *)(d->config + address));
+ val = pci_get_word(d->config + address);
break;
}
/* fall through */
@@ -485,7 +483,7 @@
val &= ~(r->size - 1);
val |= r->type;
}
- *(uint32_t *)(d->config + address) = cpu_to_le32(val);
+ pci_set_long(d->config + address, val);
pci_update_mappings(d);
return;
}
@@ -729,7 +727,7 @@
monitor_printf(mon, " Bus %2d, device %3d, function %d:\n",
d->bus->bus_num, d->devfn >> 3, d->devfn & 7);
- class = le16_to_cpu(*((uint16_t *)(d->config + PCI_CLASS_DEVICE)));
+ class = pci_get_word(d->config + PCI_CLASS_DEVICE);
monitor_printf(mon, " ");
desc = pci_class_descriptions;
while (desc->desc && class != desc->class)