From 8ee4abda8a85170a0748ce56c4571aed5d9257ce Mon Sep 17 00:00:00 2001 From: Simon Josefsson Date: Wed, 5 Oct 2005 13:29:53 +0000 Subject: [PATCH] Add memxor. --- ChangeLog | 2 ++ lib/ChangeLog | 2 ++ lib/memxor.c | 36 ++++++++++++++++++++++++++++++++++++ lib/memxor.h | 31 +++++++++++++++++++++++++++++++ m4/ChangeLog | 4 ++++ m4/memxor.m4 | 11 +++++++++++ modules/memxor | 24 ++++++++++++++++++++++++ 7 files changed, 110 insertions(+) create mode 100644 lib/memxor.c create mode 100644 lib/memxor.h create mode 100644 m4/memxor.m4 create mode 100644 modules/memxor diff --git a/ChangeLog b/ChangeLog index da5c57307..1ef00e0ac 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2005-10-05 Simon Josefsson + * modules/memxor: New file. + * modules/iconv (Files): Move config.rpath to havelib, it is used there. diff --git a/lib/ChangeLog b/lib/ChangeLog index ea40cf811..e8bd02b9e 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,5 +1,7 @@ 2005-10-05 Simon Josefsson + * memxor.h, memxor.c: New files. + * getaddrinfo.h: Don't protect sys/types.h with HAVE_SYS_TYPES_H, we assume all systems have it, suggested by Jim Meyering . Remove HAVE_SYS_SOCKET_H test too, to see if diff --git a/lib/memxor.c b/lib/memxor.c new file mode 100644 index 000000000..ac922a804 --- /dev/null +++ b/lib/memxor.c @@ -0,0 +1,36 @@ +/* memxor.c -- perform binary exclusive OR operation of two memory blocks. + Copyright (C) 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +/* Written by Simon Josefsson. The interface was inspired by memxor + in Niels Möller's Nettle. */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include "memxor.h" + +void * +memxor (void *restrict dest, const void *restrict src, size_t n) +{ + char *d = dest; + + for (; n > 0; n--) + *d++ ^= *src++; + + return dest; +} diff --git a/lib/memxor.h b/lib/memxor.h new file mode 100644 index 000000000..b507b0f74 --- /dev/null +++ b/lib/memxor.h @@ -0,0 +1,31 @@ +/* memxor.h -- perform binary exclusive OR operation on memory blocks. + Copyright (C) 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +/* Written by Simon Josefsson. The interface was inspired by memxor + in Niels Möller's Nettle. */ + +#ifndef MEMXOR_H +# define MEMXOR_H + +#include + +/* Compute binary exclusive OR of memory areas DEST and SRC, putting + the result in DEST, of length N bytes. Returns a pointer to + DEST. */ +void *memxor (void *restrict dest, const void *restrict src, size_t n); + +#endif /* MEMXOR_H */ diff --git a/m4/ChangeLog b/m4/ChangeLog index 6c1f166a2..b118d93f1 100644 --- a/m4/ChangeLog +++ b/m4/ChangeLog @@ -1,3 +1,7 @@ +2005-10-05 Simon Josefsson + + * memxor.m4: New file. + 2005-10-02 Paul Eggert Sync from coreutils. diff --git a/m4/memxor.m4 b/m4/memxor.m4 new file mode 100644 index 000000000..96764cfbf --- /dev/null +++ b/m4/memxor.m4 @@ -0,0 +1,11 @@ +# memxor.m4 serial 1 +dnl Copyright (C) 2005 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_MEMXOR], +[ + AC_LIBSOURCES([memxor.h, memxor.c]) + AC_LIBOBJ([memxor]) +]) diff --git a/modules/memxor b/modules/memxor new file mode 100644 index 000000000..d2db999cf --- /dev/null +++ b/modules/memxor @@ -0,0 +1,24 @@ +Description: +memxor() function: binary exclusive or operation on two memory blocks + +Files: +lib/memxor.h +lib/memxor.c +m4/memxor.m4 + +Depends-on: +restrict + +configure.ac: +gl_MEMXOR + +Makefile.am: + +Include: +"memxor.h" + +License: +LGPL + +Maintainer: +Simon Josefsson -- 2.11.0