]> xenbits.xensource.com Git - unikraft/libs/newlib.git/log
unikraft/libs/newlib.git
18 months agoIntroduce `Library.uk` stable staging RELEASE-0.15.0 RELEASE-0.16.0
Alexander Jung [Tue, 11 Jul 2023 21:25:56 +0000 (21:25 +0000)]
Introduce `Library.uk`

This new file represents the first step towards proper versioning support of
external microlibrary in Unikraft.  The file itself acts as mechanism for
holding metadata-only values about the microlibrary.  This metadata is designed
to be compatible with GNU Make whilst simultaneously being human-readable and
readable by programs that are not GNU Make (e.g. tools such as KraftKit).

An important feature of this file is the inclusion of microlibrary versions.
In a later step, once relevant integrations have been made to Unikrat's core
build system and to relevant tools such as KraftKit, the user will be able to
see and select from different versions of the microlibrary.

In this initial commit, the relevant metadata is absorbed from both Makefile.uk,
Config.uk, but also includes new information such as SPDX License identifier.

Signed-off-by: Alexander Jung <alex@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #34

19 months agoMakefile.uk: Suppress more warnings
Andrei Tatar [Mon, 28 Aug 2023 23:42:29 +0000 (01:42 +0200)]
Makefile.uk: Suppress more warnings

Add more warning supression & compiler specific warnings.

Signed-off-by: Andrei Tatar <andrei@unikraft.io>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Reviewed-by: Eduard Vintilă <eduard.vintila47@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #36

20 months agoMakefile.uk: Call tcb reserve conditionally RELEASE-0.14.0
Razvan Deaconescu [Mon, 31 Jul 2023 14:24:50 +0000 (17:24 +0300)]
Makefile.uk: Call tcb reserve conditionally

The `ukarch_tls_tcb_reserve` call in `Makefile.uk` should only be made
when Newlib is selected (i.e. when `CONFIG_LIBNEWLIBC` is set to `y`).
Otherwise, if `newlib` is downloaded in the build directory, but is
*not* selected in the configuration, a build error occurs:

```
  LD      simple_qemu-x86_64.dbg
/usr/bin/ld: [...]/build/libcontext.o: in function `ukarch_tls_area_init':
[...]/unikraft/arch/x86/x86_64/tls.c:201: undefined reference to `ukarch_tls_tcb_init'
```

Add an `ifeq` / `endif` wrapper to the call to `ukarch_tls_tcb_reserve`,
such that the call is made only when Newlib is selected for
configuration.

Signed-off-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Approved-by: Eduard Vintilă <eduard.vintila47@gmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #35

23 months agoMakefile.uk: Use -ffreestanding as internal build option RELEASE-0.13.0 RELEASE-0.13.1
Razvan Deaconescu [Thu, 11 May 2023 11:50:37 +0000 (14:50 +0300)]
Makefile.uk: Use -ffreestanding as internal build option

As a standard C library (libc), newlib is to be built in a freestanding
environment (i.e. not relying on a libc). For that, build internal
newlib source code files with the `-ffreestanding` option. Otherwise, a
hosted environment will be used; in a hosted environment, certain
optimizations may be enabled by the compiler, and they may cause issues
(such as an infinite set of calls).

Signed-off-by: Razvan Deaconescu <razvand@unikraft.io>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Reviewed-by: Eduard Vintilă <eduard.vintila47@gmail.com>
Approved-by: Marc Rittinghaus <marc.rittinghaus@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #33

23 months agoinclude: Add `*_OK` flags in fcntl.h header
Stefan Jumarea [Thu, 11 May 2023 11:36:51 +0000 (14:36 +0300)]
include: Add `*_OK` flags in fcntl.h header

The `*_OK` flags are defined in `fcntl.h` in both musl and nolibc. Add
them here in newlib to prevent any eventual conflicts that may appear.

Signed-off-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Reviewed-by: Eduard Vintilă <eduard.vintila47@gmail.com>
Approved-by: Eduard Vintilă <eduard.vintila47@gmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #32

23 months agoAdd patch for O_ flags
Eduard Vintilă [Sun, 9 Apr 2023 16:38:57 +0000 (19:38 +0300)]
Add patch for O_ flags

Adds a small patch which contains multiple Linux-specific O_* flags.

Signed-off-by: Eduard Vintilă <eduard.vintila47@gmail.com>
Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com>
Reviewed-by: Teodor Tiron <teotiron@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #28

23 months agoAdd musl-imported time functions
Eduard Vintilă [Sun, 9 Apr 2023 16:38:35 +0000 (19:38 +0300)]
Add musl-imported time functions

Signed-off-by: Eduard Vintilă <eduard.vintila47@gmail.com>
Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com>
Reviewed-by: Teodor Tiron <teotiron@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #28

23 months agoAdd LWIP-compatible interface
Eduard Vintilă [Wed, 7 Dec 2022 12:07:41 +0000 (14:07 +0200)]
Add LWIP-compatible interface

This commit brings back source files which were previously defined in
`lib-lwip`, but deleted as part of the Musl compatibility effort in
order to avoid redefinition. The functions need to be implemented by
the libc, so we reintroduce them in the `lib-newlib` repo to retain
compatibility with lwip.

Signed-off-by: Eduard Vintilă <eduard.vintila47@gmail.com>
Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com>
Reviewed-by: Teodor Tiron <teotiron@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #28

23 months agoAdapt to the latest changes in Unikraft core
Eduard Vintilă [Wed, 23 Nov 2022 18:34:46 +0000 (20:34 +0200)]
Adapt to the latest changes in Unikraft core

This commit updates various headers to match the latest posix-time
interface from Unikraft core, while also introducing new glue code
(`__uk_init_tls.c`) to adapt the library to the new TCB/TLS layout.

Checkpatch-Ignore: EMBEDDED_FUNCTION_NAME
Signed-off-by: Eduard Vintilă <eduard.vintila47@gmail.com>
Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com>
Reviewed-by: Teodor Tiron <teotiron@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #28

