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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgfortran/] [io/] [fbuf.h] - Blame information for rev 772

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

Line No. Rev Author Line
1 733 jeremybenn
/* Copyright (C) 2009
2
   Free Software Foundation, Inc.
3
   Contributed by Janne Blomqvist
4
 
5
This file is part of the GNU Fortran runtime library (libgfortran).
6
 
7
Libgfortran is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation; either version 3, or (at your option)
10
any later version.
11
 
12
Libgfortran is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
GNU General Public License for more details.
16
 
17
Under Section 7 of GPL version 3, you are granted additional
18
permissions described in the GCC Runtime Library Exception, version
19
3.1, as published by the Free Software Foundation.
20
 
21
You should have received a copy of the GNU General Public License and
22
a copy of the GCC Runtime Library Exception along with this program;
23
see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
24
<http://www.gnu.org/licenses/>.  */
25
 
26
#ifndef GFOR_FBUF_H
27
#define GFOR_FBUF_H
28
 
29
#include "io.h"
30
 
31
 
32
/* Formatting buffer. This is a temporary scratch buffer used by
33
   formatted read and writes.  After every formatted I/O statement,
34
   this buffer is flushed. This buffer is needed since not all devices
35
   are seekable, and T or TL edit descriptors require moving backwards
36
   in the record.  However, advance='no' complicates the situation, so
37
   the buffer must only be partially flushed from the end of the last
38
   flush until the current position in the record. */
39
 
40
struct fbuf
41
{
42
  char *buf;                    /* Start of buffer.  */
43
  int len;                      /* Length of buffer.  */
44
  int act;                      /* Active bytes in buffer.  */
45
  int pos;                      /* Current position in buffer.  */
46
};
47
 
48
extern void fbuf_init (gfc_unit *, int);
49
internal_proto(fbuf_init);
50
 
51
extern void fbuf_destroy (gfc_unit *);
52
internal_proto(fbuf_destroy);
53
 
54
extern int fbuf_reset (gfc_unit *);
55
internal_proto(fbuf_reset);
56
 
57
extern char * fbuf_alloc (gfc_unit *, int);
58
internal_proto(fbuf_alloc);
59
 
60
extern int fbuf_flush (gfc_unit *, unit_mode);
61
internal_proto(fbuf_flush);
62
 
63
extern int fbuf_seek (gfc_unit *, int, int);
64
internal_proto(fbuf_seek);
65
 
66
extern char * fbuf_read (gfc_unit *, int *);
67
internal_proto(fbuf_read);
68
 
69
/* Never call this function, only use fbuf_getc().  */
70
extern int fbuf_getc_refill (gfc_unit *);
71
internal_proto(fbuf_getc_refill);
72
 
73
static inline int
74
fbuf_getc (gfc_unit * u)
75
{
76
  if (u->fbuf->pos < u->fbuf->act)
77
    return (unsigned char) u->fbuf->buf[u->fbuf->pos++];
78
  return fbuf_getc_refill (u);
79
}
80
 
81
static inline char *
82
fbuf_getptr (gfc_unit * u)
83
{
84
  return (char*) (u->fbuf->buf + u->fbuf->pos);
85
}
86
 
87
#endif

powered by: WebSVN 2.1.0

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