Commit graph

17 commits

Author SHA1 Message Date
Nicholas Lowell
e4e9b9d8d7 posix: fix unistd.h extern C brace mismatch
If unistd.h is included while CONFIG_POSIX_API is not
defined, there is a mismatch of extern C braces that will
cause compile errors

Signed-off-by: Nicholas Lowell <nlowell@lexmark.com>
2020-02-11 17:50:21 +02:00
Robert Lubos
7fcd32b005 net: sockets: Fix gethostname socket.h/unistd.h clash
This commit fixes an issue observed with SimpleLink sockets with
multiple definitions of `gethostname` function. So far, the definition
within `socket.h` was not visible when offloading was enabled.

As this is no longer the case, and SimpleLink partially uses POSIX
subsystem, builds for this platform resulted in compilation error.

The issue was fixed by moving `gethostname` declaration in unistd.h
inside the `#ifdef CONFIG_POSIX_API` block.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-01-31 11:36:02 -05:00
Peter Bigot
ca6e3dcdc4 include/posix: rearrange for standard use of extern "C"
Consistently place C++ use of extern "C" after all include directives,
within the negative branch of _ASMLANGUAGE if used.

Background from issue #17997:

Declarations that use C linkage should be placed within extern "C"
so the language linkage is correct when the header is included by
a C++ compiler.

Similarly #include directives should be outside the extern "C" to
ensure the language-specific default linkage is applied to any
declarations provided by the included header.

See: https://en.cppreference.com/w/cpp/language/language_linkage
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2019-08-13 18:00:31 +02:00
Paul Sokolovsky
b7bb48eeac posix: unistd.h: open() doesn't belong here
Per POSIX, open() is defined in <fcntl.h>. fcntl.h in turn comes from
the underlying libc, either newlib, or minimal libc.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-07-25 13:50:58 -04:00
Anas Nashif
656f4dfdac cleanup: include/: move fs.h to fs/fs.h
move fs.h to fs/fs.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Paul Sokolovsky
6631e7c6a9 posix: unistd.h: Add gethostname()
Per POSIX, gethostname() is declared in unistd.h.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2019-06-27 14:43:40 -05:00
Kumar Gala
6cc5722a61 lib: posix: Fix compile error with mqueue.h
With newer newlib we get a build error with mqueue.h realted to mode_t.
Let's just let newlib define mode_t and have minimal libc also define
it in sys/types.h.  So we remove the duplicated definition in
posix/unistd.h.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-02-23 11:42:31 -06:00
Kumar Gala
e96d02984c lib: posix: Fix compile issue with newer newlib
Both SDK 0.10.0-beta2 and the ARM gcc 2018q2 run into a build issue with
newlib and conflict definitions of mode_t type.

First we need to add some ifdef protection if mode_t is already defined
and set _MODE_T_DECLARED if we are the first to define it.

Secondarily, we rename include/posix/sys/types.h to
include/posix/posix_types.h so that we aren't getting a name collusion
with the system sys/types.h and that we can easily and clearily include
it (which we need to do to pull in the info from newlib).

Fixes: #12224

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2019-02-22 11:55:01 -06:00
Paul Sokolovsky
7f9127578b include: posix: unistd: Fix prototypes and dependency
For read/write/lseek, use size_t and off_t types, as mandated by
POSIX:
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/unistd.h.html

Also, prototypes of unistd.h functions should not depend on
CONFIG_POSIX_FS, as (many) of them deal with generic I/O, not with
files in filesystem per se.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-10-09 08:19:44 -04:00
Paul Sokolovsky
c152ebd634 include: posix: Split dirent.h from unistd.h
From POSIX
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/dirent.h.html

"""
The <dirent.h> header shall define the following type:
DIR

...

also define the structure dirent
"""

etc.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-10-02 10:51:52 -07:00
Flavio Ceolin
67ca176754 headers: Fix headers across the project
Any word started with underscore followed by and uppercase letter or a
second underscore is a reserved word according with C99.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2018-09-17 15:49:26 -04:00
Leandro Pereira
0f1d30aa67 lib: posix: Do not redefine PATH_MAX in unistd.h
This constant should be defined in limits.h.  Define it in limits.h in
the minimal libc, and use the definition found in newlib's includes.
Values in newlib includes range from 1024 to 4096.

The rationale is that all code should use the same value; having
buffers specified with different sizes will lead to interoperability
and out of bounds array writes.

Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2018-05-19 06:59:40 +03:00
Ramakrishna Pallala
eb0aaca64d lib: posix: Add Posix Style File System API support
Add IEEE 1003.1 Posix Style file system API support.
These API's will internally use corresponding Zephyr
File System API's.

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
2018-05-18 13:32:36 +03:00
Ramakrishna Pallala
f603e603bb lib: posix: Move posix layer from 'kernel' to 'lib'
Move posix layer from 'kernel' to 'lib' folder as it is not
a core kernel feature.

Fixed posix header file dependencies as part of the move and
also removed NEWLIBC related macros from posix headers.

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
2018-04-05 16:43:05 -04:00
Youvedeep Singh
f762fdf482 kernel: posix: move sleep and usleep functions into c file.
Currently sleep and usleep functions are into unistd.h file.
unistd includes toold chain secific unistd.h file and this file
too has declaration for these functions. This is in conflict when
posix specific unistd.h is included.

Signed-off-by: Youvedeep Singh <youvedeep.singh@intel.com>
2018-04-05 08:15:55 -04:00
Youvedeep Singh
43383701ca include: posix: correcting the return type of sleep.
Currently return type of sleep is int, but as per POSIX 1003.1 it
should be unsigned.

Signed-off-by: Youvedeep Singh <youvedeep.singh@intel.com>
2018-03-26 09:50:17 -04:00
Youvedeep Singh
1f2e126d4d kernel: POSIX: Compatibility layer for POSIX sleep APIs.
This patch provides POSIX sleep APIs for POSIX 1003.1 PSE52 standard.
sleep(n) is implemented using Zephyr k_sleep API.
uleep(n) is implemented using Zephyr k_sleep/k_busy_Wait API.

Signed-off-by: Youvedeep Singh <youvedeep.singh@intel.com>
2018-02-21 19:17:28 -05:00