2 years agoDefine O_DIRECTORY with different value RELEASE-0.12.0
Maria Sfiraiala [Wed, 3 Aug 2022 15:59:43 +0000 (18:59 +0300)]
Define O_DIRECTORY with different value

Previous fix regarding confusion between O_NONBLOCK and O_DIRECTORY
values changed O_NONBLOCK to a different number, therefore it drifted
away from FNONBLOCK (for which it was an alias) and caused a blocking
socket.

This commit simply changes the value of O_DIRECTORY, without being
necessary to redefine O_NONBLOCK or FNONBLOCK.

Fixes: 58f9f3a3f7b5 ("include/fcntl.h: Replace O_NONBLOCK with new one
on arm")

Signed-off-by: Maria Sfiraiala <maria.sfiraiala@gmail.com>
Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Approved-by: Razvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #21

2 years agoFix size for long types on aarch64
Maria Sfiraiala [Wed, 3 Aug 2022 15:53:05 +0000 (18:53 +0300)]
Fix size for long types on aarch64

Default size of the data model for AArch64 is 8 (64 bits) for long
types, however newlibc ends up defining LONG_MAX as 32 bits.

This issue causes extremely optimized functions, such as memchr (which
parses DTB for apps like SQLite or redis), to crash when compiled for
AArch64.

This commit redefines the size for long types as 64 bits on AArch64.

Signed-off-by: Maria Sfiraiala <maria.sfiraiala@gmail.com>
Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Razvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Approved-by: Razvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #21

2 years agopatches: Add patch to increase 'FD_SETSIZE'
Cezar Craciunoiu [Thu, 20 Oct 2022 08:18:37 +0000 (11:18 +0300)]
patches: Add patch to increase 'FD_SETSIZE'

Change needed by lwip to increase the number of connections past 57.

Signed-off-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
Reviewed-by: Sergiu Moga <sergiu.moga@protonmail.com>
Approved-by: Marc Rittinghaus <marc.rittinghaus@kit.edu>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #24

2 years agoRemove inclusion of uk/user.h RELEASE-0.10.0
Marc Rittinghaus [Thu, 11 Aug 2022 06:50:01 +0000 (08:50 +0200)]
Remove inclusion of uk/user.h

Currently, we include uk/user.h from the core's posix-user library to
declare signatures for get/setresuid and get/setresgid. However,
these definitions should be part of the C library and not Unikraft.
This commit removes the dependency on the uk/user.h header
and moves the function declaration into the unistd.h directly. It also
adds the missing _GNU_SOURCE guard.

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@kit.edu>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Reviewed-by: Razvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Approved-by: Razvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #22

2 years agoRemove poll/select and eventfd stubs
Marc Rittinghaus [Thu, 11 Aug 2022 07:08:11 +0000 (09:08 +0200)]
Remove poll/select and eventfd stubs

This commit removes the stubs for functions provided by the
new posix-socket and posix-event libraries.

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@kit.edu>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
Reviewed-by: Razvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Approved-by: Razvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #23

3 years agoRemove mprotect stub RELEASE-0.8.0 RELEASE-0.9.0
Marc Rittinghaus [Tue, 29 Mar 2022 11:40:33 +0000 (13:40 +0200)]
Remove mprotect stub

This commit removes the stub for mprotect as it has been introduced as
stubbed system call in ukmmap.

Signed-off-by: Marc Rittinghaus <marc.rittinghaus@kit.edu>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
Approved-by: Alexander Jung <alex@unikraft.org>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #16

3 years agoinclude/syscall.h: add cpp macros RELEASE-0.7.0
Daniel Dinca [Wed, 10 Mar 2021 10:21:30 +0000 (12:21 +0200)]
include/syscall.h: add cpp macros

Make the syscall header compatible with C++ compiler.

Signed-off-by: Daniel Dinca <dincadaniel97@gmail.com>
Reviewed-by: Gabriel Mocanu <gabi.mocanu98@gmail.com>
Approved-by: Alexander Jung <a.jung@lancs.ac.uk>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #3

3 years agoAdd SHA256 checksum RELEASE-0.6
Simon Kuenzer [Fri, 16 Apr 2021 09:28:51 +0000 (11:28 +0200)]
Add SHA256 checksum

We add the SHA256 checksum of the downloaded archive so that Unikraft's
build system is able to do an integrity check of the download.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Razvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Approved-by: Alexander Jung <a.jung@lancs.ac.uk>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #4

3 years agonewlib/libc/include/sys/param.h: Check if MIN and MAX definitions are not defined...
Gabriel Mocanu [Sat, 27 Nov 2021 07:52:57 +0000 (09:52 +0200)]
newlib/libc/include/sys/param.h: Check if MIN and MAX definitions are not defined somewhere else.

Signed-off-by: Gabriel Mocanu <gabi.mocanu98@gmail.com>
Reviewed-by: Andrei Mutu <andrei.mutu@stud.acs.upb.ro>
Approved-by: Razvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #14

3 years agonewlib/include: Fix gcc 11 compilation warning
Cezar Craciunoiu [Sat, 30 Oct 2021 08:32:34 +0000 (11:32 +0300)]
newlib/include: Fix gcc 11 compilation warning

Signed-off-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #13

3 years agoAdd missing symbols to the uksignal interface
Razvan Virtan [Mon, 4 Oct 2021 16:50:18 +0000 (19:50 +0300)]
Add missing symbols to the uksignal interface

The Go runtime requires some symbols related to signals that are not
currently defined in `signal.h` (after the uksignal support was added).
Changes brought in this commit:
- add missing fields to `siginfo_t`
- declare `sigaltstack` (the stub implementation is added to uksignal
in a separate pull request, part of the core Unikraft repository)
- add symbols for `ss_flags` values

Signed-off-by: Răzvan Vîrtan <virtanrazvan@gmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #11

3 years agoMakefile.uk: Remove conflicting `resource.c` from build process
Sergiu Moga [Thu, 12 Aug 2021 11:50:46 +0000 (14:50 +0300)]
Makefile.uk: Remove conflicting `resource.c` from build process

This commit removes the conflicting function definitions for `getrlimit`,
`setrlimit` and `getrusage` by removing `resource.c` from the build process.

Signed-off-by: Sergiu Moga <sergiu.moga@protonmail.com>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #9

3 years agoCorrect license headers introduced by University Politehnica of Bucharest
Simon Kuenzer [Tue, 13 Jul 2021 19:10:23 +0000 (21:10 +0200)]
Correct license headers introduced by University Politehnica of Bucharest

This commit removes the additional clause
"THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY"
from BSD license headers that got introduced by mistake
with the following commits:
 949e761 - Use our own <time.h> and <sys/time.h> headers (Costin Lupu)
 b2192bd - Add device related stubs (Vlad-Andrei BĂDOIU (78692))
 2c79cd5 - Introduce <sys/unistd.h> for including both newlib and Unikraft definitions (Costin Lupu)
 04f03ec - Add WCOREDUMP and WIFCONTINUED (Costin Lupu)
 d901960 - Add sys/signal.h header (Mihai Pogonaru)
 9287428 - Add mntent.c stubs (Costin Lupu)
 20ab046 - Introduce <uk/_types.h> header for basic types defined by Unikraft (Costin Lupu)

On the one hand, this additional clause is redundant because
the BSD license already states that it must remain and the
copyright notice must be kept.
On the other hand, the clause freezes the file header
and prohibits future contributors from extending the
copyright notice for their contributions. This additional
clause is not part of the official BSD 3-clause.

The original author(s) or an authorized representative from
the author's affiliation consents to the change with a
`Reviewed-by` tag to this commit.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Razvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #8

3 years agoCorrect license headers introduced by NEC Laboratories Europe GmbH
Simon Kuenzer [Tue, 13 Jul 2021 19:10:23 +0000 (21:10 +0200)]
Correct license headers introduced by NEC Laboratories Europe GmbH

This commit removes the additional clause
"THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY"
from BSD license headers that got introduced by mistake
with the following commits:
 2db987a - Add dl_iterate_phdr() stub (Charalampos Mainas)
 db39aae - Initial public release: configuration and build files (Florian Schmidt)
 fd30736 - Initial public release: glue code (Florian Schmidt)
 a4f6ac2 - update newlib glue for use with vfscore (Yuri Volchkov)
 d757c96 - Expose getline (Felipe Huici)

On the one hand, this additional clause is redundant because
the BSD license already states that it must remain and the
copyright notice must be kept.
On the other hand, the clause freezes the file header
and prohibits future contributors from extending the
copyright notice for their contributions. This additional
clause is not part of the official BSD 3-clause.

The original author(s) or an authorized representative from
the author's affiliation consents to the change with a
`Reviewed-by` tag to this commit.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #7

3 years agoEnable per-library allocator statistics
Simon Kuenzer [Sun, 22 Nov 2020 00:00:03 +0000 (01:00 +0100)]
Enable per-library allocator statistics

Instruments the library so that per-library allocator statistics are
possible. We make sure that code that uses `malloc()`, `free()`, and
company will resolve `uk_alloc_get_default()` within their compilation
scope so that the individual wrapper allocators can be used.
For this purpose, we declare the allocator functions as `static inline`
within the corresponding headers (like `<stdlib.h>`). Since the libc
headers are modified, we apply the new behavior only when
`CONFIG_LIBUKALLOC_IFSTATS` is switched on.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
3 years agoRemove implementation of time()
Razvan Deaconescu [Fri, 14 May 2021 15:34:22 +0000 (18:34 +0300)]
Remove implementation of time()

time() is now implemented as part of the uktime Unikraft library. Remove
newlib implementation of time() to have a single definition.

Signed-off-by: Razvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Reviewed-by: Alexander Jung <a.jung@lancs.ac.uk>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #5

4 years agosignal: Add killpg to header
Sharan Santhanam [Tue, 9 Feb 2021 18:08:01 +0000 (19:08 +0100)]
signal: Add killpg to header

Extend signal.h to include killpg

Signed-off-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
Reviewed-by: Alexander Jung <a.jung@lancs.ac.uk>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #2

4 years agonewlib: Add uksignal dependency
Sharan Santhanam [Mon, 8 Feb 2021 08:03:24 +0000 (09:03 +0100)]
newlib: Add uksignal dependency

Add uksignal as a dependency to newlib

Signed-off-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
Reviewed-by: Alexander Jung <a.jung@lancs.ac.uk>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #1

4 years agolib/newlib: Support for uksignal RELEASE-0.5
Bernard Rizzo [Sat, 16 Jan 2021 01:51:17 +0000 (02:51 +0100)]
lib/newlib: Support for uksignal

This patch is an update of the original.

Signed-off-by: Mihai Pogonaru <pogonarumihai@gmail.com>
Signed-off-by: Felipe Huici <felipe.huici@neclab.eu>
Signed-off-by: Bernard Rizzo <b.rizzo@student.uliege.be>
Reviewed-by: ARGINT DRAGOS IULIAN <dragosargint21@gmail.com>
4 years agoAdd NAME_MAX to limits.h
Vlad-Andrei Badoiu [Sun, 27 Dec 2020 23:30:27 +0000 (01:30 +0200)]
Add NAME_MAX to limits.h

Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@upb.ro>
Reviewed-by: Gaulthier Gain <gaulthier.gain@uliege.be <mailto:gaulthier.gain@uliege.be>>
4 years agoMakefile.uk: Include unix basename and dirname
Alexander Jung [Tue, 11 Aug 2020 16:27:23 +0000 (18:27 +0200)]
Makefile.uk: Include unix basename and dirname

This commit adds basename() and dirname() into the newlib build
for Unikraft.  Both functions have only dependencies to <string.h>
making them easily compatible.

Signed-off-by: Alexander Jung <alexander.jung@neclab.eu>
Reviewed-by: Razvan Virtan <virtanrazvan@gmail.com>
4 years agoinclude/endian.h: Remove bswap* duplicate definitions
Razvan Deaconescu [Fri, 18 Sep 2020 11:32:51 +0000 (14:32 +0300)]
include/endian.h: Remove bswap* duplicate definitions

Using Clang results in compilation errors regarding the `__bswapXY` and
`__builtin_bswapXY` functions. There are simultaneously a definition of
a macro `__bswapXY` and a definition of a function `__bswapXY`; GCC
doesn't complain, but Clang does.

This is happening in Unikraft because the Unikraft core libraries are
using a minimized Unikraft newlib library[4], while the Unikraft app is
using the upstream (complete) newlib library[5]. In the end there are
two `endian.h` files: one in the Unikraft newlib[6], another one in the
upstream newlib (<repo>/newlib/libc/include/machine/endian.h). The
Unikraft newlib version of `endian.h` defines `__bswapXY` as inline
functions, whereas the upstream newlib defines them as macros. This
results in an error from Clang; GCC doesn't mind, though it's an issue
having multiple definitions for the same thing (even if one is a macro
or one is a function).

This commit fixes the issue. It removes the `__bswapXY` parts from the
Unikraft version of `endian.h` and includes the upstream version of
`endian.h`.

Signed-off-by: Razvan Deaconescu <razvan.deaconescu@cs.pub.ro>
Reviewed-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@upb.ro>
4 years agoinclude/fcntl.h: Replace O_NONBLOCK with new one on arm
Jia He [Wed, 20 May 2020 09:56:03 +0000 (17:56 +0800)]
include/fcntl.h: Replace O_NONBLOCK with new one on arm

in newlib _default_fcntl.h, it defines O_NONBLOCK as follows:
\#define _FNONBLOCK      0x4000  /* non blocking I/O (POSIX style) */
But it is different from linux definition(04000=0x800):
\#define O_NONBLOCK 00004000

This difference confused virtio-9p open() syscall. If you open a
file with O_NONBLOCK(is 0x4000 in newlib) and sys_open will regard
it as O_DIRECTORY. At last it returns a ENOTDIR error.

Signed-off-by: Jia He <justin.he@arm.com>
Reviewed-by: Razvan Deaconescu <razvan.deaconescu@cs.pub.ro>
5 years agoDefine tzname
Felipe Huici [Thu, 16 Apr 2020 19:49:39 +0000 (21:49 +0200)]
Define tzname

Currently, tzname is defined as an extern, which results in a
undefined reference linker error when attempting to use
it. This patch maps tzname to _tzanme, which *is*
defined. newlib does this mapping in OS-specific files that we
don't compile in, so this is a way to mimic that behavior.

Signed-off-by: Felipe Huici <felipe.huici@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
5 years agoMake sure floating point is enabled when ARM64 is selected.
Felipe Huici [Fri, 10 Apr 2020 06:48:19 +0000 (08:48 +0200)]
Make sure floating point is enabled when ARM64 is selected.

newlib requires floating point support. This patch ensures that
floating point is enabled whenever ARM64 is selected as the
architecture.

Signed-off-by: Felipe Huici <felipe.huici@neclab.eu>
Reviewed-by: Jia He <justin.he@arm.com>
5 years agoAdd __assert_fail from musl 1.1.19 .
Felipe Huici [Thu, 19 Mar 2020 19:28:32 +0000 (20:28 +0100)]
Add __assert_fail from musl 1.1.19 .

Signed-off-by: Felipe Huici <felipe.huici@neclab.eu>
Reviewed-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
5 years agobyteswap.h: Import from musl
Vlad-Andrei BĂDOIU [Wed, 18 Mar 2020 11:50:07 +0000 (13:50 +0200)]
byteswap.h: Import from musl

Copied as is from the official musl git mirror
git://git.musl-libc.org/musl, commit 6fcb440d.

Signed-off-by: Vlad-Andrei BĂDOIU <vlad_andrei.badoiu@stud.acs.upb.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agofeatures.h: Import from musl
Vlad-Andrei BĂDOIU [Wed, 18 Mar 2020 11:50:06 +0000 (13:50 +0200)]
features.h: Import from musl

Copied as is from the official musl git mirror
git://git.musl-libc.org/musl, commit 6fcb440d.

Signed-off-by: Vlad-Andrei BĂDOIU <vlad_andrei.badoiu@stud.acs.upb.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoAdd ptsname, ttyname_r and cfmakeraw stubs
Vlad-Andrei BĂDOIU [Wed, 18 Mar 2020 01:09:30 +0000 (03:09 +0200)]
Add ptsname, ttyname_r and cfmakeraw stubs

Signed-off-by: Vlad-Andrei BĂDOIU <vlad_andrei.badoiu@stud.acs.upb.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoConfig.uk: remove imply of shim layer library
Felipe Huici [Thu, 12 Mar 2020 14:39:17 +0000 (15:39 +0100)]
Config.uk: remove imply of shim layer library

Currently, Config.uk sets imply LIBSYSCALL_SHIM, which for all intents
and purposes forces all images built with newlib to include the
syscall shim even when it's not needed. While "imply" still allows
users to manually deselect the option, one has to know about this
possiblity, and kraft-driven builds will not do this by default.

For applications that *do* need the shim library, this should be set
explicitly in their Config.uk files, or in their respective kraft.yaml
file.

Signed-off-by: Felipe Huici <felipe.huici@neclab.eu>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
5 years agoMakefile.uk: compile lroundl.c
Hugo Lefeuvre [Mon, 9 Mar 2020 13:41:30 +0000 (14:41 +0100)]
Makefile.uk: compile lroundl.c

For some reason lroundl.c was not in the list of source files to be
compiled, causing issues in the redis build.

Signed-off-by: Hugo Lefeuvre <hugo.lefeuvre@neclab.eu>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agopatches: fix typo in atomic_compare_exchange_strong_explicit
Hugo Lefeuvre [Wed, 26 Feb 2020 15:32:20 +0000 (16:32 +0100)]
patches: fix typo in atomic_compare_exchange_strong_explicit

Fix 'expeced' typo. This breaks builds relying on
atomic_compare_exchange_strong_explicit.

Signed-off-by: Hugo Lefeuvre <hugo.lefeuvre@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
5 years agosys/syscalls.h: Provide SYS_<syscallname> macros
Simon Kuenzer [Thu, 5 Mar 2020 14:00:26 +0000 (15:00 +0100)]
sys/syscalls.h: Provide SYS_<syscallname> macros

Besides having __NR_<syscallname> as names for system call number
definitions, we also provide SYS_<syscallname> variants.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoMakefile.uk: -Wno-char-subscripts as global flag RELEASE-0.4
Simon Kuenzer [Mon, 17 Feb 2020 19:06:24 +0000 (20:06 +0100)]
Makefile.uk: -Wno-char-subscripts as global flag

Exposes the GCC suppress flag `-Wno-char-subscripts` globally. The
header <ctype.h> is causing the warning to appear when the
macros islower, isupper, tolower, toupper are used.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoAdd sys/epoll.h
Felipe Huici [Thu, 13 Feb 2020 20:40:31 +0000 (21:40 +0100)]
Add sys/epoll.h

Add header file sys/epoll.h from musl, needed by libgo and likely
other libs.

Signed-off-by: Felipe Huici <felipe.huici@neclab.eu>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
5 years agoProvide `syscall()` symbol
Simon Kuenzer [Fri, 7 Feb 2020 13:26:38 +0000 (14:26 +0100)]
Provide `syscall()` symbol

Provides the `syscall()` function symbol (some language runtimes  link
to the symbol directly). The function is calling `uk_syscall()` when
lib/syscall_shim is enabled. Otherwise, `syscall()` returns always
`-1` and sets `errno` to `ENOSYS`.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoDefine LDBL_EQ_DBL on ARM64
Vlad-Andrei BĂDOIU (78692) [Wed, 15 Jan 2020 12:34:24 +0000 (12:34 +0000)]
Define LDBL_EQ_DBL on ARM64

LDBL_EQ_DBL is used by newlib to protect the definitions of the long
double math functions(e.g. cosl) as wrappers over long math
functions(e.g. cos). In this patch we define the symbol on ARM64 since
it was already defined under x86_64.

Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoMakefile.uk: enable wcstold_l in build
Jia He [Fri, 20 Dec 2019 04:54:24 +0000 (12:54 +0800)]
Makefile.uk: enable wcstold_l in build

newlib's strtold.c compile-guards the definitinon of wcstold_l (needed
by wcstold.c) with _HAVE_LONG_DOUBLE. We set this flag to fix the
corresponding undefined reference linker error.

