OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [newlib/] [libc/] [stdio/] [local.h] - Blame information for rev 258

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
/*
2
 * Copyright (c) 1990, 2007 The Regents of the University of California.
3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms are permitted
6
 * provided that the above copyright notice and this paragraph are
7
 * duplicated in all such forms and that any documentation,
8
 * advertising materials, and other materials related to such
9
 * distribution and use acknowledge that the software was developed
10
 * by the University of California, Berkeley.  The name of the
11
 * University may not be used to endorse or promote products derived
12
 * from this software without specific prior written permission.
13
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14
 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16
 *
17
 *      %W% (UofMD/Berkeley) %G%
18
 */
19
 
20
/*
21
 * Information local to this implementation of stdio,
22
 * in particular, macros and private variables.
23
 */
24
 
25
#include <_ansi.h>
26
#include <reent.h>
27
#include <stdarg.h>
28
#include <stdlib.h>
29
#include <unistd.h>
30
#include <stdio.h>
31
#ifdef __SCLE
32
# include <io.h>
33
#endif
34
 
35
 
36
extern u_char *_EXFUN(__sccl, (char *, u_char *fmt));
37
extern int    _EXFUN(__svfscanf_r,(struct _reent *,FILE *, _CONST char *,va_list));
38
extern int    _EXFUN(__ssvfscanf_r,(struct _reent *,FILE *, _CONST char *,va_list));
39
extern int    _EXFUN(__svfiscanf_r,(struct _reent *,FILE *, _CONST char *,va_list));
40
extern int    _EXFUN(__ssvfiscanf_r,(struct _reent *,FILE *, _CONST char *,va_list));
41
extern int    _EXFUN(__svfwscanf_r,(struct _reent *,FILE *, _CONST wchar_t *,va_list));
42
extern int    _EXFUN(__ssvfwscanf_r,(struct _reent *,FILE *, _CONST wchar_t *,va_list));
43
extern int    _EXFUN(__svfiwscanf_r,(struct _reent *,FILE *, _CONST wchar_t *,va_list));
44
extern int    _EXFUN(__ssvfiwscanf_r,(struct _reent *,FILE *, _CONST wchar_t *,va_list));
45
int           _EXFUN(_svfprintf_r,(struct _reent *, FILE *, const char *,
46
                                  va_list)
47
                                _ATTRIBUTE ((__format__ (__printf__, 3, 0))));
48
int           _EXFUN(_svfiprintf_r,(struct _reent *, FILE *, const char *,
49
                                  va_list)
50
                                _ATTRIBUTE ((__format__ (__printf__, 3, 0))));
51
int           _EXFUN(_svfwprintf_r,(struct _reent *, FILE *, const wchar_t *,
52
                                  va_list));
53
int           _EXFUN(_svfiwprintf_r,(struct _reent *, FILE *, const wchar_t *,
54
                                  va_list));
55
extern FILE  *_EXFUN(__sfp,(struct _reent *));
56
extern int    _EXFUN(__sflags,(struct _reent *,_CONST char*, int*));
57
extern int    _EXFUN(__srefill_r,(struct _reent *,FILE *));
58
extern _READ_WRITE_RETURN_TYPE _EXFUN(__sread,(struct _reent *, void *, char *,
59
                                               int));
60
extern _READ_WRITE_RETURN_TYPE _EXFUN(__seofread,(struct _reent *, void *,
61
                                                  char *, int));
62
extern _READ_WRITE_RETURN_TYPE _EXFUN(__swrite,(struct _reent *, void *,
63
                                                const char *, int));
64
extern _fpos_t _EXFUN(__sseek,(struct _reent *, void *, _fpos_t, int));
65
extern int    _EXFUN(__sclose,(struct _reent *, void *));
66
extern int    _EXFUN(__stextmode,(int));
67
extern _VOID   _EXFUN(__sinit,(struct _reent *));
68
extern _VOID   _EXFUN(_cleanup_r,(struct _reent *));
69
extern _VOID   _EXFUN(__smakebuf_r,(struct _reent *, FILE *));
70
extern int    _EXFUN(_fwalk,(struct _reent *, int (*)(FILE *)));
71
extern int    _EXFUN(_fwalk_reent,(struct _reent *, int (*)(struct _reent *, FILE *)));
72
struct _glue * _EXFUN(__sfmoreglue,(struct _reent *,int n));
73
extern int _EXFUN(__submore, (struct _reent *, FILE *));
74
 
75
#ifdef __LARGE64_FILES
76
extern _fpos64_t _EXFUN(__sseek64,(struct _reent *, void *, _fpos64_t, int));
77
extern _READ_WRITE_RETURN_TYPE _EXFUN(__swrite64,(struct _reent *, void *,
78
                                                  const char *, int));
79
#endif
80
 
81
/* Called by the main entry point fns to ensure stdio has been initialized.  */
82
 
83
#ifdef _REENT_SMALL
84
#define CHECK_INIT(ptr, fp) \
85
  do                                            \
86
    {                                           \
87
      if ((ptr) && !(ptr)->__sdidinit)          \
88
        __sinit (ptr);                          \
89
      if ((fp) == (FILE *)&__sf_fake_stdin)     \
90
        (fp) = _stdin_r(ptr);                   \
91
      else if ((fp) == (FILE *)&__sf_fake_stdout) \
92
        (fp) = _stdout_r(ptr);                  \
93
      else if ((fp) == (FILE *)&__sf_fake_stderr) \
94
        (fp) = _stderr_r(ptr);                  \
95
    }                                           \
96
  while (0)
97
#else /* !_REENT_SMALL   */
98
#define CHECK_INIT(ptr, fp) \
99
  do                                            \
