libc: add optimized linaro bzero routine

Conflicts:
	libc/Android.mk
libc: enable sprintf FORTIFY_SOURCE under clang

clang doesn't support __builtin_va_arg_pack(), so we have
to use #define instead.

Change-Id: I2ee75e6267d60cdf997fee6b9b0547bf68f062a1
Merge "libc: enable sprintf FORTIFY_SOURCE under clang"
bionic: make property area expandable

The property area is initially one 4K region, automatically expanding as
needed up to 64 regions.

To avoid duplicating code, __system_property_area_init() now allocates
and initializes the first region (previously it was allocated in init's
init_property_area() and initialized in bionic).  For testing purposes,
__system_property_set_filename() may be used to override the file used
to map in regions.

Signed-off-by: Greg Hackmann <ghackmann@google.com>

(cherry picked from commit d32969701be070c0161c2643ee3c3df16066bbb8)

Change-Id: I038d451fe8849b0c4863663eec6f57f6521bf4a7
bionic: add missing memory barriers to system properties

1) Reading the value must finish before checking whether it's intact

2) Setting the serial's dirty bit must visible before modifying the
value

3) The modified value must be visible before clearing the serial's dirty
bit

4) New properties and their TOC entries must be visible before updating
the property count

Signed-off-by: Greg Hackmann <ghackmann@google.com>

(cherry picked from commit 5bfa3ee8b37ef162154559575193018a6235acba)

Change-Id: Id3fa45261fc2df2ae493ab5194bc2b6bff04e966
bionic: reimplement property area as hybrid trie/binary tree

See the comments for an explanation of how properties are stored.

The trie structure is designed to scale better than the previous
array-based implementation.  Searching an array with n properties
required average O(n) string compares of the entire key; searching the
trie requires average O(log n) string compares of each token (substrings
between '.' characters).

Signed-off-by: Greg Hackmann <ghackmann@google.com>

(cherry picked from commit 6ac8e6a46d71a51bec16938efa89f275fa89cf7d)

Change-Id: Icbe31908572f33b4d9b85d5b62ac837cbd0f85e0
bionic: revert to a single (larger) property area

d329697 is too complicated.  Change the multiple property pages back to
a single 128K property area that's mapped in entirely at initialization
(the memory will not get allocated until the pages are touched).

d329697 has other changes useful for testing (moving property area
initialization inside bionic and adding __system_property_set_filename)
so undo the change manually rather than with git revert.

Signed-off-by: Greg Hackmann <ghackmann@google.com>

(cherry picked from commit 5f05348c18286a2cea46eae8acf94ed5b7932fac)

Change-Id: I690704552afc07a4dd410277893ca9c40bc13e5f
bionic: prevent root processes from calling __system_property_add

If a root process other than init calls __system_property_add, which
it should never do, it will break the design assumption that there is
only one mutator.

Pass O_EXCL to open() in map_prop_region_rw to ensure that only one
process ever has the property pages open for write.

(cherry picked from commit fb9b7b436f3ef94385f1b0c55ab81f246f0d96b8)

Change-Id: I6df3afedbfb5d07891b095aa24b78278381a5aaf
bionic: store property names as variable-length strings

Names are immutable, so the fixed-sized arrays can be replaced with
variable-length ones to save memory (especially on internal tree nodes).

Signed-off-by: Greg Hackmann <ghackmann@google.com>

(cherry picked from commit 492ce95d9f6149137cb5b63c55cf2b3cdbe51e5e)

Change-Id: Ib074192d1b71150233d78c58e9ffcf7ecf688b6b
Merge changes Ib074192d,I6df3afed,I69070455,Icbe31908,Id3fa4526,I038d451f

* changes:
  bionic: store property names as variable-length strings
  bionic: prevent root processes from calling __system_property_add
  bionic: revert to a single (larger) property area
  bionic: reimplement property area as hybrid trie/binary tree
  bionic: add missing memory barriers to system properties
  bionic: make property area expandable
Merge https://android.googlesource.com/platform/bionic into jb-devel