syscall emulation: Enabled getrlimit and getrusage for x86.
authorMarc Orr <marc.orr@gmail.com>
Tue, 7 Aug 2012 02:52:56 +0000 (19:52 -0700)
committerMarc Orr <marc.orr@gmail.com>
Tue, 7 Aug 2012 02:52:56 +0000 (19:52 -0700)
Added/moved rlimit constants to base linux header file.

This patch is a revised version of Vince Weaver's earlier patch.

src/arch/alpha/linux/linux.hh
src/arch/arm/linux/linux.hh
src/arch/arm/linux/process.cc
src/arch/mips/linux/linux.hh
src/arch/sparc/linux/linux.hh
src/arch/x86/linux/syscalls.cc
src/kern/linux/linux.hh

index 443f70d81eee28e49cad717d8926316aefacf4c4..115508405710070bd8af22dbd0495654c5d9eabb 100644 (file)
@@ -83,13 +83,6 @@ class AlphaLinux : public Linux
     static const unsigned GSI_IEEE_FP_CONTROL = 45;
     //@}
 
-    //@{
-    /// For getrusage().
-    static const int TGT_RUSAGE_SELF     = 0;
-    static const int TGT_RUSAGE_CHILDREN = -1;
-    static const int TGT_RUSAGE_BOTH     = -2;
-    //@}
-
     //@{
     /// For setsysinfo().
     static const unsigned SSI_IEEE_FP_CONTROL = 14; //!< ieee_set_fp_control()
@@ -129,21 +122,11 @@ class AlphaLinux : public Linux
     /// For table().
     static const int TBL_SYSINFO = 12;
 
-    /// 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,
-        TGT_RLIMIT_LOCKS = 10
-    };
+    /// Resource constants for getrlimit() (overide some generics).
+    static const unsigned TGT_RLIMIT_NPROC = 8;
+    static const unsigned TGT_RLIMIT_AS = 7;
+    static const unsigned TGT_RLIMIT_NOFILE = 6;
+    static const unsigned TGT_RLIMIT_MEMLOCK = 9;
    
     typedef struct {
        int64_t  uptime;    /* Seconds since boot */
index 55af574d38f93d5d24da849e9265cb51bbdd0c3f..5a3e68a78fd54452a214405a4c724da139c60968 100644 (file)
@@ -93,31 +93,9 @@ class ArmLinux : public Linux
     static const unsigned TGT_MAP_ANONYMOUS = 0x20;
     static const unsigned TGT_MAP_FIXED     = 0x10;
 
-    //@{
-    /// For getrusage().
-    static const int TGT_RUSAGE_SELF = 0;
-    static const int TGT_RUSAGE_CHILDREN = -1;
-    static const int TGT_RUSAGE_BOTH = -2;
-    //@}
-
     /// For table().
     static const int TBL_SYSINFO = 12;
 
-    /// 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_NPROC = 6,
-        TGT_RLIMIT_NOFILE = 7,
-        TGT_RLIMIT_MEMLOCK = 8,
-        TGT_RLIMIT_AS = 9,
-        TGT_RLIMIT_LOCKS = 10
-    };
-
     /// Limit struct for getrlimit/setrlimit.
     struct rlimit {
         uint32_t  rlim_cur;     //!< soft limit
index a30b1f440afa988aa0c9594fa5b8c2318c4a4891..088f9907e2ca99a680f11fe83ce60794ccadad69 100644 (file)
@@ -151,7 +151,7 @@ SyscallDesc ArmLinuxProcess::syscallDescs[] = {
     /* 73 */ SyscallDesc("sigpending", unimplementedFunc),
     /* 74 */ SyscallDesc("sethostname", ignoreFunc),
     /* 75 */ SyscallDesc("setrlimit", ignoreFunc),
-    /* 76 */ SyscallDesc("getrlimit", unimplementedFunc),
+    /* 76 */ SyscallDesc("getrlimit", getrlimitFunc<ArmLinux>),
     /* 77 */ SyscallDesc("getrusage", getrusageFunc<ArmLinux>),
     /* 78 */ SyscallDesc("gettimeofday", gettimeofdayFunc<ArmLinux>),
     /* 79 */ SyscallDesc("settimeofday", unimplementedFunc),
index 85a647e3d79b9742bb606c38939904b50183d260..6ae5b1717997ae74206278a6d6a9d6e2e07a86a2 100644 (file)
@@ -78,13 +78,6 @@ class MipsLinux : public Linux
     static const unsigned GSI_CLK_TCK = 42;        //!< clock freq in Hz
     //@}
 
-    //@{
-    /// For getrusage().
-    static const int TGT_RUSAGE_SELF = 0;
-    static const int TGT_RUSAGE_CHILDREN = -1;
-    static const int TGT_RUSAGE_BOTH = -2;
-    //@}
-
     //@{
     /// For setsysinfo().
     static const unsigned SSI_IEEE_FP_CONTROL = 14; //!< ieee_set_fp_control()
@@ -121,22 +114,12 @@ class MipsLinux : public Linux
     /// For table().
     static const int TBL_SYSINFO = 12;
 
-    /// Resource enumeration for getrlimit()/setrlimit().
-    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_NOFILE = 5,
-        TGT_RLIMIT_AS = 6,
-        TGT_RLIMIT_RSS = 7,
-        TGT_RLIMIT_VMEM = 7,
-        TGT_RLIMIT_NPROC = 8,
-        TGT_RLIMIT_MEMLOCK = 9,
-        TGT_RLIMIT_LOCKS = 10,
-        NUM_RLIMIT_RESOURCES
-    };
+    /// Resource constants for getrlimit() (overide some generics).
+    static const unsigned TGT_RLIMIT_NPROC = 8;
+    static const unsigned TGT_RLIMIT_AS = 6;
+    static const unsigned RLIMIT_RSS = 7;
+    static const unsigned TGT_RLIMIT_NOFILE = 5;
+    static const unsigned TGT_RLIMIT_MEMLOCK = 9;
 
     /// Offset used to make sure that processes don't
     /// assign themselves to process IDs reserved for
index 7b708cbcb2eea4e7d11ec41e2e67776c71bd112b..bb7063edf9961d175ef2d3f669cd381ce5da4ae8 100644 (file)
@@ -167,6 +167,9 @@ class Sparc32Linux : public SparcLinux
         uint32_t mem_unit;  /* Memory unit size in bytes */
     } tgt_sysinfo;   
 