Signed-off-by: Jia He <justin.he@arm.com>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoFix newlib ARM64 support
Santiago Pagani [Thu, 19 Dec 2019 11:20:26 +0000 (12:20 +0100)]
Fix newlib ARM64 support

At the moment newlib compiles for ARM64 but fails at runtime.  This
patch changes some generic newlib files for the machine specific
newlib files for ARM64.

Signed-off-by: Santiago Pagani <santiagopagani@gmail.com>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agosincosl.c: Import from musl
Vlad-Andrei BĂDOIU (78692) [Wed, 8 Jan 2020 14:17:32 +0000 (14:17 +0000)]
sincosl.c: Import from musl

Copied as is from the official musl git mirror
git://git.musl-libc.org/musl, commit 6fcb440d.

We only keep the non optimized definition since
all the long double math functions from newlib
are wrappers over double.

Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoAdd patch to fix atomic_* definitions
Vlad-Andrei BĂDOIU (78692) [Tue, 17 Dec 2019 17:05:04 +0000 (17:05 +0000)]
Add patch to fix atomic_* definitions

Currently, including stdatomic.h causes the compilation to fail due to
the now obsolate definitions of atomic_* functions. We adapt the existing
implementations via a patch to fix this.

Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoInclude stdint.h in sys/_types.h
Vlad-Andrei BĂDOIU (78692) [Tue, 17 Dec 2019 17:05:03 +0000 (17:05 +0000)]
Include stdint.h in sys/_types.h

