You could put the common definitions into a base class and share them 
via inheritance. Currently X86Linux32 and X86Linux64 inherit directly 
from the Linux class, but there's no reason they need to. You could 
create an X86Linux base that inherited from Linux and have the existing 
classes inherit from that instead.

Gabe

Vince Weaver wrote:
> Implement rlimit/rusage on x86.  This is needed for the gcc benchmark.
> Unfortunately this involves a lot of code duplication.
>
>
> diff -r 8dc7a139adc9 src/arch/x86/linux/linux.hh
> --- a/src/arch/x86/linux/linux.hh     Mon Sep 21 23:39:12 2009 -0400
> +++ b/src/arch/x86/linux/linux.hh     Tue Sep 22 00:04:11 2009 -0400
> @@ -127,6 +127,28 @@
>          uint64_t mem_unit;  /* Memory unit size in bytes */
>     } tgt_sysinfo;
>  
> +   //@{
> +       /// For getrusage().
> +       static const int TGT_RUSAGE_SELF     = 0;
> +       static const int TGT_RUSAGE_CHILDREN = -1;
> +       static const int TGT_RUSAGE_BOTH     = -2;
> +   //@}
> +
> +       /// Resource enumeration for getrlimit().
> +   enum rlimit_resources {
> +       TGT_RLIMIT_CPU = 0,
> +       TGT_RLIMIT_FSIZE = 1,
> +       TGT_RLIMIT_DATA = 2,
> +       TGT_RLIMIT_STACK = 3,
> +       TGT_RLIMIT_CORE = 4,
> +       TGT_RLIMIT_RSS = 5,
> +       TGT_RLIMIT_NOFILE = 6,
> +       TGT_RLIMIT_AS = 7,
> +       TGT_RLIMIT_VMEM = 7,
> +       TGT_RLIMIT_NPROC = 8,
> +       TGT_RLIMIT_MEMLOCK = 9,
> +   };
> +
>     typedef uint64_t timet;
>  
>  };
> @@ -196,6 +218,53 @@
>         uint32_t mem_unit;  /* Memory unit size in bytes */
>     } tgt_sysinfo;
>  
> +   //@{
> +       /// For getrusage().
> +       static const int TGT_RUSAGE_SELF     = 0;
> +       static const int TGT_RUSAGE_CHILDREN = -1;
> +       static const int TGT_RUSAGE_BOTH     = -2;
> +   //@}
> +
> +       /// For gettimeofday().
> +       struct timeval {
> +                 int32_t tv_sec;         //!< seconds
> +                 int32_t tv_usec;        //!< microseconds
> +       };
> +
> +       struct rusage {
> +         struct timeval ru_utime;        //!< user time used
> +         struct timeval ru_stime;        //!< system time used
> +         int32_t ru_maxrss;              //!< max rss
> +         int32_t ru_ixrss;               //!< integral shared memory size
> +         int32_t ru_idrss;               //!< integral unshared data "
> +         int32_t ru_isrss;               //!< integral unshared stack "
> +         int32_t ru_minflt;              //!< page reclaims - total vmfaults
> +         int32_t ru_majflt;              //!< page faults
> +         int32_t ru_nswap;               //!< swaps
> +         int32_t ru_inblock;             //!< block input operations
> +         int32_t ru_oublock;             //!< block output operations
> +         int32_t ru_msgsnd;              //!< messages sent
> +         int32_t ru_msgrcv;              //!< messages received
> +         int32_t ru_nsignals;            //!< signals received
> +         int32_t ru_nvcsw;               //!< voluntary context switches
> +         int32_t ru_nivcsw;              //!< involuntary "
> +      };
> +
> +       /// Resource enumeration for getrlimit().
> +   enum rlimit_resources {
> +       TGT_RLIMIT_CPU = 0,
> +       TGT_RLIMIT_FSIZE = 1,
> +       TGT_RLIMIT_DATA = 2,
> +       TGT_RLIMIT_STACK = 3,
> +       TGT_RLIMIT_CORE = 4,
> +       TGT_RLIMIT_RSS = 5,
> +       TGT_RLIMIT_NOFILE = 6,
> +       TGT_RLIMIT_AS = 7,
> +       TGT_RLIMIT_VMEM = 7,
> +       TGT_RLIMIT_NPROC = 8,
> +       TGT_RLIMIT_MEMLOCK = 9,
> +   };
> +
>     typedef uint32_t timet;
>  
>  };
> diff -r 8dc7a139adc9 src/arch/x86/linux/syscalls.cc
> --- a/src/arch/x86/linux/syscalls.cc  Mon Sep 21 23:39:12 2009 -0400
> +++ b/src/arch/x86/linux/syscalls.cc  Tue Sep 22 00:04:11 2009 -0400
> @@ -325,8 +325,8 @@
>      /*  94 */ SyscallDesc("lchown", unimplementedFunc),
>      /*  95 */ SyscallDesc("umask", unimplementedFunc),
>      /*  96 */ SyscallDesc("gettimeofday", unimplementedFunc),
> -    /*  97 */ SyscallDesc("getrlimit", unimplementedFunc),
> -    /*  98 */ SyscallDesc("getrusage", unimplementedFunc),
> +    /*  97 */ SyscallDesc("getrlimit", getrlimitFunc<X86Linux64>),
> +    /*  98 */ SyscallDesc("getrusage", getrusageFunc<X86Linux64>),
>      /*  99 */ SyscallDesc("sysinfo", sysinfoFunc<X86Linux64>),
>      /* 100 */ SyscallDesc("times", ignoreFunc),
>      /* 101 */ SyscallDesc("ptrace", unimplementedFunc),
> @@ -583,8 +583,8 @@
>      /*  73 */ SyscallDesc("sigpending", unimplementedFunc),
>      /*  74 */ SyscallDesc("sethostname", unimplementedFunc),
>      /*  75 */ SyscallDesc("setrlimit", ignoreFunc),
> -    /*  76 */ SyscallDesc("getrlimit", unimplementedFunc),
> -    /*  77 */ SyscallDesc("getrusage", unimplementedFunc),
> +    /*  76 */ SyscallDesc("getrlimit", getrlimitFunc<X86Linux32>),
> +    /*  77 */ SyscallDesc("getrusage", getrusageFunc<X86Linux32>),
>      /*  78 */ SyscallDesc("gettimeofday", unimplementedFunc),
>      /*  79 */ SyscallDesc("settimeofday", unimplementedFunc),
>      /*  80 */ SyscallDesc("getgroups", unimplementedFunc),
> _______________________________________________
> m5-dev mailing list
> [email protected]
> http://m5sim.org/mailman/listinfo/m5-dev
>   

_______________________________________________
m5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/m5-dev

Reply via email to