# HG changeset patch # User Simon Josefsson # Date 1128518993 0 # Node ID 4b643b12df55bbb482e46b4c8e8f2b2d6f9cec70 # Parent 2cb18c08d152239887a52781b8604fd3f5578cc0 Add memxor. diff --git a/ChangeLog b/ChangeLog --- 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 --- 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 --- /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 --- /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 --- 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 --- /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 --- /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