Commit graph

650 commits

Author SHA1 Message Date
Leandro Pereira
1b8f824975 libc: Add isalnum() to ctype.h
The isalnum() primitive is used by the NATS protocol implementation to
vaildate some of the inputs.

This uses primitives that were already in place.

Change-Id: Ib53eeb7ae002a42f5b6aa8d4fc61baca029a042d
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
2017-02-17 20:39:44 +00:00
Anas Nashif
15a6598691 Merge "Merge remote-tracking branch 'origin/core'" 2017-02-15 04:33:25 +00:00
Sergio Rodriguez
f054d3e897 libc/include: Adding time.h
Dummy time.h to fulfill the compilations requirements of certain
libraries i.e. mbedTLS

Change-Id: I07e66dbf07337b935dabe9eecdf1be3850bbf394
Signed-off-by: Sergio Rodriguez <sergio.sf.rodriguez@intel.com>
2017-02-14 08:30:35 +02:00
Mazen NEIFER
44a98fb5fd Xtensa port: Fixed defintion of MAX_HEAP_SIZE, thus, compilation of new_lib.
Xtensa linker script defines _heap_sentry which helps computing the heap size.

Change-Id: Ic35db3c98aaaebe575370fb5479de1a58e6e441e
Signed-off-by: Mazen NEIFER <mazen@nestwave.com>
2017-02-13 11:39:02 -08:00
Anas Nashif
cebc7f95aa newlib: make sure the chain of includes has generated_dts_board.h
Change-Id: I2021a30e1bc16e3eb9fdcc793b908bd0e610d01d
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-02-11 07:00:39 +00:00
Andy Gross
c30b400a16 libc-hooks: Fix include file for arch ARM
This patch adds in the include to get the CONFIG_SRAM definitions on
systems which are using device tree generation.

Change-Id: Ie61efbcdfc900a2c682a2fb8bbaecb61071a20f8
Signed-off-by: Andy Gross <andy.gross@linaro.org>
2017-02-10 23:42:31 +00:00
Andrew Boie
c2a91b1b2e libc: minimal: rename private macro
As it turns out Xtensa SDK headers also define _Restrict, causing
havoc. As this was intended to be a private macro, rename it to something
less likely to cause a collision.

Change-Id: I0a7501a1af8cf87efb096872a91a7b44bd2bbdca
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
2017-02-04 19:22:07 +00:00
Marcus Shawcroft
458e2ed133 libc/minimal: Fix definition of ssize_t
Each GCC target backend is at liberty to define its own SIZE_TYPE. GCC
uses this for various purposes, not lease it drives the machinery that
spits out format specifier diagnostics when format specifiers are
applied to objects with inappropriate type.  GCC exposes the current
definition of SIZE_TYPE via the preprocessor symbol __SIZE_TYPE__.
The GCC build processes also generates various standard library header
files that directyle expose stanard types in a form consistent with
the current configuration of GCC.  Conventionally standard library
build processes (for glibc and newlib) pick up the header files
generated by the GCC build.

In the minimal libc we have no such build process, we don't pick up
the header files that the GCC build process generated.  Instead we
define our own alternative header files and align them with GCC
manually.

The current definition of ssize_t in minimal libc is out of step with
GCC which means that any use of the %z[du] format modifier will issue
a diagnostic.

We replace the open coded architecture detection in minimal libc and
use GCCs __SIZE_TYPE__ directly.

Change-Id: I63b5e17bee4f4ab83d49e492e58efd3bafe76807
Signed-off-by: Marcus Shawcroft <marcus.shawcroft@arm.com>

tests: fs: Fix printf warning when using newlib

Current code uses %ld format specifier to print data of
type ssize_t. This causes type warnings when built with
newlib. The correct format specifier to be used for
ssize_t is %zd.

Change-Id: I02a3c628e3d6e8a36a09cd694220406d8faf1730
Signed-off-by: Ramesh Thomas <ramesh.thomas@intel.com>
2017-02-01 13:57:43 -08:00
David B. Kinder
ac74d8b652 license: Replace Apache boilerplate with SPDX tag
Replace the existing Apache 2.0 boilerplate header with an SPDX tag
throughout the zephyr code tree. This patch was generated via a
script run over the master branch.

Also updated doc/porting/application.rst that had a dependency on
line numbers in a literal include.

Manually updated subsys/logging/sys_log.c that had a malformed
header in the original file.  Also cleanup several cases that already
had a SPDX tag and we either got a duplicate or missed updating.

Jira: ZEP-1457

Change-Id: I6131a1d4ee0e58f5b938300c2d2fc77d2e69572c
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-01-19 03:50:58 +00:00
Anas Nashif
9f418fe944 libc: add support for risc v
Change-Id: Iaaf87ef48057c52478816771836d8d40b2b05554
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-01-13 19:57:19 +00:00
Jean-Paul Etienne
716d25e1e2 libc-hooks: added USED_RAM_SIZE and MAX_HEAP_SIZE definitions for riscv32
added USED_RAM_SIZE and MAX_HEAP_SIZE definitions for
SOC_RISCV32_QEMU and SOC_RISCV32_PULPINO.

Otherwise, not passing sanitycheck

Change-Id: Ia32b12e1694dc472e9f7f9eb10c5f2e12e928c3a
Signed-off-by: Jean-Paul Etienne <fractalclone@gmail.com>
2017-01-13 19:56:44 +00:00
Flavio Santes
ac7300611c net: Restructure network protocols
This commit restructures the network protocols. Changes applied are:

- Move lib/iot/ to subsys/net/lib
- Move network protocol headers to include/net
- Move lib/iot/zoap/link-format.h to include/net/zoap_link_format.h
  and link-format.c to zoap_link_format.c
