Compare commits

..

123 Commits

Author SHA1 Message Date
Nick Pelly
7bbd4580af Add pn544.h clean kernel header
Allows pn544 hardware reset

Change-Id: I6d6d22b16c228f03a70a14a4655a41005761b5d6
Signed-off-by: Nick Pelly <npelly@google.com>
2010-11-01 15:49:19 -05:00
David 'Digit' Turner
1df986c21e libc: fix executable destruction support.
This change allows an executable to call its destructor functions
(declared with __attribute__((destructor))) to be properly called
when it normally exits.

Note that this is different from calling the destructors of a shared
library when it is unloaded with dlclose() or through program exit,
which are already supported.

Bug: 3106500
Change-Id: I1412ef5407f13b613fc6cb6103e0a691dbee4b1a
2010-10-21 04:16:50 +02:00
David 'Digit' Turner
d3f0638aee libc: fix typo in waitid() declaration.
The implementation file uses the correct spelling.

Change-Id: I572e336f8695a9754267c8d2e0a67b1b69bacb06
2010-10-13 15:46:55 +02:00
David 'Digit' Turner
1aa6708cc2 Fix the build. Oops.
(We remove the declaration for on_exit() from the C library headers,
so do the same for the C++ <cstdlib>)

Change-Id: I31a21d5643068cd160724908dd8156863a44d95a
2010-10-11 15:27:39 +02:00
David 'Digit' Turner
b8d2233e8a Merge "libc: tag missing functions in system headers." into gingerbread 2010-10-11 06:01:52 -07:00
David 'Digit' Turner
bb5581ad6e libc: tag missing functions in system headers.
This matches recent changes in the NDK header.
We enclose missing functions in #if 0 .. #endif blocks
with a clear "MISSING" in comments in order to locate
them later.

Change-Id: I87b3a62e777897e75c9243360fb0a82bcc53d9fb
2010-10-09 17:56:55 +02:00
David 'Digit' Turner
5b81b91817 libc: optimize memmove() with memcpy() if possible.
Change-Id: I90e578fdc82e427caee8fa4157ce3f8c6c99926d
2010-10-07 11:03:32 +02:00
Marco Nelissen
af00228b70 Revert "libc: memmove(): non-overlapping block optim."
This reverts commit 80fba9a2fe,
which caused the system to not boot anymore, aborting with:
"java.lang.RuntimeException: Missing static main on com.android.server.SystemServer".

Change-Id: I745e0a23c728cccf5f95a3c7642d544478a4e57e
2010-09-28 10:24:20 -07:00
David 'Digit' Turner
defd162212 libc: add <sys/eventfd.h> and corresponding implementations.
Change-Id: Ide040884c456190226e580513099fdb8377e015b
2010-09-28 09:20:37 +02:00
David 'Digit' Turner
9973a56422 libc: Add missing waitid() implementation.
Change-Id: I312ee608dbf9249e4886a10d45d13e3cda8a9042
2010-09-28 09:18:26 +02:00
David 'Digit' Turner
a3ae60d343 libc: Add missing fdatasync() implementation
Change-Id: I04bb655d77e414021e1f2a973329167ad76ca1c4
2010-09-28 09:17:17 +02:00
David 'Digit' Turner
307aadb847 Merge "libc: Add missing C++ guards to <pathconf.h>" into gingerbread 2010-09-28 00:15:23 -07:00
David 'Digit' Turner
79260746db Merge "libc: memmove(): non-overlapping block optim." into gingerbread 2010-09-28 00:15:05 -07:00
David 'Digit' Turner
032a713549 Merge "libc: add missing O_CLOEXEC from <fcntl.h>" into gingerbread 2010-09-28 00:12:13 -07:00
David 'Digit' Turner
223ddfcfc4 Merge "libc: Add missing pipe2() declaration and implementation." into gingerbread 2010-09-28 00:12:08 -07:00
David 'Digit' Turner
9df22a5a5f Merge "libm: remove aliasing issue." into gingerbread 2010-09-28 00:11:58 -07:00
David 'Digit' Turner
ce2ebf8d73 libm: remove aliasing issue.
See http://code.google.com/p/android/issues/detail?id=6697
for details about this change.

Change-Id: I516f00c6f3bc99b22be51669e4573246bdd6e33d
2010-09-27 17:35:48 +02:00
David 'Digit' Turner
bd8d987b3c libc: remove C++ comments from public headers.
Change-Id: I4af84f912062cd2ff34711c25122fb323f20c032
2010-09-27 17:35:26 +02:00
David 'Digit' Turner
80fba9a2fe libc: memmove(): non-overlapping block optim.
Change-Id: I5652f4f97ca59d95176443fc27c737ef76258183
2010-09-27 17:34:41 +02:00
David 'Digit' Turner
00eea3f8a0 libc: add missing O_CLOEXEC from <fcntl.h>
Change-Id: Ie7ad57898e67800a9fe92bb52589d67ec30e1cd9
2010-09-27 17:33:40 +02:00
David 'Digit' Turner
275cd48511 libc: Add missing pipe2() declaration and implementation.
Change-Id: Iacb914bd6ac5adc60c5671e6fef680ede21f9b0c
2010-09-27 17:33:08 +02:00
David 'Digit' Turner
f33a7700a5 libc: Add missing C++ guards to <pathconf.h>
Change-Id: I94dad48678181d8b02431b1c1f5d507beafb5406
2010-09-27 17:27:14 +02:00
Wink Saville
b9e49ad56e Use a recursive lock for pthread_once. DO NOT MERGE.
Backport change I9fc8b790 from Master to Gingerbread

Change-Id: I5cf48fcd4efb7991ed82f87d9365c19655dc9b7f
2010-09-22 14:51:53 -07:00
Brian Swetland
fedbcde6ef add /vendor support
- add /vendor/lib to front of default library search path
- remove long-obsolete /lib from default library search path

Change-Id: I7d33bf899be018e7cc4c213d5790bbd991023a62
2010-09-19 03:39:13 -07:00
Kenny Root
cb99ab98c9 Add wmemcmp to Android.mk
Change-Id: I9dc96d72b2becdd31981b4d176a13358aef6dcb9
2010-09-10 12:20:58 -07:00
rich cannings
6e42398dd6 Merge "Fix return value." into gingerbread 2010-08-31 15:48:25 -07:00
rich cannings
e44cb1a35c Fix return value.
Return a valid pointer (not NULL) when the character "c" is at the end of "src".

Change-Id: Iab0b677943f2c8a9fbb255c44689f5d6dc3535d7
Example:
  memccpy(dest, "xzy", 'y', 3) should return dest+3 rather than null.
2010-08-31 15:19:38 -07:00
Jesse Wilson
cc6b182910 Merge "Make timezones available to the host build." into gingerbread 2010-08-31 14:01:13 -07:00
Jesse Wilson
e77d54d98a Make timezones available to the host build.
Change-Id: Ib2c89ac13b03f07c6c712a544bc0d5d1c9dc57df
2010-08-31 13:16:25 -07:00
David 'Digit' Turner
6a51defa03 Fix __get_tls() in static C library to use kernel helpers.
This is needed to fix gdbserver's handling of threaded programs,
among other things.

Change-Id: I823387c602cef9891532da946a01db14be780ab0
2010-08-27 08:19:19 -07:00
Brian Carlstrom
22f1e3d4fa Apply https://android-git.corp.google.com/g/60855 to dalvik-dev.
(We've been missing the zoneinfo.* files for the host dalvikvm. My fix for
gingerbread will have to wait for someone to return from vacation, but I can
commit here in advance, and I need to so that I can submit
https://android-git.corp.google.com/g/60790 which -- amongst other things --
makes lack of time zone data a hard failure, rather than just silently
pretending all time zones are UTC.)

Bug: 2870945

git cherry-pick --no-commit 18a859aff4

Change-Id: I66647e824c5fee9b8d2c63085e2a58e5910a5544
2010-08-18 00:33:52 -07:00
Dima Zavin
a716190241 linker: fix overwriting the real linker error string
Change-Id: Ia9165fd9aa1951b2bb81d0ac8f5bb3057aded8bd
Signed-off-by: Dima Zavin <dima@android.com>
2010-08-17 15:57:55 -07:00
Christopher Tate
52e7d3d91a Bulletproof leak dump against null hash entries
Previously, the malloc leak checking code would crash in qsort()
if null entries existed in its bookkeeping table.  This change
makes the comparison function detect null entries and sort them
to the end safely.

Change-Id: I88244a7df1e289dd9d7992ce29606d505bd63079
2010-08-09 13:43:46 -07:00
Dima Zavin
18c5bcc66a Revert "Set SA_RESTORER in sigaction()"
This reverts commit e4fa46e75c.
2010-07-29 19:12:04 -07:00
Wu-cheng Li
7ed132a1ae bionic: update processed kernel header msm_camera.h
Change-Id: If66422d538d0fb0c6ae8a7399c62911635d1fd13
2010-07-27 14:26:21 -07:00
Eric Fischer
cd7014fd06 Update time zone data to the new version 2010k.
Change-Id: If657e1783e3f96c52bfe613bad027482d8373c67
2010-07-26 15:53:24 -07:00
David 'Digit' Turner
6774809b62 linker: Support dlopen(NULL, ...) properly.
Change-Id: Icba37823cb350c34848cc466d144c3a0af87c94c
2010-07-23 12:16:15 -07:00
Wu-cheng Li
9d1f5afc34 bionic: update processed kernel header msm_camera.h
Change-Id: I25598b08e9cafe98a86cdb2e40481d9aedc8dcee
2010-07-19 09:03:18 -07:00
The Android Open Source Project
b97c44dc9e add meta-files about 3rd party projects
Change-Id: I399d7811a07f82a6819d3973681f8b35b655dbd1
2010-07-16 11:41:33 -07:00
David 'Digit' Turner
cb7e8c5ef3 libc: update alarm() implementation to return 0 on error.
This matches the GLibc behaviour, and allows alarm(0xFFFFFFFF) to return 0.

Change-Id: I419aa71b27d6bb2015d15ba6b6112bf62eadcbb8
2010-07-08 17:20:29 -07:00
David 'Digit' Turner
ab8b54101e libc: fix fstatfs() implementation.
The syscall expects the size of the buffer as the second argument.

Change-Id: I99ede2fec7fcd385ca03ff022c2cffa4297bea8d
2010-07-08 16:52:27 -07:00
David 'Digit' Turner
d466780c7c Add missing SMP barriers to libstdc++
Change-Id: I20a8dcd2e3316ac60237e800c682cacc8e59e187
2010-07-07 14:18:20 -07:00
David 'Digit' Turner
519763265e libc: Fix sem_post() implementation to wake up all waiting threads.
This also allows us to optimize the case where we increment an
uncontended semaphore (no need to call futex_wake() then).

Change-Id: Iad48efe8551dc66dc89d3e3f18c001e5a6c1939f
2010-07-02 15:09:57 -07:00
David 'Digit' Turner
a02b93bd75 libc: add sanity checks to pthread_mutex_destroy()
Change-Id: Iddb2204fa792fa9aca5f19838926dddbb09b74a2
2010-06-28 14:20:22 -07:00
David 'Digit' Turner
0621a279ad libstdc++: use extern "C++" in all our C++ system headers.
This is needed to build an independent toolchain with g++ that doesn't think
that all these headers are in C.

Change-Id: Ie9a8ccfcab7780d6a4e5722777d61c2b1b312001
2010-06-25 16:53:37 -07:00
Nick Pelly
fa5755ae98 Merge "Add clean headers for 7x30 video codec." into gingerbread 2010-06-23 17:56:38 -07:00
Nick Pelly
21baae3d71 Add clean headers for 7x30 video codec.
Change-Id: Id4faa5bacb03cc42377527e05c53c6392c776e7d
2010-06-23 16:17:58 -07:00
David 'Digit' Turner
50ace4fec5 Remove compiler warnings when building Bionic.
Also add missing declarations to misc. functions.
Fix clearerr() implementation (previous was broken).
Handle feature test macros like _POSIX_C_SOURCE properly.

Change-Id: Icdc973a6b9d550a166fc2545f727ea837fe800c4
2010-06-22 17:51:41 -07:00
David 'Digit' Turner
6a9b888d7c Allow static C++ destructors to be properly called on dlclose().
With this patch, _and_ an upcoming build/ patch, the destruction
of static C++ objects contained in shared libraries will happen
properly when dlclose() is called.

Note that this change introduces crtbegin_so.S and crtend_so.S which
are currently ignored by the build system.

+ move definition of __dso_handle to the right place
  (before that, all shared libraries used the __dso_handle
   global variable from the C library).

  Note that we keep a 'weak' __dso_handle in aeabi.c to avoid
  breaking the build until the next patch to build/core/combo/
  appears. We will be able to remove that later.

+ move bionic/aeabi.c to arch-arm/bionic/ (its proper location)

Change-Id: Ie771aa204e3acbdf02fd30ebd4150373a1398f39
NOTE: The NDK will need to be modified to enable this feature in
      the shared libraries that are generated through it.
2010-06-18 16:07:10 -07:00
David 'Digit' Turner
6a09cfd9f9 Merge "wchar.h: improve wchar_t support in Bionic" into kraken 2010-06-15 07:05:21 -07:00
David 'Digit' Turner
3527fd6f0d wchar.h: improve wchar_t support in Bionic
Change-Id: Iffd41046fd0933c66542abf7627a1569522dfcb2
2010-06-15 07:04:41 -07:00
David 'Digit' Turner
a24bc688c0 Merge "linker: remove libcutils dependency by re-implementing simpler socket_local_client." into kraken 2010-06-15 06:54:45 -07:00
David 'Digit' Turner
da3019b553 libc: add missing truncate() declaration
Change-Id: Icb3601bbc9365b75b05ff443a39192f9cd3cbfb7
2010-06-11 14:40:02 -07:00
David 'Digit' Turner
ecb6d41334 libc: Add missing <termio.h> header
Change-Id: Id4e020ed330b3eabf09324f9b6d44d3a0f336d87
2010-06-11 14:39:39 -07:00
David 'Digit' Turner
6c8a2f2a5b libc: remove cutils dependencies
We simply copy the stuff we need from cutils headers.

A future patch will change cutils to include the private <bionic_atomic_inline.h>

Change-Id: Ib6fd9a03bc9e337ce867bd606dc94c2b4438480a
2010-06-11 13:49:09 -07:00
David 'Digit' Turner
8bff9a31aa linker: remove libcutils dependency by re-implementing simpler socket_local_client.
Change-Id: I87f29fd59454d713b9ddfb13e6cf114822f52efd
2010-06-10 22:58:22 -07:00
David 'Digit' Turner
038fbae518 sysconf(): Fix line parser for /proc files.
Change-Id: I2678010ee95933de19c8a8e3b2fe65ceb9b86400
2010-06-09 18:15:57 -07:00
Bruce Beare
9205fdf8c6 Add missing termios defns to bring on par with ARM - DO NOT MERGE
Change-Id: I6e16e7ab117b6df07ef24f092de1511fe1e9e7b1
2010-06-09 15:52:28 -07:00
David 'Digit' Turner
2beac0f5c6 DO NOT MERGE - add sincos.c to libm compilation
For some reason, a previous backport from master didn't get this.

Change-Id: I59eb96ad9de495a659808fdfb557033476c3d123
2010-06-09 15:49:35 -07:00
David 'Digit' Turner
20783c1428 Update libthread_db for gdb-7.0 - DO NOT MERGE
Change-Id: Id02b29314109ad1bf6de3388f856af6da3f90d33
2010-06-09 14:43:39 -07:00
David 'Digit' Turner
410b2ae7fb Add sincosl() function to bionic. So that sincos optimization can - DO NOT MERGE
be enabled.

Change-Id: I672cb319689aa4fb3f1f7cd868dda76842bebae9
2010-06-09 14:35:29 -07:00
Jing Yu
506b13d910 Remove a gcc-4.5 compilation warning:
bionic/libc/include/../include/stdlib.h: In function 'int grantpt(int)':
bionic/libc/include/../include/stdlib.h:138:23: warning: parameter '__fd' set but not used [-Wunused-but-set-parameter]

By adding __attribute((unused)) to __fd, the warning is gone, and this
attribute is compatible with gcc-4.4.0, gcc-4.3.1 gcc-4.2.1.
There is no any side effect.

Change-Id: I385f0f4da1013ffd1499e391eac9123aafe1f7a5
2010-06-09 13:24:22 -07:00
David 'Digit' Turner
b8e6c50cfa Fix setjmp()/longjmp() to save FP registers on ARMv7. - DO NOT MERGE
Change-Id: I3a0c2c05e295ac05ed51a531dabda668be204ca0
2010-06-09 13:18:29 -07:00
David 'Digit' Turner
aa4b1d0429 Add missing sysinfo() implementation (already declared in <sys/sysinfo.h>) - DO NOT MERGE
Change-Id: Iac4eb5911ffe4a7ab72b84df44e907685ac816af
2010-06-09 13:12:15 -07:00
David 'Digit' Turner
6304d8b218 Use private futexes for semaphores, unless they are initialized with pshared != 0.
Change-Id: I534e36a7171cd37037ae03b910ba71ea6968286d
Note: previously, sem_init() would return an error if pshared != 0.
2010-06-08 17:04:49 -07:00
Jean-Baptiste Queru
a8a2148863 resolved conflicts for merge of 7b6e6fa5 to kraken
Change-Id: I2b9b80a7fa32c56be2b85ff8be0d6e7ac1848afe
2010-06-03 15:05:04 -07:00
The Android Open Source Project
7b6e6fa572 merge from open-source master
Change-Id: Ib7fc9c6f79f9b13e2175da137005d8968ea85eaf
2010-06-03 14:39:20 -07:00
David Turner
f982f03832 Merge "pthread: introduce pthread_setname_np() as a mean to give names to threads" 2010-06-03 13:11:52 -07:00
Andy McFadden
fcd00ebbdf Atomic/SMP update, part 3.
Update ARM atomic ops to use LDREX/STREX.  Stripped out #if 0 chunk.

Insert explicit memory barriers in pthread and semaphore code.

For bug 2721865.

Change-Id: I0f153b797753a655702d8be41679273d1d5d6ae7
2010-05-28 16:12:01 -07:00
Andy McFadden
4fdbadde92 Atomic/SMP update.
Added an underscore to _ARM_HAVE_LDREX_STREX to make it match the others.

Added __ARM_HAVE_DMB and __ARM_HAVE_LDREXD when appropriate.

Fixed some typos.

Change-Id: I2f55febcff4aeb7de572a514fb2cd2f820dca27c
2010-05-20 15:59:32 -07:00
André Goddard Rosa
78c1c04ced pthread: introduce pthread_setname_np() as a mean to give names to threads
... so that each cloned process at the kernel level can be named
independently. Tools like 'top' can display the CPU/memory statistics
for each process's thread if "Show Threads" mode is on.

With this function in place, we can convert dalvik/Thread.c setThreadName()
function over this function. This feature ought to be provided by the
underlying C library and not coded directly in Dalvik.

Change-Id: Ifa997665dbaa114e0b126f8c667708be9a4137fd
Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
2010-05-19 23:17:16 -03:00
David 'Digit' Turner
8a1d2cf142 Add pthread_rwlock_t implementation to the C library (DO NOT MERGE)
Change-Id: I756d8c26afc37cd7b71117ddbaa02a2cb40fdecb
2010-05-19 14:53:18 -07:00
The Android Open Source Project
8e1ee7fd01 merge from open-source master
Change-Id: I5804d8850f2d4fb7b5d5c53d51e153f7ced9646e
2010-05-17 10:22:35 -07:00
André Goddard Rosa
a910abcd19 improve readability of stdio: fix indentation and remove trailing spaces
Change-Id: Ic51e58a7c75d20bf770dc0ebd7f97a338fbe0036
Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
2010-05-17 09:34:13 -07:00
The Android Open Source Project
fdf2454db2 merge from open-source master
Change-Id: I9c926a3cd680a96ece026cdec71c6e0fb0b7ad7c
2010-05-14 13:30:10 -07:00
David Turner
1297428e89 Merge "Add declaration for sys_signame[] forgotten in change 12489" 2010-05-14 12:12:24 -07:00
The Android Open Source Project
4aef0ae660 merge from open-source master
Change-Id: I2be62bce462ee53fe9519f433523bd7a44a73d40
2010-05-13 14:31:02 -07:00
Matt Fischer
e4fa46e75c Set SA_RESTORER in sigaction()
GDB looks for specific opcode sequences when trying to recognize a stack
frame as a signal trampoline.  The sequences it looks for happen to be those
created when SA_RESTORER is set, since glibc always sets a restorer.  This
patch does the same here, so that the trampolines can be correctly identified.

Change-Id: I0ac574a68818cb24d939c3527f3aaeb04b853d04
2010-05-12 14:18:36 -05:00
Jean-Baptiste Queru
f439445830 fix build
Change-Id: I243c98e20a250e0d40d481f16af481ff070219fd
2010-05-12 10:05:59 -07:00
The Android Open Source Project
bb7928ccda merge from open-source master
Change-Id: Iecfd2bd3069f70bbe508042cc249fcf7ff24800d
2010-05-12 09:22:50 -07:00
Jean-Baptiste Queru
c3581dc78a Merge "Sometimes the compiler is very right! Found bug in bessel routines for float." 2010-05-11 10:43:56 -07:00
David Turner
7911e057a5 Merge "Reduce compiler anxiety." 2010-05-11 10:20:15 -07:00
David Turner
16b59c4c38 Merge "Added support for LD_PRELOAD" 2010-05-11 10:17:00 -07:00
David Turner
6ba5efd59a Merge "stdio: simplify __fremovelock()" 2010-05-10 16:04:02 -07:00
Jean-Baptiste Queru
161232820c Merge "Reversed order of const and static to hush warning from compiler." 2010-05-10 16:00:22 -07:00
André Goddard Rosa
051ea9bc07 stdio: simplify __fremovelock()
... by removing extraneous NULL check, as free() already does it.

Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
Change-Id: I0445f35c7ad0a049a0e4aee1fbe002ed2f13b94b
2010-05-10 15:42:47 -07:00
Matt Fischer
4fd42c1dc0 Added support for LD_PRELOAD
The LD_PRELOAD environment variable allows the user to specify a list of
libraries which should be unconditionally loaded before any others.  This
makes possible some useful tricks, such as library interposers.

Change-Id: I433d775ab08ef63a5fbe7b21f87a5642954fc32f
2010-05-10 15:09:19 -07:00
David Turner
d791da7943 Merge "string: tidy up strndup()" 2010-05-10 14:52:02 -07:00
Scott Turner
c1f8dd9f0b Sometimes the compiler is very right! Found bug in bessel routines for float.
Original compiler error:

target arm C: libm <= bionic/libm/src/e_j0f.c
bionic/libm/src/e_j0f.c: In function 'j0f':
bionic/libm/src/e_j0f.c:66: warning: comparison between signed and unsigned integer expressions
bionic/libm/src/e_j0f.c: In function 'y0f':
bionic/libm/src/e_j0f.c:140: warning: comparison between signed and unsigned integer expressions
target arm C: libm <= bionic/libm/src/e_j1.c

It's subtle but ix is masked with 0x7f000000 so it can never ever have a value
greater than 0x80000000. So I switched to using the unmasked hx and added a
cast as a reward to the compiler for being right.

I checked the original routines that e_j0f.c was ported from (in e_j0.c) and
the double's don't use 0x80000000 so this issue didn't exist there.

Let that be a warning to those that just slap on casts to shut up the compiler,
sometimes it's sniffed out a bug for you. :-)

