]> git.sesse.net Git - vlc/blob - plugins/memcpy/memcpy.c
* ./BUGS: added a list of known bugs. Please add your findings!
[vlc] / plugins / memcpy / memcpy.c
1 /*****************************************************************************
2  * memcpy.c : classic memcpy module
3  *****************************************************************************
4  * Copyright (C) 2001 VideoLAN
5  * $Id: memcpy.c,v 1.4 2002/01/04 14:01:34 sam Exp $
6  *
7  * Authors: Samuel Hocevar <sam@zoy.org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  * 
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
22  *****************************************************************************/
23
24 /*****************************************************************************
25  * Preamble
26  *****************************************************************************/
27 #include <stdlib.h>
28 #include <string.h>
29
30 #include <videolan/vlc.h>
31
32 #undef HAVE_MMX
33 #undef HAVE_MMX2
34 #undef HAVE_SSE
35 #undef HAVE_SSE2
36 #undef HAVE_3DNOW
37
38 #if defined( MODULE_NAME_IS_memcpy3dn )
39 #   define HAVE_3DNOW
40 #   include "fastmemcpy.h"
41 #elif defined( MODULE_NAME_IS_memcpymmx )
42 #   define HAVE_MMX
43 #   include "fastmemcpy.h"
44 #elif defined( MODULE_NAME_IS_memcpymmxext )
45 #   define HAVE_MMX2
46 #   include "fastmemcpy.h"
47 #endif
48
49 /*****************************************************************************
50  * Local and extern prototypes.
51  *****************************************************************************/
52 static void memcpy_getfunctions( function_list_t * p_function_list );
53 static int  memcpy_Probe       ( probedata_t *p_data );
54 #ifndef MODULE_NAME_IS_memcpy
55 void *      _M( fast_memcpy )  ( void * to, const void * from, size_t len );
56 #endif
57
58 /*****************************************************************************
59  * Build configuration tree.
60  *****************************************************************************/
61 MODULE_CONFIG_START
62 MODULE_CONFIG_STOP
63
64 MODULE_INIT_START
65 #ifdef MODULE_NAME_IS_memcpy
66     SET_DESCRIPTION( "libc memcpy module" )
67     ADD_CAPABILITY( MEMCPY, 50 )
68     ADD_SHORTCUT( "c" )
69     ADD_SHORTCUT( "libc" )
70     ADD_SHORTCUT( "memcpy" )
71 #elif defined( MODULE_NAME_IS_memcpy3dn )
72     SET_DESCRIPTION( "3D Now! memcpy module" )
73     ADD_CAPABILITY( MEMCPY, 100 )
74     ADD_REQUIREMENT( 3DNOW )
75     ADD_SHORTCUT( "3dn" )
76     ADD_SHORTCUT( "3dnow" )
77     ADD_SHORTCUT( "memcpy3dn" )
78     ADD_SHORTCUT( "memcpy3dnow" )
79 #elif defined( MODULE_NAME_IS_memcpymmx )
80     SET_DESCRIPTION( "MMX memcpy module" )
81     ADD_CAPABILITY( MEMCPY, 100 )
82     ADD_REQUIREMENT( MMX )
83     ADD_SHORTCUT( "mmx" )
84     ADD_SHORTCUT( "memcpymmx" )
85 #elif defined( MODULE_NAME_IS_memcpymmxext )
86     SET_DESCRIPTION( "MMX EXT memcpy module" )
87     ADD_CAPABILITY( MEMCPY, 200 )
88     ADD_REQUIREMENT( MMXEXT )
89     ADD_SHORTCUT( "mmxext" )
90     ADD_SHORTCUT( "memcpymmxext" )
91 #endif
92 MODULE_INIT_STOP
93
94 MODULE_ACTIVATE_START
95     memcpy_getfunctions( &p_module->p_functions->memcpy );
96 MODULE_ACTIVATE_STOP
97
98 MODULE_DEACTIVATE_START
99 MODULE_DEACTIVATE_STOP
100
101 /* Following functions are local */
102
103 /*****************************************************************************
104  * Functions exported as capabilities. They are declared as static so that
105  * we don't pollute the namespace too much.
106  *****************************************************************************/
107 static void memcpy_getfunctions( function_list_t * p_function_list )
108 {
109     p_function_list->pf_probe = memcpy_Probe;
110 #ifdef MODULE_NAME_IS_memcpy
111     p_function_list->functions.memcpy.fast_memcpy = memcpy;
112 #else
113     p_function_list->functions.memcpy.fast_memcpy = _M( fast_memcpy );
114 #endif
115 }
116
117 /*****************************************************************************
118  * memcpy_Probe: returns a preference score
119  *****************************************************************************/
120 static int memcpy_Probe( probedata_t *p_data )
121 {
122     return( 1 );
123 }
124