Skip to content

Commit 4c264e4

Browse files
committed
Fix expansion-to-defined warnings
1 parent ec26a4c commit 4c264e4

File tree

4 files changed

+94
-21
lines changed

4 files changed

+94
-21
lines changed

config.h.guess

+64-15
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,19 @@
131131
#endif
132132

133133
#ifndef HAVE_C___HAS_EXTENSION
134-
#define HAVE_C___HAS_EXTENSION (defined __has_extension)
134+
#ifdef __has_extension
135+
#define HAVE_C___HAS_EXTENSION 1
136+
#else
137+
#define HAVE_C___HAS_EXTENSION 0
138+
#endif
135139
#endif
136140

137141
#ifndef HAVE_C___HAS_INCLUDE
138-
#define HAVE_C___HAS_INCLUDE (defined __has_include)
142+
#ifdef __has_include
143+
#define HAVE_C___HAS_INCLUDE 1
144+
#else
145+
#define HAVE_C___HAS_INCLUDE 0
146+
#endif
139147
#endif
140148

141149
#ifndef HAVE_C___EXTENSION__
@@ -163,7 +171,11 @@
163171
#endif
164172

165173
#ifndef HAVE___ATOMIC_FETCH_ADD
166-
#define HAVE___ATOMIC_FETCH_ADD (defined __ATOMIC_RELAXED)
174+
#ifdef __ATOMIC_RELAXED
175+
#define HAVE___ATOMIC_FETCH_ADD 1
176+
#else
177+
#define HAVE___ATOMIC_FETCH_ADD 0
178+
#endif
167179
#endif
168180

169181
#ifndef HAVE___ATOMIC_FETCH_SUB
@@ -525,7 +537,11 @@
525537
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
526538

527539
#ifndef HAVE_CLOCKID_T
528-
#define HAVE_CLOCKID_T (defined CLOCK_MONOTONIC)
540+
#ifdef CLOCK_MONOTONIC
541+
#define HAVE_CLOCKID_T 1
542+
#else
543+
#define HAVE_CLOCKID_T 0
544+
#endif
529545
#endif
530546

531547
#ifndef HAVE_STRUCT_SOCKADDR_SA_LEN
@@ -583,19 +599,31 @@
583599
#endif
584600

585601
#ifndef HAVE_DECL_CLOCK_MONOTONIC
586-
#define HAVE_DECL_CLOCK_MONOTONIC (defined CLOCK_MONOTONIC)
602+
#ifdef CLOCK_MONOTONIC
603+
#define HAVE_DECL_CLOCK_MONOTONIC 1
604+
#else
605+
#define HAVE_DECL_CLOCK_MONOTONIC 0
606+
#endif
587607
#endif
588608

589609
#ifndef HAVE_DECL_CLOCK_REALTIME
590-
#define HAVE_DECL_CLOCK_REALTIME (defined CLOCK_REALTIME)
610+
#ifdef CLOCK_REALTIME
611+
#define HAVE_DECL_CLOCK_REALTIME 1
612+
#else
613+
#define HAVE_DECL_CLOCK_REALTIME 0
614+
#endif
591615
#endif
592616

593617
#ifndef HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
594618
#define HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME (__linux__ && HAVE__GNU_SOURCE)
595619
#endif
596620

597621
#ifndef HAVE_DECL_PTHREAD_MUTEX_ROBUST
598-
#define HAVE_DECL_PTHREAD_MUTEX_ROBUST (defined PTHREAD_MUTEX_ROBUST || AG_GLIBC_PREREQ(2,12))
622+
#ifdef PTHREAD_MUTEX_ROBUST
623+
#define HAVE_DECL_PTHREAD_MUTEX_ROBUST 1
624+
#else
625+
#define HAVE_DECL_PTHREAD_MUTEX_ROBUST AG_GLIBC_PREREQ(2,12)
626+
#endif
599627
#endif
600628

601629
#ifndef HAVE_DECL_STRERROR_R
@@ -631,7 +659,11 @@
631659
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
632660

633661
#ifndef HAVE_ACCEPT4
634-
#define HAVE_ACCEPT4 (defined SOCK_CLOEXEC && !__NetBSD__)
662+
#ifdef SOCK_CLOEXEC
663+
#define HAVE_ACCEPT4 !__NetBSD__
664+
#else
665+
#define HAVE_ACCEPT4 0
666+
#endif
635667
#endif
636668

637669
#ifndef HAVE_ARC4RANDOM
@@ -688,15 +720,23 @@
688720
#endif
689721

690722
#ifndef HAVE_EPOLL_CREATE1
691-
#define HAVE_EPOLL_CREATE1 (HAVE_EPOLL_CREATE && (defined EPOLL_CLOEXEC || AG_GLIBC_PREREQ(2,9)))
723+
#if HAVE_EPOLL_CREATE && (defined EPOLL_CLOEXEC || AG_GLIBC_PREREQ(2,9))
724+
#define HAVE_EPOLL_CREATE1 1
725+
#else
726+
#define HAVE_EPOLL_CREATE1 0
727+
#endif
692728
#endif
693729

694730
#ifndef HAVE_EPOLL_CTL
695731
#define HAVE_EPOLL_CTL HAVE_EPOLL_CREATE
696732
#endif
697733

