[gs-cvs] rev 7119 - trunk/gs/src
tor at ghostscript.com
tor at ghostscript.com
Tue Oct 24 05:22:15 PDT 2006
Author: tor
Date: 2006-10-24 05:22:14 -0700 (Tue, 24 Oct 2006)
New Revision: 7119
Modified:
trunk/gs/src/gxccman.c
trunk/gs/src/gxfcache.h
Log:
A conditionally compiled mechanism to allow cached characters
to be locked out from eviction. A cached character has a reference
count, which if non-zero will prevent the cache slot to be evicted.
This is needed for the GSLite API.
Modified: trunk/gs/src/gxccman.c
===================================================================
--- trunk/gs/src/gxccman.c 2006-10-23 11:17:11 UTC (rev 7118)
+++ trunk/gs/src/gxccman.c 2006-10-24 12:22:14 UTC (rev 7119)
@@ -148,7 +148,11 @@
for (chi = 0; chi <= cmax;) {
cached_char *cc = dir->ccache.table[chi];
- if (cc != 0 && (*proc) (dir->memory, cc, proc_data)) {
+ if (cc != 0 &&
+#ifdef GSLITE
+ !cc->dont_evict &&
+#endif
+ (*proc) (dir->memory, cc, proc_data)) {
hash_remove_cached_char(dir, chi);
gx_free_cached_char(dir, cc);
} else
@@ -1024,7 +1028,14 @@
) {
if (cch == 0) { /* Not enough room to allocate in this chunk. */
return 0;
- } { /* Free the character */
+ }
+#ifdef GSLITE
+ /* We shouldn't free because it's used. */
+ if (cc->dont_evict) {
+ return 0;
+ }
+#endif
+ else { /* Free the character */
cached_fm_pair *pair = cc_pair(cc);
if (pair != 0) {
@@ -1034,12 +1045,19 @@
chi++;
hash_remove_cached_char(dir, chi);
}
+
gx_free_cached_char(dir, cc);
}
}
+
+#ifdef GSLITE
+ cc->dont_evict = 0;
+#endif
+
cc->chunk = cck;
cc->loc = (byte *) cc - cck->data;
return cc;
+
#undef cc
}
@@ -1080,3 +1098,18 @@
if_debug2('K', "[K]shortening creates free block 0x%lx(%u)\n",
(ulong) ((byte *) cc + cc->head.size), diff);
}
+
+#ifdef GSLITE
+
+void gx_retain_cached_char(cached_char *cc)
+{
+ cc->dont_evict ++;
+}
+
+void gx_release_cached_char(cached_char *cc)
+{
+ cc->dont_evict --;
+}
+
+#endif
+
Modified: trunk/gs/src/gxfcache.h
===================================================================
--- trunk/gs/src/gxfcache.h 2006-10-23 11:17:11 UTC (rev 7118)
+++ trunk/gs/src/gxfcache.h 2006-10-24 12:22:14 UTC (rev 7119)
@@ -169,6 +169,21 @@
uint pair_index; /* index of pair in mdata */
gs_fixed_point subpix_origin; /* glyph origin offset modulo pixel */
+#ifdef GSLITE
+ /* GSLite API needs to be able to lock a cache entry from being
+ evicted. We do this by counting how many times the GSLite user
+ has "retained" the slot. The initial value of this is zero.
+ For normal ghostscript operation it will never be changed,
+ so it has no effect.
+
+ This is an ugly and ill conceived hack that was implemented
+ at the behest of a large customer. It is guarded by this ifdef
+ for a reason. We do not want our own code to depend on
+ this functionality.
+ */
+ int dont_evict;
+#endif
+
/* The rest of the structure is the 'value'. */
/* gx_cached_bits_common has width, height, raster, */
/* shift (not used here), id. */
@@ -222,6 +237,11 @@
#define chars_head_index(glyph, pair)\
((uint)(glyph) * 59 + (pair)->hash * 73) /* scramble it a bit */
+#ifdef GSLITE
+void gx_retain_cached_char(cached_char *cc);
+void gx_release_cached_char(cached_char *cc);
+#endif
+
/* ------ Character cache ------ */
/*
More information about the gs-cvs
mailing list