ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/liblzf/lzf_d.c
(Generate patch)

Comparing liblzf/lzf_d.c (file contents):
Revision 1.11 by root, Sun May 30 05:52:57 2010 UTC vs.
Revision 1.16 by root, Mon Feb 23 23:46:10 2015 UTC

1/* 1/*
2 * Copyright (c) 2000-2010 Marc Alexander Lehmann <schmorp@schmorp.de> 2 * Copyright (c) 2000-2010 Marc Alexander Lehmann <schmorp@schmorp.de>
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without modifica- 4 * Redistribution and use in source and binary forms, with or without modifica-
5 * tion, are permitted provided that the following conditions are met: 5 * tion, are permitted provided that the following conditions are met:
6 * 6 *
7 * 1. Redistributions of source code must retain the above copyright notice, 7 * 1. Redistributions of source code must retain the above copyright notice,
8 * this list of conditions and the following disclaimer. 8 * this list of conditions and the following disclaimer.
9 * 9 *
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the 11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution. 12 * documentation and/or other materials provided with the distribution.
13 * 13 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- 15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
16 * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 16 * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
17 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- 17 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
18 * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 18 * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
34 * either the BSD or the GPL. 34 * either the BSD or the GPL.
35 */ 35 */
36 36
37#include "lzfP.h" 37#include "lzfP.h"
38 38
39#include <string.h> /* for memcpy/memset */
40
41#if AVOID_ERRNO 39#if AVOID_ERRNO
42# define SET_ERRNO(n) 40# define SET_ERRNO(n)
43#else 41#else
44# include <errno.h> 42# include <errno.h>
45# define SET_ERRNO(n) errno = (n) 43# define SET_ERRNO(n) errno = (n)
52 : "=D" (dst), "=S" (src), "=c" (len) \ 50 : "=D" (dst), "=S" (src), "=c" (len) \
53 : "0" (dst), "1" (src), "2" (len)); 51 : "0" (dst), "1" (src), "2" (len));
54#endif 52#endif
55#endif 53#endif
56 54
57unsigned int 55unsigned int
58lzf_decompress (const void *const in_data, unsigned int in_len, 56lzf_decompress (const void *const in_data, unsigned int in_len,
59 void *out_data, unsigned int out_len) 57 void *out_data, unsigned int out_len)
60{ 58{
61 u8 const *ip = (const u8 *)in_data; 59 u8 const *ip = (const u8 *)in_data;
62 u8 *op = (u8 *)out_data; 60 u8 *op = (u8 *)out_data;
85 } 83 }
86#endif 84#endif
87 85
88#ifdef lzf_movsb 86#ifdef lzf_movsb
89 lzf_movsb (op, ip, ctrl); 87 lzf_movsb (op, ip, ctrl);
88#elif OPTIMISE_SIZE
89 while (ctrl--)
90 *op++ = *ip++;
90#else 91#else
91 switch (ctrl) 92 switch (ctrl)
92 { 93 {
93 case 32: *op++ = *ip++; case 31: *op++ = *ip++; case 30: *op++ = *ip++; case 29: *op++ = *ip++; 94 case 32: *op++ = *ip++; case 31: *op++ = *ip++; case 30: *op++ = *ip++; case 29: *op++ = *ip++;
94 case 28: *op++ = *ip++; case 27: *op++ = *ip++; case 26: *op++ = *ip++; case 25: *op++ = *ip++; 95 case 28: *op++ = *ip++; case 27: *op++ = *ip++; case 26: *op++ = *ip++; case 25: *op++ = *ip++;
141 } 142 }
142 143
143#ifdef lzf_movsb 144#ifdef lzf_movsb
144 len += 2; 145 len += 2;
145 lzf_movsb (op, ref, len); 146 lzf_movsb (op, ref, len);
147#elif OPTIMISE_SIZE
148 len += 2;
149
150 do
151 *op++ = *ref++;
152 while (--len);
146#else 153#else
147 switch (len) 154 switch (len)
148 { 155 {
149 default: 156 default:
150 len += 2; 157 len += 2;
155 memcpy (op, ref, len); 162 memcpy (op, ref, len);
156 op += len; 163 op += len;
157 } 164 }
158 else 165 else
159 { 166 {
160 /* overlapping, use octte by octte copying */ 167 /* overlapping, use octet by octet copying */
161 do 168 do
162 *op++ = *ref++; 169 *op++ = *ref++;
163 while (--len); 170 while (--len);
164 } 171 }
165 172

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines