Restore the record_stream code in cutils that was removed
in e00a12bf8a as part of cutils
cleanup.
Unfortunately, there are some prebuilt vendor libs that rely on
this functionality that we cannot currently rebuild.
Remove at the earliest possible convenience once the vendor libs
have been fixed.
Bug: 9189218
Change-Id: I5d44126756f1e3ed194d1b5873d64d9154183199
Signed-off-by: Dima Zavin <dima@android.com>
Only build property support for the device, not for the
host. Host side property support is being removed, as it
was only really used for the simulator.
process_name.c: When building this for the host, don't
reference properties.
Change-Id: Idcea5ad52a85e47eef17a381cb0601657efbdf13
Removed unused code and moved libraries with single clients
near their respective users.
Change-Id: I65f90f8659f27bd0f44ca5ddf33da2bce14674c1
Signed-off-by: Dima Zavin <dima@android.com>
Move the responsibility for rebooting the system from the
reboot command to init. Init is in a better position to take
actions to bring the system down cleanly, including making sure
filesystems are mounted read-only.
The only UIDs which can perform an init triggered reboot are
root, system, and shell.
Modify the reboot command so that it calls into init to perform
the reboot. The reboot command no longer requires CAP_SYS_BOOT.
Remove the -n reboot option and code which supports it. Anyone needing
to do an unclean shutdown can just do a 'echo c > /proc/sysrq-trigger'.
Modify adb so that it calls into init to perform a shutdown.
Bug: 8646621
Change-Id: I84c0513acb549720cb0e8c9fcbda0050f5c396f5
This change adds the atrace_set_tracing_enabled call to libcutils. The call
can be used to disable all tracing (of the atrace variety) for the current
process. This is to be used to disable tracing in the Zygote process, as there
is no way for Zygote to be notified of changes to the enabled trace tags.
Change-Id: I0b691cc0dcfc65b16e3d17e1db2866a4deb253a7
For some prebuilts were built against libcutils with liblog in it.
Unfortunately that means in the future if someone checks in prebuilts
that are built against libcutils and they don't explicitly link against
liblog, they will again prevent us from removing liblog from libcutils.
Bug: 8587800
Bug: 8580410
Change-Id: I2a5ed6233df7e7d542d1e4167bec405750c0e671
This change adds support for tracing using the ATRACE_TAG_APP tag. This tag is
enabled only for processes in which the /proc/<pid>/cmdline value appears in
the comma-separated list of such values in the debug.atrace.app_cmdlines system
property. It is also only enabled if either the ro.debuggable system property
is set to 1 or the application has declared itself debuggable in its manifest,
which gets reported to libcutils by the framework.
Change-Id: Ic94ba55f4e70a9cf994056acbf151e523428b65d
# By Duane Sand
# Via Android Git Automerger (2) and others
* commit '4b9bdd333362c1f58260c37306f1902fb215f7bf':
[MIPS] Benchmark test for MIPS memset16/memset32
The last caller of this code was removed in
dalvik commit eb1703442f3fc0577b3395b7eb4d55300b4125db
(https://android-review.googlesource.com/50689)
Change-Id: I3f4865c02092752a13369a3b2c3289fc9a4f6a62
(cherry-pick of d03072ffde. This change
was originally committed to AOSP, is in internal master, but was somehow
lost from AOSP.)
Bug: 7012465
Conflicts:
libcutils/Android.mk
Change-Id: I08ee8eb9b8ce5d3f9d8f2e67437d653e08697bc1
The various atomic operations are declared as inline in the header files
to cut the function call overhead. However, the plain inline keyword is
just a suggestion to the compiler which makes its own decision on whether
to inline them or not. Worst, if they are not inlined, the
-fvisibility-inlines-hidden compiler flag will render them as hidden
symbols in the object file. If they are picked up by the linker over the
ones supplied in libcutils.so the following warning will be reported:
warning: hidden symbol 'android_atomic_inc' in foo.o is referenced by
DSO bar.so
One way is to add __attribute__((visibility("default"))) to those inline
functions to suppress the linker warnings. A better way is to force
inlining as with this patch.
Change-Id: Ie4fcfdfaaf06f42d351619a0d89671a9df15ca2f
Adds a function to read the current trace system property value, and
sets the trace tags to it, do be used as a sysprop change callback.
Change-Id: Ia6336652173aa5b07188898736c2c795a69fe79a
Basic tracing functionality to cutils, which can be turned on at start,
or dynamically controlled by the frameworks. The goal is for hardware
modules to add tracing that will be controlled by their respective
services.
Change-Id: I84eeb7d6be0038f734e719074fa4a2fae4ffe9c0
system/core/libcutils/fs.c: In function 'fs_write_atomic_int':
system/core/libcutils/fs.c:109:5: warning: implicit declaration of function 'mkstemp' [-Wimplicit-function-declaration]
Change-Id: I337ecb818f85e20b058f782df45987acf2e9d6c1
When two zygotes are starting, they both may try creating a mount
point after checking lstat(). The second mkdir() will result in
EEXIST, which is okay to ignore.
Bug: 7165469
Change-Id: If4411e2621f773c74cd05247899982fa5ebdd020
Remove mspace functionality from cutils.
Directly declare mspace from dlmalloc in code flinger's code cache, and
manage without using morecore.
Depends upon: https://android-review.googlesource.com/41717
Change-Id: If927254febd4414212c690f16509ef2ee1b44b44
Remount rootfs as recursively shared, so that mount changes are
propagated into child namespaces. Mount external storage for access
from adb.
Clean multi-user dependencies for use in Dalvik. Also define
external storage paths.
Bug: 6925012
Change-Id: I375de581a63f4f36667894c56a34a9dd45361e8f
Provides a new mechanism for dumpstate (while running as root)
to request that debuggerd dump the stacks of native processes that
we care about in bug reports. In this mode, the backtrace
is formatted to look similar to a Dalvik backtrace.
Moved the tombstone generating code into a separate file to
make it easier to maintain.
Fixed a bug where sometimes the stack traces would be incomplete
because we were not waiting for each thread to stop after issuing
PTRACE_ATTACH, only the main thread. So sometimes we were missing
traces for some threads.
Refactored the logging code to prevent accidentally writing data
to logcat when explicitly dumping a tombstone or backtrace from the
console.
Only root or system server can request to dump backtraces but
only root can dump tombstones.
Bug: 6615693
Change-Id: Ib3edcc16f9f3a687e414e3f2d250d9500566123b
Adds an apps cgroup which will contain fg tasks. Move the bg group
nested underneath it.
Bug: 6538553
Change-Id: I55279415da625e15a5bb061c2b45fbe7f7a4c047
Signed-off-by: Dima Zavin <dima@android.com>
Also tid == 0 maps to gettid() on platforms that support it.
This is needed by mediaserver code that was formerly using
the old C++ API.
Change-Id: I8baaa3e42315c9b924cec26b6da01e7cb69e0078
This change adds a layer of indirection to uevent's
uevent_kernel_multicast_recv, allowing dependent code to
get the remote endpoint if desired.
Change-Id: If2f00708a1dd6196c415b1ebc2a7eeb72399a90e
qsort_r() is declared differently on BSD and GNU libc and
may be absent on other platforms.
Provide qsort_r_compat() which should work everywhere.
Change-Id: I17a9026573b1ed971ff7d79895e7eb41ba108807
This will make it easier to add additional policies (cgroups) if needed.
Also added comments to the sched_policy APIs.
Change-Id: I33ce1cc4deae10983241f7391294b7a512d2c47c
When removing one entry, we can't just remove it from the map since
key will not be freed. So, instead, search through the map for the key
and free it once it is found.
Change-Id: Id745c166a4acc5ea25f6d6cdbfe4f8fbc21cbbb3
Reported-by: Xin Qian <xqian@marvell.com>
Signed-off-by: Dima Zavin <dima@android.com>
Both libraries are needed to build four shared libraries in 64-bit
for 64-bit emulator with "-gpu on"
lib64OpenglRender.so
lib64EGL_translator.so
lib64GLES_CM_translator.so
lib64GLES_V2_translator.so
Change-Id: If57f72d4661a74f1d5e537568881f39132e0b43d
The strftime_tz() function is not a standard C library function and should not
appear in <time.h>. Instead, it is being moved to <bionic_time.h>, a private
header only available to platform libraries.
Change-Id: I4dc18939b9380725dfaa20c9e417296363bc52f4
* Add support for
deleteTagData(tag, uid)
setCounterSet(counterSetNum, uid)
setPacifier(on)
* Add resource tracking
(If only kernel process termination had a hook)
Because the xt_qtaguid netfilter module needs to keep track of
tagged sockets, it needs a way to know when the process owning
the socket has died.
Normally the app will untag the sockets. But not on crash.
So the process opens the qtaguid misc dev, which is closed on crash,
at which point the xt_qtaguid can force-untag the processes sockets,
and thus allowing their refcount to go down and release them.
* Add pacifier support
Add function to enable/disable pacification of the xt_qtaguid
kernel module. (mostly for debugging)
Change-Id: I7f2228e65208046dd37ec1c7407ee307d5ba9b99
This adds a new function to libcutils, partition_wiped().
This is used to determine if a partition is wiped.
Change-Id: Ibb388976c6b5bd3923b62d8f79b2b97748abf6c1
If the callback passed to forEach tries to remove the element it was passed,
there's a use-after-free of the entry pointer in forEach.
Change-Id: Ia364b4775c9c55780b23f683b30cbff511b7f944
Signed-off-by: Dima Zavin <dima@android.com>
Backport Iee1ca9b7defd6
This now passes:
$ adb shell am instrument -w -e class android.os.SystemPropertiesTest \
com.android.frameworks.coretests.systemproperties/android.test.InstrumentationTestRunner
(which tests setting and re-reading back system properties in a loop)
This patch depends on I110b653a which moves property setting
from libcutils into bionic.
Bug: 3511230
Change-Id: I145e642bd13079677017bb64e361e176fc73b810
Ext4 filesystems like to be unmounted before rebooting. The Android system
doesn't have a traditional Linux init setup, and shutting down the system
was not much more than calling sync(2) and reboot(2). This adds a new
function to libcutils called android_reboot(). By default, it calls sync()
and then remounts all writable filesystems as read-only and marks them clean.
There is a flag parameter in which the caller can ask for sync() not to be
called, or to not remount the filesystems as read-only. Then it will call
reboot(2) as directed by the other parameters. This change also updates
adb, init and toolbox to call the new android_reboot() function.
Fixes bugs 3350709 and 3495575.
Change-Id: I16d71ffce3134310d7a260f61ec6f4dd204124a7
This now passes:
$ adb shell am instrument -w -e class android.os.SystemPropertiesTest \
com.android.frameworks.coretests.systemproperties/android.test.InstrumentationTestRunner
(which tests setting and re-reading back system properties in a loop)
This patch depends on I110b653a which moves property setting
from libcutils into bionic.
Bug: 3511230
Change-Id: Iee1ca9b7defd6060510a01f40fbe63ba4c96eb8d
This change moves the ARM definitions into GCC extended inline
assembler. In addition, the same set of x86 definitions are now
shared among all x86 targets.
Change-Id: I6e5aa3a413d0af2acbe5d32994983d35a01fdcb3
Added new atomic functions, renamed some old ones. Some #defines have
been added for backward compatibility.
Merged the pre- and post-ARMv6 implementations into a single file.
Renamed the semi-private __android_membar_full_smp to USE_SCREAMING_CAPS
since that's more appropriate for a macro.
Added lots of comments.
Note Mac OS X primitives have not been tested.
Change-Id: If827260750aeb61ad5c2b760e30658e29dbb26f2
Added atomic-inline.h. Added a platform-specific memory barrier call
there.
Added android_atomic_acquire_cmpxchg() and android_atomic_release_store().
Not tested on Mac OS X or SH.
Added memory barrier calls to linux-x86 atomics. Mac OS X has barrier
functions already. sh isn't really SMP-ready. linux-arm needs work
(to be done in a separate change).
Updated the makefile to make the SMP state visible to the code here.
Note that host binaries are NOT built with SMP enabled; while our hosts
are very likely SMP, it's not worth figuring out e.g. whether it's okay
to use the SSE2 mfence instruction or have to use something else. We
haven't had barriers enabled in host tools before, so there's probably
no need to stat now.
Removed quasiatomic 64-bit calls (now part of Dalvik).
Change-Id: I49e5e6c8abe70f304cdedb9d7b8e6e65f8925815
Re-use the file descriptor to change the cgroups. There's a fast path
in the kernel for the case where the value's already uncahnged. Also,
this is okay because the kernel ignores the write offset. This is
essentially a ioctl-ish/datagram interface, despite being a fd we're
writing to.
This reduces Dalvik->Dalvik void/void Binder calls on Sapphire from
~1.2 to ~0.8 ms. This is a bit slower than the ~0.7 ms we get
avoiding the write altogether.
strace confirms:
[pid 1557] ioctl(21, 0xc0186201 <unfinished ...>
[pid 1556] <... ioctl resumed> , 0x45399cd0) = 0
[pid 1556] write(22, "1556", 4) = 4
[pid 1556] ioctl(21, 0xc0186201 <unfinished ...>
[pid 1555] <... ioctl resumed> , 0x45299cd0) = 0
[pid 1555] write(22, "1555", 4) = 4
[pid 1555] ioctl(21, 0xc0186201 <unfinished ...>
[pid 1554] <... ioctl resumed> , 0x45199cd0) = 0
[pid 1554] write(22, "1554", 4) = 4
BUG=2660235
Change-Id: Ia9f9e1d5b792eaebc9560f89931faf6df0cf9c0d
- use static /dev/cpuctl filenames, rather than sprintf() on the fly
- use a custom formatter instead of sprintf() for the tid number
This is a simplified version of Dan's original
Ifc9c81f74fe65f0695ead53b30194bc6adf00da0 to be less risky for Froyo.
Bug: 2660235
Change-Id: I744bbc2ec01fd2569612c814a497df40a933b622
This routine allows creating a contiguous mspace from raw mapped memory.
In turn, this will enable preallocation of the 3 heap spaces, which will help
remembered sets and zygote/app checks given pointer values.
POSIX seems to have chosen open_memstream() over the BSD variant. We
want something for Dalvik that will work on both GNU/Linux and Android,
so this is open_memstream() implemented in terms of BSD funopen().
For Windows there's just a stub that calls abort().
I'm putting this in libcutils since it seems inappropriate for bionic
(which provides the BSD alternatives) but isn't Dalvik-specific.
Merge commit 'f95837a1e13c9b63bfe0b0f95f00ec0d72ba2e74'
* commit 'f95837a1e13c9b63bfe0b0f95f00ec0d72ba2e74':
system: sched_policy: Don't return an error when the thread we're trying to move exits on us
Merge commit 'cf9f442ef336d4fb6300318a3137b23a4697e048' into eclair-mr2-plus-aosp
* commit 'cf9f442ef336d4fb6300318a3137b23a4697e048':
system: sched_policy: Don't return an error when the thread we're trying to move exits on us
Merge commit '9fdf607c20f9610e442baa87cac5479c98f9d200'
* commit '9fdf607c20f9610e442baa87cac5479c98f9d200':
cutils: make set_process_name set kernel thread name as well
Merge commit 'b63747d4d9d2e26c90a5310c996210e722159d04' into eclair-mr2-plus-aosp
* commit 'b63747d4d9d2e26c90a5310c996210e722159d04':
cutils: make set_process_name set kernel thread name as well
Merge commit '525fb03e18f9b08651e3d8abb262d70c3482b405'
* commit '525fb03e18f9b08651e3d8abb262d70c3482b405':
cutils: sched_policy: Fix bug where we were unable to move backgrounded threads into the foreground
Merge commit '58e50f80307577268ecb6b86aa97236e008a9aa0' into eclair-mr2-plus-aosp
* commit '58e50f80307577268ecb6b86aa97236e008a9aa0':
cutils: sched_policy: Fix bug where we were unable to move backgrounded threads into the foreground
Merge commit '38b2ddc4a7cf1c47397af118a6d466d45f59da04'
* commit '38b2ddc4a7cf1c47397af118a6d466d45f59da04':
cutils: Add support for reading a processes scheduler policy
Merge commit '17bfbd3ccbb798aa4068cd59150ce712660a62a4' into eclair-mr2-plus-aosp
* commit '17bfbd3ccbb798aa4068cd59150ce712660a62a4':
cutils: Add support for reading a processes scheduler policy
Merge commit '62f39c105af8789fd9308fa6a5b91f0963a7c59b'
* commit '62f39c105af8789fd9308fa6a5b91f0963a7c59b':
adb: Add "adb disconnect" command for disconnecting TCP/IP devices.
Add support for Acer devices
adb: Add USB Vendor IDs for LG and Huawei
Add NOTICE file and license tag for adb
adb: Clean up argument passing for create_service_thread()
Revert "adb: Another attempted workaround for the adb disconnect problem."
libsysutils: Fix some bugs in NetlinkListener and NetlinkEvent
added SuperH atomic support to libcutils
This introduces a new HAVE_SCHED_H arch define, which is used
to prevent from building sched_policy.c during the Windows SDK.
Change-Id: I3667857a4ae7d6baaf1efd1cd187a5baf91419d8
The problem is that time_t is signed, and the original code relied on the
fact that (X + c < X) in case of overflow for c >= 0. Unfortunately, this
condition is only guaranteed by the standard for unsigned arithmetic, and
the gcc 4.4.0 optimizer did completely remove the corresponding test from
the code. This resulted in a missing boundary check, and an infinite loop.
The problem is solved by testing explicitely for TIME_T_MIN and TIME_T_MAX
in the loop that uses this.
Also fix increment_overflow and long_increment_overflow which were buggy
for exactly the same reasons.
Also remove some compiler warnings.
Note: a similar fix was performed in bionic/libc
ARMv6 onwards. These architectures provide the load-linked, store-conditional pair of ldrex/strex whose use
is recommended in place of 'swp'. Also, the description of the 'swp' instruction in the ARMv6 reference
manual states that the swap operation does not include any memory barrier guarantees.This fix attempts to
address these issues by providing an atomic swap implementation using ldrex/strex under _ARM_HAVE_LDREX_STREX
macro. _ARM_HAVE_LDREX_STREX macro is defined in cpu-features.h file and patch is submitted under change ID 11088.
This Fix is verified on ST Ericsson's U8500 platform and Submitted on behalf of a third-party:
Surinder-pal SINGH from STMicroelectronics.
This is needed by the MemoryFile changes in
https://android-git.corp.google.com/g/2714
where it is used to find out whether a file descriptor
refers to an ashmem region.
asocket_connect()
asocket_accept()
asocket_read()
asocket_write()
These calls are similar to the regular syscalls, but can be aborted with:
asocket_abort()
Calling close() on a regular POSIX socket does not abort blocked syscalls on
that socket in other threads.
After calling asocket_abort() the socket cannot be reused.
Call asocket_destory() *after* all threads have finished with the socket to
finish closing the socket and free the asocket structure.
The helper is implemented by setting the socket non-blocking to initiate
syscalls connect(), accept(), read(), write(), then using a blocking poll()
on both the primary socket and a local pipe. This makes the poll() abortable
by writing a byte to the local pipe in asocket_abort().
asocket_create() sets the fd to non-blocking mode. It must not be changed to
blocking mode.
Using asocket will triple the number of file descriptors required per
socket, due to the local pipe. It may be possible to use a global pipe per
process rather than per socket, but we have not been able to come up with a
race-free implementation yet.
All functions except asocket_init() and asocket_destroy() are thread safe.
asocket_connect()
asocket_accept()
asocket_read()
asocket_write()
These calls are similar to the regular syscalls, but can be aborted with:
asocket_abort()
Calling close() on a regular POSIX socket does not abort blocked syscalls on
that socket in other threads.
After calling asocket_abort() the socket cannot be reused.
Call asocket_destory() *after* all threads have finished with the socket to
finish closing the socket and free the asocket structure.
The helper is implemented by setting the socket non-blocking to initiate
syscalls connect(), accept(), read(), write(), then using a blocking poll()
on both the primary socket and a local pipe. This makes the poll() abortable
by writing a byte to the local pipe in asocket_abort().
asocket_create() sets the fd to non-blocking mode. It must not be changed to
blocking mode.
Using asocket will triple the number of file descriptors required per
socket, due to the local pipe. It may be possible to use a global pipe per
process rather than per socket, but we have not been able to come up with a
race-free implementation yet.
All functions except asocket_init() and asocket_destroy() are thread safe.
Merge commit '414ff7d98ac8d7610a26206335954ad15f43f3ac'
* commit '414ff7d98ac8d7610a26206335954ad15f43f3ac':
Move fdevent from libcutils into adb directory. ADB is the only client of this API, and I intend to modify it extensively to clean its codebase soon.
Merge commit '722a5c0462f38827f4097065bfc3826b9e0e9fb4'
* commit '722a5c0462f38827f4097065bfc3826b9e0e9fb4':
Add support for "standalone months" to tztime's strftime().
The idea here is that some languages need a different form of the month
name in constructions like "January 2" than in "January 2009", since the
one in the "January 2" case really means "of January." So with this change,
a format string of "%-B" will use the standalone month, while "%B" will
continue to use the format month.