1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
|
Description: patch to work with libc 1.8.0 and gcc 4.7
Bug: http://andybrown.me.uk/wk/2012/04/28/avr-gcc-4-7-0-and-avr-libc-1-8-0-compiled-for-windows/
Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=677294
Author: Andy Brown <http://andybrown.me.uk/wk/>
Index: arduino/hardware/arduino/cores/arduino/HardwareSerial.cpp
===================================================================
--- arduino.orig/hardware/arduino/cores/arduino/HardwareSerial.cpp 2013-03-18 22:15:41.175612317 -0400
+++ arduino/hardware/arduino/cores/arduino/HardwareSerial.cpp 2013-03-18 22:15:41.167612317 -0400
@@ -1,3 +1,5 @@
+#define __AVR_LIBC_DEPRECATED_ENABLE__
+
/*
HardwareSerial.cpp - Hardware serial library for Wiring
Copyright (c) 2006 Nicholas Zambetti. All right reserved.
Index: arduino/hardware/arduino/cores/arduino/IPAddress.cpp
===================================================================
--- arduino.orig/hardware/arduino/cores/arduino/IPAddress.cpp 2013-03-18 22:15:41.175612317 -0400
+++ arduino/hardware/arduino/cores/arduino/IPAddress.cpp 2013-03-18 22:15:41.167612317 -0400
@@ -4,42 +4,42 @@
IPAddress::IPAddress()
{
- memset(_address, 0, sizeof(_address));
+ memset(_address.a8, 0, sizeof(_address));
}
IPAddress::IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet)
{
- _address[0] = first_octet;
- _address[1] = second_octet;
- _address[2] = third_octet;
- _address[3] = fourth_octet;
+ _address.a8[0] = first_octet;
+ _address.a8[1] = second_octet;
+ _address.a8[2] = third_octet;
+ _address.a8[3] = fourth_octet;
}
IPAddress::IPAddress(uint32_t address)
{
- memcpy(_address, &address, sizeof(_address));
+ _address.a32=address;
}
IPAddress::IPAddress(const uint8_t *address)
{
- memcpy(_address, address, sizeof(_address));
+ memcpy(_address.a8, address, sizeof(_address));
}
IPAddress& IPAddress::operator=(const uint8_t *address)
{
- memcpy(_address, address, sizeof(_address));
+ memcpy(_address.a8, address, sizeof(_address));
return *this;
}
IPAddress& IPAddress::operator=(uint32_t address)
{
- memcpy(_address, (const uint8_t *)&address, sizeof(_address));
+ _address.a32=address;
return *this;
}
bool IPAddress::operator==(const uint8_t* addr)
{
- return memcmp(addr, _address, sizeof(_address)) == 0;
+ return memcmp(addr, _address.a8, sizeof(_address)) == 0;
}
size_t IPAddress::printTo(Print& p) const
@@ -47,10 +47,10 @@
size_t n = 0;
for (int i =0; i < 3; i++)
{
- n += p.print(_address[i], DEC);
+ n += p.print(_address.a8[i], DEC);
n += p.print('.');
}
- n += p.print(_address[3], DEC);
+ n += p.print(_address.a8[3], DEC);
return n;
}
Index: arduino/hardware/arduino/cores/arduino/IPAddress.h
===================================================================
--- arduino.orig/hardware/arduino/cores/arduino/IPAddress.h 2013-03-18 22:15:41.175612317 -0400
+++ arduino/hardware/arduino/cores/arduino/IPAddress.h 2013-03-18 22:15:41.167612317 -0400
@@ -32,12 +32,16 @@
class IPAddress : public Printable {
private:
- uint8_t _address[4]; // IPv4 address
+ union {
+ uint8_t a8[4]; // IPv4 address
+ uint32_t a32;
+ } _address;
+
// Access the raw byte array containing the address. Because this returns a pointer
// to the internal structure rather than a copy of the address this function should only
// be used when you know that the usage of the returned uint8_t* will be transient and not
// stored.
- uint8_t* raw_address() { return _address; };
+ uint8_t* raw_address() { return _address.a8; }
public:
// Constructors
@@ -48,13 +52,13 @@
// Overloaded cast operator to allow IPAddress objects to be used where a pointer
// to a four-byte uint8_t array is expected
- operator uint32_t() { return *((uint32_t*)_address); };
- bool operator==(const IPAddress& addr) { return (*((uint32_t*)_address)) == (*((uint32_t*)addr._address)); };
+ operator uint32_t() { return _address.a32; }
+ bool operator==(const IPAddress& addr) { return _address.a32 == addr._address.a32; };
bool operator==(const uint8_t* addr);
// Overloaded index operator to allow getting and setting individual octets of the address
- uint8_t operator[](int index) const { return _address[index]; };
- uint8_t& operator[](int index) { return _address[index]; };
+ uint8_t operator[](int index) const { return _address.a8[index]; };
+ uint8_t& operator[](int index) { return _address.a8[index]; };
// Overloaded copy operators to allow initialisation of IPAddress objects from other types
IPAddress& operator=(const uint8_t *address);
Index: arduino/hardware/arduino/cores/arduino/Print.cpp
===================================================================
--- arduino.orig/hardware/arduino/cores/arduino/Print.cpp 2013-03-18 22:15:41.175612317 -0400
+++ arduino/hardware/arduino/cores/arduino/Print.cpp 2013-03-18 22:15:41.167612317 -0400
@@ -41,7 +41,7 @@
size_t Print::print(const __FlashStringHelper *ifsh)
{
- const char PROGMEM *p = (const char PROGMEM *)ifsh;
+ const char * __attribute__((progmem)) p = (const char * ) ifsh;
size_t n = 0;
while (1) {
unsigned char c = pgm_read_byte(p++);
Index: arduino/libraries/Ethernet/Ethernet.cpp
===================================================================
--- arduino.orig/libraries/Ethernet/Ethernet.cpp 2013-03-18 22:15:41.175612317 -0400
+++ arduino/libraries/Ethernet/Ethernet.cpp 2013-03-18 22:15:41.167612317 -0400
@@ -62,9 +62,9 @@
{
W5100.init();
W5100.setMACAddress(mac);
- W5100.setIPAddress(local_ip._address);
- W5100.setGatewayIp(gateway._address);
- W5100.setSubnetMask(subnet._address);
+ W5100.setIPAddress(local_ip._address.a8);
+ W5100.setGatewayIp(gateway._address.a8);
+ W5100.setSubnetMask(subnet._address.a8);
_dnsServerAddress = dns_server;
}
|