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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [newlib-1.17.0/] [newlib/] [libc/] [reent/] [execr.c] - Blame information for rev 831

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

Line No. Rev Author Line
1 148 jeremybenn
/* Reentrant versions of execution system calls.  These
2
   implementations just call the usual system calls.  */
3
 
4
#include <reent.h>
5
#include <unistd.h>
6
#include <sys/wait.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
/* If NO_EXEC is defined, we don't need these functions.  */
19
 
20
#if defined (REENTRANT_SYSCALLS_PROVIDED) || defined (NO_EXEC)
21
 
22
int _dummy_exec_syscalls = 1;
23
 
24
#else
25
 
26
/* We use the errno variable used by the system dependent layer.  */
27
#undef errno
28
extern int errno;
29
 
30
/*
31
FUNCTION
32
        <<_execve_r>>---Reentrant version of execve
33
INDEX
34
        _execve_r
35
 
36
ANSI_SYNOPSIS
37
        #include <reent.h>
38
        int _execve_r(struct _reent *<[ptr]>, const char *<[name]>,
39
                      char *const <[argv]>[], char *const <[env]>[]);
40
 
41
TRAD_SYNOPSIS
42
        #include <reent.h>
43
        int _execve_r(<[ptr]>, <[name]>, <[argv]>, <[env]>)
44
        struct _reent *<[ptr]>;
45
        char *<[name]>;
46
        char *<[argv]>[];
47
        char *<[env]>[];
48
 
49
DESCRIPTION
50
        This is a reentrant version of <<execve>>.  It
51
        takes a pointer to the global data block, which holds
52
        <<errno>>.
53
*/
54
 
55
int
56
_DEFUN (_execve_r, (ptr, name, argv, env),
57
     struct _reent *ptr _AND
58
     _CONST char *name _AND
59
     char *_CONST argv[] _AND
60
     char *_CONST env[])
61
{
62
  int ret;
63
 
64
  errno = 0;
65
  if ((ret = _execve (name, argv, env)) == -1 && errno != 0)
66
    ptr->_errno = errno;
67
  return ret;
68
}
69
 
70
 
71
/*
72
FUNCTION
73
        <<_fork_r>>---Reentrant version of fork
74
 
75
INDEX
76
        _fork_r
77
 
78
ANSI_SYNOPSIS
79
        #include <reent.h>
80
        int _fork_r(struct _reent *<[ptr]>);
81
 
82
TRAD_SYNOPSIS
83
        #include <reent.h>
84
        int _fork_r(<[ptr]>)
85
        struct _reent *<[ptr]>;
86
 
87
DESCRIPTION
88
        This is a reentrant version of <<fork>>.  It
89
        takes a pointer to the global data block, which holds
90
        <<errno>>.
91
*/
92
 
93
#ifndef NO_FORK
94
 
95
int
96
_DEFUN (_fork_r, (ptr),
97
     struct _reent *ptr)
98
{
99
  int ret;
100
 
101
  errno = 0;
102
  if ((ret = _fork ()) == -1 && errno != 0)
103
    ptr->_errno = errno;
104
  return ret;
105
}
106
 
107
#endif
108
 
109
/*
110
FUNCTION
111
        <<_wait_r>>---Reentrant version of wait
112
 
113
INDEX
114
        _wait_r
115
 
116
ANSI_SYNOPSIS
117
        #include <reent.h>
118
        int _wait_r(struct _reent *<[ptr]>, int *<[status]>);
119
 
120
TRAD_SYNOPSIS
121
        #include <reent.h>
122
        int _wait_r(<[ptr]>, <[status]>)
123
        struct _reent *<[ptr]>;
124
        int *<[status]>;
125
 
126
DESCRIPTION
127
        This is a reentrant version of <<wait>>.  It
128
        takes a pointer to the global data block, which holds
129
        <<errno>>.
130
*/
131
 
132
int
133
_DEFUN (_wait_r, (ptr, status),
134
     struct _reent *ptr _AND
135
     int *status)
136
{
137
  int ret;
138
 
139
  errno = 0;
140
  if ((ret = _wait (status)) == -1 && errno != 0)
141
    ptr->_errno = errno;
142
  return ret;
143
}
144
 
145
#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.