Commit graph

23 commits

Author SHA1 Message Date
Emil Gydesen 299ef2e5fe cpp: Fixed compile warning with extern array declaration
The extern array declaration of size 0 gives a warning when
compiling with GCC. Updated to use [] rather than [0].

Signed-off-by: Emil Gydesen <emil_gydesen@bose.com>
2020-06-09 14:42:16 +02:00
Ulf Magnusson eddd98f811 kconfig: Replace some single-symbol 'if's with 'depends on'
I think people might be reading differences into 'if' and 'depends on'
that aren't there, like maybe 'if' being needed to "hide" a symbol,
while 'depends on' just adds a dependency.

There are no differences between 'if' and 'depends on'. 'if' is just a
shorthand for 'depends on'. They work the same when it comes to creating
implicit menus too.

The way symbols get "hidden" is through their dependencies not being
satisfied ('if'/'depends on' get copied up as a dependency on the
prompt).

Since 'if' and 'depends on' are the same, an 'if' with just a single
symbol in it can be replaced with a 'depends on'. IMO, it's best to
avoid 'if' there as a style choice too, because it confuses people into
thinking there's deep Kconfig magic going on that requires 'if'.

Going for 'depends on' can also remove some nested 'if's, which
generates nicer symbol information and docs, because nested 'if's really
are so simple/dumb that they just add the dependencies from both 'if's
to all symbols within.

Replace a bunch of single-symbol 'if's with 'depends on' to despam the
Kconfig files a bit and make it clearer how things work. Also do some
other minor related dependency refactoring.

The replacement isn't complete. Will fix up the rest later. Splitting it
a bit to make it more manageable.

(Everything above is true for choices, menus, and comments as well.)

Detected by tweaking the Kconfiglib parsing code. It's impossible to
detect after parsing, because 'if' turns into 'depends on'.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2020-02-08 08:32:42 -05:00
Peter A. Bigot 6ade720851 treewide: avoid use of unsupported C++ specifiers
constexpr and noexcept were introduced as specifiers in C++11.  Avoid
referencing them when compiling for earlier versions of the language.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-12-13 17:19:54 -06:00
Jan Van Winkel 8a98a67bf1 cpp: Use malloc/free instead of kernel variants in new/delete
Use malloc/free instead of k_malloc/k_free in operator new/delete
implementation or use libstdc++ implementation when available.

Further updated cpp_synchronization sample to enable minimal libc heap
as virtual destructor requires operator delete which depends on free.

Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
2019-11-26 12:41:54 -06:00
Sebastian Bøe 540bd67a7d kconfig: cpp: Have LIB_CPLUSPLUS depend on ! MINIMAL_LIBC
The C++ STD library is not compatible with the minimal C library. To
ensure that users do not accidentally enable LIB_CPLUSPLUS while also
enabling a minimal libc library we add a dependency in Kconfig.

Also, use depends instead of select between EXCEPTIONS, RTTI, and
LIB_CPLUSPLUS as use of select is discouraged in this situation.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2019-11-05 16:19:27 +01:00
Ulf Magnusson bd6e04411e kconfig: Clean up header comments and make them consistent
Use this short header style in all Kconfig files:

    # <description>

    # <copyright>
    # <license>

    ...

Also change all <description>s from

    # Kconfig[.extension] - Foo-related options

to just

    # Foo-related options

It's clear enough that it's about Kconfig.

