Re: [PATCH 2/6] LZ4: Implement ntohl to remove dependency on arpa/inet.h

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I saw some comments about MSVC in spice-gtk, and I thought someone could be 
using it to build the Windows client. Anyway, I don't mind using one solution 
or another, so you tell me.

El Viernes, 23 de enero de 2015 16:40:42 Christophe Fergeau escribió:
> Hey,
> 
> As this is not going to be built using MSVC, I don't think it's a huge
> problem using ntohl. If you really don't want to use it, I'd favour
> adding a dependency on glib, and using GUINT32_FROM_LE.
> 
> Christophe
> 
> On Thu, Jan 22, 2015 at 05:21:20PM +0100, Javier Celaya wrote:
> > ---
> > 
> >  common/canvas_base.c | 15 +++++++++++++--
> >  1 file changed, 13 insertions(+), 2 deletions(-)
> > 
> > diff --git a/common/canvas_base.c b/common/canvas_base.c
> > index cfbba5e..0f6b7f4 100644
> > --- a/common/canvas_base.c
> > +++ b/common/canvas_base.c
> > @@ -27,7 +27,6 @@
> > 
> >  #include <math.h>
> >  
> >  #ifdef USE_LZ4
> > 
> > -#include <arpa/inet.h>
> > 
> >  #include <lz4.h>
> >  #endif
> >  #include <spice/macros.h>
> > 
> > @@ -548,6 +547,18 @@ static pixman_image_t *canvas_get_jpeg(CanvasBase
> > *canvas, SpiceImage *image, in> 
> >  }
> >  
> >  #ifdef USE_LZ4
> > 
> > +static inline uint32_t lz4_decode32(uint8_t *buffer)
> > +{
> > +    // Network order -> big endian
> > +    uint32_t value = 0;
> > +    int i;
> > +    for (i = 0; i < 4; ++i) {
> > +        value <<= 8;
> > +        value += buffer[i];
> > +    }
> > +    return value;
> > +}
> > +
> > 
> >  static pixman_image_t *canvas_get_lz4(CanvasBase *canvas, SpiceImage
> >  *image, int invers) {
> >  
> >      pixman_image_t *surface = NULL;
> > 
> > @@ -587,7 +598,7 @@ static pixman_image_t *canvas_get_lz4(CanvasBase
> > *canvas, SpiceImage *image, int> 
> >      do {
> >      
> >          // Read next compressed block
> > 
> > -        enc_size = ntohl(*((uint32_t *)data));
> > +        enc_size = lz4_decode32(data);
> > 
> >          data += 4;
> >          dec_size = LZ4_decompress_safe_continue(stream, (const char *)
> >          data,
> >          
> >                                                  (char *) dest, enc_size,
> >                                                  available);

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]