• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Multi-include test program
3  * Validates that xxhash.h can be included multiple times and in any order
4  *
5  * Copyright (C) 2020 Yann Collet
6  *
7  * GPL v2 License
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License along
20  * with this program; if not, write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22  *
23  * You can contact the author at:
24  *   - xxHash homepage: https://www.xxhash.com
25  *   - xxHash source repository: https://github.com/Cyan4973/xxHash
26  */
27 
28 #include <stdio.h>   /* printf */
29 
30 /* Normal include, gives access to public symbols */
31 #include "../xxhash.h"
32 
33 /*
34  * Advanced include, gives access to experimental symbols
35  * This test ensure that xxhash.h can be included multiple times and in any
36  * order. This order is more difficult: Without care, the declaration of
37  * experimental symbols could be skipped.
38  */
39 #define XXH_STATIC_LINKING_ONLY
40 #include "../xxhash.h"
41 
42 /*
43  * Inlining: Re-define all identifiers, keep them private to the unit.
44  * Note: Without specific efforts, the identifier names would collide.
45  *
46  * To be linked with and without xxhash.o to test the symbol's presence and
47  * naming collisions.
48  */
49 #define XXH_INLINE_ALL
50 #include "../xxhash.h"
51 
52 
main(void)53 int main(void)
54 {
55     XXH3_state_t state;   /* part of experimental API */
56 
57     XXH3_64bits_reset(&state);
58     const char input[] = "Hello World !";
59 
60     XXH3_64bits_update(&state, input, sizeof(input));
61 
62     XXH64_hash_t const h = XXH3_64bits_digest(&state);
63     printf("hash '%s': %08x%08x \n", input, (unsigned)(h >> 32), (unsigned)h);
64 
65     return 0;
66 }
67