- Move tests/iot/ to tests/net/lib/
- Adapt sample code
- Adapt build system
- Modify doxygen paths

Change-Id: I37085fa4cc76a8a8e19a499ecb4e87b451120349
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2017-01-02 10:03:19 +01:00
Vinicius Costa Gomes
909ad359bf lib/zoap: Fix incorrect values for payload size
When retrieving the payload length of the payload, there was a mistake,
what was already in the buffer (buf->len) was being considered twice,
net_buf_tailroom() already takes buf->len into account, resulting in
incorrect values.

Change-Id: I3b78d55abca4a448cab5e035b9d66352a3c59110
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2017-01-02 10:03:18 +01:00
Flavio Santes
44b2f212a1 iot/dns: Use a k_sem for the DNS rx routine
This patch introduces a k_sem that will block until:
- data is received, or
- the user-provided timeout expires

This change allows us to simplify our previous DNS client
implementation.

This change is related to ZEP-1357 because we are refactoring the
DNS client API removing the continuous update of the net_context_recv
routine that seems to be causing issues after the kernel's update.

Jira: ZEP-1357

Change-Id: If01c9274ac8f096f0095a2872f86be2e007212ee
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2016-12-16 19:14:53 +01:00
Flavio Santes
5d0900ea93 iot/dns: Update DNS client private routines
This commit updates some DNS client private routines to simplify
function signatures and reduce stack usage. Updated routines now
use the dns_context structure.

Change-Id: Ic0d347ea9d610e85eed4179aee08955cf2302436
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2016-12-16 19:14:52 +01:00
Flavio Santes
0d257a009a iot/dns: Introduce the dns_context structure
This commit introduces the dns_context structure.

This new structure will reduce stack overhead due to
the simplication of the dns_resolve routine signature.

Furthermore, the timeout parameter is now int32_t
instead of uint32_t.

The dns sample application is also updated.

Change-Id: I5d789656bacbd23c4654edce5d116a88dc42c354
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2016-12-16 19:14:52 +01:00
Anas Nashif
fe958df4dd libc: rework libc selection and reduce Kconfigs
Moved all libc Kconfigs to where the code is and remove the default
Kconfig for selecting the minimal libc. Minimal libc is now the default
if nothing else is configured in.

Removed the options for extended libc, this obviously was restricting
features in the minimal libc without a good reason, most of the
functions are available directly when using newlib, so there is no
reason why we need to restrict those in minimal libc.

Jira: ZEP-1440
Change-Id: If0a3adf4314e2ebdf0e139dee3eb4f47ce07aa89
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-12-15 22:31:28 +00:00
Johan Hedberg
71c7c01819 net: buf: Remove the need for net_buf_pool_init()
In order to keep the initialization process light-weight, remove
net_buf_pool_init() and instead perform the initialization of the pool
and buffers in a "lazy" manner. This means storing more information
in the pool, and removing any 'const' members from net_buf. Since
there are no more const members in net_buf the buffer array can be
declared with __noinit, which further reduces initialization overhead.

Change-Id: Ia126af101c2727c130651b697dcba99d159a1c76
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-12-15 09:58:02 +02:00
Stig Bjørlykke
4ca8ca9b1c iot/mqtt: Fix rlen_decode size check.
If receiving a malformed MQTT packet with less than 5 bytes it's
possible to get a read one byte behind buf.

Change-Id: I34425add57c937c8fd9df5bf7b72af092d6f5f32
Signed-off-by: Stig Bjørlykke <stig@bjorlykke.org>
2016-12-14 22:09:19 +01:00
Johan Hedberg
c3e08c8fea net: buf: Redesigned pool & buffer allocation API
Until now it has been necessary to separately define a k_fifo and
an array of buffers when creating net_buf pools. This has been a bit
of an inconvenience as well as blurred the line of what exactly
constitutes the "pool".

This patch removes the NET_BUF_POOL() macro and replaces it with a
NET_BUF_POOL_DEFINE() macro that internally expands into the buffer
array and new net_buf_pool struct with a given name:

	NET_BUF_POOL_DEFINE(pool_name, ...);

Having a dedicated context struct for the pool has the added benefit
that we can start moving there net_buf members that have the same
value for all buffers from the same pool. The first such member that
gets moved is the destroy callback, thus shrinking net_buf by four
bytes. Another potential candidate is the user_data_size, however
right not that's left out since it would just leave 2 bytes of padding
in net_buf (i.e. not influence its size). Another common value is
buf->size, however that one is also used by net_buf_simple and can
therefore not be moved.

This patch also splits getting buffers from a FIFO and allocating a
new buffer from a pool into two separate APIs: net_buf_get and
net_buf_alloc, thus simplifying the APIs and their usage. There is no
separate 'reserve_head' parameter anymore when allocating, rather the
user is expected to call net_buf_reserve() afterwards if something
else than 0 headroom is desired.

Change-Id: Id91b1e5c2be2deb1274dde47f5edebfe29af383a
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-12-13 21:41:53 +00:00
Flavio Santes
b965fb5ff1 iot: Add HTTP support for Zephyr
This commit adds HTTP message handling support for Zephyr.
So, no network routines are involved at this level.

To add HTTP message handling support for Zephyr, we explored the
following options:

1. Importing an external project and perhaps adapting it to fit our
   requirements.
   The criteria to pick one codebase among all the available projects
   are: licensing, correctness and performance.

2. Writing our own implementation from scratch.

We decided to import an external project instead of implementing our
own parser, mainly due to code maturity and correctness. It could take
more time to obtain a production-ready parser from scratch than adapting
a state-of-art library.

The following is a list of some projects offering similar functionality.

lighttpd (many files)
	* License: revised BSD license
	* Supported: active
	* Comments: this parser can't be integrated to Zephyr due to
	  dependencies that currently are not satisficed by our SDK.

