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 #ifndef _PORTABILITY_H_ 18 #define _PORTABILITY_H_ 19 20 #include "asm-generic/portability.h" 21 /* 22 * Common portability helper routines 23 */ 24 25 /* 26 * Check a portable pointer before we access it 27 * Well behaved programs should not be passing bad pointers 28 * to the kernel but this routine can be used to check a pointer 29 * if we need to use it before calling the kernel 30 * 31 * It does not catch every possible case but it is sufficient for LTP 32 */ 33 inline static int invalid_pointer(void *p) 34 { 35 return p == 0 36 || p == (void *)-1 37 #ifdef __mips__ 38 || (int)p < 0 39 #endif 40 ; 41 } 42 43 /* 44 * Hidden functions are exposed while linking the libportable shared object 45 * but are not exposed thereafter. 46 */ 47 #define __hidden __attribute__((visibility("hidden"))) 48 49 #endif /* _PORTABILITY_H_ */ 50