The <description> cleanup was done with this command, along with some
manual cleanup (big letter at the start, etc.)

    git ls-files '*Kconfig*' | \
        xargs sed -i -E '1 s/#\s*Kconfig[\w.-]*\s*-\s*/# /'

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-11-04 17:31:27 -05:00
Ulf Magnusson 975de21858 kconfig: Global whitespace/consistency cleanup
Clean up space errors and use a consistent style throughout the Kconfig
files. This makes reading the Kconfig files more distraction-free, helps
with grepping, and encourages the same style getting copied around
everywhere (meaning another pass hopefully won't be needed).

Go for the most common style:

 - Indent properties with a single tab, including for choices.

   Properties on choices work exactly the same syntactically as
   properties on symbols, so not sure how the no-indentation thing
   happened.

 - Indent help texts with a tab followed by two spaces

 - Put a space between 'config' and the symbol name, not a tab. This
   also helps when grepping for definitions.

 - Do '# A comment' instead of '#A comment'

I tweaked Kconfiglib a bit to find most of the stuff.

Some help texts were reflowed to 79 columns with 'gq' in Vim as well,
though not all, because I was afraid I'd accidentally mess up
formatting.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-11-01 15:53:23 +01:00
Jan Van Winkel 0e59f6846f libc: Changed dependencies of NEWLIB_C into !MINIMAL_LIBC
Changed Kconfig dependencies of NEWLIB_C into !MINIMAL_LIBC

Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
2019-11-01 14:18:36 +01:00
Jan Van Winkel 626f96ec30 cpp: Added option to disable Zephyrs cpp implementation
Added a Kconfig option to disable Zephyrs cpp implementation for
operator new, delete, pure virtual functions and vtables.

Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
2019-10-31 15:02:03 +01:00
Nicolas Pitre 2bdfede0f8 cpp: support for 64-bit constructors
Make constructors work in a 64-bit build.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2019-07-30 18:55:34 -07:00
Anas Nashif 4c32258606 style: add braces around if/while statements
Per guidelines, all statements should have braces around them. We do not
have a CI check for this, so a few went in unnoticed.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-06 15:20:21 +02:00
Ulf Magnusson 9b6c2f4bf3 c++: kconfig: Fix choice dependencies and use 'menuconfig' symbol
- Make the 'C++ Standard' choice depend on CPLUSPLUS, so that it only
   shows up when C++ support is enabled.

   Also check that CPLUSPLUS is enabled before checking the standard in
   the top-level CMakeLists.txt, to avoid triggering an assert.

 - The 'C++ Options' menu now contains just CPLUSPLUS and its indented
   children. Remove one menu level by removing the menu and turning
   CPLUSPLUS into a 'menuconfig' symbol. Also change the prompt from
   "Enable C++ support for the application" to just "C++ support for the
   application", to make it consistent with e.g. "Logging".

 - Factor out the common CPLUSPLUS dependency with an 'if CPLUSPLUS'.

 - Order symbol properties more consistently with other Kconfig files,
   with the prompt at the top, etc.

Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
2019-05-16 07:08:21 -05:00
Anas Nashif 3ae52624ff license: cleanup: add SPDX Apache-2.0 license identifier
Update the files which contain no license information with the
'Apache-2.0' SPDX license identifier.  Many source files in the tree are
missing licensing information, which makes it harder for compliance
tools to determine the correct license.

By default all files without license information are under the default
license of Zephyr, which is Apache version 2.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-04-07 08:45:22 -04:00
Patrik Flykt 24d71431e9 all: Add 'U' suffix when using unsigned variables
Add a 'U' suffix to values when computing and comparing against
unsigned variables.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2019-03-28 17:15:58 -05:00
Aurelien Jarno a0b9e70e10 c++: kconfig: EXCEPTIONS needs to depend on NEWLIB_LIBC
C++ exception support needs to use the newlib C library in order to get
the abort function. C++ exceptions also do not work with the simple
malloc/free implementation provided by the Zephyr minimal C library.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2018-11-28 13:51:35 -08:00
Benoit Leforestier 16451850e7 C++: Fix vtable with libstdc++
__cxxabiv1 is an internal namespace used by GNU's libstdc++.
When linking with C++ standard library (libstdc++),
__cxxabiv1::__class_type_info is already defined inside.
If user code contains virtual classes,
__cxxabiv1::__class_type_info is defined twice.

Signed-off-by: Benoit Leforestier <benoit.leforestier@gmail.com>
2018-10-30 08:11:28 -04:00
Benoit Leforestier 26e0f9a9e1 Build: Improve C++ support
Can choose the C++ standard (C++98/11/14/17/2a)
Can link with standard C++ library (libstdc++)
Add support of C++ exceptions
Add support of C++ RTTI
Add C++ options to subsys/cpp/Kconfig
Implements new and delete using k_malloc and k_free
if CONFIG_HEAP_MEM_POOL_SIZE is defined

Signed-off-by: Benoit Leforestier <benoit.leforestier@gmail.com>
2018-10-29 09:15:04 -04:00
Sebastian Bøe f9b2da37b0 kconfig: Move CPLUSPLUS from root to "Compiler Options"
Enabling C++ support for the application has been inappropriately
located at the root of the Kconfig menu. The root should be kept as
clean possible to allow easy navigation.

This commit moves CONFIG_CPLUSPLUS into

~/"Build and Linker Features"/"Compiler Options".

This is a purely cosmetic change and does not change the
'visibility' (depends) of the Kconfig option.

Arguably, it would fit better into

~/"Build and Linker Features"/"Language Options"

but this entry does not exist.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-04-30 13:12:01 -04:00
Michael Hope 7383814d8b cpp: mark __dso_handle as weak.
The POSIX target uses the native crt0 which already provides
__dso_handle.

Signed-off-by: Michael Hope <mlhx@google.com>
2018-04-09 23:21:52 -04:00
Anas Nashif 429c2a4d9d kconfig: fix help syntax and add spaces
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-12-13 17:43:28 -06:00
Sebastian Bøe 0829ddfe9a kbuild: Removed KBuild
Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-08 20:00:22 -05:00
Sebastian Bøe 12f8f76165 Introduce cmake-based rewrite of KBuild
Introducing CMake is an important step in a larger effort to make
Zephyr easy to use for application developers working on different
platforms with different development environment needs.

Simplified, this change retains Kconfig as-is, and replaces all
Makefiles with CMakeLists.txt. The DSL-like Make language that KBuild
offers is replaced by a set of CMake extentions. These extentions have
either provided simple one-to-one translations of KBuild features or
introduced new concepts that replace KBuild concepts.

This is a breaking change for existing test infrastructure and build
scripts that are maintained out-of-tree. But for FW itself, no porting
should be necessary.

For users that just want to continue their work with minimal
disruption the following should suffice:

Install CMake 3.8.2+

Port any out-of-tree Makefiles to CMake.

Learn the absolute minimum about the new command line interface:

$ cd samples/hello_world
$ mkdir build && cd build
$ cmake -DBOARD=nrf52_pca10040 ..

$ cd build
$ make

PR: zephyrproject-rtos#4692
docs: http://docs.zephyrproject.org/getting_started/getting_started.html

Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
2017-11-08 20:00:22 -05:00
Anas Nashif da7cc84655 subsystem: cleanup misc and make cpp a subsystem
Move a way from misc/ and put in its own subsystem to allow enhancements
in the future and make it a core part of Zephyr, not just something
misc.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-07-06 09:13:46 -05:00