Subversion Repositories QNX 8.QNX8 IFS tool

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
26 pmbaty 1
/* ACC -- Automatic Compiler Configuration
2
 
3
   Copyright (C) 1996-2004 Markus Franz Xaver Johannes Oberhumer
4
   All Rights Reserved.
5
 
6
   This software is a copyrighted work licensed under the terms of
7
   the GNU General Public License. Please consult the file "ACC_LICENSE"
8
   for details.
9
 
10
   Markus F.X.J. Oberhumer
11
   <markus@oberhumer.com>
12
   http://www.oberhumer.com/
13
 */
14
 
15
 
16
#define __ACCLIB_HMEMCPY_CH_INCLUDED 1
17
#if !defined(ACCLIB_PUBLIC)
18
#  define ACCLIB_PUBLIC(r,f)    r __ACCLIB_FUNCNAME(f)
19
#endif
20
 
21
 
22
/***********************************************************************
23
// memcmp, memcpy, memmove, memset
24
************************************************************************/
25
 
26
ACCLIB_PUBLIC(int, acc_hmemcmp) (const acc_hvoid_p s1, const acc_hvoid_p s2, acc_hsize_t len)
27
{
28
#if (ACC_HAVE_MM_HUGE_PTR) || !defined(HAVE_MEMCMP)
29
    const acc_hbyte_p p1 = (const acc_hbyte_p) s1;
30
    const acc_hbyte_p p2 = (const acc_hbyte_p) s2;
31
 
32
    if (len > 0) do
33
    {
34
        int d = *p1 - *p2;
35
        if (d != 0)
36
            return d;
37
        p1++; p2++;
38
    } while (--len > 0);
39
    return 0;
40
#else
41
    return memcmp(s1, s2, len);
42
#endif
43
}
44
 
45
 
46
ACCLIB_PUBLIC(acc_hvoid_p, acc_hmemcpy) (acc_hvoid_p dest, const acc_hvoid_p src, acc_hsize_t len)
47
{
48
#if (ACC_HAVE_MM_HUGE_PTR) || !defined(HAVE_MEMCPY)
49
    acc_hbyte_p p1 = (acc_hbyte_p) dest;
50
    const acc_hbyte_p p2 = (const acc_hbyte_p) src;
51
 
52
    if (len <= 0 || p1 == p2)
53
        return dest;
54
    do
55
        *p1++ = *p2++;
56
    while (--len > 0);
57
    return dest;
58
#else
59
    return memcpy(dest, src, len);
60
#endif
61
}
62
 
63
 
64
ACCLIB_PUBLIC(acc_hvoid_p, acc_hmemmove) (acc_hvoid_p dest, const acc_hvoid_p src, acc_hsize_t len)
65
{
66
#if (ACC_HAVE_MM_HUGE_PTR) || !defined(HAVE_MEMMOVE)
67
    acc_hbyte_p p1 = (acc_hbyte_p) dest;
68
    const acc_hbyte_p p2 = (const acc_hbyte_p) src;
69
 
70
    if (len <= 0 || p1 == p2)
71
        return dest;
72
 
73
    if (p1 < p2)
74
    {
75
        do
76
            *p1++ = *p2++;
77
        while (--len > 0);
78
    }
79
    else
80
    {
81
        p1 += len;
82
        p2 += len;
83
        do
84
            *--p1 = *--p2;
85
        while (--len > 0);
86
    }
87
    return dest;
88
#else
89
    return memmove(dest, src, len);
90
#endif
91
}
92
 
93
 
94
ACCLIB_PUBLIC(acc_hvoid_p, acc_hmemset) (acc_hvoid_p s, int c, acc_hsize_t len)
95
{
96
#if (ACC_HAVE_MM_HUGE_PTR) || !defined(HAVE_MEMSET)
97
    acc_hbyte_p p = (acc_hbyte_p) s;
98
 
99
    if (len > 0) do
100
        *p++ = (unsigned char) c;
101
    while (--len > 0);
102
    return s;
103
#else
104
    return memset(s, c, len);
105
#endif
106
}
107
 
108
 
109
/*
110
vi:ts=4:et
111
*/