stdatomic.h no longer builds because it's missing the definitions of
stdint.h that should come with sys/types.h .

Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoAdd missing stubs and declarations to support Ruby
Costin Lupu [Fri, 6 Dec 2019 13:25:16 +0000 (15:25 +0200)]
Add missing stubs and declarations to support Ruby

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Stefan Teodorescu <stefanl.teodorescu@gmail.com>
5 years agofile.c: delete utimes stub implementation
Stefan Teodorescu [Thu, 28 Nov 2019 14:02:49 +0000 (16:02 +0200)]
file.c: delete utimes stub implementation

Since utimes (and other related functions) have been implemented, this
stub doesn't make sense anymore. Deleting it to prevent double
definition, which produced a linker error.

Signed-off-by: Stefan Teodorescu <stefanl.teodorescu@gmail.com>
Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
5 years agoinclude/fcntl.h: define posix_fadvise advice parameters
Stefan Teodorescu [Thu, 28 Nov 2019 14:39:10 +0000 (16:39 +0200)]
include/fcntl.h: define posix_fadvise advice parameters

Since posix_fadvise function was implemented, it needs to build with
newlib too, so it needs definitions for advice parameters.

Signed-off-by: Stefan Teodorescu <stefanl.teodorescu@gmail.com>
Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
5 years agoAdapt crypt code to Unikraft
Costin Lupu [Wed, 27 Nov 2019 14:22:31 +0000 (16:22 +0200)]
Adapt crypt code to Unikraft

