net/mlx4: separate device control functions
[dpdk.git] / drivers / net / mlx4 / mlx4_utils.h
index 9b178f5..0fbdc71 100644 (file)
@@ -34,6 +34,9 @@
 #ifndef MLX4_UTILS_H_
 #define MLX4_UTILS_H_
 
+#include <stddef.h>
+#include <stdio.h>
+
 #include <rte_common.h>
 #include <rte_log.h>
 
@@ -95,6 +98,12 @@ pmd_drv_log_basename(const char *s)
 #define WARN(...) PMD_DRV_LOG(WARNING, __VA_ARGS__)
 #define ERROR(...) PMD_DRV_LOG(ERR, __VA_ARGS__)
 
+/* Allocate a buffer on the stack and fill it with a printf format string. */
+#define MKSTR(name, ...) \
+       char name[snprintf(NULL, 0, __VA_ARGS__) + 1]; \
+       \
+       snprintf(name, sizeof(name), __VA_ARGS__)
+
 /* mlx4_utils.c */
 
 int mlx4_fd_set_non_blocking(int fd);