]>
Commit | Line | Data |
---|---|---|
a1ca6ba5 JK |
1 | From: b...@arklinux.org (Bernhard Rosenkraenzer) |
2 | Newsgroups: mailing.openssl.dev | |
3 | Subject: Re: OpenSSL breaks with gcc 4.2 | |
4 | Date: Thu, 9 Nov 2006 01:56:49 +0800 (CST) | |
5 | Organization: NCTU CSIE FreeBSD Server | |
6 | Message-ID: <eit5p1$4mi$1@FreeBSD.csie.nctu.edu.tw> | |
7 | ||
8 | On Tuesday, 7. November 2006 15:54, Dr. Stephen Henson wrote: | |
9 | > On Tue, Nov 07, 2006, Bernhard Rosenkraenzer wrote: | |
10 | > > gcc 4.2 no longer allows function casting - which is used rather heavily | |
11 | > > by openssl. (To make things worse, it compiles but inserts abort() | |
12 | > > statements resulting in app crashes). | |
13 | > | |
14 | > Ugh, I would've thought that flagging a compiliation error would make more | |
15 | > sense rather that outputting bad code... | |
16 | ||
17 | Agreed... Unfortunately sometimes gcc developers' decisions make much sense | |
18 | from the point of the compiler implementor than from that of someone actually | |
19 | using it. | |
20 | ||
21 | > > Is there a fix to make OpenSSL compatible with gcc 4.2/4.3 yet? | |
22 | > | |
23 | > No there isn't yet, some technique will be needed to make this still work | |
24 | > by tweaking some of the macros. Does casting a function to (void *) first | |
25 | > then the function cast work? | |
26 | ||
27 | Yes, but only in a really really ugly way. | |
28 | I've attached a patch that make it compile (and work), but I can't say I like | |
29 | it. | |
30 | I've tried all sorts of other things (like putting the void* cast directly | |
31 | into the defines, or even adding a (char*) cast and running +1-1 type | |
32 | arithmetics on it), but gcc's optimizer is too smart and throws it away, and | |
33 | errors out just as if it wasn't there), but the attached patch is the only | |
34 | quick fix that works. | |
35 | ||
36 | I hope someone can come up with a better idea... | |
37 | ||
38 | --- openssl-0.9.8d/crypto/asn1/asn1.h.ark 2006-11-08 19:03:36.000000000 +0100 | |
39 | +++ openssl-0.9.8d/crypto/asn1/asn1.h 2006-11-08 19:32:10.000000000 +0100 | |
40 | @@ -902,23 +902,26 @@ | |
41 | ||
42 | /* Used to implement other functions */ | |
43 | void *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, char *x); | |
20c7db86 | 44 | +static void * __attribute__((unused)) __ASN1_dup=(void *)openssl_fcast(ASN1_dup); |
a1ca6ba5 JK |
45 | #define ASN1_dup_of(type,i2d,d2i,x) \ |
46 | - ((type *(*)(I2D_OF(type),D2I_OF(type),type *))openssl_fcast(ASN1_dup))(i2d,d2i,x) | |
47 | + ((type *(*)(I2D_OF(type),D2I_OF(type),type *))__ASN1_dup)(i2d,d2i,x) | |
48 | #define ASN1_dup_of_const(type,i2d,d2i,x) \ | |
49 | - ((type *(*)(I2D_OF_const(type),D2I_OF(type),type *))openssl_fcast(ASN1_dup))(i2d,d2i,x) | |
50 | + ((type *(*)(I2D_OF_const(type),D2I_OF(type),type *))__ASN1_dup)(i2d,d2i,x) | |
51 | ||
52 | void *ASN1_item_dup(const ASN1_ITEM *it, void *x); | |
53 | ||
54 | #ifndef OPENSSL_NO_FP_API | |
55 | void *ASN1_d2i_fp(void *(*xnew)(void), d2i_of_void *d2i, FILE *in, void **x); | |
20c7db86 | 56 | +static void * __attribute__((unused)) __ASN1_d2i_fp=(void *)openssl_fcast(ASN1_d2i_fp); |
a1ca6ba5 JK |
57 | #define ASN1_d2i_fp_of(type,xnew,d2i,in,x) \ |
58 | - ((type *(*)(type *(*)(void),D2I_OF(type),FILE *,type **))openssl_fcast(ASN1_d2i_fp))(xnew,d2i,in,x) | |
59 | + ((type *(*)(type *(*)(void),D2I_OF(type),FILE *,type **))__ASN1_d2i_fp)(xnew,d2i,in,x) | |
60 | void *ASN1_item_d2i_fp(const ASN1_ITEM *it, FILE *in, void *x); | |
61 | int ASN1_i2d_fp(i2d_of_void *i2d,FILE *out,void *x); | |
20c7db86 | 62 | +static void * __attribute__((unused)) __ASN1_i2d_fp=(void *)openssl_fcast(ASN1_i2d_fp); |
a1ca6ba5 JK |
63 | #define ASN1_i2d_fp_of(type,i2d,out,x) \ |
64 | - ((int (*)(I2D_OF(type),FILE *,type *))openssl_fcast(ASN1_i2d_fp))(i2d,out,x) | |
65 | + ((int (*)(I2D_OF(type),FILE *,type *))__ASN1_i2d_fp)(i2d,out,x) | |
66 | #define ASN1_i2d_fp_of_const(type,i2d,out,x) \ | |
67 | - ((int (*)(I2D_OF_const(type),FILE *,type *))openssl_fcast(ASN1_i2d_fp))(i2d,out,x) | |
68 | + ((int (*)(I2D_OF_const(type),FILE *,type *))__ASN1_i2d_fp)(i2d,out,x) | |
69 | int ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, void *x); | |
70 | int ASN1_STRING_print_ex_fp(FILE *fp, ASN1_STRING *str, unsigned long flags); | |
71 | #endif | |
72 | @@ -927,14 +930,16 @@ | |
73 | ||
74 | #ifndef OPENSSL_NO_BIO | |
75 | void *ASN1_d2i_bio(void *(*xnew)(void), d2i_of_void *d2i, BIO *in, void **x); | |
20c7db86 | 76 | +static void * __attribute__((unused)) __ASN1_d2i_bio=(void *)openssl_fcast(ASN1_d2i_bio); |
a1ca6ba5 JK |
77 | #define ASN1_d2i_bio_of(type,xnew,d2i,in,x) \ |
78 | - ((type *(*)(type *(*)(void),D2I_OF(type),BIO *,type **))openssl_fcast(ASN1_d2i_bio))(xnew,d2i,in,x) | |
79 | + ((type *(*)(type *(*)(void),D2I_OF(type),BIO *,type **))__ASN1_d2i_bio)(xnew,d2i,in,x) | |
80 | void *ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *x); | |
81 | int ASN1_i2d_bio(i2d_of_void *i2d,BIO *out, unsigned char *x); | |
20c7db86 | 82 | +static void * __attribute__((unused)) __ASN1_i2d_bio=(void *)openssl_fcast(ASN1_i2d_bio); |
a1ca6ba5 JK |
83 | #define ASN1_i2d_bio_of(type,i2d,out,x) \ |
84 | - ((int (*)(I2D_OF(type),BIO *,type *))openssl_fcast(ASN1_i2d_bio))(i2d,out,x) | |
85 | + ((int (*)(I2D_OF(type),BIO *,type *))__ASN1_i2d_bio)(i2d,out,x) | |
86 | #define ASN1_i2d_bio_of_const(type,i2d,out,x) \ | |
87 | - ((int (*)(I2D_OF_const(type),BIO *,const type *))openssl_fcast(ASN1_i2d_bio))(i2d,out,x) | |
88 | + ((int (*)(I2D_OF_const(type),BIO *,const type *))__ASN1_i2d_bio)(i2d,out,x) | |
89 | int ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, void *x); | |
90 | int ASN1_UTCTIME_print(BIO *fp,ASN1_UTCTIME *a); | |
91 | int ASN1_GENERALIZEDTIME_print(BIO *fp,ASN1_GENERALIZEDTIME *a); | |
92 | @@ -977,8 +982,9 @@ | |
93 | void *ASN1_item_unpack(ASN1_STRING *oct, const ASN1_ITEM *it); | |
94 | ASN1_STRING *ASN1_pack_string(void *obj, i2d_of_void *i2d, | |
95 | ASN1_OCTET_STRING **oct); | |
20c7db86 | 96 | +static void * __attribute__((unused)) __ASN1_pack_string=(void *)openssl_fcast(ASN1_pack_string); |
a1ca6ba5 JK |
97 | #define ASN1_pack_string_of(type,obj,i2d,oct) \ |
98 | - ((ASN1_STRING *(*)(type *,I2D_OF(type),ASN1_OCTET_STRING **))openssl_fcast(ASN1_pack_string))(obj,i2d,oct) | |
99 | + ((ASN1_STRING *(*)(type *,I2D_OF(type),ASN1_OCTET_STRING **))__ASN1_pack_string)(obj,i2d,oct) | |
100 | ASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it, ASN1_OCTET_STRING **oct); | |
101 | ||
102 | void ASN1_STRING_set_default_mask(unsigned long mask); | |
103 | --- openssl-0.9.8d/crypto/ocsp/ocsp.h.ark 2006-11-08 19:28:48.000000000 +0100 | |
104 | +++ openssl-0.9.8d/crypto/ocsp/ocsp.h 2006-11-08 19:29:47.000000000 +0100 | |
105 | @@ -468,8 +468,9 @@ | |
106 | ||
107 | ASN1_STRING *ASN1_STRING_encode(ASN1_STRING *s, i2d_of_void *i2d, | |
108 | void *data, STACK_OF(ASN1_OBJECT) *sk); | |
20c7db86 | 109 | +static void * __attribute__((unused)) __ASN1_STRING_encode=(void *)openssl_fcast(ASN1_STRING_encode); |
a1ca6ba5 JK |
110 | #define ASN1_STRING_encode_of(type,s,i2d,data,sk) \ |
111 | -((ASN1_STRING *(*)(ASN1_STRING *,I2D_OF(type),type *,STACK_OF(ASN1_OBJECT) *))openssl_fcast(ASN1_STRING_encode))(s,i2d,data,sk) | |
112 | +((ASN1_STRING *(*)(ASN1_STRING *,I2D_OF(type),type *,STACK_OF(ASN1_OBJECT) *))__ASN1_STRING_encode)(s,i2d,data,sk) | |
113 | ||
114 | X509_EXTENSION *OCSP_crlID_new(char *url, long *n, char *tim); | |
115 | ||
116 | --- openssl-0.9.8d/crypto/pem/pem.h.ark 2006-11-08 19:09:51.000000000 +0100 | |
117 | +++ openssl-0.9.8d/crypto/pem/pem.h 2006-11-08 19:43:45.000000000 +0100 | |
118 | @@ -220,19 +220,22 @@ | |
119 | #define IMPLEMENT_PEM_read_fp(name, type, str, asn1) \ | |
120 | type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u)\ | |
121 | { \ | |
122 | -return(((type *(*)(D2I_OF(type),char *,FILE *,type **,pem_password_cb *,void *))openssl_fcast(PEM_ASN1_read))(d2i_##asn1, str,fp,x,cb,u)); \ | |
20c7db86 | 123 | +static void *__PEM_ASN1_read=(void *)openssl_fcast(PEM_ASN1_read); \ |
a1ca6ba5 | 124 | +return(((type *(*)(D2I_OF(type),char *,FILE *,type **,pem_password_cb *,void *))__PEM_ASN1_read)(d2i_##asn1, str,fp,x,cb,u)); \ |
a8f5bcdd | 125 | } |
a1ca6ba5 JK |
126 | |
127 | #define IMPLEMENT_PEM_write_fp(name, type, str, asn1) \ | |
128 | int PEM_write_##name(FILE *fp, type *x) \ | |
129 | { \ | |
130 | -return(((int (*)(I2D_OF(type),const char *,FILE *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write))(i2d_##asn1,str,fp,x,NULL,NULL,0,NULL,NULL)); \ | |
20c7db86 | 131 | +static void *__PEM_ASN1_write=(void *)openssl_fcast(PEM_ASN1_write); \ |
a1ca6ba5 JK |
132 | +return(((int (*)(I2D_OF(type),const char *,FILE *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))__PEM_ASN1_write)(i2d_##asn1,str,fp,x,NULL,NULL,0,NULL,NULL)); \ |
133 | } | |
134 | ||
135 | #define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) \ | |
136 | int PEM_write_##name(FILE *fp, const type *x) \ | |
137 | { \ | |
138 | -return(((int (*)(I2D_OF_const(type),const char *,FILE *, const type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write))(i2d_##asn1,str,fp,x,NULL,NULL,0,NULL,NULL)); \ | |
20c7db86 | 139 | +static void *__PEM_ASN1_write=(void *)openssl_fcast(PEM_ASN1_write); \ |
a1ca6ba5 JK |
140 | +return(((int (*)(I2D_OF_const(type),const char *,FILE *, const type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))__PEM_ASN1_write)(i2d_##asn1,str,fp,x,NULL,NULL,0,NULL,NULL)); \ |
141 | } | |
142 | ||
143 | #define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) \ | |
144 | @@ -240,7 +243,8 @@ | |
145 | unsigned char *kstr, int klen, pem_password_cb *cb, \ | |
146 | void *u) \ | |
147 | { \ | |
148 | - return(((int (*)(I2D_OF(type),const char *,FILE *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write))(i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u)); \ | |
20c7db86 | 149 | + static void *__PEM_ASN1_write=(void *)openssl_fcast(PEM_ASN1_write); \ |
a1ca6ba5 JK |
150 | + return(((int (*)(I2D_OF(type),const char *,FILE *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))__PEM_ASN1_write)(i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u)); \ |
151 | } | |
152 | ||
153 | #define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) \ | |
154 | @@ -248,7 +252,8 @@ | |
155 | unsigned char *kstr, int klen, pem_password_cb *cb, \ | |
156 | void *u) \ | |
157 | { \ | |
158 | - return(((int (*)(I2D_OF_const(type),const char *,FILE *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write))(i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u)); \ | |
20c7db86 | 159 | + static void *__PEM_ASN1_write=(void *)openssl_fcast(PEM_ASN1_write); \ |
a1ca6ba5 JK |
160 | + return(((int (*)(I2D_OF_const(type),const char *,FILE *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))__PEM_ASN1_write)(i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u)); \ |
161 | } | |
162 | ||
163 | #endif | |
164 | @@ -256,33 +261,38 @@ | |
165 | #define IMPLEMENT_PEM_read_bio(name, type, str, asn1) \ | |
166 | type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u)\ | |
167 | { \ | |
168 | -return(((type *(*)(D2I_OF(type),const char *,BIO *,type **,pem_password_cb *,void *))openssl_fcast(PEM_ASN1_read_bio))(d2i_##asn1, str,bp,x,cb,u)); \ | |
20c7db86 | 169 | +static void *__PEM_ASN1_read_bio=(void *)openssl_fcast(PEM_ASN1_read_bio); \ |
a1ca6ba5 JK |
170 | +return(((type *(*)(D2I_OF(type),const char *,BIO *,type **,pem_password_cb *,void *))__PEM_ASN1_read_bio)(d2i_##asn1, str,bp,x,cb,u)); \ |
171 | } | |
172 | ||
173 | #define IMPLEMENT_PEM_write_bio(name, type, str, asn1) \ | |
174 | int PEM_write_bio_##name(BIO *bp, type *x) \ | |
175 | { \ | |
176 | -return(((int (*)(I2D_OF(type),const char *,BIO *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write_bio))(i2d_##asn1,str,bp,x,NULL,NULL,0,NULL,NULL)); \ | |
20c7db86 | 177 | +static void *__PEM_ASN1_write_bio=(void *)openssl_fcast(PEM_ASN1_write_bio); \ |
a1ca6ba5 JK |
178 | +return(((int (*)(I2D_OF(type),const char *,BIO *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))__PEM_ASN1_write_bio)(i2d_##asn1,str,bp,x,NULL,NULL,0,NULL,NULL)); \ |
179 | } | |
180 | ||
181 | #define IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \ | |
182 | int PEM_write_bio_##name(BIO *bp, const type *x) \ | |
183 | { \ | |
184 | -return(((int (*)(I2D_OF_const(type),const char *,BIO *,const type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write_bio))(i2d_##asn1,str,bp,x,NULL,NULL,0,NULL,NULL)); \ | |
20c7db86 | 185 | +static void *__PEM_ASN1_write_bio=(void *)openssl_fcast(PEM_ASN1_write_bio); \ |
a1ca6ba5 JK |
186 | +return(((int (*)(I2D_OF_const(type),const char *,BIO *,const type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))__PEM_ASN1_write_bio)(i2d_##asn1,str,bp,x,NULL,NULL,0,NULL,NULL)); \ |
187 | } | |
188 | ||
189 | #define IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \ | |
190 | int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \ | |
191 | unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \ | |
192 | { \ | |
193 | - return(((int (*)(I2D_OF(type),const char *,BIO *,type *,const EVP_CIPHER *,unsigned char *,int,pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write_bio))(i2d_##asn1,str,bp,x,enc,kstr,klen,cb,u)); \ | |
20c7db86 | 194 | + static void *__PEM_ASN1_write_bio=(void *)openssl_fcast(PEM_ASN1_write_bio); \ |
a1ca6ba5 JK |
195 | + return(((int (*)(I2D_OF(type),const char *,BIO *,type *,const EVP_CIPHER *,unsigned char *,int,pem_password_cb *,void *))__PEM_ASN1_write_bio)(i2d_##asn1,str,bp,x,enc,kstr,klen,cb,u)); \ |
196 | } | |
197 | ||
198 | #define IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \ | |
199 | int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \ | |
200 | unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \ | |
201 | { \ | |
202 | - return(((int (*)(I2D_OF_const(type),const char *,BIO *,type *,const EVP_CIPHER *,unsigned char *,int,pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write_bio))(i2d_##asn1,str,bp,x,enc,kstr,klen,cb,u)); \ | |
20c7db86 | 203 | + static void *__PEM_ASN1_write_bio=(void *)openssl_fcast(PEM_ASN1_write_bio); \ |
a1ca6ba5 JK |
204 | + return(((int (*)(I2D_OF_const(type),const char *,BIO *,type *,const EVP_CIPHER *,unsigned char *,int,pem_password_cb *,void *))__PEM_ASN1_write_bio)(i2d_##asn1,str,bp,x,enc,kstr,klen,cb,u)); \ |
205 | } | |
206 | ||
207 | #define IMPLEMENT_PEM_write(name, type, str, asn1) \ | |
208 | @@ -545,13 +555,15 @@ | |
209 | pem_password_cb *cb, void *u); | |
210 | void * PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp, | |
211 | void **x, pem_password_cb *cb, void *u); | |
20c7db86 | 212 | +static void * __attribute__((unused)) __PEM_ASN1_read_bio=(void *)openssl_fcast(PEM_ASN1_read_bio); |
a1ca6ba5 JK |
213 | #define PEM_ASN1_read_bio_of(type,d2i,name,bp,x,cb,u) \ |
214 | -((type *(*)(D2I_OF(type),const char *,BIO *,type **,pem_password_cb *,void *))openssl_fcast(PEM_ASN1_read_bio))(d2i,name,bp,x,cb,u) | |
215 | +((type *(*)(D2I_OF(type),const char *,BIO *,type **,pem_password_cb *,void *))__PEM_ASN1_read_bio)(d2i,name,bp,x,cb,u) | |
216 | int PEM_ASN1_write_bio(i2d_of_void *i2d,const char *name,BIO *bp,char *x, | |
217 | const EVP_CIPHER *enc,unsigned char *kstr,int klen, | |
218 | pem_password_cb *cb, void *u); | |
20c7db86 | 219 | +static void * __attribute__((unused)) __PEM_ASN1_write_bio=(void *)openssl_fcast(PEM_ASN1_write_bio); |
a1ca6ba5 JK |
220 | #define PEM_ASN1_write_bio_of(type,i2d,name,bp,x,enc,kstr,klen,cb,u) \ |
221 | - ((int (*)(I2D_OF(type),const char *,BIO *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write_bio))(i2d,name,bp,x,enc,kstr,klen,cb,u) | |
222 | + ((int (*)(I2D_OF(type),const char *,BIO *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))__PEM_ASN1_write_bio)(i2d,name,bp,x,enc,kstr,klen,cb,u) | |
223 | ||
224 | STACK_OF(X509_INFO) * PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk, pem_password_cb *cb, void *u); | |
225 | int PEM_X509_INFO_write_bio(BIO *bp,X509_INFO *xi, EVP_CIPHER *enc, | |
226 | ||
227 | ______________________________________________________________________ | |
228 | OpenSSL Project http://www.openssl.org | |
229 | Development Mailing List openssl-...@openssl.org | |
230 | Automated List Manager majord...@openssl.org |