Subversion Repositories Kolibri OS

Rev

Rev 6639 | Go to most recent revision | Details | 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
;if DEBUG
111
 
112
;#    define verbose 0
113
;int z_verbose = verbose;
114
 
115
;void (m)
116
;    char *m;
117
align 4
118
proc z_error, m:dword
119
;    fprintf(stderr, "%s\n", m);
120
;    exit(1);
121
	ret
122
endp
123
;end if
124
 
125
; exported to allow conversion of error code to string for compress() and
126
; uncompress()
127
 
128
;const char * (err)
129
;    int err;
130
align 4
131
proc zError, err:dword
132
;    return ERR_MSG(err);
133
	ret
134
endp
135
 
136
;#ifndef HAVE_MEMCPY
137
 
138
;void (dest, source, len)
139
;    Bytef* dest;
140
;    const Bytef* source;
141
;    uInt  len;
142
align 4
143
proc zmemcpy uses ecx edi esi, dest:dword, source:dword, len:dword
144
	mov ecx,[len]
145
	cmp ecx,0
146
	jle @f
147
		mov edi,[dest]
148
		mov esi,[source]
149
		rep movsb
150
		jmp .end0
151
	@@:
152
zlib_debug 'zmemcpy size = %d',ecx
153
	.end0:
154
	ret
155
endp
156
 
157
;int (s1, s2, len)
158
;    const Bytef* s1;
159
;    const Bytef* s2;
160
;    uInt  len;
161
align 4
162
proc zmemcmp, s1:dword, s2:dword, len:dword
163
;    uInt j;
164
 
165
;    for (j = 0; j < len; j++) {
166
;        if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1;
167
;    }
168
;    return 0;
169
	ret
170
endp
171
 
172
;void (dest, len)
173
;    Bytef* dest;
174
;    uInt  len;
175
align 4
176
proc zmemzero, dest:dword, len:dword
177
;    if (len == 0) return;
178
;    do {
179
;        *dest++ = 0;  /* ??? to be unrolled */
180
;    } while (--len != 0);
181
	ret
182
endp
183
;end if
184
 
185
;#ifndef Z_SOLO
186
 
187
;voidpf (voidpf opaque, unsigned items, unsigned size)
188
align 4
189
proc zcalloc uses ebx ecx, opaque:dword, items:dword, size:dword
190
	mov ecx,[size]
191
	imul ecx,[items]
192
	mcall SF_SYS_MISC, SSF_MEM_ALLOC
193
	ret
194
endp
195
 
196
;void (voidpf opaque, voidpf ptr)
197
align 4
198
proc zcfree uses eax ebx ecx, opaque:dword, p2ptr:dword
199
	mcall SF_SYS_MISC, SSF_MEM_FREE, [p2ptr]
200
	ret
201
endp
202
 
203
;end if /* !Z_SOLO */