Whamcloud - gitweb
LU-6245 libcfs: create userland and kernel string operations
[fs/lustre-release.git] / lnet / include / lnet / nidstr.h
index b9e398e..fcfcbfb 100644 (file)
@@ -34,16 +34,29 @@ struct list_head;
 #define LNET_NIDSTR_COUNT  1024    /* # of nidstrings */
 #define LNET_NIDSTR_SIZE   32      /* size of each one (see below for usage) */
 
-/* support decl needed both by kernel and liblustre */
+/* support decl needed by both kernel and user space */
+char *libcfs_next_nidstring(void);
 int libcfs_isknown_lnd(__u32 lnd);
 char *libcfs_lnd2modname(__u32 lnd);
-char *libcfs_lnd2str(__u32 lnd);
 char *libcfs_lnd2str_r(__u32 lnd, char *buf, size_t buf_size);
+static inline char *libcfs_lnd2str(__u32 lnd)
+{
+       return libcfs_lnd2str_r(lnd, libcfs_next_nidstring(),
+                               LNET_NIDSTR_SIZE);
+}
 int libcfs_str2lnd(const char *str);
-char *libcfs_net2str(__u32 net);
 char *libcfs_net2str_r(__u32 net, char *buf, size_t buf_size);
-char *libcfs_nid2str(lnet_nid_t nid);
+static inline char *libcfs_net2str(__u32 net)
+{
+       return libcfs_net2str_r(net, libcfs_next_nidstring(),
+                               LNET_NIDSTR_SIZE);
+}
 char *libcfs_nid2str_r(lnet_nid_t nid, char *buf, size_t buf_size);
+static inline char *libcfs_nid2str(lnet_nid_t nid)
+{
+       return libcfs_nid2str_r(nid, libcfs_next_nidstring(),
+                               LNET_NIDSTR_SIZE);
+}
 __u32 libcfs_str2net(const char *str);
 lnet_nid_t libcfs_str2nid(const char *str);
 int libcfs_str2anynid(lnet_nid_t *nid, const char *str);
@@ -55,6 +68,5 @@ int cfs_match_nid(lnet_nid_t nid, struct list_head *list);
 bool cfs_nidrange_is_contiguous(struct list_head *nidlist);
 void cfs_nidrange_find_min_max(struct list_head *nidlist, char *min_nid,
                               char *max_nid, size_t nidstr_length);
-void libcfs_init_nidstrings(void);
 
 #endif /* _LNET_NIDSTRINGS_H */