We tried to keep the changes of the original code to a minimum. For this
purpose, we used the C preprocessor in order to disable the 'hidden' musl
qualifier. We also had to rename the <crypt.h> header in
`musl-imported/src/include` to <_crypt.h> because, being a private header, we
could not add its directory at the top of the include paths list to include it
before the <crypt.h> header in `musl-imported/include` (the latter being
a public include path).

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Roxana Nicolescu <nicolescu.roxana1996@gmail.com>
5 years agoImport crypt code from musl
Costin Lupu [Wed, 27 Nov 2019 14:22:30 +0000 (16:22 +0200)]
Import crypt code from musl

Copied as is from the official musl git mirror
git://git.musl-libc.org/musl, commit 6fcb440d.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Roxana Nicolescu <nicolescu.roxana1996@gmail.com>
5 years agoChange the restrict keyword to __restrict__
Vlad-Andrei BĂDOIU (78692) [Tue, 12 Nov 2019 10:12:41 +0000 (10:12 +0000)]
Change the restrict keyword to __restrict__

The restrict keyword doesn't exist in C++. Including headers that use
this keyword causes compilation errors. We replace the keyword with
the __restrict__ extension from GCC.

Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agosys/poll.h: Declare poll() even if CONFIG_LWIP_SOCKET is defined
Costin Lupu [Sat, 16 Nov 2019 22:06:48 +0000 (00:06 +0200)]
sys/poll.h: Declare poll() even if CONFIG_LWIP_SOCKET is defined

