Re: Sadistic C compiler...

2000-01-26 Thread Richard Levitte - VMS Whacker
bodo> > babinebell> I think we should seperate the functions handling values bodo> > babinebell> and the functions handling callbacks: bodo> > babinebell> bodo> > babinebell> int BIO_ctrl_callback(BIO *bp,int cmd,long larg,int (*cb)()); bodo> bodo> > Hmm, actually, I like that alternative. That

Re: Sadistic C compiler...

2000-01-26 Thread Bodo Moeller
On Wed, Jan 26, 2000, Bodo Moeller wrote: > On Thu, Jan 20, 2000, Richard Levitte - VMS Whacker wrote: >> Hmm, actually, I like that alternative. That allows us to go around >> the whole union/pass-by-value/and-so-on brouhaha... :-) > Looks ok. Will you implement it? Here "you" == Richard, i

Re: Sadistic C compiler...

2000-01-26 Thread Bodo Moeller
On Thu, Jan 20, 2000, Richard Levitte - VMS Whacker wrote: > babinebell> I think we should seperate the functions handling values > babinebell> and the functions handling callbacks: > babinebell> > babinebell> int BIO_ctrl_callback(BIO *bp,int cmd,long larg,int (*cb)()); > Hmm, actually, I like

Re: Sadistic C compiler...

2000-01-23 Thread Andy Polyakov
> It's *not* VMS specific! DEC C 6.2 for Unix issues very similar warning. But it looks like DEC has VMS specific reason to be nervous about the matter. Consider the following code: #pragma required_pointer_size save /* Save the previous pointer size */ #pragma required_pointer_size 64 /* Set poi

Re: Sadistic C compiler...

2000-01-21 Thread Matti Aarnio
On Mon, Jan 17, 2000 at 01:39:55PM +, Dr Stephen Henson wrote: > Richard Levitte - VMS Whacker wrote: > > DEC C for VMS is getting really mean. Version 6.2 (latest, as far as > > I know) spews out a message when a (char *) cast is done to a function > > pointer and vice versa. Guess what it

Re: Sadistic C compiler...

2000-01-21 Thread Richard Levitte - VMS Whacker
babinebell> I think we should seperate the functions handling values babinebell> and the functions handling callbacks: babinebell> babinebell> int BIO_ctrl_callback(BIO *bp,int cmd,long larg,int (*cb)()); babinebell> babinebell> Is not nice, requires changing of some structures but babinebell> s

Re: Sadistic C compiler...

2000-01-20 Thread Bodo Moeller
Andy Polyakov <[EMAIL PROTECTED]>: >> 5. Have the caller tuck the parameter in a union that will represent >> function pointers as well as other pointers, and pass that union >> by reference. >> Choices 4 and 5 assumes that the parameter in question will be >> prototyped and used lik

Re: Sadistic C compiler...

2000-01-20 Thread Ben Laurie
Richard Levitte - VMS Whacker wrote: > 4. Have the caller tuck the parameter in a union that will represent > function pointers as well as other pointers, and pass that union > by value. > 5. Have the caller tuck the parameter in a union that will represent > function pointers a

Re: Sadistic C compiler...

2000-01-20 Thread Bodo Moeller
Richard Levitte - VMS Whacker <[EMAIL PROTECTED]>: > Let me see if I got it all. So far, I've seen the following > alternatives: > > 1. ignore the problem (obviously not the right thing to do :-)). > 2. take the parameter in question as we do today, but use a union so > the compiler wi

Re: Sadistic C compiler...

2000-01-20 Thread Geoff Thorpe
Hi there, On Thu, 20 Jan 2000, Richard Levitte - VMS Whacker wrote: > appro> > as argument instead of a > appro> > 'void *' (a non-anonymous variant 4). > appro> But it breaks *source* code compatibility and old users gonna > appro> get (really) frustrated. > > That is true, but on the other ha

Re: Sadistic C compiler...

2000-01-20 Thread Richard Levitte - VMS Whacker
appro> > My thought about that one was that BIO_ctrl would be declared appro> > and defined to take a 'sin_of_ansification *' appro> ^ you vote for #4, no star here. Oops :-). appro> > as argument instead of a appro> > 'void *' (a non-anonymous varian

