libport: Add a memrchr() implementation.
Francois Gouget
fgouget at free.fr
Wed Jun 6 05:03:29 CDT 2012
It is not available on Solaris and FreeBSD 7.0.
---
We don't actually use it on Solaris... yet. But with the recent FreeBSD
/ DragonFly BSD patches we now do use it on FreeBSD 7.0, which
unfortunately did not have it.
configure | 1 +
configure.ac | 1 +
include/wine/port.h | 4 ++++
libs/port/Makefile.in | 1 +
libs/port/memrchr.c | 39 +++++++++++++++++++++++++++++++++++++++
5 files changed, 46 insertions(+)
create mode 100644 libs/port/memrchr.c
diff --git a/configure b/configure
index a6536b2..69fe48f 100755
--- a/configure
+++ b/configure
@@ -12789,6 +12789,7 @@ for ac_func in \
kqueue \
lstat \
memmove \
+ memrchr \
mmap \
pclose \
pipe2 \
diff --git a/configure.ac b/configure.ac
index 46e448e..cfc0950 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1985,6 +1985,7 @@ AC_CHECK_FUNCS(\
kqueue \
lstat \
memmove \
+ memrchr \
mmap \
pclose \
pipe2 \
diff --git a/include/wine/port.h b/include/wine/port.h
index 4b653c7..f31abf8 100644
--- a/include/wine/port.h
+++ b/include/wine/port.h
@@ -273,6 +273,10 @@ int lstat(const char *file_name, struct stat *buf);
void *memmove(void *dest, const void *src, size_t len);
#endif /* !defined(HAVE_MEMMOVE) */
+#ifndef HAVE_MEMRCHR
+void *memrchr( const void *source, int c, size_t n );
+#endif /* !defined(HAVE_MEMRCHR) */
+
#ifndef HAVE_POLL
struct pollfd
{
diff --git a/libs/port/Makefile.in b/libs/port/Makefile.in
index f2f6db0..7a21ff2 100644
--- a/libs/port/Makefile.in
+++ b/libs/port/Makefile.in
@@ -15,6 +15,7 @@ C_SRCS = \
lstat.c \
memcpy_unaligned.c \
memmove.c \
+ memrchr.c \
mkstemps.c \
poll.c \
pread.c \
diff --git a/libs/port/memrchr.c b/libs/port/memrchr.c
new file mode 100644
index 0000000..647c403
--- /dev/null
+++ b/libs/port/memrchr.c
@@ -0,0 +1,39 @@
+/*
+ * memrchr function
+ *
+ * Copyright 2012 Francois Gouget
+ *
+ * This 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.
+ *
+ * This 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 this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include "config.h"
+#include "wine/port.h"
+
+#ifndef HAVE_MEMRCHR
+void *memrchr( const void *source, int c, size_t n )
+{
+ register const char *src = source;
+ register const char *tail = source + n;
+ void *match = NULL;
+
+ while (src < tail)
+ {
+ if (*src == c)
+ match = (void*)src;
+ src++;
+ }
+ return match;
+}
+#endif /* HAVE_MEMRCHR */
--
1.7.10
More information about the wine-patches
mailing list