OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

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

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

Line No. Rev Author Line
1 148 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
int           _EXFUN(_svfprintf_r,(struct _reent *, FILE *, const char *,
42
                                  va_list)
43
                                _ATTRIBUTE ((__format__ (__printf__, 3, 0))));
44
int           _EXFUN(_svfiprintf_r,(struct _reent *, FILE *, const char *,
45
                                  va_list)
46
                                _ATTRIBUTE ((__format__ (__printf__, 3, 0))));
47
extern FILE  *_EXFUN(__sfp,(struct _reent *));
48
extern int    _EXFUN(__sflags,(struct _reent *,_CONST char*, int*));
49
extern int    _EXFUN(__srefill_r,(struct _reent *,FILE *));
50
extern _READ_WRITE_RETURN_TYPE _EXFUN(__sread,(struct _reent *, void *, char *,
51
                                               int));
52
extern _READ_WRITE_RETURN_TYPE _EXFUN(__swrite,(struct _reent *, void *,
53
                                                const char *, int));
54
extern _fpos_t _EXFUN(__sseek,(struct _reent *, void *, _fpos_t, int));
55
extern int    _EXFUN(__sclose,(struct _reent *, void *));
56
extern int    _EXFUN(__stextmode,(int));
57
extern _VOID   _EXFUN(__sinit,(struct _reent *));
58
extern _VOID   _EXFUN(_cleanup_r,(struct _reent *));
59
extern _VOID   _EXFUN(__smakebuf_r,(struct _reent *, FILE *));
60
extern int    _EXFUN(_fwalk,(struct _reent *, int (*)(FILE *)));
61
extern int    _EXFUN(_fwalk_reent,(struct _reent *, int (*)(struct _reent *, FILE *)));
62
struct _glue * _EXFUN(__sfmoreglue,(struct _reent *,int n));
63
extern int _EXFUN(__submore, (struct _reent *, FILE *));
64
 
65
#ifdef __LARGE64_FILES
66
extern _fpos64_t _EXFUN(__sseek64,(struct _reent *, void *, _fpos64_t, int));
67
extern _READ_WRITE_RETURN_TYPE _EXFUN(__swrite64,(struct _reent *, void *,
68
                                                  const char *, int));
69
#endif
70
 
71
/* Called by the main entry point fns to ensure stdio has been initialized.  */
72
 
73
#ifdef _REENT_SMALL
74
#define CHECK_INIT(ptr, fp) \
75
  do                                            \
76
    {                                           \
77
      if ((ptr) && !(ptr)->__sdidinit)          \
78
        __sinit (ptr);                          \
79
      if ((fp) == (FILE *)&__sf_fake_stdin)     \
80
        (fp) = _stdin_r(ptr);                   \
81
      else if ((fp) == (FILE *)&__sf_fake_stdout) \
82
        (fp) = _stdout_r(ptr);                  \
83
      else if ((fp) == (FILE *)&__sf_fake_stderr) \
84
        (fp) = _stderr_r(ptr);                  \
85
    }                                           \
86
  while (0)
87
#else /* !_REENT_SMALL   */
88
#define CHECK_INIT(ptr, fp) \
89
  do                                            \
90
    {                                           \
91
      if ((ptr) && !(ptr)->__sdidinit)          \
92
        __sinit (ptr);                          \
93
    }                                           \
94
  while (0)
95
#endif /* !_REENT_SMALL  */
96
 
97
#define CHECK_STD_INIT(ptr) \
98
  do                                            \
99
    {                                           \
100
      if ((ptr) && !(ptr)->__sdidinit)          \
101
        __sinit (ptr);                          \
102
    }                                           \
103
  while (0)
104
 
105
/* Return true iff the given FILE cannot be written now.  */
106
 
107
#define cantwrite(ptr, fp)                                     \
108
  ((((fp)->_flags & __SWR) == 0 || (fp)->_bf._base == NULL) && \
109
   __swsetup_r(ptr, fp))
110
 
111
/* Test whether the given stdio file has an active ungetc buffer;
112
   release such a buffer, without restoring ordinary unread data.  */
113
 
114
#define HASUB(fp) ((fp)->_ub._base != NULL)
115
#define FREEUB(ptr, fp) {                    \
116
        if ((fp)->_ub._base != (fp)->_ubuf) \
117
                _free_r(ptr, (char *)(fp)->_ub._base); \
118
        (fp)->_ub._base = NULL; \
119
}
120
 
121
/* Test for an fgetline() buffer.  */
122
 
123
#define HASLB(fp) ((fp)->_lb._base != NULL)
124
#define FREELB(ptr, fp) { _free_r(ptr,(char *)(fp)->_lb._base); \
125
      (fp)->_lb._base = NULL; }
126
 
127
/*
128
 * Set the orientation for a stream. If o > 0, the stream has wide-
129
 * orientation. If o < 0, the stream has byte-orientation.
130
 */
131
#define ORIENT(fp,ori)                                  \
132
  do                                                            \
133
    {                                                           \
134
      if (!((fp)->_flags & __SORD))     \
135
        {                                                       \
136
          (fp)->_flags |= __SORD;                               \
137
          if (ori > 0)                                           \
138
            (fp)->_flags2 |= __SWID;                            \
139
          else                                                  \
140
            (fp)->_flags2 &= ~__SWID;                           \
141
        }                                                       \
142
    }                                                           \
143
  while (0)
144
 
145
/* WARNING: _dcvt is defined in the stdlib directory, not here!  */
146
 
147
char *_EXFUN(_dcvt,(struct _reent *, char *, double, int, int, char, int));
148
char *_EXFUN(_sicvt,(char *, short, char));
149
char *_EXFUN(_icvt,(char *, int, char));
150
char *_EXFUN(_licvt,(char *, long, char));
151
#ifdef __GNUC__
152
char *_EXFUN(_llicvt,(char *, long long, char));
153
#endif
154
 
155
#define CVT_BUF_SIZE 128
156
 
157
#define NDYNAMIC 4      /* add four more whenever necessary */
158
 
159
#ifdef __SINGLE_THREAD__
160
#define __sfp_lock_acquire()
161
#define __sfp_lock_release()
162
#define __sinit_lock_acquire()
163
#define __sinit_lock_release()
164
#else
165
_VOID _EXFUN(__sfp_lock_acquire,(_VOID));
166
_VOID _EXFUN(__sfp_lock_release,(_VOID));
167
_VOID _EXFUN(__sinit_lock_acquire,(_VOID));
168
_VOID _EXFUN(__sinit_lock_release,(_VOID));
169
#endif

powered by: WebSVN 2.1.0

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