Similar fixes in the other functions.

Change-Id: I7a776e5d4721fc3a9e3bd89179b67e9af3a2ebfa
2010-05-07 15:02:36 -07:00
The Android Open Source Project
f450fa5f99 merge from open-source master
Change-Id: If02d33af51017dbd85e91c79ac2e848eda6cf253
2010-05-03 15:33:05 -07:00
David Turner
0be7eda75a Merge "Fix log channel initialization at bionic/logd_write.c." 2010-05-01 15:31:39 -07:00
Jean-Baptiste Queru
716e06071a Merge "added headers for SuperH which automatically generate by update_all.py" 2010-04-29 08:01:50 -07:00
Yi Sun
3472348067 linker: fix the undefined weak symbols issue
I'm not sure if this is a correct fix or not.
Also need to find out why 1.6 does not have this issue.

Change-Id: If46c844834bda1e2cbf084a1a45a1832119b3ae3
2010-04-29 07:50:04 -07:00
André Goddard Rosa
5751c54bf1 bionic: add missing NULL check from memory allocation on record_backtrace()
Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>

Change-Id: I739c63c5a7344fff1775580044dc647edf246ebf
2010-04-29 07:37:42 -07:00
André Goddard Rosa
c8a850bcd1 stdio: simplify vasprintf()
... by removing unneeded NULL check, as free() already does it.
By the way, we don't need to set a stack variable back to NULL.

Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>

Change-Id: Id90eb8f042b5c922c5ff139b11ff8366fb404566
2010-04-29 07:33:40 -07:00
André Goddard Rosa
6aed4288eb stdio: simplify asprintf()
... by removing unneeded NULL check, as free() already does it.
By the way, we don't need to set a stack variable back to NULL.

Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>

Change-Id: Id1f72e872f73366dddcea4abc75885a3d9a318c6
2010-04-29 07:31:44 -07:00
André Goddard Rosa
e734769276 improve readability of stdlib: fix indentation and remove trailing spaces
Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>

Change-Id: I7dd90a0816b5376ffc1de4499d56935e0bd574a1
2010-04-29 07:29:06 -07:00
The Android Open Source Project
5ef5272be9 merge from open-source master
Change-Id: I518bb4ae9d7269957365561d4d609f22cde519db
2010-04-21 09:10:08 -07:00
The Android Open Source Project
95faecefde merge from open-source master
Change-Id: If77618a329fc7b497c44c2585e644bc50e7e1406
2010-04-08 11:11:53 -07:00
Matt Fischer
1698d9ebfc Fixed support for RTLD_NEXT in dlsym()
The previous implementation of this flag was broken--it behaved identically
to RTLD_DEFAULT.  This adds a proper implementation, which examines the address
of the calling function, and uses it to determine which library to use to begin
the symbol search process.

Change-Id: I2ad2b46363f68932af63a3828a22f9c7987eea67
2010-04-08 10:14:47 -05:00
San Mehat
f1cd18bdec am 91638721: kernel_headers: Update rtnetlink/pkt_sched headers for 2.6.32
Merge commit '9163872132a3e92f986b1d684badb1dd4482ad8e' into froyo-plus-aosp

* commit '9163872132a3e92f986b1d684badb1dd4482ad8e':
  kernel_headers: Update rtnetlink/pkt_sched headers for 2.6.32
2010-04-06 22:02:48 -07:00
Thorsten Glaser
81569aa72c Add declaration for sys_signame[] forgotten in change 12489 2010-04-05 21:08:30 +02:00
The Android Open Source Project
1d168621a5 merge from open-source master
Change-Id: I950e9aca87cbb0c35099b1d53cff6378bd0f26f4
2010-03-31 14:24:25 -07:00
The Android Open Source Project
d046725133 merge from open-source master
Change-Id: I483fedf77d978b1c6e52d73eebc14f011bb9f809
2010-03-31 14:19:51 -07:00
The Android Open Source Project
5ffedb22c8 merge from open-source master
Change-Id: I076e0df8656fdf58c229cc9a168cd6d8e16b6d8e
2010-03-31 14:15:30 -07:00
André Goddard Rosa
350bb359fa bionic: fix memory leak in get_malloc_leak_info() error path
Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
2010-03-29 21:21:26 -03:00
David Turner
f8916e2e45 Merge "bionic: clear only the part of the buffer which is not overwritten afterward" 2010-03-30 14:52:14 -07:00
David Turner
4ad72f89b1 Merge "linker: fix the undefined weak symbols issue" 2010-03-29 15:49:42 -07:00
Min-su, Kim
3cab22c8cf linker: fix the undefined weak symbols issue 2010-03-29 15:43:09 -07:00
David Turner
8ab5b02b5f Merge changes Ibdc6e3c8,I9bcb91a2
* changes:
  Correct generic memset implementation
  Generic memcpy should define MEMCOPY before including bcopy.c
2010-03-29 15:05:47 -07:00
David Turner
87ae0da817 Merge "Atom optimized string and memory routines" 2010-03-29 14:40:05 -07:00
The Android Open Source Project
62ac0dc457 merge from open-source master
Change-Id: I96d2cd063f084fd17116bf7ee08fa7109a3c1ceb
2010-03-29 11:01:59 -07:00
André Goddard Rosa
3f61212781 bionic: clear only the part of the buffer which is not overwritten afterward
Change-Id: I5ddd93f0557e5a7401460dc9fc8a55b330a79c3a
Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
2010-03-28 21:32:36 -03:00
André Goddard Rosa
acdb052030 stdlib: optimize bsearch()
... by checking most probable condition first (elements do differ)

Change-Id: I424eab9c32a6d9eb82b686ca04025ec8c9097035
Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
2010-03-28 21:18:56 -03:00
Bruce Beare
8ff1a2759a Atom optimized string and memory routines
Change-Id: I27b68bb28551c75c9ac84bb9730e2cd8254d8991
2010-03-26 10:54:07 -07:00
Bruce Beare
58f0326362 Android hack for size_t
Change-Id: I3c967fca60f542459dc17be84da47b3b6a26242b
2010-03-26 09:36:01 -07:00
Chris Dearman
bdc6e3c83f Correct generic memset implementation
Signed-off-by: Chris Dearman <chris@mips.com>
2010-02-05 15:13:55 -08:00
Chris Dearman
9bcb91a212 Generic memcpy should define MEMCOPY before including bcopy.c
Signed-off-by: Chris Dearman <chris@mips.com>
2010-02-05 15:13:55 -08:00
Tony SIM
1d7a8944d8 added headers for SuperH which automatically generate by update_all.py
base on kernel 2.6.27 arch/sh/include/asm/
2010-02-01 16:06:40 +09:00
André Goddard Rosa
aba3ee7d32 string: tidy up strndup()
It decreases code size:
   text    data     bss     dec     hex filename
    161       0       0     161      a1 strndup-BEFORE.o
    153       0       0     153      99 strndup-AFTER.o

Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
2010-01-30 22:29:59 -02:00
Scott Turner
72d3489612 Reduce compiler anxiety.
Warning from compiler:

target arm C: libm <= bionic/libm/src/e_atan2.c
bionic/libm/src/e_atan2.c: In function 'atan2':
bionic/libm/src/e_atan2.c:71: warning: suggest parentheses around arithmetic in operand of '|'
target arm C: libm <= bionic/libm/src/e_atan2f.c
2010-01-16 10:39:00 -05:00
Scott Turner
fb02ec25e9 Reversed order of const and static to hush warning from compiler. 2010-01-16 10:23:18 -05:00
Alexey Tarasov
c22da7ed32 Fix log channel initialization at bionic/logd_write.c.
log_channel_t contains fd member, which is file descriptor for
exact logging channel. change cc05d12716
lacks initialization of this member in __write_to_log_init(), thus
logging code is not working, although not crashable.

Additional details may be found in comments here:
http://review.source.android.com/5617
2009-12-03 11:37:22 +10:00
399 changed files with 20251 additions and 963 deletions

View File

@@ -14,6 +14,11 @@
# limitations under the License.
#
LOCAL_PATH := $(call my-dir)
ifneq ($(TARGET_SIMULATOR),true)
include $(call all-subdir-makefiles)
else
# The host dalvikvm needs Android's concatenated & indexed timezone data.
include $(LOCAL_PATH)/libc/zoneinfo/Android.mk
endif

10
ThirdPartyProject.prop Normal file
View File

@@ -0,0 +1,10 @@
# Copyright 2010 Google Inc. All Rights Reserved.
#Fri Jul 16 10:03:08 PDT 2010
currentVersion=Unknown
version=Unknown
isNative=true
feedurl=http\://www.openbsd.org/security.html
name=openbsd
keywords=openbsd
onDevice=true
homepage=http\://openbsd.org

View File

@@ -11,9 +11,11 @@ libc_common_src_files := \
unistd/brk.c \
unistd/creat.c \
unistd/daemon.c \
unistd/eventfd.c \
unistd/exec.c \
unistd/fcntl.c \
unistd/fnmatch.c \
unistd/fstatfs.c \
unistd/ftime.c \
unistd/ftok.c \
unistd/getcwd.c \
@@ -63,7 +65,6 @@ libc_common_src_files := \
unistd/sleep.c \
unistd/statfs.c \
unistd/strsignal.c \
unistd/sysconf.c \
unistd/syslog.c \
unistd/system.c \
unistd/tcgetpgrp.c \
@@ -175,7 +176,6 @@ libc_common_src_files := \
stdlib/tolower_.c \
stdlib/toupper_.c \
stdlib/wchar.c \
string/bcopy.c \
string/index.c \
string/memccpy.c \
string/memchr.c \
@@ -186,7 +186,6 @@ libc_common_src_files := \
string/strcasestr.c \
string/strcat.c \
string/strchr.c \
string/strcmp.c \
string/strcoll.c \
string/strcpy.c \
string/strcspn.c \
@@ -196,7 +195,6 @@ libc_common_src_files := \
string/strlcat.c \
string/strlcpy.c \
string/strncat.c \
string/strncmp.c \
string/strncpy.c \
string/strndup.c \
string/strnlen.c \
@@ -208,6 +206,35 @@ libc_common_src_files := \
string/strtok.c \
string/strtotimeval.c \
string/strxfrm.c \
wchar/wcpcpy.c \
wchar/wcpncpy.c \
wchar/wcscasecmp.c \
wchar/wcscat.c \
wchar/wcschr.c \
wchar/wcscmp.c \
wchar/wcscoll.c \
wchar/wcscpy.c \
wchar/wcscspn.c \
wchar/wcsdup.c \
wchar/wcslcat.c \
wchar/wcslcpy.c \
wchar/wcslen.c \
wchar/wcsncasecmp.c \
wchar/wcsncat.c \
wchar/wcsncmp.c \
wchar/wcsncpy.c \
wchar/wcsnlen.c \
wchar/wcspbrk.c \
wchar/wcsrchr.c \
wchar/wcsspn.c \
wchar/wcsstr.c \
wchar/wcstok.c \
wchar/wcswidth.c \
wchar/wmemchr.c \
wchar/wmemcmp.c \
wchar/wmemcpy.c \
wchar/wmemmove.c \
wchar/wmemset.c \
inet/bindresvport.c \
inet/inet_addr.c \
inet/inet_aton.c \
@@ -219,7 +246,6 @@ libc_common_src_files := \
tzcode/localtime.c \
tzcode/strftime.c \
tzcode/strptime.c \
bionic/__errno.c \
bionic/__set_errno.c \
bionic/_rand48.c \
bionic/cpuacct.c \
@@ -288,11 +314,27 @@ libc_common_src_files := \
regex/regexec.c \
regex/regfree.c \
# The following files are common, but must be compiled
# with different C flags when building a static C library.
#
# The reason for this is the implementation of __get_tls()
# that will differ between the shared and static versions
# of the library.
#
# See comments in private/bionic_tls.h for more details.
#
# NOTE: bionic/pthread.c is added later to this list
# because it needs special handling on ARM, see
# below.
#
libc_static_common_src_files := \
unistd/sysconf.c \
bionic/__errno.c \
# Architecture specific source files go here
# =========================================================
ifeq ($(TARGET_ARCH),arm)
libc_common_src_files += \
bionic/eabi.c \
bionic/bionic_clone.c \
arch-arm/bionic/__get_pc.S \
arch-arm/bionic/__get_sp.S \
@@ -300,6 +342,7 @@ libc_common_src_files += \
arch-arm/bionic/_setjmp.S \
arch-arm/bionic/atomics_arm.S \
arch-arm/bionic/clone.S \
arch-arm/bionic/eabi.c \
arch-arm/bionic/ffs.S \
arch-arm/bionic/kill.S \
arch-arm/bionic/libgcc_compat.c \
@@ -313,16 +356,22 @@ libc_common_src_files += \
arch-arm/bionic/strlen.c.arm \
arch-arm/bionic/syscall.S \
string/memmove.c.arm \
string/bcopy.c \
string/strcmp.c \
string/strncmp.c \
unistd/socketcalls.c
# These files need to be arm so that gdbserver
# can set breakpoints in them without messing
# up any thumb code.
libc_common_src_files += \
bionic/pthread.c.arm \
bionic/pthread-rwlocks.c.arm \
bionic/pthread-timers.c.arm \
bionic/ptrace.c.arm
libc_static_common_src_files += \
bionic/pthread.c.arm \
# these are used by the static and dynamic versions of the libc
# respectively
libc_arch_static_src_files := \
@@ -344,16 +393,22 @@ libc_common_src_files += \
arch-x86/bionic/_setjmp.S \
arch-x86/bionic/vfork.S \
arch-x86/bionic/syscall.S \
arch-x86/string/bzero.S \
arch-x86/string/memset.S \
arch-x86/string/memcmp.S \
arch-x86/string/memcpy.S \
arch-x86/string/bcopy_wrapper.S \
arch-x86/string/memcpy_wrapper.S \
arch-x86/string/memmove_wrapper.S \
arch-x86/string/bzero_wrapper.S \
arch-x86/string/memcmp_wrapper.S \
arch-x86/string/memset_wrapper.S \
arch-x86/string/strcmp_wrapper.S \
arch-x86/string/strncmp_wrapper.S \
arch-x86/string/strlen.S \
string/memmove.c \
bionic/pthread.c \
bionic/pthread-rwlocks.c \
bionic/pthread-timers.c \
bionic/ptrace.c
libc_static_common_src_files += \
bionic/pthread.c \
# this is needed for static versions of libc
libc_arch_static_src_files := \
arch-x86/bionic/dl_iterate_phdr_static.c
@@ -381,13 +436,19 @@ libc_common_src_files += \
arch-sh/bionic/__set_tls.c \
arch-sh/bionic/__get_tls.c \
arch-sh/bionic/ffs.S \
string/bcopy.c \
string/strcmp.c \
string/strncmp.c \
string/memcmp.c \
string/strlen.c \
bionic/eabi.c \
bionic/pthread.c \
bionic/pthread-rwlocks.c \
bionic/pthread-timers.c \
bionic/ptrace.c \
unistd/socketcalls.c
libc_static_common_src_files += \
bionic/pthread.c \
endif # sh
endif # !x86
@@ -403,7 +464,6 @@ libc_common_cflags := \
-D_LIBC=1 \
-DSOFTFLOAT \
-DFLOATING_POINT \
-DNEED_PSELECT=1 \
-DINET6 \
-I$(LOCAL_PATH)/private \
-DUSE_DL_PREFIX \
@@ -437,9 +497,25 @@ ifeq ($(TARGET_ARCH),arm)
else # !arm
ifeq ($(TARGET_ARCH),x86)
libc_crt_target_cflags := -m32
# Enable recent IA friendly memory routines (such as for Atom)
# These will not work on the earlier x86 machines
libc_common_cflags += -mtune=i686 -DUSE_SSSE3 -DUSE_SSE2
endif # x86
endif # !arm
# Define ANDROID_SMP appropriately.
ifeq ($(TARGET_CPU_SMP),true)
libc_common_cflags += -DANDROID_SMP=1
else
libc_common_cflags += -DANDROID_SMP=0
endif
# Needed to access private/__dso_handle.S from
# crtbegin_xxx.S and crtend_xxx.S
#
libc_crt_target_cflags += -I$(LOCAL_PATH)/private
# Define some common includes
# ========================================================
libc_common_c_includes := \
@@ -453,10 +529,17 @@ libc_common_c_includes := \
# executables)
# ==========================================================================
ifeq ($(TARGET_ARCH),x86)
# we only need begin_so/end_so for x86, since it needs an appropriate .init
# section in the shared library with a function to call all the entries in
# .ctors section. ARM uses init_array, and does not need the function.
ifneq ($(filter arm x86,$(TARGET_ARCH)),)
# ARM and x86 need crtbegin_so/crtend_so.
#
# For x86, the .init section must point to a function that calls all
# entries in the .ctors section. (on ARM this is done through the
# .init_array section instead).
#
# For both platforms, the .fini_array section must point to a function
# that will call __cxa_finalize(&__dso_handle) in order to ensure that
# static C++ destructors are properly called on dlclose().
#
GEN := $(TARGET_OUT_STATIC_LIBRARIES)/crtbegin_so.o
$(GEN): $(LOCAL_PATH)/arch-$(TARGET_ARCH)/bionic/crtbegin_so.S
@mkdir -p $(dir $@)
@@ -525,10 +608,12 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
$(libc_arch_static_src_files) \
$(libc_static_common_src_files) \
bionic/libc_init_static.c
LOCAL_C_INCLUDES := $(libc_common_c_includes)
LOCAL_CFLAGS := $(libc_common_cflags)
LOCAL_CFLAGS := $(libc_common_cflags) \
-DLIBC_STATIC
LOCAL_MODULE := libc_nomalloc
LOCAL_WHOLE_STATIC_LIBRARIES := libc_common
@@ -544,6 +629,7 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
$(libc_arch_static_src_files) \
$(libc_static_common_src_files) \
bionic/dlmalloc.c \
bionic/malloc_debug_common.c \
bionic/libc_init_static.c
@@ -568,6 +654,7 @@ LOCAL_C_INCLUDES := $(libc_common_c_includes)
LOCAL_SRC_FILES := \
$(libc_arch_dynamic_src_files) \
$(libc_static_common_src_files) \
bionic/dlmalloc.c \
bionic/malloc_debug_common.c \
bionic/libc_init_dynamic.c

View File

@@ -33,7 +33,7 @@ void _exit:exit_group (int) 248,252
void _exit_thread:exit (int) 1
pid_t __fork:fork (void) 2
pid_t _waitpid:waitpid (pid_t, int*, int, struct rusage*) -1,7
int waitid(int, pid_t, struct siginfo_t*, int,void*) 280,284
int __waitid:waitid(int, pid_t, struct siginfo_t*, int,void*) 280,284
# NOTE: this system call is never called directly, but we list it there
# to have __NR_clone properly defined.
@@ -112,15 +112,17 @@ int flock(int, int) 143
int fchmod(int, mode_t) 94
int dup(int) 41
int pipe(int *) 42,42,-1
int pipe2(int *, int) 359,331
int dup2(int, int) 63
int select:_newselect(int, struct fd_set *, struct fd_set *, struct fd_set *, struct timeval *) 142
int ftruncate(int, off_t) 93
int getdents:getdents64(unsigned int, struct dirent *, unsigned int) 217,220
int fsync(int) 118
int fdatasync(int) 148
int fchown:fchown32(int, uid_t, gid_t) 207
void sync(void) 36
int __fcntl64:fcntl64(int, int, void *) 221
int fstatfs:fstatfs64(int, size_t, struct statfs *) 267,269
int __fstatfs64:fstatfs64(int, size_t, struct statfs *) 267,269
ssize_t sendfile(int out_fd, int in_fd, off_t *offset, size_t count) 187
int fstatat:fstatat64(int dirfd, const char *path, struct stat *buf, int flags) 327,300
int mkdirat(int dirfd, const char *pathname, mode_t mode) 323,296
@@ -229,8 +231,8 @@ int sched_get_priority_min(int policy) 160
int sched_rr_get_interval(pid_t pid, struct timespec *interval) 161
# io priorities
int ioprio_set(int which, int who, int ioprio) 314,289
int ioprio_get(int which, int who) 315,290
int ioprio_set(int which, int who, int ioprio) 314,289,288
int ioprio_get(int which, int who) 315,290,289
# other
int uname(struct utsname *) 122
@@ -241,6 +243,7 @@ int __syslog:syslog(int, char *, int) 103
int init_module(void *, unsigned long, const char *) 128
int delete_module(const char*, unsigned int) 129
int klogctl:syslog(int, char *, int) 103
int sysinfo(struct sysinfo *) 116
# futex
int futex(void *, int, int, void *, void *, int) 240
@@ -256,6 +259,8 @@ int inotify_rm_watch(int, unsigned int) 318,293,292
int poll(struct pollfd *, unsigned int, long) 168
int eventfd:eventfd2(unsigned int, int) 356,328
# ARM-specific ARM_NR_BASE == 0x0f0000 == 983040
int __set_tls:ARM_set_tls(void*) 983045,-1
int cacheflush:ARM_cacheflush(long start, long end, long flags) 983042,-1

View File

