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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [cpukit/] [libcsupport/] [src/] [read.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1026 ivang
/*
2
 *  read() - POSIX 1003.1b 6.4.1 - Read From a File
3
 *
4
 *  COPYRIGHT (c) 1989-1999.
5
 *  On-Line Applications Research Corporation (OAR).
6
 *
7
 *  The license and distribution terms for this file may be
8
 *  found in the file LICENSE in this distribution or at
9
 *  http://www.OARcorp.com/rtems/license.html.
10
 *
11
 *  read.c,v 1.10 2002/01/04 18:29:36 joel Exp
12
 */
13
 
14
#if HAVE_CONFIG_H
15
#include "config.h"
16
#endif
17
 
18
#include <rtems/libio_.h>
19
#include <rtems/seterr.h>
20
 
21
ssize_t read(
22
  int         fd,
23
  void       *buffer,
24
  size_t      count
25
)
26
{
27
  int             rc;  /* XXX change to a size_t when prototype is fixed */
28
  rtems_libio_t *iop;
29
 
30
  rtems_libio_check_fd( fd );
31
  iop = rtems_libio_iop( fd );
32
  rtems_libio_check_is_open(iop);
33
  rtems_libio_check_buffer( buffer );
34
  rtems_libio_check_count( count );
35
  rtems_libio_check_permissions( iop, LIBIO_FLAGS_READ );
36
 
37
  /*
38
   *  Now process the read().
39
   */
40
 
41
  if ( !iop->handlers->read_h )
42
    rtems_set_errno_and_return_minus_one( ENOTSUP );
43
 
44
  rc = (*iop->handlers->read_h)( iop, buffer, count );
45
 
46
  if ( rc > 0 )
47
    iop->offset += rc;
48
 
49
  return rc;
50
}
51
 
52
/*
53
 *  _read_r
54
 *
55
 *  This is the Newlib dependent reentrant version of read().
56
 */
57
 
58
#if defined(RTEMS_NEWLIB)
59
 
60
#include <reent.h>
61
 
62
_ssize_t _read_r(
63
  struct _reent *ptr,
64
  int            fd,
65
  void          *buf,
66
  size_t         nbytes
67
)
68
{
69
  return read( fd, buf, nbytes );
70
}
71
#endif

powered by: WebSVN 2.1.0

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