aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2021-04-19 21:44:21 +0200
committerDamjan Marion <damarion@cisco.com>2021-04-19 21:45:09 +0200
commit6db633bde1dc5f89f7c8b434dc95dc225672b277 (patch)
tree30218015a8d2374bb2d34131756980464c045076 /src
parentac6c528fb22d427d7beacd73c247ffd97389dbfe (diff)
vppinfra: momve clib_sysfs_list_to_bitmap to sysfs.c
Type: refactor Change-Id: Ia5a7ebd5c8492326f5bf2f1264f1c5ef38ccb4dc Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/vlib/threads.c27
-rw-r--r--src/vppinfra/linux/sysfs.c27
-rw-r--r--src/vppinfra/linux/sysfs.h2
3 files changed, 29 insertions, 27 deletions
diff --git a/src/vlib/threads.c b/src/vlib/threads.c
index 278838798a9..f3a66437478 100644
--- a/src/vlib/threads.c
+++ b/src/vlib/threads.c
@@ -166,33 +166,6 @@ sort_registrations_by_no_clone (void *a0, void *a1)
- ((i32) ((*tr1)->no_data_structure_clone)));
}
-static uword *
-clib_sysfs_list_to_bitmap (char *filename)
-{
- FILE *fp;
- uword *r = 0;
-
- fp = fopen (filename, "r");
-
- if (fp != NULL)
- {
- u8 *buffer = 0;
- vec_validate (buffer, 256 - 1);
- if (fgets ((char *) buffer, 256, fp))
- {
- unformat_input_t in;
- unformat_init_string (&in, (char *) buffer,
- strlen ((char *) buffer));
- if (unformat (&in, "%U", unformat_bitmap_list, &r) != 1)
- clib_warning ("unformat_bitmap_list failed");
- unformat_free (&in);
- }
- vec_free (buffer);
- fclose (fp);
- }
- return r;
-}
-
/* Called early in the init sequence */
diff --git a/src/vppinfra/linux/sysfs.c b/src/vppinfra/linux/sysfs.c
index 1157e4fe655..758eaa1a86c 100644
--- a/src/vppinfra/linux/sysfs.c
+++ b/src/vppinfra/linux/sysfs.c
@@ -16,6 +16,7 @@
#include <vppinfra/clib.h>
#include <vppinfra/clib_error.h>
#include <vppinfra/format.h>
+#include <vppinfra/bitmap.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -262,6 +263,32 @@ clib_sysfs_prealloc_hugepages (int numa_node, int log2_page_size, int nr)
return clib_sysfs_set_nr_hugepages (numa_node, log2_page_size, n + needed);
}
+__clib_export uword *
+clib_sysfs_list_to_bitmap (char *filename)
+{
+ FILE *fp;
+ uword *r = 0;
+
+ fp = fopen (filename, "r");
+
+ if (fp != NULL)
+ {
+ u8 *buffer = 0;
+ vec_validate (buffer, 256 - 1);
+ if (fgets ((char *) buffer, 256, fp))
+ {
+ unformat_input_t in;
+ unformat_init_string (&in, (char *) buffer,
+ strlen ((char *) buffer));
+ if (unformat (&in, "%U", unformat_bitmap_list, &r) != 1)
+ clib_warning ("unformat_bitmap_list failed");
+ unformat_free (&in);
+ }
+ vec_free (buffer);
+ fclose (fp);
+ }
+ return r;
+}
/*
* fd.io coding-style-patch-verification: ON
diff --git a/src/vppinfra/linux/sysfs.h b/src/vppinfra/linux/sysfs.h
index 5f5eec2d07a..9cbc34823dd 100644
--- a/src/vppinfra/linux/sysfs.h
+++ b/src/vppinfra/linux/sysfs.h
@@ -35,6 +35,8 @@ clib_error_t *clib_sysfs_get_surplus_hugepages (int numa_node,
clib_error_t *clib_sysfs_prealloc_hugepages (int numa_node,
int log2_page_size, int nr);
+uword *clib_sysfs_list_to_bitmap (char *filename);
+
#endif /* included_linux_sysfs_h */
/*