Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/stbi a macro idiom used here triggers the GCC 6.4 id...
details: https://anonhg.NetBSD.org/src/rev/074580cbd676
branches: trunk
changeset: 359200:074580cbd676
user: mrg <mrg%NetBSD.org@localhost>
date: Sun Feb 04 09:18:44 2018 +0000
description:
a macro idiom used here triggers the GCC 6.4 ident checker. work around it.
diffstat:
sys/dev/stbi/stb_image.c | 82 +++++++++++++++++++++++++++++++----------------
1 files changed, 54 insertions(+), 28 deletions(-)
diffs (120 lines):
diff -r 3d6c28253991 -r 074580cbd676 sys/dev/stbi/stb_image.c
--- a/sys/dev/stbi/stb_image.c Sun Feb 04 09:17:54 2018 +0000
+++ b/sys/dev/stbi/stb_image.c Sun Feb 04 09:18:44 2018 +0000
@@ -430,7 +430,7 @@
#endif
#ifdef _KERNEL
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: stb_image.c,v 1.8 2016/01/21 17:17:53 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: stb_image.c,v 1.9 2018/02/04 09:18:44 mrg Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
@@ -1000,18 +1000,30 @@
// convert source image with img_n components to one with req_comp components;
// avoid switch per pixel, so use switch per scanline and massive macros
switch (COMBO(img_n, req_comp)) {
- CASE(1,2) dest[0]=src[0], dest[1]=255; break;
- CASE(1,3) dest[0]=dest[1]=dest[2]=src[0]; break;
- CASE(1,4) dest[0]=dest[1]=dest[2]=src[0], dest[3]=255; break;
- CASE(2,1) dest[0]=src[0]; break;
- CASE(2,3) dest[0]=dest[1]=dest[2]=src[0]; break;
- CASE(2,4) dest[0]=dest[1]=dest[2]=src[0], dest[3]=src[1]; break;
- CASE(3,4) dest[0]=src[0],dest[1]=src[1],dest[2]=src[2],dest[3]=255; break;
- CASE(3,1) dest[0]=compute_y(src[0],src[1],src[2]); break;
- CASE(3,2) dest[0]=compute_y(src[0],src[1],src[2]), dest[1] = 255; break;
- CASE(4,1) dest[0]=compute_y(src[0],src[1],src[2]); break;
- CASE(4,2) dest[0]=compute_y(src[0],src[1],src[2]), dest[1] = src[3]; break;
- CASE(4,3) dest[0]=src[0],dest[1]=src[1],dest[2]=src[2]; break;
+ CASE(1,2) dest[0]=src[0], dest[1]=255;
+ break;
+ CASE(1,3) dest[0]=dest[1]=dest[2]=src[0];
+ break;
+ CASE(1,4) dest[0]=dest[1]=dest[2]=src[0], dest[3]=255;
+ break;
+ CASE(2,1) dest[0]=src[0];
+ break;
+ CASE(2,3) dest[0]=dest[1]=dest[2]=src[0];
+ break;
+ CASE(2,4) dest[0]=dest[1]=dest[2]=src[0], dest[3]=src[1];
+ break;
+ CASE(3,4) dest[0]=src[0],dest[1]=src[1],dest[2]=src[2],dest[3]=255;
+ break;
+ CASE(3,1) dest[0]=compute_y(src[0],src[1],src[2]);
+ break;
+ CASE(3,2) dest[0]=compute_y(src[0],src[1],src[2]), dest[1] = 255;
+ break;
+ CASE(4,1) dest[0]=compute_y(src[0],src[1],src[2]);
+ break;
+ CASE(4,2) dest[0]=compute_y(src[0],src[1],src[2]), dest[1] = src[3];
+ break;
+ CASE(4,3) dest[0]=src[0],dest[1]=src[1],dest[2]=src[2];
+ break;
default: assert(0);
}
#undef CASE
@@ -1279,7 +1291,7 @@
// predict well. I tried to table accelerate it but failed.
// maybe it's compiling as a conditional move?
if (k < m)
- return (-1 << n) + k + 1;
+ return (UINT_MAX << n) + k + 1;
else
return k;
}
@@ -2696,13 +2708,20 @@
for (i=x-1; i >= 1; --i, raw+=img_n,cur+=img_n,prior+=img_n) \
for (k=0; k < img_n; ++k)
switch (filter) {
- CASE(F_none) cur[k] = raw[k]; break;
- CASE(F_sub) cur[k] = raw[k] + cur[k-img_n]; break;
- CASE(F_up) cur[k] = raw[k] + prior[k]; break;
- CASE(F_avg) cur[k] = raw[k] + ((prior[k] + cur[k-img_n])>>1); break;
- CASE(F_paeth) cur[k] = (uint8) (raw[k] + paeth(cur[k-img_n],prior[k],prior[k-img_n])); break;
- CASE(F_avg_first) cur[k] = raw[k] + (cur[k-img_n] >> 1); break;
- CASE(F_paeth_first) cur[k] = (uint8) (raw[k] + paeth(cur[k-img_n],0,0)); break;
+ CASE(F_none) cur[k] = raw[k];
+ break;
+ CASE(F_sub) cur[k] = raw[k] + cur[k-img_n];
+ break;
+ CASE(F_up) cur[k] = raw[k] + prior[k];
+ break;
+ CASE(F_avg) cur[k] = raw[k] + ((prior[k] + cur[k-img_n])>>1);
+ break;
+ CASE(F_paeth) cur[k] = (uint8) (raw[k] + paeth(cur[k-img_n],prior[k],prior[k-img_n]));
+ break;
+ CASE(F_avg_first) cur[k] = raw[k] + (cur[k-img_n] >> 1);
+ break;
+ CASE(F_paeth_first) cur[k] = (uint8) (raw[k] + paeth(cur[k-img_n],0,0));
+ break;
}
#undef CASE
} else {
@@ -2712,13 +2731,20 @@
for (i=x-1; i >= 1; --i, cur[img_n]=255,raw+=img_n,cur+=out_n,prior+=out_n) \
for (k=0; k < img_n; ++k)
switch (filter) {
- CASE(F_none) cur[k] = raw[k]; break;
- CASE(F_sub) cur[k] = raw[k] + cur[k-out_n]; break;
- CASE(F_up) cur[k] = raw[k] + prior[k]; break;
- CASE(F_avg) cur[k] = raw[k] + ((prior[k] + cur[k-out_n])>>1); break;
- CASE(F_paeth) cur[k] = (uint8) (raw[k] + paeth(cur[k-out_n],prior[k],prior[k-out_n])); break;
- CASE(F_avg_first) cur[k] = raw[k] + (cur[k-out_n] >> 1); break;
- CASE(F_paeth_first) cur[k] = (uint8) (raw[k] + paeth(cur[k-out_n],0,0)); break;
+ CASE(F_none) cur[k] = raw[k];
+ break;
+ CASE(F_sub) cur[k] = raw[k] + cur[k-out_n];
+ break;
+ CASE(F_up) cur[k] = raw[k] + prior[k];
+ break;
+ CASE(F_avg) cur[k] = raw[k] + ((prior[k] + cur[k-out_n])>>1);
+ break;
+ CASE(F_paeth) cur[k] = (uint8) (raw[k] + paeth(cur[k-out_n],prior[k],prior[k-out_n]));
+ break;
+ CASE(F_avg_first) cur[k] = raw[k] + (cur[k-out_n] >> 1);
+ break;
+ CASE(F_paeth_first) cur[k] = (uint8) (raw[k] + paeth(cur[k-out_n],0,0));
+ break;
}
#undef CASE
}
Home |
Main Index |
Thread Index |
Old Index