We need the poll() declaration even when CONFIG_LWIP_SOCKET is defined. We
disable only the macros values if CONFIG_LWIP_SOCKET is defined because lwip
comes with its own values.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Stefan Teodorescu <stefanl.teodorescu@gmail.com>
5 years agoMakefile.uk: Use _HAVE_LONG_DOUBLE as global preprocessing symbol
Costin Lupu [Sat, 16 Nov 2019 22:06:47 +0000 (00:06 +0200)]
Makefile.uk: Use _HAVE_LONG_DOUBLE as global preprocessing symbol

Given that it is used in <stdlib.h> header, _HAVE_LONG_DOUBLE needs to be
globally visible and not just internally, only for newlib code.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Stefan Teodorescu <stefanl.teodorescu@gmail.com>
5 years agoAdd wcscasecmp.c to Makefile
Vlad-Andrei BĂDOIU (78692) [Sat, 9 Nov 2019 10:56:00 +0000 (10:56 +0000)]
Add wcscasecmp.c to Makefile

Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoAdd math sources for long functions
Vlad-Andrei BĂDOIU (78692) [Sat, 9 Nov 2019 10:55:59 +0000 (10:55 +0000)]
Add math sources for long functions

We enable some of the math sources (e.g., powl.c) by adding them to
Makefile.uk

Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoAdd missing definitions needed for Redis port
Costin Lupu [Fri, 1 Nov 2019 11:30:56 +0000 (13:30 +0200)]
Add missing definitions needed for Redis port

- Copy SA_NODEFER and SA_RESETHAND from musl
- Enable llroundl() function from origin code

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Stefan Teodorescu <stefanl.teodorescu@gmail.com>
5 years agoImport crypt.h and sys/eventfd.h from musl
Costin Lupu [Wed, 30 Oct 2019 17:42:06 +0000 (19:42 +0200)]
Import crypt.h and sys/eventfd.h from musl

Copied as is from the official musl git mirror
git://git.musl-libc.org/musl, commit 6fcb440d.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Mihai Pogonaru <pogonarumihai@gmail.com>
5 years agoAdd sys/signal.h header
Mihai Pogonaru [Tue, 29 Oct 2019 20:32:23 +0000 (22:32 +0200)]
Add sys/signal.h header

We add sys/signal.h to define si_pid as si_code.

Signed-off-by: Mihai Pogonaru <pogonarumihai@gmail.com>
Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
5 years agoRemove sys/prctl.h
Costin Lupu [Sun, 27 Oct 2019 12:09:19 +0000 (14:09 +0200)]
Remove sys/prctl.h

It was moved to posix-process internal library.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Mihai Pogonaru <pogonarumihai@gmail.com>
5 years agoAutomatically select LIBPOSIX_USER
Roxana Nicolescu [Wed, 23 Oct 2019 06:39:46 +0000 (09:39 +0300)]
Automatically select LIBPOSIX_USER

When using newlib, the posix_user library is not selected,
even if it is a strong dependency.

Signed-off-by: Roxana Nicolescu <nicolescu.roxana1996@gmail.com>
Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
5 years agoUse posix-process internal library
Costin Lupu [Mon, 21 Oct 2019 10:15:12 +0000 (13:15 +0300)]
Use posix-process internal library

We moved the process-related definitions to posix-process internal library.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Roxana Nicolescu <nicolescu.roxana1996>
5 years agoFix some other missing header inclusions
Costin Lupu [Sun, 13 Oct 2019 13:37:33 +0000 (16:37 +0300)]
Fix some other missing header inclusions

It is worth saying here that we previously forgot to add the declarations for
wait3() and wait4() stubs.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoIntroduce <sys/unistd.h> for including both newlib and Unikraft definitions
Costin Lupu [Sun, 13 Oct 2019 13:37:32 +0000 (16:37 +0300)]
Introduce <sys/unistd.h> for including both newlib and Unikraft definitions

The ukunistd internal lib defines mostly user related functions. Some of them
are not declared by newlib headers. For those ones we will use the <uk/user.h>
from the ukunistd lib.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoProvide our own <timespec.h> and <_timespec.h> headers
Costin Lupu [Sun, 13 Oct 2019 13:37:31 +0000 (16:37 +0300)]
Provide our own <timespec.h> and <_timespec.h> headers

