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.
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.
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>
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>
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>
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.
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>
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.
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.
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>
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>
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>
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>
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>
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.
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
Add the fix of commit 96f68ab in unikraft to newlib:
Calculate the remaining time to sleep and update
the rem parameter if it is given.
If the remaining time is larger than 0, it means that
the thread was waken up explicitly and nanosleep returns -1
to indicate that. Otherwise nanosleep returns 0.
Yuri Volchkov [Fri, 15 Jun 2018 11:51:32 +0000 (13:51 +0200)]
patch: set default _READ_WRITE_RETURN_TYPE to _ssize_t
The vfscore provides the same definitions of functions read/write as
in 'man 2 write'. Newlib used int as a return type of these functions,
which is wrong.
Signed-off-by: Yuri Volchkov <yuri.volchkov@neclab.eu> Reviewed-by: Simon Kuenzer <simon.kuenzer@neclab.eu>