|
0
|
1 //======================================================================== |
|
|
2 // |
|
|
3 // _exit.cxx |
|
|
4 // |
|
|
5 // _exit() as from POSIX 1003.1 section 3.2.2 "Terminate a process" |
|
|
6 // |
|
|
7 //======================================================================== |
|
|
8 //####COPYRIGHTBEGIN#### |
|
|
9 // |
|
|
10 // ------------------------------------------- |
|
|
11 // The contents of this file are subject to the Cygnus eCos Public License |
|
|
12 // Version 1.0 (the "License"); you may not use this file except in |
|
|
13 // compliance with the License. You may obtain a copy of the License at |
|
|
14 // http://sourceware.cygnus.com/ecos |
|
|
15 // |
|
|
16 // Software distributed under the License is distributed on an "AS IS" |
|
|
17 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the |
|
|
18 // License for the specific language governing rights and limitations under |
|
|
19 // the License. |
|
|
20 // |
|
|
21 // The Original Code is eCos - Embedded Cygnus Operating System, released |
|
|
22 // September 30, 1998. |
|
|
23 // |
|
|
24 // The Initial Developer of the Original Code is Cygnus. Portions created |
|
2
|
25 // by Cygnus are Copyright (C) 1998,1999 Cygnus Solutions. All Rights Reserved. |
|
0
|
26 // ------------------------------------------- |
|
|
27 // |
|
|
28 //####COPYRIGHTEND#### |
|
|
29 //======================================================================== |
|
|
30 //#####DESCRIPTIONBEGIN#### |
|
|
31 // |
|
2
|
32 // Author(s): jlarmour |
|
|
33 // Contributors: jlarmour |
|
|
34 // Date: 1999-01-21 |
|
|
35 // Purpose: Provides POSIX 1003.1 _exit() function |
|
0
|
36 // Description: |
|
|
37 // Usage: |
|
|
38 // |
|
|
39 //####DESCRIPTIONEND#### |
|
|
40 // |
|
|
41 //======================================================================== |
|
|
42 |
|
|
43 // CONFIGURATION |
|
|
44 |
|
2
|
45 #include <pkgconf/libc.h> // C library configuration header |
|
0
|
46 |
|
|
47 // INCLUDES |
|
|
48 |
|
|
49 #include <cyg/infra/cyg_type.h> // Common type definitions and support |
|
|
50 #include <cyg/infra/cyg_trac.h> // Common tracing support |
|
|
51 #include <cyg/infra/cyg_ass.h> // Common assertion support |
|
|
52 #include <stdlib.h> // Header for all stdlib functions |
|
|
53 // (like this one) |
|
|
54 #include "clibincl/stdlibsupp.hxx" // Support for stdlib functions |
|
|
55 #ifdef CYGPKG_KERNEL |
|
2
|
56 # include <pkgconf/kernel.h> // kernel configuration |
|
0
|
57 # include <cyg/kernel/thread.hxx> // eCos kernel for thread termination |
|
|
58 # include <cyg/kernel/thread.inl> // and |
|
|
59 # include <cyg/kernel/sched.hxx> // for stopping the scheduler |
|
|
60 # include <cyg/kernel/sched.inl> |
|
|
61 #endif |
|
|
62 |
|
|
63 |
|
|
64 // SYMBOLS |
|
|
65 |
|
|
66 externC void |
|
2
|
67 _exit( int ) CYGBLD_ATTRIB_WEAK_ALIAS(__libc__exit) CYGBLD_ATTRIB_NORET; |
|
0
|
68 |
|
|
69 // FUNCTIONS |
|
|
70 |
|
|
71 externC void |
|
|
72 __libc__exit( int status ) |
|
|
73 { |
|
|
74 CYG_REPORT_FUNCTION(); // shouldn't return, but CYG_FAIL will catch it |
|
|
75 CYG_REPORT_FUNCARG1DV( status ); |
|
|
76 |
|
|
77 #ifdef CYGPKG_KERNEL |
|
|
78 |
|
|
79 # ifdef CYGSEM_LIBC_EXIT_STOPS_SYSTEM |
|
|
80 |
|
|
81 Cyg_Scheduler::lock(); // prevent rescheduling |
|
|
82 |
|
|
83 for (;;) |
|
|
84 CYG_EMPTY_STATEMENT; |
|
|
85 |
|
|
86 # else |
|
|
87 |
|
|
88 Cyg_Thread::exit(); |
|
|
89 |
|
|
90 # endif |
|
|
91 #endif |
|
|
92 |
|
|
93 // loop forever |
|
|
94 for (;;) |
|
|
95 CYG_EMPTY_STATEMENT; |
|
|
96 |
|
|
97 CYG_FAIL( "__libc__exit() returning!!!" ); |
|
|
98 |
|
|
99 CYG_REPORT_RETURN(); |
|
|
100 } // _exit() |
|
|
101 |
|
|
102 |
|
|
103 // EOF _exit.cxx |