1 /****************************************
2 *  Computer Algebra System SINGULAR     *
3 ****************************************/
4 /***************************************************************
5  *  File:    p_MemCopy.h
6  *  Purpose: macros for memory addition
7  *  Author:  obachman (Olaf Bachmann)
8  *  Created: 8/00
9  *******************************************************************/
10 #ifndef P_MEM_COPY_H
11 #define P_MEM_COPY_H
12 
13 #define _p_MemCopy(i, d, s) d[i] = s[i]
14 
15 #define _p_MemCopy_LengthOne(d, s) _p_MemCopy(0, d, s)
16 #define _p_MemCopy_LengthTwo(d, s) do{_p_MemCopy_LengthOne(d, s); _p_MemCopy(1, d, s);} while(0)
17 #define _p_MemCopy_LengthThree(d, s) do{_p_MemCopy_LengthTwo(d, s); _p_MemCopy(2, d, s);} while(0)
18 #define _p_MemCopy_LengthFour(d, s) do{_p_MemCopy_LengthThree(d, s); _p_MemCopy(3, d, s);} while(0)
19 #define _p_MemCopy_LengthFive(d, s) do{_p_MemCopy_LengthFour(d, s); _p_MemCopy(4, d, s);} while(0)
20 #define _p_MemCopy_LengthSix(d, s) do{_p_MemCopy_LengthFive(d, s); _p_MemCopy(5, d, s);} while(0)
21 #define _p_MemCopy_LengthSeven(d, s) do{_p_MemCopy_LengthSix(d, s); _p_MemCopy(6, d, s);} while(0)
22 #define _p_MemCopy_LengthEight(d, s) do{_p_MemCopy_LengthSeven(d, s); _p_MemCopy(7, d, s);} while(0)
23 
24 #define _p_MemCopy_Declare(d, s)                \
25   unsigned long* _d = ((unsigned long*) d); \
26   const unsigned long* _s = ((unsigned long*) s)
27 
28 #define p_MemCopy_LengthOne(d, s, length) _p_MemCopy_LengthOne(d, s)
29 #define p_MemCopy_LengthTwo(d, s, length)   \
30 do                                          \
31 {                                           \
32   _p_MemCopy_Declare(d,s);                  \
33   _p_MemCopy_LengthTwo(_d, _s);             \
34 }                                           \
35 while (0)
36 #define p_MemCopy_LengthThree(d, s, length) \
37 do                                          \
38 {                                           \
39   _p_MemCopy_Declare(d,s);                  \
40   _p_MemCopy_LengthThree(_d, _s);           \
41 }                                           \
42 while (0)
43 #define p_MemCopy_LengthFour(d, s, length)  \
44 do                                          \
45 {                                           \
46   _p_MemCopy_Declare(d,s);                  \
47   _p_MemCopy_LengthFour(_d, _s);            \
48 }                                           \
49 while (0)
50 #define p_MemCopy_LengthFive(d, s, length)  \
51 do                                          \
52 {                                           \
53   _p_MemCopy_Declare(d,s);                  \
54   _p_MemCopy_LengthFive(_d, _s);            \
55 }                                           \
56 while (0)
57 #define p_MemCopy_LengthSix(d, s, length)   \
58 do                                          \
59 {                                           \
60   _p_MemCopy_Declare(d,s);                  \
61   _p_MemCopy_LengthSix(_d, _s);             \
62 }                                           \
63 while (0)
64 #define p_MemCopy_LengthSeven(d, s, length) \
65 do                                          \
66 {                                           \
67   _p_MemCopy_Declare(d,s);                  \
68   _p_MemCopy_LengthSeven(_d, _s);           \
69 }                                           \
70 while (0)
71 #define p_MemCopy_LengthEight(d, s, length) \
72 do                                          \
73 {                                           \
74   _p_MemCopy_Declare(d,s);                  \
75   _p_MemCopy_LengthEight(_d, _s);           \
76 }                                           \
77 while (0)
78 
79 #define p_MemCopy_LengthGeneral(d, s, length)       \
80 do                                                  \
81 {                                                   \
82   _p_MemCopy_Declare(d,s);                          \
83   const unsigned long _l = (unsigned long) length;  \
84   unsigned long _i = 0;                             \
85   do                                                \
86   {                                                 \
87     _d[_i] = _s[_i];                                \
88     _i++;                                           \
89   }                                                 \
90   while (_i != _l);                                 \
91 }                                                   \
92 while (0)
93 
94 #endif // P_MEM_COPY_H
95