Re: Sadistic C compiler...

2000-01-20 Thread Goetz Babin-Ebell
At 17:31 20.01.00 +0100, Richard Levitte - VMS Whacker wrote: Hallo Richard, I fear we don't solve the problem but try to tweak a broken implementation until it works. I think we should seperate the functions handling values and the functions handling callbacks: int BIO_ctrl_callback(BIO *bp,in

Re: Sadistic C compiler...

2000-01-20 Thread Andy Polyakov
> Hmm. That's basically an anonymous choice 4 and 5 (depending on ctl > code). Yes, that was my vote/proposal. Anonymous/whitened pointer argument is the key to binary compatibility (at _ctrl level) and having anything (anything at all) passed by value is not the right thing to do. > My thought a

Re: Sadistic C compiler...

2000-01-20 Thread Richard Levitte - VMS Whacker
appro> *** ./bio.h.origMon Sep 27 16:00:09 1999 appro> --- ./bio.h Thu Jan 20 16:57:00 2000 appro> *** appro> *** 116,121 appro> --- 116,122 appro> /* callback is int cb(BIO *bio,state,ret); */ appro> #define BIO_CTRL_SET_CALLBACK 14 /* opt - set callback fun

Re: Sadistic C compiler...

2000-01-20 Thread Richard Levitte - VMS Whacker
appro> Well, it's actually 3 and 5 which are the same. I.e. in the Ah, right, I made the comparison from a language semantics point of view... appro> > It's a good way to deal with the problem in what could be perceived as appro> > a safe way, but for a detail: there's no way to see from the API

Re: Sadistic C compiler...

2000-01-20 Thread Andy Polyakov
> appro> My vote is #5 for crypto/mem_dbg.c, crypto/bio/bss_conn.c, > appro> ssl/s3_lib.c with new calls and separate ctl codes for binary > appro> compatibility (I can fix up bss_conn.c and s3_lib.c to *show* > appro> what I mean). I'll be back about o_names.c... Below is what I ment for bss_conn

Re: Sadistic C compiler...

2000-01-20 Thread Andy Polyakov
> appro> > Why pass a reference? C has been able to pass&return aggregate types since > appro> > v7 :) > appro> Because *that* would *definitely* have impact on *a lot* of things. Pass > appro> by value is an option only if you reimplement all function dealing with > appro> whitened parameter to

Re: Sadistic C compiler...

2000-01-19 Thread Richard Levitte - VMS Whacker
appro> > Why pass a reference? C has been able to pass&return aggregate types since appro> > v7 :) appro> Because *that* would *definitely* have impact on *a lot* of things. Pass appro> by value is an option only if you reimplement all function dealing with appro> whitened parameter to callback f

Re: Sadistic C compiler...

2000-01-19 Thread Andy Polyakov
> appro> Why not simply relax the compiler with /STANDARD=RELAXED or whatever:-) > > Sure, we can do that. Is that the right thing to do? ":-)" was actually ment to designate the wrong thing. > > We need to decide if this is something that actually warrants our > attention, or if we think it ca

Re: Sadistic C compiler...

2000-01-19 Thread Andy Polyakov
> > And what if sizeof (void (*)()) != sizeof (void *)? Think MS-DOS and all > > those sick small/medium/large/huge memory models if you have to. I > > realize it's a sick thought, but that's what the compiler complains > > about and that's why "such a cast is not permitted by the standard." > >

Re: Sadistic C compiler...

2000-01-19 Thread Andy Polyakov
> Why pass a reference? C has been able to pass&return aggregate types since > v7 :) Because *that* would *definitely* have impact on *a lot* of things. Pass by value is an option only if you reimplement all function dealing with whitened parameter to callback functions. I mean if you want to sti

Re: Sadistic C compiler...

