Motr  M0
param.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2020 Seagate Technology LLC and/or its Affiliates
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * For any questions about this software or licensing,
17  * please email opensource@seagate.com or cortx-questions@seagate.com.
18  *
19  */
20 
21 
22 #include "module/param.h"
23 #include "module/instance.h" /* m0_get */
24 #include "motr/magic.h" /* M0_PARAM_SOURCE_MAGIC */
25 
32 M0_TL_DESCR_DEFINE(m0_param_sources, "m0_param_sources", static,
33  struct m0_param_source, ps_link, ps_magic,
35 M0_TL_DEFINE(m0_param_sources, M0_INTERNAL, struct m0_param_source);
36 
37 static struct m0_tl *param_sources(void)
38 {
39  struct m0_tl *list = &m0_get()->i_param_sources;
40  M0_ASSERT(list->t_head.l_head != NULL); /* the list is initialised */
41  return list;
42 }
43 
44 M0_INTERNAL void *m0_param_get(const char *key)
45 {
46  struct m0_param_source *src;
47 
48  m0_tl_for(m0_param_sources, param_sources(), src) {
49  void *p = src->ps_param_get(src, key);
50  if (p != NULL)
51  return p;
52  } m0_tl_endfor;
53  return NULL;
54 }
55 
56 M0_INTERNAL void m0_param_source_add(struct m0_param_source *src)
57 {
58  M0_PRE(src->ps_param_get != NULL);
59  m0_param_sources_tlink_init_at_tail(src, param_sources());
60 }
61 
62 M0_INTERNAL void m0_param_source_del(struct m0_param_source *src)
63 {
64  m0_param_sources_tlink_del_fini(src);
65 }
66 
static struct m0_addb2_philter p
Definition: consumer.c:40
#define M0_PRE(cond)
static struct m0_list list
Definition: list.c:144
#define NULL
Definition: misc.h:38
M0_INTERNAL struct m0 * m0_get(void)
Definition: instance.c:41
M0_INTERNAL void m0_param_source_del(struct m0_param_source *src)
Definition: param.c:62
#define m0_tl_endfor
Definition: tlist.h:700
M0_INTERNAL void * m0_param_get(const char *key)
Definition: param.c:44
struct m0_list_link * l_head
Definition: list.h:76
#define M0_ASSERT(cond)
Definition: tlist.h:251
M0_INTERNAL void m0_param_source_add(struct m0_param_source *src)
Definition: param.c:56
M0_TL_DESCR_DEFINE(m0_param_sources, "m0_param_sources", static, struct m0_param_source, ps_link, ps_magic, M0_PARAM_SOURCE_MAGIC, M0_PARAM_SOURCES_MAGIC)
struct m0_tl i_param_sources
Definition: instance.h:105
#define m0_tl_for(name, head, obj)
Definition: tlist.h:695
M0_TL_DEFINE(m0_param_sources, M0_INTERNAL, struct m0_param_source)
static struct m0_tl * param_sources(void)
Definition: param.c:37
struct m0_pdclust_src_addr src
Definition: fd.c:108
Definition: idx_mock.c:47