src/java.base/unix/classes/sun/nio/fs/UnixConstants.java.template
author igerasim
Fri, 25 May 2018 12:44:34 -0700
changeset 50275 69204b98dc3d
parent 47428 d72d7d55c765
permissions -rw-r--r--
8203369: Check for both EAGAIN and EWOULDBLOCK error codes Reviewed-by: alanb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36672
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
     1
/*
50275
69204b98dc3d 8203369: Check for both EAGAIN and EWOULDBLOCK error codes
igerasim
parents: 47428
diff changeset
     2
 * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
36672
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
     4
 *
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    10
 *
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    15
 * accompanied this code).
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    16
 *
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    20
 *
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    23
 * questions.
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    24
 */
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    25
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    26
@@END_COPYRIGHT@@
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    27
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    28
#include <stdio.h>
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    29
#include <errno.h>
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    30
#include <unistd.h>
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    31
#include <fcntl.h>
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    32
#include <sys/stat.h>
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    33
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    34
/* On Solaris, "sun" is defined as a macro. Undefine to make package
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    35
   declaration valid */
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    36
#undef sun
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    37
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    38
/* To be able to name the Java constants the same as the C constants without
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    39
   having the preprocessor rewrite those identifiers, add PREFIX_ to all
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    40
   identifiers matching a C constant. The PREFIX_ is filtered out in the
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    41
   makefile. */
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    42
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    43
@@START_HERE@@
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    44
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    45
package sun.nio.fs;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    46
class UnixConstants {
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    47
    private UnixConstants() { }
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    48
    static final int PREFIX_O_RDONLY = O_RDONLY;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    49
    static final int PREFIX_O_WRONLY = O_WRONLY;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    50
    static final int PREFIX_O_RDWR = O_RDWR;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    51
    static final int PREFIX_O_APPEND = O_APPEND;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    52
    static final int PREFIX_O_CREAT = O_CREAT;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    53
    static final int PREFIX_O_EXCL = O_EXCL;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    54
    static final int PREFIX_O_TRUNC = O_TRUNC;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    55
    static final int PREFIX_O_SYNC = O_SYNC;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    56
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    57
#ifndef O_DSYNC
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    58
    // At least FreeBSD doesn't define O_DSYNC
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    59
    static final int PREFIX_O_DSYNC = O_SYNC;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    60
#else
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    61
    static final int PREFIX_O_DSYNC = O_DSYNC;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    62
#endif
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    63
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    64
#ifdef O_NOFOLLOW
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    65
    static final int PREFIX_O_NOFOLLOW = O_NOFOLLOW;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    66
#else
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    67
    // not supported (dummy values will not be used at runtime).
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    68
    static final int PREFIX_O_NOFOLLOW = 00;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    69
#endif
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    70
47428
d72d7d55c765 8164900: Add support for O_DIRECT
bpb
parents: 47216
diff changeset
    71
#ifdef O_DIRECT
d72d7d55c765 8164900: Add support for O_DIRECT
bpb
parents: 47216
diff changeset
    72
    static final int PREFIX_O_DIRECT = O_DIRECT;
d72d7d55c765 8164900: Add support for O_DIRECT
bpb
parents: 47216
diff changeset
    73
#else
d72d7d55c765 8164900: Add support for O_DIRECT
bpb
parents: 47216
diff changeset
    74
    // not supported (dummy values will not be used at runtime).
d72d7d55c765 8164900: Add support for O_DIRECT
bpb
parents: 47216
diff changeset
    75
    static final int PREFIX_O_DIRECT = 00;
d72d7d55c765 8164900: Add support for O_DIRECT
bpb
parents: 47216
diff changeset
    76
#endif
36672
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    77
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    78
    static final int PREFIX_S_IAMB =
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    79
        (S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IWGRP|S_IXGRP|S_IROTH|S_IWOTH|S_IXOTH);
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    80
    static final int PREFIX_S_IRUSR = S_IRUSR;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    81
    static final int PREFIX_S_IWUSR = S_IWUSR;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    82
    static final int PREFIX_S_IXUSR = S_IXUSR;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    83
    static final int PREFIX_S_IRGRP = S_IRGRP;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    84
    static final int PREFIX_S_IWGRP = S_IWGRP;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    85
    static final int PREFIX_S_IXGRP = S_IXGRP;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    86
    static final int PREFIX_S_IROTH = S_IROTH;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    87
    static final int PREFIX_S_IWOTH = S_IWOTH;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    88
    static final int PREFIX_S_IXOTH = S_IXOTH;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    89
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    90
    static final int PREFIX_S_IFMT = S_IFMT;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    91
    static final int PREFIX_S_IFREG = S_IFREG;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    92
    static final int PREFIX_S_IFDIR = S_IFDIR;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    93
    static final int PREFIX_S_IFLNK = S_IFLNK;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    94
    static final int PREFIX_S_IFCHR = S_IFCHR;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    95
    static final int PREFIX_S_IFBLK = S_IFBLK;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    96
    static final int PREFIX_S_IFIFO = S_IFIFO;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    97
    static final int PREFIX_R_OK = R_OK;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    98
    static final int PREFIX_W_OK = W_OK;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
    99
    static final int PREFIX_X_OK = X_OK;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
   100
    static final int PREFIX_F_OK = F_OK;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
   101
    static final int PREFIX_ENOENT = ENOENT;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
   102
    static final int PREFIX_ENXIO = ENXIO;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
   103
    static final int PREFIX_EACCES = EACCES;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
   104
    static final int PREFIX_EEXIST = EEXIST;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
   105
    static final int PREFIX_ENOTDIR = ENOTDIR;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
   106
    static final int PREFIX_EINVAL = EINVAL;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
   107
    static final int PREFIX_EXDEV = EXDEV;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
   108
    static final int PREFIX_EISDIR = EISDIR;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
   109
    static final int PREFIX_ENOTEMPTY = ENOTEMPTY;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
   110
    static final int PREFIX_ENOSPC = ENOSPC;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
   111
    static final int PREFIX_EAGAIN = EAGAIN;
50275
69204b98dc3d 8203369: Check for both EAGAIN and EWOULDBLOCK error codes
igerasim
parents: 47428
diff changeset
   112
    static final int PREFIX_EWOULDBLOCK = EWOULDBLOCK;
36672
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
   113
    static final int PREFIX_ENOSYS = ENOSYS;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
   114
    static final int PREFIX_ELOOP = ELOOP;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
   115
    static final int PREFIX_EROFS = EROFS;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
   116
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
   117
#ifndef ENODATA
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
   118
    // Only used in Linux java source, provide any value so it compiles
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
   119
    static final int PREFIX_ENODATA = ELAST;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
   120
#else
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
   121
    static final int PREFIX_ENODATA = ENODATA;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
   122
#endif
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
   123
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
   124
    static final int PREFIX_ERANGE = ERANGE;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
   125
    static final int PREFIX_EMFILE = EMFILE;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
   126
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
   127
    // flags used with openat/unlinkat/etc.
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
   128
#if defined(AT_SYMLINK_NOFOLLOW) && defined(AT_REMOVEDIR)
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
   129
    static final int PREFIX_AT_SYMLINK_NOFOLLOW = AT_SYMLINK_NOFOLLOW;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
   130
    static final int PREFIX_AT_REMOVEDIR = AT_REMOVEDIR;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
   131
#else
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
   132
    // not supported (dummy values will not be used at runtime).
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
   133
    static final int PREFIX_AT_SYMLINK_NOFOLLOW = 00;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
   134
    static final int PREFIX_AT_REMOVEDIR = 00;
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
   135
#endif
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
   136
9e18f32e76c9 8152545: Use preprocessor instead of compiling a program to generate native nio constants
erikj
parents:
diff changeset
   137
}