Skip to content

Commit eae6659

Browse files
committed
FIFO -> linked list + socket.c test
1 parent c436306 commit eae6659

18 files changed

+502
-1572
lines changed

Makefile.am

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,32 +16,18 @@ AUTOMAKE_OPTIONS = foreign subdir-objects
1616
ACLOCAL_AMFLAGS = -I m4
1717

1818
#
19-
# utils lib
19+
# unit_test
2020
#
21-
libutils_la_SOURCES = src/vector/vec.c src/fifo/fifo.c
22-
libutils_la_CPPFLAGS = $(AM_CPPFLAGS) -Isrc/vector -Isrc/fifo
23-
24-
25-
#
26-
# utils test
27-
#
28-
utils_test_SOURCES = test/utils_test.c test/vec_test.c test/fifo_test.c
29-
utils_test_LDADD = libutils.la
30-
utils_test_CPPFLAGS = $(AM_CPPFLAGS) -Isrc/vector -Isrc/fifo -Itest
31-
32-
#
33-
# perf test
34-
#
35-
perf_test_SOURCES = test/perform/pt.c
36-
perf_test_LDADD = libutils.la
37-
perf_test_CPPFLAGS = $(AM_CPPFLAGS) -Isrc/vector -Isrc/fifo -Itest/perform
21+
unit_test_SOURCES = test/socket_test.c test/unit_test.c src/socket.c
22+
# macro MEMIF_UNIT_TEST -> compile functions without static keyword
23+
# and declare them in header files, so they can be called from unit tests
24+
unit_test_CPPFLAGS = $(AM_CPPFLAGS) -Itest -Isrc -DMEMIF_UNIT_TEST
3825

3926
#
4027
# main lib
4128
#
4229
libmemif_la_SOURCES = src/main.c src/socket.c
43-
libmemif_la_LIBADD = libutils.la
44-
libmemif_la_CPPFLAGS = $(AM_CPPFLAGS) -Isrc -Isrc/vector -Isrc/fifo
30+
libmemif_la_CPPFLAGS = $(AM_CPPFLAGS) -Isrc
4531

4632
#
4733
# ICMP responder example
@@ -50,12 +36,12 @@ icmp_responder_SOURCES = examples/icmp_responder/main.c
5036
icmp_responder_LDADD = libmemif.la
5137
icmp_responder_CPPFLAGS = $(AM_CPPFLAGS) -Isrc
5238

53-
noinst_PROGRAMS = icmp_responder perf_test
39+
noinst_PROGRAMS = icmp_responder
5440

55-
check_PROGRAMS = utils_test
41+
check_PROGRAMS = unit_test
5642

5743
include_HEADERS = src/libmemif.h
5844

59-
lib_LTLIBRARIES = libutils.la libmemif.la
45+
lib_LTLIBRARIES = libmemif.la
6046

6147
TESTS = $(check_PROGRAMS)

src/fifo/fifo.c

Lines changed: 0 additions & 68 deletions
This file was deleted.

src/fifo/fifo.h

Lines changed: 0 additions & 53 deletions
This file was deleted.

src/libmemif.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@ int memif_control_fd_handler (memif_conn_handle_t conn, int fd);
5454
/* disconnect session (free memory, close file descriptors, unmap shared memory) */
5555
int memif_disconnect (memif_conn_handle_t conn);
5656

57-
#endif
57+
#endif /* _LIBMEMIF_H_ */

src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include <stdint.h>
1919

2020
/* memif protocol msg, ring and descriptor definitions */
21-
#include <memif_proto.h>
21+
#include <memif.h>
2222
/* memif api */
2323
#include <libmemif.h>
2424
/* socket messaging functions */

src/memif_private.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@
2222
#define _GNU_SOURCE
2323
#include <unistd.h>
2424
#include <sys/syscall.h>
25+
#include <stdint.h>
26+
#include <inttypes.h>
27+
#include <limits.h>
2528

2629
#include <libmemif.h>
27-
#include <fifo.h>
2830

2931
#define MEMIF_DEFAULT_SOCKET_DIR "/run/vpp"
3032
#define MEMIF_DEFAULT_SOCKET_FILENAME "memif.sock"
@@ -59,7 +61,7 @@
5961
#else
6062
#define DBG(...)
6163
#define DBG_UNIX(...)
62-
#endif
64+
#endif /* MEMIF_DEBUG */
6365

6466
#define error_return_unix(...) do { \
6567
DBG_UNIX(__VA_ARGS__); \
@@ -92,11 +94,12 @@ typedef struct
9294
uint64_t int_count;
9395
} memif_queue_t;
9496

95-
typedef struct
97+
typedef struct memif_msg_queue_elt
9698
{
9799
memif_msg_t msg;
98100
int fd;
99-
} memif_msg_fifo_elt_t;
101+
struct memif_msg_queue_elt *next;
102+
} memif_msg_queue_elt_t;
100103

101104
struct memif_connection;
102105

@@ -114,7 +117,7 @@ typedef struct memif_connection
114117
memif_fn *write_fn, *read_fn, *error_fn;
115118

116119
/* connection message queue */
117-
memif_fifo_t msg_queue;
120+
memif_msg_queue_elt_t *msg_queue;
118121

119122
uint8_t remote_if_name[32];
120123
uint8_t remote_name[32];
@@ -169,4 +172,4 @@ memif_get_buffer (memif_connection_t *conn, memif_ring_t *ring, uint16_t index)
169172
#define F_SEAL_GROW 0x0004 /* prevent file from growing */
170173
#define F_SEAL_WRITE 0x0008 /* prevent writes */
171174

172-
#endif
175+
#endif /* _MEMIF_PRIVATE_H_ */

0 commit comments

Comments
 (0)