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