Home | History | Annotate | Download | only in include
      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 _FCNTL_PORTABLE_H_
     18 #define _FCNTL_PORTABLE_H_
     19 
     20 /* Derived from development/ndk/platforms/android-3/arch-arm/include/asm/fcntl.h */
     21 /* NB x86 does not have these and only uses the generic definitions. */
     22 #define O_DIRECTORY_PORTABLE    040000
     23 #define O_NOFOLLOW_PORTABLE     0100000
     24 #define O_DIRECT_PORTABLE       0200000
     25 #define O_LARGEFILE_PORTABLE    0400000
     26 
     27 /* Derived from development/ndk/platforms/android-3/include/asm-generic/fcntl.h */
     28 #define O_ACCMODE_PORTABLE  00000003
     29 #define O_RDONLY_PORTABLE   00000000
     30 #define O_WRONLY_PORTABLE   00000001
     31 #define O_RDWR_PORTABLE     00000002
     32 #ifndef O_CREAT_PORTABLE
     33 #define O_CREAT_PORTABLE    00000100
     34 #endif
     35 #ifndef O_EXCL_PORTABLE
     36 #define O_EXCL_PORTABLE     00000200
     37 #endif
     38 #ifndef O_NOCTTY_PORTABLE
     39 #define O_NOCTTY_PORTABLE   00000400
     40 #endif
     41 #ifndef O_TRUNC_PORTABLE
     42 #define O_TRUNC_PORTABLE    00001000
     43 #endif
     44 #ifndef O_APPEND_PORTABLE
     45 #define O_APPEND_PORTABLE   00002000
     46 #endif
     47 #ifndef O_NONBLOCK_PORTABLE
     48 #define O_NONBLOCK_PORTABLE 00004000
     49 #endif
     50 #ifndef O_SYNC_PORTABLE
     51 #define O_SYNC_PORTABLE     00010000
     52 #endif
     53 #ifndef FASYNC_PORTABLE
     54 #define FASYNC_PORTABLE     00020000
     55 #endif
     56 #ifndef O_DIRECT_PORTABLE
     57 #define O_DIRECT_PORTABLE   00040000
     58 #endif
     59 #ifndef O_LARGEFILE_PORTABLE
     60 #define O_LARGEFILE_PORTABLE    00100000
     61 #endif
     62 #ifndef O_DIRECTORY_PORTABLE
     63 #define O_DIRECTORY_PORTABLE    00200000
     64 #endif
     65 #ifndef O_NOFOLLOW_PORTABLE
     66 #define O_NOFOLLOW_PORTABLE 00400000
     67 #endif
     68 #ifndef O_NOATIME_PORTABLE
     69 #define O_NOATIME_PORTABLE  01000000
     70 #endif
     71 #ifndef O_NDELAY_PORTABLE
     72 #define O_NDELAY_PORTABLE   O_NONBLOCK_PORTABLE
     73 #endif
     74 
     75 /* From Bionic libc/kernel/common/asm-generic/fcntl.h */
     76 #ifndef O_CLOEXEC_PORTABLE
     77 #define O_CLOEXEC_PORTABLE 02000000
     78 #endif
     79 
     80 #ifndef __ARCH_FLOCK64_PAD
     81 #define __ARCH_FLOCK64_PAD
     82 #endif
     83 
     84 /*
     85  * For use with F_GETLK and F_SETLK
     86  */
     87 struct flock_portable {
     88    short l_type;
     89    short l_whence;
     90    off_t l_start;
     91    off_t l_len;
     92    pid_t l_pid;
     93    __ARCH_FLOCK64_PAD
     94 };
     95 
     96 /*
     97  * For use with F_GETLK64 and F_SETLK64
     98  */
     99 struct flock64_portable {
    100    short l_type;
    101    short l_whence;
    102    unsigned char __padding[4];
    103    loff_t l_start;
    104    loff_t l_len;
    105    pid_t l_pid;
    106    __ARCH_FLOCK64_PAD
    107 };
    108 
    109 #if 0
    110 /*
    111  * The X86 Version is
    112  */
    113 struct flock64 {
    114    short l_type;
    115    short l_whence;
    116    loff_t l_start;
    117    loff_t l_len;
    118    pid_t l_pid;
    119    __ARCH_FLOCK64_PAD
    120 };
    121 #endif /* 0 */
    122 
    123 
    124 #ifndef F_DUPFD_PORTABLE
    125 #define F_DUPFD_PORTABLE 0
    126 #define F_GETFD_PORTABLE 1
    127 #define F_SETFD_PORTABLE 2
    128 #define F_GETFL_PORTABLE 3
    129 #define F_SETFL_PORTABLE 4
    130 #endif
    131 
    132 #ifndef F_GETLK_PORTABLE
    133 #define F_GETLK_PORTABLE 5
    134 #define F_SETLK_PORTABLE 6
    135 #define F_SETLKW_PORTABLE 7
    136 #endif
    137 
    138 #ifndef F_SETOWN_PORTABLE
    139 #define F_SETOWN_PORTABLE 8
    140 #define F_GETOWN_PORTABLE 9
    141 #endif
    142 
    143 #ifndef F_SETSIG_PORTABLE
    144 #define F_SETSIG_PORTABLE 10
    145 #define F_GETSIG_PORTABLE 11
    146 #endif
    147 
    148 #ifndef F_GETLK64_PORTABLE
    149 #define F_GETLK64_PORTABLE 12
    150 #define F_SETLK64_PORTABLE 13
    151 #define F_SETLKW64_PORTABLE 14
    152 #endif
    153 
    154 /* This constant seems to be the same for all ARCH's */
    155 #define F_LINUX_SPECIFIC_BASE_PORTABLE 1024
    156 
    157 #define F_SETLEASE_PORTABLE             (F_LINUX_SPECIFIC_BASE+0)       /* 1024 */
    158 #define F_GETLEASE_PORTABLE             (F_LINUX_SPECIFIC_BASE+1)       /* 1025 */
    159 #define F_NOTIFY_PORTABLE               (F_LINUX_SPECIFIC_BASE+2)       /* 1026 */
    160 
    161 /* Currently these are only supported by X86_64 */
    162 #define F_CANCELLK_PORTABLE             (F_LINUX_SPECIFIC_BASE+5)       /* 1029 */
    163 #define F_DUPFD_CLOEXEC_PORTABLE        (F_LINUX_SPECIFIC_BASE+6)       /* 1030 */
    164 
    165 #endif /* _FCNTL_PORTABLE_H */
    166