Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define lwIP's s32/u32 to int #8560

Merged
merged 9 commits into from
May 15, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Define lwIP's s32/u32 to int
s32/u32 were previously defined as long,
but long can be 64 bits in host mode,
so this commit reduces valgrind complaints and increase coherency.
  • Loading branch information
d-a-v committed May 11, 2022
commit 548ca04bbf246432bbf819c547ca60b6bdf237ac
13 changes: 2 additions & 11 deletions cores/esp8266/IPAddress.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ class IPAddress: public Printable {
IPAddress(const IPAddress& from);
IPAddress(uint8_t first_octet, uint8_t second_octet, uint8_t third_octet, uint8_t fourth_octet);
IPAddress(uint32_t address) { ctor32(address); }
IPAddress(u32_t address) { ctor32(address); }
IPAddress(int address) { ctor32(address); }
IPAddress(const uint8_t *address);

Expand All @@ -80,16 +79,14 @@ class IPAddress: public Printable {
// to a four-byte uint8_t array is expected
operator uint32_t() const { return isV4()? v4(): (uint32_t)0; }
operator uint32_t() { return isV4()? v4(): (uint32_t)0; }
operator u32_t() const { return isV4()? v4(): (u32_t)0; }
operator u32_t() { return isV4()? v4(): (u32_t)0; }

bool isSet () const;
operator bool () const { return isSet(); } // <-
operator bool () { return isSet(); } // <- both are needed

// generic IPv4 wrapper to uint32-view like arduino loves to see it
const u32_t& v4() const { return ip_2_ip4(&_ip)->addr; } // for raw_address(const)
u32_t& v4() { return ip_2_ip4(&_ip)->addr; }
const uint32_t& v4() const { return ip_2_ip4(&_ip)->addr; } // for raw_address(const)
uint32_t& v4() { return ip_2_ip4(&_ip)->addr; }

bool operator==(const IPAddress& addr) const {
return ip_addr_cmp(&_ip, &addr._ip);
Expand All @@ -100,15 +97,9 @@ class IPAddress: public Printable {
bool operator==(uint32_t addr) const {
return isV4() && v4() == addr;
}
bool operator==(u32_t addr) const {
return isV4() && v4() == addr;
}
bool operator!=(uint32_t addr) const {
return !(isV4() && v4() == addr);
}
bool operator!=(u32_t addr) const {
return !(isV4() && v4() == addr);
}
bool operator==(const uint8_t* addr) const;

int operator>>(int n) const {
Expand Down
2 changes: 1 addition & 1 deletion libraries/ESP8266WiFi/src/WiFiServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ void WiFiServer::_discard(ClientContext* client) {
DEBUGV("WS:dis\r\n");
}

long WiFiServer::_s_accept(void *arg, tcp_pcb* newpcb, long err) {
err_t WiFiServer::_s_accept(void *arg, tcp_pcb* newpcb, err_t err) {
return reinterpret_cast<WiFiServer*>(arg)->_accept(newpcb, err);
}

Expand Down
9 changes: 5 additions & 4 deletions libraries/ESP8266WiFi/src/WiFiServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@
#define wifiserver_h

extern "C" {
#include "wl_definitions.h"
#include <wl_definitions.h>

struct tcp_pcb;
}

#include "Server.h"
#include "IPAddress.h"
#include <Server.h>
#include <IPAddress.h>
#include <lwip/err.h>

// lwIP-v2 backlog facility allows to keep memory safe by limiting the
// maximum number of incoming *pending clients*. Default number of possibly
Expand Down Expand Up @@ -106,7 +107,7 @@ class WiFiServer {
long _accept(tcp_pcb* newpcb, long err);
void _discard(ClientContext* client);

static long _s_accept(void *arg, tcp_pcb* newpcb, long err);
static err_t _s_accept(void *arg, tcp_pcb* newpcb, err_t err);
static void _s_discard(void* server, ClientContext* ctx);
};

Expand Down
2 changes: 1 addition & 1 deletion tests/host/common/user_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ extern "C"
{
auto test_ipv4
= lwip_ntohl(*(uint32_t*)&((struct sockaddr_in*)ifa->ifa_addr)->sin_addr);
mockverbose(" IPV4 (0x%08lx)", test_ipv4);
mockverbose(" IPV4 (0x%08x)", test_ipv4);
if ((test_ipv4 & 0xff000000) == 0x7f000000)
// 127./8
mockverbose(" (local, ignored)");
Expand Down
2 changes: 1 addition & 1 deletion tools/sdk/lwip2/builder
4 changes: 2 additions & 2 deletions tools/sdk/lwip2/include/lwip-err-t.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ typedef unsigned char u8_t;
typedef signed char s8_t;
typedef unsigned short u16_t;
typedef signed short s16_t;
typedef unsigned long u32_t;
typedef signed long s32_t;
typedef unsigned int u32_t;
typedef signed int s32_t;
typedef unsigned long mem_ptr_t;
#define LWIP_ERR_T s32_t
typedef uint32_t sys_prot_t;