nginx (src/http/ngx_http_parse.c)
	* License: 2-clause BSD-like
	* Supported: very active
	* Comments: this parser can't be integrated to Zephyr due to
	  dependencies that currently are not satisficed by our SDK.

wget (src/http-parse.c)
	* License: GPL 3.0
	* Supported: very active
	* Comments: this code can't be included in Zephyr due to
	  licensing issues

curl (lib/http.c)
	* License: MIT/X derivate, see:
	  https://curl.haxx.se/docs/copyright.html
	* Supported: very active
	* Comment: it must be forked and adapted to run in Zephyr.
	  It is not optimized for low-power devices.

nodejs http-parser (http_parser.c)
	* License: nginx license (2-clause BSD-like) and MIT license
	* Supported: very active
	* Comments: optimized with performance in mind.
	  From https://github.com/nodejs/http-parser: "It does
	  not make any syscalls nor allocations, it does not buffer data,
	  it can be interrupted at anytime. It only requires about 40
	  bytes of data per message stream."

So, nodejs/http-parser looks a very good choice for Zephyr. In this
commit, we integrate nodejs' parser to Zephyr.

Origin: https://github.com/nodejs/http-parser/releases/tag/v2.7.1
        https://github.com/nodejs/http-parser/archive/v2.7.1.tar.gz

NOTE:
	This patch reformats the http_parser files to reduce checkpatch
	warnings. Changes made in this refactoring are available at:
Repo:	https://gitlab.com/santes/http_parser/commits/refactoring1
Commit:	9ccfaa23f1c8438855211fa902ec8e7236b702b1

Jira: ZEP-346
Jira: ZEP-776

Change-Id: I29b1d47f323a5841cd4d0a2afbc2cc83a0f576f0
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2016-12-02 12:41:20 +02:00
Vinicius Costa Gomes
b1749afbc2 iot/zoap: Increase the range of timeouts
To avoid the risk of overflowing when dealing with retransmission
timeouts, increase the size of their representation to 32-bits.

Change-Id: I7c9c1e00c41f5ba75e19b0fd4527f273852eb85f
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2016-12-02 12:41:12 +02:00
Flavio Santes
d37b9fa9b5 iot/mqtt: Add the MQTT high-level API
This commit adds the MQTT high-level API with Quality-of-Service
support. The following MQTT messages are covered by this commit:

CONNECT (tx), DISCONNECT (tx), PUBACK (tx, rx), PUBCOMP (tx, rx),
PUBREC (tx, rx), PUBREL (tx, rx), PUBLISH (tx), PINGREQ (tx),
SUBSCRIBE (tx), UNSUBSCRIBE (tx), CONNACK (rx), PINGRESP (rx),
SUBACK (rx) and UNSUBACK (rx).

Where 'tx' stands for transmission: routines that create and send
messages. 'rx' stands for reception: routines that receive an RX
buffer from the IP stack and parse the MQTT mesage contained in
that buffer.

Jira: ZEP-365
Jira: ZEP-591
Jira: ZEP-856

Change-Id: Ibee701a298127eb713aa3fde5aaf7d089ecd1b9d
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2016-12-02 12:41:09 +02:00
Vinicius Costa Gomes
30dec49fd8 iot/zoap: Remove unnecessary cflags
These cflags were only needed when using the old network stack.

Change-Id: I660e397b2648137450c45d4f2edc8ec6ec7ae774
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2016-12-02 12:41:05 +02:00
Vinicius Costa Gomes
ac152ea884 iot/zoap: Add support for RFC6690 link format
RFC6690[1] defines a lightweight format for listing and querying
resources and their relationships.

The RFC defines an '.well-known/core' resource that will list the
resources and their associated metadata. It also allows resources to
filtered by their attributes.

The implementation uses the fact that resources are organized in an
array: only the resources present in the array after the
"ZOAP_WELL_KNOWN_CORE_RESOURCE" will be considered, this allows a
primitive form of visibility control for the attributes.

[1] https://tools.ietf.org/html/rfc6690

Change-Id: I2bc21ddf45f20e1f749d8ac36d247474fdaa9d64
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2016-12-02 12:41:05 +02:00
Vinicius Costa Gomes
ec184107be zoap: Add support for retrieving the underlying net_buf
Add an alternative to zoap_packet_get_payload(), that instead of
returning a byte array, returns the net_buf (with the COAP_MARKER
added, if needed) associated with the packet, positioned so the
application can add more data.

Change-Id: I7c955ef42f5ef8406d77da994d1673e6a69b0b6b
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2016-12-02 12:41:05 +02:00
Flavio Santes
699083140e iot: Add MQTT v3.1.1 packet handling support for Zephyr
This commit adds support for the MQTT protocol v3.1.1.
Specifically, this commit allows a Zephyr application to create
the following MQTT messages:

CONNACK, CONNECT, PUBLISH, PUBACK, PUBREC, PUBREL, PUBCOMP, UNSUBACK,
SUBSCRIBE, SUBACK, UNSUBSCRIBE, PINGREQ, PINGRESP, and DISCONNECT.

Furthermore, the following messages can be parsed by the routines
provided by this commit:

CONNACK, CONNECT, PUBLISH, PUBACK, PUBREC, PUBREL, PUBCOMP, UNSUBACK,
SUBSCRIBE, SUBACK, PINGREQ, PINGRESP and DISCONNECT.

NOTE: client behavior (routines with network access) and QoS will be
integrated in future patches.

The MQTT v3.1.1 specification can be found at:

  http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/mqtt-v3.1.1.html

Origin: Original

Jira: ZEP-365
Jira: ZEP-591
Jira: ZEP-856

