File: goHash.h

package info (click to toggle)
cgoban 1.9.14-18
  • links: PTS
  • area: main
  • in suites: buster, stretch
  • size: 3,448 kB
  • sloc: ansic: 36,037; sh: 707; makefile: 259
file content (61 lines) | stat: -rw-r--r-- 1,614 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
 * src/gohash.h, part of Complete Goban (game program)
 * Copyright (C) 1995 William Shubert.
 * See "configure.h.in" for more copyright information.
 */


#ifndef  _GOHASH_H_
#define  _GOHASH_H_  1

#ifndef  _WMS_RND_H_
#include <wms/rnd.h>
#endif


/**********************************************************************
 * Data types
 **********************************************************************/

#if  SIZEOF_LONG >= 8
#define  GoHash_isScalar  1
typedef ulong  GoHash;
#elif  SIZEOF_LONG_LONG >= 8
#define  GoHash_isScalar  1
typedef unsigned long long  GoHash;
#else
#define  GoHash_isScalar  0
typedef struct  {
  uint32  lo, hi;
} GoHash;
#endif

/**********************************************************************
 * Global variables
 **********************************************************************/
extern const GoHash  goHash_zero;
extern const GoHash  goHash_pass;

/**********************************************************************
 * Functions
 **********************************************************************/

/* In all of these functions, passing zero as the "loc" means a pass. */
GoHash  goHash_init(Rnd *r);

#if  GoHash_isScalar

#define  goHash_xor(v1, v2)  ((v1) ^ (v2))
#define  goHash_eq(v1, v2)  ((v1) == (v2))
#define  goHash_loBits(v, m)  ((v) & (m))
#define  goHash_print(v)  printf("0x%x%08x",(int)(v>>32),(int)v)

#else

extern GoHash  goHash_xor(GoHash v1, GoHash v2);
#define  goHash_eq(v1, v2)  (((v1).lo == (v2).lo) && ((v1).hi == (v2).hi))
#define  goHash_loBits(v, m)  ((v).lo & (m))

#endif  /* GoHash_isScalar */

#endif  /*  _GOHASH_H_ */