[gnutls-devel] Casting from int to (void *)
hilberg at kernelconcepts.de
Thu Feb 7 10:10:44 CET 2013
Am Donnerstag 07 Februar 2013, um 09:34:13 schrieb Nikos Mavrogiannopoulos:
> On Tue, Feb 5, 2013 at 5:23 PM, Jaak Ristioja <jaak.ristioja at cyber.ee> wrote:
> > Hello!
> > According to the documentation GnuTLS functions like
> > gnutls_transport_set_ptr can also be used for berkeley style sockets
> > descriptors, but unfortunately converting between int and void * types
> > is not always good thing to do:
> What we actually need is for the compiler to be able to do (int->ptr)
> and then (ptr->int) in a way that no information is lost (i.e., the
> last int will be the same as the first). The current approach is, if
> the callbacks are set, then the provided pointer is passed to them,
> and if not, the transport pointer is casted to an integer and provided
> to send(). If there was an issue a function like you describe could be
> used and the the value to a union, but is it really needed? Do you
> think there will be systems where the current behavior will not be
> tolerated? (such a set_berkeley function would solve the warning issue
Maybe have a look at the GLib GINT_TO_POINTER and GPOINTER_TO_INT
macros. Possibly there's some inspiration available there, although
I'm not currently sure whether they do much magic there.
kernel concepts GmbH Tel: +49-271-771091-11
Sieghuetter Hauptweg 48
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 198 bytes
Desc: This is a digitally signed message part.
More information about the Gnutls-devel