source: trunk/libs/newlib/src/newlib/libc/stdio64/stdio64.c @ 577

Last change on this file since 577 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 2.0 KB
Line 
1/* No user fns here.  Pesch 15apr92. */
2
3/*
4 * Copyright (c) 1990 The Regents of the University of California.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms are permitted
8 * provided that the above copyright notice and this paragraph are
9 * duplicated in all such forms and that any documentation,
10 * advertising materials, and other materials related to such
11 * distribution and use acknowledge that the software was developed
12 * by the University of California, Berkeley.  The name of the
13 * University may not be used to endorse or promote products derived
14 * from this software without specific prior written permission.
15 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
18 */
19
20#include <stdio.h>
21#include <sys/types.h>
22#include <fcntl.h>
23#include <sys/unistd.h>
24#include <errno.h>
25#include "local.h"
26
27#ifdef __LARGE64_FILES
28_fpos64_t
29__sseek64 (struct _reent *ptr,
30       void *cookie,
31       _fpos64_t offset,
32       int whence)
33{
34  register FILE *fp = (FILE *) cookie;
35  register _off64_t ret;
36
37  ret = _lseek64_r (ptr, fp->_file, (_off64_t) offset, whence);
38  if (ret == (_fpos64_t)-1L)
39    fp->_flags &= ~__SOFF;
40  else
41    {
42      fp->_flags |= __SOFF;
43      fp->_offset = ret;
44    }
45  return ret;
46}
47
48_READ_WRITE_RETURN_TYPE
49__swrite64 (struct _reent *ptr,
50       void *cookie,
51       char const *buf,
52       _READ_WRITE_BUFSIZE_TYPE n)
53{
54  register FILE *fp = (FILE *) cookie;
55  _READ_WRITE_RETURN_TYPE w;
56#ifdef __SCLE
57  int oldmode=0;
58#endif
59
60  if (fp->_flags & __SAPP)
61    (void) _lseek64_r (ptr, fp->_file, (_off64_t)0, SEEK_END);
62  fp->_flags &= ~__SOFF;        /* in case O_APPEND mode is set */
63
64#ifdef __SCLE
65  if (fp->_flags & __SCLE)
66    oldmode = setmode(fp->_file, O_BINARY);
67#endif
68
69  w = _write_r (ptr, fp->_file, buf, n);
70
71#ifdef __SCLE
72  if (oldmode)
73    setmode(fp->_file, oldmode);
74#endif
75
76  return w;
77}
78
79#endif /* __LARGE64_FILES */
Note: See TracBrowser for help on using the repository browser.