comparison packages/language/c/libc/current/src/clibincl/clibdata.inl @ 0:3111d98ba7b3 ecos-v1_1-release

Initial commit of eCos version 1.1
author jlarmour
date Tue, 11 May 1999 11:16:07 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:3111d98ba7b3
1 #ifndef CYGONCE_LIBC_CLIBINCL_CLIBDATA_INL
2 #define CYGONCE_LIBC_CLIBINCL_CLIBDATA_INL
3 //===========================================================================
4 //
5 // clibdata.inl
6 //
7 // Inline functions for C library internal data
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 Cygnus Solutions. All Rights Reserved.
28 // -------------------------------------------
29 //
30 //####COPYRIGHTEND####
31 //===========================================================================
32 //#####DESCRIPTIONBEGIN####
33 //
34 // Author(s): jlarmour
35 // Contributors: jlarmour@cygnus.co.uk
36 // Date: 1998-02-13
37 // Purpose:
38 // Description:
39 // Usage: Do not include this file directly.
40 // Instead #include "clibincl/clibdata.hxx"
41 //
42 //####DESCRIPTIONEND####
43 //
44 //===========================================================================
45
46 // CONFIGURATION
47
48 #include <pkgconf/libc.h> // Configuration header
49
50 // Include the C library?
51 #ifdef CYGPKG_LIBC
52
53 #include <cyg/infra/cyg_type.h> // Common project-wide type definitions
54 #include <cyg/infra/cyg_ass.h> // Assert interface
55 #include "clibincl/clibdata.hxx" // header for this file - just in case
56
57 #ifdef CYGPKG_LIBC_STDIO
58 # include "clibincl/stream.hxx" // Cyg_StdioStream internal class
59 #endif
60
61 #ifndef CYGSEM_LIBC_PER_THREAD_ERRNO
62 # include <errno.h> // for errno variable
63 #endif
64
65
66 // INLINE METHODS
67
68 inline void
69 Cyg_CLibInternalData::construct( void )
70 {
71
72 #ifdef CYGSEM_LIBC_PER_THREAD_ERRNO
73 // errno is initialised to 0 at program startup - ANSI 7.1.4
74 safe_errno = 0;
75 #endif // ifdef CYGSEM_LIBC_PER_THREAD_ERRNO
76
77
78 #ifdef CYGPKG_LIBC_RAND
79 // Initialise seed for rand()
80 rand_seed = CYGNUM_LIBC_RAND_SEED;
81 #endif
82
83 } // construct()
84
85 inline
86 Cyg_CLibInternalData::Cyg_CLibInternalData( void )
87 {
88 construct();
89 } // Cyg_CLibInternalData() constructor
90
91
92 #ifdef CYGFUN_LIBC_strtok
93 inline char **
94 Cyg_CLibInternalData::get_strtok_last_p( void )
95 {
96 return &strtok_last;
97 } // get_strtok_last_p()
98 #endif
99
100
101
102 #ifdef CYGPKG_LIBC_RAND
103 inline Cyg_CLibInternalData::Cyg_rand_seed_t *
104 Cyg_CLibInternalData::get_rand_seed_p( void )
105 {
106 return &rand_seed;
107 } // get_rand_seed_p()
108 #endif
109
110
111 #ifdef CYGPKG_LIBC_STDIO
112
113 inline Cyg_StdioStream *
114 Cyg_CLibInternalData::get_file_stream( cyg_ucount32 fd )
115 {
116 CYG_PRECONDITION( (fd < FOPEN_MAX),
117 "Attempt to open larger file descriptor than FOPEN_MAX!" );
118
119 switch (fd)
120 {
121 case 0:
122 return stdin;
123 case 1:
124 return stdout;
125 case 2:
126 return stderr;
127 default:
128 return files[fd - 3]; // shift 3 for stdin/stdout/stderr
129 } // switch
130
131 } // get_file_stream()
132
133
134 inline void
135 Cyg_CLibInternalData::set_file_stream( cyg_ucount32 fd,
136 Cyg_StdioStream *stream )
137 {
138 CYG_PRECONDITION( (fd < FOPEN_MAX),
139 "Attempt to set larger file descriptor than FOPEN_MAX!" );
140
141 switch (fd)
142 {
143 case 0:
144 stdin = stream;
145 break;
146 case 1:
147 stdout = stream;
148 break;
149 case 2:
150 stderr = stream;
151 break;
152 default:
153 files[fd - 3] = stream; // shift 3 for stdin/stdout/stderr
154 break;
155 } // switch
156 } // set_file_stream()
157
158 #endif // ifdef CYGPKG_LIBC_STDIO
159
160 inline Cyg_ErrNo *
161 Cyg_CLibInternalData::get_errno_p( void )
162 {
163 #ifdef CYGSEM_LIBC_PER_THREAD_ERRNO
164 return &safe_errno;
165 #else
166 return &errno;
167 #endif
168 } // get_errno_p()
169
170 #endif // ifdef CYGPKG_LIBC
171
172 #endif CYGONCE_LIBC_CLIBINCL_CLIBDATA_INL multiple inclusion protection
173
174 // EOF clibdata.inl