diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2002-05-24 03:44:39 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2002-05-24 03:44:39 +0000 |
commit | a2c4c67f6bef5f075a102e449c50d7bbefa3e41b (patch) | |
tree | da00f4e450bfa103f0af9d48421a2415f2b48297 /libexec/ld.so/mips/syscall.h | |
parent | 0e0146f4ca37eec8c1d0ae44892dfa75d54f4f7d (diff) |
various KNF
Diffstat (limited to 'libexec/ld.so/mips/syscall.h')
-rw-r--r-- | libexec/ld.so/mips/syscall.h | 329 |
1 files changed, 170 insertions, 159 deletions
diff --git a/libexec/ld.so/mips/syscall.h b/libexec/ld.so/mips/syscall.h index dd92915c265..baff785e39c 100644 --- a/libexec/ld.so/mips/syscall.h +++ b/libexec/ld.so/mips/syscall.h @@ -1,8 +1,8 @@ -/* $OpenBSD: syscall.h,v 1.2 2002/02/21 23:17:53 drahn Exp $ */ +/* $OpenBSD: syscall.h,v 1.3 2002/05/24 03:44:38 deraadt Exp $ */ /* * Copyright (c) 1998 Per Fogelstrom, Opsycon AB - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -44,7 +44,7 @@ #define _dl_MAX_ERRNO 4096 #endif #define _dl_check_error(__res) \ - ((int) __res < 0 && (int) __res >= -_dl_MAX_ERRNO) + ((int) __res < 0 && (int) __res >= -_dl_MAX_ERRNO) /* * Inlined system call functions that can be used before @@ -53,196 +53,207 @@ extern inline int _dl_exit (int status) -{ - register int __status __asm__ ("$2"); - __asm__ volatile ("move $4,%2\n\t" - "syscall" - : "=r" (__status) - : "0" (SYS_exit), "r" (status) - : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", - "$10","$11","$12","$13","$14","$15","$24","$25"); - while(1); -} +{ + register int __status __asm__ ("$2"); + + __asm__ volatile ("move $4,%2\n\t" + "syscall" + : "=r" (__status) + : "0" (SYS_exit), "r" (status) + : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", + "$10","$11","$12","$13","$14","$15","$24","$25"); + while (1) + ; +} extern inline int _dl_open (const char* addr, unsigned int flags) -{ - register int status __asm__ ("$2"); - __asm__ volatile ("move $4,%2\n\t" - "move $5,%3\n\t" - "syscall\n\t" - "beq $7,$0,1f\n\t" - "li $2,-1\n\t" - "1:" - : "=r" (status) - : "0" (SYS_open), "r" (addr), "r" (flags) - : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", - "$10","$11","$12","$13","$14","$15","$24","$25"); - return status; -} +{ + register int status __asm__ ("$2"); + + __asm__ volatile ("move $4,%2\n\t" + "move $5,%3\n\t" + "syscall\n\t" + "beq $7,$0,1f\n\t" + "li $2,-1\n\t" + "1:" + : "=r" (status) + : "0" (SYS_open), "r" (addr), "r" (flags) + : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", + "$10","$11","$12","$13","$14","$15","$24","$25"); + return status; +} extern inline int _dl_close (int fd) -{ - register int status __asm__ ("$2"); - __asm__ volatile ("move $4,%2\n\t" - "syscall\n\t" - "beq $7,$0,1f\n\t" - "li $2,-1\n\t" - "1:" - : "=r" (status) - : "0" (SYS_close), "r" (fd) - : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", - "$10","$11","$12","$13","$14","$15","$24","$25"); - return status; -} +{ + register int status __asm__ ("$2"); + + __asm__ volatile ("move $4,%2\n\t" + "syscall\n\t" + "beq $7,$0,1f\n\t" + "li $2,-1\n\t" + "1:" + : "=r" (status) + : "0" (SYS_close), "r" (fd) + : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", + "$10","$11","$12","$13","$14","$15","$24","$25"); + return status; +} extern inline int _dl_write (int fd, const char* buf, int len) -{ - register int status __asm__ ("$2"); - __asm__ volatile ("move $4,%2\n\t" - "move $5,%3\n\t" - "move $6,%4\n\t" - "syscall\n\t" - "beq $7,$0,1f\n\t" - "li $2,-1\n\t" - "1:" - : "=r" (status) - : "0" (SYS_write), "r" (fd), "r" (buf), "r" (len) - : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", - "$10","$11","$12","$13","$14","$15","$24","$25"); - return status; -} +{ + register int status __asm__ ("$2"); + + __asm__ volatile ("move $4,%2\n\t" + "move $5,%3\n\t" + "move $6,%4\n\t" + "syscall\n\t" + "beq $7,$0,1f\n\t" + "li $2,-1\n\t" + "1:" + : "=r" (status) + : "0" (SYS_write), "r" (fd), "r" (buf), "r" (len) + : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", + "$10","$11","$12","$13","$14","$15","$24","$25"); + return status; +} extern inline int _dl_read (int fd, const char* buf, int len) -{ - register int status __asm__ ("$2"); - __asm__ volatile ("move $4,%2\n\t" - "move $5,%3\n\t" - "move $6,%4\n\t" - "syscall\n\t" - "beq $7,$0,1f\n\t" - "li $2,-1\n\t" - "1:" - : "=r" (status) - : "0" (SYS_read), "r" (fd), "r" (buf), "r" (len) - : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", - "$10","$11","$12","$13","$14","$15","$24","$25"); - return status; -} +{ + register int status __asm__ ("$2"); + + __asm__ volatile ("move $4,%2\n\t" + "move $5,%3\n\t" + "move $6,%4\n\t" + "syscall\n\t" + "beq $7,$0,1f\n\t" + "li $2,-1\n\t" + "1:" + : "=r" (status) + : "0" (SYS_read), "r" (fd), "r" (buf), "r" (len) + : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", + "$10","$11","$12","$13","$14","$15","$24","$25"); + return status; +} extern inline int _dl_mmap (void *addr, unsigned int size, unsigned int prot, - unsigned int flags, int fd, unsigned int f_offset) -{ - register int malloc_buffer __asm__ ("$2"); - __asm__ volatile ("addiu $29,-40\n\t" - "move $6,%2\n\t" - "move $7,%3\n\t" - "sw %4,16($29)\n\t" - "sw %5,20($29)\n\t" + unsigned int flags, int fd, unsigned int f_offset) +{ + register int malloc_buffer __asm__ ("$2"); + + __asm__ volatile ("addiu $29,-40\n\t" + "move $6,%2\n\t" + "move $7,%3\n\t" + "sw %4,16($29)\n\t" + "sw %5,20($29)\n\t" #ifdef MIPSEL - "li $4,197\n\t" - "li $5,0\n\t" - "sw %6,24($29)\n\t" - "sw $0,28($29)\n\t" - "sw %7,32($29)\n\t" - "sw $0,36($29)\n\t" + "li $4,197\n\t" + "li $5,0\n\t" + "sw %6,24($29)\n\t" + "sw $0,28($29)\n\t" + "sw %7,32($29)\n\t" + "sw $0,36($29)\n\t" #endif #ifdef MIPSEB - "li $4,0\n\t" - "li $5,197\n\t" - "sw %6,24($29)\n\t" - "sw $0,28($29)\n\t" - "sw $0,32($29)\n\t" - "sw %7,36($29)\n\t" + "li $4,0\n\t" + "li $5,197\n\t" + "sw %6,24($29)\n\t" + "sw $0,28($29)\n\t" + "sw $0,32($29)\n\t" + "sw %7,36($29)\n\t" #endif - "syscall\n\t" - "addiu $29,40" - : "=r" (malloc_buffer) - : "0" (SYS___syscall), "r" (addr), "r" (size), "r" (prot), - "r" (flags), "r" (fd), "r" (f_offset) - : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", - "$10","$11","$12","$13","$14","$15","$24","$25"); - return malloc_buffer; -} + "syscall\n\t" + "addiu $29,40" + : "=r" (malloc_buffer) + : "0" (SYS___syscall), "r" (addr), "r" (size), "r" (prot), + "r" (flags), "r" (fd), "r" (f_offset) + : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", + "$10","$11","$12","$13","$14","$15","$24","$25"); + return malloc_buffer; +} extern inline int _dl_munmap (const void* addr, unsigned int len) -{ - register int status __asm__ ("$2"); - __asm__ volatile ("move $4,%2\n\t" - "move $5,%3\n\t" - "syscall\n\t" - "beq $7,$0,1f\n\t" - "li $2,-1\n\t" - "1:" - : "=r" (status) - : "0" (SYS_munmap), "r" (addr), "r" (len) - : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", - "$10","$11","$12","$13","$14","$15","$24","$25"); - return status; -} +{ + register int status __asm__ ("$2"); + + __asm__ volatile ("move $4,%2\n\t" + "move $5,%3\n\t" + "syscall\n\t" + "beq $7,$0,1f\n\t" + "li $2,-1\n\t" + "1:" + : "=r" (status) + : "0" (SYS_munmap), "r" (addr), "r" (len) + : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", + "$10","$11","$12","$13","$14","$15","$24","$25"); + return status; +} extern inline int _dl_mprotect (const void *addr, int size, int prot) -{ - register int status __asm__ ("$2"); - __asm__ volatile ("move $4,%2\n\t" - "move $5,%3\n\t" - "move $6,%4\n\t" - "syscall" - : "=r" (status) - : "0" (SYS_mprotect), "r" (addr), "r" (size), "r" (prot) - : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", - "$10","$11","$12","$13","$14","$15","$24","$25"); - return status; -} +{ + register int status __asm__ ("$2"); + + __asm__ volatile ("move $4,%2\n\t" + "move $5,%3\n\t" + "move $6,%4\n\t" + "syscall" + : "=r" (status) + : "0" (SYS_mprotect), "r" (addr), "r" (size), "r" (prot) + : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", + "$10","$11","$12","$13","$14","$15","$24","$25"); + return status; +} #ifdef USE_CACHE extern inline int _dl_stat (const char *addr, struct stat *sb) -{ - register int status __asm__ ("$2"); - __asm__ volatile ("move $4,%2\n\t" - "move $5,%3\n\t" - "syscall" - : "=r" (status) - : "0" (SYS_stat), "r" (addr), "r" (sb) - : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", - "$10","$11","$12","$13","$14","$15","$24","$25"); - return status; -} +{ + register int status __asm__ ("$2"); -#endif + __asm__ volatile ("move $4,%2\n\t" + "move $5,%3\n\t" + "syscall" + : "=r" (status) + : "0" (SYS_stat), "r" (addr), "r" (sb) + : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", + "$10","$11","$12","$13","$14","$15","$24","$25"); + return status; +} -/* Not an actual syscall, but we need something in assembly to say - whether this is OK or not. */ +#endif +/* + * Not an actual syscall, but we need something in assembly to say + * whether this is OK or not. + */ extern inline int _dl_suid_ok (void) { - unsigned int uid, euid, gid, egid; - - __asm__ volatile ("move $2,%1; syscall; move %0,$2" - : "=r" (uid) : "r" (SYS_getuid) - : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", - "$10","$11","$12","$13","$14","$15","$24","$25"); - __asm__ volatile ("move $2,%1; syscall; move %0,$2" - : "=r" (euid) : "r" (SYS_geteuid) - : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", - "$10","$11","$12","$13","$14","$15","$24","$25"); - __asm__ volatile ("move $2,%1; syscall; move %0,$2" - : "=r" (gid) : "r" (SYS_getgid) - : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", - "$10","$11","$12","$13","$14","$15","$24","$25"); - __asm__ volatile ("move $2,%1; syscall; move %0,$2" - : "=r" (egid) : "r" (SYS_getegid) - : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", - "$10","$11","$12","$13","$14","$15","$24","$25"); - - return (uid == euid && gid == egid); + unsigned int uid, euid, gid, egid; + + __asm__ volatile ("move $2,%1; syscall; move %0,$2" + : "=r" (uid) : "r" (SYS_getuid) + : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", + "$10","$11","$12","$13","$14","$15","$24","$25"); + __asm__ volatile ("move $2,%1; syscall; move %0,$2" + : "=r" (euid) : "r" (SYS_geteuid) + : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", + "$10","$11","$12","$13","$14","$15","$24","$25"); + __asm__ volatile ("move $2,%1; syscall; move %0,$2" + : "=r" (gid) : "r" (SYS_getgid) + : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", + "$10","$11","$12","$13","$14","$15","$24","$25"); + __asm__ volatile ("move $2,%1; syscall; move %0,$2" + : "=r" (egid) : "r" (SYS_getegid) + : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", + "$10","$11","$12","$13","$14","$15","$24","$25"); + + return (uid == euid && gid == egid); } #endif /*__DL_SYSCALL_H__*/ |