⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 syscalls.c

📁 它通过提供glibc兼容使得应用程序移植到较小的c 库时相当得容易. 它能够应用到带虚拟存储的Linux和uClinux上.在大多数带MMU部件的平台上为使它更加紧凑,它也能够编译成共享库.uClib
💻 C
📖 第 1 页 / 共 4 页
字号:
int setgid(gid_t gid){	return(__syscall_setgid(gid));}#endif//#define __NR_getgid           47#ifdef L_getgid#include <unistd.h>#if defined (__alpha__)#define __NR_getgid     __NR_getxgid#endif_syscall0(gid_t, getgid);#endif//#define __NR_signal           48//#define __NR_geteuid          49#ifdef	L_geteuid#include <unistd.h>#	ifdef	__NR_geteuid	_syscall0(uid_t, geteuid);#	else	uid_t geteuid(void)	{		return (getuid());	}#	endif#endif//#define __NR_getegid          50#ifdef	L_getegid#include <unistd.h>#	ifdef	__NR_getegid	_syscall0(gid_t, getegid);#	else	gid_t getegid(void)	{		return (getgid());	}#	endif#endif//#define __NR_acct             51#ifdef L_acct#include <unistd.h>_syscall1(int, acct, const char *, filename);#endif//#define __NR_umount2          52#ifdef L_umount2#	ifdef __NR_umount2 /* Old kernels don't have umount2 */ #		include <sys/mount.h>		_syscall2(int, umount2, const char *, special_file, int, flags);#	else		int umount2(const char * special_file, int flags)		{			__set_errno(ENOSYS);			return -1;		}#	endif#endif//#define __NR_lock             53//#define __NR_ioctl            54#ifdef L___syscall_ioctl#include <stdarg.h>#include <sys/ioctl.h>#define __NR___syscall_ioctl __NR_ioctlextern int __syscall_ioctl(int fd, int request, void *arg);_syscall3(int, __syscall_ioctl, int, fd, int, request, void *, arg);#if !defined (__powerpc__)#include "ioctl.c"/* Also see ioctl.c and powerpc/ioctl.c */#endif#endif//#define __NR_fcntl            55#ifdef L__fcntl#include <stdarg.h>#include <fcntl.h>#define __NR__fcntl __NR_fcntlextern int _fcntl(int fd, int cmd, long arg);_syscall3(int, _fcntl, int, fd, int, cmd, long, arg);int __libc_fcntl(int fd, int command, ...){	long arg;	va_list list;	va_start(list, command);	arg = va_arg(list, long);	va_end(list);	return _fcntl(fd, command, arg);}weak_alias(__libc_fcntl, fcntl)#endif//#define __NR_mpx              56//#define __NR_setpgid          57#ifdef L___syscall_setpgid#include <unistd.h>#define __NR___syscall_setpgid __NR_setpgidstatic inline_syscall2(int, __syscall_setpgid, __kernel_pid_t, pid, __kernel_pid_t, pgid);int setpgid(pid_t pid, pid_t pgid){	return(__syscall_setpgid(pid, pgid));}#endif//#define __NR_ulimit           58//#define __NR_oldolduname      59//#define __NR_umask            60#ifdef L___syscall_umask#include <sys/stat.h>#define __NR___syscall_umask __NR_umaskstatic inline _syscall1(__kernel_mode_t, __syscall_umask, __kernel_mode_t, mask);mode_t umask(mode_t mask){	return(__syscall_umask(mask));}#endif//#define __NR_chroot           61#ifdef L_chroot#include <unistd.h>_syscall1(int, chroot, const char *, path);#endif//#define __NR_ustat            62//#define __NR_dup2             63#ifdef L_dup2#include <unistd.h>_syscall2(int, dup2, int, oldfd, int, newfd);#endif//#define __NR_getppid          64#ifdef	L_getppid#	include <unistd.h>#	ifdef	__NR_getppid	_syscall0(pid_t, getppid);#	else	pid_t getppid(void)	{		return (getpid());	}#	endif#endif//#define __NR_getpgrp          65#ifdef L_getpgrp#include <unistd.h>_syscall0(pid_t, getpgrp);#endif//#define __NR_setsid           66#ifdef L_setsid#include <unistd.h>_syscall0(pid_t, setsid);#endif//#define __NR_sigaction        67#ifndef __NR_rt_sigaction#ifdef L___syscall_sigaction#define __NR___syscall_sigaction __NR_sigaction#include <signal.h>#undef sigaction_syscall3(int, __syscall_sigaction, int, signum, const struct sigaction *, act,		  struct sigaction *, oldact);#endif#endif//#define __NR_sgetmask         68//#define __NR_ssetmask         69//#define __NR_setreuid         70#ifdef L___syscall_setreuid#include <unistd.h>#define __NR___syscall_setreuid __NR_setreuidstatic inline_syscall2(int, __syscall_setreuid, __kernel_uid_t, ruid, __kernel_uid_t, euid);int setreuid(uid_t ruid, uid_t euid){	return(__syscall_setreuid(ruid, euid));}#endif//#define __NR_setregid         71#ifdef L___syscall_setregid#include <unistd.h>#define __NR___syscall_setregid __NR_setregidstatic inline_syscall2(int, __syscall_setregid, __kernel_gid_t, rgid, __kernel_gid_t, egid);int setregid(gid_t rgid, gid_t egid){	return(__syscall_setregid(rgid, egid));}#endif//#define __NR_sigsuspend       72#ifndef __NR_rt_sigsuspend#define __NR___sigsuspend __NR_sigsuspend#ifdef L___sigsuspend#include <signal.h>#undef sigsuspend_syscall3(int, __sigsuspend, int, a, unsigned long int, b, unsigned long int, c);int sigsuspend (const sigset_t *set){	return __sigsuspend(0, 0, set->__val[0]);}#endif#endif//#define __NR_sigpending       73#ifndef __NR_rt_sigpending#ifdef L_sigpending#include <signal.h>#undef sigpending_syscall1(int, sigpending, sigset_t *, set);#endif#endif//#define __NR_sethostname      74#ifdef L_sethostname#include <unistd.h>_syscall2(int, sethostname, const char *, name, size_t, len);#endif//#define __NR_setrlimit        75#ifndef __NR_ugetrlimit/* Only wrap setrlimit if the new ugetrlimit is not present */ #ifdef L___setrlimit#define __NR___setrlimit __NR_setrlimit#include <unistd.h>#include <sys/resource.h>#define RMIN(x, y) ((x) < (y) ? (x) : (y))_syscall2(int, __setrlimit, int, resource, const struct rlimit *, rlim);int setrlimit (__rlimit_resource_t resource, const struct rlimit *rlimits){	struct rlimit rlimits_small;	/* We might have to correct the limits values.  Since the old values	 * were signed the new values might be too large.  */	rlimits_small.rlim_cur = RMIN ((unsigned long int) rlimits->rlim_cur,				       RLIM_INFINITY >> 1);	rlimits_small.rlim_max = RMIN ((unsigned long int) rlimits->rlim_max,				       RLIM_INFINITY >> 1);	return(__setrlimit(resource, &rlimits_small));}#undef RMIN#endif#else /* We don't need to wrap setrlimit */#ifdef L_setrlimit#include <unistd.h>struct rlimit;_syscall2(int, setrlimit, unsigned int, resource, const struct rlimit *, rlim);#endif#endif /* __NR_setrlimit *///#define __NR_getrlimit        76#ifdef L___getrlimit/* Only include the old getrlimit if the new one (ugetrlimit) is not around */ #ifndef __NR_ugetrlimit#define __NR___getrlimit __NR_getrlimit#include <unistd.h>#include <sys/resource.h>_syscall2(int, __getrlimit, int, resource, struct rlimit *, rlim);int getrlimit (__rlimit_resource_t resource, struct rlimit *rlimits){	int result;	result = __getrlimit(resource, rlimits);	if (result == -1)		return result;	/* We might have to correct the limits values.  Since the old values	 * were signed the infinity value is too small.  */	if (rlimits->rlim_cur == RLIM_INFINITY >> 1)		rlimits->rlim_cur = RLIM_INFINITY;	if (rlimits->rlim_max == RLIM_INFINITY >> 1)		rlimits->rlim_max = RLIM_INFINITY;	return result;}#endif#endif /* __NR_getrlimit *///#define __NR_getrusage        77#ifdef L_getrusage#include <unistd.h>#include <wait.h>_syscall2(int, getrusage, int, who, struct rusage *, usage);#endif//#define __NR_gettimeofday     78#ifdef L_gettimeofday#include <sys/time.h>_syscall2(int, gettimeofday, struct timeval *, tv, struct timezone *, tz);#endif//#define __NR_settimeofday     79#ifdef L_settimeofday#include <sys/time.h>_syscall2(int, settimeofday, const struct timeval *, tv,		  const struct timezone *, tz);#endif//#define __NR_getgroups        80#ifdef L___syscall_getgroups#include <unistd.h>#define __NR___syscall_getgroups __NR_getgroupsstatic inline_syscall2(int, __syscall_getgroups, int, size, __kernel_gid_t *, list);#define MIN(a,b) (((a)<(b))?(a):(b))int getgroups(int n, gid_t *groups){	if (unlikely(n < 0)) {		__set_errno(EINVAL);		return -1;	} else {		int i, ngids;		__kernel_gid_t kernel_groups[n = MIN(n, sysconf(_SC_NGROUPS_MAX))];		ngids = __syscall_getgroups(n, kernel_groups);		if (n != 0 && ngids > 0) {			for (i = 0; i < ngids; i++) {				(groups)[i] = kernel_groups[i];			}		}		return ngids;	}}#endif//#define __NR_setgroups        81#ifdef L___syscall_setgroups#include <unistd.h>#include <grp.h>#define __NR___syscall_setgroups __NR_setgroupsstatic inline_syscall2(int, __syscall_setgroups, size_t, size, const __kernel_gid_t *, list);int setgroups (size_t n, const gid_t *groups){	if (n > (size_t)sysconf(_SC_NGROUPS_MAX)) {		__set_errno (EINVAL);		return -1;	} else {		size_t i;		__kernel_gid_t kernel_groups[n];		for (i = 0; i < n; i++) {			kernel_groups[i] = (groups)[i];			if (groups[i] != (gid_t) ((__kernel_gid_t)groups[i])) {				__set_errno (EINVAL);				return -1;			}		}		return(__syscall_setgroups(n, kernel_groups));	}}#endif//#define __NR_select           82#ifdef L_select//Used as a fallback if _newselect isn't available...#ifndef __NR__newselect#include <unistd.h>extern int select(int n, fd_set *readfds, fd_set *writefds, 		fd_set *exceptfds, struct timeval *timeout);_syscall5(int, select, int, n, fd_set *, readfds, fd_set *, writefds,		fd_set *, exceptfds, struct timeval *, timeout);#endif#endif//#define __NR_symlink          83#ifdef L_symlink#include <unistd.h>_syscall2(int, symlink, const char *, oldpath, const char *, newpath);#endif//#define __NR_oldlstat         84//#define __NR_readlink         85#ifdef L_readlink#include <unistd.h>_syscall3(int, readlink, const char *, path, char *, buf, size_t, bufsiz);#endif//#define __NR_uselib           86#ifdef L_uselib#include <unistd.h>_syscall1(int, uselib, const char *, library);#endif//#define __NR_swapon           87#ifdef L_swapon#include <sys/swap.h>_syscall2(int, swapon, const char *, path, int, swapflags);#endif//#define __NR_reboot           88#ifdef L__reboot#define __NR__reboot __NR_rebootextern int _reboot(int magic, int magic2, int flag);_syscall3(int, _reboot, int, magic, int, magic2, int, flag);int reboot(int flag){	return (_reboot((int) 0xfee1dead, 672274793, flag));}#endif//#define __NR_readdir          89//#define __NR_mmap             90#ifdef L__mmap#define __NR__mmap __NR_mmap#include <unistd.h>#include <sys/mman.h>extern __ptr_t _mmap(unsigned long *buffer);_syscall1(__ptr_t, _mmap, unsigned long *, buffer);__ptr_t mmap(__ptr_t addr, size_t len, int prot,			 int flags, int fd, __off_t offset){	unsigned long buffer[6];	buffer[0] = (unsigned long) addr;	buffer[1] = (unsigned long) len;	buffer[2] = (unsigned long) prot;	buffer[3] = (unsigned long) flags;	buffer[4] = (unsigned long) fd;	buffer[5] = (unsigned long) offset;	return (__ptr_t) _mmap(buffer);}#endif//#define __NR_munmap           91#ifdef L_munmap#include <unistd.h>#include <sys/mman.h>_syscall2(int, munmap, void *, start, size_t, length);#endif//#define __NR_truncate         92#ifdef L_truncate#include <unistd.h>_syscall2(int, truncate, const char *, path, __off_t, length);#endif//#define __NR_ftruncate        93#ifdef L_ftruncate#include <unistd.h>_syscall2(int, ftruncate, int, fd, __off_t, length);#endif//#define __NR_fchmod           94#ifdef L___syscall_fchmod#include <sys/stat.h>#define __NR___syscall_fchmod __NR_fchmodstatic inline _syscall2(int, __syscall_fchmod, int, fildes, __kernel_mode_t, mode);int fchmod(int fildes, mode_t mode){	return(__syscall_fchmod(fildes, mode));}#endif//#define __NR_fchown           95#ifdef L___syscall_fchown#include <unistd.h>#define __NR___syscall_fchown __NR_fchownstatic inline_syscall3(int, __syscall_fchown, int, fd, __kernel_uid_t, owner, __kernel_gid_t, group);int fchown(int fd, uid_t owner, gid_t group){	return(__syscall_fchown(fd, owner, group));}#endif//#define __NR_getpriority      96#ifdef L___syscall_getpriority#include <sys/resource.h>#define __NR___syscall_getpriority __NR_getpriority_syscall2(int, __syscall_getpriority, __priority_which_t, which, id_t, who);/* The return value of __syscall_getpriority is biased by this value * to avoid returning negative values.  */#define PZERO 20int getpriority (enum __priority_which which, id_t who){	int res;	res = __syscall_getpriority(which, who);	if (res >= 0)		res = PZERO - res;	return res;}#endif//#define __NR_setpriority      97#ifdef L_setpriority#include <sys/resource.h>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -