• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2012, The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <sys/resource.h>
18 #include <resource_portable.h>
19 
20 #if RLIMIT_NOFILE_PORTABLE==RLIMIT_NOFILE
21 #error Bad build environment
22 #endif
23 
mips_change_resource(int resource)24 static inline int mips_change_resource(int resource)
25 {
26     switch(resource) {
27     case RLIMIT_NOFILE_PORTABLE:
28         return RLIMIT_NOFILE;
29     case RLIMIT_AS_PORTABLE:
30         return RLIMIT_AS;
31     case RLIMIT_RSS_PORTABLE:
32         return RLIMIT_RSS;
33     case RLIMIT_NPROC_PORTABLE:
34         return RLIMIT_NPROC;
35     case RLIMIT_MEMLOCK_PORTABLE:
36         return RLIMIT_MEMLOCK;
37     }
38     return resource;
39 }
40 
41 extern int getrlimit(int resource, struct rlimit *rlp);
getrlimit_portable(int resource,struct rlimit * rlp)42 int getrlimit_portable(int resource, struct rlimit *rlp)
43 {
44     return getrlimit(mips_change_resource(resource), rlp);
45 }
46 
47 extern int setrlimit(int resource, const struct rlimit *rlp);
setrlimit_portable(int resource,const struct rlimit * rlp)48 int setrlimit_portable(int resource, const struct rlimit *rlp)
49 {
50     return setrlimit(mips_change_resource(resource), rlp);
51 }
52