• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2011 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 package android.system;
18 
19 /**
20  * Constants and helper functions for use with {@link Os}.
21  */
22 public final class OsConstants {
OsConstants()23     private OsConstants() {
24     }
25 
26     /**
27      * Tests whether the given mode is a block device.
28      */
S_ISBLK(int mode)29     public static boolean S_ISBLK(int mode) { return (mode & S_IFMT) == S_IFBLK; }
30 
31     /**
32      * Tests whether the given mode is a character device.
33      */
S_ISCHR(int mode)34     public static boolean S_ISCHR(int mode) { return (mode & S_IFMT) == S_IFCHR; }
35 
36     /**
37      * Tests whether the given mode is a directory.
38      */
S_ISDIR(int mode)39     public static boolean S_ISDIR(int mode) { return (mode & S_IFMT) == S_IFDIR; }
40 
41     /**
42      * Tests whether the given mode is a FIFO.
43      */
S_ISFIFO(int mode)44     public static boolean S_ISFIFO(int mode) { return (mode & S_IFMT) == S_IFIFO; }
45 
46     /**
47      * Tests whether the given mode is a regular file.
48      */
S_ISREG(int mode)49     public static boolean S_ISREG(int mode) { return (mode & S_IFMT) == S_IFREG; }
50 
51     /**
52      * Tests whether the given mode is a symbolic link.
53      */
S_ISLNK(int mode)54     public static boolean S_ISLNK(int mode) { return (mode & S_IFMT) == S_IFLNK; }
55 
56     /**
57      * Tests whether the given mode is a socket.
58      */
S_ISSOCK(int mode)59     public static boolean S_ISSOCK(int mode) { return (mode & S_IFMT) == S_IFSOCK; }
60 
61     /**
62      * Extracts the exit status of a child. Only valid if WIFEXITED returns true.
63      */
WEXITSTATUS(int status)64     public static int WEXITSTATUS(int status) { return (status & 0xff00) >> 8; }
65 
66     /**
67      * Tests whether the child dumped core. Only valid if WIFSIGNALED returns true.
68      */
WCOREDUMP(int status)69     public static boolean WCOREDUMP(int status) { return (status & 0x80) != 0; }
70 
71     /**
72      * Returns the signal that caused the child to exit. Only valid if WIFSIGNALED returns true.
73      */
WTERMSIG(int status)74     public static int WTERMSIG(int status) { return status & 0x7f; }
75 
76     /**
77      * Returns the signal that cause the child to stop. Only valid if WIFSTOPPED returns true.
78      */
WSTOPSIG(int status)79     public static int WSTOPSIG(int status) { return WEXITSTATUS(status); }
80 
81     /**
82      * Tests whether the child exited normally.
83      */
WIFEXITED(int status)84     public static boolean WIFEXITED(int status) { return (WTERMSIG(status) == 0); }
85 
86     /**
87      * Tests whether the child was stopped (not terminated) by a signal.
88      */
WIFSTOPPED(int status)89     public static boolean WIFSTOPPED(int status) { return (WTERMSIG(status) == 0x7f); }
90 
91     /**
92      * Tests whether the child was terminated by a signal.
93      */
WIFSIGNALED(int status)94     public static boolean WIFSIGNALED(int status) { return (WTERMSIG(status + 1) >= 2); }
95 
96     public static final int AF_INET = placeholder();
97     public static final int AF_INET6 = placeholder();
98     /** @hide */ public static final int AF_NETLINK = placeholder();
99     /** @hide */ public static final int AF_PACKET = placeholder();
100     public static final int AF_UNIX = placeholder();
101     public static final int AF_UNSPEC = placeholder();
102     public static final int AI_ADDRCONFIG = placeholder();
103     public static final int AI_ALL = placeholder();
104     public static final int AI_CANONNAME = placeholder();
105     public static final int AI_NUMERICHOST = placeholder();
106     public static final int AI_NUMERICSERV = placeholder();
107     public static final int AI_PASSIVE = placeholder();
108     public static final int AI_V4MAPPED = placeholder();
109     /** @hide */ public static final int ARPHRD_ETHER = placeholder();
110     /** @hide */ public static final int ARPHRD_LOOPBACK = placeholder();
111     public static final int CAP_AUDIT_CONTROL = placeholder();
112     public static final int CAP_AUDIT_WRITE = placeholder();
113     public static final int CAP_BLOCK_SUSPEND = placeholder();
114     public static final int CAP_CHOWN = placeholder();
115     public static final int CAP_DAC_OVERRIDE = placeholder();
116     public static final int CAP_DAC_READ_SEARCH = placeholder();
117     public static final int CAP_FOWNER = placeholder();
118     public static final int CAP_FSETID = placeholder();
119     public static final int CAP_IPC_LOCK = placeholder();
120     public static final int CAP_IPC_OWNER = placeholder();
121     public static final int CAP_KILL = placeholder();
122     public static final int CAP_LAST_CAP = placeholder();
123     public static final int CAP_LEASE = placeholder();
124     public static final int CAP_LINUX_IMMUTABLE = placeholder();
125     public static final int CAP_MAC_ADMIN = placeholder();
126     public static final int CAP_MAC_OVERRIDE = placeholder();
127     public static final int CAP_MKNOD = placeholder();
128     public static final int CAP_NET_ADMIN = placeholder();
129     public static final int CAP_NET_BIND_SERVICE = placeholder();
130     public static final int CAP_NET_BROADCAST = placeholder();
131     public static final int CAP_NET_RAW = placeholder();
132     public static final int CAP_SETFCAP = placeholder();
133     public static final int CAP_SETGID = placeholder();
134     public static final int CAP_SETPCAP = placeholder();
135     public static final int CAP_SETUID = placeholder();
136     public static final int CAP_SYS_ADMIN = placeholder();
137     public static final int CAP_SYS_BOOT = placeholder();
138     public static final int CAP_SYS_CHROOT = placeholder();
139     public static final int CAP_SYSLOG = placeholder();
140     public static final int CAP_SYS_MODULE = placeholder();
141     public static final int CAP_SYS_NICE = placeholder();
142     public static final int CAP_SYS_PACCT = placeholder();
143     public static final int CAP_SYS_PTRACE = placeholder();
144     public static final int CAP_SYS_RAWIO = placeholder();
145     public static final int CAP_SYS_RESOURCE = placeholder();
146     public static final int CAP_SYS_TIME = placeholder();
147     public static final int CAP_SYS_TTY_CONFIG = placeholder();
148     public static final int CAP_WAKE_ALARM = placeholder();
149     public static final int E2BIG = placeholder();
150     public static final int EACCES = placeholder();
151     public static final int EADDRINUSE = placeholder();
152     public static final int EADDRNOTAVAIL = placeholder();
153     public static final int EAFNOSUPPORT = placeholder();
154     public static final int EAGAIN = placeholder();
155     public static final int EAI_AGAIN = placeholder();
156     public static final int EAI_BADFLAGS = placeholder();
157     public static final int EAI_FAIL = placeholder();
158     public static final int EAI_FAMILY = placeholder();
159     public static final int EAI_MEMORY = placeholder();
160     public static final int EAI_NODATA = placeholder();
161     public static final int EAI_NONAME = placeholder();
162     public static final int EAI_OVERFLOW = placeholder();
163     public static final int EAI_SERVICE = placeholder();
164     public static final int EAI_SOCKTYPE = placeholder();
165     public static final int EAI_SYSTEM = placeholder();
166     public static final int EALREADY = placeholder();
167     public static final int EBADF = placeholder();
168     public static final int EBADMSG = placeholder();
169     public static final int EBUSY = placeholder();
170     public static final int ECANCELED = placeholder();
171     public static final int ECHILD = placeholder();
172     public static final int ECONNABORTED = placeholder();
173     public static final int ECONNREFUSED = placeholder();
174     public static final int ECONNRESET = placeholder();
175     public static final int EDEADLK = placeholder();
176     public static final int EDESTADDRREQ = placeholder();
177     public static final int EDOM = placeholder();
178     public static final int EDQUOT = placeholder();
179     public static final int EEXIST = placeholder();
180     public static final int EFAULT = placeholder();
181     public static final int EFBIG = placeholder();
182     public static final int EHOSTUNREACH = placeholder();
183     public static final int EIDRM = placeholder();
184     public static final int EILSEQ = placeholder();
185     public static final int EINPROGRESS = placeholder();
186     public static final int EINTR = placeholder();
187     public static final int EINVAL = placeholder();
188     public static final int EIO = placeholder();
189     public static final int EISCONN = placeholder();
190     public static final int EISDIR = placeholder();
191     public static final int ELOOP = placeholder();
192     public static final int EMFILE = placeholder();
193     public static final int EMLINK = placeholder();
194     public static final int EMSGSIZE = placeholder();
195     public static final int EMULTIHOP = placeholder();
196     public static final int ENAMETOOLONG = placeholder();
197     public static final int ENETDOWN = placeholder();
198     public static final int ENETRESET = placeholder();
199     public static final int ENETUNREACH = placeholder();
200     public static final int ENFILE = placeholder();
201     public static final int ENOBUFS = placeholder();
202     public static final int ENODATA = placeholder();
203     public static final int ENODEV = placeholder();
204     public static final int ENOENT = placeholder();
205     public static final int ENOEXEC = placeholder();
206     public static final int ENOLCK = placeholder();
207     public static final int ENOLINK = placeholder();
208     public static final int ENOMEM = placeholder();
209     public static final int ENOMSG = placeholder();
210     /** @hide */ public static final int ENONET = placeholder();
211     public static final int ENOPROTOOPT = placeholder();
212     public static final int ENOSPC = placeholder();
213     public static final int ENOSR = placeholder();
214     public static final int ENOSTR = placeholder();
215     public static final int ENOSYS = placeholder();
216     public static final int ENOTCONN = placeholder();
217     public static final int ENOTDIR = placeholder();
218     public static final int ENOTEMPTY = placeholder();
219     public static final int ENOTSOCK = placeholder();
220     public static final int ENOTSUP = placeholder();
221     public static final int ENOTTY = placeholder();
222     public static final int ENXIO = placeholder();
223     public static final int EOPNOTSUPP = placeholder();
224     public static final int EOVERFLOW = placeholder();
225     public static final int EPERM = placeholder();
226     public static final int EPIPE = placeholder();
227     public static final int EPROTO = placeholder();
228     public static final int EPROTONOSUPPORT = placeholder();
229     public static final int EPROTOTYPE = placeholder();
230     public static final int ERANGE = placeholder();
231     public static final int EROFS = placeholder();
232     public static final int ESPIPE = placeholder();
233     public static final int ESRCH = placeholder();
234     public static final int ESTALE = placeholder();
235     /** @hide */ public static final int ETH_P_ARP = placeholder();
236     /** @hide */ public static final int ETH_P_IP = placeholder();
237     /** @hide */ public static final int ETH_P_IPV6 = placeholder();
238     public static final int ETIME = placeholder();
239     public static final int ETIMEDOUT = placeholder();
240     public static final int ETXTBSY = placeholder();
241     // On Linux, EWOULDBLOCK == EAGAIN. Use EAGAIN instead, to reduce confusion.
242     public static final int EXDEV = placeholder();
243     public static final int EXIT_FAILURE = placeholder();
244     public static final int EXIT_SUCCESS = placeholder();
245     public static final int FD_CLOEXEC = placeholder();
246     public static final int FIONREAD = placeholder();
247     public static final int F_DUPFD = placeholder();
248     public static final int F_GETFD = placeholder();
249     public static final int F_GETFL = placeholder();
250     public static final int F_GETLK = placeholder();
251     public static final int F_GETLK64 = placeholder();
252     public static final int F_GETOWN = placeholder();
253     public static final int F_OK = placeholder();
254     public static final int F_RDLCK = placeholder();
255     public static final int F_SETFD = placeholder();
256     public static final int F_SETFL = placeholder();
257     public static final int F_SETLK = placeholder();
258     public static final int F_SETLK64 = placeholder();
259     public static final int F_SETLKW = placeholder();
260     public static final int F_SETLKW64 = placeholder();
261     public static final int F_SETOWN = placeholder();
262     public static final int F_UNLCK = placeholder();
263     public static final int F_WRLCK = placeholder();
264     public static final int IFA_F_DADFAILED = placeholder();
265     public static final int IFA_F_DEPRECATED = placeholder();
266     public static final int IFA_F_HOMEADDRESS = placeholder();
267     public static final int IFA_F_NODAD = placeholder();
268     public static final int IFA_F_OPTIMISTIC = placeholder();
269     public static final int IFA_F_PERMANENT = placeholder();
270     public static final int IFA_F_SECONDARY = placeholder();
271     public static final int IFA_F_TEMPORARY = placeholder();
272     public static final int IFA_F_TENTATIVE = placeholder();
273     public static final int IFF_ALLMULTI = placeholder();
274     public static final int IFF_AUTOMEDIA = placeholder();
275     public static final int IFF_BROADCAST = placeholder();
276     public static final int IFF_DEBUG = placeholder();
277     public static final int IFF_DYNAMIC = placeholder();
278     public static final int IFF_LOOPBACK = placeholder();
279     public static final int IFF_MASTER = placeholder();
280     public static final int IFF_MULTICAST = placeholder();
281     public static final int IFF_NOARP = placeholder();
282     public static final int IFF_NOTRAILERS = placeholder();
283     public static final int IFF_POINTOPOINT = placeholder();
284     public static final int IFF_PORTSEL = placeholder();
285     public static final int IFF_PROMISC = placeholder();
286     public static final int IFF_RUNNING = placeholder();
287     public static final int IFF_SLAVE = placeholder();
288     public static final int IFF_UP = placeholder();
289     public static final int IPPROTO_ICMP = placeholder();
290     public static final int IPPROTO_ICMPV6 = placeholder();
291     public static final int IPPROTO_IP = placeholder();
292     public static final int IPPROTO_IPV6 = placeholder();
293     public static final int IPPROTO_RAW = placeholder();
294     public static final int IPPROTO_TCP = placeholder();
295     public static final int IPPROTO_UDP = placeholder();
296     public static final int IPV6_CHECKSUM = placeholder();
297     public static final int IPV6_MULTICAST_HOPS = placeholder();
298     public static final int IPV6_MULTICAST_IF = placeholder();
299     public static final int IPV6_MULTICAST_LOOP = placeholder();
300     public static final int IPV6_RECVDSTOPTS = placeholder();
301     public static final int IPV6_RECVHOPLIMIT = placeholder();
302     public static final int IPV6_RECVHOPOPTS = placeholder();
303     public static final int IPV6_RECVPKTINFO = placeholder();
304     public static final int IPV6_RECVRTHDR = placeholder();
305     public static final int IPV6_RECVTCLASS = placeholder();
306     public static final int IPV6_TCLASS = placeholder();
307     public static final int IPV6_UNICAST_HOPS = placeholder();
308     public static final int IPV6_V6ONLY = placeholder();
309     public static final int IP_MULTICAST_IF = placeholder();
310     public static final int IP_MULTICAST_LOOP = placeholder();
311     public static final int IP_MULTICAST_TTL = placeholder();
312     public static final int IP_TOS = placeholder();
313     public static final int IP_TTL = placeholder();
314     public static final int MAP_FIXED = placeholder();
315     public static final int MAP_PRIVATE = placeholder();
316     public static final int MAP_SHARED = placeholder();
317     public static final int MCAST_JOIN_GROUP = placeholder();
318     public static final int MCAST_LEAVE_GROUP = placeholder();
319     public static final int MCAST_JOIN_SOURCE_GROUP = placeholder();
320     public static final int MCAST_LEAVE_SOURCE_GROUP = placeholder();
321     public static final int MCAST_BLOCK_SOURCE = placeholder();
322     public static final int MCAST_UNBLOCK_SOURCE = placeholder();
323     public static final int MCL_CURRENT = placeholder();
324     public static final int MCL_FUTURE = placeholder();
325     public static final int MSG_CTRUNC = placeholder();
326     public static final int MSG_DONTROUTE = placeholder();
327     public static final int MSG_EOR = placeholder();
328     public static final int MSG_OOB = placeholder();
329     public static final int MSG_PEEK = placeholder();
330     public static final int MSG_TRUNC = placeholder();
331     public static final int MSG_WAITALL = placeholder();
332     public static final int MS_ASYNC = placeholder();
333     public static final int MS_INVALIDATE = placeholder();
334     public static final int MS_SYNC = placeholder();
335     /** @hide */ public static final int NETLINK_ROUTE = placeholder();
336     public static final int NI_DGRAM = placeholder();
337     public static final int NI_NAMEREQD = placeholder();
338     public static final int NI_NOFQDN = placeholder();
339     public static final int NI_NUMERICHOST = placeholder();
340     public static final int NI_NUMERICSERV = placeholder();
341     public static final int O_ACCMODE = placeholder();
342     public static final int O_APPEND = placeholder();
343     /** @hide */ public static final int O_CLOEXEC = placeholder();
344     public static final int O_CREAT = placeholder();
345     public static final int O_EXCL = placeholder();
346     public static final int O_NOCTTY = placeholder();
347     public static final int O_NOFOLLOW = placeholder();
348     public static final int O_NONBLOCK = placeholder();
349     public static final int O_RDONLY = placeholder();
350     public static final int O_RDWR = placeholder();
351     public static final int O_SYNC = placeholder();
352     public static final int O_TRUNC = placeholder();
353     public static final int O_WRONLY = placeholder();
354     public static final int POLLERR = placeholder();
355     public static final int POLLHUP = placeholder();
356     public static final int POLLIN = placeholder();
357     public static final int POLLNVAL = placeholder();
358     public static final int POLLOUT = placeholder();
359     public static final int POLLPRI = placeholder();
360     public static final int POLLRDBAND = placeholder();
361     public static final int POLLRDNORM = placeholder();
362     public static final int POLLWRBAND = placeholder();
363     public static final int POLLWRNORM = placeholder();
364     public static final int PR_GET_DUMPABLE = placeholder();
365     public static final int PR_SET_DUMPABLE = placeholder();
366     public static final int PR_SET_NO_NEW_PRIVS = placeholder();
367     public static final int PROT_EXEC = placeholder();
368     public static final int PROT_NONE = placeholder();
369     public static final int PROT_READ = placeholder();
370     public static final int PROT_WRITE = placeholder();
371     public static final int R_OK = placeholder();
372     public static final int RT_SCOPE_HOST = placeholder();
373     public static final int RT_SCOPE_LINK = placeholder();
374     public static final int RT_SCOPE_NOWHERE = placeholder();
375     public static final int RT_SCOPE_SITE = placeholder();
376     public static final int RT_SCOPE_UNIVERSE = placeholder();
377     /** @hide */ public static final int RTMGRP_IPV4_IFADDR = placeholder();
378     /** @hide */ public static final int RTMGRP_IPV4_MROUTE = placeholder();
379     /** @hide */ public static final int RTMGRP_IPV4_ROUTE = placeholder();
380     /** @hide */ public static final int RTMGRP_IPV4_RULE = placeholder();
381     /** @hide */ public static final int RTMGRP_IPV6_IFADDR = placeholder();
382     /** @hide */ public static final int RTMGRP_IPV6_IFINFO = placeholder();
383     /** @hide */ public static final int RTMGRP_IPV6_MROUTE = placeholder();
384     /** @hide */ public static final int RTMGRP_IPV6_PREFIX = placeholder();
385     /** @hide */ public static final int RTMGRP_IPV6_ROUTE = placeholder();
386     /** @hide */ public static final int RTMGRP_LINK = placeholder();
387     /** @hide */ public static final int RTMGRP_NEIGH = placeholder();
388     /** @hide */ public static final int RTMGRP_NOTIFY = placeholder();
389     /** @hide */ public static final int RTMGRP_TC = placeholder();
390     public static final int SEEK_CUR = placeholder();
391     public static final int SEEK_END = placeholder();
392     public static final int SEEK_SET = placeholder();
393     public static final int SHUT_RD = placeholder();
394     public static final int SHUT_RDWR = placeholder();
395     public static final int SHUT_WR = placeholder();
396     public static final int SIGABRT = placeholder();
397     public static final int SIGALRM = placeholder();
398     public static final int SIGBUS = placeholder();
399     public static final int SIGCHLD = placeholder();
400     public static final int SIGCONT = placeholder();
401     public static final int SIGFPE = placeholder();
402     public static final int SIGHUP = placeholder();
403     public static final int SIGILL = placeholder();
404     public static final int SIGINT = placeholder();
405     public static final int SIGIO = placeholder();
406     public static final int SIGKILL = placeholder();
407     public static final int SIGPIPE = placeholder();
408     public static final int SIGPROF = placeholder();
409     public static final int SIGPWR = placeholder();
410     public static final int SIGQUIT = placeholder();
411     public static final int SIGRTMAX = placeholder();
412     public static final int SIGRTMIN = placeholder();
413     public static final int SIGSEGV = placeholder();
414     public static final int SIGSTKFLT = placeholder();
415     public static final int SIGSTOP = placeholder();
416     public static final int SIGSYS = placeholder();
417     public static final int SIGTERM = placeholder();
418     public static final int SIGTRAP = placeholder();
419     public static final int SIGTSTP = placeholder();
420     public static final int SIGTTIN = placeholder();
421     public static final int SIGTTOU = placeholder();
422     public static final int SIGURG = placeholder();
423     public static final int SIGUSR1 = placeholder();
424     public static final int SIGUSR2 = placeholder();
425     public static final int SIGVTALRM = placeholder();
426     public static final int SIGWINCH = placeholder();
427     public static final int SIGXCPU = placeholder();
428     public static final int SIGXFSZ = placeholder();
429     public static final int SIOCGIFADDR = placeholder();
430     public static final int SIOCGIFBRDADDR = placeholder();
431     public static final int SIOCGIFDSTADDR = placeholder();
432     public static final int SIOCGIFNETMASK = placeholder();
433     public static final int SOCK_DGRAM = placeholder();
434     public static final int SOCK_RAW = placeholder();
435     public static final int SOCK_SEQPACKET = placeholder();
436     public static final int SOCK_STREAM = placeholder();
437     public static final int SOL_SOCKET = placeholder();
438     public static final int SO_BINDTODEVICE = placeholder();
439     public static final int SO_BROADCAST = placeholder();
440     public static final int SO_DEBUG = placeholder();
441     public static final int SO_DONTROUTE = placeholder();
442     public static final int SO_ERROR = placeholder();
443     public static final int SO_KEEPALIVE = placeholder();
444     public static final int SO_LINGER = placeholder();
445     public static final int SO_OOBINLINE = placeholder();
446     public static final int SO_PASSCRED = placeholder();
447     public static final int SO_PEERCRED = placeholder();
448     public static final int SO_RCVBUF = placeholder();
449     public static final int SO_RCVLOWAT = placeholder();
450     public static final int SO_RCVTIMEO = placeholder();
451     public static final int SO_REUSEADDR = placeholder();
452     public static final int SO_SNDBUF = placeholder();
453     public static final int SO_SNDLOWAT = placeholder();
454     public static final int SO_SNDTIMEO = placeholder();
455     public static final int SO_TYPE = placeholder();
456     public static final int STDERR_FILENO = placeholder();
457     public static final int STDIN_FILENO = placeholder();
458     public static final int STDOUT_FILENO = placeholder();
459     public static final int ST_MANDLOCK = placeholder();
460     public static final int ST_NOATIME = placeholder();
461     public static final int ST_NODEV = placeholder();
462     public static final int ST_NODIRATIME = placeholder();
463     public static final int ST_NOEXEC = placeholder();
464     public static final int ST_NOSUID = placeholder();
465     public static final int ST_RDONLY = placeholder();
466     public static final int ST_RELATIME = placeholder();
467     public static final int ST_SYNCHRONOUS = placeholder();
468     public static final int S_IFBLK = placeholder();
469     public static final int S_IFCHR = placeholder();
470     public static final int S_IFDIR = placeholder();
471     public static final int S_IFIFO = placeholder();
472     public static final int S_IFLNK = placeholder();
473     public static final int S_IFMT = placeholder();
474     public static final int S_IFREG = placeholder();
475     public static final int S_IFSOCK = placeholder();
476     public static final int S_IRGRP = placeholder();
477     public static final int S_IROTH = placeholder();
478     public static final int S_IRUSR = placeholder();
479     public static final int S_IRWXG = placeholder();
480     public static final int S_IRWXO = placeholder();
481     public static final int S_IRWXU = placeholder();
482     public static final int S_ISGID = placeholder();
483     public static final int S_ISUID = placeholder();
484     public static final int S_ISVTX = placeholder();
485     public static final int S_IWGRP = placeholder();
486     public static final int S_IWOTH = placeholder();
487     public static final int S_IWUSR = placeholder();
488     public static final int S_IXGRP = placeholder();
489     public static final int S_IXOTH = placeholder();
490     public static final int S_IXUSR = placeholder();
491     public static final int TCP_NODELAY = placeholder();
492     public static final int WCONTINUED = placeholder();
493     public static final int WEXITED = placeholder();
494     public static final int WNOHANG = placeholder();
495     public static final int WNOWAIT = placeholder();
496     public static final int WSTOPPED = placeholder();
497     public static final int WUNTRACED = placeholder();
498     public static final int W_OK = placeholder();
499     /** @hide */ public static final int XATTR_CREATE = placeholder();
500     /** @hide */ public static final int XATTR_REPLACE = placeholder();
501     public static final int X_OK = placeholder();
502     public static final int _SC_2_CHAR_TERM = placeholder();
503     public static final int _SC_2_C_BIND = placeholder();
504     public static final int _SC_2_C_DEV = placeholder();
505     public static final int _SC_2_C_VERSION = placeholder();
506     public static final int _SC_2_FORT_DEV = placeholder();
507     public static final int _SC_2_FORT_RUN = placeholder();
508     public static final int _SC_2_LOCALEDEF = placeholder();
509     public static final int _SC_2_SW_DEV = placeholder();
510     public static final int _SC_2_UPE = placeholder();
511     public static final int _SC_2_VERSION = placeholder();
512     public static final int _SC_AIO_LISTIO_MAX = placeholder();
513     public static final int _SC_AIO_MAX = placeholder();
514     public static final int _SC_AIO_PRIO_DELTA_MAX = placeholder();
515     public static final int _SC_ARG_MAX = placeholder();
516     public static final int _SC_ASYNCHRONOUS_IO = placeholder();
517     public static final int _SC_ATEXIT_MAX = placeholder();
518     public static final int _SC_AVPHYS_PAGES = placeholder();
519     public static final int _SC_BC_BASE_MAX = placeholder();
520     public static final int _SC_BC_DIM_MAX = placeholder();
521     public static final int _SC_BC_SCALE_MAX = placeholder();
522     public static final int _SC_BC_STRING_MAX = placeholder();
523     public static final int _SC_CHILD_MAX = placeholder();
524     public static final int _SC_CLK_TCK = placeholder();
525     public static final int _SC_COLL_WEIGHTS_MAX = placeholder();
526     public static final int _SC_DELAYTIMER_MAX = placeholder();
527     public static final int _SC_EXPR_NEST_MAX = placeholder();
528     public static final int _SC_FSYNC = placeholder();
529     public static final int _SC_GETGR_R_SIZE_MAX = placeholder();
530     public static final int _SC_GETPW_R_SIZE_MAX = placeholder();
531     public static final int _SC_IOV_MAX = placeholder();
532     public static final int _SC_JOB_CONTROL = placeholder();
533     public static final int _SC_LINE_MAX = placeholder();
534     public static final int _SC_LOGIN_NAME_MAX = placeholder();
535     public static final int _SC_MAPPED_FILES = placeholder();
536     public static final int _SC_MEMLOCK = placeholder();
537     public static final int _SC_MEMLOCK_RANGE = placeholder();
538     public static final int _SC_MEMORY_PROTECTION = placeholder();
539     public static final int _SC_MESSAGE_PASSING = placeholder();
540     public static final int _SC_MQ_OPEN_MAX = placeholder();
541     public static final int _SC_MQ_PRIO_MAX = placeholder();
542     public static final int _SC_NGROUPS_MAX = placeholder();
543     public static final int _SC_NPROCESSORS_CONF = placeholder();
544     public static final int _SC_NPROCESSORS_ONLN = placeholder();
545     public static final int _SC_OPEN_MAX = placeholder();
546     public static final int _SC_PAGESIZE = placeholder();
547     public static final int _SC_PAGE_SIZE = placeholder();
548     public static final int _SC_PASS_MAX = placeholder();
549     public static final int _SC_PHYS_PAGES = placeholder();
550     public static final int _SC_PRIORITIZED_IO = placeholder();
551     public static final int _SC_PRIORITY_SCHEDULING = placeholder();
552     public static final int _SC_REALTIME_SIGNALS = placeholder();
553     public static final int _SC_RE_DUP_MAX = placeholder();
554     public static final int _SC_RTSIG_MAX = placeholder();
555     public static final int _SC_SAVED_IDS = placeholder();
556     public static final int _SC_SEMAPHORES = placeholder();
557     public static final int _SC_SEM_NSEMS_MAX = placeholder();
558     public static final int _SC_SEM_VALUE_MAX = placeholder();
559     public static final int _SC_SHARED_MEMORY_OBJECTS = placeholder();
560     public static final int _SC_SIGQUEUE_MAX = placeholder();
561     public static final int _SC_STREAM_MAX = placeholder();
562     public static final int _SC_SYNCHRONIZED_IO = placeholder();
563     public static final int _SC_THREADS = placeholder();
564     public static final int _SC_THREAD_ATTR_STACKADDR = placeholder();
565     public static final int _SC_THREAD_ATTR_STACKSIZE = placeholder();
566     public static final int _SC_THREAD_DESTRUCTOR_ITERATIONS = placeholder();
567     public static final int _SC_THREAD_KEYS_MAX = placeholder();
568     public static final int _SC_THREAD_PRIORITY_SCHEDULING = placeholder();
569     public static final int _SC_THREAD_PRIO_INHERIT = placeholder();
570     public static final int _SC_THREAD_PRIO_PROTECT = placeholder();
571     public static final int _SC_THREAD_SAFE_FUNCTIONS = placeholder();
572     public static final int _SC_THREAD_STACK_MIN = placeholder();
573     public static final int _SC_THREAD_THREADS_MAX = placeholder();
574     public static final int _SC_TIMERS = placeholder();
575     public static final int _SC_TIMER_MAX = placeholder();
576     public static final int _SC_TTY_NAME_MAX = placeholder();
577     public static final int _SC_TZNAME_MAX = placeholder();
578     public static final int _SC_VERSION = placeholder();
579     public static final int _SC_XBS5_ILP32_OFF32 = placeholder();
580     public static final int _SC_XBS5_ILP32_OFFBIG = placeholder();
581     public static final int _SC_XBS5_LP64_OFF64 = placeholder();
582     public static final int _SC_XBS5_LPBIG_OFFBIG = placeholder();
583     public static final int _SC_XOPEN_CRYPT = placeholder();
584     public static final int _SC_XOPEN_ENH_I18N = placeholder();
585     public static final int _SC_XOPEN_LEGACY = placeholder();
586     public static final int _SC_XOPEN_REALTIME = placeholder();
587     public static final int _SC_XOPEN_REALTIME_THREADS = placeholder();
588     public static final int _SC_XOPEN_SHM = placeholder();
589     public static final int _SC_XOPEN_UNIX = placeholder();
590     public static final int _SC_XOPEN_VERSION = placeholder();
591     public static final int _SC_XOPEN_XCU_VERSION = placeholder();
592 
593     /**
594      * Returns the string name of a getaddrinfo(3) error value.
595      * For example, "EAI_AGAIN".
596      */
gaiName(int error)597     public static String gaiName(int error) {
598         if (error == EAI_AGAIN) {
599             return "EAI_AGAIN";
600         }
601         if (error == EAI_BADFLAGS) {
602             return "EAI_BADFLAGS";
603         }
604         if (error == EAI_FAIL) {
605             return "EAI_FAIL";
606         }
607         if (error == EAI_FAMILY) {
608             return "EAI_FAMILY";
609         }
610         if (error == EAI_MEMORY) {
611             return "EAI_MEMORY";
612         }
613         if (error == EAI_NODATA) {
614             return "EAI_NODATA";
615         }
616         if (error == EAI_NONAME) {
617             return "EAI_NONAME";
618         }
619         if (error == EAI_OVERFLOW) {
620             return "EAI_OVERFLOW";
621         }
622         if (error == EAI_SERVICE) {
623             return "EAI_SERVICE";
624         }
625         if (error == EAI_SOCKTYPE) {
626             return "EAI_SOCKTYPE";
627         }
628         if (error == EAI_SYSTEM) {
629             return "EAI_SYSTEM";
630         }
631         return null;
632     }
633 
634     /**
635      * Returns the string name of an errno value.
636      * For example, "EACCES". See {@link Os#strerror} for human-readable errno descriptions.
637      */
errnoName(int errno)638     public static String errnoName(int errno) {
639         if (errno == E2BIG) {
640             return "E2BIG";
641         }
642         if (errno == EACCES) {
643             return "EACCES";
644         }
645         if (errno == EADDRINUSE) {
646             return "EADDRINUSE";
647         }
648         if (errno == EADDRNOTAVAIL) {
649             return "EADDRNOTAVAIL";
650         }
651         if (errno == EAFNOSUPPORT) {
652             return "EAFNOSUPPORT";
653         }
654         if (errno == EAGAIN) {
655             return "EAGAIN";
656         }
657         if (errno == EALREADY) {
658             return "EALREADY";
659         }
660         if (errno == EBADF) {
661             return "EBADF";
662         }
663         if (errno == EBADMSG) {
664             return "EBADMSG";
665         }
666         if (errno == EBUSY) {
667             return "EBUSY";
668         }
669         if (errno == ECANCELED) {
670             return "ECANCELED";
671         }
672         if (errno == ECHILD) {
673             return "ECHILD";
674         }
675         if (errno == ECONNABORTED) {
676             return "ECONNABORTED";
677         }
678         if (errno == ECONNREFUSED) {
679             return "ECONNREFUSED";
680         }
681         if (errno == ECONNRESET) {
682             return "ECONNRESET";
683         }
684         if (errno == EDEADLK) {
685             return "EDEADLK";
686         }
687         if (errno == EDESTADDRREQ) {
688             return "EDESTADDRREQ";
689         }
690         if (errno == EDOM) {
691             return "EDOM";
692         }
693         if (errno == EDQUOT) {
694             return "EDQUOT";
695         }
696         if (errno == EEXIST) {
697             return "EEXIST";
698         }
699         if (errno == EFAULT) {
700             return "EFAULT";
701         }
702         if (errno == EFBIG) {
703             return "EFBIG";
704         }
705         if (errno == EHOSTUNREACH) {
706             return "EHOSTUNREACH";
707         }
708         if (errno == EIDRM) {
709             return "EIDRM";
710         }
711         if (errno == EILSEQ) {
712             return "EILSEQ";
713         }
714         if (errno == EINPROGRESS) {
715             return "EINPROGRESS";
716         }
717         if (errno == EINTR) {
718             return "EINTR";
719         }
720         if (errno == EINVAL) {
721             return "EINVAL";
722         }
723         if (errno == EIO) {
724             return "EIO";
725         }
726         if (errno == EISCONN) {
727             return "EISCONN";
728         }
729         if (errno == EISDIR) {
730             return "EISDIR";
731         }
732         if (errno == ELOOP) {
733             return "ELOOP";
734         }
735         if (errno == EMFILE) {
736             return "EMFILE";
737         }
738         if (errno == EMLINK) {
739             return "EMLINK";
740         }
741         if (errno == EMSGSIZE) {
742             return "EMSGSIZE";
743         }
744         if (errno == EMULTIHOP) {
745             return "EMULTIHOP";
746         }
747         if (errno == ENAMETOOLONG) {
748             return "ENAMETOOLONG";
749         }
750         if (errno == ENETDOWN) {
751             return "ENETDOWN";
752         }
753         if (errno == ENETRESET) {
754             return "ENETRESET";
755         }
756         if (errno == ENETUNREACH) {
757             return "ENETUNREACH";
758         }
759         if (errno == ENFILE) {
760             return "ENFILE";
761         }
762         if (errno == ENOBUFS) {
763             return "ENOBUFS";
764         }
765         if (errno == ENODATA) {
766             return "ENODATA";
767         }
768         if (errno == ENODEV) {
769             return "ENODEV";
770         }
771         if (errno == ENOENT) {
772             return "ENOENT";
773         }
774         if (errno == ENOEXEC) {
775             return "ENOEXEC";
776         }
777         if (errno == ENOLCK) {
778             return "ENOLCK";
779         }
780         if (errno == ENOLINK) {
781             return "ENOLINK";
782         }
783         if (errno == ENOMEM) {
784             return "ENOMEM";
785         }
786         if (errno == ENOMSG) {
787             return "ENOMSG";
788         }
789         if (errno == ENONET) {
790             return "ENONET";
791         }
792         if (errno == ENOPROTOOPT) {
793             return "ENOPROTOOPT";
794         }
795         if (errno == ENOSPC) {
796             return "ENOSPC";
797         }
798         if (errno == ENOSR) {
799             return "ENOSR";
800         }
801         if (errno == ENOSTR) {
802             return "ENOSTR";
803         }
804         if (errno == ENOSYS) {
805             return "ENOSYS";
806         }
807         if (errno == ENOTCONN) {
808             return "ENOTCONN";
809         }
810         if (errno == ENOTDIR) {
811             return "ENOTDIR";
812         }
813         if (errno == ENOTEMPTY) {
814             return "ENOTEMPTY";
815         }
816         if (errno == ENOTSOCK) {
817             return "ENOTSOCK";
818         }
819         if (errno == ENOTSUP) {
820             return "ENOTSUP";
821         }
822         if (errno == ENOTTY) {
823             return "ENOTTY";
824         }
825         if (errno == ENXIO) {
826             return "ENXIO";
827         }
828         if (errno == EOPNOTSUPP) {
829             return "EOPNOTSUPP";
830         }
831         if (errno == EOVERFLOW) {
832             return "EOVERFLOW";
833         }
834         if (errno == EPERM) {
835             return "EPERM";
836         }
837         if (errno == EPIPE) {
838             return "EPIPE";
839         }
840         if (errno == EPROTO) {
841             return "EPROTO";
842         }
843         if (errno == EPROTONOSUPPORT) {
844             return "EPROTONOSUPPORT";
845         }
846         if (errno == EPROTOTYPE) {
847             return "EPROTOTYPE";
848         }
849         if (errno == ERANGE) {
850             return "ERANGE";
851         }
852         if (errno == EROFS) {
853             return "EROFS";
854         }
855         if (errno == ESPIPE) {
856             return "ESPIPE";
857         }
858         if (errno == ESRCH) {
859             return "ESRCH";
860         }
861         if (errno == ESTALE) {
862             return "ESTALE";
863         }
864         if (errno == ETIME) {
865             return "ETIME";
866         }
867         if (errno == ETIMEDOUT) {
868             return "ETIMEDOUT";
869         }
870         if (errno == ETXTBSY) {
871             return "ETXTBSY";
872         }
873         if (errno == EXDEV) {
874             return "EXDEV";
875         }
876         return null;
877     }
878 
initConstants()879     private static native void initConstants();
880 
881     // A hack to avoid these constants being inlined by javac...
placeholder()882     private static int placeholder() { return 0; }
883     // ...because we want to initialize them at runtime.
884     static {
initConstants()885         initConstants();
886     }
887 }
888