|
2
|
1 #ifndef CYGONCE_LIBC_STDIOFILES_INL |
|
|
2 #define CYGONCE_LIBC_STDIOFILES_INL |
|
|
3 //======================================================================== |
|
|
4 // |
|
|
5 // stdiofiles.inl |
|
|
6 // |
|
|
7 // ISO C library stdio central file inlines |
|
|
8 // |
|
|
9 //======================================================================== |
|
|
10 //####COPYRIGHTBEGIN#### |
|
|
11 // |
|
|
12 // ------------------------------------------- |
|
|
13 // The contents of this file are subject to the Cygnus eCos Public License |
|
|
14 // Version 1.0 (the "License"); you may not use this file except in |
|
|
15 // compliance with the License. You may obtain a copy of the License at |
|
|
16 // http://sourceware.cygnus.com/ecos |
|
|
17 // |
|
|
18 // Software distributed under the License is distributed on an "AS IS" |
|
|
19 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the |
|
|
20 // License for the specific language governing rights and limitations under |
|
|
21 // the License. |
|
|
22 // |
|
|
23 // The Original Code is eCos - Embedded Cygnus Operating System, released |
|
|
24 // September 30, 1998. |
|
|
25 // |
|
|
26 // The Initial Developer of the Original Code is Cygnus. Portions created |
|
|
27 // by Cygnus are Copyright (C) 1998,1999 Cygnus Solutions. All Rights Reserved. |
|
|
28 // ------------------------------------------- |
|
|
29 // |
|
|
30 //####COPYRIGHTEND#### |
|
|
31 //======================================================================== |
|
|
32 //#####DESCRIPTIONBEGIN#### |
|
|
33 // |
|
|
34 // Author(s): jlarmour |
|
|
35 // Contributors: jlarmour |
|
|
36 // Date: 1999-01-21 |
|
|
37 // Purpose: |
|
|
38 // Description: |
|
|
39 // Usage: Do not include this file directly. Instead use: |
|
|
40 // #include "clibincl/stdiosupp.hxx" |
|
|
41 // |
|
|
42 //####DESCRIPTIONEND#### |
|
|
43 // |
|
|
44 //======================================================================== |
|
|
45 |
|
|
46 // CONFIGURATION |
|
|
47 |
|
|
48 #include <pkgconf/libc.h> // C library configuration |
|
|
49 |
|
|
50 #ifdef CYGPKG_LIBC_STDIO |
|
|
51 |
|
|
52 // INCLUDES |
|
|
53 |
|
|
54 #include <cyg/infra/cyg_type.h> // cyg_bool |
|
|
55 #include <cyg/infra/cyg_ass.h> // Assert interface |
|
|
56 #include "clibincl/stdiofiles.hxx" // header for this file |
|
|
57 #include "clibincl/stream.hxx" // Cyg_StdioStream |
|
|
58 |
|
|
59 #ifdef CYGSEM_LIBC_STDIO_THREAD_SAFE_STREAMS |
|
|
60 # include <cyg/kernel/mutex.hxx> // mutexes |
|
|
61 #endif |
|
|
62 |
|
|
63 // INLINE METHODS |
|
|
64 |
|
|
65 inline Cyg_StdioStream * |
|
|
66 Cyg_libc_stdio_files::get_file_stream( fd_t fd ) |
|
|
67 { |
|
|
68 CYG_PRECONDITION( (fd < FOPEN_MAX), |
|
|
69 "Attempt to open larger file descriptor than FOPEN_MAX!" ); |
|
|
70 |
|
|
71 return files[fd]; |
|
|
72 |
|
|
73 } // Cyg_libc_stdio_files::get_file_stream() |
|
|
74 |
|
|
75 inline void |
|
|
76 Cyg_libc_stdio_files::set_file_stream( fd_t fd, Cyg_StdioStream *stream ) |
|
|
77 { |
|
|
78 CYG_PRECONDITION( (fd < FOPEN_MAX), |
|
|
79 "Attempt to set larger file descriptor than FOPEN_MAX!" ); |
|
|
80 |
|
|
81 files[fd] = stream; |
|
|
82 |
|
|
83 } // Cyg_libc_stdio_files::set_file_stream() |
|
|
84 |
|
|
85 |
|
|
86 inline cyg_bool |
|
|
87 Cyg_libc_stdio_files::lock(void) |
|
|
88 { |
|
|
89 # ifdef CYGSEM_LIBC_STDIO_THREAD_SAFE_STREAMS |
|
|
90 return files_lock.lock(); |
|
|
91 # else |
|
|
92 return true; |
|
|
93 # endif |
|
|
94 } // Cyg_libc_stdio_files::lock() |
|
|
95 |
|
|
96 inline cyg_bool |
|
|
97 Cyg_libc_stdio_files::trylock(void) |
|
|
98 { |
|
|
99 # ifdef CYGSEM_LIBC_STDIO_THREAD_SAFE_STREAMS |
|
|
100 return files_lock.trylock(); |
|
|
101 # else |
|
|
102 return true; |
|
|
103 # endif |
|
|
104 } // Cyg_libc_stdio_files::trylock() |
|
|
105 |
|
|
106 inline void |
|
|
107 Cyg_libc_stdio_files::unlock(void) |
|
|
108 { |
|
|
109 # ifdef CYGSEM_LIBC_STDIO_THREAD_SAFE_STREAMS |
|
|
110 files_lock.unlock(); |
|
|
111 # endif |
|
|
112 } // Cyg_libc_stdio_files::unlock() |
|
|
113 |
|
|
114 |
|
|
115 #endif // ifdef CYGPKG_LIBC_STDIO |
|
|
116 |
|
|
117 #endif // CYGONCE_LIBC_STDIOFILES_INL multiple inclusion protection |
|
|
118 |
|
|
119 // EOF stdiofiles.inl |