Change-Id: Ie0c179370cea22f7554564692bc426a8d5c419d2
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2016-12-02 12:41:03 +02:00
Ravi kumar Veeramally
c689fd6f1a net: Rename net_nbuf_write to net_nbuf_append
Current net_nbuf_write() api just appends data to last fragment. And
doesn't write data based on offset. That's why renaming this api.

New net_nbuf_write() apis based on offset will be coming soon.

Change-Id: Ie8e13e5f6091a279b62b6d8b0b3928a5187e75b0
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2016-12-02 12:40:51 +02:00
Flavio Santes
8b0467a967 iot/dns: Add '+' operator
This commit adds the '+' operator that keeps symmetry with the line
below.

Change-Id: Icb2a5f22b5202597e3e0cc252436b422ce7b44a2
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2016-12-02 12:40:51 +02:00
Vinicius Costa Gomes
ea28e4fccb iot/zoap: Add helper for generating tokens
Most applications will want to use randomly generated tokens, add a
helper for that.

Change-Id: If2a6b1d96596024afd2d2ce8e3632900adfe9c0f
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2016-12-02 12:40:50 +02:00
Vinicius Costa Gomes
dc45748d50 iot/zoap: Port to the native stack
This ports zoap to the native stack.

Just for reference, and totally not scientific, here are the numbers
using the old stack:

$ size outdir/qemu_x86/zephyr.elf
   text	   data	    bss	    dec	    hex	filename
  34657	  10316	  16916	  61889	   f1c1	outdir/qemu_x86/zephyr.elf

With yaip:

$ size outdir/qemu_x86/zephyr.elf
   text	   data	    bss	    dec	    hex	filename
  30575	   9148	   6164	  45887	   b33f	outdir/qemu_x86/zephyr.elf

Jira: ZEP-818

Change-Id: I7992a3e2af7d419081ee5a64d7cc2d49fb628ead
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2016-12-02 12:40:50 +02:00
Vinicius Costa Gomes
f996299754 iot/zoap: Add support for error 4.15
The "Unsupported Content-Format" error was missing from the list of
supported errors.

Change-Id: I208d79f8949838187b877eaa0a53597d8a5bc6cb
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2016-12-02 12:40:50 +02:00
Vinicius Costa Gomes
fa5481b1cb zoap: Fix alignment of multiline function arguments
Change-Id: I0a96c87db84671be1790fda34083e7cd53e00cd0
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2016-12-02 12:40:50 +02:00
Flavio Santes
36bbd7a935 iot/dns: Add DNS Client support for Zephyr
This commit adds support the DNS client API on top of the new
native IP stack. Some features of this implementation are:

- Support for IPv4 and IPv6
- Support for multiple concurrent queries. A net_buf structure is
  required per context. See the DNS_RESOLVER_ADDITIONAL_BUF_CTR
  configuration variable

Origin: Original

Jira: ZEP-793
Jira: ZEP-855
Jira: ZEP-975

Change-Id: I351a636462a1b78a412c9bce1ef3cd0fa6223a52
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2016-12-02 12:40:49 +02:00
Inaky Perez-Gonzalez
b53e6d7774 libc/minimal: snprintf(): KILL negative len parameter
snprintf() implements the ability to foce a negative value through the
(unsigned) size_t len parameter to allow the formatter to use a
maximum size string.

This is point less, we don't have as much memory and this is a recipe
for all kinds of vulnerabilities.

Kill the whole thing, the testcase it represents and thank Coverity
for finding this thing. Whatever use it had before, it has no more.

Change-Id: If422246548664699d8aa328a1b9304ef13cab7ea
Coverity-ID: 131625
Coverity-ID: 131626
Signed-off-by: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
2016-11-28 20:49:37 +00:00
Inaky Perez-Gonzalez
11a52750d3 libc: remove useless code in _prf()
Coverity reported a block of deadcode in _prf() that seems to be a
leftover carcass from a previous time. Replaced with a comment in case
someone decides it was needed back.

Change-Id: Id97e84f3279f807e6188371f27f6af157e6d5038
Coverity-ID: 131631
Signed-off-by: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
2016-11-23 00:57:48 +00:00
Vinicius Costa Gomes
777d57dbfb iot/zoap: Fix decoding of 16-bit delta
When an option code or length representation is encoded in a 16-bit
value, the access was wrong.

Coverity-CID: 151963

Change-Id: Ie7741998cbde348ccf490a6686e68a1ace99920e
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2016-11-18 23:13:08 +00:00
Inaky Perez-Gonzalez
c41d88fd11 libc: atoi() avoid fallthroughs in switch cases
This is a tentative fix for CID 93807, a valid Coverity warning;
however the code is valid too.

We can choose to silence the warning or rewrite the code in a way that
makes it more verbose but keeps Coverity happy.

Coverity complains about doing an implicit fallthrough in switch case
statement. I prefer patching the code to make it explicit, as the
compiler will optimize out, to avoid having to constantly filter out
the checker's warnings.

Coverity-CID: 93807
Change-Id: I7be334d48567bf52fc2b21de043310e0f73b72db
Signed-off-by: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
2016-11-16 22:05:53 +00:00
Juro Bystricky
f3bf5abd52 newlib: add support for nano-formatted-io
If newlib is configured with --enable-newlib-nano-formatted-io,
floating-point support is split out of the formatted I/O code into
weak functions which are not linked by default. This leads to a smaller
code by about 16~20k when using newlib "printf" and/or "sscanf" but not
using floating point I/O.

Programs that need floating-point I/O support must explicitly request
linking of one or both of the floating-point functions:

    _printf_float or _scanf_float.

This can be done at link time using the -u option which can be passed
to either gcc or ld.