2000-01-18 Thread Dr Stephen Henson
Bodo Moeller wrote: > > > The clean way (and not just another "clever hack") would be > > void SSL_CTX_set_tmp_rsa_callback(SSL_CTX *ctx,RSA *(*cb)(SSL *ssl, > int is_export, > in

Re: Sadistic C compiler...

2000-01-18 Thread Dr Stephen Henson
Richard Levitte - VMS Whacker wrote: > > SalzR> In the ANSI standard C sense, there is no real difference > SalzR> between the C language and the supporting libraries. > > It's useless to discuss it unless someone can cite the exact words of > the standard here. Until then, we're just talking o

RE: Sadistic C compiler...

2000-01-18 Thread Richard Levitte - VMS Whacker
SalzR> In the ANSI standard C sense, there is no real difference SalzR> between the C language and the supporting libraries. It's useless to discuss it unless someone can cite the exact words of the standard here. Until then, we're just talking out of our behinds. -- Richard Levitte \ Spannv

Re: Sadistic C compiler...

2000-01-18 Thread Bodo Moeller
Richard Levitte - VMS Whacker <[EMAIL PROTECTED]>: [...] > The easiest way to avoid the conversions noted above is to have a > union like this: > > union foo { > void *simple; > int (*fn)(); > }; > > and use it internally. You put whatever char * you wan

RE: Sadistic C compiler...

2000-01-18 Thread Salz, Rich
In the ANSI standard C sense, there is no real difference between the C language and the supporting libraries. I don't have a copy of the standard handy, but I'm fairly sure it can be safely castable as I said before. Therefore if Compaq's C compiler #define's it as void*, then their "compiler"

Re: Sadistic C compiler...

2000-01-18 Thread Ben Laurie
"Salz, Rich" wrote: > > Why pass a reference? C has been able to pass&return aggregate types since > v7 :) Good point. > >only way to do this validly is to make the functions > >actually take a foo* as their argument, surely? > > Yes you must do that. > > >I'll bet in most cases you can make

RE: Sadistic C compiler...

2000-01-18 Thread Richard Levitte - VMS Whacker
SalzR> Looks like a compiler bug; NULL is supposed to be safely SalzR> castable to any pointer type, and compared against any pointer SalzR> type. Depends on. If NULL is defined like this: #define NULL 0 then you're perfectly right, but if it's defined like this: #define NULL

RE: Sadistic C compiler...

2000-01-18 Thread Jeffrey Altman
> Looks like a compiler bug; NULL is supposed to be safely castable to any > pointer type, and compared against any pointer type. NULL is often a pound define and not a compiler name. Its definition is very frequently (char *)0 which is not comparable. Jeffrey Altman * Sr.Software Des

Re: Sadistic C compiler...

2000-01-18 Thread Bodo Moeller
On Tue, Jan 18, 2000 at 10:59:53AM +0100, Richard Levitte - VMS Whacker wrote: >> bit data pointers). To force C to convert values between >> these types, you'd have to cast to some integer type inbetween: >> (void (*)()) (long) cb > This may very well be a problem on architectures whe

RE: Sadistic C compiler...

2000-01-18 Thread Salz, Rich
Looks like a compiler bug; NULL is supposed to be safely castable to any pointer type, and compared against any pointer type. __ OpenSSL Project http://www.openssl.org Development Mailing List

Re: Sadistic C compiler...

2000-01-18 Thread Richard Levitte - VMS Whacker
appro> Why not simply relax the compiler with /STANDARD=RELAXED or whatever:-) Sure, we can do that. Is that the right thing to do? I remember that at some point, it was "all hail ANSI C", something I support. But not only that, if this problem is enough to actually create errors on "MS-DOS an

Re: Sadistic C compiler...

2000-01-18 Thread Michael Sierchio
Jeffrey Altman wrote: . > 4 fn(x, y, z);/* Function call: functions */ > /* x and y, and array z */ > /* passed as addresses */ A function pointer may not be an "address" -- in particul

RE: Sadistic C compiler...

2000-01-18 Thread Salz, Rich
Why pass a reference? C has been able to pass&return aggregate types since v7 :) >only way to do this validly is to make the functions >actually take a foo* as their argument, surely? Yes you must do that. >I'll bet in most cases you can make the foo static Unless I misunderstand what you mea

Re: Sadistic C compiler...

2000-01-18 Thread Andy Polyakov
> > > The easiest way to avoid the conversions noted above is to have a > > > union like this: > > > > > > union foo { > > > void *simple; > > > int (*fn)(); > > > }; > > > > > > and use it internally. You put whatever char * you want to convert to

