d5922f60f0a451ba62bcc17484b27a1fdb6ff7f5
[packages/trusty/cirros-testvm.git] / cirros-testvm / src-cirros / buildroot-2015.05 / package / uclibc / 0.9.33.2 / 0057-bits-waitstatus.h-correctly-interpret-status-0x007f-.patch
1 From 4a96b948687166da26a6c327e6c6733ad2336c5c Mon Sep 17 00:00:00 2001
2 From: Denys Vlasenko <vda.linux@googlemail.com>
3 Date: Thu, 18 Jul 2013 21:57:06 +0200
4 Subject: [PATCH-0.9.33] bits/waitstatus.h: correctly interpret status 0x007f on
5  MIPS
6
7 On other architectures exit status of 0x007f is not possible,
8 they don't have signal 127.
9
10 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
11 ---
12  libc/sysdeps/linux/common/bits/waitstatus.h | 16 ++++++++++++----
13  1 file changed, 12 insertions(+), 4 deletions(-)
14
15 diff --git a/libc/sysdeps/linux/common/bits/waitstatus.h b/libc/sysdeps/linux/common/bits/waitstatus.h
16 index 45d0fd3..33f39a8 100644
17 --- a/libc/sysdeps/linux/common/bits/waitstatus.h
18 +++ b/libc/sysdeps/linux/common/bits/waitstatus.h
19 @@ -24,7 +24,7 @@
20  /* Everything extant so far uses these same bits.  */
21  
22  
23 -/* If WIFEXITED(STATUS), the low-order 8 bits of the status.  */
24 +/* If WIFEXITED(STATUS), the low-order 8 bits of exit(N).  */
25  #define        __WEXITSTATUS(status)   (((status) & 0xff00) >> 8)
26  
27  /* If WIFSIGNALED(STATUS), the terminating signal.  */
28 @@ -36,12 +36,20 @@
29  /* Nonzero if STATUS indicates normal termination.  */
30  #define        __WIFEXITED(status)     (__WTERMSIG(status) == 0)
31  
32 -/* Nonzero if STATUS indicates termination by a signal.  */
33 -#define __WIFSIGNALED(status) \
34 -  (((signed char) (((status) & 0x7f) + 1) >> 1) > 0)
35 +/* Nonzero if STATUS indicates termination by a signal.
36 + * Note that status 0x007f is "died from signal 127", not "stopped by signal 0".
37 + * This does happen on MIPS.
38 + * The comparison is "< 0xff", not "< 0x7f", because WCOREDUMP bit (0x80)
39 + * can be set too.
40 + */
41 +#define        __WIFSIGNALED(status)   (((unsigned)((status) & 0xffff) - 1U) < 0xffU)
42  
43  /* Nonzero if STATUS indicates the child is stopped.  */
44 +#if !defined(__mips__)
45  #define        __WIFSTOPPED(status)    (((status) & 0xff) == 0x7f)
46 +#else
47 +#define        __WIFSTOPPED(status)    (((status) & 0xff) == 0x7f && ((status) & 0xff00))
48 +#endif
49  
50  /* Nonzero if STATUS indicates the child continued after a stop.  We only
51     define this if <bits/waitflags.h> provides the WCONTINUED flag bit.  */
52 -- 
53 1.8.1.2
54