Implemented via new configuration options:
    CONFIG_NEWLIB_LIBC_FLOAT_PRINTF
    CONFIG_NEWLIB_LIBC_FLOAT_SCANF

Change-Id: I57f9d9f02e6d21d6011d14de7153b1d3ba6f6e32
Signed-off-by: Juro Bystricky <juro.bystricky@intel.com>
2016-11-09 02:47:43 +00:00
Jaakko Hannikainen
24a2fb19f9 lib: Add implementation for strrchr
Signed-off-by: Jaakko Hannikainen <jaakko.hannikainen@intel.com>
Change-Id: I57c549fae0fa8b2321794e9256da63b0a2fe6eaf
2016-11-04 16:53:50 +00:00
Vinicius Costa Gomes
b7833b9851 iot/zoap: Add support for block sized transfers
This will add basic support for sending bodies of data that exceed the
size of a single UDP packet.

Block-wise transfers are defined in the recently adopted RFC 7959[1].

The RFC defines four options, two negotiating the block transfer, and
two for informing the size of the transfer. Depending whether the packet
is a request or a response, each option is defined as
"control" (informative) or descriptive (describes what's in the
payload).

Change-Id: Ic71275558c4afed0298d20e8712f76d53904f89f
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2016-10-25 12:56:51 +00:00
Vinicius Costa Gomes
75d7147fa4 iot/zoap: Fix comparing pointers of different signedness
strncmp() expects pointers of type 'char *', we could cast option.value
to 'char *', but we can use memcmp() instead, which has the benefit of
being simpler.

Change-Id: I8c4ee4401712f3617c134d8e5b6d84e8f5cc4e1d
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2016-10-04 12:29:07 +00:00
Anas Nashif
c83e6a1f48 libc: define EWOULDBLOCK to be the same as EAGAIN
EWOULDBLOCK is an old error code from BSD. Not much uses it, and on basically
all modern systems it's defined to the same value as EAGAIN, which is the
System V value for the same condition.

Jira: ZEP-982
Change-Id: I5435ce55fa47f5bd2fac5d881b5b195b025f48a2
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-10-03 02:29:42 +00:00
Vinicius Costa Gomes
7079a18267 iot/zoap: Add helpers for dealing with integer options
A good number of option values represent numbers, so add these helpers
so applications can avoid repeating this.

Change-Id: Ied2a844c51808dcafe751a77492d00f2063de7d6
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2016-10-01 01:11:25 +00:00
Vinicius Costa Gomes
441d22a371 iot/zoap: Add port information to network addresses
uIP keeps the port separated from the IP addresses, so if the
application wants to communicate with a remote endpoint we must also
have the port information available.

Change-Id: I8e2b01fe5717166e1f9cebcc74b2056325b8ccc3
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2016-10-01 01:11:25 +00:00
Vinicius Costa Gomes
92a79f7351 iot/zoap: Add support for observing resources
This adds support for observing resources, for client and server side.

For the server side we augment the resource struct so it can hold
information about each interested observer.

For client side, observing a resource abstracted as an reply that
can be called multiple times.

Change-Id: If3f0b41e302cff357ab891e6e91ec2d41579fb92
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2016-10-01 01:11:24 +00:00
Vinicius Costa Gomes
7d0a1279b6 iot/zoap: Fix retrieving the token for every reply
As there is only one response token, we can do this only once at the
beginning of the function, instead of every iteration.

Change-Id: Ibb324a1189929227bd1eb9837c5d330ff8c8dac2
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2016-09-22 00:54:36 +00:00
Vinicius Costa Gomes
eab5adb282 iot/zoap: Fix subtly wrong indentation
There were a few lines where the alignment was wrong.

Change-Id: I474976c218ac28564dfe9dcda0e0687ed110834e
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2016-09-22 00:54:35 +00:00
Qiu Peiyang
c53fe299c0 libc: replace null.h and size_t.h with stddef.h
According to commit b71a8a4591 and Jira: ZEP-733
(libc: remove stddef.h which is provided by the compiler),
the stddef.h in zephyr code is removed and it's provided
by the compiler. The original stddef.h includes two head
files, null.h and size_t.h, which are also useless now.
So remove these two deprecated files, in case conflicting
definition.

Change-Id: Ie7163fdbd23c32759425b50f3deff2a57cc051a9
Signed-off-by: Qiu Peiyang <peiyangx.qiu@intel.com>
2016-09-13 10:21:10 +08:00
Vinicius Costa Gomes
2baa577b49 lib: Introduce the CoAP implementation for Zephyr
This is a CoAP implementation tailored for Zephyr's requirements, it
tries to use memory predictably by exposing its control structures to
the user (so the user only pays for the features that are used) and
having a lightweight packet representation (the trade-off is that
adding options is not as efficient as it could be, if there were more
information available).

