diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/v850/lib |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'arch/v850/lib')
-rw-r--r-- | arch/v850/lib/Makefile | 6 | ||||
-rw-r--r-- | arch/v850/lib/ashldi3.c | 62 | ||||
-rw-r--r-- | arch/v850/lib/ashrdi3.c | 63 | ||||
-rw-r--r-- | arch/v850/lib/checksum.c | 154 | ||||
-rw-r--r-- | arch/v850/lib/lshrdi3.c | 62 | ||||
-rw-r--r-- | arch/v850/lib/memcpy.c | 92 | ||||
-rw-r--r-- | arch/v850/lib/memset.c | 68 | ||||
-rw-r--r-- | arch/v850/lib/muldi3.c | 61 | ||||
-rw-r--r-- | arch/v850/lib/negdi2.c | 25 |
9 files changed, 593 insertions, 0 deletions
diff --git a/arch/v850/lib/Makefile b/arch/v850/lib/Makefile new file mode 100644 index 000000000000..1c78b728a117 --- /dev/null +++ b/arch/v850/lib/Makefile | |||
@@ -0,0 +1,6 @@ | |||
1 | # | ||
2 | # arch/v850/lib/Makefile | ||
3 | # | ||
4 | |||
5 | lib-y = ashrdi3.o ashldi3.o lshrdi3.o muldi3.o negdi2.o \ | ||
6 | checksum.o memcpy.o memset.o | ||
diff --git a/arch/v850/lib/ashldi3.c b/arch/v850/lib/ashldi3.c new file mode 100644 index 000000000000..9e792d53f0e4 --- /dev/null +++ b/arch/v850/lib/ashldi3.c | |||
@@ -0,0 +1,62 @@ | |||
1 | /* ashldi3.c extracted from gcc-2.95.2/libgcc2.c which is: */ | ||
2 | /* Copyright (C) 1989, 92-98, 1999 Free Software Foundation, Inc. | ||
3 | |||
4 | This file is part of GNU CC. | ||
5 | |||
6 | GNU CC is free software; you can redistribute it and/or modify | ||
7 | it under the terms of the GNU General Public License as published by | ||
8 | the Free Software Foundation; either version 2, or (at your option) | ||
9 | any later version. | ||
10 | |||
11 | GNU CC is distributed in the hope that it will be useful, | ||
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | GNU General Public License for more details. | ||
15 | |||
16 | You should have received a copy of the GNU General Public License | ||
17 | along with GNU CC; see the file COPYING. If not, write to | ||
18 | the Free Software Foundation, 59 Temple Place - Suite 330, | ||
19 | Boston, MA 02111-1307, USA. */ | ||
20 | |||
21 | #define BITS_PER_UNIT 8 | ||
22 | |||
23 | typedef int SItype __attribute__ ((mode (SI))); | ||
24 | typedef unsigned int USItype __attribute__ ((mode (SI))); | ||
25 | typedef int DItype __attribute__ ((mode (DI))); | ||
26 | typedef int word_type __attribute__ ((mode (__word__))); | ||
27 | |||
28 | struct DIstruct {SItype high, low;}; | ||
29 | |||
30 | typedef union | ||
31 | { | ||
32 | struct DIstruct s; | ||
33 | DItype ll; | ||
34 | } DIunion; | ||
35 | |||
36 | DItype | ||
37 | __ashldi3 (DItype u, word_type b) | ||
38 | { | ||
39 | DIunion w; | ||
40 | word_type bm; | ||
41 | DIunion uu; | ||
42 | |||
43 | if (b == 0) | ||
44 | return u; | ||
45 | |||
46 | uu.ll = u; | ||
47 | |||
48 | bm = (sizeof (SItype) * BITS_PER_UNIT) - b; | ||
49 | if (bm <= 0) | ||
50 | { | ||
51 | w.s.low = 0; | ||
52 | w.s.high = (USItype)uu.s.low << -bm; | ||
53 | } | ||
54 | else | ||
55 | { | ||
56 | USItype carries = (USItype)uu.s.low >> bm; | ||
57 | w.s.low = (USItype)uu.s.low << b; | ||
58 | w.s.high = ((USItype)uu.s.high << b) | carries; | ||
59 | } | ||
60 | |||
61 | return w.ll; | ||
62 | } | ||
diff --git a/arch/v850/lib/ashrdi3.c b/arch/v850/lib/ashrdi3.c new file mode 100644 index 000000000000..78efb65e315a --- /dev/null +++ b/arch/v850/lib/ashrdi3.c | |||
@@ -0,0 +1,63 @@ | |||
1 | /* ashrdi3.c extracted from gcc-2.7.2/libgcc2.c which is: */ | ||
2 | /* Copyright (C) 1989, 1992, 1993, 1994, 1995 Free Software Foundation, Inc. | ||
3 | |||
4 | This file is part of GNU CC. | ||
5 | |||
6 | GNU CC is free software; you can redistribute it and/or modify | ||
7 | it under the terms of the GNU General Public License as published by | ||
8 | the Free Software Foundation; either version 2, or (at your option) | ||
9 | any later version. | ||
10 | |||
11 | GNU CC is distributed in the hope that it will be useful, | ||
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | GNU General Public License for more details. | ||
15 | |||
16 | You should have received a copy of the GNU General Public License | ||
17 | along with GNU CC; see the file COPYING. If not, write to | ||
18 | the Free Software Foundation, 59 Temple Place - Suite 330, | ||
19 | Boston, MA 02111-1307, USA. */ | ||
20 | |||
21 | #define BITS_PER_UNIT 8 | ||
22 | |||
23 | typedef int SItype __attribute__ ((mode (SI))); | ||
24 | typedef unsigned int USItype __attribute__ ((mode (SI))); | ||
25 | typedef int DItype __attribute__ ((mode (DI))); | ||
26 | typedef int word_type __attribute__ ((mode (__word__))); | ||
27 | |||
28 | struct DIstruct {SItype high, low;}; | ||
29 | |||
30 | typedef union | ||
31 | { | ||
32 | struct DIstruct s; | ||
33 | DItype ll; | ||
34 | } DIunion; | ||
35 | |||
36 | DItype | ||
37 | __ashrdi3 (DItype u, word_type b) | ||
38 | { | ||
39 | DIunion w; | ||
40 | word_type bm; | ||
41 | DIunion uu; | ||
42 | |||
43 | if (b == 0) | ||
44 | return u; | ||
45 | |||
46 | uu.ll = u; | ||
47 | |||
48 | bm = (sizeof (SItype) * BITS_PER_UNIT) - b; | ||
49 | if (bm <= 0) | ||
50 | { | ||
51 | /* w.s.high = 1..1 or 0..0 */ | ||
52 | w.s.high = uu.s.high >> (sizeof (SItype) * BITS_PER_UNIT - 1); | ||
53 | w.s.low = uu.s.high >> -bm; | ||
54 | } | ||
55 | else | ||
56 | { | ||
57 | USItype carries = (USItype)uu.s.high << bm; | ||
58 | w.s.high = uu.s.high >> b; | ||
59 | w.s.low = ((USItype)uu.s.low >> b) | carries; | ||
60 | } | ||
61 | |||
62 | return w.ll; | ||
63 | } | ||
diff --git a/arch/v850/lib/checksum.c b/arch/v850/lib/checksum.c new file mode 100644 index 000000000000..d308b724c023 --- /dev/null +++ b/arch/v850/lib/checksum.c | |||
@@ -0,0 +1,154 @@ | |||
1 | /* | ||
2 | * INET An implementation of the TCP/IP protocol suite for the LINUX | ||
3 | * operating system. INET is implemented using the BSD Socket | ||
4 | * interface as the means of communication with the user level. | ||
5 | * | ||
6 | * MIPS specific IP/TCP/UDP checksumming routines | ||
7 | * | ||
8 | * Authors: Ralf Baechle, <ralf@waldorf-gmbh.de> | ||
9 | * Lots of code moved from tcp.c and ip.c; see those files | ||
10 | * for more names. | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version | ||
15 | * 2 of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * $Id: checksum.c,v 1.1 2002/09/28 14:58:40 gerg Exp $ | ||
18 | */ | ||
19 | #include <net/checksum.h> | ||
20 | #include <linux/module.h> | ||
21 | #include <linux/types.h> | ||
22 | #include <asm/byteorder.h> | ||
23 | #include <asm/string.h> | ||
24 | #include <asm/uaccess.h> | ||
25 | |||
26 | static inline unsigned short from32to16 (unsigned long sum) | ||
27 | { | ||
28 | unsigned int result; | ||
29 | /* | ||
30 | %0 %1 | ||
31 | hsw %1, %0 H L L H | ||
32 | add %1, %0 H L H+L+C H+L | ||
33 | */ | ||
34 | asm ("hsw %1, %0; add %1, %0" : "=&r" (result) : "r" (sum)); | ||
35 | return result >> 16; | ||
36 | } | ||
37 | |||
38 | static inline unsigned int do_csum(const unsigned char * buff, int len) | ||
39 | { | ||
40 | int odd, count; | ||
41 | unsigned int result = 0; | ||
42 | |||
43 | if (len <= 0) | ||
44 | goto out; | ||
45 | odd = 1 & (unsigned long) buff; | ||
46 | if (odd) { | ||
47 | result = be16_to_cpu(*buff); | ||
48 | len--; | ||
49 | buff++; | ||
50 | } | ||
51 | count = len >> 1; /* nr of 16-bit words.. */ | ||
52 | if (count) { | ||
53 | if (2 & (unsigned long) buff) { | ||
54 | result += *(unsigned short *) buff; | ||
55 | count--; | ||
56 | len -= 2; | ||
57 | buff += 2; | ||
58 | } | ||
59 | count >>= 1; /* nr of 32-bit words.. */ | ||
60 | if (count) { | ||
61 | unsigned int carry = 0; | ||
62 | do { | ||
63 | unsigned int w = *(unsigned int *) buff; | ||
64 | count--; | ||
65 | buff += 4; | ||
66 | result += carry; | ||
67 | result += w; | ||
68 | carry = (w > result); | ||
69 | } while (count); | ||
70 | result += carry; | ||
71 | result = (result & 0xffff) + (result >> 16); | ||
72 | } | ||
73 | if (len & 2) { | ||
74 | result += *(unsigned short *) buff; | ||
75 | buff += 2; | ||
76 | } | ||
77 | } | ||
78 | if (len & 1) | ||
79 | result += le16_to_cpu(*buff); | ||
80 | result = from32to16(result); | ||
81 | if (odd) | ||
82 | result = ((result >> 8) & 0xff) | ((result & 0xff) << 8); | ||
83 | out: | ||
84 | return result; | ||
85 | } | ||
86 | |||
87 | /* | ||
88 | * This is a version of ip_compute_csum() optimized for IP headers, | ||
89 | * which always checksum on 4 octet boundaries. | ||
90 | */ | ||
91 | unsigned short ip_fast_csum(unsigned char * iph, unsigned int ihl) | ||
92 | { | ||
93 | return ~do_csum(iph,ihl*4); | ||
94 | } | ||
95 | |||
96 | /* | ||
97 | * this routine is used for miscellaneous IP-like checksums, mainly | ||
98 | * in icmp.c | ||
99 | */ | ||
100 | unsigned short ip_compute_csum(const unsigned char * buff, int len) | ||
101 | { | ||
102 | return ~do_csum(buff,len); | ||
103 | } | ||
104 | |||
105 | /* | ||
106 | * computes a partial checksum, e.g. for TCP/UDP fragments | ||
107 | */ | ||
108 | unsigned int csum_partial(const unsigned char *buff, int len, unsigned int sum) | ||
109 | { | ||
110 | unsigned int result = do_csum(buff, len); | ||
111 | |||
112 | /* add in old sum, and carry.. */ | ||
113 | result += sum; | ||
114 | if(sum > result) | ||
115 | result += 1; | ||
116 | return result; | ||
117 | } | ||
118 | |||
119 | EXPORT_SYMBOL(csum_partial); | ||
120 | |||
121 | /* | ||
122 | * copy while checksumming, otherwise like csum_partial | ||
123 | */ | ||
124 | unsigned int csum_partial_copy(const unsigned char *src, unsigned char *dst, | ||
125 | int len, unsigned int sum) | ||
126 | { | ||
127 | /* | ||
128 | * It's 2:30 am and I don't feel like doing it real ... | ||
129 | * This is lots slower than the real thing (tm) | ||
130 | */ | ||
131 | sum = csum_partial(src, len, sum); | ||
132 | memcpy(dst, src, len); | ||
133 | |||
134 | return sum; | ||
135 | } | ||
136 | |||
137 | /* | ||
138 | * Copy from userspace and compute checksum. If we catch an exception | ||
139 | * then zero the rest of the buffer. | ||
140 | */ | ||
141 | unsigned int csum_partial_copy_from_user (const unsigned char *src, unsigned char *dst, | ||
142 | int len, unsigned int sum, | ||
143 | int *err_ptr) | ||
144 | { | ||
145 | int missing; | ||
146 | |||
147 | missing = copy_from_user(dst, src, len); | ||
148 | if (missing) { | ||
149 | memset(dst + len - missing, 0, missing); | ||
150 | *err_ptr = -EFAULT; | ||
151 | } | ||
152 | |||
153 | return csum_partial(dst, len, sum); | ||
154 | } | ||
diff --git a/arch/v850/lib/lshrdi3.c b/arch/v850/lib/lshrdi3.c new file mode 100644 index 000000000000..93b1cb6fdee8 --- /dev/null +++ b/arch/v850/lib/lshrdi3.c | |||
@@ -0,0 +1,62 @@ | |||
1 | /* lshrdi3.c extracted from gcc-2.7.2/libgcc2.c which is: */ | ||
2 | /* Copyright (C) 1989, 1992, 1993, 1994, 1995 Free Software Foundation, Inc. | ||
3 | |||
4 | This file is part of GNU CC. | ||
5 | |||
6 | GNU CC is free software; you can redistribute it and/or modify | ||
7 | it under the terms of the GNU General Public License as published by | ||
8 | the Free Software Foundation; either version 2, or (at your option) | ||
9 | any later version. | ||
10 | |||
11 | GNU CC is distributed in the hope that it will be useful, | ||
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | GNU General Public License for more details. | ||
15 | |||
16 | You should have received a copy of the GNU General Public License | ||
17 | along with GNU CC; see the file COPYING. If not, write to | ||
18 | the Free Software Foundation, 59 Temple Place - Suite 330, | ||
19 | Boston, MA 02111-1307, USA. */ | ||
20 | |||
21 | #define BITS_PER_UNIT 8 | ||
22 | |||
23 | typedef int SItype __attribute__ ((mode (SI))); | ||
24 | typedef unsigned int USItype __attribute__ ((mode (SI))); | ||
25 | typedef int DItype __attribute__ ((mode (DI))); | ||
26 | typedef int word_type __attribute__ ((mode (__word__))); | ||
27 | |||
28 | struct DIstruct {SItype high, low;}; | ||
29 | |||
30 | typedef union | ||
31 | { | ||
32 | struct DIstruct s; | ||
33 | DItype ll; | ||
34 | } DIunion; | ||
35 | |||
36 | DItype | ||
37 | __lshrdi3 (DItype u, word_type b) | ||
38 | { | ||
39 | DIunion w; | ||
40 | word_type bm; | ||
41 | DIunion uu; | ||
42 | |||
43 | if (b == 0) | ||
44 | return u; | ||
45 | |||
46 | uu.ll = u; | ||
47 | |||
48 | bm = (sizeof (SItype) * BITS_PER_UNIT) - b; | ||
49 | if (bm <= 0) | ||
50 | { | ||
51 | w.s.high = 0; | ||
52 | w.s.low = (USItype)uu.s.high >> -bm; | ||
53 | } | ||
54 | else | ||
55 | { | ||
56 | USItype carries = (USItype)uu.s.high << bm; | ||
57 | w.s.high = (USItype)uu.s.high >> b; | ||
58 | w.s.low = ((USItype)uu.s.low >> b) | carries; | ||
59 | } | ||
60 | |||
61 | return w.ll; | ||
62 | } | ||
diff --git a/arch/v850/lib/memcpy.c b/arch/v850/lib/memcpy.c new file mode 100644 index 000000000000..492847b3e612 --- /dev/null +++ b/arch/v850/lib/memcpy.c | |||
@@ -0,0 +1,92 @@ | |||
1 | /* | ||
2 | * arch/v850/lib/memcpy.c -- Memory copying | ||
3 | * | ||
4 | * Copyright (C) 2001,02 NEC Corporation | ||
5 | * Copyright (C) 2001,02 Miles Bader <miles@gnu.org> | ||
6 | * | ||
7 | * This file is subject to the terms and conditions of the GNU General | ||
8 | * Public License. See the file COPYING in the main directory of this | ||
9 | * archive for more details. | ||
10 | * | ||
11 | * Written by Miles Bader <miles@gnu.org> | ||
12 | */ | ||
13 | |||
14 | #include <linux/types.h> | ||
15 | #include <asm/string.h> | ||
16 | |||
17 | #define CHUNK_SIZE 32 /* bytes */ | ||
18 | #define CHUNK_ALIGNED(addr) (((unsigned long)addr & 0x3) == 0) | ||
19 | |||
20 | /* Note that this macro uses 8 call-clobbered registers (not including | ||
21 | R1), which are few enough so that the following functions don't need | ||
22 | to spill anything to memory. It also uses R1, which is nominally | ||
23 | reserved for the assembler, but here it should be OK. */ | ||
24 | #define COPY_CHUNK(src, dst) \ | ||
25 | asm ("mov %0, ep;" \ | ||
26 | "sld.w 0[ep], r1; sld.w 4[ep], r12;" \ | ||
27 | "sld.w 8[ep], r13; sld.w 12[ep], r14;" \ | ||
28 | "sld.w 16[ep], r15; sld.w 20[ep], r17;" \ | ||
29 | "sld.w 24[ep], r18; sld.w 28[ep], r19;" \ | ||
30 | "mov %1, ep;" \ | ||
31 | "sst.w r1, 0[ep]; sst.w r12, 4[ep];" \ | ||
32 | "sst.w r13, 8[ep]; sst.w r14, 12[ep];" \ | ||
33 | "sst.w r15, 16[ep]; sst.w r17, 20[ep];" \ | ||
34 | "sst.w r18, 24[ep]; sst.w r19, 28[ep]" \ | ||
35 | :: "r" (src), "r" (dst) \ | ||
36 | : "r1", "r12", "r13", "r14", "r15", \ | ||
37 | "r17", "r18", "r19", "ep", "memory"); | ||
38 | |||
39 | void *memcpy (void *dst, const void *src, __kernel_size_t size) | ||
40 | { | ||
41 | char *_dst = dst; | ||
42 | const char *_src = src; | ||
43 | |||
44 | if (size >= CHUNK_SIZE && CHUNK_ALIGNED(_src) && CHUNK_ALIGNED(_dst)) { | ||
45 | /* Copy large blocks efficiently. */ | ||
46 | unsigned count; | ||
47 | for (count = size / CHUNK_SIZE; count; count--) { | ||
48 | COPY_CHUNK (_src, _dst); | ||
49 | _src += CHUNK_SIZE; | ||
50 | _dst += CHUNK_SIZE; | ||
51 | } | ||
52 | size %= CHUNK_SIZE; | ||
53 | } | ||
54 | |||
55 | if (size > 0) | ||
56 | do | ||
57 | *_dst++ = *_src++; | ||
58 | while (--size); | ||
59 | |||
60 | return dst; | ||
61 | } | ||
62 | |||
63 | void *memmove (void *dst, const void *src, __kernel_size_t size) | ||
64 | { | ||
65 | if ((unsigned long)dst < (unsigned long)src | ||
66 | || (unsigned long)src + size < (unsigned long)dst) | ||
67 | return memcpy (dst, src, size); | ||
68 | else { | ||
69 | char *_dst = dst + size; | ||
70 | const char *_src = src + size; | ||
71 | |||
72 | if (size >= CHUNK_SIZE | ||
73 | && CHUNK_ALIGNED (_src) && CHUNK_ALIGNED (_dst)) | ||
74 | { | ||
75 | /* Copy large blocks efficiently. */ | ||
76 | unsigned count; | ||
77 | for (count = size / CHUNK_SIZE; count; count--) { | ||
78 | _src -= CHUNK_SIZE; | ||
79 | _dst -= CHUNK_SIZE; | ||
80 | COPY_CHUNK (_src, _dst); | ||
81 | } | ||
82 | size %= CHUNK_SIZE; | ||
83 | } | ||
84 | |||
85 | if (size > 0) | ||
86 | do | ||
87 | *--_dst = *--_src; | ||
88 | while (--size); | ||
89 | |||
90 | return _dst; | ||
91 | } | ||
92 | } | ||
diff --git a/arch/v850/lib/memset.c b/arch/v850/lib/memset.c new file mode 100644 index 000000000000..d1b2ad821b15 --- /dev/null +++ b/arch/v850/lib/memset.c | |||
@@ -0,0 +1,68 @@ | |||
1 | /* | ||
2 | * arch/v850/lib/memset.c -- Memory initialization | ||
3 | * | ||
4 | * Copyright (C) 2001,02,04 NEC Corporation | ||
5 | * Copyright (C) 2001,02,04 Miles Bader <miles@gnu.org> | ||
6 | * | ||
7 | * This file is subject to the terms and conditions of the GNU General | ||
8 | * Public License. See the file COPYING in the main directory of this | ||
9 | * archive for more details. | ||
10 | * | ||
11 | * Written by Miles Bader <miles@gnu.org> | ||
12 | */ | ||
13 | |||
14 | #include <linux/types.h> | ||
15 | |||
16 | void *memset (void *dst, int val, __kernel_size_t count) | ||
17 | { | ||
18 | if (count) { | ||
19 | register unsigned loop; | ||
20 | register void *ptr asm ("ep") = dst; | ||
21 | |||
22 | /* replicate VAL into a long. */ | ||
23 | val &= 0xff; | ||
24 | val |= val << 8; | ||
25 | val |= val << 16; | ||
26 | |||
27 | /* copy initial unaligned bytes. */ | ||
28 | if ((long)ptr & 1) { | ||
29 | *(char *)ptr = val; | ||
30 | ptr = (void *)((char *)ptr + 1); | ||
31 | count--; | ||
32 | } | ||
33 | if (count > 2 && ((long)ptr & 2)) { | ||
34 | *(short *)ptr = val; | ||
35 | ptr = (void *)((short *)ptr + 1); | ||
36 | count -= 2; | ||
37 | } | ||
38 | |||
39 | /* 32-byte copying loop. */ | ||
40 | for (loop = count / 32; loop; loop--) { | ||
41 | asm ("sst.w %0, 0[ep]; sst.w %0, 4[ep];" | ||
42 | "sst.w %0, 8[ep]; sst.w %0, 12[ep];" | ||
43 | "sst.w %0, 16[ep]; sst.w %0, 20[ep];" | ||
44 | "sst.w %0, 24[ep]; sst.w %0, 28[ep]" | ||
45 | :: "r" (val) : "memory"); | ||
46 | ptr += 32; | ||
47 | } | ||
48 | count %= 32; | ||
49 | |||
50 | /* long copying loop. */ | ||
51 | for (loop = count / 4; loop; loop--) { | ||
52 | *(long *)ptr = val; | ||
53 | ptr = (void *)((long *)ptr + 1); | ||
54 | } | ||
55 | count %= 4; | ||
56 | |||
57 | /* finish up with any trailing bytes. */ | ||
58 | if (count & 2) { | ||
59 | *(short *)ptr = val; | ||
60 | ptr = (void *)((short *)ptr + 1); | ||
61 | } | ||
62 | if (count & 1) { | ||
63 | *(char *)ptr = val; | ||
64 | } | ||
65 | } | ||
66 | |||
67 | return dst; | ||
68 | } | ||
diff --git a/arch/v850/lib/muldi3.c b/arch/v850/lib/muldi3.c new file mode 100644 index 000000000000..277ca25c82c8 --- /dev/null +++ b/arch/v850/lib/muldi3.c | |||
@@ -0,0 +1,61 @@ | |||
1 | /* muldi3.c extracted from gcc-2.7.2.3/libgcc2.c and | ||
2 | gcc-2.7.2.3/longlong.h which is: */ | ||
3 | /* Copyright (C) 1989, 1992, 1993, 1994, 1995, 2001 Free Software Foundation, Inc. | ||
4 | |||
5 | This file is part of GNU CC. | ||
6 | |||
7 | GNU CC is free software; you can redistribute it and/or modify | ||
8 | it under the terms of the GNU General Public License as published by | ||
9 | the Free Software Foundation; either version 2, or (at your option) | ||
10 | any later version. | ||
11 | |||
12 | GNU CC is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | GNU General Public License for more details. | ||
16 | |||
17 | You should have received a copy of the GNU General Public License | ||
18 | along with GNU CC; see the file COPYING. If not, write to | ||
19 | the Free Software Foundation, 59 Temple Place - Suite 330, | ||
20 | Boston, MA 02111-1307, USA. */ | ||
21 | |||
22 | #define umul_ppmm(w1, w0, u, v) \ | ||
23 | __asm__ ("mulu %3, %0, %1" \ | ||
24 | : "=r" ((USItype)(w0)), \ | ||
25 | "=r" ((USItype)(w1)) \ | ||
26 | : "%0" ((USItype)(u)), \ | ||
27 | "r" ((USItype)(v))) | ||
28 | |||
29 | #define __umulsidi3(u, v) \ | ||
30 | ({DIunion __w; \ | ||
31 | umul_ppmm (__w.s.high, __w.s.low, u, v); \ | ||
32 | __w.ll; }) | ||
33 | |||
34 | typedef int SItype __attribute__ ((mode (SI))); | ||
35 | typedef unsigned int USItype __attribute__ ((mode (SI))); | ||
36 | typedef int DItype __attribute__ ((mode (DI))); | ||
37 | typedef int word_type __attribute__ ((mode (__word__))); | ||
38 | |||
39 | struct DIstruct {SItype high, low;}; | ||
40 | |||
41 | typedef union | ||
42 | { | ||
43 | struct DIstruct s; | ||
44 | DItype ll; | ||
45 | } DIunion; | ||
46 | |||
47 | DItype | ||
48 | __muldi3 (DItype u, DItype v) | ||
49 | { | ||
50 | DIunion w; | ||
51 | DIunion uu, vv; | ||
52 | |||
53 | uu.ll = u, | ||
54 | vv.ll = v; | ||
55 | |||
56 | w.ll = __umulsidi3 (uu.s.low, vv.s.low); | ||
57 | w.s.high += ((USItype) uu.s.low * (USItype) vv.s.high | ||
58 | + (USItype) uu.s.high * (USItype) vv.s.low); | ||
59 | |||
60 | return w.ll; | ||
61 | } | ||
diff --git a/arch/v850/lib/negdi2.c b/arch/v850/lib/negdi2.c new file mode 100644 index 000000000000..571e04fc619a --- /dev/null +++ b/arch/v850/lib/negdi2.c | |||
@@ -0,0 +1,25 @@ | |||
1 | /* | ||
2 | * arch/v850/lib/negdi2.c -- 64-bit negation | ||
3 | * | ||
4 | * Copyright (C) 2001 NEC Corporation | ||
5 | * Copyright (C) 2001 Miles Bader <miles@gnu.org> | ||
6 | * | ||
7 | * This file is subject to the terms and conditions of the GNU General | ||
8 | * Public License. See the file COPYING in the main directory of this | ||
9 | * archive for more details. | ||
10 | * | ||
11 | * Written by Miles Bader <miles@gnu.org> | ||
12 | */ | ||
13 | |||
14 | typedef int DItype __attribute__ ((mode (DI))); | ||
15 | |||
16 | DItype __negdi2 (DItype x) | ||
17 | { | ||
18 | __asm__ __volatile__ | ||
19 | ("not r6, r10;" | ||
20 | "add 1, r10;" | ||
21 | "setf c, r6;" | ||
22 | "not r7, r11;" | ||
23 | "add r6, r11" | ||
24 | ::: "r6", "r7", "r10", "r11"); | ||
25 | } | ||