Hi Kristen,

> > > +static guint32 bytes_to_32(guint8 *bytes)
> > > +{
> > > + union addr {
> > > +         guint8 bytes[4];
> > > +         guint32 word;
> > > + } a;
> > > +
> > > + memcpy(a.bytes, bytes, 4);
> > > + return(ntohl(a.word));
> > > +}
> > 
> > This works, but is pretty ugly.
> > 
> > Doesn't GLib has functions to ensure retrieve unaligned data? BlueZ has
> > the GCC magic that is required to do this right.
> >
> 
> I have looked everywhere for something nice from glib, but I'm not
> seeing it.  As far as I can tell, most people just do the bit shifting
> manually -- but that's what I had originally and you didn't like it.
> So I'm only seeing 2 options here, this way or the original way.  If
> you know of the glib function to use, please let me know what it is.

I don't see how bit shifting is gonna help you against the unaligned
access of your buffer.

Regards

Marcel


_______________________________________________
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono

Reply via email to