]> xenbits.xensource.com Git - unikraft/libs/newlib.git/log
unikraft/libs/newlib.git
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>
5 years agosys/user.h: Import from musl
Costin Lupu [Thu, 22 Aug 2019 10:10:50 +0000 (13:10 +0300)]
sys/user.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 agosys/ptrace.h: Import from musl
Costin Lupu [Thu, 22 Aug 2019 10:10:49 +0000 (13:10 +0300)]
sys/ptrace.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 agoAdd mntent.c stubs
Costin Lupu [Thu, 22 Aug 2019 10:10:47 +0000 (13:10 +0300)]
Add mntent.c stubs

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Charalampos Mainas <charalampos.mainas@neclab.eu>
5 years agomntent.h: Import from musl
Costin Lupu [Thu, 22 Aug 2019 10:10:46 +0000 (13:10 +0300)]
mntent.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 agolink.h: Import from musl
Costin Lupu [Thu, 22 Aug 2019 10:10:44 +0000 (13:10 +0300)]
link.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 agomusl-imported: Add original copyright
Costin Lupu [Thu, 22 Aug 2019 10:10:43 +0000 (13:10 +0300)]
musl-imported: Add original copyright

Given that there are and will be lots of files imported from musl, we add the
original copyright so that adding the licenses on the imported files will not be
necessary unless there will be a reasonable number of changes.

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 agomusl-imported: Add bits/alltypes.h
Costin Lupu [Thu, 22 Aug 2019 10:10:42 +0000 (13:10 +0300)]
musl-imported: Add bits/alltypes.h

Most of the musl headers need a 'bits/alltypes.h' header. In order to avoid
changing this include directive, we use a trick: we add our own
'bits/alltypes.h' header which simply includes 'sys/types', where our types are
defined.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Charalampos Mainas <charalampos.mainas@neclab.eu>
5 years agoglue: Suppress 'unused parameters' warnings
Costin Lupu [Thu, 22 Aug 2019 10:10:41 +0000 (13:10 +0300)]
glue: Suppress 'unused parameters' warnings

It's simpler to suppress the warning rather than add '__unused' qualifier each
time.

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

Signed-off-by: Charalampos Mainas <charalampos.mainas@neclab.eu>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agosys/sysmacros.h: Import from musl
Vlad-Andrei BĂDOIU (78692) [Thu, 22 Aug 2019 20:02:43 +0000 (20:02 +0000)]
sys/sysmacros.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 Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
5 years agosyslog.c: Fix checkpatch warnings
Costin Lupu [Wed, 14 Aug 2019 18:57:05 +0000 (21:57 +0300)]
syslog.c: Fix checkpatch warnings

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agosyslog.c: Add licenses
Costin Lupu [Wed, 14 Aug 2019 18:57:04 +0000 (21:57 +0300)]
syslog.c: Add licenses

We add the BSD license of OsV and the MIT license of musl.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agosyslog.c: Make it compile
Costin Lupu [Wed, 14 Aug 2019 18:57:03 +0000 (21:57 +0300)]
syslog.c: Make it compile

* Use Unikraft mutex
* Replace __syslog_chk() with syslog()

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agosyslog.c: Import from osv
Costin Lupu [Wed, 14 Aug 2019 18:57:02 +0000 (21:57 +0300)]
syslog.c: Import from osv

Copied as is from the official osv git mirror
https://github.com/cloudius-systems/osv.git, commit ee7a2cd4.

Original file locations:
* libc/syslog.c

We had to decide between importing from musl or osv. We decided to pick the osv
variant because it's simpler: it outputs to stdio. The musl implementation uses
UNIX sockets, which we currently don't have in Unikraft. Moreover, the osv
implementation was originally imported from musl and adapted. This is also the
reason why we put the file under the musl-imported/ subdirectory.

