Message ID | 20190423160448.116834-1-giulio.benetti@micronovasrl.com |
---|---|
State | Superseded |
Headers | show |
Series |
|
Related | show |
Hello, Il 23/04/2019 18:04, Giulio Benetti ha scritto: > On some libc sys/auxv.h could not be present and getauxval() too. > This way build will fail. > > Check in meson if they are present and add HAVE_SYS_AUXV_H and > HAVE_GETAUXVAL defines to cxx arguments. > Add #ifdef HAVE_ statements around #include <sys/auxv.h> and getauxval() > in utils.cpp. > > Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com> > --- > meson.build | 12 ++++++++++++ > src/libcamera/utils.cpp | 4 ++++ > 2 files changed, 16 insertions(+) > > diff --git a/meson.build b/meson.build > index 6e68c3e..72a3652 100644 > --- a/meson.build > +++ b/meson.build > @@ -20,6 +20,18 @@ common_arguments = [ > c_arguments = common_arguments > cpp_arguments = common_arguments > > +cxx = meson.get_compiler('cpp') > + > +# check for header sys/auxv.h > +if cxx.has_header('sys/auxv.h') > + cpp_arguments += ['-DHAVE_SYS_AUXV_H'] > +endif > + > +# check for function getauxval() > +if cxx.has_function('getauxval') > + cpp_arguments += ['-DHAVE_GETAUXVAL'] > +endif > + > add_project_arguments(c_arguments, language: 'c') > add_project_arguments(cpp_arguments, language: 'cpp') > > diff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp > index 66123b1..ae574ab 100644 > --- a/src/libcamera/utils.cpp > +++ b/src/libcamera/utils.cpp > @@ -8,7 +8,9 @@ > #include "utils.h" > > #include <string.h> > +#ifdef HAVE_SYS_AUXV_H > #include <sys/auxv.h> > +#endif > > /** > * \file utils.h > @@ -57,8 +59,10 @@ const char *basename(const char *path) > */ > char *secure_getenv(const char *name) > { > +#ifdef HAVE_GETAUXVAL > if (getauxval(AT_SECURE)) > return NULL; > +#endif > > return getenv(name); > } > Sorry for the noise, I thought the previous patch was discarded since I was not subscribed to ML. Best regards
diff --git a/meson.build b/meson.build index 6e68c3e..72a3652 100644 --- a/meson.build +++ b/meson.build @@ -20,6 +20,18 @@ common_arguments = [ c_arguments = common_arguments cpp_arguments = common_arguments +cxx = meson.get_compiler('cpp') + +# check for header sys/auxv.h +if cxx.has_header('sys/auxv.h') + cpp_arguments += ['-DHAVE_SYS_AUXV_H'] +endif + +# check for function getauxval() +if cxx.has_function('getauxval') + cpp_arguments += ['-DHAVE_GETAUXVAL'] +endif + add_project_arguments(c_arguments, language: 'c') add_project_arguments(cpp_arguments, language: 'cpp') diff --git a/src/libcamera/utils.cpp b/src/libcamera/utils.cpp index 66123b1..ae574ab 100644 --- a/src/libcamera/utils.cpp +++ b/src/libcamera/utils.cpp @@ -8,7 +8,9 @@ #include "utils.h" #include <string.h> +#ifdef HAVE_SYS_AUXV_H #include <sys/auxv.h> +#endif /** * \file utils.h @@ -57,8 +59,10 @@ const char *basename(const char *path) */ char *secure_getenv(const char *name) { +#ifdef HAVE_GETAUXVAL if (getauxval(AT_SECURE)) return NULL; +#endif return getenv(name); }
On some libc sys/auxv.h could not be present and getauxval() too. This way build will fail. Check in meson if they are present and add HAVE_SYS_AUXV_H and HAVE_GETAUXVAL defines to cxx arguments. Add #ifdef HAVE_ statements around #include <sys/auxv.h> and getauxval() in utils.cpp. Signed-off-by: Giulio Benetti <giulio.benetti@micronovasrl.com> --- meson.build | 12 ++++++++++++ src/libcamera/utils.cpp | 4 ++++ 2 files changed, 16 insertions(+)