Re: Sadistic C compiler...

2000-01-18 Thread Jeffrey Altman
> And what if sizeof (void (*)()) != sizeof (void *)? Think MS-DOS and all > those sick small/medium/large/huge memory models if you have to. I > realize it's a sick thought, but that's what the compiler complains > about and that's why "such a cast is not permitted by the standard." In this part

Re: Sadistic C compiler...

2000-01-18 Thread Andy Polyakov
> appro> Just to make it clear. Are you going to pass the union by > appro> reference of by value? You have to pass by reference which is > appro> equivalent to what I proposed, but without unions. Passing by > appro> value would be wrong and compiler should complain. > > As you have probably see

Re: Sadistic C compiler...

2000-01-18 Thread Dr Stephen Henson
Ben Laurie wrote: > > Richard Levitte - VMS Whacker wrote: > > The easiest way to avoid the conversions noted above is to have a > > union like this: > > > > union foo { > > void *simple; > > int (*fn)(); > > }; > > > > and use it internally. You p

Re: Sadistic C compiler...

2000-01-18 Thread Richard Levitte - VMS Whacker
appro> Just to make it clear. Are you going to pass the union by appro> reference of by value? You have to pass by reference which is appro> equivalent to what I proposed, but without unions. Passing by appro> value would be wrong and compiler should complain. As you have probably seen by now, I

Re: Sadistic C compiler...

2000-01-18 Thread Ben Laurie
Richard Levitte - VMS Whacker wrote: > The easiest way to avoid the conversions noted above is to have a > union like this: > > union foo { > void *simple; > int (*fn)(); > }; > > and use it internally. You put whatever char * you want to convert

Re: Sadistic C compiler...

2000-01-18 Thread Richard Levitte - VMS Whacker
bmoeller> bit data pointers). To force C to convert values between bmoeller> these types, you'd have to cast to some integer type inbetween: bmoeller> bmoeller> (void (*)()) (long) cb This may very well be a problem on architectures where a pointer is 64 bits while a long is 32 bits. I

Re: Sadistic C compiler...

2000-01-18 Thread Andy Polyakov
> bmoeller> &cb, > bmoeller> on the other hand, is the pointer to some data object; the > bmoeller> function that gets this pointer as an argument has to > bmoeller> retrieve the actual function pointer from inside this data > bmoeller> object, i.e. use *((void (**)()) arg) where arg is the void >

Re: Sadistic C compiler...

2000-01-18 Thread Andy Polyakov
> appro> > The function pointer *must* be inside a data object to make > appro> > such constructs legal, > > appro> But that's what Richard (subconsciously?) attempted to do in > appro> first place: > > Don't look at me, that part of the code was there in mem.c since > eons... Sorry:-) I should

Re: Sadistic C compiler...

2000-01-17 Thread Bodo Moeller
Andy Polyakov <[EMAIL PROTECTED]>: >> The function pointer *must* be inside a data object to make such constructs >> legal, > But that's what Richard (subconsciously?) attempted to do in first > place: > > static void (*mem_cb)()=NULL; > > void CRYPTO_mem_leaks_cb(void (*cb)()) > { >

Re: Sadistic C compiler...

2000-01-17 Thread Jeffrey Altman
And more text: 5.6.2 Function and Array Identifiers as Arguments Function and array identifiers can be specified as argu- ments to a function. Function identifiers are specified without parentheses, and array identifiers are specified without brackets. When so specified, the function o

Re: Sadistic C compiler...

2000-01-17 Thread Richard Levitte - VMS Whacker
levitte> BTW, I just discovered the following (about crypto/x509v3/v3_int.c): levitte> levitte> (X509V3_EXT_S2I)NULL, levitte> ^ levitte> %CC-I-NONSTANDCAST, In the initializer for v3_crl_num.s2i, "((void ...)0)" of type "pointer to void", is being converted to "pointer to functi

Re: Sadistic C compiler...

2000-01-17 Thread Jeffrey Altman
Maybe the following text from the Compaq C programmer's manual on types will be helpful: 2.7 Compatible and Composite Types Compatibility between types refers to the similarity of two types to each other. Type compatibility is important during type conversions and operations. All valid

