summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2012-09-13 00:40:03 +0100
committerRobin Watts <robin@peeves.(none)>2012-09-18 05:28:21 -0700
commit6777c88fab2afc3e6558fda1dfb51110088ede61 (patch)
treeab0ee337b8e03be4a595703c7177e76ac206e037
parent1fa1eca3be2955e1ed1f8433c18d06417ea85f4c (diff)
downloadghostpdl-6777c88fab2afc3e6558fda1dfb51110088ede61.tar.gz
Introduce GS_THREADSAFE define and modify printing calls.
Lots of debugging/error information is printed using eprintf and dlprintf etc. These functions do not take a gs_memory_t * and are not safe for use within code that runs under multiple instances created by gsapi. Introduce new versions (dmprintf, dmlprintf etc) that DO take a gs_memory_ *, and move as much of ghostscript/ghostpdl's usage over to these as possible. I have not touched the contrib directory, and some locations in the code do not easily have a gs_memory_t to hand, so I have left them be. If the GS_THREADSAFE define is made during building, then the functions that don't take an explicit memory handle are #defined away to nothing. If the GS_THREADSAFE define is made, we disable the gsapi check that checks for a single init.
-rw-r--r--gs/base/gdebug.h58
-rw-r--r--gs/base/gdevabuf.c6
-rw-r--r--gs/base/gdevbbox.c10
-rw-r--r--gs/base/gdevdbit.c51
-rw-r--r--gs/base/gdevdevn.c27
-rw-r--r--gs/base/gdevdevn.h2
-rw-r--r--gs/base/gdevdflt.c4
-rw-r--r--gs/base/gdevdrop.c28
-rw-r--r--gs/base/gdevfax.c14
-rw-r--r--gs/base/gdevhl7x.c6
-rw-r--r--gs/base/gdevifno.c12
-rw-r--r--gs/base/gdevijs.c2
-rw-r--r--gs/base/gdevjpx.c2
-rw-r--r--gs/base/gdevm1.c4
-rw-r--r--gs/base/gdevm24.c6
-rw-r--r--gs/base/gdevmr1.c2
-rw-r--r--gs/base/gdevmr8n.c14
-rw-r--r--gs/base/gdevnfwd.c8
-rw-r--r--gs/base/gdevp14.c224
-rw-r--r--gs/base/gdevpbm.c18
-rw-r--r--gs/base/gdevpdf.c70
-rw-r--r--gs/base/gdevpdfu.c2
-rw-r--r--gs/base/gdevperm.c2
-rw-r--r--gs/base/gdevplan.c14
-rw-r--r--gs/base/gdevplib.c36
-rw-r--r--gs/base/gdevprn.c10
-rw-r--r--gs/base/gdevpsd.c6
-rw-r--r--gs/base/gdevpsds.c19
-rw-r--r--gs/base/gdevpsf2.c37
-rw-r--r--gs/base/gdevpsft.c16
-rw-r--r--gs/base/gdevpsfx.c7
-rw-r--r--gs/base/gdevpx.c3
-rw-r--r--gs/base/gdevrinkj.c4
-rw-r--r--gs/base/gdevsppr.c4
-rwxr-xr-xgs/base/gdevsvg.c58
-rw-r--r--gs/base/gdevsvga.c18
-rw-r--r--gs/base/gdevtrac.c166
-rw-r--r--gs/base/gdevtsep.c30
-rw-r--r--gs/base/gdevx.c20
-rw-r--r--gs/base/gdevxcf.c4
-rw-r--r--gs/base/gdevxcmp.c48
-rw-r--r--gs/base/gp_unifs.c37
-rw-r--r--gs/base/gp_unix.c14
-rw-r--r--gs/base/gsalloc.c289
-rw-r--r--gs/base/gsalphac.c4
-rw-r--r--gs/base/gscdevn.c6
-rw-r--r--gs/base/gschar0.c71
-rw-r--r--gs/base/gscie.c4
-rw-r--r--gs/base/gsciemap.c88
-rw-r--r--gs/base/gscoord.c56
-rw-r--r--gs/base/gscsepr.c4
-rw-r--r--gs/base/gscspace.c6
-rw-r--r--gs/base/gsequivc.c4
-rw-r--r--gs/base/gserrors.h107
-rw-r--r--gs/base/gsfcmap1.c40
-rw-r--r--gs/base/gsfont.c32
-rw-r--r--gs/base/gshsb.c2
-rw-r--r--gs/base/gsht.c12
-rw-r--r--gs/base/gsht1.c4
-rw-r--r--gs/base/gshtscr.c2
-rw-r--r--gs/base/gsicc.c10
-rw-r--r--gs/base/gsicc_cache.c47
-rw-r--r--gs/base/gsicc_manage.c67
-rw-r--r--gs/base/gsicc_profilecache.c8
-rw-r--r--gs/base/gsimage.c16
-rw-r--r--gs/base/gslib.c18
-rw-r--r--gs/base/gslibctx.c5
-rw-r--r--gs/base/gsmalloc.c22
-rw-r--r--gs/base/gsmchunk.c67
-rw-r--r--gs/base/gsmemory.c22
-rw-r--r--gs/base/gsmisc.c113
-rw-r--r--gs/base/gsovrc.c4
-rw-r--r--gs/base/gspath.c4
-rw-r--r--gs/base/gspath1.c2
-rw-r--r--gs/base/gsptype1.c34
-rw-r--r--gs/base/gsrefct.h2
-rw-r--r--gs/base/gsstate.c6
-rw-r--r--gs/base/gsstruct.h6
-rw-r--r--gs/base/gstrans.c82
-rw-r--r--gs/base/gstype1.c15
-rw-r--r--gs/base/gstype2.c26
-rw-r--r--gs/base/gstype42.c7
-rw-r--r--gs/base/gxacpath.c11
-rw-r--r--gs/base/gxalloc.h12
-rw-r--r--gs/base/gxblend.c4
-rw-r--r--gs/base/gxblend1.c7
-rw-r--r--gs/base/gxccache.c45
-rw-r--r--gs/base/gxccman.c62
-rw-r--r--gs/base/gxchar.c34
-rw-r--r--gs/base/gxclbits.c32
-rw-r--r--gs/base/gxcldev.h10
-rw-r--r--gs/base/gxclimag.c43
-rw-r--r--gs/base/gxclip.c18
-rw-r--r--gs/base/gxclip2.c2
-rw-r--r--gs/base/gxclipm.c6
-rw-r--r--gs/base/gxclist.c20
-rw-r--r--gs/base/gxclmem.c24
-rw-r--r--gs/base/gxclpath.c108
-rw-r--r--gs/base/gxclrast.c252
-rw-r--r--gs/base/gxclread.c14
-rw-r--r--gs/base/gxclrect.c49
-rw-r--r--gs/base/gxclthrd.c19
-rw-r--r--gs/base/gxclutil.c67
-rw-r--r--gs/base/gxcmap.c10
-rw-r--r--gs/base/gxcpath.c40
-rw-r--r--gs/base/gxdcconv.c8
-rw-r--r--gs/base/gxdevndi.c10
-rw-r--r--gs/base/gxdtfill.h2
-rw-r--r--gs/base/gxfapiu.c6
-rw-r--r--gs/base/gxfill.c96
-rw-r--r--gs/base/gxfillsl.h8
-rw-r--r--gs/base/gxfilltr.h6
-rw-r--r--gs/base/gxht.c10
-rw-r--r--gs/base/gxi12bit.c66
-rw-r--r--gs/base/gxicolor.c44
-rw-r--r--gs/base/gxidata.c26
-rw-r--r--gs/base/gxifast.c9
-rw-r--r--gs/base/gximag3x.c9
-rw-r--r--gs/base/gximage.c26
-rw-r--r--gs/base/gximage3.c6
-rw-r--r--gs/base/gximono.c6
-rw-r--r--gs/base/gxipixel.c32
-rw-r--r--gs/base/gxiscale.c28
-rw-r--r--gs/base/gxmclip.c2
-rw-r--r--gs/base/gxp1fill.c42
-rw-r--r--gs/base/gxpath.c90
-rw-r--r--gs/base/gxpath.h2
-rw-r--r--gs/base/gxpcmap.c14
-rw-r--r--gs/base/gxpflat.c8
-rw-r--r--gs/base/gxstroke.c52
-rw-r--r--gs/base/gxtype1.c2
-rw-r--r--gs/base/lib.mak2
-rw-r--r--gs/base/sbwbs.c6
-rw-r--r--gs/base/scfd.c57
-rw-r--r--gs/base/scfe.c56
-rw-r--r--gs/base/sdctd.c24
-rw-r--r--gs/base/sdcte.c28
-rw-r--r--gs/base/sfilter2.c32
-rw-r--r--gs/base/sfxfd.c16
-rw-r--r--gs/base/sfxstdio.c12
-rw-r--r--gs/base/shc.h2
-rw-r--r--gs/base/shcgen.c30
-rw-r--r--gs/base/sidscale.c28
-rw-r--r--gs/base/siscale.c6
-rw-r--r--gs/base/sjbig2.c4
-rw-r--r--gs/base/sjbig2_luratech.c21
-rw-r--r--gs/base/sjpx_luratech.c115
-rw-r--r--gs/base/slzwd.c40
-rw-r--r--gs/base/slzwe.c4
-rw-r--r--gs/base/std.h250
-rw-r--r--gs/base/stream.c70
-rw-r--r--gs/contrib/pcl3/eprn/eprnparm.c10
-rw-r--r--gs/contrib/pcl3/eprn/eprnrend.c16
-rw-r--r--gs/contrib/pcl3/eprn/gdeveprn.c2
-rw-r--r--gs/contrib/pcl3/src/gdevpcl3.c2
-rw-r--r--gs/cups/gdevcups.c296
-rw-r--r--gs/psi/fapiufst.c2
-rw-r--r--gs/psi/ialloc.c36
-rw-r--r--gs/psi/iapi.c22
-rw-r--r--gs/psi/idebug.c98
-rw-r--r--gs/psi/idict.c41
-rw-r--r--gs/psi/idisp.c2
-rw-r--r--gs/psi/idstack.c10
-rw-r--r--gs/psi/igc.c152
-rw-r--r--gs/psi/igcref.c54
-rw-r--r--gs/psi/igcstr.c41
-rw-r--r--gs/psi/igcstr.h2
-rw-r--r--gs/psi/ilocate.c46
-rw-r--r--gs/psi/imain.c16
-rw-r--r--gs/psi/imainarg.c12
-rw-r--r--gs/psi/iname.c16
-rw-r--r--gs/psi/interp.c16
-rw-r--r--gs/psi/ireclaim.c4
-rw-r--r--gs/psi/isave.c100
-rw-r--r--gs/psi/iscan.c28
-rw-r--r--gs/psi/zcie.c20
-rw-r--r--gs/psi/zcolor.c40
-rw-r--r--gs/psi/zcontext.c7
-rw-r--r--gs/psi/zdscpars.c2
-rw-r--r--gs/psi/zfapi.c10
-rw-r--r--gs/psi/zfcid0.c4
-rw-r--r--gs/psi/zfile.c2
-rw-r--r--gs/psi/zfjbig2.c2
-rw-r--r--gs/psi/zfjpx.c8
-rw-r--r--gs/psi/zicc.c12
-rw-r--r--gs/psi/zpcolor.c4
-rw-r--r--gs/psi/zvmem.c10
-rw-r--r--pcl/pccid.c26
-rw-r--r--pcl/pccid.h4
-rw-r--r--pcl/pccsbase.c6
-rw-r--r--pcl/pcfont.c4
-rw-r--r--pcl/pcfsel.c80
-rw-r--r--pcl/pcindxed.c32
-rw-r--r--pcl/pcmacros.c6
-rw-r--r--pcl/pcpage.c6
-rw-r--r--pcl/pcparse.c46
-rw-r--r--pcl/pcpatrn.c52
-rw-r--r--pcl/pcsfont.c6
-rw-r--r--pcl/pcsymbol.c22
-rw-r--r--pcl/pctext.c6
-rw-r--r--pcl/pctop.c8
-rw-r--r--pcl/pgconfig.c2
-rw-r--r--pcl/pgdraw.c14
-rw-r--r--pcl/pginit.c4
-rw-r--r--pcl/pglabel.c15
-rw-r--r--pcl/pgmisc.c6
-rw-r--r--pcl/pgparse.c14
-rw-r--r--pcl/pgvector.c12
-rw-r--r--pl/pjparse.c12
-rw-r--r--pl/plchar.c47
-rw-r--r--pl/plfont.c8
-rw-r--r--pl/pllfont.c26
-rw-r--r--pl/plmain.c96
-rw-r--r--pl/plsrgb.c2
-rw-r--r--pl/plsymbol.c10
-rw-r--r--pl/plsymbol.h2
-rw-r--r--pl/pluchar.c6
-rw-r--r--pl/plulfont.c34
-rw-r--r--pxl/pxffont.c4
-rw-r--r--pxl/pxfont.c2
-rw-r--r--pxl/pxgstate.c6
-rw-r--r--pxl/pximage.c2
-rw-r--r--pxl/pxink.c4
-rw-r--r--pxl/pxparse.c88
-rw-r--r--pxl/pxpthr.c34
-rw-r--r--pxl/pxsessio.c2
-rw-r--r--svg/svgshapes.c18
-rw-r--r--svg/svgtop.c19
-rw-r--r--xps/ghostxps.h2
-rw-r--r--xps/xpsanalyze.c26
-rw-r--r--xps/xpscff.c6
-rw-r--r--xps/xpsdoc.c10
-rw-r--r--xps/xpsglyphs.c30
-rw-r--r--xps/xpsgradient.c2
-rw-r--r--xps/xpsimage.c2
-rw-r--r--xps/xpspage.c2
-rw-r--r--xps/xpspath.c28
-rw-r--r--xps/xpsresource.c12
-rw-r--r--xps/xpstop.c4
-rw-r--r--xps/xpsttf.c4
-rw-r--r--xps/xpsxml.c2
-rw-r--r--xps/xpszip.c20
242 files changed, 3702 insertions, 3125 deletions
diff --git a/gs/base/gdebug.h b/gs/base/gdebug.h
index acda93c50..0328d3a50 100644
--- a/gs/base/gdebug.h
+++ b/gs/base/gdebug.h
@@ -92,7 +92,7 @@ bool gs_debug_c(int /*char */ );
extern FILE *gs_debug_out;
/* Debugging printout macros. */
-#ifdef DEBUG
+#if defined(DEBUG) && !defined(GS_THREADSAFE)
# define if_debug0(c,s)\
BEGIN if (gs_debug_c(c)) dlprintf(s); END
# define if_debug1(c,s,a1)\
@@ -135,12 +135,60 @@ extern FILE *gs_debug_out;
# define if_debug12(c,s,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12) DO_NOTHING
#endif
+#ifdef DEBUG
+# define if_debug0m(c,m,s)\
+ BEGIN if (gs_debug_c(c)) dmlprintf(m,s); END
+# define if_debug1m(c,m,s,a1)\
+ BEGIN if (gs_debug_c(c)) dmlprintf1(m,s,a1); END
+# define if_debug2m(c,m,s,a1,a2)\
+ BEGIN if (gs_debug_c(c)) dmlprintf2(m,s,a1,a2); END
+# define if_debug3m(c,m,s,a1,a2,a3)\
+ BEGIN if (gs_debug_c(c)) dmlprintf3(m,s,a1,a2,a3); END
+# define if_debug4m(c,m,s,a1,a2,a3,a4)\
+ BEGIN if (gs_debug_c(c)) dmlprintf4(m,s,a1,a2,a3,a4); END
+# define if_debug5m(c,m,s,a1,a2,a3,a4,a5)\
+ BEGIN if (gs_debug_c(c)) dmlprintf5(m,s,a1,a2,a3,a4,a5); END
+# define if_debug6m(c,m,s,a1,a2,a3,a4,a5,a6)\
+ BEGIN if (gs_debug_c(c)) dmlprintf6(m,s,a1,a2,a3,a4,a5,a6); END
+# define if_debug7m(c,m,s,a1,a2,a3,a4,a5,a6,a7)\
+ BEGIN if (gs_debug_c(c)) dmlprintf7(m,s,a1,a2,a3,a4,a5,a6,a7); END
+# define if_debug8m(c,m,s,a1,a2,a3,a4,a5,a6,a7,a8)\
+ BEGIN if (gs_debug_c(c)) dmlprintf8(m,s,a1,a2,a3,a4,a5,a6,a7,a8); END
+# define if_debug9m(c,m,s,a1,a2,a3,a4,a5,a6,a7,a8,a9)\
+ BEGIN if (gs_debug_c(c)) dmlprintf9(m,s,a1,a2,a3,a4,a5,a6,a7,a8,a9); END
+# define if_debug10m(c,m,s,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10)\
+ BEGIN if (gs_debug_c(c)) dmlprintf10(m,s,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10); END
+# define if_debug11m(c,m,s,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11)\
+ BEGIN if (gs_debug_c(c)) dmlprintf11(m,s,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11); END
+# define if_debug12m(c,m,s,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12)\
+ BEGIN if (gs_debug_c(c)) dmlprintf12(m,s,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12); END
+#else
+# define if_debug0m(c,m,s) DO_NOTHING
+# define if_debug1m(c,m,s,a1) DO_NOTHING
+# define if_debug2m(c,m,s,a1,a2) DO_NOTHING
+# define if_debug3m(c,m,s,a1,a2,a3) DO_NOTHING
+# define if_debug4m(c,m,s,a1,a2,a3,a4) DO_NOTHING
+# define if_debug5m(c,m,s,a1,a2,a3,a4,a5) DO_NOTHING
+# define if_debug6m(c,m,s,a1,a2,a3,a4,a5,a6) DO_NOTHING
+# define if_debug7m(c,m,s,a1,a2,a3,a4,a5,a6,a7) DO_NOTHING
+# define if_debug8m(c,m,s,a1,a2,a3,a4,a5,a6,a7,a8) DO_NOTHING
+# define if_debug9m(c,m,s,a1,a2,a3,a4,a5,a6,a7,a8,a9) DO_NOTHING
+# define if_debug10m(c,m,s,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) DO_NOTHING
+# define if_debug11m(c,m,s,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11) DO_NOTHING
+# define if_debug12m(c,m,s,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12) DO_NOTHING
+#endif
+
/* Debugging support procedures in gsmisc.c */
-void debug_dump_bytes(const byte * from, const byte * to,
+void debug_print_string(const gs_memory_t *mem, const byte * str, uint len);
+void debug_dump_bytes(const gs_memory_t *mem,
+ const byte * from, const byte * to,
const char *msg);
-void debug_dump_bitmap(const byte * from, uint raster, uint height,
+void debug_dump_bitmap(const gs_memory_t *mem,
+ const byte * from, uint raster, uint height,
const char *msg);
-void debug_print_string(const byte * str, uint len);
-void debug_print_string_hex(const byte * str, uint len);
+#ifndef GS_THREADSAFE
+void debug_print_string_hex_nomem(const byte * str, uint len);
+#endif
+void debug_print_string_hex(const gs_memory_t *mem, const byte * str, uint len);
#endif /* gdebug_INCLUDED */
diff --git a/gs/base/gdevabuf.c b/gs/base/gdevabuf.c
index 6f4116f73..4473f92fd 100644
--- a/gs/base/gdevabuf.c
+++ b/gs/base/gdevabuf.c
@@ -339,9 +339,9 @@ y_transfer_next(y_transfer * pyt, gx_device * dev)
tby -= mdev->height;
tbh = ms + mh - dev->height - tby;
}
- if_debug7('V',
- "[V]abuf: my=%d, mh=%d, ms=%d, ty=%d, th=%d, tby=%d, tbh=%d\n",
- my, mh, ms, ty, th, tby, tbh);
+ if_debug7m('V', mdev->memory,
+ "[V]abuf: my=%d, mh=%d, ms=%d, ty=%d, th=%d, tby=%d, tbh=%d\n",
+ my, mh, ms, ty, th, tby, tbh);
if (tbh > th)
tbh = th;
pyt->height_left = th - tbh;
diff --git a/gs/base/gdevbbox.c b/gs/base/gdevbbox.c
index dd17efb24..583dbacef 100644
--- a/gs/base/gdevbbox.c
+++ b/gs/base/gdevbbox.c
@@ -386,11 +386,11 @@ bbox_output_page(gx_device * dev, int num_copies, int flush)
gs_rect bbox;
gx_device_bbox_bbox(bdev, &bbox);
- dlprintf4("%%%%BoundingBox: %d %d %d %d\n",
- (int)floor(bbox.p.x), (int)floor(bbox.p.y),
- (int)ceil(bbox.q.x), (int)ceil(bbox.q.y));
- dlprintf4("%%%%HiResBoundingBox: %f %f %f %f\n",
- bbox.p.x, bbox.p.y, bbox.q.x, bbox.q.y);
+ dmlprintf4(dev->memory, "%%%%BoundingBox: %d %d %d %d\n",
+ (int)floor(bbox.p.x), (int)floor(bbox.p.y),
+ (int)ceil(bbox.q.x), (int)ceil(bbox.q.y));
+ dmlprintf4(dev->memory, "%%%%HiResBoundingBox: %f %f %f %f\n",
+ bbox.p.x, bbox.p.y, bbox.q.x, bbox.q.y);
}
return gx_forward_output_page(dev, num_copies, flush);
}
diff --git a/gs/base/gdevdbit.c b/gs/base/gdevdbit.c
index 29ec89e66..7f8e5c529 100644
--- a/gs/base/gdevdbit.c
+++ b/gs/base/gdevdbit.c
@@ -580,17 +580,17 @@ gx_default_strip_tile_rectangle(gx_device * dev, const gx_strip_bitmap * tiles,
int ptx, pty;
const byte *ptp = tiles->data;
- dlprintf4("[t]tile %dx%d raster=%d id=%lu;",
- tiles->size.x, tiles->size.y, tiles->raster, tiles->id);
- dlprintf6(" x,y=%d,%d w,h=%d,%d p=%d,%d\n",
- x, y, w, h, px, py);
- dlputs("");
+ dmlprintf4(dev->memory, "[t]tile %dx%d raster=%d id=%lu;",
+ tiles->size.x, tiles->size.y, tiles->raster, tiles->id);
+ dmlprintf6(dev->memory, " x,y=%d,%d w,h=%d,%d p=%d,%d\n",
+ x, y, w, h, px, py);
+ dmlputs(dev->memory, "");
for (pty = 0; pty < tiles->size.y; pty++) {
- dprintf(" ");
+ dmprintf(dev->memory, " ");
for (ptx = 0; ptx < tiles->raster; ptx++)
- dprintf1("%3x", *ptp++);
+ dmprintf1(dev->memory, "%3x", *ptp++);
}
- dputc('\n');
+ dmputc(dev->memory, '\n');
}
#endif
@@ -652,7 +652,7 @@ gx_default_strip_tile_rectangle(gx_device * dev, const gx_strip_bitmap * tiles,
proc_mono = dev_proc(dev, copy_mono);
}
-#define real_copy_tile(srcx, tx, ty, tw, th, id)\
+#define real_copy_tile(dev, srcx, tx, ty, tw, th, id)\
code =\
(tiles->num_planes > 1 ?\
(*proc_planes)(dev, row, srcx, raster, id, tx, ty, tw, th, height) :\
@@ -661,18 +661,13 @@ gx_default_strip_tile_rectangle(gx_device * dev, const gx_strip_bitmap * tiles,
(*proc_mono)(dev, row, srcx, raster, id, tx, ty, tw, th, color0, color1)));\
if (code < 0) return_error(code);\
return_if_interrupt(dev->memory)
-#ifdef DEBUG
-#define copy_tile(srcx, tx, ty, tw, th, tid)\
- if_debug6('t', " copy id=%lu sx=%d => x=%d y=%d w=%d h=%d\n",\
- tid, srcx, tx, ty, tw, th);\
- real_copy_tile(srcx, tx, ty, tw, th, tid)
-#else
-#define copy_tile(srcx, tx, ty, tw, th, id)\
- real_copy_tile(srcx, tx, ty, tw, th, id)
-#endif
+#define copy_tile(dev, srcx, tx, ty, tw, th, tid)\
+ if_debug6m('t', (dev)->memory, " copy id=%lu sx=%d => x=%d y=%d w=%d h=%d\n",\
+ tid, srcx, tx, ty, tw, th);\
+ real_copy_tile(dev, srcx, tx, ty, tw, th, tid)
if (ch >= h) { /* Shallow operation */
if (icw >= w) { /* Just one (partial) tile to transfer. */
- copy_tile(irx, x, y, w, h,
+ copy_tile(dev, irx, x, y, w, h,
(w == width && h == height ? tile_id :
gs_no_bitmap_id));
} else {
@@ -681,13 +676,13 @@ gx_default_strip_tile_rectangle(gx_device * dev, const gx_strip_bitmap * tiles,
int cx = x + icw;
ulong id = (h == height ? tile_id : gs_no_bitmap_id);
- copy_tile(irx, x, y, icw, h, gs_no_bitmap_id);
+ copy_tile(dev, irx, x, y, icw, h, gs_no_bitmap_id);
while (cx <= fex) {
- copy_tile(0, cx, y, width, h, id);
+ copy_tile(dev, 0, cx, y, width, h, id);
cx += width;
}
if (cx < ex) {
- copy_tile(0, cx, y, ex - cx, h, gs_no_bitmap_id);
+ copy_tile(dev, 0, cx, y, ex - cx, h, gs_no_bitmap_id);
}
}
} else if (icw >= w && shift == 0) {
@@ -697,11 +692,11 @@ gx_default_strip_tile_rectangle(gx_device * dev, const gx_strip_bitmap * tiles,
int cy = y + ch;
ulong id = (w == width ? tile_id : gs_no_bitmap_id);
- copy_tile(irx, x, y, w, ch, (ch == height ? id : gs_no_bitmap_id));
+ copy_tile(dev, irx, x, y, w, ch, (ch == height ? id : gs_no_bitmap_id));
row = tiles->data;
do {
ch = (cy > fey ? ey - cy : height);
- copy_tile(irx, x, cy, w, ch,
+ copy_tile(dev, irx, x, cy, w, ch,
(ch == height ? id : gs_no_bitmap_id));
}
while ((cy += ch) < ey);
@@ -718,17 +713,17 @@ gx_default_strip_tile_rectangle(gx_device * dev, const gx_strip_bitmap * tiles,
ulong id = (ch == height ? tile_id : gs_no_bitmap_id);
if (icw >= w) {
- copy_tile(irx, x, cy, w, ch,
+ copy_tile(dev, irx, x, cy, w, ch,
(w == width ? id : gs_no_bitmap_id));
} else {
- copy_tile(irx, x, cy, icw, ch, gs_no_bitmap_id);
+ copy_tile(dev, irx, x, cy, icw, ch, gs_no_bitmap_id);
cx = x + icw;
while (cx <= fex) {
- copy_tile(0, cx, cy, width, ch, id);
+ copy_tile(dev, 0, cx, cy, width, ch, id);
cx += width;
}
if (cx < ex) {
- copy_tile(0, cx, cy, ex - cx, ch, gs_no_bitmap_id);
+ copy_tile(dev, 0, cx, cy, ex - cx, ch, gs_no_bitmap_id);
}
}
if ((cy += ch) >= ey)
diff --git a/gs/base/gdevdevn.c b/gs/base/gdevdevn.c
index 17b585d77..64d60f521 100644
--- a/gs/base/gdevdevn.c
+++ b/gs/base/gdevdevn.c
@@ -791,7 +791,7 @@ gs_private_st_composite(st_compressed_color_list, compressed_color_list_t,
* dumps the contents of the list.
*/
void
-print_compressed_color_list(compressed_color_list_t * pcomp_list, int num_comp)
+print_compressed_color_list(const gs_memory_t *mem, compressed_color_list_t * pcomp_list, int num_comp)
{
int i, j, comp_num, comp;
comp_bit_map_list_t * pcomp_bit_map;
@@ -801,8 +801,8 @@ print_compressed_color_list(compressed_color_list_t * pcomp_list, int num_comp)
/* Indent our print out for sub levels */
for (i = TOP_ENCODED_LEVEL - pcomp_list->level_num_comp; i > 0; i--)
- dlprintf(" ");
- dlprintf1("List level = %d\n", pcomp_list->level_num_comp);
+ dmlprintf(mem, " ");
+ dmlprintf1(mem, "List level = %d\n", pcomp_list->level_num_comp);
/*
* Print the colorant bit maps for this level.
*/
@@ -810,30 +810,31 @@ print_compressed_color_list(compressed_color_list_t * pcomp_list, int num_comp)
pcomp_bit_map = &(pcomp_list->u.comp_data[i]);
/* Indent our print out for sub levels */
for (j = TOP_ENCODED_LEVEL - pcomp_list->level_num_comp; j > 0; j--)
- dlprintf(" ");
- dlprintf4("%3d%4d%4d %d ", i, pcomp_bit_map->num_comp,
- pcomp_bit_map->num_non_solid_comp, pcomp_bit_map->solid_not_100);
+ dmlprintf(mem, " ");
+ dmlprintf4(mem,"%3d%4d%4d %d ", i, pcomp_bit_map->num_comp,
+ pcomp_bit_map->num_non_solid_comp,
+ pcomp_bit_map->solid_not_100);
for (comp_num = num_comp - 1; comp_num >= 0; comp_num--) {
comp = colorant_present(pcomp_bit_map, colorants, comp_num);
- dlprintf1("%d", comp);
+ dmlprintf1(mem, "%d", comp);
if ((comp_num & 7) == 0) /* Separate into groups of 8 bits */
- dlprintf(" ");
+ dmlprintf(mem, " ");
}
- dlprintf(" ");
+ dmlprintf(mem, " ");
for (comp_num = num_comp - 1; comp_num >= 0; comp_num--) {
comp = colorant_present(pcomp_bit_map, solid_colorants, comp_num);
- dlprintf1("%d", comp);
+ dmlprintf1(mem, "%d", comp);
if ((comp_num & 7) == 0) /* Separate into groups of 8 bits */
- dlprintf(" ");
+ dmlprintf(mem, " ");
}
- dlprintf("\n");
+ dmlprintf(mem, "\n");
}
/*
* Print the sub levels.
*/
for (i = 0; i < pcomp_list->num_sub_level_ptrs; i++)
- print_compressed_color_list(pcomp_list->u.sub_level_ptrs[i], num_comp);
+ print_compressed_color_list(mem, pcomp_list->u.sub_level_ptrs[i], num_comp);
return;
}
diff --git a/gs/base/gdevdevn.h b/gs/base/gdevdevn.h
index bdfa12638..de14ebe20 100644
--- a/gs/base/gdevdevn.h
+++ b/gs/base/gdevdevn.h
@@ -554,7 +554,7 @@ extern int comp_bit_factor[];
* A routine for debugging the encoded color colorant list. This routine
* dumps the contents of the list.
*/
-void print_compressed_color_list(compressed_color_list_t * pcomp_list, int num_comp);
+void print_compressed_color_list(const gs_memory_t *mem, compressed_color_list_t * pcomp_list, int num_comp);
/*
* Free the elements of a compressed color list.
diff --git a/gs/base/gdevdflt.c b/gs/base/gdevdflt.c
index 70c1c4403..6ac0410ba 100644
--- a/gs/base/gdevdflt.c
+++ b/gs/base/gdevdflt.c
@@ -35,7 +35,7 @@ set_cinfo_polarity(gx_device * dev, gx_color_polarity_t new_polarity)
#ifdef DEBUG
/* sanity check */
if (new_polarity == GX_CINFO_POLARITY_UNKNOWN) {
- dprintf("set_cinfo_polarity: illegal operand\n");
+ dmprintf(dev->memory, "set_cinfo_polarity: illegal operand\n");
return;
}
#endif
@@ -544,7 +544,7 @@ gx_device_fill_in_procs(register gx_device * dev)
# define CHECK_NON_DEFAULT(proc, default, procname)\
BEGIN\
if ( dev_proc(dev, proc) != NULL && dev_proc(dev, proc) != default )\
- dprintf2("**** Warning: device %s implements obsolete procedure %s\n",\
+ dmprintf2(dev->memory, "**** Warning: device %s implements obsolete procedure %s\n",\
dev->dname, procname);\
END
#else
diff --git a/gs/base/gdevdrop.c b/gs/base/gdevdrop.c
index 17c76be48..a67d8bb04 100644
--- a/gs/base/gdevdrop.c
+++ b/gs/base/gdevdrop.c
@@ -50,33 +50,33 @@ trace_copy_rop(const char *cname, gx_device * dev,
int x, int y, int width, int height,
int phase_x, int phase_y, gs_logical_operation_t lop)
{
- dlprintf4("%s: dev=0x%lx(%s) depth=%d\n",
- cname, (ulong) dev, dev->dname, dev->color_info.depth);
- dlprintf4(" source data=0x%lx x=%d raster=%u id=%lu colors=",
- (ulong) sdata, sourcex, sraster, (ulong) id);
+ dmlprintf4(dev->memory, "%s: dev=0x%lx(%s) depth=%d\n",
+ cname, (ulong) dev, dev->dname, dev->color_info.depth);
+ dmlprintf4(dev->memory, " source data=0x%lx x=%d raster=%u id=%lu colors=",
+ (ulong) sdata, sourcex, sraster, (ulong) id);
if (scolors)
- dprintf2("(%lu,%lu);\n", scolors[0], scolors[1]);
+ dmprintf2(dev->memory, "(%lu,%lu);\n", scolors[0], scolors[1]);
else
- dputs("none;\n");
+ dmputs(dev->memory, "none;\n");
if (textures)
- dlprintf8(" textures=0x%lx size=%dx%d(%dx%d) raster=%u shift=%d(%d)",
+ dmlprintf8(dev->memory, " textures=0x%lx size=%dx%d(%dx%d) raster=%u shift=%d(%d)",
(ulong) textures, textures->size.x, textures->size.y,
textures->rep_width, textures->rep_height,
textures->raster, textures->shift, textures->rep_shift);
else
- dlputs(" textures=none");
+ dmlputs(dev->memory, " textures=none");
if (tcolors)
- dprintf2(" colors=(%lu,%lu)\n", tcolors[0], tcolors[1]);
+ dmprintf2(dev->memory, " colors=(%lu,%lu)\n", tcolors[0], tcolors[1]);
else
- dputs(" colors=none\n");
- dlprintf7(" rect=(%d,%d),(%d,%d) phase=(%d,%d) op=0x%x\n",
+ dmputs(dev->memory, " colors=none\n");
+ dmlprintf7(dev->memory, " rect=(%d,%d),(%d,%d) phase=(%d,%d) op=0x%x\n",
x, y, x + width, y + height, phase_x, phase_y,
(uint) lop);
if (gs_debug_c('B')) {
if (sdata)
- debug_dump_bitmap(sdata, sraster, height, "source bits");
+ debug_dump_bitmap(dev->memory, sdata, sraster, height, "source bits");
if (textures && textures->data)
- debug_dump_bitmap(textures->data, textures->raster,
+ debug_dump_bitmap(dev->memory, textures->data, textures->raster,
textures->size.y, "textures bits");
}
}
@@ -602,7 +602,7 @@ mem_default_strip_copy_rop2(gx_device * dev,
gs_logical_operation_t lop,
uint planar_height)
{
- dlprintf("mem_default_strip_copy_rop2 should never be called!\n");
+ dmlprintf(dev->memory, "mem_default_strip_copy_rop2 should never be called!\n");
return gs_error_Fatal;
}
diff --git a/gs/base/gdevfax.c b/gs/base/gdevfax.c
index 3fdb331ab..a67d30da0 100644
--- a/gs/base/gdevfax.c
+++ b/gs/base/gdevfax.c
@@ -202,13 +202,15 @@ gdev_fax_print_strip(gx_device_printer * pdev, FILE * prn_stream,
for (lnum = row_in; ;) {
int status;
- if_debug7('w', "[w]lnum=%d r=0x%lx,0x%lx,0x%lx w=0x%lx,0x%lx,0x%lx\n", lnum,
- (ulong)in, (ulong)r.ptr, (ulong)r.limit,
- (ulong)out, (ulong)w.ptr, (ulong)w.limit);
+ if_debug7m('w', mem,
+ "[w]lnum=%d r=0x%lx,0x%lx,0x%lx w=0x%lx,0x%lx,0x%lx\n", lnum,
+ (ulong)in, (ulong)r.ptr, (ulong)r.limit,
+ (ulong)out, (ulong)w.ptr, (ulong)w.limit);
status = temp->process(ss, &r, &w, lnum == row_end);
- if_debug7('w', "...%d, r=0x%lx,0x%lx,0x%lx w=0x%lx,0x%lx,0x%lx\n", status,
- (ulong)in, (ulong)r.ptr, (ulong)r.limit,
- (ulong)out, (ulong)w.ptr, (ulong)w.limit);
+ if_debug7m('w', mem,
+ "...%d, r=0x%lx,0x%lx,0x%lx w=0x%lx,0x%lx,0x%lx\n", status,
+ (ulong)in, (ulong)r.ptr, (ulong)r.limit,
+ (ulong)out, (ulong)w.ptr, (ulong)w.limit);
switch (status) {
case 0: /* need more input data */
if (lnum == row_end)
diff --git a/gs/base/gdevhl7x.c b/gs/base/gdevhl7x.c
index 166eb41a2..fb58a8721 100644
--- a/gs/base/gdevhl7x.c
+++ b/gs/base/gdevhl7x.c
@@ -925,7 +925,7 @@ static void addByte(ByteList *list,Byte value ) {
if (list->current < list->maxSize)
list->data[list->current++] = value;
else
- errprintf_nomem("Could not add byte to command\n");
+ eprintf("Could not add byte to command\n");
}
/*
@@ -939,7 +939,7 @@ static void addArray(ByteList *list, Byte *source, short nb){
list->current += nb;
}
else
- errprintf_nomem("Could not add byte array to command\n");
+ eprintf("Could not add byte array to command\n");
}
/*
@@ -957,7 +957,7 @@ static void addNBytes(ByteList * list, Byte value, short nb){
list->current += nb;
}
else
- errprintf_nomem("Could not add %d bytes to command\n",nb);
+ eprintf1("Could not add %d bytes to command\n",nb);
}
/*
diff --git a/gs/base/gdevifno.c b/gs/base/gdevifno.c
index 1434efb66..0982623c9 100644
--- a/gs/base/gdevifno.c
+++ b/gs/base/gdevifno.c
@@ -287,7 +287,7 @@ inferno_print_page(gx_device_printer *pdev, FILE *f)
gsbpl = gdev_prn_raster(pdev);
if(gsbpl > 16384) { /* == 8192 dots across */
- errprintf(pdev->memory, "bitmap far too wide for inferno\n");
+ emprintf(pdev->memory, "bitmap far too wide for inferno\n");
return_error(gs_error_Fatal);
}
@@ -304,13 +304,13 @@ inferno_print_page(gx_device_printer *pdev, FILE *f)
bpl = bytesperline(r, ldepth);
w = initwriteimage(f, r, ldepth, bdev->memory);
if(w == nil) {
- errprintf(pdev->memory, "initwriteimage failed\n");
+ emprintf(pdev->memory, "initwriteimage failed\n");
return_error(gs_error_Fatal);
}
buf = gs_alloc_bytes(bdev->memory, gsbpl, "inferno line buffer");
if(buf == NULL) {
- errprintf(pdev->memory, "couldn't allocate line buffer\n");
+ emprintf(pdev->memory, "couldn't allocate line buffer\n");
return_error(gs_error_VMerror);
}
@@ -463,7 +463,7 @@ addbuf(WImage *w, uchar *buf, int nbuf)
int n;
if(buf == nil || w->outp+nbuf > w->eout) {
if(w->loutp==w->outbuf){ /* can't really happen -- we checked line length above */
- errprintf_nomem("buffer too small for line\n");
+ eprintf("buffer too small for line\n");
return ERROR;
}
n=w->loutp-w->outbuf;
@@ -667,7 +667,7 @@ initwriteimage(FILE *f, Rectangle r, int ldepth, gs_memory_t *mem)
bpl = bytesperline(r, ldepth);
if(r.max.y <= r.min.y || r.max.x <= r.min.x || bpl <= 0) {
- errprintf(mem, "bad rectangle, ldepth");
+ emprintf(mem, "bad rectangle, ldepth");
return nil;
}
@@ -707,7 +707,7 @@ writeimageblock(WImage *w, uchar *data, int ndata, gs_memory_t *mem)
return ERROR;
addbuf(w, nil, 0);
if(w->r.min.y != w->origr.max.y) {
- errprintf(mem, "not enough data supplied to writeimage\n");
+ emprintf(mem, "not enough data supplied to writeimage\n");
}
gs_free_object(mem, w, "inferno image");
return 0;
diff --git a/gs/base/gdevijs.c b/gs/base/gdevijs.c
index c97dbd627..e3105c108 100644
--- a/gs/base/gdevijs.c
+++ b/gs/base/gdevijs.c
@@ -1392,7 +1392,7 @@ gsijs_client_set_param(gx_device_ijs *ijsdev, const char *key,
int code = ijs_client_set_param(ijsdev->ctx, 0 /* job id */,
key, value, strlen(value));
if (code < 0)
- dprintf2("ijs: Can't set parameter %s=%s\n", key, value);
+ dmprintf2(ijsdev->memory, "ijs: Can't set parameter %s=%s\n", key, value);
return code;
}
diff --git a/gs/base/gdevjpx.c b/gs/base/gdevjpx.c
index eff86014f..6a0d32c6c 100644
--- a/gs/base/gdevjpx.c
+++ b/gs/base/gdevjpx.c
@@ -167,7 +167,7 @@ jpx_print_page(gx_device_printer * pdev, FILE * prn_stream)
case 8: state.colorspace = gs_jpx_cs_gray; break;
default:
state.colorspace = gs_jpx_cs_gray; /* safest option */
- dlprintf1("unexpected color_info depth %d\n",
+ dmlprintf1(mem, "unexpected color_info depth %d\n",
jdev->color_info.depth);
}
state.bpc = 8; /* currently only 8 bits per component is supported */
diff --git a/gs/base/gdevm1.c b/gs/base/gdevm1.c
index 158a07f25..7868295fe 100644
--- a/gs/base/gdevm1.c
+++ b/gs/base/gdevm1.c
@@ -204,7 +204,7 @@ mem_mono_strip_copy_rop_dev(gx_device * dev, const byte * sdata,
}
#ifdef DEBUG
- if_debug1('b', "final rop=0x%x\n", rop);
+ if_debug1m('b', dev->memory, "final rop=0x%x\n", rop);
#endif
/* Set up transfer parameters. */
@@ -413,7 +413,7 @@ mem_mono_strip_copy_rop_dev(gx_device * dev, const byte * sdata,
#ifdef DEBUG
if (gs_debug_c('B'))
- debug_dump_bitmap(scan_line_base(mdev, y), mdev->raster,
+ debug_dump_bitmap(mdev->memory, scan_line_base(mdev, y), mdev->raster,
height, "final dest bits");
#endif
return 0;
diff --git a/gs/base/gdevm24.c b/gs/base/gdevm24.c
index bf3a2e8b9..2eb04d166 100644
--- a/gs/base/gdevm24.c
+++ b/gs/base/gdevm24.c
@@ -108,7 +108,8 @@ mem_true24_fill_rectangle(gx_device * dev,
declare_unpack_color(r, g, b, color);
declare_scan_ptr(dest);
- if_debug4('b', "[b]device y=%d h=%d x=%d w=%d\n", y + mdev->band_y, h, x, w);
+ if_debug4m('b', dev->memory,
+ "[b]device y=%d h=%d x=%d w=%d\n", y + mdev->band_y, h, x, w);
/*
* In order to avoid testing w > 0 and h > 0 twice, we defer
* executing setup_rect, and use fit_fill_xywh instead of
@@ -469,7 +470,8 @@ mem_true24_copy_color(gx_device * dev,
{
gx_device_memory * const mdev = (gx_device_memory *)dev;
- if_debug1('w', "[w]device y=%d:\n", y + mdev->band_y); /* See siscale.c about 'w'. */
+ if_debug1m('w', dev->memory, "[w]device y=%d:\n",
+ y + mdev->band_y); /* See siscale.c about 'w'. */
fit_copy(dev, base, sourcex, sraster, id, x, y, w, h);
mem_copy_byte_rect(mdev, base, sourcex, sraster, x, y, w, h);
return 0;
diff --git a/gs/base/gdevmr1.c b/gs/base/gdevmr1.c
index 0887e5ba3..4f6a94b6b 100644
--- a/gs/base/gdevmr1.c
+++ b/gs/base/gdevmr1.c
@@ -65,7 +65,7 @@ mem_mono_strip_copy_rop(gx_device * dev, const byte * sdata,
id, scolors, textures, tcolors,
x, y, width, height, phase_x, phase_y, lop);
if (gs_debug_c('B'))
- debug_dump_bitmap(scan_line_base(mdev, y), mdev->raster,
+ debug_dump_bitmap(mdev->memory, scan_line_base(mdev, y), mdev->raster,
height, "initial dest bits");
#endif
diff --git a/gs/base/gdevmr8n.c b/gs/base/gdevmr8n.c
index f70f062d0..b8d18a133 100644
--- a/gs/base/gdevmr8n.c
+++ b/gs/base/gdevmr8n.c
@@ -231,7 +231,7 @@ df: return mem_default_strip_copy_rop(dev,
rop_body_24(const_source, const_texture);
}
if (memcmp(testbuffer, start, bytelen) != 0) {
- eprintf("Failed!\n");
+ emprintf(dev->memory, "Failed!\n");
}
#else
rop_run(&ropper, drow, width);
@@ -277,7 +277,7 @@ df: return mem_default_strip_copy_rop(dev,
rop_body_24(s_pixel, const_texture);
}
if (memcmp(testbuffer, start, bytelen) != 0) {
- eprintf("Failed!\n");
+ emprintf(dev->memory, "Failed!\n");
}
#else
/**** 1-bit source ****/
@@ -329,7 +329,7 @@ df: return mem_default_strip_copy_rop(dev,
}
}
if (memcmp(testbuffer, start, bytelen) != 0) {
- eprintf("Failed!\n");
+ emprintf(dev->memory, "Failed!\n");
}
#else
/**** 8-bit source & dest ****/
@@ -386,7 +386,7 @@ df: return mem_default_strip_copy_rop(dev,
rop_body_24(const_source, t_pixel);
}
if (memcmp(testbuffer, start, bytelen) != 0) {
- eprintf("Failed!\n");
+ emprintf(dev->memory, "Failed!\n");
}
#else
rop_run(&ropper, dptr, left);
@@ -437,7 +437,7 @@ df: return mem_default_strip_copy_rop(dev,
}
}
if (memcmp(testbuffer, start, bytelen) != 0) {
- eprintf("Failed!\n");
+ emprintf(dev->memory, "Failed!\n");
}
#else
/**** 8-bit T & D ****/
@@ -526,7 +526,7 @@ df: return mem_default_strip_copy_rop(dev,
}
}
if (memcmp(testbuffer, start, bytelen) != 0) {
- eprintf("Failed!\n");
+ emprintf(dev->memory, "Failed!\n");
}
#else
rop_run(&ropper, dptr, left);
@@ -576,7 +576,7 @@ df: return mem_default_strip_copy_rop(dev,
}
}
if (memcmp(testbuffer, start, bytelen) != 0) {
- eprintf("Failed!\n");
+ emprintf(dev->memory, "Failed!\n");
}
#else
/**** 8-bit destination ****/
diff --git a/gs/base/gdevnfwd.c b/gs/base/gdevnfwd.c
index ffb7a0de9..a44543843 100644
--- a/gs/base/gdevnfwd.c
+++ b/gs/base/gdevnfwd.c
@@ -1319,12 +1319,12 @@ static void do_device_dump(gx_device *dev, int n)
/* Dump the details of device dev */
for (i = 0; i < n; i++)
- dlprintf(" ");
+ dmlprintf(dev->memory, " ");
if (dev == NULL) {
- dlprintf("NULL\n");
+ dmlprintf(dev->memory, "NULL\n");
return;
}
- dlprintf3("%x(%d) = '%s'\n", dev, dev->rc.ref_count, dev->dname);
+ dmlprintf3(dev->memory, "%x(%d) = '%s'\n", dev, dev->rc.ref_count, dev->dname);
data.n = 0;
do {
@@ -1337,7 +1337,7 @@ static void do_device_dump(gx_device *dev, int n)
void gx_device_dump(gx_device *dev, const char *text)
{
- dlprintf1("%s", text);
+ dmlprintf1(dev->memory, "%s", text);
do_device_dump(dev, 0);
}
#endif
diff --git a/gs/base/gdevp14.c b/gs/base/gdevp14.c
index 266f28fdc..ddc6d55e8 100644
--- a/gs/base/gdevp14.c
+++ b/gs/base/gdevp14.c
@@ -660,8 +660,9 @@ pdf14_ctx_new(gs_int_rect *rect, int n_chan, bool additive, gx_device *dev)
gs_free_object(memory, result, "pdf14_ctx_new");
return NULL;
}
- if_debug4('v', "[v]base buf: %d x %d, %d color channels, %d planes \n",
- buf->rect.q.x, buf->rect.q.y, buf->n_chan, buf->n_planes);
+ if_debug4m('v', memory,
+ "[v]base buf: %d x %d, %d color channels, %d planes\n",
+ buf->rect.q.x, buf->rect.q.y, buf->n_chan, buf->n_planes);
if (buf->data != NULL) {
if (buf->has_tags) {
memset(buf->data, 0, buf->planestride * (buf->n_planes-1));
@@ -731,7 +732,8 @@ pdf14_push_transparency_group(pdf14_ctx *ctx, gs_int_rect *rect,
pdf14_buf *buf, *backdrop;
bool has_shape, has_tags;
- if_debug1('v', "[v]pdf14_push_transparency_group, idle = %d\n", idle);
+ if_debug1m('v', ctx->memory,
+ "[v]pdf14_push_transparency_group, idle = %d\n", idle);
/* todo: fix this hack, which makes all knockout groups isolated.
For the vast majority of files, there won't be any visible
effects, but it still isn't correct. The pixel compositing code
@@ -751,8 +753,9 @@ pdf14_push_transparency_group(pdf14_ctx *ctx, gs_int_rect *rect,
but that will need to be looked at later. */
buf = pdf14_buf_new(rect, has_tags, !isolated, has_shape, idle,
numcomps+1, ctx->memory);
- if_debug4('v', "[v]base buf: %d x %d, %d color channels, %d planes \n",
- buf->rect.q.x, buf->rect.q.y, buf->n_chan, buf->n_planes);
+ if_debug4m('v', ctx->memory,
+ "[v]base buf: %d x %d, %d color channels, %d planes\n",
+ buf->rect.q.x, buf->rect.q.y, buf->n_chan, buf->n_planes);
if (buf == NULL)
return_error(gs_error_VMerror);
buf->isolated = isolated;
@@ -1012,7 +1015,7 @@ exit:
we have softmasks embedded in softmasks */
ctx->smask_blend = true;
}
- if_debug1('v', "[v]pop buf, idle=%d\n", tos->idle);
+ if_debug1m('v', ctx->memory, "[v]pop buf, idle=%d\n", tos->idle);
pdf14_buf_free(tos, ctx->memory);
return 0;
}
@@ -1034,8 +1037,9 @@ pdf14_push_transparency_mask(pdf14_ctx *ctx, gs_int_rect *rect, byte bg_alpha,
pdf14_buf *buf;
unsigned char *curr_ptr, gray;
- if_debug2('v', "[v]pdf14_push_transparency_mask, idle=%d, replacing=%d\n",
- idle, replacing);
+ if_debug2m('v', ctx->memory,
+ "[v]pdf14_push_transparency_mask, idle=%d, replacing=%d\n",
+ idle, replacing);
ctx->smask_depth += 1;
/* An optimization to consider is that if the SubType is Alpha
@@ -1147,7 +1151,8 @@ pdf14_pop_transparency_mask(pdf14_ctx *ctx, gs_imager_state *pis, gx_device *dev
} else {
icc_match = -1;
}
- if_debug1('v', "[v]pdf14_pop_transparency_mask, idle=%d\n", tos->idle);
+ if_debug1m('v', ctx->memory, "[v]pdf14_pop_transparency_mask, idle=%d\n",
+ tos->idle);
ctx->stack = tos->saved;
tos->saved = NULL; /* To avoid issues with GC */
if (tos->mask_stack) {
@@ -1328,7 +1333,7 @@ pdf14_push_transparency_state(gx_device *dev, gs_imager_state *pis)
pdf14_ctx *ctx = pdev->ctx;
pdf14_mask_t *new_mask;
- if_debug0('v', "pdf14_push_transparency_state\n");
+ if_debug0m('v', ctx->memory, "pdf14_push_transparency_state\n");
/* We need to push the current mask buffer */
/* Allocate a new element for the stack.
Don't do anything if there is no mask present.*/
@@ -1356,7 +1361,7 @@ pdf14_pop_transparency_state(gx_device *dev, gs_imager_state *pis)
pdf14_ctx *ctx = pdev->ctx;
pdf14_mask_t *old_mask;
- if_debug0('v', "pdf14_pop_transparency_state\n");
+ if_debug0m('v', ctx->memory, "pdf14_pop_transparency_state\n");
/* rc decrement the current link after we break it from
the list, then free the stack element. Don't do
anything if there is no mask present. */
@@ -1388,8 +1393,8 @@ pdf14_open(gx_device *dev)
pdf14_device *pdev = (pdf14_device *)dev;
gs_int_rect rect;
- if_debug2('v', "[v]pdf14_open: width = %d, height = %d\n",
- dev->width, dev->height);
+ if_debug2m('v', dev->memory, "[v]pdf14_open: width = %d, height = %d\n",
+ dev->width, dev->height);
rect.p.x = 0;
rect.p.y = 0;
rect.q.x = dev->width;
@@ -1546,7 +1551,7 @@ pdf14_put_image(gx_device * dev, gs_imager_state * pis, gx_device * target)
gsicc_rendering_intents_t rendering_intent;
cmm_dev_profile_t *dev_profile;
- if_debug0('v', "[v]pdf14_put_image\n");
+ if_debug0m('v', dev->memory, "[v]pdf14_put_image\n");
rect_intersect(rect, buf->dirty);
x1 = min(pdev->width, rect.q.x);
y1 = min(pdev->height, rect.q.y);
@@ -1724,7 +1729,7 @@ pdf14_cmykspot_put_image(gx_device * dev, gs_imager_state * pis, gx_device * tar
int num_comp = buf->n_chan - 1;
byte *buf_ptr;
- if_debug0('v', "[v]pdf14_cmykspot_put_image\n");
+ if_debug0m('v', dev->memory, "[v]pdf14_cmykspot_put_image\n");
rect_intersect(rect, buf->dirty);
x1 = min(pdev->width, rect.q.x);
y1 = min(pdev->height, rect.q.y);
@@ -1774,7 +1779,7 @@ pdf14_custom_put_image(gx_device * dev, gs_imager_state * pis, gx_device * targe
int x1, y1, width, height;
byte *buf_ptr;
- if_debug0('v', "[v]pdf14_custom_put_image\n");
+ if_debug0m('v', dev->memory, "[v]pdf14_custom_put_image\n");
rect_intersect(rect, buf->dirty);
x1 = min(pdev->width, rect.q.x);
y1 = min(pdev->height, rect.q.y);
@@ -1939,8 +1944,9 @@ pdf14_set_marking_params(gx_device *dev, const gs_imager_state *pis)
pdev->overprint = pis->overprint;
pdev->overprint_mode = pis->overprint_mode;
- if_debug3('v', "[v]set_marking_params, opacity = %g, shape = %g, bm = %d\n",
- pdev->opacity, pdev->shape, pis->blend_mode);
+ if_debug3m('v', dev->memory,
+ "[v]set_marking_params, opacity = %g, shape = %g, bm = %d\n",
+ pdev->opacity, pdev->shape, pis->blend_mode);
}
static void
@@ -2491,10 +2497,11 @@ pdf14_tile_pattern_fill(gx_device * pdev, const gs_imager_state * pis,
if (cpath_intersection.rect_list->list.head != NULL){
curr_clip_rect = cpath_intersection.rect_list->list.head->next;
for( k = 0; k< cpath_intersection.rect_list->list.count; k++){
- if_debug5('v', "[v]pdf14_tile_pattern_fill, (%d, %d), %d x %d pat_id %d \n",
- curr_clip_rect->xmin, curr_clip_rect->ymin,
- curr_clip_rect->xmax-curr_clip_rect->xmin,
- curr_clip_rect->ymax-curr_clip_rect->ymin, ptile->id);
+ if_debug5m('v', pis->memory,
+ "[v]pdf14_tile_pattern_fill, (%d, %d), %d x %d pat_id %d \n",
+ curr_clip_rect->xmin, curr_clip_rect->ymin,
+ curr_clip_rect->xmax-curr_clip_rect->xmin,
+ curr_clip_rect->ymax-curr_clip_rect->ymin, ptile->id);
ok = gx_trans_pattern_fill_rect(curr_clip_rect->xmin, curr_clip_rect->ymin,
curr_clip_rect->xmax, curr_clip_rect->ymax, ptile,
fill_trans_buffer, phase, pdev, pdevc);
@@ -2502,14 +2509,15 @@ pdf14_tile_pattern_fill(gx_device * pdev, const gs_imager_state * pis,
}
} else if (cpath_intersection.rect_list->list.count == 1) {
/* The case when there is just a single rect */
- if_debug5('v', "[v]pdf14_tile_pattern_fill, (%d, %d), %d x %d pat_id %d \n",
- cpath_intersection.rect_list->list.single.xmin,
- cpath_intersection.rect_list->list.single.ymin,
- cpath_intersection.rect_list->list.single.xmax-
- cpath_intersection.rect_list->list.single.xmin,
- cpath_intersection.rect_list->list.single.ymax-
- cpath_intersection.rect_list->list.single.ymin,
- ptile->id);
+ if_debug5m('v', pis->memory,
+ "[v]pdf14_tile_pattern_fill, (%d, %d), %d x %d pat_id %d \n",
+ cpath_intersection.rect_list->list.single.xmin,
+ cpath_intersection.rect_list->list.single.ymin,
+ cpath_intersection.rect_list->list.single.xmax-
+ cpath_intersection.rect_list->list.single.xmin,
+ cpath_intersection.rect_list->list.single.ymax-
+ cpath_intersection.rect_list->list.single.ymin,
+ ptile->id);
ok = gx_trans_pattern_fill_rect(cpath_intersection.rect_list->list.single.xmin,
cpath_intersection.rect_list->list.single.ymin,
cpath_intersection.rect_list->list.single.xmax,
@@ -2714,7 +2722,7 @@ static void
pdf14_set_params(gs_imager_state * pis, gx_device * dev,
const gs_pdf14trans_params_t * pparams)
{
- if_debug0('v', "[v]pdf14_set_params\n");
+ if_debug0m('v', dev->memory, "[v]pdf14_set_params\n");
if (pparams->changed & PDF14_SET_BLEND_MODE)
pis->blend_mode = pparams->blend_mode;
if (pparams->changed & PDF14_SET_TEXT_KNOCKOUT)
@@ -2803,7 +2811,7 @@ pdf14_disable_device(gx_device * dev)
{
gx_device_forward * pdev = (gx_device_forward *)dev;
- if_debug0('v', "[v]pdf14_disable_device\n");
+ if_debug0m('v', dev->memory, "[v]pdf14_disable_device\n");
dev->color_info = pdev->target->color_info;
pdf14_forward_device_procs(dev);
set_dev_proc(dev, create_compositor, pdf14_forward_create_compositor);
@@ -2980,7 +2988,7 @@ pdf14_recreate_device(gs_memory_t *mem, gs_imager_state * pis,
pdf14_device temp_dev_proto;
int code;
- if_debug0('v', "[v]pdf14_recreate_device\n");
+ if_debug0m('v', dev->memory, "[v]pdf14_recreate_device\n");
/*
* We will not use the entire prototype device but we will set the
@@ -3024,7 +3032,8 @@ gx_update_pdf14_compositor(gx_device * pdev, gs_imager_state * pis,
break;
case PDF14_POP_DEVICE:
if (!(params.is_pattern)) {
- if_debug0('v', "[v]gx_update_pdf14_compositor(PDF14_POP_DEVICE)\n");
+ if_debug0m('v', pdev->memory,
+ "[v]gx_update_pdf14_compositor(PDF14_POP_DEVICE)\n");
pis->get_cmap_procs = p14dev->save_get_cmap_procs;
gx_set_cmap_procs(pis, p14dev->target);
/* Send image out raster data to output device */
@@ -3164,7 +3173,7 @@ pdf14_text_begin(gx_device * dev, gs_imager_state * pis,
int code;
gs_text_enum_t *penum;
- if_debug0('v', "[v]pdf14_text_begin\n");
+ if_debug0m('v', memory, "[v]pdf14_text_begin\n");
pdf14_set_marking_params(dev, pis);
code = gx_default_text_begin(dev, pis, text, font, path, pdcolor, pcpath,
memory, &penum);
@@ -3401,8 +3410,9 @@ pdf14_begin_transparency_group(gx_device *dev,
code = compute_group_device_int_rect(pdev, &rect, pbbox, pis);
if (code < 0)
return code;
- if_debug4('v', "[v]pdf14_begin_transparency_group, I = %d, K = %d, alpha = %g, bm = %d\n",
- ptgp->Isolated, ptgp->Knockout, alpha, pis->blend_mode);
+ if_debug4m('v', pdev->memory,
+ "[v]pdf14_begin_transparency_group, I = %d, K = %d, alpha = %g, bm = %d\n",
+ ptgp->Isolated, ptgp->Knockout, alpha, pis->blend_mode);
/* If the group color is unknown then use the current device profile. Note
that if we have a sep device there may not be a profile */
if (ptgp->group_color == UNKNOWN){
@@ -3457,7 +3467,8 @@ pdf14_begin_transparency_group(gx_device *dev,
}
code = pdf14_update_device_color_procs(dev, group_color,
ptgp->icc_hashcode, pis, curr_profile);
- if_debug0('v', "[v]Transparency group color space update\n");
+ if_debug0m('v', dev->memory,
+ "[v]Transparency group color space update\n");
} else {
code = 0;
/* Sep devices always blend in the components */
@@ -3490,7 +3501,7 @@ pdf14_end_transparency_group(gx_device *dev,
code = dev_proc(dev, get_profile)(dev, &dev_profile);
gsicc_extract_profile(GS_UNKNOWN_TAG, dev_profile, &group_profile,
&rendering_intent);
- if_debug0('v', "[v]pdf14_end_transparency_group\n");
+ if_debug0m('v', dev->memory, "[v]pdf14_end_transparency_group\n");
vd_get_dc('c');
vd_set_shift(0, 0);
vd_set_scale(0.01);
@@ -3571,7 +3582,7 @@ pdf14_update_device_color_procs(gx_device *dev,
/* This should not occur */
return_error(gs_error_undefined);
}
- if_debug0('v', "[v]pdf14_update_device_color_procs\n");
+ if_debug0m('v', dev->memory, "[v]pdf14_update_device_color_procs\n");
/* Update the device procs at this stage. Many of the procs are based upon
the color space of the device. We want to remain in the color space
@@ -3684,8 +3695,9 @@ pdf14_update_device_color_procs(gx_device *dev,
return_error(gs_error_rangecheck);
break;
}
- if_debug2('v', "[v]pdf14_update_device_color_procs,num_components_old = %d num_components_new = %d\n",
- pdev->color_info.num_components,new_num_comps);
+ if_debug2m('v', pdev->memory,
+ "[v]pdf14_update_device_color_procs,num_components_old = %d num_components_new = %d\n",
+ pdev->color_info.num_components,new_num_comps);
/* Save the old information */
parent_color_info->get_cmap_procs = pis->get_cmap_procs;
@@ -3790,7 +3802,7 @@ pdf14_update_device_color_procs_push_c(gx_device *dev,
return gs_rethrow(gs_error_undefinedresult,
"Missing ICC data");
}
- if_debug0('v', "[v]pdf14_update_device_color_procs_push_c\n");
+ if_debug0m('v', cldev->memory, "[v]pdf14_update_device_color_procs_push_c\n");
/* Check if we need to alter the device procs at this stage. Many of the procs
are based upon the color space of the device. We want to remain in the
color space defined by the color space of the soft mask or transparency
@@ -3904,8 +3916,9 @@ pdf14_update_device_color_procs_push_c(gx_device *dev,
if (has_tags) {
new_depth += 8;
}
- if_debug2('v', "[v]pdf14_update_device_color_procs_push_c,num_components_old = %d num_components_new = %d\n",
- pdev->color_info.num_components,new_num_comps);
+ if_debug2m('v', pdev->memory,
+ "[v]pdf14_update_device_color_procs_push_c,num_components_old = %d num_components_new = %d\n",
+ pdev->color_info.num_components,new_num_comps);
/* Set new information in the device */
pis->get_cmap_procs = pdf14_get_cmap_procs_group;
gx_set_cmap_procs(pis, dev);
@@ -3958,7 +3971,7 @@ pdf14_update_device_color_procs_push_c(gx_device *dev,
}
return(1); /* Lets us detect that we did do an update */
}
- if_debug0('v', "[v]procs not updated\n");
+ if_debug0m('v', pdev->memory, "[v]procs not updated\n");
return 0;
}
@@ -3970,12 +3983,13 @@ pdf14_update_device_color_procs_pop_c(gx_device *dev,gs_imager_state *pis)
pdf14_parent_color_t *parent_color = pdev->trans_group_parent_cmap_procs;
gx_device_clist_writer * cldev = (gx_device_clist_writer *)pdev->pclist_device;
- if_debug0('v', "[v]pdf14_update_device_color_procs_pop_c\n");
+ if_debug0m('v', pdev->memory, "[v]pdf14_update_device_color_procs_pop_c\n");
/* The color procs are always pushed. Simply restore them. */
if (!(parent_color->parent_color_mapping_procs == NULL &&
parent_color->parent_color_comp_index == NULL)) {
- if_debug2('v', "[v]pdf14_update_device_color_procs_pop_c,num_components_old = %d num_components_new = %d\n",
- pdev->color_info.num_components,parent_color->num_components);
+ if_debug2m('v', pdev->memory,
+ "[v]pdf14_update_device_color_procs_pop_c,num_components_old = %d num_components_new = %d\n",
+ pdev->color_info.num_components,parent_color->num_components);
pis->get_cmap_procs = parent_color->get_cmap_procs;
gx_set_cmap_procs(pis, dev);
pdev->procs.get_color_mapping_procs = parent_color->parent_color_mapping_procs;
@@ -4013,9 +4027,9 @@ pdf14_update_device_color_procs_pop_c(gx_device *dev,gs_imager_state *pis)
are closely integrated with pdf14_pop_parent_color and pdf14_push_parent color.
All four are used only on the clist writer side of the transparency code */
dev->icc_struct->device_profile[0] = parent_color->icc_profile;
- if_debug0('v', "[v]procs updated\n");
+ if_debug0m('v', dev->memory, "[v]procs updated\n");
} else {
- if_debug0('v', "[v]pdf14_update_device_color_procs_pop_c ERROR \n");
+ if_debug0m('v', dev->memory, "[v]pdf14_update_device_color_procs_pop_c ERROR \n");
}
return 0;
}
@@ -4038,7 +4052,7 @@ pdf14_push_parent_color(gx_device *dev, const gs_imager_state *pis)
code = dev_proc(dev, get_profile)(dev, &dev_profile);
gsicc_extract_profile(GS_UNKNOWN_TAG, dev_profile, &icc_profile,
&rendering_intent);
- if_debug0('v', "[v]pdf14_push_parent_color\n");
+ if_debug0m('v', dev->memory, "[v]pdf14_push_parent_color\n");
/* Allocate a new one */
new_parent_color = gs_alloc_struct(dev->memory, pdf14_parent_color_t,
&st_pdf14_clr,"pdf14_clr_new");
@@ -4084,11 +4098,11 @@ pdf14_pop_parent_color(gx_device *dev, const gs_imager_state *pis)
pdf14_device *pdev = (pdf14_device *)dev;
pdf14_parent_color_t *old_parent_color_info = pdev->trans_group_parent_cmap_procs;
- if_debug0('v', "[v]pdf14_pop_parent_color\n");
- /* We need to compliment pdf14_push_parent color */
- if (old_parent_color_info->icc_profile != NULL)
+ if_debug0m('v', dev->memory, "[v]pdf14_pop_parent_color\n");
+ /* We need to compliment pdf14_push_parent color */
+ if (old_parent_color_info->icc_profile != NULL)
rc_decrement(old_parent_color_info->icc_profile, "pdf14_pop_parent_color");
- /* Update the link */
+ /* Update the link */
pdev->trans_group_parent_cmap_procs = old_parent_color_info->previous;
/* Free the old one */
gs_free_object(dev->memory, old_parent_color_info, "pdf14_clr_free");
@@ -4116,7 +4130,8 @@ pdf14_begin_transparency_mask(gx_device *dev,
return code;
if (ptmp->Background_components)
bg_alpha = (int)(255 * ptmp->GrayBackground + 0.5);
- if_debug1('v', "pdf14_begin_transparency_mask, bg_alpha = %d\n", bg_alpha);
+ if_debug1m('v', dev->memory,
+ "pdf14_begin_transparency_mask, bg_alpha = %d\n", bg_alpha);
memcpy(transfer_fn, ptmp->transfer_fn, size_of(ptmp->transfer_fn));
/* If the group color is unknown, then we must use the previous group color
space or the device process color space */
@@ -4172,7 +4187,7 @@ pdf14_end_transparency_mask(gx_device *dev, gs_imager_state *pis)
pdf14_parent_color_t *parent_color;
int ok;
- if_debug0('v', "pdf14_end_transparency_mask\n");
+ if_debug0m('v', dev->memory, "pdf14_end_transparency_mask\n");
ok = pdf14_pop_transparency_mask(pdev->ctx, pis, dev);
#ifdef DEBUG
pdf14_debug_mask_stack_state(pdev->ctx);
@@ -4254,13 +4269,15 @@ pdf14_mark_fill_rectangle(gx_device * dev, int x, int y, int w, int h,
/* NB: gx_color_index is 4 or 8 bytes */
#if 0
if (sizeof(color) <= sizeof(ulong))
- if_debug8('v', "[v]pdf14_mark_fill_rectangle, (%d, %d), %d x %d color = %lx bm %d, nc %d, overprint %d\n",
- x, y, w, h, (ulong)color, blend_mode, num_chan, overprint);
+ if_debug8m('v', dev->memory,
+ "[v]pdf14_mark_fill_rectangle, (%d, %d), %d x %d color = %lx bm %d, nc %d, overprint %d\n",
+ x, y, w, h, (ulong)color, blend_mode, num_chan, overprint);
else
- if_debug9('v', "[v]pdf14_mark_fill_rectangle, (%d, %d), %d x %d color = %08lx%08lx bm %d, nc %d, overprint %d\n",
- x, y, w, h,
- (ulong)(color >> 8*(sizeof(color) - sizeof(ulong))), (ulong)color,
- blend_mode, num_chan, overprint);
+ if_debug9m('v', dev->memory,
+ "[v]pdf14_mark_fill_rectangle, (%d, %d), %d x %d color = %08lx%08lx bm %d, nc %d, overprint %d\n",
+ x, y, w, h,
+ (ulong)(color >> 8*(sizeof(color) - sizeof(ulong))), (ulong)color,
+ blend_mode, num_chan, overprint);
#endif
/*
* Unpack the gx_color_index values. Complement the components for subtractive
@@ -4401,13 +4418,15 @@ pdf14_mark_fill_rectangle_ko_simple(gx_device * dev, int x, int y, int w, int h,
return 0;
#if 0
if (sizeof(color) <= sizeof(ulong))
- if_debug6('v', "[v]pdf14_mark_fill_rectangle_ko_simple, (%d, %d), %d x %d color = %lx, nc %d,\n",
- x, y, w, h, (ulong)color, num_chan);
+ if_debug6m('v', dev->memory,
+ "[v]pdf14_mark_fill_rectangle_ko_simple, (%d, %d), %d x %d color = %lx, nc %d,\n",
+ x, y, w, h, (ulong)color, num_chan);
else
- if_debug7('v', "[v]pdf14_mark_fill_rectangle_ko_simple, (%d, %d), %d x %d color = %8lx%08lx, nc %d,\n",
- x, y, w, h,
- (ulong)(color >> 8*(sizeof(color) - sizeof(ulong))), (ulong)color,
- num_chan);
+ if_debug7m('v', dev->memory,
+ "[v]pdf14_mark_fill_rectangle_ko_simple, (%d, %d), %d x %d color = %8lx%08lx, nc %d,\n",
+ x, y, w, h,
+ (ulong)(color >> 8*(sizeof(color) - sizeof(ulong))), (ulong)color,
+ num_chan);
#endif
/*
* Unpack the gx_color_index values. Complement the components for subtractive
@@ -4997,7 +5016,7 @@ gs_pdf14_device_push(gs_memory_t *mem, gs_imager_state * pis,
code = dev_proc(target, get_profile)(target, &dev_profile);
gsicc_extract_profile(GS_UNKNOWN_TAG, dev_profile, &icc_profile,
&rendering_intent);
- if_debug0('v', "[v]gs_pdf14_device_push\n");
+ if_debug0m('v', mem, "[v]gs_pdf14_device_push\n");
code = get_pdf14_device_proto(target, &dev_proto,
&temp_dev_proto, pis, pdf14pct);
if (code < 0)
@@ -5293,8 +5312,9 @@ c_pdf14trans_write(const gs_composite_t * pct, byte * data, uint * psize,
memcpy(data, buf, need - mask_size);
if (mask_size) /* Include the transfer mask data if present */
memcpy(data + need - mask_size, pparams->transfer_fn, mask_size);
- if_debug3('v', "[v] c_pdf14trans_write: opcode = %s mask_id=%d need = %d\n",
- pdf14_opcode_names[opcode], mask_id, need);
+ if_debug3m('v', cdev->memory,
+ "[v] c_pdf14trans_write: opcode = %s mask_id=%d need = %d\n",
+ pdf14_opcode_names[opcode], mask_id, need);
return 0;
}
@@ -5328,8 +5348,8 @@ c_pdf14trans_read(gs_composite_t * * ppct, const byte * data,
/* Read PDF 1.4 compositor data from the clist */
params.pdf14_op = *data++;
- if_debug2('v', "[v] c_pdf14trans_read: opcode = %s avail = %d",
- pdf14_opcode_names[params.pdf14_op], size);
+ if_debug2m('v', mem, "[v] c_pdf14trans_read: opcode = %s avail = %d",
+ pdf14_opcode_names[params.pdf14_op], size);
memset(&params.ctm, 0, sizeof(params.ctm));
switch (params.pdf14_op) {
default: /* Should not occur. */
@@ -5435,7 +5455,7 @@ c_pdf14trans_read(gs_composite_t * * ppct, const byte * data,
if (code < 0)
return code;
used = data - start;
- if_debug2('v', " mask_id=%d used = %d\n", params.mask_id, used);
+ if_debug2m('v', mem, " mask_id=%d used = %d\n", params.mask_id, used);
/* If we read more than the maximum expected, return a rangecheck error */
if ( used + 3 > MAX_CLIST_COMPOSITOR_SIZE )
@@ -5453,9 +5473,9 @@ c_pdf14trans_adjust_ctm(gs_composite_t * pct0, int x0, int y0, gs_imager_state *
gs_pdf14trans_t *pct = (gs_pdf14trans_t *)pct0;
gs_matrix mat = pct->params.ctm;
- if_debug6('L', " [%g %g %g %g %g %g]\n",
- mat.xx, mat.xy, mat.yx, mat.yy,
- mat.tx, mat.ty);
+ if_debug6m('L', pis->memory, " [%g %g %g %g %g %g]\n",
+ mat.xx, mat.xy, mat.yx, mat.yy,
+ mat.tx, mat.ty);
mat.tx -= x0;
mat.ty -= y0;
gs_imager_setmatrix(pis, &mat);
@@ -6075,7 +6095,7 @@ pdf14_create_clist_device(gs_memory_t *mem, gs_imager_state * pis,
code = dev_proc(target, get_profile)(target, &dev_profile);
gsicc_extract_profile(GS_UNKNOWN_TAG, dev_profile, &target_profile,
&rendering_intent);
- if_debug0('v', "[v]pdf14_create_clist_device\n");
+ if_debug0m('v', pis->memory, "[v]pdf14_create_clist_device\n");
code = get_pdf14_clist_device_proto(target, &dev_proto,
&temp_dev_proto, pis, pdf14pct);
if (code < 0)
@@ -6135,7 +6155,7 @@ pdf14_disable_clist_device(gs_memory_t *mem, gs_imager_state * pis,
gx_device_forward * pdev = (gx_device_forward *)dev;
gx_device * target = pdev->target;
- if_debug0('v', "[v]pdf14_disable_clist_device\n");
+ if_debug0m('v', pis->memory, "[v]pdf14_disable_clist_device\n");
/*
* To disable the action of this device, we forward all device
@@ -6165,7 +6185,7 @@ pdf14_recreate_clist_device(gs_memory_t *mem, gs_imager_state * pis,
pdf14_clist_device temp_dev_proto;
int code;
- if_debug0('v', "[v]pdf14_recreate_clist_device\n");
+ if_debug0m('v', pis->memory, "[v]pdf14_recreate_clist_device\n");
/*
* We will not use the entire prototype device but we will set the
* color related info to match the prototype.
@@ -7079,7 +7099,7 @@ pdf14_clist_begin_typed_image(gx_device * dev, const gs_imager_state * pis,
&bbox_out);
if (code < 0) return code;
/* Set up a compositor action for pushing the group */
- if_debug0('v', "[v]Pushing special trans group for image\n");
+ if_debug0m('v', pis->memory, "[v]Pushing special trans group for image\n");
tgp.Isolated = true;
tgp.Knockout = false;
tgp.mask_id = 0;
@@ -7211,7 +7231,9 @@ c_pdf14trans_clist_write_update(const gs_composite_t * pcte, gx_device * dev,
softmask group through which this transparency
group must be rendered. Store it now. */
pdf14pct_noconst->params.mask_id = cdev->mask_id;
- if_debug1('v', "[v]c_pdf14trans_clist_write_update group mask_id=%d \n", cdev->mask_id);
+ if_debug1m('v', pis->memory,
+ "[v]c_pdf14trans_clist_write_update group mask_id=%d \n",
+ cdev->mask_id);
}
break;
case PDF14_END_TRANS_GROUP:
@@ -7229,7 +7251,9 @@ c_pdf14trans_clist_write_update(const gs_composite_t * pcte, gx_device * dev,
pdf14pct_noconst = (gs_pdf14trans_t *) pcte;
pdf14pct_noconst->params.mask_id = cdev->mask_id;
- if_debug1('v', "[v]c_pdf14trans_clist_write_update mask mask_id=%d \n", cdev->mask_id);
+ if_debug1m('v', pis->memory,
+ "[v]c_pdf14trans_clist_write_update mask mask_id=%d \n",
+ cdev->mask_id);
}
break;
case PDF14_END_TRANS_MASK:
@@ -7569,8 +7593,9 @@ pdf14_increment_smask_color(gs_imager_state * pis, gx_device * dev)
}
if (pdev->smaskcolor != NULL) {
pdev->smaskcolor->ref_count++;
- if_debug1(gs_debug_flag_icc,"[icc] Increment smask color now %d\n",
- pdev->smaskcolor->ref_count);
+ if_debug1m(gs_debug_flag_icc, dev->memory,
+ "[icc] Increment smask color now %d\n",
+ pdev->smaskcolor->ref_count);
} else {
/* Allocate and swap out the current profiles. The softmask
profiles should already be in place */
@@ -7592,8 +7617,8 @@ pdf14_increment_smask_color(gs_imager_state * pis, gx_device * dev)
pis->icc_manager->default_rgb = smask_profiles->smask_rgb;
pis->icc_manager->default_cmyk = smask_profiles->smask_cmyk;
pis->icc_manager->smask_profiles->swapped = true;
- if_debug0(gs_debug_flag_icc,
- "[icc] Initial creation of smask color. Ref count 1\n");
+ if_debug0m(gs_debug_flag_icc, pis->memory,
+ "[icc] Initial creation of smask color. Ref count 1\n");
pdev->smaskcolor->ref_count = 1;
/* We also need to update the profile that is currently in the
color spaces of the graphic state. Otherwise this can be
@@ -7652,16 +7677,17 @@ pdf14_decrement_smask_color(gs_imager_state * pis, gx_device * dev)
}
if (smaskcolor != NULL) {
smaskcolor->ref_count--;
- if_debug1(gs_debug_flag_icc,"[icc] Decrement smask color. Now %d\n",
- smaskcolor->ref_count);
+ if_debug1m(gs_debug_flag_icc, pis->memory,
+ "[icc] Decrement smask color. Now %d\n",
+ smaskcolor->ref_count);
if (smaskcolor->ref_count == 0) {
- if_debug0(gs_debug_flag_icc,"[icc] Reset smask color.\n");
+ if_debug0m(gs_debug_flag_icc, pis->memory, "[icc] Reset smask color.\n");
/* Lets return the profiles and clean up */
/* First see if we need to "reset" the profiles that are in
the graphic state */
if (pis->is_gstate) {
gs_state *pgs = (gs_state*) pis;
- if_debug0(gs_debug_flag_icc, "[icc] Reseting graphic state color spaces\n");
+ if_debug0m(gs_debug_flag_icc, pis->memory, "[icc] Reseting graphic state color spaces\n");
for (k = 0; k < 2; k++) {
gs_color_space *pcs = pgs->color[k].color_space;
cmm_profile_t *profile = pcs->cmm_icc_profile_data;
@@ -7736,9 +7762,9 @@ dump_mask_stack(pdf14_mask_t *mask_stack)
int level = 0;
while (curr_mask != NULL) {
- if_debug1('v', "[v]mask_level, %d\n", level);
- if_debug1('v', "[v]mask_buf, %x\n", curr_mask->rc_mask->mask_buf);
- if_debug1('v', "[v]rc_count, %d\n", curr_mask->rc_mask->rc);
+ if_debug1m('v', curr_mask->memory, "[v]mask_level, %d\n", level);
+ if_debug1m('v', curr_mask->memory, "[v]mask_buf, %x\n", curr_mask->rc_mask->mask_buf);
+ if_debug1m('v', curr_mask->memory, "[v]rc_count, %d\n", curr_mask->rc_mask->rc);
level++;
curr_mask = curr_mask->previous;
}
@@ -7748,13 +7774,13 @@ dump_mask_stack(pdf14_mask_t *mask_stack)
static void
pdf14_debug_mask_stack_state(pdf14_ctx *ctx)
{
- if_debug1('v', "[v]ctx_maskstack, %x\n", ctx->mask_stack);
+ if_debug1m('v', ctx->memory, "[v]ctx_maskstack, %x\n", ctx->mask_stack);
if (ctx->mask_stack != NULL) {
dump_mask_stack(ctx->mask_stack);
}
- if_debug1('v', "[v]ctx_stack, %x\n", ctx->stack);
+ if_debug1m('v', ctx->memory, "[v]ctx_stack, %x\n", ctx->stack);
if (ctx->stack != NULL) {
- if_debug1('v', "[v]ctx_stack_maskstack, %x\n", ctx->stack->mask_stack);
+ if_debug1m('v', ctx->memory, "[v]ctx_stack_maskstack, %x\n", ctx->stack->mask_stack);
if (ctx->stack->mask_stack != NULL) {
dump_mask_stack(ctx->stack->mask_stack);
}
diff --git a/gs/base/gdevpbm.c b/gs/base/gdevpbm.c
index e1183f81e..790345a23 100644
--- a/gs/base/gdevpbm.c
+++ b/gs/base/gdevpbm.c
@@ -471,18 +471,18 @@ ppm_put_params(gx_device * pdev, gs_param_list * plist)
if (debug_print_OutputIntent) {
int i, j;
- dlprintf1("%d strings:\n", intent.size);
+ dmlprintf1(pdev->memory, "%d strings:\n", intent.size);
for (i = 0; i < intent.size; i++) {
const gs_param_string *s = &intent.data[i];
- dlprintf2(" %d: size %d:", i, s->size);
+ dmlprintf2(pdev->memory, " %d: size %d:", i, s->size);
if (i < 4) {
for (j = 0; j < s->size; j++)
- dlprintf1("%c", s->data[j]);
+ dmlprintf1(pdev->memory, "%c", s->data[j]);
} else {
for (j = 0; j < s->size; j++)
- dlprintf1(" %02x", s->data[j]);
+ dmlprintf1(pdev->memory, " %02x", s->data[j]);
}
- dlprintf("\n");
+ dmlprintf(pdev->memory, "\n");
}
}
}
@@ -1242,10 +1242,10 @@ psm_print_page(gx_device_printer * pdev, FILE * pstream)
memset(data, 0, raster);
#ifdef DEBUG
if (plane == 0)
- if_debug4(':',
- "[:]%4d - %4d mask = 0x%lx, slow_rop = %d\n",
- lnum, band_end - 1, (ulong)color_usage.or,
- color_usage.slow_rop);
+ if_debug4m(':', pdev->memory,
+ "[:]%4d - %4d mask = 0x%lx, slow_rop = %d\n",
+ lnum, band_end - 1, (ulong)color_usage.or,
+ color_usage.slow_rop);
#endif
}
if (marked) {
diff --git a/gs/base/gdevpdf.c b/gs/base/gdevpdf.c
index ec6b73f7f..e03790f2f 100644
--- a/gs/base/gdevpdf.c
+++ b/gs/base/gdevpdf.c
@@ -1817,23 +1817,23 @@ static int pdf_linearise(gx_device_pdf *pdev, pdf_linearisation_t *linear_params
write_hint_stream(linear_params, (unsigned int *)&j, 16);
write_hint_stream(linear_params, (unsigned int *)&j, 16);
- dprintf1("LeastObjectsPerPage %d\n", linear_params->PageHintHeader.LeastObjectsPerPage);
- dprintf1("Page 1 Offset %ld\n", pdev->ResourceUsage[pdev->pages[0].Page->id].LinearisedOffset);
- dprintf1("ObjectNumBits %d\n", linear_params->PageHintHeader.ObjectNumBits);
- dprintf1("LeastPageLength %d\n", linear_params->PageHintHeader.LeastPageLength);
- dprintf1("MostPagelength %d\n", linear_params->PageHintHeader.MostPageLength);
- dprintf1("PaegLengthNumBits %d\n", linear_params->PageHintHeader.PageLengthNumBits);
- dprintf1("LeastPageOffset %d\n", linear_params->PageHintHeader.LeastPageOffset);
- dprintf1("MostPageOffset %d\n", linear_params->PageHintHeader.MostPageOffset);
- dprintf1("PageOffsetNumBits %d\n", linear_params->PageHintHeader.PageOffsetNumBits);
- dprintf1("LeastContentLength %d\n", linear_params->PageHintHeader.LeastContentLength);
- dprintf1("MostContentLength %d\n", linear_params->PageHintHeader.MostContentLength);
- dprintf1("COntentLengthNumBits %d\n", linear_params->PageHintHeader.ContentLengthNumBits);
- dprintf1("MostSharedObjects %d\n", linear_params->PageHintHeader.MostSharedObjects);
- dprintf1("LargetsSharedObject %d\n", linear_params->PageHintHeader.LargestSharedObject);
- dprintf1("SharedObjectNumBits %d\n", linear_params->PageHintHeader.SharedObjectNumBits);
- dprintf("Position Numerator 1\n");
- dprintf("Position Denominator 1\n\n");
+ dmprintf1(pdev->pdf_memory, "LeastObjectsPerPage %d\n", linear_params->PageHintHeader.LeastObjectsPerPage);
+ dmprintf1(pdev->pdf_memory, "Page 1 Offset %ld\n", pdev->ResourceUsage[pdev->pages[0].Page->id].LinearisedOffset);
+ dmprintf1(pdev->pdf_memory, "ObjectNumBits %d\n", linear_params->PageHintHeader.ObjectNumBits);
+ dmprintf1(pdev->pdf_memory, "LeastPageLength %d\n", linear_params->PageHintHeader.LeastPageLength);
+ dmprintf1(pdev->pdf_memory, "MostPagelength %d\n", linear_params->PageHintHeader.MostPageLength);
+ dmprintf1(pdev->pdf_memory, "PaegLengthNumBits %d\n", linear_params->PageHintHeader.PageLengthNumBits);
+ dmprintf1(pdev->pdf_memory, "LeastPageOffset %d\n", linear_params->PageHintHeader.LeastPageOffset);
+ dmprintf1(pdev->pdf_memory, "MostPageOffset %d\n", linear_params->PageHintHeader.MostPageOffset);
+ dmprintf1(pdev->pdf_memory, "PageOffsetNumBits %d\n", linear_params->PageHintHeader.PageOffsetNumBits);
+ dmprintf1(pdev->pdf_memory, "LeastContentLength %d\n", linear_params->PageHintHeader.LeastContentLength);
+ dmprintf1(pdev->pdf_memory, "MostContentLength %d\n", linear_params->PageHintHeader.MostContentLength);
+ dmprintf1(pdev->pdf_memory, "COntentLengthNumBits %d\n", linear_params->PageHintHeader.ContentLengthNumBits);
+ dmprintf1(pdev->pdf_memory, "MostSharedObjects %d\n", linear_params->PageHintHeader.MostSharedObjects);
+ dmprintf1(pdev->pdf_memory, "LargetsSharedObject %d\n", linear_params->PageHintHeader.LargestSharedObject);
+ dmprintf1(pdev->pdf_memory, "SharedObjectNumBits %d\n", linear_params->PageHintHeader.SharedObjectNumBits);
+ dmprintf(pdev->pdf_memory, "Position Numerator 1\n");
+ dmprintf(pdev->pdf_memory, "Position Denominator 1\n\n");
for (i=0;i < pdev->next_page;i++) {
page_hint_stream_t *hint = &linear_params->PageHints[i];
@@ -1841,7 +1841,7 @@ static int pdf_linearise(gx_device_pdf *pdev, pdf_linearisation_t *linear_params
Num = hint->NumUniqueObjects - linear_params->PageHintHeader.LeastObjectsPerPage;
write_hint_stream(linear_params, (unsigned int *)&Num, linear_params->PageHintHeader.ObjectNumBits);
- dprintf2("Page %d NumUniqueObjects %d\n", i, Num);
+ dmprintf2(pdev->pdf_memory, "Page %d NumUniqueObjects %d\n", i, Num);
}
for (i=0;i < pdev->next_page;i++) {
page_hint_stream_t *hint = &linear_params->PageHints[i];
@@ -1849,18 +1849,18 @@ static int pdf_linearise(gx_device_pdf *pdev, pdf_linearisation_t *linear_params
Num = hint->PageLength - linear_params->PageHintHeader.LeastPageLength;
write_hint_stream(linear_params, (unsigned int *)&Num, linear_params->PageHintHeader.PageLengthNumBits);
- dprintf2("Page %d PageLength %d\n", i, Num);
+ dmprintf2(pdev->pdf_memory, "Page %d PageLength %d\n", i, Num);
}
for (i=0;i < pdev->next_page;i++) {
page_hint_stream_t *hint = &linear_params->PageHints[i];
if (i == 0) {
write_hint_stream(linear_params, (unsigned int *)&i, linear_params->PageHintHeader.SharedObjectNumBits);
- dprintf2("Page %d NumSharedObjects %d\n", i, 1);
+ dmprintf2(pdev->pdf_memory, "Page %d NumSharedObjects %d\n", i, 1);
}
else {
write_hint_stream(linear_params, (unsigned int *)&hint->NumSharedObjects, linear_params->PageHintHeader.SharedObjectNumBits);
- dprintf2("Page %d NumSharedObjects %d\n", i, hint->NumSharedObjects);
+ dmprintf2(pdev->pdf_memory, "Page %d NumSharedObjects %d\n", i, hint->NumSharedObjects);
}
}
for (i=1;i < pdev->next_page;i++) {
@@ -1868,7 +1868,7 @@ static int pdf_linearise(gx_device_pdf *pdev, pdf_linearisation_t *linear_params
for (j=0;j < hint->NumSharedObjects;j++) {
write_hint_stream(linear_params, (unsigned int *)&hint->SharedObjectRef[j], linear_params->PageHintHeader.SharedObjectNumBits);
- dprintf3("Page %d SharedObject %d ObjectRef %d\n", i, j, hint->SharedObjectRef[j]);
+ dmprintf3(pdev->pdf_memory, "Page %d SharedObject %d ObjectRef %d\n", i, j, hint->SharedObjectRef[j]);
}
}
j = 1;
@@ -1877,7 +1877,7 @@ static int pdf_linearise(gx_device_pdf *pdev, pdf_linearisation_t *linear_params
for (j=0;j < hint->NumSharedObjects;j++) {
write_hint_stream(linear_params, (unsigned int *)&j, 1);
- dprintf2("Page %d SharedObject %d Position Numerator 1\n", i, j);
+ dmprintf2(pdev->pdf_memory, "Page %d SharedObject %d Position Numerator 1\n", i, j);
}
}
for (i=1;i < pdev->next_page;i++) {
@@ -1886,7 +1886,7 @@ static int pdf_linearise(gx_device_pdf *pdev, pdf_linearisation_t *linear_params
Num = hint->ContentOffset - linear_params->PageHintHeader.LeastPageOffset;
write_hint_stream(linear_params, (unsigned int *)&Num, linear_params->PageHintHeader.PageOffsetNumBits);
- dprintf2("Page %d ContentStreamOffset %d\n", i, Num);
+ dmprintf2(pdev->pdf_memory, "Page %d ContentStreamOffset %d\n", i, Num);
}
for (i=1;i < pdev->next_page;i++) {
page_hint_stream_t *hint = &linear_params->PageHints[i];
@@ -1894,7 +1894,7 @@ static int pdf_linearise(gx_device_pdf *pdev, pdf_linearisation_t *linear_params
Num = hint->ContentLength - linear_params->PageHintHeader.LeastContentLength;
write_hint_stream(linear_params, (unsigned int *)&Num, linear_params->PageHintHeader.ContentLengthNumBits);
- dprintf2("Page %d ContentStreamLength %d\n", i, Num);
+ dmprintf2(pdev->pdf_memory, "Page %d ContentStreamLength %d\n", i, Num);
}
flush_hint_stream(linear_params);
@@ -1920,20 +1920,20 @@ static int pdf_linearise(gx_device_pdf *pdev, pdf_linearisation_t *linear_params
linear_params->SharedHintHeader.NumSharedObjects = linear_params->NumSharedResources + linear_params->SharedHintHeader.FirstPageEntries;
write_hint_stream(linear_params, (unsigned int *)&linear_params->SharedHintHeader.FirstSharedObject, 32);
- dprintf1("\nFirstSharedObject %d\n", linear_params->SharedHintHeader.FirstSharedObject);
+ dmprintf1(pdev->pdf_memory, "\nFirstSharedObject %d\n", linear_params->SharedHintHeader.FirstSharedObject);
write_hint_stream(linear_params, (unsigned int *)&linear_params->SharedHintHeader.FirstObjectOffset, 32);
- dprintf1("FirstObjectOffset %ld\n", linear_params->SharedHintHeader.FirstObjectOffset);
+ dmprintf1(pdev->pdf_memory, "FirstObjectOffset %ld\n", linear_params->SharedHintHeader.FirstObjectOffset);
write_hint_stream(linear_params, (unsigned int *)&linear_params->SharedHintHeader.FirstPageEntries, 32);
- dprintf1("FirstPageEntries %d\n", linear_params->SharedHintHeader.FirstPageEntries);
+ dmprintf1(pdev->pdf_memory, "FirstPageEntries %d\n", linear_params->SharedHintHeader.FirstPageEntries);
write_hint_stream(linear_params, (unsigned int *)&linear_params->SharedHintHeader.NumSharedObjects, 32);
- dprintf1("NumSharedObjects %d\n", linear_params->SharedHintHeader.NumSharedObjects);
+ dmprintf1(pdev->pdf_memory, "NumSharedObjects %d\n", linear_params->SharedHintHeader.NumSharedObjects);
j = 1;
write_hint_stream(linear_params, (unsigned int *)&j, 32);
- dprintf("GreatestObjectsNumBits 1\n");
+ dmprintf(pdev->pdf_memory, "GreatestObjectsNumBits 1\n");
write_hint_stream(linear_params, (unsigned int *)&linear_params->SharedHintHeader.FirstObjectOffset, 16);
- dprintf1("FirstObjectOffset %ld\n", linear_params->SharedHintHeader.FirstObjectOffset);
+ dmprintf1(pdev->pdf_memory, "FirstObjectOffset %ld\n", linear_params->SharedHintHeader.FirstObjectOffset);
write_hint_stream(linear_params, (unsigned int *)&linear_params->SharedHintHeader.LeastObjectLength, 32);
- dprintf1("LeastObjectLength %d\n", linear_params->SharedHintHeader.LeastObjectLength);
+ dmprintf1(pdev->pdf_memory, "LeastObjectLength %d\n", linear_params->SharedHintHeader.LeastObjectLength);
i = (linear_params->SharedHintHeader.MostObjectLength - linear_params->SharedHintHeader.LeastObjectLength + 1) / 2;
j = 0;
@@ -1948,17 +1948,17 @@ static int pdf_linearise(gx_device_pdf *pdev, pdf_linearisation_t *linear_params
unsigned int Length = linear_params->SharedHints[i].ObjectLength - linear_params->SharedHintHeader.LeastObjectLength;
write_hint_stream(linear_params, (unsigned int *)&Length, linear_params->SharedHintHeader.LengthNumBits);
- dprintf2("Shared Object group %d, Length %d\n", i, Length);
+ dmprintf2(pdev->pdf_memory, "Shared Object group %d, Length %d\n", i, Length);
}
j = 0;
for (i = 0; i< linear_params->NumSharedHints; i++) {
write_hint_stream(linear_params, (unsigned int *)&j, 1);
- dprintf1("Shared Object group %d, SignatureFlag false\n", i);
+ dmprintf1(pdev->pdf_memory, "Shared Object group %d, SignatureFlag false\n", i);
}
for (i = 0; i< linear_params->NumSharedHints; i++) {
write_hint_stream(linear_params, (unsigned int *)&j, 1);
- dprintf1("Shared Object group %d, NumObjects 1\n", i);
+ dmprintf1(pdev->pdf_memory, "Shared Object group %d, NumObjects 1\n", i);
}
flush_hint_stream(linear_params);
diff --git a/gs/base/gdevpdfu.c b/gs/base/gdevpdfu.c
index a06acf650..5851db2c3 100644
--- a/gs/base/gdevpdfu.c
+++ b/gs/base/gdevpdfu.c
@@ -1313,7 +1313,7 @@ pdf_print_resource_statistics(gx_device_pdf * pdev)
for (i = 0; i < NUM_RESOURCE_CHAINS; i++) {
for (pres = pchain[i]; pres != 0; pres = pres->next, n++);
}
- dprintf3("Resource type %d (%s) has %d instances.\n", rtype,
+ dmprintf3(pdev->pdf_memory, "Resource type %d (%s) has %d instances.\n", rtype,
(name ? name : ""), n);
}
}
diff --git a/gs/base/gdevperm.c b/gs/base/gdevperm.c
index 85e04ed1d..7869ec223 100644
--- a/gs/base/gdevperm.c
+++ b/gs/base/gdevperm.c
@@ -461,7 +461,7 @@ perm_put_params(gx_device *pdev, gs_param_list *plist)
if (code < 0)
return code;
if (new_mode < 0 || new_mode >= sizeof(perm_cmapping_procs) / sizeof(perm_cmapping_procs[0])) {
- dlprintf("rangecheck!\n");
+ dmlprintf(pdev->memory, "rangecheck!\n");
return_error(gs_error_rangecheck);
}
dev->permute = new_permute;
diff --git a/gs/base/gdevplan.c b/gs/base/gdevplan.c
index 66c45a2f7..53404d90a 100644
--- a/gs/base/gdevplan.c
+++ b/gs/base/gdevplan.c
@@ -309,7 +309,7 @@ plan_open(gx_device * pdev)
int code;
#ifdef DEBUG_PRINT
- eprintf("plan_open\n");
+ emprintf(pdev->memory, "plan_open\n");
#endif
code = gdev_prn_open_planar(pdev, 1);
if (code < 0)
@@ -326,7 +326,7 @@ plan_close(gx_device *pdev)
gx_device_printer *pldev = (gx_device_printer *)pdev;
#ifdef DEBUG_PRINT
- eprintf("plan_close\n");
+ emprintf(pdev->memory, "plan_close\n");
#endif
return gdev_prn_close(pdev);
@@ -506,7 +506,7 @@ static int
planm_print_page(gx_device_printer * pdev, FILE * pstream)
{
#ifdef DEBUG_PRINT
- eprintf("planm_print_page\n");
+ emprintf(pdev->memory, "planm_print_page\n");
#endif
return plan_print_page_loop(pdev, 0, 1, pstream);
}
@@ -516,7 +516,7 @@ static int
plang_print_page(gx_device_printer * pdev, FILE * pstream)
{
#ifdef DEBUG_PRINT
- eprintf("plang_print_page\n");
+ emprintf(pdev->memory, "plang_print_page\n");
#endif
return plan_print_page_loop(pdev, 3, 1, pstream);
}
@@ -526,7 +526,7 @@ static int
plan_print_page(gx_device_printer * pdev, FILE * pstream)
{
#ifdef DEBUG_PRINT
- eprintf("planc_print_page\n");
+ emprintf(pdev->memory, "planc_print_page\n");
#endif
return plan_print_page_loop(pdev, 3, 3, pstream);
}
@@ -536,7 +536,7 @@ static int
plank_print_page(gx_device_printer * pdev, FILE * pstream)
{
#ifdef DEBUG_PRINT
- eprintf("plank_print_page\n");
+ emprintf(pdev->memory, "plank_print_page\n");
#endif
return plan_print_page_loop(pdev, 0, 4, pstream);
}
@@ -546,7 +546,7 @@ static int
planc_print_page(gx_device_printer * pdev, FILE * pstream)
{
#ifdef DEBUG_PRINT
- eprintf("planc_print_page\n");
+ emprintf(pdev->memory, "planc_print_page\n");
#endif
return plan_print_page_loop(pdev, 3, 4, pstream);
}
diff --git a/gs/base/gdevplib.c b/gs/base/gdevplib.c
index 9025e7788..e58392242 100644
--- a/gs/base/gdevplib.c
+++ b/gs/base/gdevplib.c
@@ -161,7 +161,7 @@ int gs_band_donor_init(void **opaque,
gs_memory_t *mem)
{
#ifdef DEBUG_PRINT
- eprintf("gs_band_donor_init\n");
+ emprintf(mem, "gs_band_donor_init\n");
#endif
*opaque = NULL;
return 0;
@@ -560,7 +560,7 @@ plib_put_params(gx_device * pdev, gs_param_list * plist)
code = gdev_prn_put_params(pdev, plist);
if (ppdev->space_params.band.BandHeight < MINBANDHEIGHT)
{
- eprintf1("Must have a BandHeight of at least %d\n", MINBANDHEIGHT);
+ emprintf1(pdev->memory, "Must have a BandHeight of at least %d\n", MINBANDHEIGHT);
ecode = gs_error_rangecheck;
@@ -718,7 +718,7 @@ plib_open(gx_device * pdev)
int code;
#ifdef DEBUG_PRINT
- eprintf("plib_open\n");
+ emprintf(pdev->memory, "plib_open\n");
#endif
bdev->printer_procs.buf_procs.create_buf_device = plib_create_buf_device;
bdev->printer_procs.buf_procs.setup_buf_device = plib_setup_buf_device;
@@ -735,11 +735,11 @@ plib_open(gx_device * pdev)
/* Start the actual job. */
#ifdef DEBUG_PRINT
- eprintf("calling job_begin\n");
+ emprintf(pdev->memory, "calling job_begin\n");
#endif
code = gs_band_donor_init(&bdev->opaque, pdev->memory);
#ifdef DEBUG_PRINT
- eprintf("called\n");
+ emprintf(pdev->memory, "called\n");
#endif
return code;
@@ -751,7 +751,7 @@ plib_close(gx_device *pdev)
gx_device_plib *pldev = (gx_device_plib *)pdev;
#ifdef DEBUG_PRINT
- eprintf("plib_close\n");
+ emprintf(pdev->memory, "plib_close\n");
#endif
gs_band_donor_fin(pldev->opaque);
pldev->opaque = NULL;
@@ -896,7 +896,7 @@ plib_print_page_loop(gx_device_printer * pdev, int log2bits, int numComps,
int bandHeight = pdev->space_params.band.BandHeight;
#ifdef DEBUG_PRINT
- eprintf("Calling page_begin\n");
+ emprintf(pdev->memory, "Calling page_begin\n");
#endif
buffer = gs_band_donor_band_get(pldev->opaque,
pdev->width,
@@ -906,7 +906,7 @@ plib_print_page_loop(gx_device_printer * pdev, int log2bits, int numComps,
stride,
bandHeight);
#ifdef DEBUG_PRINT
- eprintf1("Called page_begin %x\n", buffer);
+ emprintf1(pdev->memory, "Called page_begin %x\n", buffer);
#endif
if (buffer == NULL)
return_error(gs_error_VMerror);
@@ -945,20 +945,20 @@ plib_print_page_loop(gx_device_printer * pdev, int log2bits, int numComps,
dump_band(rect.q.y-rect.p.y, pstream);
#endif
#ifdef DEBUG_PRINT
- eprintf3("Calling band_full (%d->%d) of %d\n", rect.p.y, rect.q.y,
- pdev->height);
+ emprintf3(pdev->memory, "Calling band_full (%d->%d) of %d\n",
+ rect.p.y, rect.q.y, pdev->height);
#endif
gs_band_donor_band_full(pldev->opaque, rect.q.y-rect.p.y);
#ifdef DEBUG_PRINT
- eprintf("Called band_full\n");
+ emprintf(pdev->memory, "Called band_full\n");
#endif
}
#ifdef DEBUG_PRINT
- eprintf("Calling band_release\n");
+ emprintf(pdev->memory, "Calling band_release\n");
#endif
gs_band_donor_band_release(pldev->opaque);
#ifdef DEBUG_PRINT
- eprintf("Called band_release\n");
+ emprintf(pdev->memory, "Called band_release\n");
#endif
return (code < 0 ? code : 0);
}
@@ -970,7 +970,7 @@ static int
plibm_print_page(gx_device_printer * pdev, FILE * pstream)
{
#ifdef DEBUG_PRINT
- eprintf("plibm_print_page\n");
+ emprintf(pdev->memory, "plibm_print_page\n");
#endif
return plib_print_page_loop(pdev, 0, 1, pstream);
}
@@ -980,7 +980,7 @@ static int
plibg_print_page(gx_device_printer * pdev, FILE * pstream)
{
#ifdef DEBUG_PRINT
- eprintf("plibg_print_page\n");
+ emprintf(pdev->memory, "plibg_print_page\n");
#endif
return plib_print_page_loop(pdev, 3, 1, pstream);
}
@@ -990,7 +990,7 @@ static int
plib_print_page(gx_device_printer * pdev, FILE * pstream)
{
#ifdef DEBUG_PRINT
- eprintf("plibc_print_page\n");
+ emprintf(pdev->memory, "plibc_print_page\n");
#endif
return plib_print_page_loop(pdev, 3, 3, pstream);
}
@@ -1000,7 +1000,7 @@ static int
plibk_print_page(gx_device_printer * pdev, FILE * pstream)
{
#ifdef DEBUG_PRINT
- eprintf("plibk_print_page\n");
+ emprintf(pdev->memory, "plibk_print_page\n");
#endif
return plib_print_page_loop(pdev, 0, 4, pstream);
}
@@ -1010,7 +1010,7 @@ static int
plibc_print_page(gx_device_printer * pdev, FILE * pstream)
{
#ifdef DEBUG_PRINT
- eprintf("plibc_print_page\n");
+ emprintf(pdev->memory, "plibc_print_page\n");
#endif
return plib_print_page_loop(pdev, 3, 4, pstream);
}
diff --git a/gs/base/gdevprn.c b/gs/base/gdevprn.c
index 94a423179..6dddae82e 100644
--- a/gs/base/gdevprn.c
+++ b/gs/base/gdevprn.c
@@ -117,9 +117,9 @@ gdev_prn_setup_as_command_list(gx_device *pdev, gs_memory_t *buffer_memory,
BEGIN\
ulong *fp_ = (ulong *)&first_arg - 2;\
for (; fp_ && (fp_[1] & 0xff000000) == 0x08000000; fp_ = (ulong *)*fp_)\
- dprintf2(" fp=0x%lx ip=0x%lx\n", (ulong)fp_, fp_[1]);\
+ dmprintf2(buffer_memory, " fp=0x%lx ip=0x%lx\n", (ulong)fp_, fp_[1]);\
END
-dputs("alloc buffer:\n");
+dmputs(buffer_memory, "alloc buffer:\n");
BACKTRACE(pdev);
#endif /*DEBUGGING_HACKS*/
for ( space = space_params->BufferSpace; ; ) {
@@ -1370,10 +1370,10 @@ gdev_prn_maybe_realloc_memory(gx_device_printer *prdev,
gdev_prn_space_params new_sp;
#ifdef DEBUGGING_HACKS
-debug_dump_bytes((const byte *)old_sp, (const byte *)(old_sp + 1), "old");
-debug_dump_bytes((const byte *)&prdev->space_params,
+debug_dump_bytes(pdev->memory, (const byte *)old_sp, (const byte *)(old_sp + 1), "old");
+debug_dump_bytes(pddev->memory, (const byte *)&prdev->space_params,
(const byte *)(&prdev->space_params + 1), "new");
-dprintf4("w=%d/%d, h=%d/%d\n", old_width, new_width, old_height, new_height);
+dmprintf4(pdev->memory, "w=%d/%d, h=%d/%d\n", old_width, new_width, old_height, new_height);
#endif /*DEBUGGING_HACKS*/
new_sp = prdev->space_params;
prdev->width = old_width;
diff --git a/gs/base/gdevpsd.c b/gs/base/gdevpsd.c
index 2e439eef0..8e3746c2e 100644
--- a/gs/base/gdevpsd.c
+++ b/gs/base/gdevpsd.c
@@ -1014,9 +1014,9 @@ psd_get_color_comp_index(gx_device * dev, const char * pname,
if (index < 0 && component_type == SEPARATION_NAME &&
pdev->warning_given == false &&
pdev->devn_params.num_separation_order_names == 0) {
- dlprintf("**** Max spot colorants reached.\n");
- dlprintf("**** Some colorants will be converted to equivalent CMYK values.\n");
- dlprintf("**** If this is a Postscript file, try using the -dMaxSpots= option.\n");
+ dmlprintf(dev->memory, "**** Max spot colorants reached.\n");
+ dmlprintf(dev->memory, "**** Some colorants will be converted to equivalent CMYK values.\n");
+ dmlprintf(dev->memory, "**** If this is a Postscript file, try using the -dMaxSpots= option.\n");
pdev->warning_given = true;
}
return index;
diff --git a/gs/base/gdevpsds.c b/gs/base/gdevpsds.c
index cf13b28af..94065bf3a 100644
--- a/gs/base/gdevpsds.c
+++ b/gs/base/gdevpsds.c
@@ -562,12 +562,12 @@ test_IE(void)
w.limit = w.ptr + sizeof(out);
memset(table, 0xcc, sizeof(table));
memset(out, 0xff, sizeof(out));
- dprintf1("processing %d bytes\n", n);
+ dmprintf1(ss->memory, "processing %d bytes\n", n);
status = templat->process(ss, &r, &w, true);
- dprintf3("%d bytes read, %d bytes written, status = %d\n",
+ dmprintf3(ss->memory, "%d bytes read, %d bytes written, status = %d\n",
(int)(r.ptr + 1 - in), (int)(w.ptr + 1 - out), status);
- debug_dump_bytes(table, table + sizeof(table), "table");
- debug_dump_bytes(out, w.ptr + 1, "out");
+ debug_dump_bytes(ss->memory, table, table + sizeof(table), "table");
+ debug_dump_bytes(ss->memory, out, w.ptr + 1, "out");
}
}
@@ -627,8 +627,9 @@ s_Subsample_process(stream_state * st, stream_cursor_read * pr,
int x = ss->x, y = ss->y;
int status = 0;
- if_debug4('w', "[w]subsample: x=%d, y=%d, rcount=%ld, wcount=%ld\n",
- x, y, (long)(rlimit - p), (long)(wlimit - q));
+ if_debug4m('w', st->memory,
+ "[w]subsample: x=%d, y=%d, rcount=%ld, wcount=%ld\n",
+ x, y, (long)(rlimit - p), (long)(wlimit - q));
for (; rlimit - p >= spp; p += spp) {
if (((y % yf == yf2 && y < ylimit) || y == ylast) &&
((x % xf == xf2 && x < xlimit) || x == xlast)
@@ -643,9 +644,9 @@ s_Subsample_process(stream_state * st, stream_cursor_read * pr,
if (++x == width)
x = 0, ++y;
}
- if_debug5('w',
- "[w]subsample: x'=%d, y'=%d, read %ld, wrote %ld, status = %d\n",
- x, y, (long)(p - pr->ptr), (long)(q - pw->ptr), status);
+ if_debug5m('w', st->memory,
+ "[w]subsample: x'=%d, y'=%d, read %ld, wrote %ld, status = %d\n",
+ x, y, (long)(p - pr->ptr), (long)(q - pw->ptr), status);
pr->ptr = p;
pw->ptr = q;
ss->x = x, ss->y = y;
diff --git a/gs/base/gdevpsf2.c b/gs/base/gdevpsf2.c
index ac49c9025..b43462f57 100644
--- a/gs/base/gdevpsf2.c
+++ b/gs/base/gdevpsf2.c
@@ -1409,7 +1409,7 @@ psf_write_type2_font(stream *s, gs_font_type1 *pfont, int options,
/* Write the GSubrs Index, if any, checking the offset. */
offset = stell(writer.strm) - start_pos;
- if_debug2('l', "[l]GSubrs = %u => %u\n", GSubrs_offset, offset);
+ if_debug2m('l', s->memory, "[l]GSubrs = %u => %u\n", GSubrs_offset, offset);
if (offset > GSubrs_offset)
return_error(gs_error_rangecheck);
GSubrs_offset = offset;
@@ -1688,12 +1688,13 @@ psf_write_cid0_font(stream *s, gs_font_cid0 *pfont, int options,
cff_Index_size(gsubrs_count, gsubrs_size);
FDSelect_offset = charset_offset + charset_size;
CharStrings_offset = FDSelect_offset + fdselect_size;
- if_debug4('l', "[l]GSubrs at %u, charset at %u, FDSelect at %u, CharStrings at %u\n",
- GSubrs_offset, charset_offset, FDSelect_offset, CharStrings_offset);
+ if_debug4m('l', s->memory,
+ "[l]GSubrs at %u, charset at %u, FDSelect at %u, CharStrings at %u\n",
+ GSubrs_offset, charset_offset, FDSelect_offset, CharStrings_offset);
write:
start_pos = stell(writer.strm);
- if_debug1('l', "[l]start_pos = %ld\n", start_pos);
+ if_debug1m('l', s->memory, "[l]start_pos = %ld\n", start_pos);
/* Write the header, setting offset_size. */
cff_write_header(&writer, End_offset);
@@ -1709,14 +1710,14 @@ psf_write_cid0_font(stream *s, gs_font_cid0 *pfont, int options,
cff_write_Top_cidfont(&writer, charset_offset, CharStrings_offset,
FDSelect_offset, Font_offset, &info);
Top_size = stell(writer.strm) - start_pos - offset;
- if_debug1('l', "[l]Top_size = %u\n", Top_size);
+ if_debug1m('l', s->memory, "[l]Top_size = %u\n", Top_size);
/* Write the strings Index. */
cff_put_Index(&writer, &writer.strings);
/* Write the GSubrs Index, if any, checking the offset. */
offset = stell(writer.strm) - start_pos;
- if_debug2('l', "[l]GSubrs = %u => %u\n", GSubrs_offset, offset);
+ if_debug2m('l', s->memory, "[l]GSubrs = %u => %u\n", GSubrs_offset, offset);
if (offset > GSubrs_offset)
return_error(gs_error_rangecheck);
GSubrs_offset = offset;
@@ -1730,12 +1731,12 @@ psf_write_cid0_font(stream *s, gs_font_cid0 *pfont, int options,
pfont->cidata.FDArray[0], true);
/* Write the charset. */
- if_debug1('l', "[l]charset = %lu\n", stell(writer.strm) - start_pos);
+ if_debug1m('l', s->memory, "[l]charset = %lu\n", stell(writer.strm) - start_pos);
cff_write_cidset(&writer, &genum);
/* Write the FDSelect structure, checking the offset. */
offset = stell(writer.strm) - start_pos;
- if_debug2('l', "[l]FDSelect = %u => %u\n", FDSelect_offset, offset);
+ if_debug2m('l', s->memory, "[l]FDSelect = %u => %u\n", FDSelect_offset, offset);
if (offset > FDSelect_offset)
return_error(offset_error("FDselect"));
FDSelect_offset = offset;
@@ -1743,7 +1744,7 @@ psf_write_cid0_font(stream *s, gs_font_cid0 *pfont, int options,
/* Write the CharStrings Index, checking the offset. */
offset = stell(writer.strm) - start_pos;
- if_debug2('l', "[l]CharStrings = %u => %u\n", CharStrings_offset, offset);
+ if_debug2m('l', s->memory, "[l]CharStrings = %u => %u\n", CharStrings_offset, offset);
if (offset > CharStrings_offset)
return_error(offset_error("CharStrings"));
CharStrings_offset = offset;
@@ -1752,13 +1753,13 @@ psf_write_cid0_font(stream *s, gs_font_cid0 *pfont, int options,
/* Write the Font Dict Index. */
offset = stell(writer.strm) - start_pos;
- if_debug2('l', "[l]Font = %u => %u\n", Font_offset, offset);
+ if_debug2m('l', s->memory, "[l]Font = %u => %u\n", Font_offset, offset);
if (offset > Font_offset)
return_error(offset_error("Font"));
Font_offset = offset;
cff_write_FDArray_offsets(&writer, FDArray_offsets, num_fonts);
offset = stell(writer.strm) - start_pos;
- if_debug2('l', "[l]FDArray[0] = %u => %u\n", FDArray_offsets[0], offset);
+ if_debug2m('l', s->memory, "[l]FDArray[0] = %u => %u\n", FDArray_offsets[0], offset);
if (offset > FDArray_offsets[0])
return_error(offset_error("FDArray[0]"));
FDArray_offsets[0] = offset;
@@ -1774,8 +1775,8 @@ psf_write_cid0_font(stream *s, gs_font_cid0 *pfont, int options,
cff_write_Top_fdarray(&writer, (gs_font_base *)pfd, Private_offsets[j],
Private_offsets[j + 1] - Private_offsets[j]);
offset = stell(writer.strm) - start_pos;
- if_debug3('l', "[l]FDArray[%d] = %u => %u\n", j + 1,
- FDArray_offsets[j + 1], offset);
+ if_debug3m('l', s->memory, "[l]FDArray[%d] = %u => %u\n", j + 1,
+ FDArray_offsets[j + 1], offset);
if (offset > FDArray_offsets[j + 1])
return_error(offset_error("FDArray"));
FDArray_offsets[j + 1] = offset;
@@ -1786,8 +1787,8 @@ psf_write_cid0_font(stream *s, gs_font_cid0 *pfont, int options,
gs_font_type1 *pfd;
offset = stell(writer.strm) - start_pos;
- if_debug3('l', "[l]Private[%d] = %u => %u\n",
- j, Private_offsets[j], offset);
+ if_debug3m('l', s->memory, "[l]Private[%d] = %u => %u\n",
+ j, Private_offsets[j], offset);
if (offset > Private_offsets[j])
return_error(offset_error("Private"));
Private_offsets[j] = offset;
@@ -1803,8 +1804,8 @@ psf_write_cid0_font(stream *s, gs_font_cid0 *pfont, int options,
gs_font_type1 *pfd;
offset = stell(writer.strm) - (start_pos + Private_offsets[j]);
- if_debug3('l', "[l]Subrs[%d] = %u => %u\n",
- j, Subrs_offsets[j], offset);
+ if_debug3m('l', s->memory, "[l]Subrs[%d] = %u => %u\n",
+ j, Subrs_offsets[j], offset);
if (offset > Subrs_offsets[j])
return_error(offset_error("Subrs"));
Subrs_offsets[j] = offset;
@@ -1819,7 +1820,7 @@ psf_write_cid0_font(stream *s, gs_font_cid0 *pfont, int options,
/* Check the final offset. */
offset = stell(writer.strm) - start_pos;
- if_debug2('l', "[l]End = %u => %u\n", End_offset, offset);
+ if_debug2m('l', s->memory, "[l]End = %u => %u\n", End_offset, offset);
if (offset > End_offset)
return_error(offset_error("End"));
if (offset == End_offset) {
diff --git a/gs/base/gdevpsft.c b/gs/base/gdevpsft.c
index 852309210..b72e7670d 100644
--- a/gs/base/gdevpsft.c
+++ b/gs/base/gdevpsft.c
@@ -136,8 +136,8 @@ write_range(stream *s, gs_font_type42 *pfont, ulong start, uint length)
{
ulong base = start, size = length;
- if_debug3('l', "[l]write_range pos = %ld, start = %lu, length = %u\n",
- stell(s), start, length);
+ if_debug3m('l', s->memory, "[l]write_range pos = %ld, start = %lu, length = %u\n",
+ stell(s), start, length);
while (size > 0) {
const byte *ptr;
int code;
@@ -921,7 +921,7 @@ psf_write_truetype_data(stream *s, gs_font_type42 *pfont, int options,
if (glyph < gs_min_cid_glyph)
return_error(gs_error_invalidfont);
glyph_index = glyph & ~GS_GLYPH_TAG;
- if_debug1('L', "[L]glyph_index %u\n", glyph_index);
+ if_debug1m('L', s->memory, "[L]glyph_index %u\n", glyph_index);
glyph_data.memory = pfont->memory;
if ((code = pfont->data.get_outline(pfont, glyph_index, &glyph_data)) >= 0) {
/* Since indexToLocFormat==0 assumes even glyph lengths,
@@ -933,7 +933,7 @@ psf_write_truetype_data(stream *s, gs_font_type42 *pfont, int options,
glyf_length += l;
if (l != glyph_data.bits.size)
glyf_alignment++;
- if_debug1('L', "[L] size %u\n", glyph_data.bits.size);
+ if_debug1m('L', s->memory, "[L] size %u\n", glyph_data.bits.size);
gs_glyph_data_free(&glyph_data, "psf_write_truetype_data");
}
}
@@ -972,8 +972,8 @@ psf_write_truetype_data(stream *s, gs_font_type42 *pfont, int options,
if (glyf_length == 0)
glyf_length = 1;
}
- if_debug2('l', "[l]max_glyph = %lu, glyf_length = %lu\n",
- (ulong)max_glyph, (ulong)glyf_length);
+ if_debug2m('l', s->memory, "[l]max_glyph = %lu, glyf_length = %lu\n",
+ (ulong)max_glyph, (ulong)glyf_length);
/*
* If necessary, compute the length of the post table. Note that we
@@ -1205,12 +1205,12 @@ psf_write_truetype_data(stream *s, gs_font_type42 *pfont, int options,
if (glyph_data.bits.size < l)
stream_write(s, &zero, 1);
offset += l;
- if_debug2('L', "[L]glyf index = %u, size = %u\n",
+ if_debug2m('L', s->memory, "[L]glyf index = %u, size = %u\n",
i, glyph_data.bits.size);
gs_glyph_data_free(&glyph_data, "psf_write_truetype_data");
}
}
- if_debug1('l', "[l]glyf final offset = %lu\n", offset);
+ if_debug1m('l', s->memory, "[l]glyf final offset = %lu\n", offset);
/* Add a dummy byte if necessary to make glyf non-empty. */
while (offset < glyf_length)
stream_putc(s, 0), ++offset;
diff --git a/gs/base/gdevpsfx.c b/gs/base/gdevpsfx.c
index 02c7ac3a3..818ae52b5 100644
--- a/gs/base/gdevpsfx.c
+++ b/gs/base/gdevpsfx.c
@@ -26,6 +26,7 @@
#include "gxtype1.h"
#include "stream.h"
#include "gdevpsf.h"
+#include "gxistate.h"
/* ------ Type 1 Charstring parsing ------ */
@@ -210,15 +211,15 @@ type1_next(gs_type1_state *pcis)
const fixed *p;
for (p = pcis->ostack; p <= csp; ++p)
- dprintf1(" %g", fixed2float(*p));
+ dmprintf1(pcis->pis->memory, " %g", fixed2float(*p));
if (c == cx_escape) {
crypt_state cstate = state;
int cn;
charstring_next(*cip, cstate, cn, encrypted);
- dprintf1(" [*%d]\n", cn);
+ dmprintf1(pcis->pis->memory, " [*%d]\n", cn);
} else
- dprintf1(" [%d]\n", c);
+ dmprintf1(pcis->pis->memory, " [%d]\n", c);
}
#endif
switch ((char_command) c) {
diff --git a/gs/base/gdevpx.c b/gs/base/gdevpx.c
index 0d2bd33cb..136f5569f 100644
--- a/gs/base/gdevpx.c
+++ b/gs/base/gdevpx.c
@@ -1553,7 +1553,8 @@ pclxl_copy_mono(gx_device * dev, const byte * data, int data_x, int raster,
palette[1] = (byte) color1;
palette_size = 2;
color_space = eGray;
- if_debug2('b', "color palette %02X %02X\n", palette[0], palette[1]);
+ if_debug2m('b', dev->memory, "color palette %02X %02X\n",
+ palette[0], palette[1]);
} else {
palette[0] = (byte) (color0 >> 16);
palette[1] = (byte) (color0 >> 8);
diff --git a/gs/base/gdevrinkj.c b/gs/base/gdevrinkj.c
index 8996af79a..fdc8f5dc5 100644
--- a/gs/base/gdevrinkj.c
+++ b/gs/base/gdevrinkj.c
@@ -955,7 +955,7 @@ rinkj_set_luts(rinkj_device *rdev,
val = linebuf + i;
if (!strcmp(key, "AddLut")) {
- if_debug1('r', "[r]%s", linebuf);
+ if_debug1m('r', rdev->memory, "[r]%s", linebuf);
rinkj_add_lut(rdev, &lutset, val[0], f);
} else if (!strcmp(key, "Dither") || !strcmp(key, "Aspect")) {
rinkj_device_set_param_string(cmyk_dev, key, val);
@@ -1032,7 +1032,7 @@ rinkj_write_image_data(gx_device_printer *pdev, RinkjDevice *cmyk_dev)
rinkj_color_cache_entry *cache = NULL;
n_planes = n_planes_in + rdev->separation_names.num_names;
- if_debug1('r', "[r]n_planes = %d\n", n_planes);
+ if_debug1m('r', rdev->memory, "[r]n_planes = %d\n", n_planes);
xsb = pdev->width;
for (i = 0; i < n_planes_out; i++)
plane_data[i] = gs_alloc_bytes(pdev->memory, xsb, "rinkj_write_image_data");
diff --git a/gs/base/gdevsppr.c b/gs/base/gdevsppr.c
index b429bf98b..300600f35 100644
--- a/gs/base/gdevsppr.c
+++ b/gs/base/gdevsppr.c
@@ -146,7 +146,7 @@ sparc_print_page(gx_device_printer *pdev, FILE *prn)
{
errprintf(pdev->memory,
"sparc_print_page: Printer Problem with unknown reason...");
- dflush();
+ dmflush(pdev->memory);
warning=1;
}
sleep(5);
@@ -155,7 +155,7 @@ sparc_print_page(gx_device_printer *pdev, FILE *prn)
errprintf(pdev->memory,
"sparc_print_page: Printer-Warning: %s...",
err_code_string(lpvierr.err_code));
- dflush();
+ dmflush(pdev->memory);
warning=1;
sleep(5);
break;
diff --git a/gs/base/gdevsvg.c b/gs/base/gdevsvg.c
index 268c6d3a4..2dc5be08b 100755
--- a/gs/base/gdevsvg.c
+++ b/gs/base/gdevsvg.c
@@ -307,7 +307,7 @@ svg_get_params(gx_device *dev, gs_param_list *plist)
{
int code = 0;
- if_debug0('_', "svg_get_params\n");
+ if_debug0m('_', dev->memory, "svg_get_params\n");
/* call our superclass to add its standard set */
code = gdev_vector_get_params(dev, plist);
@@ -325,7 +325,7 @@ svg_put_params(gx_device *dev, gs_param_list *plist)
{
int code = 0;
- if_debug0('_', "svg_put_params\n");
+ if_debug0m('_', dev->memory, "svg_put_params\n");
/* svg specific parameters are parsed here */
@@ -367,7 +367,7 @@ svg_write_header(gx_device_svg *svg)
uint used;
char line[300];
- if_debug0('_', "svg_write_header\n");
+ if_debug0m('_', svg->memory, "svg_write_header\n");
/* only write the header once */
if (svg->header)
@@ -496,7 +496,7 @@ svg_beginpage(gx_device_vector *vdev)
svg_write_header(svg);
- if_debug1('_', "svg_beginpage (page count %d)\n", svg->page_count);
+ if_debug1m('_', svg->memory, "svg_beginpage (page count %d)\n", svg->page_count);
return 0;
}
@@ -506,7 +506,7 @@ svg_setlinewidth(gx_device_vector *vdev, floatp width)
{
gx_device_svg *svg = (gx_device_svg *)vdev;
- if_debug1('_', "svg_setlinewidth(%lf)\n", width);
+ if_debug1m('_', svg->memory, "svg_setlinewidth(%lf)\n", width);
svg->linewidth = width;
svg->dirty++;
@@ -522,7 +522,7 @@ svg_setlinecap(gx_device_vector *vdev, gs_line_cap cap)
if (cap < 0 || cap > gs_cap_unknown)
return gs_throw_code(gs_error_rangecheck);
- if_debug1('_', "svg_setlinecap(%s)\n", linecap_names[cap]);
+ if_debug1m('_', svg->memory, "svg_setlinecap(%s)\n", linecap_names[cap]);
svg->linecap = cap;
svg->dirty++;
@@ -538,7 +538,7 @@ svg_setlinejoin(gx_device_vector *vdev, gs_line_join join)
if (join < 0 || join > gs_join_unknown)
return gs_throw_code(gs_error_rangecheck);
- if_debug1('_', "svg_setlinejoin(%s)\n", linejoin_names[join]);
+ if_debug1m('_', svg->memory, "svg_setlinejoin(%s)\n", linejoin_names[join]);
svg->linejoin = join;
svg->dirty++;
@@ -548,21 +548,21 @@ svg_setlinejoin(gx_device_vector *vdev, gs_line_join join)
static int
svg_setmiterlimit(gx_device_vector *vdev, floatp limit)
{
- if_debug1('_', "svg_setmiterlimit(%lf)\n", limit);
+ if_debug1m('_', vdev->memory, "svg_setmiterlimit(%lf)\n", limit);
return 0;
}
static int
svg_setdash(gx_device_vector *vdev, const float *pattern,
uint count, floatp offset)
{
- if_debug0('_', "svg_setdash\n");
+ if_debug0m('_', vdev->memory, "svg_setdash\n");
return 0;
}
static int
svg_setlogop(gx_device_vector *vdev, gs_logical_operation_t lop,
gs_logical_operation_t diff)
{
- if_debug2('_', "svg_setlogop(%u,%u) set logical operation\n",
+ if_debug2m('_', vdev->memory, "svg_setlogop(%u,%u) set logical operation\n",
lop, diff);
/* SVG can fake some simpler modes, but we ignore this for now. */
return 0;
@@ -574,7 +574,7 @@ static int
svg_can_handle_hl_color(gx_device_vector *vdev, const gs_imager_state *pis,
const gx_drawing_color * pdc)
{
- if_debug0('_', "svg_can_handle_hl_color\n");
+ if_debug0m('_', vdev->memory, "svg_can_handle_hl_color\n");
return 0;
}
@@ -585,7 +585,7 @@ svg_setfillcolor(gx_device_vector *vdev, const gs_imager_state *pis,
gx_device_svg *svg = (gx_device_svg*)vdev;
gx_color_index fill = svg_get_color(svg, pdc);
- if_debug0('_', "svg_setfillcolor\n");
+ if_debug0m('_', svg->memory, "svg_setfillcolor\n");
if (svg->fillcolor == fill)
return 0; /* not a new color */
@@ -603,7 +603,7 @@ svg_setstrokecolor(gx_device_vector *vdev, const gs_imager_state *pis,
gx_device_svg *svg = (gx_device_svg*)vdev;
gx_color_index stroke = svg_get_color(svg, pdc);
- if_debug0('_', "svg_setstrokecolor\n");
+ if_debug0m('_', svg->memory, "svg_setstrokecolor\n");
if (svg->strokecolor == stroke)
return 0; /* not a new color */
@@ -625,9 +625,9 @@ static int svg_print_path_type(gx_device_svg *svg, gx_path_type_t type)
"fill and stroke", "clip"};
if (type <= 4)
- if_debug2('_', "type %d (%s)", type, path_type_names[type]);
+ if_debug2m('_', svg->memory, "type %d (%s)", type, path_type_names[type]);
else
- if_debug1('_', "type %d", type);
+ if_debug1m('_', svg->memory, "type %d", type);
return 0;
}
@@ -643,9 +643,9 @@ svg_dorect(gx_device_vector *vdev, fixed x0, fixed y0,
if (svg->page_count)
return 0;
- if_debug0('_', "svg_dorect");
+ if_debug0m('_', svg->memory, "svg_dorect");
svg_print_path_type(svg, type);
- if_debug0('_', "\n");
+ if_debug0m('_', svg->memory, "\n");
svg_write_state(svg);
@@ -685,9 +685,9 @@ svg_beginpath(gx_device_vector *vdev, gx_path_type_t type)
if (!(type & gx_path_type_fill) && !(type & gx_path_type_stroke))
return 0;
- if_debug0('_', "svg_beginpath ");
+ if_debug0m('_', svg->memory, "svg_beginpath ");
svg_print_path_type(svg, type);
- if_debug0('_', "\n");
+ if_debug0m('_', svg->memory, "\n");
svg_write_state(svg);
svg_write(svg, "<path d='");
@@ -710,9 +710,9 @@ svg_moveto(gx_device_vector *vdev, floatp x0, floatp y0,
if (!(type & gx_path_type_fill) && !(type & gx_path_type_stroke))
return 0;
- if_debug4('_', "svg_moveto(%lf,%lf,%lf,%lf) ", x0, y0, x, y);
+ if_debug4m('_', svg->memory, "svg_moveto(%lf,%lf,%lf,%lf) ", x0, y0, x, y);
svg_print_path_type(svg, type);
- if_debug0('_', "\n");
+ if_debug0m('_', svg->memory, "\n");
sprintf(line, " M%lf,%lf", x, y);
svg_write(svg, line);
@@ -735,9 +735,9 @@ svg_lineto(gx_device_vector *vdev, floatp x0, floatp y0,
if (!(type & gx_path_type_fill) && !(type & gx_path_type_stroke))
return 0;
- if_debug4('_', "svg_lineto(%lf,%lf,%lf,%lf) ", x0,y0, x,y);
+ if_debug4m('_', svg->memory, "svg_lineto(%lf,%lf,%lf,%lf) ", x0,y0, x,y);
svg_print_path_type(svg, type);
- if_debug0('_', "\n");
+ if_debug0m('_', svg->memory, "\n");
sprintf(line, " L%lf,%lf", x, y);
svg_write(svg, line);
@@ -761,10 +761,10 @@ svg_curveto(gx_device_vector *vdev, floatp x0, floatp y0,
if (!(type & gx_path_type_fill) && !(type & gx_path_type_stroke))
return 0;
- if_debug8('_', "svg_curveto(%lf,%lf, %lf,%lf, %lf,%lf, %lf,%lf) ",
+ if_debug8m('_', svg->memory, "svg_curveto(%lf,%lf, %lf,%lf, %lf,%lf, %lf,%lf) ",
x0,y0, x1,y1, x2,y2, x3,y3);
svg_print_path_type(svg, type);
- if_debug0('_', "\n");
+ if_debug0m('_', svg->memory, "\n");
sprintf(line, " C%lf,%lf %lf,%lf %lf,%lf", x1,y1, x2,y2, x3,y3);
svg_write(svg, line);
@@ -786,9 +786,9 @@ svg_closepath(gx_device_vector *vdev, floatp x, floatp y,
if (!(type & gx_path_type_fill) && !(type & gx_path_type_stroke))
return 0;
- if_debug0('_', "svg_closepath ");
+ if_debug0m('_', svg->memory, "svg_closepath ");
svg_print_path_type(svg, type);
- if_debug0('_', "\n");
+ if_debug0m('_', svg->memory, "\n");
svg_write(svg, " z");
@@ -808,9 +808,9 @@ svg_endpath(gx_device_vector *vdev, gx_path_type_t type)
if (!(type & gx_path_type_fill) && !(type & gx_path_type_stroke))
return 0;
- if_debug0('_', "svg_endpath ");
+ if_debug0m('_', svg->memory, "svg_endpath ");
svg_print_path_type(svg, type);
- if_debug0('_', "\n");
+ if_debug0m('_', svg->memory, "\n");
/* close the path data attribute */
svg_write(svg, "'");
diff --git a/gs/base/gdevsvga.c b/gs/base/gdevsvga.c
index f7b5d19da..94d9115b5 100644
--- a/gs/base/gdevsvga.c
+++ b/gs/base/gdevsvga.c
@@ -646,7 +646,7 @@ vesa_set_mode(int mode)
/* Read information about a device mode */
static int
-vesa_get_info(int mode, vesa_info _ss * info)
+vesa_get_info(const gs_memory_t *mem, int mode, vesa_info _ss * info)
{
registers regs;
struct SREGS sregs;
@@ -660,14 +660,14 @@ vesa_get_info(int mode, vesa_info _ss * info)
int86x(0x10, &regs, &regs, &sregs);
#ifdef DEBUG
if (regs.h.ah == 0 && regs.h.al == 0x4f)
- dlprintf8("vesa_get_info(%x): ma=%x wa=%x/%x wg=%x ws=%x wseg=%x/%x\n",
- mode, info->mode_attributes,
- info->win_a_attributes, info->win_b_attributes,
- info->win_granularity, info->win_size,
- info->win_a_segment, info->win_b_segment);
+ dmlprintf8(mem, "vesa_get_info(%x): ma=%x wa=%x/%x wg=%x ws=%x wseg=%x/%x\n",
+ mode, info->mode_attributes,
+ info->win_a_attributes, info->win_b_attributes,
+ info->win_granularity, info->win_size,
+ info->win_a_segment, info->win_b_segment);
else
- dlprintf3("vesa_get_info(%x) failed: ah=%x al=%x\n",
- mode, regs.h.ah, regs.h.al);
+ dmlprintf3(mem, "vesa_get_info(%x) failed: ah=%x al=%x\n",
+ mode, regs.h.ah, regs.h.al);
#endif
return (regs.h.ah == 0 && regs.h.al == 0x4f ? 0 : -1);
}
@@ -683,7 +683,7 @@ vesa_find_mode(gx_device * dev, const mode_info * mode_table)
for (mip = mode_table; mip->mode >= 0; mip++) {
if (mip->width >= fb_dev->width &&
mip->height >= fb_dev->height &&
- vesa_get_info(mip->mode, &info) >= 0 &&
+ vesa_get_info(dev->memory, mip->mode, &info) >= 0 &&
bits_include(info.mode_attributes,
m_supported | m_graphics) &&
info.win_granularity <= 64 &&
diff --git a/gs/base/gdevtrac.c b/gs/base/gdevtrac.c
index 34d8d15bd..7438b538f 100644
--- a/gs/base/gdevtrac.c
+++ b/gs/base/gdevtrac.c
@@ -42,19 +42,19 @@ extern_st(st_gx_image_enum_common);
/* ---------------- Internal utilities ---------------- */
static void
-trace_drawing_color(const char *prefix, const gx_drawing_color *pdcolor)
+trace_drawing_color(const gs_memory_t *mem, const char *prefix, const gx_drawing_color *pdcolor)
{
- dprintf1("%scolor=", prefix);
+ dmprintf1(mem, "%scolor=", prefix);
if (pdcolor->type == gx_dc_type_none)
- dputs("none");
+ dmputs(mem, "none");
else if (pdcolor->type == gx_dc_type_null)
- dputs("null");
+ dmputs(mem, "null");
else if (pdcolor->type == gx_dc_type_pure)
- dprintf1("0x%lx", (ulong)pdcolor->colors.pure);
+ dmprintf1(mem, "0x%lx", (ulong)pdcolor->colors.pure);
else if (pdcolor->type == gx_dc_type_ht_binary) {
int ci = pdcolor->colors.binary.b_index;
- dprintf5("binary(0x%lx, 0x%lx, %d/%d, index=%d)",
+ dmprintf5(mem, "binary(0x%lx, 0x%lx, %d/%d, index=%d)",
(ulong)pdcolor->colors.binary.color[0],
(ulong)pdcolor->colors.binary.color[1],
pdcolor->colors.binary.b_level,
@@ -65,23 +65,23 @@ trace_drawing_color(const char *prefix, const gx_drawing_color *pdcolor)
ulong plane_mask = pdcolor->colors.colored.plane_mask;
int ci;
- dprintf1("colored(mask=%lu", plane_mask);
+ dmprintf1(mem, "colored(mask=%lu", plane_mask);
for (ci = 0; plane_mask != 0; ++ci, plane_mask >>= 1)
if (plane_mask & 1) {
- dprintf2(", (base=%u, level=%u)",
+ dmprintf2(mem, ", (base=%u, level=%u)",
pdcolor->colors.colored.c_base[ci],
pdcolor->colors.colored.c_level[ci]);
} else
- dputs(", -");
+ dmputs(mem, ", -");
} else {
- dputs("**unknown**");
+ dmputs(mem, "**unknown**");
}
}
static void
-trace_lop(gs_logical_operation_t lop)
+trace_lop(const gs_memory_t *mem, gs_logical_operation_t lop)
{
- dprintf1(", lop=0x%x", (uint)lop);
+ dmprintf1(mem, ", lop=0x%x", (uint)lop);
}
static void
@@ -95,25 +95,25 @@ trace_path(const gx_path *path)
switch (gx_path_enum_next(&penum, pts)) {
case gs_pe_moveto:
- dprintf2(" %g %g moveto\n", fixed2float(pts[0].x),
+ dmprintf2(path->memory," %g %g moveto\n", fixed2float(pts[0].x),
fixed2float(pts[0].y));
continue;
case gs_pe_lineto:
- dprintf2(" %g %g lineto\n", fixed2float(pts[0].x),
+ dmprintf2(path->memory," %g %g lineto\n", fixed2float(pts[0].x),
fixed2float(pts[0].y));
continue;
case gs_pe_gapto:
- dprintf2(" %g %g gapto\n", fixed2float(pts[0].x),
+ dmprintf2(path->memory," %g %g gapto\n", fixed2float(pts[0].x),
fixed2float(pts[0].y));
continue;
case gs_pe_curveto:
- dprintf6(" %g %g %g %g %g %g curveto\n", fixed2float(pts[0].x),
+ dmprintf6(path->memory," %g %g %g %g %g %g curveto\n", fixed2float(pts[0].x),
fixed2float(pts[0].y), fixed2float(pts[1].x),
fixed2float(pts[1].y), fixed2float(pts[2].x),
fixed2float(pts[2].y));
continue;
case gs_pe_closepath:
- dputs(" closepath\n");
+ dmputs(path->memory," closepath\n");
continue;
default:
break;
@@ -132,12 +132,12 @@ trace_clip(gx_device *dev, const gx_clip_path *pcpath)
int2fixed(dev->height))
)
return;
- dputs(", clip={");
+ dmputs(dev->memory, ", clip={");
if (pcpath->path_valid)
trace_path(&pcpath->path);
else
- dputs("NO PATH");
- dputs("}");
+ dmputs(dev->memory, "NO PATH");
+ dmputs(dev->memory, "}");
}
/* ---------------- Low-level driver procedures ---------------- */
@@ -146,7 +146,7 @@ static int
trace_fill_rectangle(gx_device * dev, int x, int y, int w, int h,
gx_color_index color)
{
- dprintf5("fill_rectangle(%d, %d, %d, %d, 0x%lx)\n",
+ dmprintf5(dev->memory,"fill_rectangle(%d, %d, %d, %d, 0x%lx)\n",
x, y, w, h, (ulong)color);
return 0;
}
@@ -157,9 +157,9 @@ trace_copy_mono(gx_device * dev, const byte * data,
int x, int y, int w, int h,
gx_color_index zero, gx_color_index one)
{
- dprintf7("copy_mono(x=%d, y=%d, w=%d, h=%d, dx=%d, raster=%d, id=0x%lx,\n",
+ dmprintf7(dev->memory,"copy_mono(x=%d, y=%d, w=%d, h=%d, dx=%d, raster=%d, id=0x%lx,\n",
x, y, w, h, dx, raster, (ulong)id);
- dprintf2(" colors=(0x%lx,0x%lx))\n", (ulong)zero, (ulong)one);
+ dmprintf2(dev->memory," colors=(0x%lx,0x%lx))\n", (ulong)zero, (ulong)one);
return 0;
}
@@ -168,7 +168,7 @@ trace_copy_color(gx_device * dev, const byte * data,
int dx, int raster, gx_bitmap_id id,
int x, int y, int w, int h)
{
- dprintf7("copy_color(x=%d, y=%d, w=%d, h=%d, dx=%d, raster=%d, id=0x%lx)\n",
+ dmprintf7(dev->memory,"copy_color(x=%d, y=%d, w=%d, h=%d, dx=%d, raster=%d, id=0x%lx)\n",
x, y, w, h, dx, raster, (ulong)id);
return 0;
}
@@ -178,9 +178,9 @@ trace_copy_alpha(gx_device * dev, const byte * data, int dx, int raster,
gx_bitmap_id id, int x, int y, int w, int h,
gx_color_index color, int depth)
{
- dprintf7("copy_alpha(x=%d, y=%d, w=%d, h=%d, dx=%d, raster=%d, id=0x%lx,\n",
+ dmprintf7(dev->memory,"copy_alpha(x=%d, y=%d, w=%d, h=%d, dx=%d, raster=%d, id=0x%lx,\n",
x, y, w, h, dx, raster, (ulong)id);
- dprintf2(" color=0x%lx, depth=%d)\n", (ulong)color, depth);
+ dmprintf2(dev->memory," color=0x%lx, depth=%d)\n", (ulong)color, depth);
return 0;
}
@@ -191,13 +191,13 @@ trace_fill_mask(gx_device * dev,
const gx_drawing_color * pdcolor, int depth,
gs_logical_operation_t lop, const gx_clip_path * pcpath)
{
- dprintf7("fill_mask(x=%d, y=%d, w=%d, h=%d, dx=%d, raster=%d, id=0x%lx,\n",
+ dmprintf7(dev->memory,"fill_mask(x=%d, y=%d, w=%d, h=%d, dx=%d, raster=%d, id=0x%lx,\n",
x, y, w, h, dx, raster, (ulong)id);
- trace_drawing_color(" ", pdcolor);
- dprintf1(", depth=%d", depth);
- trace_lop(lop);
+ trace_drawing_color(dev->memory," ", pdcolor);
+ dmprintf1(dev->memory,", depth=%d", depth);
+ trace_lop(dev->memory,lop);
trace_clip(dev, pcpath);
- dputs(")\n");
+ dmputs(dev->memory,")\n");
return 0;
}
@@ -209,7 +209,7 @@ trace_fill_trapezoid(gx_device * dev,
const gx_drawing_color * pdcolor,
gs_logical_operation_t lop)
{
- dputs("**fill_trapezoid**\n");
+ dmputs(dev->memory,"**fill_trapezoid**\n");
return 0;
}
@@ -219,12 +219,12 @@ trace_fill_parallelogram(gx_device * dev,
fixed bx, fixed by, const gx_drawing_color * pdcolor,
gs_logical_operation_t lop)
{
- dprintf6("fill_parallelogram((%g,%g), (%g,%g), (%g,%g)",
+ dmprintf6(dev->memory,"fill_parallelogram((%g,%g), (%g,%g), (%g,%g)",
fixed2float(px), fixed2float(py), fixed2float(ax),
fixed2float(ay), fixed2float(bx), fixed2float(by));
- trace_drawing_color(", ", pdcolor);
- trace_lop(lop);
- dputs(")\n");
+ trace_drawing_color(dev->memory,", ", pdcolor);
+ trace_lop(dev->memory,lop);
+ dmputs(dev->memory,")\n");
return 0;
}
@@ -234,12 +234,12 @@ trace_fill_triangle(gx_device * dev,
const gx_drawing_color * pdcolor,
gs_logical_operation_t lop)
{
- dprintf6("fill_triangle((%g,%g), (%g,%g), (%g,%g)",
+ dmprintf6(dev->memory,"fill_triangle((%g,%g), (%g,%g), (%g,%g)",
fixed2float(px), fixed2float(py), fixed2float(ax),
fixed2float(ay), fixed2float(bx), fixed2float(by));
- trace_drawing_color(", ", pdcolor);
- trace_lop(lop);
- dputs(")\n");
+ trace_drawing_color(dev->memory,", ", pdcolor);
+ trace_lop(dev->memory,lop);
+ dmputs(dev->memory,")\n");
return 0;
}
@@ -250,12 +250,12 @@ trace_draw_thin_line(gx_device * dev,
gs_logical_operation_t lop,
fixed adjustx, fixed adjusty)
{
- dprintf4("draw_thin_line((%g,%g), (%g,%g)",
+ dmprintf4(dev->memory,"draw_thin_line((%g,%g), (%g,%g)",
fixed2float(fx0), fixed2float(fy0), fixed2float(fx1),
fixed2float(fy1));
- trace_drawing_color(", ", pdcolor);
- trace_lop(lop);
- dputs(")\n");
+ trace_drawing_color(dev->memory,", ", pdcolor);
+ trace_lop(dev->memory,lop);
+ dmputs(dev->memory,")\n");
return 0;
}
@@ -265,9 +265,9 @@ trace_strip_tile_rectangle(gx_device * dev, const gx_strip_bitmap * tiles,
gx_color_index color0, gx_color_index color1,
int px, int py)
{
- dprintf6("strip_tile_rectangle(x=%d, y=%d, w=%d, h=%d, colors=(0x%lx,0x%lx),\n",
+ dmprintf6(dev->memory,"strip_tile_rectangle(x=%d, y=%d, w=%d, h=%d, colors=(0x%lx,0x%lx),\n",
x, y, w, h, (ulong)color0, (ulong)color1);
- dprintf8(" size=(%d,%d) shift %u, rep=(%u,%u) shift %u, phase=(%d,%d))\n",
+ dmprintf8(dev->memory," size=(%d,%d) shift %u, rep=(%u,%u) shift %u, phase=(%d,%d))\n",
tiles->size.x, tiles->size.y, tiles->shift,
tiles->rep_width, tiles->rep_height, tiles->rep_shift, px, py);
return 0;
@@ -282,7 +282,7 @@ trace_strip_copy_rop(gx_device * dev, const byte * sdata, int sourcex,
int x, int y, int width, int height,
int phase_x, int phase_y, gs_logical_operation_t lop)
{
- dputs("**strip_copy_rop**\n");
+ dmputs(dev->memory,"**strip_copy_rop**\n");
return 0;
}
@@ -296,7 +296,7 @@ trace_strip_copy_rop2(gx_device * dev, const byte * sdata, int sourcex,
int phase_x, int phase_y, gs_logical_operation_t lop,
uint plane_height)
{
- dputs("**strip_copy_rop2**\n");
+ dmputs(dev->memory,"**strip_copy_rop2**\n");
return 0;
}
@@ -308,15 +308,15 @@ trace_fill_path(gx_device * dev, const gs_imager_state * pis,
const gx_drawing_color * pdcolor,
const gx_clip_path * pcpath)
{
- dputs("fill_path({\n");
+ dmputs(dev->memory,"fill_path({\n");
trace_path(ppath);
- trace_drawing_color("}, ", pdcolor);
- dprintf4(", rule=%d, adjust=(%g,%g), flatness=%g",
+ trace_drawing_color(dev->memory,"}, ", pdcolor);
+ dmprintf4(dev->memory,", rule=%d, adjust=(%g,%g), flatness=%g",
params->rule, fixed2float(params->adjust.x),
fixed2float(params->adjust.y), params->flatness);
trace_clip(dev, pcpath);
/****** pis ******/
- dputs(")\n");
+ dmputs(dev->memory,")\n");
return 0;
}
@@ -326,13 +326,13 @@ trace_stroke_path(gx_device * dev, const gs_imager_state * pis,
const gx_drawing_color * pdcolor,
const gx_clip_path * pcpath)
{
- dputs("stroke_path({\n");
+ dmputs(dev->memory,"stroke_path({\n");
trace_path(ppath);
- trace_drawing_color("}, ", pdcolor);
- dprintf1(", flatness=%g", params->flatness);
+ trace_drawing_color(dev->memory,"}, ", pdcolor);
+ dmprintf1(dev->memory,", flatness=%g", params->flatness);
trace_clip(dev, pcpath);
/****** pis ******/
- dputs(")\n");
+ dmputs(dev->memory,")\n");
return 0;
}
@@ -352,16 +352,16 @@ trace_plane_data(gx_image_enum_common_t * info,
trace_image_enum_t *pie = (trace_image_enum_t *)info;
int i;
- dprintf1("image_plane_data(height=%d", height);
+ dmprintf1(dev->memory,"image_plane_data(height=%d", height);
for (i = 0; i < pie->num_planes; ++i) {
if (planes[i].data)
- dprintf4(", {depth=%d, width=%d, dx=%d, raster=%u}",
+ dmprintf4(dev->memory,", {depth=%d, width=%d, dx=%d, raster=%u}",
pie->plane_depths[i], pie->plane_widths[i],
planes[i].data_x, planes[i].raster);
else
- dputs(", -");
+ dmputs(dev->memory,", -");
}
- dputs(")\n");
+ dmputs(dev->memory,")\n");
*rows_used = height;
return (pie->rows_left -= height) <= 0;
}
@@ -390,7 +390,7 @@ trace_begin_typed_image(gx_device * dev, const gs_imager_state * pis,
const gs_pixel_image_t *ppi = (const gs_pixel_image_t *)pim;
int ncomp;
- dprintf7("begin_typed_image(type=%d, ImageMatrix=[%g %g %g %g %g %g]",
+ dmprintf7(dev->memory,"begin_typed_image(type=%d, ImageMatrix=[%g %g %g %g %g %g]",
pim->type->index, pim->ImageMatrix.xx, pim->ImageMatrix.xy,
pim->ImageMatrix.yx, pim->ImageMatrix.yy,
pim->ImageMatrix.tx, pim->ImageMatrix.ty);
@@ -408,7 +408,7 @@ trace_begin_typed_image(gx_device * dev, const gs_imager_state * pis,
ncomp = gs_color_space_num_components(ppi->ColorSpace) + 1;
break;
case 2: /* no data */
- dputs(")\n");
+ dmputs(dev->memory, ")\n");
return 1;
default:
goto dflt;
@@ -423,14 +423,14 @@ trace_begin_typed_image(gx_device * dev, const gs_imager_state * pis,
ppi->format) < 0
)
goto dflt;
- dprintf4("\n Width=%d, Height=%d, BPC=%d, num_components=%d)\n",
+ dmprintf4(dev->memory,"\n Width=%d, Height=%d, BPC=%d, num_components=%d)\n",
ppi->Width, ppi->Height, ppi->BitsPerComponent, ncomp);
pie->memory = memory;
pie->rows_left = ppi->Height;
*pinfo = (gx_image_enum_common_t *)pie;
return 0;
dflt:
- dputs(") DEFAULTED\n");
+ dmputs(dev->memory,") DEFAULTED\n");
return gx_default_begin_typed_image(dev, pis, pmat, pim, prect, pdcolor,
pcpath, memory, pinfo);
}
@@ -464,55 +464,55 @@ trace_text_begin(gx_device * dev, gs_imager_state * pis,
gs_text_enum_t *pte;
int code;
- dputs("text_begin(");
+ dmputs(dev->memory,"text_begin(");
for (i = 0; i < countof(tags); ++i)
if (text->operation & (1 << i)) {
if (tags[i])
- dprintf1("%s ", tags[i]);
+ dmprintf1(dev->memory,"%s ", tags[i]);
else
- dprintf1("%d? ", i);
+ dmprintf1(dev->memory,"%d? ", i);
}
- dprintf1("font=%s\n text=(", font->font_name.chars);
+ dmprintf1(dev->memory,"font=%s\n text=(", font->font_name.chars);
if (text->operation & TEXT_FROM_SINGLE_CHAR)
- dprintf1("0x%lx", (ulong)text->data.d_char);
+ dmprintf1(dev->memory,"0x%lx", (ulong)text->data.d_char);
else if (text->operation & TEXT_FROM_SINGLE_GLYPH)
- dprintf1("0x%lx", (ulong)text->data.d_glyph);
+ dmprintf1(dev->memory,"0x%lx", (ulong)text->data.d_glyph);
else
for (i = 0; i < text->size; ++i) {
if (text->operation & TEXT_FROM_STRING)
- dputc(text->data.bytes[i]);
+ dmputc(dev->memory,text->data.bytes[i]);
else
- dprintf1("0x%lx ",
+ dmprintf1(dev->memory,"0x%lx ",
(text->operation & TEXT_FROM_GLYPHS ?
(ulong)text->data.glyphs[i] :
(ulong)text->data.chars[i]));
}
- dprintf1(")\n size=%u", text->size);
+ dmprintf1(dev->memory,")\n size=%u", text->size);
if (text->operation & TEXT_ADD_TO_ALL_WIDTHS)
- dprintf2(", delta_all=(%g,%g)", text->delta_all.x, text->delta_all.y);
+ dmprintf2(dev->memory,", delta_all=(%g,%g)", text->delta_all.x, text->delta_all.y);
if (text->operation & TEXT_ADD_TO_SPACE_WIDTH) {
- dprintf3(", space=0x%lx, delta_space=(%g,%g)",
+ dmprintf3(dev->memory,", space=0x%lx, delta_space=(%g,%g)",
(text->operation & TEXT_FROM_GLYPHS ?
(ulong)text->space.s_glyph : (ulong)text->space.s_char),
text->delta_space.x, text->delta_space.y);
}
if (text->operation & TEXT_REPLACE_WIDTHS) {
- dputs("\n widths=");
+ dmputs(dev->memory,"\n widths=");
for (i = 0; i < text->widths_size; ++i) {
if (text->x_widths)
- dprintf1("(%g,", text->x_widths[i]);
+ dmprintf1(dev->memory,"(%g,", text->x_widths[i]);
else
- dputs("(,");
+ dmputs(dev->memory,"(,");
if (text->y_widths)
- dprintf1("%g)",
+ dmprintf1(dev->memory,"%g)",
(text->y_widths == text->x_widths ?
text->y_widths[++i] : text->y_widths[i]));
else
- dputs(")");
+ dmputs(dev->memory,")");
}
}
if (text->operation & TEXT_DO_DRAW)
- trace_drawing_color(", ", pdcolor);
+ trace_drawing_color(dev->memory,", ", pdcolor);
/*
* We can't do it if CHAR*PATH or INTERVENE, or if (RETURN_WIDTH and not
* REPLACE_WIDTHS and we can't get the widths from the font).
@@ -589,13 +589,13 @@ trace_text_begin(gx_device * dev, gs_imager_state * pis,
if (code < 0)
goto dfree;
}
- dputs(")\n");
+ dmputs(dev->memory,")\n");
*ppenum = pte;
return 0;
dfree:
gs_free_object(memory, pte, "trace_text_begin");
dflt:
- dputs(") DEFAULTED\n");
+ dmputs(dev->memory,") DEFAULTED\n");
return gx_default_text_begin(dev, pis, text, font, path, pdcolor,
pcpath, memory, ppenum);
}
diff --git a/gs/base/gdevtsep.c b/gs/base/gdevtsep.c
index ad0e8ff43..66fc5342f 100644
--- a/gs/base/gdevtsep.c
+++ b/gs/base/gdevtsep.c
@@ -1206,9 +1206,9 @@ tiffsep_get_color_comp_index(gx_device * dev, const char * pname,
if (index < 0 && component_type == SEPARATION_NAME &&
pdev->warning_given == false &&
pdev->devn_params.num_separation_order_names == 0) {
- dlprintf("**** Max spot colorants reached.\n");
- dlprintf("**** Some colorants will be converted to equivalent CMYK values.\n");
- dlprintf("**** If this is a Postscript file, try using the -dMaxSpots= option.\n");
+ dmlprintf(dev->memory, "**** Max spot colorants reached.\n");
+ dmlprintf(dev->memory, "**** Some colorants will be converted to equivalent CMYK values.\n");
+ dmlprintf(dev->memory, "**** If this is a Postscript file, try using the -dMaxSpots= option.\n");
pdev->warning_given = true;
}
return index;
@@ -1674,9 +1674,9 @@ threshold_from_order( gx_ht_order *d_order, int *Width, int *Height, gs_memory_t
#ifdef DEBUG
if ( gs_debug_c('h') ) {
- dprintf2(" width=%d, height=%d,",
+ dmprintf2(memory, " width=%d, height=%d,",
d_order->width, d_order->height );
- dprintf2(" num_levels=%d, raster=%d\n",
+ dmprintf2(memory, " num_levels=%d, raster=%d\n",
d_order->num_levels, d_order->raster );
}
#endif
@@ -1707,12 +1707,12 @@ if ( gs_debug_c('h') ) {
int row, col;
#ifdef DEBUG
if ( gs_debug_c('h') )
- dprintf2(" level[%3d]=%3d\n", l, d_order->levels[l]);
+ dmprintf2(memory, " level[%3d]=%3d\n", l, d_order->levels[l]);
#endif
for( j=d_order->levels[prev_l]; j<d_order->levels[l]; j++) {
#ifdef DEBUG
if ( gs_debug_c('h') )
- dprintf2(" bits.offset=%3d, bits.mask=%8x ",
+ dmprintf2(memory, " bits.offset=%3d, bits.mask=%8x ",
bits[j].offset, bits[j].mask);
#endif
row = bits[j].offset / d_order->raster;
@@ -1723,7 +1723,7 @@ if ( gs_debug_c('h') ) {
col += 8 * ( bits[j].offset - (row * d_order->raster) );
#ifdef DEBUG
if ( gs_debug_c('h') )
- dprintf3("row=%2d, col=%2d, t_level=%3d\n",
+ dmprintf3(memory, "row=%2d, col=%2d, t_level=%3d\n",
row, col, t_level);
#endif
if( col < (int)d_order->width ) {
@@ -1743,10 +1743,10 @@ if ( gs_debug_c('h') ) {
#ifdef DEBUG
if (gs_debug_c('h')) {
for( i=0; i<(int)d_order->height; i++ ) {
- dprintf1("threshold array row %3d= ", i);
+ dmprintf1(memory, "threshold array row %3d= ", i);
for( j=(int)d_order->width-1; j>=0; j-- )
- dprintf1("%3d ", *(thresh+j+(i*d_order->width)) );
- dprintf("\n");
+ dmprintf1(memory, "%3d ", *(thresh+j+(i*d_order->width)) );
+ dmprintf(memory, "\n");
}
}
#endif
@@ -1789,7 +1789,7 @@ tiffsep_print_page(gx_device_printer * pdev, FILE * file)
for (sep_num = 0; sep_num < num_spot; sep_num++) {
copy_separation_name(tfdev, name,
MAX_FILE_NAME_SIZE - base_filename_length - SUFFIX_SIZE, sep_num);
- dlprintf1("%%%%SeparationName: %s\n", name);
+ dmlprintf1(pdev->memory, "%%%%SeparationName: %s\n", name);
}
}
@@ -1805,7 +1805,7 @@ tiffsep_print_page(gx_device_printer * pdev, FILE * file)
pdev->color_info.depth = 32; /* Create directory for 32 bit cmyk */
if (tfdev->Compression==COMPRESSION_NONE &&
height > ((unsigned long) 0xFFFFFFFF - ftell(file))/(width*4)) { /* note width is never 0 in print_page */
- dprintf("CMYK composite file would be too large! Reduce resolution or enable compression.\n");
+ dmprintf(pdev->memory, "CMYK composite file would be too large! Reduce resolution or enable compression.\n");
return_error(gs_error_rangecheck); /* this will overflow 32 bits */
}
@@ -1841,7 +1841,7 @@ tiffsep_print_page(gx_device_printer * pdev, FILE * file)
num_std_colorants, num_order, num_spot);
if (!num_order && num_comp < num_std_colorants + num_spot) {
- dlprintf("Warning: skipping one or more colour separations, see: Devices.htm#TIFF\n");
+ dmlprintf(pdev->memory, "Warning: skipping one or more colour separations, see: Devices.htm#TIFF\n");
}
for (comp_num = 0; comp_num < num_comp; comp_num++ ) {
@@ -2296,7 +2296,7 @@ cleanup:
* If we have any non encodable pixels then signal an error.
*/
if (non_encodable_count) {
- dlprintf1("WARNING: Non encodable pixels = %d\n", non_encodable_count);
+ dmlprintf1(pdev->memory, "WARNING: Non encodable pixels = %d\n", non_encodable_count);
return_error(gs_error_rangecheck);
}
diff --git a/gs/base/gdevx.c b/gs/base/gdevx.c
index 67da4081f..a58fee810 100644
--- a/gs/base/gdevx.c
+++ b/gs/base/gdevx.c
@@ -362,8 +362,8 @@ x_fill_rectangle(gx_device * dev,
if (xdev->bpixmap != (Pixmap) 0) {
x_update_add(xdev, x, y, w, h);
}
- if_debug5('F', "[F] fill (%d,%d):(%d,%d) %ld\n",
- x, y, w, h, (long)color);
+ if_debug5m('F', dev->memory, "[F] fill (%d,%d):(%d,%d) %ld\n",
+ x, y, w, h, (long)color);
return 0;
}
@@ -603,8 +603,8 @@ x_copy_color(gx_device * dev,
code = x_copy_image(xdev, base, sourcex, raster, x, y, w, h);
if (xdev->bpixmap != (Pixmap) 0)
x_update_add(xdev, x, y, w, h);
- if_debug4('F', "[F] copy_color (%d,%d):(%d,%d)\n",
- x, y, w, h);
+ if_debug4m('F', dev->memory, "[F] copy_color (%d,%d):(%d,%d)\n",
+ x, y, w, h);
return code;
}
@@ -693,8 +693,8 @@ x_strip_tile_rectangle(gx_device * dev, const gx_strip_bitmap * tiles,
if (xdev->bpixmap != (Pixmap) 0) {
x_update_add(xdev, x, y, w, h);
}
- if_debug6('F', "[F] tile (%d,%d):(%d,%d) %ld,%ld\n",
- x, y, w, h, lzero, lone);
+ if_debug6m('F', dev->memory, "[F] tile (%d,%d):(%d,%d) %ld,%ld\n",
+ x, y, w, h, lzero, lone);
return 0;
}
@@ -1011,12 +1011,12 @@ set_tile(gx_device * dev, const gx_strip_bitmap * tile)
if (gs_debug['H']) {
int i;
- dlprintf4("[H] 0x%lx: width=%d height=%d raster=%d\n",
+ dmlprintf4(xdev->memory, "[H] 0x%lx: width=%d height=%d raster=%d\n",
(ulong) tile->data, tile->size.x, tile->size.y, tile->raster);
- dlputs("");
+ dmlputs(xdev->memory, "");
for (i = 0; i < tile->raster * tile->size.y; i++)
- dprintf1(" %02x", tile->data[i]);
- dputc('\n');
+ dmprintf1(xdev->memory, " %02x", tile->data[i]);
+ dmputc(xdev->memory, '\n');
}
#endif
XSetTile(xdev->dpy, xdev->gc, xdev->ht.no_pixmap); /* *** X bug *** */
diff --git a/gs/base/gdevxcf.c b/gs/base/gdevxcf.c
index bc3d04f42..12aeb766b 100644
--- a/gs/base/gdevxcf.c
+++ b/gs/base/gdevxcf.c
@@ -1192,7 +1192,7 @@ xcf_write_header(xcf_write_ctx *xc, xcf_device *pdev)
for (channel_idx = 0; channel_idx < n_extra_channels; channel_idx++) {
const gs_param_string *separation_name =
pdev->separation_names.names[channel_idx];
- dlprintf1("tile offset: %d\n", tile_offset);
+ dmlprintf1(pdev->memory, "tile offset: %d\n", tile_offset);
xcf_write_32(xc, tile_offset);
tile_offset += xcf_channel_size(xc, separation_name->size);
}
@@ -1410,7 +1410,7 @@ xcf_write_footer(xcf_write_ctx *xc, xcf_device *pdev)
int offset;
int tile_idx;
- dlprintf2("actual tile offset: %d %d\n", xc->offset, (int)arch_sizeof_color_index);
+ dmlprintf2(pdev->memory, "actual tile offset: %d %d\n", xc->offset, (int)arch_sizeof_color_index);
xcf_write_32(xc, xc->width);
xcf_write_32(xc, xc->height);
xcf_write_32(xc, separation_name->size + 1);
diff --git a/gs/base/gdevxcmp.c b/gs/base/gdevxcmp.c
index 233a5c094..d91e78dd1 100644
--- a/gs/base/gdevxcmp.c
+++ b/gs/base/gdevxcmp.c
@@ -588,16 +588,16 @@ gdev_x_map_rgb_color(gx_device * dev, const gx_color_value cv[])
X_color_value mb = b & xdev->cman.match_mask.blue;
if ((mr | mg | mb) == 0) { /* i.e., all 0 */
- if_debug4('C', "[cX]%u,%u,%u => foreground = %lu\n",
- r, g, b, (ulong) xdev->foreground);
+ if_debug4m('C', dev->memory, "[cX]%u,%u,%u => foreground = %lu\n",
+ r, g, b, (ulong) xdev->foreground);
return xdev->foreground;
}
if (mr == xdev->cman.match_mask.red &&
mg == xdev->cman.match_mask.green &&
mb == xdev->cman.match_mask.blue
) {
- if_debug4('C', "[cX]%u,%u,%u => background = %lu\n",
- r, g, b, (ulong) xdev->background);
+ if_debug4m('C', dev->memory, "[cX]%u,%u,%u => background = %lu\n",
+ r, g, b, (ulong) xdev->background);
return xdev->background;
}
}
@@ -639,11 +639,11 @@ gdev_x_map_rgb_color(gx_device * dev, const gx_color_value cv[])
cr * cmap->red_mult + cg * cmap->green_mult +
cb * cmap->blue_mult) + cmap->base_pixel;
- if_debug4('C', "[cX]%u,%u,%u (std cmap) => %lu\n",
- r, g, b, pixel); /* NB: gx_color_index size is 4 or 8 */
+ if_debug4m('C', dev->memory, "[cX]%u,%u,%u (std cmap) => %lu\n",
+ r, g, b, pixel); /* NB: gx_color_index size is 4 or 8 */
return pixel;
}
- if_debug3('C', "[cX]%u,%u,%u (std cmap fails)\n", r, g, b);
+ if_debug3m('C', dev->memory, "[cX]%u,%u,%u (std cmap fails)\n", r, g, b);
} else {
uint cr;
X_color_value cvr;
@@ -653,10 +653,10 @@ gdev_x_map_rgb_color(gx_device * dev, const gx_color_value cv[])
if ((iabs((int)r - (int)cvr) & xdev->cman.match_mask.red) == 0) {
gx_color_index pixel = cr * cmap->red_mult + cmap->base_pixel;
- if_debug2('C', "[cX]%u (std cmap) => %lu\n", r, pixel);
+ if_debug2m('C', dev->memory, "[cX]%u (std cmap) => %lu\n", r, pixel);
return pixel;
}
- if_debug1('C', "[cX]%u (std cmap fails)\n", r);
+ if_debug1m('C', dev->memory, "[cX]%u (std cmap fails)\n", r);
}
} else
#endif
@@ -689,11 +689,11 @@ gdev_x_map_rgb_color(gx_device * dev, const gx_color_value cv[])
gx_color_index pixel =
xdev->cman.dither_ramp[CUBE_INDEX(cr, cg, cb)];
- if_debug4('C', "[cX]%u,%u,%u (dither cube) => %lu\n",
+ if_debug4m('C', dev->memory, "[cX]%u,%u,%u (dither cube) => %lu\n",
r, g, b, pixel);
return pixel;
}
- if_debug3('C', "[cX]%u,%u,%u (dither cube fails)\n", r, g, b);
+ if_debug3m('C', dev->memory, "[cX]%u,%u,%u (dither cube fails)\n", r, g, b);
} else {
uint cr;
X_color_value cvr;
@@ -705,10 +705,10 @@ gdev_x_map_rgb_color(gx_device * dev, const gx_color_value cv[])
if ((iabs((int)r - (int)cvr) & xdev->cman.match_mask.red) == 0) {
gx_color_index pixel = xdev->cman.dither_ramp[cr];
- if_debug2('C', "[cX]%u (dither ramp) => %lu\n", r, pixel);
+ if_debug2m('C', dev->memory, "[cX]%u (dither ramp) => %lu\n", r, pixel);
return pixel;
}
- if_debug1('C', "[cX]%u (dither ramp fails)\n", r);
+ if_debug1m('C', dev->memory, "[cX]%u (dither ramp fails)\n", r);
}
}
@@ -729,12 +729,12 @@ gdev_x_map_rgb_color(gx_device * dev, const gx_color_value cv[])
xdev->cman.dynamic.colors[i] = xcp;
}
if (xcp->color.pad) {
- if_debug4('C', "[cX]%u,%u,%u (dynamic) => %lu\n",
- r, g, b, (ulong) xcp->color.pixel);
+ if_debug4m('C', dev->memory, "[cX]%u,%u,%u (dynamic) => %lu\n",
+ r, g, b, (ulong) xcp->color.pixel);
return xcp->color.pixel;
} else {
- if_debug3('C', "[cX]%u,%u,%u (dynamic) => missing\n",
- r, g, b);
+ if_debug3m('C', dev->memory, "[cX]%u,%u,%u (dynamic) => missing\n",
+ r, g, b);
return gx_no_color_index;
}
}
@@ -743,7 +743,7 @@ gdev_x_map_rgb_color(gx_device * dev, const gx_color_value cv[])
/* ask the X server and add an entry. */
/* First check if dynamic table is exhausted */
if (xdev->cman.dynamic.used > xdev->cman.dynamic.max_used) {
- if_debug3('C', "[cX]%u,%u,%u (dynamic) => full\n", r, g, b);
+ if_debug3m('C', dev->memory, "[cX]%u,%u,%u (dynamic) => full\n", r, g, b);
return gx_no_color_index;
}
xcp = (x11_color_t *)
@@ -759,18 +759,18 @@ gdev_x_map_rgb_color(gx_device * dev, const gx_color_value cv[])
if (x_alloc_color(xdev, &xc)) {
xcp->color.pixel = xc.pixel;
xcp->color.pad = true;
- if_debug5('c', "[cX]0x%x,0x%x,0x%x (dynamic) => added [%d]%lu\n",
- dr, dg, db, xdev->cman.dynamic.used - 1,
- (ulong)xc.pixel);
+ if_debug5m('c', dev->memory, "[cX]0x%x,0x%x,0x%x (dynamic) => added [%d]%lu\n",
+ dr, dg, db, xdev->cman.dynamic.used - 1,
+ (ulong)xc.pixel);
return xc.pixel;
} else {
xcp->color.pad = false;
- if_debug3('c', "[cX]0x%x,0x%x,0x%x (dynamic) => can't alloc\n",
- dr, dg, db);
+ if_debug3m('c', dev->memory, "[cX]0x%x,0x%x,0x%x (dynamic) => can't alloc\n",
+ dr, dg, db);
return gx_no_color_index;
}
}
- if_debug3('C', "[cX]%u,%u,%u fails\n", r, g, b);
+ if_debug3m('C', dev->memory, "[cX]%u,%u,%u fails\n", r, g, b);
return gx_no_color_index;
#undef CV_DENOM
}
diff --git a/gs/base/gp_unifs.c b/gs/base/gp_unifs.c
index d312237e2..81ecb98c6 100644
--- a/gs/base/gp_unifs.c
+++ b/gs/base/gp_unifs.c
@@ -188,23 +188,24 @@ gs_private_st_ptrs3(st_file_enum, struct file_enum_s, "file_enum",
#ifdef DEBUG
static bool
wmatch(const byte * str, uint len, const byte * pstr, uint plen,
- const string_match_params * psmp)
+ const gs_memory_t *mem)
{
- bool match = string_match(str, len, pstr, plen, psmp);
+ bool match = string_match(str, len, pstr, plen, NULL);
if (gs_debug_c('e')) {
int i;
- dlputs("[e]string_match(\"");
+ dmlputs(mem, "[e]string_match(\"");
for (i=0; i<len; i++)
- errprintf_nomem("%c", str[i]);
- dputs("\", \"");
+ errprintf(mem, "%c", str[i]);
+ dmputs(mem, "\", \"");
for (i=0; i<plen; i++)
- errprintf_nomem("%c", pstr[i]);
- dprintf1("\") = %s\n", (match ? "TRUE" : "false"));
+ errprintf(mem, "%c", pstr[i]);
+ dmprintf1(mem, "\") = %s\n", (match ? "TRUE" : "false"));
}
return match;
}
-#define string_match wmatch
+#else
+#define wmatch(S,L,PS,PL,M) string_match(S,L,PS,PL,NULL)
#endif
/* Search a string backward for a character. */
@@ -331,7 +332,7 @@ gp_enumerate_files_next(file_enum * pfen, char *ptr, uint maxlen)
if (pfen->first_time) {
pfen->dirp = ((worklen == 0) ? opendir(".") : opendir(work));
- if_debug1('e', "[e]file_enum:First-Open '%s'\n", work);
+ if_debug1m('e', pfen->memory, "[e]file_enum:First-Open '%s'\n", work);
pfen->first_time = false;
if (pfen->dirp == 0) { /* first opendir failed */
gp_enumerate_files_close(pfen);
@@ -342,7 +343,7 @@ gp_enumerate_files_next(file_enum * pfen, char *ptr, uint maxlen)
if (de == 0) { /* No more entries in this directory */
char *p;
- if_debug0('e', "[e]file_enum:Closedir\n");
+ if_debug0m('e', pfen->memory, "[e]file_enum:Closedir\n");
closedir(pfen->dirp);
/* Back working directory and matching pattern up one level */
p = rchr(work, '/', worklen);
@@ -360,10 +361,10 @@ gp_enumerate_files_next(file_enum * pfen, char *ptr, uint maxlen)
pathead = 0;
if (popdir(pfen)) { /* Back up the directory tree. */
- if_debug1('e', "[e]file_enum:Dir popped '%s'\n", work);
+ if_debug1m('e', pfen->memory, "[e]file_enum:Dir popped '%s'\n", work);
goto top;
} else {
- if_debug0('e', "[e]file_enum:Dirstack empty\n");
+ if_debug0m('e', pfen->memory, "[e]file_enum:Dirstack empty\n");
gp_enumerate_files_close(pfen);
return ~(uint) 0;
}
@@ -387,7 +388,7 @@ gp_enumerate_files_next(file_enum * pfen, char *ptr, uint maxlen)
}
/* Test for a match at this directory level */
- if (!string_match((byte *) work, len, (byte *) pattern, pathead, NULL))
+ if (!wmatch((byte *) work, len, (byte *) pattern, pathead, pfen->memory))
goto top;
/* Perhaps descend into subdirectories */
@@ -422,8 +423,8 @@ gp_enumerate_files_next(file_enum * pfen, char *ptr, uint maxlen)
char save_end = pattern[pathead];
pattern[pathead] = 0;
- if_debug2('e', "[e]file_enum:fname='%s', p='%s'\n",
- work, pattern);
+ if_debug2m('e', pfen->memory, "[e]file_enum:fname='%s', p='%s'\n",
+ work, pattern);
pattern[pathead] = save_end;
}
#endif /* DEBUG */
@@ -456,8 +457,8 @@ gp_enumerate_files_next(file_enum * pfen, char *ptr, uint maxlen)
} else
DO_NOTHING; /* >>> e_VMerror!!! */
- if_debug1('e', "[e]file_enum:Dir pushed '%s'\n",
- work);
+ if_debug1m('e', pfen->memory, "[e]file_enum:Dir pushed '%s'\n",
+ work);
worklen = len;
pfen->dirp = dp;
goto top;
@@ -477,7 +478,7 @@ gp_enumerate_files_close(file_enum * pfen)
{
gs_memory_t *mem = pfen->memory;
- if_debug0('e', "[e]file_enum:Cleanup\n");
+ if_debug0m('e', mem, "[e]file_enum:Cleanup\n");
while (popdir(pfen)) /* clear directory stack */
DO_NOTHING;
gs_free_object(mem, (byte *) pfen->work,
diff --git a/gs/base/gp_unix.c b/gs/base/gp_unix.c
index 6cc44c933..bc8b7f619 100644
--- a/gs/base/gp_unix.c
+++ b/gs/base/gp_unix.c
@@ -311,6 +311,7 @@ typedef struct {
FcConfig* fc; /* FontConfig library handle */
FcFontSet* font_list; /* FontConfig font list */
char name[255]; /* name of last font */
+ gs_memory_t *mem; /* Memory pointer */
} unix_fontenum_t;
#endif
@@ -328,13 +329,14 @@ void *gp_enumerate_fonts_init(gs_memory_t *mem)
state->index = 0;
state->fc = NULL;
state->font_list = NULL;
+ state->mem = mem;
/* Load the fontconfig library */
state->fc = FcInitLoadConfigAndFonts();
if (state->fc == NULL) {
free(state);
state = NULL;
- dlprintf("destroyed state - fontconfig init failed");
+ dmlprintf(mem, "destroyed state - fontconfig init failed");
return NULL; /* Failed to open fontconfig library */
}
@@ -384,31 +386,31 @@ int gp_enumerate_fonts_next(void *enum_state, char **fontname, char **path)
result = FcPatternGetString (font, FC_FAMILY, 0, &family_fc);
if (result != FcResultMatch || family_fc == NULL) {
- dlprintf ("DEBUG: FC_FAMILY mismatch\n");
+ dmlprintf(state->mem, "DEBUG: FC_FAMILY mismatch\n");
return 0;
}
result = FcPatternGetString (font, FC_FILE, 0, &file_fc);
if (result != FcResultMatch || file_fc == NULL) {
- dlprintf ("DEBUG: FC_FILE mismatch\n");
+ dmlprintf(state->mem, "DEBUG: FC_FILE mismatch\n");
return 0;
}
result = FcPatternGetBool (font, FC_OUTLINE, 0, &outline_fc);
if (result != FcResultMatch) {
- dlprintf1 ("DEBUG: FC_OUTLINE failed to match on %s\n", (char*)family_fc);
+ dmlprintf1(state->mem, "DEBUG: FC_OUTLINE failed to match on %s\n", (char*)family_fc);
return 0;
}
result = FcPatternGetInteger (font, FC_SLANT, 0, &slant_fc);
if (result != FcResultMatch) {
- dlprintf ("DEBUG: FC_SLANT didn't match\n");
+ dmlprintf(state->mem, "DEBUG: FC_SLANT didn't match\n");
return 0;
}
result = FcPatternGetInteger (font, FC_WEIGHT, 0, &weight_fc);
if (result != FcResultMatch) {
- dlprintf ("DEBUG: FC_WEIGHT didn't match\n");
+ dmlprintf(state->mem, "DEBUG: FC_WEIGHT didn't match\n");
return 0;
}
diff --git a/gs/base/gsalloc.c b/gs/base/gsalloc.c
index 2c8bd644c..0d4a62e16 100644
--- a/gs/base/gsalloc.c
+++ b/gs/base/gsalloc.c
@@ -54,28 +54,28 @@ static void
alloc_trace(const char *chars, gs_ref_memory_t * imem, client_name_t cname,
gs_memory_type_ptr_t stype, uint size, const void *ptr)
{
- if_debug7('A', "[a%d%s]%s %s(%u) %s0x%lx\n",
- alloc_trace_space(imem), chars, client_name_string(cname),
- (ptr == 0 || stype == 0 ? "" :
- struct_type_name_string(stype)),
- size, (chars[1] == '+' ? "= " : ""), (ulong) ptr);
+ if_debug7m('A', (const gs_memory_t *)imem, "[a%d%s]%s %s(%u) %s0x%lx\n",
+ alloc_trace_space(imem), chars, client_name_string(cname),
+ (ptr == 0 || stype == 0 ? "" :
+ struct_type_name_string(stype)),
+ size, (chars[1] == '+' ? "= " : ""), (ulong) ptr);
}
static bool
alloc_size_is_ok(gs_memory_type_ptr_t stype)
{
return (stype->ssize > 0 && stype->ssize < 0x200000);
}
-# define ALLOC_CHECK_SIZE(stype)\
+# define ALLOC_CHECK_SIZE(mem,stype)\
BEGIN\
if (!alloc_size_is_ok(stype)) {\
- lprintf2("size of struct type 0x%lx is 0x%lx!\n",\
+ mlprintf2(mem,"size of struct type 0x%lx is 0x%lx!\n",\
(ulong)(stype), (ulong)((stype)->ssize));\
return 0;\
}\
END
#else
# define alloc_trace(chars, imem, cname, stype, size, ptr) DO_NOTHING
-# define ALLOC_CHECK_SIZE(stype) DO_NOTHING
+# define ALLOC_CHECK_SIZE(mem,stype) DO_NOTHING
#endif
/*
@@ -386,12 +386,13 @@ ialloc_set_limit(register gs_ref_memory_t * mem)
}
} else
mem->limit = min(max_allocated, mem->gc_allocated + FORCE_GC_LIMIT);
- if_debug7('0', "[0]space=%d, max_vm=%ld, prev.alloc=%ld, enabled=%d,\n\
- gc_alloc=%ld, threshold=%ld => limit=%ld\n",
- mem->space, (long)mem->gc_status.max_vm,
- (long)mem->previous_status.allocated,
- mem->gc_status.enabled, (long)mem->gc_allocated,
- (long)mem->gc_status.vm_threshold, (long)mem->limit);
+ if_debug7m('0', (const gs_memory_t *)mem,
+ "[0]space=%d, max_vm=%ld, prev.alloc=%ld, enabled=%d,\n"
+ " gc_alloc=%ld, threshold=%ld => limit=%ld\n",
+ mem->space, (long)mem->gc_status.max_vm,
+ (long)mem->previous_status.allocated,
+ mem->gc_status.enabled, (long)mem->gc_allocated,
+ (long)mem->gc_status.vm_threshold, (long)mem->limit);
}
/*
@@ -594,7 +595,7 @@ i_alloc_struct(gs_memory_t * mem, gs_memory_type_ptr_t pstype,
return NULL;
#endif
- ALLOC_CHECK_SIZE(pstype);
+ ALLOC_CHECK_SIZE(mem,pstype);
IF_FREELIST_ALLOC(obj, imem, size, pstype, pfl)
alloc_trace(":+<f", imem, cname, pstype, size, obj);
ELSEIF_BIG_FREELIST_ALLOC(obj, imem, size, pstype)
@@ -626,7 +627,7 @@ i_alloc_struct_immovable(gs_memory_t * mem, gs_memory_type_ptr_t pstype,
return NULL;
#endif
- ALLOC_CHECK_SIZE(pstype);
+ ALLOC_CHECK_SIZE(mem,pstype);
obj = alloc_obj(imem, size, pstype, ALLOC_IMMOVABLE | ALLOC_DIRECT, cname);
alloc_trace("|+<.", imem, cname, pstype, size, obj);
return obj;
@@ -646,10 +647,10 @@ i_alloc_byte_array(gs_memory_t * mem, uint num_elements, uint elt_size,
obj = alloc_obj(imem, (ulong) num_elements * elt_size,
&st_bytes, ALLOC_DIRECT, cname);
- if_debug6('A', "[a%d:+b.]%s -bytes-*(%lu=%u*%u) = 0x%lx\n",
- alloc_trace_space(imem), client_name_string(cname),
- (ulong) num_elements * elt_size,
- num_elements, elt_size, (ulong) obj);
+ if_debug6m('A', mem, "[a%d:+b.]%s -bytes-*(%lu=%u*%u) = 0x%lx\n",
+ alloc_trace_space(imem), client_name_string(cname),
+ (ulong) num_elements * elt_size,
+ num_elements, elt_size, (ulong) obj);
return (byte *) obj;
}
static byte *
@@ -668,10 +669,10 @@ i_alloc_byte_array_immovable(gs_memory_t * mem, uint num_elements,
&st_bytes, ALLOC_IMMOVABLE | ALLOC_DIRECT,
cname);
- if_debug6('A', "[a%d|+b.]%s -bytes-*(%lu=%u*%u) = 0x%lx\n",
- alloc_trace_space(imem), client_name_string(cname),
- (ulong) num_elements * elt_size,
- num_elements, elt_size, (ulong) obj);
+ if_debug6m('A', mem, "[a%d|+b.]%s -bytes-*(%lu=%u*%u) = 0x%lx\n",
+ alloc_trace_space(imem), client_name_string(cname),
+ (ulong) num_elements * elt_size,
+ num_elements, elt_size, (ulong) obj);
return (byte *) obj;
}
static void *
@@ -686,10 +687,10 @@ i_alloc_struct_array(gs_memory_t * mem, uint num_elements,
return NULL;
#endif
- ALLOC_CHECK_SIZE(pstype);
+ ALLOC_CHECK_SIZE(mem,pstype);
#ifdef DEBUG
if (pstype->enum_ptrs == basic_enum_ptrs) {
- dprintf2(" i_alloc_struct_array: called with incorrect structure type (not element), struct='%s', client='%s'\n",
+ dmprintf2(mem, " i_alloc_struct_array: called with incorrect structure type (not element), struct='%s', client='%s'\n",
pstype->sname, cname);
return NULL; /* fail */
}
@@ -697,11 +698,11 @@ i_alloc_struct_array(gs_memory_t * mem, uint num_elements,
obj = alloc_obj(imem,
(ulong) num_elements * pstype->ssize,
pstype, ALLOC_DIRECT, cname);
- if_debug7('A', "[a%d:+<.]%s %s*(%lu=%u*%u) = 0x%lx\n",
- alloc_trace_space(imem), client_name_string(cname),
- struct_type_name_string(pstype),
- (ulong) num_elements * pstype->ssize,
- num_elements, pstype->ssize, (ulong) obj);
+ if_debug7m('A', mem, "[a%d:+<.]%s %s*(%lu=%u*%u) = 0x%lx\n",
+ alloc_trace_space(imem), client_name_string(cname),
+ struct_type_name_string(pstype),
+ (ulong) num_elements * pstype->ssize,
+ num_elements, pstype->ssize, (ulong) obj);
return (char *)obj;
}
static void *
@@ -716,15 +717,15 @@ i_alloc_struct_array_immovable(gs_memory_t * mem, uint num_elements,
return NULL;
#endif
- ALLOC_CHECK_SIZE(pstype);
+ ALLOC_CHECK_SIZE(mem,pstype);
obj = alloc_obj(imem,
(ulong) num_elements * pstype->ssize,
pstype, ALLOC_IMMOVABLE | ALLOC_DIRECT, cname);
- if_debug7('A', "[a%d|+<.]%s %s*(%lu=%u*%u) = 0x%lx\n",
- alloc_trace_space(imem), client_name_string(cname),
- struct_type_name_string(pstype),
- (ulong) num_elements * pstype->ssize,
- num_elements, pstype->ssize, (ulong) obj);
+ if_debug7m('A', mem, "[a%d|+<.]%s %s*(%lu=%u*%u) = 0x%lx\n",
+ alloc_trace_space(imem), client_name_string(cname),
+ struct_type_name_string(pstype),
+ (ulong) num_elements * pstype->ssize,
+ num_elements, pstype->ssize, (ulong) obj);
return (char *)obj;
}
static void *
@@ -760,13 +761,13 @@ i_resize_object(gs_memory_t * mem, void *obj, uint new_num_elements,
new_obj = obj;
}
if (new_obj) {
- if_debug8('A', "[a%d:%c%c ]%s %s(%lu=>%lu) 0x%lx\n",
- alloc_trace_space(imem),
- (new_size > old_size ? '>' : '<'),
- (pstype == &st_bytes ? 'b' : '<'),
- client_name_string(cname),
- struct_type_name_string(pstype),
- old_size, new_size, (ulong) obj);
+ if_debug8m('A', mem, "[a%d:%c%c ]%s %s(%lu=>%lu) 0x%lx\n",
+ alloc_trace_space(imem),
+ (new_size > old_size ? '>' : '<'),
+ (pstype == &st_bytes ? 'b' : '<'),
+ client_name_string(cname),
+ struct_type_name_string(pstype),
+ old_size, new_size, (ulong) obj);
return new_obj;
}
/* Punt. */
@@ -798,8 +799,8 @@ i_free_object(gs_memory_t * mem, void *ptr, client_name_t cname)
chunk_locator_t cld;
if (pstype == &st_free) {
- lprintf2("%s: object 0x%lx already free!\n",
- client_name_string(cname), (ulong) ptr);
+ mlprintf2(mem, "%s: object 0x%lx already free!\n",
+ client_name_string(cname), (ulong) ptr);
return; /*gs_abort(); */
}
/* Check that this allocator owns the object being freed. */
@@ -808,9 +809,9 @@ i_free_object(gs_memory_t * mem, void *ptr, client_name_t cname)
!chunk_locate_ptr(ptr, &cld)
) {
if (!cld.memory->saved) {
- lprintf3("%s: freeing 0x%lx, not owned by memory 0x%lx!\n",
- client_name_string(cname), (ulong) ptr,
- (ulong) mem);
+ mlprintf3(mem, "%s: freeing 0x%lx, not owned by memory 0x%lx!\n",
+ client_name_string(cname), (ulong) ptr,
+ (ulong) mem);
return; /*gs_abort(); */
}
/****** HACK: we know the saved state is the first ******
@@ -823,10 +824,10 @@ i_free_object(gs_memory_t * mem, void *ptr, client_name_t cname)
if (!(PTR_BETWEEN((const byte *)pp, cld.cp->cbase,
cld.cp->cbot))
) {
- lprintf5("%s: freeing 0x%lx,\n\toutside chunk 0x%lx cbase=0x%lx, cbot=0x%lx!\n",
- client_name_string(cname), (ulong) ptr,
- (ulong) cld.cp, (ulong) cld.cp->cbase,
- (ulong) cld.cp->cbot);
+ mlprintf5(mem, "%s: freeing 0x%lx,\n\toutside chunk 0x%lx cbase=0x%lx, cbot=0x%lx!\n",
+ client_name_string(cname), (ulong) ptr,
+ (ulong) cld.cp, (ulong) cld.cp->cbase,
+ (ulong) cld.cp->cbot);
return; /*gs_abort(); */
}
}
@@ -842,9 +843,9 @@ i_free_object(gs_memory_t * mem, void *ptr, client_name_t cname)
if (gs_debug['a'] || gs_debug['A'])
saved_stype = *pstype;
- if_debug3('u', "[u]finalizing %s 0x%lx (%s)\n",
- struct_type_name_string(pstype),
- (ulong) ptr, client_name_string(cname));
+ if_debug3m('u', mem, "[u]finalizing %s 0x%lx (%s)\n",
+ struct_type_name_string(pstype),
+ (ulong) ptr, client_name_string(cname));
(*finalize) (mem, ptr);
if (gs_debug['a'] || gs_debug['A'])
@@ -951,9 +952,9 @@ i_alloc_string(gs_memory_t * mem, uint nbytes, client_name_t cname)
}
top:
if (imem->cc.ctop - imem->cc.cbot > nbytes) {
- if_debug4('A', "[a%d:+> ]%s(%u) = 0x%lx\n",
- alloc_trace_space(imem), client_name_string(cname), nbytes,
- (ulong) (imem->cc.ctop - nbytes));
+ if_debug4m('A', mem, "[a%d:+> ]%s(%u) = 0x%lx\n",
+ alloc_trace_space(imem), client_name_string(cname), nbytes,
+ (ulong) (imem->cc.ctop - nbytes));
str = imem->cc.ctop -= nbytes;
gs_alloc_fill(str, gs_alloc_fill_alloc, nbytes);
return str;
@@ -1011,9 +1012,9 @@ i_alloc_string_immovable(gs_memory_t * mem, uint nbytes, client_name_t cname)
if (cp == 0)
return 0;
str = cp->ctop = cp->climit - nbytes;
- if_debug4('a', "[a%d|+>L]%s(%u) = 0x%lx\n",
- alloc_trace_space(imem), client_name_string(cname), nbytes,
- (ulong) str);
+ if_debug4m('a', mem, "[a%d|+>L]%s(%u) = 0x%lx\n",
+ alloc_trace_space(imem), client_name_string(cname), nbytes,
+ (ulong) str);
gs_alloc_fill(str, gs_alloc_fill_alloc, nbytes);
return str;
}
@@ -1031,11 +1032,11 @@ i_resize_string(gs_memory_t * mem, byte * data, uint old_num, uint new_num,
imem->cc.ctop - imem->cc.cbot > new_num - old_num)
) { /* Resize in place. */
ptr = data + old_num - new_num;
- if_debug6('A', "[a%d:%c> ]%s(%u->%u) 0x%lx\n",
- alloc_trace_space(imem),
- (new_num > old_num ? '>' : '<'),
- client_name_string(cname), old_num, new_num,
- (ulong) ptr);
+ if_debug6m('A', mem, "[a%d:%c> ]%s(%u->%u) 0x%lx\n",
+ alloc_trace_space(imem),
+ (new_num > old_num ? '>' : '<'),
+ client_name_string(cname), old_num, new_num,
+ (ulong) ptr);
imem->cc.ctop = ptr;
memmove(ptr, data, min(old_num, new_num));
#ifdef DEBUG
@@ -1052,9 +1053,9 @@ i_resize_string(gs_memory_t * mem, byte * data, uint old_num, uint new_num,
imem->lost.strings += old_num - new_num;
gs_alloc_fill(data + new_num, gs_alloc_fill_free,
old_num - new_num);
- if_debug5('A', "[a%d:<> ]%s(%u->%u) 0x%lx\n",
- alloc_trace_space(imem), client_name_string(cname),
- old_num, new_num, (ulong)ptr);
+ if_debug5m('A', mem, "[a%d:<> ]%s(%u->%u) 0x%lx\n",
+ alloc_trace_space(imem), client_name_string(cname),
+ old_num, new_num, (ulong)ptr);
} else { /* Punt. */
ptr = gs_alloc_string(mem, new_num, cname);
if (ptr == 0)
@@ -1071,14 +1072,14 @@ i_free_string(gs_memory_t * mem, byte * data, uint nbytes,
{
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
if (data == imem->cc.ctop) {
- if_debug4('A', "[a%d:-> ]%s(%u) 0x%lx\n",
- alloc_trace_space(imem), client_name_string(cname), nbytes,
- (ulong) data);
+ if_debug4m('A', mem, "[a%d:-> ]%s(%u) 0x%lx\n",
+ alloc_trace_space(imem), client_name_string(cname), nbytes,
+ (ulong) data);
imem->cc.ctop += nbytes;
} else {
- if_debug4('A', "[a%d:->#]%s(%u) 0x%lx\n",
- alloc_trace_space(imem), client_name_string(cname), nbytes,
- (ulong) data);
+ if_debug4m('A', mem, "[a%d:->#]%s(%u) 0x%lx\n",
+ alloc_trace_space(imem), client_name_string(cname), nbytes,
+ (ulong) data);
imem->lost.strings += nbytes;
}
gs_alloc_fill(data, gs_alloc_fill_free, nbytes);
@@ -1381,9 +1382,10 @@ consolidate_chunk_free(chunk_t *cp, gs_ref_memory_t *mem)
/* We found free objects at the top of the object area. */
/* Remove the free objects from the freelists. */
remove_range_from_freelist(mem, begin_free, cp->cbot);
- if_debug4('a', "[a]resetting chunk 0x%lx cbot from 0x%lx to 0x%lx (%lu free)\n",
- (ulong) cp, (ulong) cp->cbot, (ulong) begin_free,
- (ulong) ((byte *) cp->cbot - (byte *) begin_free));
+ if_debug4m('a', (const gs_memory_t *)mem,
+ "[a]resetting chunk 0x%lx cbot from 0x%lx to 0x%lx (%lu free)\n",
+ (ulong) cp, (ulong) cp->cbot, (ulong) begin_free,
+ (ulong) ((byte *) cp->cbot - (byte *) begin_free));
cp->cbot = (byte *) begin_free;
}
}
@@ -1639,8 +1641,8 @@ i_register_root(gs_memory_t * mem, gs_gc_root_t * rp, gs_ptr_type_t ptype,
rp->free_on_unregister = true;
} else
rp->free_on_unregister = false;
- if_debug3('8', "[8]register root(%s) 0x%lx -> 0x%lx\n",
- client_name_string(cname), (ulong)rp, (ulong)up);
+ if_debug3m('8', mem, "[8]register root(%s) 0x%lx -> 0x%lx\n",
+ client_name_string(cname), (ulong)rp, (ulong)up);
rp->ptype = ptype;
rp->p = up;
rp->next = imem->roots;
@@ -1655,8 +1657,8 @@ i_unregister_root(gs_memory_t * mem, gs_gc_root_t * rp, client_name_t cname)
gs_ref_memory_t * const imem = (gs_ref_memory_t *)mem;
gs_gc_root_t **rpp = &imem->roots;
- if_debug2('8', "[8]unregister root(%s) 0x%lx\n",
- client_name_string(cname), (ulong) rp);
+ if_debug2m('8', mem, "[8]unregister root(%s) 0x%lx\n",
+ client_name_string(cname), (ulong) rp);
while (*rpp != rp)
rpp = &(*rpp)->next;
*rpp = (*rpp)->next;
@@ -1750,9 +1752,10 @@ alloc_acquire_chunk(gs_ref_memory_t * mem, ulong csize, bool has_strings,
gs_free_object(parent, cp, cname);
return 0;
}
- if_debug4('0', "[0]signaling space=%d, allocated=%ld, limit=%ld, requested=%ld\n",
- mem->space, (long)mem->allocated,
- (long)mem->limit, (long)mem->gc_status.requested);
+ if_debug4m('0', (const gs_memory_t *)mem,
+ "[0]signaling space=%d, allocated=%ld, limit=%ld, requested=%ld\n",
+ mem->space, (long)mem->allocated,
+ (long)mem->limit, (long)mem->gc_status.requested);
*mem->gc_status.psignal = mem->gc_status.signal_value;
}
}
@@ -1833,8 +1836,8 @@ alloc_close_chunk(gs_ref_memory_t * mem)
*mem->pcc = mem->cc;
#ifdef DEBUG
if (gs_debug_c('a')) {
- dlprintf1("[a%d]", alloc_trace_space(mem));
- dprintf_chunk("closing chunk", mem->pcc);
+ dmlprintf1((const gs_memory_t *)mem, "[a%d]", alloc_trace_space(mem));
+ dmprintf_chunk((const gs_memory_t *)mem, "closing chunk", mem->pcc);
}
#endif
}
@@ -1848,8 +1851,8 @@ alloc_open_chunk(gs_ref_memory_t * mem)
mem->cc = *mem->pcc;
#ifdef DEBUG
if (gs_debug_c('a')) {
- dlprintf1("[a%d]", alloc_trace_space(mem));
- dprintf_chunk("opening chunk", mem->pcc);
+ dmlprintf1((const gs_memory_t *)mem, "[a%d]", alloc_trace_space(mem));
+ dmprintf_chunk((const gs_memory_t *)mem, "opening chunk", mem->pcc);
}
#endif
}
@@ -1866,8 +1869,8 @@ alloc_unlink_chunk(chunk_t * cp, gs_ref_memory_t * mem)
while (ap != 0 && ap != cp)
ap = ap->cnext;
if (ap != cp) {
- lprintf2("unlink_chunk 0x%lx not owned by memory 0x%lx!\n",
- (ulong) cp, (ulong) mem);
+ mlprintf2((const gs_memory_t *)mem, "unlink_chunk 0x%lx not owned by memory 0x%lx!\n",
+ (ulong) cp, (ulong) mem);
return; /*gs_abort(); */
}
}
@@ -1993,16 +1996,16 @@ const dump_control_t dump_control_no_contents =
* also as characters.
*/
static void
-debug_indent(int indent)
+debug_indent(const gs_memory_t *mem, int indent)
{
int i;
for (i = indent; i > 0; --i)
- dputc(' ');
+ dmputc(mem, ' ');
}
static void
-debug_dump_contents(const byte * bot, const byte * top, int indent,
- bool as_chars)
+debug_dump_contents(const gs_memory_t *mem, const byte * bot,
+ const byte * top, int indent, bool as_chars)
{
const byte *block;
@@ -2025,39 +2028,39 @@ debug_dump_contents(const byte * bot, const byte * top, int indent,
if (block < bot + block_size * 2 ||
memcmp(block, block - block_size * 2, block_size)
) {
- debug_indent(indent);
- dputs(" ...\n");
+ debug_indent(mem, indent);
+ dmputs(mem, " ...\n");
}
continue;
}
sprintf(label, "0x%lx:", (ulong) block);
- debug_indent(indent);
- dputs(label);
+ debug_indent(mem, indent);
+ dmputs(mem, label);
for (i = 0; i < block_size; ++i) {
const char *sepr = ((i & 3) == 0 && i != 0 ? " " : " ");
- dputs(sepr);
+ dmputs(mem, sepr);
if (block + i >= bot && block + i < top)
- dprintf1("%02x", block[i]);
+ dmprintf1(mem, "%02x", block[i]);
else
- dputs(" ");
+ dmputs(mem, " ");
}
- dputc('\n');
+ dmputc(mem, '\n');
if (as_chars) {
- debug_indent(indent + strlen(label));
+ debug_indent(mem, indent + strlen(label));
for (i = 0; i < block_size; ++i) {
byte ch;
if ((i & 3) == 0 && i != 0)
- dputc(' ');
+ dmputc(mem, ' ');
if (block + i >= bot && block + i < top &&
(ch = block[i]) >= 32 && ch <= 126
)
- dprintf1(" %c", ch);
+ dmprintf1(mem, " %c", ch);
else
- dputs(" ");
+ dmputs(mem, " ");
}
- dputc('\n');
+ dmputc(mem, '\n');
}
}
#undef block_size
@@ -2074,25 +2077,25 @@ debug_print_object(const gs_memory_t *mem, const void *obj, const dump_control_t
const gs_memory_struct_type_t *type = pre->o_type;
dump_options_t options = control->options;
- dprintf3(" pre=0x%lx(obj=0x%lx) size=%lu", (ulong) pre, (ulong) obj,
+ dmprintf3(mem, " pre=0x%lx(obj=0x%lx) size=%lu", (ulong) pre, (ulong) obj,
size);
switch (options & (dump_do_type_addresses | dump_do_no_types)) {
case dump_do_type_addresses + dump_do_no_types: /* addresses only */
- dprintf1(" type=0x%lx", (ulong) type);
+ dmprintf1(mem, " type=0x%lx", (ulong) type);
break;
case dump_do_type_addresses: /* addresses & names */
- dprintf2(" type=%s(0x%lx)", struct_type_name_string(type),
+ dmprintf2(mem, " type=%s(0x%lx)", struct_type_name_string(type),
(ulong) type);
break;
case 0: /* names only */
- dprintf1(" type=%s", struct_type_name_string(type));
+ dmprintf1(mem, " type=%s", struct_type_name_string(type));
case dump_do_no_types: /* nothing */
;
}
if (options & dump_do_marks) {
- dprintf2(" smark/back=%u (0x%x)", pre->o_smark, pre->o_smark);
+ dmprintf2(mem, " smark/back=%u (0x%x)", pre->o_smark, pre->o_smark);
}
- dputc('\n');
+ dmputc(mem, '\n');
if (type == &st_free)
return;
if (options & dump_do_pointers) {
@@ -2108,35 +2111,35 @@ debug_print_object(const gs_memory_t *mem, const void *obj, const dump_control_t
) {
const void *ptr = eptr.ptr;
- dprintf1(" ptr %u: ", index);
+ dmprintf1(mem, " ptr %u: ", index);
if (ptype == ptr_string_type || ptype == ptr_const_string_type) {
const gs_const_string *str = (const gs_const_string *)&eptr;
if (!str)
- dprintf("0x0");
+ dmprintf(mem, "0x0");
else
- dprintf2("0x%lx(%u)", (ulong) str->data, str->size);
+ dmprintf2(mem, "0x%lx(%u)", (ulong) str->data, str->size);
if (options & dump_do_pointed_strings) {
- dputs(" =>\n");
+ dmputs(mem, " =>\n");
if (!str)
- dprintf("(null)\n");
+ dmprintf(mem, "(null)\n");
else
- debug_dump_contents(str->data, str->data + str->size, 6,
+ debug_dump_contents(mem, str->data, str->data + str->size, 6,
true);
} else {
- dputc('\n');
+ dmputc(mem, '\n');
}
} else {
- dprintf1((PTR_BETWEEN(ptr, obj, (const byte *)obj + size) ?
+ dmprintf1(mem, (PTR_BETWEEN(ptr, obj, (const byte *)obj + size) ?
"(0x%lx)\n" : "0x%lx\n"), (ulong) ptr);
}
}
} else { /* proc == 0 */
- dprintf("previous line should be a ref\n");
+ dmprintf(mem, "previous line should be a ref\n");
}
} /* proc != gs_no_struct_enum_ptrs */
}
if (options & dump_do_contents) {
- debug_dump_contents((const byte *)obj, (const byte *)obj + size,
+ debug_dump_contents(mem, (const byte *)obj, (const byte *)obj + size,
0, false);
}
}
@@ -2146,24 +2149,24 @@ debug_print_object(const gs_memory_t *mem, const void *obj, const dump_control_t
void
debug_dump_chunk(const gs_memory_t *mem, const chunk_t * cp, const dump_control_t * control)
{
- dprintf1("chunk at 0x%lx:\n", (ulong) cp);
- dprintf3(" chead=0x%lx cbase=0x%lx sbase=0x%lx\n",
- (ulong) cp->chead, (ulong) cp->cbase, (ulong) cp->sbase);
- dprintf3(" rcur=0x%lx rtop=0x%lx cbot=0x%lx\n",
- (ulong) cp->rcur, (ulong) cp->rtop, (ulong) cp->cbot);
- dprintf4(" ctop=0x%lx climit=0x%lx smark=0x%lx, size=%u\n",
- (ulong) cp->ctop, (ulong) cp->climit, (ulong) cp->smark,
- cp->smark_size);
- dprintf2(" sreloc=0x%lx cend=0x%lx\n",
- (ulong) cp->sreloc, (ulong) cp->cend);
- dprintf5("cprev=0x%lx cnext=0x%lx outer=0x%lx inner_count=%u has_refs=%s\n",
- (ulong) cp->cprev, (ulong) cp->cnext, (ulong) cp->outer,
- cp->inner_count, (cp->has_refs ? "true" : "false"));
-
- dprintf2(" sfree1=0x%lx sfree=0x%x\n",
- (ulong) cp->sfree1, cp->sfree);
+ dmprintf1(mem, "chunk at 0x%lx:\n", (ulong) cp);
+ dmprintf3(mem, " chead=0x%lx cbase=0x%lx sbase=0x%lx\n",
+ (ulong) cp->chead, (ulong) cp->cbase, (ulong) cp->sbase);
+ dmprintf3(mem, " rcur=0x%lx rtop=0x%lx cbot=0x%lx\n",
+ (ulong) cp->rcur, (ulong) cp->rtop, (ulong) cp->cbot);
+ dmprintf4(mem, " ctop=0x%lx climit=0x%lx smark=0x%lx, size=%u\n",
+ (ulong) cp->ctop, (ulong) cp->climit, (ulong) cp->smark,
+ cp->smark_size);
+ dmprintf2(mem, " sreloc=0x%lx cend=0x%lx\n",
+ (ulong) cp->sreloc, (ulong) cp->cend);
+ dmprintf5(mem, "cprev=0x%lx cnext=0x%lx outer=0x%lx inner_count=%u has_refs=%s\n",
+ (ulong) cp->cprev, (ulong) cp->cnext, (ulong) cp->outer,
+ cp->inner_count, (cp->has_refs ? "true" : "false"));
+
+ dmprintf2(mem, " sfree1=0x%lx sfree=0x%x\n",
+ (ulong) cp->sfree1, cp->sfree);
if (control->options & dump_do_strings) {
- debug_dump_contents((control->bottom == 0 ? cp->ctop :
+ debug_dump_contents(mem, (control->bottom == 0 ? cp->ctop :
max(control->bottom, cp->ctop)),
(control->top == 0 ? cp->climit :
min(control->top, cp->climit)),
@@ -2230,7 +2233,7 @@ debug_find_pointers(const gs_ref_memory_t *mem, const void *target)
&eptr, pre->o_type, NULL);
++index)
if (eptr.ptr == target) {
- dprintf1("Index %d in", index);
+ dmprintf1((const gs_memory_t *)mem, "Index %d in", index);
debug_print_object((const gs_memory_t *)mem, pre + 1, &control);
}
END_OBJECTS_SCAN_NO_ABORT
diff --git a/gs/base/gsalphac.c b/gs/base/gsalphac.c
index a4c0e5b88..5135c5001 100644
--- a/gs/base/gsalphac.c
+++ b/gs/base/gsalphac.c
@@ -158,7 +158,7 @@ c_alpha_write(const gs_composite_t * pcte, byte * data, uint * psize, gx_device_
uint size = *psize;
uint used;
- if_debug1('v', "[v]c_alpha_write(%d)\n", pacte->params.op);
+ if_debug1m('v', ((gx_device *)cdev)->memory, "[v]c_alpha_write(%d)\n", pacte->params.op);
if (pacte->params.op == composite_Dissolve) {
used = 1 + sizeof(pacte->params.delta);
if (size < used) {
@@ -188,7 +188,7 @@ c_alpha_read(gs_composite_t ** ppcte, const byte * data, uint size,
if (size < 1 || *data > composite_op_last)
return_error(gs_error_rangecheck);
params.op = *data;
- if_debug1('v', "[v]c_alpha_read(%d)\n", params.op);
+ if_debug1m('v', mem, "[v]c_alpha_read(%d)\n", params.op);
if (params.op == composite_Dissolve) {
if (size < 1 + sizeof(params.delta))
return_error(gs_error_rangecheck);
diff --git a/gs/base/gscdevn.c b/gs/base/gscdevn.c
index 727bf5feb..d63569498 100644
--- a/gs/base/gscdevn.c
+++ b/gs/base/gscdevn.c
@@ -326,7 +326,7 @@ gx_concrete_space_DeviceN(const gs_color_space * pcs,
* Verify that the color space and imager state info match.
*/
if (pcs->id != pis->color_component_map.cspace_id)
- dprintf("gx_concrete_space_DeviceN: color space id mismatch");
+ dmprintf(pis->memory, "gx_concrete_space_DeviceN: color space id mismatch");
#endif
/*
* Check if we are using the alternate color space.
@@ -402,7 +402,7 @@ gx_concretize_DeviceN(const gs_client_color * pc, const gs_color_space * pcs,
* Verify that the color space and imager state info match.
*/
if (pcs->id != pis->color_component_map.cspace_id)
- dprintf("gx_concretize_DeviceN: color space id mismatch");
+ dmprintf(dev->memory, "gx_concretize_DeviceN: color space id mismatch");
#endif
/*
@@ -472,7 +472,7 @@ gx_remap_concrete_DeviceN(const frac * pconc, const gs_color_space * pcs,
* Verify that the color space and imager state info match.
*/
if (pcs->id != pis->color_component_map.cspace_id)
- dprintf("gx_remap_concrete_DeviceN: color space id mismatch");
+ dmprintf(pis->memory, "gx_remap_concrete_DeviceN: color space id mismatch");
#endif
if (pis->color_component_map.use_alt_cspace) {
const gs_color_space *pacs = pcs->base_space;
diff --git a/gs/base/gschar0.c b/gs/base/gschar0.c
index 719106e68..a269246ff 100644
--- a/gs/base/gschar0.c
+++ b/gs/base/gschar0.c
@@ -46,8 +46,8 @@ gs_stack_modal_fonts(gs_text_enum_t *pte)
cfont = cmfont->data.FDepVector[cmfont->data.Encoding[0]];
pte->fstack.items[fdepth].font = cfont;
pte->fstack.items[fdepth - 1].index = 0;
- if_debug2('j', "[j]stacking depth=%d font=0x%lx\n",
- fdepth, (ulong) cfont);
+ if_debug2m('j', pte->memory, "[j]stacking depth=%d font=0x%lx\n",
+ fdepth, (ulong) cfont);
}
pte->fstack.depth = fdepth;
return 0;
@@ -59,8 +59,8 @@ gs_type0_init_fstack(gs_text_enum_t *pte, gs_font * pfont)
{
if (!(pte->text.operation & (TEXT_FROM_STRING | TEXT_FROM_BYTES)))
return_error(gs_error_invalidfont);
- if_debug1('j', "[j]stacking depth=0 font=0x%lx\n",
- (ulong) pfont);
+ if_debug1m('j', pte->memory, "[j]stacking depth=0 font=0x%lx\n",
+ (ulong) pfont);
pte->fstack.depth = 0;
pte->fstack.items[0].font = pfont;
pte->fstack.items[0].index = 0;
@@ -145,10 +145,10 @@ gs_type0_next_char_glyph(gs_text_enum_t *pte, gs_char *pchr, gs_glyph *pglyph)
need_left(2);
fidx = p[1];
p += 2;
- if_debug1('j', "[j]from root: escape %d\n", fidx);
+ if_debug1m('j', pte->memory, "[j]from root: escape %d\n", fidx);
rdown:select_descendant(pfont, pdata, fidx, idepth);
- if_debug2('j', "[j]... new depth=%d, new font=0x%lx\n",
- idepth, (ulong) pfont);
+ if_debug2m('j', pte->memory, "[j]... new depth=%d, new font=0x%lx\n",
+ idepth, (ulong) pfont);
continue;
case fmap_double_escape:
if (chr != root_esc_char(pte))
@@ -160,7 +160,7 @@ gs_type0_next_char_glyph(gs_text_enum_t *pte, gs_char *pchr, gs_glyph *pglyph)
need_left(1);
fidx = *p++ + 256;
}
- if_debug1('j', "[j]from root: double escape %d\n", fidx);
+ if_debug1m('j', pte->memory, "[j]from root: double escape %d\n", fidx);
goto rdown;
case fmap_shift:
if (chr == pdata->ShiftIn)
@@ -170,7 +170,7 @@ gs_type0_next_char_glyph(gs_text_enum_t *pte, gs_char *pchr, gs_glyph *pglyph)
else
break;
p++;
- if_debug1('j', "[j]from root: shift %d\n", fidx);
+ if_debug1m('j', pte->memory, "[j]from root: shift %d\n", fidx);
goto rdown;
default:
break;
@@ -209,7 +209,7 @@ gs_type0_next_char_glyph(gs_text_enum_t *pte, gs_char *pchr, gs_glyph *pglyph)
break;
need_left(2);
fidx = *++p;
- if_debug1('j', "[j]next: escape %d\n", fidx);
+ if_debug1m('j', pte->memory, "[j]next: escape %d\n", fidx);
/* Per Adobe, if we get an escape at the root, */
/* treat it as an ordinary character (font index). */
if (fidx == chr && fdepth > 1) {
@@ -222,8 +222,8 @@ gs_type0_next_char_glyph(gs_text_enum_t *pte, gs_char *pchr, gs_glyph *pglyph)
fdepth--;
do {
select_descendant(pfont, pdata, fidx, fdepth);
- if_debug3('j', "[j]down from modal: new depth=%d, index=%d, new font=0x%lx\n",
- fdepth, fidx, (ulong) pfont);
+ if_debug3m('j', pte->memory, "[j]down from modal: new depth=%d, index=%d, new font=0x%lx\n",
+ fdepth, fidx, (ulong) pfont);
if (pfont->FontType != ft_composite)
break;
pdata = &pfont0->data;
@@ -241,7 +241,7 @@ gs_type0_next_char_glyph(gs_text_enum_t *pte, gs_char *pchr, gs_glyph *pglyph)
need_left(2);
fidx = *++p + 256;
}
- if_debug1('j', "[j]next: double escape %d\n", fidx);
+ if_debug1m('j', pte->memory, "[j]next: double escape %d\n", fidx);
goto down;
case fmap_shift:
@@ -251,7 +251,7 @@ gs_type0_next_char_glyph(gs_text_enum_t *pte, gs_char *pchr, gs_glyph *pglyph)
fidx = 1;
else
break;
- if_debug1('j', "[j]next: shift %d\n", fidx);
+ if_debug1m('j', pte->memory, "[j]next: shift %d\n", fidx);
goto down;
}
break;
@@ -279,23 +279,23 @@ gs_type0_next_char_glyph(gs_text_enum_t *pte, gs_char *pchr, gs_glyph *pglyph)
need_left(1);
fidx = chr;
chr = *p++;
- if_debug2('J', "[J]8/8 index=%d, char=%ld\n",
- fidx, chr);
+ if_debug2m('J', pte->memory, "[J]8/8 index=%d, char=%ld\n",
+ fidx, chr);
break;
case fmap_1_7:
fidx = chr >> 7;
chr &= 0x7f;
- if_debug2('J', "[J]1/7 index=%d, char=%ld\n",
- fidx, chr);
+ if_debug2m('J', pte->memory, "[J]1/7 index=%d, char=%ld\n",
+ fidx, chr);
break;
case fmap_9_7:
need_left(1);
fidx = ((uint) chr << 1) + (*p >> 7);
chr = *p & 0x7f;
- if_debug2('J', "[J]9/7 index=%d, char=%ld\n",
- fidx, chr);
+ if_debug2m('J', pte->memory, "[J]9/7 index=%d, char=%ld\n",
+ fidx, chr);
p++;
break;
@@ -352,8 +352,8 @@ gs_type0_next_char_glyph(gs_text_enum_t *pte, gs_char *pchr, gs_glyph *pglyph)
#undef subs_loop
}
fidx = pdata->subs_size - subs_count;
- if_debug2('J', "[J]SubsVector index=%d, char=%ld\n",
- fidx, chr);
+ if_debug2m('J', pte->memory, "[J]SubsVector index=%d, char=%ld\n",
+ fidx, chr);
break;
}
@@ -374,19 +374,20 @@ gs_type0_next_char_glyph(gs_text_enum_t *pte, gs_char *pchr, gs_glyph *pglyph)
if (*(p - 1) != chr) {
byte substr[MAX_CMAP_CODE_SIZE];
int submindex = 0;
- if_debug2('j', "[j] *(p-1) 0x%02x != chr 0x%02x, modified str should be passed\n",
- *(p-1), (byte)chr);
+ if_debug2m('j', pte->memory,
+ "[j] *(p-1) 0x%02x != chr 0x%02x, modified str should be passed\n",
+ *(p-1), (byte)chr);
memcpy(substr, p - 1,
min(MAX_CMAP_CODE_SIZE, end - p + 1));
substr[0] = chr;
cstr.data = substr;
cstr.size = min(MAX_CMAP_CODE_SIZE, end - p + 1);
if (gs_debug_c('j')) {
- dlprintf("[j] original str(");
- debug_print_string_hex(str, end - str);
- dlprintf(") -> modified substr(");
- debug_print_string_hex(cstr.data, cstr.size);
- dlprintf(")\n");
+ dmlprintf(pfont->memory, "[j] original str(");
+ debug_print_string_hex(pfont->memory, str, end - str);
+ dmlprintf(pfont->memory, ") -> modified substr(");
+ debug_print_string_hex(pfont->memory, cstr.data, cstr.size);
+ dmlprintf(pfont->memory, ")\n");
}
code = gs_cmap_decode_next(pdata->CMap, &cstr,
(uint*) &submindex, &fidx, &chr, &glyph);
@@ -401,12 +402,12 @@ gs_type0_next_char_glyph(gs_text_enum_t *pte, gs_char *pchr, gs_glyph *pglyph)
return code;
pte->cmap_code = code; /* hack for widthshow */
p = str + mindex;
- if_debug3('J', "[J]CMap returns %d, chr=0x%lx, glyph=0x%lx\n",
+ if_debug3m('J', pte->memory, "[J]CMap returns %d, chr=0x%lx, glyph=0x%lx\n",
code, (ulong) chr, (ulong) glyph);
if (code == 0) {
if (glyph == gs_no_glyph) {
glyph = gs_min_cid_glyph;
- if_debug0('J', "... undefined\n");
+ if_debug0m('J', pte->memory, "... undefined\n");
/* Must select a descendant font anyway, we can't use the type 0
* even for the /.notdef...
*/
@@ -421,7 +422,7 @@ gs_type0_next_char_glyph(gs_text_enum_t *pte, gs_char *pchr, gs_glyph *pglyph)
}
select_descendant(pfont, pdata, fidx, fdepth);
- if_debug2('J', "... new depth=%d, new font=0x%lx\n",
+ if_debug2m('J', pte->memory, "... new depth=%d, new font=0x%lx\n",
fdepth, (ulong) pfont);
}
done:
@@ -461,9 +462,9 @@ done:
if (str == pte->text.data.bytes)
pte->index = p - str;
pte->fstack.depth = fdepth;
- if_debug4('J', "[J]depth=%d font=0x%lx index=%d changed=%d\n",
- fdepth, (ulong) pte->fstack.items[fdepth].font,
- pte->fstack.items[fdepth].index, changed);
+ if_debug4m('J', pte->memory, "[J]depth=%d font=0x%lx index=%d changed=%d\n",
+ fdepth, (ulong) pte->fstack.items[fdepth].font,
+ pte->fstack.items[fdepth].index, changed);
return changed;
}
#undef pfont0
diff --git a/gs/base/gscie.c b/gs/base/gscie.c
index a0a8b9876..cb69041e5 100644
--- a/gs/base/gscie.c
+++ b/gs/base/gscie.c
@@ -429,8 +429,8 @@ gx_install_CIEA(gs_color_space * pcs, gs_state * pgs)
float in = SAMPLE_LOOP_VALUE(i, lp);
pcie->caches.DecodeA.floats.values[i] = (*pcie->DecodeA)(in, pcie);
- if_debug3('C', "[C]DecodeA[%d] = %g => %g\n",
- i, in, pcie->caches.DecodeA.floats.values[i]);
+ if_debug3m('C', pgs->memory, "[C]DecodeA[%d] = %g => %g\n",
+ i, in, pcie->caches.DecodeA.floats.values[i]);
}
gx_cie_load_common_cache(&pcie->common, pgs);
gs_cie_a_complete(pcie);
diff --git a/gs/base/gsciemap.c b/gs/base/gsciemap.c
index d1193680f..61f6afdf7 100644
--- a/gs/base/gsciemap.c
+++ b/gs/base/gsciemap.c
@@ -201,7 +201,8 @@ gx_ciedefg_to_icc(gs_color_space **ppcs_icc, gs_color_space *pcs, gs_memory_t *m
gx_cie_scalar_cache *lmn_caches = &(pcs->params.abc->common.caches.DecodeLMN[0]);
gx_cie_scalar_cache *defg_caches = &(pcs->params.defg->caches_defg.DecodeDEFG[0]);
- if_debug0(gs_debug_flag_icc,"[icc] Creating ICC profile from defg object");
+ if_debug0m(gs_debug_flag_icc, memory,
+ "[icc] Creating ICC profile from defg object");
/* build the ICC color space object */
code = gs_cspace_build_ICC(ppcs_icc, NULL, memory->stable_memory);
/* record the cie alt space as the icc alternative color space */
@@ -228,9 +229,9 @@ gx_remap_CIEDEFG(const gs_client_color * pc, const gs_color_space * pcs_in,
gs_client_color scale_pc;
gs_color_space *pcs = (gs_color_space *) pcs_in;
- if_debug4('c', "[c]remap CIEDEFG [%g %g %g %g]\n",
- pc->paint.values[0], pc->paint.values[1],
- pc->paint.values[2], pc->paint.values[3]);
+ if_debug4m('c', pis->memory, "[c]remap CIEDEFG [%g %g %g %g]\n",
+ pc->paint.values[0], pc->paint.values[1],
+ pc->paint.values[2], pc->paint.values[3]);
/* If we are comming in here then we have not completed
the conversion of the DEFG space to an ICC type. We
will finish that process now. */
@@ -265,9 +266,9 @@ gx_concretize_CIEDEFG(const gs_client_color * pc, const gs_color_space * pcs_in,
gs_client_color scale_pc;
gs_color_space *pcs = (gs_color_space *) pcs_in;
- if_debug4('c', "[c]concretize DEFG [%g %g %g %g]\n",
- pc->paint.values[0], pc->paint.values[1],
- pc->paint.values[2], pc->paint.values[3]);
+ if_debug4m('c', pis->memory, "[c]concretize DEFG [%g %g %g %g]\n",
+ pc->paint.values[0], pc->paint.values[1],
+ pc->paint.values[2], pc->paint.values[3]);
/* If we are comming in here then we have not completed
the conversion of the DEFG space to an ICC type. We
will finish that process now. */
@@ -297,7 +298,7 @@ gx_psconcretize_CIEA(const gs_client_color * pc, const gs_color_space * pcs,
cie_cached_vector3 vlmn;
int code;
- if_debug1('c', "[c]concretize CIEA %g\n", pc->paint.values[0]);
+ if_debug1m('c', pis->memory, "[c]concretize CIEA %g\n", pc->paint.values[0]);
code = gx_cie_check_rendering_inline(pcs, pconc, pis);
if (code < 0)
return code;
@@ -322,9 +323,9 @@ gx_psconcretize_CIEABC(const gs_client_color * pc, const gs_color_space * pcs,
cie_cached_vector3 vec3;
int code;
- if_debug3('c', "[c]concretize CIEABC [%g %g %g]\n",
- pc->paint.values[0], pc->paint.values[1],
- pc->paint.values[2]);
+ if_debug3m('c', pis->memory, "[c]concretize CIEABC [%g %g %g]\n",
+ pc->paint.values[0], pc->paint.values[1],
+ pc->paint.values[2]);
code = gx_cie_check_rendering_inline(pcs, pconc, pis);
if (code < 0)
return code;
@@ -353,9 +354,9 @@ gx_psconcretize_CIEDEFG(const gs_client_color * pc, const gs_color_space * pcs,
cie_cached_vector3 vec3;
int code;
- if_debug4('c', "[c]concretize DEFG [%g %g %g %g]\n",
- pc->paint.values[0], pc->paint.values[1],
- pc->paint.values[2], pc->paint.values[3]);
+ if_debug4m('c', pis->memory, "[c]concretize DEFG [%g %g %g %g]\n",
+ pc->paint.values[0], pc->paint.values[1],
+ pc->paint.values[2], pc->paint.values[3]);
code = gx_cie_check_rendering_inline(pcs, pconc, pis);
if (code < 0)
return code;
@@ -415,9 +416,9 @@ gx_psconcretize_CIEDEF(const gs_client_color * pc, const gs_color_space * pcs,
cie_cached_vector3 vec3;
int code;
- if_debug3('c', "[c]concretize DEF [%g %g %g]\n",
- pc->paint.values[0], pc->paint.values[1],
- pc->paint.values[2]);
+ if_debug3m('c', pis->memory, "[c]concretize DEF [%g %g %g]\n",
+ pc->paint.values[0], pc->paint.values[1],
+ pc->paint.values[2]);
code = gx_cie_check_rendering_inline(pcs, pconc, pis);
if (code < 0)
return code;
@@ -500,9 +501,9 @@ gx_remap_CIEDEF(const gs_client_color * pc, const gs_color_space * pcs_in,
int i,code;
gs_color_space *pcs = (gs_color_space *) pcs_in;
- if_debug3('c', "[c]remap CIEDEF [%g %g %g]\n",
- pc->paint.values[0], pc->paint.values[1],
- pc->paint.values[2]);
+ if_debug3m('c', pis->memory, "[c]remap CIEDEF [%g %g %g]\n",
+ pc->paint.values[0], pc->paint.values[1],
+ pc->paint.values[2]);
/* If we are comming in here then we have not completed
the conversion of the DEF space to an ICC type. We
will finish that process now. */
@@ -537,9 +538,9 @@ gx_concretize_CIEDEF(const gs_client_color * pc, const gs_color_space * pcs_in,
gs_client_color scale_pc;
gs_color_space *pcs = (gs_color_space *) pcs_in;
- if_debug3('c', "[c]concretize DEF [%g %g %g]\n",
- pc->paint.values[0], pc->paint.values[1],
- pc->paint.values[2]);
+ if_debug3m('c', pis->memory, "[c]concretize DEF [%g %g %g]\n",
+ pc->paint.values[0], pc->paint.values[1],
+ pc->paint.values[2]);
/* If we are comming in here then we have not completed
the conversion of the DEF space to an ICC type. We
will finish that process now. */
@@ -570,7 +571,7 @@ gx_cieabc_to_icc(gs_color_space **ppcs_icc, gs_color_space *pcs, bool *islab,
gx_cie_vector_cache *abc_caches = &(pcs->params.abc->caches.DecodeABC.caches[0]);
gx_cie_scalar_cache *lmn_caches = &(pcs->params.abc->common.caches.DecodeLMN[0]);
- if_debug0(gs_debug_flag_icc,"[icc] Creating ICC profile from abc object");
+ if_debug0m(gs_debug_flag_icc, memory, "[icc] Creating ICC profile from abc object");
/* build the ICC color space object */
code = gs_cspace_build_ICC(ppcs_icc, NULL, memory);
/* record the cie alt space as the icc alternative color space */
@@ -603,9 +604,9 @@ gx_remap_CIEABC(const gs_client_color * pc, const gs_color_space * pcs_in,
gs_color_space *pcs = (gs_color_space *) pcs_in;
- if_debug3('c', "[c]remap CIEABC [%g %g %g]\n",
- pc->paint.values[0], pc->paint.values[1],
- pc->paint.values[2]);
+ if_debug3m('c', pis->memory, "[c]remap CIEABC [%g %g %g]\n",
+ pc->paint.values[0], pc->paint.values[1],
+ pc->paint.values[2]);
/* If we are comming in here then we have not completed
the conversion of the ABC space to an ICC type. We
will finish that process now. */
@@ -640,9 +641,9 @@ gx_concretize_CIEABC(const gs_client_color * pc, const gs_color_space * pcs_in,
bool islab;
gs_color_space *pcs = (gs_color_space *) pcs_in;
- if_debug3('c', "[c]concretize CIEABC [%g %g %g]\n",
- pc->paint.values[0], pc->paint.values[1],
- pc->paint.values[2]);
+ if_debug3m('c', pis->memory, "[c]concretize CIEABC [%g %g %g]\n",
+ pc->paint.values[0], pc->paint.values[1],
+ pc->paint.values[2]);
/* If we are comming in here then we have not completed
the conversion of the ABC space to an ICC type. We
will finish that process now. */
@@ -671,7 +672,8 @@ gx_ciea_to_icc(gs_color_space **ppcs_icc, gs_color_space *pcs, gs_memory_t *memo
gx_cie_vector_cache *a_cache = &(pcs->params.a->caches.DecodeA);
gx_cie_scalar_cache *lmn_caches = &(pcs->params.a->common.caches.DecodeLMN[0]);
- if_debug0(gs_debug_flag_icc,"[icc] Creating ICC profile from CIEA object");
+ if_debug0m(gs_debug_flag_icc, memory,
+ "[icc] Creating ICC profile from CIEA object");
/* build the ICC color space object */
code = gs_cspace_build_ICC(ppcs_icc, NULL, memory);
/* record the cie alt space as the icc alternative color space */
@@ -699,7 +701,7 @@ gx_remap_CIEA(const gs_client_color * pc, const gs_color_space * pcs_in,
gs_client_color scale_pc;
gs_color_space *pcs = (gs_color_space *) pcs_in;
- if_debug1('c', "[c]remap CIEA [%g]\n",pc->paint.values[0]);
+ if_debug1m('c', dev->memory, "[c]remap CIEA [%g]\n",pc->paint.values[0]);
/* If we are coming in here then we may have not completed
the conversion of the CIE A space to an ICC type. We
will finish that process now. */
@@ -734,7 +736,7 @@ gx_concretize_CIEA(const gs_client_color * pc, const gs_color_space * pcs_in,
gs_client_color scale_pc;
gs_color_space *pcs = (gs_color_space *) pcs_in;
- if_debug1('c', "[c]concretize CIEA %g\n", pc->paint.values[0]);
+ if_debug1m('c', dev->memory, "[c]concretize CIEA %g\n", pc->paint.values[0]);
/* If we are comming in here then we have not completed
the conversion of the CIE A space to an ICC type. We
will finish that process now. */
@@ -876,15 +878,15 @@ gx_cie_real_remap_finish(cie_cached_vector3 vec3, frac * pconc,
rfix[2] = FABC(2, s);
#undef FABC
#undef EABC
- if_debug6('c', "[c]ABC=%g,%g,%g => iabc=%g,%g,%g\n",
- cie_cached2float(vec3.u), cie_cached2float(vec3.v),
- cie_cached2float(vec3.w), fixed2float(rfix[0]),
- fixed2float(rfix[1]), fixed2float(rfix[2]));
+ if_debug6m('c', pis->memory, "[c]ABC=%g,%g,%g => iabc=%g,%g,%g\n",
+ cie_cached2float(vec3.u), cie_cached2float(vec3.v),
+ cie_cached2float(vec3.w), fixed2float(rfix[0]),
+ fixed2float(rfix[1]), fixed2float(rfix[2]));
gx_color_interpolate_linear(rfix, &pcrd->RenderTable.lookup,
pconc);
- if_debug3('c', "[c] interpolated => %g,%g,%g\n",
- frac2float(pconc[0]), frac2float(pconc[1]),
- frac2float(pconc[2]));
+ if_debug3m('c', pis->memory, "[c] interpolated => %g,%g,%g\n",
+ frac2float(pconc[0]), frac2float(pconc[1]),
+ frac2float(pconc[2]));
if (!pcrd->caches.RenderTableT_is_identity) {
/* Map the interpolated values. */
#define frac2cache_index(v) frac2bits(v, gx_cie_log2_cache_size)
@@ -911,9 +913,9 @@ gx_cie_real_remap_finish(cie_cached_vector3 vec3, frac * pconc,
/* (*pcrd->RenderTable.T)(prtc, m, pcrd, pconc); */
- if_debug6('c', "[c]ABC=%g,%g,%g => iabc=%d,%d,%d\n",
- cie_cached2float(vec3.u), cie_cached2float(vec3.v),
- cie_cached2float(vec3.w), ia, ib, ic);
+ if_debug6m('c', pis->memory, "[c]ABC=%g,%g,%g => iabc=%d,%d,%d\n",
+ cie_cached2float(vec3.u), cie_cached2float(vec3.v),
+ cie_cached2float(vec3.w), ia, ib, ic);
if (pcrd->caches.RenderTableT_is_identity) {
pconc[0] = byte2frac(prtc[0]);
pconc[1] = byte2frac(prtc[1]);
diff --git a/gs/base/gscoord.c b/gs/base/gscoord.c
index 9f3656ab2..41845018c 100644
--- a/gs/base/gscoord.c
+++ b/gs/base/gscoord.c
@@ -33,9 +33,9 @@
/* Forward declarations */
#ifdef DEBUG
-#define trace_ctm(pgs) trace_matrix_fixed(&(pgs)->ctm)
-static void trace_matrix_fixed(const gs_matrix_fixed *);
-static void trace_matrix(const gs_matrix *);
+#define trace_ctm(pgs) trace_matrix_fixed((pgs)->memory, &(pgs)->ctm)
+static void trace_matrix_fixed(const gs_memory_t *mem, const gs_matrix_fixed *);
+static void trace_matrix(const gs_memory_t *mem, const gs_matrix *);
#endif
@@ -43,7 +43,7 @@ static void trace_matrix(const gs_matrix *);
#ifdef DEBUG
# define print_inverse(pgs)\
if ( gs_debug_c('x') )\
- dlprintf("[x]Inverting:\n"), trace_ctm(pgs), trace_matrix(&pgs->ctm_inverse)
+ dmlprintf(pgs->memory, "[x]Inverting:\n"), trace_ctm(pgs), trace_matrix(pgs->memory, &pgs->ctm_inverse)
#else
# define print_inverse(pgs) DO_NOTHING
#endif
@@ -105,7 +105,7 @@ gs_initmatrix(gs_state * pgs)
set_ctm_only(pgs, imat);
#ifdef DEBUG
if (gs_debug_c('x'))
- dlprintf("[x]initmatrix:\n"), trace_ctm(pgs);
+ dmlprintf(pgs->memory, "[x]initmatrix:\n"), trace_ctm(pgs);
#endif
return 0;
}
@@ -162,7 +162,7 @@ gs_setcharmatrix(gs_state * pgs, const gs_matrix * pmat)
char_tm_only(pgs) = cmat;
#ifdef DEBUG
if (gs_debug_c('x'))
- dlprintf("[x]setting char_tm:"), trace_matrix_fixed(&pgs->char_tm);
+ dmlprintf(pgs->memory, "[x]setting char_tm:"), trace_matrix_fixed(pgs->memory, &pgs->char_tm);
#endif
pgs->char_tm_valid = true;
return 0;
@@ -195,7 +195,7 @@ gs_setmatrix(gs_state * pgs, const gs_matrix * pmat)
set_ctm_only(pgs, *pmat);
#ifdef DEBUG
if (gs_debug_c('x'))
- dlprintf("[x]setmatrix:\n"), trace_ctm(pgs);
+ dmlprintf(pgs->memory, "[x]setmatrix:\n"), trace_ctm(pgs);
#endif
return 0;
}
@@ -207,7 +207,7 @@ gs_imager_setmatrix(gs_imager_state * pis, const gs_matrix * pmat)
set_ctm_only(pis, *pmat);
#ifdef DEBUG
if (gs_debug_c('x'))
- dlprintf("[x]imager_setmatrix:\n"), trace_ctm(pis);
+ dmlprintf(pis->memory, "[x]imager_setmatrix:\n"), trace_ctm(pis);
#endif
return 0;
}
@@ -236,7 +236,7 @@ gs_translate(gs_state * pgs, floatp dx, floatp dy)
update_ctm(pgs, pt.x, pt.y);
#ifdef DEBUG
if (gs_debug_c('x'))
- dlprintf4("[x]translate: %f %f -> %f %f\n",
+ dmlprintf4(pgs->memory, "[x]translate: %f %f -> %f %f\n",
dx, dy, pt.x, pt.y),
trace_ctm(pgs);
#endif
@@ -254,7 +254,7 @@ gs_translate_untransformed(gs_state * pgs, floatp dx, floatp dy)
update_ctm(pgs, pt.x, pt.y);
#ifdef DEBUG
if (gs_debug_c('x'))
- dlprintf4("[x]translate_untransformed: %f %f -> %f %f\n",
+ dmlprintf4(pgs->memory, "[x]translate_untransformed: %f %f -> %f %f\n",
dx, dy, pt.x, pt.y),
trace_ctm(pgs);
#endif
@@ -271,7 +271,7 @@ gs_scale(gs_state * pgs, floatp sx, floatp sy)
pgs->ctm_inverse_valid = false, pgs->char_tm_valid = false;
#ifdef DEBUG
if (gs_debug_c('x'))
- dlprintf2("[x]scale: %f %f\n", sx, sy), trace_ctm(pgs);
+ dmlprintf2(pgs->memory, "[x]scale: %f %f\n", sx, sy), trace_ctm(pgs);
#endif
return 0;
}
@@ -285,7 +285,7 @@ gs_rotate(gs_state * pgs, floatp ang)
pgs->ctm_inverse_valid = false, pgs->char_tm_valid = false;
#ifdef DEBUG
if (gs_debug_c('x'))
- dlprintf1("[x]rotate: %f\n", ang), trace_ctm(pgs);
+ dmlprintf1(pgs->memory, "[x]rotate: %f\n", ang), trace_ctm(pgs);
#endif
return code;
}
@@ -302,7 +302,7 @@ gs_concat(gs_state * pgs, const gs_matrix * pmat)
set_ctm_only(pgs, cmat);
#ifdef DEBUG
if (gs_debug_c('x'))
- dlprintf("[x]concat:\n"), trace_matrix(pmat), trace_ctm(pgs);
+ dmlprintf(pgs->memory, "[x]concat:\n"), trace_matrix(pgs->memory, pmat), trace_ctm(pgs);
#endif
return code;
}
@@ -394,11 +394,11 @@ gx_translate_to_fixed(register gs_state * pgs, fixed px, fixed py)
}
#ifdef DEBUG
if (gs_debug_c('x')) {
- dlprintf2("[x]translate_to_fixed %g, %g:\n",
- fixed2float(px), fixed2float(py));
+ dmlprintf2(pgs->memory, "[x]translate_to_fixed %g, %g:\n",
+ fixed2float(px), fixed2float(py));
trace_ctm(pgs);
- dlprintf("[x] char_tm:\n");
- trace_matrix_fixed(&pgs->char_tm);
+ dmlprintf(pgs->memory, "[x] char_tm:\n");
+ trace_matrix_fixed(pgs->memory, &pgs->char_tm);
}
#endif
gx_setcurrentpoint(pgs, fixed2float(pgs->ctm.tx_fixed), fixed2float(pgs->ctm.ty_fixed));
@@ -423,7 +423,7 @@ gx_scale_char_matrix(register gs_state * pgs, int sx, int sy)
scale_cxy(sx, xx, yx);
scale_cxy(sy, xy, yy);
#undef scale_cxy
- if_debug2('x', "[x]char scale: %d %d\n", sx, sy);
+ if_debug2m('x', pgs->memory, "[x]char scale: %d %d\n", sx, sy);
return 0;
}
@@ -487,6 +487,7 @@ gx_matrix_to_fixed_coeff(const gs_matrix * pmat, register fixed_coeff * pfc,
SET_C(yx);
SET_C(yy);
#undef SET_C
+#ifndef GS_THREADSAFE
#ifdef DEBUG
if (gs_debug_c('x')) {
dlprintf6("[x]ctm: [%6g %6g %6g %6g %6g %6g]\n",
@@ -496,6 +497,7 @@ gx_matrix_to_fixed_coeff(const gs_matrix * pmat, register fixed_coeff * pfc,
pfc->shift);
}
#endif
+#endif
pfc->max_bits = max_bits;
return 0;
}
@@ -536,22 +538,22 @@ fixed_coeff_mult(fixed value, long coeff, const fixed_coeff *pfc, int maxb)
/* Print a matrix */
static void
-trace_matrix_fixed(const gs_matrix_fixed * pmat)
+trace_matrix_fixed(const gs_memory_t *mem, const gs_matrix_fixed * pmat)
{
- trace_matrix((const gs_matrix *)pmat);
+ trace_matrix(mem, (const gs_matrix *)pmat);
if (pmat->txy_fixed_valid) {
- dprintf2("\t\tt_fixed: [%6g %6g]\n",
- fixed2float(pmat->tx_fixed),
- fixed2float(pmat->ty_fixed));
+ dmprintf2(mem, "\t\tt_fixed: [%6g %6g]\n",
+ fixed2float(pmat->tx_fixed),
+ fixed2float(pmat->ty_fixed));
} else {
- dputs("\t\tt_fixed not valid\n");
+ dmputs(mem, "\t\tt_fixed not valid\n");
}
}
static void
-trace_matrix(register const gs_matrix * pmat)
+trace_matrix(const gs_memory_t *mem, register const gs_matrix * pmat)
{
- dlprintf6("\t[%6g %6g %6g %6g %6g %6g]\n",
- pmat->xx, pmat->xy, pmat->yx, pmat->yy, pmat->tx, pmat->ty);
+ dmlprintf6(mem, "\t[%6g %6g %6g %6g %6g %6g]\n",
+ pmat->xx, pmat->xy, pmat->yx, pmat->yy, pmat->tx, pmat->ty);
}
#endif
diff --git a/gs/base/gscsepr.c b/gs/base/gscsepr.c
index 7c0280c97..5bad26b33 100644
--- a/gs/base/gscsepr.c
+++ b/gs/base/gscsepr.c
@@ -87,7 +87,7 @@ gx_concrete_space_Separation(const gs_color_space * pcs,
* Verify that the color space and imager state info match.
*/
if (pcs->id != pis->color_component_map.cspace_id)
- dprintf("gx_concretze_space_Separation: color space id mismatch");
+ dmprintf(pis->memory, "gx_concretze_space_Separation: color space id mismatch");
#endif
/*
@@ -389,7 +389,7 @@ gx_remap_concrete_Separation(const frac * pconc, const gs_color_space * pcs,
* Verify that the color space and imager state info match.
*/
if (pcs->id != pis->color_component_map.cspace_id)
- dprintf("gx_remap_concrete_Separation: color space id mismatch");
+ dmprintf(pis->memory, "gx_remap_concrete_Separation: color space id mismatch");
#endif
if (pis->color_component_map.use_alt_cspace) {
diff --git a/gs/base/gscspace.c b/gs/base/gscspace.c
index 34edb7c52..756184c58 100644
--- a/gs/base/gscspace.c
+++ b/gs/base/gscspace.c
@@ -97,7 +97,7 @@ gs_cspace_final(const gs_memory_t *cmem, void *vptr)
if (pcs->type->final)
pcs->type->final(pcs);
- if_debug2('c', "[c]cspace final %08x %d\n", pcs, pcs->id);
+ if_debug2m('c', cmem, "[c]cspace final %08x %d\n", pcs, pcs->id);
rc_decrement_only_cs(pcs->base_space, "gs_cspace_final");
/* No need to decrement the ICC profile data. It is handled
@@ -114,8 +114,8 @@ gs_cspace_alloc_with_id(gs_memory_t *mem, ulong id,
rc_alloc_struct_1(pcs, gs_color_space, &st_color_space, mem, return NULL,
"gs_cspace_alloc_with_id");
- if_debug3('c', "[c]cspace alloc %08x %s %d\n",
- pcs, pcstype->stype->sname, pcstype->index);
+ if_debug3m('c', mem, "[c]cspace alloc %08x %s %d\n",
+ pcs, pcstype->stype->sname, pcstype->index);
pcs->type = pcstype;
pcs->id = id;
pcs->base_space = NULL;
diff --git a/gs/base/gsequivc.c b/gs/base/gsequivc.c
index c61d3ff37..41d584b5b 100644
--- a/gs/base/gsequivc.c
+++ b/gs/base/gsequivc.c
@@ -369,14 +369,14 @@ static void
cmap_separation_capture_cmyk_color(frac all, gx_device_color * pdc,
const gs_imager_state * pis, gx_device * dev, gs_color_select_t select)
{
- dprintf("cmap_separation_capture_cmyk_color - this routine should not be executed\n");
+ dmprintf(pis->memory, "cmap_separation_capture_cmyk_color - this routine should not be executed\n");
}
static void
cmap_devicen_capture_cmyk_color(const frac * pcc, gx_device_color * pdc,
const gs_imager_state * pis, gx_device * dev, gs_color_select_t select)
{
- dprintf("cmap_devicen_capture_cmyk_color - this routine should not be executed\n");
+ dmprintf(pis->memory, "cmap_devicen_capture_cmyk_color - this routine should not be executed\n");
}
/*
diff --git a/gs/base/gserrors.h b/gs/base/gserrors.h
index c3d826776..24b5eb42d 100644
--- a/gs/base/gserrors.h
+++ b/gs/base/gserrors.h
@@ -48,11 +48,16 @@
#define gs_error_Remap_Color (-103)
int gs_log_error(int, const char *, int);
-#ifndef DEBUG
+#if !defined(DEBUG) || defined(GS_THREADSAFE)
# define gs_log_error(err, file, line) (err)
#endif
+#ifdef GS_THREADSAFE
+#define gs_note_error(err) (err)
+#define return_error(err) return (err)
+#else
#define gs_note_error(err) gs_log_error(err, __FILE__, __LINE__)
#define return_error(err) return gs_note_error(err)
+#endif
#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
# if defined(__GNUC__) && __GNUC__ >= 2
@@ -82,6 +87,105 @@ int gs_log_error(int, const char *, int);
const char *gs_errstr(int code);
+#ifdef GS_THREADSAFE
+/* In threadsafe builds, we just swallow errors unreported */
+#define gs_throw_code(code) \
+ (code)
+
+#define gs_throw(code, fmt) \
+ (code)
+#define gs_throw1(code, fmt, arg1) \
+ (code)
+#define gs_throw2(code, fmt, arg1, arg2) \
+ (code)
+#define gs_throw3(code, fmt, arg1, arg2, arg3) \
+ (code)
+#define gs_throw4(code, fmt, arg1, arg2, arg3, arg4) \
+ (code)
+#define gs_throw5(code, fmt, arg1, arg2, arg3, arg4, arg5) \
+ (code)
+#define gs_throw6(code, fmt, arg1, arg2, arg3, arg4, arg5, arg6) \
+ (code)
+#define gs_throw7(code, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \
+ (code)
+#define gs_throw8(code, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) \
+ (code)
+#define gs_throw9(code, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) \
+ (code)
+
+/* Bubble the code up the stack
+*/
+#define gs_rethrow_code(code) \
+ (code)
+
+#define gs_rethrow(code, fmt) \
+ (code)
+#define gs_rethrow1(code, fmt, arg1) \
+ (code)
+#define gs_rethrow2(code, fmt, arg1, arg2) \
+ (code)
+#define gs_rethrow3(code, fmt, arg1, arg2, arg3) \
+ (code)
+#define gs_rethrow4(code, fmt, arg1, arg2, arg3, arg4) \
+ (code)
+#define gs_rethrow5(code, fmt, arg1, arg2, arg3, arg4, arg5) \
+ (code)
+#define gs_rethrow6(code, fmt, arg1, arg2, arg3, arg4, arg5, arg6) \
+ (code)
+#define gs_rethrow7(code, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \
+ (code)
+#define gs_rethrow8(code, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) \
+ (code)
+#define gs_rethrow9(code, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) \
+ (code)
+
+/* This will cause trouble, as it implies you are fixing an error
+ * the system will spew messages
+ */
+#define gs_catch(code, fmt) \
+ (code)
+#define gs_catch1(code, fmt, arg1) \
+ (code)
+#define gs_catch2(code, fmt, arg1, arg2) \
+ (code)
+#define gs_catch3(code, fmt, arg1, arg2, arg3) \
+ (code)
+#define gs_catch4(code, fmt, arg1, arg2, arg3, arg4) \
+ (code)
+#define gs_catch5(code, fmt, arg1, arg2, arg3, arg4, arg5) \
+ (code)
+#define gs_catch6(code, fmt, arg1, arg2, arg3, arg4, arg5, arg6) \
+ (code)
+#define gs_catch7(code, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \
+ (code)
+#define gs_catch8(code, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) \
+ (code)
+#define gs_catch9(code, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) \
+ (code)
+
+/* gs_warn is a printf
+ */
+#define gs_warn(fmt) \
+ DO_NOTHING
+#define gs_warn1(fmt, arg1) \
+ DO_NOTHING
+#define gs_warn2(fmt, arg1, arg2) \
+ DO_NOTHING
+#define gs_warn3(fmt, arg1, arg2, arg3) \
+ DO_NOTHING
+#define gs_warn4(fmt, arg1, arg2, arg3, arg4) \
+ DO_NOTHING
+#define gs_warn5(fmt, arg1, arg2, arg3, arg4, arg5) \
+ DO_NOTHING
+#define gs_warn6(fmt, arg1, arg2, arg3, arg4, arg5, arg6) \
+ DO_NOTHING
+#define gs_warn7(fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \
+ DO_NOTHING
+#define gs_warn8(fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) \
+ DO_NOTHING
+#define gs_warn9(fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) \
+ DO_NOTHING
+#else
int gs_throw_imp(const char *func, const char *file, int line,
int op, int code, const char *fmt, ...) __printflike(6, 7);
@@ -183,6 +287,7 @@ int gs_throw_imp(const char *func, const char *file, int line,
(void)gs_throw_imp(__func__, __FILE__, __LINE__, 3, 0, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
#define gs_warn9(fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) \
(void)gs_throw_imp(__func__, __FILE__, __LINE__, 3, 0, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9)
+#endif
/* just in case you don't know 0 means no error
* other return codes are errors.
diff --git a/gs/base/gsfcmap1.c b/gs/base/gsfcmap1.c
index 1be7ca0bf..18fe88f57 100644
--- a/gs/base/gsfcmap1.c
+++ b/gs/base/gsfcmap1.c
@@ -76,18 +76,20 @@ public_st_cmap_lookup_range_element();
* multi-dimensional range comparator
*/
+#ifndef GS_THREADSAFE
static void
print_msg_str_in_range(const byte *str,
const byte *key_lo, const byte *key_hi,
int key_size)
{
- debug_print_string_hex(str, key_size);
+ debug_print_string_hex_nomem(str, key_size);
dlprintf(" in ");
- debug_print_string_hex(key_lo, key_size);
+ debug_print_string_hex_nomem(key_lo, key_size);
dlprintf(" - ");
- debug_print_string_hex(key_hi, key_size);
+ debug_print_string_hex_nomem(key_hi, key_size);
dlprintf("\n");
}
+#endif
static int
gs_cmap_get_shortest_chr(const gx_code_map_t * pcmap, uint *pfidx)
@@ -123,12 +125,14 @@ gs_multidim_CID_offset(const byte *key_str,
int i; /* index for current dimension */
int CID_offset = 0;
+#ifndef GS_THREADSAFE
#ifdef DEBUG
if (gs_debug_c('J')) {
dlprintf("[J]gmCo() calc CID_offset for 0x");
print_msg_str_in_range(key_str, key_lo, key_hi, key_size);
}
#endif
+#endif
for (i = 0; i < key_size; i++)
CID_offset = CID_offset * (key_hi[i] - key_lo[i] + 1) +
@@ -176,14 +180,16 @@ code_map_decode_next_multidim_regime(const gx_code_map_t * pcmap,
*pchr = '\0';
+#ifndef GS_THREADSAFE
#ifdef DEBUG
if (gs_debug_c('J')) {
dlprintf("[J]CMDNmr() is called: str=(");
- debug_print_string_hex(str, ssize);
+ debug_print_string_hex_nomem(str, ssize);
dlprintf3(") @ 0x%lx ssize=%d, %d ranges to check\n",
(ulong)str, ssize, pcmap->num_lookup);
}
- #endif
+#endif
+#endif
for (i = pcmap->num_lookup - 1; i >= 0; --i) {
/* main loop - scan the map passed via pcmap */
@@ -211,6 +217,7 @@ code_map_decode_next_multidim_regime(const gx_code_map_t * pcmap,
if (0 == j) /* no match, skip to next i */
continue;
else if (j < pre_size) { /* not exact, partial match */
+#ifndef GS_THREADSAFE
#ifdef DEBUG
if (gs_debug_c('J')) {
dlprintf("[J]CMDNmr() partial match with prefix:");
@@ -218,6 +225,7 @@ code_map_decode_next_multidim_regime(const gx_code_map_t * pcmap,
prefix, pre_size);
}
#endif
+#endif
if (pm_maxlen < j) {
pm_maxlen = chr_size;
pm_chr = bytes2int(str, chr_size);
@@ -227,12 +235,14 @@ code_map_decode_next_multidim_regime(const gx_code_map_t * pcmap,
continue ; /* no need to check key, skip to next i */
}
+#ifndef GS_THREADSAFE
#ifdef DEBUG
if (gs_debug_c('J')) {
dlprintf("[J]CMDNmr() full match with prefix:");
print_msg_str_in_range(str, prefix, prefix, pre_size);
}
#endif
+#endif
} /* if (0 < pre_size) */
/* full match in prefix. check key */
@@ -253,12 +263,14 @@ code_map_decode_next_multidim_regime(const gx_code_map_t * pcmap,
for (k = 0; k < pclr->num_entries; ++k, key += step) {
+#ifndef GS_THREADSAFE
#ifdef DEBUG
if_debug0('j', "[j]CMDNmr() check key:");
if (gs_debug_c('j'))
print_msg_str_in_range(str + pre_size,
key, key + step - key_size, key_size) ;
- #endif
+#endif
+#endif
for (l = 0; l < key_size; l++) {
byte c = str[l + pre_size];
@@ -287,13 +299,15 @@ code_map_decode_next_multidim_regime(const gx_code_map_t * pcmap,
*pfidx = pclr->font_index;
pvalue = pclr->values.data + k * pclr->value_size;
+#ifndef GS_THREADSAFE
#ifdef DEBUG
if (gs_debug_c('J')) {
dlprintf("[J]CMDNmr() full matched pvalue=(");
- debug_print_string_hex(pvalue, pclr->value_size);
+ debug_print_string_hex_nomem(pvalue, pclr->value_size);
dlprintf(")\n");
}
#endif
+#endif
switch (pclr->value_type) {
case CODE_VALUE_CID:
@@ -326,13 +340,15 @@ code_map_decode_next_multidim_regime(const gx_code_map_t * pcmap,
*pfidx = pm_fidx;
*pglyph = gs_no_glyph;
+#ifndef GS_THREADSAFE
#ifdef DEBUG
if (gs_debug_c('J')) {
dlprintf("[J]CMDNmr() no full match, use partial match for (");
- debug_print_string_hex(str, pm_maxlen);
+ debug_print_string_hex_nomem(str, pm_maxlen);
dlprintf(")\n");
}
#endif
+#endif
return 0;
}
@@ -418,27 +434,31 @@ gs_cmap_adobe1_decode_next(const gs_cmap_t * pcmap_in,
*pglyph = gs_min_cid_glyph; /* CID = 0, this is CMap fallback */
*pindex = save_index + chr_size_shortest;
*pchr = '\0';
+#ifndef GS_THREADSAFE
#ifdef DEBUG
if (gs_debug_c('J')) {
dlprintf1("[J]GCDN() no partial match, skip %d byte (",
chr_size_shortest);
- debug_print_string_hex(str, chr_size_shortest);
+ debug_print_string_hex_nomem(str, chr_size_shortest);
dlprintf(")\n");
}
#endif
+#endif
return 0; /* should return some error for fallback .notdef? */
}
else {
/* Undecodable string is shorter than the shortest character,
* return 'gs_no_glyph' and update index to end-of-string
*/
+#ifndef GS_THREADSAFE
#ifdef DEBUG
if (gs_debug_c('J')) {
dlprintf2("[J]GCDN() left data in buffer (%d) is shorter than shortest defined character (%d)\n",
ssize, chr_size_shortest);
}
#endif
- *pglyph = gs_no_glyph;
+#endif
+ *pglyph = gs_no_glyph;
*pindex += ssize;
return 0; /* fixme: should return a code != 0 if caller needs to know */
}
diff --git a/gs/base/gsfont.c b/gs/base/gsfont.c
index 0199b2b78..f6f67b61f 100644
--- a/gs/base/gsfont.c
+++ b/gs/base/gsfont.c
@@ -160,8 +160,8 @@ gs_font_finalize(const gs_memory_t *cmem, void *vptr)
gs_font *prev = pfont->prev;
(void)cmem; /* unused */
- if_debug4('u', "[u]unlinking font 0x%lx, base=0x%lx, prev=0x%lx, next=0x%lx\n",
- (ulong) pfont, (ulong) pfont->base, (ulong) prev, (ulong) next);
+ if_debug4m('u', cmem, "[u]unlinking font 0x%lx, base=0x%lx, prev=0x%lx, next=0x%lx\n",
+ (ulong) pfont, (ulong) pfont->base, (ulong) prev, (ulong) next);
/* Notify clients that the font is being freed. */
gs_notify_all(&pfont->notify_list, NULL);
gs_purge_font_from_char_caches(pfont);
@@ -414,8 +414,8 @@ gs_definefont(gs_font_dir * pdir, gs_font * pfont)
return code;
}
font_link_first(&pdir->orig_fonts, pfont);
- if_debug2('m', "[m]defining font 0x%lx, next=0x%lx\n",
- (ulong) pfont, (ulong) pfont->next);
+ if_debug2m('m', pfont->memory, "[m]defining font 0x%lx, next=0x%lx\n",
+ (ulong) pfont, (ulong) pfont->next);
return 0;
}
@@ -475,14 +475,14 @@ gs_makefont(gs_font_dir * pdir, const gs_font * pfont,
const gs_font_base *const pbfont = (const gs_font_base *)pfont;
if (pfont->FontType == ft_composite)
- dlprintf("[m]composite");
+ dmlprintf(mem, "[m]composite");
else if (uid_is_UniqueID(&pbfont->UID))
- dlprintf1("[m]UniqueID=%ld", pbfont->UID.id);
+ dmlprintf1(mem, "[m]UniqueID=%ld", pbfont->UID.id);
else if (uid_is_XUID(&pbfont->UID))
- dlprintf1("[m]XUID(%u)", (uint) (-pbfont->UID.id));
+ dmlprintf1(mem, "[m]XUID(%u)", (uint) (-pbfont->UID.id));
else
- dlprintf("[m]no UID");
- dprintf8(", FontType=%d, base=0x%lx,\n[m] new FontMatrix=[%g %g %g %g %g %g]\n",
+ dmlprintf(mem, "[m]no UID");
+ dmprintf8(mem, ", FontType=%d, base=0x%lx,\n[m] new FontMatrix=[%g %g %g %g %g %g]\n",
pfont->FontType, (ulong)pfont->base,
pmat->xx, pmat->xy, pmat->yx, pmat->yy,
pmat->tx, pmat->ty);
@@ -504,7 +504,7 @@ gs_makefont(gs_font_dir * pdir, const gs_font * pfont,
pf_out->FontMatrix.ty == newmat.ty
) {
*ppfont = pf_out;
- if_debug1('m', "[m]found font=0x%lx\n", (ulong) pf_out);
+ if_debug1m('m', pfont->memory, "[m]found font=0x%lx\n", (ulong) pf_out);
return 0;
}
can_cache = true;
@@ -532,7 +532,7 @@ gs_makefont(gs_font_dir * pdir, const gs_font * pfont,
* (We can't free it, because there might be
* other references to it.)
*/
- if_debug1('m', "[m]discarding font 0x%lx\n",
+ if_debug1m('m', pfont->memory, "[m]discarding font 0x%lx\n",
(ulong) prev);
if (prev->prev != 0)
prev->prev->next = 0;
@@ -575,9 +575,9 @@ gs_makefont(gs_font_dir * pdir, const gs_font * pfont,
a complete understanding.
*/
if (prev->FontType != ft_composite) {
- if_debug1('m', "[m]discarding UID 0x%lx\n",
- (ulong) ((gs_font_base *) prev)->
- UID.xvalues);
+ if_debug1m('m', pfont->memory, "[m]discarding UID 0x%lx\n",
+ (ulong) ((gs_font_base *) prev)->
+ UID.xvalues);
uid_free(&((gs_font_base *) prev)->UID,
prev->memory,
"gs_makefont(discarding)");
@@ -590,8 +590,8 @@ gs_makefont(gs_font_dir * pdir, const gs_font * pfont,
} else { /* Prevent garbage pointers. */
pf_out->next = pf_out->prev = 0;
}
- if_debug2('m', "[m]new font=0x%lx can_cache=%s\n",
- (ulong) * ppfont, (can_cache ? "true" : "false"));
+ if_debug2m('m', pfont->memory, "[m]new font=0x%lx can_cache=%s\n",
+ (ulong) * ppfont, (can_cache ? "true" : "false"));
return 1;
}
diff --git a/gs/base/gshsb.c b/gs/base/gshsb.c
index 972aa2744..64ebc1f79 100644
--- a/gs/base/gshsb.c
+++ b/gs/base/gshsb.c
@@ -150,6 +150,7 @@ color_hsb_to_rgb(floatp hue, floatp saturation, floatp brightness, float rgb[3])
rgb[0] = frac2float(R);
rgb[1] = frac2float(G);
rgb[2] = frac2float(B);
+#ifndef GS_THREADSAFE
#ifdef DEBUG
if (gs_debug_c('c')) {
dlprintf7("[c]hsb(%g,%g,%g)->VSFI(%ld,%d,%ld,%d)->\n",
@@ -158,5 +159,6 @@ color_hsb_to_rgb(floatp hue, floatp saturation, floatp brightness, float rgb[3])
R, G, B, rgb[0], rgb[1], rgb[2]);
}
#endif
+#endif
}
}
diff --git a/gs/base/gsht.c b/gs/base/gsht.c
index deac17230..ffb416d38 100644
--- a/gs/base/gsht.c
+++ b/gs/base/gsht.c
@@ -463,6 +463,7 @@ gx_sort_ht_order(gx_ht_bit * recs, uint N)
for (i = 0; i < N; i++)
recs[i].offset = i;
qsort((void *)recs, N, sizeof(*recs), compare_samples);
+#ifndef GS_THREADSAFE
#ifdef DEBUG
if (gs_debug_c('H')) {
uint i;
@@ -473,6 +474,7 @@ gx_sort_ht_order(gx_ht_bit * recs, uint N)
i, recs[i].offset, recs[i].mask);
}
#endif
+#endif
}
/*
@@ -562,11 +564,11 @@ gx_ht_construct_bits(gx_ht_order * porder)
gx_ht_construct_bit(phb, porder->width, phb->offset);
#ifdef DEBUG
if (gs_debug_c('H')) {
- dlprintf1("[H]Halftone order bits 0x%lx:\n", (ulong)porder->bit_data);
+ dmlprintf1(porder->data_memory, "[H]Halftone order bits 0x%lx:\n", (ulong)porder->bit_data);
for (i = 0, phb = (gx_ht_bit *)porder->bit_data;
i < porder->num_bits;
i++, phb++)
- dlprintf3("%4d: %u:0x%lx\n", i, phb->offset,
+ dmlprintf3(porder->data_memory, "%4d: %u:0x%lx\n", i, phb->offset,
(ulong) phb->mask);
}
#endif
@@ -1559,10 +1561,10 @@ gx_ht_construct_threshold( gx_ht_order *d_order, gx_device *dev,
#ifdef DEBUG
if ( gs_debug_c('h') ) {
for( i=0; i<(int)d_order->height; i++ ) {
- dprintf1("threshold array row %3d= ", i);
+ dmprintf1(memory, "threshold array row %3d= ", i);
for( j=(int)d_order->width-1; j>=0; j-- )
- dprintf1("%3d ", *(thresh+j+(i*d_order->width)) );
- dprintf("\n");
+ dmprintf1(memory, "%3d ", *(thresh+j+(i*d_order->width)) );
+ dmprintf(memory, "\n");
}
}
#endif
diff --git a/gs/base/gsht1.c b/gs/base/gsht1.c
index 7361c604b..bdaf7f7a3 100644
--- a/gs/base/gsht1.c
+++ b/gs/base/gsht1.c
@@ -490,8 +490,8 @@ process_threshold2(gx_ht_order * porder, gs_state * pgs,
gx_ht_bit *bits = (gx_ht_bit *)porder->bit_data;
int row, di;
- if_debug7('h', "[h]rect1=(%d,%d), rect2=(%d,%d), strip=(%d,%d), shift=%d\n",
- w1, h1, w2, h2, sod, d, shift);
+ if_debug7m('h', mem, "[h]rect1=(%d,%d), rect2=(%d,%d), strip=(%d,%d), shift=%d\n",
+ w1, h1, w2, h2, sod, d, shift);
for (row = 0, di = 0; row < d; ++row) {
/* Iterate over destination rows. */
int dx, sy = row; /* sy = row mod d */
diff --git a/gs/base/gshtscr.c b/gs/base/gshtscr.c
index 8cf39cc33..e57e60c96 100644
--- a/gs/base/gshtscr.c
+++ b/gs/base/gshtscr.c
@@ -578,7 +578,7 @@ gs_screen_next(gs_screen_enum * penum, floatp value)
if (value < -1.0 || value > 1.0)
return_error(gs_error_rangecheck);
sample = (ht_sample_t) ((value + 1) * max_ht_sample);
-#ifdef DEBUG
+#if defined(DEBUG) && !defined(GS_THREADSAFE)
if (gs_debug_c('H')) {
gs_point pt;
diff --git a/gs/base/gsicc.c b/gs/base/gsicc.c
index 5f7fc7124..00f0f3098 100644
--- a/gs/base/gsicc.c
+++ b/gs/base/gsicc.c
@@ -364,15 +364,15 @@ gx_remap_ICC(const gs_client_color * pcc, const gs_color_space * pcs,
#ifdef DEBUG
if (!icc_link->is_identity) {
num_src_comps = pcs->cmm_icc_profile_data->num_comps;
- if_debug0(gs_debug_flag_icc,"[icc] remap [ ");
+ if_debug0m(gs_debug_flag_icc, dev->memory, "[icc] remap [ ");
for (k = 0; k < num_src_comps; k++) {
- if_debug1(gs_debug_flag_icc, "%d ",psrc[k]);
+ if_debug1m(gs_debug_flag_icc, dev->memory, "%d ", psrc[k]);
}
- if_debug0(gs_debug_flag_icc,"] --> [ ");
+ if_debug0m(gs_debug_flag_icc, dev->memory, "] --> [ ");
for (k = 0; k < num_des_comps; k++) {
- if_debug1(gs_debug_flag_icc, "%d ",psrc_temp[k]);
+ if_debug1m(gs_debug_flag_icc, dev->memory, "%d ", psrc_temp[k]);
}
- if_debug0(gs_debug_flag_icc,"]\n");
+ if_debug0m(gs_debug_flag_icc, dev->memory, "]\n");
}
#endif
/* Release the link */
diff --git a/gs/base/gsicc_cache.c b/gs/base/gsicc_cache.c
index 0af1fd68b..6830933c4 100644
--- a/gs/base/gsicc_cache.c
+++ b/gs/base/gsicc_cache.c
@@ -115,8 +115,9 @@ gsicc_cache_new(gs_memory_t *memory)
result->head = NULL;
result->num_links = 0;
result->memory = memory->stable_memory;
- if_debug2(gs_debug_flag_icc,"[icc] Allocating link cache = 0x%x memory = 0x%x\n", result,
- result->memory);
+ if_debug2m(gs_debug_flag_icc, memory,
+ "[icc] Allocating link cache = 0x%x memory = 0x%x\n", result,
+ result->memory);
return(result);
}
@@ -132,15 +133,16 @@ rc_gsicc_link_cache_free(gs_memory_t * mem, void *ptr_in, client_name_t cname)
}
#ifdef DEBUG
if (link_cache->num_links != 0) {
- eprintf1("num_links is %d, should be 0.\n", link_cache->num_links);
+ emprintf1(mem, "num_links is %d, should be 0.\n", link_cache->num_links);
}
#endif
gx_semaphore_free(link_cache->wait);
link_cache->wait = NULL;
gx_monitor_free(link_cache->lock);
link_cache->lock = NULL;
- if_debug2(gs_debug_flag_icc,"[icc] Removing link cache = 0x%x memory = 0x%x\n", link_cache,
- link_cache->memory);
+ if_debug2m(gs_debug_flag_icc, mem,
+ "[icc] Removing link cache = 0x%x memory = 0x%x\n",
+ link_cache, link_cache->memory);
gs_free_object(mem->stable_memory, link_cache, "rc_gsicc_link_cache_free");
}
@@ -418,8 +420,9 @@ gsicc_remove_link(gsicc_link_t *link, gs_memory_t *memory)
gsicc_link_t *curr, *prev;
gsicc_link_cache_t *icc_link_cache = link->icc_link_cache;
- if_debug2(gs_debug_flag_icc,"[icc] Removing link = 0x%x memory = 0x%x\n", link,
- memory->stable_memory);
+ if_debug2m(gs_debug_flag_icc, memory,
+ "[icc] Removing link = 0x%x memory = 0x%x\n", link,
+ memory->stable_memory);
/* NOTE: link->ref_count must be 0: assert ? */
gx_monitor_enter(icc_link_cache->lock);
curr = icc_link_cache->head;
@@ -641,12 +644,15 @@ gsicc_get_link_profile(const gs_imager_state *pis, gx_device *dev,
include_devicelink);
/* Got a hit, return link (ref_count for the link was already bumped */
if (found_link != NULL) {
- if_debug2(gs_debug_flag_icc, "[icc] Found Link = 0x%x, hash = %I64d \n",
- found_link, hash.link_hashcode);
- if_debug2(gs_debug_flag_icc, "[icc] input_numcomps = %d, input_hash = %I64d \n",
- gs_input_profile->num_comps, gs_input_profile->hashcode);
- if_debug2(gs_debug_flag_icc, "[icc] output_numcomps = %d, output_hash = %I64d \n",
- gs_output_profile->num_comps, gs_output_profile->hashcode);
+ if_debug2m(gs_debug_flag_icc, memory,
+ "[icc] Found Link = 0x%x, hash = %I64d \n",
+ found_link, hash.link_hashcode);
+ if_debug2m(gs_debug_flag_icc, memory,
+ "[icc] input_numcomps = %d, input_hash = %I64d \n",
+ gs_input_profile->num_comps, gs_input_profile->hashcode);
+ if_debug2m(gs_debug_flag_icc, memory,
+ "[icc] output_numcomps = %d, output_hash = %I64d \n",
+ gs_output_profile->num_comps, gs_output_profile->hashcode);
return(found_link);
}
/* If not, then lets create a new one if there is room. This may actually
@@ -799,12 +805,15 @@ gsicc_get_link_profile(const gs_imager_state *pis, gx_device *dev,
gsicc_set_link_data(link, link_handle, contextptr, hash,
icc_link_cache->lock, include_softproof,
include_devicelink);
- if_debug2(gs_debug_flag_icc,"[icc] New Link = 0x%x, hash = %I64d \n",
- link, hash.link_hashcode);
- if_debug2(gs_debug_flag_icc,"[icc] input_numcomps = %d, input_hash = %I64d \n",
- gs_input_profile->num_comps, gs_input_profile->hashcode);
- if_debug2(gs_debug_flag_icc,"[icc] output_numcomps = %d, output_hash = %I64d \n",
- gs_output_profile->num_comps, gs_output_profile->hashcode);
+ if_debug2m(gs_debug_flag_icc, cache_mem,
+ "[icc] New Link = 0x%x, hash = %I64d \n",
+ link, hash.link_hashcode);
+ if_debug2m(gs_debug_flag_icc, cache_mem,
+ "[icc] input_numcomps = %d, input_hash = %I64d \n",
+ gs_input_profile->num_comps, gs_input_profile->hashcode);
+ if_debug2m(gs_debug_flag_icc, cache_mem,
+ "[icc] output_numcomps = %d, output_hash = %I64d \n",
+ gs_output_profile->num_comps, gs_output_profile->hashcode);
} else {
gsicc_remove_link(link, cache_mem);
icc_link_cache->num_links--;
diff --git a/gs/base/gsicc_manage.c b/gs/base/gsicc_manage.c
index 62315953b..225f83409 100644
--- a/gs/base/gsicc_manage.c
+++ b/gs/base/gsicc_manage.c
@@ -726,7 +726,7 @@ gsicc_set_profile(gsicc_manager_t *icc_manager, const char* pname, int namelen,
icc_profile = gsicc_profile_new(NULL, mem_gc, NULL, 0);
icc_profile->data_cs = gsNAMED;
code = gsicc_load_namedcolor_buffer(icc_profile, str, mem_gc);
- if (code < 0) gs_rethrow1(-1, "problems with profile %s", pname);
+ if (code < 0) return gs_rethrow1(-1, "problems with profile %s", pname);
*manager_default_profile = icc_profile;
nameptr = (char*) gs_alloc_bytes(icc_profile->memory, namelen+1,
"gsicc_set_profile");
@@ -774,6 +774,9 @@ gsicc_initialize_default_profile(cmm_profile_t *icc_profile)
gsicc_profile_t defaulttype = icc_profile->default_match;
gsicc_colorbuffer_t default_space = gsUNDEFINED;
int num_comps, num_comps_out;
+#ifdef DEBUG
+ const gs_memory_t *mem = icc_profile->memory;
+#endif
/* Get the profile handle if it is not already set */
if (icc_profile->profile_handle != NULL) {
@@ -799,36 +802,36 @@ gsicc_initialize_default_profile(cmm_profile_t *icc_profile)
gscms_get_output_channel_count(icc_profile->profile_handle);
icc_profile->data_cs =
gscms_get_profile_data_space(icc_profile->profile_handle);
- if_debug0(gs_debug_flag_icc,"[icc] Setting ICC profile in Manager\n");
+ if_debug0m(gs_debug_flag_icc,mem,"[icc] Setting ICC profile in Manager\n");
switch(defaulttype) {
case DEFAULT_GRAY:
- if_debug0(gs_debug_flag_icc,"[icc] Default Gray\n");
+ if_debug0m(gs_debug_flag_icc,mem,"[icc] Default Gray\n");
default_space = gsGRAY;
break;
case DEFAULT_RGB:
- if_debug0(gs_debug_flag_icc,"[icc] Default RGB\n");
+ if_debug0m(gs_debug_flag_icc,mem,"[icc] Default RGB\n");
default_space = gsRGB;
break;
case DEFAULT_CMYK:
- if_debug0(gs_debug_flag_icc,"[icc] Default CMYK\n");
+ if_debug0m(gs_debug_flag_icc,mem,"[icc] Default CMYK\n");
default_space = gsCMYK;
break;
case NAMED_TYPE:
- if_debug0(gs_debug_flag_icc,"[icc] Named Color\n");
- break;
+ if_debug0m(gs_debug_flag_icc,mem,"[icc] Named Color\n");
+ break;
case LAB_TYPE:
- if_debug0(gs_debug_flag_icc,"[icc] CIELAB Profile\n");
- break;
+ if_debug0m(gs_debug_flag_icc,mem,"[icc] CIELAB Profile\n");
+ break;
case DEVICEN_TYPE:
- if_debug0(gs_debug_flag_icc,"[icc] DeviceN Profile\n");
+ if_debug0m(gs_debug_flag_icc,mem,"[icc] DeviceN Profile\n");
break;
case DEFAULT_NONE:
default:
return(0);
break;
}
- if_debug1(gs_debug_flag_icc,"[icc] name = %s\n", icc_profile->name);
- if_debug1(gs_debug_flag_icc,"[icc] num_comps = %d\n", icc_profile->num_comps);
+ if_debug1m(gs_debug_flag_icc,mem,"[icc] name = %s\n", icc_profile->name);
+ if_debug1m(gs_debug_flag_icc,mem,"[icc] num_comps = %d\n", icc_profile->num_comps);
/* Check that we have the proper color space for the ICC
profiles that can be externally set */
if (default_space != gsUNDEFINED ||
@@ -1023,31 +1026,32 @@ rc_free_profile_array(gs_memory_t * mem, void *ptr_in, client_name_t cname)
/* Decrement any profiles. */
for (k = 0; k < NUM_DEVICE_PROFILES; k++) {
if (icc_struct->device_profile[k] != NULL) {
- if_debug1(gs_debug_flag_icc,"[icc] Releasing device profile %d\n", k);
+ if_debug1m(gs_debug_flag_icc, mem_nongc,
+ "[icc] Releasing device profile %d\n", k);
rc_decrement(icc_struct->device_profile[k],
"rc_free_profile_array");
}
}
if (icc_struct->link_profile != NULL) {
- if_debug0(gs_debug_flag_icc,"[icc] Releasing link profile\n");
+ if_debug0m(gs_debug_flag_icc,mem_nongc,"[icc] Releasing link profile\n");
rc_decrement(icc_struct->link_profile, "rc_free_profile_array");
}
if (icc_struct->proof_profile != NULL) {
- if_debug0(gs_debug_flag_icc,"[icc] Releasing proof profile\n");
+ if_debug0m(gs_debug_flag_icc,mem_nongc,"[icc] Releasing proof profile\n");
rc_decrement(icc_struct->proof_profile, "rc_free_profile_array");
}
if (icc_struct->oi_profile != NULL) {
- if_debug0(gs_debug_flag_icc, "[icc] Releasing oi profile\n");
+ if_debug0m(gs_debug_flag_icc,mem_nongc,"[icc] Releasing oi profile\n");
rc_decrement(icc_struct->oi_profile, "rc_free_profile_array");
}
if (icc_struct->spotnames != NULL) {
- if_debug0(gs_debug_flag_icc, "[icc] Releasing spotnames\n");
+ if_debug0m(gs_debug_flag_icc, mem_nongc, "[icc] Releasing spotnames\n");
/* Free the linked list in this object */
gsicc_free_spotnames(icc_struct->spotnames, mem_nongc);
/* Free the main object */
gs_free_object(mem_nongc, icc_struct->spotnames, "rc_free_profile_array");
}
- if_debug0(gs_debug_flag_icc,"[icc] Releasing device profile struct\n");
+ if_debug0m(gs_debug_flag_icc,mem_nongc,"[icc] Releasing device profile struct\n");
gs_free_object(mem_nongc, icc_struct, "rc_free_profile_array");
}
}
@@ -1059,7 +1063,7 @@ gsicc_new_device_profile_array(gs_memory_t *memory)
cmm_dev_profile_t *result;
int k;
- if_debug0(gs_debug_flag_icc,"[icc] Allocating device profile struct\n");
+ if_debug0m(gs_debug_flag_icc,memory,"[icc] Allocating device profile struct\n");
result = (cmm_dev_profile_t *) gs_alloc_bytes(memory->non_gc_memory,
sizeof(cmm_dev_profile_t),
"gsicc_new_device_profile_array");
@@ -1296,15 +1300,16 @@ gsicc_set_device_profile(gx_device * pdev, gs_memory_t * mem,
gsicc_profile_new(str, mem, file_name, strlen(file_name));
code = sfclose(str);
if (pro_enum < gsPROOFPROFILE) {
- if_debug1(gs_debug_flag_icc, "[icc] Setting device profile %d\n", pro_enum);
+ if_debug1m(gs_debug_flag_icc, mem,
+ "[icc] Setting device profile %d\n", pro_enum);
pdev->icc_struct->device_profile[pro_enum] = icc_profile;
} else {
/* The proof, link or output intent profile */
if (pro_enum == gsPROOFPROFILE) {
- if_debug0(gs_debug_flag_icc, "[icc] Setting proof profile\n");
+ if_debug0m(gs_debug_flag_icc, mem, "[icc] Setting proof profile\n");
pdev->icc_struct->proof_profile = icc_profile;
} else {
- if_debug0(gs_debug_flag_icc, "[icc] Setting link profile\n");
+ if_debug0m(gs_debug_flag_icc, mem, "[icc] Setting link profile\n");
pdev->icc_struct->link_profile = icc_profile;
}
}
@@ -1321,8 +1326,8 @@ gsicc_set_device_profile(gx_device * pdev, gs_memory_t * mem,
/* Get the number of channels in the output profile */
icc_profile->num_comps =
gscms_get_input_channel_count(icc_profile->profile_handle);
- if_debug1(gs_debug_flag_icc, "[icc] Profile has %d components\n",
- icc_profile->num_comps);
+ if_debug1m(gs_debug_flag_icc, mem, "[icc] Profile has %d components\n",
+ icc_profile->num_comps);
icc_profile->num_comps_out =
gscms_get_output_channel_count(icc_profile->profile_handle);
icc_profile->data_cs =
@@ -1355,8 +1360,8 @@ gsicc_set_device_profile(gx_device * pdev, gs_memory_t * mem,
default:
break;
}
- if_debug1(gs_debug_flag_icc, "[icc] Profile data CS is %d\n",
- icc_profile->data_cs);
+ if_debug1m(gs_debug_flag_icc, mem, "[icc] Profile data CS is %d\n",
+ icc_profile->data_cs);
} else
return gs_rethrow(-1, "cannot find device profile");
}
@@ -1438,7 +1443,8 @@ gsicc_profile_new(stream *s, gs_memory_t *memory, const char* pname,
gs_free_object(mem_nongc, result, "gsicc_profile_new");
return(NULL);
}
- if_debug1(gs_debug_flag_icc,"[icc] allocating ICC profile = 0x%x\n", result);
+ if_debug1m(gs_debug_flag_icc, mem_nongc,
+ "[icc] allocating ICC profile = 0x%x\n", result);
return(result);
}
@@ -1448,15 +1454,16 @@ rc_free_icc_profile(gs_memory_t * mem, void *ptr_in, client_name_t cname)
cmm_profile_t *profile = (cmm_profile_t *)ptr_in;
gs_memory_t *mem_nongc = profile->memory;
- if_debug2(gs_debug_flag_icc,"[icc] rc decrement profile = 0x%x rc = %ld\n",
- ptr_in, profile->rc.ref_count);
+ if_debug2m(gs_debug_flag_icc, mem,
+ "[icc] rc decrement profile = 0x%x rc = %ld\n",
+ ptr_in, profile->rc.ref_count);
if (profile->rc.ref_count <= 1 ) {
/* Clear out the buffer if it is full */
if(profile->buffer != NULL) {
gs_free_object(mem_nongc, profile->buffer, "rc_free_icc_profile");
profile->buffer = NULL;
}
- if_debug0(gs_debug_flag_icc,"[icc] profile freed\n");
+ if_debug0m(gs_debug_flag_icc, mem, "[icc] profile freed\n");
/* Release this handle if it has been set */
if(profile->profile_handle != NULL) {
gscms_release_profile(profile->profile_handle);
diff --git a/gs/base/gsicc_profilecache.c b/gs/base/gsicc_profilecache.c
index 6324dcbe3..1ee222c21 100644
--- a/gs/base/gsicc_profilecache.c
+++ b/gs/base/gsicc_profilecache.c
@@ -81,8 +81,8 @@ rc_gsicc_profile_cache_free(gs_memory_t * mem, void *ptr_in, client_name_t cname
}
#ifdef DEBUG
if (profile_cache->num_entries != 0)
- eprintf1("gsicc_profile_cache_free, num_entries is %d (should be 0).\n",
- profile_cache->num_entries);
+ emprintf1(mem,"gsicc_profile_cache_free, num_entries is %d (should be 0).\n",
+ profile_cache->num_entries);
#endif
gs_free_object(mem->stable_memory, profile_cache,
"rc_gsicc_profile_cache_free");
@@ -148,7 +148,7 @@ gsicc_remove_cs_entry(gsicc_profile_cache_t *profile_cache)
#ifdef DEBUG
if (curr == NULL) {
- eprintf(" attempt to remove from an empty profile cache.\n");
+ emprintf(memory, " attempt to remove from an empty profile cache.\n");
return; /* gs_abort(); */
}
#endif
@@ -162,7 +162,7 @@ gsicc_remove_cs_entry(gsicc_profile_cache_t *profile_cache)
profile_cache->head = NULL;
#ifdef DEBUG
if (profile_cache->num_entries != 0) {
- eprintf1("profile cache list empty, but list has num_entries=%d.\n",
+ emprintf1(memory, "profile cache list empty, but list has num_entries=%d.\n",
profile_cache->num_entries);
}
#endif
diff --git a/gs/base/gsimage.c b/gs/base/gsimage.c
index 621ccafb2..14d7dffb1 100644
--- a/gs/base/gsimage.c
+++ b/gs/base/gsimage.c
@@ -455,9 +455,9 @@ free_row_buffers(gs_image_enum *penum, int num_planes, client_name_t cname)
int i;
for (i = num_planes - 1; i >= 0; --i) {
- if_debug3('b', "[b]free plane %d row (0x%lx,%u)\n",
- i, (ulong)penum->planes[i].row.data,
- penum->planes[i].row.size);
+ if_debug3m('b', penum->memory, "[b]free plane %d row (0x%lx,%u)\n",
+ i, (ulong)penum->planes[i].row.data,
+ penum->planes[i].row.size);
gs_free_string(gs_image_row_memory(penum), penum->planes[i].row.data,
penum->planes[i].row.size, cname);
penum->planes[i].row.data = 0;
@@ -508,7 +508,7 @@ gs_image_next_planes(gs_image_enum * penum,
int pi;
for (pi = 0; pi < num_planes; ++pi)
- dprintf6("[b]plane %d source=0x%lx,%u pos=%u data=0x%lx,%u\n",
+ dmprintf6(penum->memory, "[b]plane %d source=0x%lx,%u pos=%u data=0x%lx,%u\n",
pi, (ulong)penum->planes[pi].source.data,
penum->planes[pi].source.size, penum->planes[pi].pos,
(ulong)plane_data[pi].data, plane_data[pi].size);
@@ -552,9 +552,9 @@ gs_image_next_planes(gs_image_enum * penum,
gs_resize_string(mem, old_data, old_size, raster,
"gs_image_next(row)"));
- if_debug5('b', "[b]plane %d row (0x%lx,%u) => (0x%lx,%u)\n",
- i, (ulong)old_data, old_size,
- (ulong)row, raster);
+ if_debug5m('b', mem, "[b]plane %d row (0x%lx,%u) => (0x%lx,%u)\n",
+ i, (ulong)old_data, old_size,
+ (ulong)row, raster);
if (row == 0) {
code = gs_note_error(gs_error_VMerror);
free_row_buffers(penum, i, "gs_image_next(row)");
@@ -604,7 +604,7 @@ gs_image_next_planes(gs_image_enum * penum,
} else {
code = gx_image_plane_data_rows(penum->info, penum->image_planes,
h, &h);
- if_debug2('b', "[b]used %d, code=%d\n", h, code);
+ if_debug2m('b', penum->memory, "[b]used %d, code=%d\n", h, code);
penum->error = code < 0;
}
penum->y += h;
diff --git a/gs/base/gslib.c b/gs/base/gslib.c
index 3b3d1b989..54161b4ab 100644
--- a/gs/base/gslib.c
+++ b/gs/base/gslib.c
@@ -143,9 +143,9 @@ main(int argc, const char *argv[])
lprintf1("reading Name failed! code = %d\n", code);
gs_abort(mem);
}
- dputs("Device name = ");
- debug_print_string(nstr.data, nstr.size);
- dputs("\n");
+ dmputs(dev->memory, "Device name = ");
+ debug_print_string(dev->memory, nstr.data, nstr.size);
+ dmputs(dev->memory, "\n");
gs_c_param_list_release(&list);
}
/*
@@ -196,12 +196,12 @@ main(int argc, const char *argv[])
gs_rect bbox;
gx_device_bbox_bbox(bbdev, &bbox);
- dprintf4("Bounding box: [%g %g %g %g]\n",
+ dmprintf4(mem, "Bounding box: [%g %g %g %g]\n",
bbox.p.x, bbox.p.y, bbox.q.x, bbox.q.y);
}
if (code)
- dprintf1("**** Test returned code = %d.\n", code);
- dputs("Done. Press <enter> to exit.");
+ dmprintf1(mem, "**** Test returned code = %d.\n", code);
+ dmputs(mem, "Done. Press <enter> to exit.");
fgetc(mem->gs_lib_ctx->fstdin);
gs_lib_finit(0, 0, mem);
return 0;
@@ -817,12 +817,12 @@ test7(gs_state * pgs, gs_memory_t * mem)
/* Fabricate a Type 5 halftone. */
code = gs_ht_build(&pht, 1, mem);
- dprintf1("ht build code = %d\n", code);
+ dmprintf1(mem, "ht build code = %d\n", code);
code = gs_ht_set_mask_comp(pht, 0,
4, 4, 4, masks, NULL, NULL);
- dprintf1("set mask code = %d\n", code);
+ dmprintf1(mem, "set mask code = %d\n", code);
code = gs_sethalftone(pgs, pht);
- dprintf1("sethalftone code = %d\n", code);
+ dmprintf1(mem, "sethalftone code = %d\n", code);
for (i = 0; i <= 4; ++i) {
gs_setgray(pgs, i / 4.0);
fill_rect1(pgs, 100 + i * 100, 100, 50, 50);
diff --git a/gs/base/gslibctx.c b/gs/base/gslibctx.c
index 6e6c4397a..2e50248a0 100644
--- a/gs/base/gslibctx.c
+++ b/gs/base/gslibctx.c
@@ -150,10 +150,12 @@ int outwrite(const gs_memory_t *mem, const char *str, int len)
return code;
}
+#ifndef GS_THREADSAFE
int errwrite_nomem(const char *str, int len)
{
return errwrite(mem_err_print, str, len);
}
+#endif
int errwrite(const gs_memory_t *mem, const char *str, int len)
{
@@ -182,10 +184,13 @@ void outflush(const gs_memory_t *mem)
fflush(mem->gs_lib_ctx->fstdout);
}
+#ifndef GS_THREADSAFE
void errflush_nomem(void)
{
errflush(mem_err_print);
}
+#endif
+
void errflush(const gs_memory_t *mem)
{
if (!mem->gs_lib_ctx->stderr_fn)
diff --git a/gs/base/gsmalloc.c b/gs/base/gsmalloc.c
index d1b1acd6a..9f405a02c 100644
--- a/gs/base/gsmalloc.c
+++ b/gs/base/gsmalloc.c
@@ -213,8 +213,8 @@ gs_heap_alloc_bytes(gs_memory_t * mem, uint size, client_name_t cname)
gs_alloc_fill(ptr, gs_alloc_fill_alloc, size);
#ifdef DEBUG
if (gs_debug_c('a') || msg != ok_msg)
- dlprintf6("[a+]gs_malloc(%s)(%u) = 0x%lx: %s, used=%ld, max=%ld\n",
- client_name_string(cname), size, (ulong) ptr, msg, mmem->used, mmem->max_used);
+ dmlprintf6(mem, "[a+]gs_malloc(%s)(%u) = 0x%lx: %s, used=%ld, max=%ld\n",
+ client_name_string(cname), size, (ulong) ptr, msg, mmem->used, mmem->max_used);
#endif
return ptr;
#undef set_msg
@@ -308,17 +308,17 @@ gs_heap_free_object(gs_memory_t * mem, void *ptr, client_name_t cname)
gs_memory_type_ptr_t pstype;
struct_proc_finalize((*finalize));
- if_debug3('a', "[a-]gs_free(%s) 0x%lx(%u)\n",
- client_name_string(cname), (ulong) ptr,
- (ptr == 0 ? 0 : ((gs_malloc_block_t *) ptr)[-1].size));
+ if_debug3m('a', mem, "[a-]gs_free(%s) 0x%lx(%u)\n",
+ client_name_string(cname), (ulong) ptr,
+ (ptr == 0 ? 0 : ((gs_malloc_block_t *) ptr)[-1].size));
if (ptr == 0)
return;
pstype = ((gs_malloc_block_t *) ptr)[-1].type;
finalize = pstype->finalize;
if (finalize != 0) {
- if_debug3('u', "[u]finalizing %s 0x%lx (%s)\n",
- struct_type_name_string(pstype),
- (ulong) ptr, client_name_string(cname));
+ if_debug3m('u', mem, "[u]finalizing %s 0x%lx (%s)\n",
+ struct_type_name_string(pstype),
+ (ulong) ptr, client_name_string(cname));
(*finalize) (mem, ptr);
}
if (mmem->monitor)
@@ -478,9 +478,9 @@ gs_heap_free_all(gs_memory_t * mem, uint free_mask, client_name_t cname)
for (; bp != 0; bp = np) {
np = bp->next;
- if_debug3('a', "[a]gs_heap_free_all(%s) 0x%lx(%u)\n",
- client_name_string(bp->cname), (ulong) (bp + 1),
- bp->size);
+ if_debug3m('a', mem, "[a]gs_heap_free_all(%s) 0x%lx(%u)\n",
+ client_name_string(bp->cname), (ulong) (bp + 1),
+ bp->size);
gs_alloc_fill(bp + 1, gs_alloc_fill_free, bp->size);
free(bp);
}
diff --git a/gs/base/gsmchunk.c b/gs/base/gsmchunk.c
index 94f0c4b87..eff30ea5f 100644
--- a/gs/base/gsmchunk.c
+++ b/gs/base/gsmchunk.c
@@ -181,10 +181,10 @@ gs_memory_chunk_dump_memory(const gs_memory_t *mem)
chunk_mem_node_t *next;
int i;
- dprintf2("chunk_dump_memory: current used=%d, max_used=%d\n", cmem->used, cmem->max_used);
+ dmprintf2(mem, "chunk_dump_memory: current used=%d, max_used=%d\n", cmem->used, cmem->max_used);
if (cmem->in_use != 0)
- dprintf1("*** this memory allocator is not idle, used for: %s\n",
- cmem->in_use < 0 ? "free" : "alloc");
+ dmprintf1(mem, "*** this memory allocator is not idle, used for: %s\n",
+ cmem->in_use < 0 ? "free" : "alloc");
for (i=0; i<2; i++) {
current = head;
while ( current != NULL ) {
@@ -192,8 +192,8 @@ gs_memory_chunk_dump_memory(const gs_memory_t *mem)
chunk_obj_node_t *obj;
for (obj= current->objlist; obj != NULL; obj=obj->next)
- dprintf4("chunk_mem leak, obj=0x%lx, size=%d, type=%s, sequence#=%ld\n",
- (ulong)obj, obj->size, obj->type->sname, obj->sequence);
+ dmprintf4(mem, "chunk_mem leak, obj=0x%lx, size=%d, type=%s, sequence#=%ld\n",
+ (ulong)obj, obj->size, obj->type->sname, obj->sequence);
}
next = current->next;
current = next;
@@ -222,8 +222,8 @@ chunk_mem_node_free_all_remaining(gs_memory_chunk_t *cmem)
#ifdef DEBUG
if (cmem->in_use != 0)
- dprintf1("*** chunk_mem_node_free_all_remaining: this memory allocator is not idle, used for: %s\n",
- cmem->in_use < 0 ? "free" : "alloc");
+ dmprintf1(target, "*** chunk_mem_node_free_all_remaining: this memory allocator is not idle, used for: %s\n",
+ cmem->in_use < 0 ? "free" : "alloc");
#endif
for (i=0; i<2; i++) {
current = head;
@@ -246,8 +246,8 @@ chunk_free_all(gs_memory_t * mem, uint free_mask, client_name_t cname)
#ifdef DEBUG
if (cmem->in_use != 0)
- dprintf1("*** chunk_free_all: this memory allocator is not idle, used for: %s\n",
- cmem->in_use < 0 ? "free" : "alloc");
+ dmprintf1(target, "*** chunk_free_all: this memory allocator is not idle, used for: %s\n",
+ cmem->in_use < 0 ? "free" : "alloc");
#endif
/* Only free the structures and the allocator itself. */
if (mem->stable_memory) {
@@ -373,7 +373,7 @@ chunk_mem_node_remove(gs_memory_chunk_t *cmem, chunk_mem_node_t *addr)
/* check the head first */
if (head == NULL) {
- dprintf("FAIL - no nodes to be removed\n" );
+ dmprintf(target, "FAIL - no nodes to be removed\n" );
return -1;
}
if (head == addr) {
@@ -393,7 +393,7 @@ chunk_mem_node_remove(gs_memory_chunk_t *cmem, chunk_mem_node_t *addr)
}
}
if ( !found ) {
- dprintf1("FAIL freeing wild pointer freed address 0x%lx not found\n", (ulong)addr );
+ dmprintf1(target, "FAIL freeing wild pointer freed address 0x%lx not found\n", (ulong)addr );
return -1;
}
}
@@ -415,7 +415,7 @@ chunk_obj_alloc(gs_memory_t *mem, uint size, gs_memory_type_ptr_t type, client_n
#ifdef DEBUG
if (cmem->in_use != 0)
- dprintf1("*** chunk_obj_alloc: this memory allocator is not idle, used for: %s\n",
+ dmprintf1(mem, "*** chunk_obj_alloc: this memory allocator is not idle, used for: %s\n",
cmem->in_use < 0 ? "free" : "alloc");
cmem->in_use = 1; /* alloc */
#endif
@@ -438,7 +438,7 @@ chunk_obj_alloc(gs_memory_t *mem, uint size, gs_memory_type_ptr_t type, client_n
) < 0) {
#ifdef DEBUG
if (gs_debug_c('a'))
- dlprintf1("[a+]chunk_obj_alloc(chunk_mem_node_add)(%u) Failed.\n", size);
+ dmlprintf1(mem, "[a+]chunk_obj_alloc(chunk_mem_node_add)(%u) Failed.\n", size);
cmem->in_use = 0; /* idle */
#endif
return NULL;
@@ -454,7 +454,7 @@ chunk_obj_alloc(gs_memory_t *mem, uint size, gs_memory_type_ptr_t type, client_n
}
if (free_obj == NULL) {
- dprintf2("largest_free value = %d is too large, cannot find room for size = %d\n",
+ dmprintf2(mem, "largest_free value = %d is too large, cannot find room for size = %d\n",
current->largest_free, newsize);
#ifdef DEBUG
cmem->in_use = 0; /* idle */
@@ -507,8 +507,8 @@ chunk_obj_alloc(gs_memory_t *mem, uint size, gs_memory_type_ptr_t type, client_n
/* return the client area of the object we allocated */
#ifdef DEBUG
if (gs_debug_c('A'))
- dlprintf3("[a+]chunk_obj_alloc (%s)(%u) = 0x%lx: OK.\n",
- client_name_string(cname), size, (ulong) newobj);
+ dmlprintf3(mem, "[a+]chunk_obj_alloc (%s)(%u) = 0x%lx: OK.\n",
+ client_name_string(cname), size, (ulong) newobj);
cmem->in_use = 0; /* idle */
#endif
return (byte *)(newobj) + sizeof(chunk_obj_node_t);
@@ -618,8 +618,9 @@ chunk_free_object(gs_memory_t * mem, void *ptr, client_name_t cname)
finalize(mem, ptr);
#ifdef DEBUG
if (cmem->in_use != 0)
- dprintf1("*** chunk_free_object: this memory allocator is not idle, used for: %s\n",
- cmem->in_use < 0 ? "free" : "alloc");
+ dmprintf1(cmem->target,
+ "*** chunk_free_object: this memory allocator is not idle, used for: %s\n",
+ cmem->in_use < 0 ? "free" : "alloc");
cmem->in_use = -1; /* free */
#endif
/* finalize may change the head_**_chunk doing free of stuff */
@@ -636,8 +637,9 @@ chunk_free_object(gs_memory_t * mem, void *ptr, client_name_t cname)
/* Find the chunk containing this object */
for ( ; current != NULL; current = current->next) {
if (((byte *)obj > (byte *)current) && ((byte *)obj < (byte *)(current) + current->size)) {
- dprintf1("chunk_free_obj: OOPS! found it on the single_object list, size=%d\n",
- obj->size);
+ dmprintf1(cmem->target,
+ "chunk_free_obj: OOPS! found it on the single_object list, size=%d\n",
+ obj->size);
break;
}
}
@@ -646,15 +648,18 @@ chunk_free_object(gs_memory_t * mem, void *ptr, client_name_t cname)
/* Find the chunk containing this object */
for ( ; current != NULL; current = current->next) {
if (((byte *)obj > (byte *)current) && ((byte *)obj < (byte *)(current) + current->size)) {
- dprintf1("chunk_free_obj: OOPS! found it on the multiple_object list, size=%d\n",
- obj->size);
+ dmprintf1(cmem->target,
+ "chunk_free_obj: OOPS! found it on the multiple_object list, size=%d\n",
+ obj->size);
break;
}
}
}
if (current == NULL) {
/* Object not found in any chunk */
- dprintf2("chunk_free_obj failed, object 0x%lx not in any chunk, size=%d\n", ((ulong)obj), obj->size);
+ dmprintf2(cmem->target,
+ "chunk_free_obj failed, object 0x%lx not in any chunk, size=%d\n",
+ ((ulong)obj), obj->size);
#ifdef DEBUG
cmem->in_use = 0; /* idle */
#endif
@@ -679,8 +684,9 @@ chunk_free_object(gs_memory_t * mem, void *ptr, client_name_t cname)
}
if (scan_obj == NULL) {
/* Object not found in expected chunk */
- dprintf3("chunk_free_obj failed, object 0x%lx not in chunk at 0x%lx, size = %d\n",
- ((ulong)obj), ((ulong)current), current->size);
+ dmprintf3(cmem->target,
+ "chunk_free_obj failed, object 0x%lx not in chunk at 0x%lx, size = %d\n",
+ ((ulong)obj), ((ulong)current), current->size);
#ifdef DEBUG
cmem->in_use = 0; /* idle */
#endif
@@ -692,7 +698,7 @@ chunk_free_object(gs_memory_t * mem, void *ptr, client_name_t cname)
else
prev_obj->next = obj->next;
- if_debug3('A', "[a-]chunk_free_object(%s) 0x%lx(%u)\n",
+ if_debug3m('A', cmem->target, "[a-]chunk_free_object(%s) 0x%lx(%u)\n",
client_name_string(cname), (ulong) ptr, obj->size);
/* Add this object's space (including the header) to the free list */
@@ -750,8 +756,9 @@ memset((byte *)(obj) + sizeof(chunk_obj_node_t), 0xf1, obj->size - sizeof(chunk_
/* If this chunk is now totally empty, free it */
if (current->objlist == NULL) {
if (current->size != current->freelist->size + sizeof(chunk_mem_node_t))
- dprintf2("chunk freelist size not correct, is: %d, should be: %d\n",
- round_up_to_align(current->freelist->size + sizeof(chunk_mem_node_t)), current->size);
+ dmprintf2(cmem->target,
+ "chunk freelist size not correct, is: %d, should be: %d\n",
+ round_up_to_align(current->freelist->size + sizeof(chunk_mem_node_t)), current->size);
chunk_mem_node_remove(cmem, current);
}
#ifdef DEBUG
@@ -856,7 +863,7 @@ chunk_unregister_root(gs_memory_t * mem, gs_gc_root_t * rp, client_name_t cname)
#define A(obj, size) \
if ((obj = gs_alloc_bytes(cmem, size, "chunk_alloc_unit_test")) == NULL) { \
- dprintf("chunk alloc failed\n"); \
+ dmprintf(cmem, "chunk alloc failed\n"); \
return_error(gs_error_VMerror); \
}
@@ -871,7 +878,7 @@ chunk_allocator_unit_test(gs_memory_t *mem)
byte *obj1, *obj2, *obj3, *obj4, *obj5, *obj6, *obj7;
if ((code = gs_memory_chunk_wrap(&cmem, mem )) < 0) {
- dprintf1("chunk_wrap returned error code: %d\n", code);
+ dmprintf1(cmem, "chunk_wrap returned error code: %d\n", code);
return code;
}
diff --git a/gs/base/gsmemory.c b/gs/base/gsmemory.c
index ddb468323..33ba5f40a 100644
--- a/gs/base/gsmemory.c
+++ b/gs/base/gsmemory.c
@@ -251,29 +251,29 @@ rc_object_type_name(const void *vp, const rc_header *prc)
void
rc_trace_init_free(const void *vp, const rc_header *prc)
{
- dprintf3("[^]%s 0x%lx init = %ld\n",
- rc_object_type_name(vp, prc), (ulong)vp, (long)prc->ref_count);
+ dmprintf3(prc->memory, "[^]%s 0x%lx init = %ld\n",
+ rc_object_type_name(vp, prc), (ulong)vp, (long)prc->ref_count);
}
void
rc_trace_free_struct(const void *vp, const rc_header *prc, client_name_t cname)
{
- dprintf3("[^]%s 0x%lx => free (%s)\n",
+ dmprintf3(prc->memory, "[^]%s 0x%lx => free (%s)\n",
rc_object_type_name(vp, prc),
(ulong)vp, client_name_string(cname));
}
void
rc_trace_increment(const void *vp, const rc_header *prc)
{
- dprintf3("[^]%s 0x%lx ++ => %ld\n",
+ dmprintf3(prc->memory, "[^]%s 0x%lx ++ => %ld\n",
rc_object_type_name(vp, prc),
(ulong)vp, (long)prc->ref_count);
}
void
rc_trace_adjust(const void *vp, const rc_header *prc, int delta)
{
- dprintf4("[^]%s 0x%lx %+d => %ld\n",
- rc_object_type_name(vp, prc),
- (ulong)vp, delta, (long)(prc->ref_count + delta));
+ dmprintf4(prc->memory, "[^]%s 0x%lx %+d => %ld\n",
+ rc_object_type_name(vp, prc),
+ (ulong)vp, delta, (long)(prc->ref_count + delta));
}
#endif /* DEBUG */
@@ -297,8 +297,8 @@ ENUM_PTRS_BEGIN_PROC(basic_enum_ptrs)
/* with number of elements 0 and allocation not passing 'element' */
if (size == 0) {
#ifdef DEBUG
- dprintf2(" basic_enum_ptrs: Attempt to enum 0 size structure at 0x%lx, type: %s\n",
- (ulong)vptr, pstype->sname);
+ dmprintf2(mem, " basic_enum_ptrs: Attempt to enum 0 size structure at 0x%lx, type: %s\n",
+ (ulong)vptr, pstype->sname);
#endif
return 0;
}
@@ -309,8 +309,8 @@ ENUM_PTRS_BEGIN_PROC(basic_enum_ptrs)
#ifdef DEBUG
/* some extra checking to make sure we aren't out of bounds */
if (ppe->offset > size - sizeof(void *)) {
- dprintf4(" basic_enum_ptrs: Attempt to enum ptr with offset=%d beyond size=%d: structure at 0x%lx, type: %s\n",
- ppe->offset, size, (ulong)vptr, pstype->sname);
+ dmprintf4(mem, " basic_enum_ptrs: Attempt to enum ptr with offset=%d beyond size=%d: structure at 0x%lx, type: %s\n",
+ ppe->offset, size, (ulong)vptr, pstype->sname);
return 0;
}
#endif
diff --git a/gs/base/gsmisc.c b/gs/base/gsmisc.c
index 51197e31b..45e67e182 100644
--- a/gs/base/gsmisc.c
+++ b/gs/base/gsmisc.c
@@ -73,6 +73,7 @@ int outprintf(const gs_memory_t *mem, const char *fmt, ...)
return count;
}
+#ifndef GS_THREADSAFE
int errprintf_nomem(const char *fmt, ...)
{
int count;
@@ -90,6 +91,7 @@ int errprintf_nomem(const char *fmt, ...)
va_end(args);
return count;
}
+#endif
int errprintf(const gs_memory_t *mem, const char *fmt, ...)
{
@@ -132,7 +134,7 @@ gs_debug_c(int c)
do {
ret |= gs_debug[c];
- } while (c = gs_debug_flag_implied_by[c]);
+ } while ((c = gs_debug_flag_implied_by[c]) != 0);
return ret;
}
@@ -146,11 +148,6 @@ const char *const dprintf_file_only_format = "%10s(unkn): ";
* out/errprintf, not fprintf nor fput[cs], because of the way that
* stdout/stderr are implemented on DLL/shared library builds.
*/
-void
-dflush(void)
-{
- errflush_nomem();
-}
static const char *
dprintf_file_tail(const char *file)
{
@@ -162,6 +159,12 @@ dprintf_file_tail(const char *file)
--tail;
return tail;
}
+#ifndef GS_THREADSAFE
+void
+dflush(void)
+{
+ errflush_nomem();
+}
#if __LINE__ /* compiler provides it */
void
dprintf_file_and_line(const char *file, int line)
@@ -170,6 +173,11 @@ dprintf_file_and_line(const char *file, int line)
dpf(dprintf_file_and_line_format,
dprintf_file_tail(file), line);
}
+void
+lprintf_file_and_line(const char *file, int line)
+{
+ epf("%s(%d): ", file, line);
+}
#else
void
dprintf_file_only(const char *file)
@@ -177,18 +185,12 @@ dprintf_file_only(const char *file)
if (gs_debug['/'])
dpf(dprintf_file_only_format, dprintf_file_tail(file));
}
-#endif
void
-printf_program_ident(const gs_memory_t *mem, const char *program_name, long revision_number)
+lprintf_file_only(FILE * f, const char *file)
{
- if (program_name)
- outprintf(mem, (revision_number ? "%s " : "%s"), program_name);
- if (revision_number) {
- int fpart = revision_number % 100;
-
- outprintf(mem, "%d.%02d", (int)(revision_number / 100), fpart);
- }
+ epf("%s(?): ", file);
}
+#endif
void
eprintf_program_ident(const char *program_name,
long revision_number)
@@ -203,6 +205,34 @@ eprintf_program_ident(const char *program_name,
epf(": ");
}
}
+#endif
+#if __LINE__ /* compiler provides it */
+void
+dmprintf_file_and_line(const gs_memory_t *mem,const char *file, int line)
+{
+ if (gs_debug['/'])
+ dpfm(mem, dprintf_file_and_line_format,
+ dprintf_file_tail(file), line);
+}
+#else
+void
+dmprintf_file_only(const gs_memory_t *mem,const char *file)
+{
+ if (gs_debug['/'])
+ dpfm(mem, dprintf_file_only_format, dprintf_file_tail(file));
+}
+#endif
+void
+printf_program_ident(const gs_memory_t *mem, const char *program_name, long revision_number)
+{
+ if (program_name)
+ outprintf(mem, (revision_number ? "%s " : "%s"), program_name);
+ if (revision_number) {
+ int fpart = revision_number % 100;
+
+ outprintf(mem, "%d.%02d", (int)(revision_number / 100), fpart);
+ }
+}
void
emprintf_program_ident(const gs_memory_t *mem,
const char *program_name,
@@ -220,15 +250,15 @@ emprintf_program_ident(const gs_memory_t *mem,
}
#if __LINE__ /* compiler provides it */
void
-lprintf_file_and_line(const char *file, int line)
+mlprintf_file_and_line(const gs_memory_t *mem, const char *file, int line)
{
- epf("%s(%d): ", file, line);
+ epfm(mem, "%s(%d): ", file, line);
}
#else
void
-lprintf_file_only(FILE * f, const char *file)
+mlprintf_file_only(const gs_memory_t *mem, FILE * f, const char *file)
{
- epf("%s(?): ", file);
+ epfm(mem, "%s(?): ", file);
}
#endif
@@ -262,6 +292,7 @@ gs_return_check_interrupt(const gs_memory_t *mem, int code)
}
}
+#ifndef GS_THREADSAFE
int gs_throw_imp(const char *func, const char *file, int line, int op, int code, const char *fmt, ...)
{
char msg[1024];
@@ -298,6 +329,7 @@ int gs_throw_imp(const char *func, const char *file, int line, int op, int code,
return code;
}
+#endif
const char *gs_errstr(int code)
{
@@ -495,55 +527,68 @@ gs_realloc(void *old_ptr, size_t old_size, size_t new_size)
/* ------ Debugging support ------ */
+#ifndef GS_THREADSAFE
+/* Print a string in hexdump format. */
+void
+debug_print_string_hex_nomem(const byte * chrs, uint len)
+{
+ uint i;
+
+ for (i = 0; i < len; i++)
+ dprintf1("%02x", chrs[i]);
+ dflush();
+}
+#endif
+
/* Dump a region of memory. */
void
-debug_dump_bytes(const byte * from, const byte * to, const char *msg)
+debug_dump_bytes(const gs_memory_t *mem, const byte * from, const byte * to, const char *msg)
{
const byte *p = from;
if (from < to && msg)
- dprintf1("%s:\n", msg);
+ dmprintf1(mem, "%s:\n", msg);
while (p != to) {
const byte *q = min(p + 16, to);
- dprintf1("0x%lx:", (ulong) p);
+ dmprintf1(mem, "0x%lx:", (ulong) p);
while (p != q)
- dprintf1(" %02x", *p++);
- dputc('\n');
+ dmprintf1(mem, " %02x", *p++);
+ dmputc(mem, '\n');
}
}
/* Dump a bitmap. */
void
-debug_dump_bitmap(const byte * bits, uint raster, uint height, const char *msg)
+debug_dump_bitmap(const gs_memory_t *mem, const byte * bits, uint raster, uint height, const char *msg)
{
uint y;
const byte *data = bits;
for (y = 0; y < height; ++y, data += raster)
- debug_dump_bytes(data, data + raster, (y == 0 ? msg : NULL));
+ debug_dump_bytes(mem, data, data + raster, (y == 0 ? msg : NULL));
}
/* Print a string. */
void
-debug_print_string(const byte * chrs, uint len)
+debug_print_string(const gs_memory_t *mem, const byte * chrs, uint len)
{
uint i;
for (i = 0; i < len; i++)
- dputc(chrs[i]);
- dflush();
+ dmputc(mem, chrs[i]);
+ dmflush(mem);
}
/* Print a string in hexdump format. */
void
-debug_print_string_hex(const byte * chrs, uint len)
+debug_print_string_hex(const gs_memory_t *mem, const byte * chrs, uint len)
{
uint i;
for (i = 0; i < len; i++)
- dprintf1("%02x", chrs[i]);
- dflush();
+ dmprintf1(mem, "%02x", chrs[i]);
+ dmflush(mem);
}
/*
@@ -555,12 +600,14 @@ debug_print_string_hex(const byte * chrs, uint len)
* first_arg is the first argument of the procedure into which this code
* is patched.
*/
+#ifndef GS_THREADSAFE
#define BACKTRACE(first_arg)\
BEGIN\
ulong *fp_ = (ulong *)&first_arg - 2;\
for (; fp_ && (fp_[1] & 0xff000000) == 0x08000000; fp_ = (ulong *)*fp_)\
dprintf2(" fp=0x%lx ip=0x%lx\n", (ulong)fp_, fp_[1]);\
END
+#endif
/* ------ Arithmetic ------ */
@@ -873,10 +920,12 @@ fixed_mult_quo(fixed signed_A, fixed B, fixed C)
double
gs_sqrt(double x, const char *file, int line)
{
+#ifndef GS_THREADSAFE
if (gs_debug_c('~')) {
dprintf3("[~]sqrt(%g) at %s:%d\n", x, (const char *)file, line);
dflush();
}
+#endif
return orig_sqrt(x);
}
diff --git a/gs/base/gsovrc.c b/gs/base/gsovrc.c
index 86648f974..7f5e47a69 100644
--- a/gs/base/gsovrc.c
+++ b/gs/base/gsovrc.c
@@ -170,7 +170,7 @@ c_overprint_write(const gs_composite_t * pct, byte * data, uint * psize, gx_devi
if (used > avail)
return_error(gs_error_rangecheck);
data[0] = flags;
- if_debug1('v', "[v]c_overprint_write(%d)\n", flags);
+ if_debug1m('v', ((const gx_device *)cdev)->memory, "[v]c_overprint_write(%d)\n", flags);
return 0;
}
@@ -192,7 +192,7 @@ c_overprint_read(
if (size < 1)
return_error(gs_error_rangecheck);
flags = *data;
- if_debug1('v', "[v]c_overprint_read(%d)\n", flags);
+ if_debug1m('v', mem, "[v]c_overprint_read(%d)\n", flags);
params.retain_any_comps = (flags & OVERPRINT_ANY_COMPS) != 0;
params.retain_spot_comps = (flags & OVERPRINT_SPOT_COMPS) != 0;
params.idle = 0;
diff --git a/gs/base/gspath.c b/gs/base/gspath.c
index b5f26a369..b48993651 100644
--- a/gs/base/gspath.c
+++ b/gs/base/gspath.c
@@ -467,8 +467,8 @@ static void
note_set_clip_path(const gs_state * pgs)
{
if (gs_debug_c('P')) {
- dlprintf("[P]Clipping path:\n");
- gx_cpath_print(pgs->clip_path);
+ dmlprintf(pgs->memory, "[P]Clipping path:\n");
+ gx_cpath_print(pgs->memory, pgs->clip_path);
}
}
#else
diff --git a/gs/base/gspath1.c b/gs/base/gspath1.c
index 0ca3bb8c8..78ba2ed79 100644
--- a/gs/base/gspath1.c
+++ b/gs/base/gspath1.c
@@ -455,7 +455,7 @@ arc_add(const arc_curve_params_t * arc, bool is_quadrant)
p2.x = p3.x + (fixed)((pt.x - p3.x) * fraction);
p2.y = p3.y + (fixed)((pt.y - p3.y) * fraction);
add:
- if_debug8('r',
+ if_debug8m('r', path->memory,
"[r]Arc f=%f p0=(%f,%f) pt=(%f,%f) p3=(%f,%f) action=%d\n",
fraction, x0, y0, xt, yt, arc->p3.x, arc->p3.y,
(int)arc->action);
diff --git a/gs/base/gsptype1.c b/gs/base/gsptype1.c
index 399b3d057..de88c66fa 100644
--- a/gs/base/gsptype1.c
+++ b/gs/base/gsptype1.c
@@ -192,11 +192,11 @@ gs_pattern1_make_pattern(gs_client_color * pcc,
}
#define mat inst.step_matrix
- if_debug6('t', "[t]step_matrix=[%g %g %g %g %g %g]\n",
- inst.step_matrix.xx, inst.step_matrix.xy, inst.step_matrix.yx,
- inst.step_matrix.yy, inst.step_matrix.tx, inst.step_matrix.ty);
- if_debug5('t', "[t]bbox=(%g,%g),(%g,%g), uses_transparency=%d\n",
- bbox.p.x, bbox.p.y, bbox.q.x, bbox.q.y, inst.templat.uses_transparency);
+ if_debug6m('t', mem, "[t]step_matrix=[%g %g %g %g %g %g]\n",
+ inst.step_matrix.xx, inst.step_matrix.xy, inst.step_matrix.yx,
+ inst.step_matrix.yy, inst.step_matrix.tx, inst.step_matrix.ty);
+ if_debug5m('t', mem, "[t]bbox=(%g,%g),(%g,%g), uses_transparency=%d\n",
+ bbox.p.x, bbox.p.y, bbox.q.x, bbox.q.y, inst.templat.uses_transparency);
{
float bbw = bbox.q.x - bbox.p.x;
float bbh = bbox.q.y - bbox.p.y;
@@ -242,11 +242,11 @@ gs_pattern1_make_pattern(gs_client_color * pcc,
gs_scale(saved, (fabs(inst.size.x) - 1.0 / fixed_scale) / fabs(inst.size.x),
(fabs(inst.size.y) - 1.0 / fixed_scale) / fabs(inst.size.y));
}
- if_debug2('t',
- "[t]adjusted XStep & YStep to size=(%d,%d)\n",
- inst.size.x, inst.size.y);
- if_debug4('t', "[t]bbox=(%g,%g),(%g,%g)\n",
- bbox.p.x, bbox.p.y, bbox.q.x, bbox.q.y);
+ if_debug2m('t', mem,
+ "[t]adjusted XStep & YStep to size=(%d,%d)\n",
+ inst.size.x, inst.size.y);
+ if_debug4m('t', mem, "[t]bbox=(%g,%g),(%g,%g)\n",
+ bbox.p.x, bbox.p.y, bbox.q.x, bbox.q.y);
} else if ((ADJUST_AS_ADOBE) && (inst.templat.TilingType != 2)) {
if (inst.step_matrix.xy == 0 && inst.step_matrix.yx == 0 &&
fabs(fabs(inst.step_matrix.xx) - bbw) < 0.5 &&
@@ -330,15 +330,15 @@ gs_pattern1_make_pattern(gs_client_color * pcc,
}
if ((code = gs_bbox_transform_inverse(&bbox, &inst.step_matrix, &inst.bbox)) < 0)
goto fsaved;
- if_debug4('t', "[t]ibbox=(%g,%g),(%g,%g)\n",
- inst.bbox.p.x, inst.bbox.p.y, inst.bbox.q.x, inst.bbox.q.y);
+ if_debug4m('t', mem, "[t]ibbox=(%g,%g),(%g,%g)\n",
+ inst.bbox.p.x, inst.bbox.p.y, inst.bbox.q.x, inst.bbox.q.y);
inst.is_simple = (fabs(inst.step_matrix.xx) == inst.size.x && inst.step_matrix.xy == 0 &&
inst.step_matrix.yx == 0 && fabs(inst.step_matrix.yy) == inst.size.y);
- if_debug6('t',
- "[t]is_simple? xstep=(%g,%g) ystep=(%g,%g) size=(%d,%d)\n",
- inst.step_matrix.xx, inst.step_matrix.xy,
- inst.step_matrix.yx, inst.step_matrix.yy,
- inst.size.x, inst.size.y);
+ if_debug6m('t', mem,
+ "[t]is_simple? xstep=(%g,%g) ystep=(%g,%g) size=(%d,%d)\n",
+ inst.step_matrix.xx, inst.step_matrix.xy,
+ inst.step_matrix.yx, inst.step_matrix.yy,
+ inst.size.x, inst.size.y);
/* Absent other information, instances always require a mask. */
inst.uses_mask = true;
inst.is_clist = false; /* automatically set clist (don't force use) */
diff --git a/gs/base/gsrefct.h b/gs/base/gsrefct.h
index 80749e0cf..74c53efa5 100644
--- a/gs/base/gsrefct.h
+++ b/gs/base/gsrefct.h
@@ -62,7 +62,7 @@ void rc_trace_free_struct(const void *vp, const rc_header *prc,
client_name_t cname);
void rc_trace_increment(const void *vp, const rc_header *prc);
void rc_trace_adjust(const void *vp, const rc_header *prc, int delta);
-#define IF_RC_DEBUG(call) if (gs_debug_c('^')) dlputs(""), call
+#define IF_RC_DEBUG(call) BEGIN if (gs_debug_c('^')) { dlputs(""); call; } END
#else
#define IF_RC_DEBUG(call) DO_NOTHING
#endif
diff --git a/gs/base/gsstate.c b/gs/base/gsstate.c
index 50d02ef7a..3f519806c 100644
--- a/gs/base/gsstate.c
+++ b/gs/base/gsstate.c
@@ -348,7 +348,7 @@ gs_gsave(gs_state * pgs)
if (pgs->show_gstate == pgs)
pgs->show_gstate = pnew->show_gstate = pnew;
pgs->level++;
- if_debug2('g', "[g]gsave -> 0x%lx, level = %d\n",
+ if_debug2m('g', pgs->memory, "[g]gsave -> 0x%lx, level = %d\n",
(ulong) pnew, pgs->level);
return 0;
}
@@ -399,8 +399,8 @@ gs_grestore_only(gs_state * pgs)
void *sdata;
bool prior_overprint = pgs->overprint;
- if_debug2('g', "[g]grestore 0x%lx, level was %d\n",
- (ulong) saved, pgs->level);
+ if_debug2m('g', pgs->memory, "[g]grestore 0x%lx, level was %d\n",
+ (ulong) saved, pgs->level);
if (!saved)
return 1;
sdata = saved->client_data;
diff --git a/gs/base/gsstruct.h b/gs/base/gsstruct.h
index d846875e8..dac42d991 100644
--- a/gs/base/gsstruct.h
+++ b/gs/base/gsstruct.h
@@ -148,9 +148,9 @@ struct gs_gc_root_s {
gc_root_enum_ptrs, gc_root_reloc_ptrs, next)
/* Print a root debugging message. */
-#define if_debug_root(c, msg, rp)\
- if_debug4(c, "%s 0x%lx: 0x%lx -> 0x%lx\n",\
- msg, (ulong)(rp), (ulong)(rp)->p, (ulong)*(rp)->p)
+#define if_debug_root(c, mem, msg, rp)\
+ if_debug4m(c, mem, "%s 0x%lx: 0x%lx -> 0x%lx\n",\
+ msg, (ulong)(rp), (ulong)(rp)->p, (ulong)*(rp)->p)
/*
* We don't want to tie the allocator to using a single garbage collector,
diff --git a/gs/base/gstrans.c b/gs/base/gstrans.c
index f52d1a64c..3a7e279cc 100644
--- a/gs/base/gstrans.c
+++ b/gs/base/gstrans.c
@@ -40,11 +40,11 @@ gs_setblendmode(gs_state *pgs, gs_blend_mode_t mode)
if (gs_debug_c('v')) {
static const char *const bm_names[] = { GS_BLEND_MODE_NAMES };
- dlprintf1("[v](0x%lx)blend_mode = ", (ulong)pgs);
+ dmlprintf1(pgs->memory, "[v](0x%lx)blend_mode = ", (ulong)pgs);
if (mode >= 0 && mode < countof(bm_names))
- dprintf1("%s\n", bm_names[mode]);
+ dmprintf1(pgs->memory, "%s\n", bm_names[mode]);
else
- dprintf1("%d??\n", (int)mode);
+ dmprintf1(pgs->memory, "%d??\n", (int)mode);
}
#endif
/* Map Compatible to Normal so other code treats Compatible as Normal */
@@ -67,7 +67,7 @@ gs_currentblendmode(const gs_state *pgs)
int
gs_setopacityalpha(gs_state *pgs, floatp alpha)
{
- if_debug2('v', "[v](0x%lx)opacity.alpha = %g\n", (ulong)pgs, alpha);
+ if_debug2m('v', pgs->memory, "[v](0x%lx)opacity.alpha = %g\n", (ulong)pgs, alpha);
pgs->opacity.alpha = (alpha < 0.0 ? 0.0 : alpha > 1.0 ? 1.0 : alpha);
return 0;
}
@@ -81,7 +81,7 @@ gs_currentopacityalpha(const gs_state *pgs)
int
gs_setshapealpha(gs_state *pgs, floatp alpha)
{
- if_debug2('v', "[v](0x%lx)shape.alpha = %g\n", (ulong)pgs, alpha);
+ if_debug2m('v', pgs->memory, "[v](0x%lx)shape.alpha = %g\n", (ulong)pgs, alpha);
pgs->shape.alpha = (alpha < 0.0 ? 0.0 : alpha > 1.0 ? 1.0 : alpha);
return 0;
}
@@ -95,8 +95,8 @@ gs_currentshapealpha(const gs_state *pgs)
int
gs_settextknockout(gs_state *pgs, bool knockout)
{
- if_debug2('v', "[v](0x%lx)text_knockout = %s\n", (ulong)pgs,
- (knockout ? "true" : "false"));
+ if_debug2m('v', pgs->memory, "[v](0x%lx)text_knockout = %s\n",
+ (ulong)pgs, (knockout ? "true" : "false"));
pgs->text_knockout = knockout;
return 0;
}
@@ -129,8 +129,8 @@ check_for_nontrans_pattern(gs_state *pgs, unsigned char *comp_name)
const gs_pattern1_instance_t *pinst = clwdev->pinst;
if (!(pinst->templat.uses_transparency)) {
- if_debug1('v',
- "[v]%s NOT sending in pattern\n",comp_name);
+ if_debug1m('v', pgs->memory,
+ "[v]%s NOT sending in pattern\n",comp_name);
return(1);
}
}
@@ -139,8 +139,8 @@ check_for_nontrans_pattern(gs_state *pgs, unsigned char *comp_name)
const gs_pattern1_instance_t *pinst = padev->instance;
if (!(pinst->templat.uses_transparency)) {
- if_debug1('v',
- "[v]%s NOT sending in pattern\n",comp_name);
+ if_debug1m('v', pgs->memory,
+ "[v]%s NOT sending in pattern\n",comp_name);
return(1);
}
}
@@ -192,7 +192,7 @@ gs_update_trans_marking_params(gs_state * pgs)
{
gs_pdf14trans_params_t params = { 0 };
- if_debug0('v', "[v]gs_update_trans_marking_params\n");
+ if_debug0m('v', pgs->memory, "[v]gs_update_trans_marking_params\n");
params.pdf14_op = PDF14_SET_BLEND_PARAMS;
return gs_state_update_pdf14trans(pgs, &params);
}
@@ -302,15 +302,15 @@ gs_begin_transparency_group(gs_state *pgs,
static const char *const cs_names[] = {
GS_COLOR_SPACE_TYPE_NAMES
};
- dlprintf6("[v](0x%lx)begin_transparency_group [%g %g %g %g] Num_grp_clr_comp = %d\n",
+ dmlprintf6(pgs->memory, "[v](0x%lx)begin_transparency_group [%g %g %g %g] Num_grp_clr_comp = %d\n",
(ulong)pgs, pbbox->p.x, pbbox->p.y, pbbox->q.x, pbbox->q.y,params.group_color_numcomps);
if (ptgp->ColorSpace)
- dprintf1(" CS = %s",
+ dmprintf1(pgs->memory, " CS = %s",
cs_names[(int)gs_color_space_get_index(ptgp->ColorSpace)]);
else
- dputs(" (no CS)");
+ dmputs(pgs->memory, " (no CS)");
- dprintf2(" Isolated = %d Knockout = %d\n",
+ dmprintf2(pgs->memory, " Isolated = %d Knockout = %d\n",
ptgp->Isolated, ptgp->Knockout);
}
#endif
@@ -348,18 +348,18 @@ gx_begin_transparency_group(gs_imager_state * pis, gx_device * pdev,
static const char *const cs_names[] = {
GS_COLOR_SPACE_TYPE_NAMES
};
- dlprintf6("[v](0x%lx)gx_begin_transparency_group [%g %g %g %g] Num_grp_clr_comp = %d\n",
+ dmlprintf6(pdev->memory, "[v](0x%lx)gx_begin_transparency_group [%g %g %g %g] Num_grp_clr_comp = %d\n",
(ulong)pis, bbox.p.x, bbox.p.y, bbox.q.x, bbox.q.y,
pparams->group_color_numcomps);
if (tgp.ColorSpace)
- dprintf1(" CS = %s",
+ dmprintf1(pdev->memory, " CS = %s",
cs_names[(int)gs_color_space_get_index(tgp.ColorSpace)]);
else
- dputs(" (no CS)");
- dprintf2(" Isolated = %d Knockout = %d\n",
+ dmputs(pdev->memory, " (no CS)");
+ dmprintf2(pdev->memory, " Isolated = %d Knockout = %d\n",
tgp.Isolated, tgp.Knockout);
if (tgp.iccprofile)
- dprintf(" Have ICC Profile for blending\n");
+ dmprintf(pdev->memory, " Have ICC Profile for blending\n");
}
#endif
if (dev_proc(pdev, begin_transparency_group) != 0)
@@ -378,7 +378,7 @@ gs_end_transparency_group(gs_state *pgs)
(unsigned char *)"gs_end_transparency_group")) {
return(0);
}
- if_debug0('v', "[v]gs_end_transparency_group\n");
+ if_debug0m('v', pgs->memory, "[v]gs_end_transparency_group\n");
params.pdf14_op = PDF14_END_TRANS_GROUP; /* Other parameters not used */
return gs_state_update_pdf14trans(pgs, &params);
}
@@ -386,7 +386,7 @@ gs_end_transparency_group(gs_state *pgs)
int
gx_end_transparency_group(gs_imager_state * pis, gx_device * pdev)
{
- if_debug0('v', "[v]gx_end_transparency_group\n");
+ if_debug0m('v', pis->memory, "[v]gx_end_transparency_group\n");
if (dev_proc(pdev, end_transparency_group) != 0)
return (*dev_proc(pdev, end_transparency_group)) (pdev, pis);
else
@@ -422,13 +422,13 @@ gs_push_transparency_state(gs_state *pgs)
the current soft mask, so that we can
restore it later */
if (pis->trans_flags.xstate_change) {
- if_debug0('v', "[v]gs_push_transparency_state sending\n");
+ if_debug0m('v', pgs->memory, "[v]gs_push_transparency_state sending\n");
params.pdf14_op = PDF14_PUSH_TRANS_STATE;
code = gs_state_update_pdf14trans(pgs, &params);
if (code < 0)
return(code);
} else {
- if_debug0('v', "[v]gs_push_transparency_state NOT sending\n");
+ if_debug0m('v', pgs->memory, "[v]gs_push_transparency_state NOT sending\n");
}
return(0);
}
@@ -449,13 +449,13 @@ gs_pop_transparency_state(gs_state *pgs, bool force)
need to communicate to the compositor to pop
the softmask */
if ( pis->trans_flags.xstate_change || force) {
- if_debug0('v', "[v]gs_pop_transparency_state sending\n");
+ if_debug0m('v', pgs->memory, "[v]gs_pop_transparency_state sending\n");
params.pdf14_op = PDF14_POP_TRANS_STATE;
code = gs_state_update_pdf14trans(pgs, &params);
if ( code < 0 )
return (code);
} else {
- if_debug0('v', "[v]gs_pop_transparency_state NOT sending\n");
+ if_debug0m('v', pgs->memory, "[v]gs_pop_transparency_state NOT sending\n");
}
/* There is no reason to reset any of the flags since
they will be reset by the graphic state restore */
@@ -465,7 +465,7 @@ gs_pop_transparency_state(gs_state *pgs, bool force)
int
gx_pop_transparency_state(gs_imager_state * pis, gx_device * pdev)
{
- if_debug0('v', "[v]gx_pop_transparency_state\n");
+ if_debug0m('v', pis->memory, "[v]gx_pop_transparency_state\n");
if (dev_proc(pdev, pop_transparency_state) != 0)
return (*dev_proc(pdev, pop_transparency_state)) (pdev, pis);
else
@@ -475,7 +475,7 @@ gx_pop_transparency_state(gs_imager_state * pis, gx_device * pdev)
int
gx_push_transparency_state(gs_imager_state * pis, gx_device * pdev)
{
- if_debug0('v', "[v]gx_push_transparency_state\n");
+ if_debug0m('v', pis->memory, "[v]gx_push_transparency_state\n");
if (dev_proc(pdev, push_transparency_state) != 0)
return (*dev_proc(pdev, push_transparency_state)) (pdev, pis);
else
@@ -549,7 +549,7 @@ gs_begin_transparency_mask(gs_state * pgs,
return(code);
}
/* A new soft mask group, make sure the profiles are set */
- if_debug0('v', "[v]pushing soft mask color sending\n");
+ if_debug0m('v', pgs->memory, "[v]pushing soft mask color sending\n");
params_color.pdf14_op = PDF14_PUSH_SMASK_COLOR;
code = gs_state_update_pdf14trans(pgs, &params_color);
if (code < 0)
@@ -557,7 +557,7 @@ gs_begin_transparency_mask(gs_state * pgs,
blend_color_space = gs_cspace_new_DeviceGray(pgs->memory);
blend_color_space->cmm_icc_profile_data = pgs->icc_manager->default_gray;
rc_increment(blend_color_space->cmm_icc_profile_data);
- if_debug8('v', "[v](0x%lx)gs_begin_transparency_mask [%g %g %g %g]\n\
+ if_debug8m('v', pgs->memory, "[v](0x%lx)gs_begin_transparency_mask [%g %g %g %g]\n\
subtype = %d Background_components = %d %s\n",
(ulong)pgs, pbbox->p.x, pbbox->p.y, pbbox->q.x, pbbox->q.y,
(int)ptmp->subtype, ptmp->Background_components,
@@ -619,8 +619,9 @@ gx_begin_transparency_mask(gs_imager_state * pis, gx_device * pdev,
tmp.icc_hashcode = 0;
}
memcpy(tmp.transfer_fn, pparams->transfer_fn, size_of(tmp.transfer_fn));
- if_debug9('v', "[v](0x%lx)gx_begin_transparency_mask [%g %g %g %g]\n\
- subtype = %d Background_components = %d Num_grp_clr_comp = %d %s\n",
+ if_debug9m('v', pis->memory,
+ "[v](0x%lx)gx_begin_transparency_mask [%g %g %g %g]\n"
+ " subtype = %d Background_components = %d Num_grp_clr_comp = %d %s\n",
(ulong)pis, pparams->bbox.p.x, pparams->bbox.p.y,
pparams->bbox.q.x, pparams->bbox.q.y,
(int)tmp.subtype, tmp.Background_components,
@@ -657,13 +658,15 @@ gs_end_transparency_mask(gs_state *pgs,
is true) we will need to
push the mask graphic state (PDF14_PUSH_TRANS_STATE). */
pis->trans_flags.xstate_change = true;
- if_debug1('v', "[v]xstate_changed set true, gstate level is %d\n", pgs->level);
- if_debug2('v', "[v](0x%lx)gs_end_transparency_mask(%d)\n", (ulong)pgs,
- (int)csel);
+ if_debug1m('v', pis->memory,
+ "[v]xstate_changed set true, gstate level is %d\n", pgs->level);
+ if_debug2m('v', pis->memory,
+ "[v](0x%lx)gs_end_transparency_mask(%d)\n", (ulong)pgs,
+ (int)csel);
params.pdf14_op = PDF14_END_TRANS_MASK; /* Other parameters not used */
params.csel = csel;
/* If this is the outer end then return us to our normal defaults */
- if_debug0('v', "[v]popping soft mask color sending\n");
+ if_debug0m('v', pis->memory, "[v]popping soft mask color sending\n");
params_color.pdf14_op = PDF14_POP_SMASK_COLOR;
code = gs_state_update_pdf14trans(pgs, &params_color);
if (code < 0)
@@ -675,8 +678,9 @@ int
gx_end_transparency_mask(gs_imager_state * pis, gx_device * pdev,
const gs_pdf14trans_params_t * pparams)
{
- if_debug2('v', "[v](0x%lx)gx_end_transparency_mask(%d)\n", (ulong)pis,
- (int)pparams->csel);
+ if_debug2m('v', pis->memory,
+ "[v](0x%lx)gx_end_transparency_mask(%d)\n", (ulong)pis,
+ (int)pparams->csel);
if (dev_proc(pdev, end_transparency_mask) != 0)
return (*dev_proc(pdev, end_transparency_mask)) (pdev, pis);
else
diff --git a/gs/base/gstype1.c b/gs/base/gstype1.c
index 59bc55c4f..a81093a51 100644
--- a/gs/base/gstype1.c
+++ b/gs/base/gstype1.c
@@ -206,8 +206,8 @@ gs_type1_interpret(gs_type1_state * pcis, const gs_glyph_data_t *pgd,
}
} else /* not possible */
return_error(gs_error_invalidfont);
- pushed:if_debug3('1', "[1]%d: (%d) %f\n",
- (int)(csp - cstack), c, fixed2float(*csp));
+ pushed:if_debug3m('1', pfont->memory, "[1]%d: (%d) %f\n",
+ (int)(csp - cstack), c, fixed2float(*csp));
continue;
}
#ifdef DEBUG
@@ -216,9 +216,9 @@ gs_type1_interpret(gs_type1_state * pcis, const gs_glyph_data_t *pgd,
{char1_command_names};
if (c1names[c] == 0)
- dlprintf2("[1]0x%lx: %02x??\n", (ulong) (cip - 1), c);
+ dmlprintf2(pfont->memory, "[1]0x%lx: %02x??\n", (ulong) (cip - 1), c);
else
- dlprintf3("[1]0x%lx: %02x %s\n", (ulong) (cip - 1), c,
+ dmlprintf3(pfont->memory, "[1]0x%lx: %02x %s\n", (ulong) (cip - 1), c,
c1names[c]);
}
#endif
@@ -388,10 +388,11 @@ rsbw: /* Give the caller the opportunity to intervene. */
{char1_extended_command_names};
if (ce1names[c] == 0)
- dlprintf2("[1]0x%lx: %02x??\n", (ulong) (cip - 1), c);
+ dmlprintf2(pfont->memory, "[1]0x%lx: %02x??\n",
+ (ulong) (cip - 1), c);
else
- dlprintf3("[1]0x%lx: %02x %s\n", (ulong) (cip - 1), c,
- ce1names[c]);
+ dmlprintf3(pfont->memory, "[1]0x%lx: %02x %s\n",
+ (ulong) (cip - 1), c, ce1names[c]);
}
#endif
switch ((char1_extended_command) c) {
diff --git a/gs/base/gstype2.c b/gs/base/gstype2.c
index 5cf571e51..ca7376eb0 100644
--- a/gs/base/gstype2.c
+++ b/gs/base/gstype2.c
@@ -210,8 +210,8 @@ gs_type2_interpret(gs_type1_state * pcis, const gs_glyph_data_t *pgd,
*++csp = arith_rshift(lw, 16 - _fixed_shift);
} else /* not possible */
return_error(gs_error_invalidfont);
- pushed:if_debug3('1', "[1]%d: (%d) %f\n",
- (int)(csp - cstack), c, fixed2float(*csp));
+ pushed:if_debug3m('1', pfont->memory, "[1]%d: (%d) %f\n",
+ (int)(csp - cstack), c, fixed2float(*csp));
continue;
}
#ifdef DEBUG
@@ -220,10 +220,11 @@ gs_type2_interpret(gs_type1_state * pcis, const gs_glyph_data_t *pgd,
{char2_command_names};
if (c2names[c] == 0)
- dlprintf2("[1]0x%lx: %02x??\n", (ulong) (cip - 1), c);
+ dmlprintf2(pfont->memory, "[1]0x%lx: %02x??\n",
+ (ulong) (cip - 1), c);
else
- dlprintf3("[1]0x%lx: %02x %s\n", (ulong) (cip - 1), c,
- c2names[c]);
+ dmlprintf3(pfont->memory, "[1]0x%lx: %02x %s\n",
+ (ulong) (cip - 1), c, c2names[c]);
}
#endif
switch ((char_command) c) {
@@ -464,16 +465,16 @@ gs_type2_interpret(gs_type1_state * pcis, const gs_glyph_data_t *pgd,
for (i = 0; i < pcis->num_hints; ++cip, i += 8) {
charstring_next(*cip, state, mask[i >> 3], encrypted);
- if_debug1('1', " 0x%02x", mask[i >> 3]);
+ if_debug1m('1', pfont->memory, " 0x%02x", mask[i >> 3]);
}
- if_debug0('1', "\n");
+ if_debug0m('1', pfont->memory, "\n");
ipsp->ip = cip;
ipsp->dstate = state;
if (c == c2_cntrmask) {
/****** NYI ******/
} else { /* hintmask or equivalent */
- if_debug0('1', "[1]hstem hints:\n");
- if_debug0('1', "[1]vstem hints:\n");
+ if_debug0m('1', pfont->memory, "[1]hstem hints:\n");
+ if_debug0m('1', pfont->memory, "[1]vstem hints:\n");
code = t1_hinter__hint_mask(h, mask);
if (code < 0)
return code;
@@ -558,10 +559,11 @@ gs_type2_interpret(gs_type1_state * pcis, const gs_glyph_data_t *pgd,
{char2_extended_command_names};
if (ce2names[c] == 0)
- dlprintf2("[1]0x%lx: %02x??\n", (ulong) (cip - 1), c);
+ dmlprintf2(pfont->memory, "[1]0x%lx: %02x??\n",
+ (ulong) (cip - 1), c);
else
- dlprintf3("[1]0x%lx: %02x %s\n", (ulong) (cip - 1), c,
- ce2names[c]);
+ dmlprintf3(pfont->memory, "[1]0x%lx: %02x %s\n",
+ (ulong) (cip - 1), c, ce2names[c]);
}
#endif
switch ((char2_extended_command) c) {
diff --git a/gs/base/gstype42.c b/gs/base/gstype42.c
index 44e47d0f3..52ac2110f 100644
--- a/gs/base/gstype42.c
+++ b/gs/base/gstype42.c
@@ -1345,7 +1345,7 @@ append_simple(const byte *gdata, float sbw[4], const gs_matrix_fixed *pmat,
gs_fixed_point start,pt_start_off;
gs_fixed_point cpoints[2];
- if_debug1('1', "[1t]start %d\n", i);
+ if_debug1m('1', pfont->memory, "[1t]start %d\n", i);
for (; np <= last_point; --reps, ++np) {
gs_fixed_point dpt;
@@ -1387,8 +1387,9 @@ append_simple(const byte *gdata, float sbw[4], const gs_matrix_fixed *pmat,
if (ppath) {
/* append to a path */
- if_debug3('1', "[1t]%s (%g %g)\n",
- (flags & gf_OnCurve ? "on " : "off"), fixed2float(pt.x), fixed2float(pt.y));
+ if_debug3m('1', pfont->memory, "[1t]%s (%g %g)\n",
+ (flags & gf_OnCurve ? "on " : "off"),
+ fixed2float(pt.x), fixed2float(pt.y));
if (move) {
if(is_start_off) {
diff --git a/gs/base/gxacpath.c b/gs/base/gxacpath.c
index cff149c37..6f96fbc0d 100644
--- a/gs/base/gxacpath.c
+++ b/gs/base/gxacpath.c
@@ -296,17 +296,18 @@ accum_close(gx_device * dev)
gx_clip_rect *rp =
(adev->list.count <= 1 ? &adev->list.single : adev->list.head);
- dlprintf6("[q]list at 0x%lx, count=%d, head=0x%lx, tail=0x%lx, xrange=(%d,%d):\n",
- (ulong) & adev->list, adev->list.count,
- (ulong) adev->list.head, (ulong) adev->list.tail,
- adev->list.xmin, adev->list.xmax);
+ dmlprintf6(dev->memory,
+ "[q]list at 0x%lx, count=%d, head=0x%lx, tail=0x%lx, xrange=(%d,%d):\n",
+ (ulong) & adev->list, adev->list.count,
+ (ulong) adev->list.head, (ulong) adev->list.tail,
+ adev->list.xmin, adev->list.xmax);
while (rp != 0) {
clip_rect_print('q', " ", rp);
rp = rp->next;
}
}
if (!clip_list_validate(&adev->list)) {
- lprintf1("[q]Bad clip list 0x%lx!\n", (ulong) & adev->list);
+ mlprintf1(dev->memory, "[q]Bad clip list 0x%lx!\n", (ulong) & adev->list);
return_error(gs_error_Fatal);
}
#endif
diff --git a/gs/base/gxalloc.h b/gs/base/gxalloc.h
index b046cd9e5..129693b40 100644
--- a/gs/base/gxalloc.h
+++ b/gs/base/gxalloc.h
@@ -278,14 +278,14 @@ void alloc_free_chunk(chunk_t *, gs_ref_memory_t *);
/* define the list of variables being printed as a macro. */
#define dprintf_chunk_format\
"%s 0x%lx (0x%lx..0x%lx, 0x%lx..0x%lx..0x%lx)\n"
-#define dprintf_chunk(msg, cp)\
- dprintf7(dprintf_chunk_format,\
- msg, (ulong)(cp), (ulong)(cp)->cbase, (ulong)(cp)->cbot,\
- (ulong)(cp)->ctop, (ulong)(cp)->climit, (ulong)(cp)->cend)
-#define if_debug_chunk(c, msg, cp)\
- if_debug7(c, dprintf_chunk_format,\
+#define dmprintf_chunk(mem, msg, cp)\
+ dmprintf7(mem, dprintf_chunk_format,\
msg, (ulong)(cp), (ulong)(cp)->cbase, (ulong)(cp)->cbot,\
(ulong)(cp)->ctop, (ulong)(cp)->climit, (ulong)(cp)->cend)
+#define if_debug_chunk(c, mem, msg, cp)\
+ if_debug7m(c, mem,dprintf_chunk_format,\
+ msg, (ulong)(cp), (ulong)(cp)->cbase, (ulong)(cp)->cbot,\
+ (ulong)(cp)->ctop, (ulong)(cp)->climit, (ulong)(cp)->cend)
/* ================ Allocator state ================ */
diff --git a/gs/base/gxblend.c b/gs/base/gxblend.c
index abb3ecdb6..2aa3cc696 100644
--- a/gs/base/gxblend.c
+++ b/gs/base/gxblend.c
@@ -726,8 +726,10 @@ art_blend_pixel_8(byte *dst, const byte *backdrop,
}
break;
default:
+#ifndef GS_THREADSAFE
dlprintf1("art_blend_pixel_8: blend mode %d not implemented\n",
blend_mode);
+#endif
memcpy(dst, src, n_chan);
break;
}
@@ -851,8 +853,10 @@ art_blend_pixel(ArtPixMaxDepth* dst, const ArtPixMaxDepth *backdrop,
}
break;
default:
+#ifndef GS_THREADSAFE
dlprintf1("art_blend_pixel: blend mode %d not implemented\n",
blend_mode);
+#endif
memcpy(dst, src, n_chan);
break;
}
diff --git a/gs/base/gxblend1.c b/gs/base/gxblend1.c
index 62bd482bc..25508775d 100644
--- a/gs/base/gxblend1.c
+++ b/gs/base/gxblend1.c
@@ -238,8 +238,9 @@ pdf14_compose_group(pdf14_buf *tos, pdf14_buf *nos, pdf14_buf *maskbuf,
if ((tos->n_chan == 0) || (nos->n_chan == 0))
return;
rect_merge(nos->dirty, tos->dirty);
- if_debug6('v', "pdf14_pop_transparency_group y0 = %d, y1 = %d, w = %d, alpha = %d, shape = %d, tag = bm = %d\n",
- y0, y1, width, alpha, shape, blend_mode);
+ if_debug6m('v', nos->mask_stack->memory,
+ "pdf14_pop_transparency_group y0 = %d, y1 = %d, w = %d, alpha = %d, shape = %d, tag = bm = %d\n",
+ y0, y1, width, alpha, shape, blend_mode);
if (nos->has_alpha_g)
nos_alpha_g_ptr = nos_ptr + n_chan * nos_planestride;
else
@@ -594,7 +595,7 @@ dump_planar_rgba(gs_memory_t *mem, const pdf14_buf *pbuf)
file = fopen ("c:\\temp\\tmp.png", "wb");
- if_debug0('v', "[v]pnga_output_page\n");
+ if_debug0m('v', mem, "[v]pnga_output_page\n");
if (row == 0 || png_ptr == 0 || info_ptr == 0) {
code = gs_note_error(gs_error_VMerror);
diff --git a/gs/base/gxccache.c b/gs/base/gxccache.c
index fdd1ef8e4..e391ac4d8 100644
--- a/gs/base/gxccache.c
+++ b/gs/base/gxccache.c
@@ -120,11 +120,11 @@ gx_lookup_fm_pair(gs_font * pfont, const gs_matrix *char_tm,
if (pair->font == 0) {
pair->font = pfont;
- if_debug2('k', "[k]updating pair 0x%lx with font 0x%lx\n",
- (ulong) pair, (ulong) pfont);
+ if_debug2m('k', pfont->memory, "[k]updating pair 0x%lx with font 0x%lx\n",
+ (ulong) pair, (ulong) pfont);
} else {
- if_debug2('k', "[k]found pair 0x%lx: font=0x%lx\n",
- (ulong) pair, (ulong) pair->font);
+ if_debug2m('k', pfont->memory, "[k]found pair 0x%lx: font=0x%lx\n",
+ (ulong) pair, (ulong) pair->font);
}
code = gx_touch_fm_pair(dir, pair);
if (code < 0)
@@ -157,13 +157,14 @@ gx_lookup_cached_char(const gs_font * pfont, const cached_fm_pair * pair,
cc->subpix_origin.y == subpix_origin->y &&
cc->wmode == wmode && cc_depth(cc) == depth
) {
- if_debug4('K', "[K]found 0x%lx (depth=%d) for glyph=0x%lx, wmode=%d\n",
- (ulong) cc, cc_depth(cc), (ulong) glyph, wmode);
+ if_debug4m('K', pfont->memory,
+ "[K]found 0x%lx (depth=%d) for glyph=0x%lx, wmode=%d\n",
+ (ulong) cc, cc_depth(cc), (ulong) glyph, wmode);
return cc;
}
chi++;
}
- if_debug3('K', "[K]not found: glyph=0x%lx, wmode=%d, depth=%d\n",
+ if_debug3m('K', pfont->memory, "[K]not found: glyph=0x%lx, wmode=%d, depth=%d\n",
(ulong) glyph, wmode, depth);
return 0;
}
@@ -206,16 +207,16 @@ gx_image_cached_char(register gs_show_enum * penum, register cached_char * cc)
#ifdef DEBUG
if (gs_debug_c('K')) {
if (cc_has_bits(cc))
- debug_dump_bitmap(cc_bits(cc), cc_raster(cc), h,
+ debug_dump_bitmap(penum->memory, cc_bits(cc), cc_raster(cc), h,
"[K]bits");
else
- dputs("[K]no bits\n");
- dlprintf3("[K]copying 0x%lx, offset=(%g,%g)\n", (ulong) cc,
- fixed2float(-cc->offset.x),
- fixed2float(-cc->offset.y));
- dlprintf6(" at (%g,%g)+(%d,%d)->(%d,%d)\n",
- fixed2float(pt.x), fixed2float(pt.y),
- penum->ftx, penum->fty, x, y);
+ dmputs(penum->memory, "[K]no bits\n");
+ dmlprintf3(penum->memory, "[K]copying 0x%lx, offset=(%g,%g)\n", (ulong) cc,
+ fixed2float(-cc->offset.x),
+ fixed2float(-cc->offset.y));
+ dmlprintf6(penum->memory, " at (%g,%g)+(%d,%d)->(%d,%d)\n",
+ fixed2float(pt.x), fixed2float(pt.y),
+ penum->ftx, penum->fty, x, y);
}
#endif
if ((x < penum->ibox.p.x || x + w > penum->ibox.q.x ||
@@ -234,7 +235,7 @@ gx_image_cached_char(register gs_show_enum * penum, register cached_char * cc)
return code;
gx_make_clip_device_on_stack(&cdev, pcpath, imaging_dev);
imaging_dev = (gx_device *) & cdev;
- if_debug0('K', "[K](clipping)\n");
+ if_debug0m('K', penum->memory, "[K](clipping)\n");
}
code = gx_set_dev_color(pgs);
if (code != 0)
@@ -254,10 +255,11 @@ gx_image_cached_char(register gs_show_enum * penum, register cached_char * cc)
code = (*xf->common.procs->render_char) (xf, xg,
imaging_dev, cx, cy,
pdevc->colors.pure, 0);
- if_debug8('K', "[K]render_char display: xfont=0x%lx, glyph=0x%lx\n\tdev=0x%lx(%s) x,y=%d,%d, color=0x%lx => %d\n",
- (ulong) xf, (ulong) xg, (ulong) imaging_dev,
- imaging_dev->dname, cx, cy,
- (ulong) pdevc->colors.pure, code);
+ if_debug8m('K', penum->memory,
+ "[K]render_char display: xfont=0x%lx, glyph=0x%lx\n\tdev=0x%lx(%s) x,y=%d,%d, color=0x%lx => %d\n",
+ (ulong) xf, (ulong) xg, (ulong) imaging_dev,
+ imaging_dev->dname, cx, cy,
+ (ulong) pdevc->colors.pure, code);
if (code == 0)
return_check_interrupt(penum->memory, 0);
}
@@ -271,7 +273,8 @@ gx_image_cached_char(register gs_show_enum * penum, register cached_char * cc)
code = (*xf->common.procs->render_char) (xf, xg,
(gx_device *) & mdev, cx - x, cy - y,
(gx_color_index) 1, 1);
- if_debug7('K', "[K]render_char to bits: xfont=0x%lx, glyph=0x%lx\n\tdev=0x%lx(%s) x,y=%d,%d => %d\n",
+ if_debug7m('K', penum->memory,
+ "[K]render_char to bits: xfont=0x%lx, glyph=0x%lx\n\tdev=0x%lx(%s) x,y=%d,%d => %d\n",
(ulong) xf, (ulong) xg, (ulong) & mdev,
mdev.dname, cx - x, cy - y, code);
if (code != 0)
diff --git a/gs/base/gxccman.c b/gs/base/gxccman.c
index 48a06077c..abcae5fd5 100644
--- a/gs/base/gxccman.c
+++ b/gs/base/gxccman.c
@@ -356,10 +356,11 @@ gx_add_fm_pair(register gs_font_dir * dir, gs_font * font, const gs_uid * puid,
return code;
}
pair->memory = 0;
- if_debug8('k', "[k]adding pair 0x%lx: font=0x%lx [%g %g %g %g] UID %ld, 0x%lx\n",
- (ulong) pair, (ulong) font,
- pair->mxx, pair->mxy, pair->myx, pair->myy,
- (long)pair->UID.id, (ulong) pair->UID.xvalues);
+ if_debug8m('k', dir->memory,
+ "[k]adding pair 0x%lx: font=0x%lx [%g %g %g %g] UID %ld, 0x%lx\n",
+ (ulong) pair, (ulong) font,
+ pair->mxx, pair->mxy, pair->myx, pair->myy,
+ (long)pair->UID.id, (ulong) pair->UID.xvalues);
*ppair = pair;
return 0;
}
@@ -405,7 +406,7 @@ gs_clean_fm_pair_attributes(gs_font_dir * dir, cached_fm_pair * pair)
void
gs_clean_fm_pair(gs_font_dir * dir, cached_fm_pair * pair)
{
- if_debug1('k', "[k]cleaning pair 0x%lx\n", (ulong) pair);
+ if_debug1m('k', dir->memory, "[k]cleaning pair 0x%lx\n", (ulong) pair);
pair->font = NULL;
gs_clean_fm_pair_attributes(dir, pair);
}
@@ -413,8 +414,8 @@ gs_clean_fm_pair(gs_font_dir * dir, cached_fm_pair * pair)
int
gs_purge_fm_pair(gs_font_dir * dir, cached_fm_pair * pair, int xfont_only)
{
- if_debug2('k', "[k]purging pair 0x%lx%s\n",
- (ulong) pair, (xfont_only ? " (xfont only)" : ""));
+ if_debug2m('k', dir->memory, "[k]purging pair 0x%lx%s\n",
+ (ulong) pair, (xfont_only ? " (xfont only)" : ""));
if (pair->xfont != 0) {
(*pair->xfont->common.procs->release) (pair->xfont,
pair->memory);
@@ -504,9 +505,9 @@ gx_alloc_char_bits(gs_font_dir * dir, gx_device_memory * dev,
iraster = bitmap_raster(nwidth_bits);
if (iraster != 0 && iheight >> log2_yscale > dir->ccache.upper / iraster) {
- if_debug5('k', "[k]no cache bits: scale=%dx%d, raster/scale=%u, height/scale=%u, upper=%u\n",
- 1 << log2_xscale, 1 << log2_yscale,
- iraster, iheight, dir->ccache.upper);
+ if_debug5m('k', pdev->memory, "[k]no cache bits: scale=%dx%d, raster/scale=%u, height/scale=%u, upper=%u\n",
+ 1 << log2_xscale, 1 << log2_yscale,
+ iraster, iheight, dir->ccache.upper);
return 0; /* too big */
}
/* Compute the actual bitmap size(s) and allocate the bits. */
@@ -561,8 +562,8 @@ gx_alloc_char_bits(gs_font_dir * dir, gx_device_memory * dev,
*pcc = cc;
if (cc == 0)
return 0;
- if_debug4('k', "[k]adding char 0x%lx:%u(%u,%u)\n",
- (ulong) cc, (uint) icdsize, iwidth, iheight);
+ if_debug4m('k', dev->memory, "[k]adding char 0x%lx:%u(%u,%u)\n",
+ (ulong) cc, (uint) icdsize, iwidth, iheight);
/* Fill in the entry. */
@@ -625,8 +626,8 @@ gx_free_cached_char(gs_font_dir * dir, cached_char * cc)
dir->ccache.cnext = (byte *) cc - cck->data;
if (cc->linked)
cc_pair(cc)->num_chars--;
- if_debug2('k', "[k]freeing char 0x%lx, pair=0x%lx\n",
- (ulong) cc, (ulong) cc_pair(cc));
+ if_debug2m('k', dir->memory, "[k]freeing char 0x%lx, pair=0x%lx\n",
+ (ulong) cc, (ulong) cc_pair(cc));
gx_bits_cache_free((gx_bits_cache *) & dir->ccache, &cc->head, cck);
}
@@ -635,9 +636,10 @@ int
gx_add_cached_char(gs_font_dir * dir, gx_device_memory * dev,
cached_char * cc, cached_fm_pair * pair, const gs_log2_scale_point * pscale)
{
- if_debug5('k', "[k]chaining char 0x%lx: pair=0x%lx, glyph=0x%lx, wmode=%d, depth=%d\n",
- (ulong) cc, (ulong) pair, (ulong) cc->code,
- cc->wmode, cc_depth(cc));
+ if_debug5m('k', dev->memory,
+ "[k]chaining char 0x%lx: pair=0x%lx, glyph=0x%lx, wmode=%d, depth=%d\n",
+ (ulong) cc, (ulong) pair, (ulong) cc->code,
+ cc->wmode, cc_depth(cc));
if (dev != NULL) {
static const gs_log2_scale_point no_scale =
{0, 0};
@@ -722,12 +724,13 @@ gx_add_char_bits(gs_font_dir * dir, cached_char * cc,
*/
if ((log2_x | log2_y) != 0) {
- if_debug5('k', "[k]compressing %dx%d by %dx%d to depth=%d\n",
- cc->width, cc->height, 1 << log2_x, 1 << log2_y,
- depth);
+ if_debug5m('k', dir->memory,
+ "[k]compressing %dx%d by %dx%d to depth=%d\n",
+ cc->width, cc->height, 1 << log2_x, 1 << log2_y,
+ depth);
#ifdef DEBUG
if (gs_debug_c('K'))
- debug_dump_bitmap(bits, raster, cc->height,
+ debug_dump_bitmap(dir->memory, bits, raster, cc->height,
"[K]uncompressed bits");
#endif
/* Truncate/round the bbox to a multiple of the scale. */
@@ -799,8 +802,8 @@ gx_add_char_bits(gs_font_dir * dir, cached_char * cc,
if (diff >= sizeof(cached_char_head)) {
shorten_cached_char(dir, cc, diff);
- if_debug2('K', "[K]shortening char 0x%lx by %u (adding)\n",
- (ulong) cc, diff);
+ if_debug2m('K', dir->memory, "[K]shortening char 0x%lx by %u (adding)\n",
+ (ulong) cc, diff);
}
}
@@ -825,8 +828,8 @@ gs_purge_font_from_char_caches_forced(gs_font * font, bool force)
pair = dir->fmcache.mdata;
count = dir->fmcache.mmax;
font->is_cached = false; /* Prevent redundant execution. */
- if_debug1('k', "[k]purging font 0x%lx\n",
- (ulong) font);
+ if_debug1m('k', font->memory, "[k]purging font 0x%lx\n",
+ (ulong) font);
for (; count--; pair++) {
if (pair->font == font) {
if (!force && uid_is_valid(&pair->UID)) { /* Keep the entry. */
@@ -904,9 +907,10 @@ alloc_char(gs_font_dir * dir, ulong icdsize, cached_char **pcc)
if (cksize > tsize)
cksize = tsize;
if (icdsize + sizeof(cached_char_head) > cksize) {
- if_debug2('k', "[k]no cache bits: cdsize+head=%lu, cksize=%u\n",
- icdsize + sizeof(cached_char_head),
- cksize);
+ if_debug2m('k', mem,
+ "[k]no cache bits: cdsize+head=%lu, cksize=%u\n",
+ icdsize + sizeof(cached_char_head),
+ cksize);
return 0; /* wouldn't fit */
}
cck = (char_cache_chunk *)
@@ -1038,7 +1042,7 @@ shorten_cached_char(gs_font_dir * dir, cached_char * cc, uint diff)
{
gx_bits_cache_shorten((gx_bits_cache *) & dir->ccache, &cc->head,
diff, cc->chunk);
- if_debug2('K', "[K]shortening creates free block 0x%lx(%u)\n",
+ if_debug2m('K', dir->memory, "[K]shortening creates free block 0x%lx(%u)\n",
(ulong) ((byte *) cc + cc->head.size), diff);
}
diff --git a/gs/base/gxchar.c b/gs/base/gxchar.c
index 0dc5519aa..40c42f1fd 100644
--- a/gs/base/gxchar.c
+++ b/gs/base/gxchar.c
@@ -499,7 +499,7 @@ set_cache_device(gs_show_enum * penum, gs_state * pgs, floatp llx, floatp lly,
return 0;
if (SHOW_IS_ALL_OF(penum, TEXT_DO_NONE | TEXT_INTERVENE)) { /* cshow */
int code;
- if_debug0('k', "[k]no cache: cshow");
+ if_debug0m('k', penum->memory, "[k]no cache: cshow");
code = gs_nulldevice(pgs);
if (code < 0)
return code;
@@ -513,8 +513,8 @@ set_cache_device(gs_show_enum * penum, gs_state * pgs, floatp llx, floatp lly,
/* We can only use the cache if ctm is unchanged */
/* (aside from a possible translation). */
if (penum->can_cache <= 0 || !pgs->char_tm_valid) {
- if_debug2('k', "[k]no cache: can_cache=%d, char_tm_valid=%d\n",
- penum->can_cache, (int)pgs->char_tm_valid);
+ if_debug2m('k', penum->memory, "[k]no cache: can_cache=%d, char_tm_valid=%d\n",
+ penum->can_cache, (int)pgs->char_tm_valid);
return 0;
} {
const gs_font *pfont = pgs->font;
@@ -578,13 +578,13 @@ set_cache_device(gs_show_enum * penum, gs_state * pgs, floatp llx, floatp lly,
return code;
#ifdef DEBUG
if (gs_debug_c('k')) {
- dlprintf6("[k]cbox=[%g %g %g %g] scale=%dx%d\n",
- fixed2float(cll.x), fixed2float(cll.y),
- fixed2float(cur.x), fixed2float(cur.y),
- 1 << log2_scale.x, 1 << log2_scale.y);
- dlprintf6("[p] ctm=[%g %g %g %g %g %g]\n",
- pgs->ctm.xx, pgs->ctm.xy, pgs->ctm.yx, pgs->ctm.yy,
- pgs->ctm.tx, pgs->ctm.ty);
+ dmlprintf6(pgs->memory, "[k]cbox=[%g %g %g %g] scale=%dx%d\n",
+ fixed2float(cll.x), fixed2float(cll.y),
+ fixed2float(cur.x), fixed2float(cur.y),
+ 1 << log2_scale.x, 1 << log2_scale.y);
+ dmlprintf6(pgs->memory, "[p] ctm=[%g %g %g %g %g %g]\n",
+ pgs->ctm.xx, pgs->ctm.xy, pgs->ctm.yx, pgs->ctm.yy,
+ pgs->ctm.tx, pgs->ctm.ty);
}
#endif
cdim.x = cur.x - cll.x;
@@ -595,9 +595,9 @@ set_cache_device(gs_show_enum * penum, gs_state * pgs, floatp llx, floatp lly,
return 0; /* much too big */
iwidth = ((ushort) fixed2int_var(cdim.x) + 3) << log2_scale.x;
iheight = ((ushort) fixed2int_var(cdim.y) + 3) << log2_scale.y;
- if_debug3('k', "[k]iwidth=%u iheight=%u dev_cache %s\n",
- (uint) iwidth, (uint) iheight,
- (penum->dev_cache == 0 ? "not set" : "set"));
+ if_debug3m('k', penum->memory, "[k]iwidth=%u iheight=%u dev_cache %s\n",
+ (uint) iwidth, (uint) iheight,
+ (penum->dev_cache == 0 ? "not set" : "set"));
if (penum->dev_cache == 0) {
code = show_cache_setup(penum);
if (code < 0)
@@ -648,10 +648,10 @@ set_cache_device(gs_show_enum * penum, gs_state * pgs, floatp llx, floatp lly,
/* Truncate the offsets to avoid artifacts later. */
cc->offset.x = fixed_ceiling(-cll.x) + fixed_1;
cc->offset.y = fixed_ceiling(-cll.y) + fixed_1;
- if_debug4('k', "[k]width=%u, height=%u, offset=[%g %g]\n",
- (uint) iwidth, (uint) iheight,
- fixed2float(cc->offset.x),
- fixed2float(cc->offset.y));
+ if_debug4m('k', penum->memory, "[k]width=%u, height=%u, offset=[%g %g]\n",
+ (uint) iwidth, (uint) iheight,
+ fixed2float(cc->offset.x),
+ fixed2float(cc->offset.y));
pgs->in_cachedevice = CACHE_DEVICE_NONE; /* Provide correct grestore */
if ((code = gs_gsave(pgs)) < 0) {
gx_free_cached_char(dir, cc);
diff --git a/gs/base/gxclbits.c b/gs/base/gxclbits.c
index 8934e04fb..63f4f8485 100644
--- a/gs/base/gxclbits.c
+++ b/gs/base/gxclbits.c
@@ -202,7 +202,8 @@ cmd_put_bits(gx_device_clist_writer * cldev, gx_clist_state * pcls,
}
if (uncompressed_size > max_size) {
/* Shorten to zero, erasing the operation altogether */
- if_debug1 ('L', "[L]Uncompressed bits %u too large for buffer\n",
+ if_debug1m('L', cldev->memory,
+ "[L]Uncompressed bits %u too large for buffer\n",
uncompressed_size);
cmd_shorten_list_op(cldev,
(pcls ? &pcls->list : &cldev->band_range_list),
@@ -210,7 +211,7 @@ cmd_put_bits(gx_device_clist_writer * cldev, gx_clist_state * pcls,
return_error(gs_error_limitcheck);
}
if (uncompressed_size != short_size) {
- if_debug2 ('L', "[L]Shortening bits from %u to %u\n",
+ if_debug2m('L',cldev->memory,"[L]Shortening bits from %u to %u\n",
try_size, op_size + short_size);
cmd_shorten_list_op(cldev,
(pcls ? &pcls->list : &cldev->band_range_list),
@@ -260,12 +261,12 @@ cmd_size_tile_params(const gx_strip_bitmap * tile, bool for_pattern)
}
static void
cmd_store_tile_params(byte * dp, const gx_strip_bitmap * tile, int depth,
- uint csize, bool for_pattern)
+ uint csize, bool for_pattern, const gs_memory_t *mem)
{
byte *p = dp + 2;
byte bd = cmd_depth_to_code(depth);
- *dp = cmd_count_op(cmd_opv_set_tile_size, csize);
+ *dp = cmd_count_op(cmd_opv_set_tile_size, csize, mem);
if (for_pattern)
p = cmd_put_w(tile->id, p);
p = cmd_put_w(tile->rep_width, p);
@@ -311,8 +312,8 @@ cmd_put_tile_index(gx_device_clist_writer *cldev, gx_clist_state *pcls,
return code;
dp[1] = indx & 0xff;
}
- if_debug2('L', "[L]writing index=%u, offset=%lu\n",
- indx, cldev->tile_table[indx].offset);
+ if_debug2m('L', cldev->memory, "[L]writing index=%u, offset=%lu\n",
+ indx, cldev->tile_table[indx].offset);
return 0;
}
@@ -406,8 +407,8 @@ clist_delete_tile(gx_device_clist_writer * cldev, tile_slot * slot)
uint index = slot->index;
ulong offset;
- if_debug2('L', "[L]deleting index=%u, offset=%lu\n",
- index, (ulong) ((byte *) slot - cldev->data));
+ if_debug2m('L', cldev->memory, "[L]deleting index=%u, offset=%lu\n",
+ index, (ulong) ((byte *) slot - cldev->data));
gx_bits_cache_free(&cldev->bits, (gx_cached_bits_head *) slot,
&cldev->chunk);
table[index].offset = 0;
@@ -422,8 +423,9 @@ clist_delete_tile(gx_device_clist_writer * cldev, tile_slot * slot)
if (!clist_find_bits(cldev, tile->id, &loc)) { /* We didn't find it, so it should be moved into a slot */
/* that we just vacated; instead, delete it. */
- if_debug2('L', "[L]move-deleting index=%u, offset=%lu\n",
- index, offset);
+ if_debug2m('L', cldev->memory,
+ "[L]move-deleting index=%u, offset=%lu\n",
+ index, offset);
gx_bits_cache_free(&cldev->bits,
(gx_cached_bits_head *) (cldev->data + offset),
&cldev->chunk);
@@ -507,8 +509,8 @@ clist_add_tile(gx_device_clist_writer * cldev, const gx_strip_bitmap * tiles,
slot->index = loc.index;
cldev->tile_table[loc.index].offset =
(byte *) slot_head - cldev->data;
- if_debug2('L', "[L]adding index=%u, offset=%lu\n",
- loc.index, cldev->tile_table[loc.index].offset);
+ if_debug2m('L', cldev->memory, "[L]adding index=%u, offset=%lu\n",
+ loc.index, cldev->tile_table[loc.index].offset);
}
slot->num_bands = 0;
return 0;
@@ -667,7 +669,7 @@ clist_change_tile(gx_device_clist_writer * cldev, gx_clist_state * pcls,
return code;
if (extra) { /* Write the tile parameters before writing the bits. */
cmd_store_tile_params(dp, &cldev->tile_params, depth,
- extra, for_pattern);
+ extra, for_pattern, cldev->memory);
dp += extra;
/* This band now knows the parameters. */
pcls->known |= tile_params_known;
@@ -676,7 +678,7 @@ clist_change_tile(gx_device_clist_writer * cldev, gx_clist_state * pcls,
if (band_index > cldev->tile_known_max)
cldev->tile_known_max = band_index;
}
- *dp = cmd_count_op(cmd_opv_set_tile_bits, csize - extra);
+ *dp = cmd_count_op(cmd_opv_set_tile_bits, csize - extra, cldev->memory);
dp++;
dp = cmd_put_w(loc.index, dp);
cmd_put_w(offset, dp);
@@ -754,7 +756,7 @@ clist_change_bits(gx_device_clist_writer * cldev, gx_clist_state * pcls,
if (code < 0)
return code;
- *dp = cmd_count_op(cmd_opv_set_bits, csize);
+ *dp = cmd_count_op(cmd_opv_set_bits, csize, cldev->memory);
dp[1] = (depth << 2) + code;
dp += 2;
dp = cmd_put_w(loc.tile->width, dp);
diff --git a/gs/base/gxcldev.h b/gs/base/gxcldev.h
index a43c7e20e..83a45aed7 100644
--- a/gs/base/gxcldev.h
+++ b/gs/base/gxcldev.h
@@ -387,12 +387,12 @@ int cmd_put_params(gx_device_clist_writer *, gs_param_list *);
/* Conditionally keep command statistics. */
#ifdef DEBUG
-int cmd_count_op(int op, uint size);
+int cmd_count_op(int op, uint size, const gs_memory_t *mem);
void cmd_uncount_op(int op, uint size);
-void cmd_print_stats(void);
+void cmd_print_stats(const gs_memory_t *);
# define cmd_count_add1(v) (v++)
#else
-# define cmd_count_op(op, size) (op)
+# define cmd_count_op(op, size, mem) (op)
# define cmd_uncount_op(op, size) DO_NOTHING
# define cmd_count_add1(v) DO_NOTHING
#endif
@@ -416,7 +416,7 @@ byte *cmd_put_op(gx_device_clist_writer * cldev, gx_clist_state * pcls, uint siz
#define set_cmd_put_op(dp, cldev, pcls, op, csize)\
( (dp = cmd_put_op(cldev, pcls, csize)) == 0 ?\
(cldev)->error_code :\
- (*dp = cmd_count_op(op, csize), 0) )
+ (*dp = cmd_count_op(op, csize, cldev->memory), 0) )
/* Add a command for all bands or a range of bands. */
byte *cmd_put_range_op(gx_device_clist_writer * cldev, int band_min,
@@ -428,7 +428,7 @@ byte *cmd_put_range_op(gx_device_clist_writer * cldev, int band_min,
#define set_cmd_put_range_op(dp, cldev, op, bmin, bmax, csize)\
( (dp = cmd_put_range_op(cldev, bmin, bmax, csize)) == 0 ?\
(cldev)->error_code :\
- (*dp = cmd_count_op(op, csize), 0) )
+ (*dp = cmd_count_op(op, csize, (cldev)->memory), 0) )
#define set_cmd_put_all_op(dp, cldev, op, csize)\
set_cmd_put_range_op(dp, cldev, op, 0, (cldev)->nbands - 1, csize)
diff --git a/gs/base/gxclimag.c b/gs/base/gxclimag.c
index 25b231c3c..3eb7fcfc8 100644
--- a/gs/base/gxclimag.c
+++ b/gs/base/gxclimag.c
@@ -1075,14 +1075,14 @@ clist_create_compositor(gx_device * dev,
if(cropping_op != 0) {
- dprintf2("[v] cropping_op = %d. Total number of bands is %d \n",
+ dmprintf2(dev->memory, "[v] cropping_op = %d. Total number of bands is %d \n",
cropping_op, no_of_bands);
- dprintf2("[v] Writing out from band %d through band %d \n",
+ dmprintf2(dev->memory, "[v] Writing out from band %d through band %d \n",
first_band, last_band);
} else {
- dprintf1("[v] cropping_op = %d. Writing out to all bands \n",
+ dmprintf1(dev->memory, "[v] cropping_op = %d. Writing out to all bands \n",
cropping_op);
}
@@ -1451,12 +1451,12 @@ image_band_box(gx_device * dev, const clist_image_enum * pie, int y, int h,
bbox.q.y = fixed2float(min(cbox.q.y, by1) + fixed_half);
#ifdef DEBUG
if (gs_debug_c('b')) {
- dlprintf6("[b]band box for (%d,%d),(%d,%d), band (%d,%d) =>\n",
- px, py, qx, qy, y, y + h);
- dlprintf10(" (%g,%g),(%g,%g), matrix=[%g %g %g %g %g %g]\n",
- bbox.p.x, bbox.p.y, bbox.q.x, bbox.q.y,
- pie->matrix.xx, pie->matrix.xy, pie->matrix.yx,
- pie->matrix.yy, pie->matrix.tx, pie->matrix.ty);
+ dmlprintf6(dev->memory, "[b]band box for (%d,%d),(%d,%d), band (%d,%d) =>\n",
+ px, py, qx, qy, y, y + h);
+ dmlprintf10(dev->memory, " (%g,%g),(%g,%g), matrix=[%g %g %g %g %g %g]\n",
+ bbox.p.x, bbox.p.y, bbox.q.x, bbox.q.y,
+ pie->matrix.xx, pie->matrix.xy, pie->matrix.yx,
+ pie->matrix.yy, pie->matrix.tx, pie->matrix.ty);
}
#endif
if (is_xxyy(&pie->matrix) || is_xyyx(&pie->matrix)) {
@@ -1507,7 +1507,8 @@ image_band_box(gx_device * dev, const clist_image_enum * pie, int y, int h,
gs_point_transform_inverse(bbox.p.x, bbox.q.y, &pie->matrix,
&corners[3]) < 0
) {
- if_debug0('b', "[b]can't inverse-transform a band corner!\n");
+ if_debug0m('b', dev->memory,
+ "[b]can't inverse-transform a band corner!\n");
return false;
}
corners[4] = corners[0];
@@ -1541,34 +1542,34 @@ image_band_box(gx_device * dev, const clist_image_enum * pie, int y, int h,
if (dx != 0) {
double t = (px - pa.x) / dx;
- if_debug3('b', " (px) t=%g => (%d,%g)\n",
- t, px, pa.y + t * dy);
+ if_debug3m('b', dev->memory, " (px) t=%g => (%d,%g)\n",
+ t, px, pa.y + t * dy);
if (in_range(t, pa.y + t * dy, py, qy))
box_merge_point(pbox, (floatp) px, t);
t = (qx - pa.x) / dx;
- if_debug3('b', " (qx) t=%g => (%d,%g)\n",
- t, qx, pa.y + t * dy);
+ if_debug3m('b', dev->memory, " (qx) t=%g => (%d,%g)\n",
+ t, qx, pa.y + t * dy);
if (in_range(t, pa.y + t * dy, py, qy))
box_merge_point(pbox, (floatp) qx, t);
}
if (dy != 0) {
double t = (py - pa.y) / dy;
- if_debug3('b', " (py) t=%g => (%g,%d)\n",
- t, pa.x + t * dx, py);
+ if_debug3m('b', dev->memory, " (py) t=%g => (%g,%d)\n",
+ t, pa.x + t * dx, py);
if (in_range(t, pa.x + t * dx, px, qx))
box_merge_point(pbox, t, (floatp) py);
t = (qy - pa.y) / dy;
- if_debug3('b', " (qy) t=%g => (%g,%d)\n",
- t, pa.x + t * dx, qy);
+ if_debug3m('b', dev->memory, " (qy) t=%g => (%g,%d)\n",
+ t, pa.x + t * dx, qy);
if (in_range(t, pa.x + t * dx, px, qx))
box_merge_point(pbox, t, (floatp) qy);
}
#undef in_range
}
}
- if_debug4('b', " => (%d,%d),(%d,%d)\n", pbox->p.x, pbox->p.y,
- pbox->q.x, pbox->q.y);
+ if_debug4m('b', dev->memory, " => (%d,%d),(%d,%d)\n",
+ pbox->p.x, pbox->p.y, pbox->q.x, pbox->q.y);
/*
* If necessary, add pixels around the edges so we will have
* enough information to do interpolation.
@@ -1740,7 +1741,7 @@ write_image_end_all(gx_device *dev, const clist_image_enum *pie)
RECT_STEP_INIT(re);
if (re.pcls->known & begin_image_known) {
do {
- if_debug1('L', "[L]image_end for band %d\n", re.band);
+ if_debug1m('L', dev->memory, "[L]image_end for band %d\n", re.band);
code = set_cmd_put_op(dp, cdev, re.pcls, cmd_opv_image_data, 2);
} while (RECT_RECOVER(code));
if (code < 0 && SET_BAND_CODE(code))
diff --git a/gs/base/gxclip.c b/gs/base/gxclip.c
index 8cb500bb2..517e1f151 100644
--- a/gs/base/gxclip.c
+++ b/gs/base/gxclip.c
@@ -228,12 +228,14 @@ clip_enumerate_rest(gx_device_clip * rdev,
#ifdef DEBUG
if (INCR(loops) % clip_interval == 0 && gs_debug_c('q')) {
- dprintf5("[q]loops=%ld out=%ld in_y=%ld in=%ld in1=%ld\n",
- stats_clip.loops, stats_clip.out, stats_clip.in,
- stats_clip.in_y, stats_clip.in1);
- dprintf4("[q] down=%ld up=%ld x=%ld no_x=%ld\n",
- stats_clip.down, stats_clip.up, stats_clip.x,
- stats_clip.no_x);
+ dmprintf5(rdev->memory,
+ "[q]loops=%ld out=%ld in_y=%ld in=%ld in1=%ld\n",
+ stats_clip.loops, stats_clip.out, stats_clip.in,
+ stats_clip.in_y, stats_clip.in1);
+ dmprintf4(rdev->memory,
+ "[q] down=%ld up=%ld x=%ld no_x=%ld\n",
+ stats_clip.down, stats_clip.up, stats_clip.x,
+ stats_clip.no_x);
}
#endif
pccd->x = x, pccd->y = y;
@@ -274,7 +276,7 @@ clip_enumerate_rest(gx_device_clip * rdev,
const int ymax = rptr->ymax;
int yec = min(ymax, ye);
- if_debug2('Q', "[Q]yc=%d yec=%d\n", yc, yec);
+ if_debug2m('Q', rdev->memory, "[Q]yc=%d yec=%d\n", yc, yec);
do {
int xc = rptr->xmin;
int xec = rptr->xmax;
@@ -285,7 +287,7 @@ clip_enumerate_rest(gx_device_clip * rdev,
xec = xe;
if (xec > xc) {
clip_rect_print('Q', "match", rptr);
- if_debug2('Q', "[Q]xc=%d xec=%d\n", xc, xec);
+ if_debug2m('Q', rdev->memory, "[Q]xc=%d xec=%d\n", xc, xec);
INCR(x);
/*
* Conditionally look ahead to detect unclipped vertical strips. This is
diff --git a/gs/base/gxclip2.c b/gs/base/gxclip2.c
index 889723e98..3b9ea5efd 100644
--- a/gs/base/gxclip2.c
+++ b/gs/base/gxclip2.c
@@ -291,7 +291,7 @@ tile_clip_copy_mono(gx_device * dev,
do {\
t_next(tx);\
} while ( tx < x + w && (*tp & tbit) != 0 );\
- if_debug3('T', "[T]run x=(%d,%d), y=%d\n", tx1, tx, ty);
+ if_debug3m('T', cdev->memory, "[T]run x=(%d,%d), y=%d\n", tx1, tx, ty);
/* (body goes here) */
#define END_FOR_RUNS()\
}\
diff --git a/gs/base/gxclipm.c b/gs/base/gxclipm.c
index 8a49e66b4..4bd18807e 100644
--- a/gs/base/gxclipm.c
+++ b/gs/base/gxclipm.c
@@ -284,7 +284,7 @@ clip_runs_enumerate(gx_device_mask_clip * cdev,
int cx = mx0;
const byte *tp = tile_row;
- if_debug1('B', "[B]clip runs y=%d:", cy - cdev->phase.y);
+ if_debug1m('B', cdev->memory, "[B]clip runs y=%d:", cy - cdev->phase.y);
while (cx < mx1) {
int len;
int tx1, tx, ty;
@@ -327,7 +327,7 @@ clip_runs_enumerate(gx_device_mask_clip * cdev,
}
}
tx = cx - cdev->phase.x;
- if_debug2('B', " %d-%d,", tx1, tx);
+ if_debug2m('B', cdev->memory, " %d-%d,", tx1, tx);
ty = cy - cdev->phase.y;
/* Detect vertical rectangles. */
if (prev.p.x == tx1 && prev.q.x == tx && prev.q.y == ty)
@@ -344,7 +344,7 @@ clip_runs_enumerate(gx_device_mask_clip * cdev,
prev.q.y = ty + 1;
}
}
- if_debug0('B', "\n");
+ if_debug0m('B', cdev->memory, "\n");
tile_row += cdev->tiles.raster;
}
if (prev.q.y > prev.p.y) {
diff --git a/gs/base/gxclist.c b/gs/base/gxclist.c
index 38f89502b..02cd9031b 100644
--- a/gs/base/gxclist.c
+++ b/gs/base/gxclist.c
@@ -335,8 +335,8 @@ clist_init_bands(gx_device * dev, gx_device_memory *bdev, uint data_size,
cdev->nbands = nbands;
#ifdef DEBUG
if (gs_debug_c('l') | gs_debug_c(':'))
- dlprintf4("[:]width=%d, band_width=%d, band_height=%d, nbands=%d\n",
- bdev->width, band_width, band_height, nbands);
+ dmlprintf4(dev->memory, "[:]width=%d, band_width=%d, band_height=%d, nbands=%d\n",
+ bdev->width, band_width, band_height, nbands);
#endif
return 0;
}
@@ -844,10 +844,10 @@ clist_end_page(gx_device_clist_writer * cldev)
#ifdef DEBUG
if (gs_debug_c('l') | gs_debug_c(':')) {
if (cb.pos <= 0xFFFFFFFF)
- dlprintf2("[:]clist_end_page at cfile=%lu, bfile=%lu\n",
+ dmlprintf2(cldev->memory, "[:]clist_end_page at cfile=%lu, bfile=%lu\n",
(unsigned long)cb.pos, (unsigned long)cldev->page_bfile_end_pos);
else
- dlprintf3("[:]clist_end_page at cfile=%lu%0lu, bfile=%lu\n",
+ dmlprintf3(cldev->memory, "[:]clist_end_page at cfile=%lu%0lu, bfile=%lu\n",
(unsigned long) (cb.pos >> 32), (unsigned long) (cb.pos & 0xFFFFFFFF),
(unsigned long)cldev->page_bfile_end_pos);
}
@@ -928,7 +928,7 @@ clist_VMerror_recover(gx_device_clist_writer *cldev,
}
} while (pages_remain);
- if_debug1('L', "[L]soft flush of command list, status: %d\n", code);
+ if_debug1m('L', cldev->memory, "[L]soft flush of command list, status: %d\n", code);
return code;
}
@@ -968,7 +968,7 @@ clist_VMerror_recover_flush(gx_device_clist_writer *cldev,
}
code = (reset_code < 0 ? reset_code : free_code < 0 ? old_error_code : 0);
- if_debug1('L', "[L]hard flush of command list, status: %d\n", code);
+ if_debug1m('L', cldev->memory, "[L]hard flush of command list, status: %d\n", code);
return code;
}
@@ -1142,7 +1142,7 @@ clist_icc_addprofile(gx_device_clist_writer *cldev, cmm_profile_t *iccprofile, i
/* Get the serialized header */
gsicc_profile_serialize(&profile_data, iccprofile);
/* Write the header */
- if_debug1('l', "[l]writing icc profile in cfile at pos %ld\n",fileposit);
+ if_debug1m('l', cldev->memory, "[l]writing icc profile in cfile at pos %ld\n",fileposit);
count1 = cldev->page_info.io_procs->fwrite_chars(&profile_data, sizeof(gsicc_serialized_profile_t), cfile);
/* Now write the profile */
count2 = cldev->page_info.io_procs->fwrite_chars(iccprofile->buffer, iccprofile->buffer_size, cfile);
@@ -1234,7 +1234,7 @@ clist_writer_push_no_cropping(gx_device_clist_writer *cdev)
if (buf == NULL)
return_error(gs_error_VMerror);
- if_debug1('v', "[v]push cropping[%d]\n", cdev->cropping_level);
+ if_debug1m('v', cdev->memory, "[v]push cropping[%d]\n", cdev->cropping_level);
buf->next = cdev->cropping_stack;
cdev->cropping_stack = buf;
buf->cropping_min = cdev->cropping_min;
@@ -1270,7 +1270,7 @@ clist_writer_pop_cropping(gx_device_clist_writer *cdev)
cdev->temp_mask_id = buf->temp_mask_id;
cdev->cropping_stack = buf->next;
cdev->cropping_level--;
- if_debug1('v', "[v]pop cropping[%d]\n", cdev->cropping_level);
+ if_debug1m('v', cdev->memory, "[v]pop cropping[%d]\n", cdev->cropping_level);
gs_free_object(cdev->memory, buf, "clist_writer_transparency_pop");
return 0;
}
@@ -1279,7 +1279,7 @@ int
clist_writer_check_empty_cropping_stack(gx_device_clist_writer *cdev)
{
if (cdev->cropping_stack != NULL) {
- if_debug1('v', "[v]Error: left %d cropping(s)\n", cdev->cropping_level);
+ if_debug1m('v', cdev->memory, "[v]Error: left %d cropping(s)\n", cdev->cropping_level);
return_error(gs_error_unregistered); /* Must not happen */
}
return 0;
diff --git a/gs/base/gxclmem.c b/gs/base/gxclmem.c
index 7bdb18375..e41616a66 100644
--- a/gs/base/gxclmem.c
+++ b/gs/base/gxclmem.c
@@ -708,7 +708,7 @@ memfile_next_blk(MEMFILE * f)
/* check if need to start compressing */
if (NEED_TO_COMPRESS(f)) {
- if_debug0(':', "[:]Beginning compression\n");
+ if_debug0m(':', f->memory, "[:]Beginning compression\n");
/* compress the entire file up to this point */
if (!f->compressor_initialized) {
int code = 0;
@@ -890,8 +890,8 @@ memfile_get_pdata(MEMFILE * f)
}
f->raw_tail->fwd = NULL;
num_raw_buffers = i + 1; /* if MALLOC failed, then OK */
- if_debug1(':', "[:]Number of raw buffers allocated=%d\n",
- num_raw_buffers);
+ if_debug1m(':', f->memory, "[:]Number of raw buffers allocated=%d\n",
+ num_raw_buffers);
if (f->decompress_state->templat->init != 0)
code = (*f->decompress_state->templat->init)
(f->decompress_state);
@@ -1125,18 +1125,18 @@ memfile_free_mem(MEMFILE * f)
/* output some diagnostics about the effectiveness */
if (tot_raw > 100) {
if (tot_raw > 0xFFFFFFFF)
- if_debug4(':', "[:]tot_raw=%lu%0lu, tot_compressed=%lu%0lu\n",
- tot_raw >> 32, tot_raw & 0xFFFFFFFF,
- tot_compressed >> 32, tot_compressed & 0xFFFFFFFF);
+ if_debug4m(':', f->memory, "[:]tot_raw=%lu%0lu, tot_compressed=%lu%0lu\n",
+ tot_raw >> 32, tot_raw & 0xFFFFFFFF,
+ tot_compressed >> 32, tot_compressed & 0xFFFFFFFF);
else
- if_debug2(':', "[:]tot_raw=%lu, tot_compressed=%lu\n",
- tot_raw, tot_compressed);
+ if_debug2m(':', f->memory, "[:]tot_raw=%lu, tot_compressed=%lu\n",
+ tot_raw, tot_compressed);
}
if (tot_cache_hits != 0) {
- if_debug3(':', "[:]Cache hits=%lu, cache misses=%lu, swapouts=%lu\n",
- tot_cache_hits,
- (long)(tot_cache_miss - (f->log_length / MEMFILE_DATA_SIZE)),
- tot_swap_out);
+ if_debug3m(':', f->memory, "[:]Cache hits=%lu, cache misses=%lu, swapouts=%lu\n",
+ tot_cache_hits,
+ (long)(tot_cache_miss - (f->log_length / MEMFILE_DATA_SIZE)),
+ tot_swap_out);
}
tot_raw = 0;
tot_compressed = 0;
diff --git a/gs/base/gxclpath.c b/gs/base/gxclpath.c
index 84e2aff09..1a8ac6235 100644
--- a/gs/base/gxclpath.c
+++ b/gs/base/gxclpath.c
@@ -740,8 +740,9 @@ clist_fill_path(gx_device * dev, const gs_imager_state * pis, gx_path * ppath,
if (cdev->cropping_saved) {
cdev->cropping_min = cdev->save_cropping_min;
cdev->cropping_max = cdev->save_cropping_max;
- if_debug2('v', "[v] clist_fill_path: restore cropping_min=%d croping_max=%d\n",
- cdev->save_cropping_min, cdev->save_cropping_max);
+ if_debug2m('v', cdev->memory,
+ "[v] clist_fill_path: restore cropping_min=%d croping_max=%d\n",
+ cdev->save_cropping_min, cdev->save_cropping_max);
}
return code;
}
@@ -764,8 +765,9 @@ clist_fill_path(gx_device * dev, const gs_imager_state * pis, gx_path * ppath,
cdev->save_cropping_max = cdev->cropping_max;
cdev->cropping_min = max(ry, cdev->cropping_min);
cdev->cropping_max = min(ry + rheight, cdev->cropping_max);
- if_debug2('v', "[v] clist_fill_path: narrow cropping_min=%d croping_max=%d\n",
- cdev->save_cropping_min, cdev->save_cropping_max);
+ if_debug2m('v', cdev->memory,
+ "[v] clist_fill_path: narrow cropping_min=%d croping_max=%d\n",
+ cdev->save_cropping_min, cdev->save_cropping_max);
RECT_ENUM_INIT(re, ry, rheight);
do {
RECT_STEP_INIT(re);
@@ -1110,11 +1112,11 @@ cmd_put_segment(cmd_segment_writer * psw, byte op,
if (gs_debug_c('L')) {
int j;
- dlprintf2("[L] %s:%d:", cmd_sub_op_names[op >> 4][op & 0xf],
+ dmlprintf2(psw->cldev->memory, "[L] %s:%d:", cmd_sub_op_names[op >> 4][op & 0xf],
(int)notes);
for (j = 0; j < i; ++j)
- dprintf1(" %g", fixed2float(operands[j]));
- dputs("\n");
+ dmprintf1(psw->cldev->memory, " %g", fixed2float(operands[j]));
+ dmputs(psw->cldev->memory, "\n");
}
#endif
@@ -1146,7 +1148,7 @@ cmd_put_segment(cmd_segment_writer * psw, byte op,
operands[1] == -psw->delta_first.y
) {
cmd_uncount_op(cmd_opv_rm2lineto, psw->len);
- *psw->dp = cmd_count_op(cmd_opv_rm3lineto, psw->len);
+ *psw->dp = cmd_count_op(cmd_opv_rm3lineto, psw->len, psw->cldev->memory);
return 0;
}
break;
@@ -1302,9 +1304,9 @@ cmd_put_path(gx_device_clist_writer * cldev, gx_clist_state * pcls,
struct { fixed vs[6]; } prev;
first.x = first.y = out.x = out.y = start.x = start.y = 0; /* Quiet gcc warning. */
- if_debug4('p', "[p]initial (%g,%g), clip [%g..%g)\n",
- fixed2float(px), fixed2float(py),
- fixed2float(ymin), fixed2float(ymax));
+ if_debug4m('p', cldev->memory, "[p]initial (%g,%g), clip [%g..%g)\n",
+ fixed2float(px), fixed2float(py),
+ fixed2float(ymin), fixed2float(ymax));
gx_path_enum_init(&cenum, ppath);
writer.cldev = cldev;
writer.pcls = pcls;
@@ -1334,8 +1336,8 @@ cmd_put_path(gx_device_clist_writer * cldev, gx_clist_state * pcls,
/* All done. */
pcls->rect.x = fixed2int_var(px);
pcls->rect.y = fixed2int_var(py);
- if_debug2('p', "[p]final (%d,%d)\n",
- pcls->rect.x, pcls->rect.y);
+ if_debug2m('p', cldev->memory, "[p]final (%d,%d)\n",
+ pcls->rect.x, pcls->rect.y);
return set_cmd_put_op(dp, cldev, pcls, path_op, 1);
case gs_pe_moveto:
/* If the path is open and needs an implicit close, */
@@ -1349,16 +1351,16 @@ cmd_put_path(gx_device_clist_writer * cldev, gx_clist_state * pcls,
start_skip = false;
if ((start_side = side = which_side(B)) != 0) {
out.x = A, out.y = B;
- if_debug3('p', "[p]skip moveto (%g,%g) side %d\n",
- fixed2float(out.x), fixed2float(out.y),
- side);
+ if_debug3m('p', cldev->memory, "[p]skip moveto (%g,%g) side %d\n",
+ fixed2float(out.x), fixed2float(out.y),
+ side);
continue;
}
C = A - px, D = B - py;
first.x = px = A, first.y = py = B;
code = cmd_put_rmoveto(&writer, &C);
- if_debug2('p', "[p]moveto (%g,%g)\n",
- fixed2float(px), fixed2float(py));
+ if_debug2m('p', cldev->memory, "[p]moveto (%g,%g)\n",
+ fixed2float(px), fixed2float(py));
break;
case gs_pe_gapto:
{
@@ -1371,9 +1373,9 @@ cmd_put_path(gx_device_clist_writer * cldev, gx_clist_state * pcls,
start_skip = true;
out.x = A, out.y = B;
out_notes = notes;
- if_debug3('p', "[p]skip gapto (%g,%g) side %d\n",
- fixed2float(out.x), fixed2float(out.y),
- side);
+ if_debug3m('p', cldev->memory, "[p]skip gapto (%g,%g) side %d\n",
+ fixed2float(out.x), fixed2float(out.y),
+ side);
continue;
}
/* If we skipped any segments, put out a moveto/lineto. */
@@ -1387,9 +1389,9 @@ cmd_put_path(gx_device_clist_writer * cldev, gx_clist_state * pcls,
if (code < 0)
return code;
px = out.x, py = out.y;
- if_debug3('p', "[p]catchup %s (%g,%g) for line\n",
- (open < 0 ? "moveto" : "lineto"),
- fixed2float(px), fixed2float(py));
+ if_debug3m('p', cldev->memory, "[p]catchup %s (%g,%g) for line\n",
+ (open < 0 ? "moveto" : "lineto"),
+ fixed2float(px), fixed2float(py));
}
if ((side = next_side) != 0) { /* Note a vertex going outside the clip region. */
out.x = A, out.y = B;
@@ -1399,8 +1401,8 @@ cmd_put_path(gx_device_clist_writer * cldev, gx_clist_state * pcls,
open = 1;
code = cmd_put_rgapto(&writer, &C, notes);
}
- if_debug3('p', "[p]gapto (%g,%g) side %d\n",
- fixed2float(px), fixed2float(py), side);
+ if_debug3m('p', cldev->memory, "[p]gapto (%g,%g) side %d\n",
+ fixed2float(px), fixed2float(py), side);
break;
case gs_pe_lineto:
{
@@ -1413,9 +1415,9 @@ cmd_put_path(gx_device_clist_writer * cldev, gx_clist_state * pcls,
start_skip = true;
out.x = A, out.y = B;
out_notes = notes;
- if_debug3('p', "[p]skip lineto (%g,%g) side %d\n",
- fixed2float(out.x), fixed2float(out.y),
- side);
+ if_debug3m('p', cldev->memory, "[p]skip lineto (%g,%g) side %d\n",
+ fixed2float(out.x), fixed2float(out.y),
+ side);
continue;
}
/* If we skipped any segments, put out a moveto/lineto. */
@@ -1429,9 +1431,9 @@ cmd_put_path(gx_device_clist_writer * cldev, gx_clist_state * pcls,
if (code < 0)
return code;
px = out.x, py = out.y;
- if_debug3('p', "[p]catchup %s (%g,%g) for line\n",
- (open < 0 ? "moveto" : "lineto"),
- fixed2float(px), fixed2float(py));
+ if_debug3m('p', cldev->memory, "[p]catchup %s (%g,%g) for line\n",
+ (open < 0 ? "moveto" : "lineto"),
+ fixed2float(px), fixed2float(py));
}
if ((side = next_side) != 0) { /* Note a vertex going outside the clip region. */
out.x = A, out.y = B;
@@ -1441,8 +1443,8 @@ cmd_put_path(gx_device_clist_writer * cldev, gx_clist_state * pcls,
open = 1;
code = cmd_put_rlineto(&writer, &C, notes);
}
- if_debug3('p', "[p]lineto (%g,%g) side %d\n",
- fixed2float(px), fixed2float(py), side);
+ if_debug3m('p', cldev->memory, "[p]lineto (%g,%g) side %d\n",
+ fixed2float(px), fixed2float(py), side);
break;
case gs_pe_closepath:
#ifdef DEBUG
@@ -1457,8 +1459,9 @@ cmd_put_path(gx_device_clist_writer * cldev, gx_clist_state * pcls,
case gs_pe_moveto:
break;
default:
- lprintf1("closepath followed by %d, not end/moveto!\n",
- op);
+ mlprintf1(cldev->memory,
+ "closepath followed by %d, not end/moveto!\n",
+ op);
}
}
#endif
@@ -1471,8 +1474,8 @@ cmd_put_path(gx_device_clist_writer * cldev, gx_clist_state * pcls,
if (code < 0)
return code;
px = out.x, py = out.y;
- if_debug2('p', "[p]catchup line (%g,%g) for close\n",
- fixed2float(px), fixed2float(py));
+ if_debug2m('p', cldev->memory, "[p]catchup line (%g,%g) for close\n",
+ fixed2float(px), fixed2float(py));
}
if (open > 0 && start_skip) { /* Draw the closing line back to the start. */
C = start.x - px, D = start.y - py;
@@ -1480,8 +1483,8 @@ cmd_put_path(gx_device_clist_writer * cldev, gx_clist_state * pcls,
if (code < 0)
return code;
px = start.x, py = start.y;
- if_debug2('p', "[p]draw close to (%g,%g)\n",
- fixed2float(px), fixed2float(py));
+ if_debug2m('p', cldev->memory, "[p]draw close to (%g,%g)\n",
+ fixed2float(px), fixed2float(py));
}
}
/*
@@ -1513,7 +1516,7 @@ cmd_put_path(gx_device_clist_writer * cldev, gx_clist_state * pcls,
open = 0;
px = first.x, py = first.y;
code = cmd_put_segment(&writer, cmd_opv_closepath, &A, sn_none);
- if_debug0('p', "[p]close\n");
+ if_debug0m('p', cldev->memory, "[p]close\n");
break;
case gs_pe_curveto:
{
@@ -1540,9 +1543,10 @@ cmd_put_path(gx_device_clist_writer * cldev, gx_clist_state * pcls,
start_skip = true;
out.x = E, out.y = F;
out_notes = notes;
- if_debug3('p', "[p]skip curveto (%g,%g) side %d\n",
- fixed2float(out.x), fixed2float(out.y),
- side);
+ if_debug3m('p', cldev->memory,
+ "[p]skip curveto (%g,%g) side %d\n",
+ fixed2float(out.x), fixed2float(out.y),
+ side);
continue;
}
out_side = all_side;
@@ -1561,9 +1565,10 @@ cmd_put_path(gx_device_clist_writer * cldev, gx_clist_state * pcls,
if (code < 0)
return code;
px = out.x, py = out.y;
- if_debug3('p', "[p]catchup %s (%g,%g) for curve\n",
- (open < 0 ? "moveto" : "lineto"),
- fixed2float(px), fixed2float(py));
+ if_debug3m('p', cldev->memory,
+ "[p]catchup %s (%g,%g) for curve\n",
+ (open < 0 ? "moveto" : "lineto"),
+ fixed2float(px), fixed2float(py));
}
if ((side = out_side) != 0) { /* Note a vertex going outside the clip region. */
out.x = E, out.y = F;
@@ -1574,10 +1579,11 @@ cmd_put_path(gx_device_clist_writer * cldev, gx_clist_state * pcls,
const fixed *optr = vs;
byte op;
- if_debug7('p', "[p]curveto (%g,%g; %g,%g; %g,%g) side %d\n",
- fixed2float(A), fixed2float(B),
- fixed2float(C), fixed2float(D),
- fixed2float(E), fixed2float(F), side);
+ if_debug7m('p', cldev->memory,
+ "[p]curveto (%g,%g; %g,%g; %g,%g) side %d\n",
+ fixed2float(A), fixed2float(B),
+ fixed2float(C), fixed2float(D),
+ fixed2float(E), fixed2float(F), side);
E -= C, F -= D;
C -= A, D -= B;
A -= px, B -= py;
diff --git a/gs/base/gxclrast.c b/gs/base/gxclrast.c
index 65a962c6f..2f692f3ff 100644
--- a/gs/base/gxclrast.c
+++ b/gs/base/gxclrast.c
@@ -65,23 +65,23 @@ extern const gs_color_space_type gs_color_space_type_Indexed;
/* Print a bitmap for tracing */
#ifdef DEBUG
static void
-cmd_print_bits(const byte * data, int width, int height, int raster)
+cmd_print_bits(gs_memory_t *mem, const byte * data, int width, int height, int raster)
{
int i, j;
- dlprintf3("[L]width=%d, height=%d, raster=%d\n",
+ dmlprintf3(mem, "[L]width=%d, height=%d, raster=%d\n",
width, height, raster);
for (i = 0; i < height; i++) {
const byte *row = data + i * raster;
- dlprintf("[L]");
+ dmlprintf(mem, "[L]");
for (j = 0; j < raster; j++)
- dprintf1(" %02x", row[j]);
- dputc('\n');
+ dmprintf1(mem, " %02x", row[j]);
+ dmputc(mem, '\n');
}
}
#else
-# define cmd_print_bits(data, width, height, raster) DO_NOTHING
+# define cmd_print_bits(mem, data, width, height, raster) DO_NOTHING
#endif
/* Get a variable-length integer operand. */
@@ -443,8 +443,7 @@ read_set_misc_map(byte cb, command_buf_t *pcb, gs_imager_state *pis, gs_memory_t
cbp++;
else {
*pcomp_num = (int) *cbp++;
- if_debug1('L', " comp_num=%d",
- *pcomp_num);
+ if_debug1m('L', mem, " comp_num=%d", *pcomp_num);
}
if (cont == cmd_map_other) {
cbp = cmd_read_data(pcb, (byte *)mdata, count, cbp);
@@ -454,11 +453,11 @@ read_set_misc_map(byte cb, command_buf_t *pcb, gs_imager_state *pis, gs_memory_t
uint i;
for (i = 0; i < count / sizeof(*mdata); ++i)
- dprintf1(" 0x%04x", mdata[i]);
- dputc('\n');
+ dmprintf1(mem, " 0x%04x", mdata[i]);
+ dmputc(mem, '\n');
}
} else {
- if_debug0('L', " none\n");
+ if_debug0m('L', mem, " none\n");
#endif
}
/* Recompute the effective transfer, */
@@ -660,17 +659,17 @@ in: /* Initialize for a new page. */
long offset = (long)clist_file_offset(st, cbp - 1 - cbuf.data);
if (sub)
- dlprintf1("[L]%s", sub[op & 0xf]);
+ dmlprintf1(mem, "[L]%s", sub[op & 0xf]);
else
- dlprintf2("[L]%s %d", cmd_op_names[op >> 4], op & 0xf);
- dlprintf1("(offset=%ld):", offset);
+ dmlprintf2(mem, "[L]%s %d", cmd_op_names[op >> 4], op & 0xf);
+ dmlprintf1(mem, "(offset=%ld):", offset);
}
#endif
switch (op >> 4) {
case cmd_op_misc >> 4:
switch (op) {
case cmd_opv_end_run:
- if_debug0('L', "\n");
+ if_debug0m('L', mem, "\n");
continue;
case cmd_opv_set_tile_size:
cbuf.ptr = cbp;
@@ -683,9 +682,9 @@ in: /* Initialize for a new page. */
case cmd_opv_set_tile_phase:
cmd_getw(state.tile_phase.x, cbp);
cmd_getw(state.tile_phase.y, cbp);
- if_debug2('L', " (%d,%d)\n",
- state.tile_phase.x,
- state.tile_phase.y);
+ if_debug2m('L', mem, " (%d,%d)\n",
+ state.tile_phase.x,
+ state.tile_phase.y);
goto set_phase;
case cmd_opv_set_tile_bits:
bits = tile_bits;
@@ -704,9 +703,9 @@ in: /* Initialize for a new page. */
bits.cb_depth = *cbp++ >> 2;
cmd_getw(bits.width, cbp);
cmd_getw(bits.height, cbp);
- if_debug4('L', " compress=%d depth=%d size=(%d,%d)",
- compress, bits.cb_depth,
- bits.width, bits.height);
+ if_debug4m('L', mem, " compress=%d depth=%d size=(%d,%d)",
+ compress, bits.cb_depth,
+ bits.width, bits.height);
bits.cb_raster =
bitmap_raster(bits.width * bits.cb_depth);
bits.x_reps = bits.y_reps = 1;
@@ -715,7 +714,7 @@ in: /* Initialize for a new page. */
goto stb;
case cmd_opv_set_tile_color:
set_colors = state.tile_colors;
- if_debug0('L', "\n");
+ if_debug0m('L', mem, "\n");
continue;
case cmd_opv_set_misc:
{
@@ -725,7 +724,7 @@ in: /* Initialize for a new page. */
case cmd_set_misc_lop >> 6:
cmd_getw(state.lop, cbp);
state.lop = (state.lop << 6) + (cb & 0x3f);
- if_debug1('L', " lop=0x%x\n", state.lop);
+ if_debug1m('L', mem, " lop=0x%x\n", state.lop);
if (state.lop_enabled)
imager_state.log_op = state.lop;
break;
@@ -735,7 +734,7 @@ in: /* Initialize for a new page. */
else
data_x = 0;
data_x = (data_x << 5) + (cb & 0x1f);
- if_debug1('L', " data_x=%d\n", data_x);
+ if_debug1m('L', mem, " data_x=%d\n", data_x);
break;
case cmd_set_misc_map >> 6:
cbuf.ptr = cbp;
@@ -749,8 +748,8 @@ in: /* Initialize for a new page. */
halftone_type = cb & 0x3f;
cmd_getw(num_comp, cbp);
- if_debug2('L', " halftone type=%d num_comp=%u\n",
- halftone_type, num_comp);
+ if_debug2m('L', mem, " halftone type=%d num_comp=%u\n",
+ halftone_type, num_comp);
code = cmd_resize_halftone(
&imager_state.dev_ht,
num_comp, mem);
@@ -766,15 +765,15 @@ in: /* Initialize for a new page. */
case cmd_opv_enable_lop:
state.lop_enabled = true;
imager_state.log_op = state.lop;
- if_debug0('L', "\n");
+ if_debug0m('L', mem, "\n");
continue;
case cmd_opv_disable_lop:
state.lop_enabled = false;
imager_state.log_op = lop_default;
- if_debug0('L', "\n");
+ if_debug0m('L', mem, "\n");
continue;
case cmd_opv_end_page:
- if_debug0('L', "\n");
+ if_debug0m('L', mem, "\n");
/*
* Do end-of-page cleanup, then reinitialize if
* there are more pages to come.
@@ -834,18 +833,18 @@ in: /* Initialize for a new page. */
*pcolor += delta - cmd_delta_offsets[dev_depth_bytes];
}
if (sizeof(*pcolor) <= sizeof(ulong))
- if_debug1('L', " 0x%lx\n", (ulong)*pcolor);
+ if_debug1m('L', mem, " 0x%lx\n", (ulong)*pcolor);
else
- if_debug2('L', " 0x%8lx%08lx\n",
- (ulong)(*pcolor >> 8*(sizeof(*pcolor) - sizeof(ulong))), (ulong)*pcolor);
+ if_debug2m('L', mem, " 0x%8lx%08lx\n",
+ (ulong)(*pcolor >> 8*(sizeof(*pcolor) - sizeof(ulong))), (ulong)*pcolor);
continue;
case cmd_opv_set_copy_color:
state.color_is_alpha = 0;
- if_debug0('L', "\n");
+ if_debug0m('L', mem, "\n");
continue;
case cmd_opv_set_copy_alpha:
state.color_is_alpha = 1;
- if_debug0('L', "\n");
+ if_debug0m('L', mem, "\n");
continue;
default:
goto bad_op;
@@ -898,10 +897,10 @@ in: /* Initialize for a new page. */
*pcolor = color;
}
if (sizeof(*pcolor) <= sizeof(ulong))
- if_debug1('L', " 0x%lx\n", (ulong)*pcolor);
+ if_debug1m('L', mem, " 0x%lx\n", (ulong)*pcolor);
else
- if_debug2('L', " 0x%8lx%08lx\n",
- (ulong)(*pcolor >> 8*(sizeof(*pcolor) - sizeof(ulong))), (ulong)*pcolor);
+ if_debug2m('L', mem, " 0x%8lx%08lx\n",
+ (ulong)(*pcolor >> 8*(sizeof(*pcolor) - sizeof(ulong))), (ulong)*pcolor);
continue;
case cmd_op_fill_rect >> 4:
case cmd_op_tile_rect >> 4:
@@ -940,7 +939,7 @@ in: /* Initialize for a new page. */
} else {
depth = tdev->color_info.depth;
}
- if_debug1('L', " plane_height=0x%x", plane_height);
+ if_debug1m('L', mem, " plane_height=0x%x", plane_height);
goto copy;
case cmd_op_copy_color_alpha >> 4:
if (state.color_is_alpha) {
@@ -954,9 +953,9 @@ in: /* Initialize for a new page. */
if (op & 8) { /* Use the current "tile". */
#ifdef DEBUG
if (state_slot->index != state.tile_index) {
- lprintf2("state_slot->index = %d, state.tile_index = %d!\n",
- state_slot->index,
- state.tile_index);
+ mlprintf2(mem, "state_slot->index = %d, state.tile_index = %d!\n",
+ state_slot->index,
+ state.tile_index);
code = gs_note_error(gs_error_ioerror);
goto out;
}
@@ -999,11 +998,11 @@ in: /* Initialize for a new page. */
/* even after decompression if compressed. */
#ifdef DEBUG
if (planes * out_bytes > cbuf_size) {
- lprintf6("bitmap size exceeds buffer! width=%d raster=%d height=%d\n file pos %ld buf pos %d/%d\n",
- state.rect.width, raster,
- state.rect.height,
- stell(s), (int)(cbp - cbuf.data),
- (int)(cbuf.end - cbuf.data));
+ mlprintf6(mem, "bitmap size exceeds buffer! width=%d raster=%d height=%d\n file pos %ld buf pos %d/%d\n",
+ state.rect.width, raster,
+ state.rect.height,
+ stell(s), (int)(cbp - cbuf.data),
+ (int)(cbuf.end - cbuf.data));
code = gs_note_error(gs_error_ioerror);
goto out;
}
@@ -1097,9 +1096,9 @@ in: /* Initialize for a new page. */
}
#ifdef DEBUG
if (gs_debug_c('L')) {
- dprintf2(" depth=%d, data_x=%d\n",
- depth, data_x);
- cmd_print_bits(source, state.rect.width,
+ dmprintf2(mem, " depth=%d, data_x=%d\n",
+ depth, data_x);
+ cmd_print_bits(mem, source, state.rect.width,
state.rect.height, raster);
}
#endif
@@ -1114,9 +1113,9 @@ in: /* Initialize for a new page. */
sti:state_slot =
(tile_slot *) (cdev->chunk.data +
cdev->tile_table[state.tile_index].offset);
- if_debug2('L', " index=%u offset=%lu\n",
- state.tile_index,
- cdev->tile_table[state.tile_index].offset);
+ if_debug2m('L', mem, " index=%u offset=%lu\n",
+ state.tile_index,
+ cdev->tile_table[state.tile_index].offset);
state_tile.data = (byte *) (state_slot + 1);
stp:state_tile.size.x = state_slot->width;
state_tile.size.y = state_slot->height;
@@ -1182,18 +1181,18 @@ set_phase: /*
case cmd_opv_set_fill_adjust:
cmd_get_value(imager_state.fill_adjust.x, cbp);
cmd_get_value(imager_state.fill_adjust.y, cbp);
- if_debug2('L', " (%g,%g)\n",
- fixed2float(imager_state.fill_adjust.x),
- fixed2float(imager_state.fill_adjust.y));
+ if_debug2m('L', mem, " (%g,%g)\n",
+ fixed2float(imager_state.fill_adjust.x),
+ fixed2float(imager_state.fill_adjust.y));
continue;
case cmd_opv_set_ctm:
{
gs_matrix mat;
cbp = cmd_read_matrix(&mat, cbp);
- if_debug6('L', " [%g %g %g %g %g %g]\n",
- mat.xx, mat.xy, mat.yx, mat.yy,
- mat.tx, mat.ty);
+ if_debug6m('L', mem, " [%g %g %g %g %g %g]\n",
+ mat.xx, mat.xy, mat.yx, mat.yy,
+ mat.tx, mat.ty);
mat.tx -= x0;
mat.ty -= y0;
gs_imager_setmatrix(&imager_state, &mat);
@@ -1228,13 +1227,13 @@ set_phase: /*
if (gs_debug_c('L')) {
int i;
- dprintf4(" dot=%g(mode %d) adapt=%d offset=%g [",
+ dmprintf4(mem, " dot=%g(mode %d) adapt=%d offset=%g [",
dot_length,
(nb & 0x40) != 0,
(nb & 0x80) != 0, offset);
for (i = 0; i < n; ++i)
- dprintf1("%g ", dash_pattern[i]);
- dputs("]\n");
+ dmprintf1(mem, "%g ", dash_pattern[i]);
+ dmputs(mem, "]\n");
}
#endif
cbp += n * sizeof(float);
@@ -1243,18 +1242,18 @@ set_phase: /*
case cmd_opv_enable_clip:
pcpath = (use_clip ? &clip_path : NULL);
clipper_dev_open = false;
- if_debug0('L', "\n");
+ if_debug0m('L', mem, "\n");
break;
case cmd_opv_disable_clip:
pcpath = NULL;
clipper_dev_open = false;
- if_debug0('L', "\n");
+ if_debug0m('L', mem, "\n");
break;
case cmd_opv_begin_clip:
pcpath = NULL;
clipper_dev_open = false;
in_clip = true;
- if_debug0('L', "\n");
+ if_debug0m('L', mem, "\n");
code = gx_cpath_reset(&clip_path);
if (code < 0)
goto out;
@@ -1270,7 +1269,7 @@ set_phase: /*
imager_state.log_op = lop_default;
break;
case cmd_opv_end_clip:
- if_debug0('L', "\n");
+ if_debug0m('L', mem, "\n");
gx_cpath_accum_end(&clip_accum, &clip_path);
tdev = target;
/*
@@ -1313,13 +1312,13 @@ set_phase: /*
cbp = cmd_read_rect(op & 0xf0, &state.rect, cbp);
if (dev_color.type != gx_dc_type_devn) {
- if_debug0('L', "hl rect fill without devn color\n");
+ if_debug0m('L', mem, "hl rect fill without devn color\n");
code = gs_note_error(gs_error_typecheck);
goto out;
}
- if_debug4('L', " x=%d y=%d w=%d h=%d\n",
- state.rect.x, state.rect.y,
- state.rect.width,state.rect.height);
+ if_debug4m('L', mem, " x=%d y=%d w=%d h=%d\n",
+ state.rect.x, state.rect.y,
+ state.rect.width,state.rect.height);
rect_hl.p.x = int2fixed(state.rect.x - x0);
rect_hl.p.y = int2fixed(state.rect.y - y0);
rect_hl.q.x = int2fixed(state.rect.width) + rect_hl.p.x;
@@ -1344,9 +1343,9 @@ set_phase: /*
image_rect.q.x = image.d.Width - diff;
cmd_getw(diff, cbp);
image_rect.q.y = image.d.Height - diff;
- if_debug4('L', " rect=(%d,%d),(%d,%d)",
- image_rect.p.x, image_rect.p.y,
- image_rect.q.x, image_rect.q.y);
+ if_debug4m('L', mem, " rect=(%d,%d),(%d,%d)",
+ image_rect.p.x, image_rect.p.y,
+ image_rect.q.x, image_rect.q.y);
}
goto ibegin;
case cmd_opv_begin_image:
@@ -1359,9 +1358,9 @@ set_phase: /*
image_rect.p.y = 0;
image_rect.q.x = image.d.Width;
image_rect.q.y = image.d.Height;
- if_debug2('L', " size=(%d,%d)",
+ if_debug2m('L', mem, " size=(%d,%d)",
image.d.Width, image.d.Height);
-ibegin: if_debug0('L', "\n");
+ibegin: if_debug0m('L', mem, "\n");
{
/* Processing an image operation */
dev_proc(tdev, set_graphics_type_tag)(tdev, GS_IMAGE_TAG);
@@ -1377,7 +1376,7 @@ ibegin: if_debug0('L', "\n");
case cmd_opv_image_plane_data:
cmd_getw(data_height, cbp);
if (data_height == 0) {
- if_debug0('L', " done image\n");
+ if_debug0m('L', mem, " done image\n");
code = gx_image_end(image_info, true);
if (code < 0)
goto out;
@@ -1412,7 +1411,7 @@ ibegin: if_debug0('L', "\n");
case cmd_opv_image_data:
cmd_getw(data_height, cbp);
if (data_height == 0) {
- if_debug0('L', " done image\n");
+ if_debug0m('L', mem, " done image\n");
code = gx_image_end(image_info, true);
if (code < 0)
goto out;
@@ -1423,8 +1422,8 @@ ibegin: if_debug0('L', "\n");
int plane;
cmd_getw(bytes_per_plane, cbp);
- if_debug2('L', " height=%u raster=%u\n",
- data_height, bytes_per_plane);
+ if_debug2m('L', mem, " height=%u raster=%u\n",
+ data_height, bytes_per_plane);
for (plane = 0;
plane < image_info->num_planes;
++plane
@@ -1498,7 +1497,8 @@ idata: data_size = 0;
for (plane = 0; plane < image_info->num_planes;
++plane)
if (planes[plane].data != 0)
- cmd_print_bits(planes[plane].data,
+ cmd_print_bits(mem,
+ planes[plane].data,
image_rect.q.x -
image_rect.p.x,
data_height,
@@ -1531,7 +1531,7 @@ idata: data_size = 0;
goto out;
break;
case cmd_opv_ext_create_compositor:
- if_debug0('L', " ext_create_compositor\n");
+ if_debug0m('L', mem, " ext_create_compositor\n");
cbuf.ptr = cbp;
/*
* The screen phase may have been changed during
@@ -1695,7 +1695,7 @@ idata: data_size = 0;
{
uint ht_size;
- if_debug0('L', " ext_put_halftone\n");
+ if_debug0m('L', mem, " ext_put_halftone\n");
enc_u_getw(ht_size, cbp);
code = read_alloc_ht_buff(&ht_buff, ht_size, mem);
if (code < 0)
@@ -1703,7 +1703,7 @@ idata: data_size = 0;
}
break;
case cmd_opv_ext_put_ht_seg:
- if_debug0('L', " ext_put_ht_seg\n");
+ if_debug0m('L', mem, " ext_put_ht_seg\n");
cbuf.ptr = cbp;
code = read_ht_segment(&ht_buff, &cbuf,
&imager_state, tdev,
@@ -1714,18 +1714,18 @@ idata: data_size = 0;
break;
case cmd_opv_ext_set_color_is_devn:
state.color_is_devn = true;
- if_debug0('L', " ext_set_color_is_devn\n");
+ if_debug0m('L', mem, " ext_set_color_is_devn\n");
break;
case cmd_opv_ext_unset_color_is_devn:
state.color_is_devn = false;
- if_debug0('L', " ext_unset_color_is_devn\n");
+ if_debug0m('L', mem, " ext_unset_color_is_devn\n");
break;
case cmd_opv_ext_tile_rect_hl:
/* Strip tile with devn colors */
cbp = cmd_read_rect(op & 0xf0, &state.rect, cbp);
- if_debug4('L', " x=%d y=%d w=%d h=%d\n",
- state.rect.x, state.rect.y,
- state.rect.width,state.rect.height);
+ if_debug4m('L', mem, " x=%d y=%d w=%d h=%d\n",
+ state.rect.x, state.rect.y,
+ state.rect.width,state.rect.height);
code = (*dev_proc(tdev, strip_tile_rect_devn))
(tdev, &state_tile,
state.rect.x - x0, state.rect.y - y0,
@@ -1749,7 +1749,7 @@ idata: data_size = 0;
byte type_and_flag = *cbp++;
byte is_continuation = type_and_flag & 0x80;
- if_debug0('L', " cmd_opv_ext_put_drawing_color\n");
+ if_debug0m('L', mem, " cmd_opv_ext_put_drawing_color\n");
pdct = gx_get_dc_type_from_index(type_and_flag & 0x7F);
if (pdct == 0) {
code = gs_note_error(gs_error_rangecheck);
@@ -1810,8 +1810,8 @@ idata: data_size = 0;
if (!in_path) {
ppos.x = int2fixed(state.rect.x);
ppos.y = int2fixed(state.rect.y);
- if_debug2('L', " (%d,%d)", state.rect.x,
- state.rect.y);
+ if_debug2m('L', mem, " (%d,%d)", state.rect.x,
+ state.rect.y);
notes = sn_none;
in_path = true;
}
@@ -1825,7 +1825,7 @@ idata: data_size = 0;
vs[i++] =
((fixed) ((b ^ 0x20) - 0x20) << 13) +
((int)cbp[1] << 5) + (cbp[2] >> 3);
- if_debug1('L', " %g", fixed2float(vs[i - 1]));
+ if_debug1m('L', mem, " %g", fixed2float(vs[i - 1]));
cbp += 2;
v = (int)((*cbp & 7) ^ 4) - 4;
break;
@@ -1848,7 +1848,7 @@ idata: data_size = 0;
v = (b ^ 0xd0) - 0x10;
vs[i] =
((v << 8) + cbp[1]) << (_fixed_shift - 2);
- if_debug1('L', " %g", fixed2float(vs[i]));
+ if_debug1m('L', mem, " %g", fixed2float(vs[i]));
cbp += 2;
continue;
default /*case 7 */ :
@@ -1862,9 +1862,9 @@ idata: data_size = 0;
/* the Borland C++ 4.5 compiler incorrectly */
/* sign-extends the result of the shift. */
vs[i] = (v << 16) + (uint) (cbp[-2] << 8) + cbp[-1];
- if_debug1('L', " %g", fixed2float(vs[i]));
+ if_debug1m('L', mem, " %g", fixed2float(vs[i]));
}
- if_debug0('L', "\n");
+ if_debug0m('L', mem, "\n");
code = clist_decode_segment(&path, op, vs, &ppos,
x0, y0, notes);
if (code < 0)
@@ -1881,7 +1881,7 @@ idata: data_size = 0;
ppath = &path;
- if_debug0('L', "\n");
+ if_debug0m('L', mem, "\n");
/* if in clip, flatten path first */
if (in_clip) {
gx_path_init_local(&fpath, mem);
@@ -2077,14 +2077,14 @@ idata: data_size = 0;
goto out;
continue;
default:
- bad_op:lprintf5("Bad op %02x band y0 = %d file pos %ld buf pos %d/%d\n",
+ bad_op:mlprintf5(mem, "Bad op %02x band y0 = %d file pos %ld buf pos %d/%d\n",
op, y0, stell(s), (int)(cbp - cbuf.data), (int)(cbuf.end - cbuf.data));
{
const byte *pp;
for (pp = cbuf.data; pp < cbuf.end; pp += 10) {
- dlprintf1("%4d:", (int)(pp - cbuf.data));
- dprintf10(" %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
+ dmlprintf1(mem, "%4d:", (int)(pp - cbuf.data));
+ dmprintf10(mem, " %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
pp[0], pp[1], pp[2], pp[3], pp[4],
pp[5], pp[6], pp[7], pp[8], pp[9]);
}
@@ -2092,7 +2092,7 @@ idata: data_size = 0;
code = gs_note_error(gs_error_Fatal);
goto out;
}
- if_debug4('L', " x=%d y=%d w=%d h=%d\n",
+ if_debug4m('L', mem, " x=%d y=%d w=%d h=%d\n",
state.rect.x, state.rect.y, state.rect.width,
state.rect.height);
switch (op >> 4) {
@@ -2380,7 +2380,7 @@ read_set_bits(command_buf_t *pcb, tile_slot *bits, int compress,
cmd_getw(index, cbp);
cmd_getw(offset, cbp);
- if_debug2('L', " index=%d offset=%lu\n", pcls->tile_index, offset);
+ if_debug2m('L', mem, " index=%d offset=%lu\n", pcls->tile_index, offset);
pcls->tile_index = index;
cdev->tile_table[pcls->tile_index].offset = offset;
slot = (tile_slot *)(cdev->chunk.data + offset);
@@ -2476,7 +2476,7 @@ read_set_bits(command_buf_t *pcb, tile_slot *bits, int compress,
bits->height);
#ifdef DEBUG
if (gs_debug_c('L'))
- cmd_print_bits(data, bits->width, bits->height, bits->cb_raster);
+ cmd_print_bits(mem, data, bits->width, bits->height, bits->cb_raster);
#endif
pcb->ptr = cbp;
return 0;
@@ -2578,39 +2578,39 @@ read_set_misc2(command_buf_t *pcb, gs_imager_state *pis, segment_notes *pnotes)
cb = *cbp++;
pis->line_params.start_cap = (gs_line_cap)((cb >> 3) & 7);
pis->line_params.join = (gs_line_join)(cb & 7);
- if_debug2('L', " start_cap=%d join=%d\n",
- pis->line_params.start_cap, pis->line_params.join);
+ if_debug2m('L', pis->memory, " start_cap=%d join=%d\n",
+ pis->line_params.start_cap, pis->line_params.join);
cb = *cbp++;
pis->line_params.end_cap = (gs_line_cap)((cb >> 3) & 7);
pis->line_params.dash_cap = (gs_line_cap)(cb & 7);
- if_debug2('L', "end_cap=%d dash_cap=%d\n",
- pis->line_params.end_cap, pis->line_params.dash_cap);
+ if_debug2m('L', pis->memory, "end_cap=%d dash_cap=%d\n",
+ pis->line_params.end_cap, pis->line_params.dash_cap);
}
if (mask & cj_ac_sa_known) {
cb = *cbp++;
pis->line_params.curve_join = ((cb >> 2) & 7) - 1;
pis->accurate_curves = (cb & 2) != 0;
pis->stroke_adjust = cb & 1;
- if_debug3('L', " CJ=%d AC=%d SA=%d\n",
- pis->line_params.curve_join, pis->accurate_curves,
- pis->stroke_adjust);
+ if_debug3m('L', pis->memory, " CJ=%d AC=%d SA=%d\n",
+ pis->line_params.curve_join, pis->accurate_curves,
+ pis->stroke_adjust);
}
if (mask & flatness_known) {
cmd_get_value(pis->flatness, cbp);
- if_debug1('L', " flatness=%g\n", pis->flatness);
+ if_debug1m('L', pis->memory, " flatness=%g\n", pis->flatness);
}
if (mask & line_width_known) {
float width;
cmd_get_value(width, cbp);
- if_debug1('L', " line_width=%g\n", width);
+ if_debug1m('L', pis->memory, " line_width=%g\n", width);
gx_set_line_width(&pis->line_params, width);
}
if (mask & miter_limit_known) {
float limit;
cmd_get_value(limit, cbp);
- if_debug1('L', " miter_limit=%g\n", limit);
+ if_debug1m('L', pis->memory, " miter_limit=%g\n", limit);
gx_set_miter_limit(&pis->line_params, limit);
}
if (mask & op_bm_tk_known) {
@@ -2623,26 +2623,26 @@ read_set_misc2(command_buf_t *pcb, gs_imager_state *pis, segment_notes *pnotes)
pis->overprint = cb & 1;
cb = *cbp++;
pis->renderingintent = cb;
- if_debug5('L', " BM=%d TK=%d OPM=%d OP=%d RI=%d\n",
- pis->blend_mode, pis->text_knockout, pis->overprint_mode,
- pis->overprint, pis->renderingintent);
+ if_debug5m('L', pis->memory, " BM=%d TK=%d OPM=%d OP=%d RI=%d\n",
+ pis->blend_mode, pis->text_knockout, pis->overprint_mode,
+ pis->overprint, pis->renderingintent);
}
if (mask & segment_notes_known) {
cb = *cbp++;
*pnotes = (segment_notes)(cb & 0x3f);
- if_debug1('L', " notes=%d\n", *pnotes);
+ if_debug1m('L', pis->memory, " notes=%d\n", *pnotes);
}
if (mask & opacity_alpha_known) {
cmd_get_value(pis->opacity.alpha, cbp);
- if_debug1('L', " opacity.alpha=%g\n", pis->opacity.alpha);
+ if_debug1m('L', pis->memory, " opacity.alpha=%g\n", pis->opacity.alpha);
}
if (mask & shape_alpha_known) {
cmd_get_value(pis->shape.alpha, cbp);
- if_debug1('L', " shape.alpha=%g\n", pis->shape.alpha);
+ if_debug1m('L', pis->memory, " shape.alpha=%g\n", pis->shape.alpha);
}
if (mask & alpha_known) {
cmd_get_value(pis->alpha, cbp);
- if_debug1('L', " alpha=%u\n", pis->alpha);
+ if_debug1m('L', pis->memory, " alpha=%u\n", pis->alpha);
}
pcb->ptr = cbp;
return 0;
@@ -2661,9 +2661,9 @@ read_set_color_space(command_buf_t *pcb, gs_imager_state *pis,
cmm_profile_t *picc_profile;
clist_icc_color_t icc_information;
- if_debug3('L', " %d%s%s\n", index,
- (b & 8 ? " (indexed)" : ""),
- (b & 4 ? "(proc)" : ""));
+ if_debug3m('L', mem, " %d%s%s\n", index,
+ (b & 8 ? " (indexed)" : ""),
+ (b & 4 ? "(proc)" : ""));
/* They all store the ICC information. Even if it is NULL
it is used in the ICC case to avoid reading from the
serialized profile data which is stored elsewhere in the
@@ -2801,7 +2801,7 @@ read_put_params(command_buf_t *pcb, gs_imager_state *pis,
int code;
cmd_get_value(param_length, cbp);
- if_debug1('L', " length=%d\n", param_length);
+ if_debug1m('L', mem, " length=%d\n", param_length);
if (param_length == 0) {
code = 1; /* empty list */
goto out;
@@ -3044,7 +3044,7 @@ cmd_select_map(cmd_map_index map_index, cmd_map_contents cont,
*pcomp_num = NULL; /* Only used for color transfer maps */
switch (map_index) {
case cmd_map_transfer:
- if_debug0('L', " transfer");
+ if_debug0m('L', mem, " transfer");
rc_unshare_struct(pis->set_transfer.gray, gx_transfer_map,
&st_transfer_map, mem, return_error(gs_error_VMerror),
"cmd_select_map(default_transfer)");
@@ -3075,7 +3075,7 @@ cmd_select_map(cmd_map_index map_index, cmd_map_contents cont,
case cmd_map_transfer_3:
pmap = &pis->set_transfer.gray;
*pcomp_num = &pis->set_transfer.gray_component_num;
-transfer1: if_debug1('L', " transfer[%d]", (int)(map_index - cmd_map_transfer_0));
+transfer1: if_debug1m('L', mem, " transfer[%d]", (int)(map_index - cmd_map_transfer_0));
rc_unshare_struct(*pmap, gx_transfer_map, &st_transfer_map, mem,
return_error(gs_error_VMerror), "cmd_select_map(transfer)");
map = *pmap;
@@ -3088,12 +3088,12 @@ transfer2: if (cont != cmd_map_other) {
}
break;
case cmd_map_black_generation:
- if_debug0('L', " black generation");
+ if_debug0m('L', mem, " black generation");
pmap = &pis->black_generation;
cname = "cmd_select_map(black generation)";
goto alloc;
case cmd_map_undercolor_removal:
- if_debug0('L', " undercolor removal");
+ if_debug0m('L', mem, " undercolor removal");
pmap = &pis->undercolor_removal;
cname = "cmd_select_map(undercolor removal)";
alloc: if (cont == cmd_map_none) {
diff --git a/gs/base/gxclread.c b/gs/base/gxclread.c
index 2d66fb16f..65cfd1d1e 100644
--- a/gs/base/gxclread.c
+++ b/gs/base/gxclread.c
@@ -198,12 +198,12 @@ rb:
ss->offset_map_length++;
}
# endif
- if_debug7('l',
- "[l]reading for bands (%d,%d) at bfile %ld, cfile %ld, length %u color %d rop %d\n",
- bmin, bmax,
- (long)(io_procs->ftell(bfile) - sizeof(ss->b_this)), /* stefan foo was: 2 * sizeof ?? */
- (long)pos, left, ss->b_this.band_complexity.uses_color,
- ss->b_this.band_complexity.nontrivial_rops);
+ if_debug7m('l', st->memory,
+ "[l]reading for bands (%d,%d) at bfile %ld, cfile %ld, length %u color %d rop %d\n",
+ bmin, bmax,
+ (long)(io_procs->ftell(bfile) - sizeof(ss->b_this)), /* stefan foo was: 2 * sizeof ?? */
+ (long)pos, left, ss->b_this.band_complexity.uses_color,
+ ss->b_this.band_complexity.nontrivial_rops);
}
}
pw->ptr = q;
@@ -739,7 +739,7 @@ clist_render_rectangle(gx_device_clist *cldev, const gs_int_rect *prect,
crdev->yplane = *render_plane;
else
crdev->yplane.index = -1;
- if_debug2('l', "[l]rendering bands (%d,%d)\n", band_first, band_last);
+ if_debug2m('l', bdev->memory, "[l]rendering bands (%d,%d)\n", band_first, band_last);
#if 0 /* Disabled because it is slow and appears to have no useful effect. */
if (clear)
dev_proc(bdev, fill_rectangle)
diff --git a/gs/base/gxclrect.c b/gs/base/gxclrect.c
index 6e3289089..0b360a83d 100644
--- a/gs/base/gxclrect.c
+++ b/gs/base/gxclrect.c
@@ -70,8 +70,9 @@ cmd_write_rect_hl_cmd(gx_device_clist_writer * cldev, gx_clist_state * pcls,
}
if (code < 0)
return code;
- if_debug5('L', "rect hl r%d:%d,%d,%d,%d\n",
- rcsize - 1, pcls->rect.x, pcls->rect.y, pcls->rect.width, pcls->rect.height);
+ if_debug5m('L', cldev->memory, "rect hl r%d:%d,%d,%d,%d\n",
+ rcsize - 1, pcls->rect.x, pcls->rect.y,
+ pcls->rect.width, pcls->rect.height);
cmd_put_rect(&pcls->rect, dp);
return 0;
}
@@ -124,14 +125,14 @@ cmd_write_rect_cmd(gx_device_clist_writer * cldev, gx_clist_state * pcls,
code = set_cmd_put_op(dp, cldev, pcls, op + 0x10, 3);
if (code < 0)
return code;
- if_debug3('L', " rs2:%d,%d,0,%d\n",
- dx, dwidth, dheight);
+ if_debug3m('L', cldev->memory, " rs2:%d,%d,0,%d\n",
+ dx, dwidth, dheight);
} else {
code = set_cmd_put_op(dp, cldev, pcls, op + 0x10, 5);
if (code < 0)
return code;
- if_debug4('L', " rs4:%d,%d,%d,%d\n",
- dx, dwidth, dy, dheight);
+ if_debug4m('L', cldev->memory, " rs4:%d,%d,%d,%d\n",
+ dx, dwidth, dy, dheight);
dp[3] = dy - rmin;
dp[4] = dheight - rmin;
}
@@ -157,8 +158,8 @@ cmd_write_rect_cmd(gx_device_clist_writer * cldev, gx_clist_state * pcls,
code = set_cmd_put_op(dp, cldev, pcls, op, rcsize);
if (code < 0)
return code;
- if_debug5('L', " r%d:%d,%d,%d,%d\n",
- rcsize - 1, dx, dwidth, dy, dheight);
+ if_debug5m('L', cldev->memory, " r%d:%d,%d,%d,%d\n",
+ rcsize - 1, dx, dwidth, dy, dheight);
cmd_put_rect(&pcls->rect, dp + 1);
}
return 0;
@@ -178,7 +179,7 @@ cmd_write_page_rect_cmd(gx_device_clist_writer * cldev, int op)
gx_clist_state *pcls1;
int code;
- if_debug0('L', "[L]fillpage beg\n");
+ if_debug0m('L', cldev->memory, "[L]fillpage beg\n");
code = set_cmd_put_all_op(dp, cldev, op, rcsize);
if (code < 0)
return code;
@@ -189,7 +190,7 @@ cmd_write_page_rect_cmd(gx_device_clist_writer * cldev, int op)
cmd_putw(0, dp);
cmd_putw(0, dp);
cmd_putw(0, dp);
- if_debug0('L', "[L]fillpage end\n");
+ if_debug0m('L', cldev->memory, "[L]fillpage end\n");
return 0;
}
@@ -274,10 +275,10 @@ cmd_write_trapezoid_cmd(gx_device_clist_writer * cldev, gx_clist_state * pcls,
cmd_putw(ybot, dp);
cmd_putw(ytop, dp);
}
- if_debug6('L', " t%d:%ld,%ld,%ld,%ld %ld\n",
- rcsize - 1, left->start.x, left->start.y, left->end.x, left->end.y, ybot);
- if_debug6('L', " t%ld,%ld,%ld,%ld %ld o=%d\n",
- right->start.x, right->start.y, right->end.x, right->end.y, ytop, options);
+ if_debug6m('L', cldev->memory, " t%d:%ld,%ld,%ld,%ld %ld\n",
+ rcsize - 1, left->start.x, left->start.y, left->end.x, left->end.y, ybot);
+ if_debug6m('L', cldev->memory, " t%ld,%ld,%ld,%ld %ld o=%d\n",
+ right->start.x, right->start.y, right->end.x, right->end.y, ytop, options);
if (options & 2) {
cmd_putw(fa->clip->p.x, dp);
cmd_putw(fa->clip->p.y, dp);
@@ -838,10 +839,10 @@ copy:{
}
op += compress;
if (dx) {
- *dp++ = cmd_count_op(cmd_opv_set_misc, 2);
+ *dp++ = cmd_count_op(cmd_opv_set_misc, 2, dev->memory);
*dp++ = cmd_set_misc_data_x + dx;
}
- *dp++ = cmd_count_op(op, csize);
+ *dp++ = cmd_count_op(op, csize, dev->memory);
/* Store the plane_height */
cmd_putw(0, dp);
cmd_put2w(rx, re.y, dp);
@@ -957,10 +958,10 @@ copy:
* cmd_put_bits fill the buffer up. */
dp2 = dp;
if (dx) {
- *dp2++ = cmd_count_op(cmd_opv_set_misc, 2);
+ *dp2++ = cmd_count_op(cmd_opv_set_misc, 2, cdev->memory);
*dp2++ = cmd_set_misc_data_x + dx;
}
- *dp2++ = cmd_count_op(op + code, csize);
+ *dp2++ = cmd_count_op(op + code, csize, cdev->memory);
cmd_putw(plane_height, dp2);
cmd_put2w(rx, re.y, dp2);
cmd_put2w(w1, re.height, dp2);
@@ -1129,10 +1130,10 @@ copy:{
}
op += compress;
if (dx) {
- *dp++ = cmd_count_op(cmd_opv_set_misc, 2);
+ *dp++ = cmd_count_op(cmd_opv_set_misc, 2, dev->memory);
*dp++ = cmd_set_misc_data_x + dx;
}
- *dp++ = cmd_count_op(op, csize);
+ *dp++ = cmd_count_op(op, csize, dev->memory);
cmd_put2w(rx, re.y, dp);
cmd_put2w(w1, re.height, dp);
re.pcls->rect = rect;
@@ -1271,10 +1272,10 @@ copy:{
}
op += compress;
if (dx) {
- *dp++ = cmd_count_op(cmd_opv_set_misc, 2);
+ *dp++ = cmd_count_op(cmd_opv_set_misc, 2, dev->memory);
*dp++ = cmd_set_misc_data_x + dx;
}
- *dp++ = cmd_count_op(op, csize);
+ *dp++ = cmd_count_op(op, csize, dev->memory);
*dp++ = depth;
cmd_put2w(rx, re.y, dp);
cmd_put2w(w1, re.height, dp);
@@ -1420,10 +1421,10 @@ copy:{
}
op += compress;
if (dx) {
- *dp++ = cmd_count_op(cmd_opv_set_misc, 2);
+ *dp++ = cmd_count_op(cmd_opv_set_misc, 2, dev->memory);
*dp++ = cmd_set_misc_data_x + dx;
}
- *dp++ = cmd_count_op(op, csize);
+ *dp++ = cmd_count_op(op, csize, dev->memory);
*dp++ = depth;
cmd_put2w(rx, re.y, dp);
cmd_put2w(w1, re.height, dp);
diff --git a/gs/base/gxclthrd.c b/gs/base/gxclthrd.c
index ab3d0e967..903d0990f 100644
--- a/gs/base/gxclthrd.c
+++ b/gs/base/gxclthrd.c
@@ -60,7 +60,7 @@ clist_setup_render_threads(gx_device *dev, int y)
crdev->num_render_threads = pdev->num_render_threads_requested;
if(gs_debug[':'] != 0)
- dprintf1("%% %d rendering threads requested.\n", pdev->num_render_threads_requested);
+ dmprintf1(mem, "%% %d rendering threads requested.\n", pdev->num_render_threads_requested);
if (crdev->num_render_threads > band_count)
crdev->num_render_threads = band_count; /* don't bother starting more threads than bands */
@@ -161,10 +161,11 @@ clist_setup_render_threads(gx_device *dev, int y)
if (code < 0) return_error(gs_error_VMerror);
}
ncdev->page_uses_transparency = cdev->page_uses_transparency;
- if_debug3(gs_debug_flag_icc,"[icc] MT clist device = 0x%x profile = 0x%x handle = 0x%x\n",
- ncdev,
- ncdev->icc_struct->device_profile[0],
- ncdev->icc_struct->device_profile[0]->profile_handle);
+ if_debug3m(gs_debug_flag_icc, cdev->memory,
+ "[icc] MT clist device = 0x%x profile = 0x%x handle = 0x%x\n",
+ ncdev,
+ ncdev->icc_struct->device_profile[0],
+ ncdev->icc_struct->device_profile[0]->profile_handle);
/* If the device is_planar, then set the flag in the new_device and the procs */
if ((ncdev->is_planar = cdev->is_planar))
gdev_prn_set_procs_planar(ndev);
@@ -273,7 +274,7 @@ clist_setup_render_threads(gx_device *dev, int y)
crdev->next_band = band;
if(gs_debug[':'] != 0)
- dprintf1("%% Using %d rendering threads\n", i);
+ dmprintf1(mem, "%% Using %d rendering threads\n", i);
return 0;
}
@@ -325,10 +326,10 @@ clist_teardown_render_threads(gx_device *dev)
gs_free_object(thread->memory, thread_cdev, "clist_teardown_render_threads");
#ifdef DEBUG
if (gs_debug[':'])
- dprintf2("%% Thread %d total usertime=%ld msec\n", i, thread->cputime);
- dprintf1("\nthread: %d ending memory state...\n", i);
+ dmprintf2(mem, "%% Thread %d total usertime=%ld msec\n", i, thread->cputime);
+ dmprintf1(thread->memory, "\nthread: %d ending memory state...\n", i);
gs_memory_chunk_dump_memory(thread->memory);
- dprintf(" memory dump done.\n");
+ dmprintf(thread->memory, " memory dump done.\n");
#endif
gs_memory_chunk_release(thread->memory);
diff --git a/gs/base/gxclutil.c b/gs/base/gxclutil.c
index dd710a620..a2a2640ae 100644
--- a/gs/base/gxclutil.c
+++ b/gs/base/gxclutil.c
@@ -54,7 +54,7 @@ struct stats_cmd_s {
} stats_cmd;
extern ulong stats_cmd_diffs[5]; /* in gxclpath.c */
int
-cmd_count_op(int op, uint size)
+cmd_count_op(int op, uint size,const gs_memory_t *mem)
{
stats_cmd.op_counts[op]++;
stats_cmd.op_sizes[op] += size;
@@ -62,11 +62,11 @@ cmd_count_op(int op, uint size)
const char *const *sub = cmd_sub_op_names[op >> 4];
if (sub)
- dlprintf2(", %s(%u)\n", sub[op & 0xf], size);
+ dmlprintf2(mem, ", %s(%u)\n", sub[op & 0xf], size);
else
- dlprintf3(", %s %d(%u)\n", cmd_op_names[op >> 4], op & 0xf,
+ dmlprintf3(mem, ", %s %d(%u)\n", cmd_op_names[op >> 4], op & 0xf,
size);
- dflush();
+ dmflush(mem);
}
return op;
}
@@ -81,25 +81,25 @@ cmd_uncount_op(int op, uint size)
/* Print statistics. */
#ifdef DEBUG
void
-cmd_print_stats(void)
+cmd_print_stats(const gs_memory_t *mem)
{
int ci, cj;
- dlprintf3("[l]counts: reset = %lu, found = %lu, added = %lu\n",
+ dmlprintf3(mem, "[l]counts: reset = %lu, found = %lu, added = %lu\n",
stats_cmd.tile_reset, stats_cmd.tile_found,
stats_cmd.tile_added);
- dlprintf5(" diff 2.5 = %lu, 3 = %lu, 4 = %lu, 2 = %lu, >4 = %lu\n",
+ dmlprintf5(mem, " diff 2.5 = %lu, 3 = %lu, 4 = %lu, 2 = %lu, >4 = %lu\n",
stats_cmd_diffs[0], stats_cmd_diffs[1], stats_cmd_diffs[2],
stats_cmd_diffs[3], stats_cmd_diffs[4]);
- dlprintf2(" same_band = %lu, other_band = %lu\n",
+ dmlprintf2(mem, " same_band = %lu, other_band = %lu\n",
stats_cmd.same_band, stats_cmd.other_band);
for (ci = 0; ci < 0x100; ci += 0x10) {
const char *const *sub = cmd_sub_op_names[ci >> 4];
if (sub != 0) {
- dlprintf1("[l] %s =", cmd_op_names[ci >> 4]);
+ dmlprintf1(mem, "[l] %s =", cmd_op_names[ci >> 4]);
for (cj = ci; cj < ci + 0x10; cj += 2)
- dprintf6("\n\t%s = %lu(%lu), %s = %lu(%lu)",
+ dmprintf6(mem, "\n\t%s = %lu(%lu), %s = %lu(%lu)",
sub[cj - ci],
stats_cmd.op_counts[cj], stats_cmd.op_sizes[cj],
sub[cj - ci + 1],
@@ -110,16 +110,16 @@ cmd_print_stats(void)
for (cj = ci; cj < ci + 0x10; cj++)
tcounts += stats_cmd.op_counts[cj],
tsizes += stats_cmd.op_sizes[cj];
- dlprintf3("[l] %s (%lu,%lu) =\n\t",
+ dmlprintf3(mem, "[l] %s (%lu,%lu) =\n\t",
cmd_op_names[ci >> 4], tcounts, tsizes);
for (cj = ci; cj < ci + 0x10; cj++)
if (stats_cmd.op_counts[cj] == 0)
- dputs(" -");
+ dmputs(mem, " -");
else
- dprintf2(" %lu(%lu)", stats_cmd.op_counts[cj],
+ dmprintf2(mem, " %lu(%lu)", stats_cmd.op_counts[cj],
stats_cmd.op_sizes[cj]);
}
- dputs("\n");
+ dmputs(mem, "\n");
}
}
#endif /* DEBUG */
@@ -139,7 +139,7 @@ cmd_write_band(gx_device_clist_writer * cldev, int band_min, int band_max,
clist_file_ptr cfile = cldev->page_cfile;
clist_file_ptr bfile = cldev->page_bfile;
cmd_block cb;
- byte end = cmd_count_op(cmd_end, 1);
+ byte end = cmd_count_op(cmd_end, 1, cldev->memory);
if (cfile == 0 || bfile == 0)
return_error(gs_error_ioerror);
@@ -147,8 +147,8 @@ cmd_write_band(gx_device_clist_writer * cldev, int band_min, int band_max,
cb.band_max = band_max;
cb.pos = cldev->page_info.io_procs->ftell(cfile);
clist_copy_band_complexity(&cb.band_complexity, band_complexity);
- if_debug4('l', "[l]writing for bands (%d,%d) at %ld K %d \n",
- band_min, band_max, (long)cb.pos, cb.band_complexity.uses_color);
+ if_debug4m('l', cldev->memory, "[l]writing for bands (%d,%d) at %ld K %d \n",
+ band_min, band_max, (long)cb.pos, cb.band_complexity.uses_color);
cldev->page_info.io_procs->fwrite_chars(&cb, sizeof(cb), bfile);
if (cp != 0) {
pcl->tail->next = 0; /* terminate the list */
@@ -158,12 +158,12 @@ cmd_write_band(gx_device_clist_writer * cldev, int band_min, int band_max,
(const byte *)cp >= cldev->cend ||
cp->size > cldev->cend - (const byte *)cp
) {
- lprintf1("cmd_write_band error at 0x%lx\n", (ulong) cp);
+ mlprintf1(cldev->memory, "cmd_write_band error at 0x%lx\n", (ulong) cp);
return_error(gs_error_Fatal);
}
#endif
- if_debug2('L',"[L]Wrote cmd id=%ld at %ld\n", cp->id,
- (long)cldev->page_info.io_procs->ftell(cfile));
+ if_debug2m('L', cldev->memory, "[L]Wrote cmd id=%ld at %ld\n",
+ cp->id, (long)cldev->page_info.io_procs->ftell(cfile));
cldev->page_info.io_procs->fwrite_chars(cp + 1, cp->size, cfile);
}
pcl->head = pcl->tail = 0;
@@ -207,16 +207,16 @@ cmd_write_icctable(gx_device_clist_writer * cldev, unsigned char *pbuf, int data
cb.band_max = band;
cb.pos = cldev->page_info.io_procs->ftell(cfile);
- if_debug2('l', "[l]writing icc table band %d cb pos %ld\n",
- band, (long)cb.pos);
+ if_debug2m('l', cldev->memory, "[l]writing icc table band %d cb pos %ld\n",
+ band, (long)cb.pos);
cldev->page_info.io_procs->fwrite_chars(&cb, sizeof(cb), bfile);
/* Now store the ICC table information in the cfile */
/* Do I need to worry about having enough room here? */
- if_debug1('l', "[l]writing icc table in cfile at %ld\n",
- (long)cldev->page_info.io_procs->ftell(cfile));
+ if_debug1m('l', cldev->memory, "[l]writing icc table in cfile at %ld\n",
+ (long)cldev->page_info.io_procs->ftell(cfile));
cldev->page_info.io_procs->fwrite_chars(pbuf, data_size, cfile);
@@ -261,7 +261,7 @@ cmd_write_buffer(gx_device_clist_writer * cldev, byte cmd_end)
cldev->ccl = 0;
#ifdef DEBUG
if (gs_debug_c('l'))
- cmd_print_stats();
+ cmd_print_stats(cldev->memory);
#endif
return_check_interrupt(cldev->memory, code != 0 ? code : warning);
}
@@ -302,7 +302,8 @@ cmd_put_list_op(gx_device_clist_writer * cldev, cmd_list * pcl, uint size)
lprintf1("cmd_put_list_op error at 0x%lx\n", (ulong) pcl->tail);
}
#endif
- if_debug2('L', ", to id=%ld , offset=%ld", pcl->tail->id, (long)pcl->tail->size);
+ if_debug2m('L', cldev->memory, ", to id=%ld , offset=%ld",
+ pcl->tail->id, (long)pcl->tail->size);
pcl->tail->size += size;
} else {
/* Skip to an appropriate alignment boundary. */
@@ -328,7 +329,7 @@ cmd_put_list_op(gx_device_clist_writer * cldev, cmd_list * pcl, uint size)
cldev->ccl = pcl;
cp->size = size;
cp->id = cldev->ins_count;
- if_debug1('L', ", id=%ld ", cldev->ins_count);
+ if_debug1m('L', cldev->memory, ", id=%ld ", cldev->ins_count);
cldev->ins_count++;
}
cldev->cnext = dp + size;
@@ -355,9 +356,9 @@ cmd_get_buffer_space(gx_device_clist_writer * cldev, gx_clist_state * pcls, uint
byte *
cmd_put_op(gx_device_clist_writer * cldev, gx_clist_state * pcls, uint size)
{
- if_debug3('L', "[L]band %d: size=%u, left=%u",
- (int)(pcls - cldev->states),
- size, 0);
+ if_debug3m('L', cldev->memory, "[L]band %d: size=%u, left=%u",
+ (int)(pcls - cldev->states),
+ size, 0);
return cmd_put_list_op(cldev, &pcls->list, size);
}
#endif
@@ -367,8 +368,8 @@ byte *
cmd_put_range_op(gx_device_clist_writer * cldev, int band_min, int band_max,
uint size)
{
- if_debug4('L', "[L]band range(%d,%d): size=%u, left=%u",
- band_min, band_max, size, 0);
+ if_debug4m('L', cldev->memory, "[L]band range(%d,%d): size=%u, left=%u",
+ band_min, band_max, size, 0);
if (cldev->ccl != 0 &&
(cldev->ccl != &cldev->band_range_list ||
band_min != cldev->band_range_min ||
@@ -756,7 +757,7 @@ cmd_put_params(gx_device_clist_writer *cldev,
return code;
/* write param list to cmd list: needs to all fit in cmd buffer */
- if_debug1('l', "[l]put_params, length=%d\n", param_length);
+ if_debug1m('l', cldev->memory, "[l]put_params, length=%d\n", param_length);
dp[1] = cmd_opv_ext_put_params;
dp += 2;
memcpy(dp, &param_length, sizeof(unsigned));
diff --git a/gs/base/gxcmap.c b/gs/base/gxcmap.c
index 5b089cddc..6df7595a8 100644
--- a/gs/base/gxcmap.c
+++ b/gs/base/gxcmap.c
@@ -62,7 +62,7 @@ gx_default_encode_color(gx_device * dev, const gx_color_value cv[])
#ifdef DEBUG
if ( dev->color_info.separable_and_linear != GX_CINFO_SEP_LIN ) {
- dprintf( "gx_default_encode_color() requires separable and linear\n" );
+ dmprintf(dev->memory, "gx_default_encode_color() requires separable and linear\n" );
return gx_no_color_index;
}
#endif
@@ -91,7 +91,7 @@ gx_default_decode_color(gx_device * dev, gx_color_index color, gx_color_value cv
#ifdef DEBUG
if ( dev->color_info.separable_and_linear != GX_CINFO_SEP_LIN ) {
- dprintf( "gx_default_decode_color() requires separable and linear\n" );
+ dmprintf(dev->memory, "gx_default_decode_color() requires separable and linear\n" );
return gs_error_rangecheck;
}
#endif
@@ -124,7 +124,7 @@ gx_error_encode_color(gx_device * dev, const gx_color_value colors[])
#ifdef DEBUG
/* The "null" device is expected to be missing encode_color */
if (strcmp(dev->dname, "null") != 0)
- dprintf("No encode_color proc defined for device.\n");
+ dmprintf(dev->memory, "No encode_color proc defined for device.\n");
#endif
return gx_no_color_index;
}
@@ -135,7 +135,7 @@ gx_error_decode_color(gx_device * dev, gx_color_index cindex, gx_color_value col
int i=dev->color_info.num_components;
#ifdef DEBUG
- dprintf("No decode_color proc defined for device.\n");
+ dmprintf(dev->memory, "No decode_color proc defined for device.\n");
#endif
for(; i>=0; i--)
colors[i] = 0;
@@ -470,7 +470,7 @@ gx_error_get_color_comp_index(gx_device * dev, const char * pname,
* routine for the device.
*/
#ifdef DEBUG
- dprintf("No get_color_comp_index proc defined for device.\n");
+ dmprintf(dev->memory, "No get_color_comp_index proc defined for device.\n");
#endif
return -1; /* Always return "unknown" component name */
}
diff --git a/gs/base/gxcpath.c b/gs/base/gxcpath.c
index c114253fe..425668e54 100644
--- a/gs/base/gxcpath.c
+++ b/gs/base/gxcpath.c
@@ -1102,12 +1102,12 @@ gx_cpath_copy(const gx_clip_path * from, gx_clip_path * pcpath)
/* Print a clipping list. */
static void
-gx_clip_list_print(const gx_clip_list *list)
+gx_clip_list_print(const gs_memory_t *mem, const gx_clip_list *list)
{
const gx_clip_rect *pr;
- dlprintf3(" list count=%d xmin=%d xmax=%d\n",
- list->count, list->xmin, list->xmax);
+ dmlprintf3(mem, " list count=%d xmin=%d xmax=%d\n",
+ list->count, list->xmin, list->xmax);
switch (list->count) {
case 0:
pr = 0;
@@ -1119,31 +1119,31 @@ gx_clip_list_print(const gx_clip_list *list)
pr = list->head;
}
for (; pr != 0; pr = pr->next)
- dlprintf4(" rect: (%d,%d),(%d,%d)\n",
- pr->xmin, pr->ymin, pr->xmax, pr->ymax);
+ dmlprintf4(mem, " rect: (%d,%d),(%d,%d)\n",
+ pr->xmin, pr->ymin, pr->xmax, pr->ymax);
}
/* Print a clipping path */
void
-gx_cpath_print(const gx_clip_path * pcpath)
+gx_cpath_print(const gs_memory_t *mem, const gx_clip_path * pcpath)
{
if (pcpath->path_valid)
gx_path_print(&pcpath->path);
else
- dlputs(" (path not valid)\n");
- dlprintf4(" inner_box=(%g,%g),(%g,%g)\n",
- fixed2float(pcpath->inner_box.p.x),
- fixed2float(pcpath->inner_box.p.y),
- fixed2float(pcpath->inner_box.q.x),
- fixed2float(pcpath->inner_box.q.y));
- dlprintf4(" outer_box=(%g,%g),(%g,%g)",
- fixed2float(pcpath->outer_box.p.x),
- fixed2float(pcpath->outer_box.p.y),
- fixed2float(pcpath->outer_box.q.x),
- fixed2float(pcpath->outer_box.q.y));
- dprintf2(" rule=%d list.refct=%ld\n",
- pcpath->rule, pcpath->rect_list->rc.ref_count);
- gx_clip_list_print(gx_cpath_list(pcpath));
+ dmlputs(mem, " (path not valid)\n");
+ dmlprintf4(mem, " inner_box=(%g,%g),(%g,%g)\n",
+ fixed2float(pcpath->inner_box.p.x),
+ fixed2float(pcpath->inner_box.p.y),
+ fixed2float(pcpath->inner_box.q.x),
+ fixed2float(pcpath->inner_box.q.y));
+ dmlprintf4(mem, " outer_box=(%g,%g),(%g,%g)",
+ fixed2float(pcpath->outer_box.p.x),
+ fixed2float(pcpath->outer_box.p.y),
+ fixed2float(pcpath->outer_box.q.x),
+ fixed2float(pcpath->outer_box.q.y));
+ dmprintf2(mem, " rule=%d list.refct=%ld\n",
+ pcpath->rule, pcpath->rect_list->rc.ref_count);
+ gx_clip_list_print(mem, gx_cpath_list(pcpath));
}
#endif /* DEBUG */
diff --git a/gs/base/gxdcconv.c b/gs/base/gxdcconv.c
index edbbe67da..d1891171c 100644
--- a/gs/base/gxdcconv.c
+++ b/gs/base/gxdcconv.c
@@ -103,8 +103,8 @@ color_rgb_to_cmyk(frac r, frac g, frac b, const gs_imager_state * pis,
}
}
cmyk[3] = bg;
- if_debug7('c', "[c]RGB 0x%x,0x%x,0x%x -> CMYK 0x%x,0x%x,0x%x,0x%x\n",
- r, g, b, cmyk[0], cmyk[1], cmyk[2], cmyk[3]);
+ if_debug7m('c', mem, "[c]RGB 0x%x,0x%x,0x%x -> CMYK 0x%x,0x%x,0x%x,0x%x\n",
+ r, g, b, cmyk[0], cmyk[1], cmyk[2], cmyk[3]);
}
/* Convert CMYK to Gray. */
@@ -154,6 +154,6 @@ color_cmyk_to_rgb(frac c, frac m, frac y, frac k, const gs_imager_state * pis,
#undef deduct_black
}
}
- if_debug7('c', "[c]CMYK 0x%x,0x%x,0x%x,0x%x -> RGB 0x%x,0x%x,0x%x\n",
- c, m, y, k, rgb[0], rgb[1], rgb[2]);
+ if_debug7m('c', mem, "[c]CMYK 0x%x,0x%x,0x%x,0x%x -> RGB 0x%x,0x%x,0x%x\n",
+ c, m, y, k, rgb[0], rgb[1], rgb[2]);
}
diff --git a/gs/base/gxdevndi.c b/gs/base/gxdevndi.c
index d43a244fb..27adcc1a3 100644
--- a/gs/base/gxdevndi.c
+++ b/gs/base/gxdevndi.c
@@ -120,13 +120,13 @@ gx_render_device_DeviceN(frac * pcolor,
#ifdef DEBUG
if (gs_debug_c('c')) {
- dlprintf1("[c]ncomp=%d ", num_colors);
+ dmlprintf1(dev->memory, "[c]ncomp=%d ", num_colors);
for (i = 0; i < num_colors; i++)
- dlprintf1("0x%x, ", pcolor[i]);
- dlprintf("--> ");
+ dmlprintf1(dev->memory, "0x%x, ", pcolor[i]);
+ dmlprintf(dev->memory, "--> ");
for (i = 0; i < num_colors; i++)
- dlprintf2("%x+0x%x, ", int_color[i], l_color[i]);
- dlprintf("\n");
+ dmlprintf2(dev->memory, "%x+0x%x, ", int_color[i], l_color[i]);
+ dmlprintf(dev->memory, "\n");
}
#endif
diff --git a/gs/base/gxdtfill.h b/gs/base/gxdtfill.h
index 66470437b..a5dad2b12 100644
--- a/gs/base/gxdtfill.h
+++ b/gs/base/gxdtfill.h
@@ -175,7 +175,7 @@ GX_FILL_TRAPEZOID (gx_device * dev, const EDGE_TYPE * left,
dev_proc(dev, fill_rectangle);
# endif
- if_debug2('z', "[z]y=[%d,%d]\n", iy, iy1);
+ if_debug2m('z', dev->memory, "[z]y=[%d,%d]\n", iy, iy1);
l.h = left->end.y - left->start.y;
r.h = right->end.y - right->start.y;
diff --git a/gs/base/gxfapiu.c b/gs/base/gxfapiu.c
index 669cea2a2..1b65152b9 100644
--- a/gs/base/gxfapiu.c
+++ b/gs/base/gxfapiu.c
@@ -335,17 +335,17 @@ gx_UFST_init(gs_memory_t *mem, const UB8 *ufst_root_dir)
config_block.typePath[0] = 0;
if ((status = CGIFinit(FSA0)) != 0) {
- dprintf1("CGIFinit() error: %d\n", status);
+ dmprintf1(mem, "CGIFinit() error: %d\n", status);
gs_mem_ctx = NULL;
return status;
}
if ((status = CGIFconfig(FSA &config_block)) != 0) {
- dprintf1("CGIFconfig() error: %d\n", status);
+ dmprintf1(mem, "CGIFconfig() error: %d\n", status);
gs_mem_ctx = NULL;
return status;
}
if ((status = CGIFenter(FSA0)) != 0) {
- dprintf1("CGIFenter() error: %u\n",status);
+ dmprintf1(mem, "CGIFenter() error: %u\n",status);
gs_mem_ctx = NULL;
return status;
}
diff --git a/gs/base/gxfill.c b/gs/base/gxfill.c
index d1aec7cd7..35a92c0b8 100644
--- a/gs/base/gxfill.c
+++ b/gs/base/gxfill.c
@@ -155,42 +155,42 @@ gs_private_st_simple(st_active_line, active_line, "active_line");
#ifdef DEBUG
/* Internal procedures for printing and checking active lines. */
static void
-print_active_line(const char *label, const active_line * alp)
+print_active_line(const gs_memory_t *mem, const char *label, const active_line * alp)
{
- dlprintf5("[f]%s 0x%lx(%d): x_current=%f x_next=%f\n",
- label, (ulong) alp, alp->direction,
- fixed2float(alp->x_current), fixed2float(alp->x_next));
- dlprintf5(" start=(%f,%f) pt_end=0x%lx(%f,%f)\n",
- fixed2float(alp->start.x), fixed2float(alp->start.y),
- (ulong) alp->pseg,
- fixed2float(alp->end.x), fixed2float(alp->end.y));
- dlprintf2(" prev=0x%lx next=0x%lx\n",
- (ulong) alp->prev, (ulong) alp->next);
+ dmlprintf5(mem, "[f]%s 0x%lx(%d): x_current=%f x_next=%f\n",
+ label, (ulong) alp, alp->direction,
+ fixed2float(alp->x_current), fixed2float(alp->x_next));
+ dmlprintf5(mem, " start=(%f,%f) pt_end=0x%lx(%f,%f)\n",
+ fixed2float(alp->start.x), fixed2float(alp->start.y),
+ (ulong) alp->pseg,
+ fixed2float(alp->end.x), fixed2float(alp->end.y));
+ dmlprintf2(mem, " prev=0x%lx next=0x%lx\n",
+ (ulong) alp->prev, (ulong) alp->next);
}
static void
-print_line_list(const active_line * flp)
+print_line_list(const gs_memory_t *mem, const active_line * flp)
{
const active_line *lp;
for (lp = flp; lp != 0; lp = lp->next) {
fixed xc = lp->x_current, xn = lp->x_next;
- dlprintf3("[f]0x%lx(%d): x_current/next=%g",
+ dmlprintf3(mem, "[f]0x%lx(%d): x_current/next=%g",
(ulong) lp, lp->direction,
fixed2float(xc));
if (xn != xc)
- dprintf1("/%g", fixed2float(xn));
- dputc('\n');
+ dmprintf1(mem, "/%g", fixed2float(xn));
+ dmputc(mem, '\n');
}
}
static inline void
-print_al(const char *label, const active_line * alp)
+print_al(const gs_memory_t *mem, const char *label, const active_line * alp)
{
if (gs_debug_c('F'))
- print_active_line(label, alp);
+ print_active_line(mem, label, alp);
}
#else
-#define print_al(label,alp) DO_NOTHING
+#define print_al(mem,label,alp) DO_NOTHING
#endif
static inline bool
@@ -337,10 +337,10 @@ gx_general_fill_path(gx_device * pdev, const gs_imager_state * pis,
vd_bar(x0, k, x1, k, 1, RGB(128, 128, 128));
}
/* Check the bounding boxes. */
- if_debug6('f', "[f]adjust=%g,%g bbox=(%g,%g),(%g,%g)\n",
- fixed2float(adjust.x), fixed2float(adjust.y),
- fixed2float(ibox.p.x), fixed2float(ibox.p.y),
- fixed2float(ibox.q.x), fixed2float(ibox.q.y));
+ if_debug6m('f', pdev->memory, "[f]adjust=%g,%g bbox=(%g,%g),(%g,%g)\n",
+ fixed2float(adjust.x), fixed2float(adjust.y),
+ fixed2float(ibox.p.x), fixed2float(ibox.p.y),
+ fixed2float(ibox.q.x), fixed2float(ibox.q.y));
if (pcpath)
gx_cpath_inner_box(pcpath, &bbox);
else
@@ -352,9 +352,9 @@ gx_general_fill_path(gx_device * pdev, const gs_imager_state * pis,
*/
if (pcpath)
gx_cpath_outer_box(pcpath, &bbox);
- if_debug4('f', " outer_box=(%g,%g),(%g,%g)\n",
- fixed2float(bbox.p.x), fixed2float(bbox.p.y),
- fixed2float(bbox.q.x), fixed2float(bbox.q.y));
+ if_debug4m('f', pdev->memory, " outer_box=(%g,%g),(%g,%g)\n",
+ fixed2float(bbox.p.x), fixed2float(bbox.p.y),
+ fixed2float(bbox.q.x), fixed2float(bbox.q.y));
rect_intersect(ibox, bbox);
if (ibox.p.x - adjust.x >= ibox.q.x + adjust.x ||
ibox.p.y - adjust.y >= ibox.q.y + adjust.y
@@ -522,23 +522,25 @@ gx_general_fill_path(gx_device * pdev, const gs_imager_state * pis,
gx_path_free(pfpath, "gx_general_fill_path");
#ifdef DEBUG
if (gs_debug_c('f')) {
- dlputs("[f] # alloc up down horiz step slowx iter find band bstep bfill\n");
- dlprintf5(" %5ld %5ld %5ld %5ld %5ld",
- stats_fill.fill, stats_fill.fill_alloc,
- stats_fill.y_up, stats_fill.y_down,
- stats_fill.horiz);
- dlprintf4(" %5ld %5ld %5ld %5ld",
- stats_fill.x_step, stats_fill.slow_x,
- stats_fill.iter, stats_fill.find_y);
- dlprintf3(" %5ld %5ld %5ld\n",
- stats_fill.band, stats_fill.band_step,
- stats_fill.band_fill);
- dlputs("[f] afill slant shall sfill mqcrs order slowo\n");
- dlprintf7(" %5ld %5ld %5ld %5ld %5ld %5ld %5ld\n",
- stats_fill.afill, stats_fill.slant,
- stats_fill.slant_shallow, stats_fill.sfill,
- stats_fill.mq_cross, stats_fill.order,
- stats_fill.slow_order);
+ dmlputs(ppath->memory,
+ "[f] # alloc up down horiz step slowx iter find band bstep bfill\n");
+ dmlprintf5(ppath->memory, " %5ld %5ld %5ld %5ld %5ld",
+ stats_fill.fill, stats_fill.fill_alloc,
+ stats_fill.y_up, stats_fill.y_down,
+ stats_fill.horiz);
+ dmlprintf4(ppath->memory, " %5ld %5ld %5ld %5ld",
+ stats_fill.x_step, stats_fill.slow_x,
+ stats_fill.iter, stats_fill.find_y);
+ dmlprintf3(ppath->memory, " %5ld %5ld %5ld\n",
+ stats_fill.band, stats_fill.band_step,
+ stats_fill.band_fill);
+ dmlputs(ppath->memory,
+ "[f] afill slant shall sfill mqcrs order slowo\n");
+ dmlprintf7(ppath->memory, " %5ld %5ld %5ld %5ld %5ld %5ld %5ld\n",
+ stats_fill.afill, stats_fill.slant,
+ stats_fill.slant_shallow, stats_fill.sfill,
+ stats_fill.mq_cross, stats_fill.order,
+ stats_fill.slow_order);
}
#endif
return code;
@@ -747,7 +749,7 @@ insert_y_line(line_list *ll, active_line *alp)
}
ll->y_line = alp;
vd_bar(alp->start.x, alp->start.y, alp->end.x, alp->end.y, 1, RGB(0, 255, 0));
- print_al("add ", alp);
+ print_al(ll->memory, "add ", alp);
}
typedef struct contour_cursor_s {
@@ -1299,7 +1301,7 @@ remove_al(const line_list *ll, active_line *alp)
alp->prev->next = nlp;
if (nlp)
nlp->prev = alp->prev;
- if_debug1('F', "[F]drop 0x%lx\n", (ulong) alp);
+ if_debug1m('F', ll->memory, "[F]drop 0x%lx\n", (ulong) alp);
}
/*
@@ -1353,7 +1355,7 @@ end_x_line(active_line *alp, const line_list *ll, bool update)
}
alp->x_current = alp->x_next = alp->start.x;
vd_bar(alp->start.x, alp->start.y, alp->end.x, alp->end.y, 1, RGB(128, 0, 128));
- print_al("repl", alp);
+ print_al(ll->memory, "repl", alp);
return false;
}
@@ -1601,7 +1603,7 @@ resort_x_line(active_line * alp)
next->prev = prev;
while (x_order(prev, alp) > 0) {
if_debug2('F', "[F]swap 0x%lx,0x%lx\n",
- (ulong) alp, (ulong) prev);
+ (ulong) alp, (ulong) prev);
next = prev, prev = prev->prev;
}
alp->next = next;
@@ -1959,8 +1961,8 @@ intersect_al(line_list *ll, fixed y, fixed *y_top, int draw, bool all_bands)
}
#ifdef DEBUG
if (gs_debug_c('F')) {
- dlprintf1("[F]after loop: y1=%f\n", fixed2float(y1));
- print_line_list(ll->x_list);
+ dmlprintf1(ll->memory, "[F]after loop: y1=%f\n", fixed2float(y1));
+ print_line_list(ll->memory, ll->x_list);
}
#endif
*y_top = y1;
diff --git a/gs/base/gxfillsl.h b/gs/base/gxfillsl.h
index c45ec560e..f709a5999 100644
--- a/gs/base/gxfillsl.h
+++ b/gs/base/gxfillsl.h
@@ -149,11 +149,11 @@ TEMPLATE_spot_into_scanlines (line_list *ll, fixed band_mask)
) {
int x0 = pcr->rmin, x1 = pcr->rmax;
- if_debug4('Q', "[Qr]draw 0x%lx: [%d,%d),%d\n", (ulong)pcr,
- x0, x1, y0);
+ if_debug4m('Q', ll->memory, "[Qr]draw 0x%lx: [%d,%d),%d\n", (ulong)pcr,
+ x0, x1, y0);
VD_RECT(x0, y0, x1 - x0, 1, VD_TRAP_COLOR);
code = LOOP_FILL_RECTANGLE_DIRECT(&fo, x0, y0, x1 - x0, 1);
- if_debug3('F', "[F]drawing [%d:%d),%d\n", x0, x1, y0);
+ if_debug3m('F', ll->memory, "[F]drawing [%d:%d),%d\n", x0, x1, y0);
if (code < 0)
goto done;
}
@@ -193,7 +193,7 @@ TEMPLATE_spot_into_scanlines (line_list *ll, fixed band_mask)
for (;;) {
/* We're inside a filled region. */
- print_al("step", alp);
+ print_al(ll->memory, "step", alp);
INCR(band_step);
inside += alp->direction;
if (!INSIDE_PATH_P(inside, fo.rule))
diff --git a/gs/base/gxfilltr.h b/gs/base/gxfilltr.h
index 9ef940d86..7be312600 100644
--- a/gs/base/gxfilltr.h
+++ b/gs/base/gxfilltr.h
@@ -128,9 +128,9 @@ TEMPLATE_spot_into_trapezoids (line_list *ll, fixed band_mask)
}
# ifdef DEBUG
if (gs_debug_c('F')) {
- dlprintf2("[F]before loop: y=%f y1=%f:\n",
+ dmlprintf2(ll->memory, "[F]before loop: y=%f y1=%f:\n",
fixed2float(y), fixed2float(y1));
- print_line_list(ll->x_list);
+ print_line_list(ll->memory, ll->x_list);
}
# endif
if (y == y1) {
@@ -177,7 +177,7 @@ TEMPLATE_spot_into_trapezoids (line_list *ll, fixed band_mask)
for (alp = ll->x_list; alp != 0; alp = alp->next) {
int code;
- print_al("step", alp);
+ print_al(ll->memory, "step", alp);
INCR(band_step);
if (!INSIDE_PATH_P(inside, rule)) { /* i.e., outside */
ADVANCE_WINDING(inside, alp, ll);
diff --git a/gs/base/gxht.c b/gs/base/gxht.c
index bbe06af12..7688ddf84 100644
--- a/gs/base/gxht.c
+++ b/gs/base/gxht.c
@@ -793,12 +793,12 @@ render_ht(gx_ht_tile * pbt, int level /* [1..num_bits-1] */ ,
const byte *ptr = p + wb * pbt->tiles.size.y;
while (p < ptr) {
- dprintf8(" %d%d%d%d%d%d%d%d",
- *p >> 7, (*p >> 6) & 1, (*p >> 5) & 1,
- (*p >> 4) & 1, (*p >> 3) & 1, (*p >> 2) & 1,
- (*p >> 1) & 1, *p & 1);
+ dmprintf8(porder->data_memory, " %d%d%d%d%d%d%d%d",
+ *p >> 7, (*p >> 6) & 1, (*p >> 5) & 1,
+ (*p >> 4) & 1, (*p >> 3) & 1, (*p >> 2) & 1,
+ (*p >> 1) & 1, *p & 1);
if ((++p - data) % wb == 0)
- dputc('\n');
+ dmputc(porder->data_memory, '\n');
}
}
#endif
diff --git a/gs/base/gxi12bit.c b/gs/base/gxi12bit.c
index bdae0dbac..6e560f793 100644
--- a/gs/base/gxi12bit.c
+++ b/gs/base/gxi12bit.c
@@ -135,7 +135,7 @@ gs_image_class_2_fracs(gx_image_enum * penum)
/* DevicePixel color space used in mask from 3x type. Basically
a simple color space that just is scaled to the device bit
depth when remapped. No CM needed */
- if_debug0('b', "[b]render=frac\n");
+ if_debug0m('b', penum->memory, "[b]render=frac\n");
return &image_render_frac;
} else {
/* Set up the link now */
@@ -177,7 +177,7 @@ gs_image_class_2_fracs(gx_image_enum * penum)
}
/* Use the direct unpacking proc */
penum->unpack = sample_unpackicc_16_proc;
- if_debug0('b', "[b]render=icc16\n");
+ if_debug0m('b', penum->memory, "[b]render=icc16\n");
return &image_render_icc16;
}
}
@@ -270,8 +270,8 @@ image_render_frac(gx_image_enum * penum, const byte * buffer, int data_x,
yrun = ytf = dda_current(pnext.y);
pdyx = dda_current(penum->dda.row.x) - penum->cur.x;
pdyy = dda_current(penum->dda.row.y) - penum->cur.y;
- if_debug5('b', "[b]y=%d data_x=%d w=%d xt=%f yt=%f\n",
- penum->y, data_x, w, fixed2float(xl), fixed2float(ytf));
+ if_debug5m('b', penum->memory, "[b]y=%d data_x=%d w=%d xt=%f yt=%f\n",
+ penum->y, data_x, w, fixed2float(xl), fixed2float(ytf));
memset(&run, 0, sizeof(run));
memset(&next, 0, sizeof(next));
/* Ensure that we don't get any false dev_color_eq hits. */
@@ -312,11 +312,9 @@ image_render_frac(gx_image_enum * penum, const byte * buffer, int data_x,
decode_frac(next.v[1], cc, 1);
decode_frac(next.v[2], cc, 2);
decode_frac(next.v[3], cc, 3);
- if_debug4('B', "[B]cc[0..3]=%g,%g,%g,%g\n",
- cc.paint.values[0], cc.paint.values[1],
- cc.paint.values[2], cc.paint.values[3]);
- if_debug1('B', "[B]cc[3]=%g\n",
- cc.paint.values[3]);
+ if_debug4m('B', penum->memory, "[B]cc[0..3]=%g,%g,%g,%g\n",
+ cc.paint.values[0], cc.paint.values[1],
+ cc.paint.values[2], cc.paint.values[3]);
break;
case 3: /* may be RGB */
next.v[1] = psrc[1];
@@ -337,9 +335,9 @@ image_render_frac(gx_image_enum * penum, const byte * buffer, int data_x,
decode_frac(next.v[0], cc, 0);
decode_frac(next.v[1], cc, 1);
decode_frac(next.v[2], cc, 2);
- if_debug3('B', "[B]cc[0..2]=%g,%g,%g\n",
- cc.paint.values[0], cc.paint.values[1],
- cc.paint.values[2]);
+ if_debug3m('B', penum->memory, "[B]cc[0..2]=%g,%g,%g\n",
+ cc.paint.values[0], cc.paint.values[1],
+ cc.paint.values[2]);
break;
case 1: /* may be Gray, but could be a separation */
if (is_devn && is_sep) {
@@ -351,8 +349,8 @@ image_render_frac(gx_image_enum * penum, const byte * buffer, int data_x,
goto f;
}
decode_frac(next.v[0], cc, 0);
- if_debug1('B', "[B]cc[0]=%g\n",
- cc.paint.values[0]);
+ if_debug1m('B', penum->memory, "[B]cc[0]=%g\n",
+ cc.paint.values[0]);
break;
} else {
psrc++;
@@ -392,11 +390,11 @@ image_render_frac(gx_image_enum * penum, const byte * buffer, int data_x,
decode_frac(next.v[i], cc, i);
#ifdef DEBUG
if (gs_debug_c('B')) {
- dprintf2("[B]cc[0..%d]=%g", spp - 1,
+ dmprintf2(dev->memory, "[B]cc[0..%d]=%g", spp - 1,
cc.paint.values[0]);
for (i = 1; i < spp; ++i)
- dprintf1(",%g", cc.paint.values[i]);
- dputs("\n");
+ dmprintf1(dev->memory, ",%g", cc.paint.values[i]);
+ dmputs(dev->memory, "\n");
}
#endif
}
@@ -408,21 +406,23 @@ image_render_frac(gx_image_enum * penum, const byte * buffer, int data_x,
goto fill;
f:
if (sizeof(pdevc_next->colors.binary.color[0]) <= sizeof(ulong))
- if_debug7('B', "[B]0x%x,0x%x,0x%x,0x%x -> 0x%lx,0x%lx,0x%lx\n",
- next.v[0], next.v[1], next.v[2], next.v[3],
- (ulong)pdevc_next->colors.binary.color[0],
- (ulong)pdevc_next->colors.binary.color[1],
- (ulong)pdevc_next->type);
+ if_debug7m('B', penum->memory,
+ "[B]0x%x,0x%x,0x%x,0x%x -> 0x%lx,0x%lx,0x%lx\n",
+ next.v[0], next.v[1], next.v[2], next.v[3],
+ (ulong)pdevc_next->colors.binary.color[0],
+ (ulong)pdevc_next->colors.binary.color[1],
+ (ulong)pdevc_next->type);
else
- if_debug9('B', "[B]0x%x,0x%x,0x%x,0x%x -> 0x%08lx%08lx,0x%08lx%08lx,0x%lx\n",
- next.v[0], next.v[1], next.v[2], next.v[3],
- (ulong)(pdevc_next->colors.binary.color[0] >>
- 8 * (sizeof(pdevc_next->colors.binary.color[0]) - sizeof(ulong))),
- (ulong)pdevc_next->colors.binary.color[0],
- (ulong)(pdevc_next->colors.binary.color[1] >>
- 8 * (sizeof(pdevc_next->colors.binary.color[1]) - sizeof(ulong))),
- (ulong)pdevc_next->colors.binary.color[1],
- (ulong)pdevc_next->type);
+ if_debug9m('B', penum->memory,
+ "[B]0x%x,0x%x,0x%x,0x%x -> 0x%08lx%08lx,0x%08lx%08lx,0x%lx\n",
+ next.v[0], next.v[1], next.v[2], next.v[3],
+ (ulong)(pdevc_next->colors.binary.color[0] >>
+ 8 * (sizeof(pdevc_next->colors.binary.color[0]) - sizeof(ulong))),
+ (ulong)pdevc_next->colors.binary.color[0],
+ (ulong)(pdevc_next->colors.binary.color[1] >>
+ 8 * (sizeof(pdevc_next->colors.binary.color[1]) - sizeof(ulong))),
+ (ulong)pdevc_next->colors.binary.color[1],
+ (ulong)pdevc_next->type);
/* NB: sizeof gx_color_index is 4 or 8 bytes! */
/* Even though the supplied colors don't match, */
@@ -719,8 +719,8 @@ image_render_icc16(gx_image_enum * penum, const byte * buffer, int data_x,
irun = fixed2int_var_rounded(yrun);
break;
}
- if_debug5('b', "[b]y=%d data_x=%d w=%d xt=%f yt=%f\n",
- penum->y, data_x, w, fixed2float(xprev), fixed2float(yprev));
+ if_debug5m('b', penum->memory, "[b]y=%d data_x=%d w=%d xt=%f yt=%f\n",
+ penum->y, data_x, w, fixed2float(xprev), fixed2float(yprev));
memset(&run, 0, sizeof(run));
memset(&next, 0, sizeof(next));
run.v[0] = ~psrc_cm[0]; /* Force intial setting */
diff --git a/gs/base/gxicolor.c b/gs/base/gxicolor.c
index 92c750f50..2162603e0 100644
--- a/gs/base/gxicolor.c
+++ b/gs/base/gxicolor.c
@@ -876,8 +876,8 @@ image_render_color_icc(gx_image_enum *penum_orig, const byte *buffer, int data_x
irun = fixed2int_var_rounded(yrun);
break;
}
- if_debug5('b', "[b]y=%d data_x=%d w=%d xt=%f yt=%f\n",
- penum->y, data_x, w, fixed2float(xprev), fixed2float(yprev));
+ if_debug5m('b', penum->memory, "[b]y=%d data_x=%d w=%d xt=%f yt=%f\n",
+ penum->y, data_x, w, fixed2float(xprev), fixed2float(yprev));
memset(&run, 0, sizeof(run));
memset(&next, 0, sizeof(next));
run.v[0] = ~psrc_cm[0]; /* Force intial setting */
@@ -1096,8 +1096,8 @@ image_render_color_DeviceN(gx_image_enum *penum_orig, const byte *buffer, int da
irun = fixed2int_var_rounded(yrun);
break;
}
- if_debug5('b', "[b]y=%d data_x=%d w=%d xt=%f yt=%f\n",
- penum->y, data_x, w, fixed2float(xprev), fixed2float(yprev));
+ if_debug5m('b', penum->memory, "[b]y=%d data_x=%d w=%d xt=%f yt=%f\n",
+ penum->y, data_x, w, fixed2float(xprev), fixed2float(yprev));
memset(&run, 0, sizeof(run));
memset(&next, 0, sizeof(next));
cs_full_init_color(&cc, pcs);
@@ -1127,11 +1127,11 @@ image_render_color_DeviceN(gx_image_enum *penum_orig, const byte *buffer, int da
decode_sample(next.v[i], cc, i);
#ifdef DEBUG
if (gs_debug_c('B')) {
- dprintf2("[B]cc[0..%d]=%g", spp - 1,
+ dmprintf2(dev->memory, "[B]cc[0..%d]=%g", spp - 1,
cc.paint.values[0]);
for (i = 1; i < spp; ++i)
- dprintf1(",%g", cc.paint.values[i]);
- dputs("\n");
+ dmprintf1(dev->memory, ",%g", cc.paint.values[i]);
+ dmputs(dev->memory, "\n");
}
#endif
mcode = remap_color(&cc, pcs, pdevc_next, pis, dev,
@@ -1139,21 +1139,23 @@ image_render_color_DeviceN(gx_image_enum *penum_orig, const byte *buffer, int da
mapped: if (mcode < 0)
goto fill;
if (sizeof(pdevc_next->colors.binary.color[0]) <= sizeof(ulong))
- if_debug7('B', "[B]0x%x,0x%x,0x%x,0x%x -> 0x%lx,0x%lx,0x%lx\n",
- next.v[0], next.v[1], next.v[2], next.v[3],
- (ulong)pdevc_next->colors.binary.color[0],
- (ulong)pdevc_next->colors.binary.color[1],
- (ulong) pdevc_next->type);
+ if_debug7m('B', penum->memory,
+ "[B]0x%x,0x%x,0x%x,0x%x -> 0x%lx,0x%lx,0x%lx\n",
+ next.v[0], next.v[1], next.v[2], next.v[3],
+ (ulong)pdevc_next->colors.binary.color[0],
+ (ulong)pdevc_next->colors.binary.color[1],
+ (ulong) pdevc_next->type);
else
- if_debug9('B', "[B]0x%x,0x%x,0x%x,0x%x -> 0x%08lx%08lx,0x%08lx%08lx,0x%lx\n",
- next.v[0], next.v[1], next.v[2], next.v[3],
- (ulong)(pdevc_next->colors.binary.color[0] >>
- 8 * (sizeof(pdevc_next->colors.binary.color[0]) - sizeof(ulong))),
- (ulong)pdevc_next->colors.binary.color[0],
- (ulong)(pdevc_next->colors.binary.color[1] >>
- 8 * (sizeof(pdevc_next->colors.binary.color[1]) - sizeof(ulong))),
- (ulong)pdevc_next->colors.binary.color[1],
- (ulong) pdevc_next->type);
+ if_debug9m('B', penum->memory,
+ "[B]0x%x,0x%x,0x%x,0x%x -> 0x%08lx%08lx,0x%08lx%08lx,0x%lx\n",
+ next.v[0], next.v[1], next.v[2], next.v[3],
+ (ulong)(pdevc_next->colors.binary.color[0] >>
+ 8 * (sizeof(pdevc_next->colors.binary.color[0]) - sizeof(ulong))),
+ (ulong)pdevc_next->colors.binary.color[0],
+ (ulong)(pdevc_next->colors.binary.color[1] >>
+ 8 * (sizeof(pdevc_next->colors.binary.color[1]) - sizeof(ulong))),
+ (ulong)pdevc_next->colors.binary.color[1],
+ (ulong) pdevc_next->type);
/* NB: printf above fails to account for sizeof gx_color_index 4 or 8 bytes */
if (posture != image_skewed && dev_color_eq(*pdevc, *pdevc_next))
goto set;
diff --git a/gs/base/gxidata.c b/gs/base/gxidata.c
index 2cb2b15de..f6a93a5ef 100644
--- a/gs/base/gxidata.c
+++ b/gs/base/gxidata.c
@@ -121,7 +121,7 @@ gx_image1_plane_data(gx_image_enum_common_t * info,
}
#ifdef DEBUG
if (gs_debug_c('b'))
- dprintf1("[b]image1 y=%d\n", y);
+ dmprintf1(dev->memory, "[b]image1 y=%d\n", y);
if (gs_debug_c('B')) {
int i, n = width_spp;
@@ -129,10 +129,10 @@ gx_image1_plane_data(gx_image_enum_common_t * info,
n *= 2;
else if (penum->bps == 1 && penum->unpack_bps == 8)
n = (n + 7) / 8;
- dlputs("[B]row:");
+ dmlputs(dev->memory, "[B]row:");
for (i = 0; i < n; i++)
- dprintf1(" %02x", buffer[i]);
- dputs("\n");
+ dmprintf1(dev->memory, " %02x", buffer[i]);
+ dmputs(dev->memory, "\n");
}
#endif
penum->cur.x = dda_current(penum->dda.row.x);
@@ -163,8 +163,8 @@ gx_image1_plane_data(gx_image_enum_common_t * info,
penum->hci = fixed2int_pixround_perfect(yn) - penum->yci;
if (penum->hci == 0)
goto mt;
- if_debug2('b', "[b]yci=%d, hci=%d\n",
- penum->yci, penum->hci);
+ if_debug2m('b', penum->memory, "[b]yci=%d, hci=%d\n",
+ penum->yci, penum->hci);
}
break;
case image_landscape:
@@ -188,8 +188,8 @@ gx_image1_plane_data(gx_image_enum_common_t * info,
penum->wci = fixed2int_pixround_perfect(xn) - penum->xci;
if (penum->wci == 0)
goto mt;
- if_debug2('b', "[b]xci=%d, wci=%d\n",
- penum->xci, penum->wci);
+ if_debug2m('b', penum->memory, "[b]xci=%d, wci=%d\n",
+ penum->xci, penum->wci);
}
break;
case image_skewed:
@@ -205,9 +205,9 @@ gx_image1_plane_data(gx_image_enum_common_t * info,
dda_advance(penum->dda.pixel0.y, x_used);
penum->used.x = 0;
}
- if_debug2('b', "[b]pixel0 x=%g, y=%g\n",
- fixed2float(dda_current(penum->dda.pixel0.x)),
- fixed2float(dda_current(penum->dda.pixel0.y)));
+ if_debug2m('b', penum->memory, "[b]pixel0 x=%g, y=%g\n",
+ fixed2float(dda_current(penum->dda.pixel0.x)),
+ fixed2float(dda_current(penum->dda.pixel0.y)));
code = (*penum->render)(penum, buffer, sourcex + x_used,
width_spp - x_used * penum->spp, 1, dev);
if (code < 0) {
@@ -442,8 +442,8 @@ gx_image1_end_image(gx_image_enum_common_t * info, bool draw_last)
gs_memory_t *mem = penum->memory;
stream_image_scale_state *scaler = penum->scaler;
- if_debug2('b', "[b]%send_image, y=%d\n",
- (penum->y < penum->rect.h ? "premature " : ""), penum->y);
+ if_debug2m('b', penum->memory, "[b]%send_image, y=%d\n",
+ (penum->y < penum->rect.h ? "premature " : ""), penum->y);
if (draw_last) {
int code = gx_image_flush(info);
diff --git a/gs/base/gxifast.c b/gs/base/gxifast.c
index 9726600dd..3e5001085 100644
--- a/gs/base/gxifast.c
+++ b/gs/base/gxifast.c
@@ -88,8 +88,8 @@ gs_image_class_1_simple(gx_image_enum * penum)
return 0;
}
}
- if_debug2('b', "[b]render=simple, unpack=copy; rect.w=%d, dev_width=%ld\n",
- penum->rect.w, dev_width);
+ if_debug2m('b', penum->memory, "[b]render=simple, unpack=copy; rect.w=%d, dev_width=%ld\n",
+ penum->rect.w, dev_width);
rproc = image_render_simple;
break;
}
@@ -119,8 +119,9 @@ gs_image_class_1_simple(gx_image_enum * penum)
return 0;
}
penum->xi_next = penum->line_xy = fixed2int_var_rounded(ox);
- if_debug3('b', "[b]render=landscape, unpack=copy; rect.w=%d, dev_width=%ld, line_size=%ld\n",
- penum->rect.w, dev_width, line_size);
+ if_debug3m('b', penum->memory,
+ "[b]render=landscape, unpack=copy; rect.w=%d, dev_width=%ld, line_size=%ld\n",
+ penum->rect.w, dev_width, line_size);
rproc = image_render_landscape;
/* Precompute values needed for rasterizing. */
penum->dxy =
diff --git a/gs/base/gximag3x.c b/gs/base/gximag3x.c
index 014f8ef82..4660448fa 100644
--- a/gs/base/gximag3x.c
+++ b/gs/base/gximag3x.c
@@ -760,10 +760,11 @@ gx_image3x_plane_data(gx_image_enum_common_t * info,
}
}
}
- if_debug7('b', "[b]image3x h=%d %sopacity.y=%d %sopacity.y=%d %spixel.y=%d\n",
- h, (mask_plane[0].data ? "+" : ""), penum->mask[0].y,
- (mask_plane[1].data ? "+" : ""), penum->mask[1].y,
- (pixel_planes[0].data ? "+" : ""), penum->pixel.y);
+ if_debug7m('b', penum->memory,
+ "[b]image3x h=%d %sopacity.y=%d %sopacity.y=%d %spixel.y=%d\n",
+ h, (mask_plane[0].data ? "+" : ""), penum->mask[0].y,
+ (mask_plane[1].data ? "+" : ""), penum->mask[1].y,
+ (pixel_planes[0].data ? "+" : ""), penum->pixel.y);
if (penum->mask[0].depth == 0 || penum->mask[0].y >= penum->mask[0].height) {
if (penum->mask[1].depth == 0 || penum->mask[1].y >= penum->mask[1].height) {
if (penum->pixel.y >= penum->pixel.height) {
diff --git a/gs/base/gximage.c b/gs/base/gximage.c
index 0af828ff5..6c369766a 100644
--- a/gs/base/gximage.c
+++ b/gs/base/gximage.c
@@ -240,7 +240,7 @@ gx_image_default_release(gs_image_common_t *pic, gs_memory_t *mem)
#ifdef DEBUG
static void
-debug_b_print_matrix(const gs_pixel_image_t *pim)
+debug_b_print_matrix(const gs_memory_t *mem,const gs_pixel_image_t *pim)
{
if_debug6('b', " ImageMatrix=[%g %g %g %g %g %g]\n",
pim->ImageMatrix.xx, pim->ImageMatrix.xy,
@@ -248,20 +248,20 @@ debug_b_print_matrix(const gs_pixel_image_t *pim)
pim->ImageMatrix.tx, pim->ImageMatrix.ty);
}
static void
-debug_b_print_decode(const gs_pixel_image_t *pim, int num_decode)
+debug_b_print_decode(const gs_memory_t *mem,const gs_pixel_image_t *pim, int num_decode)
{
if (gs_debug_c('b')) {
const char *str = " Decode=[";
int i;
for (i = 0; i < num_decode; str = " ", ++i)
- dprintf2("%s%g", str, pim->Decode[i]);
- dputs("]\n");
+ dmprintf2(mem,"%s%g", str, pim->Decode[i]);
+ dmputs(mem,"]\n");
}
}
#else
-# define debug_b_print_matrix(pim) DO_NOTHING
-# define debug_b_print_decode(pim, num_decode) DO_NOTHING
+# define debug_b_print_matrix(mem,pim) DO_NOTHING
+# define debug_b_print_decode(mem,pim, num_decode) DO_NOTHING
#endif
/* Test whether an image has a default ImageMatrix. */
@@ -361,13 +361,13 @@ gx_pixel_image_sput(const gs_pixel_image_t *pim, stream *s,
/* Write the encoding on the stream. */
- if_debug3('b', "[b]put control=0x%x, Width=%d, Height=%d\n",
- control, pim->Width, pim->Height);
+ if_debug3m('b', s->memory, "[b]put control=0x%x, Width=%d, Height=%d\n",
+ control, pim->Width, pim->Height);
sput_variable_uint(s, control);
sput_variable_uint(s, (uint)pim->Width);
sput_variable_uint(s, (uint)pim->Height);
if (control & PI_ImageMatrix) {
- debug_b_print_matrix(pim);
+ debug_b_print_matrix(s->memory,pim);
sput_matrix(s, &pim->ImageMatrix);
}
if (control & PI_Decode) {
@@ -376,7 +376,7 @@ gx_pixel_image_sput(const gs_pixel_image_t *pim, stream *s,
float decode[8];
int di = 0;
- debug_b_print_decode(pim, num_decode);
+ debug_b_print_decode(s->memory, pim, num_decode);
for (i = 0; i < num_decode; i += 2) {
float u = pim->Decode[i], v = pim->Decode[i + 1];
float dv = DECODE_DEFAULT(i + 1, decode_default_1);
@@ -455,12 +455,12 @@ gx_pixel_image_sget(gs_pixel_image_t *pim, stream *s,
(code = sget_variable_uint(s, (uint *)&pim->Height)) < 0
)
return code;
- if_debug3('b', "[b]get control=0x%x, Width=%d, Height=%d\n",
+ if_debug3m('b', s->memory, "[b]get control=0x%x, Width=%d, Height=%d\n",
control, pim->Width, pim->Height);
if (control & PI_ImageMatrix) {
if ((code = sget_matrix(s, &pim->ImageMatrix)) < 0)
return code;
- debug_b_print_matrix(pim);
+ debug_b_print_matrix(s->memory,pim);
} else
gx_image_matrix_set_default((gs_data_image_t *)pim);
pim->BitsPerComponent = ((control >> PI_BPC_SHIFT) & PI_BPC_MASK) + 1;
@@ -498,7 +498,7 @@ gx_pixel_image_sget(gs_pixel_image_t *pim, stream *s,
break;
}
}
- debug_b_print_decode(pim, num_decode);
+ debug_b_print_decode(s->memory, pim, num_decode);
} else {
for (i = 0; i < num_decode; ++i)
pim->Decode[i] = DECODE_DEFAULT(i, decode_default_1);
diff --git a/gs/base/gximage3.c b/gs/base/gximage3.c
index e5df163d8..8ae2f4f2f 100644
--- a/gs/base/gximage3.c
+++ b/gs/base/gximage3.c
@@ -664,9 +664,9 @@ gx_image3_plane_data(gx_image_enum_common_t * info,
}
}
}
- if_debug5('b', "[b]image3 h=%d %smask_y=%d %spixel_y=%d\n",
- h, (mask_plane.data ? "+" : ""), penum->mask_y,
- (pixel_planes[0].data ? "+" : ""), penum->pixel_y);
+ if_debug5m('b', penum->memory, "[b]image3 h=%d %smask_y=%d %spixel_y=%d\n",
+ h, (mask_plane.data ? "+" : ""), penum->mask_y,
+ (pixel_planes[0].data ? "+" : ""), penum->pixel_y);
if (penum->mask_y >= penum->mask_height &&
penum->pixel_y >= penum->pixel_height)
return 1;
diff --git a/gs/base/gximono.c b/gs/base/gximono.c
index 19caa2f36..ec696a23c 100644
--- a/gs/base/gximono.c
+++ b/gs/base/gximono.c
@@ -182,7 +182,7 @@ not_fast_halftoning:
/* We can bypass X clipping for portrait mono-component images. */
if (!(penum->slow_loop || penum->posture != image_portrait))
penum->clip_image &= ~(image_clip_xmin | image_clip_xmax);
- if_debug0('b', "[b]render=mono\n");
+ if_debug0m('b', penum->memory, "[b]render=mono\n");
/* Precompute values needed for rasterizing. */
penum->dxx =
float2fixed(penum->matrix.xx + fixed2float(fixed_epsilon) / 2);
@@ -624,8 +624,8 @@ image_render_mono(gx_image_enum * penum, const byte * buffer, int data_x,
int xmax = fixed2int_pixround(penum->clip_outer.q.x);
#define xl dda_current(next.x)
- if_debug2('b', "[b]image y=%d dda.y.Q=%lg\n", penum->y + penum->rect.y,
- penum->dda.row.y.state.Q / 256.);
+ if_debug2m('b', penum->memory, "[b]image y=%d dda.y.Q=%lg\n",
+ penum->y + penum->rect.y, penum->dda.row.y.state.Q / 256.);
/* Fold the adjustment into xrun and xl, */
/* including the +0.5-epsilon for rounding. */
xrun = xrun - xa + (fixed_half - fixed_epsilon);
diff --git a/gs/base/gxipixel.c b/gs/base/gxipixel.c
index 89d467613..b364d7cff 100644
--- a/gs/base/gxipixel.c
+++ b/gs/base/gxipixel.c
@@ -193,9 +193,9 @@ gx_image_enum_alloc(const gs_image_common_t * pic,
penum->rrect.h = penum->rect.h;
#ifdef DEBUG
if (gs_debug_c('b')) {
- dlprintf2("[b]Image: w=%d h=%d", width, height);
+ dmlprintf2(mem, "[b]Image: w=%d h=%d", width, height);
if (prect)
- dprintf4(" ((%d,%d),(%d,%d))",
+ dmprintf4(mem, " ((%d,%d),(%d,%d))",
prect->p.x, prect->p.y, prect->q.x, prect->q.y);
}
#endif
@@ -420,7 +420,7 @@ gx_image_enum_begin(gx_device * dev, const gs_imager_state * pis,
penum->matrix.yy = mat.yy;
penum->matrix.tx = mat.tx;
penum->matrix.ty = mat.ty;
- if_debug6('b', " [%g %g %g %g %g %g]\n",
+ if_debug6m('b', penum->memory, " [%g %g %g %g %g %g]\n",
mat.xx, mat.xy, mat.yx, mat.yy, mat.tx, mat.ty);
/* following works for 1, 2, 4, 8, 12, 16 */
index_bps = (bps < 8 ? bps >> 1 : (bps >> 2) + 1);
@@ -668,8 +668,8 @@ gx_image_enum_begin(gx_device * dev, const gs_imager_state * pis,
#ifdef DEBUG
if (gs_debug_c('*')) {
if (penum->use_rop)
- dprintf1("[%03x]", lop);
- dprintf5("%c%d%c%dx%d ",
+ dmprintf1(mem, "[%03x]", lop);
+ dmprintf5(mem, "%c%d%c%dx%d ",
(masked ? (color_is_pure(pdcolor) ? 'm' : 'h') : 'i'),
bps,
(penum->posture == image_portrait ? ' ' :
@@ -741,16 +741,16 @@ gx_image_enum_begin(gx_device * dev, const gs_imager_state * pis,
mty = (((mty + diff) | fixed_half) & -fixed_half) - diff;
}
}
- if_debug5('b', "[b]Image: %sspp=%d, bps=%d, mt=(%g,%g)\n",
- (masked? "masked, " : ""), spp, bps,
- fixed2float(mtx), fixed2float(mty));
- if_debug9('b',
- "[b] cbox=(%g,%g),(%g,%g), obox=(%g,%g),(%g,%g), clip_image=0x%x\n",
- fixed2float(cbox.p.x), fixed2float(cbox.p.y),
- fixed2float(cbox.q.x), fixed2float(cbox.q.y),
- fixed2float(obox.p.x), fixed2float(obox.p.y),
- fixed2float(obox.q.x), fixed2float(obox.q.y),
- penum->clip_image);
+ if_debug5m('b', penum->memory, "[b]Image: %sspp=%d, bps=%d, mt=(%g,%g)\n",
+ (masked? "masked, " : ""), spp, bps,
+ fixed2float(mtx), fixed2float(mty));
+ if_debug9m('b', penum->memory,
+ "[b] cbox=(%g,%g),(%g,%g), obox=(%g,%g),(%g,%g), clip_image=0x%x\n",
+ fixed2float(cbox.p.x), fixed2float(cbox.p.y),
+ fixed2float(cbox.q.x), fixed2float(cbox.q.y),
+ fixed2float(obox.p.x), fixed2float(obox.p.y),
+ fixed2float(obox.q.x), fixed2float(obox.q.y),
+ penum->clip_image);
dda_init(penum->dda.row.x, mtx, col_extent.x, height);
dda_init(penum->dda.row.y, mty, col_extent.y, height);
penum->dst_width = row_extent.x;
@@ -827,7 +827,7 @@ gx_image_enum_begin(gx_device * dev, const gs_imager_state * pis,
} else {
penum->unpack = procs[interleaved][index_bps];
}
- if_debug1('b', "[b]unpack=%d\n", bps);
+ if_debug1m('b', penum->memory, "[b]unpack=%d\n", bps);
/* Set up pixel0 for image class procedures. */
penum->dda.pixel0 = penum->dda.strip;
for (i = 0; i < gx_image_class_table_count; ++i)
diff --git a/gs/base/gxiscale.c b/gs/base/gxiscale.c
index a8e338c6a..77048966d 100644
--- a/gs/base/gxiscale.c
+++ b/gs/base/gxiscale.c
@@ -319,7 +319,7 @@ gs_image_class_0_interpolate(gx_image_enum * penum)
}
penum->xyi.y = penum->yi0 + fixed2int_pixround_perfect((fixed)((int64_t)penum->rect.y
* penum->dst_height / penum->Height));
- if_debug0('b', "[b]render=interpolate\n");
+ if_debug0m('b', penum->memory, "[b]render=interpolate\n");
if (use_icc) {
/* Set up the link now */
const gs_color_space *pcs;
@@ -549,7 +549,7 @@ initial_decode(gx_image_enum * penum, const byte * buffer, int data_x, int h,
dpd = - dpd;
}
stream_r->ptr = (byte *) psrc - 1;
- if_debug0('B', "[B]Remap row:\n[B]");
+ if_debug0m('B', penum->memory, "[B]Remap row:\n[B]");
if (is_icc) {
stream_r->ptr = (byte *) pdata - 1;
} else {
@@ -568,14 +568,14 @@ initial_decode(gx_image_enum * penum, const byte * buffer, int data_x, int h,
int ci;
for (ci = 0; ci < spp_decode; ++ci)
- dprintf2("%c%04x", (ci == 0 ? ' ' : ','), psrc[ci]);
+ dmprintf2(penum->memory, "%c%04x", (ci == 0 ? ' ' : ','), psrc[ci]);
}
#endif
}
}
out += round_up(pss->params.WidthIn * spp_decode * sizeof(frac),
align_bitmap_mod);
- if_debug0('B', "\n");
+ if_debug0m('B', penum->memory, "\n");
} else {
/* indexed and more than 8bps. Need to get to the base space */
int bps = penum->bps;
@@ -690,8 +690,8 @@ image_render_interpolate(gx_image_enum * penum, const byte * buffer,
/* Are we active? (i.e. in the render rectangle) */
if (!pss->params.Active)
goto inactive;
- if_debug1('B', "[B]Interpolated row %d:\n[B]",
- penum->line_xy);
+ if_debug1m('B', penum->memory, "[B]Interpolated row %d:\n[B]",
+ penum->line_xy);
psrc += pss->params.LeftMarginOut * spp_decode;
for (x = xo; x < xe;) {
#ifdef DEBUG
@@ -699,7 +699,7 @@ image_render_interpolate(gx_image_enum * penum, const byte * buffer,
int ci;
for (ci = 0; ci < spp_decode; ++ci)
- dprintf2("%c%04x", (ci == 0 ? ' ' : ','),
+ dmprintf2(dev->memory, "%c%04x", (ci == 0 ? ' ' : ','),
psrc[ci]);
}
#endif
@@ -809,10 +809,10 @@ image_render_interpolate(gx_image_enum * penum, const byte * buffer,
}
}
LINE_ACCUM_COPY(dev, out, bpp, xo, x, raster, ry);
- /*if_debug1('w', "[w]Y=%d:\n", ry);*/ /* See siscale.c about 'w'. */
+ /*if_debug1m('w', dev->memory, "[w]Y=%d:\n", ry);*/ /* See siscale.c about 'w'. */
inactive:
penum->line_xy++;
- if_debug0('B', "\n");
+ if_debug0m('B', dev->memory, "\n");
}
if ((status == 0 && stream_r.ptr == stream_r.limit) || status == EOFC)
break;
@@ -948,8 +948,8 @@ image_render_interpolate_icc(gx_image_enum * penum, const byte * buffer,
/* Are we active? (i.e. in the render rectangle) */
if (!pss->params.Active)
goto inactive;
- if_debug1('B', "[B]Interpolated row %d:\n[B]",
- penum->line_xy);
+ if_debug1m('B', penum->memory, "[B]Interpolated row %d:\n[B]",
+ penum->line_xy);
/* Take care of CM on the entire interpolated row, if we
did not already do CM */
if (penum->icc_link->is_identity || pss->params.early_cm) {
@@ -971,7 +971,7 @@ image_render_interpolate_icc(gx_image_enum * penum, const byte * buffer,
int ci;
for (ci = 0; ci < spp_cm; ++ci)
- dprintf2("%c%04x", (ci == 0 ? ' ' : ','),
+ dmprintf2(dev->memory, "%c%04x", (ci == 0 ? ' ' : ','),
p_cm_interp[ci]);
}
#endif
@@ -1038,10 +1038,10 @@ image_render_interpolate_icc(gx_image_enum * penum, const byte * buffer,
}
} /* End on x loop */
LINE_ACCUM_COPY(dev, out, bpp, xo, x, raster, ry);
- /*if_debug1('w', "[w]Y=%d:\n", ry);*/ /* See siscale.c about 'w'. */
+ /*if_debug1m('w', penum->memory, "[w]Y=%d:\n", ry);*/ /* See siscale.c about 'w'. */
inactive:
penum->line_xy++;
- if_debug0('B', "\n");
+ if_debug0m('B', penum->memory, "\n");
}
if ((status == 0 && stream_r.ptr == stream_r.limit) || status == EOFC)
break;
diff --git a/gs/base/gxmclip.c b/gs/base/gxmclip.c
index 021b8505d..43f6fc068 100644
--- a/gs/base/gxmclip.c
+++ b/gs/base/gxmclip.c
@@ -15,8 +15,8 @@
/* Mask clipping support */
-#include "gserrors.h"
#include "gx.h"
+#include "gserrors.h"
#include "gxdevice.h"
#include "gxdevmem.h"
#include "gxmclip.h"
diff --git a/gs/base/gxp1fill.c b/gs/base/gxp1fill.c
index 26870e09d..737f65cdc 100644
--- a/gs/base/gxp1fill.c
+++ b/gs/base/gxp1fill.c
@@ -149,6 +149,9 @@ tile_by_steps(tile_fill_state_t * ptfs, int x0, int y0, int w0, int h0,
int i0, i1, j0, j1, i, j;
gs_matrix step_matrix; /* translated by phase */
int code;
+#ifdef DEBUG
+ const gs_memory_t *mem = ptfs->pcdev->memory;
+#endif
ptfs->x0 = x0, ptfs->w0 = w0;
ptfs->y0 = y0, ptfs->h0 = h0;
@@ -165,11 +168,11 @@ tile_by_steps(tile_fill_state_t * ptfs, int x0, int y0, int w0, int h0,
bbox.p.x = x0, bbox.p.y = y0;
bbox.q.x = x1, bbox.q.y = y1;
gs_bbox_transform_inverse(&bbox, &step_matrix, &ibbox);
- if_debug10('T',
+ if_debug10m('T', mem,
"[T]x,y=(%d,%d) w,h=(%d,%d) => (%g,%g),(%g,%g), offset=(%g,%g)\n",
- x0, y0, w0, h0,
- ibbox.p.x, ibbox.p.y, ibbox.q.x, ibbox.q.y,
- step_matrix.tx, step_matrix.ty);
+ x0, y0, w0, h0,
+ ibbox.p.x, ibbox.p.y, ibbox.q.x, ibbox.q.y,
+ step_matrix.tx, step_matrix.ty);
/*
* If the pattern is partly transparent and XStep/YStep is smaller
* than the device space BBox, we need to ensure that we cover
@@ -187,7 +190,7 @@ tile_by_steps(tile_fill_state_t * ptfs, int x0, int y0, int w0, int h0,
i1 = (int)ceil(u1);
j1 = (int)ceil(v1);
}
- if_debug4('T', "[T]i=(%d,%d) j=(%d,%d)\n", i0, i1, j0, j1);
+ if_debug4m('T', mem, "[T]i=(%d,%d) j=(%d,%d)\n", i0, i1, j0, j1);
for (i = i0; i < i1; i++)
for (j = j0; j < j1; j++) {
int x = (int)fastfloor(step_matrix.xx * i +
@@ -198,7 +201,7 @@ tile_by_steps(tile_fill_state_t * ptfs, int x0, int y0, int w0, int h0,
int h = tbits_or_tmask->size.y;
int xoff, yoff;
- if_debug4('T', "[T]i=%d j=%d x,y=(%d,%d)", i, j, x, y);
+ if_debug4m('T', mem, "[T]i=%d j=%d x,y=(%d,%d)", i, j, x, y);
if (x < x0)
xoff = x0 - x, x = x0, w -= xoff;
else
@@ -211,8 +214,8 @@ tile_by_steps(tile_fill_state_t * ptfs, int x0, int y0, int w0, int h0,
w = x1 - x;
if (y + h > y1)
h = y1 - y;
- if_debug6('T', "=>(%d,%d) w,h=(%d,%d) x/yoff=(%d,%d)\n",
- x, y, w, h, xoff, yoff);
+ if_debug6m('T', mem, "=>(%d,%d) w,h=(%d,%d) x/yoff=(%d,%d)\n",
+ x, y, w, h, xoff, yoff);
if (w > 0 && h > 0) {
if (ptfs->pcdev == (gx_device *) & ptfs->cdev)
tile_clip_set_phase(&ptfs->cdev,
@@ -324,10 +327,10 @@ tile_pattern_clist(const tile_fill_state_t * ptfs,
/* Also allocate the icc cache for the clist reader */
if ( crdev->icc_cache_cl == NULL )
crdev->icc_cache_cl = gsicc_cache_new(crdev->memory);
- if_debug0('L', "Pattern clist playback begin\n");
+ if_debug0m('L', dev->memory, "Pattern clist playback begin\n");
code = clist_playback_file_bands(playback_action_render,
crdev, &crdev->page_info, dev, 0, 0, ptfs->xoff - x, ptfs->yoff - y);
- if_debug0('L', "Pattern clist playback end\n");
+ if_debug0m('L', dev->memory, "Pattern clist playback end\n");
return code;
}
@@ -572,6 +575,9 @@ tile_by_steps_trans(tile_fill_trans_state_t * ptfs, int x0, int y0, int w0, int
int i0, i1, j0, j1, i, j;
gs_matrix step_matrix; /* translated by phase */
gx_pattern_trans_t *ptrans_pat = ptile->ttrans;
+#ifdef DEBUG
+ const gs_memory_t *mem = ptfs->pcdev->memory;
+#endif
ptfs->x0 = x0, ptfs->w0 = w0;
ptfs->y0 = y0, ptfs->h0 = h0;
@@ -588,11 +594,11 @@ tile_by_steps_trans(tile_fill_trans_state_t * ptfs, int x0, int y0, int w0, int
bbox.p.x = x0, bbox.p.y = y0;
bbox.q.x = x1, bbox.q.y = y1;
gs_bbox_transform_inverse(&bbox, &step_matrix, &ibbox);
- if_debug10('T',
+ if_debug10m('T', mem,
"[T]x,y=(%d,%d) w,h=(%d,%d) => (%g,%g),(%g,%g), offset=(%g,%g)\n",
- x0, y0, w0, h0,
- ibbox.p.x, ibbox.p.y, ibbox.q.x, ibbox.q.y,
- step_matrix.tx, step_matrix.ty);
+ x0, y0, w0, h0,
+ ibbox.p.x, ibbox.p.y, ibbox.q.x, ibbox.q.y,
+ step_matrix.tx, step_matrix.ty);
/*
* If the pattern is partly transparent and XStep/YStep is smaller
* than the device space BBox, we need to ensure that we cover
@@ -610,7 +616,7 @@ tile_by_steps_trans(tile_fill_trans_state_t * ptfs, int x0, int y0, int w0, int
i1 = (int)ceil(u1);
j1 = (int)ceil(v1);
}
- if_debug4('T', "[T]i=(%d,%d) j=(%d,%d)\n", i0, i1, j0, j1);
+ if_debug4m('T', mem, "[T]i=(%d,%d) j=(%d,%d)\n", i0, i1, j0, j1);
for (i = i0; i < i1; i++)
for (j = j0; j < j1; j++) {
int x = (int)fastfloor(step_matrix.xx * i +
@@ -622,7 +628,7 @@ tile_by_steps_trans(tile_fill_trans_state_t * ptfs, int x0, int y0, int w0, int
int xoff, yoff;
int px, py;
- if_debug4('T', "[T]i=%d j=%d x,y=(%d,%d)", i, j, x, y);
+ if_debug4m('T', mem, "[T]i=%d j=%d x,y=(%d,%d)", i, j, x, y);
if (x < x0)
xoff = x0 - x, x = x0, w -= xoff;
else
@@ -635,8 +641,8 @@ tile_by_steps_trans(tile_fill_trans_state_t * ptfs, int x0, int y0, int w0, int
w = x1 - x;
if (y + h > y1)
h = y1 - y;
- if_debug6('T', "=>(%d,%d) w,h=(%d,%d) x/yoff=(%d,%d)\n",
- x, y, w, h, xoff, yoff);
+ if_debug6m('T', mem, "=>(%d,%d) w,h=(%d,%d) x/yoff=(%d,%d)\n",
+ x, y, w, h, xoff, yoff);
if (w > 0 && h > 0) {
px = imod(xoff - x, ptile->ttrans->width);
diff --git a/gs/base/gxpath.c b/gs/base/gxpath.c
index 63edf1ced..dc97511a1 100644
--- a/gs/base/gxpath.c
+++ b/gs/base/gxpath.c
@@ -31,12 +31,12 @@ static int path_alloc_copy(gx_path *);
static int gx_path_new_subpath(gx_path *);
#ifdef DEBUG
-static void gx_print_segment(const segment *);
+static void gx_print_segment(const gs_memory_t *,const segment *);
-# define trace_segment(msg, pseg)\
- if ( gs_debug_c('P') ) dlprintf(msg), gx_print_segment(pseg);
+# define trace_segment(msg, mem, pseg)\
+ if ( gs_debug_c('P') ) dmlprintf(mem, msg), gx_print_segment(mem,pseg);
#else
-# define trace_segment(msg, pseg) DO_NOTHING
+# define trace_segment(msg, mem, pseg) DO_NOTHING
#endif
/* Check a point against a preset bounding box. */
@@ -380,7 +380,7 @@ rc_free_path_segments_local(gs_memory_t * mem, void *vpsegs,
while (pseg) {
segment *prev = pseg->prev;
- trace_segment("[P]release", pseg);
+ trace_segment("[P]release", mem, pseg);
gs_free_object(mem, pseg, cname);
pseg = prev;
}
@@ -479,7 +479,7 @@ gx_path_new_subpath(gx_path * ppath)
}
ppath->current_subpath = spp;
ppath->subpath_count++;
- trace_segment("[P]", (const segment *)spp);
+ trace_segment("[P]", ppath->memory, (const segment *)spp);
return 0;
}
@@ -584,7 +584,7 @@ gz_path_add_line_notes(gx_path * ppath, fixed x, fixed y, segment_notes notes)
path_alloc_link(lp);
path_set_point(lp, x, y);
path_update_draw(ppath);
- trace_segment("[P]", (segment *) lp);
+ trace_segment("[P]", ppath->memory, (segment *) lp);
return 0;
}
static int
@@ -614,7 +614,7 @@ gz_path_add_gap_notes(gx_path * ppath, fixed x, fixed y, segment_notes notes)
path_alloc_link(lp);
path_set_point(lp, x, y);
path_update_draw(ppath);
- trace_segment("[P]", (segment *) lp);
+ trace_segment("[P]", ppath->memory, (segment *) lp);
return 0;
}
static int
@@ -673,7 +673,7 @@ gx_path_add_lines_notes(gx_path *ppath, const gs_fixed_point *ppts, int count,
lp->pt.x = x;
lp->pt.y = y;
prev = (segment *) lp;
- trace_segment("[P]", (segment *) lp);
+ trace_segment("[P]", ppath->memory, (segment *) lp);
}
if (lp != 0)
ppath->position.x = lp->pt.x,
@@ -702,7 +702,7 @@ gx_path_add_dash_notes(gx_path * ppath, fixed x, fixed y, fixed dx, fixed dy, se
lp->tangent.x = dx;
lp->tangent.y = dy;
path_update_draw(ppath);
- trace_segment("[P]", (segment *) lp);
+ trace_segment("[P]", ppath->memory, (segment *) lp);
return 0;
}
@@ -759,7 +759,7 @@ gz_path_add_curve_notes(gx_path * ppath,
psub->curve_count++;
ppath->curve_count++;
path_update_draw(ppath);
- trace_segment("[P]", (segment *) lp);
+ trace_segment("[P]", ppath->memory, (segment *) lp);
return 0;
}
static int
@@ -913,7 +913,7 @@ gz_path_close_subpath_notes(gx_path * ppath, segment_notes notes)
lp->sub = psub;
psub->is_closed = 1;
path_update_closepath(ppath);
- trace_segment("[P]", (segment *) lp);
+ trace_segment("[P]", ppath->memory, (segment *) lp);
return 0;
}
static int
@@ -998,7 +998,7 @@ path_alloc_copy(gx_path * ppath)
void
gx_dump_path(const gx_path * ppath, const char *tag)
{
- dlprintf2("[P]Path 0x%lx %s:\n", (ulong) ppath, tag);
+ dmlprintf2(ppath->memory, "[P]Path 0x%lx %s:\n", (ulong) ppath, tag);
gx_path_print(ppath);
}
@@ -1008,26 +1008,28 @@ gx_path_print(const gx_path * ppath)
{
const segment *pseg = (const segment *)ppath->first_subpath;
- dlprintf5(" %% state_flags=%d subpaths=%d, curves=%d, point=(%f,%f)\n",
- ppath->state_flags, ppath->subpath_count, ppath->curve_count,
- fixed2float(ppath->position.x),
- fixed2float(ppath->position.y));
- dlprintf5(" %% box=(%f,%f),(%f,%f) last=0x%lx\n",
- fixed2float(ppath->bbox.p.x), fixed2float(ppath->bbox.p.y),
- fixed2float(ppath->bbox.q.x), fixed2float(ppath->bbox.q.y),
- (ulong) ppath->box_last);
- dlprintf4(" %% segments=0x%lx (refct=%ld, first=0x%lx, current=0x%lx)\n",
- (ulong) ppath->segments, (long)ppath->segments->rc.ref_count,
- (ulong) ppath->segments->contents.subpath_first,
- (ulong) ppath->segments->contents.subpath_current);
+ dmlprintf5(ppath->memory,
+ " %% state_flags=%d subpaths=%d, curves=%d, point=(%f,%f)\n",
+ ppath->state_flags, ppath->subpath_count, ppath->curve_count,
+ fixed2float(ppath->position.x),
+ fixed2float(ppath->position.y));
+ dmlprintf5(ppath->memory," %% box=(%f,%f),(%f,%f) last=0x%lx\n",
+ fixed2float(ppath->bbox.p.x), fixed2float(ppath->bbox.p.y),
+ fixed2float(ppath->bbox.q.x), fixed2float(ppath->bbox.q.y),
+ (ulong) ppath->box_last);
+ dmlprintf4(ppath->memory,
+ " %% segments=0x%lx (refct=%ld, first=0x%lx, current=0x%lx)\n",
+ (ulong) ppath->segments, (long)ppath->segments->rc.ref_count,
+ (ulong) ppath->segments->contents.subpath_first,
+ (ulong) ppath->segments->contents.subpath_current);
while (pseg) {
- dlputs("");
- gx_print_segment(pseg);
+ dmlputs(ppath->memory,"");
+ gx_print_segment(ppath->memory, pseg);
pseg = pseg->next;
}
}
static void
-gx_print_segment(const segment * pseg)
+gx_print_segment(const gs_memory_t *mem, const segment * pseg)
{
double px = fixed2float(pseg->pt.x);
double py = fixed2float(pseg->pt.y);
@@ -1039,45 +1041,45 @@ gx_print_segment(const segment * pseg)
case s_start:{
const subpath *const psub = (const subpath *)pseg;
- dprintf5(" %1.4f %1.4f moveto\t%% %s #curves=%d last=0x%lx\n",
- px, py, out, psub->curve_count, (ulong) psub->last);
+ dmprintf5(mem, " %1.4f %1.4f moveto\t%% %s #curves=%d last=0x%lx\n",
+ px, py, out, psub->curve_count, (ulong) psub->last);
break;
}
case s_curve:{
const curve_segment *const pcur = (const curve_segment *)pseg;
- dprintf7(" %1.4f %1.4f %1.4f %1.4f %1.4f %1.4f curveto\t%% %s\n",
- fixed2float(pcur->p1.x), fixed2float(pcur->p1.y),
- fixed2float(pcur->p2.x), fixed2float(pcur->p2.y),
- px, py, out);
+ dmprintf7(mem, " %1.4f %1.4f %1.4f %1.4f %1.4f %1.4f curveto\t%% %s\n",
+ fixed2float(pcur->p1.x), fixed2float(pcur->p1.y),
+ fixed2float(pcur->p2.x), fixed2float(pcur->p2.y),
+ px, py, out);
break;
}
case s_line:
- dprintf3(" %1.4f %1.4f lineto\t%% %s\n", px, py, out);
+ dmprintf3(mem, " %1.4f %1.4f lineto\t%% %s\n", px, py, out);
break;
case s_gap:
- dprintf3(" %1.4f %1.4f gapto\t%% %s\n", px, py, out);
+ dmprintf3(mem, " %1.4f %1.4f gapto\t%% %s\n", px, py, out);
break;
case s_dash:{
const dash_segment *const pd = (const dash_segment *)pseg;
- dprintf5(" %1.4f %1.4f %1.4f %1.4f dash\t%% %s\n",
- fixed2float(pd->pt.x), fixed2float(pd->pt.y),
- fixed2float(pd->tangent.x),fixed2float(pd->tangent.y),
- out);
+ dmprintf5(mem, " %1.4f %1.4f %1.4f %1.4f dash\t%% %s\n",
+ fixed2float(pd->pt.x), fixed2float(pd->pt.y),
+ fixed2float(pd->tangent.x),fixed2float(pd->tangent.y),
+ out);
break;
}
case s_line_close:{
const line_close_segment *const plc =
(const line_close_segment *)pseg;
- dprintf4(" closepath\t%% %s %1.4f %1.4f 0x%lx\n",
- out, px, py, (ulong) (plc->sub));
+ dmprintf4(mem, " closepath\t%% %s %1.4f %1.4f 0x%lx\n",
+ out, px, py, (ulong) (plc->sub));
break;
}
default:
- dprintf4(" %1.4f %1.4f <type 0x%x>\t%% %s\n",
- px, py, pseg->type, out);
+ dmprintf4(mem, " %1.4f %1.4f <type 0x%x>\t%% %s\n",
+ px, py, pseg->type, out);
}
}
diff --git a/gs/base/gxpath.h b/gs/base/gxpath.h
index 10475919a..f40a1cd2c 100644
--- a/gs/base/gxpath.h
+++ b/gs/base/gxpath.h
@@ -384,7 +384,7 @@ segment_notes
gx_cpath_enum_notes(const gs_cpath_enum *);
#ifdef DEBUG
-void gx_cpath_print(const gx_clip_path *);
+void gx_cpath_print(const gs_memory_t *mem, const gx_clip_path *);
#endif
#endif /* gxpath_INCLUDED */
diff --git a/gs/base/gxpcmap.c b/gs/base/gxpcmap.c
index 1d00218e0..818ee144d 100644
--- a/gs/base/gxpcmap.c
+++ b/gs/base/gxpcmap.c
@@ -287,7 +287,7 @@ gx_pattern_accum_alloc(gs_memory_t * mem, gs_memory_t * storage_memory,
return 0;
#ifdef DEBUG
if (pinst->is_clist)
- eprintf("not using clist even though clist is requested\n");
+ emprintf(mem, "not using clist even though clist is requested\n");
#endif
pinst->is_clist = false;
gx_device_init((gx_device *)adev,
@@ -1328,7 +1328,7 @@ gx_pattern_load(gx_device_color * pdc, const gs_imager_state * pis,
saved->pattern_cache = pis->pattern_cache;
gs_setdevice_no_init(saved, (gx_device *)adev);
if (pinst->templat.uses_transparency) {
- if_debug0('v', "gx_pattern_load: pushing the pdf14 compositor device into this graphics state\n");
+ if_debug0m('v', mem, "gx_pattern_load: pushing the pdf14 compositor device into this graphics state\n");
if ((code = gs_push_pdf14trans_device(saved, true)) < 0)
return code;
saved->device->is_open = true;
@@ -1367,7 +1367,7 @@ gx_pattern_load(gx_device_color * pdc, const gs_imager_state * pis,
return code;
}
if (pinst->templat.uses_transparency) {
- /* if_debug0('v', "gx_pattern_load: popping the pdf14 compositor device from this graphics state\n");
+ /* if_debug0m('v', saved->memory, "gx_pattern_load: popping the pdf14 compositor device from this graphics state\n");
if ((code = gs_pop_pdf14trans_device(saved, true)) < 0)
return code; */
if (pinst->is_clist) {
@@ -1393,7 +1393,7 @@ gx_pattern_load(gx_device_color * pdc, const gs_imager_state * pis,
adev, &ctile);
if (code >= 0) {
if (!gx_pattern_cache_lookup(pdc, pis, dev, select)) {
- lprintf("Pattern cache lookup failed after insertion!\n");
+ mlprintf(mem, "Pattern cache lookup failed after insertion!\n");
code = gs_note_error(gs_error_Fatal);
}
}
@@ -1402,10 +1402,12 @@ gx_pattern_load(gx_device_color * pdc, const gs_imager_state * pis,
gx_device_pattern_accum *pdev = (gx_device_pattern_accum *)adev;
if (pdev->mask)
- debug_dump_bitmap(pdev->mask->base, pdev->mask->raster,
+ debug_dump_bitmap(pdev->memory,
+ pdev->mask->base, pdev->mask->raster,
pdev->mask->height, "[B]Pattern mask");
if (pdev->bits)
- debug_dump_bitmap(((gx_device_memory *) pdev->target)->base,
+ debug_dump_bitmap(pdev->memory,
+ ((gx_device_memory *) pdev->target)->base,
((gx_device_memory *) pdev->target)->raster,
pdev->target->height, "[B]Pattern bits");
}
diff --git a/gs/base/gxpflat.c b/gs/base/gxpflat.c
index b581a6b91..145cbccf9 100644
--- a/gs/base/gxpflat.c
+++ b/gs/base/gxpflat.c
@@ -204,6 +204,7 @@ gx_flattened_iterator__init(gx_flattened_iterator *self,
self->curve = true;
vd_curve(self->x0, self->y0, x1, y1, x2, y2, self->x3, self->y3, 0, RGB(255, 255, 255));
self->k = k;
+#ifndef GS_THREADSAFE
# ifdef DEBUG
if (gs_debug_c('3')) {
dlprintf4("[3]x0=%f y0=%f x1=%f y1=%f\n",
@@ -214,6 +215,7 @@ gx_flattened_iterator__init(gx_flattened_iterator *self,
fixed2float(self->x3), fixed2float(self->y3), self->k);
}
# endif
+#endif
if (k == -1) {
/* A special hook for gx_subdivide_curve_rec.
Only checked the range.
@@ -335,7 +337,7 @@ gx_flattened_iterator__init_line(gx_flattened_iterator *self,
return true;
}
-#ifdef DEBUG
+#if defined(DEBUG) && !defined(GS_THREADSAFE)
static inline void
gx_flattened_iterator__print_state(gx_flattened_iterator *self)
{
@@ -421,7 +423,7 @@ gx_flattened_iterator__next(gx_flattened_iterator *self)
--self->i;
if (self->i == 0)
goto last; /* don't bother with last accum */
-# ifdef DEBUG
+# if defined(DEBUG) && !defined(GS_THREADSAFE)
gx_flattened_iterator__print_state(self);
# endif
# define accum(i, r, di, dr, rmask)\
@@ -495,7 +497,7 @@ gx_flattened_iterator__prev(gx_flattened_iterator *self)
}
gx_flattened_iterator__unaccum(self);
self->i++;
-# ifdef DEBUG
+# if defined(DEBUG) && !defined(GS_THREADSAFE)
if_debug5('3', "[3]%s x=%g, y=%g x=%ld y=%ld\n",
(((self->x ^ self->lx1) | (self->y ^ self->ly1)) & float2fixed(-0.5) ?
"add" : "skip"),
diff --git a/gs/base/gxstroke.c b/gs/base/gxstroke.c
index b3ea7b1cb..7b7d2d65f 100644
--- a/gs/base/gxstroke.c
+++ b/gs/base/gxstroke.c
@@ -502,19 +502,19 @@ gx_stroke_path_only_aux(gx_path * ppath, gx_path * to_path, gx_device * pdev,
int count = pgs_lp->dash.pattern_size;
int i;
- dlprintf4("[o]half_width=%f, start_cap=%d, end_cap=%d, dash_cap=%d,\n",
- pgs_lp->half_width, (int)pgs_lp->start_cap,
- (int)pgs_lp->end_cap, (int)pgs_lp->dash_cap);
- dlprintf3(" join=%d, miter_limit=%f, miter_check=%f,\n",
- (int)pgs_lp->join, pgs_lp->miter_limit,
- pgs_lp->miter_check);
- dlprintf1(" dash pattern=%d", count);
+ dmlprintf4(ppath->memory, "[o]half_width=%f, start_cap=%d, end_cap=%d, dash_cap=%d,\n",
+ pgs_lp->half_width, (int)pgs_lp->start_cap,
+ (int)pgs_lp->end_cap, (int)pgs_lp->dash_cap);
+ dmlprintf3(ppath->memory, " join=%d, miter_limit=%f, miter_check=%f,\n",
+ (int)pgs_lp->join, pgs_lp->miter_limit,
+ pgs_lp->miter_check);
+ dmlprintf1(ppath->memory, " dash pattern=%d", count);
for (i = 0; i < count; i++)
- dprintf1(",%f", pgs_lp->dash.pattern[i]);
- dputs(",\n");
- dlprintf4("\toffset=%f, init(ink_on=%d, index=%d, dist_left=%f)\n",
- pgs_lp->dash.offset, pgs_lp->dash.init_ink_on,
- pgs_lp->dash.init_index, pgs_lp->dash.init_dist_left);
+ dmprintf1(ppath->memory, ",%f", pgs_lp->dash.pattern[i]);
+ dmputs(ppath->memory, ",\n");
+ dmlprintf4(ppath->memory, "\toffset=%f, init(ink_on=%d, index=%d, dist_left=%f)\n",
+ pgs_lp->dash.offset, pgs_lp->dash.init_ink_on,
+ pgs_lp->dash.init_index, pgs_lp->dash.init_dist_left);
}
#endif
@@ -560,9 +560,9 @@ gx_stroke_path_only_aux(gx_path * ppath, gx_path * to_path, gx_device * pdev,
if (pcpath) {
gx_cpath_outer_box(pcpath, &bbox);
- if_debug4('f', " outer_box=(%g,%g),(%g,%g)\n",
- fixed2float(bbox.p.x), fixed2float(bbox.p.y),
- fixed2float(bbox.q.x), fixed2float(bbox.q.y));
+ if_debug4m('f', ppath->memory, " outer_box=(%g,%g),(%g,%g)\n",
+ fixed2float(bbox.p.x), fixed2float(bbox.p.y),
+ fixed2float(bbox.q.x), fixed2float(bbox.q.y));
rect_intersect(ibox, bbox);
} else
rect_intersect(ibox, cbox);
@@ -644,7 +644,7 @@ gx_stroke_path_only_aux(gx_path * ppath, gx_path * to_path, gx_device * pdev,
}
}
}
- if_debug7('o', "[o]ctm=(%g,%g,%g,%g,%g,%g) thin=%d\n",
+ if_debug7m('o', ppath->memory, "[o]ctm=(%g,%g,%g,%g,%g,%g) thin=%d\n",
xx, xy, yx, yy, pis->ctm.tx, pis->ctm.ty, always_thin);
if (device_dot_length != 0) {
/*
@@ -1256,9 +1256,9 @@ adjust_stroke(gx_device *dev, pl_ptr plp, const gs_imager_state * pis,
if (plp->o.p.x < dev->sgr.orig[0].x ||
(plp->o.p.x == dev->sgr.orig[0].x && plp->o.p.y < dev->sgr.orig[0].y)) {
/* Left contact, adjust to keep the contact. */
- if_debug4('O', "[O]don't adjust {{%f,%f},{%f,%f}}\n",
- fixed2float(plp->o.p.x), fixed2float(plp->o.p.y),
- fixed2float(plp->e.p.x), fixed2float(plp->e.p.y));
+ if_debug4m('O', dev->memory, "[O]don't adjust {{%f,%f},{%f,%f}}\n",
+ fixed2float(plp->o.p.x), fixed2float(plp->o.p.y),
+ fixed2float(plp->e.p.x), fixed2float(plp->e.p.y));
plp->width.x += (shift_o_x - delta_w_x) / 2;
plp->width.y += (shift_o_y - delta_w_y) / 2;
plp->o.p.x += (shift_o_x - delta_w_x) / 2;
@@ -1268,9 +1268,9 @@ adjust_stroke(gx_device *dev, pl_ptr plp, const gs_imager_state * pis,
adjust = false;
} else {
/* Right contact, adjust to keep the contact. */
- if_debug4('O', "[O]don't adjust {{%f,%f},{%f,%f}}\n",
- fixed2float(plp->o.p.x), fixed2float(plp->o.p.y),
- fixed2float(plp->e.p.x), fixed2float(plp->e.p.y));
+ if_debug4m('O', dev->memory, "[O]don't adjust {{%f,%f},{%f,%f}}\n",
+ fixed2float(plp->o.p.x), fixed2float(plp->o.p.y),
+ fixed2float(plp->e.p.x), fixed2float(plp->e.p.y));
plp->width.x -= (shift_o_x + delta_w_x) / 2;
plp->width.y -= (shift_o_y + delta_w_y) / 2;
plp->o.p.x += (shift_o_x + delta_w_x) / 2;
@@ -1328,7 +1328,7 @@ line_intersect(
double f1;
double max_result = any_abs(denom) * (double)max_fixed;
-#ifdef DEBUG
+#if defined(DEBUG) && !defined(GS_THREADSAFE)
if (gs_debug_c('O')) {
dlprintf4("[o]Intersect %f,%f(%f/%f)",
fixed2float(pp1->x), fixed2float(pp1->y),
@@ -1994,7 +1994,7 @@ check_miter(const gx_line_params * pgs_lp, pl_ptr plp, pl_ptr nplp,
* we actually have to do the test backwards.
*/
ccw0 = v1 * u2 < v2 * u1;
-#ifdef DEBUG
+#if defined(DEBUG) && !defined(GS_THREADSAFE)
{
double a1 = atan2(u1, v1), a2 = atan2(u2, v2), dif = a1 - a2;
@@ -2017,7 +2017,7 @@ check_miter(const gx_line_params * pgs_lp, pl_ptr plp, pl_ptr nplp,
*/
if (!ccw0) /* have plp - nplp, want vice versa */
num = -num;
-#ifdef DEBUG
+#if defined(DEBUG) && !defined(GS_THREADSAFE)
if (gs_debug_c('O')) {
dlprintf4("[o]Miter check: u1/v1=%f/%f, u2/v2=%f/%f,\n",
u1, v1, u2, v2);
@@ -2310,7 +2310,7 @@ compute_caps(pl_ptr plp)
plp->o.ce.x = plp->o.p.x - wx2, plp->o.ce.y = plp->o.p.y - wy2;
plp->e.co.x = plp->e.p.x - wx2, plp->e.co.y = plp->e.p.y - wy2;
plp->e.ce.x = plp->e.p.x + wx2, plp->e.ce.y = plp->e.p.y + wy2;
-#ifdef DEBUG
+#if defined(DEBUG) && !defined(GS_THREADSAFE)
if (gs_debug_c('O')) {
dlprintf4("[o]Stroke o=(%f,%f) e=(%f,%f)\n",
fixed2float(plp->o.p.x), fixed2float(plp->o.p.y),
diff --git a/gs/base/gxtype1.c b/gs/base/gxtype1.c
index 0fa1e02d5..f5b0d22fb 100644
--- a/gs/base/gxtype1.c
+++ b/gs/base/gxtype1.c
@@ -107,7 +107,7 @@ gs_type1_interp_init(register gs_type1_state * pcis, gs_imager_state * pis,
const gs_log2_scale_point *plog2_subpixels =
(FORCE_HINTS_TO_BIG_PIXELS ? (psubpixels != NULL ? psubpixels : plog2_scale) : &no_scale);
- if_debug0('1', "[1]gs_type1_interp_init\n");
+ if_debug0m('1', pis->memory, "[1]gs_type1_interp_init\n");
pcis->pfont = pfont;
pcis->pis = pis;
pcis->path = ppath;
diff --git a/gs/base/lib.mak b/gs/base/lib.mak
index 3f6590eff..dde87d686 100644
--- a/gs/base/lib.mak
+++ b/gs/base/lib.mak
@@ -2493,7 +2493,7 @@ $(GLOBJ)gdevpsfu.$(OBJ) : $(GLSRC)gdevpsfu.c $(AK) $(gx_h)\
$(GLOBJ)gdevpsfx.$(OBJ) : $(GLSRC)gdevpsfx.c $(AK) $(gx_h)\
$(gserrors_h) $(math__h) $(memory__h)\
$(gxfixed_h) $(gxfont_h) $(gxfont1_h) $(gxmatrix_h) $(gxtype1_h)\
- $(stream_h) $(gdevpsf_h) $(MAKEDIRS)
+ $(stream_h) $(gdevpsf_h) $(gxistate_h) $(MAKEDIRS)
$(GLCC) $(GLO_)gdevpsfx.$(OBJ) $(C_) $(GLSRC)gdevpsfx.c
# ---------------- Font copying ---------------- #
diff --git a/gs/base/sbwbs.c b/gs/base/sbwbs.c
index 815e0c765..30642c952 100644
--- a/gs/base/sbwbs.c
+++ b/gs/base/sbwbs.c
@@ -77,8 +77,8 @@ s_buffered_process(stream_state * st, stream_cursor_read * pr, bool last)
return 1;
if (left < count)
count = left;
- if_debug3('w', "[w]buffering %d bytes to position %d, last = %s\n",
- count, ss->bpos, (last ? "true" : "false"));
+ if_debug3m('w', st->memory, "[w]buffering %d bytes to position %d, last = %s\n",
+ count, ss->bpos, (last ? "true" : "false"));
memcpy(ss->buffer + ss->bpos, p + 1, count);
pr->ptr = p += count;
ss->bpos += count;
@@ -485,7 +485,7 @@ s_BWBSD_process(stream_state * st, stream_cursor_read * pr,
I = (I << 8) + *++p;
ss->N = N;
ss->I = I;
- if_debug2('w', "[w]N=%d I=%d\n", N, I);
+ if_debug2m('w', ss->memory, "[w]N=%d I=%d\n", N, I);
pr->ptr = p;
if (N < 0 || N > ss->BlockSize || I < 0 || I >= N)
return ERRC;
diff --git a/gs/base/scfd.c b/gs/base/scfd.c
index 411b6cdb5..970c9258b 100644
--- a/gs/base/scfd.c
+++ b/gs/base/scfd.c
@@ -223,12 +223,13 @@ s_CFD_process(stream_state * st, stream_cursor_read * pr,
{
hcd_declare_state;
hcd_load_state();
- if_debug8('w', "[w]CFD_process top: eol_count=%d, k_left=%d, rows_left=%d\n"
- " bits=0x%lx, bits_left=%d, read %u, wrote %u%s\n",
- eol_count, k_left, rows_left,
- (ulong) bits, bits_left,
- (uint) (p - rstart), (uint) (pw->ptr - wstart),
- (ss->skipping_damage ? ", skipping damage" : ""));
+ if_debug8m('w', ss->memory,
+ "[w]CFD_process top: eol_count=%d, k_left=%d, rows_left=%d\n"
+ " bits=0x%lx, bits_left=%d, read %u, wrote %u%s\n",
+ eol_count, k_left, rows_left,
+ (ulong) bits, bits_left,
+ (uint) (p - rstart), (uint) (pw->ptr - wstart),
+ (ss->skipping_damage ? ", skipping damage" : ""));
}
#endif
if (ss->skipping_damage) { /* Skip until we reach an EOL. */
@@ -314,7 +315,7 @@ s_CFD_process(stream_state * st, stream_cursor_read * pr,
*/
ck_eol:
while ((status = cf_decode_eol(ss, pr)) > 0) {
- if_debug0('w', "[w]EOL\n");
+ if_debug0m('w', ss->memory, "[w]EOL\n");
/* If we are in a Group 3 mixed regime, */
/* check the next bit for 1- vs. 2-D. */
if (ss->K > 0) {
@@ -352,17 +353,17 @@ ck_eol:
}
/* Now decode actual data. */
if (k_left < 0) {
- if_debug0('w', "[w2]new row\n");
+ if_debug0m('w', ss->memory, "[w2]new row\n");
status = cf_decode_2d(ss, pr);
} else if (k_left == 0) {
- if_debug0('w', "[w1]new row\n");
+ if_debug0m('w', ss->memory, "[w1]new row\n");
status = cf_decode_1d(ss, pr);
} else {
- if_debug1('w', "[w1]new 2-D row, k_left=%d\n", k_left);
+ if_debug1m('w', ss->memory, "[w1]new 2-D row, k_left=%d\n", k_left);
status = cf_decode_2d(ss, pr);
}
- if_debug3('w', "[w]CFD status = %d, wpos = %d, cbit = %d\n",
- status, ss->wpos, ss->cbit);
+ if_debug3m('w', ss->memory, "[w]CFD status = %d, wpos = %d, cbit = %d\n",
+ status, ss->wpos, ss->cbit);
check:switch (status) {
case 1: /* output full */
goto top;
@@ -450,7 +451,7 @@ cf_decode_1d(stream_CFD_state * ss, stream_cursor_read * pr)
int bcnt;
cfd_load_state();
- if_debug1('w', "[w1]entry run_color = %d\n", ss->run_color);
+ if_debug1m('w', ss->memory, "[w1]entry run_color = %d\n", ss->run_color);
if (ss->run_color > 0)
goto db;
else
@@ -512,7 +513,7 @@ cf_decode_1d(stream_CFD_state * ss, stream_cursor_read * pr)
status = 1;
out:cfd_store_state();
ss->run_color = run_color;
- if_debug1('w', "[w1]exit run_color = %d\n", run_color);
+ if_debug1m('w', ss->memory, "[w1]exit run_color = %d\n", run_color);
return status;
out0: /* We already set run_color to 0 or -1. */
status = 0;
@@ -544,7 +545,7 @@ cf_decode_2d(stream_CFD_state * ss, stream_cursor_read * pr)
count = ((endptr - q) << 3) + qbit;
endptr[1] = 0xa0; /* a byte with some 0s and some 1s, */
/* to ensure run scan will stop */
- if_debug1('W', "[w2]raster=%d\n", raster);
+ if_debug1m('W', ss->memory, "[w2]raster=%d\n", raster);
switch (ss->run_color) {
case -2:
ss->run_color = 0;
@@ -567,15 +568,15 @@ cf_decode_2d(stream_CFD_state * ss, stream_cursor_read * pr)
/* If invert == invert_white, white and black have their */
/* correct meanings; if invert == ~invert_white, */
/* black and white are interchanged. */
- if_debug1('W', "[w2]%4d:\n", count);
+ if_debug1m('W', ss->memory, "[w2]%4d:\n", count);
#ifdef DEBUG
/* Check the invariant between q, qbit, and count. */
{
int pcount = (endptr - q) * 8 + qbit;
if (pcount != count)
- dlprintf2("[w2]Error: count=%d pcount=%d\n",
- count, pcount);
+ dmlprintf2(ss->memory, "[w2]Error: count=%d pcount=%d\n",
+ count, pcount);
}
#endif
/*
@@ -652,37 +653,37 @@ v0: skip_bits(1);
if ((prev_data & count_bit[prev_count & 7]) &&
(prev_count < init_count || invert != invert_white)
) { /* Look for changing white first. */
- if_debug1('W', " data=0x%x", prev_data);
+ if_debug1m('W', ss->memory, " data=0x%x", prev_data);
skip_black_pixels(prev_data, prev_q,
prev_count, invert, plen);
if (prev_count < end_count) /* overshot */
prev_count = end_count;
- if_debug1('W', " b1 other=%d", prev_count);
+ if_debug1m('W', ss->memory, " b1 other=%d", prev_count);
}
if (prev_count != end_count) {
- if_debug1('W', " data=0x%x", prev_data);
+ if_debug1m('W', ss->memory, " data=0x%x", prev_data);
skip_white_pixels(prev_data, prev_q,
prev_count, invert, plen);
if (prev_count < end_count) /* overshot */
prev_count = end_count;
- if_debug1('W', " b1 same=%d", prev_count);
+ if_debug1m('W', ss->memory, " b1 same=%d", prev_count);
}
/* b1 = prev_count; */
if (rlen == run2_pass) { /* Pass mode. Find b2. */
if (prev_count != end_count) {
- if_debug1('W', " data=0x%x", prev_data);
+ if_debug1m('W', ss->memory, " data=0x%x", prev_data);
skip_black_pixels(prev_data, prev_q,
prev_count, invert, plen);
if (prev_count < end_count) /* overshot */
prev_count = end_count;
}
/* b2 = prev_count; */
- if_debug2('W', " b2=%d, pass %d\n",
+ if_debug2m('W', ss->memory, " b2=%d, pass %d\n",
prev_count, count - prev_count);
} else { /* Vertical coding. */
/* Remember that count counts *down*. */
prev_count += rlen - vertical_0; /* a1 */
- if_debug2('W', " vertical %d -> %d\n",
+ if_debug2m('W', ss->memory, " vertical %d -> %d\n",
rlen - vertical_0, prev_count);
}
/* Now either invert or skip from count */
@@ -790,11 +791,11 @@ cf_decode_uncompressed(stream * s)
break;
}
if (rlen == cfd_uncompressed_initial_bits) { /* Longest representable white run */
- if_debug1('W', "[wu]%d\n", rlen);
+ if_debug1m('W', s->memory, "[wu]%d\n", rlen);
if ((qbit -= cfd_uncompressed_initial_bits) < 0)
qbit += 8, q++;
} else {
- if_debug1('W', "[wu]%d+1\n", rlen);
+ if_debug1m('W', s->memory, "[wu]%d+1\n", rlen);
if (qbit -= rlen < 0)
qbit += 8, q++;
*q ^= 1 << qbit;
@@ -807,7 +808,7 @@ cf_decode_uncompressed(stream * s)
np = &cf_uncompressed_decode[rlen + peek_var_bits(clen)];
rlen = np->run_length;
skip_bits(np->code_length);
- if_debug1('w', "[wu]exit %d\n", rlen);
+ if_debug1m('w', s->memory, "[wu]exit %d\n", rlen);
if (rlen >= 0) { /* Valid exit code, rlen = 2 * run length + next polarity */
if ((qbit -= rlen >> 1) < 0)
qbit += 8, q++;
diff --git a/gs/base/scfe.c b/gs/base/scfe.c
index 04542dda3..177f00b7b 100644
--- a/gs/base/scfe.c
+++ b/gs/base/scfe.c
@@ -37,19 +37,19 @@ static stats_runs_t stats_white_runs, stats_black_runs;
#define COUNT_RUN(tab, i) (tab)[i]++;
static void
-print_run_stats(const stats_runs_t * stats)
+print_run_stats(const gs_memory_t *mem, const stats_runs_t * stats)
{
int i;
ulong total;
for (i = 0, total = 0; i < 41; i++)
- dprintf1(" %lu", stats->make_up[i]),
+ dmprintf1(mem, " %lu", stats->make_up[i]),
total += stats->make_up[i];
- dprintf1(" total=%lu\n\t", total);
+ dmprintf1(mem, " total=%lu\n\t", total);
for (i = 0, total = 0; i < 64; i++)
- dprintf1(" %lu", stats->termination[i]),
+ dmprintf1(mem, " %lu", stats->termination[i]),
total += stats->termination[i];
- dprintf1(" total=%lu\n", total);
+ dmprintf1(mem, " total=%lu\n", total);
}
#else /* !DEBUG */
@@ -208,11 +208,11 @@ s_CFE_process(stream_state * st, stream_cursor_read * pr,
for (;;) {
stream_cursor_write w;
- if_debug2('w', "[w]CFE: read_count = %d, write_count=%d,\n",
- ss->read_count, ss->write_count);
- if_debug6('w', " pr = 0x%lx(%d)0x%lx, pw = 0x%lx(%d)0x%lx\n",
- (ulong) pr->ptr, (int)(rlimit - pr->ptr), (ulong) rlimit,
- (ulong) pw->ptr, (int)(wlimit - pw->ptr), (ulong) wlimit);
+ if_debug2m('w', ss->memory, "[w]CFE: read_count = %d, write_count=%d,\n",
+ ss->read_count, ss->write_count);
+ if_debug6m('w', ss->memory, " pr = 0x%lx(%d)0x%lx, pw = 0x%lx(%d)0x%lx\n",
+ (ulong) pr->ptr, (int)(rlimit - pr->ptr), (ulong) rlimit,
+ (ulong) pw->ptr, (int)(wlimit - pw->ptr), (ulong) wlimit);
if (ss->write_count) {
/* Copy more of an encoded line to the caller. */
int wcount = wlimit - pw->ptr;
@@ -268,10 +268,10 @@ s_CFE_process(stream_state * st, stream_cursor_read * pr,
}
#ifdef DEBUG
if (ss->K > 0) {
- if_debug2('w', "[w2]new %d-D row, k_left=%d\n",
- (ss->k_left == 1 ? 1 : 2), ss->k_left);
+ if_debug2m('w', ss->memory, "[w2]new %d-D row, k_left=%d\n",
+ (ss->k_left == 1 ? 1 : 2), ss->k_left);
} else {
- if_debug1('w', "[w%d]new row\n", (ss->K < 0 ? 2 : 1));
+ if_debug1m('w', ss->memory, "[w%d]new row\n", (ss->K < 0 ? 2 : 1));
}
#endif
/*
@@ -358,20 +358,20 @@ s_CFE_process(stream_state * st, stream_cursor_read * pr,
pw->ptr = hc_put_last_bits((stream_hc_state *) ss, q);
}
out:
- if_debug9('w', "[w]CFE exit %d: read_count = %d, write_count = %d,\n pr = 0x%lx(%d)0x%lx; pw = 0x%lx(%d)0x%lx\n",
- status, ss->read_count, ss->write_count,
- (ulong) pr->ptr, (int)(rlimit - pr->ptr), (ulong) rlimit,
- (ulong) pw->ptr, (int)(wlimit - pw->ptr), (ulong) wlimit);
+ if_debug9m('w', ss->memory, "[w]CFE exit %d: read_count = %d, write_count = %d,\n pr = 0x%lx(%d)0x%lx; pw = 0x%lx(%d)0x%lx\n",
+ status, ss->read_count, ss->write_count,
+ (ulong) pr->ptr, (int)(rlimit - pr->ptr), (ulong) rlimit,
+ (ulong) pw->ptr, (int)(wlimit - pw->ptr), (ulong) wlimit);
#ifdef DEBUG
if (pr->ptr > rlimit || pw->ptr > wlimit) {
lprintf("Pointer overrun!\n");
status = ERRC;
}
if (gs_debug_c('w') && status == 1) {
- dlputs("[w]white runs:");
- print_run_stats(&stats_white_runs);
- dlputs("[w]black runs:");
- print_run_stats(&stats_black_runs);
+ dmlputs(ss->memory, "[w]white runs:");
+ print_run_stats(ss->memory, &stats_white_runs);
+ dmlputs(ss->memory, "[w]black runs:");
+ print_run_stats(ss->memory, &stats_black_runs);
}
#endif
return status;
@@ -477,8 +477,8 @@ cf_encode_2d(stream_CFE_state * ss, const byte * lbuf, stream_cursor_write * pw,
prev_count, invert, rlen);
if (prev_count > a1) {
/* Use pass mode. */
- if_debug4('W', "[W]pass: count = %d, a1 = %d, b1 = %d, new count = %d\n",
- a0, a1, b1, prev_count);
+ if_debug4m('W', ss->memory, "[W]pass: count = %d, a1 = %d, b1 = %d, new count = %d\n",
+ a0, a1, b1, prev_count);
hc_put_value(ss, q, cf2_run_pass_value, cf2_run_pass_length);
a0 = prev_count;
goto pass;
@@ -489,8 +489,8 @@ cf_encode_2d(stream_CFE_state * ss, const byte * lbuf, stream_cursor_write * pw,
/* Use vertical coding. */
const cfe_run *cp = &cf2_run_vertical[diff + 3];
- if_debug5('W', "[W]vertical %d: count = %d, a1 = %d, b1 = %d, new count = %d\n",
- diff, a0, a1, b1, count);
+ if_debug5m('W', ss->memory, "[W]vertical %d: count = %d, a1 = %d, b1 = %d, new count = %d\n",
+ diff, a0, a1, b1, count);
hc_put_code(ss, q, cp);
invert = ~invert; /* a1 polarity changes */
data ^= 0xff;
@@ -504,13 +504,13 @@ cf_encode_2d(stream_CFE_state * ss, const byte * lbuf, stream_cursor_write * pw,
a0 -= a1;
a1 -= count;
if (invert == invert_white) {
- if_debug3('W', "[W]horizontal: white = %d, black = %d, new count = %d\n",
+ if_debug3m('W', ss->memory, "[W]horizontal: white = %d, black = %d, new count = %d\n",
a0, a1, count);
CF_PUT_WHITE_RUN(ss, a0);
CF_PUT_BLACK_RUN(ss, a1);
} else {
- if_debug3('W', "[W]horizontal: black = %d, white = %d, new count = %d\n",
- a0, a1, count);
+ if_debug3m('W', ss->memory, "[W]horizontal: black = %d, white = %d, new count = %d\n",
+ a0, a1, count);
CF_PUT_BLACK_RUN(ss, a0);
CF_PUT_WHITE_RUN(ss, a1);
#undef b1
diff --git a/gs/base/sdctd.c b/gs/base/sdctd.c
index 0128ecf18..8b1d9aea9 100644
--- a/gs/base/sdctd.c
+++ b/gs/base/sdctd.c
@@ -147,8 +147,8 @@ s_DCTD_process(stream_state * st, stream_cursor_read * pr,
struct jpeg_source_mgr *src = jddp->dinfo.src;
int code;
- if_debug3('w', "[wdd]process avail=%u, skip=%u, last=%d\n",
- (uint) (pr->limit - pr->ptr), (uint) jddp->skip, last);
+ if_debug3m('w', st->memory, "[wdd]process avail=%u, skip=%u, last=%d\n",
+ (uint) (pr->limit - pr->ptr), (uint) jddp->skip, last);
if (jddp->skip != 0) {
long avail = pr->limit - pr->ptr;
@@ -219,10 +219,10 @@ s_DCTD_process(stream_state * st, stream_cursor_read * pr,
return 0;
ss->scan_line_size =
jddp->dinfo.output_width * jddp->dinfo.output_components;
- if_debug4('w', "[wdd]width=%u, components=%d, scan_line_size=%u, min_out_size=%u\n",
- jddp->dinfo.output_width,
- jddp->dinfo.output_components,
- ss->scan_line_size, jddp->templat.min_out_size);
+ if_debug4m('w', ss->memory, "[wdd]width=%u, components=%d, scan_line_size=%u, min_out_size=%u\n",
+ jddp->dinfo.output_width,
+ jddp->dinfo.output_components,
+ ss->scan_line_size, jddp->templat.min_out_size);
if (ss->scan_line_size > (uint) jddp->templat.min_out_size) {
/* Create a spare buffer for oversize scanline */
jddp->scanline_buffer =
@@ -242,8 +242,8 @@ s_DCTD_process(stream_state * st, stream_cursor_read * pr,
uint tomove = min(jddp->bytes_in_scanline,
avail);
- if_debug2('w', "[wdd]moving %u/%u\n",
- tomove, avail);
+ if_debug2m('w', ss->memory, "[wdd]moving %u/%u\n",
+ tomove, avail);
memcpy(pw->ptr + 1, jddp->scanline_buffer +
(ss->scan_line_size - jddp->bytes_in_scanline),
tomove);
@@ -266,10 +266,10 @@ s_DCTD_process(stream_state * st, stream_cursor_read * pr,
read = gs_jpeg_read_scanlines(ss, &samples, 1);
if (read < 0)
return ERRC;
- if_debug3('w', "[wdd]read returns %d, used=%u, faked_eoi=%d\n",
- read,
- (uint) (src->next_input_byte - 1 - pr->ptr),
- (int)jddp->faked_eoi);
+ if_debug3m('w', ss->memory, "[wdd]read returns %d, used=%u, faked_eoi=%d\n",
+ read,
+ (uint) (src->next_input_byte - 1 - pr->ptr),
+ (int)jddp->faked_eoi);
pr->ptr =
(jddp->faked_eoi ? pr->limit : src->next_input_byte - 1);
if (!read) {
diff --git a/gs/base/sdcte.c b/gs/base/sdcte.c
index 59f5cfebb..d70ec9bc9 100644
--- a/gs/base/sdcte.c
+++ b/gs/base/sdcte.c
@@ -88,19 +88,19 @@ s_DCTE_process(stream_state * st, stream_cursor_read * pr,
jpeg_compress_data *jcdp = ss->data.compress;
struct jpeg_destination_mgr *dest = jcdp->cinfo.dest;
- if_debug2('w', "[wde]process avail=%u, last=%d\n",
- (uint) (pr->limit - pr->ptr), last);
+ if_debug2m('w', st->memory, "[wde]process avail=%u, last=%d\n",
+ (uint) (pr->limit - pr->ptr), last);
dest->next_output_byte = pw->ptr + 1;
dest->free_in_buffer = pw->limit - pw->ptr;
switch (ss->phase) {
case 0: /* not initialized yet */
if (gs_jpeg_start_compress(ss, TRUE) < 0)
return ERRC;
- if_debug4('w', "[wde]width=%u, height=%u, components=%d, scan_line_size=%u\n",
- jcdp->cinfo.image_width,
- jcdp->cinfo.image_height,
- jcdp->cinfo.input_components,
- ss->scan_line_size);
+ if_debug4m('w', st->memory, "[wde]width=%u, height=%u, components=%d, scan_line_size=%u\n",
+ jcdp->cinfo.image_width,
+ jcdp->cinfo.image_height,
+ jcdp->cinfo.input_components,
+ ss->scan_line_size);
pw->ptr = dest->next_output_byte - 1;
ss->phase = 1;
/* falls through */
@@ -213,8 +213,8 @@ s_DCTE_process(stream_state * st, stream_cursor_read * pr,
*/
/*const */ byte *samples = (byte *) (pr->ptr + 1);
- if_debug1('w', "[wde]next_scanline=%u\n",
- jcdp->cinfo.next_scanline);
+ if_debug1m('w', st->memory, "[wde]next_scanline=%u\n",
+ jcdp->cinfo.next_scanline);
if ((uint) (pr->limit - pr->ptr) < ss->scan_line_size) {
if (last)
return ERRC; /* premature EOD */
@@ -223,10 +223,10 @@ s_DCTE_process(stream_state * st, stream_cursor_read * pr,
written = gs_jpeg_write_scanlines(ss, &samples, 1);
if (written < 0)
return ERRC;
- if_debug3('w', "[wde]write returns %d, used=%u, written=%u\n",
- written,
- (uint) (samples - 1 - pr->ptr),
- (uint) (dest->next_output_byte - 1 - pw->ptr));
+ if_debug3m('w', st->memory, "[wde]write returns %d, used=%u, written=%u\n",
+ written,
+ (uint) (samples - 1 - pr->ptr),
+ (uint) (dest->next_output_byte - 1 - pw->ptr));
pw->ptr = dest->next_output_byte - 1;
if (!written)
return 1; /* output full */
@@ -252,7 +252,7 @@ s_DCTE_process(stream_state * st, stream_cursor_read * pr,
int count = min(jcdp->fcb_size - jcdp->fcb_pos,
pw->limit - pw->ptr);
- if_debug1('w', "[wde]copying final %d\n", count);
+ if_debug1m('w', st->memory, "[wde]copying final %d\n", count);
memcpy(pw->ptr + 1, jcdp->finish_compress_buf + jcdp->fcb_pos,
count);
jcdp->fcb_pos += count;
diff --git a/gs/base/sfilter2.c b/gs/base/sfilter2.c
index 93b3453df..40d556b83 100644
--- a/gs/base/sfilter2.c
+++ b/gs/base/sfilter2.c
@@ -52,8 +52,8 @@ s_A85E_process(stream_state * st, stream_cursor_read * pr,
int prev = ss->last_char;
int count;
- if_debug3('w', "[w85]initial ss->count = %d, rcount = %d, wcount = %d\n",
- ss->count, (int)(rlimit - p), (int)(wlimit - q));
+ if_debug3m('w', ss->memory, "[w85]initial ss->count = %d, rcount = %d, wcount = %d\n",
+ ss->count, (int)(rlimit - p), (int)(wlimit - q));
for (; (count = rlimit - p) >= 4; p += 4) {
ulong word =
((ulong) (((uint) p[1] << 8) + p[2]) << 16) +
@@ -67,7 +67,7 @@ s_A85E_process(stream_state * st, stream_cursor_read * pr,
}
*++q = prev = '\n';
qn = q + LINE_LIMIT;
- if_debug1('w', "[w85]EOL at %d bytes written\n",
+ if_debug1m('w', ss->memory, "[w85]EOL at %d bytes written\n",
(int)(q - pw->ptr));
} else {
if (q >= wlimit) {
@@ -89,8 +89,8 @@ put: if (q + 5 > qn) {
}
*++q = prev = '\n';
qn = q + LINE_LIMIT;
- if_debug1('w', "[w85]EOL at %d bytes written\n",
- (int)(q - pw->ptr));
+ if_debug1m('w', ss->memory, "[w85]EOL at %d bytes written\n",
+ (int)(q - pw->ptr));
goto put;
}
if (wlimit - q < 5) {
@@ -113,9 +113,9 @@ put: if (q + 5 > qn) {
/* A line would begin with %%. */
*++q = prev = '\n';
qn = q + LINE_LIMIT;
- if_debug1('w',
- "[w85]EOL for %%%% at %d bytes written\n",
- (int)(q - pw->ptr));
+ if_debug1m('w', ss->memory,
+ "[w85]EOL for %%%% at %d bytes written\n",
+ (int)(q - pw->ptr));
goto put;
}
} else if (prev == '\n' && (q[2] == '%' || q[2] == '!')) {
@@ -136,8 +136,8 @@ put: if (q + 5 > qn) {
status = 1;
break;
}
- if_debug6('w', "[w]%c%c%c%c%c extra = %d\n",
- q[1], q[2], q[3], q[4], q[5], extra);
+ if_debug6m('w', ss->memory, "[w]%c%c%c%c%c extra = %d\n",
+ q[1], q[2], q[3], q[4], q[5], extra);
switch (extra) {
case 4:
q[9] = q[5], q[8] = '\n';
@@ -154,8 +154,8 @@ put: if (q + 5 > qn) {
q[6] = q[5], q[5] = q[4], q[4] = q[3];
e1:q[3] = q[2], q[2] = '\n';
}
- if_debug1('w', "[w85]EOL at %d bytes written\n",
- (int)(q + 2 * extra - pw->ptr));
+ if_debug1m('w', ss->memory, "[w85]EOL at %d bytes written\n",
+ (int)(q + 2 * extra - pw->ptr));
qn = q + 2 * extra + LINE_LIMIT;
q += extra;
}
@@ -165,8 +165,8 @@ put: if (q + 5 > qn) {
/* A line would begin with %!. */
*++q = prev = '\n';
qn = q + LINE_LIMIT;
- if_debug1('w', "[w85]EOL for %%! at %d bytes written\n",
- (int)(q - pw->ptr));
+ if_debug1m('w', ss->memory, "[w85]EOL for %%! at %d bytes written\n",
+ (int)(q - pw->ptr));
goto put;
}
prev = *(q += 5);
@@ -220,8 +220,8 @@ put: if (q + 5 > qn) {
*++q = '>';
}
}
- if_debug3('w', "[w85]final ss->count = %d, %d bytes read, %d written\n",
- ss->count, (int)(p - pr->ptr), (int)(q - pw->ptr));
+ if_debug3m('w', ss->memory, "[w85]final ss->count = %d, %d bytes read, %d written\n",
+ ss->count, (int)(p - pr->ptr), (int)(q - pw->ptr));
pr->ptr = p;
if (q > pw->ptr)
ss->last_char = *q;
diff --git a/gs/base/sfxfd.c b/gs/base/sfxfd.c
index 2fe74f507..7f3540630 100644
--- a/gs/base/sfxfd.c
+++ b/gs/base/sfxfd.c
@@ -123,8 +123,8 @@ sread_fileno(register stream * s, FILE * file, byte * buf, uint len)
s_std_init(s, buf, len, &p,
(seekable ? s_mode_read + s_mode_seek : s_mode_read));
- if_debug2('s', "[s]read file=0x%lx, fd=%d\n", (ulong) file,
- fileno(file));
+ if_debug2m('s', s->memory, "[s]read file=0x%lx, fd=%d\n", (ulong) file,
+ fileno(file));
s->file = file;
s->file_modes = s->modes;
s->file_offset = 0;
@@ -264,8 +264,8 @@ swrite_fileno(register stream * s, FILE * file, byte * buf, uint len)
s_std_init(s, buf, len, &p,
(file == stdout ? s_mode_write : s_mode_write + s_mode_seek));
- if_debug2('s', "[s]write file=0x%lx, fd=%d\n", (ulong) file,
- fileno(file));
+ if_debug2m('s', s->memory, "[s]write file=0x%lx, fd=%d\n", (ulong) file,
+ fileno(file));
s->file = file;
s->file_modes = s->modes;
s->file_offset = 0; /* in case we switch to reading later */
@@ -353,8 +353,8 @@ s_fileno_switch(stream * s, bool writing)
if (!(s->file_modes & s_mode_write))
return ERRC;
pos = stell(s);
- if_debug2('s', "[s]switch 0x%lx to write at %ld\n",
- (ulong) s, pos);
+ if_debug2m('s', s->memory, "[s]switch 0x%lx to write at %ld\n",
+ (ulong) s, pos);
lseek(fd, pos, SEEK_SET); /* pacify OS */
if (modes & s_mode_append) {
sappend_file(s, s->file, s->cbuf, s->cbsize); /* sets position */
@@ -367,8 +367,8 @@ s_fileno_switch(stream * s, bool writing)
if (!(s->file_modes & s_mode_read))
return ERRC;
pos = stell(s);
- if_debug2('s', "[s]switch 0x%lx to read at %ld\n",
- (ulong) s, pos);
+ if_debug2m('s', s->memory, "[s]switch 0x%lx to read at %ld\n",
+ (ulong) s, pos);
if (sflush(s) < 0)
return ERRC;
lseek(fd, 0L, SEEK_CUR); /* pacify OS */
diff --git a/gs/base/sfxstdio.c b/gs/base/sfxstdio.c
index b65939fc4..0866bd5c3 100644
--- a/gs/base/sfxstdio.c
+++ b/gs/base/sfxstdio.c
@@ -66,7 +66,7 @@ sread_file(register stream * s, FILE * file, byte * buf, uint len)
clearerr(file);
s_std_init(s, buf, len, &p,
(seekable ? s_mode_read + s_mode_seek : s_mode_read));
- if_debug1('s', "[s]read file=0x%lx\n", (ulong) file);
+ if_debug1m('s', s->memory, "[s]read file=0x%lx\n", (ulong) file);
s->file = file;
s->file_modes = s->modes;
s->file_offset = 0;
@@ -189,7 +189,7 @@ swrite_file(register stream * s, FILE * file, byte * buf, uint len)
s_std_init(s, buf, len, &p,
(file == stdout ? s_mode_write : s_mode_write + s_mode_seek));
- if_debug1('s', "[s]write file=0x%lx\n", (ulong) file);
+ if_debug1m('s', s->memory, "[s]write file=0x%lx\n", (ulong) file);
s->file = file;
s->file_modes = s->modes;
s->file_offset = 0; /* in case we switch to reading later */
@@ -277,8 +277,8 @@ s_file_switch(stream * s, bool writing)
if (!(s->file_modes & s_mode_write))
return ERRC;
pos = stell(s);
- if_debug2('s', "[s]switch 0x%lx to write at %ld\n",
- (ulong) s, pos);
+ if_debug2m('s', s->memory, "[s]switch 0x%lx to write at %ld\n",
+ (ulong) s, pos);
fseek(file, pos, SEEK_SET);
if (modes & s_mode_append) {
sappend_file(s, file, s->cbuf, s->cbsize); /* sets position */
@@ -291,8 +291,8 @@ s_file_switch(stream * s, bool writing)
if (!(s->file_modes & s_mode_read))
return ERRC;
pos = stell(s);
- if_debug2('s', "[s]switch 0x%lx to read at %ld\n",
- (ulong) s, pos);
+ if_debug2m('s', s->memory, "[s]switch 0x%lx to read at %ld\n",
+ (ulong) s, pos);
if (sflush(s) < 0)
return ERRC;
fseek(file, 0L, SEEK_CUR); /* pacify C library */
diff --git a/gs/base/shc.h b/gs/base/shc.h
index d22d0956f..3d22ec912 100644
--- a/gs/base/shc.h
+++ b/gs/base/shc.h
@@ -105,7 +105,7 @@ typedef struct hce_table_s {
* that q does not exceed pw->limit.
*/
-#ifdef DEBUG
+#if defined(DEBUG) && !defined(GS_THREADSAFE)
# define hc_print_value(code, clen)\
(gs_debug_c('W') ?\
(dlprintf2("[W]0x%x,%d\n", code, clen), 0) : 0)
diff --git a/gs/base/shcgen.c b/gs/base/shcgen.c
index 80888eec6..ea4c8c7b5 100644
--- a/gs/base/shcgen.c
+++ b/gs/base/shcgen.c
@@ -40,32 +40,32 @@ struct count_node_s {
};
#ifdef DEBUG
-# define debug_print_nodes(nodes, n, tag, lengths)\
- if ( gs_debug_c('W') ) print_nodes_proc(nodes, n, tag, lengths);
+# define debug_print_nodes(mem, nodes, n, tag, lengths)\
+ if ( gs_debug_c('W') ) print_nodes_proc(mem, nodes, n, tag, lengths);
static void
-print_nodes_proc(const count_node * nodes, int n, const char *tag, int lengths)
+print_nodes_proc(const gs_memory_t *mem, const count_node * nodes, int n, const char *tag, int lengths)
{
int i;
- dlprintf1("[w]---------------- %s ----------------\n", tag);
+ dmlprintf1(mem, "[w]---------------- %s ----------------\n", tag);
for (i = 0; i < n; ++i)
- dlprintf7("[w]node %d: f=%ld v=%d len=%d N=%d L=%d R=%d\n",
- i, nodes[i].freq, nodes[i].value, nodes[i].code_length,
- (nodes[i].next == 0 ? -1 : (int)(nodes[i].next - nodes)),
- (nodes[i].left == 0 ? -1 : (int)(nodes[i].left - nodes)),
- (nodes[i].right == 0 ? -1 : (int)(nodes[i].right - nodes)));
+ dmlprintf7(mem, "[w]node %d: f=%ld v=%d len=%d N=%d L=%d R=%d\n",
+ i, nodes[i].freq, nodes[i].value, nodes[i].code_length,
+ (nodes[i].next == 0 ? -1 : (int)(nodes[i].next - nodes)),
+ (nodes[i].left == 0 ? -1 : (int)(nodes[i].left - nodes)),
+ (nodes[i].right == 0 ? -1 : (int)(nodes[i].right - nodes)));
for (i = lengths; i > 0;) {
int j = i;
int len = nodes[--j].code_length;
while (j > 0 && nodes[j - 1].code_length == len)
--j;
- dlprintf2("[w]%d codes of length %d\n", i - j, len);
+ dmlprintf2(mem, "[w]%d codes of length %d\n", i - j, len);
i = j;
}
}
#else
-# define debug_print_nodes(nodes, n, tag, lengths) DO_NOTHING
+# define debug_print_nodes(mem, nodes, n, tag, lengths) DO_NOTHING
#endif
/* Node comparison procedures for sorting. */
@@ -189,7 +189,7 @@ hc_compute(hc_definition * def, const long *freqs, gs_memory_t * mem)
nodes[i].code_length = 0,
nodes[i].left = nodes[i].right = 0;
nodes[0].next = 0;
- debug_print_nodes(nodes, num_values, "after sort", 0);
+ debug_print_nodes(mem, nodes, num_values, "after sort", 0);
/* Construct the Huffman code tree. */
for (lowest = &nodes[num_values - 1], comb = &nodes[num_values];;
@@ -235,15 +235,15 @@ hc_compute(hc_definition * def, const long *freqs, gs_memory_t * mem)
comb->left->code_length = comb->right->code_length =
comb->code_length + 1;
}
- debug_print_nodes(nodes, num_values * 2 - 1, "after combine", 0);
+ debug_print_nodes(mem, nodes, num_values * 2 - 1, "after combine", 0);
/* Sort the leaves again by code length. */
qsort(nodes, num_values, sizeof(count_node), compare_code_lengths);
- debug_print_nodes(nodes, num_values, "after re-sort", num_values);
+ debug_print_nodes(mem, nodes, num_values, "after re-sort", num_values);
/* Limit the code length to def->num_counts. */
hc_limit_code_lengths(nodes, num_values, def->num_counts);
- debug_print_nodes(nodes, num_values, "after limit", num_values);
+ debug_print_nodes(mem, nodes, num_values, "after limit", num_values);
/* Sort within each code length by increasing code value. */
/* This doesn't affect data compression, but it makes */
diff --git a/gs/base/sidscale.c b/gs/base/sidscale.c
index d826ee8ba..9bcab8b43 100644
--- a/gs/base/sidscale.c
+++ b/gs/base/sidscale.c
@@ -86,7 +86,7 @@ idownscale_x(void /* PixelIn */ * tmp, const void /* PixelIn */ *src, stream_ISp
const byte *pp = (const byte *)src + c;
ss->dda_x = ss->dda_x_init;
- if_debug1('W', "[W]idownscale_x color %d:", c);
+ if_debug1m('W', ss->memory, "[W]idownscale_x color %d:", c);
for ( i = 0; i < WidthIn; tp += Colors) {
int endx;
@@ -104,9 +104,9 @@ idownscale_x(void /* PixelIn */ * tmp, const void /* PixelIn */ *src, stream_ISp
*tp = *pp;
i++; pp += Colors;
}
- if_debug1('W', " %d", *tp);
+ if_debug1m('W', ss->memory, " %d", *tp);
}
- if_debug0('W', "\n");
+ if_debug0m('W', ss->memory, "\n");
}
} else { /* sizeofPixelIn == 2 */
for (c = 0; c < Colors; ++c) {
@@ -114,7 +114,7 @@ idownscale_x(void /* PixelIn */ * tmp, const void /* PixelIn */ *src, stream_ISp
const bits16 *pp = (const bits16 *)src + c;
ss->dda_x = ss->dda_x_init;
- if_debug1('W', "[W]idownscale_x color %d:", c);
+ if_debug1m('W', ss->memory, "[W]idownscale_x color %d:", c);
for ( i = 0; i < WidthIn; tp += Colors) {
int endx;
@@ -132,9 +132,9 @@ idownscale_x(void /* PixelIn */ * tmp, const void /* PixelIn */ *src, stream_ISp
*tp = *pp;
i++; pp += Colors;
}
- if_debug1('W', " %d", *tp);
+ if_debug1m('W', ss->memory, " %d", *tp);
}
- if_debug0('W', "\n");
+ if_debug0m('W', ss->memory, "\n");
}
}
}
@@ -154,21 +154,21 @@ idownscale_y(void /*PixelOut */ *dst, const void /* PixelIn */ *tmp,
int kc;
float scale = (float) ss->params.MaxValueOut/255.0;
- if_debug0('W', "[W]idownscale_y: ");
+ if_debug0m('W', ss->memory, "[W]idownscale_y: ");
if (ss->sizeofPixelOut == 1) {
if (ss->sizeofPixelIn == 1) {
const byte *pp = (byte *)tmp;
for ( kc = 0; kc < kn; ++kc, pp++ ) {
- if_debug1('W', " %d", *pp);
+ if_debug1m('W', ss->memory, " %d", *pp);
((byte *)dst)[kc] = *pp;
}
} else { /* sizeofPixelIn == 2 */
const bits16 *pp = (bits16 *)tmp;
for ( kc = 0; kc < kn; ++kc, pp++ ) {
- if_debug1('W', " %d", *pp);
+ if_debug1m('W', ss->memory, " %d", *pp);
((byte *)dst)[kc] = frac2byte(*pp);
}
}
@@ -177,19 +177,19 @@ idownscale_y(void /*PixelOut */ *dst, const void /* PixelIn */ *tmp,
const byte *pp = (byte *)tmp;
for ( kc = 0; kc < kn; ++kc, pp++ ) {
- if_debug1('W', " %d", *pp);
+ if_debug1m('W', ss->memory, " %d", *pp);
((bits16 *)dst)[kc] = (bits16)((*pp)*scale);
}
} else { /* sizeofPixelIn == 2 */
const bits16 *pp = (bits16 *)tmp;
for ( kc = 0; kc < kn; ++kc, pp++ ) {
- if_debug1('W', " %d", *pp);
+ if_debug1m('W', ss->memory, " %d", *pp);
((bits16 *)dst)[kc] = *pp;
}
}
}
- if_debug0('W', "n");
+ if_debug0m('W', ss->memory, "n");
}
/* ------ Stream implementation ------ */
@@ -325,8 +325,8 @@ adv: ++(ss->dst_y);
ss->src_offset = 0;
}
/* Apply filter to zoom horizontally from src to tmp. */
- if_debug2('w', "[w]idownscale_x y = %d to tmp row %d\n",
- ss->src_y, (ss->src_y % MAX_ISCALE_SUPPORT));
+ if_debug2m('w', ss->memory, "[w]idownscale_x y = %d to tmp row %d\n",
+ ss->src_y, (ss->src_y % MAX_ISCALE_SUPPORT));
idownscale_x(ss->tmp, row, ss);
pr->ptr += rcount;
++(ss->src_y);
diff --git a/gs/base/siscale.c b/gs/base/siscale.c
index 10a223910..3779a04b4 100644
--- a/gs/base/siscale.c
+++ b/gs/base/siscale.c
@@ -422,7 +422,7 @@ calculate_dst_contrib(stream_IScale_state * ss, int y)
ss->filter, ss->min_scale);
int first_index_mod = ss->dst_next_list.first_pixel / row_size;
- if_debug2('w', "[W]calculate_dst_contrib for y = %d, y+offset=%d\n", y, y + ss->src_y_offset);
+ if_debug2m('w', ss->memory, "[W]calculate_dst_contrib for y = %d, y+offset=%d\n", y, y + ss->src_y_offset);
ss->dst_last_index = last_index;
last_index %= ss->max_support;
if (last_index < first_index_mod) { /* Shuffle the indices to account for wraparound. */
@@ -436,13 +436,13 @@ calculate_dst_contrib(stream_IScale_state * ss, int y)
i >= first_index_mod ?
ss->dst_items[i - first_index_mod].weight :
0);
- if_debug1('W', " %f", shuffle[i].weight);
+ if_debug1m('W', ss->memory, " %f", shuffle[i].weight);
}
memcpy(ss->dst_items, shuffle, ss->max_support * sizeof(CONTRIB));
ss->dst_next_list.n = ss->max_support;
ss->dst_next_list.first_pixel = 0;
}
- if_debug0('W', "\n");
+ if_debug0m('W', ss->memory, "\n");
}
/* Set default parameter values (actually, just clear pointers). */
diff --git a/gs/base/sjbig2.c b/gs/base/sjbig2.c
index 93408c149..69d0f82fd 100644
--- a/gs/base/sjbig2.c
+++ b/gs/base/sjbig2.c
@@ -68,9 +68,9 @@ s_jbig2decode_error(void *error_callback_data, const char *msg, Jbig2Severity se
else sprintf(segment, "(segment 0x%02x)", seg_idx);
if (severity == JBIG2_SEVERITY_FATAL) {
- dlprintf3("jbig2dec %s %s %s\n", type, msg, segment);
+ dmlprintf3(state->memory, "jbig2dec %s %s %s\n", type, msg, segment);
} else {
- if_debug3('w', "[w] jbig2dec %s %s %s\n", type, msg, segment);
+ if_debug3m('w', state->memory, "[w] jbig2dec %s %s %s\n", type, msg, segment);
}
return code;
diff --git a/gs/base/sjbig2_luratech.c b/gs/base/sjbig2_luratech.c
index 5ef41275b..b2045b63e 100644
--- a/gs/base/sjbig2_luratech.c
+++ b/gs/base/sjbig2_luratech.c
@@ -147,6 +147,7 @@ s_jbig2_free(void *ptr, void *userdata)
static void JB2_Callback
s_jbig2_message(const char *message, JB2_Message_Level level, void *userdata)
{
+ stream_jbig2decode_state *const state = (stream_jbig2decode_state *) userdata;
const char *type;
if (message == NULL) return;
@@ -164,9 +165,9 @@ s_jbig2_message(const char *message, JB2_Message_Level level, void *userdata)
}
if (level == cJB2_Message_Error) {
- dprintf2("Luratech JBIG2 %s %s\n", type, message);
+ dmprintf2(state->memory, "Luratech JBIG2 %s %s\n", type, message);
} else {
- if_debug2('w', "[w]Luratech JBIG2 %s %s\n", type, message);
+ if_debug2m('w', state->memory, "[w]Luratech JBIG2 %s %s\n", type, message);
}
return;
@@ -211,7 +212,7 @@ s_jbig2_write(unsigned char *buffer,
long available = ((width - 1) >> 3) + 1;
if (row >= state->height) {
- dlprintf2("jbig2decode: output for row index %lu of %lu called!\n", row, state->height);
+ dmlprintf2(state->memory, "jbig2decode: output for row index %lu of %lu called!\n", row, state->height);
return cJB2_Error_Invalid_Index;
}
@@ -242,8 +243,8 @@ s_jbig2decode_inbuf(stream_jbig2decode_state *state, stream_cursor_read * pr)
while (new_size < state->infill + in_size)
new_size = new_size << 1;
- if_debug1('s', "[s]jbig2decode growing input buffer to %lu bytes\n",
- new_size);
+ if_debug1m('s', state->memory, "[s]jbig2decode growing input buffer to %lu bytes\n",
+ new_size);
new = realloc(state->inbuf, new_size);
if (new == NULL) return gs_error_VMerror;
@@ -334,7 +335,7 @@ s_jbig2decode_process(stream_state * ss, stream_cursor_read * pr,
if (error != cJB2_Error_OK) return ERRC;
state->height = result;
state->stride = ((state->width - 1) >> 3) + 1;
- if_debug2('w', "[w]jbig2decode page is %ldx%ld; allocating image\n", state->width, state->height);
+ if_debug2m('w', state->memory, "[w]jbig2decode page is %ldx%ld; allocating image\n", state->width, state->height);
state->image = malloc(state->height*state->stride);
/* start image decode */
@@ -439,7 +440,7 @@ s_jbig2encode_write(const unsigned char *buffer,
if (state->outbuf == NULL) {
state->outbuf = malloc(JBIG2_BUFFER_SIZE);
if (state->outbuf == NULL) {
- dprintf("jbig2encode: failed to allocate output buffer\n");
+ dmprintf(state->memory, "jbig2encode: failed to allocate output buffer\n");
return 0; /* can't return an error! */
}
state->outsize = JBIG2_BUFFER_SIZE;
@@ -447,13 +448,13 @@ s_jbig2encode_write(const unsigned char *buffer,
/* grow the output buffer if necessary */
while (pos+size > state->outsize) {
- unsigned char *new = realloc(state->outbuf, state->outsize*2);
+ unsigned char *new_ = realloc(state->outbuf, state->outsize*2);
if (new == NULL) {
- dprintf1("jbig2encode: failed to resize output buffer"
+ dmprintf1(state->memory, "jbig2encode: failed to resize output buffer"
" beyond %lu bytes\n", state->outsize);
return 0; /* can't return an error! */
}
- state->outbuf = new;
+ state->outbuf = new_;
state->outsize *= 2;
}
diff --git a/gs/base/sjpx_luratech.c b/gs/base/sjpx_luratech.c
index ab4ce6c64..18efaf829 100644
--- a/gs/base/sjpx_luratech.c
+++ b/gs/base/sjpx_luratech.c
@@ -353,8 +353,8 @@ s_jpxd_inbuf(stream_jpxd_state *state, stream_cursor_read * pr)
while (new_size < state->inbuf_fill + in_size)
new_size = new_size << 1;
- if_debug1('s', "[s]jpxd growing input buffer to %lu bytes\n",
- new_size);
+ if_debug1m('s', state->memory, "[s]jpxd growing input buffer to %lu bytes\n",
+ new_size);
new = realloc(state->inbuf, new_size);
if (new == NULL) return gs_error_VMerror;
@@ -478,7 +478,7 @@ s_jpxd_process(stream_state * ss, stream_cursor_read * pr,
s_jpxd_read_data, (JP2_Callback_Param)state
);
if (err != cJP2_Error_OK) {
- dlprintf1("Luratech JP2 error %d starting decompression\n", (int)err);
+ dmlprintf1(state->memory, "Luratech JP2 error %d starting decompression\n", (int)err);
return ERRC;
}
#if defined(JP2_LICENSE_NUM_1) && defined(JP2_LICENSE_NUM_2)
@@ -486,7 +486,7 @@ s_jpxd_process(stream_state * ss, stream_cursor_read * pr,
err = JP2_Decompress_SetLicense(state->handle,
JP2_LICENSE_NUM_1, JP2_LICENSE_NUM_2);
if (err != cJP2_Error_OK) {
- dlprintf1("Luratech JP2 error %d setting license\n", (int)err);
+ dmlprintf1(state->memory, "Luratech JP2 error %d setting license\n", (int)err);
return ERRC;
}
#endif
@@ -494,7 +494,7 @@ s_jpxd_process(stream_state * ss, stream_cursor_read * pr,
err = JP2_Decompress_GetProp(state->handle,
cJP2_Prop_Components, &result, -1, -1);
if (err != cJP2_Error_OK) {
- dlprintf1("Luratech JP2 error %d decoding number of image components\n", (int)err);
+ dmlprintf1(state->memory, "Luratech JP2 error %d decoding number of image components\n", (int)err);
return ERRC;
}
ncomp = result;
@@ -504,25 +504,25 @@ s_jpxd_process(stream_state * ss, stream_cursor_read * pr,
unsigned long nchans = 0;
err = JP2_Decompress_GetChannelDefs(state->handle, &chans, &nchans);
if (err != cJP2_Error_OK) {
- dlprintf1("Luratech JP2 error %d reading channel definitions\n", (int)err);
+ dmlprintf1(state->memory, "Luratech JP2 error %d reading channel definitions\n", (int)err);
return ERRC;
}
state->clut = malloc(nchans * sizeof(int));
state->ncomp = map_components(chans, nchans, state->alpha, state->clut);
if (state->ncomp < 0) {
- dlprintf("Luratech JP2 error decoding channel definitions\n");
+ dmlprintf(state->memory, "Luratech JP2 error decoding channel definitions\n");
return ERRC;
}
}
- if_debug1('w', "[w]jpxd image has %d components\n", state->ncomp);
+ if_debug1m('w', state->memory, "[w]jpxd image has %d components\n", state->ncomp);
{
const char *cspace = "unknown";
err = JP2_Decompress_GetProp(state->handle,
cJP2_Prop_Extern_Colorspace, &result, -1, -1);
if (err != cJP2_Error_OK) {
- dlprintf1("Luratech JP2 error %d decoding colorspace\n", (int)err);
+ dmlprintf1(state->memory, "Luratech JP2 error %d decoding colorspace\n", (int)err);
return ERRC;
}
image_cs = (JP2_Colorspace)result;
@@ -576,7 +576,7 @@ s_jpxd_process(stream_state * ss, stream_cursor_read * pr,
state->image_is_indexed = true;
break;
}
- if_debug1('w', "[w]jpxd image colorspace is %s\n", cspace);
+ if_debug1m('w', state->memory, "[w]jpxd image colorspace is %s\n", cspace);
}
/* the library doesn't return the overall image dimensions
@@ -592,36 +592,36 @@ s_jpxd_process(stream_state * ss, stream_cursor_read * pr,
err= JP2_Decompress_GetProp(state->handle,
cJP2_Prop_Width, &result, -1, (short)comp);
if (err != cJP2_Error_OK) {
- dlprintf2("Luratech JP2 error %d decoding "
- "width for component %d\n", (int)err, comp);
+ dmlprintf2(state->memory, "Luratech JP2 error %d decoding "
+ "width for component %d\n", (int)err, comp);
return ERRC;
}
width = result;
err= JP2_Decompress_GetProp(state->handle,
cJP2_Prop_Height, &result, -1, (short)comp);
if (err != cJP2_Error_OK) {
- dlprintf2("Luratech JP2 error %d decoding "
- "height for component %d\n", (int)err, comp);
+ dmlprintf2(state->memory, "Luratech JP2 error %d decoding "
+ "height for component %d\n", (int)err, comp);
return ERRC;
}
height = result;
err= JP2_Decompress_GetProp(state->handle,
cJP2_Prop_Bits_Per_Sample, &result, -1, (short)comp);
if (err != cJP2_Error_OK) {
- dlprintf2("Luratech JP2 error %d decoding "
- "bits per sample for component %d\n", (int)err, comp);
+ dmlprintf2(state->memory, "Luratech JP2 error %d decoding "
+ "bits per sample for component %d\n", (int)err, comp);
return ERRC;
}
bits = result;
err= JP2_Decompress_GetProp(state->handle,
cJP2_Prop_Signed_Samples, &result, -1, (short)comp);
if (err != cJP2_Error_OK) {
- dlprintf2("Luratech JP2 error %d decoding "
- "signedness of component %d\n", (int)err, comp);
+ dmlprintf2(state->memory, "Luratech JP2 error %d decoding "
+ "signedness of component %d\n", (int)err, comp);
return ERRC;
}
is_signed = result;
- if_debug5('w',
+ if_debug5m('w', state->memory,
"[w]jpxd image component %d has %dx%d %s %d bit samples\n",
comp, width, height,
is_signed ? "signed" : "unsigned", bits);
@@ -632,9 +632,9 @@ s_jpxd_process(stream_state * ss, stream_cursor_read * pr,
if (state->bpc < bits) state->bpc = bits;
}
}
- if_debug3('w', "[w]jpxd decoding image at %ldx%ld"
- " with %d bits per component\n",
- state->width, state->height, state->bpc);
+ if_debug3m('w', state->memory, "[w]jpxd decoding image at %ldx%ld"
+ " with %d bits per component\n",
+ state->width, state->height, state->bpc);
}
if (state->handle != (JP2_Decomp_Handle)NULL &&
@@ -659,21 +659,21 @@ s_jpxd_process(stream_state * ss, stream_cursor_read * pr,
err = JP2_Decompress_SetProp(state->handle,
cJP2_Prop_Output_Parameter, (JP2_Property_Value)state);
if (err != cJP2_Error_OK) {
- dlprintf1("Luratech JP2 error %d setting output parameter\n", (int)err);
+ dmlprintf1(state->memory, "Luratech JP2 error %d setting output parameter\n", (int)err);
return ERRC;
}
err = JP2_Decompress_SetProp(state->handle,
cJP2_Prop_Output_Function,
(JP2_Property_Value)s_jpxd_write_data);
if (err != cJP2_Error_OK) {
- dlprintf1("Luratech JP2 error %d setting output function\n", (int)err);
+ dmlprintf1(state->memory, "Luratech JP2 error %d setting output function\n", (int)err);
return ERRC;
}
/* decompress the image */
err = JP2_Decompress_Image(state->handle);
if (err != cJP2_Error_OK) {
- dlprintf1("Luratech JP2 error %d decoding image data\n", (int)err);
+ dmlprintf1(state->memory, "Luratech JP2 error %d decoding image data\n", (int)err);
return ERRC; /* parsing error */
}
@@ -750,8 +750,9 @@ s_jpxe_read(unsigned char *buffer, short component,
int i;
if (component < 0 || component >= state->components) {
- dlprintf2("Luratech JP2 requested image data for unknown component %d of %u\n",
- (int)component, state->components);
+ dmlprintf2(state->memory,
+ "Luratech JP2 requested image data for unknown component %d of %u\n",
+ (int)component, state->components);
return cJP2_Error_Invalid_Component_Index;
}
@@ -789,7 +790,7 @@ s_jpxe_write(unsigned char *buffer,
if (state->outbuf == NULL) {
state->outbuf = malloc(JPX_BUFFER_SIZE);
if (state->outbuf == NULL) {
- dprintf("jpx encode: failed to allocate output buffer.\n");
+ dmprintf(state->memory, "jpx encode: failed to allocate output buffer.\n");
return cJP2_Error_Failure_Malloc;
}
state->outsize = JPX_BUFFER_SIZE;
@@ -799,14 +800,14 @@ s_jpxe_write(unsigned char *buffer,
while (pos+size > state->outsize) {
unsigned char *new = realloc(state->outbuf, state->outsize*2);
if (new == NULL) {
- dprintf1("jpx encode: failed to resize output buffer"
+ dmprintf1(state->memory, "jpx encode: failed to resize output buffer"
" beyond %lu bytes.\n", state->outsize);
return cJP2_Error_Failure_Malloc;
}
state->outbuf = new;
state->outsize *= 2;
- if_debug1('s', "[s] jpxe output buffer resized to %lu bytes\n",
- state->outsize);
+ if_debug1m('s', state->memory, "[s] jpxe output buffer resized to %lu bytes\n",
+ state->outsize);
}
/* copy data into our buffer; we've assured there is enough room. */
@@ -849,15 +850,15 @@ s_jpxe_init(stream_state *ss)
}
state->stride = state->width * state->components;
- if_debug3('w', "[w] jpxe init %lux%lu image with %d components\n",
- state->width, state->height, state->components);
- if_debug1('w', "[w] jpxe init image is %d bits per component\n", state->bpc);
+ if_debug3m('w', state->memory, "[w] jpxe init %lux%lu image with %d components\n",
+ state->width, state->height, state->components);
+ if_debug1m('w', state->memory, "[w] jpxe init image is %d bits per component\n", state->bpc);
if (state->lossless) {
- if_debug0('w', "[w] jpxe image using lossless encoding\n");
+ if_debug0m('w', state->memory, "[w] jpxe image using lossless encoding\n");
state->quality = 100; /* implies lossless */
} else {
- if_debug1('w', "[w] jpxe image quality level %d\n", state->quality);
+ if_debug1m('w', state->memory, "[w] jpxe image quality level %d\n", state->quality);
}
/* null the input buffer */
@@ -878,7 +879,7 @@ s_jpxe_init(stream_state *ss)
s_jpx_free, (JP2_Callback_Param)state,
state->components);
if (err != cJP2_Error_OK) {
- dlprintf1("Luratech JP2 error %d starting compressor\n", (int)err);
+ dmlprintf1(state->memory, "Luratech JP2 error %d starting compressor\n", (int)err);
return ERRC;
}
@@ -887,7 +888,7 @@ s_jpxe_init(stream_state *ss)
err = JP2_Decompress_SetLicense(state->handle,
JP2_LICENSE_NUM_1, JP2_LICENSE_NUM_2);
if (err != cJP2_Error_OK) {
- dlprintf1("Luratech JP2 error %d setting license\n", (int)err);
+ dmlprintf1(state->memory, "Luratech JP2 error %d setting license\n", (int)err);
return ERRC;
}
#endif
@@ -896,25 +897,25 @@ s_jpxe_init(stream_state *ss)
err = JP2_Compress_SetProp(state->handle,
cJP2_Prop_Input_Parameter, (JP2_Property_Value)state, -1, -1);
if (err != cJP2_Error_OK) {
- dlprintf1("Luratech JP2 error %d setting input callback parameter.\n", (int)err);
+ dmlprintf1(state->memory, "Luratech JP2 error %d setting input callback parameter.\n", (int)err);
return ERRC;
}
err = JP2_Compress_SetProp(state->handle,
cJP2_Prop_Input_Function, (JP2_Property_Value)s_jpxe_read, -1, -1);
if (err != cJP2_Error_OK) {
- dlprintf1("Luratech JP2 error %d setting input callback function.\n", (int)err);
+ dmlprintf1(state->memory, "Luratech JP2 error %d setting input callback function.\n", (int)err);
return ERRC;
}
err = JP2_Compress_SetProp(state->handle,
cJP2_Prop_Write_Parameter, (JP2_Property_Value)state, -1, -1);
if (err != cJP2_Error_OK) {
- dlprintf1("Luratech JP2 error %d setting compressed output callback parameter.\n", (int)err);
+ dmlprintf1(state->memory, "Luratech JP2 error %d setting compressed output callback parameter.\n", (int)err);
return ERRC;
}
err = JP2_Compress_SetProp(state->handle,
cJP2_Prop_Write_Function, (JP2_Property_Value)s_jpxe_write, -1, -1);
if (err != cJP2_Error_OK) {
- dlprintf1("Luratech JP2 error %d setting compressed output callback function.\n", (int)err);
+ dmlprintf1(state->memory, "Luratech JP2 error %d setting compressed output callback function.\n", (int)err);
return ERRC;
}
@@ -922,19 +923,19 @@ s_jpxe_init(stream_state *ss)
err = JP2_Compress_SetProp(state->handle,
cJP2_Prop_Width, state->width, -1, -1);
if (err != cJP2_Error_OK) {
- dlprintf1("Luratech JP2 error %d setting width\n", (int)err);
+ dmlprintf1(state->memory, "Luratech JP2 error %d setting width\n", (int)err);
return ERRC;
}
err = JP2_Compress_SetProp(state->handle,
cJP2_Prop_Height, state->height, -1, -1);
if (err != cJP2_Error_OK) {
- dlprintf1("Luratech JP2 error %d setting height\n", (int)err);
+ dmlprintf1(state->memory, "Luratech JP2 error %d setting height\n", (int)err);
return ERRC;
}
err = JP2_Compress_SetProp(state->handle,
cJP2_Prop_Bits_Per_Sample, state->bpc, -1, -1);
if (err != cJP2_Error_OK) {
- dlprintf1("Luratech JP2 error %d setting bits per sample\n", (int)err);
+ dmlprintf1(state->memory, "Luratech JP2 error %d setting bits per sample\n", (int)err);
return ERRC;
}
@@ -943,14 +944,14 @@ s_jpxe_init(stream_state *ss)
case gs_jpx_cs_rgb: value = cJP2_Colorspace_RGBa; break;
case gs_jpx_cs_cmyk: value = cJP2_Colorspace_CMYKa; break;
default:
- dlprintf1("Unknown colorspace %d initializing JP2 encoder\n",
+ dmlprintf1(state->memory, "Unknown colorspace %d initializing JP2 encoder\n",
(int)state->colorspace);
return ERRC;
}
err = JP2_Compress_SetProp(state->handle,
cJP2_Prop_Extern_Colorspace, value, -1, -1);
if (err != cJP2_Error_OK) {
- dlprintf1("Luratech JP2 error %d setting colorspace\n", (int)err);
+ dmlprintf1(state->memory, "Luratech JP2 error %d setting colorspace\n", (int)err);
return ERRC;
}
@@ -963,13 +964,13 @@ s_jpxe_init(stream_state *ss)
err = JP2_Compress_SetProp(state->handle,
cJP2_Prop_Wavelet_Filter, cJP2_Wavelet_9_7, -1, -1);
if (err != cJP2_Error_OK) {
- dlprintf1("Luratech JP2 error %d setting wavelet filter\n", (int)err);
+ dmlprintf1(state->memory, "Luratech JP2 error %d setting wavelet filter\n", (int)err);
return ERRC;
}
err = JP2_Compress_SetProp(state->handle,
cJP2_Prop_Rate_Quality, state->quality, -1, -1);
if (err != cJP2_Error_OK) {
- dlprintf1("Luratech JP2 error %d setting compression quality\n", (int)err);
+ dmlprintf1(state->memory, "Luratech JP2 error %d setting compression quality\n", (int)err);
return ERRC;
}
@@ -996,13 +997,13 @@ s_jpxe_process(stream_state *ss, stream_cursor_read *pr,
err = JP2_Compress_SetProp(state->handle,
cJP2_Prop_Input_Parameter, (JP2_Property_Value)state, -1, -1);
if (err != cJP2_Error_OK) {
- dlprintf1("Luratech JP2 error %d setting input callback parameter.\n", (int)err);
+ dmlprintf1(state->memory, "Luratech JP2 error %d setting input callback parameter.\n", (int)err);
return ERRC;
}
err = JP2_Compress_SetProp(state->handle,
cJP2_Prop_Write_Parameter, (JP2_Property_Value)state, -1, -1);
if (err != cJP2_Error_OK) {
- dlprintf1("Luratech JP2 error %d setting compressed output callback parameter.\n", (int)err);
+ dmlprintf1(state->memory, "Luratech JP2 error %d setting compressed output callback parameter.\n", (int)err);
return ERRC;
}
@@ -1011,7 +1012,7 @@ s_jpxe_process(stream_state *ss, stream_cursor_read *pr,
if (state->inbuf == NULL) {
state->inbuf = malloc(JPX_BUFFER_SIZE);
if (state->inbuf == NULL) {
- dprintf("jpx encode: failed to allocate input buffer.\n");
+ dmprintf(state->memory, "jpx encode: failed to allocate input buffer.\n");
return ERRC;
}
state->insize = JPX_BUFFER_SIZE;
@@ -1021,7 +1022,7 @@ s_jpxe_process(stream_state *ss, stream_cursor_read *pr,
while (state->infill + in_size > state->insize) {
unsigned char *new = realloc(state->inbuf, state->insize*2);
if (new == NULL) {
- dprintf("jpx encode: failed to resize input buffer.\n");
+ dmprintf(state->memory, "jpx encode: failed to resize input buffer.\n");
return ERRC;
}
state->inbuf = new;
@@ -1037,10 +1038,10 @@ s_jpxe_process(stream_state *ss, stream_cursor_read *pr,
if (last && state->outbuf == NULL) {
/* We have all the data; call the compressor.
our callback will automatically allocate the output buffer */
- if_debug0('w', "[w] jpxe process compressing image data\n");
+ if_debug0m('w', state->memory, "[w] jpxe process compressing image data\n");
err = JP2_Compress_Image(state->handle);
if (err != cJP2_Error_OK) {
- dlprintf1("Luratech JP2 error %d compressing image data.\n", (int)err);
+ dmlprintf1(state->memory, "Luratech JP2 error %d compressing image data.\n", (int)err);
return ERRC;
}
}
@@ -1072,8 +1073,8 @@ s_jpxe_release(stream_state *ss)
err = JP2_Compress_End(state->handle);
if (err != cJP2_Error_OK) {
/* we can't return an error, so only print on debug builds */
- if_debug1('w', "[w]jpxe Luratech JP2 error %d"
- " closing compression context", (int)err);
+ if_debug1m('w', state->memory, "[w]jpxe Luratech JP2 error %d"
+ " closing compression context", (int)err);
}
/* free our own storage */
diff --git a/gs/base/slzwd.c b/gs/base/slzwd.c
index b8c4ad367..75c35db02 100644
--- a/gs/base/slzwd.c
+++ b/gs/base/slzwd.c
@@ -122,8 +122,8 @@ s_LZWD_process(stream_state * st, stream_cursor_read * pr,
byte b;
byte *q1;
- if_debug2('w', "[w]process decode: code_size=%d next_code=%d\n",
- code_size, next_code);
+ if_debug2m('w', ss->memory, "[w]process decode: code_size=%d next_code=%d\n",
+ code_size, next_code);
#define set_code_size()\
code_mask = (1 << code_size) - 1,\
switch_code = code_mask + 1 - ss->EarlyChange
@@ -139,8 +139,8 @@ s_LZWD_process(stream_state * st, stream_cursor_read * pr,
c = code;
ss->copy_left = rlen -= len;
- if_debug3('W', "[W]copying 0x%x, %d byte(s) out of %d left\n",
- code, len, rlen + len);
+ if_debug3m('W', ss->memory, "[W]copying 0x%x, %d byte(s) out of %d left\n",
+ code, len, rlen + len);
while (rlen)
c = table[c].prefix,
rlen--;
@@ -171,7 +171,7 @@ s_LZWD_process(stream_state * st, stream_cursor_read * pr,
if (p == rlimit)
goto out;
bytes_left = *++p;
- if_debug1('W', "[W]block count %d\n", bytes_left);
+ if_debug1m('W', ss->memory, "[W]block count %d\n", bytes_left);
if (bytes_left == 0) {
status = EOFC;
goto out;
@@ -187,8 +187,8 @@ s_LZWD_process(stream_state * st, stream_cursor_read * pr,
if (rlimit - p < 3)
goto out;
bytes_left = p[2];
- if_debug1('W', "[W]block count %d\n",
- bytes_left);
+ if_debug1m('W', ss->memory, "[W]block count %d\n",
+ bytes_left);
if (bytes_left == 0) {
status = EOFC;
goto out;
@@ -230,7 +230,7 @@ s_LZWD_process(stream_state * st, stream_cursor_read * pr,
code = bits >> bits_left;
}
code &= code_mask;
- if_debug2('W', "[W]reading 0x%x,%d\n", code, code_size);
+ if_debug2m('W', ss->memory, "[W]reading 0x%x,%d\n", code, code_size);
/*
* There is an anomalous case where a code S is followed
* immediately by another occurrence of the S string.
@@ -243,7 +243,7 @@ s_LZWD_process(stream_state * st, stream_cursor_read * pr,
if (code >= next_code) {
if (code > next_code) {
#ifdef DEBUG
- lprintf2("[W]code = %d > next_code = %d\n",
+ mlprintf2(ss->memory, "[W]code = %d > next_code = %d\n",
code, next_code);
#endif
status = ERRC;
@@ -256,8 +256,8 @@ s_LZWD_process(stream_state * st, stream_cursor_read * pr,
len = prev_len + 1;
dc_next->len = min(len, 255);
dc_next->prefix = prev_code;
- if_debug3('w', "[w]decoding anomalous 0x%x=0x%x+%c\n",
- next_code, prev_code, dc_next->datum);
+ if_debug3m('w', ss->memory, "[w]decoding anomalous 0x%x=0x%x+%c\n",
+ next_code, prev_code, dc_next->datum);
}
/* See if there is enough room for the code. */
reset:
@@ -266,8 +266,8 @@ reset:
/* We set their lengths to 255 to avoid doing */
/* an extra check in the normal case. */
if (code == code_reset) {
- if_debug1('w', "[w]reset: next_code was %d\n",
- next_code);
+ if_debug1m('w', ss->memory, "[w]reset: next_code was %d\n",
+ next_code);
next_code = code_0;
dc_next = table + code_0;
code_size = ss->InitialCodeLength + 1;
@@ -282,7 +282,7 @@ reset:
/* compute it the hard way. */
for (c = code, len = 0; c != eod; len++)
c = table[c].prefix;
- if_debug2('w', "[w]long code %d, length=%d\n", code, len);
+ if_debug2m('w', ss->memory, "[w]long code %d, length=%d\n", code, len);
}
if (wlimit - q < len) {
ss->copy_code = code;
@@ -367,16 +367,16 @@ reset:
dc_next->len = min(prev_len, 254) + 1;
dc_next->prefix = prev_code;
dc_next++;
- if_debug4('W', "[W]adding 0x%x=0x%x+%c(%d)\n",
- next_code, prev_code, b, min(len, 255));
+ if_debug4m('W', ss->memory, "[W]adding 0x%x=0x%x+%c(%d)\n",
+ next_code, prev_code, b, min(len, 255));
if (++next_code == switch_code) { /* Crossed a power of 2. */
/* We have to make a strange special check for */
/* reaching the end of the code space. */
if (next_code < lzw_decode_max - 1) {
code_size++;
set_code_size();
- if_debug2('w', "[w]crossed power of 2: new code_size=%d, next_code=%d\n",
- code_size, next_code);
+ if_debug2m('w', ss->memory, "[w]crossed power of 2: new code_size=%d, next_code=%d\n",
+ code_size, next_code);
}
}
}
@@ -392,8 +392,8 @@ reset:
ss->bits_left = bits_left;
ss->bytes_left = bytes_left;
ss->next_code = next_code;
- if_debug3('w', "[w]decoded %d bytes, prev_code=%d, next_code=%d\n",
- (int)(q - q0), prev_code, next_code);
+ if_debug3m('w', ss->memory, "[w]decoded %d bytes, prev_code=%d, next_code=%d\n",
+ (int)(q - q0), prev_code, next_code);
return status;
}
diff --git a/gs/base/slzwe.c b/gs/base/slzwe.c
index ed03a83a0..efb84bec5 100644
--- a/gs/base/slzwe.c
+++ b/gs/base/slzwe.c
@@ -63,7 +63,7 @@ lzw_put_code(register stream_LZW_state *ss, byte *q, uint code)
{ uint size = ss->code_size;
byte cb = (ss->bits << ss->bits_left) +
(code >> (size - ss->bits_left));
- if_debug2('W', "[w]writing 0x%x,%d\n", code, ss->code_size);
+ if_debug2m('W', ss->memory, "[w]writing 0x%x,%d\n", code, ss->code_size);
*++q = cb;
if ( (ss->bits_left += 8 - size) <= 0 )
{ *++q = code >> -ss->bits_left;
@@ -168,7 +168,7 @@ s_LZWE_process(stream_state *st, stream_cursor_read *pr,
ss->code_size++;
set_limit_code();
}
- if_debug3('W', "[W]encoding 0x%x=0x%x+%c\n",
+ if_debug3m('W', ss->memory, "[W]encoding 0x%x=0x%x+%c\n",
ss->next_code, code, c);
*tp = ss->next_code++;
ep = &table->encode[*tp];
diff --git a/gs/base/std.h b/gs/base/std.h
index c017c9f0b..99b80d728 100644
--- a/gs/base/std.h
+++ b/gs/base/std.h
@@ -127,14 +127,22 @@ typedef ulong bits32;
/*
* Standard error printing macros.
- * Use dprintf for messages that just go to dpf;
- * dlprintf for messages to dpf with optional with file name (and,
- * if available, line number);
- * eprintf or eprintfm for error messages to epf that include the program
- * name (eprintfm requires a memory pointer and is safe to use in
- * multithreaded environments - eprint does not, and is not, and should
- * therefore be avoided where possible);
- * lprintf for debugging messages that should include line number info.
+ *
+ * Use dmprintf (and dmputs, dmputc, dmflush etc for messages intended for
+ * stdout). If you would like an optional filename/line number (where
+ * available) prepended, use dmlprintf (and family).
+ *
+ * Use emprintf (and emputs, emputc, emflush etc for messages intended for
+ * stderr).
+ *
+ * All these above functions/macros take a "const gs_memory_t *" pointer to
+ * ensure that the correct stdout/stderr is used for the given gsapi instance.
+ *
+ * If you do not have a gs_memory_t * to hand, then you may call dprintf (and
+ * family) and eprintf(and family) insteads. Be aware that these functions
+ * compile away to nothing in GS_THREADSAFE builds, as they will not work in
+ * multithreaded environments.
+ *
* Since we all stdout/stderr output must go via outprintf/errprintf,
* we have to define dputc and dputs in terms of errprintf also.
*/
@@ -157,9 +165,13 @@ typedef struct gs_memory_s gs_memory_t;
int proc(gs_memory_t *)
/* dpf and epf may be redefined */
+#define dpfm errprintf
+#define epfm errprintf
+
+#ifndef GS_THREADSAFE
#define dpf errprintf_nomem
#define epf errprintf_nomem
-#define epfm errprintf
+#endif /* GS_THREADSAFE */
/* To allow stdout and stderr to be redirected, all stdout goes
* though outwrite and all stderr goes through errwrite.
@@ -170,11 +182,13 @@ int errwrite(const gs_memory_t *mem, const char *str, int len);
void outflush(const gs_memory_t *mem);
void errflush(const gs_memory_t *mem);
+#ifndef GS_THREADSAFE
/* As a temporary measure, we allow forms of errwrite/errflush that do not
* need to be given a memory pointer. Any uses of this (largely the debugging
* system) will fail with multithreaded usage. */
int errwrite_nomem(const char *str, int len);
void errflush_nomem(void);
+#endif /* GS_THREADSAFE */
/* Formatted output to outwrite and errwrite.
* The maximum string length is 1023 characters.
@@ -191,14 +205,77 @@ void errflush_nomem(void);
# endif
int outprintf(const gs_memory_t *mem, const char *fmt, ...) __printflike(2, 3);
int errprintf(const gs_memory_t *mem, const char *fmt, ...) __printflike(2, 3);
+#ifndef GS_THREADSAFE
int errprintf_nomem(const char *fmt, ...) __printflike(1, 2);
+#endif
#else
int outprintf();
int errprintf();
+#ifndef GS_THREADSAFE
int errprintf_nomem();
#endif
+#endif
-/* Print the program line # for debugging. */
+/* Print the program line # for debugging - NON THREADSAFE VERSIONS */
+#ifdef GS_THREADSAFE
+#define dflush() DO_NOTHING
+#define dputc(chr) DO_NOTHING
+#define dlputc(chr) DO_NOTHING
+#define dputs(str) DO_NOTHING
+#define dlputs(str) DO_NOTHING
+#define dprintf(str)\
+ DO_NOTHING
+#define dlprintf(str)\
+ DO_NOTHING
+#define dprintf1(str,arg1)\
+ DO_NOTHING
+#define dlprintf1(str,arg1)\
+ DO_NOTHING
+#define dprintf2(str,arg1,arg2)\
+ DO_NOTHING
+#define dlprintf2(str,arg1,arg2)\
+ DO_NOTHING
+#define dprintf3(str,arg1,arg2,arg3)\
+ DO_NOTHING
+#define dlprintf3(str,arg1,arg2,arg3)\
+ DO_NOTHING
+#define dprintf4(str,arg1,arg2,arg3,arg4)\
+ DO_NOTHING
+#define dlprintf4(str,arg1,arg2,arg3,arg4)\
+ DO_NOTHING
+#define dprintf5(str,arg1,arg2,arg3,arg4,arg5)\
+ DO_NOTHING
+#define dlprintf5(str,arg1,arg2,arg3,arg4,arg5)\
+ DO_NOTHING
+#define dprintf6(str,arg1,arg2,arg3,arg4,arg5,arg6)\
+ DO_NOTHING
+#define dlprintf6(str,arg1,arg2,arg3,arg4,arg5,arg6)\
+ DO_NOTHING
+#define dprintf7(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7)\
+ DO_NOTHING
+#define dlprintf7(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7)\
+ DO_NOTHING
+#define dprintf8(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)\
+ DO_NOTHING
+#define dlprintf8(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)\
+ DO_NOTHING
+#define dprintf9(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)\
+ DO_NOTHING
+#define dlprintf9(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)\
+ DO_NOTHING
+#define dprintf10(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10)\
+ DO_NOTHING
+#define dlprintf10(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10)\
+ DO_NOTHING
+#define dprintf11(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11)\
+ DO_NOTHING
+#define dlprintf11(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11)\
+ DO_NOTHING
+#define dprintf12(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12)\
+ DO_NOTHING
+#define dlprintf12(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12)\
+ DO_NOTHING
+#else
#if __LINE__ /* compiler provides it */
void dprintf_file_and_line(const char *, int);
# define _dpl dprintf_file_and_line(__FILE__, __LINE__),
@@ -264,15 +341,112 @@ void dflush(void); /* flush stderr */
dpf(str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12)
#define dlprintf12(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12)\
(_dpl dprintf12(str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12))
+#endif /* GS_THREADSAFE */
+
+/* Print the program line # for debugging. */
+#if __LINE__ /* compiler provides it */
+void dmprintf_file_and_line(const gs_memory_t *,const char *, int);
+# define _dmpl(M) dmprintf_file_and_line(M,__FILE__, __LINE__),
+#else
+void dmprintf_file_only(const gs_memory_t *,const char *);
+# define _dmpl(M) dmprintf_file_only(M,__FILE__),
+#endif
+
+#define dmflush(mem) errflush(mem)
+#define dmputc(mem,chr) dmprintf1(mem,"%c", chr)
+#define dmlputc(mem,chr) dmlprintf1(mem,"%c", chr)
+#define dmputs(mem,str) dmprintf1(mem,"%s", str)
+#define dmlputs(mem,str) dmlprintf1(mem,"%s", str)
+#define dmprintf(mem,str)\
+ dpfm(mem,str)
+#define dmlprintf(mem,str)\
+ (_dmpl(mem) dpfm(mem,str))
+#define dmprintf1(mem,str,arg1)\
+ dpfm(mem,str, arg1)
+#define dmlprintf1(mem,str,arg1)\
+ (_dmpl(mem) dmprintf1(mem,str, arg1))
+#define dmprintf2(mem,str,arg1,arg2)\
+ dpfm(mem,str, arg1, arg2)
+#define dmlprintf2(mem,str,arg1,arg2)\
+ (_dmpl(mem) dmprintf2(mem,str, arg1, arg2))
+#define dmprintf3(mem,str,arg1,arg2,arg3)\
+ dpfm(mem,str, arg1, arg2, arg3)
+#define dmlprintf3(mem,str,arg1,arg2,arg3)\
+ (_dmpl(mem) dmprintf3(mem,str, arg1, arg2, arg3))
+#define dmprintf4(mem,str,arg1,arg2,arg3,arg4)\
+ dpfm(mem,str, arg1, arg2, arg3, arg4)
+#define dmlprintf4(mem,str,arg1,arg2,arg3,arg4)\
+ (_dmpl(mem) dmprintf4(mem,str, arg1, arg2, arg3, arg4))
+#define dmprintf5(mem,str,arg1,arg2,arg3,arg4,arg5)\
+ dpfm(mem,str, arg1, arg2, arg3, arg4, arg5)
+#define dmlprintf5(mem,str,arg1,arg2,arg3,arg4,arg5)\
+ (_dmpl(mem) dmprintf5(mem,str, arg1, arg2, arg3, arg4, arg5))
+#define dmprintf6(mem,str,arg1,arg2,arg3,arg4,arg5,arg6)\
+ dpfm(mem,str, arg1, arg2, arg3, arg4, arg5, arg6)
+#define dmlprintf6(mem,str,arg1,arg2,arg3,arg4,arg5,arg6)\
+ (_dmpl(mem) dmprintf6(mem,str, arg1, arg2, arg3, arg4, arg5, arg6))
+#define dmprintf7(mem,str,arg1,arg2,arg3,arg4,arg5,arg6,arg7)\
+ dpfm(mem,str, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
+#define dmlprintf7(mem,str,arg1,arg2,arg3,arg4,arg5,arg6,arg7)\
+ (_dmpl(mem) dmprintf7(mem,str, arg1, arg2, arg3, arg4, arg5, arg6, arg7))
+#define dmprintf8(mem,str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)\
+ dpfm(mem,str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
+#define dmlprintf8(mem,str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)\
+ (_dmpl(mem) dmprintf8(mem,str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8))
+#define dmprintf9(mem,str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)\
+ dpfm(mem,str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9)
+#define dmlprintf9(mem,str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)\
+ (_dmpl(mem) dmprintf9(mem,str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9))
+#define dmprintf10(mem,str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10)\
+ dpfm(mem,str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10)
+#define dmlprintf10(mem,str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10)\
+ (_dmpl(mem) dmprintf10(mem,str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10))
+#define dmprintf11(mem,str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11)\
+ dpfm(mem,str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11)
+#define dmlprintf11(mem,str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11)\
+ (_dmpl(mem) dmprintf11(mem,str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11))
+#define dmprintf12(mem,str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12)\
+ dpfm(mem,str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12)
+#define dmlprintf12(mem,str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10,arg11,arg12)\
+ (_dmpl(mem) dmprintf12(mem,str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12))
+
void printf_program_ident(const gs_memory_t *mem, const char *program_name, long revision_number);
+#ifdef GS_THREADSAFE
+#define eprintf_program_ident(NAME,NUM) DO_NOTHING
+#else
void eprintf_program_ident(const char *program_name, long revision_number);
+#endif /* GS_THREADSAFE */
void emprintf_program_ident(const gs_memory_t *mem,
const char *program_name,
long revision_number);
const char *gs_program_name(void);
long gs_revision_number(void);
+#ifdef GS_THREADSAFE
+#define eprintf(str)\
+ DO_NOTHING
+#define eprintf1(str,arg1)\
+ DO_NOTHING
+#define eprintf2(str,arg1,arg2)\
+ DO_NOTHING
+#define eprintf3(str,arg1,arg2,arg3)\
+ DO_NOTHING
+#define eprintf4(str,arg1,arg2,arg3,arg4)\
+ DO_NOTHING
+#define eprintf5(str,arg1,arg2,arg3,arg4,arg5)\
+ DO_NOTHING
+#define eprintf6(str,arg1,arg2,arg3,arg4,arg5,arg6)\
+ DO_NOTHING
+#define eprintf7(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7)\
+ DO_NOTHING
+#define eprintf8(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)\
+ DO_NOTHING
+#define eprintf9(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)\
+ DO_NOTHING
+#define eprintf10(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10)\
+ DO_NOTHING
+#else
#define _epi eprintf_program_ident(gs_program_name(), gs_revision_number()),
#define eprintf(str)\
@@ -297,6 +471,7 @@ long gs_revision_number(void);
(_epi epf(str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9))
#define eprintf10(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10)\
(_epi epf(str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10))
+#endif /* GS_THREADSAFE */
#define _epim(mem) emprintf_program_ident(mem, gs_program_name(), gs_revision_number()),
@@ -323,6 +498,30 @@ long gs_revision_number(void);
#define emprintf10(mem, str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10)\
(_epim(mem) epfm(mem, str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10))
+#ifdef GS_THREADSAFE
+#define lprintf(str)\
+ DO_NOTHING
+#define lprintf1(str,arg1)\
+ DO_NOTHING
+#define lprintf2(str,arg1,arg2)\
+ DO_NOTHING
+#define lprintf3(str,arg1,arg2,arg3)\
+ DO_NOTHING
+#define lprintf4(str,arg1,arg2,arg3,arg4)\
+ DO_NOTHING
+#define lprintf5(str,arg1,arg2,arg3,arg4,arg5)\
+ DO_NOTHING
+#define lprintf6(str,arg1,arg2,arg3,arg4,arg5,arg6)\
+ DO_NOTHING
+#define lprintf7(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7)\
+ DO_NOTHING
+#define lprintf8(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)\
+ DO_NOTHING
+#define lprintf9(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)\
+ DO_NOTHING
+#define lprintf10(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10)\
+ DO_NOTHING
+#else
#if __LINE__ /* compiler provides it */
void lprintf_file_and_line(const char *, int);
# define _epl _epi lprintf_file_and_line(__FILE__, __LINE__),
@@ -353,7 +552,38 @@ void lprintf_file_only(const char *);
(_epl epf(str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9))
#define lprintf10(str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10)\
(_epl epf(str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10))
+#endif /* GS_THREADSAFE */
+
+#if __LINE__ /* compiler provides it */
+void mlprintf_file_and_line(const gs_memory_t *,const char *, int);
+# define _eplm(mem) _epim(mem) mlprintf_file_and_line(mem, __FILE__, __LINE__),
+#else
+void lprintf_file_only(const gs_memory_t *,const char *);
+# define _eplm(mem) _epim(mem) mlprintf_file_only(mem, __FILE__)
+#endif
+#define mlprintf(mem,str)\
+ (_eplm(mem) epfm(mem,str))
+#define mlprintf1(mem,str,arg1)\
+ (_eplm(mem) epfm(mem,str, arg1))
+#define mlprintf2(mem,str,arg1,arg2)\
+ (_eplm(mem) epfm(mem,str, arg1, arg2))
+#define mlprintf3(mem,str,arg1,arg2,arg3)\
+ (_eplm(mem) epfm(mem,str, arg1, arg2, arg3))
+#define mlprintf4(mem,str,arg1,arg2,arg3,arg4)\
+ (_eplm(mem) epfm(mem,str, arg1, arg2, arg3, arg4))
+#define mlprintf5(mem,str,arg1,arg2,arg3,arg4,arg5)\
+ (_eplm(mem) epfm(mem,str, arg1, arg2, arg3, arg4, arg5))
+#define mlprintf6(mem,str,arg1,arg2,arg3,arg4,arg5,arg6)\
+ (_eplm(mem) epfm(mem,str, arg1, arg2, arg3, arg4, arg5, arg6))
+#define mlprintf7(mem,str,arg1,arg2,arg3,arg4,arg5,arg6,arg7)\
+ (_eplm(mem) epfm(mem,str, arg1, arg2, arg3, arg4, arg5, arg6, arg7))
+#define mlprintf8(mem,str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8)\
+ (_eplm(mem) epfm(mem,str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8))
+#define mlprintf9(mem,str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9)\
+ (_eplm(mem) epfm(mem,str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9))
+#define mlprintf10(mem,str,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10)\
+ (_eplm(mem) epfm(mem,str, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10))
/*
* Define the prototype for module initialization procedures. This is not
* a very good place to define this, but we can't find a better one.
diff --git a/gs/base/stream.c b/gs/base/stream.c
index a5079ee36..7132f679e 100644
--- a/gs/base/stream.c
+++ b/gs/base/stream.c
@@ -79,11 +79,11 @@ stream_finalize(const gs_memory_t *cmem, void *vptr)
stream *const st = vptr;
(void)cmem; /* unused */
- if_debug2('u', "[u]%s 0x%lx\n",
- (!s_is_valid(st) ? "already closed:" :
- st->is_temp ? "is_temp set:" :
- st->file == 0 ? "not file:" :
- "closing file:"), (ulong) st);
+ if_debug2m('u', cmem, "[u]%s 0x%lx\n",
+ (!s_is_valid(st) ? "already closed:" :
+ st->is_temp ? "is_temp set:" :
+ st->file == 0 ? "not file:" :
+ "closing file:"), (ulong) st);
if (s_is_valid(st) && !st->is_temp && st->file != 0) {
/* Prevent any attempt to free the buffer. */
st->cbuf = 0;
@@ -118,8 +118,8 @@ s_alloc(gs_memory_t * mem, client_name_t cname)
{
stream *s = gs_alloc_struct(mem, stream, &st_stream, cname);
- if_debug2('s', "[s]alloc(%s) = 0x%lx\n",
- client_name_string(cname), (ulong) s);
+ if_debug2m('s', mem, "[s]alloc(%s) = 0x%lx\n",
+ client_name_string(cname), (ulong) s);
if (s == 0)
return 0;
s_init(s, mem);
@@ -143,10 +143,10 @@ s_alloc_state(gs_memory_t * mem, gs_memory_type_ptr_t stype,
{
stream_state *st = gs_alloc_struct(mem, stream_state, stype, cname);
- if_debug3('s', "[s]alloc_state %s(%s) = 0x%lx\n",
- client_name_string(cname),
- client_name_string(stype->sname),
- (ulong) st);
+ if_debug3m('s', mem, "[s]alloc_state %s(%s) = 0x%lx\n",
+ client_name_string(cname),
+ client_name_string(stype->sname),
+ (ulong) st);
if (st)
s_init_state(st, NULL, mem);
return st;
@@ -174,8 +174,8 @@ s_std_init(register stream * s, byte * ptr, uint len, const stream_procs * pp,
s->file = 0;
s->file_name.data = 0; /* in case stream is on stack */
s->file_name.size = 0;
- if_debug4('s', "[s]init 0x%lx, buf=0x%lx, len=%u, modes=%d\n",
- (ulong) s, (ulong) ptr, len, modes);
+ if_debug4m('s', s->memory, "[s]init 0x%lx, buf=0x%lx, len=%u, modes=%d\n",
+ (ulong) s, (ulong) ptr, len, modes);
}
/* Set the file name of a stream, copying the name. */
@@ -311,7 +311,7 @@ s_disable(register stream * s)
s->file_name.size = 0;
}
/****** SHOULD DO MORE THAN THIS ******/
- if_debug1('s', "[s]disable 0x%lx\n", (ulong) s);
+ if_debug1m('s', s->memory, "[s]disable 0x%lx\n", (ulong) s);
}
/* Implement flushing for encoding filters. */
@@ -396,8 +396,8 @@ stell(stream * s)
int
spseek(stream * s, long pos)
{
- if_debug3('s', "[s]seek 0x%lx to %ld, position was %ld\n",
- (ulong) s, pos, stell(s));
+ if_debug3m('s', s->memory, "[s]seek 0x%lx to %ld, position was %ld\n",
+ (ulong) s, pos, stell(s));
return (*(s)->procs.seek) (s, pos);
}
@@ -802,15 +802,15 @@ sreadbuf(stream * s, stream_cursor_write * pbuf)
eof = strm->end_status == EOFC;
}
pw = (prev == 0 ? pbuf : &curr->cursor.w);
- if_debug4('s', "[s]read process 0x%lx, nr=%u, nw=%u, eof=%d\n",
- (ulong) curr, (uint) (pr->limit - pr->ptr),
- (uint) (pw->limit - pw->ptr), eof);
+ if_debug4m('s', s->memory, "[s]read process 0x%lx, nr=%u, nw=%u, eof=%d\n",
+ (ulong) curr, (uint) (pr->limit - pr->ptr),
+ (uint) (pw->limit - pw->ptr), eof);
oldpos = pw->ptr;
status = (*curr->procs.process) (curr->state, pr, pw, eof);
pr->limit += left;
- if_debug5('s', "[s]after read 0x%lx, nr=%u, nw=%u, status=%d, position=%ld\n",
- (ulong) curr, (uint) (pr->limit - pr->ptr),
- (uint) (pw->limit - pw->ptr), status, s->position);
+ if_debug5m('s', s->memory, "[s]after read 0x%lx, nr=%u, nw=%u, status=%d, position=%ld\n",
+ (ulong) curr, (uint) (pr->limit - pr->ptr),
+ (uint) (pw->limit - pw->ptr), status, s->position);
if (strm == 0 || status != 0)
break;
if (strm->end_status < 0) {
@@ -885,19 +885,19 @@ swritebuf(stream * s, stream_cursor_read * pbuf, bool last)
pr = pbuf;
else
pr = &curr->cursor.r;
- if_debug5('s',
- "[s]write process 0x%lx(%s), nr=%u, nw=%u, end=%d\n",
- (ulong)curr,
- gs_struct_type_name(curr->state->templat->stype),
- (uint)(pr->limit - pr->ptr),
- (uint)(pw->limit - pw->ptr), end);
+ if_debug5m('s', s->memory,
+ "[s]write process 0x%lx(%s), nr=%u, nw=%u, end=%d\n",
+ (ulong)curr,
+ gs_struct_type_name(curr->state->templat->stype),
+ (uint)(pr->limit - pr->ptr),
+ (uint)(pw->limit - pw->ptr), end);
status = curr->end_status;
if (status >= 0) {
status = (*curr->procs.process)(curr->state, pr, pw, end);
- if_debug5('s',
- "[s]after write 0x%lx, nr=%u, nw=%u, end=%d, status=%d\n",
- (ulong) curr, (uint) (pr->limit - pr->ptr),
- (uint) (pw->limit - pw->ptr), end, status);
+ if_debug5m('s', s->memory,
+ "[s]after write 0x%lx, nr=%u, nw=%u, end=%d, status=%d\n",
+ (ulong) curr, (uint) (pr->limit - pr->ptr),
+ (uint) (pw->limit - pw->ptr), end, status);
if (status == 0 && end)
status = EOFC;
if (status == EOFC || status == ERRC)
@@ -918,7 +918,7 @@ swritebuf(stream * s, stream_cursor_read * pbuf, bool last)
break;
if (!curr->is_temp)
++depth;
- if_debug1('s', "[s]moving ahead, depth = %d\n", depth);
+ if_debug1m('s', strm->memory, "[s]moving ahead, depth = %d\n", depth);
MOVE_AHEAD(curr, prev);
stream_compact(curr, false);
}
@@ -933,7 +933,7 @@ swritebuf(stream * s, stream_cursor_read * pbuf, bool last)
* otherwise leave it alone.
*/
while (prev) {
- if_debug0('s', "[s]unwinding\n");
+ if_debug0m('s', s->memory, "[s]unwinding\n");
MOVE_BACK(curr, prev);
if (status >= 0)
curr->end_status = 0;
@@ -945,7 +945,7 @@ swritebuf(stream * s, stream_cursor_read * pbuf, bool last)
MOVE_BACK(curr, prev);
if (!curr->is_temp)
--depth;
- if_debug1('s', "[s]moving back, depth = %d\n", depth);
+ if_debug1m('s', s->memory, "[s]moving back, depth = %d\n", depth);
}
}
diff --git a/gs/contrib/pcl3/eprn/eprnparm.c b/gs/contrib/pcl3/eprn/eprnparm.c
index 0d1a5984a..15fff172c 100644
--- a/gs/contrib/pcl3/eprn/eprnparm.c
+++ b/gs/contrib/pcl3/eprn/eprnparm.c
@@ -189,11 +189,11 @@ void eprn_dump_parameter_list(gs_param_list *plist)
int j;
count++;
- dlprintf(" `");
- for (j = 0; j < key.size; j++) dputc(key.data[j]);
- dprintf("'\n");
+ dmlprintf(plist->memory, " `");
+ for (j = 0; j < key.size; j++) dmputc(plist->memory, key.data[j]);
+ dmprintf(plist->memory, "'\n");
}
- dlprintf1(" Number of parameters: %d.\n", count);
+ dmlprintf1(plist->memory, " Number of parameters: %d.\n", count);
return;
}
@@ -894,7 +894,7 @@ int eprn_put_params(gx_device *dev, gs_param_list *plist)
#ifdef EPRN_TRACE
if (gs_debug_c(EPRN_TRACE_CHAR)) {
- dlprintf(
+ dmlprintf(dev->memory,
"! eprn_put_params() called with the following device parameters:\n");
eprn_dump_parameter_list(plist);
}
diff --git a/gs/contrib/pcl3/eprn/eprnrend.c b/gs/contrib/pcl3/eprn/eprnrend.c
index 3a9b3a413..06fca8b3e 100644
--- a/gs/contrib/pcl3/eprn/eprnrend.c
+++ b/gs/contrib/pcl3/eprn/eprnrend.c
@@ -1034,13 +1034,13 @@ int eprn_fetch_scan_line(eprn_Device *dev, eprn_OctetString *line)
#if 0 && defined(EPRN_TRACE)
if (gs_debug_c(EPRN_TRACE_CHAR)) {
int j;
- dlprintf("! eprn_fetch_scan_line(): Fetched ");
- if (line->length == 0) dprintf("empty scan line.");
+ dmlprintf(dev->memory, "! eprn_fetch_scan_line(): Fetched ");
+ if (line->length == 0) dmprintf(dev->memory, "empty scan line.");
else {
- dprintf("scan line: 0x");
- for (j = 0; j < line->length; j++) dprintf1("%02X", line->str[j]);
+ dmprintf(dev->memory, "scan line: 0x");
+ for (j = 0; j < line->length; j++) dmprintf1(dev->memory, "%02X", line->str[j]);
}
- dlprintf("\n");
+ dmlprintf(dev->memory, "\n");
}
#endif
@@ -1124,9 +1124,9 @@ int eprn_get_planes(eprn_Device *dev, eprn_OctetString bitplanes[])
if (gs_debug_c(EPRN_TRACE_CHAR)) {
static bool already_noted = false;
if (!already_noted && line->str[line->length - 1] != 0xEE) {
- dlprintf1("! eprn_get_planes(): "
- "Line-terminating octet is 0x%02X.\n",
- line->str[line->length - 1]);
+ dmlprintf1(dev->memory, "! eprn_get_planes(): "
+ "Line-terminating octet is 0x%02X.\n",
+ line->str[line->length - 1]);
already_noted = true;
}
}
diff --git a/gs/contrib/pcl3/eprn/gdeveprn.c b/gs/contrib/pcl3/eprn/gdeveprn.c
index 841229076..74d18abf9 100644
--- a/gs/contrib/pcl3/eprn/gdeveprn.c
+++ b/gs/contrib/pcl3/eprn/gdeveprn.c
@@ -314,7 +314,7 @@ static void print_flags(ms_MediaCode flags, const ms_Flag *user_flags)
if (user_flags != NULL) {
while (user_flags->code != ms_none) {
if (user_flags->code & flags) {
- errprintf_nomem("%s", user_flags->name);
+ eprintf1("%s", user_flags->name);
flags &= ~user_flags->code;
}
user_flags++;
diff --git a/gs/contrib/pcl3/src/gdevpcl3.c b/gs/contrib/pcl3/src/gdevpcl3.c
index 4c15d6de1..ec4176aba 100644
--- a/gs/contrib/pcl3/src/gdevpcl3.c
+++ b/gs/contrib/pcl3/src/gdevpcl3.c
@@ -675,7 +675,7 @@ static int pcl3_get_params(gx_device *device, gs_param_list *plist)
#ifdef EPRN_TRACE
if (gs_debug_c(EPRN_TRACE_CHAR)) {
- dlprintf("! pcl3_get_params() returns the following parameters:\n");
+ dmlprintf(dev->memory, "! pcl3_get_params() returns the following parameters:\n");
eprn_dump_parameter_list(plist);
}
#endif
diff --git a/gs/cups/gdevcups.c b/gs/cups/gdevcups.c
index 2a80b3564..723a0b891 100644
--- a/gs/cups/gdevcups.c
+++ b/gs/cups/gdevcups.c
@@ -459,10 +459,10 @@ private int
cups_close(gx_device *pdev) /* I - Device info */
{
#ifdef CUPS_DEBUG2
- dprintf1("DEBUG2: cups_close(%p)\n", pdev);
+ dmprintf1(pdev->memory, "DEBUG2: cups_close(%p)\n", pdev);
#endif /* CUPS_DEBUG2 */
- dprintf("INFO: Rendering completed\n");
+ dmprintf(pdev->memory, "INFO: Rendering completed\n");
if (cups->stream != NULL)
{
@@ -557,7 +557,7 @@ cups_encode_color(gx_device *pdev,
ci = (ci << shift) | cups->EncodeLUT[cv[i]];
#ifdef CUPS_DEBUG2
- dprintf2("DEBUG2: cv[0]=%d -> %llx\n", cv[0], ci);
+ dmprintf2(pdev->memory, "DEBUG2: cv[0]=%d -> %llx\n", cv[0], ci);
#endif /* CUPS_DEBUG2 */
/*
@@ -766,7 +766,7 @@ cups_get_matrix(gx_device *pdev, /* I - Device info */
gs_matrix *pmat) /* O - Physical transform matrix */
{
#ifdef CUPS_DEBUG2
- dprintf2("DEBUG2: cups_get_matrix(%p, %p)\n", pdev, pmat);
+ dmprintf2(pdev->memory, "DEBUG2: cups_get_matrix(%p, %p)\n", pdev, pmat);
#endif /* CUPS_DEBUG2 */
/*
@@ -801,7 +801,7 @@ cups_get_matrix(gx_device *pdev, /* I - Device info */
* Do portrait orientation...
*/
#ifdef CUPS_DEBUG2
- dprintf("DEBUG2: Portrait matrix: XX=+1 XY=0 YX=0 YY=-1\n");
+ dmprintf(pdev->memory, "DEBUG2: Portrait matrix: XX=+1 XY=0 YX=0 YY=-1\n");
#endif /* CUPS_DEBUG2 */
pmat->xx = (float)cups->header.HWResolution[0] / 72.0;
pmat->xy = 0.0;
@@ -825,16 +825,16 @@ cups_get_matrix(gx_device *pdev, /* I - Device info */
#endif /* CUPS_RASTER_SYNCv1 */
#ifdef CUPS_DEBUG2
- dprintf2("DEBUG2: width = %d, height = %d\n", cups->header.cupsWidth,
- cups->header.cupsHeight);
- dprintf4("DEBUG2: PageSize = [ %d %d ], HWResolution = [ %d %d ]\n",
- cups->header.PageSize[0], cups->header.PageSize[1],
- cups->header.HWResolution[0], cups->header.HWResolution[1]);
- dprintf4("DEBUG2: HWMargins = [ %.3f %.3f %.3f %.3f ]\n",
- pdev->HWMargins[0], pdev->HWMargins[1], pdev->HWMargins[2],
- pdev->HWMargins[3]);
- dprintf6("DEBUG2: matrix = [ %.3f %.3f %.3f %.3f %.3f %.3f ]\n",
- pmat->xx, pmat->xy, pmat->yx, pmat->yy, pmat->tx, pmat->ty);
+ dmprintf2(pdev->memory, "DEBUG2: width = %d, height = %d\n", cups->header.cupsWidth,
+ cups->header.cupsHeight);
+ dmprintf4(pdev->memory, "DEBUG2: PageSize = [ %d %d ], HWResolution = [ %d %d ]\n",
+ cups->header.PageSize[0], cups->header.PageSize[1],
+ cups->header.HWResolution[0], cups->header.HWResolution[1]);
+ dmprintf4(pdev->memory, "DEBUG2: HWMargins = [ %.3f %.3f %.3f %.3f ]\n",
+ pdev->HWMargins[0], pdev->HWMargins[1], pdev->HWMargins[2],
+ pdev->HWMargins[3]);
+ dmprintf6(pdev->memory, "DEBUG2: matrix = [ %.3f %.3f %.3f %.3f %.3f %.3f ]\n",
+ pmat->xx, pmat->xy, pmat->yx, pmat->yy, pmat->tx, pmat->ty);
#endif /* CUPS_DEBUG2 */
}
@@ -857,7 +857,7 @@ cups_get_params(gx_device *pdev, /* I - Device info */
#ifdef CUPS_DEBUG2
- dprintf2("DEBUG2: cups_get_params(%p, %p)\n", pdev, plist);
+ dmprintf2(pdev->memory, "DEBUG2: cups_get_params(%p, %p)\n", pdev, plist);
#endif /* CUPS_DEBUG2 */
/*
@@ -865,14 +865,14 @@ cups_get_params(gx_device *pdev, /* I - Device info */
*/
#ifdef CUPS_DEBUG2
- dprintf("DEBUG2: before gdev_prn_get_params()\n");
+ dmprintf(pdev->memory, "DEBUG2: before gdev_prn_get_params()\n");
#endif /* CUPS_DEBUG2 */
if ((code = gdev_prn_get_params(pdev, plist)) < 0)
return (code);
#ifdef CUPS_DEBUG2
- dprintf("DEBUG2: after gdev_prn_get_params()\n");
+ dmprintf(pdev->memory, "DEBUG2: after gdev_prn_get_params()\n");
#endif /* CUPS_DEBUG2 */
/*
@@ -1062,7 +1062,7 @@ cups_get_params(gx_device *pdev, /* I - Device info */
#endif /* CUPS_RASTER_SYNCv1 */
#ifdef CUPS_DEBUG2
- dprintf("DEBUG2: Leaving cups_get_params()\n");
+ dmprintf(pdev->memory, "DEBUG2: Leaving cups_get_params()\n");
#endif /* CUPS_DEBUG2 */
return (0);
@@ -1085,7 +1085,7 @@ cups_get_space_params(const gx_device_printer *pdev,
#ifdef CUPS_DEBUG2
- dprintf2("DEBUG2: cups_get_space_params(%p, %p)\n", pdev, space_params);
+ dmprintf2(pdev->memory, "DEBUG2: cups_get_space_params(%p, %p)\n", pdev, space_params);
#endif /* CUPS_DEBUG2 */
if ((cache_env = getenv("RIP_MAX_CACHE")) != NULL)
@@ -1116,7 +1116,7 @@ cups_get_space_params(const gx_device_printer *pdev,
return;
#ifdef CUPS_DEBUG2
- dprintf1("DEBUG2: cache_size = %.0f\n", cache_size);
+ dmprintf1(pdev->memory, "DEBUG2: cache_size = %.0f\n", cache_size);
#endif /* CUPS_DEBUG2 */
space_params->MaxBitmap = (long)cache_size;
@@ -1166,8 +1166,8 @@ cups_map_cmyk(gx_device *pdev, /* I - Device info */
#ifdef CUPS_DEBUG2
- dprintf6("DEBUG2: cups_map_cmyk(%p, %d, %d, %d, %d, %p)\n",
- pdev, c, m, y, k, out);
+ dmprintf6(pdev->memory, "DEBUG2: cups_map_cmyk(%p, %d, %d, %d, %d, %p)\n",
+ pdev, c, m, y, k, out);
#endif /* CUPS_DEBUG2 */
/*
@@ -1596,17 +1596,17 @@ cups_map_cmyk(gx_device *pdev, /* I - Device info */
{
default :
case 1 :
- dprintf1("DEBUG2: \\=== COLOR %d\n", out[0]);
+ dmprintf1(pdev->memory, "DEBUG2: \\=== COLOR %d\n", out[0]);
break;
case 3 :
- dprintf3("DEBUG2: \\=== COLOR %d, %d, %d\n",
- out[0], out[1], out[2]);
+ dmprintf3(pdev->memory, "DEBUG2: \\=== COLOR %d, %d, %d\n",
+ out[0], out[1], out[2]);
break;
case 4 :
- dprintf4("DEBUG2: \\=== COLOR %d, %d, %d, %d\n",
- out[0], out[1], out[2], out[3]);
+ dmprintf4(pdev->memory, "DEBUG2: \\=== COLOR %d, %d, %d, %d\n",
+ out[0], out[1], out[2], out[3]);
break;
}
#endif /* CUPS_DEBUG2 */
@@ -1623,8 +1623,8 @@ cups_map_gray(gx_device *pdev, /* I - Device info */
frac *out) /* O - Device colors */
{
#ifdef CUPS_DEBUG22
- dprintf3("DEBUG2: cups_map_gray(%p, %d, %p)\n",
- pdev, g, out);
+ dmprintf3(pdev->memory, "DEBUG2: cups_map_gray(%p, %d, %p)\n",
+ pdev, g, out);
#endif /* CUPS_DEBUG22 */
/*
@@ -1654,8 +1654,8 @@ cups_map_rgb(gx_device *pdev,
#ifdef CUPS_DEBUG2
- dprintf6("DEBUG2: cups_map_rgb(%p, %p, %d, %d, %d, %p)\n",
- pdev, pis, r, g, b, out);
+ dmprintf6(pdev->memory, "DEBUG2: cups_map_rgb(%p, %p, %d, %d, %d, %p)\n",
+ pdev, pis, r, g, b, out);
#endif /* CUPS_DEBUG2 */
/*
@@ -1746,8 +1746,8 @@ cups_map_cmyk_color(gx_device *pdev,
k = cv[3];
#ifdef CUPS_DEBUG2
- dprintf5("DEBUG2: cups_map_cmyk_color(%p, %d, %d, %d, %d)\n", pdev,
- c, m, y, k);
+ dmprintf5(pdev->memory, "DEBUG2: cups_map_cmyk_color(%p, %d, %d, %d, %d)\n",
+ pdev, c, m, y, k);
#endif /* CUPS_DEBUG2 */
/*
@@ -1878,8 +1878,8 @@ cups_map_cmyk_color(gx_device *pdev,
}
#ifdef CUPS_DEBUG2
- dprintf9("DEBUG2: CMYK (%d,%d,%d,%d) -> CMYK %08x (%d,%d,%d,%d)\n",
- c, m, y, k, (unsigned)i, ic, im, iy, ik);
+ dmprintf9(pdev->memory, "DEBUG2: CMYK (%d,%d,%d,%d) -> CMYK %08x (%d,%d,%d,%d)\n",
+ c, m, y, k, (unsigned)i, ic, im, iy, ik);
#endif /* CUPS_DEBUG2 */
/*
@@ -1908,8 +1908,8 @@ cups_map_color_rgb(gx_device *pdev,/* I - Device info */
#ifdef CUPS_DEBUG2
- dprintf3("DEBUG2: cups_map_color_rgb(%p, %d, %p)\n", pdev,
- (unsigned)color, prgb);
+ dmprintf3(pdev->memory, "DEBUG2: cups_map_color_rgb(%p, %d, %p)\n", pdev,
+ (unsigned)color, prgb);
#endif /* CUPS_DEBUG2 */
/*
@@ -1922,7 +1922,7 @@ cups_map_color_rgb(gx_device *pdev,/* I - Device info */
}
#ifdef CUPS_DEBUG2
- dprintf1("DEBUG2: COLOR %08x = ", (unsigned)color);
+ dmprintf1(pdev->memory, "DEBUG2: COLOR %08x = ", (unsigned)color);
#endif /* CUPS_DEBUG2 */
/*
@@ -2148,7 +2148,8 @@ cups_map_color_rgb(gx_device *pdev,/* I - Device info */
}
#ifdef CUPS_DEBUG2
- dprintf3("DEBUG2: RGB values: %d,%d,%d\n", prgb[0], prgb[1], prgb[2]);
+ dmprintf3(pdev->memory, "DEBUG2: RGB values: %d,%d,%d\n",
+ prgb[0], prgb[1], prgb[2]);
#endif /* CUPS_DEBUG2 */
return (0);
@@ -2182,7 +2183,8 @@ cups_map_rgb_color(gx_device *pdev,/* I - Device info */
b = cv[2];
#ifdef CUPS_DEBUG2
- dprintf4("DEBUG2: cups_map_rgb_color(%p, %d, %d, %d)\n", pdev, r, g, b);
+ dmprintf4(pdev->memory, "DEBUG2: cups_map_rgb_color(%p, %d, %d, %d)\n",
+ pdev, r, g, b);
#endif /* CUPS_DEBUG2 */
/*
@@ -2443,8 +2445,8 @@ cups_map_rgb_color(gx_device *pdev,/* I - Device info */
}
#ifdef CUPS_DEBUG2
- dprintf8("DEBUG2: CMY (%d,%d,%d) -> CMYK %08x (%d,%d,%d,%d)\n",
- r, g, b, (unsigned)i, ic, im, iy, ik);
+ dmprintf8(pdev->memory, "DEBUG2: CMY (%d,%d,%d) -> CMYK %08x (%d,%d,%d,%d)\n",
+ r, g, b, (unsigned)i, ic, im, iy, ik);
#endif /* CUPS_DEBUG2 */
break;
@@ -2702,7 +2704,8 @@ cups_map_rgb_color(gx_device *pdev,/* I - Device info */
}
#ifdef CUPS_DEBUG2
- dprintf4("DEBUG2: RGB %d,%d,%d = %08x\n", r, g, b, (unsigned)i);
+ dmprintf4(pdev->memory, "DEBUG2: RGB %d,%d,%d = %08x\n",
+ r, g, b, (unsigned)i);
#endif /* CUPS_DEBUG2 */
return (i);
@@ -2720,15 +2723,15 @@ cups_open(gx_device *pdev) /* I - Device info */
int code; /* Return status */
#ifdef CUPS_DEBUG2
- dprintf1("DEBUG2: cups_open(%p)\n", pdev);
+ dmprintf1(pdev->memory, "DEBUG2: cups_open(%p)\n", pdev);
#endif /* CUPS_DEBUG2 */
- dprintf("INFO: Start rendering...\n");
+ dmprintf(pdev->memory, "INFO: Start rendering...\n");
cups->printer_procs.get_space_params = cups_get_space_params;
if (cups->page == 0)
{
- dprintf("INFO: Processing page 1...\n");
+ dmprintf(pdev->memory, "INFO: Processing page 1...\n");
cups->page = 1;
}
@@ -2768,8 +2771,8 @@ cups_print_pages(gx_device_printer *pdev,
(void)fp; /* reference unused file pointer to prevent compiler warning */
#ifdef CUPS_DEBUG2
- dprintf3("DEBUG2: cups_print_pages(%p, %p, %d)\n", pdev, fp,
- num_copies);
+ dmprintf3(pdev->memory, "DEBUG2: cups_print_pages(%p, %p, %d)\n", pdev, fp,
+ num_copies);
#endif /* CUPS_DEBUG2 */
/*
@@ -2807,9 +2810,9 @@ cups_print_pages(gx_device_printer *pdev,
srcbytes = gdev_prn_raster(pdev);
#ifdef CUPS_DEBUG2
- dprintf4("DEBUG2: cupsBitsPerPixel = %d, cupsWidth = %d, cupsBytesPerLine = %d, srcbytes = %d\n",
- cups->header.cupsBitsPerPixel, cups->header.cupsWidth,
- cups->header.cupsBytesPerLine, srcbytes);
+ dmprintf4(pdev->memory, "DEBUG2: cupsBitsPerPixel = %d, cupsWidth = %d, cupsBytesPerLine = %d, srcbytes = %d\n",
+ cups->header.cupsBitsPerPixel, cups->header.cupsWidth,
+ cups->header.cupsBytesPerLine, srcbytes);
#endif /* CUPS_DEBUG2 */
src = (unsigned char *)gs_malloc(pdev->memory->non_gc_memory, srcbytes, 1, "cups_print_pages");
@@ -2840,13 +2843,14 @@ cups_print_pages(gx_device_printer *pdev,
RasterVersion = ppdFindAttr(cups->PPD, "cupsRasterVersion", NULL);
if (RasterVersion) {
#ifdef CUPS_DEBUG2
- dprintf1("DEBUG2: cupsRasterVersion = %s\n", RasterVersion->value);
+ dmprintf1(pdev->memory, "DEBUG2: cupsRasterVersion = %s\n",
+ RasterVersion->value);
#endif /* CUPS_DEBUG2 */
cups->cupsRasterVersion = atoi(RasterVersion->value);
if ((cups->cupsRasterVersion != 2) &&
(cups->cupsRasterVersion != 3)) {
- dprintf1("ERROR: Unsupported CUPS Raster Version: %s",
- RasterVersion->value);
+ dmprintf1(pdev->memory, "ERROR: Unsupported CUPS Raster Version: %s",
+ RasterVersion->value);
return_error(gs_error_unknownerror);
}
}
@@ -2874,9 +2878,9 @@ cups_print_pages(gx_device_printer *pdev,
}
#ifdef CUPS_DEBUG
- dprintf3("DEBUG2: cupsWidth = %d, cupsHeight = %d, cupsBytesPerLine = %d\n",
- cups->header.cupsWidth, cups->header.cupsHeight,
- cups->header.cupsBytesPerLine);
+ dmprintf3(pdev->memory, "DEBUG2: cupsWidth = %d, cupsHeight = %d, cupsBytesPerLine = %d\n",
+ cups->header.cupsWidth, cups->header.cupsHeight,
+ cups->header.cupsBytesPerLine);
#endif /* CUPS_DEBUG */
for (copy = num_copies; copy > 0; copy --)
@@ -2913,7 +2917,7 @@ cups_print_pages(gx_device_printer *pdev,
return (code);
cups->page ++;
- dprintf1("INFO: Processing page %d...\n", cups->page);
+ dmprintf1(pdev->memory, "INFO: Processing page %d...\n", cups->page);
return (0);
}
@@ -2960,7 +2964,7 @@ cups_put_params(gx_device *pdev, /* I - Device info */
int old_depth = cups->color_info.depth;
#ifdef CUPS_DEBUG
- dprintf2("DEBUG2: cups_put_params(%p, %p)\n", pdev, plist);
+ dmprintf2(pdev->memory, "DEBUG2: cups_put_params(%p, %p)\n", pdev, plist);
#endif /* CUPS_DEBUG */
/*
@@ -2970,7 +2974,7 @@ cups_put_params(gx_device *pdev, /* I - Device info */
#define stringoption(name, sname) \
if ((code = param_read_string(plist, sname, &stringval)) < 0) \
{ \
- dprintf1("ERROR: Error setting %s...\n", sname); \
+ dmprintf1(pdev->memory, "ERROR: Error setting %s...\n", sname); \
param_signal_error(plist, sname, code); \
return (code); \
} \
@@ -2984,7 +2988,7 @@ cups_put_params(gx_device *pdev, /* I - Device info */
#define intoption(name, sname, type) \
if ((code = param_read_int(plist, sname, &intval)) < 0) \
{ \
- dprintf1("ERROR: Error setting %s ...\n", sname); \
+ dmprintf1(pdev->memory, "ERROR: Error setting %s ...\n", sname); \
param_signal_error(plist, sname, code); \
return (code); \
} \
@@ -2996,7 +3000,7 @@ cups_put_params(gx_device *pdev, /* I - Device info */
#define floatoption(name, sname) \
if ((code = param_read_float(plist, sname, &floatval)) < 0) \
{ \
- dprintf1("ERROR: Error setting %s ...\n", sname); \
+ dmprintf1(pdev->memory, "ERROR: Error setting %s ...\n", sname); \
param_signal_error(plist, sname, code); \
return (code); \
} \
@@ -3010,7 +3014,7 @@ cups_put_params(gx_device *pdev, /* I - Device info */
{ \
if ((code = param_read_null(plist, sname)) < 0) \
{ \
- dprintf1("ERROR: Error setting %s ...\n", sname); \
+ dmprintf1(pdev->memory, "ERROR: Error setting %s ...\n", sname); \
param_signal_error(plist, sname, code); \
return (code); \
} \
@@ -3027,7 +3031,7 @@ cups_put_params(gx_device *pdev, /* I - Device info */
{ \
if ((code = param_read_null(plist, sname)) < 0) \
{ \
- dprintf1("ERROR: Error setting %s...\n", sname); \
+ dmprintf1(pdev->memory, "ERROR: Error setting %s...\n", sname); \
param_signal_error(plist, sname, code); \
return (code); \
} \
@@ -3195,8 +3199,8 @@ cups_put_params(gx_device *pdev, /* I - Device info */
*/
#ifdef CUPS_DEBUG
- dprintf2("DEBUG: Updating PageSize to [%.0f %.0f]...\n",
- cups->MediaSize[0], cups->MediaSize[1]);
+ dmprintf2(pdev->memory, "DEBUG: Updating PageSize to [%.0f %.0f]...\n",
+ cups->MediaSize[0], cups->MediaSize[1]);
#endif /* CUPS_DEBUG */
memset(margins, 0, sizeof(margins));
@@ -3206,29 +3210,29 @@ cups_put_params(gx_device *pdev, /* I - Device info */
if (cups->PPD != NULL)
{
#ifdef CUPS_DEBUG
- dprintf1("DEBUG2: cups->header.Duplex = %d\n", cups->header.Duplex);
- dprintf1("DEBUG2: cups->header.Tumble = %d\n", cups->header.Tumble);
- dprintf1("DEBUG2: cups->page = %d\n", cups->page);
- dprintf1("DEBUG2: cups->PPD = %p\n", cups->PPD);
+ dmprintf1(pdev->memory, "DEBUG2: cups->header.Duplex = %d\n", cups->header.Duplex);
+ dmprintf1(pdev->memory, "DEBUG2: cups->header.Tumble = %d\n", cups->header.Tumble);
+ dmprintf1(pdev->memory, "DEBUG2: cups->page = %d\n", cups->page);
+ dmprintf1(pdev->memory, "DEBUG2: cups->PPD = %p\n", cups->PPD);
#endif /* CUPS_DEBUG */
backside = ppdFindAttr(cups->PPD, "cupsBackSide", NULL);
if (backside) {
#ifdef CUPS_DEBUG
- dprintf1("DEBUG2: cupsBackSide = %s\n", backside->value);
+ dmprintf1(pdev->memory, "DEBUG2: cupsBackSide = %s\n", backside->value);
#endif /* CUPS_DEBUG */
cups->PPD->flip_duplex = 0;
}
#ifdef CUPS_DEBUG
- dprintf1("DEBUG2: cups->PPD->flip_duplex = %d\n", cups->PPD->flip_duplex);
+ dmprintf1(pdev->memory, "DEBUG2: cups->PPD->flip_duplex = %d\n", cups->PPD->flip_duplex);
#endif /* CUPS_DEBUG */
backsiderequiresflippedmargins =
ppdFindAttr(cups->PPD, "APDuplexRequiresFlippedMargin", NULL);
#ifdef CUPS_DEBUG
if (backsiderequiresflippedmargins)
- dprintf1("DEBUG2: APDuplexRequiresFlippedMargin = %s\n",
- backsiderequiresflippedmargins->value);
+ dmprintf1(pdev->memory, "DEBUG2: APDuplexRequiresFlippedMargin = %s\n",
+ backsiderequiresflippedmargins->value);
#endif /* CUPS_DEBUG */
if (cups->header.Duplex &&
@@ -3240,12 +3244,12 @@ cups_put_params(gx_device *pdev, /* I - Device info */
if (backsiderequiresflippedmargins &&
!strcasecmp(backsiderequiresflippedmargins->value, "False")) {
#ifdef CUPS_DEBUG
- dprintf("DEBUG2: (1) Flip: X=1 Y=0\n");
+ dmprintf(pdev->memory, "DEBUG2: (1) Flip: X=1 Y=0\n");
#endif /* CUPS_DEBUG */
yflip = 0;
} else {
#ifdef CUPS_DEBUG
- dprintf("DEBUG2: (1) Flip: X=1 Y=1\n");
+ dmprintf(pdev->memory, "DEBUG2: (1) Flip: X=1 Y=1\n");
#endif /* CUPS_DEBUG */
yflip = 1;
}
@@ -3259,12 +3263,12 @@ cups_put_params(gx_device *pdev, /* I - Device info */
if (backsiderequiresflippedmargins &&
!strcasecmp(backsiderequiresflippedmargins->value, "False")) {
#ifdef CUPS_DEBUG
- dprintf("DEBUG2: (2) Flip: X=0 Y=1\n");
+ dmprintf(pdev->memory, "DEBUG2: (2) Flip: X=0 Y=1\n");
#endif /* CUPS_DEBUG */
yflip = 1;
} else {
#ifdef CUPS_DEBUG
- dprintf("DEBUG2: (2) Flip: X=0 Y=0\n");
+ dmprintf(pdev->memory, "DEBUG2: (2) Flip: X=0 Y=0\n");
#endif /* CUPS_DEBUG */
yflip = 0;
}
@@ -3281,12 +3285,12 @@ cups_put_params(gx_device *pdev, /* I - Device info */
if (backsiderequiresflippedmargins &&
!strcasecmp(backsiderequiresflippedmargins->value, "True")) {
#ifdef CUPS_DEBUG
- dprintf("DEBUG2: (3) Flip: X=1 Y=0\n");
+ dmprintf(pdev->memory, "DEBUG2: (3) Flip: X=1 Y=0\n");
#endif /* CUPS_DEBUG */
yflip = 0;
} else {
#ifdef CUPS_DEBUG
- dprintf("DEBUG2: (3) Flip: X=1 Y=1\n");
+ dmprintf(pdev->memory, "DEBUG2: (3) Flip: X=1 Y=1\n");
#endif /* CUPS_DEBUG */
yflip = 1;
}
@@ -3294,7 +3298,7 @@ cups_put_params(gx_device *pdev, /* I - Device info */
else
{
#ifdef CUPS_DEBUG
- dprintf("DEBUG2: (4) Flip: X=0 Y=0\n");
+ dmprintf(pdev->memory, "DEBUG2: (4) Flip: X=0 Y=0\n");
#endif /* CUPS_DEBUG */
xflip = 0;
yflip = 0;
@@ -3317,7 +3321,8 @@ cups_put_params(gx_device *pdev, /* I - Device info */
if (found == 0) cups->header.cupsPageSizeName[0] = '\0';
}
#ifdef CUPS_DEBUG
- dprintf1("DEBUG2: cups->header.cupsPageSizeName = %s\n", cups->header.cupsPageSizeName);
+ dmprintf1(pdev->memory, "DEBUG2: cups->header.cupsPageSizeName = %s\n",
+ cups->header.cupsPageSizeName);
#endif /* CUPS_DEBUG */
#endif /* CUPS_RASTER_SYNCv1 */
@@ -3362,7 +3367,7 @@ cups_put_params(gx_device *pdev, /* I - Device info */
*/
#ifdef CUPS_DEBUG
- dprintf1("DEBUG: size = %s\n", size->name);
+ dmprintf1(pdev->memory, "DEBUG: size = %s\n", size->name);
#endif /* CUPS_DEBUG */
gx_device_set_media_size(pdev, size->width, size->length);
@@ -3426,7 +3431,7 @@ cups_put_params(gx_device *pdev, /* I - Device info */
*/
#ifdef CUPS_DEBUG
- dprintf1("DEBUG: landscape size = %s\n", size->name);
+ dmprintf1(pdev->memory, "DEBUG: landscape size = %s\n", size->name);
#endif /* CUPS_DEBUG */
gx_device_set_media_size(pdev, size->length, size->width);
@@ -3453,7 +3458,7 @@ cups_put_params(gx_device *pdev, /* I - Device info */
*/
#ifdef CUPS_DEBUG
- dprintf("DEBUG: size = Custom\n");
+ dmprintf(pdev->memory, "DEBUG: size = Custom\n");
#endif /* CUPS_DEBUG */
/* Rotate page if it only fits into the printer's dimensions
@@ -3499,8 +3504,8 @@ cups_put_params(gx_device *pdev, /* I - Device info */
}
#ifdef CUPS_DEBUG
- dprintf4("DEBUG: margins[] = [ %f %f %f %f ]\n",
- margins[0], margins[1], margins[2], margins[3]);
+ dmprintf4(pdev->memory, "DEBUG: margins[] = [ %f %f %f %f ]\n",
+ margins[0], margins[1], margins[2], margins[3]);
#endif /* CUPS_DEBUG */
}
@@ -3561,8 +3566,8 @@ cups_put_params(gx_device *pdev, /* I - Device info */
*/
#ifdef CUPS_DEBUG
- dprintf4("DEBUG2: Reallocating memory, [%.0f %.0f] = %dx%d pixels...\n",
- pdev->MediaSize[0], pdev->MediaSize[1], width, height);
+ dmprintf4(pdev->memory, "DEBUG2: Reallocating memory, [%.0f %.0f] = %dx%d pixels...\n",
+ pdev->MediaSize[0], pdev->MediaSize[1], width, height);
#endif /* CUPS_DEBUG */
if ((code = gdev_prn_maybe_realloc_memory((gx_device_printer *)pdev,
@@ -3572,8 +3577,8 @@ cups_put_params(gx_device *pdev, /* I - Device info */
< 0)
return (code);
#ifdef CUPS_DEBUG
- dprintf4("DEBUG2: Reallocated memory, [%.0f %.0f] = %dx%d pixels...\n",
- pdev->MediaSize[0], pdev->MediaSize[1], width, height);
+ dmprintf4(pdev->memory, "DEBUG2: Reallocated memory, [%.0f %.0f] = %dx%d pixels...\n",
+ pdev->MediaSize[0], pdev->MediaSize[1], width, height);
#endif /* CUPS_DEBUG */
}
else
@@ -3583,8 +3588,8 @@ cups_put_params(gx_device *pdev, /* I - Device info */
*/
#ifdef CUPS_DEBUG
- dprintf4("DEBUG: Setting initial media size, [%.0f %.0f] = %dx%d pixels...\n",
- pdev->MediaSize[0], pdev->MediaSize[1], width, height);
+ dmprintf4(pdev->memory, "DEBUG: Setting initial media size, [%.0f %.0f] = %dx%d pixels...\n",
+ pdev->MediaSize[0], pdev->MediaSize[1], width, height);
#endif /* CUPS_DEBUG */
pdev->width = width;
@@ -3692,19 +3697,19 @@ cups_put_params(gx_device *pdev, /* I - Device info */
cups->header.cupsHeight = cups->height;
#ifdef CUPS_DEBUG
- dprintf1("DEBUG2: ppd = %p\n", cups->PPD);
- dprintf2("DEBUG2: PageSize = [ %.3f %.3f ]\n",
- pdev->MediaSize[0], pdev->MediaSize[1]);
+ dmprintf1(pdev->memory, "DEBUG2: ppd = %p\n", cups->PPD);
+ dmprintf2(pdev->memory, "DEBUG2: PageSize = [ %.3f %.3f ]\n",
+ pdev->MediaSize[0], pdev->MediaSize[1]);
if (size_set)
- dprintf4("DEBUG2: margins = [ %.3f %.3f %.3f %.3f ]\n",
- margins[0], margins[1], margins[2], margins[3]);
- dprintf2("DEBUG2: HWResolution = [ %.3f %.3f ]\n",
- pdev->HWResolution[0], pdev->HWResolution[1]);
- dprintf2("DEBUG2: width = %d, height = %d\n",
- pdev->width, pdev->height);
- dprintf4("DEBUG2: HWMargins = [ %.3f %.3f %.3f %.3f ]\n",
- pdev->HWMargins[0], pdev->HWMargins[1],
- pdev->HWMargins[2], pdev->HWMargins[3]);
+ dmprintf4(pdev->memory, "DEBUG2: margins = [ %.3f %.3f %.3f %.3f ]\n",
+ margins[0], margins[1], margins[2], margins[3]);
+ dmprintf2(pdev->memory, "DEBUG2: HWResolution = [ %.3f %.3f ]\n",
+ pdev->HWResolution[0], pdev->HWResolution[1]);
+ dmprintf2(pdev->memory, "DEBUG2: width = %d, height = %d\n",
+ pdev->width, pdev->height);
+ dmprintf4(pdev->memory, "DEBUG2: HWMargins = [ %.3f %.3f %.3f %.3f ]\n",
+ pdev->HWMargins[0], pdev->HWMargins[1],
+ pdev->HWMargins[2], pdev->HWMargins[3]);
#endif /* CUPS_DEBUG */
return (0);
@@ -3727,7 +3732,7 @@ cups_set_color_info(gx_device *pdev) /* I - Device info */
int code = 0;
#ifdef CUPS_DEBUG
- dprintf1("DEBUG2: cups_set_color_info(%p)\n", pdev);
+ dmprintf1(pdev->memory, "DEBUG2: cups_set_color_info(%p)\n", pdev);
#endif /* CUPS_DEBUG */
#ifndef GX_COLOR_INDEX_TYPE
@@ -3984,30 +3989,31 @@ cups_set_color_info(gx_device *pdev) /* I - Device info */
#ifdef CUPS_DEBUG
if (i == 0 || cups->EncodeLUT[i] != cups->EncodeLUT[i - 1])
- dprintf2("DEBUG2: cups->EncodeLUT[%d] = %d\n", i, (int)cups->EncodeLUT[i]);
+ dmprintf2(pdev->memory, "DEBUG2: cups->EncodeLUT[%d] = %d\n", i,
+ (int)cups->EncodeLUT[i]);
#endif /* CUPS_DEBUG */
}
#ifdef CUPS_DEBUG
- dprintf1("DEBUG2: cups->EncodeLUT[0] = %d\n", (int)cups->EncodeLUT[0]);
- dprintf2("DEBUG2: cups->EncodeLUT[%d] = %d\n", gx_max_color_value,
- (int)cups->EncodeLUT[gx_max_color_value]);
+ dmprintf1(pdev->memory, "DEBUG2: cups->EncodeLUT[0] = %d\n", (int)cups->EncodeLUT[0]);
+ dmprintf2(pdev->memory, "DEBUG2: cups->EncodeLUT[%d] = %d\n", gx_max_color_value,
+ (int)cups->EncodeLUT[gx_max_color_value]);
#endif /* CUPS_DEBUG */
for (i = 0; i < cups->color_info.dither_grays; i ++)
cups->DecodeLUT[i] = gx_max_color_value * i / max_lut;
#ifdef CUPS_DEBUG
- dprintf2("DEBUG: num_components = %d, depth = %d\n",
- cups->color_info.num_components, cups->color_info.depth);
- dprintf2("DEBUG: cupsColorSpace = %d, cupsColorOrder = %d\n",
- cups->header.cupsColorSpace, cups->header.cupsColorOrder);
- dprintf2("DEBUG: cupsBitsPerPixel = %d, cupsBitsPerColor = %d\n",
- cups->header.cupsBitsPerPixel, cups->header.cupsBitsPerColor);
- dprintf2("DEBUG: max_gray = %d, dither_grays = %d\n",
- cups->color_info.max_gray, cups->color_info.dither_grays);
- dprintf2("DEBUG: max_color = %d, dither_colors = %d\n",
- cups->color_info.max_color, cups->color_info.dither_colors);
+ dmprintf2(pdev->memory, "DEBUG: num_components = %d, depth = %d\n",
+ cups->color_info.num_components, cups->color_info.depth);
+ dmprintf2(pdev->memory, "DEBUG: cupsColorSpace = %d, cupsColorOrder = %d\n",
+ cups->header.cupsColorSpace, cups->header.cupsColorOrder);
+ dmprintf2(pdev->memory, "DEBUG: cupsBitsPerPixel = %d, cupsBitsPerColor = %d\n",
+ cups->header.cupsBitsPerPixel, cups->header.cupsBitsPerColor);
+ dmprintf2(pdev->memory, "DEBUG: max_gray = %d, dither_grays = %d\n",
+ cups->color_info.max_gray, cups->color_info.dither_grays);
+ dmprintf2(pdev->memory, "DEBUG: max_color = %d, dither_colors = %d\n",
+ cups->color_info.max_color, cups->color_info.dither_colors);
#endif /* CUPS_DEBUG */
/*
@@ -4023,14 +4029,14 @@ cups_set_color_info(gx_device *pdev) /* I - Device info */
#endif /* dev_t_proc_encode_color */
{
#ifdef CUPS_DEBUG
- dprintf1("DEBUG: Using user-defined profile \"%s\"...\n", cups->Profile);
+ dmprintf1(pdev->memory, "DEBUG: Using user-defined profile \"%s\"...\n", cups->Profile);
#endif /* CUPS_DEBUG */
if (sscanf(cups->Profile, "%f,%f,%f,%f,%f,%f,%f,%f,%f,%f,%f", &d, &g,
m[0] + 0, m[0] + 1, m[0] + 2,
m[1] + 0, m[1] + 1, m[1] + 2,
m[2] + 0, m[2] + 1, m[2] + 2) != 11)
- dprintf("ERROR: User-defined profile does not contain 11 integers!\n");
+ dmprintf(pdev->memory, "ERROR: User-defined profile does not contain 11 integers!\n");
else
{
cups->HaveProfile = 1;
@@ -4080,7 +4086,7 @@ cups_set_color_info(gx_device *pdev) /* I - Device info */
if (i < cups->PPD->num_profiles)
{
#ifdef CUPS_DEBUG
- dprintf("DEBUG: Using color profile in PPD file!\n");
+ dmprintf(pdev->memory, "DEBUG: Using color profile in PPD file!\n");
#endif /* CUPS_DEBUG */
cups->HaveProfile = 1;
@@ -4102,8 +4108,8 @@ cups_set_color_info(gx_device *pdev) /* I - Device info */
#ifdef CUPS_DEBUG
if ((k & 4095) == 0)
- dprintf4("DEBUG2: cups->Matrix[%d][%d][%d] = %d\n",
- i, j, k, cups->Matrix[i][j][k]);
+ dmprintf4(pdev->memory, "DEBUG2: cups->Matrix[%d][%d][%d] = %d\n",
+ i, j, k, cups->Matrix[i][j][k]);
#endif /* CUPS_DEBUG */
}
@@ -4116,7 +4122,7 @@ cups_set_color_info(gx_device *pdev) /* I - Device info */
#ifdef CUPS_DEBUG
if ((k & 4095) == 0)
- dprintf2("DEBUG2: cups->Density[%d] = %d\n", k, cups->Density[k]);
+ dmprintf2(pdev->memory, "DEBUG2: cups->Density[%d] = %d\n", k, cups->Density[k]);
#endif /* CUPS_DEBUG */
}
}
@@ -4218,7 +4224,7 @@ cups_set_color_info(gx_device *pdev) /* I - Device info */
private int /* O - Error status */
cups_sync_output(gx_device *pdev) /* I - Device info */
{
- dprintf1("INFO: Processing page %d...\n", cups->page);
+ dmprintf1(pdev->memory, "INFO: Processing page %d...\n", cups->page);
return (0);
}
@@ -4248,17 +4254,17 @@ cups_print_chunked(gx_device_printer *pdev,
ppd_attr_t *backside = NULL;
#ifdef CUPS_DEBUG
- dprintf1("DEBUG2: cups->header.Duplex = %d\n", cups->header.Duplex);
- dprintf1("DEBUG2: cups->header.Tumble = %d\n", cups->header.Tumble);
- dprintf1("DEBUG2: cups->page = %d\n", cups->page);
- dprintf1("DEBUG2: cups->PPD = %p\n", cups->PPD);
+ dmprintf1(pdev->memory, "DEBUG2: cups->header.Duplex = %d\n", cups->header.Duplex);
+ dmprintf1(pdev->memory, "DEBUG2: cups->header.Tumble = %d\n", cups->header.Tumble);
+ dmprintf1(pdev->memory, "DEBUG2: cups->page = %d\n", cups->page);
+ dmprintf1(pdev->memory, "DEBUG2: cups->PPD = %p\n", cups->PPD);
#endif /* CUPS_DEBUG */
if (cups->PPD) {
backside = ppdFindAttr(cups->PPD, "cupsBackSide", NULL);
if (backside) {
#ifdef CUPS_DEBUG
- dprintf1("DEBUG2: cupsBackSide = %s\n", backside->value);
+ dmprintf1(pdev->memory, "DEBUG2: cupsBackSide = %s\n", backside->value);
#endif /* CUPS_DEBUG */
cups->PPD->flip_duplex = 0;
}
@@ -4294,8 +4300,8 @@ cups_print_chunked(gx_device_printer *pdev,
}
#ifdef CUPS_DEBUG
- dprintf3("DEBUG: cups_print_chunked: xflip = %d, yflip = %d, height = %d\n",
- xflip, yflip, cups->height);
+ dmprintf3(pdev->memory, "DEBUG: cups_print_chunked: xflip = %d, yflip = %d, height = %d\n",
+ xflip, yflip, cups->height);
#endif /* CUPS_DEBUG */
/*
@@ -4310,7 +4316,7 @@ cups_print_chunked(gx_device_printer *pdev,
if (gdev_prn_get_bits((gx_device_printer *)pdev, y, src, &srcptr) < 0)
{
- dprintf1("ERROR: Unable to get scanline %d!\n", y);
+ dmprintf1(pdev->memory, "ERROR: Unable to get scanline %d!\n", y);
return_error(gs_error_unknownerror);
}
@@ -4475,17 +4481,17 @@ cups_print_banded(gx_device_printer *pdev,
ppd_attr_t *backside = NULL;
#ifdef CUPS_DEBUG
- dprintf1("DEBUG2: cups->header.Duplex = %d\n", cups->header.Duplex);
- dprintf1("DEBUG2: cups->header.Tumble = %d\n", cups->header.Tumble);
- dprintf1("DEBUG2: cups->page = %d\n", cups->page);
- dprintf1("DEBUG2: cups->PPD = %p\n", cups->PPD);
+ dmprintf1(pdev->memory, "DEBUG2: cups->header.Duplex = %d\n", cups->header.Duplex);
+ dmprintf1(pdev->memory, "DEBUG2: cups->header.Tumble = %d\n", cups->header.Tumble);
+ dmprintf1(pdev->memory, "DEBUG2: cups->page = %d\n", cups->page);
+ dmprintf1(pdev->memory, "DEBUG2: cups->PPD = %p\n", cups->PPD);
#endif /* CUPS_DEBUG */
if (cups->PPD) {
backside = ppdFindAttr(cups->PPD, "cupsBackSide", NULL);
if (backside) {
#ifdef CUPS_DEBUG
- dprintf1("DEBUG2: cupsBackSide = %s\n", backside->value);
+ dmprintf1(pdev->memory, "DEBUG2: cupsBackSide = %s\n", backside->value);
#endif /* CUPS_DEBUG */
cups->PPD->flip_duplex = 0;
}
@@ -4521,8 +4527,8 @@ cups_print_banded(gx_device_printer *pdev,
}
#ifdef CUPS_DEBUG
- dprintf3("DEBUG: cups_print_chunked: xflip = %d, yflip = %d, height = %d\n",
- xflip, yflip, cups->height);
+ dmprintf3(pdev->memory, "DEBUG: cups_print_chunked: xflip = %d, yflip = %d, height = %d\n",
+ xflip, yflip, cups->height);
#endif /* CUPS_DEBUG */
/*
@@ -4548,7 +4554,7 @@ cups_print_banded(gx_device_printer *pdev,
if (gdev_prn_get_bits((gx_device_printer *)pdev, y, src, &srcptr) < 0)
{
- dprintf1("ERROR: Unable to get scanline %d!\n", y);
+ dmprintf1(pdev->memory, "ERROR: Unable to get scanline %d!\n", y);
return_error(gs_error_unknownerror);
}
@@ -5199,7 +5205,7 @@ cups_print_planar(gx_device_printer *pdev,
if (gdev_prn_get_bits((gx_device_printer *)pdev, y, src, &srcptr) < 0)
{
- dprintf1("ERROR: Unable to get scanline %d!\n", y);
+ dmprintf1(pdev->memory, "ERROR: Unable to get scanline %d!\n", y);
return_error(gs_error_unknownerror);
}
diff --git a/gs/psi/fapiufst.c b/gs/psi/fapiufst.c
index 2f81c47e6..eb14a9544 100644
--- a/gs/psi/fapiufst.c
+++ b/gs/psi/fapiufst.c
@@ -1760,7 +1760,7 @@ static void gs_fapiufst_finit(i_plugin_instance *this, i_plugin_client_memory *m
FSA_FROM_SERVER;
#if UFST_MEMORY_CHECKING
- dprintf1("UFST used %Lf kb\n", ((long double)maxmem) / 1024);
+ dmprintf1(r->mem, "UFST used %Lf kb\n", ((long double)maxmem) / 1024);
#endif
if (r->If.ig.d != &ufst_descriptor)
diff --git a/gs/psi/ialloc.c b/gs/psi/ialloc.c
index 46c0e814e..c2332bd4e 100644
--- a/gs/psi/ialloc.c
+++ b/gs/psi/ialloc.c
@@ -171,9 +171,9 @@ gs_alloc_ref_array(gs_ref_memory_t * mem, ref * parr, uint attrs,
ref *end;
obj = (ref *) mem->cc.rtop - 1; /* back up over last ref */
- if_debug4('A', "[a%d:+$ ]%s(%u) = 0x%lx\n",
- ialloc_trace_space(mem), client_name_string(cname),
- num_refs, (ulong) obj);
+ if_debug4m('A', (const gs_memory_t *)mem, "[a%d:+$ ]%s(%u) = 0x%lx\n",
+ ialloc_trace_space(mem), client_name_string(cname),
+ num_refs, (ulong) obj);
mem->cc.rcur[-1].o_size += num_refs * sizeof(ref);
end = (ref *) (mem->cc.rtop = mem->cc.cbot +=
num_refs * sizeof(ref));
@@ -249,16 +249,16 @@ gs_resize_ref_array(gs_ref_memory_t * mem, ref * parr,
ref *end = (ref *) (mem->cc.cbot = mem->cc.rtop -=
diff * sizeof(ref));
- if_debug4('A', "[a%d:<$ ]%s(%u) 0x%lx\n",
- ialloc_trace_space(mem), client_name_string(cname), diff,
- (ulong) obj);
+ if_debug4m('A', (const gs_memory_t *)mem, "[a%d:<$ ]%s(%u) 0x%lx\n",
+ ialloc_trace_space(mem), client_name_string(cname), diff,
+ (ulong) obj);
mem->cc.rcur[-1].o_size -= diff * sizeof(ref);
make_mark(end - 1);
} else {
/* Punt. */
- if_debug4('A', "[a%d:<$#]%s(%u) 0x%lx\n",
- ialloc_trace_space(mem), client_name_string(cname), diff,
- (ulong) obj);
+ if_debug4m('A', (const gs_memory_t *)mem, "[a%d:<$#]%s(%u) 0x%lx\n",
+ ialloc_trace_space(mem), client_name_string(cname), diff,
+ (ulong) obj);
mem->lost.refs += diff * sizeof(ref);
}
r_set_size(parr, new_num_refs);
@@ -293,9 +293,9 @@ gs_free_ref_array(gs_ref_memory_t * mem, ref * parr, client_name_t cname)
mem->cc.rtop = 0;
} else {
/* Deallocate it at the end of the refs object. */
- if_debug4('A', "[a%d:-$ ]%s(%u) 0x%lx\n",
- ialloc_trace_space(mem), client_name_string(cname),
- num_refs, (ulong) obj);
+ if_debug4m('A', (const gs_memory_t *)mem, "[a%d:-$ ]%s(%u) 0x%lx\n",
+ ialloc_trace_space(mem), client_name_string(cname),
+ num_refs, (ulong) obj);
mem->cc.rcur[-1].o_size -= num_refs * sizeof(ref);
mem->cc.rtop = mem->cc.cbot = (byte *) (obj + 1);
make_mark(obj);
@@ -314,9 +314,9 @@ gs_free_ref_array(gs_ref_memory_t * mem, ref * parr, client_name_t cname)
(byte *) (obj + (num_refs + 1)) == cl.cp->cend
) {
/* Free the chunk. */
- if_debug4('a', "[a%d:-$L]%s(%u) 0x%lx\n",
- ialloc_trace_space(mem), client_name_string(cname),
- num_refs, (ulong) obj);
+ if_debug4m('a', (const gs_memory_t *)mem, "[a%d:-$L]%s(%u) 0x%lx\n",
+ ialloc_trace_space(mem), client_name_string(cname),
+ num_refs, (ulong) obj);
if ((gs_memory_t *)mem != mem->stable_memory)
alloc_save_remove(mem, (ref_packed *)obj, "gs_free_ref_array");
alloc_free_chunk(cl.cp, mem);
@@ -325,9 +325,9 @@ gs_free_ref_array(gs_ref_memory_t * mem, ref * parr, client_name_t cname)
}
/* Punt, but fill the array with nulls so that there won't be */
/* dangling references to confuse the garbage collector. */
- if_debug4('A', "[a%d:-$#]%s(%u) 0x%lx\n",
- ialloc_trace_space(mem), client_name_string(cname), num_refs,
- (ulong) obj);
+ if_debug4m('A', (const gs_memory_t *)mem, "[a%d:-$#]%s(%u) 0x%lx\n",
+ ialloc_trace_space(mem), client_name_string(cname), num_refs,
+ (ulong) obj);
{
uint size;
diff --git a/gs/psi/iapi.c b/gs/psi/iapi.c
index 2846aab45..2e9ac7cad 100644
--- a/gs/psi/iapi.c
+++ b/gs/psi/iapi.c
@@ -30,11 +30,13 @@
#include "gsmalloc.h"
#include "gslibctx.h"
-/* number of threads to allow per process
- * currently more than 1 is guarenteed to fail
+#ifndef GS_THREADSAFE
+/* Number of threads to allow per process. Unless GS_THREADSAFE is defined
+ * more than 1 is guarenteed to fail.
*/
-//static int gsapi_instance_counter = 0;
-//static const int gsapi_instance_max = 1;
+static int gsapi_instance_counter = 0;
+static const int gsapi_instance_max = 1;
+#endif
/* Return revision numbers and strings of Ghostscript. */
/* Used for determining if wrong GSDLL loaded. */
@@ -65,10 +67,12 @@ gsapi_new_instance(void **pinstance, void *caller_handle)
if (pinstance == NULL)
return e_Fatal;
+#ifndef GS_THREADSAFE
/* limited to 1 instance, till it works :) */
- //if ( gsapi_instance_counter >= gsapi_instance_max )
- // return e_Fatal;
- //++gsapi_instance_counter;
+ if ( gsapi_instance_counter >= gsapi_instance_max )
+ return e_Fatal;
+ ++gsapi_instance_counter;
+#endif
if (*pinstance == NULL)
/* first instance in this process */
@@ -120,7 +124,9 @@ gsapi_delete_instance(void *lib)
/* Release the memory (frees up everything) */
gs_malloc_release(minst->heap);
- //--gsapi_instance_counter;
+#ifndef GS_THREADSAFE
+ --gsapi_instance_counter;
+#endif
}
}
diff --git a/gs/psi/idebug.c b/gs/psi/idebug.c
index 660cc3d8b..7c5984d64 100644
--- a/gs/psi/idebug.c
+++ b/gs/psi/idebug.c
@@ -45,7 +45,7 @@ debug_print_name(const gs_memory_t *mem, const ref * pnref)
ref sref;
name_string_ref(mem, pnref, &sref);
- debug_print_string(sref.value.const_bytes, r_size(&sref));
+ debug_print_string(mem, sref.value.const_bytes, r_size(&sref));
}
void
debug_print_name_index(const gs_memory_t *mem, name_index_t nidx)
@@ -63,49 +63,49 @@ debug_print_full_ref(const gs_memory_t *mem, const ref * pref)
uint size = r_size(pref);
ref nref;
- dprintf1("(%x)", r_type_attrs(pref));
+ dmprintf1(mem, "(%x)", r_type_attrs(pref));
switch (r_type(pref)) {
case t_array:
- dprintf2("array(%u)0x%lx", size, (ulong) pref->value.refs);
+ dmprintf2(mem, "array(%u)0x%lx", size, (ulong) pref->value.refs);
break;
case t_astruct:
goto strct;
case t_boolean:
- dprintf1("boolean %x", pref->value.boolval);
+ dmprintf1(mem, "boolean %x", pref->value.boolval);
break;
case t_device:
- dprintf1("device 0x%lx", (ulong) pref->value.pdevice);
+ dmprintf1(mem, "device 0x%lx", (ulong) pref->value.pdevice);
break;
case t_dictionary:
- dprintf3("dict(%u/%u)0x%lx",
+ dmprintf3(mem, "dict(%u/%u)0x%lx",
dict_length(pref), dict_maxlength(pref),
(ulong) pref->value.pdict);
break;
case t_file:
- dprintf1("file 0x%lx", (ulong) pref->value.pfile);
+ dmprintf1(mem, "file 0x%lx", (ulong) pref->value.pfile);
break;
case t_fontID:
goto strct;
case t_integer:
- dprintf1("int %d", pref->value.intval);
+ dmprintf1(mem, "int %d", pref->value.intval);
break;
case t_mark:
- dprintf("mark");
+ dmprintf(mem, "mark");
break;
case t_mixedarray:
- dprintf2("mixed packedarray(%u)0x%lx", size,
+ dmprintf2(mem, "mixed packedarray(%u)0x%lx", size,
(ulong) pref->value.packed);
break;
case t_name:
- dprintf2("name(0x%lx#%u)", (ulong) pref->value.pname,
+ dmprintf2(mem, "name(0x%lx#%u)", (ulong) pref->value.pname,
name_index(mem, pref));
debug_print_name(mem, pref);
break;
case t_null:
- dprintf("null");
+ dmprintf(mem, "null");
break;
case t_oparray:
- dprintf2("op_array(%u)0x%lx:", size, (ulong) pref->value.const_refs);
+ dmprintf2(mem, "op_array(%u)0x%lx:", size, (ulong) pref->value.const_refs);
{
const op_array_table *opt = get_op_array(mem, size);
@@ -114,23 +114,23 @@ debug_print_full_ref(const gs_memory_t *mem, const ref * pref)
debug_print_name(mem, &nref);
break;
case t_operator:
- dprintf1("op(%u", size);
+ dmprintf1(mem, "op(%u", size);
if (size > 0 && size < op_def_count) /* just in case */
- dprintf1(":%s", (const char *)(op_index_def(size)->oname + 1));
- dprintf1(")0x%lx", (ulong) pref->value.opproc);
+ dmprintf1(mem, ":%s", (const char *)(op_index_def(size)->oname + 1));
+ dmprintf1(mem, ")0x%lx", (ulong) pref->value.opproc);
break;
case t_real:
- dprintf1("real %f", pref->value.realval);
+ dmprintf1(mem, "real %f", pref->value.realval);
break;
case t_save:
- dprintf1("save %lu", pref->value.saveid);
+ dmprintf1(mem, "save %lu", pref->value.saveid);
break;
case t_shortarray:
- dprintf2("short packedarray(%u)0x%lx", size,
+ dmprintf2(mem, "short packedarray(%u)0x%lx", size,
(ulong) pref->value.packed);
break;
case t_string:
- dprintf2("string(%u)0x%lx", size, (ulong) pref->value.bytes);
+ dmprintf2(mem, "string(%u)0x%lx", size, (ulong) pref->value.bytes);
break;
case t_struct:
strct:{
@@ -139,14 +139,14 @@ debug_print_full_ref(const gs_memory_t *mem, const ref * pref)
gs_memory_type_ptr_t otype =
gs_ref_memory_procs.object_type(NULL, obj);
- dprintf2("struct %s 0x%lx",
+ dmprintf2(mem, "struct %s 0x%lx",
(r_is_foreign(pref) ? "-foreign-" :
gs_struct_type_name_string(otype)),
(ulong) obj);
}
break;
default:
- dprintf1("type 0x%x", r_type(pref));
+ dmprintf1(mem, "type 0x%x", r_type(pref));
}
}
static void
@@ -157,24 +157,24 @@ debug_print_packed_ref(const gs_memory_t *mem, const ref_packed *pref)
switch (*pref >> r_packed_type_shift) {
case pt_executable_operator:
- dprintf("<op_name>");
+ dmprintf(mem, "<op_name>");
op_index_ref(mem, elt, &nref);
debug_print_ref(mem, &nref);
break;
case pt_integer:
- dprintf1("<int> %d", (int)elt + packed_min_intval);
+ dmprintf1(mem, "<int> %d", (int)elt + packed_min_intval);
break;
case pt_literal_name:
- dprintf("<lit_name>");
+ dmprintf(mem, "<lit_name>");
goto ptn;
case pt_executable_name:
- dprintf("<exec_name>");
+ dmprintf(mem, "<exec_name>");
ptn: name_index_ref(mem, elt, &nref);
- dprintf2("(0x%lx#%u)", (ulong) nref.value.pname, elt);
+ dmprintf2(mem, "(0x%lx#%u)", (ulong) nref.value.pname, elt);
debug_print_name(mem, &nref);
break;
default:
- dprintf2("<packed_%d?>0x%x", *pref >> r_packed_type_shift, elt);
+ dmprintf2(mem, "<packed_%d?>0x%x", *pref >> r_packed_type_shift, elt);
}
}
void
@@ -184,7 +184,7 @@ debug_print_ref_packed(const gs_memory_t *mem, const ref_packed *rpp)
debug_print_packed_ref(mem, rpp);
else
debug_print_full_ref(mem, (const ref *)rpp);
- dflush();
+ dmflush(mem);
}
void
debug_print_ref(const gs_memory_t *mem, const ref * pref)
@@ -206,17 +206,17 @@ debug_dump_one_ref(const gs_memory_t *mem, const ref * p)
const ref_attr_print_mask_t *ap = apm;
if (type >= tx_next_index)
- dprintf1("0x%02x?? ", type);
+ dmprintf1(mem, "0x%02x?? ", type);
else if (type >= t_next_index)
- dprintf("opr* ");
+ dmprintf(mem, "opr* ");
else
- dprintf1("%s ", type_strings[type]);
+ dmprintf1(mem, "%s ", type_strings[type]);
for (; ap->mask; ++ap)
if ((attrs & ap->mask) == ap->value)
- dputc(ap->print);
- dprintf2(" 0x%04x 0x%08lx", r_size(p), *(const ulong *)&p->value);
+ dmputc(mem, ap->print);
+ dmprintf2(mem, " 0x%04x 0x%08lx", r_size(p), *(const ulong *)&p->value);
print_ref_data(mem, p);
- dflush();
+ dmflush(mem);
}
static void
print_ref_data(const gs_memory_t *mem, const ref *p)
@@ -230,7 +230,7 @@ print_ref_data(const gs_memory_t *mem, const ref *p)
pchars == buf &&
((buf[plen] = 0), strcmp((char *)buf, "--nostringval--"))
)
- dprintf1(" = %s", (char *)buf);
+ dmprintf1(mem, " = %s", (char *)buf);
#undef BUF_SIZE
}
@@ -243,11 +243,11 @@ debug_dump_refs(const gs_memory_t *mem, const ref * from,
uint count = size;
if (size && msg)
- dprintf2("%s at 0x%lx:\n", msg, (ulong) from);
+ dmprintf2(mem, "%s at 0x%lx:\n", msg, (ulong) from);
while (count--) {
- dprintf2("0x%lx: 0x%04x ", (ulong)p, r_type_attrs(p));
+ dmprintf2(mem, "0x%lx: 0x%04x ", (ulong)p, r_type_attrs(p));
debug_dump_one_ref(mem, p);
- dputc('\n');
+ dmputc(mem, '\n');
p++;
}
}
@@ -264,12 +264,12 @@ debug_dump_stack(const gs_memory_t *mem,
const ref *p = ref_stack_index(pstack, --i);
if (m) {
- dprintf2("%s at 0x%lx:\n", m, (ulong) pstack);
+ dmprintf2(mem, "%s at 0x%lx:\n", m, (ulong) pstack);
m = NULL;
}
- dprintf2("0x%lx: 0x%02x ", (ulong)p, r_type(p));
+ dmprintf2(mem, "0x%lx: 0x%02x ", (ulong)p, r_type(p));
debug_dump_one_ref(mem, p);
- dputc('\n');
+ dmputc(mem, '\n');
}
}
@@ -283,10 +283,10 @@ debug_dump_array(const gs_memory_t *mem, const ref * array)
switch (type) {
default:
- dprintf2("%s at 0x%lx isn't an array.\n",
- (type < countof(type_strings) ?
- type_strings[type] : "????"),
- (ulong) array);
+ dmprintf2(mem, "%s at 0x%lx isn't an array.\n",
+ (type < countof(type_strings) ?
+ type_strings[type] : "????"),
+ (ulong) array);
return;
case t_oparray:
/* This isn't really an array, but we'd like to see */
@@ -307,12 +307,12 @@ debug_dump_array(const gs_memory_t *mem, const ref * array)
packed_get(mem, pp, &temp);
if (r_is_packed(pp)) {
- dprintf2("0x%lx* 0x%04x ", (ulong)pp, (uint)*pp);
+ dmprintf2(mem, "0x%lx* 0x%04x ", (ulong)pp, (uint)*pp);
print_ref_data(mem, &temp);
} else {
- dprintf2("0x%lx: 0x%02x ", (ulong)pp, r_type(&temp));
+ dmprintf2(mem, "0x%lx: 0x%02x ", (ulong)pp, r_type(&temp));
debug_dump_one_ref(mem, &temp);
}
- dputc('\n');
+ dmputc(mem, '\n');
}
}
diff --git a/gs/psi/idict.c b/gs/psi/idict.c
index 4d4084d5f..3e4891dc4 100644
--- a/gs/psi/idict.c
+++ b/gs/psi/idict.c
@@ -105,10 +105,12 @@ dict_find(const ref * pdref, const ref * pkey, ref ** ppvalue)
)
stats_dict.probe2++;
}
+#ifndef GS_THREADSAFE
/* Do the cheap flag test before the expensive remainder test. */
if (gs_debug_c('d') && !(stats_dict.lookups % 1000))
dlprintf3("[d]lookups=%ld probe1=%ld probe2=%ld\n",
stats_dict.lookups, stats_dict.probe1, stats_dict.probe2);
+#endif
return code;
}
#define dict_find real_dict_find
@@ -502,8 +504,8 @@ dict_put(ref * pdref /* t_dictionary */ , const ref * pkey, const ref * pvalue,
} else {
ref *kp = pdict->keys.value.refs + index;
- if_debug2('d', "[d]0x%lx: fill key at 0x%lx\n",
- (ulong) pdict, (ulong) kp);
+ if_debug2m('d', (const gs_memory_t *)mem, "[d]0x%lx: fill key at 0x%lx\n",
+ (ulong) pdict, (ulong) kp);
store_check_dest(pdref, pkey);
ref_assign_old_in(mem, &pdict->keys, kp, pkey,
"dict_put(key)"); /* set key of pair */
@@ -517,21 +519,22 @@ dict_put(ref * pdref /* t_dictionary */ , const ref * pkey, const ref * pvalue,
if (pname->pvalue == pv_no_defn &&
CAN_SET_PVALUE_CACHE(pds, pdref, mem)
) { /* Set the cache. */
- if_debug0('d', "[d]set cache\n");
+ if_debug0m('d', (const gs_memory_t *)mem, "[d]set cache\n");
pname->pvalue = pvslot;
} else { /* The cache can't be used. */
- if_debug0('d', "[d]no cache\n");
+ if_debug0m('d', (const gs_memory_t *)mem, "[d]no cache\n");
pname->pvalue = pv_other;
}
}
rcode = 1;
}
- if_debug8('d', "[d]0x%lx: put key 0x%lx 0x%lx\n value at 0x%lx: old 0x%lx 0x%lx, new 0x%lx 0x%lx\n",
- (ulong) pdref->value.pdict,
- ((const ulong *)pkey)[0], ((const ulong *)pkey)[1],
- (ulong) pvslot,
- ((const ulong *)pvslot)[0], ((const ulong *)pvslot)[1],
- ((const ulong *)pvalue)[0], ((const ulong *)pvalue)[1]);
+ if_debug8m('d', (const gs_memory_t *)mem,
+ "[d]0x%lx: put key 0x%lx 0x%lx\n value at 0x%lx: old 0x%lx 0x%lx, new 0x%lx 0x%lx\n",
+ (ulong) pdref->value.pdict,
+ ((const ulong *)pkey)[0], ((const ulong *)pkey)[1],
+ (ulong) pvslot,
+ ((const ulong *)pvslot)[0], ((const ulong *)pvslot)[1],
+ ((const ulong *)pvalue)[0], ((const ulong *)pvalue)[1]);
ref_assign_old_in(mem, &pdref->value.pdict->values, pvslot, pvalue,
"dict_put(value)");
return rcode;
@@ -581,8 +584,9 @@ dict_undef(ref * pdref, const ref * pkey, dict_stack_t *pds)
ref_packed *pkp = pdict->keys.value.writable_packed + index;
bool must_save = ref_must_save_in(mem, &pdict->keys);
- if_debug3('d', "[d]0x%lx: removing key at 0%lx: 0x%x\n",
- (ulong)pdict, (ulong)pkp, (uint)*pkp);
+ if_debug3m('d', (const gs_memory_t *)mem,
+ "[d]0x%lx: removing key at 0%lx: 0x%x\n",
+ (ulong)pdict, (ulong)pkp, (uint)*pkp);
/* See the initial comment for why it is safe not to save */
/* the change if the keys array itself is new. */
if (must_save)
@@ -615,8 +619,9 @@ dict_undef(ref * pdref, const ref * pkey, dict_stack_t *pds)
} else { /* not packed */
ref *kp = pdict->keys.value.refs + index;
- if_debug4('d', "[d]0x%lx: removing key at 0%lx: 0x%lx 0x%lx\n",
- (ulong)pdict, (ulong)kp, ((ulong *)kp)[0], ((ulong *)kp)[1]);
+ if_debug4m('d', (const gs_memory_t *)mem,
+ "[d]0x%lx: removing key at 0%lx: 0x%lx 0x%lx\n",
+ (ulong)pdict, (ulong)kp, ((ulong *)kp)[0], ((ulong *)kp)[1]);
make_null_old_in(mem, &pdict->keys, kp, "dict_undef(key)");
/*
* Accumulating deleted entries slows down lookup.
@@ -866,10 +871,10 @@ dict_next(const ref * pdref, int index, ref * eltp /* ref eltp[2] */ )
(!dict_is_packed(pdict) && !r_has_type(eltp, t_null))
) {
eltp[1] = *vp;
- if_debug6('d', "[d]0x%lx: index %d: %lx %lx, %lx %lx\n",
- (ulong) pdict, index,
- ((ulong *) eltp)[0], ((ulong *) eltp)[1],
- ((ulong *) vp)[0], ((ulong *) vp)[1]);
+ if_debug6m('d', dict_mem(pdict), "[d]0x%lx: index %d: %lx %lx, %lx %lx\n",
+ (ulong) pdict, index,
+ ((ulong *) eltp)[0], ((ulong *) eltp)[1],
+ ((ulong *) vp)[0], ((ulong *) vp)[1]);
return index;
}
}
diff --git a/gs/psi/idisp.c b/gs/psi/idisp.c
index 2be51d00e..6a0157f8b 100644
--- a/gs/psi/idisp.c
+++ b/gs/psi/idisp.c
@@ -96,7 +96,7 @@ display_set_callback(gs_main_instance *minst, display_callback *callback)
if (was_open) {
code = gs_opendevice(dev);
if (code < 0) {
- dprintf("**** Unable to open the display device, quitting.\n");
+ dmprintf(dev->memory, "**** Unable to open the display device, quitting.\n");
return_error(code);
}
}
diff --git a/gs/psi/idstack.c b/gs/psi/idstack.c
index ad41ad26e..0c042de9c 100644
--- a/gs/psi/idstack.c
+++ b/gs/psi/idstack.c
@@ -66,10 +66,12 @@ dstack_find_name_by_index(dict_stack_t * pds, uint nidx)
)
INCR(probes[1]);
}
+#ifndef GS_THREADSAFE
if (gs_debug_c('d') && !(stats_dstack.lookups % 1000))
dlprintf3("[d]lookups=%ld probe1=%ld probe2=%ld\n",
stats_dstack.lookups, stats_dstack.probes[0],
stats_dstack.probes[1]);
+#endif
return pvalue;
}
#define dstack_find_name_by_index real_dstack_find_name_by_index
@@ -119,11 +121,11 @@ dstack_find_name_by_index(dict_stack_t * pds, uint nidx)
ref dnref;
name_index_ref(mem, nidx, &dnref);
- dlputs("[D]lookup ");
+ dmlputs(mem, "[D]lookup ");
debug_print_name(mem, &dnref);
- dprintf3(" in 0x%lx(%u/%u)\n",
- (ulong) pdict, dict_length(pdref),
- dict_maxlength(pdref));
+ dmprintf3(mem," in 0x%lx(%u/%u)\n",
+ (ulong) pdict, dict_length(pdref),
+ dict_maxlength(pdref));
}
#endif
#define INCR_DEPTH(pdref)\
diff --git a/gs/psi/igc.c b/gs/psi/igc.c
index b6aa02327..f8ffc642f 100644
--- a/gs/psi/igc.c
+++ b/gs/psi/igc.c
@@ -121,12 +121,12 @@ const gs_ptr_procs_t ptr_name_index_procs =
/* Top level of garbage collector. */
#ifdef DEBUG
static void
-end_phase(const char *str)
+end_phase(const gs_memory_t *mem, const char *str)
{
if (gs_debug_c('6')) {
- dlprintf1("[6]---------------- end %s ----------------\n",
- (const char *)str);
- dflush();
+ dmlprintf1(mem, "[6]---------------- end %s ----------------\n",
+ (const char *)str);
+ dmflush(mem);
}
}
static const char *const depth_dots_string = "..........";
@@ -151,7 +151,7 @@ gc_validate_spaces(gs_ref_memory_t **spaces, int max_space, gc_state_t *gcst)
ialloc_validate_memory(mem, gcst);
}
#else /* !DEBUG */
-# define end_phase(str) DO_NOTHING
+# define end_phase(mem,str) DO_NOTHING
#endif /* DEBUG */
void
@@ -243,7 +243,7 @@ gs_gc_reclaim(vm_spaces * pspaces, bool global)
(void **)&space_memories[ispace],
"gc_top_level");
- end_phase("register space roots");
+ end_phase(state.heap,"register space roots");
#ifdef DEBUG
@@ -251,7 +251,7 @@ gs_gc_reclaim(vm_spaces * pspaces, bool global)
gc_validate_spaces(space_memories, max_trace, &state);
- end_phase("pre-validate pointers");
+ end_phase(state.heap,"pre-validate pointers");
#endif
@@ -267,7 +267,7 @@ gs_gc_reclaim(vm_spaces * pspaces, bool global)
gc_strings_set_marks(cp, false);
}
- end_phase("clear chunk marks");
+ end_phase(state.heap,"clear chunk marks");
/* Clear the marks of roots. We must do this explicitly, */
/* since some roots are not in any chunk. */
@@ -276,11 +276,11 @@ gs_gc_reclaim(vm_spaces * pspaces, bool global)
enum_ptr_t eptr;
eptr.ptr = *rp->p;
- if_debug_root('6', "[6]unmarking root", rp);
+ if_debug_root('6', (const gs_memory_t *)mem, "[6]unmarking root", rp);
(*rp->ptype->unmark)(&eptr, &state);
}
- end_phase("clear root marks");
+ end_phase(state.heap,"clear root marks");
if (global) {
op_array_table *global_ops = get_global_op_array(cmem);
@@ -314,8 +314,9 @@ gs_gc_reclaim(vm_spaces * pspaces, bool global)
end->next = pms;
pms->prev = end;
pms->on_heap = false;
- if_debug2('6', "[6]adding free 0x%lx(%u) to mark stack\n",
- (ulong) pms, pms->count);
+ if_debug2m('6', (const gs_memory_t *)mem,
+ "[6]adding free 0x%lx(%u) to mark stack\n",
+ (ulong) pms, pms->count);
}
cp->rescan_bot = cp->cend;
cp->rescan_top = cp->cbase;
@@ -330,11 +331,11 @@ gs_gc_reclaim(vm_spaces * pspaces, bool global)
/* Mark from roots. */
for_roots(max_trace, mem, rp) {
- if_debug_root('6', "[6]marking root", rp);
+ if_debug_root('6', (const gs_memory_t *)mem, "[6]marking root", rp);
more |= gc_trace(rp, &state, mark_stack);
}
- end_phase("mark");
+ end_phase(state.heap,"mark");
/* If this is a local GC, mark from non-local chunks. */
@@ -350,7 +351,7 @@ gs_gc_reclaim(vm_spaces * pspaces, bool global)
more |= gc_rescan_chunk(cp, &state, mark_stack);
}
- end_phase("mark overflow");
+ end_phase(state.heap,"mark overflow");
}
/* Free the mark stack. */
@@ -372,13 +373,13 @@ gs_gc_reclaim(vm_spaces * pspaces, bool global)
}
}
- end_phase("free mark stack");
+ end_phase(state.heap,"free mark stack");
if (global) {
gc_trace_finish(&state);
names_trace_finish(state.ntable, &state);
- end_phase("finish trace");
+ end_phase(state.heap,"finish trace");
}
/* Filter save change lists with removing elements,
@@ -399,12 +400,12 @@ gs_gc_reclaim(vm_spaces * pspaces, bool global)
for_chunks(min_collect - 1, mem, cp)
gc_objects_clear_marks((const gs_memory_t *)mem, cp);
- end_phase("post-clear marks");
+ end_phase(state.heap,"post-clear marks");
for_chunks(min_collect - 1, mem, cp)
gc_clear_reloc(cp);
- end_phase("clear reloc");
+ end_phase(state.heap,"clear reloc");
/* Set the relocation of roots outside any chunk to o_untraced, */
/* so we won't try to relocate pointers to them. */
@@ -436,7 +437,7 @@ gs_gc_reclaim(vm_spaces * pspaces, bool global)
gs_enable_free((gs_memory_t *)space_memories[i], true);
}
- end_phase("set reloc");
+ end_phase(state.heap,"set reloc");
/* Relocate pointers. */
@@ -447,11 +448,12 @@ gs_gc_reclaim(vm_spaces * pspaces, bool global)
for_collected_chunks(mem, cp)
gc_do_reloc(cp, mem, &state);
- end_phase("relocate chunks");
+ end_phase(state.heap,"relocate chunks");
for_roots(max_trace, mem, rp) {
- if_debug3('6', "[6]relocating root 0x%lx: 0x%lx -> 0x%lx\n",
- (ulong) rp, (ulong) rp->p, (ulong) * rp->p);
+ if_debug3m('6', (const gs_memory_t *)mem,
+ "[6]relocating root 0x%lx: 0x%lx -> 0x%lx\n",
+ (ulong) rp, (ulong) rp->p, (ulong) * rp->p);
if (rp->ptype == ptr_ref_type) {
ref *pref = (ref *) * rp->p;
@@ -460,21 +462,22 @@ gs_gc_reclaim(vm_spaces * pspaces, bool global)
&state);
} else
*rp->p = (*rp->ptype->reloc) (*rp->p, &state);
- if_debug3('6', "[6]relocated root 0x%lx: 0x%lx -> 0x%lx\n",
- (ulong) rp, (ulong) rp->p, (ulong) * rp->p);
+ if_debug3m('6', (const gs_memory_t *)mem,
+ "[6]relocated root 0x%lx: 0x%lx -> 0x%lx\n",
+ (ulong) rp, (ulong) rp->p, (ulong) * rp->p);
}
- end_phase("relocate roots");
+ end_phase(state.heap,"relocate roots");
/* Compact data. We only do this for spaces we are collecting. */
for_collected_spaces(ispace) {
for_space_mems(ispace, mem) {
for_mem_chunks(mem, cp) {
- if_debug_chunk('6', "[6]compacting chunk", cp);
+ if_debug_chunk('6', (const gs_memory_t *)mem, "[6]compacting chunk", cp);
gc_objects_compact(cp, &state);
- gc_strings_compact(cp);
- if_debug_chunk('6', "[6]after compaction:", cp);
+ gc_strings_compact(cp, cmem);
+ if_debug_chunk('6', (const gs_memory_t *)mem, "[6]after compaction:", cp);
if (mem->pcc == cp)
mem->cc = *cp;
}
@@ -483,7 +486,7 @@ gs_gc_reclaim(vm_spaces * pspaces, bool global)
}
}
- end_phase("compact");
+ end_phase(state.heap,"compact");
/* Free empty chunks. */
@@ -493,7 +496,7 @@ gs_gc_reclaim(vm_spaces * pspaces, bool global)
}
}
- end_phase("free empty chunks");
+ end_phase(state.heap,"free empty chunks");
/*
* Update previous_status to reflect any freed chunks,
@@ -525,20 +528,21 @@ gs_gc_reclaim(vm_spaces * pspaces, bool global)
next = mem->saved;
mem->saved = prev;
mem->previous_status = total;
- if_debug3('6',
- "[6]0x%lx previous allocated=%lu, used=%lu\n",
- (ulong) mem, total.allocated, total.used);
+ if_debug3m('6', (const gs_memory_t *)mem,
+ "[6]0x%lx previous allocated=%lu, used=%lu\n",
+ (ulong) mem, total.allocated, total.used);
gs_memory_status((gs_memory_t *) mem, &total);
mem->gc_allocated = mem->allocated + total.allocated;
}
mem = space_memories[ispace];
mem->previous_status = total;
mem->gc_allocated = mem->allocated + total.allocated;
- if_debug3('6', "[6]0x%lx previous allocated=%lu, used=%lu\n",
- (ulong) mem, total.allocated, total.used);
+ if_debug3m('6', (const gs_memory_t *)mem,
+ "[6]0x%lx previous allocated=%lu, used=%lu\n",
+ (ulong) mem, total.allocated, total.used);
}
- end_phase("update stats");
+ end_phase(state.heap,"update stats");
no_collect:
@@ -548,7 +552,7 @@ gs_gc_reclaim(vm_spaces * pspaces, bool global)
gs_unregister_root((gs_memory_t *)space_memories[ispace],
&space_roots[ispace], "gc_top_level");
- end_phase("unregister space roots");
+ end_phase(state.heap,"unregister space roots");
#ifdef DEBUG
@@ -556,7 +560,7 @@ gs_gc_reclaim(vm_spaces * pspaces, bool global)
gc_validate_spaces(space_memories, max_trace, &state);
- end_phase("validate pointers");
+ end_phase(state.heap,"validate pointers");
#endif
}
@@ -601,7 +605,7 @@ ptr_name_index_unmark(enum_ptr_t *pep, gc_state_t * gcst)
static void
gc_objects_clear_marks(const gs_memory_t *mem, chunk_t * cp)
{
- if_debug_chunk('6', "[6]unmarking chunk", cp);
+ if_debug_chunk('6', mem, "[6]unmarking chunk", cp);
SCAN_CHUNK_OBJECTS(cp)
DO_ALL
struct_proc_clear_marks((*proc)) =
@@ -610,9 +614,9 @@ gc_objects_clear_marks(const gs_memory_t *mem, chunk_t * cp)
if (pre->o_type != &st_free)
debug_check_object(pre, cp, NULL);
#endif
- if_debug3('7', " [7](un)marking %s(%lu) 0x%lx\n",
- struct_type_name_string(pre->o_type),
- (ulong) size, (ulong) pre);
+ if_debug3m('7', (const gs_memory_t *)mem, " [7](un)marking %s(%lu) 0x%lx\n",
+ struct_type_name_string(pre->o_type),
+ (ulong) size, (ulong) pre);
o_set_unmarked(pre);
if (proc != 0)
(*proc) (mem, pre + 1, size, pre->o_type);
@@ -668,7 +672,7 @@ gc_rescan_chunk(chunk_t * cp, gc_state_t * pstate, gc_mark_stack * pmstack)
if (sbot > stop)
return 0;
root.p = &comp;
- if_debug_chunk('6', "[6]rescanning chunk", cp);
+ if_debug_chunk('6', mem, "[6]rescanning chunk", cp);
cp->rescan_bot = cp->cend;
cp->rescan_top = cp->cbase;
SCAN_CHUNK_OBJECTS(cp)
@@ -677,8 +681,8 @@ gc_rescan_chunk(chunk_t * cp, gc_state_t * pstate, gc_mark_stack * pmstack)
else if ((byte *) (pre + 1) > stop)
return more; /* 'break' won't work here */
else {
- if_debug2('7', " [7]scanning/marking 0x%lx(%lu)\n",
- (ulong) pre, (ulong) size);
+ if_debug2m('7', mem, " [7]scanning/marking 0x%lx(%lu)\n",
+ (ulong) pre, (ulong) size);
if (pre->o_type == &st_refs) {
ref_packed *rp = (ref_packed *) (pre + 1);
char *end = (char *)rp + size;
@@ -731,12 +735,12 @@ gc_trace_chunk(const gs_memory_t *mem, chunk_t * cp, gc_state_t * pstate, gc_mar
int min_trace = pstate->min_collect;
root.p = &comp;
- if_debug_chunk('6', "[6]marking from chunk", cp);
+ if_debug_chunk('6', mem, "[6]marking from chunk", cp);
SCAN_CHUNK_OBJECTS(cp)
DO_ALL
{
- if_debug2('7', " [7]scanning/marking 0x%lx(%lu)\n",
- (ulong) pre, (ulong) size);
+ if_debug2m('7', mem, " [7]scanning/marking 0x%lx(%lu)\n",
+ (ulong) pre, (ulong) size);
if (pre->o_type == &st_refs) {
ref_packed *rp = (ref_packed *) (pre + 1);
char *end = (char *)rp + size;
@@ -799,7 +803,7 @@ gc_trace(gs_gc_root_t * rp, gc_state_t * pstate, gc_mark_stack * pmstack)
BEGIN\
if (names_mark_index(nt, nidx)) {\
new |= 1;\
- if_debug2('8', " [8]marked name 0x%lx(%u)\n",\
+ if_debug2m('8', gcst_get_memory_ptr(pstate), " [8]marked name 0x%lx(%u)\n",\
(ulong)names_index_ptr(nt, nidx), nidx);\
}\
END
@@ -845,17 +849,17 @@ gc_trace(gs_gc_root_t * rp, gc_state_t * pstate, gc_mark_stack * pmstack)
continue;
}
debug_check_object(ptr - 1, NULL, NULL);
- ts:if_debug4('7', " [7]%smarking %s 0x%lx[%u]",
- depth_dots(sp, pms),
- struct_type_name_string(ptr[-1].o_type),
- (ulong) ptr, sp->index);
+ ts:if_debug4m('7', pstate->heap, " [7]%smarking %s 0x%lx[%u]",
+ depth_dots(sp, pms),
+ struct_type_name_string(ptr[-1].o_type),
+ (ulong) ptr, sp->index);
mproc = ptr[-1].o_type->enum_ptrs;
if (mproc == gs_no_struct_enum_ptrs ||
(ptp = (*mproc)
(gcst_get_memory_ptr(pstate), ptr, pre_obj_contents_size(ptr - 1),
sp->index, &nep, ptr[-1].o_type, pstate)) == 0
) {
- if_debug0('7', " - done\n");
+ if_debug0m('7', pstate->heap, " - done\n");
sp--;
continue;
}
@@ -864,7 +868,7 @@ gc_trace(gs_gc_root_t * rp, gc_state_t * pstate, gc_mark_stack * pmstack)
/* template for pointer enumeration work. */
nptr = (void *)nep.ptr;
sp->index++;
- if_debug1('7', " = 0x%lx\n", (ulong) nptr);
+ if_debug1m('7', pstate->heap, " = 0x%lx\n", (ulong) nptr);
/* Descend into nep.ptr, whose pointer type is ptp. */
if (ptp == ptr_struct_type) {
sp[1].index = 0;
@@ -904,7 +908,7 @@ gc_trace(gs_gc_root_t * rp, gc_state_t * pstate, gc_mark_stack * pmstack)
continue;
}
--(sp->index);
- if_debug3('8', " [8]%smarking refs 0x%lx[%u]\n",
+ if_debug3m('8', pstate->heap, " [8]%smarking refs 0x%lx[%u]\n",
depth_dots(sp, pms), (ulong) pptr, sp->index);
if (r_is_packed(pptr)) {
if (!r_has_pmark(pptr)) {
@@ -1175,7 +1179,7 @@ gc_objects_set_reloc(gc_state_t * gcst, chunk_t * cp)
chunk_head_t *chead = cp->chead;
byte *pfree = (byte *) & chead->free; /* most recent free object */
- if_debug_chunk('6', "[6]setting reloc for chunk", cp);
+ if_debug_chunk('6', gcst->heap, "[6]setting reloc for chunk", cp);
gc_init_reloc(cp);
SCAN_CHUNK_OBJECTS(cp)
DO_ALL
@@ -1188,16 +1192,16 @@ gc_objects_set_reloc(gc_state_t * gcst, chunk_t * cp)
) { /* Free object */
reloc += sizeof(obj_header_t) + obj_align_round(size);
if ((finalize = pre->o_type->finalize) != 0) {
- if_debug2('u', "[u]GC finalizing %s 0x%lx\n",
- struct_type_name_string(pre->o_type),
- (ulong) (pre + 1));
+ if_debug2m('u', gcst->heap, "[u]GC finalizing %s 0x%lx\n",
+ struct_type_name_string(pre->o_type),
+ (ulong) (pre + 1));
(*finalize) (gcst->cur_mem, pre + 1);
}
pfree = (byte *) pre;
pre->o_back = (pfree - (byte *) chead) >> obj_back_shift;
pre->o_nreloc = reloc;
- if_debug3('7', " [7]at 0x%lx, unmarked %lu, new reloc = %u\n",
- (ulong) pre, (ulong) size, reloc);
+ if_debug3m('7', gcst->heap, " [7]at 0x%lx, unmarked %lu, new reloc = %u\n",
+ (ulong) pre, (ulong) size, reloc);
} else { /* Useful object */
debug_check_object(pre, cp, gcst);
pre->o_back = ((byte *) pre - pfree) >> obj_back_shift;
@@ -1205,8 +1209,8 @@ gc_objects_set_reloc(gc_state_t * gcst, chunk_t * cp)
END_OBJECTS_SCAN
#ifdef DEBUG
if (reloc != 0) {
- if_debug1('6', "[6]freed %u", reloc);
- if_debug_chunk('6', " in", cp);
+ if_debug1m('6', gcst->heap, "[6]freed %u", reloc);
+ if_debug_chunk('6', gcst->heap, " in", cp);
}
#endif
}
@@ -1219,7 +1223,7 @@ gc_do_reloc(chunk_t * cp, gs_ref_memory_t * mem, gc_state_t * pstate)
{
chunk_head_t *chead = cp->chead;
- if_debug_chunk('6', "[6]relocating in chunk", cp);
+ if_debug_chunk('6', (const gs_memory_t *)mem, "[6]relocating in chunk", cp);
SCAN_CHUNK_OBJECTS(cp)
DO_ALL
#ifdef DEBUG
@@ -1235,10 +1239,10 @@ gc_do_reloc(chunk_t * cp, gs_ref_memory_t * mem, gc_state_t * pstate)
struct_proc_reloc_ptrs((*proc)) =
pre->o_type->reloc_ptrs;
- if_debug3('7',
- " [7]relocating ptrs in %s(%lu) 0x%lx\n",
- struct_type_name_string(pre->o_type),
- (ulong) size, (ulong) pre);
+ if_debug3m('7', (const gs_memory_t *)mem,
+ " [7]relocating ptrs in %s(%lu) 0x%lx\n",
+ struct_type_name_string(pre->o_type),
+ (ulong) size, (ulong) pre);
if (proc != 0)
(*proc) (pre + 1, size, pre->o_type, pstate);
}
@@ -1334,10 +1338,10 @@ gc_objects_compact(chunk_t * cp, gc_state_t * gcst)
const struct_shared_procs_t *procs = pre->o_type->shared;
debug_check_object(pre, cp, gcst);
- if_debug4('7',
- " [7]compacting %s 0x%lx(%lu) to 0x%lx\n",
- struct_type_name_string(pre->o_type),
- (ulong) pre, (ulong) size, (ulong) dpre);
+ if_debug4m('7', cmem,
+ " [7]compacting %s 0x%lx(%lu) to 0x%lx\n",
+ struct_type_name_string(pre->o_type),
+ (ulong) pre, (ulong) size, (ulong) dpre);
if (procs == 0) {
if (dpre != pre)
memmove(dpre, pre,
diff --git a/gs/psi/igcref.c b/gs/psi/igcref.c
index 9bff137c4..e22123442 100644
--- a/gs/psi/igcref.c
+++ b/gs/psi/igcref.c
@@ -28,9 +28,9 @@
/* Define whether to trace every step of relocating ref pointers. */
#if 0
-# define rputc(c) dputc(c)
+# define rputc(m,c) dmputc(m,c)
#else
-# define rputc(c) DO_NOTHING
+# define rputc(m,c) DO_NOTHING
#endif
/* Forward references */
@@ -118,9 +118,9 @@ refs_clear_marks(const gs_memory_t *cmem,
if (r_is_packed(rp)) {
#ifdef DEBUG
if (gs_debug_c('8')) {
- dlprintf1(" [8]unmark packed 0x%lx ", (ulong) rp);
+ dmlprintf1(cmem, " [8]unmark packed 0x%lx ", (ulong) rp);
debug_print_ref(cmem, (const ref *)rp);
- dputs("\n");
+ dmputs(cmem, "\n");
}
#endif
r_clear_pmark(rp);
@@ -130,9 +130,9 @@ refs_clear_marks(const gs_memory_t *cmem,
#ifdef DEBUG
if (gs_debug_c('8')) {
- dlprintf1(" [8]unmark ref 0x%lx ", (ulong) rp);
+ dmlprintf1(cmem, " [8]unmark ref 0x%lx ", (ulong) rp);
debug_print_ref(cmem, pref);
- dputs("\n");
+ dmputs(cmem, "\n");
}
#endif
r_clear_attrs(pref, l_mark);
@@ -413,9 +413,9 @@ igc_reloc_refs(ref_packed * from, ref_packed * to, gc_state_t * gcst)
/* The following assignment is logically unnecessary; */
/* we do it only for convenience in debugging. */
pref = (ref *) rp;
- if_debug3('8', " [8]relocating %s %d ref at 0x%lx\n",
- (r_has_attr(pref, l_mark) ? "marked" : "unmarked"),
- r_btype(pref), (ulong) pref);
+ if_debug3m('8', gcst->heap, " [8]relocating %s %d ref at 0x%lx\n",
+ (r_has_attr(pref, l_mark) ? "marked" : "unmarked"),
+ r_btype(pref), (ulong) pref);
if ((r_has_attr(pref, l_mark) || do_all) &&
r_space(pref) >= min_trace
) {
@@ -436,7 +436,7 @@ igc_reloc_refs(ref_packed * from, ref_packed * to, gc_state_t * gcst)
break;
/* Non-trivial non-struct cases */
case t_dictionary:
- rputc('d');
+ rputc(gcst->heap, 'd');
SET_RELOC(pref->value.pdict,
(dict *)igc_reloc_ref_ptr((ref_packed *)pref->value.pdict, gcst));
break;
@@ -456,12 +456,12 @@ igc_reloc_refs(ref_packed * from, ref_packed * to, gc_state_t * gcst)
* just after it.
*/
if (size < max_size_st_refs / sizeof(ref)) {
- rputc('a');
+ rputc(gcst->heap, 'a');
SET_RELOC(pref->value.refs,
(ref *) igc_reloc_ref_ptr(
(ref_packed *) pref->value.refs, gcst));
} else {
- rputc('A');
+ rputc(gcst->heap, 'A');
/*
* See the t_shortarray case below for why we
* decrement size.
@@ -477,7 +477,7 @@ igc_reloc_refs(ref_packed * from, ref_packed * to, gc_state_t * gcst)
break;
case t_mixedarray:
if (r_size(pref) != 0) { /* value.refs might be NULL */
- rputc('m');
+ rputc(gcst->heap, 'm');
SET_RELOC(pref->value.packed,
igc_reloc_ref_ptr(pref->value.packed, gcst));
}
@@ -495,7 +495,7 @@ igc_reloc_refs(ref_packed * from, ref_packed * to, gc_state_t * gcst)
* beginning.
*/
if (size != 0) { /* value.refs might be NULL */
- rputc('s');
+ rputc(gcst->heap, 's');
/*
* igc_reloc_ref_ptr has to be able to determine
* whether the pointer points into a space that
@@ -534,15 +534,15 @@ igc_reloc_refs(ref_packed * from, ref_packed * to, gc_state_t * gcst)
}
break;
case t_oparray:
- rputc('o');
+ rputc(gcst->heap, 'o');
SET_RELOC(pref->value.const_refs,
(const ref *)igc_reloc_ref_ptr((const ref_packed *)pref->value.const_refs, gcst));
break;
default:
goto no_reloc; /* don't print trace message */
}
- if_debug2('8', " [8]relocated 0x%lx => 0x%lx\n",
- (ulong)before, (ulong)after);
+ if_debug2m('8', gcst->heap, " [8]relocated 0x%lx => 0x%lx\n",
+ (ulong)before, (ulong)after);
}
no_reloc:
rp += packed_per_ref;
@@ -577,11 +577,11 @@ igc_reloc_ref_ptr_nocheck(const ref_packed * prp, gc_state_t *gcst)
* each such unmarked packed ref we pass over,
* we have to decrement the final relocation.
*/
- rputc((*rp & lp_mark ? '1' : '0'));
+ rputc(gcst->heap, (*rp & lp_mark ? '1' : '0'));
if (!(*rp & lp_mark)) {
if (*rp != pt_tag(pt_integer) + packed_max_value) {
/* This is a stored relocation value. */
- rputc('\n');
+ rputc(gcst->heap, '\n');
rp = print_reloc(prp, "ref",
(const ref_packed *)
((const char *)prp -
@@ -601,7 +601,7 @@ igc_reloc_ref_ptr_nocheck(const ref_packed * prp, gc_state_t *gcst)
}
if (!ref_type_uses_size_or_null(r_type(RP_REF(rp)))) {
/* reloc is in r_size */
- rputc('\n');
+ rputc(gcst->heap, '\n');
rp = print_reloc(prp, "ref",
(const ref_packed *)
(r_size(RP_REF(rp)) == 0 ? prp :
@@ -609,7 +609,7 @@ igc_reloc_ref_ptr_nocheck(const ref_packed * prp, gc_state_t *gcst)
r_size(RP_REF(rp)) + dec)));
break;
}
- rputc('u');
+ rputc(gcst->heap, 'u');
rp += packed_per_ref;
}
/* Use a severely deprecated pun to remove the const property. */
@@ -688,7 +688,7 @@ refs_compact(const gs_memory_t *mem, obj_header_t * pre, obj_header_t * dpre, ui
if (r_is_packed(src)) {
if (!r_has_pmark(src))
break;
- if_debug1('8', " [8]packed ref 0x%lx \"copied\"\n",
+ if_debug1m('8', mem, " [8]packed ref 0x%lx \"copied\"\n",
(ulong) src);
*src &= ~lp_mark;
src++;
@@ -697,7 +697,7 @@ refs_compact(const gs_memory_t *mem, obj_header_t * pre, obj_header_t * dpre, ui
if (!r_has_attr(pref, l_mark))
break;
- if_debug1('8', " [8]ref 0x%lx \"copied\"\n", (ulong) src);
+ if_debug1m('8', mem, " [8]ref 0x%lx \"copied\"\n", (ulong) src);
r_clear_attrs(pref, l_mark);
src += packed_per_ref;
}
@@ -707,7 +707,7 @@ refs_compact(const gs_memory_t *mem, obj_header_t * pre, obj_header_t * dpre, ui
for (;;) {
if (r_is_packed(src)) {
if (r_has_pmark(src)) {
- if_debug2('8', " [8]packed ref 0x%lx copied to 0x%lx\n",
+ if_debug2m('8', mem, " [8]packed ref 0x%lx copied to 0x%lx\n",
(ulong) src, (ulong) dest);
*dest++ = *src & ~lp_mark;
}
@@ -716,8 +716,8 @@ refs_compact(const gs_memory_t *mem, obj_header_t * pre, obj_header_t * dpre, ui
if (r_has_attr((ref *) src, l_mark)) {
ref rtemp;
- if_debug2('8', " [8]ref 0x%lx copied to 0x%lx\n",
- (ulong) src, (ulong) dest);
+ if_debug2m('8', mem, " [8]ref 0x%lx copied to 0x%lx\n",
+ (ulong) src, (ulong) dest);
/* We can't just use ref_assign_inline, */
/* because the source and destination */
/* might overlap! */
@@ -738,7 +738,7 @@ refs_compact(const gs_memory_t *mem, obj_header_t * pre, obj_header_t * dpre, ui
/* Check that the relocation came out OK. */
/* NOTE: this check only works within a single chunk. */
if ((byte *) src - (byte *) dest != r_size((ref *) src - 1) + sizeof(ref)) {
- lprintf3("Reloc error for refs 0x%lx: reloc = %lu, stored = %u\n",
+ mlprintf3(mem, "Reloc error for refs 0x%lx: reloc = %lu, stored = %u\n",
(ulong) dpre, (ulong) ((byte *) src - (byte *) dest),
(uint) r_size((ref *) src - 1));
gs_abort(mem);
diff --git a/gs/psi/igcstr.c b/gs/psi/igcstr.c
index d2bb62ceb..28f6d89d7 100644
--- a/gs/psi/igcstr.c
+++ b/gs/psi/igcstr.c
@@ -21,6 +21,7 @@
#include "gsstruct.h"
#include "iastate.h"
#include "igcstr.h"
+#include "igc.h"
/* Forward references */
static bool gc_mark_string(const byte *, uint, bool, const chunk_t *);
@@ -117,11 +118,11 @@ gc_mark_string(const byte * ptr, uint size, bool set, const chunk_t * cp)
* equivalent of fwrite.
*/
static void
-dfwrite(const byte *ptr, uint count)
+dmfwrite(const gs_memory_t *mem, const byte *ptr, uint count)
{
uint i;
for (i = 0; i < count; ++i)
- dputc(ptr[i]);
+ dmputc(mem, ptr[i]);
}
#endif
@@ -134,15 +135,15 @@ gc_string_mark(const byte * ptr, uint size, bool set, gc_state_t * gcst)
if (size == 0)
return false;
-#define dprintstr()\
- dputc('('); dfwrite(ptr, min(size, 20));\
- dputs((size <= 20 ? ")" : "...)"))
+#define dmprintstr(mem)\
+ dmputc(mem, '('); dmfwrite(mem, ptr, min(size, 20));\
+ dmputs(mem, (size <= 20 ? ")" : "...)"))
if (!(cp = gc_locate(ptr, gcst))) { /* not in a chunk */
#ifdef DEBUG
if (gs_debug_c('5')) {
- dlprintf2("[5]0x%lx[%u]", (ulong) ptr, size);
- dprintstr();
- dputs(" not in a chunk\n");
+ dmlprintf2(gcst->heap, "[5]0x%lx[%u]", (ulong) ptr, size);
+ dmprintstr(gcst->heap);
+ dmputs(gcst->heap, " not in a chunk\n");
}
#endif
return false;
@@ -180,11 +181,11 @@ gc_string_mark(const byte * ptr, uint size, bool set, gc_state_t * gcst)
marks = gc_mark_string(ptr, size, set, cp);
#ifdef DEBUG
if (gs_debug_c('5')) {
- dlprintf4("[5]%s%smarked 0x%lx[%u]",
+ dmlprintf4(gcst->heap, "[5]%s%smarked 0x%lx[%u]",
(marks ? "" : "already "), (set ? "" : "un"),
(ulong) ptr, size);
- dprintstr();
- dputc('\n');
+ dmprintstr(gcst->heap);
+ dmputc(gcst->heap, '\n');
}
#endif
return marks;
@@ -338,7 +339,7 @@ igc_reloc_param_string(gs_param_string * sptr, gc_state_t * gcst)
/* Compact the strings in a chunk. */
void
-gc_strings_compact(chunk_t * cp)
+gc_strings_compact(chunk_t * cp, const gs_memory_t *mem)
{
if (cp->smark != 0) {
byte *hi = cp->climit;
@@ -357,24 +358,24 @@ gc_strings_compact(chunk_t * cp)
for (; i < n; i += R) {
uint j;
- dlprintf1("[4]0x%lx: ", (ulong) (base + i));
+ dmlprintf1(mem, "[4]0x%lx: ", (ulong) (base + i));
for (j = i; j < i + R; j++) {
byte ch = base[j];
if (ch <= 31) {
- dputc('^');
- dputc(ch + 0100);
+ dmputc(mem, '^');
+ dmputc(mem, ch + 0100);
} else
- dputc(ch);
+ dmputc(mem, ch);
}
- dputc(' ');
+ dmputc(mem, ' ');
for (j = i; j < i + R; j++)
- dputc((cp->smark[j >> 3] & (1 << (j & 7)) ?
+ dmputc(mem, (cp->smark[j >> 3] & (1 << (j & 7)) ?
'+' : '.'));
#undef R
if (!(i & (string_data_quantum - 1)))
- dprintf1(" %u", cp->sreloc[i >> log2_string_data_quantum]);
- dputc('\n');
+ dmprintf1(mem, " %u", cp->sreloc[i >> log2_string_data_quantum]);
+ dmputc(mem, '\n');
}
}
#endif
diff --git a/gs/psi/igcstr.h b/gs/psi/igcstr.h
index ac9f6b370..4bf0fbc93 100644
--- a/gs/psi/igcstr.h
+++ b/gs/psi/igcstr.h
@@ -27,7 +27,7 @@ void gc_strings_set_marks(chunk_t *, bool);
bool gc_string_mark(const byte *, uint, bool, gc_state_t *);
void gc_strings_clear_reloc(chunk_t *);
void gc_strings_set_reloc(chunk_t *);
-void gc_strings_compact(chunk_t *);
+void gc_strings_compact(chunk_t *, const gs_memory_t *);
string_proc_reloc(igc_reloc_string);
const_string_proc_reloc(igc_reloc_const_string);
param_string_proc_reloc(igc_reloc_param_string);
diff --git a/gs/psi/ilocate.c b/gs/psi/ilocate.c
index ac041066e..96d32a321 100644
--- a/gs/psi/ilocate.c
+++ b/gs/psi/ilocate.c
@@ -248,13 +248,13 @@ ialloc_validate_memory(const gs_ref_memory_t * mem, gc_state_t * gcst)
const chunk_t *cp;
int i;
- if_debug3('6', "[6]validating memory 0x%lx, space %d, level %d\n",
- (ulong) mem, mem->space, level);
+ if_debug3m('6', (gs_memory_t *)mem, "[6]validating memory 0x%lx, space %d, level %d\n",
+ (ulong) mem, mem->space, level);
/* Validate chunks. */
for (cp = smem->cfirst; cp != 0; cp = cp->cnext)
if (do_validate_chunk(cp, gcst)) {
- lprintf3("while validating memory 0x%lx, space %d, level %d\n",
- (ulong) mem, mem->space, level);
+ mlprintf3((gs_memory_t *)mem, "while validating memory 0x%lx, space %d, level %d\n",
+ (ulong) mem, mem->space, level);
gs_abort(gcst->heap);
}
/* Validate freelists. */
@@ -268,15 +268,15 @@ ialloc_validate_memory(const gs_ref_memory_t * mem, gc_state_t * gcst)
uint size = pfree[-1].o_size;
if (pfree[-1].o_type != &st_free) {
- lprintf3("Non-free object 0x%lx(%u) on freelist %i!\n",
- (ulong) pfree, size, i);
+ mlprintf3((gs_memory_t *)mem, "Non-free object 0x%lx(%u) on freelist %i!\n",
+ (ulong) pfree, size, i);
break;
}
if ((i == LARGE_FREELIST_INDEX && size < max_freelist_size) ||
(i != LARGE_FREELIST_INDEX &&
(size < free_size - obj_align_mask || size > free_size))) {
- lprintf3("Object 0x%lx(%u) size wrong on freelist %i!\n",
- (ulong) pfree, size, i);
+ mlprintf3((gs_memory_t *)mem, "Object 0x%lx(%u) size wrong on freelist %i!\n",
+ (ulong) pfree, size, i);
break;
}
}
@@ -307,7 +307,7 @@ do_validate_chunk(const chunk_t * cp, gc_state_t * gcst)
{
int ret = 0;
- if_debug_chunk('6', "[6]validating chunk", cp);
+ if_debug_chunk('6', gcst->heap, "[6]validating chunk", cp);
SCAN_CHUNK_OBJECTS(cp);
DO_ALL
if (pre->o_type == &st_free) {
@@ -317,12 +317,12 @@ do_validate_chunk(const chunk_t * cp, gc_state_t * gcst)
return 1;
}
} else if (do_validate_object(pre + 1, cp, gcst)) {
- dprintf_chunk("while validating chunk", cp);
+ dmprintf_chunk(gcst->heap, "while validating chunk", cp);
return 1;
}
- if_debug3('7', " [7]validating %s(%lu) 0x%lx\n",
- struct_type_name_string(pre->o_type),
- (ulong) size, (ulong) pre);
+ if_debug3m('7', gcst->heap, " [7]validating %s(%lu) 0x%lx\n",
+ struct_type_name_string(pre->o_type),
+ (ulong) size, (ulong) pre);
if (pre->o_type == &st_refs) {
const ref_packed *rp = (const ref_packed *)(pre + 1);
const char *end = (const char *)rp + size;
@@ -334,10 +334,10 @@ do_validate_chunk(const chunk_t * cp, gc_state_t * gcst)
ret = ialloc_validate_ref_packed(rp, gcst);
# endif
if (ret) {
- lprintf3("while validating %s(%lu) 0x%lx\n",
+ mlprintf3(gcst->heap, "while validating %s(%lu) 0x%lx\n",
struct_type_name_string(pre->o_type),
(ulong) size, (ulong) pre);
- dprintf_chunk("in chunk", cp);
+ dmprintf_chunk(gcst->heap, "in chunk", cp);
return ret;
}
rp = packed_next(rp);
@@ -368,7 +368,7 @@ do_validate_chunk(const chunk_t * cp, gc_state_t * gcst)
ret = ialloc_validate_ref_packed(eptr.ptr, gcst);
# endif
if (ret) {
- dprintf_chunk("while validating chunk", cp);
+ dmprintf_chunk(gcst->heap, "while validating chunk", cp);
return ret;
}
}
@@ -586,13 +586,13 @@ do_validate_object(const obj_header_t * ptr, const chunk_t * cp,
st = *gcst; /* no side effects! */
if (!(cp = gc_locate(pre, &st))) {
- lprintf1("Object 0x%lx not in any chunk!\n",
- (ulong) ptr);
+ mlprintf1(gcst->heap, "Object 0x%lx not in any chunk!\n",
+ (ulong) ptr);
return 1; /*gs_abort(); */
}
}
if (otype == &st_free) {
- lprintf3("Reference to free object 0x%lx(%lu), in chunk 0x%lx!\n",
+ mlprintf3(gcst->heap, "Reference to free object 0x%lx(%lu), in chunk 0x%lx!\n",
(ulong) ptr, (ulong) size, (ulong) cp);
return 1;
}
@@ -602,10 +602,10 @@ do_validate_object(const obj_header_t * ptr, const chunk_t * cp,
(oname = struct_type_name_string(otype),
*oname < 33 || *oname > 126)
) {
- lprintf2("Bad object 0x%lx(%lu),\n",
- (ulong) ptr, (ulong) size);
- dprintf2(" ssize = %u, in chunk 0x%lx!\n",
- otype->ssize, (ulong) cp);
+ mlprintf2(gcst->heap, "Bad object 0x%lx(%lu),\n",
+ (ulong) ptr, (ulong) size);
+ dmprintf2(gcst->heap, " ssize = %u, in chunk 0x%lx!\n",
+ otype->ssize, (ulong) cp);
return 1;
}
return 0;
diff --git a/gs/psi/imain.c b/gs/psi/imain.c
index 891f25d5d..3a71a1c1e 100644
--- a/gs/psi/imain.c
+++ b/gs/psi/imain.c
@@ -867,7 +867,7 @@ gs_main_finit(gs_main_instance * minst, int exit_status, int code)
i_ctx_p = minst->i_ctx_p; /* get current interp context */
if (gs_debug_c(':')) {
print_resource_usage(minst, &gs_imemory, "Final");
- dprintf1("%% Exiting instance 0x%p\n", minst);
+ dmprintf1(minst->heap, "%% Exiting instance 0x%p\n", minst);
}
/* Do the equivalent of a restore "past the bottom". */
/* This will release all memory, close all open files, etc. */
@@ -959,10 +959,10 @@ print_resource_usage(const gs_main_instance * minst, gs_dual_memory_t * dmem,
}
}
}
- dprintf4("%% %s time = %g, memory allocated = %lu, used = %lu\n",
- msg, utime[0] - minst->base_time[0] +
- (utime[1] - minst->base_time[1]) / 1000000000.0,
- allocated, used);
+ dmprintf4(minst->heap, "%% %s time = %g, memory allocated = %lu, used = %lu\n",
+ msg, utime[0] - minst->base_time[0] +
+ (utime[1] - minst->base_time[1]) / 1000000000.0,
+ allocated, used);
}
/* Dump the stacks after interpretation */
@@ -972,11 +972,11 @@ gs_main_dump_stack(gs_main_instance *minst, int code, ref * perror_object)
i_ctx_t *i_ctx_p = minst->i_ctx_p;
zflush(i_ctx_p); /* force out buffered output */
- dprintf1("\nUnexpected interpreter error %d.\n", code);
+ dmprintf1(minst->heap, "\nUnexpected interpreter error %d.\n", code);
if (perror_object != 0) {
- dputs("Error object: ");
+ dmputs(minst->heap, "Error object: ");
debug_print_ref(minst->heap, perror_object);
- dputc('\n');
+ dmputc(minst->heap, '\n');
}
debug_dump_stack(minst->heap, &o_stack, "Operand stack");
debug_dump_stack(minst->heap, &e_stack, "Execution stack");
diff --git a/gs/psi/imainarg.c b/gs/psi/imainarg.c
index b5301e24e..58d8655d7 100644
--- a/gs/psi/imainarg.c
+++ b/gs/psi/imainarg.c
@@ -216,10 +216,10 @@ gs_main_init_with_args(gs_main_instance * minst, int argc, char *argv[])
if (gs_debug[':'] && arg[1] == 'Z') {
int i;
- dprintf1("%% Init started, instance 0x%p, with args: ", minst);
+ dmprintf1(minst->heap, "%% Init started, instance 0x%p, with args: ", minst);
for (i=1; i<argc; i++)
- dprintf1("%s ", argv[i]);
- dprintf("\n");
+ dmprintf1(minst->heap, "%s ", argv[i]);
+ dmprintf(minst->heap, "\n");
}
break;
default:
@@ -238,10 +238,10 @@ gs_main_init_with_args(gs_main_instance * minst, int argc, char *argv[])
if (gs_debug[':']) {
int i;
- dprintf1("%% Init done, instance 0x%p, with args: ", minst);
+ dmprintf1(minst->heap, "%% Init done, instance 0x%p, with args: ", minst);
for (i=1; i<argc; i++)
- dprintf1("%s ", argv[i]);
- dprintf("\n");
+ dmprintf1(minst->heap, "%s ", argv[i]);
+ dmprintf(minst->heap, "\n");
}
if (!minst->run_start)
return e_Quit;
diff --git a/gs/psi/iname.c b/gs/psi/iname.c
index c99374008..2eb8ee29f 100644
--- a/gs/psi/iname.c
+++ b/gs/psi/iname.c
@@ -63,12 +63,12 @@ name_print(const char *msg, const name_table *nt, uint nidx, const int *pflag)
const name *pname = names_index_ptr_inline(nt, nidx);
const byte *str = pnstr->string_bytes;
- dlprintf1("[n]%s", msg);
+ dmlprintf1(nt->memory, "[n]%s", msg);
if (pflag)
- dprintf1("(%d)", *pflag);
- dprintf2(" (0x%lx#%u)", (ulong)pname, nidx);
- debug_print_string(str, pnstr->string_size);
- dprintf2("(0x%lx,%u)\n", (ulong)str, pnstr->string_size);
+ dmprintf1(nt->memory, "(%d)", *pflag);
+ dmprintf2(nt->memory, " (0x%lx#%u)", (ulong)pname, nidx);
+ debug_print_string(nt->memory, str, pnstr->string_size);
+ dmprintf2(nt->memory, "(0x%lx,%u)\n", (ulong)str, pnstr->string_size);
}
# define if_debug_name(msg, nt, nidx, pflag)\
if ( gs_debug_c('n') ) name_print(msg, nt, nidx, pflag)
@@ -513,7 +513,7 @@ name_alloc_sub(name_table * nt)
for (i0 = 0; i0 < NT_HASH_SIZE; i0 += 16) {
int i;
- dlprintf1("[n]chain %d:", i0);
+ dmlprintf1(mem, "[n]chain %d:", i0);
for (i = i0; i < i0 + 16; i++) {
int n = 0;
uint nidx;
@@ -523,9 +523,9 @@ name_alloc_sub(name_table * nt)
names_index_string_inline(nt, nidx))
)
n++;
- dprintf1(" %d", n);
+ dmprintf1(mem, " %d", n);
}
- dputc('\n');
+ dmputc(mem, '\n');
}
}
#endif
diff --git a/gs/psi/interp.c b/gs/psi/interp.c
index 506f8b899..d384e8164 100644
--- a/gs/psi/interp.c
+++ b/gs/psi/interp.c
@@ -94,16 +94,16 @@ do_call_operator_verbose(op_proc_t op_proc, i_ctx_t *i_ctx_p)
int code;
#ifndef SHOW_STACK_DEPTHS
- if_debug1('!', "[!]operator %s\n", op_get_name_string(op_proc));
+ if_debug1m('!', imemory, "[!]operator %s\n", op_get_name_string(op_proc));
#else
- if_debug3('!', "[!][es=%d os=%d]operator %s\n",
+ if_debug3m('!', imemory, "[!][es=%d os=%d]operator %s\n",
esp-i_ctx_p->exec_stack.stack.bot,
osp-i_ctx_p->op_stack.stack.bot,
op_get_name_string(op_proc));
#endif
code = do_call_operator(op_proc, i_ctx_p);
#if defined(SHOW_STACK_DEPTHS)
- if_debug2('!', "[!][es=%d os=%d]\n",
+ if_debug2m('!', imemory, "[!][es=%d os=%d]\n",
esp-i_ctx_p->exec_stack.stack.bot,
osp-i_ctx_p->op_stack.stack.bot);
#endif
@@ -909,7 +909,7 @@ interp(i_ctx_t **pi_ctx_p /* context for execution, updated if resched */,
if (iosp >= osbot &&
(r_type(iosp) == t__invalid || r_type(iosp) >= tx_next_op)
) {
- lprintf("Invalid value on o-stack!\n");
+ mlprintf(imemory, "Invalid value on o-stack!\n");
return_with_error_iref(e_Fatal);
}
if (gs_debug['I'] ||
@@ -923,18 +923,18 @@ interp(i_ctx_t **pi_ctx_p /* context for execution, updated if resched */,
osp = iosp;
esp = iesp;
- dlprintf5("d%u,e%u<%u>0x%lx(%d): ",
+ dmlprintf5(imemory, "d%u,e%u<%u>0x%lx(%d): ",
ref_stack_count(&d_stack), ref_stack_count(&e_stack),
ref_stack_count(&o_stack), (ulong)IREF, icount);
debug_print_ref(imemory, IREF);
if (iosp >= osbot) {
- dputs(" // ");
+ dmputs(imemory, " // ");
debug_print_ref(imemory, iosp);
}
- dputc('\n');
+ dmputc(imemory, '\n');
osp = save_osp;
esp = save_esp;
- dflush();
+ dmflush(imemory);
}
#endif
/* Objects that have attributes (arrays, dictionaries, files, and strings) */
diff --git a/gs/psi/ireclaim.c b/gs/psi/ireclaim.c
index 653998f0a..e883505ce 100644
--- a/gs/psi/ireclaim.c
+++ b/gs/psi/ireclaim.c
@@ -69,8 +69,8 @@ ireclaim(gs_dual_memory_t * dmem, int space)
} else {
mem = dmem->spaces_indexed[space >> r_space_shift];
}
- if_debug3('0', "[0]GC called, space=%d, requestor=%d, requested=%ld\n",
- space, mem->space, (long)mem->gc_status.requested);
+ if_debug3m('0', (gs_memory_t *)mem, "[0]GC called, space=%d, requestor=%d, requested=%ld\n",
+ space, mem->space, (long)mem->gc_status.requested);
global = mem->space != avm_local;
/* Since dmem may move, reset the request now. */
ialloc_reset_requested(dmem);
diff --git a/gs/psi/isave.c b/gs/psi/isave.c
index 19d1073bd..30952b45a 100644
--- a/gs/psi/isave.c
+++ b/gs/psi/isave.c
@@ -236,27 +236,27 @@ gs_private_st_complex_only(st_alloc_change, alloc_change_t, "alloc_change",
/* Debugging printout */
#ifdef DEBUG
static void
-alloc_save_print(alloc_change_t * cp, bool print_current)
+alloc_save_print(const gs_memory_t *mem, alloc_change_t * cp, bool print_current)
{
- dprintf2(" 0x%lx: 0x%lx: ", (ulong) cp, (ulong) cp->where);
+ dmprintf2(mem, " 0x%lx: 0x%lx: ", (ulong) cp, (ulong) cp->where);
if (r_is_packed(&cp->contents)) {
if (print_current)
- dprintf2("saved=%x cur=%x\n", *(ref_packed *) & cp->contents,
- *cp->where);
+ dmprintf2(mem, "saved=%x cur=%x\n", *(ref_packed *) & cp->contents,
+ *cp->where);
else
- dprintf1("%x\n", *(ref_packed *) & cp->contents);
+ dmprintf1(mem, "%x\n", *(ref_packed *) & cp->contents);
} else {
if (print_current)
- dprintf6("saved=%x %x %lx cur=%x %x %lx\n",
- r_type_attrs(&cp->contents), r_size(&cp->contents),
- (ulong) cp->contents.value.intval,
- r_type_attrs((ref *) cp->where),
- r_size((ref *) cp->where),
- (ulong) ((ref *) cp->where)->value.intval);
+ dmprintf6(mem, "saved=%x %x %lx cur=%x %x %lx\n",
+ r_type_attrs(&cp->contents), r_size(&cp->contents),
+ (ulong) cp->contents.value.intval,
+ r_type_attrs((ref *) cp->where),
+ r_size((ref *) cp->where),
+ (ulong) ((ref *) cp->where)->value.intval);
else
- dprintf3("%x %x %lx\n",
- r_type_attrs(&cp->contents), r_size(&cp->contents),
- (ulong) cp->contents.value.intval);
+ dmprintf3(mem, "%x %x %lx\n",
+ r_type_attrs(&cp->contents), r_size(&cp->contents),
+ (ulong) cp->contents.value.intval);
}
}
#endif
@@ -415,8 +415,8 @@ alloc_save_space(gs_ref_memory_t * mem, gs_dual_memory_t * dmem, ulong sid)
break; /* maybe should fail */
alloc_init_chunk(inner, cp->cbot, cp->ctop, cp->sreloc != 0, cp);
alloc_link_chunk(inner, mem);
- if_debug2('u', "[u]inner chunk: cbot=0x%lx ctop=0x%lx\n",
- (ulong) inner->cbot, (ulong) inner->ctop);
+ if_debug2m('u', (gs_memory_t *)mem, "[u]inner chunk: cbot=0x%lx ctop=0x%lx\n",
+ (ulong) inner->cbot, (ulong) inner->ctop);
if (cp == save_mem.pcc)
new_pcc = inner;
}
@@ -426,8 +426,8 @@ alloc_save_space(gs_ref_memory_t * mem, gs_dual_memory_t * dmem, ulong sid)
save = gs_alloc_struct((gs_memory_t *) mem, alloc_save_t,
&st_alloc_save, "alloc_save_space(save)");
- if_debug2('u', "[u]save space %u at 0x%lx\n",
- mem->space, (ulong) save);
+ if_debug2m('u', (gs_memory_t *)mem, "[u]save space %u at 0x%lx\n",
+ mem->space, (ulong) save);
if (save == 0) {
/* Free the inner chunk structures. This is the easiest way. */
restore_free(mem);
@@ -440,8 +440,8 @@ alloc_save_space(gs_ref_memory_t * mem, gs_dual_memory_t * dmem, ulong sid)
save->is_current = (dmem->current == mem);
save->id = sid;
mem->saved = save;
- if_debug2('u', "[u%u]file_save 0x%lx\n",
- mem->space, (ulong) mem->streams);
+ if_debug2m('u', (gs_memory_t *)mem, "[u%u]file_save 0x%lx\n",
+ mem->space, (ulong) mem->streams);
mem->streams = 0;
mem->total_scanned = 0;
mem->total_scanned_after_compacting = 0;
@@ -486,8 +486,8 @@ alloc_save_change_in(gs_ref_memory_t *mem, const ref * pcont,
mem->changes = cp;
#ifdef DEBUG
if (gs_debug_c('U')) {
- dlprintf1("[U]save(%s)", client_name_string(cname));
- alloc_save_print(cp, false);
+ dmlprintf1((const gs_memory_t *)mem, "[U]save(%s)", client_name_string(cname));
+ alloc_save_print((const gs_memory_t *)mem, cp, false);
}
#endif
return 0;
@@ -605,8 +605,8 @@ alloc_is_since_save(const void *vptr, const alloc_save_t * save)
const char *const ptr = (const char *)vptr;
register const gs_ref_memory_t *mem = save->space_local;
- if_debug2('U', "[U]is_since_save 0x%lx, 0x%lx:\n",
- (ulong) ptr, (ulong) save);
+ if_debug2m('U', (gs_memory_t *)mem, "[U]is_since_save 0x%lx, 0x%lx:\n",
+ (ulong) ptr, (ulong) save);
if (mem->saved == 0) { /* This is a special case, the final 'restore' from */
/* alloc_restore_all. */
return true;
@@ -616,15 +616,15 @@ alloc_is_since_save(const void *vptr, const alloc_save_t * save)
for (;; mem = &mem->saved->state) {
const chunk_t *cp;
- if_debug1('U', "[U]checking mem=0x%lx\n", (ulong) mem);
+ if_debug1m('U', (gs_memory_t *)mem, "[U]checking mem=0x%lx\n", (ulong) mem);
for (cp = mem->cfirst; cp != 0; cp = cp->cnext) {
if (ptr_is_within_chunk(ptr, cp)) {
- if_debug3('U', "[U+]in new chunk 0x%lx: 0x%lx, 0x%lx\n",
- (ulong) cp,
- (ulong) cp->cbase, (ulong) cp->cend);
+ if_debug3m('U', (gs_memory_t *)mem, "[U+]in new chunk 0x%lx: 0x%lx, 0x%lx\n",
+ (ulong) cp,
+ (ulong) cp->cbase, (ulong) cp->cend);
return true;
}
- if_debug1('U', "[U-]not in 0x%lx\n", (ulong) cp);
+ if_debug1m('U', (gs_memory_t *)mem, "[U-]not in 0x%lx\n", (ulong) cp);
}
if (mem->saved == save) { /* We've checked all the more recent saves, */
/* must be OK. */
@@ -645,11 +645,11 @@ alloc_is_since_save(const void *vptr, const alloc_save_t * save)
) {
const chunk_t *cp;
- if_debug1('U', "[U]checking global mem=0x%lx\n", (ulong) mem);
+ if_debug1m('U', (gs_memory_t *)mem, "[U]checking global mem=0x%lx\n", (ulong) mem);
for (cp = mem->cfirst; cp != 0; cp = cp->cnext)
if (ptr_is_within_chunk(ptr, cp)) {
- if_debug3('U', "[U+] new chunk 0x%lx: 0x%lx, 0x%lx\n",
- (ulong) cp, (ulong) cp->cbase, (ulong) cp->cend);
+ if_debug3m('U', (gs_memory_t *)mem, "[U+] new chunk 0x%lx: 0x%lx, 0x%lx\n",
+ (ulong) cp, (ulong) cp->cbase, (ulong) cp->cend);
return true;
}
}
@@ -824,8 +824,8 @@ restore_space(gs_ref_memory_t * mem, gs_dual_memory_t *dmem)
while (cp) {
#ifdef DEBUG
if (gs_debug_c('U')) {
- dlputs("[U]restore");
- alloc_save_print(cp, true);
+ dmlputs((const gs_memory_t *)mem, "[U]restore");
+ alloc_save_print((const gs_memory_t *)mem, cp, true);
}
#endif
if (cp->offset == AC_OFFSET_ALLOCATED)
@@ -939,9 +939,9 @@ restore_finalize(gs_ref_memory_t * mem)
struct_proc_finalize((*finalize)) =
pre->o_type->finalize;
if (finalize != 0) {
- if_debug2('u', "[u]restore finalizing %s 0x%lx\n",
- struct_type_name_string(pre->o_type),
- (ulong) (pre + 1));
+ if_debug2m('u', (gs_memory_t *)mem, "[u]restore finalizing %s 0x%lx\n",
+ struct_type_name_string(pre->o_type),
+ (ulong) (pre + 1));
(*finalize) ((gs_memory_t *) mem, pre + 1);
}
END_OBJECTS_SCAN
@@ -957,9 +957,9 @@ restore_resources(alloc_save_t * sprev, gs_ref_memory_t * mem)
#ifdef DEBUG
if (mem) {
/* Note restoring of the file list. */
- if_debug4('u', "[u%u]file_restore 0x%lx => 0x%lx for 0x%lx\n",
- mem->space, (ulong)mem->streams,
- (ulong)sprev->state.streams, (ulong) sprev);
+ if_debug4m('u', (gs_memory_t *)mem, "[u%u]file_restore 0x%lx => 0x%lx for 0x%lx\n",
+ mem->space, (ulong)mem->streams,
+ (ulong)sprev->state.streams, (ulong) sprev);
}
#endif
@@ -1134,7 +1134,7 @@ forget_changes(gs_ref_memory_t * mem)
for (; chp; chp = next) {
ref_packed *prp = chp->where;
- if_debug1('U', "[U]forgetting change 0x%lx\n", (ulong) chp);
+ if_debug1m('U', (gs_memory_t *)mem, "[U]forgetting change 0x%lx\n", (ulong) chp);
if (chp->offset == AC_OFFSET_ALLOCATED)
DO_NOTHING;
else
@@ -1153,9 +1153,9 @@ file_forget_save(gs_ref_memory_t * mem)
stream *streams = mem->streams;
stream *saved_streams = save->state.streams;
- if_debug4('u', "[u%d]file_forget_save 0x%lx + 0x%lx for 0x%lx\n",
- mem->space, (ulong) streams, (ulong) saved_streams,
- (ulong) save);
+ if_debug4m('u', (gs_memory_t *)mem, "[u%d]file_forget_save 0x%lx + 0x%lx for 0x%lx\n",
+ mem->space, (ulong) streams, (ulong) saved_streams,
+ (ulong) save);
if (streams == 0)
mem->streams = saved_streams;
else if (saved_streams != 0) {
@@ -1270,8 +1270,8 @@ save_set_new(gs_ref_memory_t * mem, bool to_new, bool set_limit, ulong *pscanned
SCAN_CHUNK_OBJECTS(cp)
DO_ALL
- if_debug3('U', "[U]set_new scan(0x%lx(%u), %d)\n",
- (ulong) pre, size, to_new);
+ if_debug3m('U', (gs_memory_t *)mem, "[U]set_new scan(0x%lx(%u), %d)\n",
+ (ulong) pre, size, to_new);
if (pre->o_type == &st_refs) {
/* These are refs, scan them. */
ref_packed *prp = (ref_packed *) (pre + 1);
@@ -1288,8 +1288,8 @@ save_set_new(gs_ref_memory_t * mem, bool to_new, bool set_limit, ulong *pscanned
}
}
END_CHUNKS_SCAN
- if_debug2('u', "[u]set_new (%s) scanned %ld\n",
- (to_new ? "restore" : "save"), scanned);
+ if_debug2m('u', (gs_memory_t *)mem, "[u]set_new (%s) scanned %ld\n",
+ (to_new ? "restore" : "save"), scanned);
*pscanned = scanned;
return 0;
}
@@ -1368,8 +1368,8 @@ save_set_new_changes(gs_ref_memory_t * mem, bool to_new, bool set_limit)
} else {
ref_packed *prp = chp->where;
- if_debug3('U', "[U]set_new 0x%lx: (0x%lx, %d)\n",
- (ulong)chp, (ulong)prp, new);
+ if_debug3m('U', (gs_memory_t *)mem, "[U]set_new 0x%lx: (0x%lx, %d)\n",
+ (ulong)chp, (ulong)prp, new);
if (!r_is_packed(prp)) {
ref *const rp = (ref *) prp;
diff --git a/gs/psi/iscan.c b/gs/psi/iscan.c
index 4f605120c..7d6ac2ddf 100644
--- a/gs/psi/iscan.c
+++ b/gs/psi/iscan.c
@@ -355,9 +355,9 @@ scan_comment(i_ctx_t *i_ctx_p, ref *pref, scanner_state *pstate,
/* Process as a DSC comment if requested. */
#ifdef DEBUG
if (gs_debug_c('%')) {
- dlprintf2("[%%%%%s%c]", sstr, (len >= 3 ? '+' : '-'));
- debug_print_string(base, len);
- dputs("\n");
+ dmlprintf2(imemory, "[%%%%%s%c]", sstr, (len >= 3 ? '+' : '-'));
+ debug_print_string(imemory, base, len);
+ dmputs(imemory, "\n");
}
#endif
if (gs_scan_dsc_proc != NULL) {
@@ -373,9 +373,9 @@ scan_comment(i_ctx_t *i_ctx_p, ref *pref, scanner_state *pstate,
#ifdef DEBUG
else {
if (gs_debug_c('%')) {
- dlprintf2("[%% %s%c]", sstr, (len >= 2 ? '+' : '-'));
- debug_print_string(base, len);
- dputs("\n");
+ dmlprintf2(imemory, "[%% %s%c]", sstr, (len >= 2 ? '+' : '-'));
+ debug_print_string(imemory, base, len);
+ dmputs(imemory, "\n");
}
}
#endif
@@ -564,7 +564,7 @@ gs_scan_token(i_ctx_t *i_ctx_p, ref * pref, scanner_state * pstate)
* If pstack != 0, myref = osp, and *osp is a valid slot.
*/
top:c = scan_getc();
- if_debug1('S', (c >= 32 && c <= 126 ? "`%c'" : c >= 0 ? "`\\%03o'" : "`%d'"), c);
+ if_debug1m('S', s->memory, (c >= 32 && c <= 126 ? "`%c'" : c >= 0 ? "`\\%03o'" : "`%d'"), c);
switch (c) {
case ' ':
case '\f':
@@ -680,8 +680,8 @@ gs_scan_token(i_ctx_t *i_ctx_p, ref * pref, scanner_state * pstate)
}
make_int(osp, pstack);
pstack = ref_stack_count_inline(&o_stack);
- if_debug3('S', "[S{]d=%d, s=%d->%d\n",
- pdepth, (int)osp->value.intval, pstack);
+ if_debug3m('S', s->memory, "[S{]d=%d, s=%d->%d\n",
+ pdepth, (int)osp->value.intval, pstack);
goto snext;
case '>':
if (scan_enable_level2) {
@@ -701,11 +701,11 @@ gs_scan_token(i_ctx_t *i_ctx_p, ref * pref, scanner_state * pstate)
uint size = ref_stack_count_inline(&o_stack) - pstack;
ref arr;
- if_debug4('S', "[S}]d=%d, s=%d->%d, c=%d\n",
- pdepth, pstack,
- (pstack == pdepth ? 0 :
- ref_stack_index(&o_stack, size)->value.intval),
- size + pstack);
+ if_debug4m('S', s->memory, "[S}]d=%d, s=%d->%d, c=%d\n",
+ pdepth, pstack,
+ (pstack == pdepth ? 0 :
+ ref_stack_index(&o_stack, size)->value.intval),
+ size + pstack);
if (size > max_array_size)
sreturn(e_limitcheck);
myref = (pstack == pdepth ? pref : &arr);
diff --git a/gs/psi/zcie.c b/gs/psi/zcie.c
index 87d8b788b..cc44ae90b 100644
--- a/gs/psi/zcie.c
+++ b/gs/psi/zcie.c
@@ -792,8 +792,8 @@ cie_cache_finish_store(i_ctx_t *i_ctx_p, bool replicate)
pcache = (cie_cache_floats *) (r_ptr(esp - 1, char) + esp->value.intval);
pcache->params.is_identity = false; /* cache_set_linear computes this */
- if_debug3('c', "[c]cache 0x%lx base=%g, factor=%g:\n",
- (ulong) pcache, pcache->params.base, pcache->params.factor);
+ if_debug3m('c', imemory, "[c]cache 0x%lx base=%g, factor=%g:\n",
+ (ulong) pcache, pcache->params.base, pcache->params.factor);
if (replicate ||
(code = float_params(op, gx_cie_cache_size, &pcache->values[0])) < 0
) {
@@ -814,9 +814,9 @@ cie_cache_finish_store(i_ctx_t *i_ctx_p, bool replicate)
int i;
for (i = 0; i < gx_cie_cache_size; i += 4)
- dlprintf5("[c] cache[%3d]=%g, %g, %g, %g\n", i,
- pcache->values[i], pcache->values[i + 1],
- pcache->values[i + 2], pcache->values[i + 3]);
+ dmlprintf5(imemory, "[c] cache[%3d]=%g, %g, %g, %g\n", i,
+ pcache->values[i], pcache->values[i + 1],
+ pcache->values[i + 2], pcache->values[i + 3]);
}
#endif
ref_stack_pop(&o_stack, (replicate ? 1 : gx_cie_cache_size));
@@ -927,8 +927,8 @@ cie_create_icc(i_ctx_t *i_ctx_p)
pcache = (cie_cache_floats *) (r_ptr(esp - 1, char) + esp->value.intval);
pcache->params.is_identity = false; /* cache_set_linear computes this */
- if_debug3('c', "[c]icc_sample_proc 0x%lx base=%g, factor=%g:\n",
- (ulong) pcache, pcache->params.base, pcache->params.factor);
+ if_debug3m('c', imemory, "[c]icc_sample_proc 0x%lx base=%g, factor=%g:\n",
+ (ulong) pcache, pcache->params.base, pcache->params.factor);
if ((code = float_params(op, gx_cie_cache_size, &pcache->values[0])) < 0) {
/* We might have underflowed the current stack block. */
/* Handle the parameters one-by-one. */
@@ -946,9 +946,9 @@ cie_create_icc(i_ctx_t *i_ctx_p)
int i;
for (i = 0; i < gx_cie_cache_size; i += 4)
- dlprintf5("[c] icc_sample_proc[%3d]=%g, %g, %g, %g\n", i,
- pcache->values[i], pcache->values[i + 1],
- pcache->values[i + 2], pcache->values[i + 3]);
+ dmlprintf5(imemory, "[c] icc_sample_proc[%3d]=%g, %g, %g, %g\n", i,
+ pcache->values[i], pcache->values[i + 1],
+ pcache->values[i + 2], pcache->values[i + 3]);
}
#endif
ref_stack_pop(&o_stack, gx_cie_cache_size);
diff --git a/gs/psi/zcolor.c b/gs/psi/zcolor.c
index d9f317664..6de917cf7 100644
--- a/gs/psi/zcolor.c
+++ b/gs/psi/zcolor.c
@@ -818,13 +818,13 @@ zcolor_test_all(i_ctx_t *i_ctx_p)
cvbad[i] = 0;
}
- dprintf1("Number of components = %d\n", ncomp);
- dprintf1("Depth = %d\n", dev->color_info.depth);
- dprintf2("max_gray = %d dither_grays = %d\n",
- dev->color_info.max_gray, dev->color_info.dither_grays);
- dprintf2("max_color = %d dither_colors = %d\n",
- dev->color_info.max_color, dev->color_info.dither_colors);
- dprintf1("polarity = %s\n",
+ dmprintf1(dev->memory, "Number of components = %d\n", ncomp);
+ dmprintf1(dev->memory, "Depth = %d\n", dev->color_info.depth);
+ dmprintf2(dev->memory, "max_gray = %d dither_grays = %d\n",
+ dev->color_info.max_gray, dev->color_info.dither_grays);
+ dmprintf2(dev->memory, "max_color = %d dither_colors = %d\n",
+ dev->color_info.max_color, dev->color_info.dither_colors);
+ dmprintf1(dev->memory, "polarity = %s\n",
dev->color_info.polarity == GX_CINFO_POLARITY_ADDITIVE ? "Additive" :
dev->color_info.polarity == GX_CINFO_POLARITY_SUBTRACTIVE ?"Subtractive":
"Unknown");
@@ -833,23 +833,23 @@ zcolor_test_all(i_ctx_t *i_ctx_p)
cv[i] = 0;
color = (*dev_proc(dev, encode_color)) (dev, cv);
if (sizeof(color) <= sizeof(ulong))
- dprintf1("Zero color index: %8lx\n", (ulong)color);
+ dmprintf1(dev->memory, "Zero color index: %8lx\n", (ulong)color);
else
- dprintf2("Zero color index: %8lx%08lx\n",
+ dmprintf2(dev->memory, "Zero color index: %8lx%08lx\n",
(ulong)(color >> 8*(sizeof(color) - sizeof(ulong))), (ulong)color);
- dprintf1("separable_and_linear = %s\n",
+ dmprintf1(dev->memory, "separable_and_linear = %s\n",
linsep == GX_CINFO_SEP_LIN_NONE ? "No" :
linsep == GX_CINFO_SEP_LIN ? "Yes" :
"Unknown");
if (dev->color_info.gray_index == GX_CINFO_COMP_INDEX_UNKNOWN)
- dprintf("gray_index is unknown\n");
+ dmprintf(dev->memory, "gray_index is unknown\n");
else
- dprintf1("gray_index = %d\n", dev->color_info.gray_index);
+ dmprintf1(dev->memory, "gray_index = %d\n", dev->color_info.gray_index);
if (linsep) {
- dprintf(" Shift Mask Bits\n");
+ dmprintf(dev->memory, " Shift Mask Bits\n");
for (i = 0; i < ncomp; i++) {
- dprintf3(" %5d %8x %4d\n",
+ dmprintf3(dev->memory, " %5d %8x %4d\n",
(int)(dev->color_info.comp_shift[i]),
(int)(dev->color_info.comp_mask[i]),
(int)(dev->color_info.comp_bits[i]));
@@ -866,11 +866,11 @@ zcolor_test_all(i_ctx_t *i_ctx_p)
lscolor = gx_default_encode_color(dev, cv);
if ((color != lscolor) && (linsepfailed < 5)) {
linsepfailed++;
- dprintf("Failed separable_and_linear for");
+ dmprintf(dev->memory, "Failed separable_and_linear for");
for (i = 0; i < ncomp; i++)
- dprintf1(" %d", cv[i]);
- dprintf("\n");
- dprintf2("encode_color=%x gx_default_encode_color=%x\n",
+ dmprintf1(dev->memory, " %d", cv[i]);
+ dmprintf(dev->memory, "\n");
+ dmprintf2(dev->memory, "encode_color=%x gx_default_encode_color=%x\n",
(int)color, (int)lscolor);
}
}
@@ -913,13 +913,13 @@ zcolor_test_all(i_ctx_t *i_ctx_p)
finished = 1;
}
- dprintf2("Maximum error %g %s\n",
+ dmprintf2(dev->memory, "Maximum error %g %s\n",
(float)maxerror / (float)gx_max_color_value,
maxerror <= acceptable_error ? "is Ok" :
maxerror <= 3*acceptable_error/2 ? "is POOR" : "FAILED");
if (linsep)
- dprintf2("Maximum linear_and_separable error %g %s\n",
+ dmprintf2(dev->memory, "Maximum linear_and_separable error %g %s\n",
(float)lsmaxerror / (float)gx_max_color_value,
lsmaxerror <= acceptable_error ? "is Ok" :
lsmaxerror <= 3*acceptable_error/2 ? "is POOR" : "FAILED");
diff --git a/gs/psi/zcontext.c b/gs/psi/zcontext.c
index c459d149b..41dcd2dfb 100644
--- a/gs/psi/zcontext.c
+++ b/gs/psi/zcontext.c
@@ -1174,7 +1174,7 @@ context_create(gs_scheduler_t * psched, gs_context_t ** ppctx,
*pte = pctx;
*ppctx = pctx;
if (gs_debug_c('\'') | gs_debug_c('"'))
- dlprintf2("[']create %ld at 0x%lx\n", ctx_index, (ulong) pctx);
+ dmlprintf2(imemory, "[']create %ld at 0x%lx\n", ctx_index, (ulong) pctx);
return 0;
}
@@ -1214,8 +1214,9 @@ context_destroy(gs_context_t * pctx)
ppctx = &(*ppctx)->table_next;
*ppctx = (*ppctx)->table_next;
if (gs_debug_c('\'') | gs_debug_c('"'))
- dlprintf3("[']destroy %ld at 0x%lx, status = %d\n",
- pctx->index, (ulong) pctx, pctx->status);
+ dmlprintf3((const gs_memory_t *)mem,
+ "[']destroy %ld at 0x%lx, status = %d\n",
+ pctx->index, (ulong) pctx, pctx->status);
if (!context_state_free(&pctx->state))
gs_free_object((gs_memory_t *) mem, pctx, "context_destroy");
}
diff --git a/gs/psi/zdscpars.c b/gs/psi/zdscpars.c
index bc854692e..a6f8fc930 100644
--- a/gs/psi/zdscpars.c
+++ b/gs/psi/zdscpars.c
@@ -457,7 +457,7 @@ zparse_dsc_comments(i_ctx_t *i_ctx_p)
* location of the data area for the parser in our DSC dict.
*/
comment_code = dsc_scan_data(dsc_state->dsc_data_ptr, dsc_buffer, ssize + 1);
- if_debug1('%', "[%%].parse_dsc_comments: code = %d\n", comment_code);
+ if_debug1m('%', imemory, "[%%].parse_dsc_comments: code = %d\n", comment_code);
/*
* We ignore any errors from Russell's parser. The only value that
* it will return for an error is -1 so there is very little information.
diff --git a/gs/psi/zfapi.c b/gs/psi/zfapi.c
index 5cf98415b..d82c35713 100644
--- a/gs/psi/zfapi.c
+++ b/gs/psi/zfapi.c
@@ -2417,7 +2417,7 @@ retry_oversampling:
glyphn = ref_to_string(&char_name, imemory, "FAPI_do_char");
if (glyphn) {
- dprintf2(" Substituting .notdef for %s in the font %s \n", glyphn, pbfont->font_name.chars);
+ dmprintf2(imemory, " Substituting .notdef for %s in the font %s \n", glyphn, pbfont->font_name.chars);
gs_free_string(imemory, (byte *)glyphn, strlen(glyphn) + 1, "FAPI_do_char");
}
}
@@ -2960,17 +2960,17 @@ static int do_FAPIpassfont(i_ctx_t *i_ctx_p, char *font_file_path, bool *success
fapi_request = ref_to_string(&reqstr, imemory, "FAPI_do_char");
if (fapi_request) {
- dprintf1("Requested FAPI plugin: %s ", fapi_request);
+ dmprintf1(imemory, "Requested FAPI plugin: %s ", fapi_request);
while (h && (strncmp(h->I->d->type, "FAPI", 4) != 0 || strncmp(h->I->d->subtype, fapi_request, strlen(fapi_request)) != 0)) {
h = h->next;
}
if (!h) {
- dprintf("not found. Falling back to normal plugin search\n");
+ dmprintf(imemory, "not found. Falling back to normal plugin search\n");
h = i_plugin_get_list(i_ctx_p);
}
else {
- dprintf("found.\n");
+ dmprintf(imemory, "found.\n");
do_restart = true;
}
gs_free_string(imemory, (byte *)fapi_request, strlen(fapi_request) + 1, "do_FAPIpassfont");
@@ -3005,7 +3005,7 @@ static int do_FAPIpassfont(i_ctx_t *i_ctx_p, char *font_file_path, bool *success
/* renderer failed, continue search */
pbfont->FAPI = NULL;
if (do_restart == true) {
- dprintf1("Requested FAPI plugin %s failed, searching for alternative plugin\n", h->I->d->subtype);
+ dmprintf1(imemory, "Requested FAPI plugin %s failed, searching for alternative plugin\n", h->I->d->subtype);
h = i_plugin_get_list(i_ctx_p);
do_restart = false;
}
diff --git a/gs/psi/zfcid0.c b/gs/psi/zfcid0.c
index 68a4bdf6b..014aa59e7 100644
--- a/gs/psi/zfcid0.c
+++ b/gs/psi/zfcid0.c
@@ -545,7 +545,7 @@ ztype9mapcid(i_ctx_t *i_ctx_p)
if (code < 0) { /* failed to load glyph data, put CID 0 */
int default_fallback_CID = 0 ;
- if_debug2('J', "[J]ztype9cidmap() use CID %d instead of glyph-missing CID %d\n", default_fallback_CID, op->value.intval);
+ if_debug2m('J', imemory, "[J]ztype9cidmap() use CID %d instead of glyph-missing CID %d\n", default_fallback_CID, op->value.intval);
op->value.intval = default_fallback_CID;
@@ -556,7 +556,7 @@ ztype9mapcid(i_ctx_t *i_ctx_p)
&gdata, &fidx);
if (code < 0) {
- if_debug1('J', "[J]ztype9cidmap() could not load default glyph (CID %d)\n", op->value.intval);
+ if_debug1m('J', imemory, "[J]ztype9cidmap() could not load default glyph (CID %d)\n", op->value.intval);
return_error(e_invalidfont);
}
diff --git a/gs/psi/zfile.c b/gs/psi/zfile.c
index a7f94e3be..4011789ef 100644
--- a/gs/psi/zfile.c
+++ b/gs/psi/zfile.c
@@ -1088,7 +1088,7 @@ file_read_string(const byte *str, uint len, ref *pfile, gs_ref_memory_t *imem)
int
filter_report_error(stream_state * st, const char *str)
{
- if_debug1('s', "[s]stream error: %s\n", str);
+ if_debug1m('s', st->memory, "[s]stream error: %s\n", str);
strncpy(st->error_string, str, STREAM_MAX_ERROR_STRING);
/* Ensure null termination. */
st->error_string[STREAM_MAX_ERROR_STRING] = 0;
diff --git a/gs/psi/zfjbig2.c b/gs/psi/zfjbig2.c
index a87163a31..88add3ab5 100644
--- a/gs/psi/zfjbig2.c
+++ b/gs/psi/zfjbig2.c
@@ -105,7 +105,7 @@ z_jbig2makeglobalctx(i_ctx_t * i_ctx_p)
code = s_jbig2decode_make_global_data(data, size,
&global);
if (size > 0 && global == NULL) {
- dlprintf("failed to create parsed JBIG2GLOBALS object.");
+ dmlprintf(imemory, "failed to create parsed JBIG2GLOBALS object.");
return_error(e_unknownerror);
}
diff --git a/gs/psi/zfjpx.c b/gs/psi/zfjpx.c
index 3f20884af..937d84bac 100644
--- a/gs/psi/zfjpx.c
+++ b/gs/psi/zfjpx.c
@@ -76,7 +76,7 @@ z_jpx_decode(i_ctx_t * i_ctx_p)
/* use the name directly */
csname = sop;
} else {
- dprintf("warning: JPX ColorSpace value is an unhandled type!\n");
+ dmprintf(imemory, "warning: JPX ColorSpace value is an unhandled type!\n");
}
if (csname != NULL) {
ref sref;
@@ -114,8 +114,8 @@ z_jpx_decode(i_ctx_t * i_ctx_p)
/* else guess based on the number of components */
if (state.colorspace == gs_jpx_cs_unset &&
dict_find_string(csdict, "N", &nref) > 0) {
- if_debug1('w', "[w] JPX image has an external %d"
- " channel colorspace\n", nref->value.intval);
+ if_debug1m('w', imemory, "[w] JPX image has an external %d"
+ " channel colorspace\n", nref->value.intval);
switch (nref->value.intval) {
case 1: state.colorspace = gs_jpx_cs_gray;
break;
@@ -128,7 +128,7 @@ z_jpx_decode(i_ctx_t * i_ctx_p)
}
}
} else {
- if_debug0('w', "[w] Couldn't read JPX ColorSpace key!\n");
+ if_debug0m('w', imemory, "[w] Couldn't read JPX ColorSpace key!\n");
}
}
}
diff --git a/gs/psi/zicc.c b/gs/psi/zicc.c
index 6845892ee..cc30daccc 100644
--- a/gs/psi/zicc.c
+++ b/gs/psi/zicc.c
@@ -246,7 +246,7 @@ zset_outputintent(i_ctx_t * i_ctx_p)
check_type(*op, t_dictionary);
check_dict_read(*op);
- if_debug0(gs_debug_flag_icc,"[icc] Using OutputIntent\n");
+ if_debug0m(gs_debug_flag_icc, imemory, "[icc] Using OutputIntent\n");
/* Get the device structure */
code = dev_proc(dev, get_profile)(dev, &dev_profile);
@@ -340,7 +340,7 @@ zset_outputintent(i_ctx_t * i_ctx_p)
color management */
rc_assign(dev_profile->device_profile[0], picc_profile,
"zset_outputintent");
- if_debug0(gs_debug_flag_icc,"[icc] OutputIntent used for device profile\n");
+ if_debug0m(gs_debug_flag_icc, imemory, "[icc] OutputIntent used for device profile\n");
} else {
if (dev_profile->proof_profile == NULL) {
/* This means that we should use the OI profile as the proofing
@@ -350,7 +350,7 @@ zset_outputintent(i_ctx_t * i_ctx_p)
just for the source data below */
dev_profile->proof_profile = picc_profile;
rc_increment(picc_profile);
- if_debug0(gs_debug_flag_icc,"[icc] OutputIntent used for proof profile\n");
+ if_debug0m(gs_debug_flag_icc, imemory, "[icc] OutputIntent used for proof profile\n");
}
}
/* Now the source colors. See which source color space needs to use the
@@ -360,17 +360,17 @@ zset_outputintent(i_ctx_t * i_ctx_p)
/* source_profile is currently the default. Set it to the OI profile */
switch (picc_profile->data_cs) {
case gsGRAY:
- if_debug0(gs_debug_flag_icc,"[icc] OutputIntent used source Gray\n");
+ if_debug0m(gs_debug_flag_icc, imemory, "[icc] OutputIntent used source Gray\n");
rc_assign(icc_manager->default_gray, picc_profile,
"zset_outputintent");
break;
case gsRGB:
- if_debug0(gs_debug_flag_icc,"[icc] OutputIntent used source RGB\n");
+ if_debug0m(gs_debug_flag_icc, imemory, "[icc] OutputIntent used source RGB\n");
rc_assign(icc_manager->default_rgb, picc_profile,
"zset_outputintent");
break;
case gsCMYK:
- if_debug0(gs_debug_flag_icc,"[icc] OutputIntent used source CMYK\n");
+ if_debug0m(gs_debug_flag_icc, imemory, "[icc] OutputIntent used source CMYK\n");
rc_assign(icc_manager->default_cmyk, picc_profile,
"zset_outputintent");
break;
diff --git a/gs/psi/zpcolor.c b/gs/psi/zpcolor.c
index 490f9f1c2..546e6ccdc 100644
--- a/gs/psi/zpcolor.c
+++ b/gs/psi/zpcolor.c
@@ -242,7 +242,7 @@ pattern_paint_prepare(i_ctx_t *i_ctx_p)
if (internal_accum) {
gs_setdevice_no_init(pgs, (gx_device *)pdev);
if (pinst->templat.uses_transparency) {
- if_debug0('v', " pushing the pdf14 compositor device into this graphics state\n");
+ if_debug0m('v', imemory, " pushing the pdf14 compositor device into this graphics state\n");
if ((code = gs_push_pdf14trans_device(pgs, true)) < 0)
return code;
} else { /* not transparent */
@@ -329,7 +329,7 @@ pattern_paint_finish(i_ctx_t *i_ctx_p)
}
if (o_stack_adjust > 0) {
#if 0
- dlprintf1("PaintProc left %d extra on operator stack!\n", o_stack_adjust);
+ dmlprintf1(imemory, "PaintProc left %d extra on operator stack!\n", o_stack_adjust);
#endif
pop(o_stack_adjust);
}
diff --git a/gs/psi/zvmem.c b/gs/psi/zvmem.c
index 32f938108..4ad8f9a20 100644
--- a/gs/psi/zvmem.c
+++ b/gs/psi/zvmem.c
@@ -84,8 +84,8 @@ zsave(i_ctx_t *i_ctx_p)
ifree_object(vmsave, "zsave");
return_error(e_VMerror);
}
- if_debug2('u', "[u]vmsave 0x%lx, id = %lu\n",
- (ulong) vmsave, (ulong) sid);
+ if_debug2m('u', imemory, "[u]vmsave 0x%lx, id = %lu\n",
+ (ulong) vmsave, (ulong) sid);
code = gs_gsave_for_save(igs, &prev);
if (code < 0)
return code;
@@ -115,9 +115,9 @@ zrestore(i_ctx_t *i_ctx_p)
if (code < 0)
return code;
- if_debug2('u', "[u]vmrestore 0x%lx, id = %lu\n",
- (ulong) alloc_save_client_data(asave),
- (ulong) op->value.saveid);
+ if_debug2m('u', imemory, "[u]vmrestore 0x%lx, id = %lu\n",
+ (ulong) alloc_save_client_data(asave),
+ (ulong) op->value.saveid);
if (I_VALIDATE_BEFORE_RESTORE)
ivalidate_clean_spaces(i_ctx_p);
/* Check the contents of the stacks. */
diff --git a/pcl/pccid.c b/pcl/pccid.c
index a770f96ce..a05e694a3 100644
--- a/pcl/pccid.c
+++ b/pcl/pccid.c
@@ -72,13 +72,13 @@ static const char * const pcl_encnames[] = {
};
const char *
-pcl_cid_cspace_get_debug_name(int index)
+pcl_cid_cspace_get_debug_name(const gs_memory_t *mem, int index)
{
if (index == -1)
return WHITE_CS;
if (index < 0 || index >= countof(pcl_csnames)) {
- dprintf("index out of range\n");
+ dmprintf(mem, "index out of range\n");
return pcl_csnames[0];
} else {
return pcl_csnames[index];
@@ -86,10 +86,10 @@ pcl_cid_cspace_get_debug_name(int index)
}
const char *
-pcl_cid_enc_get_debug_name(int index)
+pcl_cid_enc_get_debug_name(const gs_memory_t *mem, int index)
{
if (index < 0 || index >= countof(pcl_encnames)) {
- dprintf("index out of range\n");
+ dmprintf(mem, "index out of range\n");
return pcl_encnames[0];
} else {
return pcl_encnames[index];
@@ -299,7 +299,7 @@ check_cid_hdr(
if (pcidh->bits_per_primary[i] == 0)
pcidh->bits_per_primary[i] = 8;
if ( pcs->personality == pcl5e && pcidh->bits_per_primary[i] != 1 )
- dprintf("pcl5e personality with color primaries\n" );
+ dmprintf(pcs->memory, "pcl5e personality with color primaries\n" );
}
switch (pcidh->encoding) {
@@ -429,20 +429,16 @@ install_cid_data(
cid.len = len;
memcpy(&(cid.u.hdr), pbuff, sizeof(pcl_cid_hdr_t));
-#ifdef DEBUG
- if_debug2('c', "[c] cid before check color space: %s encoding: %s\n",
- pcl_cid_cspace_get_debug_name(pcl_cid_get_cspace(&cid)),
- pcl_cid_enc_get_debug_name(pcl_cid_get_encoding(&cid)));
-#endif
+ if_debug2m('c', pcs->memory, "[c] cid before check color space: %s encoding: %s\n",
+ pcl_cid_cspace_get_debug_name(pcs->memory, pcl_cid_get_cspace(&cid)),
+ pcl_cid_enc_get_debug_name(pcs->memory, pcl_cid_get_encoding(&cid)));
/* check the header this will also make corrections if possible */
code = check_cid_hdr(pcs, &cid);
-#ifdef DEBUG
- if_debug2('c', "[c] cid after check color space: %s encoding: %s\n",
- pcl_cid_cspace_get_debug_name(pcl_cid_get_cspace(&cid)),
- pcl_cid_enc_get_debug_name(pcl_cid_get_encoding(&cid)));
-#endif
+ if_debug2m('c', pcs->memory, "[c] cid after check color space: %s encoding: %s\n",
+ pcl_cid_cspace_get_debug_name(pcs->memory, pcl_cid_get_cspace(&cid)),
+ pcl_cid_enc_get_debug_name(pcs->memory, pcl_cid_get_encoding(&cid)));
if (code >= 0) {
/* check if we should substitute colometric for a device color space */
diff --git a/pcl/pccid.h b/pcl/pccid.h
index afce467b7..59193280f 100644
--- a/pcl/pccid.h
+++ b/pcl/pccid.h
@@ -173,8 +173,8 @@ extern const pcl_init_t pcl_cid_init;
*/
#ifdef DEBUG
-const char *pcl_cid_cspace_get_debug_name(int index);
-const char *pcl_cid_enc_get_debug_name(int index);
+const char *pcl_cid_cspace_get_debug_name(const gs_memory_t *mem, int index);
+const char *pcl_cid_enc_get_debug_name(const gs_memory_t *mem, int index);
#endif
#endif /* pccid_INCLUDED */
diff --git a/pcl/pccsbase.c b/pcl/pccsbase.c
index b8be4a8db..e0bce74f1 100644
--- a/pcl/pccsbase.c
+++ b/pcl/pccsbase.c
@@ -1055,10 +1055,8 @@ pcl_cs_base_build_cspace(
/* release the existing color space, if present */
if (pbase != 0) {
-#ifdef DEBUG
- if_debug1('c', "[c]releasing color space:%s\n",
- pcl_cid_cspace_get_debug_name(pbase->type));
-#endif
+ if_debug1m('c', pmem, "[c]releasing color space:%s\n",
+ pcl_cid_cspace_get_debug_name(pmem, pbase->type));
rc_decrement(pbase, "build base pcl color space");
}
/* build basic structure and client info. structure */
diff --git a/pcl/pcfont.c b/pcl/pcfont.c
index 07ddc6c7c..ea4373b5a 100644
--- a/pcl/pcfont.c
+++ b/pcl/pcfont.c
@@ -543,7 +543,7 @@ pcl_set_current_font_environment(pcl_state_t *pcs)
pcl_data_storage = pcds_all_simms;
break;
default:
- dprintf("pcfont.c: unknown pjl resource\n");
+ dmprintf(pcs->memory, "pcfont.c: unknown pjl resource\n");
return -1;
}
{
@@ -614,7 +614,7 @@ pcl_unload_resident_fonts(pcl_state_t *pcs)
pl_font_t *plfont = (pl_font_t *)value;
if ( plfont->font_file )
if ( pl_store_resident_font_data_in_file(plfont->font_file, pcs->memory, plfont) < 0 )
- dprintf1("%s", "could not store data" );
+ dmprintf1(pcs->memory, "%s", "could not store data" );
}
}
diff --git a/pcl/pcfsel.c b/pcl/pcfsel.c
index 63bd74d8c..db82db1f3 100644
--- a/pcl/pcfsel.c
+++ b/pcl/pcfsel.c
@@ -65,23 +65,25 @@ static const char * const score_name[] = {
};
static void
-dprint_cc(const byte *pcc)
-{ dprintf8("cc=%02x %02x %02x %02x %02x %02x %02x %02x", pcc[0],
- pcc[1], pcc[2], pcc[3], pcc[4], pcc[5], pcc[6], pcc[7]);
+dmprint_cc(const gs_memory_t *mem, const byte *pcc)
+{
+ dmprintf8(mem, "cc=%02x %02x %02x %02x %02x %02x %02x %02x", pcc[0],
+ pcc[1], pcc[2], pcc[3], pcc[4], pcc[5], pcc[6], pcc[7]);
}
void
-dprint_font_params_t(const pl_font_params_t *pfp)
-{ dprintf8("symset=%u %s pitch=%g ht=%u style=%u wt=%d face=%u:%u\n",
- pfp->symbol_set,
- (pfp->proportional_spacing ? "prop." : "fixed"),
- pl_fp_pitch_cp(pfp) / 100.0, pfp->height_4ths / 4, pfp->style,
- pfp->stroke_weight, pfp->typeface_family, (0x07FF &pfp->typeface_family) );
+dmprint_font_params_t(const gs_memory_t *mem, const pl_font_params_t *pfp)
+{
+ dmprintf8(mem, "symset=%u %s pitch=%g ht=%u style=%u wt=%d face=%u:%u\n",
+ pfp->symbol_set,
+ (pfp->proportional_spacing ? "prop." : "fixed"),
+ pl_fp_pitch_cp(pfp) / 100.0, pfp->height_4ths / 4, pfp->style,
+ pfp->stroke_weight, pfp->typeface_family, (0x07FF &pfp->typeface_family) );
}
#include "plftable.h"
static void
-dprint_font_name(const pl_font_t *pfont)
+dmprint_font_name(const gs_memory_t *mem, const pl_font_t *pfont)
{
int i;
bool found = false;
@@ -95,49 +97,49 @@ dprint_font_name(const pl_font_t *pfont)
}
}
if (found) {
- dprintf1("%s ", resident_table[i].full_font_name);
+ dmprintf1(mem, "%s ", resident_table[i].full_font_name);
} else {
if (pfont->storage == pcds_internal) {
- dprintf("internal font not found in resident table");
- dprintf1("%s\n", pfont->font_file);
+ dmprintf(mem, "internal font not found in resident table");
+ dmprintf1(mem, "%s\n", pfont->font_file);
}
- dprintf("external font ");
+ dmprintf(mem, "external font ");
}
}
static void
-dprint_font_t(const pl_font_t *pfont)
+dmprint_font_t(const gs_memory_t *mem, const pl_font_t *pfont)
{
- dprint_font_name(pfont);
- dprintf3("storage=%d scaling=%d type=%d ",
- pfont->storage, pfont->scaling_technology, pfont->font_type);
- dprint_cc(pfont->character_complement);
- dputs(";\n ");
- dprint_font_params_t(&pfont->params);
+ dmprint_font_name(mem, pfont);
+ dmprintf3(mem, "storage=%d scaling=%d type=%d ",
+ pfont->storage, pfont->scaling_technology, pfont->font_type);
+ dmprint_cc(mem, pfont->character_complement);
+ dmputs(mem, ";\n ");
+ dmprint_font_params_t(mem, &pfont->params);
}
static void
-dprint_font_map(const pl_symbol_map_t *pmap)
+dmprint_font_map(const gs_memory_t *mem, const pl_symbol_map_t *pmap)
{
if (pmap != 0)
- dprintf3("selected symbol set id:%d type:%d format:%s\n", pl_get_uint16(pmap->id),
- pmap->type, (pmap->format == 1 ? "MSL" : "Unicode"));
+ dmprintf3(mem, "selected symbol set id:%d type:%d format:%s\n", pl_get_uint16(pmap->id),
+ pmap->type, (pmap->format == 1 ? "MSL" : "Unicode"));
else
- dprintf("selected symbol set NULL\n");
+ dmprintf(mem, "selected symbol set NULL\n");
}
static void
-dprintf_font_scoring(const char *type, const pl_font_t *pfont, pl_symbol_map_t *pmap, match_score_t score)
+dmprintf_font_scoring(const gs_memory_t *mem, const char *type, const pl_font_t *pfont, pl_symbol_map_t *pmap, match_score_t score)
{
int i;
- dprintf1("%s: ", type);
- dprint_font_t(pfont);
- dprint_font_map(pmap);
- dputs(" score:");
+ dmprintf1(mem, "%s: ", type);
+ dmprint_font_t(mem, pfont);
+ dmprint_font_map(mem, pmap);
+ dmputs(mem, " score:");
for ( i = 0; i < score_limit; ++i )
- dprintf2(" %s: %d", score_name[i], score[i]);
- dputs("\n");
+ dmprintf2(mem, " %s: %d", score_name[i], score[i]);
+ dmputs(mem, "\n");
}
#endif
@@ -359,7 +361,7 @@ score_match(const pcl_state_t *pcs, const pcl_font_selection_t *pfs,
#ifdef DEBUG
if ( gs_debug_c('=') )
- dprintf_font_scoring("candidate", fp, *mapp, score);
+ dmprintf_font_scoring(pcs->memory, "candidate", fp, *mapp, score);
#endif
}
@@ -380,8 +382,8 @@ pcl_reselect_font(pcl_font_selection_t *pfs, const pcl_state_t *pcs, bool intern
#ifdef DEBUG
if ( gs_debug_c('=') )
- { dputs("[=]request: ");
- dprint_font_params_t(&pfs->params);
+ { dmputs(pcs->memory, "[=]request: ");
+ dmprint_font_params_t(pcs->memory, &pfs->params);
}
#endif
/* if the font table is set up to select character by id
@@ -415,7 +417,7 @@ pcl_reselect_font(pcl_font_selection_t *pfs, const pcl_state_t *pcs, bool intern
#ifdef DEBUG
if ( gs_debug_c('=') ) {
if (best_match[0] != -1) /* skip sentinel */
- dprintf_font_scoring("best", best_font, mapp, best_match);
+ dmprintf_font_scoring(pcs->memory, "best", best_font, mapp, best_match);
}
#endif
for (i=(score_index_t)0; i<score_limit; i++)
@@ -429,8 +431,8 @@ pcl_reselect_font(pcl_font_selection_t *pfs, const pcl_state_t *pcs, bool intern
sizeof(match));
#ifdef DEBUG
if ( gs_debug_c('=') ) {
- dprintf_font_scoring("usurper", fp, mapp, best_match);
- dprintf1(" better %s***)\n", score_name[i]);
+ dmprintf_font_scoring(pcs->memory, "usurper", fp, mapp, best_match);
+ dmprintf1(pcs->memory, " better %s***)\n", score_name[i]);
}
#endif
@@ -443,7 +445,7 @@ pcl_reselect_font(pcl_font_selection_t *pfs, const pcl_state_t *pcs, bool intern
return gs_throw_code(gs_error_Fatal);
#ifdef DEBUG
if ( gs_debug_c('=') ) {
- dprintf_font_scoring("champion", best_font, mapp, best_match);
+ dmprintf_font_scoring(pcs->memory, "champion", best_font, mapp, best_match);
}
#endif
diff --git a/pcl/pcindxed.c b/pcl/pcindxed.c
index 373bde9ba..abdece63b 100644
--- a/pcl/pcindxed.c
+++ b/pcl/pcindxed.c
@@ -113,9 +113,7 @@ alloc_indexed_cspace(
uint palette_size = 3 * num_entries;
int i;
-#ifdef DEBUG
- if_debug1('c', "[c]alloc_indexed_cspace entries:%d\n", num_entries);
-#endif
+ if_debug1m('c', pmem, "[c]alloc_indexed_cspace entries:%d\n", num_entries);
rc_alloc_struct_1( pindexed,
pcl_cs_indexed_t,
@@ -174,10 +172,9 @@ resize_indexed_cspace(
uint new_size = num_entries * 3;
int i;
uint num_old_entries;
-#ifdef DEBUG
- if_debug2('c', "[c]resizing_indexed_cspace new:%d old:%d\n",
- num_entries, pindexed->num_entries);
-#endif
+
+ if_debug2m('c', pmem, "[c]resizing_indexed_cspace new:%d old:%d\n",
+ num_entries, pindexed->num_entries);
pdata = gs_resize_string(pmem, pindexed->palette.data, pindexed->palette.size, new_size,
"resize pcl indexed color space");
@@ -737,9 +734,7 @@ pcl_cs_indexed_set_num_entries(
pindexed->is_GL = gl2;
-#ifdef DEBUG
- if_debug3('c', "pcl_cs_indexed_set_num_entries, is gl2:%d, entries old:%d, new:%d\n", gl2, old_num, new_num);
-#endif
+ if_debug3m('c', pindexed->rc.memory, "pcl_cs_indexed_set_num_entries, is gl2:%d, entries old:%d, new:%d\n", gl2, old_num, new_num);
/*
* Set new_num to the smallest larger power of 2 less than
@@ -991,9 +986,7 @@ pcl_cs_indexed_build_cspace(
if (pfixed && (pcid->u.hdr.bits_per_index == dflt_cid_hdr.bits_per_index)) {
is_default = true;
if (pcs->pdflt_cs_indexed != 0) {
-#ifdef DEBUG
- if_debug0('c', "[c]build request for default color space\n");
-#endif
+ if_debug0m('c', pmem, "[c]build request for default color space\n");
pcl_cs_indexed_copy_from(*ppindexed, pcs->pdflt_cs_indexed);
return 0;
}
@@ -1001,10 +994,8 @@ pcl_cs_indexed_build_cspace(
/* release the existing color space, if present */
if (pindexed != 0) {
-#ifdef DEBUG
- if_debug1('c', "[c]releasing index for underlying color space:%s\n",
- pcl_cid_cspace_get_debug_name(pindexed->pbase->type));
-#endif
+ if_debug1m('c', pmem, "[c]releasing index for underlying color space:%s\n",
+ pcl_cid_cspace_get_debug_name(pmem, pindexed->pbase->type));
rc_decrement(pindexed, "build indexed color space");
}
@@ -1019,11 +1010,8 @@ pcl_cs_indexed_build_cspace(
}
pindexed = *ppindexed;
-#ifdef DEBUG
- if_debug1('c', "[c]built base and index for color space:%s\n",
- pcl_cid_cspace_get_debug_name(pindexed->pbase->type));
-
-#endif
+ if_debug1m('c', pmem, "[c]built base and index for color space:%s\n",
+ pcl_cid_cspace_get_debug_name(pmem, pindexed->pbase->type));
/* release our extra reference of the base color space */
pcl_cs_base_release(pbase);
diff --git a/pcl/pcmacros.c b/pcl/pcmacros.c
index 7b566e08a..8fe410aab 100644
--- a/pcl/pcmacros.c
+++ b/pcl/pcmacros.c
@@ -29,10 +29,10 @@ static void
pcl_dump_current_macro(pcl_state_t *pcs, const char *msg)
{
int i;
- dputs(msg); dputs(" ");
+ dmputs(pcs->memory, msg); dmputs(pcs->memory, " ");
for (i=0; i < current_macro_id_size; i++)
- dprintf1("%02x", current_macro_id[i]);
- dputs("\n");
+ dmprintf1(pcs->memory, "%02x", current_macro_id[i]);
+ dmputs(pcs->memory, "\n");
return;
}
#endif
diff --git a/pcl/pcpage.c b/pcl/pcpage.c
index 5eae64ad3..629114456 100644
--- a/pcl/pcpage.c
+++ b/pcl/pcpage.c
@@ -517,12 +517,12 @@ pcl_mark_page_for_current_pos(pcl_state_t *pcs)
page_bbox_float.q.y = fixed2float(page_bbox_fixed.q.y);
if ( gs_currentpoint(pcs->pgs, &current_pt) < 0 ) {
- dprintf("Not expected to fail\n" );
+ dmprintf(pcs->memory, "Not expected to fail\n" );
return;
}
if ( gs_transform(pcs->pgs, current_pt.x, current_pt.y, &dev_pt) ) {
- dprintf("Not expected to fail\n" );
+ dmprintf(pcs->memory, "Not expected to fail\n" );
return;
}
@@ -1282,7 +1282,7 @@ pcl_get_default_paper(
pcs->wide_a4 = true;
return &(PAPER_SIZES[i].psize);
}
- dprintf("system does not support requested paper setting\n");
+ dmprintf(pcs->memory, "system does not support requested paper setting\n");
return &(PAPER_SIZES[1].psize);
}
diff --git a/pcl/pcparse.c b/pcl/pcparse.c
index a2d50d724..a4f47cd1f 100644
--- a/pcl/pcparse.c
+++ b/pcl/pcparse.c
@@ -312,9 +312,9 @@ pcl_process(pcl_parser_state_t * pst, pcl_state_t * pcs,
#ifdef DEBUG
if (gs_debug_c('i')) {
int i;
- dprintf("Scanned Data:\n");
+ dmprintf(pcs->memory,"Scanned Data:\n");
for (i=0; i<count; i++) {
- dprintf2("%02x%c", pst->args.data[i],
+ dmprintf2(pcs->memory, "%02x%c", pst->args.data[i],
(i % 16 == 15 || i == count - 1) ?
'\n' : ' ');
}
@@ -401,18 +401,18 @@ pcl_process(pcl_parser_state_t * pst, pcl_state_t * pcs,
}
#ifdef DEBUG
if (gs_debug_c('i')) {
- dprintf2("(ESC %c %c)",
- pst->param_class, pst->param_group);
+ dmprintf2(pcs->memory, "(ESC %c %c)",
+ pst->param_class, pst->param_group);
if (value_is_present(&avalue)) {
- dputc(' ');
+ dmputc(pcs->memory, ' ');
if (value_is_signed(&avalue))
- dputc((value_is_neg(&avalue) ? '-' : '+'));
+ dmputc(pcs->memory, (value_is_neg(&avalue) ? '-' : '+'));
if (value_is_float(&avalue))
- dprintf1("%g", avalue.i + avalue.fraction);
+ dmprintf1(pcs->memory, "%g", avalue.i + avalue.fraction);
else
- dprintf1("%u", avalue.i);
+ dmprintf1(pcs->memory, "%u", avalue.i);
}
- dprintf1(" %c\n", chr);
+ dmprintf1(pcs->memory, " %c\n", chr);
}
#endif
if (chr >= min_escape_command + 32 &&
@@ -432,7 +432,7 @@ pcl_process(pcl_parser_state_t * pst, pcl_state_t * pcs,
pst->param_class,
pst->param_group, chr);
if (cdefn) {
- if_debug1('i', " [%s]\n", cdefn->cname);
+ if_debug1m('i', pcs->memory, " [%s]\n", cdefn->cname);
code = pcl_adjust_arg(&pst->args, cdefn);
if (code < 0)
goto x;
@@ -486,7 +486,7 @@ pcl_process(pcl_parser_state_t * pst, pcl_state_t * pcs,
--p;
goto x;
}
- if_debug2('i', "%x%x\n", p[0], p[1]);
+ if_debug2m('i', pcs->memory, "%x%x\n", p[0], p[1]);
code = pcl_text(p, bytelen, pcs, false);
if (code < 0)
goto x;
@@ -494,10 +494,10 @@ pcl_process(pcl_parser_state_t * pst, pcl_state_t * pcs,
p += (bytelen - 1);
cdefn = NULL;
} else if (chr != ESC) {
- if_debug1('i',
- (chr == '\\' ? "\\%c\n" :
- chr >= 33 && chr <= 126 ?
- "%c\n" : "\\%03o\n"), chr);
+ if_debug1m('i', pcs->memory,
+ (chr == '\\' ? "\\%c\n" :
+ chr >= 33 && chr <= 126 ?
+ "%c\n" : "\\%03o\n"), chr);
cdefn = pst->definitions->pcl_command_list
[chr < 33 ?
pst->definitions->pcl_control_command_indices[chr] :
@@ -510,11 +510,11 @@ pcl_process(pcl_parser_state_t * pst, pcl_state_t * pcs,
const byte *str = p;
while (p < rlimit && p[1] >= 32 && p[1] <= 127) {
- if_debug1('i', "%c", p[1]);
+ if_debug1m('i', pcs->memory, "%c", p[1]);
++p;
}
- if_debug0('i', "\n");
+ if_debug0m('i', pcs->memory, "\n");
code = pcl_text(str, (uint) (p + 1 - str),
pcs, false);
if (code < 0)
@@ -528,9 +528,9 @@ pcl_process(pcl_parser_state_t * pst, pcl_state_t * pcs,
}
chr = *++p;
if (chr < min_escape_class || chr > max_escape_class) {
- if_debug1('i',
- (chr >= 33 && chr <= 126 ?
- "ESC %c\n" : "ESC \\%03o\n"), chr);
+ if_debug1m('i', pcs->memory,
+ (chr >= 33 && chr <= 126 ?
+ "ESC %c\n" : "ESC \\%03o\n"), chr);
cdefn = pcl_get_command_definition(pst, 0, 0, chr);
if (!cdefn) {
/* Skip the ESC, back up
@@ -539,7 +539,7 @@ pcl_process(pcl_parser_state_t * pst, pcl_state_t * pcs,
--p;
continue;
}
- if_debug1('i', " [%s]\n", cdefn->cname);
+ if_debug1m('i', pcs->memory, " [%s]\n", cdefn->cname);
} else {
if (p >= rlimit) {
p -= 2;
@@ -552,7 +552,7 @@ pcl_process(pcl_parser_state_t * pst, pcl_state_t * pcs,
chr = 0;
}
pst->param_group = chr;
- if_debug2('i', "ESC %c %c\n", pst->param_class, chr);
+ if_debug2m('i', pcs->memory, "ESC %c %c\n", pst->param_class, chr);
pst->scan_type = scanning_parameter;
param_init();
continue;
@@ -594,7 +594,7 @@ pcl_process(pcl_parser_state_t * pst, pcl_state_t * pcs,
}
if (code == e_Unimplemented) {
#if e_Unimplemented != 0
- if_debug0('i', "Unimplemented\n");
+ if_debug0m('i', pcs->memory, "Unimplemented\n");
#endif
} else if (code < 0)
break;
diff --git a/pcl/pcpatrn.c b/pcl/pcpatrn.c
index ecdf6eb5e..6a24482aa 100644
--- a/pcl/pcpatrn.c
+++ b/pcl/pcpatrn.c
@@ -187,10 +187,8 @@ set_unpatterned_color(
int code = 0;
pcl_ccolor_type_t type;
-#ifdef DEBUG
- if_debug3('c', "[c]set unpatterned color %f %f %f\n", ppaint->values[0],
+ if_debug3m('c', pcs->memory, "[c]set unpatterned color %f %f %f\n", ppaint->values[0],
ppaint->values[1], ppaint->values[2]);
-#endif
if ( pcur != 0 )
type = pcur->type;
@@ -826,9 +824,7 @@ pattern_set_white(
pcl_cs_base_t * pwhite_cs = 0;
pcl_ht_t * pdflt_ht = 0;
-#ifdef DEBUG
- if_debug0('c', "[c]pattern_set_white\n");
-#endif
+ if_debug0m('c', pcs->memory, "[c]pattern_set_white\n");
/* build the pure white color space and default halftone if necessary */
if ((code = pcl_cs_base_build_white_cspace(pcs, &pwhite_cs, pcs->memory)) >= 0)
@@ -863,10 +859,8 @@ pattern_set_pen(
int num_entries = pindexed->num_entries;
int code = 0;
-#ifdef DEBUG
- if_debug3('c', "[c]pattern_set_pen pen=%d, for raster=%d entries=%d\n",
+ if_debug3m('c', pcs->memory, "[c]pattern_set_pen pen=%d, for raster=%d entries=%d\n",
pen, for_pcl_raster, num_entries);
-#endif
/* put the pen number in the proper range */
if ( (pen >= num_entries) &&
@@ -908,9 +902,7 @@ pattern_set_frgrnd(
pcl_palette_t * ppalet = pcs->ppalet;
int code = 0;
-#ifdef DEBUG
- if_debug1('c', "[c]pattern_set_frgrnd for image=%d\n", for_image);
-#endif
+ if_debug1m('c', pcs->memory, "[c]pattern_set_frgrnd for image=%d\n", for_image);
/* check if a solid pattern should be substituted */
if ( for_image ) {
@@ -950,10 +942,8 @@ pattern_set_shade_pcl(
{
pcl_pattern_t * pptrn = pcl_pattern_get_shade(pcs, inten);
-#ifdef DEBUG
- if_debug2('c', "[c]pattern_set_shade_pcl intensity=%d, for raster=%d\n",
- inten, for_image);
-#endif
+ if_debug2m('c', pcs->memory, "[c]pattern_set_shade_pcl intensity=%d, for raster=%d\n",
+ inten, for_image);
if (pptrn == 0)
return ( inten > 0 ? pattern_set_frgrnd(pcs, 0, for_image)
: pattern_set_white(pcs, 0, 0) );
@@ -975,10 +965,8 @@ pattern_set_shade_gl(
{
pcl_pattern_t * pptrn = pcl_pattern_get_shade(pcs, inten);
-#ifdef DEBUG
- if_debug2('c', "[c]pattern_set_shade_gl intensity=%d, pen=%d\n",
- inten, pen);
-#endif
+ if_debug2m('c', pcs->memory, "[c]pattern_set_shade_gl intensity=%d, pen=%d\n",
+ inten, pen);
/* check if the current pen is white or the pattern is transparent
and the intensity is 0 (white) and if so use the unsolid
@@ -1003,10 +991,8 @@ pattern_set_hatch_pcl(
{
pcl_pattern_t * pptrn = pcl_pattern_get_cross(pcs, indx);
-#ifdef DEBUG
- if_debug2('c', "[c]pattern_set_hatch_pcl index=%d, for raster=%d\n",
- indx, for_image);
-#endif
+ if_debug2m('c', pcs->memory, "[c]pattern_set_hatch_pcl index=%d, for raster=%d\n",
+ indx, for_image);
if (pptrn == 0)
return pattern_set_frgrnd(pcs, 0, for_image);
@@ -1028,9 +1014,7 @@ pattern_set_hatch_gl(
{
pcl_pattern_t * pptrn = pcl_pattern_get_cross(pcs, indx);
-#ifdef DEBUG
- if_debug2('c', "[c]pattern_set_hatch_gl index=%d pen=%d\n", indx, pen);
-#endif
+ if_debug2m('c', pcs->memory, "[c]pattern_set_hatch_gl index=%d pen=%d\n", indx, pen);
/* check if the current pen is white; if so, use the "unsolid" pattern */
if (pcl_cs_indexed_is_white(pcs->ppalet->pindexed, pen))
pptrn = pcl_pattern_get_unsolid_pattern(pcs);
@@ -1050,9 +1034,7 @@ pattern_set_user_pcl(
{
pcl_pattern_t * pptrn = pcl_pattern_get_pcl_uptrn(pcs, id);
-#ifdef DEBUG
- if_debug2('c', "[c]pattern_set_user_pcl id=%d raster=%d\n", id, for_image);
-#endif
+ if_debug2m('c', pcs->memory, "[c]pattern_set_user_pcl id=%d raster=%d\n", id, for_image);
if (pptrn == 0)
return pattern_set_frgrnd(pcs, 0, for_image);
@@ -1075,9 +1057,7 @@ pattern_set_user_gl(
{
pcl_pattern_t * pptrn = pcl_pattern_get_pcl_uptrn(pcs, id);
-#ifdef DEBUG
- if_debug2('c', "[c]pattern_set_user_gl id=%d, pen=%d\n", id, pen);
-#endif
+ if_debug2m('c', pcs->memory, "[c]pattern_set_user_gl id=%d, pen=%d\n", id, pen);
if (pptrn == 0)
return pattern_set_pen(pcs, 0, false);
@@ -1105,9 +1085,7 @@ pattern_set_gl_RF(
{
pcl_pattern_t * pptrn = pcl_pattern_get_gl_uptrn(pcs, indx);
-#ifdef DEBUG
- if_debug2('c', "[c]pattern_set_gl_RF index=%d pen=%d\n", indx, pen);
-#endif
+ if_debug2m('c', pcs->memory, "[c]pattern_set_gl_RF index=%d pen=%d\n", indx, pen);
/*
* HACK - if pen 1 is to be use for actual uncolored RF patterns, the pen
* operand will be the opposite of the current pen number. This allows us
@@ -1308,7 +1286,7 @@ set_driver_configuration(
if ( ( driver->device_id < 6 ) /* 6 == hp color laserjet */
|| /* 7 == hp clj 5 */
( driver->device_id > 8 ) ) /* 8 == hp 4500 - 4550 */ {
- dprintf1("unknown device id %d\n", driver->device_id );
+ dmprintf1(pcs->memory, "unknown device id %d\n", driver->device_id );
return e_Range;
}
diff --git a/pcl/pcsfont.c b/pcl/pcsfont.c
index c8d1ff6dd..218359859 100644
--- a/pcl/pcsfont.c
+++ b/pcl/pcsfont.c
@@ -200,7 +200,7 @@ pcl_font_control(pcl_args_t *pargs, pcl_state_t *pcs)
pcs->memory,
"pcl_font_control()");
if ( plfont == 0 ) {
- dprintf("pcsfont.c clone font FIXME\n");
+ dmprintf(pcs->memory, "pcsfont.c clone font FIXME\n");
return 0;
}
code = gs_definefont(pcs->font_dir, plfont->pfont);
@@ -281,7 +281,7 @@ pcl_font_header(pcl_args_t *pargs, pcl_state_t *pcs)
}
if (sum != 0) {
- dprintf1("corrupt font sum=%ld\n", sum);
+ dmprintf1(pcs->memory, "corrupt font sum=%ld\n", sum);
return e_Range;
}
}
@@ -483,7 +483,7 @@ pcl_character_data(pcl_args_t *pargs, pcl_state_t *pcs)
characters for now, since we don't have real world
examples for the other font file formats. */
if ( data[0] != pccd_bitmap && data[3] != 1 ) {
- dprintf("continuation not implemented for this font type\n");
+ dmprintf(pcs->memory, "continuation not implemented for this font type\n");
return e_Unimplemented;
}
/* append the new data to the new object */
diff --git a/pcl/pcsymbol.c b/pcl/pcsymbol.c
index 3b7a0f9f0..a59f524e2 100644
--- a/pcl/pcsymbol.c
+++ b/pcl/pcsymbol.c
@@ -39,20 +39,20 @@ pcl_symbol_set_id_code(pcl_args_t *pargs, pcl_state_t *pcs)
#ifdef DEBUG
static void
-dump_dl_symbol_set(const pl_symbol_map_t *psm)
+dump_dl_symbol_set(const gs_memory_t *mem, const pl_symbol_map_t *psm)
{
- dprintf6("header size:%d id:%d format:%s type:%d first code:%d last code:%d\n",
- pl_get_uint16(psm->header_size),
- pl_get_uint16(psm->id),
- (psm->format == 1 ? "MSL" : (psm->format == 3 ? "Unicode" : "Unknown")),
- psm->type,
- pl_get_uint16(psm->first_code),
- pl_get_uint16(psm->last_code));
+ dmprintf6(mem, "header size:%d id:%d format:%s type:%d first code:%d last code:%d\n",
+ pl_get_uint16(psm->header_size),
+ pl_get_uint16(psm->id),
+ (psm->format == 1 ? "MSL" : (psm->format == 3 ? "Unicode" : "Unknown")),
+ psm->type,
+ pl_get_uint16(psm->first_code),
+ pl_get_uint16(psm->last_code));
{
int i;
int num_codes = pl_get_uint16(psm->last_code) - pl_get_uint16(psm->first_code) + 1;
for (i = 0; i < num_codes; i++) {
- dprintf2("index=%d, code:%d\n", i, psm->codes[i]);
+ dmprintf2(mem, "index=%d, code:%d\n", i, psm->codes[i]);
}
}
}
@@ -128,7 +128,7 @@ pcl_define_symbol_set(pcl_args_t *pargs, pcl_state_t *pcs)
#ifdef DEBUG
if ( gs_debug_c('=') )
- dump_dl_symbol_set(psm);
+ dump_dl_symbol_set(mem, psm);
#endif
/* Symbol set may already exist; if so, we may be replacing one of
@@ -348,7 +348,7 @@ pcsymbol_do_reset(pcl_state_t *pcs, pcl_reset_type_t type)
/* NB. Symbol sets are require for RTL/HPGL/2 mode for
* stickfonts but we shouldn't load all of them. */
if ( pcl_load_built_in_symbol_sets(pcs) < 0 )
- dprintf("Internal error, no symbol sets found");
+ dmprintf(pcs->memory, "Internal error, no symbol sets found");
}
else if ( type & pcl_reset_printer ) {
pcl_args_t args;
diff --git a/pcl/pctext.c b/pcl/pctext.c
index e8f44bcdd..0d7d3bd69 100644
--- a/pcl/pctext.c
+++ b/pcl/pctext.c
@@ -139,7 +139,8 @@ substituting_allowed(pcl_state_t *pcs, gs_char mapped_chr)
remapped_chr = pl_map_symbol(pcs->map, mapped_chr,
false, /* storage not internal */
false, /* unicode not msl */
- false /* is_590 */);
+ false /* is_590 */,
+ pcs->memory);
/* now we can assume the characters are unicode */
if (
@@ -243,7 +244,8 @@ get_next_char(
r: db = pcl_downloaded_and_bound(plfont);
mapped_chr = pl_map_symbol((db ? NULL : pcs->map), chr,
plfont->storage == pcds_internal,
- plfont->font_type == plft_MSL, false);
+ plfont->font_type == plft_MSL, false,
+ pcs->memory);
*pchr = mapped_chr;
if (mapped_chr == 0xffff) {
if ((plfont->storage != pcds_internal) &&
diff --git a/pcl/pctop.c b/pcl/pctop.c
index 8392e8e94..7fe1d63e3 100644
--- a/pcl/pctop.c
+++ b/pcl/pctop.c
@@ -609,16 +609,16 @@ pcl_impl_remove_device(
/* return to the original graphic state w/color mapper, bbox, target */
code = pcl_grestore(&pcli->pcs);
if (code < 0 )
- dprintf1("error code %d restoring gstate, continuing\n", code );
+ dmprintf1(pcli->memory, "error code %d restoring gstate, continuing\n", code );
/* return to original gstate w/bbox, target */
code = gs_grestore_only(pcli->pcs.pgs); /* destroys gs_save stack */
if (code < 0 )
- dprintf1("error code %d destroying gstate, continuing\n", code );
+ dmprintf1(pcli->memory, "error code %d destroying gstate, continuing\n", code );
/* Deselect bbox. Bbox has been prevented from auto-closing/deleting */
code = gs_nulldevice(pcli->pcs.pgs);
if ( code < 0 )
- dprintf1("error code %d installing nulldevice, continuing\n", code );
+ dmprintf1(pcli->memory, "error code %d installing nulldevice, continuing\n", code );
return pcl_do_resets(&pcli->pcs, pcl_reset_permanent);
}
@@ -632,7 +632,7 @@ pcl_impl_deallocate_interp_instance(
gs_memory_t *mem = pcli->memory;
/* free memory used by the parsers */
if ( pcl_parser_shutdown(&pcli->pst, mem ) < 0 ) {
- dprintf("Undefined error shutting down parser, continuing\n" );
+ dmprintf(mem, "Undefined error shutting down parser, continuing\n" );
}
/* this should have a shutdown procedure like pcl above */
gs_free_object(mem,
diff --git a/pcl/pgconfig.c b/pcl/pgconfig.c
index a97d5934b..397908d73 100644
--- a/pcl/pgconfig.c
+++ b/pcl/pgconfig.c
@@ -75,7 +75,7 @@ hpgl_CO(hpgl_args_t *pargs, hpgl_state_t *pgls)
}
break;
default:
- dprintf("HPGL CO automata is in an unknown state\n" );
+ dmprintf(pgls->memory, "HPGL CO automata is in an unknown state\n" );
pargs->source.ptr = p;
return 0;
}
diff --git a/pcl/pgdraw.c b/pcl/pgdraw.c
index cb8aa3a0e..9a91970db 100644
--- a/pcl/pgdraw.c
+++ b/pcl/pgdraw.c
@@ -56,7 +56,7 @@ hpgl_picture_frame_scale(hpgl_state_t *pgls)
(pgls->g.picture_frame_width == 0) ||
(pgls->g.plot_width == 0) ||
(pgls->g.plot_height == 0) ) {
- dprintf("bad picture frame coordinates\n");
+ dmprintf(pgls->memory, "bad picture frame coordinates\n");
} else {
scale.x = (pgls->g.plot_size_horizontal_specified) ?
((hpgl_real_t)pgls->g.picture_frame_width /
@@ -447,7 +447,7 @@ vector:
default:
/* shouldn't happen; we must have a mode to properly parse hpgl file. */
- dprintf("warning no hpgl rendering mode set using vector mode\n");
+ dmprintf(pgls->memory, "warning no hpgl rendering mode set using vector mode\n");
goto vector;
}
@@ -943,7 +943,7 @@ hpgl_set_drawing_color(
goto fill;
default:
- dprintf("hpgl_set_drawing_color: internal error illegal fill\n");
+ dmprintf(pgls->memory, "hpgl_set_drawing_color: internal error illegal fill\n");
return 0;
}
break;
@@ -1008,7 +1008,7 @@ fill:
break;
default:
- dprintf("hpgl_set_drawing_color: internal error illegal fill\n");
+ dmprintf(pgls->memory, "hpgl_set_drawing_color: internal error illegal fill\n");
break;
}
break;
@@ -1053,13 +1053,13 @@ fill:
break;
default:
- dprintf("hpgl_set_drawing_color: internal error illegal fill\n");
+ dmprintf(pgls->memory, "hpgl_set_drawing_color: internal error illegal fill\n");
break;
}
break;
default:
- dprintf("hpgl_set_drawing_color: internal error illegal mode\n");
+ dmprintf(pgls->memory, "hpgl_set_drawing_color: internal error illegal mode\n");
break;
}
@@ -1669,7 +1669,7 @@ hpgl_draw_current_path(
break;
}
default :
- dprintf("unknown render mode\n");
+ dmprintf(pgls->memory, "unknown render mode\n");
}
return 0;
diff --git a/pcl/pginit.c b/pcl/pginit.c
index 8d69a0df4..7a977ad3a 100644
--- a/pcl/pginit.c
+++ b/pcl/pginit.c
@@ -189,7 +189,7 @@ hpgl_do_reset(
if ((type & pcl_reset_picture_frame) != 0) {
/* this shouldn't happen. Picture frame side effects are
handled directly by the command picture frame command. */
- dprintf("PCL reset picture frame received\n");
+ dmprintf(pcs->memory, "PCL reset picture frame received\n");
}
if ((type & pcl_reset_overlay) != 0)
@@ -199,7 +199,7 @@ hpgl_do_reset(
if ((type & (pcl_reset_plot_size)) != 0) {
/* this shouldn't happen. Plot size side effects are handled
directly by the command picture frame command. */
- dprintf("PCL reset plot received\n");
+ dmprintf(pcs->memory, "PCL reset plot received\n");
}
if ((type & (pcl_reset_permanent)) != 0 ) {
diff --git a/pcl/pglabel.c b/pcl/pglabel.c
index c17e4ae48..38cad9965 100644
--- a/pcl/pglabel.c
+++ b/pcl/pglabel.c
@@ -128,7 +128,8 @@ hpgl_map_symbol(uint chr, const hpgl_state_t *pgls)
return pl_map_symbol(psm, chr,
pfs->font->storage == pcds_internal,
pfs->font->font_type == plgv_MSL,
- false);
+ false,
+ pgls->memory);
}
/* ------ Font selection ------- */
@@ -1038,7 +1039,7 @@ hpgl_get_character_origin_offset(hpgl_state_t *pgls, int origin,
#ifdef CHECK_UNIMPLEMENTED
if (pgls->g.character.extra_space.x != 0 || pgls->g.character.extra_space.y != 0)
- dprintf("warning origin offset with non zero extra space not supported\n");
+ dmprintf(pgls->memory, "warning origin offset with non zero extra space not supported\n");
#endif
adjusted_height /= 1.6;
if (hpgl_is_currentfont_stick(pgls))
@@ -1126,7 +1127,7 @@ hpgl_get_character_origin_offset(hpgl_state_t *pgls, int origin,
}
break;
default:
- dprintf("unknown label parameter");
+ dmprintf(pgls->memory, "unknown label parameter");
}
/* a relative move to the new position */
@@ -1417,10 +1418,10 @@ hpgl_LB(hpgl_args_t *pargs, hpgl_state_t *pgls)
GL_LB_HAVE_16BITS = !GL_LB_HAVE_16BITS;
GL_LB_PREV_CH = GL_LB_CH;
GL_LB_CH = *++p;
- if_debug1('I',
- (GL_LB_CH == '\\' ? " \\%c" : GL_LB_CH >= 33 && GL_LB_CH <= 126 ? " %c" :
- " \\%03o"),
- GL_LB_CH);
+ if_debug1m('I', pgls->memory,
+ (GL_LB_CH == '\\' ? " \\%c" : GL_LB_CH >= 33 && GL_LB_CH <= 126 ? " %c" :
+ " \\%03o"),
+ GL_LB_CH);
if ( is_terminator(pgls, GL_LB_PREV_CH, GL_LB_CH, GL_LB_HAVE_16BITS) )
{
if ( !print_terminator )
diff --git a/pcl/pgmisc.c b/pcl/pgmisc.c
index 30c924d87..60f733bee 100644
--- a/pcl/pgmisc.c
+++ b/pcl/pgmisc.c
@@ -48,7 +48,7 @@ hpgl_set_lost_mode(hpgl_state_t *pgls, hpgl_lost_mode_t lost_mode)
hpgl_PU(&args, pgls);
#endif
#ifdef DEBUG
- dprintf("entering lost mode\n");
+ dmprintf(pgls->memory, "entering lost mode\n");
#endif
}
pgls->g.lost_mode = lost_mode;
@@ -63,8 +63,8 @@ int
hpgl_print_error(const gs_memory_t *mem,
const char *function, const char *file, int line, int code)
{
- dprintf4("hpgl call failed\n\tcalled from: %s\n\tfile: %s\n\tline: %d\n\terror code: %d\n",
- (function == 0 ? "" : function), file, line, code);
+ dmprintf4(mem, "hpgl call failed\n\tcalled from: %s\n\tfile: %s\n\tline: %d\n\terror code: %d\n",
+ (function == 0 ? "" : function), file, line, code);
hpgl_error();
return code;
}
diff --git a/pcl/pgparse.c b/pcl/pgparse.c
index 977a04d81..14fded0b9 100644
--- a/pcl/pgparse.c
+++ b/pcl/pgparse.c
@@ -62,7 +62,7 @@ hpgl_define_commands(const gs_memory_t *mem, const hpgl_named_command_t *pcmds,
&pcmd->defn)
#ifdef DEBUG
)
- dprintf2("Redefining command %c%c\n", pcmd->char1, pcmd->char2);
+ dmprintf2(mem, "Redefining command %c%c\n", pcmd->char1, pcmd->char2);
#endif
;
}
@@ -95,7 +95,7 @@ hpgl_process(hpgl_parser_state_t *pst, hpgl_state_t *pgls,
pr->ptr = pst->source.ptr;
if ( code < 0 && code != e_NeedData )
{ pst->command = 0; /* cancel command */
- if_debug0('i', "\n");
+ if_debug0m('i', pgls->memory, "\n");
return code;
}
return 0;
@@ -109,7 +109,7 @@ call: if ( pst->command )
if ( code < 0 )
goto x;
pst->command = 0;
- if_debug0('i', "\n");
+ if_debug0m('i', pgls->memory, "\n");
}
while ( p < rlimit )
{ byte next = *++p;
@@ -139,8 +139,8 @@ call: if ( pst->command )
#ifdef DEBUG
if ( gs_debug_c('i') )
{ char c = (index ? '-' : '?');
- dprintf4("--%c%c%c%c", pst->first_letter + 'A',
- next + 'A', c, c);
+ dmprintf4(pgls->memory, "--%c%c%c%c",
+ pst->first_letter + 'A', next + 'A', c, c);
}
#endif
if ( index == 0 ) /* anomalous, drop 1st letter */
@@ -311,11 +311,11 @@ out: pst->source.ptr = p;
case 0: /* no argument */
return NULL;
case 1: /* integer */
- if_debug1('I', " %ld", (long)pvalue->v_n.i);
+ if_debug1m('I', mem, " %ld", (long)pvalue->v_n.i);
pvalue->is_real = false;
break;
default /* case 2 */: /* real */
- if_debug1('I', " %g", pvalue->v_n.r);
+ if_debug1m('I', mem, " %g", pvalue->v_n.r);
pvalue->is_real = true;
}
hpgl_arg_init(pst);
diff --git a/pcl/pgvector.c b/pcl/pgvector.c
index e8e92d90f..d4b95b050 100644
--- a/pcl/pgvector.c
+++ b/pcl/pgvector.c
@@ -410,7 +410,7 @@ hpgl_PE(hpgl_args_t *pargs, hpgl_state_t *pgls)
hpgl_call(hpgl_draw_current_path(pgls, hpgl_rm_vector));
return 0;
case ':':
- if_debug0('I', "\n PE SP");
+ if_debug0m('I', pgls->memory, "\n PE SP");
{
int32 pen;
hpgl_pe_args_ret_t ret = pe_args(pgls->memory, pargs, 1);
@@ -431,11 +431,11 @@ hpgl_PE(hpgl_args_t *pargs, hpgl_state_t *pgls)
p = pargs->source.ptr;
continue;
case '<':
- if_debug0('I', "\n PE PU");
+ if_debug0m('I', pgls->memory, "\n PE PU");
pargs->phase |= pe_pen_up;
continue;
case '>':
- if_debug0('I', "\n PE PD");
+ if_debug0m('I', pgls->memory, "\n PE PD");
{
int32 fbits;
hpgl_pe_args_ret_t ret = pe_args(pgls->memory, pargs, 1);
@@ -453,11 +453,11 @@ hpgl_PE(hpgl_args_t *pargs, hpgl_state_t *pgls)
p = pargs->source.ptr;
continue;
case '=':
- if_debug0('I', " PE ABS");
+ if_debug0m('I', pgls->memory, " PE ABS");
pargs->phase |= pe_absolute;
continue;
case '7':
- if_debug0('I', "\n PE 7bit");
+ if_debug0m('I', pgls->memory, "\n PE 7bit");
pargs->phase |= pe_7bit;
continue;
case ESC:
@@ -561,7 +561,7 @@ pe_args(const gs_memory_t *mem, hpgl_args_t *pargs, int count)
}
}
VALUE = (VALUE & 1 ? -(VALUE >> 1) : VALUE >> 1);
- if_debug1('I', " [%ld]", (long)VALUE);
+ if_debug1m('I', mem, " [%ld]", (long)VALUE);
}
pargs->source.ptr = p;
return pe_okay;
diff --git a/pl/pjparse.c b/pl/pjparse.c
index 7f9977df3..4a5e76bfa 100644
--- a/pl/pjparse.c
+++ b/pl/pjparse.c
@@ -498,7 +498,7 @@ pjl_verify_file_operation(pjl_parser_state_t *pst, char *fname)
/* make sure we are playing in the pjl sandbox */
if ( 0 != strncmp(PJL_VOLUME_0, fname, strlen(PJL_VOLUME_0))
&& 0 != strncmp(PJL_VOLUME_1, fname, strlen(PJL_VOLUME_1)) ) {
- dprintf1("illegal path name %s\n", fname);
+ dmprintf1(pst->mem, "illegal path name %s\n", fname);
return -1;
}
/* make sure we are not currently writing to a file.
@@ -521,7 +521,7 @@ pjl_warn_exists(const gs_memory_t *mem, char *fname)
/* issue a warning if the file exists */
if ( (fpdownload = fopen(fname, gp_fmode_rb) ) != NULL ) {
fclose(fpdownload);
- dprintf1("warning file exists overwriting %s\n", fname);
+ dmprintf1(mem, "warning file exists overwriting %s\n", fname);
}
}
@@ -542,7 +542,7 @@ pjl_setup_file_for_writing(pjl_parser_state_t *pst, char *pathname, int size, bo
if (append)
strcat(fmode, "+");
if ( (fp = fopen(fname, gp_fmode_wb)) == NULL) {
- dprintf("warning file open for writing failed\n" );
+ dmprintf(pst->mem, "warning file open for writing failed\n" );
return NULL;
}
}
@@ -669,7 +669,7 @@ pjl_fsdirlist(pjl_parser_state_t *pst, char *pathname, int entry, int count)
return 0;
fontfilename[fstatus] = '\0';
/* NB - debugging output only */
- dprintf1("%s\n", fontfilename);
+ dmprintf1(pst->mem, "%s\n", fontfilename);
} while (1);
}
/* should not get here */
@@ -1250,7 +1250,7 @@ pjl_process_destroy(pjl_parser_state *pst, gs_memory_t *mem)
pjl_register_permanent_soft_font_deletion(pjl_parser_state *pst, int font_number)
{
if ( (font_number > MAX_PERMANENT_FONTS - 1) || (font_number < 0) ) {
- dprintf("pjparse.c:pjl_register_permanent_soft_font_deletion() bad font number\n");
+ dmprintf(pst->mem, "pjparse.c:pjl_register_permanent_soft_font_deletion() bad font number\n");
return 0;
}
/* if the font is present. */
@@ -1302,7 +1302,7 @@ pjl_register_permanent_soft_font_addition(pjl_parser_state *pst)
}
/* yikes, shouldn't happen */
if ( !slot_found ) {
- dprintf("pjparse.c:pjl_register_permanent_soft_font_addition()\
+ dmprintf(pst->mem, "pjparse.c:pjl_register_permanent_soft_font_addition()\
font table full recycling font number 0\n");
font_num = 0;
}
diff --git a/pl/plchar.c b/pl/plchar.c
index fe85084d3..674bf205c 100644
--- a/pl/plchar.c
+++ b/pl/plchar.c
@@ -113,7 +113,7 @@ pl_bitmap_char_width(const pl_font_t *plfont, const void *pgs, uint char_code, g
pwidth->x = pwidth->y = 0;
if ( !pwidth ) {
#ifdef DEBUG
- dprintf("Warning should not call width function without width\n" );
+ dmprintf(plfont->pfont->memory, "Warning should not call width function without width\n" );
#endif
return (cdata == 0 ? 1 : 0);
}
@@ -449,14 +449,14 @@ pl_bitmap_build_char(gs_show_enum *penum, gs_state *pgs, gs_font *pfont,
if ( gs_debug_c('B') ) {
int i;
int pixels = round_up(image.Width,8) * image.Height;
- dprintf7("bitmap font data chr=%ld, width=%d, height=%d, lsb=%d, ascent=%d, top offset=%d left offset=%d\n",
- chr, image.Width, image.Height, lsb, ascent, pl_get_int16(params + 2), pl_get_int16(params));
+ dmprintf7(pgs->memory, "bitmap font data chr=%ld, width=%d, height=%d, lsb=%d, ascent=%d, top offset=%d left offset=%d\n",
+ chr, image.Width, image.Height, lsb, ascent, pl_get_int16(params + 2), pl_get_int16(params));
for ( i = 0; i < pixels; i++ ) {
if ( i % round_up(image.Width, 8) == 0 )
- dprintf("\n");
- dprintf1("%d", bitmap_data[i >> 3] & (128 >> (i & 7)) ? 1 : 0);
+ dmprintf(pgs->memory, "\n");
+ dmprintf1(pgs->memory, "%d", bitmap_data[i >> 3] & (128 >> (i & 7)) ? 1 : 0);
}
- dprintf("\n");
+ dmprintf(pgs->memory, "\n");
}
#endif
code = image_bitmap_char(ienum, &image, bitmap_data,
@@ -595,7 +595,7 @@ pl_tt_get_metrics(gs_font_type42 * pfont, uint glyph_index,
}
else {
if ( gs_debug_c('=') ) {
- dprintf("Found vertical metrics\n");
+ dmprintf(pfont->memory, "Found vertical metrics\n");
}
}
}
@@ -783,7 +783,7 @@ pl_tt_cmap_encode_char(gs_font_type42 *pfont, ulong cmap_offset,
cmap_sub = cmap + 4;
{ uint i;
for ( i = 0; i < pl_get_uint16(cmap + 2); ++i )
- { if_debug3('j', "[j]cmap %d: platform %u encoding %u\n",
+ { if_debug3m('j', pfont->memory, "[j]cmap %d: platform %u encoding %u\n",
i, pl_get_uint16(cmap_sub + i * 8), pl_get_uint16(cmap_sub + i * 8 + 2));
if ( pl_get_uint16(cmap_sub + i * 8) == 3 )
{ cmap_sub += i * 8;
@@ -1203,7 +1203,7 @@ pl_intelli_show_char(gs_state *pgs, const pl_font_t *plfont, gs_glyph glyph)
cdata = font_glyph->data;
if ( cdata == 0 ) {
- if_debug1('1', "[1] no character data for glyph %ld\n",glyph);
+ if_debug1m('1', pgs->memory, "[1] no character data for glyph %ld\n",glyph);
return 0;
}
if ( cdata[3] == 4 ) { /* Compound character */
@@ -1232,7 +1232,7 @@ pl_intelli_show_char(gs_state *pgs, const pl_font_t *plfont, gs_glyph glyph)
outlines = cdata + pl_get_uint16(cdata + 6);
num_loops = pl_get_uint16(outlines);
- if_debug2('1', "[1]ifont glyph %lu: loops=%u\n",(ulong)glyph, num_loops);
+ if_debug2m('1', pgs->memory, "[1]ifont glyph %lu: loops=%u\n",(ulong)glyph, num_loops);
if (num_loops == 0)
return -1;
@@ -1292,13 +1292,13 @@ pl_intelli_show_char(gs_state *pgs, const pl_font_t *plfont, gs_glyph glyph)
gs_free_object(pgs->memory, xBuffer, "x point buffer");
if( yBuffer != NULL)
gs_free_object(pgs->memory, yBuffer, "y point buffer");
- if_debug1('1', "[1]cannot allocate point buffers %i\n",pointBufferSize * sizeof(int));
+ if_debug1m('1', pgs->memory, "[1]cannot allocate point buffers %i\n",pointBufferSize * sizeof(int));
return_error(gs_error_VMerror);
}
xLast = NULL;
- if_debug2('1', "[1]num_points=%u num_aux_points=%u\n", num_points, num_aux_points);
+ if_debug2m('1', pgs->memory, "[1]num_points=%u num_aux_points=%u\n", num_points, num_aux_points);
/* collect the points in the buffers, since we need to clean them up later */
/* only points inside the bounding box are allowed */
@@ -1308,9 +1308,9 @@ pl_intelli_show_char(gs_state *pgs, const pl_font_t *plfont, gs_glyph glyph)
x = pl_get_uint16(x_coords) & 0x3fff;
y = pl_get_uint16(y_coords) & 0x3fff;
- if_debug4('1', "[1]%s (%d,%d) %s\n",
- (*x_coords & 0x80 ? " line" : "curve"), x, y,
- (*y_coords & 0x80 ? " line" : "curve"));
+ if_debug4m('1', pgs->memory, "[1]%s (%d,%d) %s\n",
+ (*x_coords & 0x80 ? " line" : "curve"), x, y,
+ (*y_coords & 0x80 ? " line" : "curve"));
if (xScan > xBuffer) { /* not first point, therefore aux is possible */
if ( x_aux_coords < x_aux_coords_last &&!(*x_coords & 0x80) ) { /* use an aux point */
@@ -1318,7 +1318,7 @@ pl_intelli_show_char(gs_state *pgs, const pl_font_t *plfont, gs_glyph glyph)
int dx = (*x_aux_coords++ ^ 0x80) - 0x80;
int dy = (*y_aux_coords++ ^ 0x80) - 0x80;
- if_debug2('1', "[1]... aux (%d,%d)\n", dx, dy);
+ if_debug2m('1', pgs->memory, "[1]... aux (%d,%d)\n", dx, dy);
xAux = (x + *(xScan-1)) / 2 + dx;
yAux = (y + *(yScan-1)) / 2 + dy;
@@ -1404,8 +1404,8 @@ pl_intelli_char_width(const pl_font_t *plfont, const void *pgs, uint char_code,
#ifdef DEBUG
{
pl_font_glyph_t *cglyph = pl_font_lookup_glyph(plfont, char_code);
- if_debug1('1', "[1] glyph %ld\n", cglyph->glyph);
- if_debug2('1', "[1] intelli width of %d %f\n", char_code, pwidth->x);
+ if_debug1m('1', plfont->pfont->memory, "[1] glyph %ld\n", cglyph->glyph);
+ if_debug2m('1', plfont->pfont->memory, "[1] intelli width of %d %f\n", char_code, pwidth->x);
}
#endif
return 0;
@@ -1426,7 +1426,8 @@ pl_intelli_char_metrics(const pl_font_t *plfont, const void *pgs, uint char_code
/* compound */
if ( cdata[3] == 4 ) {
- dprintf("warning compound intellifont metrics not supported" );
+ dmprintf(plfont->pfont->memory,
+ "warning compound intellifont metrics not supported");
return 0;
}
@@ -1535,9 +1536,11 @@ pl_tt_finish_init(gs_font_type42 *pfont, bool downloaded)
access(12, numTables * 16, TableDirectory);
for ( i = 0; i < numTables; ++i )
{ const byte *tab = TableDirectory + i * 16;
- dprintf6("%c%c%c%c offset = %lu length = %lu\n",
- tab[0], tab[1], tab[2], tab[3],
- (ulong)pl_get_uint32(tab + 8), (ulong)pl_get_uint32(tab + 12));
+ dmprintf6(pfont->memory,
+ "%c%c%c%c offset = %lu length = %lu\n",
+ tab[0], tab[1], tab[2], tab[3],
+ (ulong)pl_get_uint32(tab + 8),
+ (ulong)pl_get_uint32(tab + 12));
}
}
#endif
diff --git a/pl/plfont.c b/pl/plfont.c
index 355a8306a..4357cb809 100644
--- a/pl/plfont.c
+++ b/pl/plfont.c
@@ -355,7 +355,7 @@ pl_glyph_name(gs_font *pfont, gs_glyph glyph, gs_const_string *pstr)
pstr->size = strlen((const char *)pstr->data);
return 0;
} else {
- if_debug1('=', "[=]glyph index %lx out of range\n", (ulong)glyph);
+ if_debug1m('=', pfont->memory, "[=]glyph index %lx out of range\n", (ulong)glyph);
return -1;
}
}
@@ -381,13 +381,13 @@ pl_glyph_name(gs_font *pfont, gs_glyph glyph, gs_const_string *pstr)
/* format 1.0 (mac encoding) is a simple table see the TT
spec. We don't implement this because we don't see it
in practice */
- dprintf1("unkonwn post table format %lX\n", format);
+ dmprintf1(pfont->memory, "unknown post table format %lX\n", format);
return -1;
}
/* skip over the post header */
numGlyphs = u16(postp + 32);
if ( glyph < 0 || glyph > numGlyphs - 1) {
- if_debug1('=', "[=]glyph index %lx out of range\n", glyph);
+ if_debug1m('=', pfont->memory, "[=]glyph index %lx out of range\n", glyph);
return -1;
}
/* glyph name index starts at post + 34 each entry is 2 bytes */
@@ -422,7 +422,7 @@ pl_glyph_name(gs_font *pfont, gs_glyph glyph, gs_const_string *pstr)
/* sanity check */
if ( pstr->data + pstr->size > postp + table_length ||
pstr->data - 1 < postp) {
- dprintf("data out of range\n");
+ dmprintf(pfont->memory, "data out of range\n");
return -1;
}
/* sigh - we have to allocate a copy of the data - by the
diff --git a/pl/pllfont.c b/pl/pllfont.c
index 0e847cb71..25416b14e 100644
--- a/pl/pllfont.c
+++ b/pl/pllfont.c
@@ -169,13 +169,13 @@ check_resident_fonts(pl_dict_t *pfontdict, gs_memory_t *mem)
i ++)
if (!pl_lookup_font_by_pjl_number(pfontdict, i)) {
int j;
- dprintf2("%s (entry %d) not found\n", resident_table[i].full_font_name, i);
- dprintf("pxl unicode name:");
+ dmprintf2(mem, "%s (entry %d) not found\n", resident_table[i].full_font_name, i);
+ dmprintf(mem, "pxl unicode name:");
for (j = 0;
j < countof(resident_table[i].unicode_fontname);
j++)
- dprintf1("'%c'", resident_table[i].unicode_fontname[j]);
- dprintf("\n");
+ dmprintf1(mem, "'%c'", resident_table[i].unicode_fontname[j]);
+ dmprintf(mem, "\n");
}
}
#endif
@@ -227,7 +227,7 @@ pl_load_built_in_fonts(const char *pathname, gs_memory_t *mem,
if ((strlen(pattern) +
strlen(tmp_pathp) + 1 ) +
(append_separator ? separator_length : 0) > sizeof( tmp_path_copy ) ) {
- dprintf1("path name %s too long\n", tmp_pathp );
+ dmprintf1(mem, "path name %s too long\n", tmp_pathp );
continue;
}
@@ -251,7 +251,7 @@ pl_load_built_in_fonts(const char *pathname, gs_memory_t *mem,
pl_font_t *plfont;
if (code > sizeof(tmp_path_copy)) {
- dprintf("filename length exceeds file name storage buffer length\n");
+ dmprintf(mem, "filename length exceeds file name storage buffer length\n");
continue;
}
/* null terminate the string */
@@ -259,13 +259,13 @@ pl_load_built_in_fonts(const char *pathname, gs_memory_t *mem,
in = sfopen(tmp_path_copy, "rb", mem);
if (in == NULL) { /* shouldn't happen */
- dprintf1("cannot open file %s\n", tmp_path_copy );
+ dmprintf1(mem, "cannot open file %s\n", tmp_path_copy );
continue;
}
if ( !is_ttfile( in ) ) {
#ifdef DEBUG
if ( gs_debug_c('=') ) {
- dprintf1("%s not a TrueType file\n", tmp_path_copy);
+ dmprintf1(mem, "%s not a TrueType file\n", tmp_path_copy);
}
#endif
continue;
@@ -273,12 +273,12 @@ pl_load_built_in_fonts(const char *pathname, gs_memory_t *mem,
code = get_name_from_tt_file( in, mem, buffer, PSNAME);
if ( code < 0 ) {
- dprintf1("input output failure on TrueType File %s\n", tmp_path_copy );
+ dmprintf1(mem, "input output failure on TrueType File %s\n", tmp_path_copy );
continue;
}
if (strlen( buffer ) == 0) {
- dprintf1("could not extract font file name from file %s\n", tmp_path_copy );
+ dmprintf1(mem, "could not extract font file name from file %s\n", tmp_path_copy );
continue;
}
@@ -318,7 +318,7 @@ pl_load_built_in_fonts(const char *pathname, gs_memory_t *mem,
/* leave data stored in the file. NB this should be a fatal error also. */
if (pl_store_resident_font_data_in_file( tmp_path_copy, mem, plfont ) < 0) {
- dprintf1("%s could not store data", tmp_path_copy);
+ dmprintf1(mem, "%s could not store data", tmp_path_copy);
continue;
}
}
@@ -331,11 +331,11 @@ pl_load_built_in_fonts(const char *pathname, gs_memory_t *mem,
if (!found) {
#ifdef DEBUG
if (gs_debug_c('=')) {
- dprintf2("TrueType font %s in file %s not found in table\n", buffer, tmp_path_copy);
+ dmprintf2(mem, "TrueType font %s in file %s not found in table\n", buffer, tmp_path_copy);
in = sfopen(tmp_path_copy, "rb", mem);
code = get_name_from_tt_file(in, mem, buffer, WINDOWSNAME);
sfclose(in);
- dprintf1("Windows name %s\n", buffer);
+ dmprintf1(mem, "Windows name %s\n", buffer);
}
#endif
}
diff --git a/pl/plmain.c b/pl/plmain.c
index 64d313626..b811ed499 100644
--- a/pl/plmain.c
+++ b/pl/plmain.c
@@ -357,43 +357,43 @@ pl_main_aux(
#ifdef DEBUG
if (gs_debug_c(':'))
- dprintf1("%% Reading %s:\n", filename);
+ dmprintf1(mem, "%% Reading %s:\n", filename);
#endif
/* pump data thru PJL/PDL until EOD or error */
new_job = false;
in_pjl = true;
for (;;) {
- if_debug1('i', "[i][file pos=%ld]\n", pl_main_cursor_position(&r));
+ if_debug1m('i', mem, "[i][file pos=%ld]\n", pl_main_cursor_position(&r));
/* end of data - if we are not back in pjl the job has
ended in the middle of the data stream. */
if (pl_main_cursor_next(&r) <= 0) {
- if_debug0('|', "End of of data\n");
+ if_debug0m('|', mem, "End of of data\n");
if ( !in_pjl ) {
- if_debug0('|', "end of data stream found in middle of job\n");
+ if_debug0m('|', mem, "end of data stream found in middle of job\n");
pl_process_eof(curr_instance);
if ( close_job(&universe, &inst) < 0 ) {
- dprintf("Unable to deinit PDL job.\n");
+ dmprintf(mem, "Unable to deinit PDL job.\n");
return -1;
}
}
break;
}
if ( in_pjl ) {
- if_debug0('|', "Processing pjl\n");
+ if_debug0m('|', mem, "Processing pjl\n");
code = pl_process(pjl_instance, &r.cursor);
if (code == e_ExitLanguage) {
- if_debug0('|', "Exiting pjl\n" );
+ if_debug0m('|', mem, "Exiting pjl\n" );
in_pjl = false;
new_job = true;
}
}
if ( new_job ) {
if (mem->gs_lib_ctx->gs_next_id > 0xFF000000) {
- dprintf("Once a year reset the gs_next_id.\n");
+ dmprintf(mem, "Once a year reset the gs_next_id.\n");
return -1;
}
- if_debug0('|', "Selecting PDL\n" );
+ if_debug0m('|', mem, "Selecting PDL\n" );
curr_instance = pl_main_universe_select(&universe, err_buf,
pjl_instance,
pl_select_implementation(pjl_instance, &inst, r),
@@ -404,11 +404,11 @@ pl_main_aux(
}
if ( pl_init_job(curr_instance) < 0 ) {
- dprintf("Unable to init PDL job.\n");
+ dmprintf(mem, "Unable to init PDL job.\n");
return -1;
}
- if_debug1('|', "selected and initializing (%s)\n",
- pl_characteristics(curr_instance->interp->implementation)->language);
+ if_debug1m('|', mem, "selected and initializing (%s)\n",
+ pl_characteristics(curr_instance->interp->implementation)->language);
new_job = false;
}
if ( curr_instance ) {
@@ -418,44 +418,44 @@ pl_main_aux(
time. */
if (curr_instance->interp->implementation->proc_process_file &&
r.strm != mem->gs_lib_ctx->fstdin) {
- if_debug1('|', "processing job from file (%s)\n", filename);
+ if_debug1m('|', mem, "processing job from file (%s)\n", filename);
code = pl_process_file(curr_instance, filename);
if (code < 0) {
- dprintf1("Warning interpreter exited with error code %d\n", code);
+ dmprintf1(mem, "Warning interpreter exited with error code %d\n", code);
}
if (close_job(&universe, &inst) < 0) {
- dprintf("Unable to deinit PJL.\n");
+ dmprintf(mem, "Unable to deinit PJL.\n");
return -1;
}
- if_debug0('|', "exiting job and proceeding to next file\n");
+ if_debug0m('|', mem, "exiting job and proceeding to next file\n");
break; /* break out of the loop to process the next file */
}
code = pl_process(curr_instance, &r.cursor);
- if_debug1('|', "processing (%s) job\n",
- pl_characteristics(curr_instance->interp->implementation)->language);
+ if_debug1m('|', mem, "processing (%s) job\n",
+ pl_characteristics(curr_instance->interp->implementation)->language);
if (code == e_ExitLanguage) {
in_pjl = true;
- if_debug1('|', "exiting (%s) job back to pjl\n",
- pl_characteristics(curr_instance->interp->implementation)->language);
+ if_debug1m('|', mem, "exiting (%s) job back to pjl\n",
+ pl_characteristics(curr_instance->interp->implementation)->language);
if ( close_job(&universe, &inst) < 0 ) {
- dprintf( "Unable to deinit PDL job.\n");
+ dmprintf(mem, "Unable to deinit PDL job.\n");
return -1;
}
if ( pl_init_job(pjl_instance) < 0 ) {
- dprintf("Unable to init PJL job.\n");
+ dmprintf(mem, "Unable to init PJL job.\n");
return -1;
}
pl_renew_cursor_status(&r);
} else if ( code < 0 ) { /* error and not exit language */
- dprintf1("Warning interpreter exited with error code %d\n", code );
- dprintf("Flushing to end of job\n" );
+ dmprintf1(mem, "Warning interpreter exited with error code %d\n", code );
+ dmprintf(mem, "Flushing to end of job\n" );
/* flush eoj may require more data */
while ((pl_flush_to_eoj(curr_instance, &r.cursor)) == 0) {
- if_debug1('|', "flushing to eoj for (%s) job\n",
- pl_characteristics(curr_instance->interp->implementation)->language);
+ if_debug1m('|', mem, "flushing to eoj for (%s) job\n",
+ pl_characteristics(curr_instance->interp->implementation)->language);
if (pl_main_cursor_next(&r) <= 0) {
- if_debug0('|', "end of data found while flushing\n");
+ if_debug0m('|', mem, "end of data found while flushing\n");
break;
}
}
@@ -463,7 +463,7 @@ pl_main_aux(
pl_main_cursor_position(&r),
inst.error_report > 0);
if ( close_job(&universe, &inst) < 0 ) {
- dprintf("Unable to deinit PJL.\n");
+ dmprintf(mem, "Unable to deinit PJL.\n");
return -1;
}
/* Print PDL status if applicable, then dnit PDL job */
@@ -487,7 +487,7 @@ pl_main_aux(
/* dnit pjl */
if ( pl_deallocate_interp_instance(pjl_instance) < 0
|| pl_deallocate_interp(pjl_interp) < 0 ) {
- dprintf("Unable to close out PJL instance.\n");
+ dmprintf(mem, "Unable to close out PJL instance.\n");
return -1;
}
@@ -502,7 +502,7 @@ pl_main_aux(
visual_tracer_close();
#endif
if ( gs_debug_c('A') )
- dprintf("Final time" );
+ dmprintf(mem, "Final time" );
pl_platform_dnit(0);
return 0;
}
@@ -891,7 +891,7 @@ pl_main_process_options(pl_main_instance_t *pmi, arg_list *pal,
}
/* FALLTHROUGH */
default:
- dprintf1("Unrecognized switch: %s\n", arg);
+ dmprintf1(pmi->memory, "Unrecognized switch: %s\n", arg);
return -1;
case '\0':
/* read from stdin - must be last arg */
@@ -943,7 +943,7 @@ pl_main_process_options(pl_main_instance_t *pmi, arg_list *pal,
*val++ = 0x00;
sscanf(value, "%d", &base);
if (base < 2 || base > 36) {
- dprintf1("Value out of range %s", value);
+ dmprintf1(pmi->memory, "Value out of range %s", value);
return -1;
}
while(*val) {
@@ -956,7 +956,7 @@ pl_main_process_options(pl_main_instance_t *pmi, arg_list *pal,
if (*val >= 'a' && *val <= 'z') {
number = number * base + (*val - 'a');
} else {
- dprintf1("Value out of range %s", val);
+ dmprintf1(pmi->memory, "Value out of range %s", val);
return -1;
}
}
@@ -1016,7 +1016,7 @@ pl_main_process_options(pl_main_instance_t *pmi, arg_list *pal,
buffer[eqp - arg] = '\0';
code = param_write_bool((gs_param_list *)params, arg_heap_copy(buffer), &bval);
} else {
- dprintf("Usage for -d is -d<option>=[<integer>|<float>|true|false]\n");
+ dmprintf(pmi->memory, "Usage for -d is -d<option>=[<integer>|<float>|true|false]\n");
continue;
}
}
@@ -1033,7 +1033,7 @@ pl_main_process_options(pl_main_instance_t *pmi, arg_list *pal,
gs_param_int_array ia;
if ( sscanf(arg, "%ux%u", &geom[0], &geom[1]) != 2 ) {
- dprintf("-g must be followed by <width>x<height>\n");
+ dmprintf(pmi->memory, "-g must be followed by <width>x<height>\n");
return -1;
}
ia.data = geom;
@@ -1058,7 +1058,7 @@ pl_main_process_options(pl_main_instance_t *pmi, arg_list *pal,
/* length of arg + newline (expected by PJL parser) + null */
int buf_len = strlen(arg) + 2;
if ( (buf_len ) > sizeof(buf) ) {
- dprintf("pjl sequence too long\n");
+ dmprintf(pmi->memory, "pjl sequence too long\n");
return -1;
}
@@ -1100,7 +1100,7 @@ pl_main_process_options(pl_main_instance_t *pmi, arg_list *pal,
(gs_malloc_memory_t *)gs_memory_chunk_target(pmi->memory)->non_gc_memory;
#endif
if ( sscanf(arg, "%d", &maxk) != 1 ) {
- dprintf("-K must be followed by a number\n");
+ dmprintf(pmi->memory, "-K must be followed by a number\n");
return -1;
}
rawheap->limit = (long)maxk << 10;
@@ -1132,11 +1132,11 @@ pl_main_process_options(pl_main_instance_t *pmi, arg_list *pal,
if (impl_array[index] != 0)
pmi->implementation = impl_array[index];
else {
- dprintf("Choose language in -L<language> from: ");
+ dmprintf(pmi->memory, "Choose language in -L<language> from: ");
for (index = 0; impl_array[index] != 0; ++index)
- dprintf1("%s ",
- pl_characteristics(impl_array[index])->language);
- dprintf("\n");
+ dmprintf1(pmi->memory, "%s ",
+ pl_characteristics(impl_array[index])->language);
+ dmprintf(pmi->memory, "\n");
return -1;
}
break;
@@ -1147,7 +1147,7 @@ pl_main_process_options(pl_main_instance_t *pmi, arg_list *pal,
!strcmp(arg, "PCL5C") )
strcpy(pmi->pcl_personality, arg);
else
- dprintf("PCL personality must be RTL, PCL5E or PCL5C\n");
+ dmprintf(pmi->memory, "PCL personality must be RTL, PCL5E or PCL5C\n");
}
break;
case 'r':
@@ -1157,7 +1157,7 @@ pl_main_process_options(pl_main_instance_t *pmi, arg_list *pal,
switch ( sscanf(arg, "%fx%f", &res[0], &res[1]) ) {
default:
- dprintf("-r must be followed by <res> or <xres>x<yres>\n");
+ dmprintf(pmi->memory, "-r must be followed by <res> or <xres>x<yres>\n");
return -1;
case 1: /* -r<res> */
res[1] = res[0];
@@ -1180,7 +1180,7 @@ pl_main_process_options(pl_main_instance_t *pmi, arg_list *pal,
gs_param_string str;
eqp = strchr(arg, '=');
if ( !(eqp || (eqp = strchr(arg, '#'))) ) {
- dprintf("Usage for -s is -s<option>=<string>\n");
+ dmprintf(pmi->memory, "Usage for -s is -s<option>=<string>\n");
return -1;
}
value = eqp + 1;
@@ -1296,10 +1296,10 @@ pl_print_usage(const pl_main_instance_t *pti,
{
long utime[2];
gp_get_usertime(utime);
- dprintf3("%% %s time = %g, pages = %d\n",
- msg, utime[0] - pti->base_time[0] +
- (utime[1] - pti->base_time[1]) / 1000000000.0,
- pti->page_count);
+ dmprintf3(pti->memory, "%% %s time = %g, pages = %d\n",
+ msg, utime[0] - pti->base_time[0] +
+ (utime[1] - pti->base_time[1]) / 1000000000.0,
+ pti->page_count);
}
/* Log a string to console, optionally wait for input */
diff --git a/pl/plsrgb.c b/pl/plsrgb.c
index 4ee62856b..35aac852a 100644
--- a/pl/plsrgb.c
+++ b/pl/plsrgb.c
@@ -301,7 +301,7 @@ pl_build_crd(gs_state *pgs)
pl_pcrd_built = true;
if ( pl_read_device_CRD(pl_pcrd, pgs) ) {
- dprintf("CRD initialized from device\n");
+ dmprintf(pgs->memory, "CRD initialized from device\n");
return 0;
}
diff --git a/pl/plsymbol.c b/pl/plsymbol.c
index 5f8917934..9ebc0105b 100644
--- a/pl/plsymbol.c
+++ b/pl/plsymbol.c
@@ -3570,7 +3570,7 @@ const int pl_built_in_symbol_map_count =
ulong
pl_map_symbol(const pl_symbol_map_t *psm,
uint chr, bool is_resident_font, bool is_MSL,
- bool is_590)
+ bool is_590, const gs_memory_t *mem)
{
uint first_code, last_code, code;
@@ -3611,8 +3611,8 @@ pl_map_symbol(const pl_symbol_map_t *psm,
(pl_symbol_map_vocabulary(psm) == plgv_Unicode)) {
#ifdef DEBUG
if ( gs_debug_c('=') ) {
- dprintf3("[=] unicode to msl conversion: chr=%d, unicode=0x%x, msl code=%d\n",
- chr, code, pl_map_Unicode_to_MSL(code, (psm->id[0] << 8) + psm->id[1]));
+ dmprintf3(mem, "[=] unicode to msl conversion: chr=%d, unicode=0x%x, msl code=%d\n",
+ chr, code, pl_map_Unicode_to_MSL(code, (psm->id[0] << 8) + psm->id[1]));
}
#endif
code = pl_map_Unicode_to_MSL(code, (psm->id[0] << 8) + psm->id[1]);
@@ -3620,8 +3620,8 @@ pl_map_symbol(const pl_symbol_map_t *psm,
(pl_symbol_map_vocabulary(psm) == plgv_MSL)) {
#ifdef DEBUG
if ( gs_debug_c('=') ) {
- dprintf3("[=] msl to unicode conversion: chr=%d, msl=0x%x, unicode=%d\n",
- chr, code, pl_map_MSL_to_Unicode(code, (psm->id[0] << 8) + psm->id[1]));
+ dmprintf3(mem, "[=] msl to unicode conversion: chr=%d, msl=0x%x, unicode=%d\n",
+ chr, code, pl_map_MSL_to_Unicode(code, (psm->id[0] << 8) + psm->id[1]));
}
#endif
code = pl_map_MSL_to_Unicode(code, (psm->id[0] << 8) + psm->id[1]);
diff --git a/pl/plsymbol.h b/pl/plsymbol.h
index 94c822166..c51af7e6d 100644
--- a/pl/plsymbol.h
+++ b/pl/plsymbol.h
@@ -86,7 +86,7 @@ extern const int pl_built_in_symbol_map_count;
of gs_char to avoid pulling in all the gs_char graphics library
dependencies. */
ulong pl_map_symbol(const pl_symbol_map_t *psm, uint chr, bool is_resident_font,
- bool is_MSL, bool is_590);
+ bool is_MSL, bool is_590, const gs_memory_t *mem);
/* supported pcl and xl wide encodings - 4 Asian encodings and an an
undocumented unicode variant which we haven't conclusively
diff --git a/pl/pluchar.c b/pl/pluchar.c
index 7915184bc..b2951f2dc 100644
--- a/pl/pluchar.c
+++ b/pl/pluchar.c
@@ -165,7 +165,7 @@ pl_set_ufst_font(const pl_font_t * plfont, FONTCONTEXT * pfc)
uint status = CGIFfont(FSA pfc);
if (status != 0)
- dprintf1("CGIFfont error %d\n", status);
+ dmprintf1(plfont->pfont->memory, "CGIFfont error %d\n", status);
else
plfont_last = plfont; /* record this font for use in call-backs */
return status;
@@ -264,7 +264,7 @@ pl_ufst_char_width(
CGIFchIdptr(FSA (VOID *)&chIdloc, NULL);
fcode.CharType.TT_unicode = char_code;
if ((status = CGIFwidth2(FSA &fcode, 1, 4, fontWidth)) != 0) {
- dprintf1("CGIFwidth error %d\n", status);
+ dmprintf1(pgs->memory, "CGIFwidth error %d\n", status);
return status;
}
if (fontWidth[0] == ERR_char_unavailable || fontWidth[1] == 0)
@@ -315,7 +315,7 @@ pl_ufst_make_char(
}
}
if (status != 0) {
- dprintf2("CGIFchar_handle error %d for char=0x%x\n", status, chr);
+ dmprintf2(pgs->memory, "CGIFchar_handle error %d for char=0x%x\n", status, chr);
gs_setcharwidth(penum, pgs, 0.0, 0.0);
return 0; /* returning status causes the job to be aborted */
}
diff --git a/pl/plulfont.c b/pl/plulfont.c
index 7bfff1d38..2f0378f3b 100644
--- a/pl/plulfont.c
+++ b/pl/plulfont.c
@@ -100,7 +100,7 @@ char **build_strs(gs_memory_t *mem, char *str, char separator)
"build_strs");
if ( list == NULL ) {
/* NB no fall back or freeing of memory already consumed */
- dprintf("Fatal System Failure\n" );
+ dmprintf(mem, "Fatal System Failure\n" );
return NULL;
}
/* terminate the list of strings */
@@ -112,7 +112,7 @@ char **build_strs(gs_memory_t *mem, char *str, char separator)
if ( list[i] == NULL ) {
/* NB no fall back or freeing of memory already consumed */
- dprintf("Fatal System Failure\n" );
+ dmprintf(mem, "Fatal System Failure\n" );
return NULL;
}
@@ -174,8 +174,8 @@ pl_ufst_root_dir(char *pathname, int pathlen)
/* check all table entries have a value in the font dictionary */
#ifdef DEBUG
-void
-pl_check_fonts(pl_dict_t *pfontdict, bool use_unicode_names_for_keys)
+static void
+pl_check_fonts(const gs_memory_t *mem, pl_dict_t *pfontdict, bool use_unicode_names_for_keys)
{
int j;
for ( j = 0; strlen(resident_table[j].full_font_name); j++ ) {
@@ -187,13 +187,13 @@ pl_check_fonts(pl_dict_t *pfontdict, bool use_unicode_names_for_keys)
sizeof(resident_table[j].unicode_fontname),
&value, true, NULL) /* return data ignored */ ) {
int i;
- dprintf("Font with unicode key: ");
+ dmprintf(mem, "Font with unicode key: ");
for (i = 0;
i < sizeof(resident_table[j].unicode_fontname)/sizeof(resident_table[j].unicode_fontname[0]);
i++) {
- dprintf1("%c", (char)resident_table[j].unicode_fontname[i]);
+ dmprintf1(mem, "%c", (char)resident_table[j].unicode_fontname[i]);
}
- dprintf1(" not available in font dictionary, resident table position: %d\n", j);
+ dmprintf1(mem, " not available in font dictionary, resident table position: %d\n", j);
}
} else {
byte key[3];
@@ -203,8 +203,8 @@ pl_check_fonts(pl_dict_t *pfontdict, bool use_unicode_names_for_keys)
key,
sizeof(key),
&value, true, NULL) /* return data ignored */ )
- dprintf2("%s not available in font dictionary, resident table position: %d\n",
- resident_table[j].full_font_name, j);
+ dmprintf2(mem, "%s not available in font dictionary, resident table position: %d\n",
+ resident_table[j].full_font_name, j);
}
}
return;
@@ -238,11 +238,11 @@ pl_load_built_in_fonts(const char *pathname, gs_memory_t *mem, pl_dict_t *pfontd
strcpy((char *)pthnm, ufst_root_dir);
strcat((char *)pthnm, plugins[k]);
if ((status = gx_UFST_open_static_fco(pthnm, &fcHndlPlAry[k])) != 0) {
- dprintf2("CGIFfco_Open error %d for %s\n", status, pthnm);
+ dmprintf2(mem, "CGIFfco_Open error %d for %s\n", status, pthnm);
return FALSE;
}
if ((status = CGIFfco_Plugin(FSA fcHndlPlAry[k])) != 0) {
- dprintf1("CGIFfco_Plugin error %d\n", status);
+ dmprintf1(mem, "CGIFfco_Plugin error %d\n", status);
return FALSE;
}
}
@@ -272,7 +272,7 @@ pl_load_built_in_fonts(const char *pathname, gs_memory_t *mem, pl_dict_t *pfontd
if (fcoHandle == 0 &&
(status = gx_UFST_open_static_fco(pthnm, &fcoHandle)) != 0) {
- dprintf2("CGIFfco_Open error %d for %s\n", status, pthnm);
+ dmprintf2(mem, "CGIFfco_Open error %d for %s\n", status, pthnm);
continue;
}
/* enumerat the files in this fco */
@@ -284,7 +284,7 @@ pl_load_built_in_fonts(const char *pathname, gs_memory_t *mem, pl_dict_t *pfontd
"TTFONTINFO buffer" );
if (pBuffer == 0) {
- dprintf1("VM error for built-in font %d", i);
+ dmprintf1(mem, "VM error for built-in font %d", i);
continue;
}
status = CGIFfco_Access( FSA
@@ -294,7 +294,7 @@ pl_load_built_in_fonts(const char *pathname, gs_memory_t *mem, pl_dict_t *pfontd
&bSize,
pBuffer );
if (status != 0)
- dprintf1("CGIFfco_Access error %d\n", status);
+ dmprintf1(mem, "CGIFfco_Access error %d\n", status);
else {
TTFONTINFOTYPE * pfDesc = (TTFONTINFOTYPE *)pBuffer;
LPSB8 pname = pBuffer + pfDesc->psname;
@@ -318,7 +318,7 @@ pl_load_built_in_fonts(const char *pathname, gs_memory_t *mem, pl_dict_t *pfontd
/ pfDesc->scaleFactor + 0.5;
#ifdef DEBUG
if (gs_debug_c('=') )
- dprintf2("Loading %s from fco %s\n", pname, fcos[k] );
+ dmprintf2(mem, "Loading %s from fco %s\n", pname, fcos[k] );
#endif
/* Record the differing points per inch value
for Intellifont derived fonts. */
@@ -330,7 +330,7 @@ pl_load_built_in_fonts(const char *pathname, gs_memory_t *mem, pl_dict_t *pfontd
}
#ifdef DEBUG
if (gs_debug_c('=') )
- dprintf3("scale factor=%d, pitch (cp)=%d per_inch_x100=%d\n", pfDesc->scaleFactor, pitch_cp, (uint)(720000.0/pitch_cp));
+ dmprintf3(mem, "scale factor=%d, pitch (cp)=%d per_inch_x100=%d\n", pfDesc->scaleFactor, pitch_cp, (uint)(720000.0/pitch_cp));
#endif
plfont->font_type = resident_table[j].font_type;
@@ -366,7 +366,7 @@ pl_load_built_in_fonts(const char *pathname, gs_memory_t *mem, pl_dict_t *pfontd
(void)pl_load_ufst_lineprinter(mem, pfontdict, pdir, storage, use_unicode_names_for_keys);
#ifdef DEBUG
if (gs_debug_c('=') )
- pl_check_fonts(pfontdict, use_unicode_names_for_keys);
+ pl_check_fonts(mem, pfontdict, use_unicode_names_for_keys);
#endif
return TRUE;
}
diff --git a/pxl/pxffont.c b/pxl/pxffont.c
index 97c7704f6..fe9f1faff 100644
--- a/pxl/pxffont.c
+++ b/pxl/pxffont.c
@@ -101,14 +101,14 @@ px_find_existing_font(px_value_t *pfnv, px_font_t **ppxfont,
*ppxfont = pxfont;
else {
/* in the process of being downloaded. */
- dprintf("font is being downloaded???\n");
+ dmprintf(pxs->memory, "font is being downloaded???\n");
return -1;
}
} else if ( px_dict_find(&pxs->builtin_font_dict, pfnv, &pxfont) )
if ( ((px_font_t *)pxfont)->pfont )
*ppxfont = pxfont;
else {
- dprintf("corrupt pxl builtin font\n");
+ dmprintf(pxs->memory, "corrupt pxl builtin font\n");
return -1;
}
else
diff --git a/pxl/pxfont.c b/pxl/pxfont.c
index c794586d6..13bd7e3bb 100644
--- a/pxl/pxfont.c
+++ b/pxl/pxfont.c
@@ -305,7 +305,7 @@ px_str_to_gschars( px_args_t *par, px_state_t *pxs, gs_char *pchr)
pchr[i] = pl_map_symbol((db ? NULL : psm), chr,
pxs->pxgs->base_font->storage == pxfsInternal,
false /* pxl does not support MSL */,
- symbol_set == 590);
+ symbol_set == 590, pxs->memory);
}
}
diff --git a/pxl/pxgstate.c b/pxl/pxgstate.c
index e3a0e2134..fd2a97d13 100644
--- a/pxl/pxgstate.c
+++ b/pxl/pxgstate.c
@@ -919,7 +919,7 @@ int
pxBeginUserDefinedLineCap(px_args_t *par, px_state_t *pxs)
{
- dprintf("undocumented\n" );
+ dmprintf(pxs->memory, "undocumented\n" );
return 0;
}
@@ -928,7 +928,7 @@ int
pxEndUserDefinedLineCap(px_args_t *par, px_state_t *pxs)
{
- dprintf("undocumented\n" );
+ dmprintf(pxs->memory, "undocumented\n" );
return 0;
}
@@ -1034,7 +1034,7 @@ pxSetPageScale(px_args_t *par, px_state_t *pxs)
sy = pxs->units_per_measure.y / suy;
/* check for overflow. NB we should do a better job here */
if ( fabs(sx) > 1000.0 ) {
- dprintf2("warning probable overflow avoided for scaling factors %f %f\n",
+ dmprintf2(pxs->memory, "warning probable overflow avoided for scaling factors %f %f\n",
sx, sy );
sx = sy = 1;
}
diff --git a/pxl/pximage.c b/pxl/pximage.c
index a65070abf..346c12260 100644
--- a/pxl/pximage.c
+++ b/pxl/pximage.c
@@ -166,7 +166,7 @@ begin_bitmap(px_bitmap_params_t *params, px_bitmap_enum_t *benum,
static int
stream_error(stream_state * st, const char *str)
{
- dprintf1("pxl stream error %s\n", str );
+ dmprintf1(st->memory, "pxl stream error %s\n", str );
return 0;
}
diff --git a/pxl/pxink.c b/pxl/pxink.c
index 8f7fbe92f..4a93d0c7e 100644
--- a/pxl/pxink.c
+++ b/pxl/pxink.c
@@ -449,7 +449,7 @@ px_needs_halftone(const gs_memory_t *mem, px_paint_t *ppt)
}
}
} else {
- dprintf("unknown paint type\n");
+ dmprintf(mem, "unknown paint type\n");
needs_halftone = true;
}
return needs_halftone;
@@ -547,7 +547,7 @@ set_source(const px_args_t *par, px_state_t *pxs, px_paint_t *ppt)
else if ( pxgs->color_space == eSRGB )
ppt->type = pxpSRGB;
else {
- dprintf1("Warning unknown color space %d\n", pxgs->color_space);
+ dmprintf1(pxgs->memory, "Warning unknown color space %d\n", pxgs->color_space);
ppt->type = pxpGray;
}
/* NB depth?? - for range checking */
diff --git a/pxl/pxparse.c b/pxl/pxparse.c
index 510857e13..f9c6f5837 100644
--- a/pxl/pxparse.c
+++ b/pxl/pxparse.c
@@ -255,16 +255,16 @@ px_save_array(px_value_t *pv, px_state_t *pxs, client_name_t cname,
/* Define data tracing if debugging. */
#ifdef DEBUG
-# define trace_data(format, cast, ptr, count)\
+# define trace_data(mem, format, cast, ptr, count)\
do\
{ uint i_;\
for ( i_ = 0; i_ < count; ++i_ )\
- dprintf1(format, (cast)((ptr)[i_]));\
- dputc('\n');\
+ dmprintf1(mem, format, (cast)((ptr)[i_]));\
+ dmputc(mem, '\n');\
}\
while (0)
static void
-trace_array_data(const char *label, const px_value_t *pav)
+trace_array_data(const gs_memory_t *mem, const char *label, const px_value_t *pav)
{ px_data_type_t type = pav->type;
const byte *ptr = pav->value.array.data;
uint count = pav->value.array.size;
@@ -272,46 +272,46 @@ trace_array_data(const char *label, const px_value_t *pav)
bool text = (type & pxd_ubyte) != 0;
uint i;
- dputs(label);
- dputs((type & pxd_ubyte ? " <" : " {"));
+ dmputs(mem, label);
+ dmputs(mem, (type & pxd_ubyte ? " <" : " {"));
for ( i = 0; i < count; ++i )
{ if ( !(i & 15) && i )
{ const char *p;
- dputs("\n ");
+ dmputs(mem, "\n ");
for ( p = label; *p; ++p )
- dputc(' ');
+ dmputc(mem, ' ');
}
if ( type & pxd_ubyte )
- { dprintf1("%02x ", ptr[i]);
+ { dmprintf1(mem, "%02x ", ptr[i]);
if ( ptr[i] < 32 || ptr[i] > 126 )
text = false;
}
else if ( type & pxd_uint16 )
- dprintf1("%u ", uint16at(ptr + i * 2, big_endian));
+ dmprintf1(mem, "%u ", uint16at(ptr + i * 2, big_endian));
else if ( type & pxd_sint16 )
- dprintf1("%d ", sint16at(ptr + i * 2, big_endian));
+ dmprintf1(mem, "%d ", sint16at(ptr + i * 2, big_endian));
else if ( type & pxd_uint32 )
- dprintf1("%lu ", (ulong)uint32at(ptr + i * 4, big_endian));
+ dmprintf1(mem, "%lu ", (ulong)uint32at(ptr + i * 4, big_endian));
else if ( type & pxd_sint32 )
- dprintf1("%ld ", (long)sint32at(ptr + i * 4, big_endian));
+ dmprintf1(mem, "%ld ", (long)sint32at(ptr + i * 4, big_endian));
else if ( type & pxd_real32 )
- dprintf1("%g ", real32at(ptr + i * 4, big_endian));
+ dmprintf1(mem, "%g ", real32at(ptr + i * 4, big_endian));
else
- dputs("? ");
+ dmputs(mem, "? ");
}
- dputs((type & pxd_ubyte ? ">\n" : "}\n"));
+ dmputs(mem, (type & pxd_ubyte ? ">\n" : "}\n"));
if ( text )
- { dputs("%chars: \"");
- debug_print_string(ptr, count);
- dputs("\"\n");
+ { dmputs(mem, "%chars: \"");
+ debug_print_string(mem, ptr, count);
+ dmputs(mem, "\"\n");
}
}
-# define trace_array(pav)\
+# define trace_array(mem,pav)\
if ( gs_debug_c('I') )\
- trace_array_data("array:", pav)
+ trace_array_data(mem,"array:", pav)
#else
-# define trace_data(format, cast, ptr, count) DO_NOTHING
-# define trace_array(pav) DO_NOTHING
+# define trace_data(mem, format, cast, ptr, count) DO_NOTHING
+# define trace_array(mem,pav) DO_NOTHING
#endif
/* Process a buffer of PCL XL commands. */
@@ -364,7 +364,7 @@ top: if ( st->data_left )
data_array.type = pxd_ubyte;
data_array.value.array.data = p + 1;
data_array.value.array.size = used;
- trace_array_data("data:", &data_array);
+ trace_array_data(pxs->memory,"data:", &data_array);
}
#endif
p = st->args.source.data - 1;
@@ -406,7 +406,7 @@ top: if ( st->data_left )
}
/* Complete the array and continue parsing. */
memcpy(dest, p + 1, st->data_left);
- trace_array(sp);
+ trace_array(memory, sp);
p += st->data_left;
}
st->data_left = 0;
@@ -426,16 +426,16 @@ top: if ( st->data_left )
if ( left < 5 )
goto x; /* can't look ahead */
st->data_left = get_uint32(st, p + 2);
- if_debug2('i', "tag= 0x%2x data, length %u\n",
- p[1], st->data_left);
+ if_debug2m('i', memory, "tag= 0x%2x data, length %u\n",
+ p[1], st->data_left);
p += 5;
goto top;
case pxt_dataLengthByte:
if ( left < 2 )
goto x; /* can't look ahead */
st->data_left = p[2];
- if_debug2('i', "tag= 0x%2x data, length %u\n",
- p[1], st->data_left);
+ if_debug2m('i', memory, "tag= 0x%2x data, length %u\n",
+ p[1], st->data_left);
p += 2;
goto top;
default:
@@ -453,15 +453,15 @@ top: if ( st->data_left )
{ int count;
#ifdef DEBUG
if ( gs_debug_c('i') )
- { dprintf1("tag= 0x%02x ", tag);
+ { dmprintf1(memory, "tag= 0x%02x ", tag);
if ( tag == pxt_attr_ubyte || tag == pxt_attr_uint16 )
{ px_attribute_t attr =
(tag == pxt_attr_ubyte ? p[2] : get_uint16(st, p + 2));
const char *aname = px_attribute_names[attr];
if ( aname )
- dprintf1(" @%s\n", aname);
+ dmprintf1(memory, " @%s\n", aname);
else
- dprintf1(" attribute %u ???\n", attr);
+ dmprintf1(memory, " attribute %u ???\n", attr);
}
else
{ const char *format;
@@ -480,12 +480,12 @@ top: if ( st->data_left )
format = "%s\n";
}
if ( tname ) {
- dprintf1(format, tname);
+ dmprintf1(memory, format, tname);
if (operator)
- dprintf1(" (%ld)\n", st->operator_count+1);
+ dmprintf1(memory, " (%ld)\n", st->operator_count+1);
}
else
- dputs("???\n");
+ dmputs(memory, "???\n");
}
}
#endif
@@ -657,11 +657,11 @@ data: { int i;
sp->attribute = 0;
p += 2;
#ifdef DEBUG
-# define trace_scalar(format, cast, alt)\
+# define trace_scalar(mem, format, cast, alt)\
if ( gs_debug_c('i') )\
- trace_data(format, cast, sp->value.alt, count)
+ trace_data(mem, format, cast, sp->value.alt, count)
#else
-# define trace_scalar(format, cast, alt) DO_NOTHING
+# define trace_scalar(mem, format, cast, alt) DO_NOTHING
#endif
switch ( tag & 7 )
{
@@ -669,7 +669,7 @@ data: { int i;
sp->type |= pxd_ubyte;
for ( i = 0; i < count; ++p, ++i )
sp->value.ia[i] = *p;
-dux: trace_scalar(" %lu", ulong, ia);
+dux: trace_scalar(pxs->memory, " %lu", ulong, ia);
--p;
continue;
case pxt_uint16 & 7:
@@ -686,7 +686,7 @@ dux: trace_scalar(" %lu", ulong, ia);
sp->type |= pxd_sint16;
for ( i = 0; i < count; p += 2, ++i )
sp->value.ia[i] = get_sint16(st, p);
-dsx: trace_scalar(" %ld", long, ia);
+dsx: trace_scalar(pxs->memory, " %ld", long, ia);
--p;
continue;
case pxt_sint32 & 7:
@@ -698,7 +698,7 @@ dsx: trace_scalar(" %ld", long, ia);
sp->type |= pxd_real32;
for ( i = 0; i < count; p += 4, ++i )
sp->value.ra[i] = get_real32(st, p);
- trace_scalar(" %g", double, ra);
+ trace_scalar(pxs->memory, " %g", double, ra);
--p;
continue;
default:
@@ -722,7 +722,7 @@ dsx: trace_scalar(" %ld", long, ia);
break;
case pxt_uint16:
if ( left < 4 )
- { if_debug0('i', "...\n");
+ { if_debug0m('i', memory, "...\n");
/* Undo the state transition. */
st->macro_state ^= syntax->state_transition;
goto x;
@@ -736,7 +736,7 @@ dsx: trace_scalar(" %ld", long, ia);
goto x;
}
nbytes = sp[1].value.array.size;
- if_debug1('i', "[%u]\n", sp[1].value.array.size);
+ if_debug1m('i', memory, "[%u]\n", sp[1].value.array.size);
switch ( tag )
{
case pxt_ubyte_array:
@@ -763,7 +763,7 @@ array: ++sp;
goto x;
}
p = dp + nbytes - 1;
- trace_array(sp);
+ trace_array(memory, sp);
continue;
case pxt_uint16_array:
sp[1].type = pxd_array | pxd_uint16;
diff --git a/pxl/pxpthr.c b/pxl/pxpthr.c
index 9977351e0..84ef8051d 100644
--- a/pxl/pxpthr.c
+++ b/pxl/pxpthr.c
@@ -94,15 +94,15 @@ pxPassthrough_pcl_state_nonpage_exceptions(px_state_t *pxs)
global_pcs->cap.x = 0;
global_pcs->cap.y = inch2coord(2.0/6.0); /* 1/6" off by 2x in resolution. */
if (gs_debug_c('i'))
- dprintf2("passthrough: changing cap NO currentpoint (%d, %d) \n",
- global_pcs->cap.x, global_pcs->cap.y);
+ dmprintf2(pxs->memory, "passthrough: changing cap NO currentpoint (%d, %d) \n",
+ global_pcs->cap.x, global_pcs->cap.y);
} else {
if (gs_debug_c('i'))
- dprintf8("passthrough: changing cap from (%d,%d) (%d,%d) (%d, %d) (%d, %d) \n",
- global_pcs->cap.x, global_pcs->cap.y,
- (coord)xlcp.x, (coord)xlcp.y,
- (coord)dp.x, (coord)dp.y,
- (coord)pclcp.x, (coord)pclcp.y);
+ dmprintf8(pxs->memory, "passthrough: changing cap from (%d,%d) (%d,%d) (%d, %d) (%d, %d) \n",
+ global_pcs->cap.x, global_pcs->cap.y,
+ (coord)xlcp.x, (coord)xlcp.y,
+ (coord)dp.x, (coord)dp.y,
+ (coord)pclcp.x, (coord)pclcp.y);
global_pcs->cap.x = (coord)pclcp.x;
global_pcs->cap.y = (coord)pclcp.y;
}
@@ -130,7 +130,7 @@ pxPassthrough_init(px_state_t *pxs)
int code;
if (gs_debug_c('i'))
- dprintf("passthrough: initializing global pcl state\n");
+ dmprintf(pxs->memory, "passthrough: initializing global pcl state\n");
global_pcs = pcl_get_gstate(pxs->pcls);
/* default to pcl5c */
@@ -188,7 +188,7 @@ pxPassthrough_setpagestate(px_state_t *pxs)
the page */
if ( pxs->have_page ) {
if (gs_debug_c('i'))
- dprintf("passthrough: snippet mode\n");
+ dmprintf(pxs->memory, "passthrough: snippet mode\n");
/* disable an end page in pcl, also used to flag in snippet mode */
global_pcs->end_page = pcl_end_page_noop;
/* set the page size and orientation. Really just sets
@@ -198,8 +198,8 @@ pxPassthrough_setpagestate(px_state_t *pxs)
&pxs->media_dims);
if (gs_debug_c('i'))
- dprintf2("passthrough: snippet mode changing orientation from %d to %d\n",
- global_pcs->xfm_state.lp_orient, (int)pxs->orientation);
+ dmprintf2(pxs->memory, "passthrough: snippet mode changing orientation from %d to %d\n",
+ global_pcs->xfm_state.lp_orient, (int)pxs->orientation);
} else { /* not snippet mode - full page mode */
/* pcl can feed the page and presumedely pcl commands will
@@ -210,7 +210,7 @@ pxPassthrough_setpagestate(px_state_t *pxs)
global_pcs->page_marked = 0;
pcl_new_logical_page_for_passthrough(global_pcs, (int)pxs->orientation, &pxs->media_dims);
if (gs_debug_c('i'))
- dprintf("passthrough: full page mode\n");
+ dmprintf(pxs->memory, "passthrough: full page mode\n");
}
}
@@ -225,7 +225,7 @@ pxPassthrough(px_args_t *par, px_state_t *pxs)
spec this should already be open, in practice it is not. */
if ( !pxs->data_source_open ) {
if (gs_debug_c('i'))
- dprintf("passthrough: data source not open upon entry\n");
+ dmprintf(pxs->memory, "passthrough: data source not open upon entry\n");
pxs->data_source_open = true;
pxs->data_source_big_endian = true;
}
@@ -235,7 +235,7 @@ pxPassthrough(px_args_t *par, px_state_t *pxs)
if ( par->source.available == 0 ) {
if (par->source.phase == 0) {
if (gs_debug_c('i'))
- dprintf("passthrough starting getting more data\n");
+ dmprintf(pxs->memory, "passthrough starting getting more data\n");
if ( !global_pcs )
pxPassthrough_init(pxs);
@@ -270,14 +270,14 @@ pxPassthrough(px_args_t *par, px_state_t *pxs)
par->source.data = r.ptr + 1;
if ( code < 0 ) {
- dprintf1("passthrough: error return %d\n", code);
+ dmprintf1(pxs->memory, "passthrough: error return %d\n", code);
return code;
}
/* always return need data and we exit at the top when the data is
exhausted. */
{
if (used > px_parser_data_left(par->parser)) {
- dprintf("error: read past end of stream\n");
+ dmprintf(pxs->memory, "error: read past end of stream\n");
return -1;
} else if (used < px_parser_data_left(par->parser)) {
return pxNeedData;
@@ -305,7 +305,7 @@ pxpcl_release(void)
{
if (global_pcs) {
if (gs_debug_c('i'))
- dprintf("passthrough: releasing global pcl state\n");
+ dmprintf(global_pcs->memory, "passthrough: releasing global pcl state\n");
pcl_grestore(global_pcs);
gs_grestore_only(global_pcs->pgs);
gs_nulldevice(global_pcs->pgs);
diff --git a/pxl/pxsessio.c b/pxl/pxsessio.c
index ad24fc10a..fb73ff2e2 100644
--- a/pxl/pxsessio.c
+++ b/pxl/pxsessio.c
@@ -258,7 +258,7 @@ pxBeginSession(px_args_t *par, px_state_t *pxs)
pxs->font_dir,
(int)pxfsInternal,
true /* use unicode key names */) < 0 ) {
- dprintf("Fatal error - no resident fonts\n");
+ dmprintf(pxs->memory, "Fatal error - no resident fonts\n");
return -1;
}
diff --git a/svg/svgshapes.c b/svg/svgshapes.c
index 032e086f3..498d16bb2 100644
--- a/svg/svgshapes.c
+++ b/svg/svgshapes.c
@@ -358,7 +358,7 @@ svg_parse_path_data(svg_context_t *ctx, char *str)
case 'M':
if (nargs == 2)
{
- // dprintf2("moveto %g %g\n", args[0], args[1]);
+ // dmprintf2(ctx->memory, "moveto %g %g\n", args[0], args[1]);
gs_moveto(ctx->pgs, args[0], args[1]);
nargs = 0;
cmd = 'L'; /* implicit lineto after */
@@ -368,7 +368,7 @@ svg_parse_path_data(svg_context_t *ctx, char *str)
case 'm':
if (nargs == 2)
{
- // dprintf2("rmoveto %g %g\n", args[0], args[1]);
+ // dmprintf2(ctx->memory, "rmoveto %g %g\n", args[0], args[1]);
gs_rmoveto(ctx->pgs, args[0], args[1]);
nargs = 0;
cmd = 'l'; /* implicit lineto after */
@@ -379,7 +379,7 @@ svg_parse_path_data(svg_context_t *ctx, char *str)
case 'z':
if (nargs == 0)
{
- // dprintf("closepath\n");
+ // dmprintf(ctx->memory, "closepath\n");
gs_closepath(ctx->pgs);
}
break;
@@ -387,7 +387,7 @@ svg_parse_path_data(svg_context_t *ctx, char *str)
case 'L':
if (nargs == 2)
{
- // dprintf2("lineto %g %g\n", args[0], args[1]);
+ // dmprintf2(ctx->memory, "lineto %g %g\n", args[0], args[1]);
gs_lineto(ctx->pgs, args[0], args[1]);
nargs = 0;
}
@@ -396,7 +396,7 @@ svg_parse_path_data(svg_context_t *ctx, char *str)
case 'l':
if (nargs == 2)
{
- // dprintf2("rlineto %g %g\n", args[0], args[1]);
+ // dmprintf2(ctx->memory, "rlineto %g %g\n", args[0], args[1]);
gs_rlineto(ctx->pgs, args[0], args[1]);
nargs = 0;
}
@@ -406,7 +406,7 @@ svg_parse_path_data(svg_context_t *ctx, char *str)
if (nargs == 1)
{
gs_currentpoint(ctx->pgs, &pt);
- // dprintf1("hlineto %g\n", args[0]);
+ // dmprintf1(ctx->memory, "hlineto %g\n", args[0]);
gs_lineto(ctx->pgs, args[0], pt.y);
nargs = 0;
}
@@ -415,7 +415,7 @@ svg_parse_path_data(svg_context_t *ctx, char *str)
case 'h':
if (nargs == 1)
{
- // dprintf1("rhlineto %g\n", args[0]);
+ // dmprintf1(ctx->memory, "rhlineto %g\n", args[0]);
gs_rlineto(ctx->pgs, args[0], 0.0);
nargs = 0;
}
@@ -425,7 +425,7 @@ svg_parse_path_data(svg_context_t *ctx, char *str)
if (nargs == 1)
{
gs_currentpoint(ctx->pgs, &pt);
- // dprintf1("vlineto %g\n", args[0]);
+ // dmprintf1(ctx->memory, "vlineto %g\n", args[0]);
gs_lineto(ctx->pgs, pt.x, args[0]);
nargs = 0;
}
@@ -434,7 +434,7 @@ svg_parse_path_data(svg_context_t *ctx, char *str)
case 'v':
if (nargs == 1)
{
- // dprintf1("rvlineto %g\n", args[0]);
+ // dmprintf1(ctx->memory, "rvlineto %g\n", args[0]);
gs_rlineto(ctx->pgs, 0.0, args[0]);
nargs = 0;
}
diff --git a/svg/svgtop.c b/svg/svgtop.c
index 546480634..8b42cd781 100644
--- a/svg/svgtop.c
+++ b/svg/svgtop.c
@@ -88,7 +88,7 @@ svg_imp_allocate_interp_instance(pl_interp_instance_t **ppinstance,
svg_context_t *ctx;
gs_state *pgs;
- dputs("-- svg_imp_allocate_interp_instance --\n");
+ dmputs(pmem, "-- svg_imp_allocate_interp_instance --\n");
instance = (svg_interp_instance_t *) gs_alloc_bytes(pmem,
sizeof(svg_interp_instance_t), "svg_imp_allocate_interp_instance");
@@ -183,7 +183,7 @@ svg_imp_set_device(pl_interp_instance_t *pinstance, gx_device *pdevice)
svg_context_t *ctx = instance->ctx;
int code;
- dputs("-- svg_imp_set_device --\n");
+ dmputs(ctx->memory, "-- svg_imp_set_device --\n");
gs_opendevice(pdevice);
@@ -246,7 +246,7 @@ svg_imp_process_file(pl_interp_instance_t *pinstance, char *filename)
char buf[4096];
int n;
- dprintf1("svg_imp_process_file %s\n", filename);
+ dmprintf1(ctx->memory, "svg_imp_process_file %s\n", filename);
file = fopen(filename, "rb");
if (!file)
@@ -321,7 +321,7 @@ svg_imp_process_eof(pl_interp_instance_t *pinstance)
svg_item_t *root;
int code;
- dputs("-- svg_imp_process_eof --\n");
+ dmputs(ctx->memory, "-- svg_imp_process_eof --\n");
root = svg_close_xml_parser(ctx);
if (!root)
@@ -354,7 +354,7 @@ svg_imp_init_job(pl_interp_instance_t *pinstance)
svg_interp_instance_t *instance = (svg_interp_instance_t *)pinstance;
svg_context_t *ctx = instance->ctx;
- dputs("-- svg_imp_init_job --\n");
+ dmputs(ctx->memory, "-- svg_imp_init_job --\n");
return svg_open_xml_parser(ctx);
}
@@ -363,7 +363,10 @@ svg_imp_init_job(pl_interp_instance_t *pinstance)
static int
svg_imp_dnit_job(pl_interp_instance_t *pinstance)
{
- dputs("-- svg_imp_dnit_job --\n");
+ svg_interp_instance_t *instance = (svg_interp_instance_t *)pinstance;
+ svg_context_t *ctx = instance->ctx;
+
+ dmputs(ctx->memory, "-- svg_imp_dnit_job --\n");
return 0;
}
@@ -378,7 +381,7 @@ svg_imp_remove_device(pl_interp_instance_t *pinstance)
int code = 0; /* first error status encountered */
int error;
- dputs("-- svg_imp_remove_device --\n");
+ dmputs(ctx->memory, "-- svg_imp_remove_device --\n");
/* return to original gstate */
gs_grestore_only(ctx->pgs); /* destroys gs_save stack */
@@ -400,7 +403,7 @@ svg_imp_deallocate_interp_instance(pl_interp_instance_t *pinstance)
svg_context_t *ctx = instance->ctx;
gs_memory_t *mem = ctx->memory;
- dputs("-- svg_imp_deallocate_interp_instance --\n");
+ dmputs(mem, "-- svg_imp_deallocate_interp_instance --\n");
/* language clients don't free the font cache machinery */
diff --git a/xps/ghostxps.h b/xps/ghostxps.h
index bd1cfa5f8..37b2bbf90 100644
--- a/xps/ghostxps.h
+++ b/xps/ghostxps.h
@@ -309,7 +309,7 @@ int xps_parse_resource_dictionary(xps_context_t *ctx, xps_resource_t **dictp, ch
void xps_free_resource_dictionary(xps_context_t *ctx, xps_resource_t *dict);
void xps_resolve_resource_reference(xps_context_t *ctx, xps_resource_t *dict, char **attp, xps_item_t **tagp, char **urip);
-void xps_debug_resource_dictionary(xps_resource_t *dict);
+void xps_debug_resource_dictionary(xps_context_t *ctx, xps_resource_t *dict);
/*
* Fixed page/graphics parsing.
diff --git a/xps/xpsanalyze.c b/xps/xpsanalyze.c
index 5903b47d1..8a85f59b5 100644
--- a/xps/xpsanalyze.c
+++ b/xps/xpsanalyze.c
@@ -24,7 +24,7 @@
static int
xps_remote_resource_dictionary_has_transparency(xps_context_t *ctx, char *base_uri, char *source_att)
{
- //dputs("page has transparency: uses a remote resource; not parsed; being conservative\n");
+ //dmputs(ctx->memory, "page has transparency: uses a remote resource; not parsed; being conservative\n");
return 1;
}
@@ -64,7 +64,7 @@ xps_gradient_stops_have_transparency(xps_context_t *ctx, char *base_uri, xps_ite
xps_parse_color(ctx, base_uri, color_att, &colorspace, samples);
if (samples[0] < 1.0)
{
- //dputs("page has transparency: GradientStop has alpha\n");
+ //dmputs(ctx->memory, "page has transparency: GradientStop has alpha\n");
return 1;
}
}
@@ -85,7 +85,7 @@ xps_gradient_brush_has_transparency(xps_context_t *ctx, char *base_uri, xps_item
{
if (atof(opacity_att) < 1.0)
{
- //dputs("page has transparency: GradientBrush Opacity\n");
+ //dmputs(ctx->memory, "page has transparency: GradientBrush Opacity\n");
return 1;
}
}
@@ -125,7 +125,7 @@ xps_brush_has_transparency(xps_context_t *ctx, char *base_uri, xps_item_t *root)
float opacity = atof(opacity_att);
if (opacity < 1.0 && opacity != 0.0)
{
- //dputs("page has transparency: SolidColorBrush Opacity\n");
+ //dmputs(ctx->memory, "page has transparency: SolidColorBrush Opacity\n");
return 1;
}
}
@@ -136,7 +136,7 @@ xps_brush_has_transparency(xps_context_t *ctx, char *base_uri, xps_item_t *root)
xps_parse_color(ctx, base_uri, color_att, &colorspace, samples);
if (samples[0] < 1.0 && samples[0] != 0.0)
{
- //dputs("page has transparency: SolidColorBrush Color has alpha\n");
+ //dmputs(ctx->memory, "page has transparency: SolidColorBrush Color has alpha\n");
return 1;
}
}
@@ -149,7 +149,7 @@ xps_brush_has_transparency(xps_context_t *ctx, char *base_uri, xps_item_t *root)
{
if (atof(opacity_att) < 1.0)
{
- //dputs("page has transparency: VisualBrush Opacity\n");
+ //dmputs(ctx->memory, "page has transparency: VisualBrush Opacity\n");
return 1;
}
}
@@ -194,7 +194,7 @@ xps_path_has_transparency(xps_context_t *ctx, char *base_uri, xps_item_t *root)
{
if (!strcmp(xps_tag(node), "Path.OpacityMask"))
{
- //dputs("page has transparency: Path.OpacityMask\n");
+ //dmputs(ctx->memory, "page has transparency: Path.OpacityMask\n");
return 1;
}
@@ -223,7 +223,7 @@ xps_glyphs_has_transparency(xps_context_t *ctx, char *base_uri, xps_item_t *root
{
if (!strcmp(xps_tag(node), "Glyphs.OpacityMask"))
{
- //dputs("page has transparency: Glyphs.OpacityMask\n");
+ //dmputs(ctx->memory, "page has transparency: Glyphs.OpacityMask\n");
return 1;
}
@@ -252,7 +252,7 @@ xps_canvas_has_transparency(xps_context_t *ctx, char *base_uri, xps_item_t *root
if (!strcmp(xps_tag(node), "Canvas.OpacityMask"))
{
- //dputs("page has transparency: Canvas.OpacityMask\n");
+ //dmputs(ctx->memory, "page has transparency: Canvas.OpacityMask\n");
return 1;
}
@@ -279,7 +279,7 @@ xps_element_has_transparency(xps_context_t *ctx, char *base_uri, xps_item_t *nod
xps_parse_color(ctx, base_uri, stroke_att, &colorspace, samples);
if (samples[0] < 1.0 && samples[0] != 0.0)
{
- //dprintf1("page has transparency: Stroke alpha=%g\n", samples[0]);
+ //dmprintf1(ctx->memory, "page has transparency: Stroke alpha=%g\n", samples[0]);
return 1;
}
}
@@ -290,7 +290,7 @@ xps_element_has_transparency(xps_context_t *ctx, char *base_uri, xps_item_t *nod
xps_parse_color(ctx, base_uri, fill_att, &colorspace, samples);
if (samples[0] < 1.0 && samples[0] != 0.0)
{
- //dprintf1("page has transparency: Fill alpha=%g\n", samples[0]);
+ //dmprintf1(ctx->memory, "page has transparency: Fill alpha=%g\n", samples[0]);
return 1;
}
}
@@ -301,14 +301,14 @@ xps_element_has_transparency(xps_context_t *ctx, char *base_uri, xps_item_t *nod
float opacity = atof(opacity_att);
if (opacity < 1.0 && opacity != 0.0)
{
- //dprintf1("page has transparency: Opacity=%g\n", atof(opacity_att));
+ //dmprintf1(ctx->memory, "page has transparency: Opacity=%g\n", atof(opacity_att));
return 1;
}
}
if (xps_att(node, "OpacityMask"))
{
- //dputs("page has transparency: OpacityMask\n");
+ //dmputs(ctx->memory, "page has transparency: OpacityMask\n");
return 1;
}
diff --git a/xps/xpscff.c b/xps/xpscff.c
index 18342f4bc..b6ca4d537 100644
--- a/xps/xpscff.c
+++ b/xps/xpscff.c
@@ -607,7 +607,7 @@ xps_post_callback_decode_glyph(gs_font *p42, gs_glyph glyph, int ch)
static int
xps_post_callback_glyph_name(gs_font *pf, gs_glyph glyph, gs_const_string *pstr)
{
- dprintf1("asking for CFF glyph name %lu\n", (ulong)glyph);
+ dmprintf1(pf->memory, "asking for CFF glyph name %lu\n", (ulong)glyph);
return -1;
}
@@ -615,7 +615,7 @@ static int
xps_post_callback_glyph_info(gs_font *font, gs_glyph glyph,
const gs_matrix *pmat, int members, gs_glyph_info_t *info)
{
- dprintf1("asking for CFF glyph info %lu\n", (ulong)glyph);
+ dmprintf1(font->memory, "asking for CFF glyph info %lu\n", (ulong)glyph);
return -1;
}
@@ -623,7 +623,7 @@ static int
xps_post_callback_glyph_outline(gs_font *font, int wmode, gs_glyph glyph,
const gs_matrix *pmat, gx_path *ppath, double sbw[4])
{
- dprintf1("asking for CFF glyph outline %lu\n", (ulong)glyph);
+ dmprintf1(font->memory, "asking for CFF glyph outline %lu\n", (ulong)glyph);
return -1;
}
diff --git a/xps/xpsdoc.c b/xps/xpsdoc.c
index 85a56acd2..c4724ec71 100644
--- a/xps/xpsdoc.c
+++ b/xps/xpsdoc.c
@@ -53,17 +53,17 @@ xps_debug_fixdocseq(xps_context_t *ctx)
xps_page_t *page = ctx->first_page;
if (ctx->start_part)
- dprintf1("start part %s\n", ctx->start_part);
+ dmprintf1(ctx->memory, "start part %s\n", ctx->start_part);
while (fixdoc)
{
- dprintf1("fixdoc %s\n", fixdoc->name);
+ dmprintf1(ctx->memory, "fixdoc %s\n", fixdoc->name);
fixdoc = fixdoc->next;
}
while (page)
{
- dprintf3("page %s w=%d h=%d\n", page->name, page->width, page->height);
+ dmprintf3(ctx->memory, "page %s w=%d h=%d\n", page->name, page->width, page->height);
page = page->next;
}
}
@@ -78,7 +78,7 @@ xps_add_fixed_document(xps_context_t *ctx, char *name)
if (!strcmp(fixdoc->name, name))
return;
- if_debug1('|', "doc: adding fixdoc %s\n", name);
+ if_debug1m('|', ctx->memory, "doc: adding fixdoc %s\n", name);
fixdoc = xps_alloc(ctx, sizeof(xps_document_t));
fixdoc->name = xps_strdup(ctx, name);
@@ -121,7 +121,7 @@ xps_add_fixed_page(xps_context_t *ctx, char *name, int width, int height)
if (!strcmp(page->name, name))
return;
- if_debug1('|', "doc: adding page %s\n", name);
+ if_debug1m('|', ctx->memory, "doc: adding page %s\n", name);
page = xps_alloc(ctx, sizeof(xps_page_t));
page->name = xps_strdup(ctx, name);
diff --git a/xps/xpsglyphs.c b/xps/xpsglyphs.c
index d44eccca9..8847e3ee2 100644
--- a/xps/xpsglyphs.c
+++ b/xps/xpsglyphs.c
@@ -51,27 +51,27 @@ xps_debug_path(xps_context_t *ctx)
switch (seg->type)
{
case s_start:
- dprintf2("%g %g moveto\n",
- fixed2float(seg->pt.x) * 0.001,
- fixed2float(seg->pt.y) * 0.001);
+ dmprintf2(ctx->memory, "%g %g moveto\n",
+ fixed2float(seg->pt.x) * 0.001,
+ fixed2float(seg->pt.y) * 0.001);
break;
case s_line:
- dprintf2("%g %g lineto\n",
- fixed2float(seg->pt.x) * 0.001,
- fixed2float(seg->pt.y) * 0.001);
+ dmprintf2(ctx->memory, "%g %g lineto\n",
+ fixed2float(seg->pt.x) * 0.001,
+ fixed2float(seg->pt.y) * 0.001);
break;
case s_line_close:
- dputs("closepath\n");
+ dmputs(ctx->memory, "closepath\n");
break;
case s_curve:
cseg = (curve_segment*)seg;
- dprintf6("%g %g %g %g %g %g curveto\n",
- fixed2float(cseg->p1.x) * 0.001,
- fixed2float(cseg->p1.y) * 0.001,
- fixed2float(cseg->p2.x) * 0.001,
- fixed2float(cseg->p2.y) * 0.001,
- fixed2float(seg->pt.x) * 0.001,
- fixed2float(seg->pt.y) * 0.001);
+ dmprintf6(ctx->memory, "%g %g %g %g %g %g curveto\n",
+ fixed2float(cseg->p1.x) * 0.001,
+ fixed2float(cseg->p1.y) * 0.001,
+ fixed2float(cseg->p2.x) * 0.001,
+ fixed2float(cseg->p2.y) * 0.001,
+ fixed2float(seg->pt.x) * 0.001,
+ fixed2float(seg->pt.y) * 0.001);
break;
}
seg = seg->next;
@@ -168,7 +168,7 @@ xps_flush_text_buffer(xps_context_t *ctx, xps_font_t *font,
int code;
int i;
- // dprintf1("flushing text buffer (%d glyphs)\n", buf->count);
+ // dmprintf1(ctx->memory, "flushing text buffer (%d glyphs)\n", buf->count);
gs_moveto(ctx->pgs, x, y);
diff --git a/xps/xpsgradient.c b/xps/xpsgradient.c
index 4515b5677..efafd6795 100644
--- a/xps/xpsgradient.c
+++ b/xps/xpsgradient.c
@@ -693,7 +693,7 @@ xps_draw_radial_gradient(xps_context_t *ctx, xps_item_t *root, int spread, gs_fu
/* Draw current circle */
if (!point_inside_circle(x0, y0, x1, y1, r1))
- dputs("xps: we should reverse gradient here too\n");
+ dmputs(ctx->memory, "xps: we should reverse gradient here too\n");
if (spread == SPREAD_REFLECT && (i & 1))
code = xps_draw_one_radial_gradient(ctx, func, 0, x1, y1, r1, x0, y0, r0);
diff --git a/xps/xpsimage.c b/xps/xpsimage.c
index 6f0a05c86..39731b093 100644
--- a/xps/xpsimage.c
+++ b/xps/xpsimage.c
@@ -199,7 +199,7 @@ xps_decode_image(xps_context_t *ctx, xps_part_t *part, xps_image_t *image)
if (image->hasalpha)
{
if (image->bits < 8)
- dprintf1("cannot isolate alpha channel in %d bpc images\n", image->bits);
+ dmprintf1(ctx->memory, "cannot isolate alpha channel in %d bpc images\n", image->bits);
if (image->bits == 8)
xps_isolate_alpha_channel_8(ctx, image);
if (image->bits == 16)
diff --git a/xps/xpspage.c b/xps/xpspage.c
index 84945a727..bfd1d7393 100644
--- a/xps/xpspage.c
+++ b/xps/xpspage.c
@@ -123,7 +123,7 @@ xps_parse_fixed_page(xps_context_t *ctx, xps_part_t *part)
char *s;
int code;
- if_debug1('|', "doc: parsing page %s\n", part->name);
+ if_debug1m('|', ctx->memory, "doc: parsing page %s\n", part->name);
xps_strlcpy(base_uri, part->name, sizeof base_uri);
s = strrchr(base_uri, '/');
diff --git a/xps/xpspath.c b/xps/xpspath.c
index 9383b208d..260bc163c 100644
--- a/xps/xpspath.c
+++ b/xps/xpspath.c
@@ -263,7 +263,7 @@ xps_parse_abbreviated_geometry(xps_context_t *ctx, char *geom)
args = xps_alloc(ctx, sizeof(char*) * (strlen(geom) + 1));
pargs = args;
- //dprintf1("new path (%.70s)\n", geom);
+ //dmprintf1(ctx->memory, "new path (%.70s)\n", geom);
gs_newpath(ctx->pgs);
while (*s)
@@ -321,47 +321,47 @@ xps_parse_abbreviated_geometry(xps_context_t *ctx, char *geom)
case 'M':
gs_moveto(ctx->pgs, atof(args[i]), atof(args[i+1]));
- //dprintf2("moveto %g %g\n", atof(args[i]), atof(args[i+1]));
+ //dmprintf2(ctx->memory, "moveto %g %g\n", atof(args[i]), atof(args[i+1]));
i += 2;
break;
case 'm':
gs_rmoveto(ctx->pgs, atof(args[i]), atof(args[i+1]));
- //dprintf2("rmoveto %g %g\n", atof(args[i]), atof(args[i+1]));
+ //dmprintf2(ctx->memory, "rmoveto %g %g\n", atof(args[i]), atof(args[i+1]));
i += 2;
break;
case 'L':
gs_lineto(ctx->pgs, atof(args[i]), atof(args[i+1]));
- //dprintf2("lineto %g %g\n", atof(args[i]), atof(args[i+1]));
+ //dmprintf2(ctx->memory, "lineto %g %g\n", atof(args[i]), atof(args[i+1]));
i += 2;
break;
case 'l':
gs_rlineto(ctx->pgs, atof(args[i]), atof(args[i+1]));
- //dprintf2("rlineto %g %g\n", atof(args[i]), atof(args[i+1]));
+ //dmprintf2(ctx->memory, "rlineto %g %g\n", atof(args[i]), atof(args[i+1]));
i += 2;
break;
case 'H':
gs_currentpoint(ctx->pgs, &pt);
gs_lineto(ctx->pgs, atof(args[i]), pt.y);
- //dprintf1("hlineto %g\n", atof(args[i]));
+ //dmprintf1(ctx->memory, "hlineto %g\n", atof(args[i]));
i += 1;
break;
case 'h':
gs_rlineto(ctx->pgs, atof(args[i]), 0.0);
- //dprintf1("rhlineto %g\n", atof(args[i]));
+ //dmprintf1(ctx->memory, "rhlineto %g\n", atof(args[i]));
i += 1;
break;
case 'V':
gs_currentpoint(ctx->pgs, &pt);
gs_lineto(ctx->pgs, pt.x, atof(args[i]));
- //dprintf1("vlineto %g\n", atof(args[i]));
+ //dmprintf1(ctx->memory, "vlineto %g\n", atof(args[i]));
i += 1;
break;
case 'v':
gs_rlineto(ctx->pgs, 0.0, atof(args[i]));
- //dprintf1("rvlineto %g\n", atof(args[i]));
+ //dmprintf1(ctx->memory, "rvlineto %g\n", atof(args[i]));
i += 1;
break;
@@ -400,7 +400,7 @@ xps_parse_abbreviated_geometry(xps_context_t *ctx, char *geom)
y1 = atof(args[i+1]);
x2 = atof(args[i+2]);
y2 = atof(args[i+3]);
- //dprintf2("smooth %g %g\n", smooth_x, smooth_y);
+ //dmprintf2(ctx->memory, "smooth %g %g\n", smooth_x, smooth_y);
gs_curveto(ctx->pgs, pt.x + smooth_x, pt.y + smooth_y, x1, y1, x2, y2);
i += 4;
reset_smooth = 0;
@@ -414,7 +414,7 @@ xps_parse_abbreviated_geometry(xps_context_t *ctx, char *geom)
y1 = atof(args[i+1]) + pt.y;
x2 = atof(args[i+2]) + pt.x;
y2 = atof(args[i+3]) + pt.y;
- //dprintf2("smooth %g %g\n", smooth_x, smooth_y);
+ //dmprintf2(ctx->memory, "smooth %g %g\n", smooth_x, smooth_y);
gs_curveto(ctx->pgs, pt.x + smooth_x, pt.y + smooth_y, x1, y1, x2, y2);
i += 4;
reset_smooth = 0;
@@ -428,7 +428,7 @@ xps_parse_abbreviated_geometry(xps_context_t *ctx, char *geom)
y1 = atof(args[i+1]);
x2 = atof(args[i+2]);
y2 = atof(args[i+3]);
- //dprintf4("conicto %g %g %g %g\n", x1, y1, x2, y2);
+ //dmprintf4(ctx->memory, "conicto %g %g %g %g\n", x1, y1, x2, y2);
gs_curveto(ctx->pgs,
(pt.x + 2 * x1) / 3, (pt.y + 2 * y1) / 3,
(x2 + 2 * x1) / 3, (y2 + 2 * y1) / 3,
@@ -441,7 +441,7 @@ xps_parse_abbreviated_geometry(xps_context_t *ctx, char *geom)
y1 = atof(args[i+1]) + pt.y;
x2 = atof(args[i+2]) + pt.x;
y2 = atof(args[i+3]) + pt.y;
- //dprintf4("conicto %g %g %g %g\n", x1, y1, x2, y2);
+ //dmprintf4(ctx->memory, "conicto %g %g %g %g\n", x1, y1, x2, y2);
gs_curveto(ctx->pgs,
(pt.x + 2 * x1) / 3, (pt.y + 2 * y1) / 3,
(x2 + 2 * x1) / 3, (y2 + 2 * y1) / 3,
@@ -468,7 +468,7 @@ xps_parse_abbreviated_geometry(xps_context_t *ctx, char *geom)
case 'Z':
case 'z':
gs_closepath(ctx->pgs);
- //dputs("closepath\n");
+ //dmputs(ctx->memory, "closepath\n");
break;
default:
diff --git a/xps/xpsresource.c b/xps/xpsresource.c
index 3ad14fc15..88ac3e6aa 100644
--- a/xps/xpsresource.c
+++ b/xps/xpsresource.c
@@ -189,18 +189,18 @@ xps_free_resource_dictionary(xps_context_t *ctx, xps_resource_t *dict)
}
void
-xps_debug_resource_dictionary(xps_resource_t *dict)
+xps_debug_resource_dictionary(xps_context_t *ctx, xps_resource_t *dict)
{
while (dict)
{
if (dict->base_uri)
- dprintf1("URI = '%s'\n", dict->base_uri);
- dprintf2("KEY = '%s' VAL = %p\n", dict->name, dict->data);
+ dmprintf1(ctx->memory, "URI = '%s'\n", dict->base_uri);
+ dmprintf2(ctx->memory, "KEY = '%s' VAL = %p\n", dict->name, dict->data);
if (dict->parent)
{
- dputs("PARENT = {\n");
- xps_debug_resource_dictionary(dict->parent);
- dputs("}\n");
+ dmputs(ctx->memory, "PARENT = {\n");
+ xps_debug_resource_dictionary(ctx, dict->parent);
+ dmputs(ctx->memory, "}\n");
}
dict = dict->next;
}
diff --git a/xps/xpstop.c b/xps/xpstop.c
index 2e8ffa6a7..e6fa382c6 100644
--- a/xps/xpstop.c
+++ b/xps/xpstop.c
@@ -318,7 +318,7 @@ xps_imp_process(pl_interp_instance_t *pinstance, stream_cursor_read *cursor)
gs_catch(gs_error_invalidfileaccess, "cannot open scratch file");
return e_ExitLanguage;
}
- if_debug1('|', "xps: open scratch file '%s'\n", instance->scratch_name);
+ if_debug1m('|', ctx->memory, "xps: open scratch file '%s'\n", instance->scratch_name);
}
avail = cursor->limit - cursor->ptr;
@@ -354,7 +354,7 @@ xps_imp_process_eof(pl_interp_instance_t *pinstance)
if (instance->scratch_file)
{
- if_debug0('|', "xps: executing scratch file\n");
+ if_debug0m('|', ctx->memory, "xps: executing scratch file\n");
fclose(instance->scratch_file);
instance->scratch_file = NULL;
code = xps_process_file(ctx, instance->scratch_name);
diff --git a/xps/xpsttf.c b/xps/xpsttf.c
index ef160be46..b70868e74 100644
--- a/xps/xpsttf.c
+++ b/xps/xpsttf.c
@@ -202,7 +202,7 @@ xps_true_callback_glyph_name(gs_font *pfont, gs_glyph glyph, gs_const_string *ps
/* mac easy */
if ( glyph_name_index < 258 )
{
- // dprintf2("glyph name (mac) %d = %s\n", glyph, pl_mac_names[glyph_name_index]);
+ // dmprintf2(pfont->memory, "glyph name (mac) %d = %s\n", glyph, pl_mac_names[glyph_name_index]);
pstr->data = (byte*) pl_mac_names[glyph_name_index];
pstr->size = strlen((char*)pstr->data);
return 0;
@@ -262,7 +262,7 @@ xps_true_callback_build_char(gs_show_enum *penum, gs_state *pgs, gs_font *pfont,
gs_fixed_point saved_adjust;
int code;
- // dprintf1("build char ttf %d\n", glyph);
+ // dmprintf1(pfont->memory, "build char ttf %d\n", glyph);
code = gs_type42_get_metrics(p42, glyph, sbw);
if (code < 0)
diff --git a/xps/xpsxml.c b/xps/xpsxml.c
index 37d154d60..1d8dc2627 100644
--- a/xps/xpsxml.c
+++ b/xps/xpsxml.c
@@ -90,7 +90,7 @@ on_open_tag(void *zp, char *ns_name, char **atts)
if (!name)
{
- dprintf1("unknown namespace: %s\n", ns_name);
+ dmprintf1(ctx->memory, "unknown namespace: %s\n", ns_name);
name = ns_name;
}
diff --git a/xps/xpszip.c b/xps/xpszip.c
index 1e91e3504..b67046d92 100644
--- a/xps/xpszip.c
+++ b/xps/xpszip.c
@@ -98,7 +98,7 @@ xps_read_zip_entry(xps_context_t *ctx, xps_entry_t *ent, unsigned char *outbuf)
int namelength, extralength;
int code;
- if_debug1('|', "zip: inflating entry '%s'\n", ent->name);
+ if_debug1m('|', ctx->memory, "zip: inflating entry '%s'\n", ent->name);
fseek(ctx->file, ent->offset, 0);
@@ -233,10 +233,10 @@ xps_read_zip_dir(xps_context_t *ctx, int start_offset)
for (i = 0; i < ctx->zip_count; i++)
{
- if_debug3('|', "zip entry '%s' csize=%d usize=%d\n",
- ctx->zip_table[i].name,
- ctx->zip_table[i].csize,
- ctx->zip_table[i].usize);
+ if_debug3m('|', ctx->memory, "zip entry '%s' csize=%d usize=%d\n",
+ ctx->zip_table[i].name,
+ ctx->zip_table[i].csize,
+ ctx->zip_table[i].usize);
}
return gs_okay;
@@ -480,7 +480,7 @@ xps_process_file(xps_context_t *ctx, char *filename)
xps_part_t *part;
int size;
- if_debug0('|', "zip: single page mode\n");
+ if_debug0m('|', ctx->memory, "zip: single page mode\n");
xps_strlcpy(buf, filename, sizeof buf);
while (1)
{
@@ -490,19 +490,19 @@ xps_process_file(xps_context_t *ctx, char *filename)
if (!p)
break;
xps_strlcpy(p, "/_rels/.rels", buf + sizeof buf - p);
- if_debug1('|', "zip: testing if '%s' exists\n", buf);
+ if_debug1m('|', ctx->memory, "zip: testing if '%s' exists\n", buf);
if (isfile(buf))
{
*p = 0;
ctx->directory = xps_strdup(ctx, buf);
- if_debug1('|', "zip: using '%s' as root directory\n", ctx->directory);
+ if_debug1m('|', ctx->memory, "zip: using '%s' as root directory\n", ctx->directory);
break;
}
*p = 0;
}
if (!ctx->directory)
{
- if_debug0('|', "zip: no /_rels/.rels found; assuming absolute paths\n");
+ if_debug0m('|', ctx->memory, "zip: no /_rels/.rels found; assuming absolute paths\n");
ctx->directory = xps_strdup(ctx, "");
}
@@ -528,7 +528,7 @@ xps_process_file(xps_context_t *ctx, char *filename)
p = strstr(buf, "\\_rels\\.rels");
*p = 0;
ctx->directory = xps_strdup(ctx, buf);
- if_debug1('|', "zip: using '%s' as root directory\n", ctx->directory);
+ if_debug1m('|', ctx->memory, "zip: using '%s' as root directory\n", ctx->directory);
}
else
{