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

📄 signal32.c

📁 是关于linux2.5.1的完全源码
💻 C
📖 第 1 页 / 共 4 页
字号:
	}	ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);	if (!ret && oact) {		switch (_NSIG_WORDS) {		case 4:			set32.sig[7] = (old_ka.sa.sa_mask.sig[3] >> 32);			set32.sig[6] = old_ka.sa.sa_mask.sig[3];		case 3:			set32.sig[5] = (old_ka.sa.sa_mask.sig[2] >> 32);			set32.sig[4] = old_ka.sa.sa_mask.sig[2];		case 2:			set32.sig[3] = (old_ka.sa.sa_mask.sig[1] >> 32);			set32.sig[2] = old_ka.sa.sa_mask.sig[1];		case 1:			set32.sig[1] = (old_ka.sa.sa_mask.sig[0] >> 32);			set32.sig[0] = old_ka.sa.sa_mask.sig[0];		}		ret = put_user((long)old_ka.sa.sa_handler, &oact->sa_handler);		ret |= __copy_to_user(&oact->sa_mask, &set32,				      sizeof(sigset32_t));		ret |= __put_user(old_ka.sa.sa_flags, &oact->sa_flags);	}  	PPCDBG(PPCDBG_SIGNAL, "sys32_rt_sigaction - exiting - sig=%x \n", sig);	return ret;}extern asmlinkage long sys_rt_sigprocmask(int how, sigset_t *set, sigset_t *oset,					  size_t sigsetsize);/* Note: it is necessary to treat how as an unsigned int,  * with the corresponding cast to a signed int to insure that the  * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode) * and the register representation of a signed int (msr in 64-bit mode) is performed. */asmlinkage long sys32_rt_sigprocmask(u32 how, sigset32_t *set, sigset32_t *oset, size_t sigsetsize){	sigset_t s;	sigset32_t s32;	int ret;	mm_segment_t old_fs = get_fs();	PPCDBG(PPCDBG_SIGNAL, "sys32_rt_sigprocmask - entered how=%x \n", (int)how);		if (set) {		if (copy_from_user (&s32, set, sizeof(sigset32_t)))			return -EFAULT;    		switch (_NSIG_WORDS) {		case 4: s.sig[3] = s32.sig[6] | (((long)s32.sig[7]) << 32);		case 3: s.sig[2] = s32.sig[4] | (((long)s32.sig[5]) << 32);		case 2: s.sig[1] = s32.sig[2] | (((long)s32.sig[3]) << 32);		case 1: s.sig[0] = s32.sig[0] | (((long)s32.sig[1]) << 32);		}	}		set_fs (KERNEL_DS);	ret = sys_rt_sigprocmask((int)how, set ? &s : NULL, oset ? &s : NULL,				 sigsetsize); 	set_fs (old_fs);	if (ret) return ret;	if (oset) {		switch (_NSIG_WORDS) {		case 4: s32.sig[7] = (s.sig[3] >> 32); s32.sig[6] = s.sig[3];		case 3: s32.sig[5] = (s.sig[2] >> 32); s32.sig[4] = s.sig[2];		case 2: s32.sig[3] = (s.sig[1] >> 32); s32.sig[2] = s.sig[1];		case 1: s32.sig[1] = (s.sig[0] >> 32); s32.sig[0] = s.sig[0];		}		if (copy_to_user (oset, &s32, sizeof(sigset32_t)))			return -EFAULT;	}	return 0;}extern asmlinkage long sys_rt_sigpending(sigset_t *set, size_t sigsetsize);asmlinkage long sys32_rt_sigpending(sigset32_t *set,   __kernel_size_t32 sigsetsize){	sigset_t s;	sigset32_t s32;	int ret;	mm_segment_t old_fs = get_fs();			set_fs (KERNEL_DS);	ret = sys_rt_sigpending(&s, sigsetsize);	set_fs (old_fs);	if (!ret) {		switch (_NSIG_WORDS) {		case 4: s32.sig[7] = (s.sig[3] >> 32); s32.sig[6] = s.sig[3];		case 3: s32.sig[5] = (s.sig[2] >> 32); s32.sig[4] = s.sig[2];		case 2: s32.sig[3] = (s.sig[1] >> 32); s32.sig[2] = s.sig[1];		case 1: s32.sig[1] = (s.sig[0] >> 32); s32.sig[0] = s.sig[0];		}		if (copy_to_user (set, &s32, sizeof(sigset32_t)))			return -EFAULT;	}	return ret;}siginfo_t32 *siginfo64to32(siginfo_t32 *d, siginfo_t *s){	memset (d, 0, sizeof(siginfo_t32));	d->si_signo = s->si_signo;	d->si_errno = s->si_errno;	d->si_code = s->si_code;	if (s->si_signo >= SIGRTMIN) {		d->si_pid = s->si_pid;		d->si_uid = s->si_uid;				d->si_int = s->si_int;	} else switch (s->si_signo) {	/* XXX: What about POSIX1.b timers */	case SIGCHLD:		d->si_pid = s->si_pid;		d->si_status = s->si_status;		d->si_utime = s->si_utime;		d->si_stime = s->si_stime;		break;	case SIGSEGV:	case SIGBUS:	case SIGFPE:	case SIGILL:		d->si_addr = (long)(s->si_addr);        break;	case SIGPOLL:		d->si_band = s->si_band;		d->si_fd = s->si_fd;		break;	default:		d->si_pid = s->si_pid;		d->si_uid = s->si_uid;		break;	}	return d;}extern asmlinkage longsys_rt_sigtimedwait(const sigset_t *uthese, siginfo_t *uinfo,		    const struct timespec *uts, size_t sigsetsize);asmlinkage longsys32_rt_sigtimedwait(sigset32_t *uthese, siginfo_t32 *uinfo,		      struct timespec32 *uts, __kernel_size_t32 sigsetsize){	sigset_t s;	sigset32_t s32;	struct timespec t;	int ret;	mm_segment_t old_fs = get_fs();	siginfo_t info;	siginfo_t32 info32;			if (copy_from_user (&s32, uthese, sizeof(sigset32_t)))		return -EFAULT;	switch (_NSIG_WORDS) {	case 4: s.sig[3] = s32.sig[6] | (((long)s32.sig[7]) << 32);	case 3: s.sig[2] = s32.sig[4] | (((long)s32.sig[5]) << 32);	case 2: s.sig[1] = s32.sig[2] | (((long)s32.sig[3]) << 32);	case 1: s.sig[0] = s32.sig[0] | (((long)s32.sig[1]) << 32);	}	if (uts) {		ret = get_user (t.tv_sec, &uts->tv_sec);		ret |= __get_user (t.tv_nsec, &uts->tv_nsec);		if (ret)			return -EFAULT;	}	set_fs (KERNEL_DS);	if (uts) 	{		ret = sys_rt_sigtimedwait(&s, &info, &t, sigsetsize);	} else {		ret = sys_rt_sigtimedwait(&s, &info, (struct timespec *)uts, sigsetsize);	}		set_fs (old_fs);	if (ret >= 0 && uinfo) {		if (copy_to_user (uinfo, siginfo64to32(&info32, &info),				  sizeof(siginfo_t32)))			return -EFAULT;	}	return ret;}siginfo_t *siginfo32to64(siginfo_t *d, siginfo_t32 *s){	d->si_signo = s->si_signo;	d->si_errno = s->si_errno;	d->si_code = s->si_code;	if (s->si_signo >= SIGRTMIN) {		d->si_pid = s->si_pid;		d->si_uid = s->si_uid;		d->si_int = s->si_int;        	} else switch (s->si_signo) {	/* XXX: What about POSIX1.b timers */	case SIGCHLD:		d->si_pid = s->si_pid;		d->si_status = s->si_status;		d->si_utime = s->si_utime;		d->si_stime = s->si_stime;		break;	case SIGSEGV:	case SIGBUS:	case SIGFPE:	case SIGILL:		d->si_addr = (void *)A(s->si_addr);  		break;	case SIGPOLL:		d->si_band = s->si_band;		d->si_fd = s->si_fd;		break;	default:		d->si_pid = s->si_pid;		d->si_uid = s->si_uid;		break;	}	return d;}extern asmlinkage long sys_rt_sigqueueinfo(int pid, int sig, siginfo_t *uinfo);/* Note: it is necessary to treat pid and sig as unsigned ints, * with the corresponding cast to a signed int to insure that the  * proper conversion (sign extension) between the register representation of a signed int (msr in 32-bit mode) * and the register representation of a signed int (msr in 64-bit mode) is performed. */asmlinkage long sys32_rt_sigqueueinfo(u32 pid, u32 sig, siginfo_t32 *uinfo){	siginfo_t info;	siginfo_t32 info32;	int ret;	mm_segment_t old_fs = get_fs();		if (copy_from_user (&info32, uinfo, sizeof(siginfo_t32)))		return -EFAULT;    	/* XXX: Is this correct? */	siginfo32to64(&info, &info32);	set_fs (KERNEL_DS);	ret = sys_rt_sigqueueinfo((int)pid, (int)sig, &info);	set_fs (old_fs);	return ret;}int do_signal(sigset_t *oldset, struct pt_regs *regs);int sys32_rt_sigsuspend(sigset32_t* unewset, size_t sigsetsize, int p3, int p4, int p6, int p7, struct pt_regs *regs){	sigset_t saveset, newset;		sigset32_t s32;	/* XXX: Don't preclude handling different sized sigset_t's.  */	if (sigsetsize != sizeof(sigset_t))		return -EINVAL;	if (copy_from_user(&s32, unewset, sizeof(s32)))		return -EFAULT;	/* Swap the 2 words of the 64-bit sigset_t (they are stored in the "wrong" endian in 32-bit user storage). */	switch (_NSIG_WORDS) 	{		case 4: newset.sig[3] = s32.sig[6] | (((long)s32.sig[7]) << 32);		case 3: newset.sig[2] = s32.sig[4] | (((long)s32.sig[5]) << 32);		case 2: newset.sig[1] = s32.sig[2] | (((long)s32.sig[3]) << 32);		case 1: newset.sig[0] = s32.sig[0] | (((long)s32.sig[1]) << 32);	}	sigdelsetmask(&newset, ~_BLOCKABLE);	spin_lock_irq(&current->sigmask_lock);	saveset = current->blocked;	current->blocked = newset;	recalc_sigpending();	spin_unlock_irq(&current->sigmask_lock);	regs->gpr[3] = -EINTR;	while (1) {		current->state = TASK_INTERRUPTIBLE;		schedule();		if (do_signal(&saveset, regs))			return regs->gpr[3];	}}/* * Set up a rt signal frame. */static voidsetup_rt_frame32(struct pt_regs *regs, struct sigregs32 *frame,            unsigned int newsp){	unsigned int copyreg4,copyreg5;	struct rt_sigframe_32 * rt_sf = (struct rt_sigframe_32 *) (u64)newsp;  	if (verify_area(VERIFY_WRITE, frame, sizeof(*frame)))		goto badframe;	if (regs->msr & MSR_FP)		giveup_fpu(current);	/***************************************************************/	/*                                                             */ 	/* Copy the register contents for the pt_regs structure on the */	/*   kernel stack to the elf_gregset_t32 structure on the user */	/*   stack. This is a copy of 64 bit register values to 32 bit */	/*   register values. The high order 32 bits of the 64 bit     */	/*   registers are not needed since a 32 bit application is    */	/*   running and the saved registers are the contents of the   */	/*   user registers at the time of a system call.              */	/*                                                             */	/* The values saved on the user stack will be restored into    */	/*  the registers during the signal return processing          */	/*                                                             */	/* Note the +1 is needed in order to get the lower 32 bits     */	/*  of 64 bit register                                         */	/***************************************************************/	if (__copy_to_user(&frame->gp_regs[0], (u32*)(&regs->gpr[0])+1, sizeof(u32))	    || __copy_to_user(&frame->gp_regs[1], (u32*)(&regs->gpr[1])+1, sizeof(u32))	    || __copy_to_user(&frame->gp_regs[2], (u32*)(&regs->gpr[2])+1, sizeof(u32))	    || __copy_to_user(&frame->gp_regs[3], (u32*)(&regs->gpr[3])+1, sizeof(u32))	    || __copy_to_user(&frame->gp_regs[4], (u32*)(&regs->gpr[4])+1, sizeof(u32))	    || __copy_to_user(&frame->gp_regs[5], (u32*)(&regs->gpr[5])+1, sizeof(u32))	    || __copy_to_user(&frame->gp_regs[6], (u32*)(&regs->gpr[6])+1, sizeof(u32))	    || __copy_to_user(&frame->gp_regs[7], (u32*)(&regs->gpr[7])+1, sizeof(u32))	    || __copy_to_user(&frame->gp_regs[8], (u32*)(&regs->gpr[8])+1, sizeof(u32))	    || __copy_to_user(&frame->gp_regs[9], (u32*)(&regs->gpr[9])+1, sizeof(u32))	    || __copy_to_user(&frame->gp_regs[10], (u32*)(&regs->gpr[10])+1, sizeof(u32))	    || __copy_to_user(&frame->gp_regs[11], (u32*)(&regs->gpr[11])+1, sizeof(u32))	    || __copy_to_user(&frame->gp_regs[12], (u32*)(&regs->gpr[12])+1, sizeof(u32))	    || __copy_to_user(&frame->gp_regs[13], (u32*)(&regs->gpr[13])+1, sizeof(u32))	    || __copy_to_user(&frame->gp_regs[14], (u32*)(&regs->gpr[14])+1, sizeof(u32))	    || __copy_to_user(&frame->gp_regs[15], (u32*)(&regs->gpr[15])+1, sizeof(u32))	    || __copy_to_user(&frame->gp_regs[16], (u32*)(&regs->gpr[16])+1, sizeof(u32))	    || __copy_to_user(&frame->gp_regs[17], (u32*)(&regs->gpr[17])+1, sizeof(u32))	    || __copy_to_user(&frame->gp_regs[18], (u32*)(&regs->gpr[18])+1, sizeof(u32))	    || __copy_to_user(&frame->gp_regs[19], (u32*)(&regs->gpr[19])+1, sizeof(u32))	    || __copy_to_user(&frame->gp_regs[20], (u32*)(&regs->gpr[20])+1, sizeof(u32))	    || __copy_to_user(&frame->gp_regs[21], (u32*)(&regs->gpr[21])+1, sizeof(u32))	    || __copy_to_user(&frame->gp_regs[22], (u32*)(&regs->gpr[22])+1, sizeof(u32))	    || __copy_to_user(&frame->gp_regs[23], (u32*)(&regs->gpr[23])+1, sizeof(u32))	    || __copy_to_user(&frame->gp_regs[24], (u32*)(&regs->gpr[24])+1, sizeof(u32))	    || __copy_to_user(&frame->gp_regs[25], (u32*)(&regs->gpr[25])+1, sizeof(u32))	    || __copy_to_user(&frame->gp_regs[26], (u32*)(&regs->gpr[26])+1, sizeof(u32))	    || __copy_to_user(&frame->gp_regs[27], (u32*)(&regs->gpr[27])+1, sizeof(u32))	    || __copy_to_user(&frame->gp_regs[28], (u32*)(&regs->gpr[28])+1, sizeof(u32))	    || __copy_to_user(&frame->gp_regs[29], (u32*)(&regs->gpr[29])+1, sizeof(u32))	    || __copy_to_user(&frame->gp_regs[30], (u32*)(&regs->gpr[30])+1, sizeof(u32))	    || __copy_to_user(&frame->gp_regs[31], (u32*)(&regs->gpr[31])+1, sizeof(u32))) 

⌨️ 快捷键说明

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