diff options
author | Thomas Martitz <kugel@rockbox.org> | 2010-05-06 21:04:40 +0000 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2010-05-06 21:04:40 +0000 |
commit | 50a6ca39ad4ed01922aa4f755f0ca579788226cf (patch) | |
tree | c7881b015b220558167310345b162324c96be15a /firmware/common/strcpy.c | |
parent | adb506df14aded06ed6e9ebf8540e6fd383ffd6a (diff) | |
download | rockbox-50a6ca39ad4ed01922aa4f755f0ca579788226cf.tar.gz rockbox-50a6ca39ad4ed01922aa4f755f0ca579788226cf.zip |
Move c/h files implementing/defining standard library stuff into a new libc directory, also standard'ify some parts of the code base (almost entirely #include fixes).
This is to a) to cleanup firmware/common and firmware/include a bit, but also b) for Rockbox as an application which should use the host system's c library and headers, separating makes it easy to exclude our files from the build.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25850 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/common/strcpy.c')
-rw-r--r-- | firmware/common/strcpy.c | 99 |
1 files changed, 0 insertions, 99 deletions
diff --git a/firmware/common/strcpy.c b/firmware/common/strcpy.c deleted file mode 100644 index 077ae73cc6..0000000000 --- a/firmware/common/strcpy.c +++ /dev/null | |||
@@ -1,99 +0,0 @@ | |||
1 | /* | ||
2 | FUNCTION | ||
3 | <<strcpy>>---copy string | ||
4 | |||
5 | INDEX | ||
6 | strcpy | ||
7 | |||
8 | ANSI_SYNOPSIS | ||
9 | #include <string.h> | ||
10 | char *strcpy(char *<[dst]>, const char *<[src]>); | ||
11 | |||
12 | TRAD_SYNOPSIS | ||
13 | #include <string.h> | ||
14 | char *strcpy(<[dst]>, <[src]>) | ||
15 | char *<[dst]>; | ||
16 | char *<[src]>; | ||
17 | |||
18 | DESCRIPTION | ||
19 | <<strcpy>> copies the string pointed to by <[src]> | ||
20 | (including the terminating null character) to the array | ||
21 | pointed to by <[dst]>. | ||
22 | |||
23 | RETURNS | ||
24 | This function returns the initial value of <[dst]>. | ||
25 | |||
26 | PORTABILITY | ||
27 | <<strcpy>> is ANSI C. | ||
28 | |||
29 | <<strcpy>> requires no supporting OS subroutines. | ||
30 | |||
31 | QUICKREF | ||
32 | strcpy ansi pure | ||
33 | */ | ||
34 | |||
35 | #include <string.h> | ||
36 | #include <limits.h> | ||
37 | |||
38 | /*SUPPRESS 560*/ | ||
39 | /*SUPPRESS 530*/ | ||
40 | |||
41 | /* Nonzero if either X or Y is not aligned on a "long" boundary. */ | ||
42 | #define UNALIGNED(X, Y) \ | ||
43 | (((long)X & (sizeof (long) - 1)) | ((long)Y & (sizeof (long) - 1))) | ||
44 | |||
45 | #if LONG_MAX == 2147483647L | ||
46 | #define DETECTNULL(X) (((X) - 0x01010101) & ~(X) & 0x80808080) | ||
47 | #else | ||
48 | #if LONG_MAX == 9223372036854775807L | ||
49 | /* Nonzero if X (a long int) contains a NULL byte. */ | ||
50 | #define DETECTNULL(X) (((X) - 0x0101010101010101) & ~(X) & 0x8080808080808080) | ||
51 | #else | ||
52 | #error long int is not a 32bit or 64bit type. | ||
53 | #endif | ||
54 | #endif | ||
55 | |||
56 | #ifndef DETECTNULL | ||
57 | #error long int is not a 32bit or 64bit byte | ||
58 | #endif | ||
59 | |||
60 | char* | ||
61 | _DEFUN (strcpy, (dst0, src0), | ||
62 | char *dst0 _AND | ||
63 | _CONST char *src0) | ||
64 | { | ||
65 | #if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__) | ||
66 | char *s = dst0; | ||
67 | |||
68 | while ((*dst0++ = *src0++)) | ||
69 | ; | ||
70 | |||
71 | return s; | ||
72 | #else | ||
73 | char *dst = dst0; | ||
74 | _CONST char *src = src0; | ||
75 | long *aligned_dst; | ||
76 | _CONST long *aligned_src; | ||
77 | |||
78 | /* If SRC or DEST is unaligned, then copy bytes. */ | ||
79 | if (!UNALIGNED (src, dst)) | ||
80 | { | ||
81 | aligned_dst = (long*)dst; | ||
82 | aligned_src = (long*)src; | ||
83 | |||
84 | /* SRC and DEST are both "long int" aligned, try to do "long int" | ||
85 | sized copies. */ | ||
86 | while (!DETECTNULL(*aligned_src)) | ||
87 | { | ||
88 | *aligned_dst++ = *aligned_src++; | ||
89 | } | ||
90 | |||
91 | dst = (char*)aligned_dst; | ||
92 | src = (char*)aligned_src; | ||
93 | } | ||
94 | |||
95 | while ((*dst++ = *src++)) | ||
96 | ; | ||
97 | return dst0; | ||
98 | #endif /* not PREFER_SIZE_OVER_SPEED */ | ||
99 | } | ||