Motr  M0
ext.h
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2012-2020 Seagate Technology LLC and/or its Affiliates
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * For any questions about this software or licensing,
18  * please email opensource@seagate.com or cortx-questions@seagate.com.
19  *
20  */
21 
22 
23 #pragma once
24 
25 #ifndef __MOTR_LIB_EXT_H__
26 #define __MOTR_LIB_EXT_H__
27 
28 #include "format/format.h" /* m0_format_header */
29 #include "format/format_xc.h"
30 
37 struct m0_ext {
42 } M0_XCA_RECORD M0_XCA_DOMAIN(be|rpc);
43 
46 
47  /* future versions, uncomment and update M0_EXT_FORMAT_VERSION */
48  /*M0_EXT_FORMAT_VERSION_2,*/
49  /*M0_EXT_FORMAT_VERSION_3,*/
50 
53 };
54 
55 #define M0_EXT(start, end) \
56  ((struct m0_ext){ .e_start = (start), .e_end = (end) })
57 
58 M0_INTERNAL void m0_ext_init(struct m0_ext *ext);
59 M0_INTERNAL m0_bcount_t m0_ext_length(const struct m0_ext *ext);
60 M0_INTERNAL bool m0_ext_is_in(const struct m0_ext *ext, m0_bindex_t index);
61 
62 M0_INTERNAL bool m0_ext_are_overlapping(const struct m0_ext *e0,
63  const struct m0_ext *e1);
64 M0_INTERNAL bool m0_ext_is_partof(const struct m0_ext *super,
65  const struct m0_ext *sub);
66 M0_INTERNAL bool m0_ext_equal(const struct m0_ext *a, const struct m0_ext *b);
67 M0_INTERNAL bool m0_ext_is_empty(const struct m0_ext *ext);
68 M0_INTERNAL void m0_ext_intersection(const struct m0_ext *e0,
69  const struct m0_ext *e1,
70  struct m0_ext *result);
71 /* must work correctly when minuend == difference */
72 M0_INTERNAL void m0_ext_sub(const struct m0_ext *minuend,
73  const struct m0_ext *subtrahend,
74  struct m0_ext *difference);
75 /* must work correctly when sum == either of terms. */
76 M0_INTERNAL void m0_ext_add(const struct m0_ext *term0,
77  const struct m0_ext *term1, struct m0_ext *sum);
78 
79 /* what about signed? */
80 M0_INTERNAL m0_bindex_t m0_ext_cap(const struct m0_ext *ext2, m0_bindex_t val);
81 
83 M0_INTERNAL bool m0_ext_is_valid(const struct m0_ext *ext);
84 
85 #define EXT_F "[%" PRIx64 ", %" PRIx64 ")"
86 #define EXT_P(x) (x)->e_start, (x)->e_end
87 
89 #endif /* __MOTR_LIB_EXT_H__ */
90 
91 /*
92  * Local variables:
93  * c-indentation-style: "K&R"
94  * c-basic-offset: 8
95  * tab-width: 8
96  * fill-column: 80
97  * scroll-step: 1
98  * End:
99  */
M0_INTERNAL m0_bcount_t m0_ext_length(const struct m0_ext *ext)
Definition: ext.c:42
enum m0_ext_format_version M0_XCA_DOMAIN
m0_bindex_t e_end
Definition: ext.h:40
Definition: idx_mock.c:52
struct m0_format_header e_header
Definition: ext.h:38
M0_INTERNAL void m0_ext_add(const struct m0_ext *term0, const struct m0_ext *term1, struct m0_ext *sum)
static int sum
Definition: rwlock.c:53
uint64_t m0_bindex_t
Definition: types.h:80
uint64_t m0_bcount_t
Definition: types.h:77
M0_INTERNAL m0_bindex_t m0_ext_cap(const struct m0_ext *ext2, m0_bindex_t val)
M0_INTERNAL bool m0_ext_equal(const struct m0_ext *a, const struct m0_ext *b)
Definition: ext.c:70
M0_INTERNAL bool m0_ext_is_valid(const struct m0_ext *ext)
Definition: ext.c:90
M0_INTERNAL void m0_ext_init(struct m0_ext *ext)
Definition: ext.c:32
M0_INTERNAL bool m0_ext_is_partof(const struct m0_ext *super, const struct m0_ext *sub)
Definition: ext.c:62
M0_INTERNAL void m0_ext_sub(const struct m0_ext *minuend, const struct m0_ext *subtrahend, struct m0_ext *difference)
m0_ext_format_version
Definition: ext.h:44
M0_INTERNAL bool m0_ext_is_in(const struct m0_ext *ext, m0_bindex_t index)
Definition: ext.c:48
M0_INTERNAL bool m0_ext_is_empty(const struct m0_ext *ext)
Definition: ext.c:76
Definition: ext.h:37
m0_bindex_t e_start
Definition: ext.h:39
struct m0_format_footer e_footer
Definition: ext.h:41
M0_INTERNAL bool m0_ext_are_overlapping(const struct m0_ext *e0, const struct m0_ext *e1)
Definition: ext.c:53
M0_INTERNAL void m0_ext_intersection(const struct m0_ext *e0, const struct m0_ext *e1, struct m0_ext *result)
Definition: ext.c:81
static struct m0_be_ut_backend be
Definition: service_ut.c:59