This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] pagecopy.h removal


I found this cleanup opportunity. This was only used for real on "mach" (GNU Hurd, I presume), and the error checking there doesn't look particularly reliable to me.

I suspect applying this should wait until after the release.

--
Florian Weimer / Red Hat Product Security Team
2014-01-14  Florian Weimer  <fweimer@redhat.com>

	* sysdeps/generic/pagecopy.h: Delete file.
	* sysdeps/mach/pagecopy.h: Likewise.
	* debug/memcpy_chk.c: Do not include <pagecopy.h>.
	* debug/memmove_chk.c: Likewise.
	* debug/mempcpy_chk.c: Likewise.
	* string/memcpy.c: Do not include <pagecopy.h>.
	(memcpy): Do not call PAGE_COPY_FWD_MAYBE.
	* string/memmove.c: Do not include <pagecopy.h>.
	(MEMMOVE): Do not call PAGE_COPY_FWD_MAYBE.
	* sysdeps/powerpc/memmove.c: Do not include <pagecopy.h>.
	(MEMMOVE): Do not call PAGE_COPY_FWD_MAYBE.

diff --git a/debug/memcpy_chk.c b/debug/memcpy_chk.c
index ab5adab..c445c42 100644
--- a/debug/memcpy_chk.c
+++ b/debug/memcpy_chk.c
@@ -20,7 +20,6 @@
 
 #include <string.h>
 #include <memcopy.h>
-#include <pagecopy.h>
 
 void *
 __memcpy_chk (dstpp, srcpp, len, dstlen)
diff --git a/debug/memmove_chk.c b/debug/memmove_chk.c
index aa02873..fd65baa 100644
--- a/debug/memmove_chk.c
+++ b/debug/memmove_chk.c
@@ -20,7 +20,6 @@
 
 #include <string.h>
 #include <memcopy.h>
-#include <pagecopy.h>
 
 #ifndef MEMMOVE_CHK
 # define MEMMOVE_CHK __memmove_chk
diff --git a/debug/mempcpy_chk.c b/debug/mempcpy_chk.c
index 87db7e1..f4d6871 100644
--- a/debug/mempcpy_chk.c
+++ b/debug/mempcpy_chk.c
@@ -21,7 +21,6 @@
 
 #include <string.h>
 #include <memcopy.h>
-#include <pagecopy.h>
 
 void *
 __mempcpy_chk (dstpp, srcpp, len, dstlen)
diff --git a/string/memcpy.c b/string/memcpy.c
index c19bad3..19ba127 100644
--- a/string/memcpy.c
+++ b/string/memcpy.c
@@ -20,7 +20,6 @@
 
 #include <string.h>
 #include <memcopy.h>
-#include <pagecopy.h>
 
 #undef memcpy
 
@@ -42,11 +41,6 @@ memcpy (dstpp, srcpp, len)
       len -= (-dstp) % OPSIZ;
       BYTE_COPY_FWD (dstp, srcp, (-dstp) % OPSIZ);
 
-      /* Copy whole pages from SRCP to DSTP by virtual address manipulation,
-	 as much as possible.  */
-
-      PAGE_COPY_FWD_MAYBE (dstp, srcp, len, len);
-
       /* Copy from SRCP to DSTP taking advantage of the known alignment of
 	 DSTP.  Number of bytes remaining is put in the third argument,
 	 i.e. in LEN.  This number may vary from machine to machine.  */
diff --git a/string/memmove.c b/string/memmove.c
index 3373401..82e679d 100644
--- a/string/memmove.c
+++ b/string/memmove.c
@@ -20,7 +20,6 @@
 
 #include <string.h>
 #include <memcopy.h>
-#include <pagecopy.h>
 
 /* All this is so that bcopy.c can #include
    this file after defining some things.  */
@@ -66,11 +65,6 @@ MEMMOVE (a1, a2, len)
 	  len -= (-dstp) % OPSIZ;
 	  BYTE_COPY_FWD (dstp, srcp, (-dstp) % OPSIZ);
 
