Commit graph

69 commits

Author SHA1 Message Date
Josh Gao
34c599a8b0 Add __INTRODUCED_IN_FUTURE for unreleased APIs.
Future API levels aren't known (e.g. 25 could be a maintenance release
of N that doesn't contain any bionic updates), so use a placeholder
macro that we can find and replace with the actual API level before each
release.

Bug: http://b/28178111
Change-Id: I667fe53ea1ac49b64135170fc30d5dbe9df94e29
2016-04-29 16:39:50 -07:00
Josh Gao
14adff1cfa Add versioning information to symbols.
Bug: http://b/28178111
Change-Id: I46bf95accd819f4521afb1173d8badcc5e9df31c
2016-04-29 16:39:50 -07:00
Josh Gao
8c8ef5965d Move <sys/sysconf.h> to <bits/sysconf.h>.
Also remove unneeded declaration of sysconf in <unistd.h>.

Bug: http://b/28067717
Change-Id: Ife4692e48ca97480e422db0686c61133e1d619aa
2016-04-07 18:02:00 -07:00
Josh Gao
7449e599d8 Extract getopt and friends to <bits/getopt.h>
Bug: http://b/28067717
Change-Id: If19653d0da8b964c43768aa1051f9c926b3c6acb
2016-04-07 18:01:59 -07:00
Josh Gao
98e574c8de Extract ioctl to <bits/ioctl.h>.
Bug: http://b/28067717
Change-Id: I93625d19fa5a033ab22c650d536e98674f0a8d9d
2016-04-07 18:01:59 -07:00
Josh Gao
ee8d169997 Extract fcntl to <bits/fcntl.h>.
Bug: http://b/28067717
Change-Id: Id8c19056244660a6e0276a5614282af8d41fbe1e
2016-04-07 18:01:59 -07:00
Greg Hackmann
e2faf07d65 Add {get,set}domainname(2)
{get,set}domainname aren't in POSIX but are widely-implemented
extensions.

The Linux kernel provides a setdomainname syscall but not a symmetric
getdomainname syscall, since it expects userspace to get the domain name
from uname(2).

Change-Id: I96726c242f4bb646c130b361688328b0b97269a0
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2016-03-25 14:16:58 -07:00
Elliott Hughes
5704c423c8 Implement POSIX lockf.
This has been requested a few times over the years. This is basically
a very late rebase of https://android-review.googlesource.com/45470
which was abandoned years ago. One addition is that this version has
_FILE_OFFSET_BITS=64 support.

POSIX puts this in <unistd.h>. glibc also has it in <fcntl.h>.

Bug: http://b/13077650
Change-Id: I5862b1dc326e326c01ad92438ecc1578d19ba739
2016-01-26 11:09:44 -08:00
Dan Albert
af4713e6a5 Unify unistd.h.
Make unistd.h usable from all platform versions.

Also name all function parameters for Android Studio.

Bug: http://b/21952040
Change-Id: Ia1777fd4a6d4e37f25cc402c28fb78c003e481e3
2015-09-04 13:02:09 -07:00
Daniel Micay
afdd15456a add fortified implementations of write/pwrite{,64}
These are just based on the read/pread{,64} implementations with the
function calls and error messages adjusted as appropriate. The only
difference is that the buffer parameters are const.

Change-Id: Ida1597a903807f583f230d74bcedffdb7b24fcf6
2015-08-20 13:46:51 -04:00
Daniel Micay
9101b00400 add a fortified implementation of getcwd
Change-Id: Ice3e6d3e1ff07788305dc85f8ee4059baad5fac4
2015-08-01 00:42:30 -04:00
Daniel Micay
42281880a8 add fortified readlink/readlinkat implementations
Change-Id: Ia4b1824d20cad3a072b9162047492dade8576779
2015-04-17 18:49:12 -04:00
Daniel Micay
e7e1c875b0 add fortified implementations of pread/pread64
Change-Id: Iec39c3917e0bc94371bd81541619392f5abe29b9
2015-04-16 10:33:35 -04:00
Yabin Cui
8c41eae6fc Merge "Move getusershell/endusershell/setusershell to ndk_cruft.cpp." 2015-02-25 00:00:51 +00:00
Yabin Cui
7fb680bfda Move getusershell/endusershell/setusershell to ndk_cruft.cpp.
Bug: 19108648
Change-Id: I65134040345398dde612c4325d902db58f3bd2be
2015-02-24 14:46:59 -08:00
Elliott Hughes
4c5891d93d valgrind can't find syscall because we didn't put it in <unistd.h>.
Change-Id: I1e47291d4476bd2816138a8cf58f29d4986d39e3
2015-02-19 22:49:44 -08:00
Elliott Hughes
1dbc6bb025 Merge "Implement _FILE_OFFSET_BITS (mostly)." 2015-02-18 18:01:05 +00:00
Elliott Hughes
68dc20d411 Implement _FILE_OFFSET_BITS (mostly).
I still don't think we can make stdio's fseeko and ftello work, but we can
have everything else, and very few programs use fseeko/ftello (and they can
just refrain from using _FILE_OFFSET_BITS and be no worse off than they are
today).