Newlib uses <timespec.h> and <_timespec.h> headers for defining itimerspec and
timespec types, respectively. However, these definitions are not protected with
preprocessing guards in case they were previously defined, which happens for us
because we define these types in uktime internal lib. Therefore the solution is
to skip using newlib's headers and provide our own.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoUse our own <time.h> and <sys/time.h> headers
Costin Lupu [Sun, 13 Oct 2019 13:37:30 +0000 (16:37 +0300)]
Use our own <time.h> and <sys/time.h> headers

The uktime internal library provides the headers with the time related
definitions that we need. Given that newlib does not provide guard macros for
most of its definitions (and consequently we get errors because of duplicated
definitions), we decided to skip using its time headers.

In these glue headers we add only those definitions and inclusions that are
needed by newlib. For example, newlib's <sys/time.h> includes <sys/reent.h>, so
we will do the same here. In <time.h> we added the time zone/locale definitions
needed by newlib.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoIntroduce <uk/_types.h> header for basic types defined by Unikraft
Costin Lupu [Sun, 13 Oct 2019 13:37:29 +0000 (16:37 +0300)]
Introduce <uk/_types.h> header for basic types defined by Unikraft

Newlib defines some fundamental data types in its <sys/_types.h> header. We need
to overwrite those definitions that are provided by Unikraft so we introduce the
<uk/_types.h> header. In order to use both our <uk/_types.h> and Newlib's
<sys/_types.h> we use an intermediary <sys/_types.h> header in which we can also
overwrite some other type definitions (e.g. _CLOCK_T_ in this patch).

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoSelect uktime library
Costin Lupu [Wed, 9 Oct 2019 13:54:11 +0000 (16:54 +0300)]
Select uktime library

Because newlib needs functions such as gettimeofday().

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoDelete time.c
Roxana Nicolescu [Tue, 8 Oct 2019 07:23:02 +0000 (10:23 +0300)]
Delete time.c

Remove time.c from newlibc because its content was moved to lib/uktime.

Signed-off-by: Roxana Nicolescu <nicolescu.roxana1996@gmail.com>
Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
5 years agoAdd stub for sigsuspend
Mihai Pogonaru [Sun, 6 Oct 2019 22:56:23 +0000 (01:56 +0300)]
Add stub for sigsuspend

Signed-off-by: Mihai Pogonaru <pogonarumihai@gmail.com>
Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
5 years agoAdd glob.c to source files.
Mihai Pogonaru [Sun, 6 Oct 2019 22:56:22 +0000 (01:56 +0300)]
Add glob.c to source files.

This provides glob and globfree functions needed by Nginx

Signed-off-by: Mihai Pogonaru <pogonarumihai@gmail.com>
Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
5 years agoRemove mmap stub.
Charalampos Mainas [Thu, 19 Sep 2019 09:33:25 +0000 (11:33 +0200)]
Remove mmap stub.

Remove mmap stub from newlib glue code, an early implementation of it
is now provided as a Unikraft-internal library.f

Signed-off-by: Charalampos Mainas <Charalampos.Mainas@neclab.eu>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agofile.c: Remove pipe() function
Costin Lupu [Fri, 20 Sep 2019 14:37:43 +0000 (17:37 +0300)]
file.c: Remove pipe() function

pipe() is implemented in the kernel now.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
5 years agoRemove umask, fchown, lchown, rename
Simon Kuenzer [Wed, 18 Sep 2019 12:23:46 +0000 (14:23 +0200)]
Remove umask, fchown, lchown, rename

Removes the stubs `umask`, `fchown`, and `lchown` from the the glue
code, since these functions are now provided by libvfscore.  Further,
libfscore now provides an implementation of `rename`; as a result, we
no longer build newlibc's version of it.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoConfigure IO C99 formats and errno extensions
Costin Lupu [Thu, 12 Sep 2019 08:36:12 +0000 (11:36 +0300)]
Configure IO C99 formats and errno extensions

This patch adds support for enabling the following extensions:
* IO C99 formats enable more options for formatting output. We need this to
support "%z" in Python 3
* Linux errno extensions define more error numbers. We need this to support
ESHUTDOWN in Python 3

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
5 years agoucontext.h: Adapt to unikraft
Charalampos Mainas [Wed, 4 Sep 2019 10:25:38 +0000 (12:25 +0200)]
ucontext.h: Adapt to unikraft

Comment out features.h and include bits/signal.h which defines struct
ucontext_t.

Signed-off-by: Charalampos Mainas <Charalampos.Mainas@neclab.eu>
Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
5 years agoucontext.h: Import from musl
Charalampos Mainas [Wed, 4 Sep 2019 10:25:37 +0000 (12:25 +0200)]
ucontext.h: Import from musl

Copied as is from the official musl git mirror
git://git.musl-libc.org/musl, commit 6fcb440d.

Signed-off-by: Charalampos Mainas <Charalampos.Mainas@neclab.eu>
Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
5 years agobits/signal.h: Adapt to unikraft
Charalampos Mainas [Wed, 4 Sep 2019 10:25:36 +0000 (12:25 +0200)]
bits/signal.h: Adapt to unikraft

struct sigaltstack is already defined from newlib's sys/signal.h which
is included from ucontext.h. To avoid redinition error while compiling,
struct sigaltstack definition is disabled. We also disable the SA_* and SIG*
definitions since they are already defined in newlib's origin code.

Signed-off-by: Charalampos Mainas <Charalampos.Mainas@neclab.eu>
Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
5 years agobits/signal.h: Import from musl
Charalampos Mainas [Wed, 4 Sep 2019 10:25:35 +0000 (12:25 +0200)]
bits/signal.h: Import from musl

Copied as is from the official musl git mirror
git://git.musl-libc.org/musl, commit 6fcb440d.

Signed-off-by: Charalampos Mainas <Charalampos.Mainas@neclab.eu>
Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
5 years agoRevisit the pipe function
Vlad-Andrei BĂDOIU (78692) [Wed, 4 Sep 2019 15:47:25 +0000 (15:47 +0000)]
Revisit the pipe function

