FS#12102 - Manual, "Quick Start" section for AMSv2 players: Clarifies
[kugel-rb.git] / tools / ucl / src / ucl_util.h
blob2292716e4cfdbe86d5a8cd5fa9dc6129517bea62
1 /* ucl_util.h -- utilities for the UCL library
3 This file is part of the UCL data compression library.
5 Copyright (C) 1996-2002 Markus Franz Xaver Johannes Oberhumer
6 All Rights Reserved.
8 The UCL library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2 of
11 the License, or (at your option) any later version.
13 The UCL library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with the UCL library; see the file COPYING.
20 If not, write to the Free Software Foundation, Inc.,
21 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 Markus F.X.J. Oberhumer
24 <markus@oberhumer.com>
28 /* WARNING: this file should *not* be used by applications. It is
29 part of the implementation of the library and is subject
30 to change.
34 #ifndef __UCL_UTIL_H
35 #define __UCL_UTIL_H
37 #ifndef __UCL_CONF_H
38 # include "ucl_conf.h"
39 #endif
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
46 /***********************************************************************
47 // fast memcpy that copies multiples of 8 byte chunks.
48 // len is the number of bytes.
49 // note: all parameters must be lvalues, len >= 8
50 // dest and src advance, len is undefined afterwards
51 ************************************************************************/
53 #if 1 && defined(HAVE_MEMCPY)
54 #if !defined(__UCL_DOS16) && !defined(__UCL_WIN16)
56 #define MEMCPY8_DS(dest,src,len) \
57 memcpy(dest,src,len); \
58 dest += len; \
59 src += len
61 #endif
62 #endif
65 #if 0 && !defined(MEMCPY8_DS)
67 #define MEMCPY8_DS(dest,src,len) \
68 { do { \
69 *dest++ = *src++; \
70 *dest++ = *src++; \
71 *dest++ = *src++; \
72 *dest++ = *src++; \
73 *dest++ = *src++; \
74 *dest++ = *src++; \
75 *dest++ = *src++; \
76 *dest++ = *src++; \
77 len -= 8; \
78 } while (len > 0); }
80 #endif
83 #if !defined(MEMCPY8_DS)
85 #define MEMCPY8_DS(dest,src,len) \
86 { register ucl_uint __l = (len) / 8; \
87 do { \
88 *dest++ = *src++; \
89 *dest++ = *src++; \
90 *dest++ = *src++; \
91 *dest++ = *src++; \
92 *dest++ = *src++; \
93 *dest++ = *src++; \
94 *dest++ = *src++; \
95 *dest++ = *src++; \
96 } while (--__l > 0); }
98 #endif
101 /***********************************************************************
102 // memcpy and pseudo-memmove
103 // len is the number of bytes.
104 // note: all parameters must be lvalues, len > 0
105 // dest and src advance, len is undefined afterwards
106 ************************************************************************/
108 #define MEMCPY_DS(dest,src,len) \
109 do *dest++ = *src++; \
110 while (--len > 0)
112 #define MEMMOVE_DS(dest,src,len) \
113 do *dest++ = *src++; \
114 while (--len > 0)
117 /***********************************************************************
118 // fast bzero that clears multiples of 8 pointers
119 // n is the number of pointers.
120 // note: n > 0
121 // s and n are undefined afterwards
122 ************************************************************************/
124 #if (UCL_UINT_MAX <= SIZE_T_MAX) && defined(HAVE_MEMSET)
126 #if 1
127 #define BZERO8_PTR(s,l,n) memset((s),0,(ucl_uint)(l)*(n))
128 #else
129 #define BZERO8_PTR(s,l,n) memset((ucl_voidp)(s),0,(ucl_uint)(l)*(n))
130 #endif
132 #else
134 #define BZERO8_PTR(s,l,n) \
135 ucl_memset((ucl_voidp)(s),0,(ucl_uint)(l)*(n))
137 #endif
140 /***********************************************************************
141 // rotate (not used at the moment)
142 ************************************************************************/
144 #if 0
145 #if defined(__GNUC__) && defined(__i386__)
147 unsigned char ucl_rotr8(unsigned char value, int shift);
148 extern __inline__ unsigned char ucl_rotr8(unsigned char value, int shift)
150 unsigned char result;
152 __asm__ __volatile__ ("movb %b1, %b0; rorb %b2, %b0"
153 : "=a"(result) : "g"(value), "c"(shift));
154 return result;
157 unsigned short ucl_rotr16(unsigned short value, int shift);
158 extern __inline__ unsigned short ucl_rotr16(unsigned short value, int shift)
160 unsigned short result;
162 __asm__ __volatile__ ("movw %b1, %b0; rorw %b2, %b0"
163 : "=a"(result) : "g"(value), "c"(shift));
164 return result;
167 #endif
168 #endif
172 #ifdef __cplusplus
173 } /* extern "C" */
174 #endif
176 #endif /* already included */
179 vi:ts=4:et