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