Re: Sadistic C compiler...

2000-01-17 Thread Richard Levitte - VMS Whacker
appro> > The function pointer *must* be inside a data object to make appro> > such constructs legal, appro> But that's what Richard (subconsciously?) attempted to do in appro> first place: Don't look at me, that part of the code was there in mem.c since eons... appro> static void (*mem_cb)()=NU

Re: Sadistic C compiler...

2000-01-17 Thread Richard Levitte - VMS Whacker
BTW, I just discovered the following (about crypto/x509v3/v3_int.c): (X509V3_EXT_S2I)NULL, ^ %CC-I-NONSTANDCAST, In the initializer for v3_crl_num.s2i, "((void ...)0)" of type "pointer to void", is being converted to "pointer to function (pointer to struct v3_ext_method, pointer

Re: Sadistic C compiler...

2000-01-17 Thread Richard Levitte - VMS Whacker
drh> Hmmm. Does VMS have an equivalent to shared libraries which can drh> be loaded at runtime? drh> If so how is that handled? Looks like this: int status = LIB$FIND_FILE_SYMBOL(lib_file, symbol_name, &symbol_address, dir_spec, flags); The secret is that LIB$

Re: Sadistic C compiler...

2000-01-17 Thread Richard Levitte - VMS Whacker
ssampson> > DEC C for VMS is getting really mean. ssampson> ssampson> There's a reason DEC went out of business :-) True. However, that's not it. DEC software has had a tendency to hold quite high quality, and it seems that Compaq will keep that. Sorry, but you really shot the wrong dog here.

Re: Sadistic C compiler...

2000-01-17 Thread Richard Levitte - VMS Whacker
bmoeller> The function pointer *must* be inside a data object to make bmoeller> such constructs legal, so this is not silly at all. Perfectly right. My "silly" wasn't completely serious... Anyway, thanks for the input, it confirmed that my thoughts were right. Time to hack :-). -- Richard Le

Re: Sadistic C compiler...

2000-01-17 Thread Andy Polyakov
And why not even get rid of mem_cb:-) > > typedef void (*cb_t) (); > > static void cb_leak(MEM *m, void *cb) > { > void (*mem_callback)()=*((cb_t *)cb); > mem_callback(m->order,m->file,m->line,m->num,m->addr); > } > > void CRYPTO_mem_leaks_cb(void (*cb)()) >

Re: Sadistic C compiler...

2000-01-17 Thread Andy Polyakov
> > DEC C for VMS is getting really mean. Version 6.2 ^^^ It has nothing to do with VMS. It complains about casts between (*) and * even on Unix. > > > It's especially visible in all the places where lh_doall_arg() gets a > > casted function pointer as last argument (for example, se

Re: Sadistic C compiler...

2000-01-17 Thread Dr Stephen Henson
Richard Levitte - VMS Whacker wrote: > > DEC C for VMS is getting really mean. Version 6.2 (latest, as far as > I know) spews out a message when a (char *) cast is done to a function > pointer and vice versa. Guess what it finds a little here and there > in OpenSSL? :-) > > Changing (char *)

Re: Sadistic C compiler...

2000-01-17 Thread Bodo Moeller
On Mon, Jan 17, 2000 at 01:06:27AM +0100, Richard Levitte - VMS Whacker wrote: > DEC C for VMS is getting really mean. Version 6.2 (latest, as far as > I know) spews out a message when a (char *) cast is done to a function > pointer and vice versa. Every compiler should print such warnings, suc

Re: Sadistic C compiler...

2000-01-17 Thread Steve Sampson
> > DEC C for VMS is getting really mean. There's a reason DEC went out of business :-) __ OpenSSL Project http://www.openssl.org Development Mailing List [EMAIL PROTECTED]

Re: Sadistic C compiler...

2000-01-17 Thread Ben Laurie
Richard Levitte - VMS Whacker wrote: > > DEC C for VMS is getting really mean. Version 6.2 (latest, as far as > I know) spews out a message when a (char *) cast is done to a function > pointer and vice versa. Guess what it finds a little here and there > in OpenSSL? :-) Presumably this is bec