Debian Codegraph @

cuneiform_src/Kern/lns32/src/memops.h

raw
1 /*
2 Copyright (c) 1993-2008, Cognitive Technologies
3 All rights reserved.
4
5 Разрешается повторное распространение и использование как в виде исходного кода,
6 так и в двоичной форме, с изменениями или без, при соблюдении следующих условий:
7
8 * При повторном распространении исходного кода должны оставаться указанное
9 выше уведомление об авторском праве, этот список условий и последующий
10 отказ от гарантий.
11 * При повторном распространении двоичного кода в документации и/или в
12 других материалах, поставляемых при распространении, должны сохраняться
13 указанная выше информация об авторском праве, этот список условий и
14 последующий отказ от гарантий.
15 * Ни название Cognitive Technologies, ни имена ее сотрудников не могут
16 быть использованы в качестве средства поддержки и/или продвижения
17 продуктов, основанных на этом ПО, без предварительного письменного
18 разрешения.
19
20 ЭТА ПРОГРАММА ПРЕДОСТАВЛЕНА ВЛАДЕЛЬЦАМИ АВТОРСКИХ ПРАВ И/ИЛИ ДРУГИМИ ЛИЦАМИ "КАК
21 ОНА ЕСТЬ" БЕЗ КАКОГО-ЛИБО ВИДА ГАРАНТИЙ, ВЫРАЖЕННЫХ ЯВНО ИЛИ ПОДРАЗУМЕВАЕМЫХ,
22 ВКЛЮЧАЯ ГАРАНТИИ КОММЕРЧЕСКОЙ ЦЕННОСТИ И ПРИГОДНОСТИ ДЛЯ КОНКРЕТНОЙ ЦЕЛИ, НО НЕ
23 ОГРАНИЧИВАЯСЬ ИМИ. НИ ВЛАДЕЛЕЦ АВТОРСКИХ ПРАВ И НИ ОДНО ДРУГОЕ ЛИЦО, КОТОРОЕ
24 МОЖЕТ ИЗМЕНЯТЬ И/ИЛИ ПОВТОРНО РАСПРОСТРАНЯТЬ ПРОГРАММУ, НИ В КОЕМ СЛУЧАЕ НЕ
25 НЕСЁТ ОТВЕТСТВЕННОСТИ, ВКЛЮЧАЯ ЛЮБЫЕ ОБЩИЕ, СЛУЧАЙНЫЕ, СПЕЦИАЛЬНЫЕ ИЛИ
26 ПОСЛЕДОВАВШИЕ УБЫТКИ, СВЯЗАННЫЕ С ИСПОЛЬЗОВАНИЕМ ИЛИ ПОНЕСЕННЫЕ ВСЛЕДСТВИЕ
27 НЕВОЗМОЖНОСТИ ИСПОЛЬЗОВАНИЯ ПРОГРАММЫ (ВКЛЮЧАЯ ПОТЕРИ ДАННЫХ, ИЛИ ДАННЫЕ,
28 СТАВШИЕ НЕГОДНЫМИ, ИЛИ УБЫТКИ И/ИЛИ ПОТЕРИ ДОХОДОВ, ПОНЕСЕННЫЕ ИЗ-ЗА ДЕЙСТВИЙ
29 ТРЕТЬИХ ЛИЦ И/ИЛИ ОТКАЗА ПРОГРАММЫ РАБОТАТЬ СОВМЕСТНО С ДРУГИМИ ПРОГРАММАМИ,
30 НО НЕ ОГРАНИЧИВАЯСЬ ЭТИМИ СЛУЧАЯМИ), НО НЕ ОГРАНИЧИВАЯСЬ ИМИ, ДАЖЕ ЕСЛИ ТАКОЙ
31 ВЛАДЕЛЕЦ ИЛИ ДРУГОЕ ЛИЦО БЫЛИ ИЗВЕЩЕНЫ О ВОЗМОЖНОСТИ ТАКИХ УБЫТКОВ И ПОТЕРЬ.
32
33 Redistribution and use in source and binary forms, with or without modification,
34 are permitted provided that the following conditions are met:
35
36 * Redistributions of source code must retain the above copyright notice,
37 this list of conditions and the following disclaimer.
38 * Redistributions in binary form must reproduce the above copyright notice,
39 this list of conditions and the following disclaimer in the documentation
40 and/or other materials provided with the distribution.
41 * Neither the name of the Cognitive Technologies nor the names of its
42 contributors may be used to endorse or promote products derived from this
43 software without specific prior written permission.
44
45 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
46 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
47 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
48 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
49 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
50 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
51 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
52 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
53 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
54 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
55 */
56
57 #ifndef __MEMOPS_H
58 #define __MEMOPS_H
59 #ifdef __cplusplus
60
61 /*#ifndef NO_ASM*/
62 #if 0
63 extern "C"
64 {
65 //#endif
66 // realized in 'memops.asm'
67 void CopyOR( void* dst,
68 void* src,
69 unsigned short dword_cnt
70 );
71 void CopyAND( void* dst,
72 void* src,
73 unsigned short dword_cnt
74 );
75
76 #undef memcpy
77 void* memcpy( void* dst,
78 const void* src,
79 unsigned int byte_cnt
80 );
81
82 void InvertTo( void* dst,
83 void* src,
84 unsigned short dwcnt
85 );
86
87 void InvertSelf( void* dst,
88 unsigned short dwcnt
89 );
90 #ifdef __cplusplus
91 }
92 #endif
93
94 #else // ============ NO_ASM ============
95
96 #ifndef MEMOPS_INLINE
97 #define MEMOPS_INLINE inline
98 // you can use here 'static' instead
99 // if you have some problems with 'inline'
100 #endif
101
102 MEMOPS_INLINE
103 void __CopyOR(uchar* dst, const uchar* src, const int bytes_cnt) {
104 for(int i=0; i<bytes_cnt; i++) {
105 *dst++ |= *src++;
106 }
107 }
108
109 MEMOPS_INLINE
110 void CopyOR(void* dst, const void* src, const unsigned short dword_cnt) {
111 __CopyOR((uchar*)dst, (uchar*)src, 4*(int)dword_cnt);
112 }
113
114 MEMOPS_INLINE
115 void __CopyAND(uchar* dst, const uchar* src, const int bytes_cnt) {
116 for(int i=0; i<bytes_cnt; i++) {
117 *dst++ &= *src++;
118 }
119 }
120
121 MEMOPS_INLINE
122 void CopyAND(void* dst, const void* src, const unsigned short dword_cnt) {
123 __CopyAND((uchar*)dst, (uchar*)src, 4*(int)dword_cnt);
124 }
125
126 MEMOPS_INLINE
127 void __InvertSelf(uchar* dst, const int bytes_cnt) {
128 for(int i=0; i<bytes_cnt; i++) {
129 *dst++ = ~*dst;
130 }
131 }
132
133 MEMOPS_INLINE
134 void InvertSelf(void* dst, const unsigned short dword_cnt) {
135 __InvertSelf((uchar*)dst, 4*(int)dword_cnt);
136 }
137
138 MEMOPS_INLINE
139 void InvertTo(void* dst, const void* src, const unsigned short dword_cnt) {
140 unsigned char *ldst = (unsigned char*)dst;
141 unsigned char *lsrc = (unsigned char*)src;
142 for(int i=0; i<4*(int)dword_cnt; i++) {
143 *ldst++ = ~*lsrc++;
144 }
145 }
146
147
148
149 #endif
150 #endif
151 #endif