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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.17.0/] [newlib/] [libc/] [reent/] [renamer.c] - Blame information for rev 194

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 148 jeremybenn
/* Reentrant version of rename system call.  */
2
 
3
#include <reent.h>
4
#include <unistd.h>
5
#include <sys/stat.h>
6
#include <_syslist.h>
7
 
8
/* Some targets provides their own versions of these 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
21
extern int errno;
22
 
23
/*
24
FUNCTION
25
        <<_rename_r>>---Reentrant version of rename
26
 
27
INDEX
28
        _rename_r
29
 
30
ANSI_SYNOPSIS
31
        #include <reent.h>
32
        int _rename_r(struct _reent *<[ptr]>,
33
                const char *<[old]>, const char *<[new]>);
34
 
35
TRAD_SYNOPSIS
36
        #include <reent.h>
37
        int _rename_r(<[ptr]>, <[old]>, <[new]>)
38
        struct _reent *<[ptr]>;
39
        char *<[old]>;
40
        char *<[new]>;
41
 
42
DESCRIPTION
43
        This is a reentrant version of <<rename>>.  It
44
        takes a pointer to the global data block, which holds
45
        <<errno>>.
46
*/
47
 
48
int
49
_DEFUN (_rename_r, (ptr, old, new),
50
     struct _reent *ptr _AND
51
     _CONST char *old _AND
52
     _CONST char *new)
53
{
54
  int ret = 0;
55
 
56
#ifdef HAVE_RENAME
57
  errno = 0;
58
  if ((ret = _rename (old, new)) == -1 && errno != 0)
59
    ptr->_errno = errno;
60
#else
61
  if (_link_r (ptr, old, new) == -1)
62
    return -1;
63
 
64
  if (_unlink_r (ptr, old) == -1)
65
    {
66
      /* ??? Should we unlink new? (rhetorical question) */
67
      return -1;
68
    }
69
#endif
70
  return ret;
71
}
72
 
73
#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */

powered by: WebSVN 2.1.0

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