Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Jul 2000 12:34:47 -0400 (EDT)
From:      root@monsta.privatelabs.com
To:        FreeBSD-gnats-submit@freebsd.org
Cc:        andreas@klemm.gtn.com
Subject:   ports/20038: improving the print/ghostscript6 port
Message-ID:  <200007191634.MAA22294@monsta.privatelabs.com>

next in thread | raw e-mail | index | archive | help

>Number:         20038
>Category:       ports
>Synopsis:       improving the print/ghostscript6 port
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-ports
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jul 19 09:40:04 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     Mikhail Teterin
>Release:        FreeBSD 4.0-STABLE i386
>Organization:
Virtual Estates, Inc.
>Environment:

>Description:

	The software's own genarch program took several HOURS on
	my dual PIII-700  trying to figure out the  sizes of the
	primary and secondary caches. The sizes turned out to be
	rather wrong (definetly true for the L2 cache, may be L1
	is indeed 32Kb). Their algorithm  seems bogus to me, but
	most  importantly,  the  obtained values  are  NOT  USED
	anywhere in the GhostScript code... One of the submitted
	patches rips  the "cache size" section  from the genarch
	entirely.

	The attached modification and new patches also:
		. replace the use of mktemp/fopen with mkstemp/fdopen
		. modify the unix-gcc.mak so that there is no need for
		  GNU-make

>How-To-Repeat:

>Fix:

Add the following files to the patches subdirectory, and apply the patch
at the end to the port itself.

begin patches/patch-ac:
This patch removes the  code that tries to figure out  the cache size of
the host. The  algorithm may very well fail under  some circumstances --
it  makes too  many  assumptions  about the  cache  behaviour, but  most
importantly,  the  figured out  values  ARE  NOT  USED anywhere  in  the
ghostscript code anymore.

	-mi

--- src/genarch.c	Thu Mar  9 03:40:41 2000
+++ src/genarch.c	Wed Jul 19 09:37:30 2000
@@ -43,11 +42,0 @@
-private clock_t
-time_clear(char *buf, int bsize, int nreps)
-{
-    clock_t t = clock();
-    int i;
-
-    for (i = 0; i < nreps; ++i)
-	memset(buf, 0, bsize);
-    return clock() - t;
-}
-
@@ -181,63 +170,2 @@
 #undef PRINT_MAX
-
-    section(f, "Cache sizes");
-
-    /*
-     * Determine the primary and secondary cache sizes by looking for a
-     * non-linearity in the time required to fill blocks with memset.
-     */
-    {
-#define MAX_BLOCK (1 << 20)
-	static char buf[MAX_BLOCK];
-	int bsize = 1 << 10;
-	int nreps = 1;
-	clock_t t = 0;
-	clock_t t_eps;
-
-	/*
-	 * Increase the number of repetitions until the time is
-	 * long enough to exceed the likely uncertainty.
-	 */
-
-	while ((t = time_clear(buf, bsize, nreps)) == 0)
-	    nreps <<= 1;
-	t_eps = t;
-	while ((t = time_clear(buf, bsize, nreps)) < t_eps * 10)
-	    nreps <<= 1;
-
-	/*
-	 * Increase the block size until the time jumps non-linearly.
-	 */
-	for (; bsize <= MAX_BLOCK;) {
-	    clock_t dt = time_clear(buf, bsize, nreps);
-
-	    if (dt > t + (t >> 1)) {
-		t = dt;
-		break;
-	    }
-	    bsize <<= 1;
-	    nreps >>= 1;
-	    if (nreps == 0)
-		nreps = 1, t <<= 1;
-	}
-	define_int(f, "ARCH_CACHE1_SIZE", bsize >> 1);
-	/*
-	 * Do the same thing a second time for the secondary cache.
-	 */
-	if (nreps > 1)
-	    nreps >>= 1, t >>= 1;
-	for (; bsize <= MAX_BLOCK;) {
-	    clock_t dt = time_clear(buf, bsize, nreps);
-
-	    if (dt > t * 1.25) {
-		t = dt;
-		break;
-	    }
-	    bsize <<= 1;
-	    nreps >>= 1;
-	    if (nreps == 0)
-		nreps = 1, t <<= 1;
-	}
-	define_int(f, "ARCH_CACHE2_SIZE", bsize >> 1);
-    }
 
------- end of patches/patch-ac
------- begin patches/patch-ad
This patch replaces the use of the dangerous mktemp/fopen combo
with the safe mkstemp/fdopen.

	-mi

--- src/gp_unifs.c	Thu Mar  9 03:40:41 2000
+++ src/gp_unifs.c	Wed Jul 19 09:56:42 2000
@@ -71,4 +71,5 @@
     strcat(fname, "XXXXXX");
-    mktemp(fname);
-    return fopen(fname, mode);
+    len = mkstemp(fname); /* reuse the no longer needed variable */
+    if (len == -1) return NULL;
+    return fdopen(len, mode);
 }
-------- end of patches/patch-ad

cvs diff: Diffing .
Index: Makefile
===================================================================
RCS file: ...ncvs/ports/print/ghostscript6/Makefile,v
retrieving revision 1.49
diff -U1 -r1.49 Makefile
--- Makefile	2000/07/04 07:12:49	1.49
+++ Makefile	2000/07/19 15:19:57
@@ -29,3 +29,2 @@
 WRKSRC=		${WRKDIR}/gs${PORTVERSION}
