util: resource: Add new is_resource_attr_interested function 85/276985/4
authorChanwoo Choi <cw00.choi@samsung.com>
Wed, 29 Jun 2022 01:44:08 +0000 (10:44 +0900)
committerDongwoo Lee <dwoo08.lee@samsung.com>
Wed, 29 Jun 2022 10:12:35 +0000 (19:12 +0900)
Provide is_resource_attr_interested function to check whether
some attribute id is already interested or not. It will be
used as internal function for libpass-resource-monitor
and capi-resource-monitor.

Change-Id: I1cdac2eab2672869cfa98069fc7d958c4da4dc93
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
include/util/resource.h
src/util/resource.c

index 97a1b93..4934cc4 100644 (file)
@@ -199,6 +199,7 @@ int get_resource_attr_ptr(struct resource *resource, u_int64_t attr_id, void **d
 
 int set_resource_attr_interest(struct resource *resource, u_int64_t interest_mask);
 int unset_resource_attr_interest(struct resource *resource, u_int64_t interest_mask);
+bool is_resource_attr_interested(struct resource *resource, u_int64_t interest_mask);
 
 inline __attribute__((always_inline)) int64_t get_time_now(void)
 {
index 9c2233d..4543981 100644 (file)
@@ -943,3 +943,14 @@ int unset_resource_attr_interest(struct resource *resource, u_int64_t interest_m
 
        return 0;
 }
+
+bool is_resource_attr_interested(struct resource *resource, u_int64_t interest_mask)
+{
+       if (!resource)
+               return false;
+
+       if (resource->attr_interest != (resource->attr_interest | interest_mask))
+               return false;
+
+       return true;
+}