@@ -3,6 +3,7 @@
/*
* Copyright (c) 1997 Mark Brinicombe
* Copyright (c) 2010 Android Open Source Project.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -35,6 +36,7 @@
#include <machine/asm.h>
#include <machine/setjmp.h>
#include <machine/cpu-features.h>
/*
* C library -- _setjmp, _longjmp
@@ -51,18 +53,20 @@
ENTRY(_setjmp)
ldr r1, .L_setjmp_magic
str r1, [r0], #4
#ifdef SOFTFLOAT
add r0, r0, #52
#else
/* Store fp registers */
sfm f4, 4, [r0], #48
/* Store fpsr */
rfs r1
str r1, [r0], #0x0004
#endif /* SOFTFLOAT */
/* Store integer registers */
stmia r0, {r4-r14}
str r1, [r0, #(_JB_MAGIC * 4)]
/* Store core registers */
add r1, r0, #(_JB_CORE_BASE * 4)
stmia r1, {r4-r14}
#ifdef __ARM_HAVE_VFP
/* Store floating-point registers */
add r1, r0, #(_JB_FLOAT_BASE * 4)
vstmia r1, {d8-d15}
/* Store floating-point state */
fmrx r1, fpscr
str r1, [r0, #(_JB_FLOAT_STATE * 4)]
#endif /* __ARM_HAVE_VFP */
mov r0, #0x00000000
bx lr
@@ -72,21 +76,22 @@ ENTRY(_setjmp)
ENTRY(_longjmp)
ldr r2, .L_setjmp_magic
ldr r3, [r0], #4
ldr r3, [r0, #(_JB_MAGIC * 4)]
teq r2, r3
bne botch
#ifdef SOFTFLOAT
add r0, r0, #52
#else
/* Restore fp registers */
lfm f4, 4, [r0], #48
/* Restore fpsr */
ldr r4, [r0], #0x0004
wfs r4
#endif /* SOFTFLOAT */
/* Restore integer registers */
ldmia r0, {r4-r14}
#ifdef __ARM_HAVE_VFP
/* Restore floating-point registers */
add r2, r0, #(_JB_FLOAT_BASE * 4)
vldmia r2, {d8-d15}
/* Restore floating-point state */
ldr r2, [r0, #(_JB_FLOAT_STATE * 4)]
fmxr fpscr, r2
#endif /* __ARM_HAVE_VFP */
/* Restore core registers */
add r2, r0, #(_JB_CORE_BASE * 4)
ldmia r2, {r4-r14}
/* Validate sp and r14 */
teq sp, #0

View File

@@ -26,6 +26,7 @@
* SUCH DAMAGE.
*/
#include <sys/linux-syscalls.h>
#include <machine/cpu-features.h>
.global __atomic_cmpxchg
.type __atomic_cmpxchg, %function
@@ -39,9 +40,73 @@
#define FUTEX_WAIT 0
#define FUTEX_WAKE 1
#if 1
.equ kernel_cmpxchg, 0xFFFF0FC0
.equ kernel_atomic_base, 0xFFFF0FFF
#if defined(__ARM_HAVE_LDREX_STREX)
/*
* ===========================================================================
* ARMv6+ implementation
* ===========================================================================
*/
/* r0(addr) -> r0(old) */
__atomic_dec:
.fnstart
mov r1, r0 @ copy addr so we don't clobber it
1: ldrex r0, [r1] @ load current value into r0
sub r2, r0, #1 @ generate new value into r2
strex r3, r2, [r1] @ try to store new value; result in r3
cmp r3, #0 @ success?
bxeq lr @ yes, return
b 1b @ no, retry
.fnend
/* r0(addr) -> r0(old) */
__atomic_inc:
.fnstart
mov r1, r0
1: ldrex r0, [r1]
add r2, r0, #1
strex r3, r2, [r1]
cmp r3, #0
bxeq lr
b 1b
.fnend
/* r0(old) r1(new) r2(addr) -> r0(zero_if_succeeded) */
__atomic_cmpxchg:
.fnstart
1: mov ip, #2 @ ip=2 means "new != old"
ldrex r3, [r2] @ load current value into r3
teq r0, r3 @ new == old?
strexeq ip, r1, [r2] @ yes, try store, set ip to 0 or 1
teq ip, #1 @ strex failure?
beq 1b @ yes, retry
mov r0, ip @ return 0 on success, 2 on failure
bx lr
.fnend
/* r0(new) r1(addr) -> r0(old) */
__atomic_swap:
.fnstart
1: ldrex r2, [r1]
strex r3, r0, [r1]
teq r3, #0
bne 1b
mov r0, r2
bx lr
.fnend
#else /*not defined __ARM_HAVE_LDREX_STREX*/
/*
* ===========================================================================
* Pre-ARMv6 implementation
* ===========================================================================
*/
/* int __kernel_cmpxchg(int oldval, int newval, int* ptr) */
.equ kernel_cmpxchg, 0xFFFF0FC0
.equ kernel_atomic_base, 0xFFFF0FFF
/* r0(addr) -> r0(old) */
__atomic_dec:
.fnstart
.save {r4, lr}
@@ -59,6 +124,7 @@ __atomic_dec:
bx lr
.fnend
/* r0(addr) -> r0(old) */
__atomic_inc:
.fnstart
.save {r4, lr}
@@ -95,64 +161,16 @@ __atomic_cmpxchg:
ldmia sp!, {r4, lr}
bx lr
.fnend
#else
#define KUSER_CMPXCHG 0xffffffc0
/* r0(old) r1(new) r2(addr) -> r0(zero_if_succeeded) */
__atomic_cmpxchg:
stmdb sp!, {r4, lr}
mov r4, r0 /* r4 = save oldvalue */
1: add lr, pc, #4
mov r0, r4 /* r0 = oldvalue */
mov pc, #KUSER_CMPXCHG
bcs 2f /* swap was made. we're good, return. */
ldr r3, [r2] /* swap not made, see if it's because *ptr!=oldvalue */
cmp r3, r4
beq 1b
2: ldmia sp!, {r4, lr}
bx lr
/* r0(addr) -> r0(old) */
__atomic_dec:
stmdb sp!, {r4, lr}
mov r2, r0 /* address */
1: ldr r0, [r2] /* oldvalue */
add lr, pc, #4
sub r1, r0, #1 /* newvalue = oldvalue - 1 */
mov pc, #KUSER_CMPXCHG
bcc 1b /* no swap, try again until we get it right */
mov r0, ip /* swapped, return the old value */
ldmia sp!, {r4, lr}
bx lr
/* r0(addr) -> r0(old) */
__atomic_inc:
stmdb sp!, {r4, lr}
mov r2, r0 /* address */
1: ldr r0, [r2] /* oldvalue */
add lr, pc, #4
add r1, r0, #1 /* newvalue = oldvalue + 1 */
mov pc, #KUSER_CMPXCHG
bcc 1b /* no swap, try again until we get it right */
mov r0, ip /* swapped, return the old value */
ldmia sp!, {r4, lr}
bx lr
#endif
/* r0(new) r1(addr) -> r0(old) */
/* replaced swp instruction with ldrex/strex for ARMv6 & ARMv7 */
__atomic_swap:
#if defined (_ARM_HAVE_LDREX_STREX)
1: ldrex r2, [r1]
strex r3, r0, [r1]
teq r3, #0
bne 1b
mov r0, r2
mcr p15, 0, r0, c7, c10, 5 /* or, use dmb */
#else
.fnstart
swp r0, r0, [r1]
#endif
bx lr
.fnend
#endif /*not defined __ARM_HAVE_LDREX_STREX*/
/* __futex_wait(*ftx, val, *timespec) */
/* __futex_wake(*ftx, counter) */
@@ -197,6 +215,8 @@ __futex_wait:
.fnend
__futex_wake:
.fnstart
.save {r4, r7}
stmdb sp!, {r4, r7}
mov r2, r1
mov r1, #FUTEX_WAKE
@@ -204,6 +224,7 @@ __futex_wake:
swi #0
ldmia sp!, {r4, r7}
bx lr
.fnend
#else

View File

@@ -31,7 +31,7 @@
.globl _start
# this is the small startup code that is first run when
# any executable that is statically-linked with Bionic
# any executable that is dynamically-linked with Bionic
# runs.
#
# it's purpose is to call __libc_init with appropriate
@@ -63,13 +63,7 @@ _start:
.long __INIT_ARRAY__
.long __FINI_ARRAY__
.long __CTOR_LIST__
# the .ctors section contains a list of pointers to "constructor"
# functions that need to be called in order during C library initialization,
# just before the program is being run. This is a C++ requirement
#
# the last entry shall be 0, and is defined in crtend.S
#
.section .preinit_array, "aw"
.globl __PREINIT_ARRAY__
__PREINIT_ARRAY__:
@@ -90,3 +84,4 @@ __FINI_ARRAY__:
__CTOR_LIST__:
.long -1
#include "__dso_handle.S"

View File

@@ -0,0 +1,55 @@
/*
* Copyright (C) 2008 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
# Implement static C++ destructors when the shared
# library is unloaded through dlclose().
#
# A call to this function must be the first entry
# in the .fini_array. See 3.3.5.3.C of C++ ABI
# standard.
#
__on_dlclose:
adr r0, 0f
ldr r0, [r0]
b __cxa_finalize
0:
.long __dso_handle
.section .init_array, "aw"
.globl __INIT_ARRAY__
__INIT_ARRAY__:
.long -1
.section .fini_array, "aw"
.globl __FINI_ARRAY__
__FINI_ARRAY__:
.long -1
.long __on_dlclose
#include "__dso_handle.S"

View File

@@ -63,13 +63,7 @@ _start:
.long __INIT_ARRAY__
.long __FINI_ARRAY__
.long __CTOR_LIST__
# the .ctors section contains a list of pointers to "constructor"
# functions that need to be called in order during C library initialization,
# just before the program is being run. This is a C++ requirement
#
# the last entry shall be 0, and is defined in crtend.S
#
.section .preinit_array, "aw"
.globl __PREINIT_ARRAY__
__PREINIT_ARRAY__:
@@ -90,3 +84,5 @@ __FINI_ARRAY__:
__CTOR_LIST__:
.long -1
#include "__dso_handle.S"

View File

@@ -0,0 +1,38 @@
/*
* Copyright (C) 2010 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/* This is the same than crtend.S except that a shared library
* cannot have a .preinit_array
*/
.section .init_array, "aw"
.long 0
.section .fini_array, "aw"
.long 0

View File

@@ -30,7 +30,21 @@
extern int __cxa_atexit(void (*)(void*), void*, void* );
void* __dso_handle = 0;
/* Temporary hack: this variable should not be part of the C library
* itself, but placed in the .bss section of each executable or
* shared library instead.
*
* We keep it here temporarily until the build system has been
* modified properly to use crtbegin_so.S and crtend_so.S when
* generating shared libraries.
*
* It must be a 'weak' symbol to avoid conflicts with the definitions
* that have been moved to crtbegin_static.S and crtbegin_dynamic.S
*
* For the record, it is used for static C++ object construction
* and destruction. See http://www.codesourcery.com/public/cxx-abi/abi.html#dso-dtor
*/
void* __attribute__((weak)) __dso_handle;
/* The "C++ ABI for ARM" document states that static C++ constructors,
* which are called from the .init_array, should manually call

View File

@@ -3,6 +3,7 @@
/*
* Copyright (c) 1997 Mark Brinicombe
* Copyright (c) 2010 Android Open Source Project.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -35,6 +36,7 @@
#include <machine/asm.h>
#include <machine/setjmp.h>
#include <machine/cpu-features.h>
/*
* C library -- setjmp, longjmp
@@ -57,24 +59,26 @@ ENTRY(setjmp)
ldmfd sp!, {r0, r14}
/* Store signal mask */
str r1, [r0, #(25 * 4)]
str r1, [r0, #(_JB_SIGMASK * 4)]
ldr r1, .Lsetjmp_magic
str r1, [r0], #4
str r1, [r0, #(_JB_MAGIC * 4)]
#ifdef SOFTFLOAT
add r0, r0, #52
#else
/* Store fp registers */
sfm f4, 4, [r0], #48
/* Store fpsr */
rfs r1
str r1, [r0], #0x0004
#endif /*SOFTFLOAT*/
/* Store integer registers */
stmia r0, {r4-r14}
mov r0, #0x00000000
bx lr
/* Store core registers */
add r1, r0, #(_JB_CORE_BASE * 4)
stmia r1, {r4-r14}
#ifdef __ARM_HAVE_VFP
/* Store floating-point registers */
add r1, r0, #(_JB_FLOAT_BASE * 4)
vstmia r1, {d8-d15}
/* Store floating-point state */
fmrx r1, fpscr
str r1, [r0, #(_JB_FLOAT_STATE * 4)]
#endif /* __ARM_HAVE_VFP */
mov r0, #0x00000000
bx lr
.Lsetjmp_magic:
.word _JB_MAGIC_SETJMP
@@ -82,12 +86,12 @@ ENTRY(setjmp)
ENTRY(longjmp)
ldr r2, .Lsetjmp_magic
ldr r3, [r0]
ldr r3, [r0, #(_JB_MAGIC * 4)]
teq r2, r3
bne botch
/* Fetch signal mask */
ldr r2, [r0, #(25 * 4)]
ldr r2, [r0, #(_JB_SIGMASK * 4)]
/* Set signal mask */
stmfd sp!, {r0, r1, r14}
@@ -99,18 +103,18 @@ ENTRY(longjmp)
add sp, sp, #4 /* unalign the stack */
ldmfd sp!, {r0, r1, r14}
add r0, r0, #4
#ifdef SOFTFLOAT
add r0, r0, #52
#else
/* Restore fp registers */
lfm f4, 4, [r0], #48
/* Restore FPSR */
ldr r4, [r0], #0x0004
wfs r4
#endif /* SOFTFLOAT */
/* Restore integer registers */
ldmia r0, {r4-r14}
#ifdef __ARM_HAVE_VFP
/* Restore floating-point registers */
add r2, r0, #(_JB_FLOAT_BASE * 4)
vldmia r2, {d8-d15}
/* Restore floating-point state */
ldr r2, [r0, #(_JB_FLOAT_STATE * 4)]
fmxr fpscr, r2
#endif /* __ARM_HAVE_VFP */
/* Restore core registers */
add r2, r0, #(_JB_CORE_BASE * 4)
ldmia r2, {r4-r14}
/* Validate sp and r14 */
teq sp, #0

View File

@@ -46,8 +46,6 @@ typedef long ssize_t;
typedef long ptrdiff_t;
#endif
//#include <linux/types.h>
/* 7.18.1.1 Exact-width integer types */
typedef __signed char __int8_t;
typedef unsigned char __uint8_t;

View File

@@ -38,7 +38,7 @@
* IMPORTANT: We have no intention to support anything below an ARMv4T !
*/
/* _ARM_ARCH_REVISION is a number corresponding to the ARM revision
/* __ARM_ARCH__ is a number corresponding to the ARM revision
* we're going to support
*
* it looks like our toolchain doesn't define __ARM_ARCH__
@@ -142,20 +142,47 @@
*
* ldr pc, [<some address>]
*
* note that this affects any instruction that explicitely changes the
* note that this affects any instruction that explicitly changes the
* value of the pc register, including ldm { ...,pc } or 'add pc, #offset'
*/
#if __ARM_ARCH__ >= 5
# define __ARM_HAVE_PC_INTERWORK
#endif
/* define _ARM_HAVE_LDREX_STREX for ARMv6 and ARMv7 architecure to be
* used in replacement of depricated swp instruction
/* define __ARM_HAVE_LDREX_STREX for ARMv6 and ARMv7 architecture to be
* used in replacement of deprecated swp instruction
*/
#if __ARM_ARCH__ >= 6
# define _ARM_HAVE_LDREX_STREX
# define __ARM_HAVE_LDREX_STREX
#endif
/* define __ARM_HAVE_DMB for ARMv7 architecture
*/
#if __ARM_ARCH__ >= 7
# define __ARM_HAVE_DMB
#endif
/* define __ARM_HAVE_LDREXD for ARMv7 architecture
* (also present in ARMv6K, but not implemented in ARMv7-M, neither of which
* we care about)
*/
#if __ARM_ARCH__ >= 7
# define __ARM_HAVE_LDREXD
#endif
/* define _ARM_HAVE_VFP if we have VFPv3
*/
#if __ARM_ARCH__ >= 7 && defined __VFP_FP__
# define __ARM_HAVE_VFP
#endif
/* define _ARM_HAVE_NEON for ARMv7 architecture if we support the
* Neon SIMD instruction set extensions. This also implies
* that VFPv3-D32 is supported.
*/
#if __ARM_ARCH__ >= 7 && defined __ARM_NEON__
# define __ARM_HAVE_NEON
#endif
/* Assembly-only macros */

View File

@@ -1,87 +1,82 @@
/* $OpenBSD: setjmp.h,v 1.1 2004/02/01 05:09:49 drahn Exp $ */
/* $NetBSD: setjmp.h,v 1.2 2001/08/25 14:45:59 bjh21 Exp $ */
/*
* Copyright (C) 2010 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* machine/setjmp.h: machine dependent setjmp-related information.
*/
#ifdef __ELF__
#define _JBLEN 64 /* size, in longs, of a jmp_buf */
#else
#define _JBLEN 29 /* size, in longs, of a jmp_buf */
#endif
/*
* NOTE: The internal structure of a jmp_buf is *PRIVATE*
* This information is provided as there is software
* that fiddles with this with obtain the stack pointer
* (yes really ! and its commercial !).
/* _JBLEN is the size of a jmp_buf in longs.
* Do not modify this value or you will break the ABI !
*
* Description of the setjmp buffer
*
* word 0 magic number (dependant on creator)
* 1 - 3 f4 fp register 4
* 4 - 6 f5 fp register 5
* 7 - 9 f6 fp register 6
* 10 - 12 f7 fp register 7
* 13 fpsr fp status register
* 14 r4 register 4
* 15 r5 register 5
* 16 r6 register 6
* 17 r7 register 7
* 18 r8 register 8
* 19 r9 register 9
* 20 r10 register 10 (sl)
* 21 r11 register 11 (fp)
* 22 r12 register 12 (ip)
* 23 r13 register 13 (sp)
* 24 r14 register 14 (lr)
* 25 signal mask (dependant on magic)
* 26 (con't)
* 27 (con't)
* 28 (con't)
*
* The magic number number identifies the jmp_buf and
* how the buffer was created as well as providing
* a sanity check
*
* A side note I should mention - Please do not tamper
* with the floating point fields. While they are
* always saved and restored at the moment this cannot
* be garenteed especially if the compiler happens
* to be generating soft-float code so no fp
* registers will be used.
*
* Whilst this can be seen an encouraging people to
* use the setjmp buffer in this way I think that it
* is for the best then if changes occur compiles will
* break rather than just having new builds falling over
* mysteriously.
* This value comes from the original OpenBSD ARM-specific header
* that was replaced by this one.
*/
#define _JBLEN 64
/* According to the ARM AAPCS document, we only need to save
* the following registers:
*
* Core r4-r14
*
* VFP d8-d15 (see section 5.1.2.1)
*
* Registers s16-s31 (d8-d15, q4-q7) must be preserved across subroutine
* calls; registers s0-s15 (d0-d7, q0-q3) do not need to be preserved
* (and can be used for passing arguments or returning results in standard
* procedure-call variants). Registers d16-d31 (q8-q15), if present, do
* not need to be preserved.
*
* FPSCR saved because GLibc does saves it too.
*
*/
/* The internal structure of a jmp_buf is totally private.
* Current layout (may change in the future):
*
* word name description
* 0 magic magic number
* 1 sigmask signal mask (not used with _setjmp / _longjmp)
* 2 float_base base of float registers (d8 to d15)
* 18 float_state floating-point status and control register
* 19 core_base base of core registers (r4 to r14)
* 30 reserved reserved entries (room to grow)
* 64
*
* NOTE: float_base must be at an even word index, since the
* FP registers will be loaded/stored with instructions
* that expect 8-byte alignment.
*/
#define _JB_MAGIC 0
#define _JB_SIGMASK (_JB_MAGIC+1)
#define _JB_FLOAT_BASE (_JB_SIGMASK+1)
#define _JB_FLOAT_STATE (_JB_FLOAT_BASE + (15-8+1)*2)
#define _JB_CORE_BASE (_JB_FLOAT_STATE+1)
#define _JB_MAGIC__SETJMP 0x4278f500
#define _JB_MAGIC_SETJMP 0x4278f501
/* Valid for all jmp_buf's */
#define _JB_MAGIC 0
#define _JB_REG_F4 1
#define _JB_REG_F5 4
#define _JB_REG_F6 7
#define _JB_REG_F7 10
#define _JB_REG_FPSR 13
#define _JB_REG_R4 14
#define _JB_REG_R5 15
#define _JB_REG_R6 16
#define _JB_REG_R7 17
#define _JB_REG_R8 18
#define _JB_REG_R9 19
#define _JB_REG_R10 20
#define _JB_REG_R11 21
#define _JB_REG_R12 22
#define _JB_REG_R13 23
#define _JB_REG_R14 24
/* Only valid with the _JB_MAGIC_SETJMP magic */
#define _JB_SIGMASK 25

View File

@@ -3,7 +3,7 @@ syscall_src :=
syscall_src += arch-arm/syscalls/_exit.S
syscall_src += arch-arm/syscalls/_exit_thread.S
syscall_src += arch-arm/syscalls/__fork.S
syscall_src += arch-arm/syscalls/waitid.S
syscall_src += arch-arm/syscalls/__waitid.S
syscall_src += arch-arm/syscalls/__sys_clone.S
syscall_src += arch-arm/syscalls/execve.S
syscall_src += arch-arm/syscalls/__setuid.S
@@ -66,15 +66,17 @@ syscall_src += arch-arm/syscalls/flock.S
syscall_src += arch-arm/syscalls/fchmod.S
syscall_src += arch-arm/syscalls/dup.S
syscall_src += arch-arm/syscalls/pipe.S
syscall_src += arch-arm/syscalls/pipe2.S
syscall_src += arch-arm/syscalls/dup2.S
syscall_src += arch-arm/syscalls/select.S
syscall_src += arch-arm/syscalls/ftruncate.S
syscall_src += arch-arm/syscalls/getdents.S
syscall_src += arch-arm/syscalls/fsync.S
syscall_src += arch-arm/syscalls/fdatasync.S
syscall_src += arch-arm/syscalls/fchown.S
syscall_src += arch-arm/syscalls/sync.S
syscall_src += arch-arm/syscalls/__fcntl64.S
syscall_src += arch-arm/syscalls/fstatfs.S
syscall_src += arch-arm/syscalls/__fstatfs64.S
syscall_src += arch-arm/syscalls/sendfile.S
syscall_src += arch-arm/syscalls/fstatat.S
syscall_src += arch-arm/syscalls/mkdirat.S
@@ -161,6 +163,7 @@ syscall_src += arch-arm/syscalls/__syslog.S
syscall_src += arch-arm/syscalls/init_module.S
syscall_src += arch-arm/syscalls/delete_module.S
syscall_src += arch-arm/syscalls/klogctl.S
syscall_src += arch-arm/syscalls/sysinfo.S
syscall_src += arch-arm/syscalls/futex.S
syscall_src += arch-arm/syscalls/epoll_create.S
syscall_src += arch-arm/syscalls/epoll_ctl.S
@@ -169,5 +172,6 @@ syscall_src += arch-arm/syscalls/inotify_init.S
syscall_src += arch-arm/syscalls/inotify_add_watch.S
syscall_src += arch-arm/syscalls/inotify_rm_watch.S
syscall_src += arch-arm/syscalls/poll.S
syscall_src += arch-arm/syscalls/eventfd.S
syscall_src += arch-arm/syscalls/__set_tls.S
syscall_src += arch-arm/syscalls/cacheflush.S

View File

@@ -2,12 +2,12 @@
#include <sys/linux-syscalls.h>
.text
.type fstatfs, #function
.globl fstatfs
.type __fstatfs64, #function
.globl __fstatfs64
.align 4
.fnstart
fstatfs:
__fstatfs64:
.save {r4, r7}
stmfd sp!, {r4, r7}
ldr r7, =__NR_fstatfs64

View File

@@ -2,12 +2,12 @@
#include <sys/linux-syscalls.h>
.text
.type waitid, #function
.globl waitid
.type __waitid, #function
.globl __waitid
.align 4
.fnstart
waitid:
__waitid:
mov ip, sp
.save {r4, r5, r6, r7}
stmfd sp!, {r4, r5, r6, r7}

View File

@@ -0,0 +1,19 @@
/* autogenerated by gensyscalls.py */
#include <sys/linux-syscalls.h>
.text
.type eventfd, #function
.globl eventfd
.align 4
.fnstart
eventfd:
.save {r4, r7}
stmfd sp!, {r4, r7}
ldr r7, =__NR_eventfd2
swi #0
ldmfd sp!, {r4, r7}
movs r0, r0
bxpl lr
b __set_syscall_errno
.fnend

View File

@@ -0,0 +1,19 @@
/* autogenerated by gensyscalls.py */
#include <sys/linux-syscalls.h>
.text
.type fdatasync, #function
.globl fdatasync
.align 4
.fnstart
fdatasync:
.save {r4, r7}
stmfd sp!, {r4, r7}
ldr r7, =__NR_fdatasync
swi #0
ldmfd sp!, {r4, r7}
movs r0, r0
bxpl lr
b __set_syscall_errno
.fnend

View File

@@ -0,0 +1,19 @@
/* autogenerated by gensyscalls.py */
#include <sys/linux-syscalls.h>
.text
.type pipe2, #function
.globl pipe2
.align 4
.fnstart
pipe2:
.save {r4, r7}
stmfd sp!, {r4, r7}
ldr r7, =__NR_pipe2
swi #0
ldmfd sp!, {r4, r7}
movs r0, r0
bxpl lr
b __set_syscall_errno
.fnend

View File

@@ -0,0 +1,19 @@
/* autogenerated by gensyscalls.py */
#include <sys/linux-syscalls.h>
.text
.type sysinfo, #function
.globl sysinfo
.align 4
.fnstart
sysinfo:
.save {r4, r7}
stmfd sp!, {r4, r7}
ldr r7, =__NR_sysinfo
swi #0
ldmfd sp!, {r4, r7}
movs r0, r0
bxpl lr
b __set_syscall_errno
.fnend

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2009 The Android Open Source Project
* Copyright (C) 2009-2010 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -31,7 +31,7 @@
.globl _start
# this is the small startup code that is first run when
# any executable that is statically-linked with Bionic
# any executable that is dynamically-linked with Bionic
# runs.
#
# it's purpose is to call __libc_init with appropriate
@@ -93,3 +93,5 @@ __FINI_ARRAY__:
.globl __CTOR_LIST__
__CTOR_LIST__:
.long -1
#include "__dso_handle.S"

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2009 The Android Open Source Project
* Copyright (C) 2009-2010 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -68,12 +68,6 @@ _start:
.long __FINI_ARRAY__
.long __CTOR_LIST__
# the .ctors section contains a list of pointers to "constructor"
# functions that need to be called in order during C library initialization,
# just before the program is being run. This is a C++ requirement
#
# the last entry shall be 0, and is defined in crtend.S
#
.section .preinit_array, "aw"
.globl __PREINIT_ARRAY__
__PREINIT_ARRAY__:
@@ -94,3 +88,4 @@ __FINI_ARRAY__:
__CTOR_LIST__:
.long -1
#include "__dso_handle.S"

View File

@@ -4,7 +4,7 @@ syscall_src += arch-sh/syscalls/_exit.S
syscall_src += arch-sh/syscalls/_exit_thread.S
syscall_src += arch-sh/syscalls/__fork.S
syscall_src += arch-sh/syscalls/_waitpid.S
syscall_src += arch-sh/syscalls/waitid.S
syscall_src += arch-sh/syscalls/__waitid.S
syscall_src += arch-sh/syscalls/__sys_clone.S
syscall_src += arch-sh/syscalls/execve.S
syscall_src += arch-sh/syscalls/__setuid.S
@@ -69,15 +69,17 @@ syscall_src += arch-sh/syscalls/__fcntl.S
syscall_src += arch-sh/syscalls/flock.S
syscall_src += arch-sh/syscalls/fchmod.S
syscall_src += arch-sh/syscalls/dup.S
syscall_src += arch-sh/syscalls/pipe2.S
syscall_src += arch-sh/syscalls/dup2.S
syscall_src += arch-sh/syscalls/select.S
syscall_src += arch-sh/syscalls/ftruncate.S
syscall_src += arch-sh/syscalls/getdents.S
syscall_src += arch-sh/syscalls/fsync.S
syscall_src += arch-sh/syscalls/fdatasync.S
syscall_src += arch-sh/syscalls/fchown.S
syscall_src += arch-sh/syscalls/sync.S
syscall_src += arch-sh/syscalls/__fcntl64.S
syscall_src += arch-sh/syscalls/fstatfs.S
syscall_src += arch-sh/syscalls/__fstatfs64.S
syscall_src += arch-sh/syscalls/sendfile.S
syscall_src += arch-sh/syscalls/fstatat.S
syscall_src += arch-sh/syscalls/mkdirat.S
@@ -150,6 +152,7 @@ syscall_src += arch-sh/syscalls/__syslog.S
syscall_src += arch-sh/syscalls/init_module.S
syscall_src += arch-sh/syscalls/delete_module.S
syscall_src += arch-sh/syscalls/klogctl.S
syscall_src += arch-sh/syscalls/sysinfo.S
syscall_src += arch-sh/syscalls/futex.S
syscall_src += arch-sh/syscalls/epoll_create.S
syscall_src += arch-sh/syscalls/epoll_ctl.S
@@ -158,3 +161,4 @@ syscall_src += arch-sh/syscalls/inotify_init.S
syscall_src += arch-sh/syscalls/inotify_add_watch.S
syscall_src += arch-sh/syscalls/inotify_rm_watch.S
syscall_src += arch-sh/syscalls/poll.S
syscall_src += arch-sh/syscalls/eventfd.S

View File

@@ -2,11 +2,11 @@
#include <sys/linux-syscalls.h>
.text
.type fstatfs, @function
.globl fstatfs
.type __fstatfs64, @function
.globl __fstatfs64
.align 4
fstatfs:
__fstatfs64:
/* invoke trap */
mov.l 0f, r3 /* trap num */

View File

@@ -2,11 +2,11 @@
#include <sys/linux-syscalls.h>
.text
.type waitid, @function
.globl waitid
.type __waitid, @function
.globl __waitid
.align 4
waitid:
__waitid:
/* get ready for additonal arg */
mov.l @r15, r0

View File

@@ -0,0 +1,32 @@
/* autogenerated by gensyscalls.py */
#include <sys/linux-syscalls.h>
.text
.type eventfd, @function
.globl eventfd
.align 4
eventfd:
/* invoke trap */
mov.l 0f, r3 /* trap num */
trapa #(2 + 0x10)
/* check return value */
cmp/pz r0
bt __NR_eventfd2_end
/* keep error number */
sts.l pr, @-r15
mov.l 1f, r1
jsr @r1
mov r0, r4
lds.l @r15+, pr
__NR_eventfd2_end:
rts
nop
.align 2
0: .long __NR_eventfd2
1: .long __set_syscall_errno

View File

@@ -0,0 +1,32 @@
/* autogenerated by gensyscalls.py */
#include <sys/linux-syscalls.h>
.text
.type fdatasync, @function
.globl fdatasync
.align 4
fdatasync:
/* invoke trap */
mov.l 0f, r3 /* trap num */
trapa #(1 + 0x10)
/* check return value */
cmp/pz r0
bt __NR_fdatasync_end
/* keep error number */
sts.l pr, @-r15
mov.l 1f, r1
jsr @r1
mov r0, r4
lds.l @r15+, pr
__NR_fdatasync_end:
rts
nop
.align 2
0: .long __NR_fdatasync
1: .long __set_syscall_errno

View File

@@ -0,0 +1,32 @@
/* autogenerated by gensyscalls.py */
#include <sys/linux-syscalls.h>
.text
.type pipe2, @function
.globl pipe2
.align 4
pipe2:
/* invoke trap */
mov.l 0f, r3 /* trap num */
trapa #(2 + 0x10)
/* check return value */
cmp/pz r0
bt __NR_pipe2_end
/* keep error number */
sts.l pr, @-r15
mov.l 1f, r1
jsr @r1
mov r0, r4
lds.l @r15+, pr
__NR_pipe2_end:
rts
nop
.align 2
0: .long __NR_pipe2
1: .long __set_syscall_errno

View File

@@ -0,0 +1,32 @@
/* autogenerated by gensyscalls.py */
#include <sys/linux-syscalls.h>
.text
.type sysinfo, @function
.globl sysinfo
.align 4
sysinfo:
/* invoke trap */
mov.l 0f, r3 /* trap num */
trapa #(1 + 0x10)
/* check return value */
cmp/pz r0
bt __NR_sysinfo_end
/* keep error number */
sts.l pr, @-r15
mov.l 1f, r1
jsr @r1
mov r0, r4
lds.l @r15+, pr
__NR_sysinfo_end:
rts
nop
.align 2
0: .long __NR_sysinfo
1: .long __set_syscall_errno

View File

@@ -30,7 +30,7 @@
.globl _start
# this is the small startup code that is first run when
# any executable that is statically-linked with Bionic
# any executable that is dynamically-linked with Bionic
# runs.
#
# it's purpose is to call __libc_init with appropriate
@@ -94,3 +94,4 @@ __FINI_ARRAY__:
__CTOR_LIST__:
.long -1
#include "__dso_handle.S"

View File

@@ -1,3 +1,10 @@
# This function is to be called when the shared library
# is unloaded through dlclose()
_on_dlclose:
lea __dso_handle, %eax
call __cxa_finalize
ret
/* we put the _init() function here in case the user files for the shared
* libs want to drop things into .init section.
* We then will call our ctors from crtend_so.o */
@@ -20,6 +27,7 @@ __INIT_ARRAY__:
.globl __FINI_ARRAY__
__FINI_ARRAY__:
.long -1
.long _on_dlclose
.section .ctors, "aw"
.align 4
@@ -27,3 +35,5 @@ __FINI_ARRAY__:
.globl __CTOR_LIST__
__CTOR_LIST__:
.long -1
#include "__dso_handle.S"

View File

@@ -67,12 +67,6 @@ _start:
.long __FINI_ARRAY__
.long __CTOR_LIST__
# the .ctors section contains a list of pointers to "constructor"
# functions that need to be called in order during C library initialization,
# just before the program is being run. This is a C++ requirement
#
# the last entry shall be 0, and is defined in crtend.S
#
.section .preinit_array, "aw"
.globl __PREINIT_ARRAY__
__PREINIT_ARRAY__:
@@ -93,3 +87,4 @@ __FINI_ARRAY__:
__CTOR_LIST__:
.long -1
#include "__dso_handle.S"

View File

@@ -36,10 +36,23 @@
#define _I386__TYPES_H_
/* the kernel defines size_t as unsigned int, but g++ wants it to be unsigned long */
#define _SIZE_T
#ifndef _SIZE_T
# define _SIZE_T
# ifdef ANDROID
typedef unsigned int size_t;
# else
typedef unsigned long size_t;
# endif
#endif
#if !defined(_SSIZE_T) && !defined(_SSIZE_T_DEFINED_)
#define _SSIZE_T
#define _SSIZE_T_DEFINED_
typedef long int ssize_t;
#endif
#ifndef _PTRDIFF_T
#define _PTRDIFF_T
typedef unsigned int size_t;
typedef int ptrdiff_t;
typedef long ptrdiff_t;
#endif
#define _OFF_T_DEFINED_
#define _SIZE_T_DEFINED_

View File

@@ -0,0 +1,45 @@
/*
Copyright (c) 2010, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(USE_SSSE3)
# include "cache_wrapper.S"
# undef __i686
# define MEMCPY bcopy
# define USE_AS_MEMMOVE
# define USE_AS_BCOPY
# include "ssse3-memcpy5.S"
#else
# include "bcopy.S"
#endif

View File

@@ -0,0 +1,43 @@
/*
Copyright (c) 2010, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(USE_SSE2)
# include "cache_wrapper.S"
# undef __i686
# define USE_AS_BZERO
# define sse2_memset5_atom bzero
# include "sse2-memset5-atom.S"
#else
# include "bzero.S"
#endif

View File

@@ -0,0 +1,35 @@
/*
Copyright (c) 2010, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* Values are optimized for Atom */
#define SHARED_CACHE_SIZE (512*1024) /* Atom L2 Cache */
#define DATA_CACHE_SIZE (24*1024) /* Atom L1 Data Cache */
#define SHARED_CACHE_SIZE_HALF (SHARED_CACHE_SIZE / 2)
#define DATA_CACHE_SIZE_HALF (DATA_CACHE_SIZE / 2)

View File

@@ -0,0 +1,40 @@
/*
Copyright (c) 2010, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(USE_SSSE3)
# define MEMCMP memcmp
# include "ssse3-memcmp3.S"
#else
# include "memcmp.S"
#endif

View File

@@ -0,0 +1,43 @@
/*
Copyright (c) 2010, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(USE_SSSE3)
# include "cache_wrapper.S"
# undef __i686
# define MEMCPY memcpy
# define USE_AS_MEMMOVE
# include "ssse3-memcpy5.S"
#else
# include "memcpy.S"
#endif

View File

@@ -0,0 +1,43 @@
/*
Copyright (c) 2010, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(USE_SSSE3)
# include "cache_wrapper.S"
# undef __i686
# define MEMCPY memmove
# define USE_AS_MEMMOVE
# include "ssse3-memcpy5.S"
#else
# include "memmove.S"
#endif

View File

@@ -0,0 +1,42 @@
/*
Copyright (c) 2010, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(USE_SSE2)
# include "cache_wrapper.S"
# undef __i686
# define sse2_memset5_atom memset
# include "sse2-memset5-atom.S"
#else
# include "memset.S"
#endif

View File

@@ -0,0 +1,907 @@
/*
Copyright (c) 2010, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef L
# define L(label) .L##label
#endif
#ifndef ALIGN
# define ALIGN(n) .p2align n
#endif
#ifndef cfi_startproc
# define cfi_startproc .cfi_startproc
#endif
#ifndef cfi_endproc
# define cfi_endproc .cfi_endproc
#endif
#ifndef cfi_rel_offset
# define cfi_rel_offset(reg, off) .cfi_rel_offset reg, off
#endif
#ifndef cfi_restore
# define cfi_restore(reg) .cfi_restore (reg)
#endif
#ifndef cfi_adjust_cfa_offset
# define cfi_adjust_cfa_offset(off) .cfi_adjust_cfa_offset off
#endif
#ifndef ENTRY
# define ENTRY(name) \
.type name, @function; \
.globl name; \
.p2align 4; \
name: \
cfi_startproc
#endif
#ifndef END
# define END(name) \
cfi_endproc; \
.size name, .-name
#endif
#define CFI_PUSH(REG) \
cfi_adjust_cfa_offset (4); \
cfi_rel_offset (REG, 0)
#define CFI_POP(REG) \
cfi_adjust_cfa_offset (-4); \
cfi_restore (REG)
#define PUSH(REG) pushl REG; CFI_PUSH (REG)
#define POP(REG) popl REG; CFI_POP (REG)
#ifdef USE_AS_BZERO
# define DEST PARMS
# define LEN DEST+4
# define SETRTNVAL
#else
# define DEST PARMS
# define CHR DEST+4
# define LEN CHR+4
# define SETRTNVAL movl DEST(%esp), %eax
#endif
#ifdef SHARED
# define ENTRANCE PUSH (%ebx);
# define RETURN_END POP (%ebx); ret
# define RETURN RETURN_END; CFI_PUSH (%ebx)
# define PARMS 8 /* Preserve EBX. */
# define JMPTBL(I, B) I - B
/* Load an entry in a jump table into EBX and branch to it. TABLE is a
jump table with relative offsets. */
# define BRANCH_TO_JMPTBL_ENTRY(TABLE) \
/* We first load PC into EBX. */ \
call __i686.get_pc_thunk.bx; \
/* Get the address of the jump table. */ \
add $(TABLE - .), %ebx; \
/* Get the entry and convert the relative offset to the \
absolute address. */ \
add (%ebx,%ecx,4), %ebx; \
add %ecx, %edx; \
/* We loaded the jump table and adjuested EDX. Go. */ \
jmp *%ebx
.section .gnu.linkonce.t.__i686.get_pc_thunk.bx,"ax",@progbits
.globl __i686.get_pc_thunk.bx
.hidden __i686.get_pc_thunk.bx
ALIGN (4)
.type __i686.get_pc_thunk.bx,@function
__i686.get_pc_thunk.bx:
movl (%esp), %ebx
ret
#else
# define ENTRANCE
# define RETURN_END ret
# define RETURN RETURN_END
# define PARMS 4
# define JMPTBL(I, B) I
/* Branch to an entry in a jump table. TABLE is a jump table with
absolute offsets. */
# define BRANCH_TO_JMPTBL_ENTRY(TABLE) \
add %ecx, %edx; \
jmp *TABLE(,%ecx,4)
#endif
.section .text.sse2,"ax",@progbits
ALIGN (4)
ENTRY (sse2_memset5_atom)
ENTRANCE
movl LEN(%esp), %ecx
#ifdef USE_AS_BZERO
xor %eax, %eax
#else
movzbl CHR(%esp), %eax
movb %al, %ah
/* Fill the whole EAX with pattern. */
movl %eax, %edx
shl $16, %eax
or %edx, %eax
#endif
movl DEST(%esp), %edx
cmp $32, %ecx
jae L(32bytesormore)
L(write_less32bytes):
BRANCH_TO_JMPTBL_ENTRY (L(table_less_32bytes))
.pushsection .rodata.sse2,"a",@progbits
ALIGN (2)
L(table_less_32bytes):
.int JMPTBL (L(write_0bytes), L(table_less_32bytes))
.int JMPTBL (L(write_1bytes), L(table_less_32bytes))
.int JMPTBL (L(write_2bytes), L(table_less_32bytes))
.int JMPTBL (L(write_3bytes), L(table_less_32bytes))
.int JMPTBL (L(write_4bytes), L(table_less_32bytes))
.int JMPTBL (L(write_5bytes), L(table_less_32bytes))
.int JMPTBL (L(write_6bytes), L(table_less_32bytes))
.int JMPTBL (L(write_7bytes), L(table_less_32bytes))
.int JMPTBL (L(write_8bytes), L(table_less_32bytes))
.int JMPTBL (L(write_9bytes), L(table_less_32bytes))
.int JMPTBL (L(write_10bytes), L(table_less_32bytes))
.int JMPTBL (L(write_11bytes), L(table_less_32bytes))
.int JMPTBL (L(write_12bytes), L(table_less_32bytes))
.int JMPTBL (L(write_13bytes), L(table_less_32bytes))
.int JMPTBL (L(write_14bytes), L(table_less_32bytes))
.int JMPTBL (L(write_15bytes), L(table_less_32bytes))
.int JMPTBL (L(write_16bytes), L(table_less_32bytes))
.int JMPTBL (L(write_17bytes), L(table_less_32bytes))
.int JMPTBL (L(write_18bytes), L(table_less_32bytes))
.int JMPTBL (L(write_19bytes), L(table_less_32bytes))
.int JMPTBL (L(write_20bytes), L(table_less_32bytes))
.int JMPTBL (L(write_21bytes), L(table_less_32bytes))
.int JMPTBL (L(write_22bytes), L(table_less_32bytes))
.int JMPTBL (L(write_23bytes), L(table_less_32bytes))
.int JMPTBL (L(write_24bytes), L(table_less_32bytes))
.int JMPTBL (L(write_25bytes), L(table_less_32bytes))
.int JMPTBL (L(write_26bytes), L(table_less_32bytes))
.int JMPTBL (L(write_27bytes), L(table_less_32bytes))
.int JMPTBL (L(write_28bytes), L(table_less_32bytes))
.int JMPTBL (L(write_29bytes), L(table_less_32bytes))
.int JMPTBL (L(write_30bytes), L(table_less_32bytes))
.int JMPTBL (L(write_31bytes), L(table_less_32bytes))
.popsection
ALIGN (4)
L(write_28bytes):
movl %eax, -28(%edx)
L(write_24bytes):
movl %eax, -24(%edx)
L(write_20bytes):
movl %eax, -20(%edx)
L(write_16bytes):
movl %eax, -16(%edx)
L(write_12bytes):
movl %eax, -12(%edx)
L(write_8bytes):
movl %eax, -8(%edx)
L(write_4bytes):
movl %eax, -4(%edx)
L(write_0bytes):
SETRTNVAL
RETURN
ALIGN (4)
L(write_29bytes):
movl %eax, -29(%edx)
L(write_25bytes):
movl %eax, -25(%edx)
L(write_21bytes):
movl %eax, -21(%edx)
L(write_17bytes):
movl %eax, -17(%edx)
L(write_13bytes):
movl %eax, -13(%edx)
L(write_9bytes):
movl %eax, -9(%edx)
L(write_5bytes):
movl %eax, -5(%edx)
L(write_1bytes):
movb %al, -1(%edx)
SETRTNVAL
RETURN
ALIGN (4)
L(write_30bytes):
movl %eax, -30(%edx)
L(write_26bytes):
movl %eax, -26(%edx)
L(write_22bytes):
movl %eax, -22(%edx)
L(write_18bytes):
movl %eax, -18(%edx)
L(write_14bytes):
movl %eax, -14(%edx)
L(write_10bytes):
movl %eax, -10(%edx)
L(write_6bytes):
movl %eax, -6(%edx)
L(write_2bytes):
movw %ax, -2(%edx)
SETRTNVAL
RETURN
ALIGN (4)
L(write_31bytes):
movl %eax, -31(%edx)
L(write_27bytes):
movl %eax, -27(%edx)
L(write_23bytes):
movl %eax, -23(%edx)
L(write_19bytes):
movl %eax, -19(%edx)
L(write_15bytes):
movl %eax, -15(%edx)
L(write_11bytes):
movl %eax, -11(%edx)
L(write_7bytes):
movl %eax, -7(%edx)
L(write_3bytes):
movw %ax, -3(%edx)
movb %al, -1(%edx)
SETRTNVAL
RETURN
ALIGN (4)
/* ECX > 32 and EDX is 4 byte aligned. */
L(32bytesormore):
/* Fill xmm0 with the pattern. */
#ifdef USE_AS_BZERO
pxor %xmm0, %xmm0
#else
movd %eax, %xmm0
punpcklbw %xmm0, %xmm0
pshufd $0, %xmm0, %xmm0
#endif
testl $0xf, %edx
jz L(aligned_16)
/* ECX > 32 and EDX is not 16 byte aligned. */
L(not_aligned_16):
movdqu %xmm0, (%edx)
movl %edx, %eax
and $-16, %edx
add $16, %edx
sub %edx, %eax
add %eax, %ecx
movd %xmm0, %eax
ALIGN (4)
L(aligned_16):
cmp $128, %ecx
jae L(128bytesormore)
L(aligned_16_less128bytes):
BRANCH_TO_JMPTBL_ENTRY (L(table_16_128bytes))
ALIGN (4)
L(128bytesormore):
#ifdef SHARED_CACHE_SIZE
PUSH (%ebx)
mov $SHARED_CACHE_SIZE, %ebx
#else
# ifdef SHARED
call __i686.get_pc_thunk.bx
add $_GLOBAL_OFFSET_TABLE_, %ebx
mov __x86_shared_cache_size@GOTOFF(%ebx), %ebx
# else
PUSH (%ebx)
mov __x86_shared_cache_size, %ebx
# endif
#endif
cmp %ebx, %ecx
jae L(128bytesormore_nt_start)
#ifdef DATA_CACHE_SIZE
POP (%ebx)
cmp $DATA_CACHE_SIZE, %ecx
#else
# ifdef SHARED
call __i686.get_pc_thunk.bx
add $_GLOBAL_OFFSET_TABLE_, %ebx
cmp __x86_data_cache_size@GOTOFF(%ebx), %ecx
# else
POP (%ebx)
cmp __x86_data_cache_size, %ecx
# endif
#endif
jae L(128bytes_L2_normal)
subl $128, %ecx
L(128bytesormore_normal):
sub $128, %ecx
movdqa %xmm0, (%edx)
movdqa %xmm0, 0x10(%edx)
movdqa %xmm0, 0x20(%edx)
movdqa %xmm0, 0x30(%edx)
movdqa %xmm0, 0x40(%edx)
movdqa %xmm0, 0x50(%edx)
movdqa %xmm0, 0x60(%edx)
movdqa %xmm0, 0x70(%edx)
lea 128(%edx), %edx
jb L(128bytesless_normal)
sub $128, %ecx
movdqa %xmm0, (%edx)
movdqa %xmm0, 0x10(%edx)
movdqa %xmm0, 0x20(%edx)
movdqa %xmm0, 0x30(%edx)
movdqa %xmm0, 0x40(%edx)
movdqa %xmm0, 0x50(%edx)
movdqa %xmm0, 0x60(%edx)
movdqa %xmm0, 0x70(%edx)
lea 128(%edx), %edx
jae L(128bytesormore_normal)
L(128bytesless_normal):
lea 128(%ecx), %ecx
BRANCH_TO_JMPTBL_ENTRY (L(table_16_128bytes))
ALIGN (4)
L(128bytes_L2_normal):
prefetcht0 0x380(%edx)
prefetcht0 0x3c0(%edx)
sub $128, %ecx
movdqa %xmm0, (%edx)
movaps %xmm0, 0x10(%edx)
movaps %xmm0, 0x20(%edx)
movaps %xmm0, 0x30(%edx)
movaps %xmm0, 0x40(%edx)
movaps %xmm0, 0x50(%edx)
movaps %xmm0, 0x60(%edx)
movaps %xmm0, 0x70(%edx)
add $128, %edx
cmp $128, %ecx
jae L(128bytes_L2_normal)
L(128bytesless_L2_normal):
BRANCH_TO_JMPTBL_ENTRY (L(table_16_128bytes))
L(128bytesormore_nt_start):
sub %ebx, %ecx
ALIGN (4)
L(128bytesormore_shared_cache_loop):
prefetcht0 0x3c0(%edx)
prefetcht0 0x380(%edx)
sub $0x80, %ebx
movdqa %xmm0, (%edx)
movdqa %xmm0, 0x10(%edx)
movdqa %xmm0, 0x20(%edx)
movdqa %xmm0, 0x30(%edx)
movdqa %xmm0, 0x40(%edx)
movdqa %xmm0, 0x50(%edx)
movdqa %xmm0, 0x60(%edx)
movdqa %xmm0, 0x70(%edx)
add $0x80, %edx
cmp $0x80, %ebx
jae L(128bytesormore_shared_cache_loop)
cmp $0x80, %ecx
jb L(shared_cache_loop_end)
ALIGN (4)
L(128bytesormore_nt):
sub $0x80, %ecx
movntdq %xmm0, (%edx)
movntdq %xmm0, 0x10(%edx)
movntdq %xmm0, 0x20(%edx)
movntdq %xmm0, 0x30(%edx)
movntdq %xmm0, 0x40(%edx)
movntdq %xmm0, 0x50(%edx)
movntdq %xmm0, 0x60(%edx)
movntdq %xmm0, 0x70(%edx)
add $0x80, %edx
cmp $0x80, %ecx
jae L(128bytesormore_nt)
sfence
L(shared_cache_loop_end):
#if defined DATA_CACHE_SIZE || !defined SHARED
POP (%ebx)
#endif
BRANCH_TO_JMPTBL_ENTRY (L(table_16_128bytes))
.pushsection .rodata.sse2,"a",@progbits
ALIGN (2)
L(table_16_128bytes):
.int JMPTBL (L(aligned_16_0bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_1bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_2bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_3bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_4bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_5bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_6bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_7bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_8bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_9bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_10bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_11bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_12bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_13bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_14bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_15bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_16bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_17bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_18bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_19bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_20bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_21bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_22bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_23bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_24bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_25bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_26bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_27bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_28bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_29bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_30bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_31bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_32bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_33bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_34bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_35bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_36bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_37bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_38bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_39bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_40bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_41bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_42bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_43bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_44bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_45bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_46bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_47bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_48bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_49bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_50bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_51bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_52bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_53bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_54bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_55bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_56bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_57bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_58bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_59bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_60bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_61bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_62bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_63bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_64bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_65bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_66bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_67bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_68bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_69bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_70bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_71bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_72bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_73bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_74bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_75bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_76bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_77bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_78bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_79bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_80bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_81bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_82bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_83bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_84bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_85bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_86bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_87bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_88bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_89bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_90bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_91bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_92bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_93bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_94bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_95bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_96bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_97bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_98bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_99bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_100bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_101bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_102bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_103bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_104bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_105bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_106bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_107bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_108bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_109bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_110bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_111bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_112bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_113bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_114bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_115bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_116bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_117bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_118bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_119bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_120bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_121bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_122bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_123bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_124bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_125bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_126bytes), L(table_16_128bytes))
.int JMPTBL (L(aligned_16_127bytes), L(table_16_128bytes))
.popsection
ALIGN (4)
L(aligned_16_112bytes):
movdqa %xmm0, -112(%edx)
L(aligned_16_96bytes):
movdqa %xmm0, -96(%edx)
L(aligned_16_80bytes):
movdqa %xmm0, -80(%edx)
L(aligned_16_64bytes):
movdqa %xmm0, -64(%edx)
L(aligned_16_48bytes):
movdqa %xmm0, -48(%edx)
L(aligned_16_32bytes):
movdqa %xmm0, -32(%edx)
L(aligned_16_16bytes):
movdqa %xmm0, -16(%edx)
L(aligned_16_0bytes):
SETRTNVAL
RETURN
ALIGN (4)
L(aligned_16_113bytes):
movdqa %xmm0, -113(%edx)
L(aligned_16_97bytes):
movdqa %xmm0, -97(%edx)
L(aligned_16_81bytes):
movdqa %xmm0, -81(%edx)
L(aligned_16_65bytes):
movdqa %xmm0, -65(%edx)
L(aligned_16_49bytes):
movdqa %xmm0, -49(%edx)
L(aligned_16_33bytes):
movdqa %xmm0, -33(%edx)
L(aligned_16_17bytes):
movdqa %xmm0, -17(%edx)
L(aligned_16_1bytes):
movb %al, -1(%edx)
SETRTNVAL
RETURN
ALIGN (4)
L(aligned_16_114bytes):
movdqa %xmm0, -114(%edx)
L(aligned_16_98bytes):
movdqa %xmm0, -98(%edx)
L(aligned_16_82bytes):
movdqa %xmm0, -82(%edx)
L(aligned_16_66bytes):
movdqa %xmm0, -66(%edx)
L(aligned_16_50bytes):
movdqa %xmm0, -50(%edx)
L(aligned_16_34bytes):
movdqa %xmm0, -34(%edx)
L(aligned_16_18bytes):
movdqa %xmm0, -18(%edx)
L(aligned_16_2bytes):
movw %ax, -2(%edx)
SETRTNVAL
RETURN
ALIGN (4)
L(aligned_16_115bytes):
movdqa %xmm0, -115(%edx)
L(aligned_16_99bytes):
movdqa %xmm0, -99(%edx)
L(aligned_16_83bytes):
movdqa %xmm0, -83(%edx)
L(aligned_16_67bytes):
movdqa %xmm0, -67(%edx)
L(aligned_16_51bytes):
movdqa %xmm0, -51(%edx)
L(aligned_16_35bytes):
movdqa %xmm0, -35(%edx)
L(aligned_16_19bytes):
movdqa %xmm0, -19(%edx)
L(aligned_16_3bytes):
movw %ax, -3(%edx)
movb %al, -1(%edx)
SETRTNVAL
RETURN
ALIGN (4)
L(aligned_16_116bytes):
movdqa %xmm0, -116(%edx)
L(aligned_16_100bytes):
movdqa %xmm0, -100(%edx)
L(aligned_16_84bytes):
movdqa %xmm0, -84(%edx)
L(aligned_16_68bytes):
movdqa %xmm0, -68(%edx)
L(aligned_16_52bytes):
movdqa %xmm0, -52(%edx)
L(aligned_16_36bytes):
movdqa %xmm0, -36(%edx)
L(aligned_16_20bytes):
movdqa %xmm0, -20(%edx)
L(aligned_16_4bytes):
movl %eax, -4(%edx)
SETRTNVAL
RETURN
ALIGN (4)
L(aligned_16_117bytes):
movdqa %xmm0, -117(%edx)
L(aligned_16_101bytes):
movdqa %xmm0, -101(%edx)
L(aligned_16_85bytes):
movdqa %xmm0, -85(%edx)
L(aligned_16_69bytes):
movdqa %xmm0, -69(%edx)
L(aligned_16_53bytes):
movdqa %xmm0, -53(%edx)
L(aligned_16_37bytes):
movdqa %xmm0, -37(%edx)
L(aligned_16_21bytes):
movdqa %xmm0, -21(%edx)
L(aligned_16_5bytes):
movl %eax, -5(%edx)
movb %al, -1(%edx)
SETRTNVAL
RETURN
ALIGN (4)
L(aligned_16_118bytes):
movdqa %xmm0, -118(%edx)
L(aligned_16_102bytes):
movdqa %xmm0, -102(%edx)
L(aligned_16_86bytes):
movdqa %xmm0, -86(%edx)
L(aligned_16_70bytes):
movdqa %xmm0, -70(%edx)
L(aligned_16_54bytes):
movdqa %xmm0, -54(%edx)
L(aligned_16_38bytes):
movdqa %xmm0, -38(%edx)
L(aligned_16_22bytes):
movdqa %xmm0, -22(%edx)
L(aligned_16_6bytes):
movl %eax, -6(%edx)
movw %ax, -2(%edx)
SETRTNVAL
RETURN
ALIGN (4)
L(aligned_16_119bytes):
movdqa %xmm0, -119(%edx)
L(aligned_16_103bytes):
movdqa %xmm0, -103(%edx)
L(aligned_16_87bytes):
movdqa %xmm0, -87(%edx)
L(aligned_16_71bytes):
movdqa %xmm0, -71(%edx)
L(aligned_16_55bytes):
movdqa %xmm0, -55(%edx)
L(aligned_16_39bytes):
movdqa %xmm0, -39(%edx)
L(aligned_16_23bytes):
movdqa %xmm0, -23(%edx)
L(aligned_16_7bytes):
movl %eax, -7(%edx)
movw %ax, -3(%edx)
movb %al, -1(%edx)
SETRTNVAL
RETURN
ALIGN (4)
L(aligned_16_120bytes):
movdqa %xmm0, -120(%edx)
L(aligned_16_104bytes):
movdqa %xmm0, -104(%edx)
L(aligned_16_88bytes):
movdqa %xmm0, -88(%edx)
L(aligned_16_72bytes):
movdqa %xmm0, -72(%edx)
L(aligned_16_56bytes):
movdqa %xmm0, -56(%edx)
L(aligned_16_40bytes):
movdqa %xmm0, -40(%edx)
L(aligned_16_24bytes):
movdqa %xmm0, -24(%edx)
L(aligned_16_8bytes):
movq %xmm0, -8(%edx)
SETRTNVAL
RETURN
ALIGN (4)
L(aligned_16_121bytes):
movdqa %xmm0, -121(%edx)
L(aligned_16_105bytes):
movdqa %xmm0, -105(%edx)
L(aligned_16_89bytes):
movdqa %xmm0, -89(%edx)
L(aligned_16_73bytes):
movdqa %xmm0, -73(%edx)
L(aligned_16_57bytes):
movdqa %xmm0, -57(%edx)
L(aligned_16_41bytes):
movdqa %xmm0, -41(%edx)
L(aligned_16_25bytes):
movdqa %xmm0, -25(%edx)
L(aligned_16_9bytes):
movq %xmm0, -9(%edx)
movb %al, -1(%edx)
SETRTNVAL
RETURN
ALIGN (4)
L(aligned_16_122bytes):
movdqa %xmm0, -122(%edx)
L(aligned_16_106bytes):
movdqa %xmm0, -106(%edx)
L(aligned_16_90bytes):
movdqa %xmm0, -90(%edx)
L(aligned_16_74bytes):
movdqa %xmm0, -74(%edx)
L(aligned_16_58bytes):
movdqa %xmm0, -58(%edx)
L(aligned_16_42bytes):
movdqa %xmm0, -42(%edx)
L(aligned_16_26bytes):
movdqa %xmm0, -26(%edx)
L(aligned_16_10bytes):
movq %xmm0, -10(%edx)
movw %ax, -2(%edx)
SETRTNVAL
RETURN
ALIGN (4)
L(aligned_16_123bytes):
movdqa %xmm0, -123(%edx)
L(aligned_16_107bytes):
movdqa %xmm0, -107(%edx)
L(aligned_16_91bytes):
movdqa %xmm0, -91(%edx)
L(aligned_16_75bytes):
movdqa %xmm0, -75(%edx)
L(aligned_16_59bytes):
movdqa %xmm0, -59(%edx)
L(aligned_16_43bytes):
movdqa %xmm0, -43(%edx)
L(aligned_16_27bytes):
movdqa %xmm0, -27(%edx)
L(aligned_16_11bytes):
movq %xmm0, -11(%edx)
movw %ax, -3(%edx)
movb %al, -1(%edx)
SETRTNVAL
RETURN
ALIGN (4)
L(aligned_16_124bytes):
movdqa %xmm0, -124(%edx)
L(aligned_16_108bytes):
movdqa %xmm0, -108(%edx)
L(aligned_16_92bytes):
movdqa %xmm0, -92(%edx)
L(aligned_16_76bytes):
movdqa %xmm0, -76(%edx)
L(aligned_16_60bytes):
movdqa %xmm0, -60(%edx)
L(aligned_16_44bytes):
movdqa %xmm0, -44(%edx)
L(aligned_16_28bytes):
movdqa %xmm0, -28(%edx)
L(aligned_16_12bytes):
movq %xmm0, -12(%edx)
movl %eax, -4(%edx)
SETRTNVAL
RETURN
ALIGN (4)
L(aligned_16_125bytes):
movdqa %xmm0, -125(%edx)
L(aligned_16_109bytes):
movdqa %xmm0, -109(%edx)
L(aligned_16_93bytes):
movdqa %xmm0, -93(%edx)
L(aligned_16_77bytes):
movdqa %xmm0, -77(%edx)
L(aligned_16_61bytes):
movdqa %xmm0, -61(%edx)
L(aligned_16_45bytes):
movdqa %xmm0, -45(%edx)
L(aligned_16_29bytes):
movdqa %xmm0, -29(%edx)
L(aligned_16_13bytes):
movq %xmm0, -13(%edx)
movl %eax, -5(%edx)
movb %al, -1(%edx)
SETRTNVAL
RETURN
ALIGN (4)
L(aligned_16_126bytes):
movdqa %xmm0, -126(%edx)
L(aligned_16_110bytes):
movdqa %xmm0, -110(%edx)
L(aligned_16_94bytes):
movdqa %xmm0, -94(%edx)
L(aligned_16_78bytes):
movdqa %xmm0, -78(%edx)
L(aligned_16_62bytes):
movdqa %xmm0, -62(%edx)
L(aligned_16_46bytes):
movdqa %xmm0, -46(%edx)
L(aligned_16_30bytes):
movdqa %xmm0, -30(%edx)
L(aligned_16_14bytes):
movq %xmm0, -14(%edx)
movl %eax, -6(%edx)
movw %ax, -2(%edx)
SETRTNVAL
RETURN
ALIGN (4)
L(aligned_16_127bytes):
movdqa %xmm0, -127(%edx)
L(aligned_16_111bytes):
movdqa %xmm0, -111(%edx)
L(aligned_16_95bytes):
movdqa %xmm0, -95(%edx)
L(aligned_16_79bytes):
movdqa %xmm0, -79(%edx)
L(aligned_16_63bytes):
movdqa %xmm0, -63(%edx)
L(aligned_16_47bytes):
movdqa %xmm0, -47(%edx)
L(aligned_16_31bytes):
movdqa %xmm0, -31(%edx)
L(aligned_16_15bytes):
movq %xmm0, -15(%edx)
movl %eax, -7(%edx)
movw %ax, -3(%edx)
movb %al, -1(%edx)
SETRTNVAL
RETURN_END
END (sse2_memset5_atom)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,40 @@
/*
Copyright (c) 2010, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(USE_SSSE3)
# define ssse3_strcmp_latest strcmp
# include "ssse3-strcmp.S"
#else
# include "strcmp.S"
#endif

View File

@@ -0,0 +1,42 @@
/*
Copyright (c) 2010, Intel Corporation
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#if defined(USE_SSSE3)
# define USE_AS_STRNCMP
# define ssse3_strcmp_latest strncmp
# include "ssse3-strcmp.S"
#else
# include "strncmp.S"
#endif

View File

@@ -4,7 +4,7 @@ syscall_src += arch-x86/syscalls/_exit.S
syscall_src += arch-x86/syscalls/_exit_thread.S
syscall_src += arch-x86/syscalls/__fork.S
syscall_src += arch-x86/syscalls/_waitpid.S
syscall_src += arch-x86/syscalls/waitid.S
syscall_src += arch-x86/syscalls/__waitid.S
syscall_src += arch-x86/syscalls/__sys_clone.S
syscall_src += arch-x86/syscalls/execve.S
syscall_src += arch-x86/syscalls/__setuid.S
@@ -69,15 +69,17 @@ syscall_src += arch-x86/syscalls/flock.S
syscall_src += arch-x86/syscalls/fchmod.S
syscall_src += arch-x86/syscalls/dup.S
syscall_src += arch-x86/syscalls/pipe.S
syscall_src += arch-x86/syscalls/pipe2.S
syscall_src += arch-x86/syscalls/dup2.S
syscall_src += arch-x86/syscalls/select.S
syscall_src += arch-x86/syscalls/ftruncate.S
syscall_src += arch-x86/syscalls/getdents.S
syscall_src += arch-x86/syscalls/fsync.S
syscall_src += arch-x86/syscalls/fdatasync.S
syscall_src += arch-x86/syscalls/fchown.S
syscall_src += arch-x86/syscalls/sync.S
syscall_src += arch-x86/syscalls/__fcntl64.S
syscall_src += arch-x86/syscalls/fstatfs.S
syscall_src += arch-x86/syscalls/__fstatfs64.S
syscall_src += arch-x86/syscalls/sendfile.S
syscall_src += arch-x86/syscalls/fstatat.S
syscall_src += arch-x86/syscalls/mkdirat.S
@@ -164,6 +166,7 @@ syscall_src += arch-x86/syscalls/__syslog.S
syscall_src += arch-x86/syscalls/init_module.S
syscall_src += arch-x86/syscalls/delete_module.S
syscall_src += arch-x86/syscalls/klogctl.S
syscall_src += arch-x86/syscalls/sysinfo.S
syscall_src += arch-x86/syscalls/futex.S
syscall_src += arch-x86/syscalls/epoll_create.S
syscall_src += arch-x86/syscalls/epoll_ctl.S
@@ -172,3 +175,4 @@ syscall_src += arch-x86/syscalls/inotify_init.S
syscall_src += arch-x86/syscalls/inotify_add_watch.S
syscall_src += arch-x86/syscalls/inotify_rm_watch.S
syscall_src += arch-x86/syscalls/poll.S
syscall_src += arch-x86/syscalls/eventfd.S

View File

@@ -2,11 +2,11 @@
#include <sys/linux-syscalls.h>
.text
.type fstatfs, @function
.globl fstatfs
.type __fstatfs64, @function
.globl __fstatfs64
.align 4
fstatfs:
__fstatfs64:
pushl %ebx
pushl %ecx
pushl %edx

View File

@@ -2,11 +2,11 @@
#include <sys/linux-syscalls.h>
.text
.type waitid, @function
.globl waitid
.type __waitid, @function
.globl __waitid
.align 4
waitid:
__waitid:
pushl %ebx
pushl %ecx
pushl %edx

View File

@@ -0,0 +1,26 @@
/* autogenerated by gensyscalls.py */
#include <sys/linux-syscalls.h>
.text
.type eventfd, @function
.globl eventfd
.align 4
eventfd:
pushl %ebx
pushl %ecx
mov 12(%esp), %ebx
mov 16(%esp), %ecx
movl $__NR_eventfd2, %eax
int $0x80
cmpl $-129, %eax
jb 1f
negl %eax
pushl %eax
call __set_errno
addl $4, %esp
orl $-1, %eax
1:
popl %ecx
popl %ebx
ret

View File

@@ -0,0 +1,23 @@
/* autogenerated by gensyscalls.py */
#include <sys/linux-syscalls.h>
.text
.type fdatasync, @function
.globl fdatasync
.align 4
fdatasync:
pushl %ebx
mov 8(%esp), %ebx
movl $__NR_fdatasync, %eax
int $0x80
cmpl $-129, %eax
jb 1f
negl %eax
pushl %eax
call __set_errno
addl $4, %esp
orl $-1, %eax
1:
popl %ebx
ret

View File

@@ -0,0 +1,26 @@
/* autogenerated by gensyscalls.py */
#include <sys/linux-syscalls.h>
.text
.type pipe2, @function
.globl pipe2
.align 4
pipe2:
pushl %ebx
pushl %ecx
mov 12(%esp), %ebx
mov 16(%esp), %ecx
movl $__NR_pipe2, %eax
int $0x80
cmpl $-129, %eax
jb 1f
negl %eax
pushl %eax
call __set_errno
addl $4, %esp
orl $-1, %eax
1:
popl %ecx
popl %ebx
ret

View File

@@ -0,0 +1,23 @@
/* autogenerated by gensyscalls.py */
#include <sys/linux-syscalls.h>
.text
.type sysinfo, @function
.globl sysinfo
.align 4
sysinfo:
pushl %ebx
mov 8(%esp), %ebx
movl $__NR_sysinfo, %eax
int $0x80
cmpl $-129, %eax
jb 1f
negl %eax
pushl %eax
call __set_errno
addl $4, %esp
orl $-1, %eax
1:
popl %ebx
ret

View File

@@ -26,14 +26,17 @@
* SUCH DAMAGE.
*/
#include <stddef.h>
extern char** environ;
int clearenv(void)
{
char **P = environ;
int offset;
char **P = environ;
for (P = &environ[offset]; *P; ++P)
*P = 0;
return 0;
if (P != NULL) {
for (; *P; ++P)
*P = NULL;
}
return 0;
}

View File

@@ -29,7 +29,7 @@
#include <stdio.h>
#include <errno.h>
#include <sys/stat.h>
//#include <sys/types.h>
#include "cpuacct.h"
int cpuacct_add(uid_t uid)
{

View File

@@ -27,6 +27,7 @@
*/
#include <unistd.h>
#include "pthread_internal.h"
#include "cpuacct.h"
extern int __fork(void);

View File

@@ -548,9 +548,9 @@ fts_build(FTS *sp, int type)
DIR *dirp;
void *oldaddr;
size_t len, maxlen;
int nitems, cderrno, descend, level, nlinks, nostat, doadjust;
int nitems, cderrno, descend, level, nlinks, nostat = 0, doadjust;
int saved_errno;
char *cp;
char *cp = NULL;
/* Set current node pointer. */
cur = sp->fts_cur;

View File

@@ -84,3 +84,39 @@ void __libc_init_common(uintptr_t *elfdata)
/* setup system properties - requires environment */
__system_properties_init();
}
/* This function will be called during normal program termination
* to run the destructors that are listed in the .fini_array section
* of the executable, if any.
*
* 'fini_array' points to a list of function addresses. The first
* entry in the list has value -1, the last one has value 0.
*/
void __libc_fini(void* array)
{
int count;
void** fini_array = array;
const size_t minus1 = ~(size_t)0; /* ensure proper sign extension */
/* Sanity check - first entry must be -1 */
if (array == NULL || (size_t)fini_array[0] != minus1) {
return;
}
/* skip over it */
fini_array += 1;
/* Count the number of destructors. */
for (count = 0; fini_array[count] != NULL; count++);
/* Now call each destructor in reverse order. */
while (count > 0) {
void (*func)() = (void (*)) fini_array[--count];
/* Sanity check, any -1 in the list is ignored */
if ((size_t)func == minus1)
continue;
func();
}
}

View File

@@ -39,5 +39,6 @@ typedef struct
} structors_array_t;
extern void __libc_init_common(uintptr_t *elfdata);
extern void __libc_fini(void* finit_array);
#endif

View File

@@ -57,9 +57,9 @@
* This ensures that the function is called by the dynamic linker
* as soon as the shared library is loaded.
*/
void __attribute__((constructor)) __libc_prenit(void);
void __attribute__((constructor)) __libc_preinit(void);
void __libc_prenit(void)
void __libc_preinit(void)
{
/* Read the ELF data pointer form a special slot of the
* TLS area, then call __libc_init_common with it.
@@ -83,14 +83,19 @@ void __libc_prenit(void)
malloc_debug_init();
}
/* This function is called from the executable's _start entry point
* (see arch-$ARCH/bionic/crtbegin_dynamic.S), which is itself
* called by the dynamic linker after it has loaded all shared
* libraries the executable depends on.
*
* Note that the dynamic linker has also run all constructors in the
* executable at this point.
*/
__noreturn void __libc_init(uintptr_t *elfdata,
void (*onexit)(void),
int (*slingshot)(int, char**, char**),
structors_array_t const * const structors)
{
/* When we reach this point, all initializers have been already
* run by the dynamic linker, so ignore 'structors'.
*/
int argc = (int)*elfdata;
char** argv = (char**)(elfdata + 1);
char** envp = argv + argc + 1;
@@ -99,5 +104,12 @@ __noreturn void __libc_init(uintptr_t *elfdata,
* do never use it. Therefore, we ignore it.
*/
/* The executable may have its own destructors listed in its .fini_array
* so we need to ensure that these are called when the program exits
* normally.
*/
if (structors->fini_array)
__cxa_atexit(__libc_fini,structors->fini_array,NULL);
exit(slingshot(argc, argv, envp));
}

View File

@@ -85,5 +85,12 @@ __noreturn void __libc_init(uintptr_t *elfdata,
argv = (char**)(elfdata + 1);
envp = argv + argc + 1;
/* The executable may have its own destructors listed in its .fini_array
* so we need to ensure that these are called when the program exits
* normally.
*/
if (structors->fini_array)
__cxa_atexit(__libc_fini,structors->fini_array,NULL);
exit(slingshot(argc, argv, envp));
}

View File

@@ -38,12 +38,17 @@
#include <stdarg.h>
#include <fcntl.h>
#include <cutils/logger.h>
#include "logd.h"
/* should match system/core/include/cutils/logger.h */
#define LOGGER_LOG_MAIN "log/main"
#define LOGGER_LOG_RADIO "log/radio"
#define LOGGER_LOG_EVENTS "log/events"
#define LOGGER_LOG_SYSTEM "log/system"
#include <pthread.h>
#define LOG_BUF_SIZE 1024
#define LOG_BUF_SIZE 1024
typedef enum {
LOG_ID_NONE = 0,
@@ -114,6 +119,8 @@ static int __write_to_log_init(log_id_t log_id, struct iovec *vec)
(fd < 0) ? __write_to_log_null : __write_to_log_kernel;
log_channels[log_id].fd = fd;
log_channels[log_id].fd = fd;
pthread_mutex_unlock(&log_init_lock);
return log_channels[log_id].logger(log_id, vec);

View File

@@ -60,34 +60,43 @@ HashTable gHashTable;
static int hash_entry_compare(const void* arg1, const void* arg2)
{
int result;
HashEntry* e1 = *(HashEntry**)arg1;
HashEntry* e2 = *(HashEntry**)arg2;
size_t nbAlloc1 = e1->allocations;
size_t nbAlloc2 = e2->allocations;
size_t size1 = e1->size & ~SIZE_FLAG_MASK;
size_t size2 = e2->size & ~SIZE_FLAG_MASK;
size_t alloc1 = nbAlloc1 * size1;
size_t alloc2 = nbAlloc2 * size2;
// sort in descending order by:
// 1) total size
// 2) number of allocations
//
// This is used for sorting, not determination of equality, so we don't
// need to compare the bit flags.
int result;
if (alloc1 > alloc2) {
// if one or both arg pointers are null, deal gracefully
if (e1 == NULL) {
result = (e2 == NULL) ? 0 : 1;
} else if (e2 == NULL) {
result = -1;
} else if (alloc1 < alloc2) {
result = 1;
} else {
if (nbAlloc1 > nbAlloc2) {
size_t nbAlloc1 = e1->allocations;
size_t nbAlloc2 = e2->allocations;
size_t size1 = e1->size & ~SIZE_FLAG_MASK;
size_t size2 = e2->size & ~SIZE_FLAG_MASK;
size_t alloc1 = nbAlloc1 * size1;
size_t alloc2 = nbAlloc2 * size2;
// sort in descending order by:
// 1) total size
// 2) number of allocations
//
// This is used for sorting, not determination of equality, so we don't
// need to compare the bit flags.
int result;
if (alloc1 > alloc2) {
result = -1;
} else if (nbAlloc1 < nbAlloc2) {
} else if (alloc1 < alloc2) {
result = 1;
} else {
result = 0;
if (nbAlloc1 > nbAlloc2) {
result = -1;
} else if (nbAlloc1 < nbAlloc2) {
result = 1;
} else {
result = 0;
}
}
}
return result;
@@ -149,7 +158,7 @@ void get_malloc_leak_info(uint8_t** info, size_t* overallSize,
if (*info == NULL) {
*overallSize = 0;
goto done;
goto out_nomem_info;
}
qsort((void*)list, gHashTable.count, sizeof(void*), hash_entry_compare);
@@ -161,8 +170,7 @@ void get_malloc_leak_info(uint8_t** info, size_t* overallSize,
size_t entrySize = (sizeof(size_t) * 2) + (sizeof(intptr_t) * entry->numEntries);
if (entrySize < *infoSize) {
/* we're writing less than a full entry, clear out the rest */
/* TODO: only clear out the part we're not overwriting? */
memset(head, 0, *infoSize);
memset(head + entrySize, 0, *infoSize - entrySize);
} else {
/* make sure the amount we're copying doesn't exceed the limit */
entrySize = *infoSize;
@@ -171,6 +179,7 @@ void get_malloc_leak_info(uint8_t** info, size_t* overallSize,
head += *infoSize;
}
out_nomem_info:
dlfree(list);
done:

View File

@@ -149,6 +149,8 @@ static HashEntry* record_backtrace(intptr_t* backtrace, size_t numEntries, size_
} else {
// create a new entry
entry = (HashEntry*)dlmalloc(sizeof(HashEntry) + numEntries*sizeof(intptr_t));
if (!entry)
return NULL;
entry->allocations = 1;
entry->slot = slot;
entry->prev = NULL;

View File

@@ -0,0 +1,347 @@
/*
* Copyright (C) 2010 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include "pthread_internal.h"
#include <errno.h>
/* Technical note:
*
* Possible states of a read/write lock:
*
* - no readers and no writer (unlocked)
* - one or more readers sharing the lock at the same time (read-locked)
* - one writer holding the lock (write-lock)
*
* Additionally:
* - trying to get the write-lock while there are any readers blocks
* - trying to get the read-lock while there is a writer blocks
* - a single thread can acquire the lock multiple times in the same mode
*
* - Posix states that behaviour is undefined it a thread tries to acquire
* the lock in two distinct modes (e.g. write after read, or read after write).
*
* - This implementation tries to avoid writer starvation by making the readers
* block as soon as there is a waiting writer on the lock. However, it cannot
* completely eliminate it: each time the lock is unlocked, all waiting threads
* are woken and battle for it, which one gets it depends on the kernel scheduler
* and is semi-random.
*
*/
#define __likely(cond) __builtin_expect(!!(cond), 1)
#define __unlikely(cond) __builtin_expect(!!(cond), 0)
#define RWLOCKATTR_DEFAULT 0
#define RWLOCKATTR_SHARED_MASK 0x0010
extern pthread_internal_t* __get_thread(void);
/* Return a global kernel ID for the current thread */
static int __get_thread_id(void)
{
return __get_thread()->kernel_id;
}
int pthread_rwlockattr_init(pthread_rwlockattr_t *attr)
{
if (!attr)
return EINVAL;
*attr = PTHREAD_PROCESS_PRIVATE;
return 0;
}
int pthread_rwlockattr_destroy(pthread_rwlockattr_t *attr)
{
if (!attr)
return EINVAL;
*attr = -1;
return 0;
}
int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *attr, int pshared)
{
if (!attr)
return EINVAL;
switch (pshared) {
case PTHREAD_PROCESS_PRIVATE:
case PTHREAD_PROCESS_SHARED:
*attr = pshared;
return 0;
default:
return EINVAL;
}
}
int pthread_rwlockattr_getpshared(pthread_rwlockattr_t *attr, int *pshared)
{
if (!attr || !pshared)
return EINVAL;
*pshared = *attr;
return 0;
}
int pthread_rwlock_init(pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr)
{
pthread_mutexattr_t* lock_attr = NULL;
pthread_condattr_t* cond_attr = NULL;
pthread_mutexattr_t lock_attr0;
pthread_condattr_t cond_attr0;
int ret;
if (rwlock == NULL)
return EINVAL;
if (attr && *attr == PTHREAD_PROCESS_SHARED) {
lock_attr = &lock_attr0;
pthread_mutexattr_init(lock_attr);
pthread_mutexattr_setpshared(lock_attr, PTHREAD_PROCESS_SHARED);
cond_attr = &cond_attr0;
pthread_condattr_init(cond_attr);
pthread_condattr_setpshared(cond_attr, PTHREAD_PROCESS_SHARED);
}
ret = pthread_mutex_init(&rwlock->lock, lock_attr);
if (ret != 0)
return ret;
ret = pthread_cond_init(&rwlock->cond, cond_attr);
if (ret != 0) {
pthread_mutex_destroy(&rwlock->lock);
return ret;
}
rwlock->numLocks = 0;
rwlock->pendingReaders = 0;
rwlock->pendingWriters = 0;
rwlock->writerThreadId = 0;
return 0;
}
int pthread_rwlock_destroy(pthread_rwlock_t *rwlock)
{
int ret;
if (rwlock == NULL)
return EINVAL;
if (rwlock->numLocks > 0)
return EBUSY;
pthread_cond_destroy(&rwlock->cond);
pthread_mutex_destroy(&rwlock->lock);
return 0;
}
/* Returns TRUE iff we can acquire a read lock. */
static __inline__ int read_precondition(pthread_rwlock_t *rwlock, int thread_id)
{
/* We can't have the lock if any writer is waiting for it (writer bias).
* This tries to avoid starvation when there are multiple readers racing.
*/
if (rwlock->pendingWriters > 0)
return 0;
/* We can have the lock if there is no writer, or if we write-own it */
/* The second test avoids a self-dead lock in case of buggy code. */
if (rwlock->writerThreadId == 0 || rwlock->writerThreadId == thread_id)
return 1;
/* Otherwise, we can't have it */
return 0;
}
/* returns TRUE iff we can acquire a write lock. */
static __inline__ int write_precondition(pthread_rwlock_t *rwlock, int thread_id)
{
/* We can get the lock if nobody has it */
if (rwlock->numLocks == 0)
return 1;
/* Or if we already own it */
if (rwlock->writerThreadId == thread_id)
return 1;
/* Otherwise, not */
return 0;
}
/* This function is used to waken any waiting thread contending
* for the lock. One of them should be able to grab it after
* that.
*/
static void _pthread_rwlock_pulse(pthread_rwlock_t *rwlock)
{
if (rwlock->pendingReaders > 0 || rwlock->pendingWriters > 0)
pthread_cond_broadcast(&rwlock->cond);
}
int pthread_rwlock_rdlock(pthread_rwlock_t *rwlock)
{
return pthread_rwlock_timedrdlock(rwlock, NULL);
}
int pthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock)
{
int ret = 0;
if (rwlock == NULL)
return EINVAL;
pthread_mutex_lock(&rwlock->lock);
if (__unlikely(!read_precondition(rwlock, __get_thread_id())))
ret = EBUSY;
else
rwlock->numLocks ++;
pthread_mutex_unlock(&rwlock->lock);
return ret;
}
int pthread_rwlock_timedrdlock(pthread_rwlock_t *rwlock, const struct timespec *abs_timeout)
{
int thread_id, ret = 0;
if (rwlock == NULL)
return EINVAL;
pthread_mutex_lock(&rwlock->lock);
thread_id = __get_thread_id();
if (__unlikely(!read_precondition(rwlock, thread_id))) {
rwlock->pendingReaders += 1;
do {
ret = pthread_cond_timedwait(&rwlock->cond, &rwlock->lock, abs_timeout);
} while (ret == 0 && !read_precondition(rwlock, thread_id));
rwlock->pendingReaders -= 1;
if (ret != 0)
goto EXIT;
}
rwlock->numLocks ++;
EXIT:
pthread_mutex_unlock(&rwlock->lock);
return ret;
}
int pthread_rwlock_wrlock(pthread_rwlock_t *rwlock)
{
return pthread_rwlock_timedwrlock(rwlock, NULL);
}
int pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock)
{
int thread_id, ret = 0;
if (rwlock == NULL)
return EINVAL;
pthread_mutex_lock(&rwlock->lock);
thread_id = __get_thread_id();
if (__unlikely(!write_precondition(rwlock, thread_id))) {
ret = EBUSY;
} else {
rwlock->numLocks ++;
rwlock->writerThreadId = thread_id;
}
pthread_mutex_unlock(&rwlock->lock);
return ret;
}
int pthread_rwlock_timedwrlock(pthread_rwlock_t *rwlock, const struct timespec *abs_timeout)
{
int thread_id, ret = 0;
if (rwlock == NULL)
return EINVAL;
pthread_mutex_lock(&rwlock->lock);
thread_id = __get_thread_id();
if (__unlikely(!write_precondition(rwlock, thread_id))) {
/* If we can't read yet, wait until the rwlock is unlocked
* and try again. Increment pendingReaders to get the
* cond broadcast when that happens.
*/
rwlock->pendingWriters += 1;
do {
ret = pthread_cond_timedwait(&rwlock->cond, &rwlock->lock, abs_timeout);
} while (ret == 0 && !write_precondition(rwlock, thread_id));
rwlock->pendingWriters -= 1;
if (ret != 0)
goto EXIT;
}
rwlock->numLocks ++;
rwlock->writerThreadId = thread_id;
EXIT:
pthread_mutex_unlock(&rwlock->lock);
return ret;
}
int pthread_rwlock_unlock(pthread_rwlock_t *rwlock)
{
int ret = 0;
if (rwlock == NULL)
return EINVAL;
pthread_mutex_lock(&rwlock->lock);
/* The lock must be held */
if (rwlock->numLocks == 0) {
ret = EPERM;
goto EXIT;
}
/* If it has only readers, writerThreadId is 0 */
if (rwlock->writerThreadId == 0) {
if (--rwlock->numLocks == 0)
_pthread_rwlock_pulse(rwlock);
}
/* Otherwise, it has only a single writer, which
* must be ourselves.
*/
else {
if (rwlock->writerThreadId != __get_thread_id()) {
ret = EPERM;
goto EXIT;
}
if (--rwlock->numLocks == 0) {
rwlock->writerThreadId = 0;
_pthread_rwlock_pulse(rwlock);
}
}
EXIT:
pthread_mutex_unlock(&rwlock->lock);
return ret;
}

View File

@@ -43,13 +43,28 @@
#include <memory.h>
#include <assert.h>
#include <malloc.h>
#include <linux/futex.h>
#include <bionic_futex.h>
#include <bionic_atomic_inline.h>
#include <sys/prctl.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
extern int __pthread_clone(int (*fn)(void*), void *child_stack, int flags, void *arg);
extern void _exit_with_stack_teardown(void * stackBase, int stackSize, int retCode);
extern void _exit_thread(int retCode);
extern int __set_errno(int);
int __futex_wake_ex(volatile void *ftx, int pshared, int val)
{
return __futex_syscall3(ftx, pshared ? FUTEX_WAKE : FUTEX_WAKE_PRIVATE, val);
}
int __futex_wait_ex(volatile void *ftx, int pshared, int val, const struct timespec *timeout)
{
return __futex_syscall4(ftx, pshared ? FUTEX_WAIT : FUTEX_WAIT_PRIVATE, val, timeout);
}
#define __likely(cond) __builtin_expect(!!(cond), 1)
#define __unlikely(cond) __builtin_expect(!!(cond), 0)
@@ -712,24 +727,6 @@ int pthread_setschedparam(pthread_t thid, int policy,
}
int __futex_wait(volatile void *ftx, int val, const struct timespec *timeout);
int __futex_wake(volatile void *ftx, int count);
int __futex_syscall3(volatile void *ftx, int op, int val);
int __futex_syscall4(volatile void *ftx, int op, int val, const struct timespec *timeout);
#ifndef FUTEX_PRIVATE_FLAG
#define FUTEX_PRIVATE_FLAG 128
#endif
#ifndef FUTEX_WAIT_PRIVATE
#define FUTEX_WAIT_PRIVATE (FUTEX_WAIT|FUTEX_PRIVATE_FLAG)
#endif
#ifndef FUTEX_WAKE_PRIVATE
#define FUTEX_WAKE_PRIVATE (FUTEX_WAKE|FUTEX_PRIVATE_FLAG)
#endif
// mutex lock states
//
// 0: unlocked
@@ -883,8 +880,13 @@ int pthread_mutex_init(pthread_mutex_t *mutex,
int pthread_mutex_destroy(pthread_mutex_t *mutex)
{
if (__unlikely(mutex == NULL))
return EINVAL;
int ret;
/* use trylock to ensure that the mutex value is
* valid and is not already locked. */
ret = pthread_mutex_trylock(mutex);
if (ret != 0)
return ret;
mutex->value = 0xdead10cc;
return 0;
@@ -931,11 +933,10 @@ _normal_lock(pthread_mutex_t* mutex)
* that the mutex is in state 2 when we go to sleep on it, which
* guarantees a wake-up call.
*/
int wait_op = shared ? FUTEX_WAIT : FUTEX_WAIT_PRIVATE;
while (__atomic_swap(shared|2, &mutex->value ) != (shared|0))
__futex_syscall4(&mutex->value, wait_op, shared|2, 0);
__futex_wait_ex(&mutex->value, shared, shared|2, 0);
}
ANDROID_MEMBAR_FULL();
}
/*
@@ -945,6 +946,8 @@ _normal_lock(pthread_mutex_t* mutex)
static __inline__ void
_normal_unlock(pthread_mutex_t* mutex)
{
ANDROID_MEMBAR_FULL();
/* We need to preserve the shared flag during operations */
int shared = mutex->value & MUTEX_SHARED_MASK;
@@ -954,7 +957,6 @@ _normal_unlock(pthread_mutex_t* mutex)
* if it wasn't 1 we have to do some additional work.
*/
if (__atomic_dec(&mutex->value) != (shared|1)) {
int wake_op = shared ? FUTEX_WAKE : FUTEX_WAKE_PRIVATE;
/*
* Start by releasing the lock. The decrement changed it from
* "contended lock" to "uncontended lock", which means we still
@@ -992,7 +994,7 @@ _normal_unlock(pthread_mutex_t* mutex)
* Either way we have correct behavior and nobody is orphaned on
* the wait queue.
*/
__futex_syscall3(&mutex->value, wake_op, 1);
__futex_wake_ex(&mutex->value, shared, 1);
}
}
@@ -1012,7 +1014,7 @@ _recursive_unlock(void)
int pthread_mutex_lock(pthread_mutex_t *mutex)
{
int mtype, tid, new_lock_type, shared, wait_op;
int mtype, tid, new_lock_type, shared;
if (__unlikely(mutex == NULL))
return EINVAL;
@@ -1057,8 +1059,7 @@ int pthread_mutex_lock(pthread_mutex_t *mutex)
new_lock_type = 1;
/* compute futex wait opcode and restore shared flag in mtype */
wait_op = shared ? FUTEX_WAIT : FUTEX_WAIT_PRIVATE;
mtype |= shared;
mtype |= shared;
for (;;) {
int oldv;
@@ -1084,7 +1085,7 @@ int pthread_mutex_lock(pthread_mutex_t *mutex)
*/
new_lock_type = 2;
__futex_syscall4(&mutex->value, wait_op, oldv, NULL);
__futex_wait_ex(&mutex->value, shared, oldv, NULL);
}
return 0;
}
@@ -1124,8 +1125,7 @@ int pthread_mutex_unlock(pthread_mutex_t *mutex)
/* Wake one waiting thread, if any */
if ((oldv & 3) == 2) {
int wake_op = shared ? FUTEX_WAKE : FUTEX_WAKE_PRIVATE;
__futex_syscall3(&mutex->value, wake_op, 1);
__futex_wake_ex(&mutex->value, shared, 1);
}
return 0;
}
@@ -1144,8 +1144,10 @@ int pthread_mutex_trylock(pthread_mutex_t *mutex)
/* Handle common case first */
if ( __likely(mtype == MUTEX_TYPE_NORMAL) )
{
if (__atomic_cmpxchg(shared|0, shared|1, &mutex->value) == 0)
if (__atomic_cmpxchg(shared|0, shared|1, &mutex->value) == 0) {
ANDROID_MEMBAR_FULL();
return 0;
}
return EBUSY;
}
@@ -1225,7 +1227,7 @@ int pthread_mutex_lock_timeout_np(pthread_mutex_t *mutex, unsigned msecs)
clockid_t clock = CLOCK_MONOTONIC;
struct timespec abstime;
struct timespec ts;
int mtype, tid, oldv, new_lock_type, shared, wait_op;
int mtype, tid, oldv, new_lock_type, shared;
/* compute absolute expiration time */
__timespec_to_relative_msec(&abstime, msecs, clock);
@@ -1239,19 +1241,20 @@ int pthread_mutex_lock_timeout_np(pthread_mutex_t *mutex, unsigned msecs)
/* Handle common case first */
if ( __likely(mtype == MUTEX_TYPE_NORMAL) )
{
int wait_op = shared ? FUTEX_WAIT : FUTEX_WAIT_PRIVATE;
/* fast path for unconteded lock */
if (__atomic_cmpxchg(shared|0, shared|1, &mutex->value) == 0)
/* fast path for uncontended lock */
if (__atomic_cmpxchg(shared|0, shared|1, &mutex->value) == 0) {
ANDROID_MEMBAR_FULL();
return 0;
}
/* loop while needed */
while (__atomic_swap(shared|2, &mutex->value) != (shared|0)) {
if (__timespec_to_absolute(&ts, &abstime, clock) < 0)
return EBUSY;
__futex_syscall4(&mutex->value, wait_op, shared|2, &ts);
__futex_wait_ex(&mutex->value, shared, shared|2, &ts);
}
ANDROID_MEMBAR_FULL();
return 0;
}
@@ -1282,7 +1285,6 @@ int pthread_mutex_lock_timeout_np(pthread_mutex_t *mutex, unsigned msecs)
new_lock_type = 1;
/* Compute wait op and restore sharing bit in mtype */
wait_op = shared ? FUTEX_WAIT : FUTEX_WAIT_PRIVATE;
mtype |= shared;
for (;;) {
@@ -1313,7 +1315,7 @@ int pthread_mutex_lock_timeout_np(pthread_mutex_t *mutex, unsigned msecs)
if (__timespec_to_absolute(&ts, &abstime, clock) < 0)
return EBUSY;
__futex_syscall4(&mutex->value, wait_op, oldv, &ts);
__futex_wait_ex(&mutex->value, shared, oldv, &ts);
}
return 0;
}
@@ -1406,7 +1408,6 @@ static int
__pthread_cond_pulse(pthread_cond_t *cond, int counter)
{
long flags;
int wake_op;
if (__unlikely(cond == NULL))
return EINVAL;
@@ -1420,8 +1421,7 @@ __pthread_cond_pulse(pthread_cond_t *cond, int counter)
break;
}
wake_op = COND_IS_SHARED(cond) ? FUTEX_WAKE : FUTEX_WAKE_PRIVATE;
__futex_syscall3(&cond->value, wake_op, counter);
__futex_wake_ex(&cond->value, COND_IS_SHARED(cond), counter);
return 0;
}
@@ -1446,10 +1446,9 @@ int __pthread_cond_timedwait_relative(pthread_cond_t *cond,
{
int status;
int oldvalue = cond->value;
int wait_op = COND_IS_SHARED(cond) ? FUTEX_WAIT : FUTEX_WAIT_PRIVATE;
pthread_mutex_unlock(mutex);
status = __futex_syscall4(&cond->value, wait_op, oldvalue, reltime);
status = __futex_wait_ex(&cond->value, COND_IS_SHARED(cond), oldvalue, reltime);
pthread_mutex_lock(mutex);
if (status == (-ETIMEDOUT)) return ETIMEDOUT;
@@ -1867,15 +1866,66 @@ int pthread_getcpuclockid(pthread_t tid, clockid_t *clockid)
*/
int pthread_once( pthread_once_t* once_control, void (*init_routine)(void) )
{
static pthread_mutex_t once_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t once_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER;
if (*once_control == PTHREAD_ONCE_INIT) {
_normal_lock( &once_lock );
pthread_mutex_lock( &once_lock );
if (*once_control == PTHREAD_ONCE_INIT) {
(*init_routine)();
*once_control = ~PTHREAD_ONCE_INIT;
}
_normal_unlock( &once_lock );
pthread_mutex_unlock( &once_lock );
}
return 0;
}
/* This value is not exported by kernel headers, so hardcode it here */
#define MAX_TASK_COMM_LEN 16
#define TASK_COMM_FMT "/proc/self/task/%u/comm"
int pthread_setname_np(pthread_t thid, const char *thname)
{
size_t thname_len;
int saved_errno, ret;
if (thid == 0 || thname == NULL)
return EINVAL;
thname_len = strlen(thname);
if (thname_len >= MAX_TASK_COMM_LEN)
return ERANGE;
saved_errno = errno;
if (thid == pthread_self())
{
ret = prctl(PR_SET_NAME, (unsigned long)thname, 0, 0, 0) ? errno : 0;
}
else
{
/* Have to change another thread's name */
pthread_internal_t *thread = (pthread_internal_t *)thid;
char comm_name[sizeof(TASK_COMM_FMT) + 8];
ssize_t n;
int fd;
snprintf(comm_name, sizeof(comm_name), TASK_COMM_FMT, (unsigned int)thread->kernel_id);
fd = open(comm_name, O_RDWR);
if (fd == -1)
{
ret = errno;
goto exit;
}
n = TEMP_FAILURE_RETRY(write(fd, thname, thname_len));
close(fd);
if (n < 0)
ret = errno;
else if ((size_t)n != thname_len)
ret = EIO;
else
ret = 0;
}
exit:
errno = saved_errno;
return ret;
}

View File

@@ -30,6 +30,62 @@
#include <sys/time.h>
#include <sys/atomics.h>
#include <time.h>
#include <bionic_atomic_inline.h>
#include <bionic_futex.h>
#include <limits.h>
/* In this implementation, a semaphore contains a
* 31-bit signed value and a 1-bit 'shared' flag
* (for process-sharing purpose).
*
* We use the value -1 to indicate contention on the
* semaphore, 0 or more to indicate uncontended state,
* any value lower than -2 is invalid at runtime.
*
* State diagram:
*
* post(1) ==> 2
* post(0) ==> 1
* post(-1) ==> 1, then wake all waiters
*
* wait(2) ==> 1
* wait(1) ==> 0
* wait(0) ==> -1 then wait for a wake up + loop
* wait(-1) ==> -1 then wait for a wake up + loop
*
*/
/* Use the upper 31-bits for the counter, and the lower one
* for the shared flag.
*/
#define SEMCOUNT_SHARED_MASK 0x00000001
#define SEMCOUNT_VALUE_MASK 0xfffffffe
#define SEMCOUNT_VALUE_SHIFT 1
/* Maximum unsigned value that can be stored in the semaphore.
* One bit is used for the shared flag, another one for the
* sign bit, leaving us with only 30 bits.
*/
#define SEM_MAX_VALUE 0x3fffffff
/* convert a value into the corresponding sem->count bit pattern */
#define SEMCOUNT_FROM_VALUE(val) (((val) << SEMCOUNT_VALUE_SHIFT) & SEMCOUNT_VALUE_MASK)
/* convert a sem->count bit pattern into the corresponding signed value */
#define SEMCOUNT_TO_VALUE(sval) ((int)(sval) >> SEMCOUNT_VALUE_SHIFT)
/* the value +1 as a sem->count bit-pattern. */
#define SEMCOUNT_ONE SEMCOUNT_FROM_VALUE(1)
/* the value -1 as a sem->count bit-pattern. */
#define SEMCOUNT_MINUS_ONE SEMCOUNT_FROM_VALUE(-1)
#define SEMCOUNT_DECREMENT(sval) (((sval) - (1U << SEMCOUNT_VALUE_SHIFT)) & SEMCOUNT_VALUE_MASK)
#define SEMCOUNT_INCREMENT(sval) (((sval) + (1U << SEMCOUNT_VALUE_SHIFT)) & SEMCOUNT_VALUE_MASK)
/* return the shared bitflag from a semaphore */
#define SEM_GET_SHARED(sem) ((sem)->count & SEMCOUNT_SHARED_MASK)
int sem_init(sem_t *sem, int pshared, unsigned int value)
{
@@ -38,26 +94,34 @@ int sem_init(sem_t *sem, int pshared, unsigned int value)
return -1;
}
if (pshared != 0) {
errno = ENOSYS;
/* ensure that 'value' can be stored in the semaphore */
if (value > SEM_MAX_VALUE) {
errno = EINVAL;
return -1;
}
sem->count = value;
sem->count = SEMCOUNT_FROM_VALUE(value);
if (pshared != 0)
sem->count |= SEMCOUNT_SHARED_MASK;
return 0;
}
int sem_destroy(sem_t *sem)
{
int count;
if (sem == NULL) {
errno = EINVAL;
return -1;
}
if (sem->count == 0) {
count = SEMCOUNT_TO_VALUE(sem->count);
if (count < 0) {
errno = EBUSY;
return -1;
}
sem->count = 0;
return 0;
}
@@ -90,38 +154,120 @@ int sem_unlink(const char * name)
}
/* Decrement a semaphore's value atomically,
* and return the old one. As a special case,
* this returns immediately if the value is
* negative (i.e. -1)
*/
static int
__atomic_dec_if_positive( volatile unsigned int* pvalue )
__sem_dec(volatile unsigned int *pvalue)
{
unsigned int old;
unsigned int shared = (*pvalue & SEMCOUNT_SHARED_MASK);
unsigned int old, new;
int ret;
do {
old = *pvalue;
}
while ( old != 0 && __atomic_cmpxchg( (int)old, (int)old-1, (volatile int*)pvalue ) != 0 );
old = (*pvalue & SEMCOUNT_VALUE_MASK);
ret = SEMCOUNT_TO_VALUE(old);
if (ret < 0)
break;
return old;
new = SEMCOUNT_DECREMENT(old);
}
while (__atomic_cmpxchg((int)(old|shared),
(int)(new|shared),
(volatile int *)pvalue) != 0);
return ret;
}
/* Same as __sem_dec, but will not touch anything if the
* value is already negative *or* 0. Returns the old value.
*/
static int
__sem_trydec(volatile unsigned int *pvalue)
{
unsigned int shared = (*pvalue & SEMCOUNT_SHARED_MASK);
unsigned int old, new;
int ret;
do {
old = (*pvalue & SEMCOUNT_VALUE_MASK);
ret = SEMCOUNT_TO_VALUE(old);
if (ret <= 0)
break;
new = SEMCOUNT_DECREMENT(old);
}
while (__atomic_cmpxchg((int)(old|shared),
(int)(new|shared),
(volatile int *)pvalue) != 0);
return ret;
}
/* "Increment" the value of a semaphore atomically and
* return its old value. Note that this implements
* the special case of "incrementing" any negative
* value to +1 directly.
*
* NOTE: The value will _not_ wrap above SEM_VALUE_MAX
*/
static int
__sem_inc(volatile unsigned int *pvalue)
{
unsigned int shared = (*pvalue & SEMCOUNT_SHARED_MASK);
unsigned int old, new;
int ret;
do {
old = (*pvalue & SEMCOUNT_VALUE_MASK);
ret = SEMCOUNT_TO_VALUE(old);
/* Can't go higher than SEM_MAX_VALUE */
if (ret == SEM_MAX_VALUE)
break;
/* If the counter is negative, go directly to +1,
* otherwise just increment */
if (ret < 0)
new = SEMCOUNT_ONE;
else
new = SEMCOUNT_INCREMENT(old);
}
while ( __atomic_cmpxchg((int)(old|shared),
(int)(new|shared),
(volatile int*)pvalue) != 0);
return ret;
}
/* lock a semaphore */
int sem_wait(sem_t *sem)
{
unsigned shared;
if (sem == NULL) {
errno = EINVAL;
return -1;
}
shared = SEM_GET_SHARED(sem);
for (;;) {
if (__atomic_dec_if_positive(&sem->count))
if (__sem_dec(&sem->count) > 0)
break;
__futex_wait(&sem->count, 0, 0);
__futex_wait_ex(&sem->count, shared, shared|SEMCOUNT_MINUS_ONE, NULL);
}
ANDROID_MEMBAR_FULL();
return 0;
}
int sem_timedwait(sem_t *sem, const struct timespec *abs_timeout)
{
int ret;
unsigned int shared;
if (sem == NULL) {
errno = EINVAL;
@@ -129,11 +275,15 @@ int sem_timedwait(sem_t *sem, const struct timespec *abs_timeout)
}
/* POSIX says we need to try to decrement the semaphore
* before checking the timeout value */
if (__atomic_dec_if_positive(&sem->count))
* before checking the timeout value. Note that if the
* value is currently 0, __sem_trydec() does nothing.
*/
if (__sem_trydec(&sem->count) > 0) {
ANDROID_MEMBAR_FULL();
return 0;
}
/* check it as per Posix */
/* Check it as per Posix */
if (abs_timeout == NULL ||
abs_timeout->tv_sec < 0 ||
abs_timeout->tv_nsec < 0 ||
@@ -143,6 +293,8 @@ int sem_timedwait(sem_t *sem, const struct timespec *abs_timeout)
return -1;
}
shared = SEM_GET_SHARED(sem);
for (;;) {
struct timespec ts;
int ret;
@@ -161,27 +313,47 @@ int sem_timedwait(sem_t *sem, const struct timespec *abs_timeout)
return -1;
}
ret = __futex_wait(&sem->count, 0, &ts);
/* Try to grab the semaphore. If the value was 0, this
* will also change it to -1 */
if (__sem_dec(&sem->count) > 0) {
ANDROID_MEMBAR_FULL();
break;
}
/* Contention detected. wait for a wakeup event */
ret = __futex_wait_ex(&sem->count, shared, shared|SEMCOUNT_MINUS_ONE, &ts);
/* return in case of timeout or interrupt */
if (ret == -ETIMEDOUT || ret == -EINTR) {
errno = -ret;
return -1;
}
if (__atomic_dec_if_positive(&sem->count))
break;
}
return 0;
}
/* Unlock a semaphore */
int sem_post(sem_t *sem)
{
unsigned int shared;
int old;
if (sem == NULL)
return EINVAL;
if (__atomic_inc((volatile int*)&sem->count) >= 0)
__futex_wake(&sem->count, 1);
shared = SEM_GET_SHARED(sem);
ANDROID_MEMBAR_FULL();
old = __sem_inc(&sem->count);
if (old < 0) {
/* contention on the semaphore, wake up all waiters */
__futex_wake_ex(&sem->count, shared, INT_MAX);
}
else if (old == SEM_MAX_VALUE) {
/* overflow detected */
errno = EOVERFLOW;
return -1;
}
return 0;
}
@@ -193,7 +365,8 @@ int sem_trywait(sem_t *sem)
return -1;
}
if (__atomic_dec_if_positive(&sem->count) > 0) {
if (__sem_trydec(&sem->count) > 0) {
ANDROID_MEMBAR_FULL();
return 0;
} else {
errno = EAGAIN;
@@ -201,13 +374,29 @@ int sem_trywait(sem_t *sem)
}
}
/* Note that Posix requires that sem_getvalue() returns, in
* case of contention, the negative of the number of waiting
* threads.
*
* However, code that depends on this negative value to be
* meaningful is most probably racy. The GLibc sem_getvalue()
* only returns the semaphore value, which is 0, in case of
* contention, so we will mimick this behaviour here instead
* for better compatibility.
*/
int sem_getvalue(sem_t *sem, int *sval)
{
int val;
if (sem == NULL || sval == NULL) {
errno = EINVAL;
return -1;
}
*sval = sem->count;
val = SEMCOUNT_TO_VALUE(sem->count);
if (val < 0)
val = 0;
*sval = val;
return 0;
}

View File

@@ -126,7 +126,7 @@ int __system_property_read(const prop_info *pi, char *name, char *value)
for(;;) {
serial = pi->serial;
while(SERIAL_DIRTY(serial)) {
__futex_wait(&pi->serial, serial, 0);
__futex_wait((volatile void *)&pi->serial, serial, 0);
serial = pi->serial;
}
len = SERIAL_VALUE_LEN(serial);
@@ -164,7 +164,7 @@ int __system_property_wait(const prop_info *pi)
} else {
n = pi->serial;
do {
__futex_wait(&pi->serial, n, 0);
__futex_wait((volatile void *)&pi->serial, n, 0);
} while(n == pi->serial);
}
return 0;

View File

@@ -1,7 +1,89 @@
Bionic ChangeLog:
-----------------
Differences between current and Android 2.1:
Differences between current and Android 2.2:
- <pthread.h>: Add reader/writer locks implementation. Add sanity
checking to pthread_mutex_destroy() (e.g. a locked mutex will return
EBUSY).
- <semaphore.h>: Use private futexes for semaphore implementation,
unless your set 'pshared' to non-0 when calling sem_init().
Also fixed a bug in sem_post() to make it wake up all waiting
threads, instead of one. As a consequence, the maximum semaphore
value is now reduced to 0x3fffffff.
- <math.h>: Added sincos(), sincosf() and sincosl() (GLibc compatibility).
- <sys/sysinfo.h>: Added missing sysinfo() system call implementation
(the function was already declared in the header though).
- sysconf() didn't work for some arguments due to a small bug in the
/proc line parser.
- <termio.h>: added missing header (just includes <termios.h>)
- <unistd.h>: add missing declaration for truncate(). The implementation
was already here since Android 1.5.
modify implementation of alarm() to return 0 in case of error (i.e.
if a value larger than 0x7fffffff seconds is passed to it). This
makes the implementation compliant with the GLibc behaviour.
- <wchar.h>: small fixes to really support wchar_t in Bionic (not there yet).
the size of wchar_t is still 32-bit (decided by the compiler)
WCHAR_MIN: changed from 0 to INT_MIN
WCHAR_MAX: changed from 255 to INT_MAX
wcpcpy(), wcpncpy(), wcscat(), wcschr(), wcscmp(),
wcscpy(), wcscspn(), wcsdup(), wcslcat(), wcslcpy(),
wcslen(), wcsncat(), wcsncmp(), wcsncpy(), wcsnlen(),
wcspbrk(), wcsrchr(), wcsrchr(), wcsspn(), wcsstr(),
wcstok(), wcswidth(), wmemchr(), wmemcmp(), wmemcpy(),
wmemmove(), wmemset(): Added proper implementations.
wcscasecmp(), wcsncasecmp(): Added implementation limited
to ASCII codes for lower/upper.
wcscoll(): added dummy implementation that calls wcscmp()
wcsxfrm(): added dummy implementation that calls wcsncpy()
NOTE: Technically, this breaks the ABI, but we never claimed to support
wchar_t anyway. The wchar_t support is still *NOT* official at this
point. We need better multi-byte support code, and wprintf/wscanf
stuff too.
- <inttypes.h>: add missing declarations for strntoimax abd strntoumax.
- <stdlib.h>: add missing declarations for drand48() and erand48().
- clearerr(): fix broken implementation.
- Feature test macros like _POSIX_C_SOURCE / _XOPEN_SOURCE / _C99_SOURCE
are now handled correctly by our C library headers (see <sys/cdefs.h>)
- <sys/select.h>: add missing declaration for pselect()
- <sys/vfs.h>: fixed implementation of fstatfs() (also fixes fpathconf()
which uses it).
- <dlfcn.h>: fixed dlopen() implementation to support dlopen(NULL, ...).
This allows one to look at the dynamic symbols exported by an executable.
- <private/bionic_tls.h>: use kernel helper functions for static versions
of the C library. This is necessary because we don't know where the corresponding
machine code is going to run, and the optimization for __get_tls() might
not match the features of the target device where we run a static executable
linked to the C library. This fixes one of the bug that explains why gdbserver
didn't work well with threads.
-------------------------------------------------------------------------------
Differences between Android 2.2. and Android 2.1:
- Support FP register save/load in setjmp()/longjmp() on ARMv7 builds.
- Add support for SH-4 CPU architecture !

View File

@@ -39,6 +39,10 @@ __BEGIN_DECLS
#define O_ASYNC FASYNC
#endif
#ifndef O_CLOEXEC
#define O_CLOEXEC 02000000
#endif
extern int open(const char* path, int mode, ...);
extern int openat(int fd, const char* path, int mode, ...);
extern int unlinkat(int dirfd, const char *pathname, int flags);

View File

@@ -71,14 +71,19 @@ int getopt_long_only(int, char * const *, const char *,
#ifndef _GETOPT_DEFINED_
#define _GETOPT_DEFINED_
int getopt(int, char * const *, const char *);
int getsubopt(char **, char * const *, char **);
extern char *optarg; /* getopt(3) external variables */
extern int opterr;
extern int optind;
extern int optopt;
extern int optreset;
#if 0 /* MISSING FROM BIONIC */
int getsubopt(char **, char * const *, char **);
extern char *suboptarg; /* getsubopt(3) external variable */
#endif /* MISSING */
#endif
__END_DECLS

View File

@@ -253,6 +253,9 @@ intmax_t imaxabs(intmax_t);
imaxdiv_t imaxdiv(intmax_t, intmax_t);
intmax_t strtoimax(const char *, char **, int);
uintmax_t strtoumax(const char *, char **, int);
intmax_t strntoimax(const char *nptr, char **endptr, int base, size_t n);
uintmax_t strntoumax(const char *nptr, char **endptr, int base, size_t n);
__END_DECLS
#endif /* _INTTYPES_H_ */

View File

@@ -86,7 +86,7 @@
#include <sys/limits.h>
#if __POSIX_VISIBLE
#include <arch/syslimits.h>
#include <sys/syslimits.h>
#endif
#ifndef PAGESIZE

View File

@@ -28,6 +28,10 @@
#ifndef _PATHCONF_H_
#define _PATHCONF_H_
#include <sys/cdefs.h>
__BEGIN_DECLS
/* constants to be used for the 'name' paremeter of pathconf/fpathconf */
#define _PC_FILESIZEBITS 0x0000
@@ -54,5 +58,7 @@
extern long fpathconf(int fildes, int name);
extern long pathconf(const char *path, int name);
__END_DECLS
#endif /* _PATHCONF_H_ */

View File

@@ -219,6 +219,41 @@ int pthread_cond_timeout_np(pthread_cond_t *cond,
*/
int pthread_mutex_lock_timeout_np(pthread_mutex_t *mutex, unsigned msecs);
/* read-write lock support */
typedef int pthread_rwlockattr_t;
typedef struct {
pthread_mutex_t lock;
pthread_cond_t cond;
int numLocks;
int writerThreadId;
int pendingReaders;
int pendingWriters;
void* reserved[4]; /* for future extensibility */
} pthread_rwlock_t;
#define PTHREAD_RWLOCK_INITIALIZER { PTHREAD_MUTEX_INITIALIZER, 0, NULL, 0, 0 }
int pthread_rwlockattr_init(pthread_rwlockattr_t *attr);
int pthread_rwlockattr_destroy(pthread_rwlockattr_t *attr);
int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *attr, int pshared);
int pthread_rwlockattr_getpshared(pthread_rwlockattr_t *attr, int *pshared);
int pthread_rwlock_init(pthread_rwlock_t *rwlock, const pthread_rwlockattr_t *attr);
int pthread_rwlock_destroy(pthread_rwlock_t *rwlock);
int pthread_rwlock_rdlock(pthread_rwlock_t *rwlock);
int pthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock);
int pthread_rwlock_timedrdlock(pthread_rwlock_t *rwlock, const struct timespec *abs_timeout);
int pthread_rwlock_wrlock(pthread_rwlock_t *rwlock);
int pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock);
int pthread_rwlock_timedwrlock(pthread_rwlock_t *rwlock, const struct timespec *abs_timeout);
int pthread_rwlock_unlock(pthread_rwlock_t *rwlock);
int pthread_key_create(pthread_key_t *key, void (*destructor_function)(void *));
int pthread_key_delete (pthread_key_t);
int pthread_setspecific(pthread_key_t key, const void *value);
@@ -231,6 +266,8 @@ int pthread_getcpuclockid(pthread_t tid, clockid_t *clockid);
int pthread_once(pthread_once_t *once_control, void (*init_routine)(void));
int pthread_setname_np(pthread_t thid, const char *thname);
typedef void (*__pthread_cleanup_func_t)(void*);
typedef struct __pthread_cleanup_t {
@@ -272,4 +309,4 @@ extern void __pthread_cleanup_pop(__pthread_cleanup_t* c,
#define LONG_LONG_MAX __LONG_LONG_MAX__
#define LONG_LONG_MIN (-__LONG_LONG_MAX__ - 1)
#endif // _PTHREAD_H_
#endif /* _PTHREAD_H_ */

View File

@@ -69,7 +69,7 @@ extern int sched_rr_get_interval(pid_t pid, struct timespec *tp);
#define CLONE_CHILD_SETTID 0x01000000
#define CLONE_STOPPED 0x02000000
#ifdef __GNU_SOURCE
#ifdef _GNU_SOURCE
extern int clone(int (*fn)(void *), void *child_stack, int flags, void* arg, ...);
#endif

View File

@@ -51,6 +51,7 @@ typedef int sig_atomic_t;
#endif
extern const char * const sys_siglist[];
extern const char * const sys_signame[];
static __inline__ int sigismember(sigset_t *set, int signum)
{
@@ -119,6 +120,7 @@ extern int siginterrupt(int sig, int flag);
extern int raise(int);
extern int kill(pid_t, int);
extern int killpg(int pgrp, int sig);
extern int sigaltstack(const stack_t *ss, stack_t *oss);
__END_DECLS

View File

@@ -300,12 +300,14 @@ __END_DECLS
#define L_cuserid 9 /* size for cuserid(); UT_NAMESIZE + 1 */
__BEGIN_DECLS
#if 0 /* MISSING FROM BIONIC */
char *ctermid(char *);
char *cuserid(char *);
#endif /* MISSING */
FILE *fdopen(int, const char *);
int fileno(FILE *);
#if (__POSIX_VISIBLE >= 199209) || 1 /* ANDROID: Bionic does include this */
#if (__POSIX_VISIBLE >= 199209)
int pclose(FILE *);
FILE *popen(const char *, const char *);
#endif

View File

@@ -50,7 +50,6 @@ __BEGIN_DECLS
extern __noreturn void exit(int);
extern __noreturn void abort(void);
extern int atexit(void (*)(void));
extern int on_exit(void (*)(int, void *), void *);
extern char *getenv(const char *);
extern int putenv(const char *);
@@ -107,6 +106,8 @@ extern long mrand48(void);
extern long nrand48(unsigned short *);
extern long lrand48(void);
extern unsigned short *seed48(unsigned short*);
extern double erand48(unsigned short xsubi[3]);
extern double drand48(void);
extern void srand48(long);
extern unsigned int arc4random(void);
extern void arc4random_stir(void);
@@ -135,7 +136,7 @@ extern char* ptsname(int);
extern int ptsname_r(int, char*, size_t);
extern int getpt(void);
static __inline__ int grantpt(int __fd)
static __inline__ int grantpt(int __fd __attribute((unused)))
{
(void)__fd;
return 0; /* devpts does this all for us! */
@@ -162,6 +163,7 @@ typedef struct {
extern lldiv_t lldiv(long long, long long);
#if 1 /* MISSING FROM BIONIC - ENABLED FOR STLPort and libstdc++-v3 */
/* make STLPort happy */
extern int mblen(const char *, size_t);
extern size_t mbstowcs(wchar_t *, const char *, size_t);
@@ -170,8 +172,14 @@ extern int mbtowc(wchar_t *, const char *, size_t);
/* Likewise, make libstdc++-v3 happy. */
extern int wctomb(char *, wchar_t);
extern size_t wcstombs(char *, const wchar_t *, size_t);
#endif /* MISSING */
#define MB_CUR_MAX 1
#if 0 /* MISSING FROM BIONIC */
extern int on_exit(void (*)(int, void *), void *);
#endif /* MISSING */
__END_DECLS
#endif /* _STDLIB_H_ */

View File

@@ -37,12 +37,6 @@
#ifndef _SYS_CDEFS_H_
#define _SYS_CDEFS_H_
/* our implementation of wchar_t is only 8-bit - die die non-portable code */
#undef __WCHAR_TYPE__
#define __WCHAR_TYPE__ unsigned char
/*
* Macro to test if we're using a GNU C compiler of a specific vintage
* or later, for e.g. features that appeared in a particular version
@@ -62,11 +56,6 @@
#define __GNUC_PREREQ__(x, y) 0
#endif
//XXX #include <machine/cdefs.h>
/* BIONIC: simpler definition */
#define __BSD_VISIBLE 1
#include <sys/cdefs_elf.h>
#if defined(__cplusplus)
@@ -371,6 +360,142 @@
#define __link_set_entry(set, idx) (__link_set_begin(set)[idx])
/*
* Some of the recend FreeBSD sources used in Bionic need this.
* Originally, this is used to embed the rcs versions of each source file
* in the generated binary. We certainly don't want this in Bionic.
*/
#define __FBSDID(s) struct __hack
/*-
* The following definitions are an extension of the behavior originally
* implemented in <sys/_posix.h>, but with a different level of granularity.
* POSIX.1 requires that the macros we test be defined before any standard
* header file is included.
*
* Here's a quick run-down of the versions:
* defined(_POSIX_SOURCE) 1003.1-1988
* _POSIX_C_SOURCE == 1 1003.1-1990
* _POSIX_C_SOURCE == 2 1003.2-1992 C Language Binding Option
* _POSIX_C_SOURCE == 199309 1003.1b-1993
* _POSIX_C_SOURCE == 199506 1003.1c-1995, 1003.1i-1995,
* and the omnibus ISO/IEC 9945-1: 1996
* _POSIX_C_SOURCE == 200112 1003.1-2001
* _POSIX_C_SOURCE == 200809 1003.1-2008
*
* In addition, the X/Open Portability Guide, which is now the Single UNIX
* Specification, defines a feature-test macro which indicates the version of
* that specification, and which subsumes _POSIX_C_SOURCE.
*
* Our macros begin with two underscores to avoid namespace screwage.
*/
/* Deal with IEEE Std. 1003.1-1990, in which _POSIX_C_SOURCE == 1. */
#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 1
#undef _POSIX_C_SOURCE /* Probably illegal, but beyond caring now. */
#define _POSIX_C_SOURCE 199009
#endif
/* Deal with IEEE Std. 1003.2-1992, in which _POSIX_C_SOURCE == 2. */
#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE == 2
#undef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 199209
#endif
/* Deal with various X/Open Portability Guides and Single UNIX Spec. */
#ifdef _XOPEN_SOURCE
#if _XOPEN_SOURCE - 0 >= 700
#define __XSI_VISIBLE 700
#undef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200809
#elif _XOPEN_SOURCE - 0 >= 600
#define __XSI_VISIBLE 600
#undef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200112
#elif _XOPEN_SOURCE - 0 >= 500
#define __XSI_VISIBLE 500
#undef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 199506
#endif
#endif
/*
* Deal with all versions of POSIX. The ordering relative to the tests above is
* important.
*/
#if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE)
#define _POSIX_C_SOURCE 198808
#endif
#ifdef _POSIX_C_SOURCE
#if _POSIX_C_SOURCE >= 200809
#define __POSIX_VISIBLE 200809
#define __ISO_C_VISIBLE 1999
#elif _POSIX_C_SOURCE >= 200112
#define __POSIX_VISIBLE 200112
#define __ISO_C_VISIBLE 1999
#elif _POSIX_C_SOURCE >= 199506
#define __POSIX_VISIBLE 199506
#define __ISO_C_VISIBLE 1990
#elif _POSIX_C_SOURCE >= 199309
#define __POSIX_VISIBLE 199309
#define __ISO_C_VISIBLE 1990
#elif _POSIX_C_SOURCE >= 199209
#define __POSIX_VISIBLE 199209
#define __ISO_C_VISIBLE 1990
#elif _POSIX_C_SOURCE >= 199009
#define __POSIX_VISIBLE 199009
#define __ISO_C_VISIBLE 1990
#else
#define __POSIX_VISIBLE 198808
#define __ISO_C_VISIBLE 0
#endif /* _POSIX_C_SOURCE */
#else
/*-
* Deal with _ANSI_SOURCE:
* If it is defined, and no other compilation environment is explicitly
* requested, then define our internal feature-test macros to zero. This
* makes no difference to the preprocessor (undefined symbols in preprocessing
* expressions are defined to have value zero), but makes it more convenient for
* a test program to print out the values.
*
* If a program mistakenly defines _ANSI_SOURCE and some other macro such as
* _POSIX_C_SOURCE, we will assume that it wants the broader compilation
* environment (and in fact we will never get here).
*/
#if defined(_ANSI_SOURCE) /* Hide almost everything. */
#define __POSIX_VISIBLE 0
#define __XSI_VISIBLE 0
#define __BSD_VISIBLE 0
#define __ISO_C_VISIBLE 1990
#elif defined(_C99_SOURCE) /* Localism to specify strict C99 env. */
#define __POSIX_VISIBLE 0
#define __XSI_VISIBLE 0
#define __BSD_VISIBLE 0
#define __ISO_C_VISIBLE 1999
#else /* Default environment: show everything. */
#define __POSIX_VISIBLE 200809
#define __XSI_VISIBLE 700
#define __BSD_VISIBLE 1
#define __ISO_C_VISIBLE 1999
#endif
#endif
/*
* Default values.
*/
#ifndef __XPG_VISIBLE
# define __XPG_VISIBLE 700
#endif
#ifndef __POSIX_VISIBLE
# define __POSIX_VISIBLE 200809
#endif
#ifndef __ISO_C_VISIBLE
# define __ISO_C_VISIBLE 1999
#endif
#ifndef __BSD_VISIBLE
# define __BSD_VISIBLE 1
#endif
#define __BIONIC__ 1
#endif /* !_SYS_CDEFS_H_ */

View File

@@ -0,0 +1,50 @@
/*
* Copyright (C) 2008 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifndef _SYS_EVENTFD_H
#define _SYS_EVENTFD_H
#include <sys/cdefs.h>
#include <fcntl.h>
__BEGIN_DECLS
#define EFD_CLOEXEC O_CLOEXEC
#define EFD_NONBLOCK O_NONBLOCK
/* type of event counter */
typedef uint64_t eventfd_t;
extern int eventfd(unsigned int initval, int flags);
/* Compatibility with GLibc */
extern int eventfd_read(int fd, eventfd_t *counter);
extern int eventfd_write(int fd, const eventfd_t counter);
__END_DECLS
#endif /* _SYS_EVENTFD_H */

View File

@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#include <sys/types.h>
// ANDROID: needed for flock()
/* ANDROID: needed for flock() */
#include <unistd.h>
#include <fcntl.h>

View File

@@ -33,8 +33,10 @@
__BEGIN_DECLS
#if 0 /* MISSING FROM BIONIC */
extern int setfsuid(uid_t);
extern int setfsgid(gid_t);
#endif /* MISSING */
__END_DECLS

View File

@@ -39,8 +39,8 @@
#ifndef _SYS_IOCTL_COMPAT_H_
#define _SYS_IOCTL_COMPAT_H_
//#include <sys/ttychars.h>
//#include <sys/ttydev.h>
/*#include <sys/ttychars.h>*/
/*#include <sys/ttydev.h>*/
struct tchars {
char t_intrc; /* interrupt */

View File

@@ -72,6 +72,7 @@
#define __NR__newselect (__NR_SYSCALL_BASE + 142)
#define __NR_ftruncate (__NR_SYSCALL_BASE + 93)
#define __NR_fsync (__NR_SYSCALL_BASE + 118)
#define __NR_fdatasync (__NR_SYSCALL_BASE + 148)
#define __NR_fchown32 (__NR_SYSCALL_BASE + 207)
#define __NR_sync (__NR_SYSCALL_BASE + 36)
#define __NR_fcntl64 (__NR_SYSCALL_BASE + 221)
@@ -127,6 +128,7 @@
#define __NR_init_module (__NR_SYSCALL_BASE + 128)
#define __NR_delete_module (__NR_SYSCALL_BASE + 129)
#define __NR_syslog (__NR_SYSCALL_BASE + 103)
#define __NR_sysinfo (__NR_SYSCALL_BASE + 116)
#define __NR_futex (__NR_SYSCALL_BASE + 240)
#define __NR_poll (__NR_SYSCALL_BASE + 168)
@@ -137,6 +139,7 @@
#define __NR_openat (__NR_SYSCALL_BASE + 322)
#define __NR_madvise (__NR_SYSCALL_BASE + 220)
#define __NR_mincore (__NR_SYSCALL_BASE + 219)
#define __NR_pipe2 (__NR_SYSCALL_BASE + 359)
#define __NR_getdents64 (__NR_SYSCALL_BASE + 217)
#define __NR_fstatfs64 (__NR_SYSCALL_BASE + 267)
#define __NR_fstatat64 (__NR_SYSCALL_BASE + 327)
@@ -179,6 +182,7 @@
#define __NR_inotify_init (__NR_SYSCALL_BASE + 316)
#define __NR_inotify_add_watch (__NR_SYSCALL_BASE + 317)
#define __NR_inotify_rm_watch (__NR_SYSCALL_BASE + 318)
#define __NR_eventfd2 (__NR_SYSCALL_BASE + 356)
#define __NR_ARM_set_tls (__NR_SYSCALL_BASE + 983045)
#define __NR_ARM_cacheflush (__NR_SYSCALL_BASE + 983042)
#endif
@@ -193,6 +197,7 @@
#define __NR_openat (__NR_SYSCALL_BASE + 295)
#define __NR_madvise (__NR_SYSCALL_BASE + 219)
#define __NR_mincore (__NR_SYSCALL_BASE + 218)
#define __NR_pipe2 (__NR_SYSCALL_BASE + 331)
#define __NR_getdents64 (__NR_SYSCALL_BASE + 220)
#define __NR_fstatfs64 (__NR_SYSCALL_BASE + 269)
#define __NR_fstatat64 (__NR_SYSCALL_BASE + 300)
@@ -221,6 +226,7 @@
#define __NR_inotify_init (__NR_SYSCALL_BASE + 291)
#define __NR_inotify_add_watch (__NR_SYSCALL_BASE + 292)
#define __NR_inotify_rm_watch (__NR_SYSCALL_BASE + 293)
#define __NR_eventfd2 (__NR_SYSCALL_BASE + 328)
#endif
#if defined(__SH3__) || defined(__SH4__)
@@ -234,6 +240,7 @@
#define __NR_openat (__NR_SYSCALL_BASE + 295)
#define __NR_madvise (__NR_SYSCALL_BASE + 219)
#define __NR_mincore (__NR_SYSCALL_BASE + 218)
#define __NR_pipe2 (__NR_SYSCALL_BASE + 331)
#define __NR_getdents64 (__NR_SYSCALL_BASE + 220)
#define __NR_fstatfs64 (__NR_SYSCALL_BASE + 269)
#define __NR_fstatat64 (__NR_SYSCALL_BASE + 300)
@@ -269,14 +276,15 @@
#define __NR_socketcall (__NR_SYSCALL_BASE + 102)
#define __NR_socketcall (__NR_SYSCALL_BASE + 102)
#define __NR___socketcall (__NR_SYSCALL_BASE + 102)
#define __NR_ioprio_set (__NR_SYSCALL_BASE + 289)
#define __NR_ioprio_get (__NR_SYSCALL_BASE + 290)
#define __NR_ioprio_set (__NR_SYSCALL_BASE + 288)
#define __NR_ioprio_get (__NR_SYSCALL_BASE + 289)
#define __NR_epoll_create (__NR_SYSCALL_BASE + 254)
#define __NR_epoll_ctl (__NR_SYSCALL_BASE + 255)
#define __NR_epoll_wait (__NR_SYSCALL_BASE + 256)
#define __NR_inotify_init (__NR_SYSCALL_BASE + 290)
#define __NR_inotify_add_watch (__NR_SYSCALL_BASE + 291)
#define __NR_inotify_rm_watch (__NR_SYSCALL_BASE + 292)
#define __NR_eventfd2 (__NR_SYSCALL_BASE + 328)
#endif
#endif

View File

@@ -9,7 +9,7 @@ void _exit (int);
void _exit_thread (int);
pid_t __fork (void);
pid_t _waitpid (pid_t, int*, int, struct rusage*);
int waitid (int, pid_t, struct siginfo_t*, int,void*);
int __waitid (int, pid_t, struct siginfo_t*, int,void*);
pid_t __sys_clone (int, void*, int*, void*, int*);
int execve (const char*, char* const*, char* const*);
int __setuid (uid_t);
@@ -79,15 +79,17 @@ int flock (int, int);
int fchmod (int, mode_t);
int dup (int);
int pipe (int *);
int pipe2 (int *, int);
int dup2 (int, int);
int select (int, struct fd_set *, struct fd_set *, struct fd_set *, struct timeval *);
int ftruncate (int, off_t);
int getdents (unsigned int, struct dirent *, unsigned int);
int fsync (int);
int fdatasync (int);
int fchown (int, uid_t, gid_t);
void sync (void);
int __fcntl64 (int, int, void *);
int fstatfs (int, size_t, struct statfs *);
int __fstatfs64 (int, size_t, struct statfs *);
ssize_t sendfile (int out_fd, int in_fd, off_t *offset, size_t count);
int fstatat (int dirfd, const char *path, struct stat *buf, int flags);
int mkdirat (int dirfd, const char *pathname, mode_t mode);
@@ -191,6 +193,7 @@ int __syslog (int, char *, int);
int init_module (void *, unsigned long, const char *);
int delete_module (const char*, unsigned int);
int klogctl (int, char *, int);
int sysinfo (struct sysinfo *);
int futex (void *, int, int, void *, void *, int);
int epoll_create (int size);
int epoll_ctl (int epfd, int op, int fd, struct epoll_event *event);
@@ -199,6 +202,7 @@ int inotify_init (void);
int inotify_add_watch (int, const char *, unsigned int);
int inotify_rm_watch (int, unsigned int);
int poll (struct pollfd *, unsigned int, long);
int eventfd (unsigned int, int);
int __set_tls (void*);
int cacheflush (long start, long end, long flags);
#ifdef __cplusplus

View File

@@ -92,7 +92,10 @@ extern int mount(const char *, const char *,
const void *);
extern int umount(const char *);
extern int umount2(const char *, int);
#if 0 /* MISSING FROM BIONIC */
extern int pivot_root(const char *, const char *);
#endif /* MISSING */
__END_DECLS

View File

@@ -30,7 +30,7 @@
#include <sys/cdefs.h>
#include <sys/types.h>
// For all of the defines
/* For all of the defines */
#include <linux/ptrace.h>
__BEGIN_DECLS

View File

@@ -31,12 +31,15 @@
#include <sys/cdefs.h>
#include <sys/time.h>
#include <sys/types.h>
#include <signal.h>
__BEGIN_DECLS
typedef __kernel_fd_set fd_set;
extern int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
extern int pselect(int n, fd_set *readfds, fd_set *writefds, fd_set *errfds,
const struct timespec *timeout, const sigset_t *sigmask);
__END_DECLS

View File

@@ -62,8 +62,10 @@ typedef __kernel_ino_t ino_t;
typedef __kernel_key_t key_t;
typedef __kernel_mode_t mode_t;
typedef __kernel_nlink_t nlink_t;
#ifndef _OFF_T_DEFINED_
#define _OFF_T_DEFINED_
typedef __kernel_off_t off_t;
#endif
typedef __kernel_loff_t loff_t;
typedef loff_t off64_t; /* GLibc-specific */

View File

@@ -32,6 +32,7 @@
#include <sys/types.h>
#include <sys/resource.h>
#include <linux/wait.h>
#include <signal.h>
__BEGIN_DECLS
@@ -49,6 +50,14 @@ extern pid_t waitpid(pid_t, int *, int);
extern pid_t wait3(int *, int, struct rusage *);
extern pid_t wait4(pid_t, int *, int, struct rusage *);
/* Posix states that idtype_t should be an enumeration type, but
* the kernel headers define P_ALL, P_PID and P_PGID as constant macros
* instead.
*/
typedef int idtype_t;
extern int waitid(idtype_t which, id_t id, siginfo_t *info, int options);
__END_DECLS
#endif /* _SYS_WAIT_H_ */

32
libc/include/termio.h Normal file
View File

@@ -0,0 +1,32 @@
/*
* Copyright (C) 2010 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/* All definitions related to termio are in Linux kernel headers
* that are already included by <termios.h>
*/
#include <termios.h>

View File

@@ -61,16 +61,13 @@ extern pid_t getppid(void);
extern pid_t getpgrp(void);
extern int setpgrp(void);
extern pid_t setsid(void);
extern pid_t getsid(pid_t);
extern int execv(const char *, char * const *);
extern int execvp(const char *, char * const *);
extern int execve(const char *, char * const *, char * const *);
extern int execvpe(const char *, char * const *, char * const *);
extern int execl(const char *, const char *, ...);
extern int execlp(const char *, const char *, ...);
extern int execle(const char *, const char *, ...);
extern int execlpe(const char *, const char *, ...);
extern int capget(cap_user_header_t hdrp, cap_user_data_t datap);
extern int capset(cap_user_header_t hdrp, const cap_user_data_t datap);
extern int prctl(int option, unsigned long arg2, unsigned long arg3,
@@ -94,11 +91,8 @@ extern int setresuid(uid_t, uid_t, uid_t);
extern int setresgid(gid_t, gid_t, gid_t);
extern int getresuid(uid_t *ruid, uid_t *euid, uid_t *suid);
extern int getresgid(gid_t *rgid, gid_t *egid, gid_t *sgid);
extern int getfsuid(uid_t);
extern int setfsuid(uid_t);
extern int issetugid(void);
extern char* getlogin(void);
extern int getlogin_r(char* name, size_t namesize);
extern char* getusershell(void);
extern void setusershell(void);
extern void endusershell(void);
@@ -118,12 +112,16 @@ extern int chdir(const char *);
extern int fchdir(int);
extern int rmdir(const char *);
extern int pipe(int *);
#ifdef _GNU_SOURCE /* GLibc compatibility */
extern int pipe2(int *, int);
#endif
extern int chroot(const char *);
extern int symlink(const char *, const char *);
extern int readlink(const char *, char *, size_t);
extern int chown(const char *, uid_t, gid_t);
extern int fchown(int, uid_t, gid_t);
extern int lchown(const char *, uid_t, gid_t);
extern int truncate(const char *, off_t);
extern char *getcwd(char *, size_t);
extern int sync(void);
@@ -152,9 +150,6 @@ extern unsigned int sleep(unsigned int);
extern int usleep(unsigned long);
extern int gethostname(char *, size_t);
extern int sethostname(const char *, size_t);
extern int getdomainname(char *, size_t);
extern int setdomainname(const char *, size_t);
extern int getdtablesize(void);
@@ -191,6 +186,18 @@ extern int cacheflush(long start, long end, long flags);
extern pid_t tcgetpgrp(int fd);
extern int tcsetpgrp(int fd, pid_t _pid);
#if 0 /* MISSING FROM BIONIC */
extern pid_t getsid(pid_t);
extern int execvpe(const char *, char * const *, char * const *);
extern int execlpe(const char *, const char *, ...);
extern int getfsuid(uid_t);
extern int setfsuid(uid_t);
extern int getlogin_r(char* name, size_t namesize);
extern int sethostname(const char *, size_t);
extern int getdomainname(char *, size_t);
extern int setdomainname(const char *, size_t);
#endif /* MISSING */
/* Used to retry syscalls that can return EINTR. */
#define TEMP_FAILURE_RETRY(exp) ({ \
typeof (exp) _rc; \

View File

@@ -87,4 +87,4 @@ struct utmp* getutent();
__END_DECLS
#endif // _UTMP_H_
#endif /* _UTMP_H_ */

View File

@@ -70,9 +70,9 @@ typedef enum {
WC_TYPE_MAX
} wctype_t;
#define WCHAR_MAX 255
#define WCHAR_MIN 0
#define WEOF (-1)
#define WCHAR_MAX INT_MAX
#define WCHAR_MIN INT_MIN
#define WEOF ((wint_t)(-1))
extern wint_t btowc(int);
extern int fwprintf(FILE *, const wchar_t *, ...);

View File

@@ -0,0 +1,14 @@
/****************************************************************************
****************************************************************************
***
*** This header was automatically generated from a Linux kernel header
*** of the same name, to make information necessary for userspace to
*** call into the kernel available to libc. It contains only constants,
*** structures, and macros generated from the original header, and thus,
*** contains no copyrightable information.
***
****************************************************************************
****************************************************************************/
#ifndef __ASM_ADC_H
#define __ASM_ADC_H
#endif

View File

@@ -0,0 +1,15 @@
/****************************************************************************
****************************************************************************
***
*** This header was automatically generated from a Linux kernel header
*** of the same name, to make information necessary for userspace to
*** call into the kernel available to libc. It contains only constants,
*** structures, and macros generated from the original header, and thus,
*** contains no copyrightable information.
***
****************************************************************************
****************************************************************************/
#ifndef __ASM_SH_ADDRSPACE_H
#define __ASM_SH_ADDRSPACE_H
#endif

View File

@@ -0,0 +1,15 @@
/****************************************************************************
****************************************************************************
***
*** This header was automatically generated from a Linux kernel header
*** of the same name, to make information necessary for userspace to
*** call into the kernel available to libc. It contains only constants,
*** structures, and macros generated from the original header, and thus,
*** contains no copyrightable information.
***
****************************************************************************
****************************************************************************/
#ifndef __ASM_SH_ATOMIC_GRB_H
#define __ASM_SH_ATOMIC_GRB_H
#endif

Some files were not shown because too many files have changed in this diff Show More