Change-Id: I6f74146c4626a0c554f50b42f163a076e82805ba
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
2016-09-12 12:25:24 +00:00
Andy Ross
5729235b57 libc/printf: Use compiler-provided 64 bit math, phase 2
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>
2016-09-10 00:49:01 +00:00
Andy Ross
d06eea4eda libc/printf: Use compiler-provided 64 bit math, phase 1
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>
2016-09-10 00:49:00 +00:00
Andy Ross
073cfddd0f libc/printf: Remove vestigial "full" parameter to _to_float()
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>
2016-09-10 00:49:00 +00:00
Andy Ross
a4537cb0d3 libc/printf: Unify & simplify number printing
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>
2016-09-10 00:48:59 +00:00
Anas Nashif
b71a8a4591 libc: remove stddef.h which is provided by the compiler
Jira: ZEP-733
Change-Id: I26ba720377826bfa662c61e46c0358f05218524b
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-09-09 11:57:41 +00:00
Johan Hedberg
65a8e3c1c9 libc: printf: Add support for 'z' length specifier
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>
2016-09-07 15:10:57 +00:00
Andrew Boie
ad9d5265c3 libc: minimal: add reduced inttypes.h
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>
2016-08-28 11:33:15 +00:00
Carles Cufi
1980b7bb0f lib: Use offsetof() builtin with GCC
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>
2016-08-27 18:29:27 +00:00
Maureen Helm
0a9e0d0a5e libc: Add assert.h to minimal libc
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>
2016-07-21 02:09:44 +00:00
Sergio Rodriguez
6d5981bf28 lib: Adding the strstr() function
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>
2016-07-19 22:35:21 +00:00
Andrew Boie
00365c188c nios2: Kconfig: remove some unused config options
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>
2016-06-10 15:22:42 +00:00
Kumar Gala
7fdd4f758d newlib: Support both namespace protected & nonprotected stubs
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>
2016-06-09 16:22:28 +00:00
Kumar Gala
ab5614ed9e newlib: Drop _fstat implementation
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>
2016-06-09 16:22:27 +00:00
Anas Nashif
7d76e9619b ext: move tinycrypt to ext/lib
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>
2016-06-01 14:27:41 -04:00
Szymon Janc
f23582fe71 tinycrypt: Fix discrepancy of ecc_make_key definition and declaration
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>
2016-05-27 11:19:00 +00:00
Anas Nashif
37b1d1eb55 ext: include headers based on HAL being used
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>
2016-05-27 01:38:23 +00:00
Kumar Gala
9ec2f3be80 Cleanup whitespace in Kconfig files
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>
2016-05-25 13:28:07 -05:00
Anas Nashif
083a7ad0df build: move library related code to lib/
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>
2016-05-16 19:43:50 +00:00
Anas Nashif
0b2c44a771 tinycrypt: move from lib to regular objects
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>
2016-05-16 19:43:50 +00:00
Andrew Boie
3395211a0b newlib: treat x86 as the special case
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>
2016-05-09 18:09:29 +00:00
Bogdan Davidoaia
c2216c7088 libc: newlib: fix RAM config names for ARC
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>
2016-05-05 14:08:50 +00:00
Andrew Boie
9433895954 nios2: basic build, non-functional
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>
2016-05-03 23:18:45 +00:00
Benjamin Walsh
f557d71b52 libc: add strncat() to minimal libc
Change-Id: I0a44e1bb80c815ff89d8c9648d6e5db70e911fd2
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-04-16 05:29:21 +00:00
Peter Mitsis
7f14e706ec printf: Limit width modifier to [0..MAXFLD]
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>
2016-03-19 11:03:54 +00:00
Johan Hedberg
41f8a33555 libc: Add off_t definition
Add definition for the POSIX standard off_t type.

Change-Id: I1142428a3d226d641a8628cbba71cb3ea341ef92
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-03-11 01:09:56 +00:00
Johan Hedberg
6692e98298 libc: Move ssize_t definition to sys/types.h
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>
2016-03-11 01:09:56 +00:00
Iván Briano
4370b5da6c libc-hooks: Provide the 'open()' syscall
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>
2016-03-10 23:28:15 +00:00
Jithu Joseph
4ad7f2a5a3 libc-hooks: newlib's heap may use entire unused RAM
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>
2016-02-27 09:57:19 +00:00
Iván Briano
428d51b5db libc-hooks: Make newlib's heap size configurable
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>
2016-02-20 14:57:53 +00:00
Johan Hedberg
da1552a923 libc: Add definition for ssize_t
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>
2016-02-20 14:15:26 +00:00
Peter Mitsis
8413e1f872 doc: Fix misuse of @file doxygen tag
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>
2016-02-11 20:11:03 +00:00
Szymon Janc
c12c48c4b2 tinycrypt: Fix compilation with ECC enabled
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>
2016-02-10 22:14:58 +00:00
Szymon Janc
0f7bc9dd67 tinycrypt: Fix few typos in Kconfig help messages
Change-Id: Ia6442359e1ab5116083c065ae63e4b929e74ef76
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-10 22:14:58 +00:00
Peter Mitsis
08b353b8b4 minimal libc: stdlib.h no longer includes ctype.h
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>
2016-02-09 23:41:59 +00:00
Dan Kalowsky
a97c9bce4a lib : tinycrypt : Adding README for external library
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>
2016-02-08 20:09:04 -05:00
Constanza Heath
eaed145cb6 Integration of TinyCrypt v2: ECC, CMAC, AES-CCM with test cases for CMAC and CCM.
Change-Id: I26a5c3027af0d00f55021c1ac063100606084314
Signed-off-by: Constanza Heath <constanza.m.heath@intel.com>
2016-02-05 20:25:23 -05:00
Peter Mitsis
df3c6b13ab c++: Update minimal libc headers
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>
2016-02-05 20:25:22 -05:00
Peter Mitsis
497d0e53c4 libc: Consolidate size_t definitions
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>
2016-02-05 20:25:22 -05:00
Peter Mitsis
b111d6c932 libc: Consolidate NULL definitions
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>
2016-02-05 20:25:22 -05:00
Peter Mitsis
a0e4568760 c++: Add extern "C" { } block to header files
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>
2016-02-05 20:25:22 -05:00
Andre Guedes
aa47bd8d6c newlib: Rename exit to _exit
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>
2016-02-05 20:25:16 -05:00
Vlad Lungu
8de1dac833 Add isgraph()/isprint()/isxdigit()/toupper()
Needed for porting various software

