Skip to content

Commit 619d5b7

Browse files
committed
Deal with compiler changes on Windows giving different bitfield padding
1 parent 191a694 commit 619d5b7

File tree

16 files changed

+173
-12
lines changed

16 files changed

+173
-12
lines changed

CHANGES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,6 @@ Jul 2019 (v5.1.2)
9595

9696
Aug 2019 (v5.1.3)
9797
* Print QJST SLPTU as number not timestamp
98+
99+
Aug 2019 (v5.1.4)
100+
* Newer compilers have changed bitfield structure padding layouts

bin/aix/convH

791 Bytes
Binary file not shown.

bin/aix/mqsmfcsv

3.71 KB
Binary file not shown.

bin/linux/convH

3.98 KB
Binary file not shown.

bin/linux/mqsmfcsv

7.69 KB
Binary file not shown.

bin/win/convH.exe

-9.99 KB
Binary file not shown.

bin/win/mqsmfcsv.exe

322 KB
Binary file not shown.

src/M

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ plat=`uname`
44

55
if [ "$plat" = "AIX" ]
66
then
7-
flags="-q32 -qmaxmem=-1 $CCEXTRAFLAGS"
7+
flags="-q32 -qmaxmem=-1 $CCEXTRAFLAGS -D PLATFORM_AIX"
88
cc="xlc"
99
targdir="../bin/aix"
1010
optim="-O3"
1111
else
12-
flags="-m32 $CCEXTRAFLAGS"
12+
flags="-m32 $CCEXTRAFLAGS -D PLATFORM_LINUX"
1313
cc="gcc"
1414
targdir="../bin/linux"
1515
optim="-O3"

src/Makefile.gcc.win

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
CC=i686-w64-mingw32-gcc
3-
CFLAGS= -I. -m32 -O2
3+
CFLAGS= -I. -m32 -fpack-struct=1 -DPLATFORM_WINDOWS
44
PLATFLAGS=
55
VERS=913
66
SRC = mqsmf.c \
@@ -9,6 +9,7 @@ SRC = mqsmf.c \
99
smfConv.c \
1010
smfJson.c \
1111
smfPrint.c \
12+
checkSize.c \
1213
printDEBUG.c \
1314
printQ5ST.c \
1415
printQCST.c \
@@ -38,6 +39,11 @@ SRC = mqsmf.c \
3839
HDR = mqsmfstruc.h \
3940
mqsmf.h
4041

42+
checkSize: mqsmfcsv.exe
43+
./mqsmfcsv.exe -v > sizes.tmp
44+
diff -b sizes.tmp sizes.master
45+
46+
4147
mqsmfcsv.exe: $(SRC) $(HDR) Makefile.gcc.win dummy
4248
-rm -f $@
4349
$(CC) $(PLATFLAGS) -o $@ $(SRC) $(CFLAGS) -DCSQDSMF_VERSION=$(VERS)
@@ -48,7 +54,7 @@ mqsmfstruc.h: csqdsmfc-$(VERS).h convH.exe dummy
4854
./convH.exe < csqdsmfc-$(VERS).h > $@
4955

5056
convH.exe: convH.c
51-
$(CC) -o $@ convH.c
57+
$(CC) $(CFLAGS) -o $@ convH.c
5258
cp $@ ../bin/win
5359

5460

src/Makefile.unix

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ SRC = \
88
smfDate.c \
99
smfConv.c \
1010
smfJson.c \
11+
checkSize.c \
1112
printDEBUG.c \
1213
printQ5ST.c \
1314
printQCST.c \
@@ -38,6 +39,10 @@ SRC = \
3839
HDR = mqsmfstruc.h \
3940
mqsmf.h
4041

42+
checkSize: mqsmfcsv
43+
./mqsmfcsv -v > sizes.tmp
44+
diff -b sizes.tmp sizes.master
45+
4146
mqsmfcsv: $(SRC) $(HDR) Makefile.unix dummy
4247
$(CC) $(PLATFLAGS) -o $@ $(SRC) $(CFLAGS) -DCSQDSMF_VERSION=$(VERS)
4348

src/Makefile.win

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
CFLAGS=-nologo /D_CRT_SECURE_NO_WARNINGS /Zp1 /J /O2
1+
CFLAGS=-nologo /D_CRT_SECURE_NO_WARNINGS /Zp1 /J /O2 /DPLATFORM_WINDOWS
22
VERS=913
33
SRC = mqsmf.c \
44
smfDDL.c \
55
smfDate.c \
66
smfConv.c \
77
smfJson.c \
88
smfPrint.c \
9+
checkSize.c \
910
printDEBUG.c \
1011
printQ5ST.c \
1112
printQCST.c \
@@ -35,6 +36,10 @@ SRC = mqsmf.c \
3536
HDR = mqsmfstruc.h \
3637
mqsmf.h
3738

