comparison packages/language/c/libc/stdio/current/include/stdiofiles.inl @ 115:6ed91473a1cd ecos-sw-2000-08-21

Merge from eCos master repository on 2000-08-21-22:40:54-BST
author jlarmour
date Fri, 25 Aug 2000 17:32:38 +0000
parents
children e0c0827131d1
comparison
equal deleted inserted replaced
114:5ad2b71d525e 115:6ed91473a1cd
1 #ifndef CYGONCE_LIBC_STDIO_STDIOFILES_INL
2 #define CYGONCE_LIBC_STDIO_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 Red Hat eCos Public License
14 // Version 1.1 (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://www.redhat.com/
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 Configurable Operating System,
24 // released September 30, 1998.
25 //
26 // The Initial Developer of the Original Code is Red Hat.
27 // Portions created by Red Hat are
28 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc.
29 // All Rights Reserved.
30 // -------------------------------------------
31 //
32 //####COPYRIGHTEND####
33 //========================================================================
34 //#####DESCRIPTIONBEGIN####
35 //
36 // Author(s): jlarmour
37 // Contributors:
38 // Date: 2000-04-19
39 // Purpose:
40 // Description:
41 // Usage: Do not include this file directly. Instead use:
42 // #include <cyg/libc/stdio/stdiofiles.hxx>
43 //
44 //####DESCRIPTIONEND####
45 //
46 //========================================================================
47
48 // CONFIGURATION
49
50 #include <pkgconf/libc_stdio.h> // libc stdio configuration
51
52 // INCLUDES
53
54 #include <cyg/infra/cyg_type.h> // cyg_bool
55 #include <cyg/infra/cyg_ass.h> // Assert interface
56 #include <cyg/libc/stdio/stdiofiles.hxx> // header for this file
57 #include <cyg/libc/stdio/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 // CYGONCE_LIBC_STDIO_STDIOFILES_INL multiple inclusion protection
116
117 // EOF stdiofiles.inl