[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commits] r22287 - in /fsf/trunk/libc: ./ debug/ ports/ ports/sysdeps/aarch64/
- To: commits@xxxxxxxxxx
- Subject: [Commits] r22287 - in /fsf/trunk/libc: ./ debug/ ports/ ports/sysdeps/aarch64/
- From: eglibc@xxxxxxxxxx
- Date: Fri, 25 Jan 2013 00:01:48 -0000
Author: eglibc
Date: Fri Jan 25 00:01:47 2013
New Revision: 22287
Log:
Import glibc-mainline for 2013-01-25
Added:
fsf/trunk/libc/debug/tst-backtrace.h
fsf/trunk/libc/ports/sysdeps/aarch64/strncmp.S
fsf/trunk/libc/ports/sysdeps/aarch64/strnlen.S
Modified:
fsf/trunk/libc/ChangeLog
fsf/trunk/libc/debug/tst-backtrace2.c
fsf/trunk/libc/debug/tst-backtrace3.c
fsf/trunk/libc/debug/tst-backtrace4.c
fsf/trunk/libc/debug/tst-backtrace5.c
fsf/trunk/libc/ports/ChangeLog.aarch64
fsf/trunk/libc/ports/sysdeps/aarch64/sysdep.h
Modified: fsf/trunk/libc/ChangeLog
==============================================================================
--- fsf/trunk/libc/ChangeLog (original)
+++ fsf/trunk/libc/ChangeLog Fri Jan 25 00:01:47 2013
@@ -1,3 +1,31 @@
+2013-01-23 Joseph Myers <joseph@xxxxxxxxxxxxxxxx>
+
+ * debug/tst-backtrace.h: New file.
+ * debug/tst-backtrace2.c: Include tst-backtrace.h.
+ (ret): Remove variable.
+ (x): Likewise.
+ (FAIL): Remove macro.
+ (NO_INLINE): Likewise.
+ (fn1): Use match function instead of strstr.
+ * debug/tst-backtrace3.c: Include tst-backtrace.h.
+ (ret): Remove variable.
+ (x): Likewise.
+ (FAIL): Remove macro.
+ (NO_INLINE): Likewise.
+ (fn): Use match function instead of strstr.
+ * debug/tst-backtrace4.c: Include tst-backtrace.h.
+ (ret): Remove variable.
+ (x): Likewise.
+ (FAIL): Remove macro.
+ (NO_INLINE): Likewise.
+ (handle_signal): Use match function instead of strstr.
+ * debug/tst-backtrace5.c: Include tst-backtrace.h.
+ (ret): Remove variable.
+ (x): Likewise.
+ (FAIL): Remove macro.
+ (NO_INLINE): Likewise.
+ (handle_signal): Use match function instead of strstr.
+
2013-01-23 Roland McGrath <roland@xxxxxxxxxxxxx>
* misc/sys/cdefs.h (__glibc_unlikely, __glibc_likely): Fix whitespace.
Added: fsf/trunk/libc/debug/tst-backtrace.h
==============================================================================
--- fsf/trunk/libc/debug/tst-backtrace.h (added)
+++ fsf/trunk/libc/debug/tst-backtrace.h Fri Jan 25 00:01:47 2013
@@ -1,0 +1,48 @@
+/* Test backtrace and backtrace_symbols: common code for examining
+ backtraces.
+ Copyright (C) 2013 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <stdbool.h>
+#include <stdio.h>
+#include <string.h>
+
+/* Set to a non-zero value if the test fails. */
+volatile int ret;
+
+/* Accesses to X are used to prevent optimization. */
+volatile int x;
+
+/* Called if the test fails. */
+#define FAIL() \
+ do { printf ("Failure on line %d\n", __LINE__); ret = 1; } while (0)
+
+/* Use this attribute to prevent inlining, so that all expected frames
+ are present. */
+#define NO_INLINE __attribute__ ((noinline))
+
+/* Look for a match in SYM from backtrace_symbols to NAME, a fragment
+ of a function name. Ignore the filename before '(', but presume
+ that the function names are chosen so they cannot accidentally
+ match the hex offset before the closing ')'. */
+
+static inline bool
+match (const char *sym, const char *name)
+{
+ char *p = strchr (sym, '(');
+ return p != NULL && strstr (p, name) != NULL;
+}
Modified: fsf/trunk/libc/debug/tst-backtrace2.c
==============================================================================
--- fsf/trunk/libc/debug/tst-backtrace2.c (original)
+++ fsf/trunk/libc/debug/tst-backtrace2.c Fri Jan 25 00:01:47 2013
@@ -22,26 +22,14 @@
#include <stdlib.h>
#include <string.h>
+#include "tst-backtrace.h"
+
static int do_test (void);
#define TEST_FUNCTION do_test ()
#include "../test-skeleton.c"
-/* Set to a non-zero value if the test fails. */
-int ret;
-
-/* Accesses to X are used to prevent optimization. */
-volatile int x;
-
-/* Called if the test fails. */
-#define FAIL() \
- do { printf ("Failure on line %d\n", __LINE__); ret = 1; } while (0)
-
/* The backtrace should include at least f1, f2, f3, and do_test. */
#define NUM_FUNCTIONS 4
-
-/* Use this attribute to prevent inlining, so that all expected frames
- are present. */
-#define NO_INLINE __attribute__ ((noinline))
NO_INLINE void
fn1 (void)
@@ -71,14 +59,14 @@
for (i = 0; i < n; ++i)
printf ("Function %d: %s\n", i, symbols[i]);
/* Check that the function names obtained are accurate. */
- if (strstr (symbols[0], "fn1") == NULL)
+ if (!match (symbols[0], "fn1"))
{
FAIL ();
return;
}
/* Symbol names are not available for static functions, so we do not
check f2. */
- if (strstr (symbols[2], "fn3") == NULL)
+ if (!match (symbols[2], "fn3"))
{
FAIL ();
return;
Modified: fsf/trunk/libc/debug/tst-backtrace3.c
==============================================================================
--- fsf/trunk/libc/debug/tst-backtrace3.c (original)
+++ fsf/trunk/libc/debug/tst-backtrace3.c Fri Jan 25 00:01:47 2013
@@ -22,26 +22,14 @@
#include <stdlib.h>
#include <string.h>
+#include "tst-backtrace.h"
+
static int do_test (void);
#define TEST_FUNCTION do_test ()
#include "../test-skeleton.c"
-/* Set to a non-zero value if the test fails. */
-int ret;
-
-/* Accesses to X are used to prevent optimization. */
-volatile int x;
-
-/* Called if the test fails. */
-#define FAIL() \
- do { printf ("Failure on line %d\n", __LINE__); ret = 1; } while (0)
-
/* The backtrace should include at least 3 * fn, and do_test. */
#define NUM_FUNCTIONS 4
-
-/* Use this attribute to prevent inlining, so that all expected frames
- are present. */
-#define NO_INLINE __attribute__ ((noinline))
NO_INLINE int
fn (int c)
@@ -77,7 +65,7 @@
printf ("Function %d: %s\n", i, symbols[i]);
/* Check that the function names obtained are accurate. */
for (i = 0; i < n - 1; ++i)
- if (strstr (symbols[i], "fn") == NULL)
+ if (!match (symbols[i], "fn"))
{
FAIL ();
return 1;
Modified: fsf/trunk/libc/debug/tst-backtrace4.c
==============================================================================
--- fsf/trunk/libc/debug/tst-backtrace4.c (original)
+++ fsf/trunk/libc/debug/tst-backtrace4.c Fri Jan 25 00:01:47 2013
@@ -25,27 +25,15 @@
#include <signal.h>
#include <unistd.h>
+#include "tst-backtrace.h"
+
static int do_test (void);
#define TEST_FUNCTION do_test ()
#include "../test-skeleton.c"
-/* Set to a non-zero value if the test fails. */
-volatile int ret;
-
-/* Accesses to X are used to prevent optimization. */
-volatile int x;
-
-/* Called if the test fails. */
-#define FAIL() \
- do { printf ("Failure on line %d\n", __LINE__); ret = 1; } while (0)
-
/* The backtrace should include at least handle_signal, a signal
trampoline, 3 * fn, and do_test. */
#define NUM_FUNCTIONS 6
-
-/* Use this attribute to prevent inlining, so that all expected frames
- are present. */
-#define NO_INLINE __attribute__ ((noinline))
volatile int sig_handled = 0;
@@ -79,14 +67,14 @@
for (i = 0; i < n; ++i)
printf ("Function %d: %s\n", i, symbols[i]);
/* Check that the function names obtained are accurate. */
- if (strstr (symbols[0], "handle_signal") == NULL)
+ if (!match (symbols[0], "handle_signal"))
{
FAIL ();
return;
}
/* Do not check name for signal trampoline. */
for (i = 2; i < n - 1; i++)
- if (strstr (symbols[i], "fn") == NULL)
+ if (!match (symbols[i], "fn"))
{
FAIL ();
return;
Modified: fsf/trunk/libc/debug/tst-backtrace5.c
==============================================================================
--- fsf/trunk/libc/debug/tst-backtrace5.c (original)
+++ fsf/trunk/libc/debug/tst-backtrace5.c Fri Jan 25 00:01:47 2013
@@ -26,27 +26,15 @@
#include <signal.h>
#include <unistd.h>
+#include "tst-backtrace.h"
+
static int do_test (void);
#define TEST_FUNCTION do_test ()
#include "../test-skeleton.c"
-/* Set to a non-zero value if the test fails. */
-volatile int ret;
-
-/* Accesses to X are used to prevent optimization. */
-volatile int x;
-
-/* Called if the test fails. */
-#define FAIL() \
- do { printf ("Failure on line %d\n", __LINE__); ret = 1; } while (0)
-
/* The backtrace should include at least handle_signal, a signal
trampoline, read, 3 * fn, and do_test. */
#define NUM_FUNCTIONS 7
-
-/* Use this attribute to prevent inlining, so that all expected frames
- are present. */
-#define NO_INLINE __attribute__ ((noinline))
void
handle_signal (int signum)
@@ -76,24 +64,24 @@
for (i = 0; i < n; ++i)
printf ("Function %d: %s\n", i, symbols[i]);
/* Check that the function names obtained are accurate. */
- if (strstr (symbols[0], "handle_signal") == NULL)
+ if (!match (symbols[0], "handle_signal"))
{
FAIL ();
return;
}
/* Do not check name for signal trampoline. */
i = 2;
- if (strstr (symbols[i++], "read") == NULL)
+ if (!match (symbols[i++], "read"))
{
/* Perhaps symbols[2] is __kernel_vsyscall? */
- if (strstr (symbols[i++], "read") == NULL)
+ if (!match (symbols[i++], "read"))
{
FAIL ();
return;
}
}
for (; i < n - 1; i++)
- if (strstr (symbols[i], "fn") == NULL)
+ if (!match (symbols[i], "fn"))
{
FAIL ();
return;
Modified: fsf/trunk/libc/ports/ChangeLog.aarch64
==============================================================================
--- fsf/trunk/libc/ports/ChangeLog.aarch64 (original)
+++ fsf/trunk/libc/ports/ChangeLog.aarch64 Fri Jan 25 00:01:47 2013
@@ -1,3 +1,12 @@
+2013-01-23 Marcus Shawcroft <marcus.shawcroft@xxxxxxxxxx>
+
+ * sysdeps/aarch64/strncmp.S: New file.
+
+2013-01-23 Marcus Shawcroft <marcus.shawcroft@xxxxxxxxxx>
+
+ * sysdeps/aarch64/sysdep.h (ENTRY_ALIGN_AND_PAD): New.
+ * sysdeps/aarch64/strnlen.S: New file.
+
2013-01-17 Marcus Shawcroft <marcus.shawcroft@xxxxxxxxxx>
* sysdeps/aarch64/strlen.S: New file.
Added: fsf/trunk/libc/ports/sysdeps/aarch64/strncmp.S
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/aarch64/strncmp.S (added)
+++ fsf/trunk/libc/ports/sysdeps/aarch64/strncmp.S Fri Jan 25 00:01:47 2013
@@ -1,0 +1,204 @@
+/* Copyright (C) 2013 Free Software Foundation, Inc.
+
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+
+/* Assumptions:
+ *
+ * ARMv8-a, AArch64
+ */
+
+#define REP8_01 0x0101010101010101
+#define REP8_7f 0x7f7f7f7f7f7f7f7f
+#define REP8_80 0x8080808080808080
+
+/* Parameters and result. */
+#define src1 x0
+#define src2 x1
+#define limit x2
+#define result x0
+
+/* Internal variables. */
+#define data1 x3
+#define data1w w3
+#define data2 x4
+#define data2w w4
+#define has_nul x5
+#define diff x6
+#define syndrome x7
+#define tmp1 x8
+#define tmp2 x9
+#define tmp3 x10
+#define zeroones x11
+#define pos x12
+#define limit_wd x13
+#define mask x14
+#define endloop x15
+
+ENTRY_ALIGN_AND_PAD (strncmp, 6, 7)
+ cbz limit, L(ret0)
+ eor tmp1, src1, src2
+ mov zeroones, #REP8_01
+ tst tmp1, #7
+ b.ne L(misaligned8)
+ ands tmp1, src1, #7
+ b.ne L(mutual_align)
+ /* Calculate the number of full and partial words -1. */
+ sub limit_wd, limit, #1 /* limit != 0, so no underflow. */
+ lsr limit_wd, limit_wd, #3 /* Convert to Dwords. */
+
+ /* NUL detection works on the principle that (X - 1) & (~X) & 0x80
+ (=> (X - 1) & ~(X | 0x7f)) is non-zero iff a byte is zero, and
+ can be done in parallel across the entire word. */
+ /* Start of performance-critical section -- one 64B cache line. */
+L(loop_aligned):
+ ldr data1, [src1], #8
+ ldr data2, [src2], #8
+L(start_realigned):
+ subs limit_wd, limit_wd, #1
+ sub tmp1, data1, zeroones
+ orr tmp2, data1, #REP8_7f
+ eor diff, data1, data2 /* Non-zero if differences found. */
+ csinv endloop, diff, xzr, pl /* Last Dword or differences. */
+ bics has_nul, tmp1, tmp2 /* Non-zero if NUL terminator. */
+ ccmp endloop, #0, #0, eq
+ b.eq L(loop_aligned)
+ /* End of performance-critical section -- one 64B cache line. */
+
+ /* Not reached the limit, must have found the end or a diff. */
+ tbz limit_wd, #63, L(not_limit)
+
+ /* Limit % 8 == 0 => all bytes significant. */
+ ands limit, limit, #7
+ b.eq L(not_limit)
+
+ lsl limit, limit, #3 /* Bits -> bytes. */
+ mov mask, #~0
+#ifdef __AARCH64EB__
+ lsr mask, mask, limit
+#else
+ lsl mask, mask, limit
+#endif
+ bic data1, data1, mask
+ bic data2, data2, mask
+
+ /* Make sure that the NUL byte is marked in the syndrome. */
+ orr has_nul, has_nul, mask
+
+L(not_limit):
+ orr syndrome, diff, has_nul
+
+#ifndef __AARCH64EB__
+ rev syndrome, syndrome
+ rev data1, data1
+ /* The MS-non-zero bit of the syndrome marks either the first bit
+ that is different, or the top bit of the first zero byte.
+ Shifting left now will bring the critical information into the
+ top bits. */
+ clz pos, syndrome
+ rev data2, data2
+ lsl data1, data1, pos
+ lsl data2, data2, pos
+ /* But we need to zero-extend (char is unsigned) the value and then
+ perform a signed 32-bit subtraction. */
+ lsr data1, data1, #56
+ sub result, data1, data2, lsr #56
+ RET
+#else
+ /* For big-endian we cannot use the trick with the syndrome value
+ as carry-propagation can corrupt the upper bits if the trailing
+ bytes in the string contain 0x01. */
+ /* However, if there is no NUL byte in the dword, we can generate
+ the result directly. We can't just subtract the bytes as the
+ MSB might be significant. */
+ cbnz has_nul, 1f
+ cmp data1, data2
+ cset result, ne
+ cneg result, result, lo
+ RET
+1:
+ /* Re-compute the NUL-byte detection, using a byte-reversed value. */
+ rev tmp3, data1
+ sub tmp1, tmp3, zeroones
+ orr tmp2, tmp3, #REP8_7f
+ bic has_nul, tmp1, tmp2
+ rev has_nul, has_nul
+ orr syndrome, diff, has_nul
+ clz pos, syndrome
+ /* The MS-non-zero bit of the syndrome marks either the first bit
+ that is different, or the top bit of the first zero byte.
+ Shifting left now will bring the critical information into the
+ top bits. */
+ lsl data1, data1, pos
+ lsl data2, data2, pos
+ /* But we need to zero-extend (char is unsigned) the value and then
+ perform a signed 32-bit subtraction. */
+ lsr data1, data1, #56
+ sub result, data1, data2, lsr #56
+ RET
+#endif
+
+L(mutual_align):
+ /* Sources are mutually aligned, but are not currently at an
+ alignment boundary. Round down the addresses and then mask off
+ the bytes that precede the start point.
+ We also need to adjust the limit calculations, but without
+ overflowing if the limit is near ULONG_MAX. */
+ bic src1, src1, #7
+ bic src2, src2, #7
+ ldr data1, [src1], #8
+ neg tmp3, tmp1, lsl #3 /* 64 - bits(bytes beyond align). */
+ ldr data2, [src2], #8
+ mov tmp2, #~0
+ sub limit_wd, limit, #1 /* limit != 0, so no underflow. */
+#ifdef __AARCH64EB__
+ /* Big-endian. Early bytes are at MSB. */
+ lsl tmp2, tmp2, tmp3 /* Shift (tmp1 & 63). */
+#else
+ /* Little-endian. Early bytes are at LSB. */
+ lsr tmp2, tmp2, tmp3 /* Shift (tmp1 & 63). */
+#endif
+ and tmp3, limit_wd, #7
+ lsr limit_wd, limit_wd, #3
+ /* Adjust the limit. Only low 3 bits used, so overflow irrelevant. */
+ add limit, limit, tmp1
+ add tmp3, tmp3, tmp1
+ orr data1, data1, tmp2
+ orr data2, data2, tmp2
+ add limit_wd, limit_wd, tmp3, lsr #3
+ b L(start_realigned)
+
+L(ret0):
+ mov result, #0
+ RET
+
+ .p2align 6
+L(misaligned8):
+ sub limit, limit, #1
+1:
+ /* Perhaps we can do better than this. */
+ ldrb data1w, [src1], #1
+ ldrb data2w, [src2], #1
+ subs limit, limit, #1
+ ccmp data1w, #1, #0, cs /* NZCV = 0b0000. */
+ ccmp data1w, data2w, #0, cs /* NZCV = 0b0000. */
+ b.eq 1b
+ sub result, data1, data2
+ RET
+END (strncmp)
+libc_hidden_builtin_def (strncmp)
Added: fsf/trunk/libc/ports/sysdeps/aarch64/strnlen.S
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/aarch64/strnlen.S (added)
+++ fsf/trunk/libc/ports/sysdeps/aarch64/strnlen.S Fri Jan 25 00:01:47 2013
@@ -1,0 +1,161 @@
+/* strnlen - calculate the length of a string with limit.
+
+ Copyright (C) 2013 Free Software Foundation, Inc.
+
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library. If not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+
+/* Assumptions:
+ *
+ * ARMv8-a, AArch64
+ */
+
+/* Arguments and results. */
+#define srcin x0
+#define len x0
+#define limit x1
+
+/* Locals and temporaries. */
+#define src x2
+#define data1 x3
+#define data2 x4
+#define data2a x5
+#define has_nul1 x6
+#define has_nul2 x7
+#define tmp1 x8
+#define tmp2 x9
+#define tmp3 x10
+#define tmp4 x11
+#define zeroones x12
+#define pos x13
+#define limit_wd x14
+
+#define REP8_01 0x0101010101010101
+#define REP8_7f 0x7f7f7f7f7f7f7f7f
+#define REP8_80 0x8080808080808080
+
+ENTRY_ALIGN_AND_PAD (__strnlen, 6, 9)
+ cbz limit, L(hit_limit)
+ mov zeroones, #REP8_01
+ bic src, srcin, #15
+ ands tmp1, srcin, #15
+ b.ne L(misaligned)
+ /* Calculate the number of full and partial words -1. */
+ sub limit_wd, limit, #1 /* Limit != 0, so no underflow. */
+ lsr limit_wd, limit_wd, #4 /* Convert to Qwords. */
+
+ /* NUL detection works on the principle that (X - 1) & (~X) & 0x80
+ (=> (X - 1) & ~(X | 0x7f)) is non-zero iff a byte is zero, and
+ can be done in parallel across the entire word. */
+ /* The inner loop deals with two Dwords at a time. This has a
+ slightly higher start-up cost, but we should win quite quickly,
+ especially on cores with a high number of issue slots per
+ cycle, as we get much better parallelism out of the operations. */
+
+ /* Start of critial section -- keep to one 64Byte cache line. */
+L(loop):
+ ldp data1, data2, [src], #16
+L(realigned):
+ sub tmp1, data1, zeroones
+ orr tmp2, data1, #REP8_7f
+ sub tmp3, data2, zeroones
+ orr tmp4, data2, #REP8_7f
+ bic has_nul1, tmp1, tmp2
+ bic has_nul2, tmp3, tmp4
+ subs limit_wd, limit_wd, #1
+ orr tmp1, has_nul1, has_nul2
+ ccmp tmp1, #0, #0, pl /* NZCV = 0000 */
+ b.eq L(loop)
+ /* End of critical section -- keep to one 64Byte cache line. */
+
+ orr tmp1, has_nul1, has_nul2
+ cbz tmp1, L(hit_limit) /* No null in final Qword. */
+
+ /* We know there's a null in the final Qword. The easiest thing
+ to do now is work out the length of the string and return
+ MIN (len, limit). */
+
+ sub len, src, srcin
+ cbz has_nul1, L(nul_in_data2)
+#ifdef __AARCH64EB__
+ mov data2, data1
+#endif
+ sub len, len, #8
+ mov has_nul2, has_nul1
+L(nul_in_data2):
+#ifdef __AARCH64EB__
+ /* For big-endian, carry propagation (if the final byte in the
+ string is 0x01) means we cannot use has_nul directly. The
+ easiest way to get the correct byte is to byte-swap the data
+ and calculate the syndrome a second time. */
+ rev data2, data2
+ sub tmp1, data2, zeroones
+ orr tmp2, data2, #REP8_7f
+ bic has_nul2, tmp1, tmp2
+#endif
+ sub len, len, #8
+ rev has_nul2, has_nul2
+ clz pos, has_nul2
+ add len, len, pos, lsr #3 /* Bits to bytes. */
+ cmp len, limit
+ csel len, len, limit, ls /* Return the lower value. */
+ RET
+
+L(misaligned):
+ /* Deal with a partial first word.
+ We're doing two things in parallel here;
+ 1) Calculate the number of words (but avoiding overflow if
+ limit is near ULONG_MAX) - to do this we need to work out
+ limit + tmp1 - 1 as a 65-bit value before shifting it;
+ 2) Load and mask the initial data words - we force the bytes
+ before the ones we are interested in to 0xff - this ensures
+ early bytes will not hit any zero detection. */
+ sub limit_wd, limit, #1
+ neg tmp4, tmp1
+ cmp tmp1, #8
+
+ and tmp3, limit_wd, #15
+ lsr limit_wd, limit_wd, #4
+ mov tmp2, #~0
+
+ ldp data1, data2, [src], #16
+ lsl tmp4, tmp4, #3 /* Bytes beyond alignment -> bits. */
+ add tmp3, tmp3, tmp1
+
+#ifdef __AARCH64EB__
+ /* Big-endian. Early bytes are at MSB. */
+ lsl tmp2, tmp2, tmp4 /* Shift (tmp1 & 63). */
+#else
+ /* Little-endian. Early bytes are at LSB. */
+ lsr tmp2, tmp2, tmp4 /* Shift (tmp1 & 63). */
+#endif
+ add limit_wd, limit_wd, tmp3, lsr #4
+
+ orr data1, data1, tmp2
+ orr data2a, data2, tmp2
+
+ csinv data1, data1, xzr, le
+ csel data2, data2, data2a, le
+ b L(realigned)
+
+L(hit_limit):
+ mov len, limit
+ RET
+END (__strnlen)
+weak_alias (__strnlen, strnlen)
+libc_hidden_def (strnlen)
Modified: fsf/trunk/libc/ports/sysdeps/aarch64/sysdep.h
==============================================================================
--- fsf/trunk/libc/ports/sysdeps/aarch64/sysdep.h (original)
+++ fsf/trunk/libc/ports/sysdeps/aarch64/sysdep.h Fri Jan 25 00:01:47 2013
@@ -42,6 +42,22 @@
cfi_startproc; \
CALL_MCOUNT
+/* Define an entry point visible from C with a specified alignment and
+ pre-padding with NOPs. This can be used to ensure that a critical
+ loop within a function is cache line aligned. Note this version
+ does not adjust the padding if CALL_MCOUNT is defined. */
+
+#define ENTRY_ALIGN_AND_PAD(name, align, padding) \
+ .globl C_SYMBOL_NAME(name); \
+ .type C_SYMBOL_NAME(name),%function; \
+ .p2align align; \
+ .rep padding; \
+ nop; \
+ .endr; \
+ C_LABEL(name) \
+ cfi_startproc; \
+ CALL_MCOUNT
+
#undef END
#define END(name) \
cfi_endproc; \
_______________________________________________
Commits mailing list
Commits@xxxxxxxxxx
http://eglibc.org/cgi-bin/mailman/listinfo/commits