1 #include <common/unistd.h>
2 #include <common/glib.h>
3
4 /**
5 * @brief fork当前进程
6 *
7 * @return pid_t
8 */
fork(void)9 pid_t fork(void)
10 {
11 return (pid_t)enter_syscall_int(SYS_FORK, 0, 0, 0, 0, 0, 0, 0, 0);
12 }
13
14 /**
15 * @brief vfork当前进程
16 *
17 * @return pid_t
18 */
vfork(void)19 pid_t vfork(void)
20 {
21 return (pid_t)enter_syscall_int(SYS_VFORK, 0, 0, 0, 0, 0, 0, 0, 0);
22 }
23
swab(void * restrict src,void * restrict dest,ssize_t nbytes)24 void swab(void *restrict src, void *restrict dest, ssize_t nbytes)
25 {
26 unsigned char buf[32];
27 char *_src = src;
28 char *_dest = dest;
29 uint32_t transfer;
30 for (; nbytes > 0; nbytes -= transfer)
31 {
32 transfer = (nbytes > 32) ? 32 : nbytes;
33 memcpy(buf, _src, transfer);
34 memcpy(_src, _dest, transfer);
35 memcpy(_dest, buf, transfer);
36 _src += transfer;
37 _dest += transfer;
38 }
39 }