OpenSSL - a couple of questions

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

OpenSSL - a couple of questions

Schwab,Wilhelm K
Hello all,

Do you have any thoughts on whether a wrapper for OpenSSL should be a plugin or based on FFI/Alien?  Would blocking calls be best handled by using OS threads or non-blocking sockets?  In either case, I would envision using semaphores to block only the calling Process instance.

Loosely related, can you understand (and explain to me - perhaps the hard part<g>) the following syntax:

   void (*CRYPTO_get_locking_callback(void))(int mode,int type,const char
*file,int line);

It looks to me like a shotgun wedding of an incomplete typedef of a function pointer type and a function prototype.  Any ideas?

Bill



_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: OpenSSL - a couple of questions

Nicolas Cellier-3
Schwab,Wilhelm K <bschwab@...> writes:

>
> Hello all,
>
> Do you have any thoughts on whether a wrapper for OpenSSL should be a plugin
or based on FFI/Alien?  Would
> blocking calls be best handled by using OS threads or non-blocking sockets?
In either case, I would
> envision using semaphores to block only the calling Process instance.
>
> Loosely related, can you understand (and explain to me - perhaps the hard
part<g>) the following syntax:
>
>    void (*CRYPTO_get_locking_callback(void))(int mode,int type,const char
> *file,int line);
>
> It looks to me like a shotgun wedding of an incomplete typedef of a function
pointer type and a function
> prototype.  Any ideas?
>
> Bill
>

Doesn't the CRYPTO_get_locking_callback function returns a pointer to a function
with no argument (void) and no return value (void), or something like that ?

Nicolas





_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: OpenSSL - a couple of questions

Schwab,Wilhelm K
Nicolas,

Fair enough, but it's the rest of the expression that bothers me - what does the second argument sequence do?

Bill



-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Nicolas Cellier
Sent: Tuesday, March 10, 2009 3:23 PM
To: [hidden email]
Subject: Re: [Pharo-project] OpenSSL - a couple of questions

Schwab,Wilhelm K <bschwab@...> writes:

>
> Hello all,
>
> Do you have any thoughts on whether a wrapper for OpenSSL should be a plugin
or based on FFI/Alien?  Would
> blocking calls be best handled by using OS threads or non-blocking sockets?
In either case, I would
> envision using semaphores to block only the calling Process instance.
>
> Loosely related, can you understand (and explain to me - perhaps the hard
part<g>) the following syntax:
>
>    void (*CRYPTO_get_locking_callback(void))(int mode,int type,const char
> *file,int line);
>
> It looks to me like a shotgun wedding of an incomplete typedef of a function
pointer type and a function
> prototype.  Any ideas?
>
> Bill
>

Doesn't the CRYPTO_get_locking_callback function returns a pointer to a function
with no argument (void) and no return value (void), or something like that ?

Nicolas





_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: OpenSSL - a couple of questions

Nicolas Cellier-3
Schwab,Wilhelm K <bschwab@...> writes:

>
> Nicolas,
>
> Fair enough, but it's the rest of the expression that bothers me - what does
the second argument sequence do?
>
> Bill
>

I'm not sure I understand the question, but i'll tell how I read this syntax:

CRYPTO_get_locking_callback is a function taking four arguments
(int mode,int type,const char *file,int line).

CRYPTO_get_locking_callback will return a pointer to a function, say F.
This function F does take no argument and return no result.
void F(void).

Nicolas

> -----Original Message-----
> From: pharo-project-bounces@...
> [mailto:pharo-project-bounces@...] On Behalf
> Of Nicolas Cellier
> Sent: Tuesday, March 10, 2009 3:23 PM
> To: pharo-project@...
> Subject: Re: [Pharo-project] OpenSSL - a couple of questions
>
> Schwab,Wilhelm K <bschwab@...> writes:
>
gmane want me to snip...


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: OpenSSL - a couple of questions

Schwab,Wilhelm K
Nicolas,

I would read

void (*CRYPTO_get_locking_callback)(int mode,int type,const
      char *file,int line)

as a pointer to a function taking four arguments and returning nothing.  
That is _not_ what OpenSSL defines.  With the added void argument, it looks to me like the callback takes no arguments and returns nothing.

I would expect what you described to look more like

(void* (*CRYPTO_get_locking_callback)(int mode,int type,const
      char *file,int line)) F(void);


I prefer to "hide" function pointers using type definitions to make them clear.  You mention a function named F, but the given syntax does not name it.  It does look like any prototype I have seen, and it's not a typedef, unless that is happening implicitly??

Bill


-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Nicolas Cellier
Sent: Tuesday, March 10, 2009 5:14 PM
To: [hidden email]
Subject: Re: [Pharo-project] OpenSSL - a couple of questions

Schwab,Wilhelm K <bschwab@...> writes:

>
> Nicolas,
>
> Fair enough, but it's the rest of the expression that bothers me - what does
the second argument sequence do?
>
> Bill
>

I'm not sure I understand the question, but i'll tell how I read this syntax:

CRYPTO_get_locking_callback is a function taking four arguments
(int mode,int type,const char *file,int line).

