Merge "Support getrlimit and setrlimit for MIPS."
This commit is contained in:
@@ -32,6 +32,7 @@ ifeq ($(TARGET_ARCH),mips)
|
||||
libportable_arch_src_files += \
|
||||
arch-mips/ioctl.c \
|
||||
arch-mips/mmap.c \
|
||||
arch-mips/resource.c \
|
||||
arch-mips/stat.c \
|
||||
arch-mips/statfs.c \
|
||||
arch-mips/open.c \
|
||||
|
||||
51
ndk/sources/android/libportable/arch-mips/resource.c
Normal file
51
ndk/sources/android/libportable/arch-mips/resource.c
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright 2012, The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <sys/resource.h>
|
||||
#include <resource_portable.h>
|
||||
|
||||
#if RLIMIT_NOFILE_PORTABLE==RLIMIT_NOFILE
|
||||
#error Bad build environment
|
||||
#endif
|
||||
|
||||
static inline int mips_change_resource(int resource)
|
||||
{
|
||||
switch(resource) {
|
||||
case RLIMIT_NOFILE_PORTABLE:
|
||||
return RLIMIT_NOFILE;
|
||||
case RLIMIT_AS_PORTABLE:
|
||||
return RLIMIT_AS;
|
||||
case RLIMIT_RSS_PORTABLE:
|
||||
return RLIMIT_RSS;
|
||||
case RLIMIT_NPROC_PORTABLE:
|
||||
return RLIMIT_NPROC;
|
||||
case RLIMIT_MEMLOCK_PORTABLE:
|
||||
return RLIMIT_MEMLOCK;
|
||||
}
|
||||
return resource;
|
||||
}
|
||||
|
||||
extern int getrlimit(int resource, struct rlimit *rlp);
|
||||
int getrlimit_portable(int resource, struct rlimit *rlp)
|
||||
{
|
||||
return getrlimit(mips_change_resource(resource), rlp);
|
||||
}
|
||||
|
||||
extern int setrlimit(int resource, const struct rlimit *rlp);
|
||||
int setrlimit_portable(int resource, const struct rlimit *rlp)
|
||||
{
|
||||
return setrlimit(mips_change_resource(resource), rlp);
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright 2012, The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef _RESOURCE_PORTABLE_H_
|
||||
#define _RESOURCE_PORTABLE_H_
|
||||
|
||||
/* Derived from development/ndk/platforms/android-3/include/asm-generic/resource.h */
|
||||
|
||||
#define RLIMIT_CPU_PORTABLE 0
|
||||
#define RLIMIT_FSIZE_PORTABLE 1
|
||||
#define RLIMIT_DATA_PORTABLE 2
|
||||
#define RLIMIT_STACK_PORTABLE 3
|
||||
#define RLIMIT_CORE_PORTABLE 4
|
||||
|
||||
#ifndef RLIMIT_RSS_PORTABLE
|
||||
#define RLIMIT_RSS_PORTABLE 5
|
||||
#endif
|
||||
|
||||
#ifndef RLIMIT_NPROC_PORTABLE
|
||||
#define RLIMIT_NPROC_PORTABLE 6
|
||||
#endif
|
||||
|
||||
#ifndef RLIMIT_NOFILE_PORTABLE
|
||||
#define RLIMIT_NOFILE_PORTABLE 7
|
||||
#endif
|
||||
|
||||
#ifndef RLIMIT_MEMLOCK_PORTABLE
|
||||
#define RLIMIT_MEMLOCK_PORTABLE 8
|
||||
#endif
|
||||
|
||||
#ifndef RLIMIT_AS_PORTABLE
|
||||
#define RLIMIT_AS_PORTABLE 9
|
||||
#endif
|
||||
|
||||
#define RLIMIT_LOCKS_PORTABLE 10
|
||||
#define RLIMIT_SIGPENDING_PORTABLE 11
|
||||
#define RLIMIT_MSGQUEUE_PORTABLE 12
|
||||
#define RLIMIT_NICE_PORTABLE 13
|
||||
#define RLIMIT_RTPRIO_PORTABLE 14
|
||||
#define RLIMIT_RTTIME_PORTABLE 15
|
||||
|
||||
#define RLIM_NLIMITS_PORTABLE 16
|
||||
|
||||
#ifndef RLIM_INFINITY_PORTABLE
|
||||
#define RLIM_INFINITY_PORTABLE (~0UL)
|
||||
#endif
|
||||
|
||||
#ifndef _STK_LIM_MAX_PORTABLE
|
||||
#define _STK_LIM_MAX_PORTABLE RLIM_INFINITY_PORTABLE
|
||||
#endif
|
||||
|
||||
#endif /* _RESOURCE_PORTABLE_H_ */
|
||||
Reference in New Issue
Block a user