In the future, a better syslog implementation may replace this one and it might
even become an internal library with fully fledged functionality, just like
classic OSes.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agosyslog.h: Adapt to Unikraft
Bogdan Lascu [Wed, 14 Aug 2019 18:57:01 +0000 (21:57 +0300)]
syslog.h: Adapt to Unikraft

* Fix include
* Add licenses

Signed-off-by: Bogdan Lascu <lascu.bogdan96@gmail.com>
Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agosyslog.h: Import from musl
Bogdan Lascu [Wed, 14 Aug 2019 18:57:00 +0000 (21:57 +0300)]
syslog.h: Import from musl

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

Original file locations:
* include/sys/syslog.h
* include/syslog.h

Signed-off-by: Bogdan Lascu <lascu.bogdan96@gmail.com>
Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoAdd licenses to source files and the source files to Makefile.uk
Costin Lupu [Mon, 5 Aug 2019 15:17:50 +0000 (18:17 +0300)]
Add licenses to source files and the source files to Makefile.uk

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoImport tcgetattr() and tcsetattr() functions from musl
Costin Lupu [Mon, 5 Aug 2019 15:17:49 +0000 (18:17 +0300)]
Import tcgetattr() and tcsetattr() functions from musl

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

Original file locations:
* src/termios/tcgetattr.c
* src/termios/tcsetattr.c

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoAdapt termios.h headers to newlib glue code
Costin Lupu [Mon, 5 Aug 2019 15:17:48 +0000 (18:17 +0300)]
Adapt termios.h headers to newlib glue code

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoImport termios.h from musl
Costin Lupu [Mon, 5 Aug 2019 15:17:47 +0000 (18:17 +0300)]
Import termios.h from musl

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

Original file locations:
* include/termios.h

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoMove include/sys/termios.h to musl-imported subdirectory
Costin Lupu [Mon, 5 Aug 2019 15:17:46 +0000 (18:17 +0300)]
Move include/sys/termios.h to musl-imported subdirectory

We move include/sys/termios.h in order to make it consistent with the musl
directory structure.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoAdapt and use musl ioctl.h headers
Costin Lupu [Mon, 5 Aug 2019 15:17:45 +0000 (18:17 +0300)]
Adapt and use musl ioctl.h headers

The lwip library has its own definition for SIOCATMARK which we cannot
overwrite, so we avoid using our own in that case. Also, the same
definition for winsize structure is already provided by the musl
headers, so we stick to those.

This patch also adds licenses for the musl ioctl.h headers.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoImport ioctl.h headers from musl
Costin Lupu [Mon, 5 Aug 2019 15:17:44 +0000 (18:17 +0300)]
Import ioctl.h headers from musl

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

Original file locations:
* arch/generic/bits/ioctl.h
* include/sys/ioctl.h

We introduce a new approach for the source files imported from musl. All of
them will be put in the musl-imported/ subdirectory, keeping the original
directory structure from musl.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoMakefile.uk: Remove useless include directives
Costin Lupu [Mon, 5 Aug 2019 15:17:43 +0000 (18:17 +0300)]
Makefile.uk: Remove useless include directives

The removed lines from Makefile.uk do not have any kind of effect because
$(LIBNEWLIBGLUE) is not a configuration flag.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoExports lstat and mknod
Gaulthier Gain [Mon, 5 Aug 2019 12:14:28 +0000 (14:14 +0200)]
Exports lstat and mknod

This patch exports lstat and mknod declaration and allows to
support sqlite.

Signed-off-by: Gaulthier Gain <gaulthier.gain@uliege.be>
Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
5 years agoExpose getline
Felipe Huici [Tue, 30 Jul 2019 14:45:22 +0000 (16:45 +0200)]
Expose getline

Signed-off-by: Felipe Huici <felipe.huici@neclab.eu>
Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
5 years agoRemove sigfillset() stub
Florian Schmidt [Mon, 3 Jun 2019 12:16:36 +0000 (14:16 +0200)]
Remove sigfillset() stub

