Subversion Repositories Kolibri OS

Rev

Rev 6617 | Rev 6847 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
6617 IgorA 1
; zutil.asm -- target dependent utility functions for the compression library
2
; Copyright (C) 1995-2005, 2010, 2011, 2012 Jean-loup Gailly.
3
; For conditions of distribution and use, see copyright notice in zlib.inc
4
 
5
align 4
6
z_errmsg dd ze0,ze1,ze2,ze3,ze4,ze5,ze6,ze7,ze8,ze9
7
ze0 db 'need dictionary',0 ;Z_NEED_DICT       2
8
ze1 db 'stream end',0      ;Z_STREAM_END      1
9
ze2 db '',0                ;Z_OK              0
10
ze3 db 'file error',0      ;Z_ERRNO         (-1)
11
ze4 db 'stream error',0    ;Z_STREAM_ERROR  (-2)
12
ze5 db 'data error',0      ;Z_DATA_ERROR    (-3)
13
ze6 db 'insufficient memory',0  ;Z_MEM_ERROR     (-4)
14
ze7 db 'buffer error',0         ;Z_BUF_ERROR     (-5)
15
ze8 db 'incompatible version',0 ;Z_VERSION_ERROR (-6)
16
ze9 db '',0
17
 
18
;const char * ()
19
align 4
20
proc zlibVersion
21
	mov eax,ZLIB_VERSION;
22
	ret
23
endp
24
 
25
;uLong ()
26
align 4
27
proc zlibCompileFlags
28
;    uLong flags;
29
 
30
;    flags = 0;
31
;    switch ((int)(sizeof(uInt))) {
32
;    case 2:     break;
33
;    case 4:     flags += 1;     break;
34
;    case 8:     flags += 2;     break;
35
;    default:    flags += 3;
36
;    }
37
;    switch ((int)(sizeof(uLong))) {
38
;    case 2:     break;
39
;    case 4:     flags += 1 << 2;        break;
40
;    case 8:     flags += 2 << 2;        break;
41
;    default:    flags += 3 << 2;
42
;    }
43
;    switch ((int)(sizeof(voidpf))) {
44
;    case 2:     break;
45
;    case 4:     flags += 1 << 4;        break;
46
;    case 8:     flags += 2 << 4;        break;
47
;    default:    flags += 3 << 4;
48
;    }
49
;    switch ((int)(sizeof(z_off_t))) {
50
;    case 2:     break;
51
;    case 4:     flags += 1 << 6;        break;
52
;    case 8:     flags += 2 << 6;        break;
53
;    default:    flags += 3 << 6;
54
;    }
55
;if DEBUG
56
;    flags += 1 << 8;
57
;end if
58
;#if defined(ASMV) || defined(ASMINF)
59
;    flags += 1 << 9;
60
;end if
61
if ZLIB_WINAPI eq 1
62
;    flags += 1 << 10;
63
end if
64
if BUILDFIXED eq 1
65
;    flags += 1 << 12;
66
end if
67
if DYNAMIC_CRC_TABLE eq 1
68
;    flags += 1 << 13;
69
end if
70
if NO_GZCOMPRESS eq 1
71
;    flags += 1L << 16;
72
end if
73
if NO_GZIP eq 1
74
;    flags += 1L << 17;
75
end if
76
if PKZIP_BUG_WORKAROUND eq 1
77
;    flags += 1L << 20;
78
end if
79
if FASTEST eq 1
80
;    flags += 1L << 21;
81
end if
82
;#if defined(STDC) || defined(Z_HAVE_STDARG_H)
83
;#  ifdef NO_vsnprintf
84
;    flags += 1L << 25;
85
;#    ifdef HAS_vsprintf_void
86
;    flags += 1L << 26;
87
;#    endif
88
;#  else
89
;#    ifdef HAS_vsnprintf_void
90
;    flags += 1L << 26;
91
;#    endif
92
;#  endif
93
;#else
94
;    flags += 1L << 24;
95
;#  ifdef NO_snprintf
96
;    flags += 1L << 25;
97
;#    ifdef HAS_sprintf_void
98
;    flags += 1L << 26;
99
;#    endif
100
;#  else
101
;#    ifdef HAS_snprintf_void
102
;    flags += 1L << 26;
103
;#    endif
104
;#  endif
105
;end if
106
;    return flags;
107
	ret
108
endp
109
 
110
;void (m)
6639 IgorA 111
;    char *m
6617 IgorA 112
align 4
113
proc z_error, m:dword
114
;    fprintf(stderr, "%s\n", m);
115
;    exit(1);
116
	ret
117
endp
118
 
119
; exported to allow conversion of error code to string for compress() and
120
; uncompress()
121
 
122
;const char * (err)
6639 IgorA 123
;    int err
6617 IgorA 124
align 4
6639 IgorA 125
proc zError uses ecx, err:dword
126
	ERR_MSG [err]
127
	mov eax,ecx
6617 IgorA 128
	ret
129
endp
130
 
131
;#ifndef HAVE_MEMCPY
132
 
133
;void (dest, source, len)
6639 IgorA 134
;    Bytef* dest
135
;    const Bytef* source
136
;    uInt  len
6617 IgorA 137
align 4
138
proc zmemcpy uses ecx edi esi, dest:dword, source:dword, len:dword
139
	mov ecx,[len]
140
	cmp ecx,0
141
	jle @f
142
		mov edi,[dest]
143
		mov esi,[source]
144
		rep movsb
145
		jmp .end0
146
	@@:
147
zlib_debug 'zmemcpy size = %d',ecx
148
	.end0:
149
	ret
150
endp
151
 
152
;int (s1, s2, len)
6639 IgorA 153
;    const Bytef* s1
154
;    const Bytef* s2
155
;    uInt  len
6617 IgorA 156
align 4
157
proc zmemcmp, s1:dword, s2:dword, len:dword
158
;    uInt j;
159
 
160
;    for (j = 0; j < len; j++) {
161
;        if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1;
162
;    }
163
;    return 0;
164
	ret
165
endp
166
 
167
;void (dest, len)
6639 IgorA 168
;    Bytef* dest
169
;    uInt  len
6617 IgorA 170
align 4
171
proc zmemzero, dest:dword, len:dword
172
;    if (len == 0) return;
173
;    do {
174
;        *dest++ = 0;  /* ??? to be unrolled */
175
;    } while (--len != 0);
176
	ret
177
endp
178
;end if
179
 
180
;voidpf (voidpf opaque, unsigned items, unsigned size)
181
align 4
182
proc zcalloc uses ebx ecx, opaque:dword, items:dword, size:dword
183
	mov ecx,[size]
184
	imul ecx,[items]
185
	mcall SF_SYS_MISC, SSF_MEM_ALLOC
186
	ret
187
endp
188
 
189
;void (voidpf opaque, voidpf ptr)
190
align 4
191
proc zcfree uses eax ebx ecx, opaque:dword, p2ptr:dword
192
	mcall SF_SYS_MISC, SSF_MEM_FREE, [p2ptr]
193
	ret
194
endp
195