diff options
author | David Monniaux <david.monniaux@univ-grenoble-alpes.fr> | 2019-02-01 17:52:33 +0100 |
---|---|---|
committer | David Monniaux <david.monniaux@univ-grenoble-alpes.fr> | 2019-02-01 17:53:12 +0100 |
commit | 8844e567fdc7f68c378f727a63278d94c2dd51bf (patch) | |
tree | 0a25cb72af3575fd09e4d6e83630034b0b707943 /test/monniaux | |
parent | 35244064bbb2a853fb5c08898e8a74a7ec489aaa (diff) | |
download | compcert-kvx-8844e567fdc7f68c378f727a63278d94c2dd51bf.tar.gz compcert-kvx-8844e567fdc7f68c378f727a63278d94c2dd51bf.zip |
it still seems to work
Diffstat (limited to 'test/monniaux')
-rw-r--r-- | test/monniaux/jpeg-6b/Makefile | 4 | ||||
-rw-r--r-- | test/monniaux/jpeg-6b/jccoefct.c | 4 | ||||
-rw-r--r-- | test/monniaux/jpeg-6b/jconfig.h | 18 | ||||
-rw-r--r-- | test/monniaux/jpeg-6b/jcparam.c | 4 | ||||
-rw-r--r-- | test/monniaux/jpeg-6b/jcsample.c | 10 | ||||
-rw-r--r-- | test/monniaux/jpeg-6b/jdcoefct.c | 20 | ||||
-rw-r--r-- | test/monniaux/jpeg-6b/jdmainct.c | 24 | ||||
-rw-r--r-- | test/monniaux/jpeg-6b/transupp.c | 18 |
8 files changed, 59 insertions, 43 deletions
diff --git a/test/monniaux/jpeg-6b/Makefile b/test/monniaux/jpeg-6b/Makefile index 05a96602..bd0a737b 100644 --- a/test/monniaux/jpeg-6b/Makefile +++ b/test/monniaux/jpeg-6b/Makefile @@ -6,10 +6,10 @@ # Read installation instructions before saying "make" !! # The name of your C compiler: -CC= ../../../ccomp +# CC= ../../../ccomp # You may need to adjust these cc options: -CFLAGS= -O3 +CFLAGS= -O3 -Wall # Generally, we recommend defining any configuration symbols in jconfig.h, # NOT via -D switches here. # However, any special defines for ansi2knr.c may be included here: diff --git a/test/monniaux/jpeg-6b/jccoefct.c b/test/monniaux/jpeg-6b/jccoefct.c index e2f19130..48bb2933 100644 --- a/test/monniaux/jpeg-6b/jccoefct.c +++ b/test/monniaux/jpeg-6b/jccoefct.c @@ -266,13 +266,13 @@ compress_first_pass (j_compress_ptr cinfo, JSAMPIMAGE input_buf) block_rows = compptr->v_samp_factor; else { /* NB: can't use last_row_height here, since may not be set! */ - block_rows = (int) (compptr->height_in_blocks % compptr->v_samp_factor); + block_rows = (int) INT_UMOD(compptr->height_in_blocks, compptr->v_samp_factor); if (block_rows == 0) block_rows = compptr->v_samp_factor; } blocks_across = compptr->width_in_blocks; h_samp_factor = compptr->h_samp_factor; /* Count number of dummy blocks to be added at the right margin. */ - ndummy = (int) (blocks_across % h_samp_factor); + ndummy = (int) INT_UMOD(blocks_across, h_samp_factor); if (ndummy > 0) ndummy = h_samp_factor - ndummy; /* Perform DCT for all non-dummy blocks in this iMCU row. Each call diff --git a/test/monniaux/jpeg-6b/jconfig.h b/test/monniaux/jpeg-6b/jconfig.h index 56345384..e42ea31b 100644 --- a/test/monniaux/jpeg-6b/jconfig.h +++ b/test/monniaux/jpeg-6b/jconfig.h @@ -28,12 +28,24 @@ */ #define HAVE_PROTOTYPES +#ifdef __COMPCERT__ extern long long __compcert_i64_sdiv(long long a, long long b); -extern unsigned __compcert_i32_umod(unsigned a, unsigned b); +extern long long __compcert_i64_smod(long long a, long long b); + +#define INT_UMOD(a, b) __compcert_i64_smod(a, b) +#define INT_UDIV(a, b) __compcert_i64_sdiv(a, b) +#define INT_DIV(a, b) __compcert_i64_sdiv(a, b) +#define LONG_DIV(a, b) __compcert_i64_sdiv(a, b) -#define LONG_SDIV(x, y) __compcert_i64_sdiv(x, y) -#define INT_UMOD(x, y) __compcert_i32_umod(x, y) #define KILL_TAIL_CALL() { int x=1; } +#else +#define INT_UMOD(a, b) ((a) % (b)) +#define INT_UDIV(a, b) ((a) / (b)) +#define INT_DIV(a, b) ((a) / (b)) +#define LONG_DIV(a, b) ((a) / (b)) + +#define KILL_TAIL_CALL() { } +#endif /* Does your compiler support the declaration "unsigned char" ? * How about "unsigned short" ? diff --git a/test/monniaux/jpeg-6b/jcparam.c b/test/monniaux/jpeg-6b/jcparam.c index 2049f055..f6c90f47 100644 --- a/test/monniaux/jpeg-6b/jcparam.c +++ b/test/monniaux/jpeg-6b/jcparam.c @@ -46,7 +46,7 @@ jpeg_add_quant_table (j_compress_ptr cinfo, int which_tbl, *qtblptr = jpeg_alloc_quant_table((j_common_ptr) cinfo); for (i = 0; i < DCTSIZE2; i++) { - temp = LONG_SDIV((long) basic_table[i] * scale_factor + 50L, 100L); + temp = LONG_DIV((basic_table[i] * scale_factor + 50L), 100L); /* limit the values to the valid range */ if (temp <= 0L) temp = 1L; if (temp > 32767L) temp = 32767L; /* max quantizer needed for 12 bits */ @@ -120,7 +120,7 @@ jpeg_quality_scaling (int quality) * Qualities 1..50 are converted to scaling percentage 5000/Q. */ if (quality < 50) - quality = LONG_SDIV(5000, quality); + quality = INT_DIV(5000, quality); else quality = 200 - quality*2; diff --git a/test/monniaux/jpeg-6b/jcsample.c b/test/monniaux/jpeg-6b/jcsample.c index 212ec875..d2693198 100644 --- a/test/monniaux/jpeg-6b/jcsample.c +++ b/test/monniaux/jpeg-6b/jcsample.c @@ -146,8 +146,8 @@ int_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, JSAMPROW inptr, outptr; INT32 outvalue; - h_expand = cinfo->max_h_samp_factor / compptr->h_samp_factor; - v_expand = cinfo->max_v_samp_factor / compptr->v_samp_factor; + h_expand = INT_DIV(cinfo->max_h_samp_factor, compptr->h_samp_factor); + v_expand = INT_DIV(cinfo->max_v_samp_factor, compptr->v_samp_factor); numpix = h_expand * v_expand; numpix2 = numpix/2; @@ -170,7 +170,7 @@ int_downsample (j_compress_ptr cinfo, jpeg_component_info * compptr, outvalue += (INT32) GETJSAMPLE(*inptr++); } } - *outptr++ = (JSAMPLE) ((outvalue + numpix2) / numpix); + *outptr++ = (JSAMPLE) INT_DIV((outvalue + numpix2), numpix); } inrow += v_expand; } @@ -504,8 +504,8 @@ jinit_downsampler (j_compress_ptr cinfo) } else #endif downsample->methods[ci] = h2v2_downsample; - } else if ((cinfo->max_h_samp_factor % compptr->h_samp_factor) == 0 && - (cinfo->max_v_samp_factor % compptr->v_samp_factor) == 0) { + } else if (INT_UMOD(cinfo->max_h_samp_factor, compptr->h_samp_factor) == 0 && + INT_UMOD(cinfo->max_v_samp_factor, compptr->v_samp_factor) == 0) { smoothok = FALSE; downsample->methods[ci] = int_downsample; } else diff --git a/test/monniaux/jpeg-6b/jdcoefct.c b/test/monniaux/jpeg-6b/jdcoefct.c index 4938d20f..c14c936f 100644 --- a/test/monniaux/jpeg-6b/jdcoefct.c +++ b/test/monniaux/jpeg-6b/jdcoefct.c @@ -575,11 +575,11 @@ decompress_smooth_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf) if ((Al=coef_bits[1]) != 0 && workspace[1] == 0) { num = 36 * Q00 * (DC4 - DC6); if (num >= 0) { - pred = (int) (((Q01<<7) + num) / (Q01<<8)); + pred = (int) INT_DIV(((Q01<<7) + num), (Q01<<8)); if (Al > 0 && pred >= (1<<Al)) pred = (1<<Al)-1; } else { - pred = (int) (((Q01<<7) - num) / (Q01<<8)); + pred = (int) INT_DIV(((Q01<<7) - num), (Q01<<8)); if (Al > 0 && pred >= (1<<Al)) pred = (1<<Al)-1; pred = -pred; @@ -590,11 +590,11 @@ decompress_smooth_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf) if ((Al=coef_bits[2]) != 0 && workspace[8] == 0) { num = 36 * Q00 * (DC2 - DC8); if (num >= 0) { - pred = (int) (((Q10<<7) + num) / (Q10<<8)); + pred = (int) INT_DIV(((Q10<<7) + num), (Q10<<8)); if (Al > 0 && pred >= (1<<Al)) pred = (1<<Al)-1; } else { - pred = (int) (((Q10<<7) - num) / (Q10<<8)); + pred = (int) INT_DIV(((Q10<<7) - num), (Q10<<8)); if (Al > 0 && pred >= (1<<Al)) pred = (1<<Al)-1; pred = -pred; @@ -605,11 +605,11 @@ decompress_smooth_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf) if ((Al=coef_bits[3]) != 0 && workspace[16] == 0) { num = 9 * Q00 * (DC2 + DC8 - 2*DC5); if (num >= 0) { - pred = (int) (((Q20<<7) + num) / (Q20<<8)); + pred = (int) INT_DIV(((Q20<<7) + num), (Q20<<8)); if (Al > 0 && pred >= (1<<Al)) pred = (1<<Al)-1; } else { - pred = (int) (((Q20<<7) - num) / (Q20<<8)); + pred = (int) INT_DIV(((Q20<<7) - num), (Q20<<8)); if (Al > 0 && pred >= (1<<Al)) pred = (1<<Al)-1; pred = -pred; @@ -620,11 +620,11 @@ decompress_smooth_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf) if ((Al=coef_bits[4]) != 0 && workspace[9] == 0) { num = 5 * Q00 * (DC1 - DC3 - DC7 + DC9); if (num >= 0) { - pred = (int) (((Q11<<7) + num) / (Q11<<8)); + pred = (int) INT_DIV(((Q11<<7) + num), (Q11<<8)); if (Al > 0 && pred >= (1<<Al)) pred = (1<<Al)-1; } else { - pred = (int) (((Q11<<7) - num) / (Q11<<8)); + pred = (int) INT_DIV(((Q11<<7) - num), (Q11<<8)); if (Al > 0 && pred >= (1<<Al)) pred = (1<<Al)-1; pred = -pred; @@ -635,11 +635,11 @@ decompress_smooth_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf) if ((Al=coef_bits[5]) != 0 && workspace[2] == 0) { num = 9 * Q00 * (DC4 + DC6 - 2*DC5); if (num >= 0) { - pred = (int) (((Q02<<7) + num) / (Q02<<8)); + pred = (int) INT_DIV(((Q02<<7) + num), (Q02<<8)); if (Al > 0 && pred >= (1<<Al)) pred = (1<<Al)-1; } else { - pred = (int) (((Q02<<7) - num) / (Q02<<8)); + pred = (int) INT_DIV(((Q02<<7) - num), (Q02<<8)); if (Al > 0 && pred >= (1<<Al)) pred = (1<<Al)-1; pred = -pred; diff --git a/test/monniaux/jpeg-6b/jdmainct.c b/test/monniaux/jpeg-6b/jdmainct.c index c4be8ac1..e78bd8a4 100644 --- a/test/monniaux/jpeg-6b/jdmainct.c +++ b/test/monniaux/jpeg-6b/jdmainct.c @@ -175,8 +175,9 @@ alloc_funny_pointers (j_decompress_ptr cinfo) for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; ci++, compptr++) { - rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) / - cinfo->min_DCT_scaled_size; /* height of a row group of component */ + rgroup = INT_DIV((compptr->v_samp_factor * compptr->DCT_scaled_size), + cinfo->min_DCT_scaled_size); + /* height of a row group of component */ /* Get space for pointer lists --- M+4 row groups in each list. * We alloc both pointer lists with one call to save a few cycles. */ @@ -208,8 +209,9 @@ make_funny_pointers (j_decompress_ptr cinfo) for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; ci++, compptr++) { - rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) / - cinfo->min_DCT_scaled_size; /* height of a row group of component */ + rgroup = INT_DIV((compptr->v_samp_factor * compptr->DCT_scaled_size), + cinfo->min_DCT_scaled_size); + /* height of a row group of component */ xbuf0 = main->xbuffer[0][ci]; xbuf1 = main->xbuffer[1][ci]; /* First copy the workspace pointers as-is */ @@ -248,8 +250,9 @@ set_wraparound_pointers (j_decompress_ptr cinfo) for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; ci++, compptr++) { - rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) / - cinfo->min_DCT_scaled_size; /* height of a row group of component */ + rgroup = INT_DIV((compptr->v_samp_factor * compptr->DCT_scaled_size), + cinfo->min_DCT_scaled_size); + /* height of a row group of component */ xbuf0 = main->xbuffer[0][ci]; xbuf1 = main->xbuffer[1][ci]; for (i = 0; i < rgroup; i++) { @@ -278,7 +281,7 @@ set_bottom_pointers (j_decompress_ptr cinfo) ci++, compptr++) { /* Count sample rows in one iMCU row and in one row group */ iMCUheight = compptr->v_samp_factor * compptr->DCT_scaled_size; - rgroup = iMCUheight / cinfo->min_DCT_scaled_size; + rgroup = INT_DIV(iMCUheight, cinfo->min_DCT_scaled_size); /* Count nondummy sample rows remaining for this component */ rows_left = (int) (compptr->downsampled_height % (JDIMENSION) iMCUheight); if (rows_left == 0) rows_left = iMCUheight; @@ -286,7 +289,7 @@ set_bottom_pointers (j_decompress_ptr cinfo) * so we need only do it once. */ if (ci == 0) { - main->rowgroups_avail = (JDIMENSION) ((rows_left-1) / rgroup + 1); + main->rowgroups_avail = (JDIMENSION) (INT_DIV((rows_left-1), rgroup) + 1); } /* Duplicate the last real sample row rgroup*2 times; this pads out the * last partial rowgroup and ensures at least one full rowgroup of context. @@ -503,8 +506,9 @@ jinit_d_main_controller (j_decompress_ptr cinfo, boolean need_full_buffer) for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; ci++, compptr++) { - rgroup = (compptr->v_samp_factor * compptr->DCT_scaled_size) / - cinfo->min_DCT_scaled_size; /* height of a row group of component */ + rgroup = INT_DIV((compptr->v_samp_factor * compptr->DCT_scaled_size), + cinfo->min_DCT_scaled_size); + /* height of a row group of component */ main->buffer[ci] = (*cinfo->mem->alloc_sarray) ((j_common_ptr) cinfo, JPOOL_IMAGE, compptr->width_in_blocks * compptr->DCT_scaled_size, diff --git a/test/monniaux/jpeg-6b/transupp.c b/test/monniaux/jpeg-6b/transupp.c index e5ec5642..1f34e873 100644 --- a/test/monniaux/jpeg-6b/transupp.c +++ b/test/monniaux/jpeg-6b/transupp.c @@ -79,7 +79,7 @@ do_flip_h (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, * mirroring by changing the signs of odd-numbered columns. * Partial iMCUs at the right edge are left untouched. */ - MCU_cols = dstinfo->image_width / (dstinfo->max_h_samp_factor * DCTSIZE); + MCU_cols = INT_DIV(dstinfo->image_width, (dstinfo->max_h_samp_factor * DCTSIZE)); for (ci = 0; ci < dstinfo->num_components; ci++) { compptr = dstinfo->comp_info + ci; @@ -131,7 +131,7 @@ do_flip_v (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, * of odd-numbered rows. * Partial iMCUs at the bottom edge are copied verbatim. */ - MCU_rows = dstinfo->image_height / (dstinfo->max_v_samp_factor * DCTSIZE); + MCU_rows = INT_DIV(dstinfo->image_height, (dstinfo->max_v_samp_factor * DCTSIZE)); for (ci = 0; ci < dstinfo->num_components; ci++) { compptr = dstinfo->comp_info + ci; @@ -246,7 +246,7 @@ do_rot_90 (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, * at the (output) right edge properly. They just get transposed and * not mirrored. */ - MCU_cols = dstinfo->image_width / (dstinfo->max_h_samp_factor * DCTSIZE); + MCU_cols = INT_DIV(dstinfo->image_width, (dstinfo->max_h_samp_factor * DCTSIZE)); for (ci = 0; ci < dstinfo->num_components; ci++) { compptr = dstinfo->comp_info + ci; @@ -371,8 +371,8 @@ do_rot_180 (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, JCOEFPTR src_ptr, dst_ptr; jpeg_component_info *compptr; - MCU_cols = dstinfo->image_width / (dstinfo->max_h_samp_factor * DCTSIZE); - MCU_rows = dstinfo->image_height / (dstinfo->max_v_samp_factor * DCTSIZE); + MCU_cols = INT_DIV(dstinfo->image_width, (dstinfo->max_h_samp_factor * DCTSIZE)); + MCU_rows = INT_DIV(dstinfo->image_height, (dstinfo->max_v_samp_factor * DCTSIZE)); for (ci = 0; ci < dstinfo->num_components; ci++) { compptr = dstinfo->comp_info + ci; @@ -475,8 +475,8 @@ do_transverse (j_decompress_ptr srcinfo, j_compress_ptr dstinfo, JCOEFPTR src_ptr, dst_ptr; jpeg_component_info *compptr; - MCU_cols = dstinfo->image_width / (dstinfo->max_h_samp_factor * DCTSIZE); - MCU_rows = dstinfo->image_height / (dstinfo->max_v_samp_factor * DCTSIZE); + MCU_cols = INT_DIV(dstinfo->image_width, (dstinfo->max_h_samp_factor * DCTSIZE)); + MCU_rows = INT_DIV(dstinfo->image_height, (dstinfo->max_v_samp_factor * DCTSIZE)); for (ci = 0; ci < dstinfo->num_components; ci++) { compptr = dstinfo->comp_info + ci; @@ -691,7 +691,7 @@ trim_right_edge (j_compress_ptr dstinfo) int h_samp_factor = dstinfo->comp_info[ci].h_samp_factor; max_h_samp_factor = MAX(max_h_samp_factor, h_samp_factor); } - MCU_cols = dstinfo->image_width / (max_h_samp_factor * DCTSIZE); + MCU_cols = INT_DIV(dstinfo->image_width, (max_h_samp_factor * DCTSIZE)); if (MCU_cols > 0) /* can't trim to 0 pixels */ dstinfo->image_width = MCU_cols * (max_h_samp_factor * DCTSIZE); } @@ -711,7 +711,7 @@ trim_bottom_edge (j_compress_ptr dstinfo) int v_samp_factor = dstinfo->comp_info[ci].v_samp_factor; max_v_samp_factor = MAX(max_v_samp_factor, v_samp_factor); } - MCU_rows = dstinfo->image_height / (max_v_samp_factor * DCTSIZE); + MCU_rows = INT_DIV(dstinfo->image_height, (max_v_samp_factor * DCTSIZE)); if (MCU_rows > 0) /* can't trim to 0 pixels */ dstinfo->image_height = MCU_rows * (max_v_samp_factor * DCTSIZE); } |