2002-08-27 Egor Duda <deo@logos-m.ru>

* libc/stdlib/wmemchr.c: New file.
        * libc/stdlib/wmemcmp.c: Ditto.
        * libc/stdlib/wmemcpy.c: Ditto.
        * libc/stdlib/wmemmove.c: Ditto.
        * libc/stdlib/wmemset.c: Ditto.
        * libc/stdlib/Makefile.am (GENERAL_SOURCES): Add new files.
        * configure.host: Default -DMB_CAPABLE for cygwin.
        * libc/include/wchar.h: Declare wmemchr(), wmemcmp(), wmemcpy(),
        wmemmove() and wmemset().  Add include of <_ansi.h>.
        * libc/stdlib/Makefile.in: Regenerate.
This commit is contained in:
Jeff Johnston 2002-08-27 21:20:10 +00:00
parent ff2bf8523b
commit 7d08241b68
10 changed files with 269 additions and 13 deletions

View File

@ -1,3 +1,16 @@
2002-08-27 Egor Duda <deo@logos-m.ru>
* libc/stdlib/wmemchr.c: New file.
* libc/stdlib/wmemcmp.c: Ditto.
* libc/stdlib/wmemcpy.c: Ditto.
* libc/stdlib/wmemmove.c: Ditto.
* libc/stdlib/wmemset.c: Ditto.
* libc/stdlib/Makefile.am (GENERAL_SOURCES): Add new files.
* configure.host: Default -DMB_CAPABLE for cygwin.
* libc/include/wchar.h: Declare wmemchr(), wmemcmp(), wmemcpy(),
wmemmove() and wmemset(). Add include of <_ansi.h>.
* libc/stdlib/Makefile.in: Regenerate.
2002-08-27 Jeff Johnston <jjohnstn@redhat.com>
* configure.host: Remove _ELIX_LEVEL flag setting.

View File

@ -413,7 +413,7 @@ esac
case "${host}" in
*-*-cygwin*)
newlib_cflags="${newlib_cflags} -DHAVE_OPENDIR -DHAVE_RENAME -DSIGNAL_PROVIDED -DWANT_IO_LONG_DBL -DWANT_PRINTF_LONG_LONG -D_COMPILING_NEWLIB -DHAVE_FCNTL -DMALLOC_PROVIDED"
newlib_cflags="${newlib_cflags} -DHAVE_OPENDIR -DHAVE_RENAME -DSIGNAL_PROVIDED -DWANT_IO_LONG_DBL -DWANT_PRINTF_LONG_LONG -D_COMPILING_NEWLIB -DHAVE_FCNTL -DMALLOC_PROVIDED -DMB_CAPABLE"
syscall_dir=syscalls
;;
# RTEMS supplies its own versions of some routines:

View File

@ -1,6 +1,8 @@
#ifndef _WCHAR_H_
#define _WCHAR_H_
#include <_ansi.h>
#define __need_size_t
#define __need_wchar_t
#define __need_wint_t
@ -26,5 +28,10 @@ size_t mbrtowc(wchar_t *pwc, const char *s, size_t n, mbstate_t *ps);
size_t wcrtomb(char *s, wchar_t wc, mbstate_t *ps);
size_t mbsrtowcs(wchar_t *dst, const char **src, size_t len, mbstate_t *ps);
size_t wcsrtombs(char *dst, const wchar_t **src, size_t len, mbstate_t *ps);
wchar_t *wmemchr(const wchar_t *ws, wchar_t wc, size_t n);
int wmemcmp(const wchar_t *ws1, const wchar_t *ws2, size_t n);
wchar_t *wmemcpy(wchar_t *ws1, const wchar_t *ws2, size_t n);
wchar_t *wmemmove(wchar_t *ws1, const wchar_t *ws2, size_t n);
wchar_t *wmemset(wchar_t *ws, wchar_t wc, size_t n);
#endif /* _WCHAR_H_ */

View File

