4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
30 #pragma ident "%Z%%M% %I% %E% SMI"
32 #include <sys/types.h>
40 * Structure to hold fields to be skipped when calculating the checksum
42 typedef struct crc_skip
{
43 struct crc_skip
*skip_next
;
48 extern uint_t
crcfunc(uint_t check
,
53 extern void crcfreetab(void);
56 * The following crc defines allow for a number of areas to be skipped
57 * (not be included in the data being crc'd) in the record
58 * block (mddb_rb_32). These areas are the 12 byte area covering
59 * rb_checksum_fiddle, rb_private and rb_userdata
61 * In addition the skipped areas include the timestamps in the crc for
65 #define crcgen(record, result, size, skip) \
66 (void) crcfunc(0, (uchar_t *)(record), (uint_t *)(result), \
67 (size_t)(size), (crc_skip_t *)(skip))
72 #define crcgen(record, result, size, skip) {\
73 uint_t b = crcfunc(0, (uchar_t *)(record), (uint_t *)(result), \
74 (size_t)(size), (crc_skip_t *)(skip)); \
75 (void) crcfunc(0, (uchar_t *)(record), (uint_t *)(result), \
76 (size_t)(size), (crc_skip_t *)(skip)); \
77 ASSERT (*((uint_t *)(result)) == b); \
80 #define crcgen(record, result, size, skip) {\
81 uint_t b = crcfunc(0, (uchar_t *)(record), (uint_t *)(result), \
82 (size_t)(size), (crc_skip_t *)(skip)); \
83 (void) crcfunc(0, (uchar_t *)(record), (uint_t *)(result), \
84 (size_t)(size), (crc_skip_t *)(skip)); \
85 assert (*((uint_t *)(result)) == b); \
90 #define crcchk(record, result, size, skip) crcfunc(1, (uchar_t *)(record), \
91 (uint_t *)(result), (size_t)(size), (crc_skip_t *)(skip))
97 #endif /* _SYS_MD_CRC_H */