--std=c++17 (#2330)

* switch to c++17

* more 17

* 1z

* use std::clamp

* Fix types in clamp

* bump submodules

* bump laika

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
albatross
Willem Melching 2020-10-17 22:33:12 +02:00 committed by GitHub
parent 96b637737b
commit 339d1967cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 23 additions and 27 deletions

View File

@ -138,6 +138,7 @@ env = Environment(
"-Werror",
"-Wno-unknown-warning-option",
"-Wno-deprecated-register",
"-Wno-register",
"-Wno-inconsistent-missing-override",
"-Wno-c99-designator",
"-Wno-reorder-init-list",
@ -177,7 +178,7 @@ env = Environment(
RPATH=rpath,
CFLAGS=["-std=gnu11"] + cflags,
CXXFLAGS=["-std=c++14"] + cxxflags,
CXXFLAGS=["-std=c++1z"] + cxxflags,
LIBPATH=libpath + [
"#cereal",
"#selfdrive/common",

2
cereal

@ -1 +1 @@
Subproject commit 1e7810dbbfe31003b85f11f948ac6e03b1134570
Subproject commit 5c7e91abb7fa93f86164fc48124c596bf9cfc849

View File

@ -4,7 +4,7 @@ from Cython.Build import cythonize
from common.cython_hacks import BuildExtWithoutPlatformSuffix
sourcefiles = ['clock.pyx']
extra_compile_args = ["-std=c++14"]
extra_compile_args = ["-std=c++1z"]
setup(name='common',
cmdclass={'build_ext': BuildExtWithoutPlatformSuffix},

View File

@ -44,7 +44,7 @@ def compile_code(name, c_code, c_header, directory, cflags="", libraries=None):
ffibuilder = FFI()
ffibuilder.set_source(name, c_code, source_extension='.cpp', libraries=libraries)
ffibuilder.cdef(c_header)
os.environ['OPT'] = "-fwrapv -O2 -DNDEBUG -std=c++11"
os.environ['OPT'] = "-fwrapv -O2 -DNDEBUG -std=c++1z"
os.environ['CFLAGS'] = cflags
ffibuilder.compile(verbose=True, debug=False, tmpdir=directory)

View File

@ -12,7 +12,7 @@ setup(
"transformations",
sources=["transformations.pyx"],
language="c++",
extra_compile_args=["-std=c++14", "-Wno-cpp"],
extra_compile_args=["-std=c++1z", "-Wno-cpp"],
include_dirs=[numpy.get_include()],
),
nthreads=4,

View File

@ -11,7 +11,7 @@ WARN_FLAGS = -Werror=implicit-function-declaration \
-Werror=format-extra-args
CFLAGS = -std=gnu11 -fPIC -O2 $(WARN_FLAGS)
CXXFLAGS = -std=c++11 -fPIC -O2 $(WARN_FLAGS)
CXXFLAGS = -std=c++1z -fPIC -O2 $(WARN_FLAGS)
NANOVG_FLAGS = -I$(PHONELIBS)/nanovg

View File

@ -10,7 +10,7 @@ WARN_FLAGS = -Werror=implicit-function-declaration \
-Werror=format-extra-args
CFLAGS = -std=gnu11 -g -fPIC -O2 $(WARN_FLAGS)
CXXFLAGS = -std=c++11 -g -fPIC -O2 $(WARN_FLAGS)
CXXFLAGS = -std=c++1z -g -fPIC -O2 $(WARN_FLAGS)
CURL_FLAGS = -I$(PHONELIBS)/curl/include
CURL_LIBS = $(PHONELIBS)/curl/lib/libcurl.a \

@ -1 +1 @@
Subproject commit bb4003cc04efc615bce7cf9e883367ba3a7bd878
Subproject commit bfb59fa18dd05d8766101b16624d020965793a14

@ -1 +1 @@
Subproject commit a14baf55531e8e2f10f4b8010f355def11e63bcc
Subproject commit 25dc12a87b13c78e78be9664e496402f0e0286db

@ -1 +1 @@
Subproject commit 32267071160ac461f513ca684b831e3a6d8896cc
Subproject commit 10bf459f33adcdb75ca6851555f5ff870cfea10e

View File

@ -16,7 +16,7 @@ setup(name='Boardd API Implementation',
],
sources=['boardd_api_impl.pyx'],
language="c++",
extra_compile_args=["-std=c++11", "-Wno-nullability-completeness"],
extra_compile_args=["-std=c++1z", "-Wno-nullability-completeness"],
)
)
)

View File

@ -8,6 +8,7 @@
#include <poll.h>
#include <sys/ioctl.h>
#include <atomic>
#include <algorithm>
#include <linux/media.h>
@ -376,7 +377,7 @@ static void set_exposure(CameraState *s, float exposure_frac, float gain_frac) {
unsigned int integ_lines = s->cur_integ_lines;
if (exposure_frac >= 0) {
exposure_frac = clamp(exposure_frac, 2.0 / frame_length, 1.0);
exposure_frac = std::clamp(exposure_frac, 2.0f / frame_length, 1.0f);
integ_lines = frame_length * exposure_frac;
// See page 79 of the datasheet, this is the max allowed (-1 for phase adjust)
@ -385,7 +386,7 @@ static void set_exposure(CameraState *s, float exposure_frac, float gain_frac) {
if (gain_frac >= 0) {
// ISO200 is minimum gain
gain_frac = clamp(gain_frac, 1.0/64, 1.0);
gain_frac = std::clamp(gain_frac, 1.0f/64, 1.0f);
// linearize gain response
// TODO: will be wrong for front camera
@ -1718,7 +1719,7 @@ void actuator_move(CameraState *s, uint16_t target) {
}
int dest_step_pos = s->cur_step_pos + step;
dest_step_pos = clamp(dest_step_pos, 0, 255);
dest_step_pos = std::clamp(dest_step_pos, 0, 255);
struct msm_actuator_cfg_data actuator_cfg_data = {0};
actuator_cfg_data.cfgtype = CFG_MOVE_FOCUS;
@ -1804,8 +1805,8 @@ static void do_autofocus(CameraState *s) {
}
// stay off the walls
lens_true_pos = clamp(lens_true_pos, dac_down, dac_up);
int target = clamp(lens_true_pos - sag, dac_down, dac_up);
lens_true_pos = std::clamp(lens_true_pos, float(dac_down), float(dac_up));
int target = std::clamp(lens_true_pos - sag, float(dac_down), float(dac_up));
s->lens_true_pos = lens_true_pos;
/*char debug[4096];

View File

@ -21,12 +21,6 @@ typedef void (*sighandler_t)(int sig);
#endif
#define clamp(a,b,c) \
({ __typeof__ (a) _a = (a); \
__typeof__ (b) _b = (b); \
__typeof__ (c) _c = (c); \
_a < _b ? _b : (_a > _c ? _c : _a); })
#define ARRAYSIZE(x) (sizeof(x)/sizeof(x[0]))
#undef ALIGN

View File

@ -11,7 +11,7 @@ WARN_FLAGS = -Werror=implicit-function-declaration \
-Wno-deprecated-declarations
CFLAGS = -std=gnu11 -g -fPIC -O2 $(WARN_FLAGS)
CXXFLAGS = -std=c++11 -g -fPIC -O2 $(WARN_FLAGS)
CXXFLAGS = -std=c++1z -g -fPIC -O2 $(WARN_FLAGS)
FFMPEG_LIBS = -lavformat \
-lavcodec \

View File

@ -20,7 +20,7 @@ WARN_FLAGS = -Werror=implicit-function-declaration \
-Werror=format-extra-args
CFLAGS = -std=gnu11 -g -fPIC $(OPT_FLAGS) $(WARN_FLAGS)
CXXFLAGS = -std=c++14 -fPIC $(OPT_FLAGS) $(WARN_FLAGS)
CXXFLAGS = -std=c++1z -fPIC $(OPT_FLAGS) $(WARN_FLAGS)
EIGEN_FLAGS = -I$(PHONELIBS)/eigen

View File

@ -10,7 +10,7 @@ WARN_FLAGS = -Werror=implicit-function-declaration \
-Werror=format-extra-args
CFLAGS = -std=gnu11 -fPIC -O2 $(WARN_FLAGS)
CXXFLAGS = -std=c++11 -fPIC -O2 $(WARN_FLAGS)
CXXFLAGS = -std=c++1z -fPIC -O2 $(WARN_FLAGS)
NANOVG_FLAGS = -I$(PHONELIBS)/nanovg

View File

@ -10,7 +10,7 @@ WARN_FLAGS = -Werror=implicit-function-declaration \
-Werror=format-extra-args
CFLAGS = -std=gnu11 -g -fPIC -O2 $(WARN_FLAGS)
CXXFLAGS = -std=c++11 -g -fPIC -O2 $(WARN_FLAGS)
CXXFLAGS = -std=c++1z -g -fPIC -O2 $(WARN_FLAGS)
ZMQ_FLAGS = -I$(PHONELIBS)/zmq/aarch64/include
ZMQ_LIBS = -L$(PHONELIBS)/zmq/aarch64/lib \

View File

@ -10,7 +10,7 @@ WARN_FLAGS = -Werror=implicit-function-declaration \
-Werror=format-extra-args
CFLAGS = -std=gnu11 -fPIC -O2 $(WARN_FLAGS)
CXXFLAGS = -std=c++11 -fPIC -O2 $(WARN_FLAGS)
CXXFLAGS = -std=c++1z -fPIC -O2 $(WARN_FLAGS)
NANOVG_FLAGS = -I$(PHONELIBS)/nanovg