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.