From 521cb5f96a03acba4dd1b3502edff17aa8b52d76 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Mon, 14 Jul 2003 18:50:59 +0000 Subject: [PATCH] New module 'mempcpy'. --- ChangeLog | 5 +++++ lib/ChangeLog | 5 +++++ lib/mempcpy.c | 29 +++++++++++++++++++++++++++++ lib/mempcpy.h | 32 ++++++++++++++++++++++++++++++++ m4/ChangeLog | 4 ++++ m4/mempcpy.m4 | 23 +++++++++++++++++++++++ modules/mempcpy | 21 +++++++++++++++++++++ 7 files changed, 119 insertions(+) create mode 100644 lib/mempcpy.c create mode 100644 lib/mempcpy.h create mode 100644 m4/mempcpy.m4 create mode 100644 modules/mempcpy diff --git a/ChangeLog b/ChangeLog index 70471926de..fb2d5ccbf4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2003-07-14 Simon Josefsson + + * modules/mempcpy: New file. + * MODULES.html.sh (func_all_modules): Add mempcpy. + 2003-07-14 Paul Eggert * modules/getdate, modules/posixtm: Depend on mktime. diff --git a/lib/ChangeLog b/lib/ChangeLog index d978ca1c74..52d80b5c5e 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,8 @@ +2003-07-14 Simon Josefsson + + * mempcpy.h: New file. + * mempcpy.c: New file. + 2003-07-14 Paul Eggert * ceill.c, expl.c, floorl.c, frexpl.c, ldexpl.c, mathl.h, diff --git a/lib/mempcpy.c b/lib/mempcpy.c new file mode 100644 index 0000000000..3ac42af288 --- /dev/null +++ b/lib/mempcpy.c @@ -0,0 +1,29 @@ +/* Copy memory area and return pointer after last written byte. + Copyright (C) 2003 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +/* Specification. */ +#include "mempcpy.h" + +#include + +/* Copy N bytes of SRC to DEST, return pointer to bytes after the + last written byte. */ +void * +mempcpy (void *dest, const void *src, size_t n) +{ + return (char *) memcpy (dest, src, n) + n; +} diff --git a/lib/mempcpy.h b/lib/mempcpy.h new file mode 100644 index 0000000000..577745055d --- /dev/null +++ b/lib/mempcpy.h @@ -0,0 +1,32 @@ +/* Copy memory area and return pointer after last written byte. + Copyright (C) 2003 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#if HAVE_MEMPCPY + +/* Get mempcpy() declaration. */ +#include + +#else + +/* Get size_t */ +#include + +/* Copy N bytes of SRC to DEST, return pointer to bytes after the + last written byte. */ +extern void *mempcpy (void *dest, const void *src, size_t n); + +#endif diff --git a/m4/ChangeLog b/m4/ChangeLog index b1a76120b2..e409b2acb6 100644 --- a/m4/ChangeLog +++ b/m4/ChangeLog @@ -1,3 +1,7 @@ +2003-07-14 Simon Josefsson + + * mempcpy.m4: New file. + 2003-07-10 Jim Meyering * clock_time.m4: Remove trailing blank. diff --git a/m4/mempcpy.m4 b/m4/mempcpy.m4 new file mode 100644 index 0000000000..a5ed8de838 --- /dev/null +++ b/m4/mempcpy.m4 @@ -0,0 +1,23 @@ +# mempcpy.m4 serial 1 +dnl Copyright (C) 2003 Free Software Foundation, Inc. +dnl This file is free software, distributed under the terms of the GNU +dnl General Public License. As a special exception to the GNU General +dnl Public License, this file may be distributed as part of a program +dnl that contains a configuration script generated by Autoconf, under +dnl the same distribution terms as the rest of that program. + +AC_DEFUN([gl_FUNC_MEMPCPY], +[ + dnl Persuade glibc to declare mempcpy(). + AC_REQUIRE([AC_GNU_SOURCE]) + + AC_REPLACE_FUNCS(mempcpy) + if test $ac_cv_func_mempcpy = no; then + gl_PREREQ_MEMPCPY + fi +]) + +# Prerequisites of lib/mempcpy.c. +AC_DEFUN([gl_PREREQ_MEMPCPY], [ + : +]) diff --git a/modules/mempcpy b/modules/mempcpy new file mode 100644 index 0000000000..fbbe88087d --- /dev/null +++ b/modules/mempcpy @@ -0,0 +1,21 @@ +Description: +mempcpy() function: copy memory area, return point after last written byte. + +Files: +lib/mempcpy.h +lib/mempcpy.c +m4/mempcpy.m4 + +Depends-on: + +configure.ac: +gl_FUNC_MEMPCPY + +Makefile.am: +lib_SOURCES += mempcpy.h + +Include: +"mempcpy.h" + +Maintainer: +Simon Josefsson -- 2.30.2