Lines Matching +full:ecx +full:- +full:1000
1 /* SPDX-License-Identifier: LGPL-2.1 OR MIT */
3 * Copyright (C) 2017-2018 Willy Tarreau <w@1wt.eu>
14 * - The lower level is the arch-specific syscall() definition, consisting in
22 * - The second level is mostly architecture-independent. It is made of
27 * A few of them are architecture-specific because the syscalls are not all
32 * - The third level is the libc call definition. It exposes the lower raw
45 * Some stdint-like integer types are defined. These are valid on all currently
53 * The definitions start with the architecture-specific parts, which are picked
56 * target architecture, cross-compiling normally works out of the box without
59 * Finally some very common libc-level functions are provided. It is the case
73 * $ gcc -fno-asynchronous-unwind-tables -fno-ident -s -Os -nostdlib \
74 * -static -include nolibc.h -lgcc -o hello hello.c
77 * http://man7.org/linux/man-pages/man2/syscall.2.html
235 #define AT_FDCWD -100
275 /* Below comes the architecture-specific code. For each architecture, we have
286 * - registers are 64-bit
287 * - syscall number is passed in rax
288 * - arguments are in rdi, rsi, rdx, r10, r8, r9 respectively
289 * - the system call is performed by calling the syscall instruction
290 * - syscall return comes in rax
291 * - rcx and r8..r11 may be clobbered, others are preserved.
292 * - the arguments are cast to long and assigned into the target registers
295 * - the syscall number is always specified last in order to allow to force
296 * some registers before (gcc refuses a %-register at the last position).
431 "and $-16, %rsp\n" // x86 ABI : esp must be 16-byte aligned when
481 * - mostly similar to x86_64
482 * - registers are 32-bit
483 * - syscall number is passed in eax
484 * - arguments are in ebx, ecx, edx, esi, edi, ebp respectively
485 * - all registers are preserved (except eax of course)
486 * - the system call is performed by calling int $0x80
487 * - syscall return comes in eax
488 * - the arguments are cast to long and assigned into the target registers
491 * - the syscall number is always specified last in order to allow to force
492 * some registers before (gcc refuses a %-register at the last position).
533 register long _arg2 asm("ecx") = (long)(arg2); \
550 register long _arg2 asm("ecx") = (long)(arg2); \
568 register long _arg2 asm("ecx") = (long)(arg2); \
587 register long _arg2 asm("ecx") = (long)(arg2); \
608 "lea 4(%ebx,%eax,4),%ecx\n" // then a NULL then envp (third arg, %ecx)
609 "and $-16, %esp\n" // x86 ABI : esp must be 16-byte aligned when
610 "push %ecx\n" // push all registers on the stack so that we
632 /* The struct returned by the stat() syscall, 32-bit only, the syscall returns
660 * - registers are 32-bit
661 * - stack is 8-byte aligned
663 * - syscall number is passed in r7
664 * - arguments are in r0, r1, r2, r3, r4, r5
665 * - the system call is performed by calling svc #0
666 * - syscall return comes in r0.
667 * - only lr is clobbered.
668 * - the arguments are cast to long and assigned into the target registers
671 * - the syscall number is always specified last in order to allow to force
672 * some registers before (gcc refuses a %-register at the last position).
782 /* We enter here in 32-bit mode but if some previous functions were in
783 * 16-bit mode, the assembler cannot know, so we need to tell it we're in
784 * 32-bit now, then switch to 16-bit (is there a better way to do it than
785 * adding 1 by hand ?) and tell the asm we're now in 16-bit mode so that
797 "and %r3, %r1, $-8\n" // AAPCS : sp must be 8-byte aligned in the
817 /* The struct returned by the stat() syscall, 32-bit only, the syscall returns
853 * - registers are 64-bit
854 * - stack is 16-byte aligned
855 * - syscall number is passed in x8
856 * - arguments are in x0, x1, x2, x3, x4, x5
857 * - the system call is performed by calling svc 0
858 * - syscall return comes in x0.
859 * - the arguments are cast to long and assigned into the target registers
995 "and sp, x1, -16\n" // sp must be 16-byte aligned in the callee
1044 * - WARNING! there's always a delayed slot!
1045 * - WARNING again, the syntax is different, registers take a '$' and numbers
1047 * - registers are 32-bit
1048 * - stack is 8-byte aligned
1049 * - syscall number is passed in v0 (starts at 0xfa0).
1050 * - arguments are in a0, a1, a2, a3, then the stack. The caller needs to
1052 * - Many registers are clobbered, in fact only a0..a2 and s0..s8 are
1053 * preserved. See: https://www.linux-mips.org/wiki/Syscall as well as
1054 * scall32-o32.S in the kernel sources.
1055 * - the system call is performed by calling "syscall"
1056 * - syscall return comes in v0, and register a3 needs to be checked to know
1058 * - the arguments are cast to long and assigned into the target registers
1069 "addiu $sp, $sp, -32\n" \
1077 _arg4 ? -_num : _num; \
1087 "addiu $sp, $sp, -32\n" \
1096 _arg4 ? -_num : _num; \
1107 "addiu $sp, $sp, -32\n" \
1116 _arg4 ? -_num : _num; \
1128 "addiu $sp, $sp, -32\n" \
1137 _arg4 ? -_num : _num; \
1149 "addiu $sp, $sp, -32\n" \
1158 _arg4 ? -_num : _num; \
1171 "addiu $sp, $sp, -32\n" \
1181 _arg4 ? -_num : _num; \
1197 "li $t0, -8\n"
1198 "and $sp, $sp, $t0\n" // sp must be 8-byte aligned
1199 "addiu $sp,$sp,-16\n" // the callee expects to save a0..a3 there!
1257 * - stack is 16-byte aligned
1258 * - syscall number is passed in a7
1259 * - arguments are in a0, a1, a2, a3, a4, a5
1260 * - the system call is performed by calling ecall
1261 * - syscall return comes in a0
1262 * - the arguments are cast to long and assigned into the target
1398 "andi sp,a1,-16\n" // sp must be 16-byte aligned
1429 long st_blocks; /* Number 512-byte blocks allocated. */
1444 * architecture-agnostic, and return either a success or -errno. Declaring them
1662 t.tv_sec = timeout->tv_sec; in sys_select()
1663 t.tv_nsec = timeout->tv_usec * 1000; in sys_select()
1698 buf->st_dev = stat.st_dev; in sys_stat()
1699 buf->st_ino = stat.st_ino; in sys_stat()
1700 buf->st_mode = stat.st_mode; in sys_stat()
1701 buf->st_nlink = stat.st_nlink; in sys_stat()
1702 buf->st_uid = stat.st_uid; in sys_stat()
1703 buf->st_gid = stat.st_gid; in sys_stat()
1704 buf->st_rdev = stat.st_rdev; in sys_stat()
1705 buf->st_size = stat.st_size; in sys_stat()
1706 buf->st_blksize = stat.st_blksize; in sys_stat()
1707 buf->st_blocks = stat.st_blocks; in sys_stat()
1708 buf->st_atime = stat.st_atime; in sys_stat()
1709 buf->st_mtime = stat.st_mtime; in sys_stat()
1710 buf->st_ctime = stat.st_ctime; in sys_stat()
1762 return sys_waitpid(-1, status, 0); in sys_wait()
1772 /* Below are the libc-compatible syscalls which return x or -1 and set errno.
1784 return -1; in brk()
1801 SET_ERRNO(-ret); in chdir()
1802 ret = -1; in chdir()
1813 SET_ERRNO(-ret); in chmod()
1814 ret = -1; in chmod()
1825 SET_ERRNO(-ret); in chown()
1826 ret = -1; in chown()
1837 SET_ERRNO(-ret); in chroot()
1838 ret = -1; in chroot()
1849 SET_ERRNO(-ret); in close()
1850 ret = -1; in close()
1861 SET_ERRNO(-ret); in dup2()
1862 ret = -1; in dup2()
1873 SET_ERRNO(-ret); in execve()
1874 ret = -1; in execve()
1885 SET_ERRNO(-ret); in fork()
1886 ret = -1; in fork()
1897 SET_ERRNO(-ret); in fsync()
1898 ret = -1; in fsync()
1909 SET_ERRNO(-ret); in getdents64()
1910 ret = -1; in getdents64()
1921 SET_ERRNO(-ret); in getpgrp()
1922 ret = -1; in getpgrp()
1933 SET_ERRNO(-ret); in getpid()
1934 ret = -1; in getpid()
1945 SET_ERRNO(-ret); in gettimeofday()
1946 ret = -1; in gettimeofday()
1957 SET_ERRNO(-ret); in ioctl()
1958 ret = -1; in ioctl()
1969 SET_ERRNO(-ret); in kill()
1970 ret = -1; in kill()
1981 SET_ERRNO(-ret); in link()
1982 ret = -1; in link()
1993 SET_ERRNO(-ret); in lseek()
1994 ret = -1; in lseek()
2005 SET_ERRNO(-ret); in mkdir()
2006 ret = -1; in mkdir()
2017 SET_ERRNO(-ret); in mknod()
2018 ret = -1; in mknod()
2031 SET_ERRNO(-ret); in mount()
2032 ret = -1; in mount()
2043 SET_ERRNO(-ret); in open()
2044 ret = -1; in open()
2055 SET_ERRNO(-ret); in pivot_root()
2056 ret = -1; in pivot_root()
2067 SET_ERRNO(-ret); in poll()
2068 ret = -1; in poll()
2079 SET_ERRNO(-ret); in read()
2080 ret = -1; in read()
2091 SET_ERRNO(-ret); in reboot()
2092 ret = -1; in reboot()
2107 return (void *)-1; in sbrk()
2116 SET_ERRNO(-ret); in sched_yield()
2117 ret = -1; in sched_yield()
2128 SET_ERRNO(-ret); in select()
2129 ret = -1; in select()
2140 SET_ERRNO(-ret); in setpgid()
2141 ret = -1; in setpgid()
2152 SET_ERRNO(-ret); in setsid()
2153 ret = -1; in setsid()
2175 SET_ERRNO(-ret); in stat()
2176 ret = -1; in stat()
2187 SET_ERRNO(-ret); in symlink()
2188 ret = -1; in symlink()
2211 SET_ERRNO(-ret); in umount2()
2212 ret = -1; in umount2()
2223 SET_ERRNO(-ret); in unlink()
2224 ret = -1; in unlink()
2235 SET_ERRNO(-ret); in wait4()
2236 ret = -1; in wait4()
2247 SET_ERRNO(-ret); in waitpid()
2248 ret = -1; in waitpid()
2259 SET_ERRNO(-ret); in wait()
2260 ret = -1; in wait()
2271 SET_ERRNO(-ret); in write()
2272 ret = -1; in write()
2277 /* some size-optimized reimplementations of a few common str* and mem*
2286 ssize_t pos = (dst <= src) ? -1 : (long)len; in memmove()
2289 while (len--) { in memmove()
2290 pos += (dst <= src) ? 1 : -1; in memmove()
2301 while (len--) in memset()
2312 while (ofs < n && !(c1 = ((char *)s1)[ofs] - ((char *)s2)[ofs])) { in memcmp()
2369 return (unsigned int)(c - '0') <= 9; in isdigit()
2379 if (*s == '-') { in atol()
2385 d = (*s++) - '0'; in atol()
2392 return neg ? -ret : ret; in atol()
2404 /* large enough for -9223372036854775808 */ in ltoa()
2406 char *pos = buffer + sizeof(buffer) - 1; in ltoa()
2408 unsigned long n = neg ? -in : in; in ltoa()
2410 *pos-- = '\0'; in ltoa()
2412 *pos-- = '0' + n % 10; in ltoa()
2419 *pos-- = '-'; in ltoa()
2449 set->fd32[fd / 32] |= 1 << (fd & 31); in FD_SET()