libmemif: ubuntu 18.04 build fix
Change-Id: I6624cacd625eea6a9b8214f67d14ec162e2c0195 Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com>
This commit is contained in:
@ -7,6 +7,8 @@ AC_PREFIX_DEFAULT([/usr])
|
|||||||
PKG_CHECK_MODULES([CHECK], [check], [HAVE_CHECK=1], [HAVE_CHECK=0])
|
PKG_CHECK_MODULES([CHECK], [check], [HAVE_CHECK=1], [HAVE_CHECK=0])
|
||||||
AM_CONDITIONAL([USE_CHECK],[test "$HAVE_CHECK" -eq 1])
|
AM_CONDITIONAL([USE_CHECK],[test "$HAVE_CHECK" -eq 1])
|
||||||
|
|
||||||
|
AC_CHECK_FUNC([memfd_create], [AC_DEFINE([HAVE_MEMFD_CREATE], [1], [Define if memfd exists])])
|
||||||
|
|
||||||
AC_PROG_CC
|
AC_PROG_CC
|
||||||
|
|
||||||
AC_OUTPUT([Makefile])
|
AC_OUTPUT([Makefile])
|
||||||
|
@ -169,7 +169,7 @@ typedef struct
|
|||||||
|
|
||||||
memif_interface_id_t interface_id;
|
memif_interface_id_t interface_id;
|
||||||
uint8_t interface_name[32];
|
uint8_t interface_name[32];
|
||||||
uint8_t instance_name[32];
|
uint8_t instance_name[32]; /*!< deprecated, will be removed in 2.0 */
|
||||||
memif_interface_mode_t mode:8;
|
memif_interface_mode_t mode:8;
|
||||||
} memif_conn_args_t;
|
} memif_conn_args_t;
|
||||||
|
|
||||||
@ -308,7 +308,7 @@ int memif_get_details (memif_conn_handle_t conn, memif_details_t * md,
|
|||||||
|
|
||||||
/** \brief Memif initialization
|
/** \brief Memif initialization
|
||||||
@param on_control_fd_update - if control fd updates inform user to watch new fd
|
@param on_control_fd_update - if control fd updates inform user to watch new fd
|
||||||
@param app_name - application name
|
@param app_name - application name (will be truncated to 32 chars)
|
||||||
|
|
||||||
if param on_control_fd_update is set to NULL,
|
if param on_control_fd_update is set to NULL,
|
||||||
libmemif will handle file descriptor event polling
|
libmemif will handle file descriptor event polling
|
||||||
|
@ -406,17 +406,16 @@ memif_init (memif_control_fd_update_t * on_control_fd_update, char *app_name)
|
|||||||
{
|
{
|
||||||
int err = MEMIF_ERR_SUCCESS; /* 0 */
|
int err = MEMIF_ERR_SUCCESS; /* 0 */
|
||||||
libmemif_main_t *lm = &libmemif_main;
|
libmemif_main_t *lm = &libmemif_main;
|
||||||
|
memset (lm, 0, sizeof (libmemif_main_t));
|
||||||
|
|
||||||
if (app_name)
|
if (app_name)
|
||||||
{
|
{
|
||||||
lm->app_name = malloc (strlen (app_name) + sizeof (char));
|
uint8_t len = (strlen (app_name) < MEMIF_NAME_LEN)
|
||||||
memset (lm->app_name, 0, strlen (app_name) + sizeof (char));
|
? MEMIF_NAME_LEN : strlen (app_name);
|
||||||
strncpy ((char *) lm->app_name, app_name, strlen (app_name));
|
strncpy ((char *) lm->app_name, app_name, strlen (app_name));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lm->app_name = malloc (strlen (MEMIF_DEFAULT_APP_NAME) + sizeof (char));
|
|
||||||
memset (lm->app_name, 0, strlen (app_name) + sizeof (char));
|
|
||||||
strncpy ((char *) lm->app_name, MEMIF_DEFAULT_APP_NAME,
|
strncpy ((char *) lm->app_name, MEMIF_DEFAULT_APP_NAME,
|
||||||
strlen (MEMIF_DEFAULT_APP_NAME));
|
strlen (MEMIF_DEFAULT_APP_NAME));
|
||||||
}
|
}
|
||||||
@ -438,8 +437,6 @@ memif_init (memif_control_fd_update_t * on_control_fd_update, char *app_name)
|
|||||||
DBG ("libmemif event polling initialized");
|
DBG ("libmemif event polling initialized");
|
||||||
}
|
}
|
||||||
|
|
||||||
memset (&lm->ms, 0, sizeof (memif_socket_t));
|
|
||||||
|
|
||||||
lm->control_list_len = 2;
|
lm->control_list_len = 2;
|
||||||
lm->interrupt_list_len = 2;
|
lm->interrupt_list_len = 2;
|
||||||
lm->listener_list_len = 1;
|
lm->listener_list_len = 1;
|
||||||
@ -490,7 +487,6 @@ memif_init (memif_control_fd_update_t * on_control_fd_update, char *app_name)
|
|||||||
lm->arm.it_value.tv_nsec = 0;
|
lm->arm.it_value.tv_nsec = 0;
|
||||||
lm->arm.it_interval.tv_sec = 2;
|
lm->arm.it_interval.tv_sec = 2;
|
||||||
lm->arm.it_interval.tv_nsec = 0;
|
lm->arm.it_interval.tv_nsec = 0;
|
||||||
memset (&lm->disarm, 0, sizeof (lm->disarm));
|
|
||||||
|
|
||||||
if (lm->control_fd_update (lm->timerfd, MEMIF_FD_EVENT_READ) < 0)
|
if (lm->control_fd_update (lm->timerfd, MEMIF_FD_EVENT_READ) < 0)
|
||||||
{
|
{
|
||||||
@ -2096,9 +2092,6 @@ int
|
|||||||
memif_cleanup ()
|
memif_cleanup ()
|
||||||
{
|
{
|
||||||
libmemif_main_t *lm = &libmemif_main;
|
libmemif_main_t *lm = &libmemif_main;
|
||||||
if (lm->app_name)
|
|
||||||
free (lm->app_name);
|
|
||||||
lm->app_name = NULL;
|
|
||||||
if (lm->control_list)
|
if (lm->control_list)
|
||||||
free (lm->control_list);
|
free (lm->control_list);
|
||||||
lm->control_list = NULL;
|
lm->control_list = NULL;
|
||||||
|
@ -26,9 +26,14 @@
|
|||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <sys/timerfd.h>
|
#include <sys/timerfd.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include <libmemif.h>
|
#include <libmemif.h>
|
||||||
|
|
||||||
|
#define MEMIF_NAME_LEN 32
|
||||||
|
_Static_assert (strlen (MEMIF_DEFAULT_APP_NAME) <= MEMIF_NAME_LEN,
|
||||||
|
"MEMIF_DEFAULT_APP_NAME max length is 32");
|
||||||
|
|
||||||
#define MEMIF_DEFAULT_SOCKET_DIR "/run/vpp"
|
#define MEMIF_DEFAULT_SOCKET_DIR "/run/vpp"
|
||||||
#define MEMIF_DEFAULT_SOCKET_FILENAME "memif.sock"
|
#define MEMIF_DEFAULT_SOCKET_FILENAME "memif.sock"
|
||||||
#define MEMIF_DEFAULT_RING_SIZE 1024
|
#define MEMIF_DEFAULT_RING_SIZE 1024
|
||||||
@ -142,8 +147,8 @@ typedef struct memif_connection
|
|||||||
/* connection message queue */
|
/* connection message queue */
|
||||||
memif_msg_queue_elt_t *msg_queue;
|
memif_msg_queue_elt_t *msg_queue;
|
||||||
|
|
||||||
uint8_t remote_if_name[32];
|
uint8_t remote_if_name[MEMIF_NAME_LEN];
|
||||||
uint8_t remote_name[32];
|
uint8_t remote_name[MEMIF_NAME_LEN];
|
||||||
uint8_t remote_disconnect_string[96];
|
uint8_t remote_disconnect_string[96];
|
||||||
|
|
||||||
memif_region_t *regions;
|
memif_region_t *regions;
|
||||||
@ -186,7 +191,7 @@ typedef struct
|
|||||||
int timerfd;
|
int timerfd;
|
||||||
struct itimerspec arm, disarm;
|
struct itimerspec arm, disarm;
|
||||||
uint16_t disconn_slaves;
|
uint16_t disconn_slaves;
|
||||||
uint8_t *app_name;
|
uint8_t app_name[MEMIF_NAME_LEN];
|
||||||
|
|
||||||
/* master implementation... */
|
/* master implementation... */
|
||||||
memif_socket_t ms;
|
memif_socket_t ms;
|
||||||
@ -237,11 +242,13 @@ int free_list_elt (memif_list_elt_t * list, uint16_t len, int key);
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_MEMFD_CREATE
|
||||||
static inline int
|
static inline int
|
||||||
memfd_create (const char *name, unsigned int flags)
|
memfd_create (const char *name, unsigned int flags)
|
||||||
{
|
{
|
||||||
return syscall (__NR_memfd_create, name, flags);
|
return syscall (__NR_memfd_create, name, flags);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static inline void *
|
static inline void *
|
||||||
memif_get_buffer (memif_connection_t * conn, memif_ring_t * ring,
|
memif_get_buffer (memif_connection_t * conn, memif_ring_t * ring,
|
||||||
@ -254,7 +261,12 @@ memif_get_buffer (memif_connection_t * conn, memif_ring_t * ring,
|
|||||||
#ifndef F_LINUX_SPECIFIC_BASE
|
#ifndef F_LINUX_SPECIFIC_BASE
|
||||||
#define F_LINUX_SPECIFIC_BASE 1024
|
#define F_LINUX_SPECIFIC_BASE 1024
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef MFD_ALLOW_SEALING
|
||||||
#define MFD_ALLOW_SEALING 0x0002U
|
#define MFD_ALLOW_SEALING 0x0002U
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef F_ADD_SEALS
|
||||||
#define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9)
|
#define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9)
|
||||||
#define F_GET_SEALS (F_LINUX_SPECIFIC_BASE + 10)
|
#define F_GET_SEALS (F_LINUX_SPECIFIC_BASE + 10)
|
||||||
|
|
||||||
@ -262,5 +274,6 @@ memif_get_buffer (memif_connection_t * conn, memif_ring_t * ring,
|
|||||||
#define F_SEAL_SHRINK 0x0002 /* prevent file from shrinking */
|
#define F_SEAL_SHRINK 0x0002 /* prevent file from shrinking */
|
||||||
#define F_SEAL_GROW 0x0004 /* prevent file from growing */
|
#define F_SEAL_GROW 0x0004 /* prevent file from growing */
|
||||||
#define F_SEAL_WRITE 0x0008 /* prevent writes */
|
#define F_SEAL_WRITE 0x0008 /* prevent writes */
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif /* _MEMIF_PRIVATE_H_ */
|
#endif /* _MEMIF_PRIVATE_H_ */
|
||||||
|
Reference in New Issue
Block a user