fcntl.c revision 5f79ffb27119766a5f946d912849ffb1bdface72
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 <fcntl.h> 18#include <stdarg.h> 19#include <fcntl_portable.h> 20 21#if F_GETLK_PORTABLE==F_GETLK 22#error Bad build environment 23#endif 24 25static inline int mips_change_cmd(int cmd) 26{ 27 switch(cmd) { 28 case F_GETLK_PORTABLE: 29 return F_GETLK; 30 case F_SETLK_PORTABLE: 31 return F_SETLK; 32 case F_SETLKW_PORTABLE: 33 return F_SETLKW; 34 case F_SETOWN_PORTABLE: 35 return F_SETOWN; 36 case F_GETOWN_PORTABLE: 37 return F_GETOWN; 38 case F_GETLK64_PORTABLE: 39 return F_GETLK64; 40 case F_SETLK64_PORTABLE: 41 return F_SETLK64; 42 case F_SETLKW64_PORTABLE: 43 return F_SETLKW64; 44 } 45 return cmd; 46} 47 48extern int __fcntl64(int, int, void *); 49 50int fcntl_portable(int fd, int cmd, ...) 51{ 52 va_list ap; 53 void * arg; 54 55 va_start(ap, cmd); 56 arg = va_arg(ap, void *); 57 va_end(ap); 58 59 return __fcntl64(fd, mips_change_cmd(cmd), arg); 60} 61 62