Skip to content

Commit 14c791f

Browse files
authored
Merge pull request #4815 from mysterywolf/syscall
[libc][syscall]整理函数格式
2 parents a1a656f + fa3d95b commit 14c791f

File tree

1 file changed

+24
-48
lines changed

1 file changed

+24
-48
lines changed

components/libc/compilers/newlib/syscalls.c

Lines changed: 24 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,18 @@
2929
/* Reentrant versions of system calls. */
3030

3131
#ifndef _REENT_ONLY
32-
int *
33-
__errno ()
32+
int *__errno ()
3433
{
3534
return _rt_errno();
3635
}
3736
#endif
3837

39-
int
40-
_getpid_r(struct _reent *ptr)
38+
int _getpid_r(struct _reent *ptr)
4139
{
4240
return 0;
4341
}
4442

45-
int
46-
_close_r(struct _reent *ptr, int fd)
43+
int _close_r(struct _reent *ptr, int fd)
4744
{
4845
#ifndef RT_USING_DFS
4946
/* return "not supported" */
@@ -54,40 +51,35 @@ _close_r(struct _reent *ptr, int fd)
5451
#endif
5552
}
5653

57-
int
58-
_execve_r(struct _reent *ptr, const char * name, char *const *argv, char *const *env)
54+
int _execve_r(struct _reent *ptr, const char * name, char *const *argv, char *const *env)
5955
{
6056
/* return "not supported" */
6157
ptr->_errno = ENOTSUP;
6258
return -1;
6359
}
6460

65-
int
66-
_fcntl_r(struct _reent *ptr, int fd, int cmd, int arg)
61+
int _fcntl_r(struct _reent *ptr, int fd, int cmd, int arg)
6762
{
6863
/* return "not supported" */
6964
ptr->_errno = ENOTSUP;
7065
return -1;
7166
}
7267

73-
int
74-
_fork_r(struct _reent *ptr)
68+
int _fork_r(struct _reent *ptr)
7569
{
7670
/* return "not supported" */
7771
ptr->_errno = ENOTSUP;
7872
return -1;
7973
}
8074

81-
int
82-
_fstat_r(struct _reent *ptr, int fd, struct stat *pstat)
75+
int _fstat_r(struct _reent *ptr, int fd, struct stat *pstat)
8376
{
8477
/* return "not supported" */
8578
ptr->_errno = ENOTSUP;
8679
return -1;
8780
}
8881

89-
int
90-
_isatty_r(struct _reent *ptr, int fd)
82+
int _isatty_r(struct _reent *ptr, int fd)
9183
{
9284
if (fd >=0 && fd < 3)
9385
{
@@ -99,24 +91,21 @@ _isatty_r(struct _reent *ptr, int fd)
9991
}
10092
}
10193

102-
int
103-
_kill_r(struct _reent *ptr, int pid, int sig)
94+
int _kill_r(struct _reent *ptr, int pid, int sig)
10495
{
10596
/* return "not supported" */
10697
ptr->_errno = ENOTSUP;
10798
return -1;
10899
}
109100

110-
int
111-
_link_r(struct _reent *ptr, const char *old, const char *new)
101+
int _link_r(struct _reent *ptr, const char *old, const char *new)
112102
{
113103
/* return "not supported" */
114104
ptr->_errno = ENOTSUP;
115105
return -1;
116106
}
117107

118-
_off_t
119-
_lseek_r(struct _reent *ptr, int fd, _off_t pos, int whence)
108+
_off_t _lseek_r(struct _reent *ptr, int fd, _off_t pos, int whence)
120109
{
121110
#ifndef RT_USING_DFS
122111
/* return "not supported" */
@@ -130,8 +119,7 @@ _lseek_r(struct _reent *ptr, int fd, _off_t pos, int whence)
130119
#endif
131120
}
132121

133-
int
134-
_mkdir_r(struct _reent *ptr, const char *name, int mode)
122+
int _mkdir_r(struct _reent *ptr, const char *name, int mode)
135123
{
136124
#ifndef RT_USING_DFS
137125
/* return "not supported" */
@@ -145,8 +133,7 @@ _mkdir_r(struct _reent *ptr, const char *name, int mode)
145133
#endif
146134
}
147135