@ -49,7 +49,12 @@ GENERAL_SOURCES = \
wcstombs.c \
wcstombs_r.c \
wctomb.c \
wctomb_r.c
wctomb_r.c \
wmemchr.c \
wmemcmp.c \
wmemcpy.c \
wmemmove.c \
wmemset.c
EXTENDED_SOURCES = \
drand48.c \

View File

@ -155,7 +155,12 @@ GENERAL_SOURCES = \
wcstombs.c \
wcstombs_r.c \
wctomb.c \
wctomb_r.c
wctomb_r.c \
wmemchr.c \
wmemcmp.c \
wmemcpy.c \
wmemmove.c \
wmemset.c
EXTENDED_SOURCES = \
@ -307,12 +312,15 @@ LIBS = @LIBS@
@USE_LIBTOOL_FALSE@realloc.$(OBJEXT) strtod.$(OBJEXT) strtol.$(OBJEXT) \
@USE_LIBTOOL_FALSE@strtoul.$(OBJEXT) wcstombs.$(OBJEXT) \
@USE_LIBTOOL_FALSE@wcstombs_r.$(OBJEXT) wctomb.$(OBJEXT) \
@USE_LIBTOOL_FALSE@wctomb_r.$(OBJEXT) drand48.$(OBJEXT) \
@USE_LIBTOOL_FALSE@ecvtbuf.$(OBJEXT) efgcvt.$(OBJEXT) erand48.$(OBJEXT) \
@USE_LIBTOOL_FALSE@jrand48.$(OBJEXT) lcong48.$(OBJEXT) \
@USE_LIBTOOL_FALSE@lrand48.$(OBJEXT) mrand48.$(OBJEXT) msize.$(OBJEXT) \
@USE_LIBTOOL_FALSE@mtrim.$(OBJEXT) nrand48.$(OBJEXT) rand48.$(OBJEXT) \
@USE_LIBTOOL_FALSE@seed48.$(OBJEXT) srand48.$(OBJEXT) strtoll.$(OBJEXT) \
@USE_LIBTOOL_FALSE@wctomb_r.$(OBJEXT) wmemchr.$(OBJEXT) \
@USE_LIBTOOL_FALSE@wmemcmp.$(OBJEXT) wmemcpy.$(OBJEXT) \
@USE_LIBTOOL_FALSE@wmemmove.$(OBJEXT) wmemset.$(OBJEXT) \
@USE_LIBTOOL_FALSE@drand48.$(OBJEXT) ecvtbuf.$(OBJEXT) efgcvt.$(OBJEXT) \
@USE_LIBTOOL_FALSE@erand48.$(OBJEXT) jrand48.$(OBJEXT) \
@USE_LIBTOOL_FALSE@lcong48.$(OBJEXT) lrand48.$(OBJEXT) \
@USE_LIBTOOL_FALSE@mrand48.$(OBJEXT) msize.$(OBJEXT) mtrim.$(OBJEXT) \
@USE_LIBTOOL_FALSE@nrand48.$(OBJEXT) rand48.$(OBJEXT) seed48.$(OBJEXT) \
@USE_LIBTOOL_FALSE@srand48.$(OBJEXT) strtoll.$(OBJEXT) \
@USE_LIBTOOL_FALSE@strtoll_r.$(OBJEXT) strtoull.$(OBJEXT) \
@USE_LIBTOOL_FALSE@strtoull_r.$(OBJEXT)
LTLIBRARIES = $(noinst_LTLIBRARIES)
@ -326,10 +334,11 @@ LTLIBRARIES = $(noinst_LTLIBRARIES)
@USE_LIBTOOL_TRUE@mbstowcs.lo mbstowcs_r.lo mbtowc.lo mbtowc_r.lo \
@USE_LIBTOOL_TRUE@mlock.lo mprec.lo mstats.lo rand.lo rand_r.lo \
@USE_LIBTOOL_TRUE@realloc.lo strtod.lo strtol.lo strtoul.lo wcstombs.lo \
@USE_LIBTOOL_TRUE@wcstombs_r.lo wctomb.lo wctomb_r.lo drand48.lo \
@USE_LIBTOOL_TRUE@ecvtbuf.lo efgcvt.lo erand48.lo jrand48.lo lcong48.lo \
@USE_LIBTOOL_TRUE@lrand48.lo mrand48.lo msize.lo mtrim.lo nrand48.lo \
@USE_LIBTOOL_TRUE@rand48.lo seed48.lo srand48.lo strtoll.lo \
@USE_LIBTOOL_TRUE@wcstombs_r.lo wctomb.lo wctomb_r.lo wmemchr.lo \
@USE_LIBTOOL_TRUE@wmemcmp.lo wmemcpy.lo wmemmove.lo wmemset.lo \
@USE_LIBTOOL_TRUE@drand48.lo ecvtbuf.lo efgcvt.lo erand48.lo jrand48.lo \
@USE_LIBTOOL_TRUE@lcong48.lo lrand48.lo mrand48.lo msize.lo mtrim.lo \
@USE_LIBTOOL_TRUE@nrand48.lo rand48.lo seed48.lo srand48.lo strtoll.lo \
@USE_LIBTOOL_TRUE@strtoll_r.lo strtoull.lo strtoull_r.lo
CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)

