|
2
|
1 //======================================================================== |
|
|
2 // |
|
|
3 // stdout.cxx |
|
|
4 // |
|
|
5 // Initialization of stdout stream for ISO C library |
|
|
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 |
|
|
25 // by Cygnus are Copyright (C) 1998,1999 Cygnus Solutions. All Rights Reserved. |
|
|
26 // ------------------------------------------- |
|
|
27 // |
|
|
28 //####COPYRIGHTEND#### |
|
|
29 //======================================================================== |
|
|
30 //#####DESCRIPTIONBEGIN#### |
|
|
31 // |
|
|
32 // Author(s): jlarmour |
|
|
33 // Contributors: jlarmour |
|
|
34 // Date: 1999-01-15 |
|
|
35 // Purpose: Initialization of stdout stream for ISO C library |
|
|
36 // Description: We put all this in a separate file in the hope that if |
|
|
37 // no-one uses stdout, then it is not included in the image |
|
|
38 // Usage: |
|
|
39 // |
|
|
40 //####DESCRIPTIONEND#### |
|
|
41 // |
|
|
42 //======================================================================== |
|
|
43 |
|
|
44 // CONFIGURATION |
|
|
45 |
|
|
46 #include <pkgconf/libc.h> // Configuration header |
|
|
47 |
|
|
48 #ifdef CYGPKG_LIBC_STDIO |
|
|
49 |
|
|
50 // Don't let us get the stream definitions of stdin/out/err from stdio.h |
|
|
51 // since we are going to break the type safety :-( |
|
|
52 #define CYGPRI_LIBC_STDIO_NO_DEFAULT_STREAMS |
|
|
53 |
|
|
54 // And we don't need the stdio inlines, which will otherwise complain if |
|
|
55 // stdin/out/err are not available |
|
|
56 #ifdef CYGIMP_LIBC_STDIO_INLINES |
|
|
57 # undef CYGIMP_LIBC_STDIO_INLINES |
|
|
58 #endif |
|
|
59 |
|
|
60 // INCLUDES |
|
|
61 |
|
|
62 #include <cyg/infra/cyg_type.h> // Common type definitions and support |
|
|
63 #include "clibincl/stream.hxx" // Cyg_StdioStream class |
|
|
64 #include "clibincl/stdiofiles.hxx" // C library files |
|
|
65 #include "clibincl/stdiosupp.hxx" // Cyg_libc_stdio_find_filename() |
|
|
66 |
|
|
67 // STATICS |
|
|
68 |
|
|
69 Cyg_StdioStream |
|
|
70 cyg_libc_stdio_stdout CYG_INIT_PRIORITY(LIBC) = Cyg_StdioStream( |
|
|
71 Cyg_libc_stdio_find_filename(CYGDAT_LIBC_STDIO_DEFAULT_CONSOLE), |
|
|
72 Cyg_StdioStream::CYG_STREAM_WRITE, false, false, _IOLBF ); |
|
|
73 |
|
|
74 // CLASSES |
|
|
75 |
|
|
76 // This is a dummy class just so we can execute arbitrary code when |
|
|
77 // stdout is requested |
|
|
78 |
|
|
79 class cyg_libc_dummy_stdout_init_class { |
|
|
80 public: |
|
|
81 cyg_libc_dummy_stdout_init_class(void) { |
|
|
82 Cyg_libc_stdio_files::set_file_stream(1, &cyg_libc_stdio_stdout); |
|
|
83 } |
|
|
84 }; |
|
|
85 |
|
|
86 // And here's an instance of the class just to make the code run |
|
|
87 static cyg_libc_dummy_stdout_init_class cyg_libc_dummy_stdout_init |
|
|
88 CYG_INIT_PRIORITY(LIBC); |
|
|
89 |
|
|
90 #endif // ifdef CYGPKG_LIBC_STDIO |
|
|
91 |
|
|
92 // EOF stdout.cxx |