changeset 6334:4b643b12df55

Add memxor.
author Simon Josefsson <simon@josefsson.org>
date Wed, 05 Oct 2005 13:29:53 +0000
parents 2cb18c08d152
children 7eaa3cbec8e5
files ChangeLog lib/ChangeLog lib/memxor.c lib/memxor.h m4/ChangeLog m4/memxor.m4 modules/memxor
diffstat 7 files changed, 110 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2005-10-05  Simon Josefsson  <jas@extundo.com>
 
+	* modules/memxor: New file.
+
 	* modules/iconv (Files): Move config.rpath to havelib, it is used
 	there.
 
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,5 +1,7 @@
 2005-10-05  Simon Josefsson  <jas@extundo.com>
 
+	* 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
 	<jim@meyering.net>.  Remove HAVE_SYS_SOCKET_H test too, to see if
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 <config.h>
+#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;
+}
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 <stddef.h>
+
+/* 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 */
--- a/m4/ChangeLog
+++ b/m4/ChangeLog
@@ -1,3 +1,7 @@
+2005-10-05  Simon Josefsson  <jas@extundo.com>
+
+	* memxor.m4: New file.
+
 2005-10-02  Paul Eggert  <eggert@cs.ucla.edu>
 
 	Sync from coreutils.
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])
+])
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