1 |
27 |
unneback |
#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 |
|
|
//####ECOSGPLCOPYRIGHTBEGIN####
|
11 |
|
|
// -------------------------------------------
|
12 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
13 |
|
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
|
14 |
|
|
//
|
15 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
16 |
|
|
// the terms of the GNU General Public License as published by the Free
|
17 |
|
|
// Software Foundation; either version 2 or (at your option) any later version.
|
18 |
|
|
//
|
19 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
20 |
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
21 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
22 |
|
|
// for more details.
|
23 |
|
|
//
|
24 |
|
|
// You should have received a copy of the GNU General Public License along
|
25 |
|
|
// with eCos; if not, write to the Free Software Foundation, Inc.,
|
26 |
|
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
27 |
|
|
//
|
28 |
|
|
// As a special exception, if other files instantiate templates or use macros
|
29 |
|
|
// or inline functions from this file, or you compile this file and link it
|
30 |
|
|
// with other works to produce a work based on this file, this file does not
|
31 |
|
|
// by itself cause the resulting work to be covered by the GNU General Public
|
32 |
|
|
// License. However the source code for this file must still be made available
|
33 |
|
|
// in accordance with section (3) of the GNU General Public License.
|
34 |
|
|
//
|
35 |
|
|
// This exception does not invalidate any other reasons why a work based on
|
36 |
|
|
// this file might be covered by the GNU General Public License.
|
37 |
|
|
//
|
38 |
|
|
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
|
39 |
|
|
// at http://sources.redhat.com/ecos/ecos-license/
|
40 |
|
|
// -------------------------------------------
|
41 |
|
|
//####ECOSGPLCOPYRIGHTEND####
|
42 |
|
|
//========================================================================
|
43 |
|
|
//#####DESCRIPTIONBEGIN####
|
44 |
|
|
//
|
45 |
|
|
// Author(s): jlarmour
|
46 |
|
|
// Contributors:
|
47 |
|
|
// Date: 2000-04-19
|
48 |
|
|
// Purpose:
|
49 |
|
|
// Description:
|
50 |
|
|
// Usage: Do not include this file directly. Instead use:
|
51 |
|
|
// #include
|
52 |
|
|
//
|
53 |
|
|
//####DESCRIPTIONEND####
|
54 |
|
|
//
|
55 |
|
|
//========================================================================
|
56 |
|
|
|
57 |
|
|
// CONFIGURATION
|
58 |
|
|
|
59 |
|
|
#include // libc stdio configuration
|
60 |
|
|
|
61 |
|
|
// INCLUDES
|
62 |
|
|
|
63 |
|
|
#include // cyg_bool
|
64 |
|
|
#include // Assert interface
|
65 |
|
|
#include // header for this file
|
66 |
|
|
#include // Cyg_StdioStream
|
67 |
|
|
|
68 |
|
|
#ifdef CYGSEM_LIBC_STDIO_THREAD_SAFE_STREAMS
|
69 |
|
|
# include // mutexes
|
70 |
|
|
#endif
|
71 |
|
|
|
72 |
|
|
// INLINE METHODS
|
73 |
|
|
|
74 |
|
|
inline Cyg_StdioStream *
|
75 |
|
|
Cyg_libc_stdio_files::get_file_stream( fd_t fd )
|
76 |
|
|
{
|
77 |
|
|
CYG_PRECONDITION( (fd < FOPEN_MAX),
|
78 |
|
|
"Attempt to open larger file descriptor than FOPEN_MAX!" );
|
79 |
|
|
|
80 |
|
|
return files[fd];
|
81 |
|
|
|
82 |
|
|
} // Cyg_libc_stdio_files::get_file_stream()
|
83 |
|
|
|
84 |
|
|
inline void
|
85 |
|
|
Cyg_libc_stdio_files::set_file_stream( fd_t fd, Cyg_StdioStream *stream )
|
86 |
|
|
{
|
87 |
|
|
CYG_PRECONDITION( (fd < FOPEN_MAX),
|
88 |
|
|
"Attempt to set larger file descriptor than FOPEN_MAX!" );
|
89 |
|
|
|
90 |
|
|
files[fd] = stream;
|
91 |
|
|
|
92 |
|
|
} // Cyg_libc_stdio_files::set_file_stream()
|
93 |
|
|
|
94 |
|
|
|
95 |
|
|
inline cyg_bool
|
96 |
|
|
Cyg_libc_stdio_files::lock(void)
|
97 |
|
|
{
|
98 |
|
|
# ifdef CYGSEM_LIBC_STDIO_THREAD_SAFE_STREAMS
|
99 |
|
|
return files_lock.lock();
|
100 |
|
|
# else
|
101 |
|
|
return true;
|
102 |
|
|
# endif
|
103 |
|
|
} // Cyg_libc_stdio_files::lock()
|
104 |
|
|
|
105 |
|
|
inline cyg_bool
|
106 |
|
|
Cyg_libc_stdio_files::trylock(void)
|
107 |
|
|
{
|
108 |
|
|
# ifdef CYGSEM_LIBC_STDIO_THREAD_SAFE_STREAMS
|
109 |
|
|
return files_lock.trylock();
|
110 |
|
|
# else
|
111 |
|
|
return true;
|
112 |
|
|
# endif
|
113 |
|
|
} // Cyg_libc_stdio_files::trylock()
|
114 |
|
|
|
115 |
|
|
inline void
|
116 |
|
|
Cyg_libc_stdio_files::unlock(void)
|
117 |
|
|
{
|
118 |
|
|
# ifdef CYGSEM_LIBC_STDIO_THREAD_SAFE_STREAMS
|
119 |
|
|
files_lock.unlock();
|
120 |
|
|
# endif
|
121 |
|
|
} // Cyg_libc_stdio_files::unlock()
|
122 |
|
|
|
123 |
|
|
|
124 |
|
|
#endif // CYGONCE_LIBC_STDIO_STDIOFILES_INL multiple inclusion protection
|
125 |
|
|
|
126 |
|
|
// EOF stdiofiles.inl
|