Message ID | 20210416194209.191245-4-mark.weiman@markzz.com |
---|---|
State | Superseded, archived |
Headers | show |
Series | Various fixes for FreeBSD (and perhaps others) | expand |
On 04/16/21 at 03:42pm, Mark Weiman wrote: > On Linux, signal.h is not required to have access to the signal > constants. On FreeBSD, this is not the case and requires signal.h to be > explicitly included. > > This patch checks if SIGINT can be used without signal.h and if not, > make sure its included in the files that need it. No need for the check; just include signal.h wherever we use it.
On Fri, 2021-04-16 at 13:08 -0700, Andrew Gregory wrote: > On 04/16/21 at 03:42pm, Mark Weiman wrote: > > On Linux, signal.h is not required to have access to the signal > > constants. On FreeBSD, this is not the case and requires signal.h to be > > explicitly included. > > > > This patch checks if SIGINT can be used without signal.h and if not, > > make sure its included in the files that need it. > > No need for the check; just include signal.h wherever we use it. Along with the suggested changes, since FreeBSD (and others) typically use clangas the C compiler of choice, a lot of warnings get tossed when compiling pacman.Would it be worth it to address clang warnings as long as it doesn't affect a normal GCC compilation? Mark
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index b386fde6..d2a688a2 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -34,6 +34,10 @@ #include <fnmatch.h> #include <poll.h> +#if defined(INCLUDE_SIGNAL_H) +#include <signal.h> +#endif + /* libarchive */ #include <archive.h> #include <archive_entry.h> diff --git a/meson.build b/meson.build index 14b3381a..0dc0d612 100644 --- a/meson.build +++ b/meson.build @@ -189,6 +189,12 @@ if not conf.get('HAVE_STRUCT_STATVFS_F_MNTONNAME', false) and conf.get('HAVE_STR conf.set('FSSTATSTYPE', 'struct statfs') endif +signal_code = '''void foo() { int sig = SIGINT; }''' +signal_test = cc.compiles(signal_code, name : 'test if signal.h is not needed') +if not signal_test + conf.set('INCLUDE_SIGNAL_H', true) +endif + if get_option('debug') extra_cflags = [ '-Wcast-align', diff --git a/src/pacman/conf.c b/src/pacman/conf.c index a4f2ba35..fcb1ccd8 100644 --- a/src/pacman/conf.c +++ b/src/pacman/conf.c @@ -32,6 +32,10 @@ #include <sys/wait.h> #include <unistd.h> +#if defined(INCLUDE_SIGNAL_H) +#include <signal.h> +#endif + /* pacman */ #include "conf.h" #include "ini.h"
On Linux, signal.h is not required to have access to the signal constants. On FreeBSD, this is not the case and requires signal.h to be explicitly included. This patch checks if SIGINT can be used without signal.h and if not, make sure its included in the files that need it. Signed-off-by: Mark Weiman <mark.weiman@markzz.com> --- lib/libalpm/util.c | 4 ++++ meson.build | 6 ++++++ src/pacman/conf.c | 4 ++++ 3 files changed, 14 insertions(+)