net/socket: use the iterable section object constructor/iterator
The handcrafted allocation falls victim of misaligned structures due to toolchain padding which crashes the socket test code on 64-bit targets. Let's move it to the iterable section utility where those issues are already taken care of. Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
This commit is contained in:
parent
9d7da6a6f8
commit
66045b5db0
3 changed files with 6 additions and 15 deletions
|
@ -70,10 +70,9 @@
|
||||||
#if defined(CONFIG_NET_SOCKETS)
|
#if defined(CONFIG_NET_SOCKETS)
|
||||||
SECTION_PROLOGUE(net_socket_register,,)
|
SECTION_PROLOGUE(net_socket_register,,)
|
||||||
{
|
{
|
||||||
__net_socket_register_start = .;
|
_net_socket_register_list_start = .;
|
||||||
*(".net_socket_register.init")
|
KEEP(*(SORT_BY_NAME("._net_socket_register.*")))
|
||||||
KEEP(*(SORT_BY_NAME(".net_socket_register.init*")))
|
_net_socket_register_list_end = .;
|
||||||
__net_socket_register_end = .;
|
|
||||||
} GROUP_LINK_IN(ROMABLE_REGION)
|
} GROUP_LINK_IN(ROMABLE_REGION)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -760,9 +760,8 @@ struct net_socket_register {
|
||||||
(__net_socket_register_##socket_name)
|
(__net_socket_register_##socket_name)
|
||||||
|
|
||||||
#define NET_SOCKET_REGISTER(socket_name, _family, _is_supported, _handler) \
|
#define NET_SOCKET_REGISTER(socket_name, _family, _is_supported, _handler) \
|
||||||
static const struct net_socket_register \
|
static const Z_STRUCT_SECTION_ITERABLE(net_socket_register, \
|
||||||
(NET_SOCKET_GET_NAME(socket_name)) __used \
|
NET_SOCKET_GET_NAME(socket_name)) = { \
|
||||||
__attribute__((__section__(".net_socket_register.init"))) = { \
|
|
||||||
.family = _family, \
|
.family = _family, \
|
||||||
.is_supported = _is_supported, \
|
.is_supported = _is_supported, \
|
||||||
.handler = _handler, \
|
.handler = _handler, \
|
||||||
|
|
|
@ -21,9 +21,6 @@ LOG_MODULE_REGISTER(net_sock, CONFIG_NET_SOCKETS_LOG_LEVEL);
|
||||||
|
|
||||||
#include "sockets_internal.h"
|
#include "sockets_internal.h"
|
||||||
|
|
||||||
extern struct net_socket_register __net_socket_register_start[];
|
|
||||||
extern struct net_socket_register __net_socket_register_end[];
|
|
||||||
|
|
||||||
#define SET_ERRNO(x) \
|
#define SET_ERRNO(x) \
|
||||||
{ int _err = x; if (_err < 0) { errno = -_err; return -1; } }
|
{ int _err = x; if (_err < 0) { errno = -_err; return -1; } }
|
||||||
|
|
||||||
|
@ -133,11 +130,7 @@ int zsock_socket_internal(int family, int type, int proto)
|
||||||
|
|
||||||
int z_impl_zsock_socket(int family, int type, int proto)
|
int z_impl_zsock_socket(int family, int type, int proto)
|
||||||
{
|
{
|
||||||
struct net_socket_register *sock_family;
|
Z_STRUCT_SECTION_FOREACH(net_socket_register, sock_family) {
|
||||||
|
|
||||||
for (sock_family = __net_socket_register_start;
|
|
||||||
sock_family != __net_socket_register_end;
|
|
||||||
sock_family++) {
|
|
||||||
if (sock_family->family != family &&
|
if (sock_family->family != family &&
|
||||||
sock_family->family != AF_UNSPEC) {
|
sock_family->family != AF_UNSPEC) {
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue