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