-	  /* Copy whole pages from SRCP to DSTP by virtual address
-	     manipulation, as much as possible.  */
-
-	  PAGE_COPY_FWD_MAYBE (dstp, srcp, len, len);
-
 	  /* Copy from SRCP to DSTP taking advantage of the known
 	     alignment of DSTP.  Number of bytes remaining is put
 	     in the third argument, i.e. in LEN.  This number may
diff --git a/sysdeps/generic/pagecopy.h b/sysdeps/generic/pagecopy.h
deleted file mode 100644
index 2c35b71..0000000
--- a/sysdeps/generic/pagecopy.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/* Macros for copying by pages; used in memcpy, memmove.  Generic macros.
-   Copyright (C) 1995-2014 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library 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
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-/* This file defines the macro:
-
-   PAGE_COPY_FWD_MAYBE (dstp, srcp, nbytes_left, nbytes)
-
-   which is invoked like WORD_COPY_FWD et al.  The pointers should be at
-   least word aligned.  This will check if virtual copying by pages can and
-   should be done and do it if so.
-
-   System-specific pagecopy.h files should define these macros and then
-   #include this file:
-
-   PAGE_COPY_THRESHOLD
-   -- Minimum size for which virtual copying by pages is worthwhile.
-
-   PAGE_SIZE
-   -- Size of a page.
-
-   PAGE_COPY_FWD (dstp, srcp, nbytes_left, nbytes)
-   -- Macro to perform the virtual copy operation.
-   The pointers will be aligned to PAGE_SIZE bytes.
-*/
-
-
-#if PAGE_COPY_THRESHOLD
-
-#include <assert.h>
-
-#define PAGE_COPY_FWD_MAYBE(dstp, srcp, nbytes_left, nbytes)		      \
-  do									      \
-    {									      \
-      if ((nbytes) >= PAGE_COPY_THRESHOLD &&				      \
-	  PAGE_OFFSET ((dstp) - (srcp)) == 0) 				      \
-	{								      \
-	  /* The amount to copy is past the threshold for copying	      \
-	     pages virtually with kernel VM operations, and the		      \
-	     source and destination addresses have the same alignment.  */    \
-	  size_t nbytes_before = PAGE_OFFSET (-(dstp));			      \
-	  if (nbytes_before != 0)					      \
-	    {								      \
-	      /* First copy the words before the first page boundary.  */     \
-	      WORD_COPY_FWD (dstp, srcp, nbytes_left, nbytes_before);	      \
-	      assert (nbytes_left == 0);				      \
-	      nbytes -= nbytes_before;					      \
-	    }								      \
-	  PAGE_COPY_FWD (dstp, srcp, nbytes_left, nbytes);		      \
-	}								      \
-    } while (0)
-
-/* The page size is always a power of two, so we can avoid modulo division.  */
-#define PAGE_OFFSET(n)	((n) & (PAGE_SIZE - 1))
-
-#else
-
-#define PAGE_COPY_FWD_MAYBE(dstp, srcp, nbytes_left, nbytes) /* nada */
-
-#endif
diff --git a/sysdeps/mach/pagecopy.h b/sysdeps/mach/pagecopy.h
deleted file mode 100644
index 36c3697..0000000
--- a/sysdeps/mach/pagecopy.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Macros for copying by pages; used in memcpy, memmove.  Mach version.
-   Copyright (C) 1995-2014 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library 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
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   <http://www.gnu.org/licenses/>.  */
-
-#include <mach.h>
-
-/* Threshold at which vm_copy is more efficient than well-optimized copying
-   by words.  This parameter should be tuned as necessary.  */
-#define PAGE_THRESHOLD		(2 * PAGE_SIZE)	/* XXX ? */
-
-#define PAGE_SIZE		__vm_page_size
-#define PAGE_COPY_FWD(dstp, srcp, nbytes_left, nbytes)			      \
-  ((nbytes_left) = ((nbytes) -						      \
-		    (__vm_copy (__mach_task_self (),			      \
-				(vm_address_t) srcp, trunc_page (nbytes),     \
-				(vm_address_t) dstp) == KERN_SUCCESS	      \
-		     ? trunc_page (nbytes)				      \
-		     : 0)))
-
-/* Get the generic macro.  */
-#include <sysdeps/generic/pagecopy.h>
diff --git a/sysdeps/powerpc/memmove.c b/sysdeps/powerpc/memmove.c
index 3859da8..5da8f94 100644
--- a/sysdeps/powerpc/memmove.c
+++ b/sysdeps/powerpc/memmove.c
@@ -20,7 +20,6 @@
 
 #include <string.h>
 #include <memcopy.h>
-#include <pagecopy.h>
 
 /* All this is so that bcopy.c can #include
    this file after defining some things.  */
@@ -66,11 +65,6 @@ MEMMOVE (a1, a2, len)
          len -= (-dstp) % OPSIZ;
          BYTE_COPY_FWD (dstp, srcp, (-dstp) % OPSIZ);
 
-         /* Copy whole pages from SRCP to DSTP by virtual address
-            manipulation, as much as possible.  */
-
-         PAGE_COPY_FWD_MAYBE (dstp, srcp, len, len);
-
          /* Copy from SRCP to DSTP taking advantage of the known
             alignment of DSTP.  Number of bytes remaining is put
             in the third argument, i.e. in LEN.  This number may

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]