1 /* { dg-require-effective-target indirect_calls } */
2 
3 double sin(double x);
4 double cos(double x);
5 double tan(double x);
6 double asin(double x);
7 double acos(double x);
8 double atan(double x);
9 double atan2(double y, double x);
10 double sinh(double x);
11 double cosh(double x);
12 double tanh(double x);
13 double exp(double x);
14 double expm1(double x);
15 double log(double x);
16 double log10(double x);
17 double log1p(double x);
18 double pow(double x, double y);
19 double sqrt(double x);
20 double cbrt(double x);
21 double ceil(double x);
22 double floor(double x);
23 double fabs(double x);
24 double frexp(double value, int *eptr);
25 double ldexp(double value, int exp);
26 double modf(double value, double *iptr);
27 double erf(double x);
28 double erfc(double x);
29 double atof(const char *nptr);
30 double hypot(double x, double y);
31 double lgamma(double x);
32 double j0(double x);
33 double j1(double x);
34 double jn(int n, double x);
35 double y0(double x);
36 double y1(double x);
37 double yn(int n, double x);
38 extern struct _iobuf {
39  int _cnt;
40  char *_ptr;
41  char *_base;
42  int _bufsiz;
43  short _flag;
44  char _file;
45 } _iob[];
46 typedef __SIZE_TYPE__ size_t;
47 typedef char *va_list;
48 struct _iobuf *fopen(const char *filename, const char *type);
49 struct _iobuf *freopen(const char *filename, const char *type, struct _iobuf *stream);
50 struct _iobuf *fdopen(int fildes, const char *type);
51 struct _iobuf *popen(const char *command, const char *type);
52 int pclose(struct _iobuf *stream);
53 int fflush(struct _iobuf *stream);
54 int fclose(struct _iobuf *stream);
55 int remove(const char *path);
56 int rename(const char *from, const char *to);
57 struct _iobuf *tmpfile(void);
58 char *tmpnam(char *s);
59 int setvbuf(struct _iobuf *iop, char *buf, int type, size_t size);
60 int setbuf(struct _iobuf *stream, char *buf);
61 int setbuffer(struct _iobuf *stream, char *buf, size_t size);
62 int setlinebuf(struct _iobuf *stream);
63 int fprintf(struct _iobuf *stream, const char *format, ...);
64 int printf(const char *format, ...);
65 char *sprintf(char *s, const char *format, ...);
66 int vfprintf(struct _iobuf *stream, const char *format, va_list arg);
67 int vprintf(const char *format, va_list arg);
68 int vsprintf(char *s, const char *format, va_list arg);
69 int fscanf(struct _iobuf *stream, const char *format, ...);
70 int scanf(const char *format, ...);
71 int sscanf(char *s, const char *format, ...);
72 int fgetc(struct _iobuf *stream);
73 int getw(struct _iobuf *stream);
74 char *fgets(char *s, int n, struct _iobuf *stream);
75 char *gets(char *s);
76 int fputc(int c, struct _iobuf *stream);
77 int putw(int w, struct _iobuf *stream);
78 int fputs(const char *s, struct _iobuf *stream);
79 int puts(const char *s);
80 int ungetc(int c, struct _iobuf *stream);
81 int fread(void *ptr, size_t size, size_t count, struct _iobuf *iop);
82 int fwrite(const void *ptr, size_t size, size_t count, struct _iobuf *iop);
83 int fseek(struct _iobuf *stream, long offset, int ptrname);
84 long ftell(struct _iobuf *stream);
85 void rewind(struct _iobuf *stream);
86 int fgetpos(struct _iobuf *stream, long *pos);
87 int fsetpos(struct _iobuf *stream, const long *pos);
88 void perror(const char *s);
89 typedef unsigned char byte;
90 typedef unsigned char uchar;
91 typedef unsigned short ushort;
92 typedef unsigned int uint;
93 typedef unsigned long ulong;
94 typedef unsigned char u_char;
95 typedef unsigned short u_short;
96 typedef unsigned int u_int;
97 typedef unsigned long u_long;
98 typedef unsigned short ushort_;
99 typedef struct _physadr { int r[1]; } *physadr;
100 typedef struct label_t {
101  int val[11];
102 } label_t;
103 typedef struct _quad { long val[2]; } quad;
104 typedef long daddr_t;
105 typedef char * caddr_t;
106 typedef u_long ino_t;
107 typedef long swblk_t;
108 typedef long time_t;
109 typedef short dev_t;
110 typedef long off_t;
111 typedef u_short uid_t;
112 typedef u_short gid_t;
113 typedef signed char prio_t;
114 typedef long fd_mask;
115 typedef struct fd_set {
116  fd_mask fds_bits[(((256 )+(( (sizeof(fd_mask) * 8 ) )-1))/( (sizeof(fd_mask) * 8 ) )) ];
117 } fd_set;
118 typedef struct qhdr {
119  struct qhdr *link, *rlink;
120 } *queue_t;
121 typedef char *ptr_ord_t;
122 typedef double floatp;
123 typedef char *(*proc_alloc_t)(unsigned num_elements, unsigned element_size, const char *client_name );
124 typedef void (*proc_free_t)(char *data, unsigned num_elements, unsigned element_size, const char *client_name );
125 extern struct _iobuf *gs_out;
126 typedef struct gs_point_s {
127  double x, y;
128 } gs_point;
129 typedef struct gs_int_point_s {
130  int x, y;
131 } gs_int_point;
132 typedef struct gs_rect_s {
133  gs_point p, q;
134 } gs_rect;
135 typedef struct gs_int_rect_s {
136  gs_int_point p, q;
137 } gs_int_rect;
138 typedef struct gs_state_s gs_state;
139 typedef struct {
140  proc_alloc_t alloc;
141  proc_free_t free;
142 } gs_memory_procs;
143 char *gs_malloc(uint, uint, const char * );
144 void gs_free(char *, uint, uint, const char * );
145 extern char gs_debug[128];
146 extern int gs_log_error(int, const char *, int );
147 typedef long fixed;
148 typedef struct gs_fixed_point_s {
149  fixed x, y;
150 } gs_fixed_point;
151 typedef struct gs_fixed_rect_s {
152  gs_fixed_point p, q;
153 } gs_fixed_rect;
154 typedef struct gs_matrix_s {
155  long _xx; float xx; long _xy; float xy; long _yx; float yx; long _yy; float yy; long _tx; float tx; long _ty; float ty;
156 } gs_matrix;
157 void gs_make_identity(gs_matrix * );
158 int gs_make_translation(floatp, floatp, gs_matrix * ),
159  gs_make_scaling(floatp, floatp, gs_matrix * ),
160  gs_make_rotation(floatp, gs_matrix * );
161 int gs_matrix_multiply(const gs_matrix *, const gs_matrix *, gs_matrix * ),
162  gs_matrix_invert(const gs_matrix *, gs_matrix * ),
163  gs_matrix_rotate(const gs_matrix *, floatp, gs_matrix * );
164 int gs_point_transform(floatp, floatp, const gs_matrix *, gs_point * ),
165  gs_point_transform_inverse(floatp, floatp, const gs_matrix *, gs_point * ),
166  gs_distance_transform(floatp, floatp, const gs_matrix *, gs_point * ),
167  gs_distance_transform_inverse(floatp, floatp, const gs_matrix *, gs_point * ),
168  gs_bbox_transform_inverse(gs_rect *, gs_matrix *, gs_rect * );
169 typedef struct gs_matrix_fixed_s {
170  long _xx; float xx; long _xy; float xy; long _yx; float yx; long _yy; float yy; long _tx; float tx; long _ty; float ty;
171  fixed tx_fixed, ty_fixed;
172 } gs_matrix_fixed;
173 extern void gs_update_matrix_fixed(gs_matrix_fixed * );
174 int gs_point_transform2fixed(gs_matrix_fixed *, floatp, floatp, gs_fixed_point * ),
175  gs_distance_transform2fixed(gs_matrix_fixed *, floatp, floatp, gs_fixed_point * );
176 typedef struct {
177  long xx, xy, yx, yy;
178  int skewed;
179  int shift;
180  int max_bits;
181  fixed round;
182 } fixed_coeff;
183 
184 typedef enum {
185  gs_cap_butt = 0,
186  gs_cap_round = 1,
187  gs_cap_square = 2
188 } gs_line_cap;
189 typedef enum {
190  gs_join_miter = 0,
191  gs_join_round = 1,
192  gs_join_bevel = 2
193 } gs_line_join;
194 gs_state *gs_state_alloc(proc_alloc_t, proc_free_t );
195 int gs_state_free(gs_state * );
196 int gs_gsave(gs_state * ),
197  gs_grestore(gs_state * ),
198  gs_grestoreall(gs_state * );
199 gs_state *gs_gstate(gs_state * );
200 int gs_currentgstate(gs_state * , const gs_state * ),
201  gs_setgstate(gs_state * , const gs_state * );
202 gs_state *gs_state_swap_saved(gs_state *, gs_state * );
203 void gs_state_swap(gs_state *, gs_state * );
204 int gs_initgraphics(gs_state * );
205 typedef struct gx_device_s gx_device;
206 int gs_flushpage(gs_state * );
207 int gs_copypage(gs_state * );
208 int gs_output_page(gs_state *, int, int );
209 int gs_copyscanlines(gx_device *, int, byte *, uint, int *, uint * );
210 gx_device * gs_getdevice(int );
211 int gs_copydevice(gx_device **, gx_device *, proc_alloc_t );
212 int gs_makeimagedevice(gx_device **, gs_matrix *, uint, uint, byte *, int, proc_alloc_t );
213 void gs_nulldevice(gs_state * );
214 int gs_setdevice(gs_state *, gx_device * );
215 gx_device * gs_currentdevice(gs_state * );
216 const char * gs_devicename(gx_device * );
217 void gs_deviceinitialmatrix(gx_device *, gs_matrix * );
218 int gs_closedevice(gx_device * );
219 int gs_setlinewidth(gs_state *, floatp );
220 float gs_currentlinewidth(const gs_state * );
221 int gs_setlinecap(gs_state *, gs_line_cap );
222 gs_line_cap gs_currentlinecap(const gs_state * );
223 int gs_setlinejoin(gs_state *, gs_line_join );
224 gs_line_join gs_currentlinejoin(const gs_state * );
225 int gs_setmiterlimit(gs_state *, floatp );
226 float gs_currentmiterlimit(const gs_state * );
227 int gs_setdash(gs_state *, const float *, uint, floatp );
228 uint gs_currentdash_length(const gs_state * );
229 int gs_currentdash_pattern(const gs_state *, float * );
230 float gs_currentdash_offset(const gs_state * );
231 int gs_setflat(gs_state *, floatp );
232 float gs_currentflat(const gs_state * );
233 int gs_setstrokeadjust(gs_state *, int );
234 int gs_currentstrokeadjust(const gs_state * );
235 typedef enum {
236  gs_color_space_DeviceGray = 0,
237  gs_color_space_DeviceRGB,
238  gs_color_space_DeviceCMYK
239 } gs_color_space;
240 typedef struct gs_color_s gs_color;
241 extern const uint gs_color_sizeof;
242 int gs_setgray(gs_state *, floatp );
243 float gs_currentgray(gs_state * );
244 int gs_sethsbcolor(gs_state *, floatp, floatp, floatp ),
245  gs_currenthsbcolor(gs_state *, float [3] ),
246  gs_setrgbcolor(gs_state *, floatp, floatp, floatp ),
247  gs_currentrgbcolor(gs_state *, float [3] );
248 int gs_currentcolorspace(gs_state *, gs_color_space * );
249 typedef float (*gs_transfer_proc)(gs_state *, floatp );
250 int gs_settransfer(gs_state *, gs_transfer_proc ),
251  gs_settransfer_remap(gs_state *, gs_transfer_proc, int );
252 gs_transfer_proc gs_currenttransfer(gs_state * );
253 int gs_setcolortransfer(gs_state *, gs_transfer_proc ,
254  gs_transfer_proc , gs_transfer_proc ,
255  gs_transfer_proc ),
256  gs_setcolortransfer_remap(gs_state *, gs_transfer_proc ,
257  gs_transfer_proc , gs_transfer_proc ,
258  gs_transfer_proc , int );
259 void gs_currentcolortransfer(gs_state *, gs_transfer_proc [4] );
260 int gs_setscreen(gs_state *, floatp, floatp, float (*)(floatp, floatp ) );
261 int gs_currentscreen(gs_state *, float *, float *, float (**)(floatp, floatp ) );
262 int gs_sethalftonephase(gs_state *, int, int );
263 int gs_currenthalftonephase(gs_state *, gs_int_point * );
264 typedef struct gs_screen_enum_s gs_screen_enum;
265 extern const uint gs_screen_enum_sizeof;
266 int gs_screen_init(gs_screen_enum *, gs_state *, floatp, floatp );
267 int gs_screen_currentpoint(gs_screen_enum *, gs_point * );
268 int gs_screen_next(gs_screen_enum *, floatp );
269 struct gs_state_s {
270  gs_state *saved;
271  gs_memory_procs memory_procs;
272  gs_matrix_fixed ctm;
273  gs_matrix ctm_inverse;
274  int inverse_valid;
275  struct gx_path_s *path;
276  struct gx_clip_path_s *clip_path;
277  int clip_rule;
278  struct line_params_s *line_params;
279  struct halftone_params_s *halftone;
280  float (*ht_proc)(floatp, floatp );
281  gs_int_point ht_phase;
282  gs_int_point phase_mod;
283  struct gs_color_s *color;
284  struct gx_device_color_s *dev_color;
285  struct gx_transfer_s *transfer;
286  struct gs_font_s *font;
287  gs_matrix char_tm;
288  int char_tm_valid;
289  byte in_cachedevice;
290  byte in_charpath;
291 
292 
293 
294 
295  int level;
296  float flatness;
297  int stroke_adjust;
298  struct device_s *device;
299  int device_is_shared;
300 
301 };
302 typedef unsigned long gx_bitmap_id;
303 typedef struct gx_bitmap_s {
304  byte *data;
305  int raster;
306  gs_int_point size;
307  gx_bitmap_id id;
308  ushort rep_width, rep_height;
309 } gx_bitmap;
310 typedef unsigned long gx_color_index;
311 typedef unsigned short gx_color_value;
312 typedef struct gx_device_color_info_s {
313  int num_components;
314 
315  int depth;
316  gx_color_value max_gray;
317  gx_color_value max_rgb;
318 
319  gx_color_value dither_gray;
320  gx_color_value dither_rgb;
321 
322 } gx_device_color_info;
323 typedef struct gx_device_procs_s gx_device_procs;
324 struct gx_device_s {
325  int params_size; gx_device_procs *procs; const char *dname; int width; int height; float x_pixels_per_inch; float y_pixels_per_inch; float l_margin, b_margin, r_margin, t_margin; gx_device_color_info color_info; int is_open;
326 };
327 typedef struct gs_prop_item_s gs_prop_item;
328 struct gx_device_procs_s {
329  int (*open_device)(gx_device *dev );
330  void (*get_initial_matrix)(gx_device *dev, gs_matrix *pmat );
331  int (*sync_output)(gx_device *dev );
332  int (*output_page)(gx_device *dev, int num_copies, int flush );
333  int (*close_device)(gx_device *dev );
334  gx_color_index (*map_rgb_color)(gx_device *dev, gx_color_value red, gx_color_value green, gx_color_value blue );
335  int (*map_color_rgb)(gx_device *dev, gx_color_index color, gx_color_value rgb[3] );
336  int (*fill_rectangle)(gx_device *dev, int x, int y, int width, int height, gx_color_index color );
337  int (*tile_rectangle)(gx_device *dev, gx_bitmap *tile, int x, int y, int width, int height, gx_color_index color0, gx_color_index color1, int phase_x, int phase_y );
338  int (*copy_mono)(gx_device *dev, unsigned char *data, int data_x, int raster, gx_bitmap_id id, int x, int y, int width, int height, gx_color_index color0, gx_color_index color1 );
339  int (*copy_color)(gx_device *dev, unsigned char *data, int data_x, int raster, gx_bitmap_id id, int x, int y, int width, int height );
340  int (*draw_line)(gx_device *dev, int x0, int y0, int x1, int y1, gx_color_index color );
341  int (*get_bits)(gx_device *dev, int y, unsigned char *data, unsigned int size, int pad_to_word );
342  int (*get_props)(gx_device *dev, gs_prop_item *plist );
343 
344  int (*put_props)(gx_device *dev, gs_prop_item *plist, int count );
345 
346 };
347 extern unsigned int gx_device_bytes_per_scan_line(gx_device *dev, int pad_to_word );
348 int gx_default_open_device(gx_device *dev );
349 void gx_default_get_initial_matrix(gx_device *dev, gs_matrix *pmat );
350 int gx_default_sync_output(gx_device *dev );
351 int gx_default_output_page(gx_device *dev, int num_copies, int flush );
352 int gx_default_close_device(gx_device *dev );
353 gx_color_index gx_default_map_rgb_color(gx_device *dev, gx_color_value red, gx_color_value green, gx_color_value blue );
354 int gx_default_map_color_rgb(gx_device *dev, gx_color_index color, gx_color_value rgb[3] );
355 int gx_default_tile_rectangle(gx_device *dev, gx_bitmap *tile, int x, int y, int width, int height, gx_color_index color0, gx_color_index color1, int phase_x, int phase_y );
356 int gx_default_copy_color(gx_device *dev, unsigned char *data, int data_x, int raster, gx_bitmap_id id, int x, int y, int width, int height );
357 int gx_default_draw_line(gx_device *dev, int x0, int y0, int x1, int y1, gx_color_index color );
358 int gx_default_get_bits(gx_device *dev, int y, unsigned char *data, unsigned int size, int pad_to_word );
359 int gx_default_get_props(gx_device *dev, gs_prop_item *plist );
360 int gx_default_put_props(gx_device *dev, gs_prop_item *plist, int count );
361 typedef struct device_s {
362  gx_device *info;
363  int is_band_device;
364  gx_color_index white, black;
365 } device;
366 int gs_initmatrix(gs_state * ),
367  gs_defaultmatrix(const gs_state *, gs_matrix * ),
368  gs_currentmatrix(const gs_state *, gs_matrix * ),
369  gs_setmatrix(gs_state *, const gs_matrix * ),
370  gs_translate(gs_state *, floatp, floatp ),
371  gs_scale(gs_state *, floatp, floatp ),
372  gs_rotate(gs_state *, floatp ),
373  gs_concat(gs_state *, const gs_matrix * );
374 int gs_transform(gs_state *, floatp, floatp, gs_point * ),
375  gs_dtransform(gs_state *, floatp, floatp, gs_point * ),
376  gs_itransform(gs_state *, floatp, floatp, gs_point * ),
377  gs_idtransform(gs_state *, floatp, floatp, gs_point * );
378 static int
ctm_set_inverse(gs_state * pgs)379 ctm_set_inverse(gs_state *pgs)
380 { int code = gs_matrix_invert(&*(gs_matrix *)&(pgs)->ctm , &pgs->ctm_inverse);
381  0;
382  if ( code < 0 ) return code;
383  pgs->inverse_valid = 1;
384  return 0;
385 }
386 void
gs_update_matrix_fixed(gs_matrix_fixed * pmat)387 gs_update_matrix_fixed(gs_matrix_fixed *pmat)
388 { (*pmat). tx = ((float)(((*pmat). tx_fixed = ((fixed)(((*pmat). tx)*(float)(1<<12 ) )) )*(1.0/(1<<12 ) ))) , (*pmat). ty = ((float)(((*pmat). ty_fixed = ((fixed)(((*pmat). ty)*(float)(1<<12 ) )) )*(1.0/(1<<12 ) )));
389 }
390 int
gs_initmatrix(gs_state * pgs)391 gs_initmatrix(gs_state *pgs)
392 { gx_device *dev = pgs->device->info;
393  (*dev->procs->get_initial_matrix)(dev, &*(gs_matrix *)&(pgs)->ctm );
394  (pgs->ctm). tx = ((float)(((pgs->ctm). tx_fixed = ((fixed)(((pgs->ctm). tx)*(float)(1<<12 ) )) )*(1.0/(1<<12 ) ))) , (pgs->ctm). ty = ((float)(((pgs->ctm). ty_fixed = ((fixed)(((pgs->ctm). ty)*(float)(1<<12 ) )) )*(1.0/(1<<12 ) ))) , pgs->inverse_valid = 0, pgs->char_tm_valid = 0;
395  return 0;
396 }
397 int
gs_defaultmatrix(const gs_state * pgs,gs_matrix * pmat)398 gs_defaultmatrix(const gs_state *pgs, gs_matrix *pmat)
399 { gx_device *dev = pgs->device->info;
400  (*dev->procs->get_initial_matrix)(dev, pmat);
401  return 0;
402 }
403 int
gs_currentmatrix(const gs_state * pgs,gs_matrix * pmat)404 gs_currentmatrix(const gs_state *pgs, gs_matrix *pmat)
405 { *pmat = *(gs_matrix *)&(pgs)->ctm;
406  return 0;
407 }
408 int
gs_setmatrix(gs_state * pgs,const gs_matrix * pmat)409 gs_setmatrix(gs_state *pgs, const gs_matrix *pmat)
410 { *(gs_matrix *)&(pgs)->ctm = *pmat;
411  (pgs->ctm). tx = ((float)(((pgs->ctm). tx_fixed = ((fixed)(((pgs->ctm). tx)*(float)(1<<12 ) )) )*(1.0/(1<<12 ) ))) , (pgs->ctm). ty = ((float)(((pgs->ctm). ty_fixed = ((fixed)(((pgs->ctm). ty)*(float)(1<<12 ) )) )*(1.0/(1<<12 ) ))) , pgs->inverse_valid = 0, pgs->char_tm_valid = 0;
412  return 0;
413 }
414 int
gs_translate(gs_state * pgs,floatp dx,floatp dy)415 gs_translate(gs_state *pgs, floatp dx, floatp dy)
416 { gs_point pt;
417  int code;
418  if ( (code = gs_distance_transform(dx, dy, &*(gs_matrix *)&(pgs)->ctm , &pt)) < 0 )
419  return code;
420  pgs->ctm.tx += pt.x;
421  pgs->ctm.ty += pt.y;
422  (pgs->ctm). tx = ((float)(((pgs->ctm). tx_fixed = ((fixed)(((pgs->ctm). tx)*(float)(1<<12 ) )) )*(1.0/(1<<12 ) ))) , (pgs->ctm). ty = ((float)(((pgs->ctm). ty_fixed = ((fixed)(((pgs->ctm). ty)*(float)(1<<12 ) )) )*(1.0/(1<<12 ) ))) , pgs->inverse_valid = 0, pgs->char_tm_valid = 0;
423  return 0;
424 }
425 int
gs_scale(gs_state * pgs,floatp sx,floatp sy)426 gs_scale(gs_state *pgs, floatp sx, floatp sy)
427 { pgs->ctm.xx *= sx;
428  pgs->ctm.xy *= sx;
429  pgs->ctm.yx *= sy;
430  pgs->ctm.yy *= sy;
431  pgs->inverse_valid = 0, pgs->char_tm_valid = 0;
432  return 0;
433 }
434 int
gs_rotate(gs_state * pgs,floatp ang)435 gs_rotate(gs_state *pgs, floatp ang)
436 { int code = gs_matrix_rotate(&*(gs_matrix *)&(pgs)->ctm , ang, &*(gs_matrix *)&(pgs)->ctm );
437  pgs->inverse_valid = 0, pgs->char_tm_valid = 0;
438  return code;
439 }
440 int
gs_concat(gs_state * pgs,const gs_matrix * pmat)441 gs_concat(gs_state *pgs, const gs_matrix *pmat)
442 { int code = gs_matrix_multiply(pmat, &*(gs_matrix *)&(pgs)->ctm , &*(gs_matrix *)&(pgs)->ctm );
443  (pgs->ctm). tx = ((float)(((pgs->ctm). tx_fixed = ((fixed)(((pgs->ctm). tx)*(float)(1<<12 ) )) )*(1.0/(1<<12 ) ))) , (pgs->ctm). ty = ((float)(((pgs->ctm). ty_fixed = ((fixed)(((pgs->ctm). ty)*(float)(1<<12 ) )) )*(1.0/(1<<12 ) ))) , pgs->inverse_valid = 0, pgs->char_tm_valid = 0;
444  return code;
445 }
446 int
gs_transform(gs_state * pgs,floatp x,floatp y,gs_point * pt)447 gs_transform(gs_state *pgs, floatp x, floatp y, gs_point *pt)
448 { return gs_point_transform(x, y, &*(gs_matrix *)&(pgs)->ctm , pt);
449 }
450 int
gs_dtransform(gs_state * pgs,floatp dx,floatp dy,gs_point * pt)451 gs_dtransform(gs_state *pgs, floatp dx, floatp dy, gs_point *pt)
452 { return gs_distance_transform(dx, dy, &*(gs_matrix *)&(pgs)->ctm , pt);
453 }
454 int
gs_itransform(gs_state * pgs,floatp x,floatp y,gs_point * pt)455 gs_itransform(gs_state *pgs, floatp x, floatp y, gs_point *pt)
456 {
457 
458  if ( !!(((*(long *)(&((&pgs->ctm)->xy)) | *(long *)(&( (&pgs->ctm)->yx)) ) << 1) == 0) )
459  { return gs_point_transform_inverse(x, y, &*(gs_matrix *)&(pgs)->ctm , pt);
460  }
461  else
462  { if ( !pgs->inverse_valid ) { int code = ctm_set_inverse(pgs); if ( code < 0 ) return code; };
463  return gs_point_transform(x, y, &pgs->ctm_inverse, pt);
464  }
465 }
466 int
gs_idtransform(gs_state * pgs,floatp dx,floatp dy,gs_point * pt)467 gs_idtransform(gs_state *pgs, floatp dx, floatp dy, gs_point *pt)
468 {
469 
470  if ( !!(((*(long *)(&((&pgs->ctm)->xy)) | *(long *)(&( (&pgs->ctm)->yx)) ) << 1) == 0) )
471  { return gs_distance_transform_inverse(dx, dy,
472  &*(gs_matrix *)&(pgs)->ctm , pt);
473  }
474  else
475  { if ( !pgs->inverse_valid ) { int code = ctm_set_inverse(pgs); if ( code < 0 ) return code; };
476  return gs_distance_transform(dx, dy, &pgs->ctm_inverse, pt);
477  }
478 }
479 int
gs_translate_to_fixed(register gs_state * pgs,fixed px,fixed py)480 gs_translate_to_fixed(register gs_state *pgs, fixed px, fixed py)
481 { pgs->ctm.tx = ((float)((pgs->ctm.tx_fixed = px)*(1.0/(1<<12 ) )));
482  pgs->ctm.ty = ((float)((pgs->ctm.ty_fixed = py)*(1.0/(1<<12 ) )));
483  pgs->inverse_valid = 0;
484  pgs->char_tm_valid = 1;
485  return 0;
486 }
487 int
gx_matrix_to_fixed_coeff(const gs_matrix * pmat,register fixed_coeff * pfc,int max_bits)488 gx_matrix_to_fixed_coeff(const gs_matrix *pmat, register fixed_coeff *pfc,
489  int max_bits)
490 { gs_matrix ctm;
491  int scale = -10000;
492  int expt, shift;
493  ctm = *pmat;
494  pfc->skewed = 0;
495  if ( !((*(long *)(&(ctm.xx)) << 1) == 0) )
496  { (void)frexp(ctm.xx, &scale);
497  }
498  if ( !((*(long *)(&(ctm.xy)) << 1) == 0) )
499  { (void)frexp(ctm.xy, &expt);
500  if ( expt > scale ) scale = expt;
501  pfc->skewed = 1;
502  }
503  if ( !((*(long *)(&(ctm.yx)) << 1) == 0) )
504  { (void)frexp(ctm.yx, &expt);
505  if ( expt > scale ) scale = expt;
506  pfc->skewed = 1;
507  }
508  if ( !((*(long *)(&(ctm.yy)) << 1) == 0) )
509  { (void)frexp(ctm.yy, &expt);
510  if ( expt > scale ) scale = expt;
511  }
512  scale = sizeof(long) * 8 - 1 - max_bits - scale;
513  shift = scale - 12;
514  if ( shift > 0 )
515  { pfc->shift = shift;
516  pfc->round = (fixed)1 << (shift - 1);
517  }
518  else
519  { pfc->shift = 0;
520  pfc->round = 0;
521  scale -= shift;
522  }
523  pfc->xx = (((*(long *)(&(ctm.xx)) << 1) == 0) ? 0 : (long)ldexp(ctm.xx, scale));
524  pfc->yy = (((*(long *)(&(ctm.yy)) << 1) == 0) ? 0 : (long)ldexp(ctm.yy, scale));
525  if ( pfc->skewed )
526  { pfc->xy = (((*(long *)(&(ctm.xy)) << 1) == 0) ? 0 : (long)ldexp(ctm.xy, scale));
527  pfc->yx = (((*(long *)(&(ctm.yx)) << 1) == 0) ? 0 : (long)ldexp(ctm.yx, scale));
528  }
529  else
530  pfc->xy = pfc->yx = 0;
531  pfc->max_bits = max_bits;
532  return 0;
533 }
534