The pipe(...) stub should return an error. This is becuase the callee
will try to use the file descriptors returned by this function.

Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
5 years agoUpdate fcntl() related definitions
Costin Lupu [Wed, 4 Sep 2019 14:59:36 +0000 (17:59 +0300)]
Update fcntl() related definitions

Since we are using the fcntl() implementation in vfscore, we don't use newlib's
any more. This patch also adds some flags that are needed by fcntl() and that
were copied from musl, just like the previous ones from fcntl.h.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
5 years agoRevisit process.c functions
Costin Lupu [Wed, 4 Sep 2019 06:58:56 +0000 (09:58 +0300)]
Revisit process.c functions

This patch revisits the functions in process.c, redistributes some of them and
implements the others. The remaining functions may very well be moved into an
internal "process" related library, but we will do this at another time. It's
worth saying that we set the PID of the unikernel to 1, saving the PID 0 for its
"parent", an invisibile process that is also not shown on Linux.

Redistributed functions:
- kill() and killpg() are moved to signal.c
- times() is moved to time.c

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agofile.c: Add realpath() stub.
Felipe Huici [Tue, 3 Sep 2019 09:47:56 +0000 (11:47 +0200)]
file.c: Add realpath() stub.

Add stub for realpath() needed by the upcoming Micropython port.

Signed-off-by: Felipe Huici <felipe.huici@neclab.eu>
Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
5 years agoAdd clock_getres and clock_settime stubs
Vlad-Andrei BĂDOIU (78692) [Tue, 3 Sep 2019 12:21:50 +0000 (12:21 +0000)]
Add clock_getres and clock_settime stubs

Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
5 years agoRevisit pty.c functions
Costin Lupu [Mon, 2 Sep 2019 13:31:03 +0000 (16:31 +0300)]
Revisit pty.c functions

Actually the openpty() and forkpty() stubs should return errors, because
otherwise the callee will try to use the amaster and aslave file descriptors
returned by the functions.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agosyslog.c: Fix file location
Costin Lupu [Mon, 2 Sep 2019 15:06:46 +0000 (18:06 +0300)]
syslog.c: Fix file location

Files imported from musl should have the same location, relative to
musl-imported/ subdirectory. However, this was not applied when syslog.c was
imported.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Vlad-Andrei Badoiu<vlad_andrei.badoiu@stud.acs.upb.ro>
5 years agosyslog.c: Bring back setlogmask() from musl
Costin Lupu [Mon, 2 Sep 2019 15:06:45 +0000 (18:06 +0300)]
syslog.c: Bring back setlogmask() from musl

The OSv implementation, where we took this from, dropped the setlogmask()
function. We bring it back from the musl implementation because it is needed by
Python 3.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Vlad-Andrei Badoiu<vlad_andrei.badoiu@stud.acs.upb.ro>
5 years agoAdd syscall.h
Costin Lupu [Mon, 26 Aug 2019 14:36:36 +0000 (17:36 +0300)]
Add syscall.h

We simply redirect inclusion to our syscall.h header in syscall_shim library.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Charalampos Mainas <charalampos.mainas@neclab.eu>
5 years agosys/un.h: Adapt to Unikraft
Costin Lupu [Mon, 26 Aug 2019 14:36:35 +0000 (17:36 +0300)]
sys/un.h: Adapt to Unikraft

* Comment inclusion of 'features.h'

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Charalampos Mainas <charalampos.mainas@neclab.eu>
5 years agosys/un.h: Import from musl
Costin Lupu [Mon, 26 Aug 2019 14:36:34 +0000 (17:36 +0300)]
sys/un.h: Import from musl

Copied as is from the official musl git mirror
git://git.musl-libc.org/musl, commit 6fcb440d.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Charalampos Mainas <charalampos.mainas@neclab.eu>
5 years agopatches: Allow including custom malloc.h headers
Costin Lupu [Thu, 22 Aug 2019 10:10:56 +0000 (13:10 +0300)]
patches: Allow including custom malloc.h headers

We found this while porting Go runtime. The libgo library had its own malloc.h
header which it tried to include, but because of global include paths it
included the malloc.h of newlib. We workaround this by defining
_INCLUDE_MALLOC_H_ guard before including newlib's malloc.h and including our
own malloc.h next.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Charalampos Mainas <charalampos.mainas@neclab.eu>
5 years agoFix signal related issues
Costin Lupu [Thu, 22 Aug 2019 10:10:55 +0000 (13:10 +0300)]
Fix signal related issues

1. We enable _POSIX_REALTIME_SIGNALS preprocessing flag in order to use
siginfo_t definition.

2. We extend the siginfo_t definition with si_addr field by patching original
code. Further more, we use the same definition of struct sigaction as in the
case of RTEMS.

3. We have a circular inclusion cycle in the original code, where time.h
includes signal.h and viceversa. We fix this by using forward declaration in the
original code (again, by patching).

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Charalampos Mainas <charalampos.mainas@neclab.eu>
5 years agosyslog.h: Fix missing include directive
Costin Lupu [Thu, 22 Aug 2019 10:10:53 +0000 (13:10 +0300)]
syslog.h: Fix missing include directive

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Charalampos Mainas <charalampos.mainas@neclab.eu>
5 years agoAdd WCOREDUMP and WIFCONTINUED
Costin Lupu [Thu, 22 Aug 2019 10:10:52 +0000 (13:10 +0300)]
Add WCOREDUMP and WIFCONTINUED

These macros are missing from newlib's wait.h definitions.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Charalampos Mainas <charalampos.mainas@neclab.eu>
5 years agosys/prctl.h: Import from musl
Costin Lupu [Thu, 22 Aug 2019 10:10:51 +0000 (13:10 +0300)]
sys/prctl.h: Import from musl

Copied as is from the official musl git mirror
git://git.musl-libc.org/musl, commit 6fcb440d.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Charalampos Mainas <charalampos.mainas@neclab.eu>