Poprawka.

Marcin Dalecki dalecki w cs.net.pl
Nie, 21 Lut 1999, 05:49:26 CET


Marcin Dalecki wrote:
> 
> Z mi³ym zaskoczeniem stwierdzi³em, ¿e w przeciwieñstwie do serwera
> CVS na PG to ftp.ps.pl jest dla mnie dobrze osiagalny.
> 
> Tak czy siak. Powoli czyjê siê znów bardziej ludzko, awiec i
> kolejne ³aty siê sypi±.
> Pierwsza dla speca egcs-a jest drobn± poprawk± wy¿ucaj±c± ³atê
> pgcc z pakietu oraz zapobiegajac± instalacji niezdatnej statycznej
> biblioteki libiberty.
> 
> Durga z nich nieco bardziej ciekawa dodaje wyko¿ystywanie
> nowego wywo³ania systemowego, które optymalizuje kopiowanie
> plików to pakietu fileutils. Postaram siê jeszcze dzisiaj w nocy
> tego samego rodzaju modyfikacje zastosowaæ zaróno do komendy cat
> jak i cp wbudowanego do bash-a.
> 
> Dodatkowo mam na agendzie rozwi±zanie problemu z klawiszami Home i End
> oraz Delete poprzez wprowadzenie odpowiednich modyfikacji do terminali
> lub biblioteki readline.
> 
> Uprzejmie proszê jak zwykle o mo¿liwie rych³e zastosowanie tych ³at.
> --
>         Marcin Dalecki
> 
> 
> --- egcs.spec-orig      Sat Feb 20 07:24:04 1999
> +++ egcs.spec   Sat Feb 20 07:36:52 1999
> @@ -2,7 +2,7 @@
>  Summary(pl):   Zaawansowany kompilator GNU
>  Name:          egcs
>  Version:       1.1.1
> -Release:       9d
> +Release:       10
>  Copyright:     GPL
>  Group:         Development/Languages
>  Group(pl):     Programowanie/Jêzyki
> @@ -11,7 +11,6 @@
>  Patch0:                egcs-libio.patch
>  Patch1:                egcs-mandir.patch
>  Patch2:                egcs-info.patch
> -Patch3:                egcs-pgcc.patch
>  Prereq:                /sbin/install-info
>  Requires:      binutils >= 2.9.1.0.18
>  Requires:      %{name}-cpp = %{version}
> @@ -229,10 +228,6 @@
>  %patch1 -p1
>  %patch2 -p1
> 
> -%ifarch i386
> -#%patch3 -p1
> -%endif
> -
>  %build
>  rm -rf obj-$RPM_ARCH-linux
>  install -d obj-$RPM_ARCH-linux
> @@ -346,7 +341,6 @@
>  %attr(755,root,root) /usr/lib/gcc-lib/%{buildarch}*/egcs-*/*.o
>  %endif
> 
> -/usr/%{buildarch}*
>  %attr(755,root,root) /usr/lib/gcc-lib/%{buildarch}*/egcs-*/collect2
> 
>  %ifarch ppc
> @@ -443,6 +437,11 @@
>  %attr(755,root,root) /usr/lib/gcc-lib/%{buildarch}*/egcs-*/cpp
> 
>  %changelog
> +* Sat Feb 20 1999 Marcin Dalecki <dalecki w cs.net.pl>
> +  [1.1.1-10]
> +- removed finally bogous pgcc patch from distributton,
> +- removed useless static libiberty stuff from installation.
> +
>  * Fri Jan 29 1999 Tomasz K³oczko <kloczek w rudy.mif.pg.gda.pl>
>    [1.1.1-8d]
>  - removed no splitting info files,
> 
> 
> diff -urN fileutils-4.0/src/copy.c fileutils-4.0-new/src/copy.c
> --- fileutils-4.0/src/copy.c    Mon Sep 28 18:09:18 1998
> +++ fileutils-4.0-new/src/copy.c        Sun Feb 21 01:03:27 1999
> @@ -26,6 +26,18 @@
>  #include <assert.h>
>  #include <sys/types.h>
> 
> +/*
> + * Check whatever the sendfile(2) system call is supporter on this system.
> + * Actually linux is even learning from NT :-).
> + */
> +#if defined(__linux__) && (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)
> +#define HAS_SENDFILE
> +#endif
> +
> +#ifdef HAS_SENDFILE
> +#include <sys/sendfile.h>
> +#endif
> +
>  #include "system.h"
>  #include "error.h"
>  #include "backupfile.h"
> @@ -236,6 +248,14 @@
>      }
>  #endif
> 
> +  /*
> +   * If we expect to make any holes we resort to normalcopy mode.
> +   * Better save then sorry...
> +   */
> +#ifdef HAS_SENDFILE
> +  if (make_holes) {
> +normal_copy:
> +#endif
Oto poprawka do poprzedniej ³aty, która niestety nie dzia³a³a na
nieregularnych plikach. Tak to ju¿ bywa z niezdokumentowanymi
funkcjami systemu...

--
	Marcin Dalecki / free programmer :-).
-------------- nastêpna czê¶æ ---------
diff -ur textutils-1.22/src/cat.c textutils-1.22-new/src/cat.c
--- textutils-1.22/src/cat.c	Sat Nov 23 23:00:51 1996
+++ textutils-1.22-new/src/cat.c	Sun Feb 21 05:19:09 1999
@@ -30,6 +30,16 @@
 #ifndef _POSIX_SOURCE
 #include <sys/ioctl.h>
 #endif
