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).
426 * x86-64 System V ABI mandates:
427 * 1) %rsp must be 16-byte aligned right before the function call.
438 "and $-16, %rsp\n" // x86 ABI : esp must be 16-byte aligned before call
487 * - mostly similar to x86_64
488 * - registers are 32-bit
489 * - syscall number is passed in eax
490 * - arguments are in ebx, ecx, edx, esi, edi, ebp respectively
491 * - all registers are preserved (except eax of course)
492 * - the system call is performed by calling int $0x80
493 * - syscall return comes in eax
494 * - the arguments are cast to long and assigned into the target registers
497 * - the syscall number is always specified last in order to allow to force
498 * some registers before (gcc refuses a %-register at the last position).
539 register long _arg2 asm("ecx") = (long)(arg2); \
556 register long _arg2 asm("ecx") = (long)(arg2); \
574 register long _arg2 asm("ecx") = (long)(arg2); \
593 register long _arg2 asm("ecx") = (long)(arg2); \
611 * 1) last pushed argument must be 16-byte aligned.
620 "lea 4(%ebx,%eax,4),%ecx\n" // then a NULL then envp (third arg, %ecx)
622 "and $-16, %esp\n" // x86 ABI : esp must be 16-byte aligned before
624 "push %ecx\n" // push all registers on the stack so that we
628 "mov %eax, %ebx\n" // retrieve exit code (32-bit int)
646 /* The struct returned by the stat() syscall, 32-bit only, the syscall returns
674 * - registers are 32-bit
675 * - stack is 8-byte aligned
677 * - syscall number is passed in r7
678 * - arguments are in r0, r1, r2, r3, r4, r5
679 * - the system call is performed by calling svc #0
680 * - syscall return comes in r0.
681 * - only lr is clobbered.
682 * - the arguments are cast to long and assigned into the target registers
685 * - the syscall number is always specified last in order to allow to force
686 * some registers before (gcc refuses a %-register at the last position).
796 /* We enter here in 32-bit mode but if some previous functions were in
797 * 16-bit mode, the assembler cannot know, so we need to tell it we're in
798 * 32-bit now, then switch to 16-bit (is there a better way to do it than
799 * adding 1 by hand ?) and tell the asm we're now in 16-bit mode so that
811 "and %r3, %r1, $-8\n" // AAPCS : sp must be 8-byte aligned in the
830 /* The struct returned by the stat() syscall, 32-bit only, the syscall returns
866 * - registers are 64-bit
867 * - stack is 16-byte aligned
868 * - syscall number is passed in x8
869 * - arguments are in x0, x1, x2, x3, x4, x5
870 * - the system call is performed by calling svc 0
871 * - syscall return comes in x0.
872 * - the arguments are cast to long and assigned into the target registers
1008 "and sp, x1, -16\n" // sp must be 16-byte aligned in the callee
1056 * - WARNING! there's always a delayed slot!
1057 * - WARNING again, the syntax is different, registers take a '$' and numbers
1059 * - registers are 32-bit
1060 * - stack is 8-byte aligned
1061 * - syscall number is passed in v0 (starts at 0xfa0).
1062 * - arguments are in a0, a1, a2, a3, then the stack. The caller needs to
1064 * - Many registers are clobbered, in fact only a0..a2 and s0..s8 are
1065 * preserved. See: https://www.linux-mips.org/wiki/Syscall as well as
1066 * scall32-o32.S in the kernel sources.
1067 * - the system call is performed by calling "syscall"
1068 * - syscall return comes in v0, and register a3 needs to be checked to know
1070 * - the arguments are cast to long and assigned into the target registers
1081 "addiu $sp, $sp, -32\n" \
1089 _arg4 ? -_num : _num; \
1099 "addiu $sp, $sp, -32\n" \
1108 _arg4 ? -_num : _num; \
1119 "addiu $sp, $sp, -32\n" \
1128 _arg4 ? -_num : _num; \
1140 "addiu $sp, $sp, -32\n" \
1149 _arg4 ? -_num : _num; \
1161 "addiu $sp, $sp, -32\n" \
1170 _arg4 ? -_num : _num; \
1183 "addiu $sp, $sp, -32\n" \
1193 _arg4 ? -_num : _num; \
1209 "li $t0, -8\n"
1210 "and $sp, $sp, $t0\n" // sp must be 8-byte aligned
1211 "addiu $sp,$sp,-16\n" // the callee expects to save a0..a3 there!
1214 "move $a0, $v0\n" // retrieve 32-bit exit code from v0
1269 * - stack is 16-byte aligned
1270 * - syscall number is passed in a7
1271 * - arguments are in a0, a1, a2, a3, a4, a5
1272 * - the system call is performed by calling ecall
1273 * - syscall return comes in a0
1274 * - the arguments are cast to long and assigned into the target
1410 "andi sp,a1,-16\n" // sp must be 16-byte aligned
1440 long st_blocks; /* Number 512-byte blocks allocated. */
1455 * architecture-agnostic, and return either a success or -errno. Declaring them
1673 t.tv_sec = timeout->tv_sec; in sys_select()
1674 t.tv_nsec = timeout->tv_usec * 1000; in sys_select()
1709 buf->st_dev = stat.st_dev; in sys_stat()
1710 buf->st_ino = stat.st_ino; in sys_stat()
1711 buf->st_mode = stat.st_mode; in sys_stat()
1712 buf->st_nlink = stat.st_nlink; in sys_stat()
1713 buf->st_uid = stat.st_uid; in sys_stat()
1714 buf->st_gid = stat.st_gid; in sys_stat()
1715 buf->st_rdev = stat.st_rdev; in sys_stat()
1716 buf->st_size = stat.st_size; in sys_stat()
1717 buf->st_blksize = stat.st_blksize; in sys_stat()
1718 buf->st_blocks = stat.st_blocks; in sys_stat()
1719 buf->st_atime = stat.st_atime; in sys_stat()
1720 buf->st_mtime = stat.st_mtime; in sys_stat()
1721 buf->st_ctime = stat.st_ctime; in sys_stat()
1773 return sys_waitpid(-1, status, 0); in sys_wait()
1783 /* Below are the libc-compatible syscalls which return x or -1 and set errno.
1795 return -1; in brk()
1812 SET_ERRNO(-ret); in chdir()
1813 ret = -1; in chdir()
1824 SET_ERRNO(-ret); in chmod()
1825 ret = -1; in chmod()
1836 SET_ERRNO(-ret); in chown()
1837 ret = -1; in chown()
1848 SET_ERRNO(-ret); in chroot()
1849 ret = -1; in chroot()
1860 SET_ERRNO(-ret); in close()
1861 ret = -1; in close()
1872 SET_ERRNO(-ret); in dup2()
1873 ret = -1; in dup2()
1884 SET_ERRNO(-ret); in execve()
1885 ret = -1; in execve()
1896 SET_ERRNO(-ret); in fork()
1897 ret = -1; in fork()
1908 SET_ERRNO(-ret); in fsync()
1909 ret = -1; in fsync()
1920 SET_ERRNO(-ret); in getdents64()
1921 ret = -1; in getdents64()
1932 SET_ERRNO(-ret); in getpgrp()
1933 ret = -1; in getpgrp()
1944 SET_ERRNO(-ret); in getpid()
1945 ret = -1; in getpid()
1956 SET_ERRNO(-ret); in gettimeofday()
1957 ret = -1; in gettimeofday()
1968 SET_ERRNO(-ret); in ioctl()
1969 ret = -1; in ioctl()
1980 SET_ERRNO(-ret); in kill()
1981 ret = -1; in kill()
1992 SET_ERRNO(-ret); in link()
1993 ret = -1; in link()
2004 SET_ERRNO(-ret); in lseek()
2005 ret = -1; in lseek()
2016 SET_ERRNO(-ret); in mkdir()
2017 ret = -1; in mkdir()
2028 SET_ERRNO(-ret); in mknod()
2029 ret = -1; in mknod()
2042 SET_ERRNO(-ret); in mount()
2043 ret = -1; in mount()
2054 SET_ERRNO(-ret); in open()
2055 ret = -1; in open()
2066 SET_ERRNO(-ret); in pivot_root()
2067 ret = -1; in pivot_root()
2078 SET_ERRNO(-ret); in poll()
2079 ret = -1; in poll()
2090 SET_ERRNO(-ret); in read()
2091 ret = -1; in read()
2102 SET_ERRNO(-ret); in reboot()
2103 ret = -1; in reboot()
2118 return (void *)-1; in sbrk()
2127 SET_ERRNO(-ret); in sched_yield()
2128 ret = -1; in sched_yield()
2139 SET_ERRNO(-ret); in select()
2140 ret = -1; in select()
2151 SET_ERRNO(-ret); in setpgid()
2152 ret = -1; in setpgid()
2163 SET_ERRNO(-ret); in setsid()
2164 ret = -1; in setsid()
2186 SET_ERRNO(-ret); in stat()
2187 ret = -1; in stat()
2198 SET_ERRNO(-ret); in symlink()
2199 ret = -1; in symlink()
2222 SET_ERRNO(-ret); in umount2()
2223 ret = -1; in umount2()
2234 SET_ERRNO(-ret); in unlink()
2235 ret = -1; in unlink()
2246 SET_ERRNO(-ret); in wait4()
2247 ret = -1; in wait4()
2258 SET_ERRNO(-ret); in waitpid()
2259 ret = -1; in waitpid()
2270 SET_ERRNO(-ret); in wait()
2271 ret = -1; in wait()
2282 SET_ERRNO(-ret); in write()
2283 ret = -1; in write()
2288 /* some size-optimized reimplementations of a few common str* and mem*
2297 ssize_t pos = (dst <= src) ? -1 : (long)len; in memmove()
2300 while (len--) { in memmove()
2301 pos += (dst <= src) ? 1 : -1; in memmove()
2312 while (len--) in memset()
2323 while (ofs < n && !(c1 = ((unsigned char *)s1)[ofs] - ((unsigned char *)s2)[ofs])) { in memcmp()
2380 return (unsigned int)(c - '0') <= 9; in isdigit()
2390 if (*s == '-') { in atol()
2396 d = (*s++) - '0'; in atol()
2403 return neg ? -ret : ret; in atol()
2415 /* large enough for -9223372036854775808 */ in ltoa()
2417 char *pos = buffer + sizeof(buffer) - 1; in ltoa()
2419 unsigned long n = neg ? -in : in; in ltoa()
2421 *pos-- = '\0'; in ltoa()
2423 *pos-- = '0' + n % 10; in ltoa()
2430 *pos-- = '-'; in ltoa()
2460 set->fd32[fd / 32] |= 1 << (fd & 31); in FD_SET()