~ubuntu-branches/ubuntu/hoary/kvirc/hoary

« back to all changes in this revision

Viewing changes to src/kvicore/kvi_memmove.h

  • Committer: Bazaar Package Importer
  • Author(s): Robin Verduijn
  • Date: 2004-12-14 15:32:19 UTC
  • mfrom: (0.2.1 upstream) (1.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20041214153219-fdink3gyp2s20b6g
Tags: 2:2.1.3.1-2
* Change Recommends on xmms to a Suggests.
* Rebuild against KDE 3.3.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifndef _KVI_MEMMOVE_H_INCLUDED_
2
 
#define _KVI_MEMMOVE_H_INCLUDED_
3
 
 
4
 
//
5
 
//   File : kvi_memmove.h (/usr/build/NEW_kvirc/kvirc/src/kvicore/kvi_memmove.h)
6
 
//   Last major modification : Fri Mar 19 1999 03:15:21 by Szymon Stefanek
7
 
//
8
 
//   This file is part of the KVirc irc client distribution
9
 
//   Copyright (C) 1999-2000 Szymon Stefanek (stefanek@tin.it)
10
 
//
11
 
//   This program is FREE software. You can redistribute it and/or
12
 
//   modify it under the terms of the GNU General Public License
13
 
//   as published by the Free Software Foundation; either version 2
14
 
//   of the License, or (at your opinion) any later version.
15
 
//
16
 
//   This program is distributed in the HOPE that it will be USEFUL,
17
 
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19
 
//   See the GNU General Public License for more details.
20
 
//
21
 
//   You should have received a copy of the GNU General Public License
22
 
//   along with this program. If not, write to the Free Software Foundation,
23
 
//   Inc. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24
 
//
25
 
 
26
 
#include "kvi_settings.h"
27
 
 
28
 
#ifndef _KVI_MEMMOVE_CPP_
29
 
 
30
 
        extern void *kvi_memmove(void *dst_ptr,const void *src_ptr,int len);
31
 
        // In fastmove the src and dst may not overlap
32
 
 
33
 
        #ifdef COMPILE_i386_ASM_CODE
34
 
 
35
 
        inline void kvi_fastmove(void * dst_ptr,const void *src_ptr,int len)
36
 
        {
37
 
                __asm__ __volatile__(
38
 
                        "       cld\n"
39
 
                        "       shr $1,%0\n"
40
 
                        "       jnc 1f\n"
41
 
                        "       movsb\n"
42
 
                        "1:\n"
43
 
                        "       shr $1,%0\n"
44
 
                        "       jnc 2f\n"
45
 
                        "       movsw\n"
46
 
                        "2:\n"
47
 
                        "       repnz; movsl\n"
48
 
                        : "=c" (len), "=&S" (src_ptr), "=&D" (dst_ptr)
49
 
                        : "0"  (len), "1"   (src_ptr), "2"   (dst_ptr)
50
 
                );
51
 
        }
52
 
 
53
 
        // Hehe...I am tempted to place a mmx extension here too...but
54
 
        // which proggy can assemble that ? My asm SEEMS to not understand movsq ...
55
 
        // If your compiler can , and you want to some performance tests , well...use this one.
56
 
        // I am not sure that it will work faster in kvirc , because the average
57
 
        // size of data moved is probably smaller than 15 bytes ...
58
 
 
59
 
        //      inline void kvi_fastmove(void * dst_ptr,const void *src_ptr,int len)
60
 
        //      {
61
 
        //              __asm__ __volatile__(
62
 
        //                      "       cld\n"
63
 
        //                      "       shr $1,%0\n"
64
 
        //                      "       jnc 1f\n"
65
 
        //                      "       movsb\n"
66
 
        //                      "1:\n"
67
 
        //                      "       shr $1,%0\n"
68
 
        //                      "       jnc 2f\n"
69
 
        //                      "       movsw\n"
70
 
        //                      "2:\n"
71
 
        //                      "       shr $1,%0\n"
72
 
        //                      "       jnc 3f\n"
73
 
        //                      "       movsl\n"
74
 
        //                      "3:\n"
75
 
        //                      "       repnz; movsq\n"
76
 
        //                      : "=c" (len), "=&S" (src_ptr), "=&D" (dst_ptr)
77
 
        //                      : "0"  (len), "1"   (src_ptr), "2"   (dst_ptr)
78
 
        //              );
79
 
        //      }
80
 
 
81
 
        #else
82
 
 
83
 
                extern void kvi_fastmove(void *dst_ptr,const void *src_ptr,int len);
84
 
 
85
 
        #endif
86
 
 
87
 
#endif
88
 
#endif //!_KVI_MEMMOVE_H_INCLUDED_