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