ReactOS 0.4.16-dev-297-gc569aee
movebytes.c File Reference
#include <schily/standard.h>
#include <schily/align.h>
#include <schily/types.h>
#include <schily/schily.h>
Include dependency graph for movebytes.c:

Go to the source code of this file.

Macros

#define DO8(a)   a; a; a; a; a; a; a; a;
 

Functions

EXPORT charmovebytes (void *fromv, void *tov, ssize_t cnt) const
 

Macro Definition Documentation

◆ DO8

#define DO8 (   a)    a; a; a; a; a; a; a; a;

Definition at line 24 of file movebytes.c.

Function Documentation

◆ movebytes()

EXPORT char * movebytes ( void fromv,
void tov,
ssize_t  cnt 
) const

Definition at line 30 of file movebytes.c.

34{
35 register const char *from = fromv;
36 register char *to = tov;
37 register ssize_t n;
38
39 /*
40 * If we change cnt to be unsigned, check for == instead of <=
41 */
42 if ((n = cnt) <= 0)
43 return (to);
44
45 if (from >= to) {
46 /*
47 * source is on higher addresses than destination:
48 * move bytes forwards
49 */
50 if (n >= (ssize_t)(8 * sizeof (long))) {
51 if (l2aligned(from, to)) {
52 register const long *froml = (const long *)from;
53 register long *tol = (long *)to;
54 register ssize_t rem = n % (8 * sizeof (long));
55
56 n /= (8 * sizeof (long));
57 do {
58 DO8 (*tol++ = *froml++);
59 } while (--n > 0);
60
61 from = (const char *)froml;
62 to = (char *)tol;
63 n = rem;
64 }
65
66 if (n >= 8) {
67 n -= 8;
68 do {
69 DO8 (*to++ = *from++);
70 } while ((n -= 8) >= 0);
71 n += 8;
72 }
73
74 if (n > 0) do {
75 *to++ = *from++;
76 } while (--n > 0);
77 return (to);
78 }
79 if (n > 0) do {
80 *to++ = *from++;
81 } while (--n > 0);
82 return (to);
83 } else {
84 char *ep;
85
86 /*
87 * source is on lower addresses than destination:
88 * move bytes backwards
89 */
90 to += n;
91 from += n;
92 ep = to;
93 if (n >= (ssize_t)(8 * sizeof (long))) {
94 if (l2aligned(from, to)) {
95 register const long *froml = (const long *)from;
96 register long *tol = (long *)to;
97 register ssize_t rem = n % (8 * sizeof (long));
98
99 n /= (8 * sizeof (long));
100 do {
101 DO8 (*--tol = *--froml);
102 } while (--n > 0);
103
104 from = (const char *)froml;
105 to = (char *)tol;
106 n = rem;
107 }
108 if (n >= 8) {
109 n -= 8;
110 do {
111 DO8 (*--to = *--from);
112 } while ((n -= 8) >= 0);
113 n += 8;
114 }
115 if (n > 0) do {
116 *--to = *--from;
117 } while (--n > 0);
118 return (ep);
119 }
120 if (n > 0) do {
121 *--to = *--from;
122 } while (--n > 0);
123 return (ep);
124 }
125}
GLdouble n
Definition: glext.h:7729
#define DO8(a)
Definition: movebytes.c:24
#define long
Definition: qsort.c:33
#define l2aligned(a, b)
Definition: align.h:20
int ssize_t
Definition: rosdhcp.h:48
CardRegion * from
Definition: spigame.cpp:19

Referenced by _more_flags(), outputlist_insert(), and read_merging_directory().