Branch libreoffice-5-0-4
[LibreOffice.git] / include / vcl / checksum.hxx
blob7e1076fb31390c4383b6a363864156105cc3db42
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #ifndef INCLUDED_VCL_INC_CHECKSUM_HXX
22 #define INCLUDED_VCL_INC_CHECKSUM_HXX
24 #include <sal/config.h>
25 #include <sal/types.h>
26 #include <tools/solar.h>
27 #include <vcl/dllapi.h>
29 #include <boost/preprocessor/arithmetic/inc.hpp>
30 #include <boost/preprocessor/arithmetic/mul.hpp>
31 #include <boost/preprocessor/repetition/repeat_from_to.hpp>
33 #define BITMAP_CHECKSUM_SIZE 8
34 #define BITMAP_CHECKSUM_BITS BOOST_PP_MUL(BITMAP_CHECKSUM_SIZE, 8)
36 typedef sal_uInt64 BitmapChecksum;
37 typedef sal_uInt8 BitmapChecksumOctetArray[BITMAP_CHECKSUM_SIZE];
39 #define BITMAP_CHECKSUM_SET_OCTET(z, i, unused) \
40 p[i] = (sal_uInt8)(n >> BOOST_PP_MUL(8, i));
43 inline void BCToBCOA( BitmapChecksum n , BitmapChecksumOctetArray p )
45 BOOST_PP_REPEAT(BITMAP_CHECKSUM_SIZE , BITMAP_CHECKSUM_SET_OCTET, unused)
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
52 /*========================================================================
54 * vcl_crc64 interface.
56 *======================================================================*/
57 /** Evaluate CRC64 over given data.
59 This function evaluates the CRC polynomial 0xEDB88320.
61 @param Crc [in] CRC64 over previous data or zero.
62 @param Data [in] data buffer.
63 @param DatLen [in] data buffer length.
64 @return new CRC64 value.
66 VCL_DLLPUBLIC sal_uInt64 SAL_CALL vcl_crc64 (
67 sal_uInt64 Crc,
68 const void *Data, sal_uInt32 DatLen
69 ) SAL_THROW_EXTERN_C();
73 VCL_DLLPUBLIC const sal_uInt64* vcl_get_crc64_table();
76 #ifdef __cplusplus
78 #endif
80 inline BitmapChecksum vcl_get_checksum (
81 BitmapChecksum Checksum,
82 const void *Data,
83 sal_uInt32 DatLen
86 return (BitmapChecksum)(vcl_crc64( Checksum, Data, DatLen ));
90 #endif // INCLUDED_VCL_INC_CHECKSUM_HXX
92 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */