summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/src/include/log_inline.h
blob: 861d0afb022b14653b30ef015278d7003b87d576 (plain)
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
/*-
 * Copyright (c) 2014-present MongoDB, Inc.
 * Copyright (c) 2008-2014 WiredTiger, Inc.
 *	All rights reserved.
 *
 * See the file LICENSE for redistribution information.
 */

/*
 * __wt_log_cmp --
 *     Compare 2 LSNs, return -1 if lsn1 < lsn2, 0if lsn1 == lsn2 and 1 if lsn1 > lsn2.
 */
static inline int
__wt_log_cmp(WT_LSN *lsn1, WT_LSN *lsn2)
{
    uint64_t l1, l2;

    /*
     * Read LSNs into local variables so that we only read each field once and all comparisons are
     * on the same values.
     */
    l1 = ((volatile WT_LSN *)lsn1)->file_offset;
    l2 = ((volatile WT_LSN *)lsn2)->file_offset;

    return (l1 < l2 ? -1 : (l1 > l2 ? 1 : 0));
}