As a result of patch 9049be5a9330 ("Yet another try to fix the __rtems__
shenanigans"), sigfillset should now always be available as a define
when including signal.h. In fact, if plat.c includes, in a roundabout
way, signal.h, then the build fails. So remove this stub.

Signed-off-by: Florian Schmidt <florian.schmidt@neclab.eu>
Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
5 years agoImplement isatty
Vlad-Andrei BĂDOIU (78692) [Sun, 2 Jun 2019 16:13:17 +0000 (16:13 +0000)]
Implement isatty

Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
5 years agoAdd missing stubs needed by CPython2
Vlad-Andrei BĂDOIU (78692) [Sun, 2 Jun 2019 16:13:16 +0000 (16:13 +0000)]
Add missing stubs needed by CPython2

This patch adds a number of stubs needed by CPython2 to compile.

Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
5 years agoAdd signal related stubs
Vlad-Andrei BĂDOIU (78692) [Sun, 2 Jun 2019 16:13:15 +0000 (16:13 +0000)]
Add signal related stubs

This patch adds a new file signal.c which contains stubs related to signals.

Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
5 years agoAdd device related stubs
Vlad-Andrei BĂDOIU (78692) [Sun, 2 Jun 2019 16:13:14 +0000 (16:13 +0000)]
Add device related stubs

This patch adds a new file dev.c which contains stubs related to devices.

Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
5 years agoAdd sysexits.h
Vlad-Andrei BĂDOIU (78692) [Sun, 2 Jun 2019 16:13:14 +0000 (16:13 +0000)]
Add sysexits.h

The header was taken from newlibc, release version 2.5.0.20170922.

Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
5 years agoImplement usleep
Vlad-Andrei BĂDOIU (78692) [Thu, 30 May 2019 11:38:50 +0000 (11:38 +0000)]
Implement usleep

Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agopatches: Fix setgroups declaration in origin
Costin Lupu [Wed, 29 May 2019 16:37:25 +0000 (19:37 +0300)]
patches: Fix setgroups declaration in origin

It seems that the setgroups() declaration is not POSIX. The patch fixes
that.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoRemove functions provided by internal Unikraft libs
Costin Lupu [Wed, 29 May 2019 16:37:24 +0000 (19:37 +0300)]
Remove functions provided by internal Unikraft libs

* User functions, such as getpwnam(), are provided by ukunistd
* pathconf() and sysconf() are provided by uksysinfo

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agopoll.h: Include lwip/sockets.h if lwIP is available
Florian Schmidt [Tue, 28 May 2019 07:55:32 +0000 (09:55 +0200)]
poll.h: Include lwip/sockets.h if lwIP is available

for POLLIN and friends.

Signed-off-by: Florian Schmidt <florian.schmidt@neclab.eu>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoSilence unused parameter warnings
Florian Schmidt [Tue, 28 May 2019 07:55:31 +0000 (09:55 +0200)]
Silence unused parameter warnings

Signed-off-by: Florian Schmidt <florian.schmidt@neclab.eu>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoYet another try to fix the __rtems__ shenanigans
Florian Schmidt [Tue, 28 May 2019 07:55:30 +0000 (09:55 +0200)]
Yet another try to fix the __rtems__ shenanigans

Originally, we defined __rtems__ in sys/stat.h because we wanted it to
provide st_{a,c,m}tim in struct stat. That lead to some unintended side
effects, so we reduced the scope to only that header file by
conditional-defining-and-undefining. It turns out even that has
unintended side effects regarding the definition of sigaddset etc.

Considering that we're not really the RTEMS OS, let's try this the other
way round and provide a patch instead that unconditionally gives us
st_{a,c,m}tim, and to not touch __rtems__ definitions.

Signed-off-by: Florian Schmidt <florian.schmidt@neclab.eu>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoAdd poll() and select() support via lwIP if available
Florian Schmidt [Tue, 28 May 2019 07:55:29 +0000 (09:55 +0200)]
Add poll() and select() support via lwIP if available

Otherwise, provide dummy stubs.

Signed-off-by: Florian Schmidt <florian.schmidt@neclab.eu>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoGlue code for getpwnam()
Florian Schmidt [Tue, 28 May 2019 07:55:28 +0000 (09:55 +0200)]
Glue code for getpwnam()

Signed-off-by: Florian Schmidt <florian.schmidt@neclab.eu>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agoAlign POLL* values in glue code with musl.
Florian Schmidt [Tue, 28 May 2019 07:55:27 +0000 (09:55 +0200)]
Align POLL* values in glue code with musl.

In turn, this helps lwip with its own definitions to not conflict with
either of these libc implementations.

Signed-off-by: Florian Schmidt <florian.schmidt@neclab.eu>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
5 years agobuild: export -D__DYNAMIC_REENT__ to global C[XX]FLAGS if used
Florian Schmidt [Fri, 10 May 2019 08:49:38 +0000 (10:49 +0200)]
build: export -D__DYNAMIC_REENT__ to global C[XX]FLAGS if used

__DYNAMIC_REENT__ is used as a preprocessor flag in several public
header files (most importantly, stdio.h). This means that if newlib is
compiled with one set of flags and the rest of the build with another,
the header file and the implementation don't match. This leads to
problems such as stdin/stdoud/stderr not working because they always use
the (non-functional) versions inside _impure_data instead instead of the
current environment's private _reent struct.

Signed-off-by: Florian Schmidt <florian.schmidt@neclab.eu>
Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
6 years agoRemove functions provided by libvfscore
Vlad-Andrei BĂDOIU (78692) [Thu, 18 Apr 2019 11:09:54 +0000 (11:09 +0000)]
Remove functions provided by libvfscore

The core patch 'lib/vfs: expose remaining vfs functions'
provides additional functions which are currently stubs
in newlib's gluecode. This patch removes the stubs.

Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
6 years agoFix fwrite's return value for newline ended strings
Vlad-Andrei BĂDOIU (78692) [Wed, 10 Apr 2019 11:22:05 +0000 (11:22 +0000)]
Fix fwrite's return value for newline ended strings

Fwrite does not return the correct number of items
written. If we pass a string that ends in '\n' we
get n - 1(the '\n') for a string of length n.
That is because __sputc_r returns EOF for the
the newline character. This patch solves the problem
by increasing the variable i if  __sputc_r returned
EOF when p[i] is '\n'.

Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
6 years agoRemove readdir stub function
Florian Schmidt [Fri, 12 Apr 2019 07:09:00 +0000 (09:09 +0200)]
Remove readdir stub function

This is provided by vfscore, on which newlib has a dependency.

Signed-off-by: Florian Schmidt <florian.schmidt@neclab.eu>
Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
6 years agoSuppress code style warnings when using GCC 6, 7 or 8
Simon Kuenzer [Wed, 10 Apr 2019 09:27:39 +0000 (11:27 +0200)]
Suppress code style warnings when using GCC 6, 7 or 8

Supress code style warnings for external libnewlib sources when using
GCC 6, GCC 7, or GCC 8. The new warning suppression flags are
introduced depending on the GCC version that is in use.
Additionally, this patch name spaces `SUPPRESS_FLAGS` to
`LIBNEWLIB_SUPPRESS_FLAGS-y` and we remove the double definition of
`-Wno-implicit-function-declaration`.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
6 years agoAdd libvfscore as dependency
Simon Kuenzer [Wed, 10 Apr 2019 08:32:37 +0000 (10:32 +0200)]
Add libvfscore as dependency

The current implementation requires libvfscore to be selected. Without
libvfscore `read`, `write`, `close`, and `fstat` are undefined and
linking fails. With this commit we also fix a typo in the dependency
definition to libukalloc.

Signed-off-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Reviewed-by: Sharan Santhanam <sharan.santhanam@neclab.eu>
6 years agoRemove stub for opendir
Felipe Huici [Fri, 5 Apr 2019 18:25:04 +0000 (20:25 +0200)]
Remove stub for opendir

The opendir function is now provided by Unikraft's vfs library,
remove the stub from newlib to prevent multiple definition errors.

Signed-off-by: Felipe Huici <felipe.huici@neclab.eu>
Reviewed-by: Costin Lupu <costin.lupu@cs.pub.ro>
6 years agoImplement gettimeofday, clock_gettime, sleep
Florian Schmidt [Wed, 3 Apr 2019 12:16:39 +0000 (14:16 +0200)]
Implement gettimeofday, clock_gettime, sleep

The implementations are taken from nolibc.

Signed-off-by: Florian Schmidt <florian.schmidt@neclab.eu>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
6 years agoFix selectively included type definitions
Florian Schmidt [Tue, 26 Mar 2019 13:51:36 +0000 (14:51 +0100)]
Fix selectively included type definitions

The newlib glue code uses code originally taken from musl. In musl, the
way to selectively include certain data types from those defined in
types.h is through the use of __NEED_* macros. Newlib uses a different
approach: it provides all definitions as underscored variants via
sys/_types.h, and the header files then typedef them over to the normal
variants as needed, with preprocessor guards around each of them to
provent duplications.

Replace the __NEED macros (which are effectively noops, so none of those
data types ever got properly defined in those headers) with the newlib
_types solution.

Signed-off-by: Florian Schmidt <florian.schmidt@neclab.eu>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
6 years agoUse Unikraft __getreent() when scheduling is enabled
Costin Lupu [Fri, 22 Mar 2019 14:11:07 +0000 (16:11 +0200)]
Use Unikraft __getreent() when scheduling is enabled

When scheduling is enabled, Unikraft provides the __getreent() function.

The current patch also fixes the compilation warnings that occur
because of __DYNAMIC_REENT__ redefinition when __rtems__ is defined.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Florian Schmidt <florian.schmidt@neclab.eu>
6 years agoAdd stubs for C++ libraries
Vlad-Andrei BĂDOIU (78692) [Thu, 21 Mar 2019 15:34:56 +0000 (15:34 +0000)]
Add stubs for C++ libraries

This patch adds the missing stubs needed by the
C++ llvm libraries. It creates a new locale.c
file for the stubs related to the locales.
This patch adds the missing include
to stddef inside mman.h.

Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@stud.acs.upb.ro>
Reviewed-by: Felipe Huici <felipe.huici@neclab.eu>
6 years agoFix __rtems__ usage in glue code headers
Costin Lupu [Thu, 14 Mar 2019 09:41:00 +0000 (11:41 +0200)]
Fix __rtems__ usage in glue code headers

In order to use __rtems__ one has to define it in all affected headers.
Besides 'sys/stat.h', we also identified 'time.h'. Moreover, we define
__rtems__ only if it was not previously defined.

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
6 years agoEnable setjmp and longjmp support
Costin Lupu [Sun, 10 Mar 2019 14:33:06 +0000 (16:33 +0200)]
Enable setjmp and longjmp support

Signed-off-by: Costin Lupu <costin.lupu@cs.pub.ro>
Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
6 years agoadd declarations needed for vfscore in the gluecode RELEASE-0.3.1
Yuri Volchkov [Tue, 5 Mar 2019 18:29:55 +0000 (19:29 +0100)]
add declarations needed for vfscore in the gluecode

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Florian Schmidt <florian.schmidt@neclab.eu>
6 years agoupdate newlib glue for use with vfscore
Yuri Volchkov [Tue, 5 Mar 2019 18:29:54 +0000 (19:29 +0100)]
update newlib glue for use with vfscore

Consists of multiple fixes:
  - remove stubs of the functions provided by vfscore
  - import mount.h, statfs.h, uio.h from nolibc (minimal changes)
  - add stub for sigfillset

Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu>
Reviewed-by: Florian Schmidt <florian.schmidt@neclab.eu>