-USE_GMAKE=	yes
 MAKEFILE=	src/unix-gcc.mak
cvs diff: Diffing files
cvs diff: Diffing patches
Index: patches/patch-aa
===================================================================
RCS file: ...ncvs/ports/print/ghostscript6/patches/patch-aa,v
retrieving revision 1.11
diff -U1 -r1.11 patch-aa
--- patches/patch-aa	2000/03/25 21:02:47	1.11
+++ patches/patch-aa	2000/07/19 15:12:03
@@ -1,4 +1,28 @@
---- src/unix-gcc.mak.orig	Sat Mar 18 05:13:40 2000
-+++ src/unix-gcc.mak	Sat Mar 25 21:47:45 2000
-@@ -52,11 +52,10 @@
+--- src/unix-gcc.mak	Fri Mar 17 23:13:40 2000
++++ src/unix-gcc.mak	Wed Jul 19 10:23:42 2000
+@@ -26,14 +26,15 @@
+ # source, generated intermediate file, and object directories
+ # for the graphics library (GL) and the PostScript/PDF interpreter (PS).
+ 
+-BINDIR=./bin
+-GLSRCDIR=./src
+-GLGENDIR=./obj
+-GLOBJDIR=./obj
+-PSSRCDIR=./src
+-PSLIBDIR=./lib
+-PSGENDIR=./obj
+-PSOBJDIR=./obj
++.CURDIR?=.
++BINDIR=${.CURDIR}/bin
++GLSRCDIR=${.CURDIR}/src
++GLGENDIR=${.CURDIR}/obj
++GLOBJDIR=${.CURDIR}/obj
++PSSRCDIR=${.CURDIR}/src
++PSLIBDIR=${.CURDIR}/lib
++PSGENDIR=${.CURDIR}/obj
++PSOBJDIR=${.CURDIR}/obj
+ 
+ # Do not edit the next group of lines.
+ 
+@@ -52,11 +53,10 @@
  # the directories also define the default search path for the
@@ -17,3 +41,20 @@
  scriptdir = $(bindir)
-@@ -153,7 +152,7 @@
+@@ -128,7 +128,7 @@
+ # You may need to change this if the IJG library version changes.
+ # See jpeg.mak for more information.
+ 
+-JSRCDIR=jpeg
++JSRCDIR=${.CURDIR}/jpeg
+ JVERSION=6
+ 
+ # Choose whether to use a shared version of the IJG JPEG library (-ljpeg).
+@@ -146,14 +147,14 @@
+ # You may need to change this if the libpng version changes.
+ # See libpng.mak for more information.
+ 
+-PSRCDIR=libpng
++PSRCDIR=${PREFIX}/include
+ PVERSION=10005
+ 
+ # Choose whether to use a shared version of the PNG library, and if so,
  # what its name is.
@@ -26,3 +67,3 @@
  # Define the directory where the zlib sources are stored.
-@@ -165,7 +164,7 @@
+@@ -165,7 +165,7 @@
  # what its name is (usually libz, but sometimes libgz).
@@ -35,3 +76,3 @@
  
-@@ -180,7 +179,7 @@
+@@ -180,7 +180,7 @@
  
@@ -40,3 +81,3 @@
 -CC=gcc
-+CC=cc
++CC?=cc
  
@@ -44,3 +85,3 @@
  # Normally this is the same as the C compiler.
-@@ -213,7 +212,7 @@
+@@ -213,7 +213,7 @@
  #   gcc to accept ANSI-style function prototypes and function definitions.
@@ -53,3 +94,3 @@
  # SunOS 4.n may need -Bstatic.
-@@ -222,7 +221,7 @@
+@@ -222,7 +222,7 @@
  #	-R /usr/local/xxx/lib:/usr/local/lib
@@ -62,3 +103,3 @@
  
-@@ -242,7 +241,7 @@
+@@ -242,7 +242,7 @@
  # All reasonable platforms require -lm, but Rhapsody and perhaps one or
@@ -71,3 +112,3 @@
  # This can be null if handled in some other way (e.g., the files are
-@@ -252,7 +251,7 @@
+@@ -252,7 +252,7 @@
  # Note that x_.h expects to find the header files in $(XINCLUDE)/X11,
@@ -80,3 +121,3 @@
  # XLIBDIRS is for ld and should include -L; XLIBDIR is for LD_RUN_PATH
-@@ -264,12 +263,12 @@
+@@ -264,12 +264,12 @@
  # Solaris and other SVR4 systems with dynamic linking probably want
@@ -96,3 +137,3 @@
  #	FPU_TYPE=2 means floating point is faster than fixed point.
-@@ -327,7 +326,7 @@
+@@ -327,7 +327,7 @@
  # Choose the device(s) to include.  See devs.mak for details,
@@ -105,3 +146,3 @@
  #DEVICE_DEVS2=
-@@ -345,27 +344,27 @@
+@@ -345,27 +345,27 @@
  #DEVICE_DEVS14=
@@ -154,3 +195,3 @@
  
-@@ -379,13 +378,13 @@
+@@ -379,13 +379,13 @@
  # detect whether we're running a version of gcc with the const optimization
@@ -171,3 +212,3 @@
  CC_LEAF_PG=$(CC_)
-@@ -412,5 +411,5 @@
+@@ -412,5 +412,5 @@
  include $(GLSRCDIR)/unixinst.mak
cvs diff: Diffing pkg
cvs diff: Diffing scripts

>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-ports" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200007191634.MAA22294>