CRYPTO_get_locking_callback will return a pointer to a function, say F.
This function F does take no argument and return no result.
void F(void).

Nicolas

> -----Original Message-----
> From: pharo-project-bounces@...
> [mailto:pharo-project-bounces@...] On Behalf
> Of Nicolas Cellier
> Sent: Tuesday, March 10, 2009 3:23 PM
> To: pharo-project@...
> Subject: Re: [Pharo-project] OpenSSL - a couple of questions
>
> Schwab,Wilhelm K <bschwab@...> writes:
>
gmane want me to snip...


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: OpenSSL - a couple of questions

Nicolas Cellier-3
Schwab,Wilhelm K <bschwab@...> writes:

>
> Nicolas,
>
> I would read
>
> void (*CRYPTO_get_locking_callback)(int mode,int type,const
>       char *file,int line)
>
> as a pointer to a function taking four arguments and returning nothing.  
> That is _not_ what OpenSSL defines.  With the added void argument, it looks to
me like the callback takes no
> arguments and returns nothing.
>
> I would expect what you described to look more like
>
> (void* (*CRYPTO_get_locking_callback)(int mode,int type,const
>       char *file,int line)) F(void);
>
> I prefer to "hide" function pointers using type definitions to make them
clear.  You mention a function
> named F, but the given syntax does not name it.  It does look like any
prototype I have seen, and it's not a
> typedef, unless that is happening implicitly??
>
> Bill
>

I introduced a named return value F just for trying to explain.
F is the return value, so it is anonymous.

This is a valid syntax for a function returning a pointer to a function.

But of course my explanation was plain wrong...
Sorry. I inverted the arguments...

So here is a better explanation.

0) CRYPTO_get_locking_callback is the name of the function.
It is not a typedef.
1) CRYPTO_get_locking_callback is a function taking no argument (void)
2) it returns a pointer to a function which
2.a) return nothing (void)
2.b) takes four arguments int mode,int type,const char *file,int line))

I can read C, but const and function pointer are ones I will fail to parse 50%
of time... Feel like I must not be alone...

This is C anyway... It's not that easy to speak to a dumb compiler, so that he
finally understands how to optimize that code! And not to optimize that code is
of course not an option...

Nicolas

> -----Original Message-----
> From: pharo-project-bounces@...
> [mailto:pharo-project-bounces@...] On Behalf
> Of Nicolas Cellier
> Sent: Tuesday, March 10, 2009 5:14 PM
> To: pharo-project@...
> Subject: Re: [Pharo-project] OpenSSL - a couple of questions
>
> Schwab,Wilhelm K <bschwab@...> writes:
>
> >
> > Nicolas,
> >
> > Fair enough, but it's the rest of the expression that bothers me - what does
> the second argument sequence do?
> >
> > Bill
> >
>
> I'm not sure I understand the question, but i'll tell how I read this syntax:
>
> CRYPTO_get_locking_callback is a function taking four arguments
> (int mode,int type,const char *file,int line).
>
> CRYPTO_get_locking_callback will return a pointer to a function, say F.
> This function F does take no argument and return no result.
> void F(void).
>
> Nicolas
>
> > -----Original Message-----
> > From: pharo-project-bounces@...
> > [mailto:pharo-project-bounces@...] On Behalf
> > Of Nicolas Cellier
> > Sent: Tuesday, March 10, 2009 3:23 PM
> > To: pharo-project@...
> > Subject: Re: [Pharo-project] OpenSSL - a couple of questions
> >
> > Schwab,Wilhelm K <bschwab@...> writes:
> >
> gmane want me to snip...
>
> _______________________________________________
> Pharo-project mailing list
> Pharo-project@...
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>





_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: OpenSSL - a couple of questions

Schwab,Wilhelm K
Nicolas,

I think I am starting to get it.  It is a prototype for CRYPTO_get_locking_callback() ??

It appears that

   ( *funcName(args) )

signifies that funcName() returns a pointer to the function type "wrapped around" it?  In this case void NoName(int mode, int type, const char* file, int line).

I think I just found this described on pg 169-170 of my copy of Lippman's C++ Primer.  Why people do not consistently use typedefs for this type of thing is beyond me ~:(

Thanks!

Bill





>    void (*CRYPTO_get_locking_callback(void))(int mode,int type,const
> char *file,int line);

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Nicolas Cellier
Sent: Tuesday, March 10, 2009 7:23 PM
To: [hidden email]
Subject: Re: [Pharo-project] OpenSSL - a couple of questions


So here is a better explanation.

0) CRYPTO_get_locking_callback is the name of the function.
It is not a typedef.
1) CRYPTO_get_locking_callback is a function taking no argument (void)
2) it returns a pointer to a function which
2.a) return nothing (void)
2.b) takes four arguments int mode,int type,const char *file,int line))

I can read C, but const and function pointer are ones I will fail to parse 50%
of time... Feel like I must not be alone...

This is C anyway... It's not that easy to speak to a dumb compiler, so that he
finally understands how to optimize that code! And not to optimize that code is
of course not an option...

Nicolas


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project