source: trunk/libs/newlib/src/newlib/libc/reent/fcntlr.c @ 543

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

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

File size: 1.1 KB
Line 
1/* Reentrant versions of fcntl system call.  This implementation just
2   calls the fcntl system call.  */
3
4#include <reent.h>
5#include <fcntl.h>
6#include <sys/stat.h>
7#include <_syslist.h>
8
9/* Some targets provides their own versions of these functions.  Those
10   targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS.  */
11
12#ifdef _REENT_ONLY
13#ifndef REENTRANT_SYSCALLS_PROVIDED
14#define REENTRANT_SYSCALLS_PROVIDED
15#endif
16#endif
17
18#ifndef REENTRANT_SYSCALLS_PROVIDED
19
20/* We use the errno variable used by the system dependent layer.  */
21#undef errno
22extern int errno;
23
24/*
25FUNCTION
26        <<_fcntl_r>>---Reentrant version of fcntl
27       
28INDEX
29        _fcntl_r
30
31SYNOPSIS
32        #include <reent.h>
33        int _fcntl_r(struct _reent *<[ptr]>,
34                     int <[fd]>, int <[cmd]>, <[arg]>);
35
36DESCRIPTION
37        This is a reentrant version of <<fcntl>>.  It
38        takes a pointer to the global data block, which holds
39        <<errno>>.
40*/
41
42int
43_fcntl_r (struct _reent *ptr,
44     int fd,
45     int cmd,
46     int arg)
47{
48  int ret;
49
50  errno = 0;
51  if ((ret = _fcntl (fd, cmd, arg)) == -1 && errno != 0)
52    ptr->_errno = errno;
53  return ret;
54}
55
56#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */
Note: See TracBrowser for help on using the repository browser.