Remove the function wrappers around the 64 bit math and just use C
syntax natively, combining ops where appropriate (e.g. there was a
sequence implementing "(x<<2+x)<<2" to do "multiply by 10"). The
_ldiv5 and _rlrshift routines are non-standard ops that provide useful
abstraction, so they remain as separate functions.
Change-Id: I4d83847348fdd7be09887b833c8ccbd2aa1e4182
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
The _to_float() implementation had a somewhat kludgey hand-written 64
bit math implementation, which is unhelpful on Zephyr as all our
toolchains provide a working uint64_t runtime. This is at best just
dupicated code from libgcc, and at worst less efficient.
This patch replaces the existing 64 bit minilibrary but keeps the
uint32_t[2] API as is for ease of validation and review.
One exception is _ldiv5, a specialized divide-by-five implementation.
The 64 bit division routines are large on some architectures (ARM and
ARC in particular), not pulled in by a default Zephyr build, and will
swamp the benefit from this patch. So this includes a
refactored/improved _ldiv5 which leverages libgcc for multiword shifts
instead of just using raw division.
Note also the "noinline" attribute on _ladd(). This is a workaround
for an apparent compiler bug when built with -Og or -Os (hand-hacking
the Makefiles to build with -O0 works), perhaps due to my aliasing the
int array with a long long. This will go away in phase 2.
Change-Id: I63e8c82dabe2bfaa75b63ddb59e5f11d51be538e
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
The _to_float routine was apparently written to be able to take a 32
bit float bit representationa as well as a 64 bit double. But in a
printf routine, that can never happen per the C standard (where floats
are always promoted to doubles in varargs context).
This was just hard-configured to 1 at the top of the file, and nothing
else in the project sets "DOUBLE" to try to change it. Just remove
it. If we ever want code to convert a float to a double in memory so
we can use this routine, we have it in libgcc. Or even in hardware on
the FPU where available.
Change-Id: I796814c0fce3ce96faa34fde8da411a28c826699
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
Hex, octal and decimal all had separately implemented reduction loops
to generate strings. With only a little work these can all be unified
to a single implementation that works with an arbitrary base.
Performance is probably a little lower owing to the fact that
hex/octal now requires a division per character, and the extra
"reverse the string" trick at the end of the conversion. But code
size savings are substantial.
Change-Id: I11ff376aeca1483f974d328271e19918221b2a41
Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
The 'z' length specifier is the appropriate one to be used with size_t
(%zu) and ssize_t (%zd) types. Having support for this in our libc
means that we can utilize the compiler format string checks
(__printf_like) without getting warnings of incorrect format
specifiers for size_t and ssize_t variables.
Change-Id: I73fec0145692e0a59934cab548caf24c1c16a3df
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This implements a subset of the standard inttypes.h, based on what
other functionality exists in minimal libc.
Change-Id: Ib5685a6da13768ee46acbfca734d145f7018b9e0
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
The default offsetof() implementation generates a warning
(variably modified <variable> at file scope) when used in
to define the size of an array. By using this builtin with
GCC we avoid the warning and make sure no variable-size
arrays are used.
Change-Id: Iae215f777241f7daaa061067230086dffaa8311d
Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
This is an adaptation of
net/ip/tinydtls/platform-specific/config-zephyr.h to allow external
imports such as KSDK to include assert.h.
Change-Id: I0afee37deb79447363037ba6b4bb9cdbc629be3a
Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
The strstr function finds the first occurrence of a substring
in another string, null terminated strings are not compared, this
function is added for compability for porting other libraries (like
mbedtls)
Jira: ZEP-327
Origin: http://www.leidinger.net/freebsd/dox/libkern/html/d3/d29/
strstr_8c_source.html
Change-Id: I52aac218ce0bd86373ec60f5afc49a92c85f6319
Signed-off-by: Sergio Rodriguez <sergio.sf.rodriguez@intel.com>
We get these out of system.h instead. A clause in libc-hooks.c
for newlib added since we don't get RAM size from
CONFIG_SRAM_BASE_ADDRESS.
Change-Id: Ic35113395b951f625e8e29658afe19c525037964
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
Some variants of newlib build and expect namespace protected stubs
(typically having an underscore prefix). To support such newlib variants
change all the stubs to the namespace protect version and use function
aliases to support the nonprotected namespace version.
Change-Id: I6a4162eca949afec96b152ffe6f60b87c4496c4d
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
We only need to implement fstat(), so drop the _fstat implementation and
have fstat() match the newlib docs for minimal implementation and only
set st_mode = S_IFCHR.
Change-Id: Iba9042707d1ee5975ab98293cfe20e2996b17c05
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Tinycrypt is maintained at github and thus should be treated as an
external library and hosted under ext/.
Change-Id: I4c4a3bcdacf01d4922919e5ea1f9dec21a19cd37
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
ecc_make_key declaration has random size of NUM_ECC_DIGITS * 2 but
definition has (and use) only NUM_ECC_DIGITS.
Change-Id: I18f0d7992b21a2ed7ed99851b1b795cff0a08a10
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
For CMSIS we now have HAS_CMSIS which needs to be added to the
SoC definition.
Instead of changing the main Makefile we now include a sub-Makefile
with all related header and library paths that are hosted in
ext/
Move redifintion of LIB_INCLUDE_DIR later to get variables defined
in Makefile.toolchain.*
Change-Id: I9f90f90247c2a66b4565427b89d4e1d4dd5c9622
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Convert leading whitespace into tabs in Kconfig files. Also replaced
double spaces between config and <prompt>.
Change-Id: I341c718ecf4143529b477c239bbde88e18f37062
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Cleanup main Makefile and remove all library related code to
lib/ to better support the increasing number of libraries and
to keep the main Makefile clean from library dependencies.
Jira: ZEP-308
Change-Id: Id83cf309020604b8eab8d80cad0021905d5b5f7a
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
tinycrypt was built using the lib- scripts without any real benefit. We
also had a wrong placement of the Kconfig files under misc/ and a Kconfig
file for Crypto that was never used before.
Change-Id: I82d5902d92e7c06e10a95f418d9ead3cbcabcce4
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Although it's unclear why x86 has a different naming convention,
this scales better.
Change-Id: I939b9d4d04b1833391304700a7c12c9c8607192f
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
The RAM config symbols need to be updated as they were named by the
commit:
1a1f7fd arc: make SRAM/DCCM values configurable
Change-Id: Ieeb06de2f77b4c9e10a0bc32d8318834ce150f5e
Signed-off-by: Bogdan Davidoaia <bogdan.m.davidoaia@intel.com>
Basic build framework for Nios2. Everything is stubbed out,
we just want to have a build going so that we can start to
parallelize implementation tasks.
This patch is not intended to be functional, but should be
able to produce a binary for all the nanokernel-based
sanity checks.
Change-Id: I12dd8ca4a2273f7662bee46175822c9bbd99202a
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
When capping the the absolute value of the width modifier in printf(),
it must first be cast to an 'unsigned'. This stems from the fact that
in two's complement, not all negative numbers have a positive counterpart.
Change-Id: I3e6f92f68ab1b8dab48bbf883c5ad4b078a93f87
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
Add definition for the POSIX standard off_t type.
Change-Id: I1142428a3d226d641a8628cbba71cb3ea341ef92
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
There's no need to have a separate file for this, and we'll be adding
other types like off_t here soon as well.
Change-Id: I40629a5a0fba7af44828eaeead294e4e55844bb0
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Some parts of Newlib, notably the locale handling stuff, will try to
call open(), and if it's not provided, any application that for some
reason is bringing in that code will fail to link.
Having a non-working implementation keeps that code working.
Change-Id: I28345dabb93431d6b80c839b23a46b7f99dc8734
Signed-off-by: Iván Briano <ivan.briano@intel.com>
Use linker symbol and board configs to determine the start
and extent of remaining RAM present in a board and use
it as newlib's heap.
Change-Id: I7128cf2857664331d83f212f27e8af7ad3bb8936
Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
While we don't have a proper heap that can make use of all the
available RAM, make it possible for applications using Newlib to
configure the size of the heap exposed via the sbrk() hook.
Change-Id: I4e3193c1f2df0ace1dbc5b1f6ceb2cdc61479762
Signed-off-by: Iván Briano <ivan.briano@intel.com>
Add definition for ssize_t that may be useful to represent sizes with
variables that also need to be able to have negative values (e.g. to
represent errors).
Change-Id: I52ec69591ccfd760021dad38f5ba1b1ebe707ea5
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Summary lines follow the @brief tag instead of the @file tag.
This prevents doxygen build warnings such as ...
The name xxx supplied as the second argument in the \file
statement is not an input file
Change-Id: I1014586ad21be12e14aa1d2a942e6b8a11211795
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
Common ecc.c code was not compiled resulting in following link error:
crypto/tinycrypt/lib.a(ecc_dh.o): In function `ecc_make_key':
crypto/tinycrypt/source/ecc_dh.c:50: undefined reference to `vli_set'
crypto/tinycrypt/source/ecc_dh.c:51: undefined reference to `curve_n'
crypto/tinycrypt/source/ecc_dh.c:51: undefined reference to `vli_sub'
crypto/tinycrypt/source/ecc_dh.c:54: undefined reference to `curve_n'
crypto/tinycrypt/source/ecc_dh.c:54: undefined reference to `vli_cmp'
crypto/tinycrypt/source/ecc_dh.c:53: undefined reference to `vli_cond_set'
crypto/tinycrypt/source/ecc_dh.c:56: undefined reference to `vli_isZero'
crypto/tinycrypt/source/ecc_dh.c:62: undefined reference to `curve_G'
...
Change-Id: Ib590fd7330753c0ae8ef54159b0f2b7461b5b38e
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
The libc 'ctype.h' header file is not supposed to be automatically
included when including 'stdlib.h'.
Change-Id: I821a9946894572a7b82804b1569b7b18c24316db
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
Adding in a README file for the external library of TinyCrypt providing
details for origin, commit id, and where to find the original.
Source: Original to Zephyr Project
Change-Id: Ibc7ec33f7f459e8df88978b5b4505e67a2141998
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
Updates the minimal libc headers for differences between the C and C++
languages. This includes ...
1. Conditionally defining "bool", "true" and "false" as they are
already keywords in C++.
2. Making the definition of NULL language dependent.
3. Using the _Restrict macro instead of the restrict keyword as
restrict exists in C, but not in C++.
4. Changing the definition of size_t so that it is compatible with
what the compiler expects when building the new operator stubs
(as it varies by architecture).
Change-Id: I37ff058a60b90a05f96e9dd6f61d454d143041ce
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
Consolidates the definitions of size_t in the minimal libc library.
This prevents code duplication.
Change-Id: I996990ad9093ebec1f9ba0045d14319e1a243e70
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
Consolidates definitions of NULL in the minimal libc library.
This prevents code duplication.
Change-Id: Ia4a2bde1329d66e7c83afeab806a39b22704ab48
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
Adds extern "C" { } blocks to header files so that they can be
safely used by C++ source files.
Change-Id: Ia4db0c36a5dac5d3de351184a297d2af0df64532
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
This patch renames the 'exit' function from newlib/libc-hooks.c to
'_exit' since this is the correct name of the newlib system call.
This patch fixes some linking errors that occur when an applications
uses abort() or assert().
Change-Id: I593e5ec5dc0f84dbbebe4aceb38703256e140914
Signed-off-by: Andre Guedes <andre.guedes@intel.com>
Add a simple implementation of isprint() which is used to test for a
printable character.
Change-Id: I0ebca10ec0f8e43ee245f6508c5b82c6e207bd32
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Provides proper access to the per-thread errno variable, by using the
_get_errno() call.
Users can now do:
errno = EINVAL;
printk("errno: %d\n", errno);
Change-Id: I0ef365199656d002623b39b7f45f14f561501375
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
The previous implementation mistakenly kept outputting the first
character of the string endlessly.
Change-Id: I299c627a52158218be8e88c952935edb87a636fe
Suggested-by: Tom Yeon <tom.yeon@windriver.com>
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Change-Id: I34a54230bc4a63c8a4391d03ff530835910c3705
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Change-Id: Ib3f69be9f9273e57952a3ebceebc82d84c607c64
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Change-Id: I6da43e41f9c6efee577b70513ec368ae3cce0144
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Change all the Intel and Wind River code license from BSD-3 to Apache 2.
Change-Id: Id8be2c1c161a06ea8a0b9f38e17660e11dbb384b
Signed-off-by: Javier B Perez Hernandez <javier.b.perez.hernandez@linux.intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
Passing checkpatch check to use tabs instead of spaces for everything.
Change-Id: Ieffa0b0cc4b24598e7cbce7edf9ed640c8fb27dd
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
Moving the includes to include/tinycrypt. This will help make it
clear when looking at source files where each header originated from.
Change-Id: Ic79978da286f9c288868074a69262d89488925b8
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
This commit breaks the sanitychecks
This reverts commit 93fa1053b21efe3d030ea060a31b80d6008d5bfd.
Change-Id: Ia52092e845c33234817a1cb27cd1f17064c65e7e
Signed-off-by: Anas Nashif <nashif@linux.intel.com>
Passing checkpatch check to use tabs instead of spaces for everything.
Change-Id: I2fdd507d48db83fda8d183043c5a4ab1b97148dc
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
Moving the includes to include/tinycrypt. This will help make it
clear when looking at source files where each header originated from.
Change-Id: I062cb3c6ecc5bc2ed2d28228d5926646b6b5f912
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
Fixes the tinycrypt library to use Zephyr checkpath acceptable line
lengths.
Change-Id: Ia7bef46a39fa029cda826ec5b2d7d42036d9bdfe
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
Do not use local _isdigit function, use public isdigit
instead.
Change-Id: Ifc2721fc2def429de4934c9855f08dae30326694
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This option adds optional libc functions that are not directly
used by the kernel but can be used for testing purposes.
This option is experimental.
Change-Id: Ia4dba718359c4f381047a5b52ebddb26d87ea75a
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Add function for comparing two strings ignoring case.
Change-Id: I2fc78c0a0d0f53e23566ffacd8dca3b23e386c26
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Needed by CoAP implementation in net/ip/er-coap
Change-Id: I724bc7569a29c35f386bbc301d883a000882de78
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This will allow adding more libc implementations in the future.
Also use the location of the include directory from the toolchain
settings.
Change-Id: Idae5e4ffd9b1bcb5e924da156df56e81f10c8842
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
The way we build the libc files is not a real library that can be
used as a libc and makes managing the source files a bit
difficult, so lets revert back to building the c function files
like everything else in the system to avoid any confusion.
Change-Id: I4e998e37bc376522fe253c4aefefe7804597f0f2
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Remove function name from comment and add @brief instead.
Also capitilize first letter.
Change-Id: Ib708b49bf02e5bc89b0066637a55874e659637e0
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Previous comment style used RETRURNS:, use @return to comply
with javadoc style.
Change-Id: Ib1dffd92da1d97d60063ec5309b08049828f6661
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
The change replaces multiple asterisks to ** at
the beginning of comments and adds a space before
the asterisks at the beginning of lines.
Change-Id: I7656bde3bf4d9a31e38941e43b580520432dabc1
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Add a tolower implementation that may be used in various parts of the
operating system.
Change-Id: I5aa855b41e2a09fcb077860b4580dbe1e6d4a093
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Revises kernel so that it uses the standard boolean type library
defined for C99, rather than having its own custom boolean type.
Also revises sample projects that used the non-standard type.
Change-Id: Ib41b7f836da25352aa5ae9dfbbfdd29739017b6f
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Builds upon the approach taken by the x86 version of k_memset()
and k_memcpy() APIs, which uses word-sized operations for greater
efficiency when manipulating large buffers. The algorithms used
here are architecture-independent.
Change-Id: I01ea8b22c8e6028f881e9b61ccc3a01e8ba4c02b
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
This options allows us to link against newlib instead of the
integrated minimal c library.
Change-Id: I20990354d74c08f2f6348f0aeea452b8f0f4c8e9
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit changes the way libc is built.
Instead of building a hierarchy of objects linked into the
microkernel, libc minimal is built as a static library and
linked against the microkernel binary.
The location of the libc is configurable with the variable
KLIBC_DIR. This gives the flexibility to build against a
different libc other than minimal.
Change-Id: I9c0b6a684a9f3b407861aa387727c45eceb269c4
Signed-off-by: Juan Manuel Cruz <juan.m.cruz.alcaraz@linux.intel.com>
TiMo is very ambigous, be generic and call it kernel.
Change-Id: I66b3e436afbc89e874f31a89b98cc04aa821c787
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit adds the Makefiles to create object-bundle for
libc minimal.
Signed-off-by: Juan Manuel Cruz <juan.m.cruz.alcaraz@linux.intel.com>
Change-Id: I9d15e0203664010ba4ef5cf3625b4075d7827ad7
The previous implementation would read one byte past both buffers if
the buffers were equal. Make sure the pointers are not incremented
past the last byte. Also ensure that comparing zero bytes always
returns 0.
Change-Id: I5ef25d6bd2f7417b60102dc1c2602d8b23c4c1bc
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Add a memcmp implementation that may be used in various parts of the
operating system.
Change-Id: I784bdcb26b924b2513ecd0b3ce1898195453f755
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Line's length should be shorten than 100 characters. This commit
fixes these lines separating them into two parts.
Change-Id: Ic68c9086866cd778187aa1465470acc0485e2271
Signed-off-by: Yonattan Louise <yonattan.a.louise.mendoza@intel.com>
Spaces between the function name and the open parenthesis are not allowed.
This commit fixes the case where only one open parenthesis with leading
whitespaces is present in the line.
#!/bin/bash
checkpatch_script="$VXMICRO_BASE/scripts/checkpatch.pl --mailback --no-tree -f --emacs --summary-file --show-types --ignore BRACES,PRINTK_WITHOUT_KERN_LEVEL,SPLIT_STRING --max-line-length=100 "
for file in $(find ./ -name "*.[ch]" ! -path "./scripts/*" ! -path "./host/src/wrsconfig/*");
do
# fixing spaces between function name and open parenthesis
for line in $(eval $checkpatch_script $file | grep "WARNING:SPACING: space prohibited between function name and open parenthesis '('" | cut -d":" -f2)
do
echo "$file : $line"
sed -i ''$line' { /[ \t](.*[ \t](/ b skip_it s/[ \t]*(/(/ ; :skip_it }' $file;
done;
done;
Change-Id: I1e026eaee930e297374e5f2f725b78f29824dee3
Signed-off-by: Yonattan Louise <yonattan.a.louise.mendoza@intel.com>
Enables the section garbage collection compiler flags regardless of the
state of the SECTION_GARBAGE_COLLECTION kconfig option.
Change-Id: Iad488b3ca4ee0a80898f83809e4c615efcdbd03f
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
When the source string is shorter than the maximum number of bytes to copy
to the destination string, strncpy() must fill the remaining bytes in the
destination string with null bytes.
Change-Id: I419d11efd1dd33b1437d1891f1bf2ec7647826ee
Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
This commit changes the pointer's location in order to comply with
the defined coding style.
Signed-off-by: Yonattan Louise <yonattan.a.louise.mendoza@linux.intel.com>
Change-Id: Ibcf1ef0e4fc53b0cb5286b36119e76d017f24cd9
Assignment in if condition should be avoided. The source code is
restructured to have the assignment outside the if condition.
Signed-off-by: Yonattan Louise <yonattan.a.louise.mendoza@intel.com>
Change-Id: I9e3e1d069657d3ce9f54e1f4b4b74163c724a733
Signed-off-by: Anas Nashif <anas.nashif@intel.com>