Add memxor.
authorSimon Josefsson <simon@josefsson.org>
Wed, 5 Oct 2005 13:29:53 +0000 (13:29 +0000)
committerSimon Josefsson <simon@josefsson.org>
Wed, 5 Oct 2005 13:29:53 +0000 (13:29 +0000)
ChangeLog
lib/ChangeLog
lib/memxor.c [new file with mode: 0644]
lib/memxor.h [new file with mode: 0644]
m4/ChangeLog
m4/memxor.m4 [new file with mode: 0644]
modules/memxor [new file with mode: 0644]

index da5c573..1ef00e0 100644 (file)
--- 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.
 
index ea40cf8..e8bd02b 100644 (file)
@@ -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
diff --git a/lib/memxor.c b/lib/memxor.c
new file mode 100644 (file)
index 0000000..ac922a8
--- /dev/null
@@ -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;
+}
diff --git a/lib/memxor.h b/lib/memxor.h
new file mode 100644 (file)
index 0000000..b507b0f
--- /dev/null
@@ -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 */
index 6c1f166..b118d93 100644 (file)
@@ -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.
diff --git a/m4/memxor.m4 b/m4/memxor.m4
new file mode 100644 (file)
index 0000000..96764cf
--- /dev/null
@@ -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 (file)
index 0000000..d2db999
--- /dev/null
@@ -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