148-
int
149-
_open_r(struct _reent *ptr, const char *file, int flags, int mode)
136+
int _open_r(struct _reent *ptr, const char *file, int flags, int mode)
150137
{
151138
#ifndef RT_USING_DFS
152139
/* return "not supported" */
@@ -160,8 +147,7 @@ _open_r(struct _reent *ptr, const char *file, int flags, int mode)
160147
#endif
161148
}
162149

163-
_ssize_t
164-
_read_r(struct _reent *ptr, int fd, void *buf, size_t nbytes)
150+
_ssize_t _read_r(struct _reent *ptr, int fd, void *buf, size_t nbytes)
165151
{
166152
#ifndef RT_USING_DFS
167153
/* return "not supported" */
@@ -175,8 +161,7 @@ _read_r(struct _reent *ptr, int fd, void *buf, size_t nbytes)
175161
#endif
176162
}
177163

178-
int
179-
_rename_r(struct _reent *ptr, const char *old, const char *new)
164+
int _rename_r(struct _reent *ptr, const char *old, const char *new)
180165
{
181166
#ifndef RT_USING_DFS
182167
/* return "not supported" */
@@ -190,8 +175,7 @@ _rename_r(struct _reent *ptr, const char *old, const char *new)
190175
#endif
191176
}
192177

193-
int
194-
_stat_r(struct _reent *ptr, const char *file, struct stat *pstat)
178+
int _stat_r(struct _reent *ptr, const char *file, struct stat *pstat)
195179
{
196180
#ifndef RT_USING_DFS
197181
/* return "not supported" */
@@ -205,8 +189,7 @@ _stat_r(struct _reent *ptr, const char *file, struct stat *pstat)
205189
#endif
206190
}
207191

208-
int
209-
_unlink_r(struct _reent *ptr, const char *file)
192+
int _unlink_r(struct _reent *ptr, const char *file)
210193
{
211194
#ifndef RT_USING_DFS
212195
/* return "not supported" */
@@ -217,16 +200,14 @@ _unlink_r(struct _reent *ptr, const char *file)
217200
#endif
218201
}
219202

220-
int
221-
_wait_r(struct _reent *ptr, int *status)
203+
int _wait_r(struct _reent *ptr, int *status)
222204
{
223205
/* return "not supported" */
224206
ptr->_errno = ENOTSUP;
225207
return -1;
226208
}
227209

228-
_ssize_t
229-
_write_r(struct _reent *ptr, int fd, const void *buf, size_t nbytes)
210+
_ssize_t _write_r(struct _reent *ptr, int fd, const void *buf, size_t nbytes)
230211
{
231212
#ifndef RT_USING_DFS
232213
#ifdef RT_USING_DEVICE
@@ -253,8 +234,7 @@ _write_r(struct _reent *ptr, int fd, const void *buf, size_t nbytes)
253234
}
254235

255236
#ifdef RT_USING_HEAP /* Memory routine */
256-
void *
257-
_malloc_r (struct _reent *ptr, size_t size)
237+
void *_malloc_r (struct _reent *ptr, size_t size)
258238
{
259239
void* result;
260240

@@ -267,8 +247,7 @@ _malloc_r (struct _reent *ptr, size_t size)
267247
return result;
268248
}
269249

270-
void *
271-
_realloc_r (struct _reent *ptr, void *old, size_t newlen)
250+
void *_realloc_r (struct _reent *ptr, void *old, size_t newlen)
272251
{
273252
void* result;
274253

@@ -294,8 +273,7 @@ void *_calloc_r (struct _reent *ptr, size_t size, size_t len)
294273
return result;
295274
}
296275

297-
void
298-
_free_r (struct _reent *ptr, void *addr)
276+
void _free_r (struct _reent *ptr, void *addr)
299277
{
300278
rt_free (addr);
301279
}
@@ -309,16 +287,14 @@ _sbrk_r(struct _reent *ptr, ptrdiff_t incr)
309287
#endif /*RT_USING_HEAP*/
310288

311289
/* for exit() and abort() */
312-
__attribute__ ((noreturn)) void
313-
_exit (int status)
290+
__attribute__ ((noreturn)) void _exit (int status)
314291
{
315292
extern void __rt_libc_exit(int status);
316293
__rt_libc_exit(status);
317294
while(1);
318295
}
319296

320-
void
321-
_system(const char *s)
297+
void _system(const char *s)
322298
{
323299
extern int __rt_libc_system(const char *string);
324300
__rt_libc_system(s);

0 commit comments

Comments
 (0)