Bug: 11865851
Change-Id: Ic3cb409aae6713f4b345de954bcc4241fcd969ec
2015-02-17 19:54:43 -08:00
Elliott Hughes
92b9c6ff3e POSIX says flock is in <sys/file.h>, not <unistd.h>.
Bug: 19392265
Change-Id: I14d0b56883f0354e13db04a1d140b8f60dae08d7
2015-02-17 09:08:24 -08:00
Elliott Hughes
1ed337dbdf Clean up SEEK_SET definitions.
If we lose the #ifndef, the compiler will tell us if the definitions
of SEEK_SET and friends ever get out of sync.

Change-Id: I357cabec7c9cd451c604342344f210bba20fb6bc
2015-02-02 14:02:09 -08:00
Elliott Hughes
a381fe8ebc Fix ptsname(3) and ttyname(3) to use TLS.
Be safe by default.

Change-Id: I6c4a3f1fd4eee3a651b3162ce95b7e873de57521
2014-12-09 20:30:23 -08:00
Elliott Hughes
60d84af172 sysconf(3) returns long.
On LP32, this makes no difference. Not an ABI change.

On LP64, results are going to be in %rax or x0 whether they're 32- or 64-bit,
and the only difference is going to be whether the top bits are clobbered.

Bug: 18390956
Change-Id: I0bd4496231bdded34c1fa03e895021ac0df7f8e1
2014-11-14 15:14:44 -08:00
Elliott Hughes
b86a4c7f65 Add sethostname(2).
Not very useful, but helps building stuff like toybox out of the box.

Change-Id: I110e39030452bd093a84278e019c5752d293718d
2014-11-07 16:48:27 -08:00
Dan Albert
658727e111 Inline helpers need to be exported unmangled.
__open_2() is used by the fortify implementation of open(2) in
fcntl.h, and as such needs an unmangled C name. For some reason
(inlining?), this doesn't cause problems at the default optimization
level, but does for -O0.

The rest of these didn't cause build failures, but they look suspect
and probably will, we just haven't caught them yet.

Bug: 17784968
Change-Id: I7391a7a8999ee204eaf6abd14a3d5373ea419d5b
2014-10-07 16:46:47 -07:00
Elliott Hughes
31165edf57 CLOEXEC support in fdopen, freopen, and mkostemp/mkostemps.
Change-Id: I74ea88e0d4973d6ab3c57da7d8bb643c31592b14
2014-09-23 18:21:52 -07:00
Elliott Hughes
a186b2e0ca Clean up fpathconf(3)/pathconf(3).
fpathconf(3) and pathconf(3) can share code. There's no such
header file as <pathconf.h>. glibc/POSIX and BSD disagree about where
the _POSIX_* definitions should go.

Change-Id: I4a67f1595c9f5fbb26700a131178eedebd6bf712
2014-09-22 22:49:40 +00:00
Elliott Hughes
f4c948a9e9 Move the meat of <features.h> into <sys/cdefs.h>.
This way it's a lot harder for us to screw up (since we should always
be including <sys/cdefs.h> anyway).

