ia64/xen-unstable

view tools/libfsimage/zfs/zfs_fletcher.c @ 19648:f0e2df69a8eb

x86 hvm: Allow cross-vendor migration

Intercept #UD and emulate SYSCALL/SYSENTER/SYSEXIT as necessary.

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue May 26 15:01:36 2009 +0100 (2009-05-26)
parents 64f790e90d3d
children
line source
1 /*
2 * GRUB -- GRand Unified Bootloader
3 * Copyright (C) 1999,2000,2001,2002,2003,2004 Free Software Foundation, Inc.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19 /*
20 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
21 * Use is subject to license terms.
22 */
24 #include "fsys_zfs.h"
27 void
28 fletcher_2_native(const void *buf, uint64_t size, zio_cksum_t *zcp)
29 {
30 const uint64_t *ip = buf;
31 const uint64_t *ipend = ip + (size / sizeof (uint64_t));
32 uint64_t a0, b0, a1, b1;
34 for (a0 = b0 = a1 = b1 = 0; ip < ipend; ip += 2) {
35 a0 += ip[0];
36 a1 += ip[1];
37 b0 += a0;
38 b1 += a1;
39 }
41 ZIO_SET_CHECKSUM(zcp, a0, a1, b0, b1);
42 }
44 void
45 fletcher_2_byteswap(const void *buf, uint64_t size, zio_cksum_t *zcp)
46 {
47 const uint64_t *ip = buf;
48 const uint64_t *ipend = ip + (size / sizeof (uint64_t));
49 uint64_t a0, b0, a1, b1;
51 for (a0 = b0 = a1 = b1 = 0; ip < ipend; ip += 2) {
52 a0 += BSWAP_64(ip[0]);
53 a1 += BSWAP_64(ip[1]);
54 b0 += a0;
55 b1 += a1;
56 }
58 ZIO_SET_CHECKSUM(zcp, a0, a1, b0, b1);
59 }
61 void
62 fletcher_4_native(const void *buf, uint64_t size, zio_cksum_t *zcp)
63 {
64 const uint32_t *ip = buf;
65 const uint32_t *ipend = ip + (size / sizeof (uint32_t));
66 uint64_t a, b, c, d;
68 for (a = b = c = d = 0; ip < ipend; ip++) {
69 a += ip[0];
70 b += a;
71 c += b;
72 d += c;
73 }
75 ZIO_SET_CHECKSUM(zcp, a, b, c, d);
76 }
78 void
79 fletcher_4_byteswap(const void *buf, uint64_t size, zio_cksum_t *zcp)
80 {
81 const uint32_t *ip = buf;
82 const uint32_t *ipend = ip + (size / sizeof (uint32_t));
83 uint64_t a, b, c, d;
85 for (a = b = c = d = 0; ip < ipend; ip++) {
86 a += BSWAP_32(ip[0]);
87 b += a;
88 c += b;
89 d += c;
90 }
92 ZIO_SET_CHECKSUM(zcp, a, b, c, d);
93 }