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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [newlib-1.17.0/] [newlib/] [libc/] [stdio64/] [fopen64.c] - Blame information for rev 825

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

Line No. Rev Author Line
1 148 jeremybenn
/*
2
 * Copyright (c) 1990 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
 
18
/*
19
FUNCTION
20
<<fopen64>>---open a large file
21
 
22
INDEX
23
        fopen64
24
INDEX
25
        _fopen64_r
26
 
27
ANSI_SYNOPSIS
28
        #include <stdio.h>
29
        FILE *fopen64(const char *<[file]>, const char *<[mode]>);
30
        FILE *_fopen64_r(void *<[reent]>,
31
                       const char *<[file]>, const char *<[mode]>);
32
 
33
TRAD_SYNOPSIS
34
        #include <stdio.h>
35
        FILE *fopen64(<[file]>, <[mode]>)
36
        char *<[file]>;
37
        char *<[mode]>;
38
 
39
        FILE *_fopen64_r(<[reent]>, <[file]>, <[mode]>)
40
        char *<[reent]>;
41
        char *<[file]>;
42
        char *<[mode]>;
43
 
44
DESCRIPTION
45
<<fopen64>> is identical to <<fopen>> except it opens a large file that
46
is potentially >2GB in size.  See <<fopen>> for further details.
47
 
48
RETURNS
49
<<fopen64>> return a file pointer which you can use for other file
50
operations, unless the file you requested could not be opened; in that
51
situation, the result is <<NULL>>.  If the reason for failure was an
52
invalid string at <[mode]>, <<errno>> is set to <<EINVAL>>.
53
 
54
PORTABILITY
55
<<fopen64>> is a glibc extension.
56
 
57
Supporting OS subroutines required: <<close>>, <<fstat64>>, <<isatty>>,
58
<<lseek64>>, <<open64>>, <<read>>, <<sbrk>>, <<write>>.
59
*/
60
 
61
/* Copied from fopen.c */
62
 
63
#if defined(LIBC_SCCS) && !defined(lint)
64
static char sccsid[] = "%W% (Berkeley) %G%";
65
#endif /* LIBC_SCCS and not lint */
66
 
67
#include <stdio.h>
68
#include <errno.h>
69
#include "local.h"
70
#ifdef __CYGWIN__
71
#include <fcntl.h>
72
#endif
73
#include <sys/lock.h>
74
 
75
#ifdef __LARGE64_FILES
76
 
77
FILE *
78
_DEFUN (_fopen64_r, (ptr, file, mode),
79
        struct _reent *ptr _AND
80
        _CONST char *file _AND
81
        _CONST char *mode)
82
{
83
  register FILE *fp;
84
  register int f;
85
  int flags, oflags;
86
 
87
  if ((flags = __sflags (ptr, mode, &oflags)) == 0)
88
    return NULL;
89
  if ((fp = __sfp (ptr)) == NULL)
90
    return NULL;
91
 
92
  if ((f = _open64_r (ptr, file, oflags, 0666)) < 0)
93
    {
94
      __sfp_lock_acquire ();
95
      fp->_flags = 0;            /* release */
96
#ifndef __SINGLE_THREAD__
97
      __lock_close_recursive (fp->_lock);
98
#endif
99
      __sfp_lock_release ();
100
      return NULL;
101
    }
102
 
103
  _flockfile(fp);
104
 
105
  fp->_file = f;
106
  fp->_flags = flags;
107
  fp->_cookie = (_PTR) fp;
108
  fp->_read = __sread;
109
  fp->_write = __swrite64;
110
  fp->_seek = __sseek;
111
  fp->_seek64 = __sseek64;
112
  fp->_close = __sclose;
113
 
114
  if (fp->_flags & __SAPP)
115
    _fseeko64_r (ptr, fp, 0, SEEK_END);
116
 
117
#ifdef __SCLE
118
  if (__stextmode (fp->_file))
119
    fp->_flags |= __SCLE;
120
#endif
121
 
122
  fp->_flags |= __SL64;
123
 
124
  _funlockfile(fp);
125
  return fp;
126
}
127
 
128
#ifndef _REENT_ONLY
129
 
130
FILE *
131
_DEFUN (fopen64, (file, mode),
132
        _CONST char *file _AND
133
        _CONST char *mode)
134
{
135
  return _fopen64_r (_REENT, file, mode);
136
}
137
 
138
#endif
139
 
140
#endif /* __LARGE64_FILES */

powered by: WebSVN 2.1.0

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