summaryrefslogtreecommitdiffstats
path: root/binutils-2.23/libiberty/memchr.c
diff options
context:
space:
mode:
authorBen Cheng <bccheng@google.com>2013-04-09 11:29:01 -0700
committerBen Cheng <bccheng@google.com>2013-04-09 11:29:01 -0700
commitf226517827d64cc8f9dccb0952731601ac13ef2a (patch)
tree84b1056255b318a87b7a47b2684655660cab66f0 /binutils-2.23/libiberty/memchr.c
parent30fe22e2cc89991b16ab3853f95c7319574456ce (diff)
downloadtoolchain_binutils-f226517827d64cc8f9dccb0952731601ac13ef2a.tar.gz
toolchain_binutils-f226517827d64cc8f9dccb0952731601ac13ef2a.tar.bz2
toolchain_binutils-f226517827d64cc8f9dccb0952731601ac13ef2a.zip
Initial checkin for binutils 2.23.2 (needed by aarch64)
Change-Id: I7e5f319e9e632cc0ccc8a4ec1051169ed2849ca4
Diffstat (limited to 'binutils-2.23/libiberty/memchr.c')
-rw-r--r--binutils-2.23/libiberty/memchr.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/binutils-2.23/libiberty/memchr.c b/binutils-2.23/libiberty/memchr.c
new file mode 100644
index 00000000..7448ab9e
--- /dev/null
+++ b/binutils-2.23/libiberty/memchr.c
@@ -0,0 +1,33 @@
+/*
+
+@deftypefn Supplemental void* memchr (const void *@var{s}, int @var{c}, @
+ size_t @var{n})
+
+This function searches memory starting at @code{*@var{s}} for the
+character @var{c}. The search only ends with the first occurrence of
+@var{c}, or after @var{length} characters; in particular, a null
+character does not terminate the search. If the character @var{c} is
+found within @var{length} characters of @code{*@var{s}}, a pointer
+to the character is returned. If @var{c} is not found, then @code{NULL} is
+returned.
+
+@end deftypefn
+
+*/
+
+#include <ansidecl.h>
+#include <stddef.h>
+
+PTR
+memchr (register const PTR src_void, int c, size_t length)
+{
+ const unsigned char *src = (const unsigned char *)src_void;
+
+ while (length-- > 0)
+ {
+ if (*src == c)
+ return (PTR)src;
+ src++;
+ }
+ return NULL;
+}