View File

@ -0,0 +1,48 @@
/*-
* Copyright (c)1999 Citrus 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:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. 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 AUTHOR 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 AUTHOR 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.
*
* citrus Id: wmemchr.c,v 1.2 2000/12/20 14:08:31 itojun Exp
*/
#include <stdlib.h>
#include <wchar.h>
wchar_t *
_DEFUN (wmemchr, (s, c, n),
const wchar_t *s _AND
wchar_t c _AND
size_t n)
{
size_t i;
for (i = 0; i < n; i++) {
if (*s == c) {
/* LINTED const castaway */
return (wchar_t *)s;
}
s++;
}
return NULL;
}

View File

@ -0,0 +1,48 @@
/*-
* Copyright (c)1999 Citrus 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:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. 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 AUTHOR 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 AUTHOR 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.
*
* citrus Id: wmemcmp.c,v 1.2 2000/12/20 14:08:31 itojun Exp
*/
#include <wchar.h>
int
_DEFUN (wmemcmp, (s1, s2, n),
const wchar_t *s1 _AND
const wchar_t *s2 _AND
size_t n)
{
size_t i;
for (i = 0; i < n; i++) {
if (*s1 != *s2) {
/* wchar might be unsigned */
return *s1 > *s2 ? 1 : -1;
}
s1++;
s2++;
}
return 0;
}

View File

@ -0,0 +1,40 @@
/*-
* Copyright (c)1999 Citrus 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:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. 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 AUTHOR 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 AUTHOR 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.
*
* citrus Id: wmemcpy.c,v 1.2 2000/12/20 14:08:31 itojun Exp
*/
#include <string.h>
#include <wchar.h>
wchar_t *
_DEFUN (wmemcpy, (d, s, n),
wchar_t *d _AND
const wchar_t *s _AND
size_t n)
{
return (wchar_t *)memcpy(d, s, n * sizeof(wchar_t));
}

View File

@ -0,0 +1,40 @@
/*-
* Copyright (c)1999 Citrus 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:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. 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 AUTHOR 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 AUTHOR 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.
*
* citrus Id: wmemmove.c,v 1.2 2000/12/20 14:08:31 itojun Exp
*/
#include <string.h>
#include <wchar.h>
wchar_t *
_DEFUN (wmemmove, (d, s, n),
wchar_t *d _AND
const wchar_t *s _AND
size_t n)
{
return (wchar_t *)memmove(d, s, n * sizeof(wchar_t));
}

View File

@ -0,0 +1,46 @@
/*-
* Copyright (c)1999 Citrus 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:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. 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 AUTHOR 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 AUTHOR 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.
*
* citrus Id: wmemset.c,v 1.2 2000/12/20 14:08:31 itojun Exp
*/
#include <wchar.h>
wchar_t *
_DEFUN(wmemset, (s, c, n),
wchar_t *s _AND
wchar_t c _AND
size_t n)
{
size_t i;
wchar_t *p;
p = (wchar_t *)s;
for (i = 0; i < n; i++) {
*p = c;
p++;
}
return s;
}