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

Subversion Repositories or1k

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1026 ivang
/*
2
 *  write() - POSIX 1003.1b 6.4.2 - Write to 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
 *  write.c,v 1.11 2002/01/04 18:29:37 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
/*
22
 * write
23
 *
24
 * This routine writes count bytes from from buffer pointed to by buffer
25
 * to the file associated with the open file descriptor, fildes.
26
 */
27
 
28
ssize_t write(
29
  int         fd,
30
  const void *buffer,
31
  size_t      count
32
)
33
{
34
  ssize_t  rc;
35
  rtems_libio_t     *iop;
36
 
37
  rtems_libio_check_fd( fd );
38
  iop = rtems_libio_iop( fd );
39
  rtems_libio_check_is_open(iop);
40
  rtems_libio_check_buffer( buffer );
41
  rtems_libio_check_count( count );
42
  rtems_libio_check_permissions( iop, LIBIO_FLAGS_WRITE );
43
 
44
  /*
45
   *  Now process the write() request.
46
   */
47
 
48
  if ( !iop->handlers->write_h )
49
    rtems_set_errno_and_return_minus_one( ENOTSUP );
50
 
51
  rc = (*iop->handlers->write_h)( iop, buffer, count );
52
 
53
  if ( rc > 0 )
54
    iop->offset += rc;
55
 
56
  return rc;
57
}
58
 
59
/*
60
 *  _write_r
61
 *
62
 *  This is the Newlib dependent reentrant version of write().
63
 */
64
 
65
#if defined(RTEMS_NEWLIB)
66
 
67
#include <reent.h>
68
 
69
long _write_r(
70
  struct _reent *ptr,
71
  int            fd,
72
  const void    *buf,
73
  size_t         nbytes
74
)
75
{
76
  return write( fd, buf, nbytes );
77
}
78
#endif

powered by: WebSVN 2.1.0

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