Change-Id: Ic5e89f4e606e46bd0c6de67cebb5b8e3159ab90e
Signed-off-by: Vlad Lungu <vlad.lungu@windriver.com>
2016-02-05 20:25:06 -05:00
Johan Hedberg
26484222ef lib/libc: Add implementation for isprint()
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>
2016-02-05 20:25:03 -05:00
Benjamin Walsh
fc1c0c3345 libc/minimal: use per-thread errno implementation
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>
2016-02-05 20:24:58 -05:00
Allan Stephens
bf223a8838 stdio: Fix bug in fputs()
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>
2016-02-05 20:24:44 -05:00
Dan Kalowsky
486c382bfe checkpatch: warning - block_comment_style
Change-Id: Ib2c6b713dd74e8b24a9a4a636f8923ae21c7c25e
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
2016-02-05 20:24:35 -05:00
Dan Kalowsky
070a6e3ec9 checkpatch: error - trailing_whitespace
Change-Id: Id096b9eabcd8468e9343ceae5444c7726a1c539e
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
2016-02-05 20:24:35 -05:00
Dan Kalowsky
72f0a1314e checkpatch: warning - unnecssary_else
Change-Id: I6cc45cfcf09448b8fc988dc56219ea7560636af4
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
2016-02-05 20:24:35 -05:00
Dan Kalowsky
e45956c9a0 checkpatch: warning - leading_space
Change-Id: I34a54230bc4a63c8a4391d03ff530835910c3705
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:24:33 -05:00
Dan Kalowsky
a92e48890c checkpatch: error - global_initialisers
Change-Id: Ib3f69be9f9273e57952a3ebceebc82d84c607c64
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:24:33 -05:00
Dan Kalowsky
da67b29569 checkpatch: warning - block_comment_style
Change-Id: I6da43e41f9c6efee577b70513ec368ae3cce0144
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:24:33 -05:00
Dan Kalowsky
e4bb957a00 checkpatch: error - pointer_location
Change-Id: I9ce224cb75ba21caecffd6747833257f748b5ecf
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
2016-02-05 20:24:31 -05:00
Dan Kalowsky
a60c866c70 checkpatch: error - open_brace
Change-Id: I434037ce969bcd1fc08bd4b407f9508773e64b1e
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
2016-02-05 20:24:31 -05:00
Dan Kalowsky
d04ae83e11 checkpatch: error - return_parentheses
Change-Id: If1964349a115043fa54bf48ebfe4b3c0a414ed57
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
2016-02-05 20:24:31 -05:00
Dan Kalowsky
39063598db checkpatch: error - spacing
Change-Id: Ie6e1c43581dd4b0734625b3a4e59a4ca79619e99
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
2016-02-05 20:24:31 -05:00
Dan Kalowsky
3bc4039601 checkpatch: error - switch_case_indent_level
Change-Id: I9cbd6ab80b0c0f170626bb1c6b2d07498038fb8f
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
2016-02-05 20:24:31 -05:00
Dan Kalowsky
7cfc703711 checkpatch: error - trailing statements
Change-Id: I461134536da0288261b90f605a904ab3ea466340
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
2016-02-05 20:24:31 -05:00
Dan Kalowsky
978851fb6a checkpatch: code_indent failures
Corrects the checkpatch code_indent failures

Change-Id: I2ff93b8907d3eddbaa543ccbd12aecef8af7f698
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
2016-02-05 20:24:31 -05:00
Javier B Perez Hernandez
f7fffae8aa Change BSD-3 licenses to Apache 2
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>
2016-02-05 20:24:29 -05:00
Dan Kalowsky
94d60babaa tinycrypt: use tabs not spaces
Passing checkpatch check to use tabs instead of spaces for everything.

Change-Id: Ieffa0b0cc4b24598e7cbce7edf9ed640c8fb27dd
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
2016-02-05 20:24:27 -05:00
Dan Kalowsky
31ff5ad01f tinycrypt: moving includes
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>
2016-02-05 20:24:27 -05:00
Anas Nashif
93f06fad7d Revert "tinycrypt: moving includes"
This commit breaks the sanitychecks

This reverts commit 93fa1053b21efe3d030ea060a31b80d6008d5bfd.

Change-Id: Ia52092e845c33234817a1cb27cd1f17064c65e7e

Signed-off-by: Anas Nashif <nashif@linux.intel.com>
2016-02-05 20:24:27 -05:00
Anas Nashif
cd6e315167 Revert "tinycrypt: use tabs not spaces"
breaks sanitychecks

This reverts commit 6712ac6c73dcfd6a8e5dc04f6e05ab33b8dbf51c.

Change-Id: I69c3938da0d215b63361cf4d741f2c978ad80661

Signed-off-by: Anas Nashif <nashif@linux.intel.com>
2016-02-05 20:24:27 -05:00
Dan Kalowsky
3b650c5c44 tinycrypt: use tabs not spaces
Passing checkpatch check to use tabs instead of spaces for everything.

Change-Id: I2fdd507d48db83fda8d183043c5a4ab1b97148dc
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
2016-02-05 20:24:27 -05:00
Dan Kalowsky
9d506d0a26 tinycrypt: moving includes
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>
2016-02-05 20:24:27 -05:00
Dan Kalowsky
53dbe1f1ec crypto: comply with checkpatch file length
Fixes the tinycrypt library to use Zephyr checkpath acceptable line
lengths.

Change-Id: Ia7bef46a39fa029cda826ec5b2d7d42036d9bdfe
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
2016-02-05 20:24:26 -05:00
Anas Nashif
196bb2e17f libc: use isdigit from ctype.h
Do not use local _isdigit function, use public isdigit
instead.

Change-Id: Ifc2721fc2def429de4934c9855f08dae30326694
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:16:15 -05:00
Anas Nashif
f3f7eac765 Add MINIMAL_LIBC_EXTENDED to limit libc builds
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>
2016-02-05 20:16:15 -05:00
Anas Nashif
751d90da85 libc: add support for strncasecmp function
Add function for comparing two strings ignoring case.

