OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [uclinux/] [uC-libc/] [include/] [waitstatus.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 199 simons
/* Definitions of status bits for `wait' et al.
2
Copyright (C) 1992 Free Software Foundation, Inc.
3
This file is part of the GNU C Library.
4
 
5
The GNU C Library is free software; you can redistribute it and/or
6
modify it under the terms of the GNU Library General Public License as
7
published by the Free Software Foundation; either version 2 of the
8
License, or (at your option) any later version.
9
 
10
The GNU C Library is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
Library General Public License for more details.
14
 
15
You should have received a copy of the GNU Library General Public
16
License along with the GNU C Library; see the file COPYING.LIB.  If
17
not, write to the Free Software Foundation, Inc., 675 Mass Ave,
18
Cambridge, MA 02139, USA.  */
19
 
20
/* Everything extant so far uses these same bits.  */
21
 
22
#ifndef _WAITSTATUS_H
23
#define _WAITSTATUS_H
24
 
25
/* If WIFEXITED(STATUS), the low-order 8 bits of the status.  */
26
#define __WEXITSTATUS(status)   (((status) & 0xff00) >> 8)
27
 
28
/* If WIFSIGNALED(STATUS), the terminating signal.  */
29
#define __WTERMSIG(status)      ((status) & 0x7f)
30
 
31
/* If WIFSTOPPED(STATUS), the signal that stopped the child.  */
32
#define __WSTOPSIG(status)      __WEXITSTATUS(status)
33
 
34
#ifdef __linux__
35
/* Nonzero if STATUS indicates normal termination.  */
36
#define __WIFEXITED(status)     (((status) & 0xff) == 0)
37
 
38
/* Nonzero if STATUS indicates termination by a signal.  */
39
#define __WIFSIGNALED(status)   (((unsigned int)((status)-1) & 0xFFFF) < 0xFF)
40
 
41
#else   /* __linux__ */
42
 
43
/* Nonzero if STATUS indicates normal termination.  */
44
#define __WIFEXITED(status)     (__WTERMSIG(status) == 0)
45
 
46
/* Nonzero if STATUS indicates termination by a signal.  */
47
#ifdef  __GNUC__
48
#define __WIFSIGNALED(status)                                                 \
49
  (__extension__ ({ int __stat = (status);                                    \
50
                    !__WIFSTOPPED(__stat) && !__WIFEXITED(__stat); }))
51
#else   /* Not GCC.  */
52
#define __WIFSIGNALED(status)   (!__WIFSTOPPED(status) && !__WIFEXITED(status))
53
#endif  /* GCC.  */
54
 
55
#endif  /* __linux__ */
56
 
57
/* Nonzero if STATUS indicates the child is stopped.  */
58
#define __WIFSTOPPED(status)    (((status) & 0xff) == 0x7f)
59
 
60
/* Nonzero if STATUS indicates the child dumped core.  */
61
#define __WCOREDUMP(status)     ((status) & 0200)
62
 
63
/* Macros for constructing status values.  */
64
#define __W_EXITCODE(ret, sig)  ((ret) << 8 | (sig))
65
#define __W_STOPCODE(sig)       ((sig) << 8 | 0x7f)
66
 
67
 
68
#ifdef  __USE_BSD
69
 
70
#include <endian.h>
71
 
72
union wait
73
  {
74
    int w_status;
75
    struct
76
      {
77
#if     __BYTE_ORDER == __LITTLE_ENDIAN
78
        unsigned int __w_termsig:7; /* Terminating signal.  */
79
        unsigned int __w_coredump:1; /* Set if dumped core.  */
80
        unsigned int __w_retcode:8; /* Return code if exited normally.  */
81
        unsigned int:16;
82
#endif                          /* Little endian.  */
83
#if     __BYTE_ORDER == __BIG_ENDIAN
84
        unsigned int:16;
85
        unsigned int __w_retcode:8;
86
        unsigned int __w_coredump:1;
87
        unsigned int __w_termsig:7;
88
#endif                          /* Big endian.  */
89
      } __wait_terminated;
90
    struct
91
      {
92
#if     __BYTE_ORDER == __LITTLE_ENDIAN
93
        unsigned int __w_stopval:8; /* W_STOPPED if stopped.  */
94
        unsigned int __w_stopsig:8; /* Stopping signal.  */
95
        unsigned int:16;
96
#endif                          /* Little endian.  */
97
#if     __BYTE_ORDER == __BIG_ENDIAN
98
        unsigned int:16;
99
        unsigned int __w_stopsig:8; /* Stopping signal.  */
100
        unsigned int __w_stopval:8; /* W_STOPPED if stopped.  */
101
#endif                          /* Big endian.  */
102
      } __wait_stopped;
103
  };
104
 
105
#define w_termsig       __wait_terminated.__w_termsig
106
#define w_coredump      __wait_terminated.__w_coredump
107
#define w_retcode       __wait_terminated.__w_retcode
108
#define w_stopsig       __wait_stopped.__w_stopsig
109
#define w_stopval       __wait_stopped.__w_stopval
110
 
111
#endif  /* Use BSD.  */
112
 
113
 
114
#endif  /* waitstatus.h */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.