1
0
mirror of https://git.FreeBSD.org/ports.git synced 2025-01-04 06:15:24 +00:00

forgot the two patches, sorry.

PR:		20038
Submitted by:	Mikhail Teterin <mi@aldan.algebra.com>
This commit is contained in:
Andreas Klemm 2000-08-24 20:44:58 +00:00
parent 9269d1b0eb
commit 9f1c27c0ec
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=31937
8 changed files with 408 additions and 0 deletions

View File

@ -0,0 +1,87 @@
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);
- }

View File

@ -0,0 +1,15 @@
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);
}

View File

@ -0,0 +1,87 @@
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);
- }

View File

@ -0,0 +1,15 @@
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);
}

View File

@ -0,0 +1,87 @@
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);
- }

View File

@ -0,0 +1,15 @@
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);
}

View File

@ -0,0 +1,87 @@
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);
- }

View File

@ -0,0 +1,15 @@
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);
}