100
    {                                           \
101
      if ((ptr) && !(ptr)->__sdidinit)          \
102
        __sinit (ptr);                          \
103
    }                                           \
104
  while (0)
105
#endif /* !_REENT_SMALL  */
106
 
107
#define CHECK_STD_INIT(ptr) \
108
  do                                            \
109
    {                                           \
110
      if ((ptr) && !(ptr)->__sdidinit)          \
111
        __sinit (ptr);                          \
112
    }                                           \
113
  while (0)
114
 
115
/* Return true iff the given FILE cannot be written now.  */
116
 
117
#define cantwrite(ptr, fp)                                     \
118
  ((((fp)->_flags & __SWR) == 0 || (fp)->_bf._base == NULL) && \
119
   __swsetup_r(ptr, fp))
120
 
121
/* Test whether the given stdio file has an active ungetc buffer;
122
   release such a buffer, without restoring ordinary unread data.  */
123
 
124
#define HASUB(fp) ((fp)->_ub._base != NULL)
125
#define FREEUB(ptr, fp) {                    \
126
        if ((fp)->_ub._base != (fp)->_ubuf) \
127
                _free_r(ptr, (char *)(fp)->_ub._base); \
128
        (fp)->_ub._base = NULL; \
129
}
130
 
131
/* Test for an fgetline() buffer.  */
132
 
133
#define HASLB(fp) ((fp)->_lb._base != NULL)
134
#define FREELB(ptr, fp) { _free_r(ptr,(char *)(fp)->_lb._base); \
135
      (fp)->_lb._base = NULL; }
136
 
137
/*
138
 * Set the orientation for a stream. If o > 0, the stream has wide-
139
 * orientation. If o < 0, the stream has byte-orientation.
140
 */
141
#define ORIENT(fp,ori)                                  \
142
  do                                                            \
143
    {                                                           \
144
      if (!((fp)->_flags & __SORD))     \
145
        {                                                       \
146
          (fp)->_flags |= __SORD;                               \
147
          if (ori > 0)                                           \
148
            (fp)->_flags2 |= __SWID;                            \
149
          else                                                  \
150
            (fp)->_flags2 &= ~__SWID;                           \
151
        }                                                       \
152
    }                                                           \
153
  while (0)
154
 
155
/* WARNING: _dcvt is defined in the stdlib directory, not here!  */
156
 
157
char *_EXFUN(_dcvt,(struct _reent *, char *, double, int, int, char, int));
158
char *_EXFUN(_sicvt,(char *, short, char));
159
char *_EXFUN(_icvt,(char *, int, char));
160
char *_EXFUN(_licvt,(char *, long, char));
161
#ifdef __GNUC__
162
char *_EXFUN(_llicvt,(char *, long long, char));
163
#endif
164
 
165
#define CVT_BUF_SIZE 128
166
 
167
#define NDYNAMIC 4      /* add four more whenever necessary */
168
 
169
#ifdef __SINGLE_THREAD__
170
#define __sfp_lock_acquire()
171
#define __sfp_lock_release()
172
#define __sinit_lock_acquire()
173
#define __sinit_lock_release()
174
#else
175
_VOID _EXFUN(__sfp_lock_acquire,(_VOID));
176
_VOID _EXFUN(__sfp_lock_release,(_VOID));
177
_VOID _EXFUN(__sinit_lock_acquire,(_VOID));
178
_VOID _EXFUN(__sinit_lock_release,(_VOID));
179
#endif
180
 
181
/* Types used in positional argument support in vfprinf/vfwprintf.
182
   The implementation is char/wchar_t dependent but the class and state
183
   tables are only defined once in vfprintf.c. */
184
typedef enum {
185
  ZERO,   /* '0' */
186
  DIGIT,  /* '1-9' */
187
  DOLLAR, /* '$' */
188
  MODFR,  /* spec modifier */
189
  SPEC,   /* format specifier */
190
  DOT,    /* '.' */
191
  STAR,   /* '*' */
192
  FLAG,   /* format flag */
193
  OTHER,  /* all other chars */
194
  MAX_CH_CLASS /* place-holder */
195
} __CH_CLASS;
196
 
197
typedef enum {
198
  START,  /* start */
199
  SFLAG,  /* seen a flag */
200
  WDIG,   /* seen digits in width area */
201
  WIDTH,  /* processed width */
202
  SMOD,   /* seen spec modifier */
203
  SDOT,   /* seen dot */
204
  VARW,   /* have variable width specifier */
205
  VARP,   /* have variable precision specifier */
206
  PREC,   /* processed precision */
207
  VWDIG,  /* have digits in variable width specification */
208
  VPDIG,  /* have digits in variable precision specification */
209
  DONE,   /* done */
210
  MAX_STATE, /* place-holder */
211
} __STATE;
212
 
213
typedef enum {
214
  NOOP,  /* do nothing */
215
  NUMBER, /* build a number from digits */
216
  SKIPNUM, /* skip over digits */
217
  GETMOD,  /* get and process format modifier */
218
  GETARG,  /* get and process argument */
219
  GETPW,   /* get variable precision or width */
220
  GETPWB,  /* get variable precision or width and pushback fmt char */
221
  GETPOS,  /* get positional parameter value */
222
  PWPOS,   /* get positional parameter value for variable width or precision */
223
} __ACTION;
224
 
225
extern _CONST __CH_CLASS __chclass[256];
226
extern _CONST __STATE __state_table[MAX_STATE][MAX_CH_CLASS];
227
extern _CONST __ACTION __action_table[MAX_STATE][MAX_CH_CLASS];

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.