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

Test for posix lib + newlib (also start to fix issues) #13685

Merged
merged 3 commits into from
Feb 23, 2019
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
1 change: 0 additions & 1 deletion include/posix/mqueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ extern "C" {
#endif

typedef void *mqd_t;
typedef unsigned int mode_t;

typedef struct mq_attr {
long mq_flags;
Expand Down
18 changes: 16 additions & 2 deletions include/posix/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,29 @@
extern "C" {
#endif


#ifndef __timespec_defined
#define __timespec_defined
struct timespec {
signed int tv_sec;
signed int tv_nsec;
signed int tv_sec;
signed int tv_nsec;
};
#endif

/* Older newlib's like 2.{0-2}.0 don't define any newlib version defines, only
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@galak, The proper fix for this would be the same as for mode_t - figure out the proper header belongs to, rely on newlib's existing definition there, and move def from posix/* to minimal/*. (Again, when we repeat that process a hundred of times, we'll find that we just recreated newlib headers in minimal. So, it's still not to late to say "POSIX and minimal don't plat well together, a [decent] libc is part of POSIX", and concentrate only on POSIX+newlib).

* __NEWLIB_H__ so we use that to decide if itimerspec was defined in
* sys/types.h w/o any protection. It appears sometime in the 2.3.0 version
* of newlib did itimerspec move out of sys/types.h, however version 2.3.0
* seems to report itself as __NEWLIB_MINOR__ == 2, where as 2.2.0 doesn't
* even define __NEWLIB_MINOR__ or __NEWLIB__
*/
#if !defined(__NEWLIB_H__) || (__NEWLIB__ >= 3) || \
(__NEWLIB__ == 2 && __NEWLIB_MINOR__ >= 2)
struct itimerspec {
struct timespec it_interval; /* Timer interval */
struct timespec it_value; /* Timer expiration */
};
#endif

struct timeval {
signed int tv_sec;
Expand Down
5 changes: 0 additions & 5 deletions include/posix/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ extern "C" {
#ifdef CONFIG_POSIX_API
#include <fs.h>

#ifndef _MODE_T_DECLARED
typedef unsigned int mode_t;
#define _MODE_T_DECLARED
#endif

/* File related operations */
extern int open(const char *name, int flags);
extern int close(int file);
Expand Down
2 changes: 2 additions & 0 deletions lib/libc/minimal/include/sys/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#ifndef ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_SYS_TYPES_H_
#define ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_SYS_TYPES_H_

typedef unsigned int mode_t;

#if !defined(__ssize_t_defined)
#define __ssize_t_defined

Expand Down
13 changes: 10 additions & 3 deletions tests/posix/common/testcase.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
common:
tags: posix
min_ram: 64
arch_exclude: posix
tests:
portability.posix:
tags: posix
min_ram: 64
arch_exclude: posix
extra_configs:
- CONFIG_NEWLIB_LIBC=n
portability.posix.newlib:
filter: TOOLCHAIN_HAS_NEWLIB == 1
extra_configs:
- CONFIG_NEWLIB_LIBC=y
14 changes: 10 additions & 4 deletions tests/posix/fs/testcase.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
common:
arch_exclude: nios2 posix
min_ram: 128
tags: posix filesystem
tests:
portability.posix:
arch_exclude: nios2 posix
min_ram: 128
tags: posix filesystem

extra_configs:
- CONFIG_NEWLIB_LIBC=n
portability.posix.newlib:
filter: TOOLCHAIN_HAS_NEWLIB == 1
extra_configs:
- CONFIG_NEWLIB_LIBC=y