698734
#ifndef HAVE_EPOLL_PWAIT
699-
#define HAVE_EPOLL_PWAIT (HAVE_EPOLL_WAIT && (AG_GLIBC_PREREQ(2,6) || (!AG_GLIBC_PREREQ(0,0) && defined EPOLL_CLOEXEC)))
735+
#if HAVE_EPOLL_WAIT && (AG_GLIBC_PREREQ(2,6) || (!AG_GLIBC_PREREQ(0,0) && defined EPOLL_CLOEXEC))
736+
#define HAVE_EPOLL_PWAIT 1
737+
#else
738+
#define HAVE_EPOLL_PWAIT 0
739+
#endif
700740
#endif
701741

702742
#ifndef HAVE_EPOLL_WAIT
@@ -732,7 +772,11 @@
732772
#endif
733773

734774
#ifndef HAVE_INOTIFY_INIT1
735-
#define HAVE_INOTIFY_INIT1 (HAVE_INOTIFY_INIT && defined IN_CLOEXEC)
775+
#if HAVE_INOTIFY_INIT && defined IN_CLOEXEC
776+
#define HAVE_INOTIFY_INIT1 1
777+
#else
778+
#define HAVE_INOTIFY_INIT1 0
779+
#endif
736780
#endif
737781

738782
#ifndef HAVE_ISSETUGID
@@ -744,7 +788,11 @@
744788
#endif
745789

746790
#ifndef HAVE_KEVENT
747-
#define HAVE_KEVENT (defined EV_SET)
791+
#ifdef EV_SET
792+
#define HAVE_KEVENT 1
793+
#else
794+
#define HAVE_KEVENT 0
795+
#endif
748796
#endif
749797

750798
#ifndef HAVE_KQUEUE
@@ -822,10 +870,11 @@
822870
#endif
823871

824872
#ifndef HAVE_STATIC_ASSERT
825-
#if AG_GLIBC_PREREQ(0,0) && !HAVE__STATIC_ASSERT
826-
#define HAVE_STATIC_ASSERT 0 /* glibc doesn't check GCC version */
873+
/* glibc doesn't check GCC version */
874+
#if (AG_GLIBC_PREREQ(0,0) && !HAVE__STATIC_ASSERT) || (!defined static_assert)
875+
#define HAVE_STATIC_ASSERT 0
827876
#else
828-
#define HAVE_STATIC_ASSERT (defined static_assert)
877+
#define HAVE_STATIC_ASSERT 1
829878
#endif
830879
#endif
831880

src/lib/notify.c

+20-4
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,35 @@
6161
#endif
6262

6363
#ifndef HAVE_O_CLOEXEC
64-
#define HAVE_O_CLOEXEC (defined O_CLOEXEC)
64+
#ifdef O_CLOEXEC
65+
#define HAVE_O_CLOEXEC 1
66+
#else
67+
#define HAVE_O_CLOEXEC 0
68+
#endif
6569
#endif
6670

6771
#ifndef HAVE_O_DIRECTORY
68-
#define HAVE_O_DIRECTORY (defined O_DIRECTORY)
72+
#ifdef O_DIRECTORY
73+
#define HAVE_O_DIRECTORY 1
74+
#else
75+
#define HAVE_O_DIRECTORY 0
76+
#endif
6977
#endif
7078

7179
#ifndef HAVE_IN_CLOEXEC
72-
#define HAVE_IN_CLOEXEC (defined IN_CLOEXEC)
80+
#ifdef IN_CLOEXEC
81+
#define HAVE_IN_CLOEXEC 1
82+
#else
83+
#define HAVE_IN_CLOEXEC 0
84+
#endif
7385
#endif
7486

7587
#ifndef HAVE_IN_NONBLOCK
76-
#define HAVE_IN_NONBLOCK (defined IN_NONBLOCK)
88+
#ifdef IN_NONBLOCK
89+
#define HAVE_IN_NONBLOCK 1
90+
#else
91+
#define HAVE_IN_NONBLOCK 0
92+
#endif
7793
#endif
7894

7995
#if ENABLE_INOTIFY

src/lib/socket.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,11 @@ static inline void so_setbool(so_optional *v, _Bool b) {
224224
*
225225
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
226226

227-
#define SA_UNIX defined(AF_UNIX) && !_WIN32
227+
#if defined(AF_UNIX)
228+
#define SA_UNIX (!_WIN32)
229+
#else
230+
#define SA_UNIX 0
231+
#endif
228232

229233
union sockaddr_any {
230234
struct sockaddr sa;

src/signal.c

+5-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@
5454
#endif
5555

5656
#ifndef ENABLE_EVFILT_SIGNAL
57-
#define ENABLE_EVFILT_SIGNAL (ENABLE_KQUEUE && defined EVFILT_SIGNAL)
57+
#ifdef EVFILT_SIGNAL
58+
#define ENABLE_EVFILT_SIGNAL ENABLE_KQUEUE
59+
#else
60+
#define ENABLE_EVFILT_SIGNAL 0
61+
#endif
5862
#endif
5963

6064
#define LSL_CLASS "CQS Signal"

0 commit comments

Comments
 (0)