39+
checkSize: mqsmfcsv.exe
40+
mqsmfcsv.exe -v > sizes.tmp
41+
diff -b sizes.master sizes.tmp
42+
3843
mqsmfcsv.exe: $(SRC) $(HDR) Makefile.win
3944
rm -f $@
4045
$(CC) $(SRC) -I. /Fe$@ $(CFLAGS) -DCSQDSMF_VERSION=$(VERS)
@@ -45,7 +50,7 @@ mqsmfstruc.h: csqdsmfc-$(VERS).h convH.exe dummy
4550
convH < csqdsmfc-$(VERS).h > $@
4651

4752
convH.exe: convH.c
48-
$(CC) /Fe$@ convH.c
53+
$(CC) $(CFLAGS) /Fe$@ convH.c
4954
copy $@ ..\bin\win
5055

5156

src/checkSize.c

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#include "stdio.h"
2+
#include "stddef.h"
3+
#include "../src/mqsmfstruc.h"
4+
5+
void checkStructureSizes(FILE *fp) {
6+
7+
fprintf(fp,"%s : %d\n","q5st",sizeof(q5st));
8+
fprintf(fp,"%s : %d\n","qcct",sizeof(qcct));
9+
fprintf(fp,"%s : %d\n","qct_dsp",sizeof(qct_dsp));
10+
fprintf(fp,"%s : %d\n","qct_adp",sizeof(qct_adp));
11+
fprintf(fp,"%s : %d\n","qct_ssl",sizeof(qct_ssl));
12+
fprintf(fp,"%s : %d\n","qct_dns",sizeof(qct_dns));
13+
fprintf(fp,"%s : %d\n","qcst",sizeof(qcst));
14+
fprintf(fp,"%s : %d\n","qest",sizeof(qest));
15+
fprintf(fp,"%s : %d\n","qesd",sizeof(qesd));
16+
fprintf(fp,"%s : %d\n","qist",sizeof(qist));
17+
fprintf(fp,"%s : %d\n","qis1",sizeof(qis1));
18+
fprintf(fp,"%s : %d\n","qjst",sizeof(qjst));
19+
fprintf(fp,"%s : %d\n","qlst",sizeof(qlst));
20+
fprintf(fp,"%s : %d\n","qmac",sizeof(qmac));
21+
fprintf(fp,"%s : %d\n","qmst",sizeof(qmst));
22+
fprintf(fp,"%s : %d\n","qpst",sizeof(qpst));
23+
fprintf(fp,"%s : %d\n","qsgm",sizeof(qsgm));
24+
fprintf(fp,"%s : %d\n","qsph",sizeof(qsph));
25+
fprintf(fp,"%s : %d\n","qsrs",sizeof(qsrs));
26+
fprintf(fp,"%s : %d\n","qsst",sizeof(qsst));
27+
fprintf(fp,"%s : %d\n","qtst",sizeof(qtst));
28+
fprintf(fp,"%s : %d\n","qwac",sizeof(qwac));
29+
fprintf(fp,"%s : %d\n","qwhc",sizeof(qwhc));
30+
fprintf(fp,"%s : %d\n","qwhs",sizeof(qwhs));
31+
fprintf(fp,"%s : %d\n","wtas",sizeof(wtas));
32+
fprintf(fp,"%s : %d\n","wtid",sizeof(wtid));
33+
fprintf(fp,"%s : %d\n","qwst",sizeof(qwst));
34+
fprintf(fp,"%s : %d\n","qws0",sizeof(qws0));
35+
fprintf(fp,"%s : %d\n","qws1",sizeof(qws1));
36+
fprintf(fp,"%s : %d\n","qws5",sizeof(qws5));
37+
fprintf(fp,"%s : %d\n","qws8",sizeof(qws8));
38+
fprintf(fp,"%s : %d\n","qws9",sizeof(qws9));
39+
fprintf(fp,"%s : %d\n","qwsx",sizeof(qwsx));
40+
fprintf(fp,"%s : %d\n","qwas",sizeof(qwas));
41+
fprintf(fp,"%s : %d\n","qwa0",sizeof(qwa0));
42+
fprintf(fp,"%s : %d\n","wq ",sizeof(wq));
43+
fprintf(fp,"wq->maxqdpth: %d\n",offsetof(wq,maxqdpth));
44+
fprintf(fp,"wq->z__001 : %d\n",offsetof(wq,z__001 ));
45+
}

src/convH.c

Lines changed: 59 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,37 @@
1313
#include <stdio.h>
1414
#include <string.h>
1515