Bug: 14659579
Change-Id: I23070fff3296b0d1c683bb5e3a6e214146327d53
2014-08-19 11:18:20 -07:00
Elliott Hughes
5f5cc45cf0 Fix <features.h> (_BSD_SOURCE and _GNU_SOURCE).
<features.h> is supposed to take user-settable stuff like _GNU_SOURCE
and _BSD_SOURCE and turn them into __USE_GNU and __USE_BSD for use in
the C library headers. Instead, bionic used to unconditionally define
_BSD_SOURCE and _GNU_SOURCE, and then test _GNU_SOURCE in the header
files (which makes no sense whatsoever).

Bug: 14659579
Change-Id: Ice4cf21a364ea2e559071dc8329e995277d5b987
2014-08-18 16:04:03 -07:00
Elliott Hughes
2cfb4e8e2e Improve <sys/cdefs.h>.
Fix and use __RENAME (and lose ___RENAME --- two underscores should be
enough for anybody). This was the point of this change, because I want
to use __RENAME to support the two basename variants and the two
strerror_r variants.

Lose a bunch of macros that weren't being used.

Lose three dead files from the DNS code.

Change-Id: I3ef645c566b16a52217bc2e68c7d54b37c7c9522
2014-08-18 14:45:42 -07:00
Elliott Hughes
f4c1a36a45 Remove declarations for things that don't exist.
The <grp.h> ones prevent gdb from building out of the box.

Change-Id: I0efbffad2215cfcd75b4d442dfc972444b51d97c
2014-07-29 16:57:47 -07:00
Elliott Hughes
4916706cfe Fix linkage of grantpt(3).
Also clean up the implementation of all the pty functions, add tests,
and fix the stub implementations of ttyname(3) and ttyname_r(3).

Bug: https://code.google.com/p/android/issues/detail?id=58888
Change-Id: I0fb36438cd1abf8d4e87c29415f03db9ba13c3c2
2014-07-25 19:55:23 -07:00
Elliott Hughes
9c07aee83b Clean up some misinformation around prctl.
prctl shouldn't be in <unistd.h>.

Change-Id: I29609fc91c033e1ad143b75d9b4eb17aefbd63d6
2014-07-18 16:15:32 -07:00
Dan Albert
462abab12b Removes getdtablesize(3) from LP64.
getdtablesize(3) was removed fro POSIX 2004. Keep the symbol around in LP32 for
binary compatibility, but remove the declaration from unistd.h.

Bug: 13935372
Change-Id: I1f96cd290bf9176f922dad58bd5a7ab2cae7ef0f
2014-06-16 10:12:37 -07:00
Elliott Hughes
b27a840f4b Add __pure2 to a few more functions, most notably gettid and pthread_self.
Change-Id: I7eee9f26f45130038af09d8285782b07f70a996f
2014-06-11 16:32:10 -07:00
Elliott Hughes
b4e099c6f7 Remove issetugid.
Bug: 14569474
Change-Id: I752c77ed53c724f144f0b618443eb95e87f2929a
2014-05-29 16:43:01 -07:00
Dan Albert
a7821b7121 Use __typeof__() instead of typeof()
typeof() is a gcc builtin and is not always available (such as clang when
-std=c*). Both gcc and clang always expose __typeof__(), so just use that.

Change-Id: I75e2a990acc35f6f39b2c353f6548100ec03c67f
2014-05-27 12:47:54 -07:00
Elliott Hughes
58d9e280d4 Switch to the upstream OpenBSD getenv/putenv/setenv implementation.
This fixes all the bugs found by the new tests.

Change-Id: Id5a5f9f39a0620208bafa053f871a044725b4795
2014-04-22 17:41:00 -07:00
Elliott Hughes
0133944b09 Clean up our OpenBSD usage.
Also undo some of the mess where we have OpenBSD <stdio.h> but a mix of
different BSD's implementations.

In this first pass, I've only moved easy OpenBSD stuff.

Change-Id: Iae67b02cde6dba9d8d06fedeb53efbfdac0a8cf6
2014-02-21 14:30:18 -08:00
Elliott Hughes
a6ecba4d23 Clean up cacheflush.
No cacheflush for LP64; use the GCC builtin instead. Clean up the
32-bit MIPS implementation now we no longer need to worry about
old versions of GCC.

Bug: 12924756
Change-Id: Ie23955b3ec194e226c4b2bce35b11d5e061f4753
2014-02-11 10:24:40 -08:00
Elliott Hughes
ab61eb366a Switch to upstream sleep(3) and usleep(3).
Also fix the signature of usleep, and the definition of useconds_t which
should be unsigned, as the 'u' in its name implies.

