From: Benjamin O. <co...@us...> - 2002-01-29 20:42:21
|
Update of /cvsroot/gstreamer/gstreamer/gst/elements In directory usw-pr-cvs1:/tmp/cvs-serv30729 Modified Files: gstmd5sink.c Log Message: dude, use glib swap functions Index: gstmd5sink.c =================================================================== RCS file: /cvsroot/gstreamer/gstreamer/gst/elements/gstmd5sink.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- gstmd5sink.c 2002/01/29 20:06:07 1.1 +++ gstmd5sink.c 2002/01/29 20:42:18 1.2 @@ -24,18 +24,7 @@ */ #include <string.h> -#include <endian.h> -# define SWAP(n) (n) -#ifdef _LIBC -# include <endian.h> -# if __BYTE_ORDER == __BIG_ENDIAN -# undef SWAP -# define SWAP(n) \ - (((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24)) -# endif -#endif - #include <config.h> #include <gst/gst.h> @@ -124,8 +113,8 @@ memcpy (&ctx->buffer[bytes], fillbuf, pad); /* Put the 64-bit file length in *bits* at the end of the buffer. */ - *(guint32 *) &ctx->buffer[bytes + pad] = SWAP (ctx->total[0] << 3); - *(guint32 *) &ctx->buffer[bytes + pad + 4] = SWAP ((ctx->total[1] << 3) | + *(guint32 *) &ctx->buffer[bytes + pad] = GUINT32_TO_LE (ctx->total[0] << 3); + *(guint32 *) &ctx->buffer[bytes + pad + 4] = GUINT32_TO_LE ((ctx->total[1] << 3) | (ctx->total[0] >> 29)); /* Process last bytes. */ @@ -141,10 +130,10 @@ gpointer md5_read_ctx (GstMD5Sink *ctx, gpointer resbuf) { - ((guint32 *) resbuf)[0] = SWAP (ctx->A); - ((guint32 *) resbuf)[1] = SWAP (ctx->B); - ((guint32 *) resbuf)[2] = SWAP (ctx->C); - ((guint32 *) resbuf)[3] = SWAP (ctx->D); + ((guint32 *) resbuf)[0] = GUINT32_TO_LE (ctx->A); + ((guint32 *) resbuf)[1] = GUINT32_TO_LE (ctx->B); + ((guint32 *) resbuf)[2] = GUINT32_TO_LE (ctx->C); + ((guint32 *) resbuf)[3] = GUINT32_TO_LE (ctx->D); return resbuf; } @@ -257,7 +246,7 @@ #define OP(a, b, c, d, s, T) \ do \ { \ - a += FF (b, c, d) + (*cwp++ = SWAP (*words)) + T; \ + a += FF (b, c, d) + (*cwp++ = GUINT32_TO_LE (*words)) + T; \ ++words; \ CYCLIC (a, s); \ a += b; \ |