16+
#if defined(PLATFORM_WINDOWS)
17+
#define BITFIELDREPRINTNEEDED (1)
18+
#else
19+
#define BITFIELDREPRINTNEEDED (0)
20+
#endif
21+
22+
int inBitfieldReplace = 0;
23+
void bitfieldReprint(int c);
24+
1625
/*
1726
* This is a very simple filter to take the product-provided
1827
* header file from z/OS and strip a few things that are
1928
* problematic on other platform compilers.
2029
*
2130
* It means we don't need to keep a variant copy
22-
* of the header in sync when new versions come out.
31+
* of the header in sync [Awhen new versions come out.
2332
*
2433
* In particular, get rid of the z/OS format for
2534
* the pragmas, and also the trigraph at the top
2635
* of the file.
2736
*
2837
* If the contents of the header file change, this
2938
* filter may need to be updated to match.
39+
*
40+
* Newer compiler versions on some platforms have also
41+
* affected how bitfields are laid out. This program now
42+
* rewrites bitfield structures that have been found to be a problem.
43+
* The changes have to be explicitly for each issue, but the build process
44+
* does now check if the structure sizes are unexpectedly different.
45+
* The AIX compiler seems to give the same sizes as z/OS so that's the master
46+
* we will drive the comparison from.
3047
*/
3148
int main(int argc, char **argv)
3249
{
@@ -57,13 +74,51 @@ int main(int argc, char **argv)
5774
continue;
5875
else
5976
{
60-
printf("%s",line);
61-
if (line[strlen(line)-1] != '\n')
62-
printf("\n");
77+
if (BITFIELDREPRINTNEEDED) {
78+
if (strstr(line,"fNoAcctg")) {
79+
bitfieldReprint(1);
80+
}
81+
if (strstr(line,"qwhssmfc")) {
82+
bitfieldReprint(2);
83+
}
84+
}
85+
86+
if (inBitfieldReplace) {
87+
/* Have we reached the end of the bitfield structure */
88+
if (strstr(line,"}"))
89+
inBitfieldReplace = 0;
90+
}
91+
92+
if (!inBitfieldReplace) {
93+
printf("%s",line);
94+
if (line[strlen(line)-1] != '\n')
95+
printf("\n");
96+
}
97+
6398
}
6499
}
65100
} while (c);
66101

67102
fflush(stdout);
68103
return 0;
69104
}
105+
106+
void bitfieldReprint(int c) {
107+
inBitfieldReplace = 1;
108+
switch (c) {
109+
case 1:
110+
printf(" unsigned char fNoAcctg : 1;\n");
111+
printf(" unsigned char fTopic : 1;\n");
112+
printf(" unsigned char fAcctqC : 1;\n");
113+
printf(" unsigned char spare : 5;\n");
114+
printf(" unsigned char spare2 : 8;\n");
115+
break;
116+
case 2:
117+
printf(" unsigned char qwhssmfc : 1;\n");
118+
printf(" unsigned char qwhspad1 : 7;\n");
119+
break;
120+
default:
121+
break;
122+
}
123+
}
124+

src/mqsmf.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,14 +239,14 @@ int main( int argc, char *argv[] )
239239
exit(1);
240240
}
241241

242+
242243
infoStream=stdout;
243244

244-
/*fprintf(infoStream,"Sizeof qwhs = %d\n",sizeof(qwhs));*/
245245

246246
/******************************************************************/
247247
/* Parse command-line parameters */
248248
/******************************************************************/
249-
while((c = mqgetopt(argc, argv, "ab:cd:e:f:h:i:m:o:p:rst:")) != EOF)
249+
while((c = mqgetopt(argc, argv, "ab:cd:e:f:h:i:m:o:p:rst:v")) != EOF)
250250
{
251251
switch(c)
252252
{
@@ -327,6 +327,9 @@ int main( int argc, char *argv[] )
327327
case 't':
328328
ticker = atoi(mqoptarg);
329329
break;
330+
case 'v':
331+
checkStructureSizes(infoStream);
332+
exit(0);
330333
default:
331334
error = TRUE;
332335
break;

src/mqsmf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ extern void smfPrintStop(FILE *,BOOL, BOOL *,columnHeader_t **);
280280
extern void smfAddHead(BOOL first,BOOL,char *h,int type,int len);
281281
extern void smfAddData(int datatype,char *fmt,...);
282282
extern void smfAddString(int, char *);
283+
extern void checkStructureSizes(FILE *);
283284

284285
#define SMFPRINTGLOB \
285286
static BOOL first = TRUE;\

src/sizes.master

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
q5st : 672
2+
qcct : 48
3+
qct_dsp : 36
4+
qct_adp : 32
5+
qct_ssl : 48
6+
qct_dns : 48
7+
qcst : 324
8+
qest : 4104
9+
qesd : 328
10+
qist : 80
11+
qis1 : 104
12+
qjst : 592
13+
qlst : 32
14+
qmac : 48
15+
qmst : 104
16+
qpst : 104
17+
qsgm : 48
18+
qsph : 88
19+
qsrs : 232
20+
qsst : 72
21+
qtst : 96
22+
qwac : 176
23+
qwhc : 92
24+
qwhs : 52
25+
wtas : 2344
26+
wtid : 208
27+
qwst : 28
28+
qws0 : 96
29+
qws1 : 72
30+
qws5 : 16
31+
qws8 : 16
32+
qws9 : 16
33+
qwsx : 48
34+
qwas : 28
35+
qwa0 : 56
36+
wq : 2788
37+
wq->maxqdpth: 588
38+
wq->z__001 : 594

0 commit comments

Comments
 (0)