Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
25 changes: 20 additions & 5 deletions include/zephyr/net/socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -1401,13 +1401,28 @@ struct net_socket_register {
* We have these includes here so that we do not need
* to change the applications that were only including
* zephyr/net/socket.h header file.
*
* Additionally, if non-zephyr-prefixed headers are used here,
* native_sim pulls in those from the host rather than Zephyr's.
*
* This should be removed when CONFIG_NET_SOCKETS_POSIX_NAMES is removed.
*/
#if defined(CONFIG_POSIX_API)
#include <arpa/inet.h>
#include <netdb.h>
#include <unistd.h>
#include <poll.h>
#include <sys/socket.h>
#if !defined(ZEPHYR_INCLUDE_POSIX_ARPA_INET_H_)
#include <zephyr/posix/arpa/inet.h>
#endif
#if !defined(ZEPHYR_INCLUDE_POSIX_NETDB_H_)
#include <zephyr/posix/netdb.h>
#endif
#if !defined(ZEPHYR_INCLUDE_POSIX_UNISTD_H_)
#include <zephyr/posix/unistd.h>
#endif
#if !defined(ZEPHYR_INCLUDE_POSIX_POLL_H_)
#include <zephyr/posix/poll.h>
#endif
#if !defined(ZEPHYR_INCLUDE_POSIX_SYS_SOCKET_H_)
#include <zephyr/posix/sys/socket.h>
#endif
#endif /* CONFIG_POSIX_API */

#endif /* ZEPHYR_INCLUDE_NET_SOCKET_H_ */
64 changes: 50 additions & 14 deletions include/zephyr/posix/posix_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,48 @@
extern "C" {
#endif

#if !defined(_DEV_T_DECLARED) && !defined(__dev_t_defined)
typedef int dev_t;
#define _DEV_T_DECLARED
#define __dev_t_defined
#endif

#if !defined(_INO_T_DECLARED) && !defined(__ino_t_defined)
typedef int ino_t;
#define _INO_T_DECLARED
#define __ino_t_defined
#endif

#if !defined(_NLINK_T_DECLARED) && !defined(__nlink_t_defined)
typedef unsigned short nlink_t;
#define _NLINK_T_DECLARED
#define __nlink_t_defined
#endif

#if !defined(_UID_T_DECLARED) && !defined(__uid_t_defined)
typedef unsigned short uid_t;
#define _UID_T_DECLARED
#define __uid_t_defined
#endif

#if !defined(_GID_T_DECLARED) && !defined(__gid_t_defined)
typedef unsigned short gid_t;
#define _GID_T_DECLARED
#define __gid_t_defined
#endif

#if !defined(_BLKSIZE_T_DECLARED) && !defined(__blksize_t_defined)
typedef unsigned long blksize_t;
#define _BLKSIZE_T_DECLARED
#define __blksize_t_defined
#endif

#if !defined(_BLKCNT_T_DECLARED) && !defined(__blkcnt_t_defined)
typedef unsigned long blkcnt_t;
#define _BLKCNT_T_DECLARED
#define __blkcnt_t_defined
#endif

#if !defined(CONFIG_ARCMWDT_LIBC)
typedef int pid_t;
#endif
Expand All @@ -45,12 +87,10 @@ struct pthread_attr {
uint32_t details[2];
};

#if defined(CONFIG_MINIMAL_LIBC) || defined(CONFIG_PICOLIBC) || defined(CONFIG_ARMCLANG_STD_LIBC) \
|| defined(CONFIG_ARCMWDT_LIBC)
#if !defined(CONFIG_NEWLIB_LIBC)
typedef struct pthread_attr pthread_attr_t;
#endif

BUILD_ASSERT(sizeof(pthread_attr_t) >= sizeof(struct pthread_attr));
#endif

typedef uint32_t pthread_t;
typedef uint32_t pthread_spinlock_t;
Expand All @@ -65,11 +105,10 @@ struct pthread_mutexattr {
unsigned char type: 2;
bool initialized: 1;
};
#if defined(CONFIG_MINIMAL_LIBC) || defined(CONFIG_PICOLIBC) || defined(CONFIG_ARMCLANG_STD_LIBC) \
|| defined(CONFIG_ARCMWDT_LIBC)
#if !defined(CONFIG_NEWLIB_LIBC)
typedef struct pthread_mutexattr pthread_mutexattr_t;
#endif
BUILD_ASSERT(sizeof(pthread_mutexattr_t) >= sizeof(struct pthread_mutexattr));
#endif

/* Condition variables */
typedef uint32_t pthread_cond_t;
Expand All @@ -78,11 +117,10 @@ struct pthread_condattr {
clockid_t clock;
};

#if defined(CONFIG_MINIMAL_LIBC) || defined(CONFIG_PICOLIBC) || defined(CONFIG_ARMCLANG_STD_LIBC) \
|| defined(CONFIG_ARCMWDT_LIBC)
#if !defined(CONFIG_NEWLIB_LIBC)
typedef struct pthread_condattr pthread_condattr_t;
#endif
BUILD_ASSERT(sizeof(pthread_condattr_t) >= sizeof(struct pthread_condattr));
#endif

/* Barrier */
typedef uint32_t pthread_barrier_t;
Expand All @@ -99,14 +137,12 @@ struct pthread_once {
bool flag;
};

#if defined(CONFIG_MINIMAL_LIBC) || defined(CONFIG_PICOLIBC) || defined(CONFIG_ARMCLANG_STD_LIBC) \
|| defined(CONFIG_ARCMWDT_LIBC)
#if !defined(CONFIG_NEWLIB_LIBC)
typedef uint32_t pthread_key_t;
typedef struct pthread_once pthread_once_t;
#endif

/* Newlib typedefs pthread_once_t as a struct with two ints */
BUILD_ASSERT(sizeof(pthread_once_t) >= sizeof(struct pthread_once));
#endif

#ifdef __cplusplus
}
Expand Down
37 changes: 1 addition & 36 deletions include/zephyr/posix/sys/stat.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,43 +36,8 @@ extern "C" {

#include <time.h>
#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/_timespec.h>

#ifndef _DEV_T_DECLARED
typedef int dev_t;
#define _DEV_T_DECLARED
#endif

#ifndef _INO_T_DECLARED
typedef int ino_t;
#define _INO_T_DECLARED
#endif

#ifndef _NLINK_T_DECLARED
typedef unsigned short nlink_t;
#define _NLINK_T_DECLARED
#endif

#ifndef _UID_T_DECLARED
typedef unsigned short uid_t;
#define _UID_T_DECLARED
#endif

#ifndef _GID_T_DECLARED
typedef unsigned short gid_t;
#define _GID_T_DECLARED
#endif

#ifndef _BLKSIZE_T_DECLARED
typedef unsigned long blksize_t;
#define _BLKSIZE_T_DECLARED
#endif

#ifndef _BLKCNT_T_DECLARED
typedef unsigned long blkcnt_t;
#define _BLKCNT_T_DECLARED
#endif
#include <zephyr/posix/posix_types.h>

/* dj's stat defines _STAT_H_ */
#ifndef _STAT_H_
Expand Down
21 changes: 14 additions & 7 deletions tests/posix/net/testcase.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
common:
depends_on: netif
# native_sim uses if_*() from the native libc
filter: not CONFIG_NATIVE_LIBC
integration_platforms:
- qemu_x86
min_ram: 16
platform_allow:
- qemu_x86
tags:
- iface
- net
- posix
tests:
portability.posix.net: {}
portability.posix.net:
# native_sim links to if_*() from the host libc which causes the test to crash immediately.
filter: not CONFIG_NATIVE_LIBC
portability.posix.net.cpp.native_sim:
# demonstrate that #75319 fixes the build error in #75849
tags:
- cpp
build_only: true
platform_allow:
- native_sim
extra_configs:
- CONFIG_CPP=y
- CONFIG_STD_CPP20=y
- CONFIG_REQUIRES_FULL_LIBCPP=y