This patch also cleans up the existing FreeBSD hacks by moving the libm
stuff from <sys/cdefs.h> to a libm-private header, and adding comments
about the hacks we use to build FreeBSD source.

Change-Id: Ibe5067a380502df94a0a3a7901969b35411085b6
2013-11-20 16:24:16 -08:00
Elliott Hughes
cac7b9d6ec Remove dependencies on obsolete __ARCH_WANT_SYSCALL_NO_FLAGS syscalls.
(aarch64 kernels only have the newer system calls.)

Also expose the new functionality that's exposed by glibc in our header files.

Change-Id: I45d2d168a03f88723d1f7fbf634701006a4843c5
2013-10-23 09:48:29 -07:00
Elliott Hughes
f8fcfbc85a Move away from the __ARCH_WANT_SYSCALL_NO_AT system calls.
Modern architectures only get the *at(2) system calls. For example,
aarch64 doesn't have open(2), and expects userspace to use openat(2)
instead.

Change-Id: I87b4ed79790cb8a80844f5544ac1a13fda26c7b5
2013-10-22 16:31:01 -07:00
Nick Kralevich
b036b5ca36 FORTIFY_SOURCE: fortify read()
Change-Id: Ic7de163fe121db13e00560adb257331bc709814d
2013-10-09 20:17:03 -07:00
Nick Kralevich
8d25327639 Revert "FORTIFY_SOURCE: fortify read()"
This change reverts
* fb3f956d07.
* 65c99de2cb

Change-Id: Id5774eeede41130579115cf67a72ee914f2b47d5
2013-10-09 16:46:25 -07:00
Nick Kralevich
65c99de2cb FORTIFY_SOURCE: fortify read()
Change-Id: I3d7b4ec86d04efb865117ce7629a2e26917f3331
2013-10-09 13:44:38 -07:00
Elliott Hughes
b4f7616fd6 Ensure we have the off64_t variant of every function that takes an off_t.
Change-Id: Ib2eee0cf13162be3b62559b84e90c6dcf5aab1c3
2013-09-19 16:27:24 -07:00
Bernhard Rosenkraenzer
9ae59c02ca Declare __page_shift and __page_size with C linkage.
__page_shift and __page_size were accidentally declared in unistd.h with
C linkage - their implementation needs to use the same linkage.

Going forward, though, let's stop the inlining madness and let's kill
the non-standard __getpageshift(). This patch takes getpagesize(3) out
of line and removes __getpageshift but fixes __page_shift and __page_size
for backwards binary compatibility.

Change-Id: I35ed66a08989ced1db422eb03e4d154a5d6b5bda
Signed-off-by: Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>
2013-09-19 11:55:36 -07:00
Nick Kralevich
6524d3cad7 unistd.h: don't include sys/capability.h
Don't pull in unnecessary header files. AFAIK, I've fixed all
the code which didn't include the correct header files.

Change-Id: If0b7bba74e77cb24a0cf9ce8968aa07400855e58
2013-03-01 10:10:55 -08:00
Nick Kralevich
7c0dd555c0 libc: create sys/capability.h
Per "man capset", sys/capability.h is the appropriate header file
for the capget / capset definition, not unistd.h. Fixed.

As a short term hack, continue to include sys/capability.h in
unistd.h, until we can fix all the code which uses capget / capset.

Change-Id: I6e7cf55955d761ca785a14c5e4b7a44125d8fc15
2013-02-26 13:27:15 -08:00
Irina Tirdea
1ad10a566e Add getsid system call to bionic
Add getsid() system call to bionic for
all architectures. This is needed for various tools
(e.g. perf).

Adding the getsid system call was done in 3 steps:
() add getsid system call (function name and syscall
number) to libc/SYSCALLS.TXT
() generate all necessary headers by calling
libc/tools/gensyscalls.py. This patch is adding
the generated files since the build system
does not call gensyscalls.py.
() add the system call signature to libc/include/unistd.h

Change-Id: Id69a257e13ec02e1a44085a6b217a3f19ab025b1
Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
2012-09-03 01:38:34 +03:00