Skip to content

Commit 7452fa3

Browse files
committed
posix: signal.h: reorder where sigval and siginfo_t are declared
In order to avoid warnings, declare `union sigval` ahead of `struct sigevent` and declare `siginfo_t` ahead of `struct sigaction`. Signed-off-by: Chris Friedt <[email protected]>
1 parent 1f1d0f4 commit 7452fa3

File tree

1 file changed

+29
-30
lines changed

1 file changed

+29
-30
lines changed

include/zephyr/posix/posix_signal.h

Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,15 @@ typedef struct {
9898

9999
#if defined(_POSIX_REALTIME_SIGNALS) || defined(__DOXYGEN__)
100100

101-
union sigval; /* forward declaration (to preserve spec order) */
101+
/* slightly out of order w.r.t. the specification */
102+
#if !defined(_SIGVAL_DECLARED) && !defined(__sigval_defined)
103+
union sigval {
104+
int sival_int;
105+
void *sival_ptr;
106+
};
107+
#define _SIGVAL_DECLARED
108+
#define __sigval_defined
109+
#endif
102110

103111
#if !defined(_SIGEVENT_DECLARED) && !defined(__sigevent_defined)
104112
struct sigevent {
@@ -121,17 +129,28 @@ struct sigevent {
121129

122130
#endif /* defined(_POSIX_REALTIME_SIGNALS) || defined(__DOXYGEN__) */
123131

124-
#if !defined(_SIGVAL_DECLARED) && !defined(__sigval_defined)
125-
union sigval {
126-
int sival_int;
127-
void *sival_ptr;
128-
};
129-
#define _SIGVAL_DECLARED
130-
#define __sigval_defined
131-
#endif
132-
133132
/* SIGRTMIN and SIGRTMAX defined above */
134133

134+
#if !defined(_SIGINFO_T_DECLARED) && !defined(__siginfo_t_defined)
135+
typedef struct {
136+
void *si_addr;
137+
#if defined(_XOPEN_STREAMS) || defined(__DOXYGEN__)
138+
long si_band;
139+
#endif
140+
union sigval si_value;
141+
pid_t si_pid;
142+
uid_t si_uid;
143+
int si_signo;
144+
int si_code;
145+
#if defined(_XOPEN_SOURCE) || defined(__DOXYGEN__)
146+
int si_errno;
147+
#endif
148+
int si_status;
149+
} siginfo_t;
150+
#define _SIGINFO_T_DECLARED
151+
#define __siginfo_t_defined
152+
#endif
153+
135154
#if defined(_POSIX_REALTIME_SIGNALS) || defined(__DOXYGEN__)
136155

137156
#if !defined(_SIGACTION_DECLARED) && !defined(__sigaction_defined)
@@ -200,26 +219,6 @@ typedef struct {
200219

201220
#endif /* defined(_POSIX_REALTIME_SIGNALS) || defined(__DOXYGEN__) */
202221

203-
#if !defined(_SIGINFO_T_DECLARED) && !defined(__siginfo_t_defined)
204-
typedef struct {
205-
void *si_addr;
206-
#if defined(_XOPEN_STREAMS) || defined(__DOXYGEN__)
207-
long si_band;
208-
#endif
209-
union sigval si_value;
210-
pid_t si_pid;
211-
uid_t si_uid;
212-
int si_signo;
213-
int si_code;
214-
#if defined(_XOPEN_SOURCE) || defined(__DOXYGEN__)
215-
int si_errno;
216-
#endif
217-
int si_status;
218-
} siginfo_t;
219-
#define _SIGINFO_T_DECLARED
220-
#define __siginfo_t_defined
221-
#endif
222-
223222
/* Siginfo codes are defined below */
224223

225224
#if !defined(_SIGHANDLER_T_DECLARED) && !defined(__sighandler_t_defined)

0 commit comments

Comments
 (0)