1 /* $NetBSD: gvmat32c.c,v 1.1.1.1 2006/01/14 20:10:56 christos Exp $ */
2
3 /* gvmat32.c -- C portion of the optimized longest_match for 32 bits x86
4 * Copyright (C) 1995-1996 Jean-loup Gailly and Gilles Vollant.
5 * File written by Gilles Vollant, by modifiying the longest_match
6 * from Jean-loup Gailly in deflate.c
7 * it prepare all parameters and call the assembly longest_match_gvasm
8 * longest_match execute standard C code is wmask != 0x7fff
9 * (assembly code is faster with a fixed wmask)
10 *
11 * Read comment at beginning of gvmat32.asm for more information
12 */
13
14 #if defined(ASMV) && (!defined(NOOLDPENTIUMCODE))
15 #include "deflate.h"
16
17 /* if your C compiler don't add underline before function name,
18 define ADD_UNDERLINE_ASMFUNC */
19 #ifdef ADD_UNDERLINE_ASMFUNC
20 #define longest_match_7fff _longest_match_7fff
21 #define longest_match_686 _longest_match_686
22 #define cpudetect32 _cpudetect32
23 #endif
24
25
26 unsigned long cpudetect32();
27
28 uInt longest_match_c(
29 deflate_state *s,
30 IPos cur_match); /* current match */
31
32
33 uInt longest_match_7fff(
34 deflate_state *s,
35 IPos cur_match); /* current match */
36
37 uInt longest_match_686(
38 deflate_state *s,
39 IPos cur_match); /* current match */
40
41
42 static uInt iIsPPro=2;
43
match_init()44 void match_init ()
45 {
46 iIsPPro = (((cpudetect32()/0x100)&0xf)>=6) ? 1 : 0;
47 }
48
longest_match(deflate_state * s,IPos cur_match)49 uInt longest_match(
50 deflate_state *s,
51 IPos cur_match) /* current match */
52 {
53 if (iIsPPro!=0)
54 return longest_match_686(s,cur_match);
55
56 if (s->w_mask != 0x7fff)
57 return longest_match_686(s,cur_match);
58
59 /* now ((s->w_mask == 0x7fff) && (iIsPPro==0)) */
60 return longest_match_7fff(s,cur_match);
61 }
62
63
64 #endif /* defined(ASMV) && (!defined(NOOLDPENTIUMCODE)) */
65