syscall_emul.cc (11875:8e928c0f98d1) syscall_emul.cc (11885:79af314e9f0d)
1/*
2 * Copyright (c) 2003-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 715 unchanged lines hidden (view full) ---

724 /**
725 * Alpha Linux convention for pipe() is that fd[0] is returned as
726 * the return value of the function, and fd[1] is returned in r20.
727 */
728 tc->setIntReg(SyscallPseudoReturnReg, tgt_fds[1]);
729 return sim_fds[0];
730}
731
1/*
2 * Copyright (c) 2003-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 715 unchanged lines hidden (view full) ---

724 /**
725 * Alpha Linux convention for pipe() is that fd[0] is returned as
726 * the return value of the function, and fd[1] is returned in r20.
727 */
728 tc->setIntReg(SyscallPseudoReturnReg, tgt_fds[1]);
729 return sim_fds[0];
730}
731
732SyscallReturn
733setpgidFunc(SyscallDesc *desc, int callnum, Process *process,
734 ThreadContext *tc)
735{
736 int index = 0;
737 int pid = process->getSyscallArg(tc, index);
738 int pgid = process->getSyscallArg(tc, index);
732
739
740 if (pgid < 0)
741 return -EINVAL;
742
743 if (pid == 0) {
744 process->setpgid(process->pid());
745 return 0;
746 }
747
748 Process *matched_ph = NULL;
749 System *sysh = tc->getSystemPtr();
750
751 // Retrieves process pointer from active/suspended thread contexts.
752 for (int i = 0; i < sysh->numContexts(); i++) {
753 if (sysh->threadContexts[i]->status() != ThreadContext::Halted) {
754 Process *temp_h = sysh->threadContexts[i]->getProcessPtr();
755 Process *walk_ph = (Process*)temp_h;
756
757 if (walk_ph && walk_ph->pid() == process->pid())
758 matched_ph = walk_ph;
759 }
760 }
761
762 assert(matched_ph != NULL);
763 matched_ph->setpgid((pgid == 0) ? matched_ph->pid() : pgid);
764
765 return 0;
766}
767
733SyscallReturn
734getpidPseudoFunc(SyscallDesc *desc, int callnum, Process *process,
735 ThreadContext *tc)
736{
737 // Make up a PID. There's no interprocess communication in
738 // fake_syscall mode, so there's no way for a process to know it's
739 // not getting a unique value.
740

--- 34 unchanged lines hidden (view full) ---

775 warn("Ignoring call to setuid(%d)\n", process->getSyscallArg(tc, index));
776 return 0;
777}
778
779SyscallReturn
780getpidFunc(SyscallDesc *desc, int callnum, Process *process,
781 ThreadContext *tc)
782{
768SyscallReturn
769getpidPseudoFunc(SyscallDesc *desc, int callnum, Process *process,
770 ThreadContext *tc)
771{
772 // Make up a PID. There's no interprocess communication in
773 // fake_syscall mode, so there's no way for a process to know it's
774 // not getting a unique value.
775

--- 34 unchanged lines hidden (view full) ---

810 warn("Ignoring call to setuid(%d)\n", process->getSyscallArg(tc, index));
811 return 0;
812}
813
814SyscallReturn
815getpidFunc(SyscallDesc *desc, int callnum, Process *process,
816 ThreadContext *tc)
817{
783 // Make up a PID. There's no interprocess communication in
784 // fake_syscall mode, so there's no way for a process to know it's
785 // not getting a unique value.
818 return process->tgid();
819}
786
820
787 tc->setIntReg(SyscallPseudoReturnReg, process->ppid()); //PID
821SyscallReturn
822gettidFunc(SyscallDesc *desc, int callnum, Process *process,
823 ThreadContext *tc)
824{
788 return process->pid();
789}
790
791SyscallReturn
792getppidFunc(SyscallDesc *desc, int callnum, Process *process,
793 ThreadContext *tc)
794{
795 return process->ppid();

--- 160 unchanged lines hidden ---
825 return process->pid();
826}
827
828SyscallReturn
829getppidFunc(SyscallDesc *desc, int callnum, Process *process,
830 ThreadContext *tc)
831{
832 return process->ppid();

--- 160 unchanged lines hidden ---