1/* $NetBSD: idl.h,v 1.2 2021/08/14 16:15:02 christos Exp $ */ 2 3/* OpenLDAP WiredTiger backend */ 4/* $OpenLDAP$ */ 5/* This work is part of OpenLDAP Software <http://www.openldap.org/>. 6 * 7 * Copyright 2002-2021 The OpenLDAP Foundation. 8 * All rights reserved. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted only as authorized by the OpenLDAP 12 * Public License. 13 * 14 * A copy of this license is available in the file LICENSE in the 15 * top-level directory of the distribution or, alternatively, at 16 * <http://www.OpenLDAP.org/license.html>. 17 */ 18/* ACKNOWLEDGEMENTS: 19 * This work was developed by HAMANO Tsukasa <hamano@osstech.co.jp> 20 * based on back-bdb for inclusion in OpenLDAP Software. 21 * WiredTiger is a product of MongoDB Inc. 22 */ 23 24#ifndef _WI_IDL_H_ 25#define _WT_IDL_H_ 26 27/* IDL sizes - likely should be even bigger 28 * limiting factors: sizeof(ID), thread stack size 29 */ 30#define WT_IDL_LOGN 16 /* DB_SIZE is 2^16, UM_SIZE is 2^17 */ 31#define WT_IDL_DB_SIZE (1<<WT_IDL_LOGN) 32#define WT_IDL_UM_SIZE (1<<(WT_IDL_LOGN+1)) 33#define WT_IDL_UM_SIZEOF (WT_IDL_UM_SIZE * sizeof(ID)) 34 35#define WT_IDL_DB_MAX (WT_IDL_DB_SIZE-1) 36 37#define WT_IDL_UM_MAX (WT_IDL_UM_SIZE-1) 38 39#define WT_IDL_IS_RANGE(ids) ((ids)[0] == NOID) 40#define WT_IDL_RANGE_SIZE (3) 41#define WT_IDL_RANGE_SIZEOF (WT_IDL_RANGE_SIZE * sizeof(ID)) 42#define WT_IDL_SIZEOF(ids) ((WT_IDL_IS_RANGE(ids) \ 43 ? WT_IDL_RANGE_SIZE : ((ids)[0]+1)) * sizeof(ID)) 44 45#define WT_IDL_RANGE_FIRST(ids) ((ids)[1]) 46#define WT_IDL_RANGE_LAST(ids) ((ids)[2]) 47 48#define WT_IDL_RANGE( ids, f, l ) \ 49 do { \ 50 (ids)[0] = NOID; \ 51 (ids)[1] = (f); \ 52 (ids)[2] = (l); \ 53 } while(0) 54 55#define WT_IDL_ZERO(ids) \ 56 do { \ 57 (ids)[0] = 0; \ 58 (ids)[1] = 0; \ 59 (ids)[2] = 0; \ 60 } while(0) 61 62#define WT_IDL_IS_ZERO(ids) ( (ids)[0] == 0 ) 63#define WT_IDL_IS_ALL( range, ids ) ( (ids)[0] == NOID \ 64 && (ids)[1] <= (range)[1] && (range)[2] <= (ids)[2] ) 65 66#define WT_IDL_CPY( dst, src ) (AC_MEMCPY( dst, src, WT_IDL_SIZEOF( src ) )) 67 68#define WT_IDL_ID( wi, ids, id ) WT_IDL_RANGE( ids, id, ((wi)->wi_lastid) ) 69#define WT_IDL_ALL( wi, ids ) WT_IDL_RANGE( ids, 1, ((wi)->wi_lastid) ) 70 71#define WT_IDL_FIRST( ids ) ( (ids)[1] ) 72#define WT_IDL_LLAST( ids ) ( (ids)[(ids)[0]] ) 73#define WT_IDL_LAST( ids ) ( WT_IDL_IS_RANGE(ids) \ 74 ? (ids)[2] : (ids)[(ids)[0]] ) 75 76#define WT_IDL_N( ids ) ( WT_IDL_IS_RANGE(ids) \ 77 ? ((ids)[2]-(ids)[1])+1 : (ids)[0] ) 78 79LDAP_BEGIN_DECL 80LDAP_END_DECL 81 82#endif 83