Change-Id: I2fc78c0a0d0f53e23566ffacd8dca3b23e386c26
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:16:15 -05:00
Anas Nashif
3e02a4a107 libc: add atoi to minimal libc
Change-Id: I589fe6599dec1a93e9700005742b8b34b42dee64
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:16:15 -05:00
Anas Nashif
9d648ebc48 libc: add strcat to minimal libc
Change-Id: Ifae9da3abb60d061a4211e0fac20037f72ca90e2
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:16:15 -05:00
Anas Nashif
bddd72602c libc: add strtol and strtoul to minimal libc
Change-Id: Ia6198cd34ff486d8eb9d978a59d885cae06b60d3
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:16:15 -05:00
Anas Nashif
17f666bd89 libc: update ctype.h with isdigit, isspace, isalpha, isupper
Change-Id: Id8d865cde04d66367ddcf26995780767ad1b05f8
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:16:15 -05:00
Dirk Brandewie
6bc71f5933 libc: added errno global variable
Change-Id: I42ae30fe5826828cc4696f155caeb186a31f913b
Signed-off-by: Fabien Chereau <fabien.chereau@intel.com>
Signed-off-by: Dirk Brandewie <dirk.j.brandewie@intel.com>
2016-02-05 20:16:01 -05:00
Constanza Heath
7d0e1d9218 Add initial import of TinyCrypt crypto library and tests
Change-Id: I89b8db6925385dd02e95e0401bc42f32543e0daf
Signed-off-by: Constanza Heath <constanza.m.heath@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:15:36 -05:00
Jukka Rissanen
efed446bee libc: Add memchr implementation
Needed by CoAP implementation in net/ip/er-coap

Change-Id: I724bc7569a29c35f386bbc301d883a000882de78
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2016-02-05 20:15:32 -05:00
Anas Nashif
42fbd4afd2 cleanup libc kconfig and use choice
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>
2016-02-05 20:15:25 -05:00
Anas Nashif
8d00ec5c4e build: build libc as object, not kbuild library (lib.a)
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>
2016-02-05 20:14:45 -05:00
Anas Nashif
f367f071b6 doxygen: add @brief and capitalize
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>
2016-02-05 20:14:33 -05:00
Anas Nashif
1362e3c162 doxygen: RETURNS: -> @return
Previous comment style used RETRURNS:, use @return to comply
with javadoc style.

Change-Id: Ib1dffd92da1d97d60063ec5309b08049828f6661
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:14:32 -05:00
Anas Nashif
ea0d0b220c doxygen: change comment style to match javadoc
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>
2016-02-05 20:14:32 -05:00
Jukka Rissanen
d639bb8c99 libc: Add tolower implementation
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>
2016-02-05 20:14:14 -05:00
Allan Stephens
5a4be58707 Eliminate non-standard boolean type support
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>
2016-02-05 20:14:14 -05:00
Anas Nashif
987d64c9ba newlib: Fix coding style and checkpatch warnings/errors
Change-Id: I96d2fc5232b5babdb5d849b603dcd2fa44c50de1
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:14:14 -05:00
Allan Stephens
b52a09f536 Optimize performance of memset() and memcpy()
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>
2016-02-05 20:14:12 -05:00
Anas Nashif
e30e8969af libc: add license header
Change-Id: I5cc68ad996afd93faf0bdd25f5d6481c06bef29c
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:14:09 -05:00
Anas Nashif
19f0ff2756 Kbuild: enable toolchain newlib library instead of minimal libc
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>
2016-02-05 20:14:09 -05:00
Juan Manuel Cruz
de1cec29d6 Kbuild: Build minimal libc as a static library.
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>
2016-02-05 20:14:08 -05:00
Anas Nashif
4acde800b0 Kbuild: User kernel instead of TiMo
TiMo is very ambigous, be generic and call it kernel.

Change-Id: I66b3e436afbc89e874f31a89b98cc04aa821c787
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:14:07 -05:00
Juan Manuel Cruz
d31a6a6f31 Creation of Makefiles for libc minimal.
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
2016-02-05 20:14:04 -05:00
Johan Hedberg
afffab10a4 libc: Fix memcmp implementation
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>
2016-02-05 20:14:00 -05:00
Johan Hedberg
7fc1c37c32 libc: Add memcmp implementation
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>
2016-02-05 20:14:00 -05:00
Yonattan Louise
b0b11989df Fix checkpatch issue - WARNING:LONG_LINE
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>
2016-02-05 20:13:59 -05:00
Yonattan Louise
a8571c4b7f Fix checkpatch issue - WARNING:SPACING
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>
2016-02-05 20:13:54 -05:00
Peter Mitsis
743ff6a74e build: Always enable section garbage collection flags
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>
2016-02-05 20:13:48 -05:00
Peter Mitsis
7637d818fc Fix null byte padding in strncpy()
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>
2016-02-05 20:13:45 -05:00
Peter Mitsis
c26a2e8147 Fix definition of 'offsetof'
The definition of 'offsetof' must cast NULL to (type *), not (type).

Signed-off-by: Peter Mitsis <peter.mitsis@windriver.com>
2016-02-05 20:13:39 -05:00
Yonattan Louise
29bd1c70ab Fix checkpatch issue - ERROR:POINTER_LOCATION
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
2016-02-05 20:13:39 -05:00
Yonattan Louise
ef7e799909 Fix checkpatch issue - ERROR:ASSIGN_IN_IF
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>
2016-02-05 20:12:51 -05:00
Inaky Perez-Gonzalez
8ddf82cf70 First commit
Signed-off-by:  <inaky.perez-gonzalez@intel.com>
2015-04-10 16:44:37 -07:00