+
+#if defined(__linux__) && (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)
+#define HAS_SENDFILE 1
+#endif
+
+#ifdef HAS_SENDFILE
+#include <sys/sendfile.h>
+#include <sys/user.h> 		/* needed for PAGE_SIZE */
+#endif
+
 #include "system.h"
 #include "error.h"
 
@@ -132,16 +142,46 @@
 
 static void
 simple_cat (
-     /* Pointer to the buffer, used by reads and writes.  */
-     unsigned char *buf,
-
      /* Number of characters preferably read or written by each read and write
         call.  */
      int bufsize)
 {
   /* Actual number of characters read, and therefore written.  */
   int n_read;
+  unsigned char * buf;
+
+#ifdef HAS_SENDFILE
+   /*
+    * Sun Feb 21 02:30:47 CET 1999 Marcin Dalecki <dalecki w cs.net.pl>:
+    *
+    * Under Linux we can do better now. We use the brand new sendfile system
+    * call to prevent unnecessary physical data copying.
+    */
+
+   for (;;)
+    {
+      /* Read a block of input.  */
+      n_read = sendfile(output_desc, input_desc, NULL, PAGE_SIZE);
+      if (n_read < 0) {
+	if (errno == EINVAL) {
+	  errno = 0;
+	  goto not_regular;
+	} else {
+	  error (EXIT_FAILURE, errno, "%s", infile);
+	  return;
+	}
+      }
+
+      /* End of this file?  */
+
+      if (n_read == 0)
+	break;
+    }
+  return;
 
+not_regular:
+#endif
+  buf = (unsigned char *) alloca (bufsize);
   /* Loop until the end of the file.  */
 
   for (;;)
@@ -176,15 +216,9 @@
 
 static void
 cat (
-     /* Pointer to the beginning of the input buffer.  */
-     unsigned char *inbuf,
-
      /* Number of characters read in each read call.  */
      int insize,
 
-     /* Pointer to the beginning of the output buffer.  */
-     unsigned char *outbuf,
-
      /* Number of characters written by each write call.  */
      int outsize,
 
@@ -196,6 +230,12 @@
      int mark_line_ends,
      int squeeze_empty_lines)
 {
+  /* Pointer to the beginning of the input buffer.  */
+  unsigned char *inbuf;
+
+  /* Pointer to the beginning of the output buffer.  */
+  unsigned char *outbuf;
+
   /* Last character read from the input buffer.  */
   unsigned char ch;
 
@@ -225,6 +265,26 @@
   int use_fionread = 1;
 #endif
 
+  inbuf = (unsigned char *) alloca (insize + 1);
+
+  /* Why are (OUTSIZE  - 1 + INSIZE * 4 + 13) bytes allocated for
+     the output buffer?
+
+     A test whether output needs to be written is done when the input
+     buffer empties or when a newline appears in the input.  After
+     output is written, at most (OUTSIZE - 1) bytes will remain in the
+     buffer.  Now INSIZE bytes of input is read.  Each input character
+     may grow by a factor of 4 (by the prepending of M-^).  If all
+     characters do, and no newlines appear in this block of input, we
+     will have at most (OUTSIZE - 1 + INSIZE) bytes in the buffer.  If
+     the last character in the preceding block of input was a
+     newline, a line number may be written (according to the given
+     options) as the first thing in the output buffer. (Done after the
+     new input is read, but before processing of the input begins.)  A
+     line number requires seldom more than 13 positions.  */
+
+  outbuf = (unsigned char *) alloca (outsize - 1 + insize * 4 + 13);
+
   /* The inbuf pointers are initialized so that BPIN > EOB, and thereby input
      is read immediately.  */
 
@@ -449,12 +509,6 @@
   /* Optimal size of i/o operations of input.  */
   int insize;
 
-  /* Pointer to the input buffer.  */
-  unsigned char *inbuf;
-
-  /* Pointer to the output buffer.  */
-  unsigned char *outbuf;
-
   int c;
 
   /* Index in argv to processed argument.  */
@@ -673,40 +727,14 @@
       if (options == 0)
 	{
 	  insize = max (insize, outsize);
-	  inbuf = (unsigned char *) xmalloc (insize);
-
-	  simple_cat (inbuf, insize);
+	  simple_cat (insize);
 	}
       else
 	{
-	  inbuf = (unsigned char *) xmalloc (insize + 1);
-
-	  /* Why are (OUTSIZE  - 1 + INSIZE * 4 + 13) bytes allocated for
-	     the output buffer?
-
-	     A test whether output needs to be written is done when the input
-	     buffer empties or when a newline appears in the input.  After
-	     output is written, at most (OUTSIZE - 1) bytes will remain in the
-	     buffer.  Now INSIZE bytes of input is read.  Each input character
-	     may grow by a factor of 4 (by the prepending of M-^).  If all
-	     characters do, and no newlines appear in this block of input, we
-	     will have at most (OUTSIZE - 1 + INSIZE) bytes in the buffer.  If
-	     the last character in the preceding block of input was a
-	     newline, a line number may be written (according to the given
-	     options) as the first thing in the output buffer. (Done after the
-	     new input is read, but before processing of the input begins.)  A
-	     line number requires seldom more than 13 positions.  */
-
-	  outbuf = (unsigned char *) xmalloc (outsize - 1 + insize * 4 + 13);
-
-	  cat (inbuf, insize, outbuf, outsize, quote,
+	  cat (insize, outsize, quote,
 	       output_tabs, numbers, numbers_at_empty_lines, mark_line_ends,
 	       squeeze_empty_lines);
-
-	  free (outbuf);
 	}
-
-      free (inbuf);
 
     contin:
       if (strcmp (infile, "-") && close (input_desc) < 0)


Więcej informacji o liście dyskusyjnej pld-devel-pl