+    /// Resource constants for getrlimit() (overide some generics).
+    static const unsigned TGT_RLIMIT_NPROC = 7;
+    static const unsigned TGT_RLIMIT_NOFILE = 6;
 };
 
 #endif
index 322868ee1cfa3a9d71d2fe887bea192039a53872..4319ff9a8709d065391adf543e4a99978bf46469 100644 (file)
@@ -310,8 +310,8 @@ SyscallDesc X86_64LinuxProcess::syscallDescs[] = {
     /*  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", timesFunc<X86Linux64>),
     /* 101 */ SyscallDesc("ptrace", unimplementedFunc),
@@ -568,8 +568,8 @@ SyscallDesc I386LinuxProcess::syscallDescs[] = {
     /*  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),
index bc3da60e4f7a856d7c0bc82b3eff1fc76d16f2ae..1d52ff32386b023c9b1a4a4636fbbcbd10137fb4 100644 (file)
@@ -174,7 +174,30 @@ class Linux : public OperatingSystem
     }
 
 
+    /// Resource constants for getrlimit().
+    static const unsigned TGT_RLIMIT_CPU = 0;
+    static const unsigned TGT_RLIMIT_FSIZE = 1;
+    static const unsigned TGT_RLIMIT_DATA = 2;
+    static const unsigned TGT_RLIMIT_STACK = 3;
+    static const unsigned TGT_RLIMIT_CORE = 4;
+    static const unsigned TGT_RLIMIT_RSS = 5;
+    static const unsigned TGT_RLIMIT_NPROC = 6;
+    static const unsigned TGT_RLIMIT_NOFILE = 7;
+    static const unsigned TGT_RLIMIT_MEMLOCK = 8;
+    static const unsigned TGT_RLIMIT_AS = 9;
+    static const unsigned TGT_RLIMIT_LOCKS = 10;
+    static const unsigned TGT_RLIMIT_SIGPENDING = 11;
+    static const unsigned TGT_RLIMIT_MSGQUEUE = 12;
+    static const unsigned TGT_RLIMIT_NICE = 13;
+    static const unsigned TGT_RLIMIT_RTPRIO = 14;
+    static const unsigned TGT_RLIMIT_RTTIME = 15;
+    static const unsigned TGT_RLIM_NLIMITS = 16;
+
     /// For getrusage().
+    static const int TGT_RUSAGE_SELF     = 0;
+    static const int TGT_RUSAGE_CHILDREN = -1;
+    static const int TGT_RUSAGE_BOTH     = -2;
+
     struct rusage {
         struct timeval ru_utime;        //!< user time used
         struct timeval ru_stime;        //!< system time used