syscall_emul.hh (3669:3607aaed36b6) syscall_emul.hh (3670:1ad04efc333e)
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;

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

929template <class OS>
930SyscallReturn
931getrusageFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
932 ThreadContext *tc)
933{
934 int who = tc->getSyscallArg(0); // THREAD, SELF, or CHILDREN
935 TypedBufferArg<typename OS::rusage> rup(tc->getSyscallArg(1));
936
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;

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

929template <class OS>
930SyscallReturn
931getrusageFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
932 ThreadContext *tc)
933{
934 int who = tc->getSyscallArg(0); // THREAD, SELF, or CHILDREN
935 TypedBufferArg<typename OS::rusage> rup(tc->getSyscallArg(1));
936
937 if (who != OS::TGT_RUSAGE_SELF) {
938 // don't really handle THREAD or CHILDREN, but just warn and
939 // plow ahead
940 warn("getrusage() only supports RUSAGE_SELF. Parameter %d ignored.",
941 who);
942 }
943
944 getElapsedTime(rup->ru_utime.tv_sec, rup->ru_utime.tv_usec);
945 rup->ru_utime.tv_sec = htog(rup->ru_utime.tv_sec);
946 rup->ru_utime.tv_usec = htog(rup->ru_utime.tv_usec);
947
937 rup->ru_utime.tv_sec = 0;
938 rup->ru_utime.tv_usec = 0;
948 rup->ru_stime.tv_sec = 0;
949 rup->ru_stime.tv_usec = 0;
950 rup->ru_maxrss = 0;
951 rup->ru_ixrss = 0;
952 rup->ru_idrss = 0;
953 rup->ru_isrss = 0;
954 rup->ru_minflt = 0;
955 rup->ru_majflt = 0;
956 rup->ru_nswap = 0;
957 rup->ru_inblock = 0;
958 rup->ru_oublock = 0;
959 rup->ru_msgsnd = 0;
960 rup->ru_msgrcv = 0;
961 rup->ru_nsignals = 0;
962 rup->ru_nvcsw = 0;
963 rup->ru_nivcsw = 0;
964
939 rup->ru_stime.tv_sec = 0;
940 rup->ru_stime.tv_usec = 0;
941 rup->ru_maxrss = 0;
942 rup->ru_ixrss = 0;
943 rup->ru_idrss = 0;
944 rup->ru_isrss = 0;
945 rup->ru_minflt = 0;
946 rup->ru_majflt = 0;
947 rup->ru_nswap = 0;
948 rup->ru_inblock = 0;
949 rup->ru_oublock = 0;
950 rup->ru_msgsnd = 0;
951 rup->ru_msgrcv = 0;
952 rup->ru_nsignals = 0;
953 rup->ru_nvcsw = 0;
954 rup->ru_nivcsw = 0;
955
956 switch (who) {
957 case OS::TGT_RUSAGE_SELF:
958 getElapsedTime(rup->ru_utime.tv_sec, rup->ru_utime.tv_usec);
959 rup->ru_utime.tv_sec = htog(rup->ru_utime.tv_sec);
960 rup->ru_utime.tv_usec = htog(rup->ru_utime.tv_usec);
961 break;
962
963 case OS::TGT_RUSAGE_CHILDREN:
964 // do nothing. We have no child processes, so they take no time.
965 break;
966
967 default:
968 // don't really handle THREAD or CHILDREN, but just warn and
969 // plow ahead
970 warn("getrusage() only supports RUSAGE_SELF. Parameter %d ignored.",
971 who);
972 }
973
965 rup.copyOut(tc->getMemPort());
966
967 return 0;
968}
969
970
971
972
973#endif // __SIM_SYSCALL_EMUL_HH__
974 rup.copyOut(tc->getMemPort());
975
976 return 0;
977}
978
979
980
981
982#endif // __SIM_SYSCALL_EMUL_HH__