Cygwin: cygwin_GetCommandLineW/A: don't rely on __argv[0] content
[newlib-cygwin.git] / libgloss / arm / linux-syscalls1.c
bloba196352b51d6b953c6ce9fb9f82dca39c13f4a48
1 /** Linux system call interface.
2 * Written by Shaun Jackman <sjackman@gmail.com>.
3 * Copyright 2006 Pathway Connectivity
5 * Permission to use, copy, modify, and distribute this software
6 * is freely granted, provided that this notice is preserved.
7 */
9 #include <errno.h>
10 #include <stdint.h>
12 extern char _end[];
13 static void *curbrk = _end;
15 extern void *_brk(void *addr);
17 int brk(void *addr)
19 void *newbrk;
20 if (curbrk == addr)
21 return 0;
22 newbrk = _brk(addr);
23 curbrk = newbrk;
24 if (newbrk < addr) {
25 errno = ENOMEM;
26 return -1;
28 return 0;
31 void *_sbrk(intptr_t incr)
33 void *oldbrk = curbrk;
34 if (brk(oldbrk + incr) == -1)
35 return (void *)-1;
36 return oldbrk;
39 void *sbrk(intptr_t incr) __attribute__((alias("_sbrk")));
41 int _set_errno(int n)
43 if (n < 0) {
44 errno = -n;
45 return -1;
47 return n;
50 #include <sys/wait.h>
52 struct rusage;
54 pid_t wait4(pid_t pid, int *status, int options, struct rusage *rusage);
56 pid_t _wait(int *status)
58 return wait4(-1, status, 0, NULL);
61 pid_t waitpid(pid_t pid, int *status, int options)
63 return wait4(pid, status, options, NULL);
66 extern int _reboot(int magic, int magic2, int flag, void *arg);
68 int reboot(int flag)
70 return _reboot(0xfee1dead, 0x28121969, flag, NULL);