2005-11-28 23:09:21 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
2006-08-23 04:29:35 +04:00
|
|
|
* Copyright (c) 2004-2006 The University of Tennessee and The University
|
2005-11-28 23:09:21 +03:00
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2005-11-28 20:20:21 +03:00
|
|
|
#ifndef _OPAL_CRC_H_
|
|
|
|
#define _OPAL_CRC_H_
|
|
|
|
|
2006-10-20 11:01:52 +04:00
|
|
|
#include "opal_config.h"
|
|
|
|
|
2006-10-18 02:06:51 +04:00
|
|
|
#include <stddef.h>
|
|
|
|
|
2006-08-23 04:29:35 +04:00
|
|
|
#if defined(c_plusplus) || defined(__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2005-11-28 20:20:21 +03:00
|
|
|
#define CRC_POLYNOMIAL ((unsigned int)0x04c11db7)
|
|
|
|
#define CRC_INITIAL_REGISTER ((unsigned int)0xffffffff)
|
|
|
|
|
2006-03-17 21:46:48 +03:00
|
|
|
|
|
|
|
#define OPAL_CSUM( SRC, LEN ) opal_uicsum( SRC, LEN )
|
|
|
|
#define OPAL_CSUM_PARTIAL( SRC, LEN, UI1, UI2 ) \
|
|
|
|
opal_uicsum_partial( SRC, LEN, UI1, UI2 )
|
|
|
|
#define OPAL_CSUM_BCOPY_PARTIAL( SRC, DST, LEN1, LEN2, UI1, UI2 ) \
|
|
|
|
opal_bcopy_uicsum_partial( SRC, DST, LEN1, LEN2, UI1, UI2 )
|
|
|
|
#define OPAL_CSUM_ZERO 0
|
|
|
|
|
|
|
|
|
2006-08-23 04:29:35 +04:00
|
|
|
OPAL_DECLSPEC unsigned long
|
2005-11-28 20:20:21 +03:00
|
|
|
opal_bcopy_csum_partial(
|
|
|
|
const void * source,
|
|
|
|
void * destination,
|
2006-10-18 00:20:58 +04:00
|
|
|
size_t copylen,
|
|
|
|
size_t csumlen,
|
|
|
|
unsigned long* lastPartialLong,
|
|
|
|
size_t* lastPartialLength
|
2005-11-28 20:20:21 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
static inline unsigned long
|
|
|
|
opal_bcopy_csum (
|
|
|
|
const void * source,
|
|
|
|
void * destination,
|
2006-10-18 00:20:58 +04:00
|
|
|
size_t copylen,
|
|
|
|
size_t csumlen
|
2005-11-28 20:20:21 +03:00
|
|
|
)
|
|
|
|
{
|
|
|
|
unsigned long plong = 0;
|
2006-10-18 00:20:58 +04:00
|
|
|
size_t plength = 0;
|
2005-11-28 20:20:21 +03:00
|
|
|
return opal_bcopy_csum_partial(source, destination, copylen, csumlen, &plong, &plength);
|
|
|
|
}
|
|
|
|
|
2006-08-23 04:29:35 +04:00
|
|
|
OPAL_DECLSPEC unsigned int
|
2005-11-28 20:20:21 +03:00
|
|
|
opal_bcopy_uicsum_partial (
|
|
|
|
const void * source,
|
|
|
|
void * destination,
|
2006-10-18 00:20:58 +04:00
|
|
|
size_t copylen,
|
|
|
|
size_t csumlen,
|
|
|
|
unsigned int* lastPartialInt,
|
|
|
|
size_t* lastPartialLength
|
2005-11-28 20:20:21 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
static inline unsigned int
|
|
|
|
opal_bcopy_uicsum (
|
|
|
|
const void * source,
|
|
|
|
void * destination,
|
2006-10-18 00:20:58 +04:00
|
|
|
size_t copylen,
|
|
|
|
size_t csumlen
|
2005-11-28 20:20:21 +03:00
|
|
|
)
|
|
|
|
{
|
|
|
|
unsigned int pint = 0;
|
2006-10-18 00:20:58 +04:00
|
|
|
size_t plength = 0;
|
2005-11-28 20:20:21 +03:00
|
|
|
return opal_bcopy_uicsum_partial(source, destination, copylen, csumlen, &pint, &plength);
|
|
|
|
}
|
|
|
|
|
2006-08-23 04:29:35 +04:00
|
|
|
OPAL_DECLSPEC unsigned long
|
2005-11-28 20:20:21 +03:00
|
|
|
opal_csum_partial (
|
|
|
|
const void * source,
|
2006-10-18 00:20:58 +04:00
|
|
|
size_t csumlen,
|
|
|
|
unsigned long* lastPartialLong,
|
|
|
|
size_t* lastPartialLength
|
2005-11-28 20:20:21 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
static inline unsigned long
|
2006-10-18 00:20:58 +04:00
|
|
|
opal_csum(const void * source, size_t csumlen)
|
2005-11-28 20:20:21 +03:00
|
|
|
{
|
|
|
|
unsigned long lastPartialLong = 0;
|
2006-10-18 00:20:58 +04:00
|
|
|
size_t lastPartialLength = 0;
|
2005-11-28 20:20:21 +03:00
|
|
|
return opal_csum_partial(source, csumlen, &lastPartialLong, &lastPartialLength);
|
|
|
|
}
|
|
|
|
|
2006-08-23 04:29:35 +04:00
|
|
|
OPAL_DECLSPEC unsigned int
|
2005-11-28 20:20:21 +03:00
|
|
|
opal_uicsum_partial (
|
|
|
|
const void * source,
|
2006-10-18 00:20:58 +04:00
|
|
|
size_t csumlen,
|
2005-11-28 20:20:21 +03:00
|
|
|
unsigned int * lastPartialInt,
|
2006-10-18 00:20:58 +04:00
|
|
|
size_t* lastPartialLength
|
2005-11-28 20:20:21 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
static inline unsigned int
|
2006-10-18 00:20:58 +04:00
|
|
|
opal_uicsum(const void * source, size_t csumlen)
|
2005-11-28 20:20:21 +03:00
|
|
|
{
|
|
|
|
unsigned int lastPartialInt = 0;
|
2006-10-18 00:20:58 +04:00
|
|
|
size_t lastPartialLength = 0;
|
2005-11-28 20:20:21 +03:00
|
|
|
return opal_uicsum_partial(source, csumlen, &lastPartialInt, &lastPartialLength);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* CRC Support
|
|
|
|
*/
|
|
|
|
|
|
|
|
void opal_initialize_crc_table(void);
|
|
|
|
|
2006-08-23 04:29:35 +04:00
|
|
|
OPAL_DECLSPEC unsigned int
|
2005-11-28 20:20:21 +03:00
|
|
|
opal_bcopy_uicrc_partial(
|
|
|
|
const void * source,
|
|
|
|
void * destination,
|
2006-10-18 00:20:58 +04:00
|
|
|
size_t copylen,
|
|
|
|
size_t crclen,
|
2005-11-28 20:20:21 +03:00
|
|
|
unsigned int partial_crc);
|
|
|
|
|
|
|
|
static inline unsigned int
|
|
|
|
opal_bcopy_uicrc(
|
|
|
|
const void * source,
|
|
|
|
void * destination,
|
2006-10-18 00:20:58 +04:00
|
|
|
size_t copylen,
|
|
|
|
size_t crclen)
|
2005-11-28 20:20:21 +03:00
|
|
|
{
|
|
|
|
return opal_bcopy_uicrc_partial(source, destination, copylen, crclen, CRC_INITIAL_REGISTER);
|
|
|
|
}
|
|
|
|
|
2006-08-23 04:29:35 +04:00
|
|
|
OPAL_DECLSPEC unsigned int
|
2005-11-28 20:20:21 +03:00
|
|
|
opal_uicrc_partial(
|
|
|
|
const void * source,
|
2006-10-18 00:20:58 +04:00
|
|
|
size_t crclen,
|
2005-11-28 20:20:21 +03:00
|
|
|
unsigned int partial_crc);
|
|
|
|
|
|
|
|
|
|
|
|
static inline unsigned int
|
2006-10-18 00:20:58 +04:00
|
|
|
opal_uicrc(const void * source, size_t crclen)
|
2005-11-28 20:20:21 +03:00
|
|
|
{
|
|
|
|
return opal_uicrc_partial(source, crclen, CRC_INITIAL_REGISTER);
|
|
|
|
}
|
|
|
|
|
2006-08-23 04:29:35 +04:00
|
|
|
#if defined(c_plusplus) || defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2005-11-28 20:20:21 +03:00
|
|
|
#endif
|
|
|
|
|