blob: fd314bfee5848520dd94adfe099b4c1d0eb1fdcc [file] [log] [blame]
Patrick Williamsb48b7b42016-08-17 15:04:38 -05001By default, gcc-5 uses C99 inline semantics, this semantics doesn't
2generate externally visible function for inline functions. This results in
3below error, when an another translation unit (TU) tries to link with the
4inline function,
5
6-- snip --
7| lsuio.o: In function `main':
8| <...>/libuio/0.2.1-r0/git/tools/lsuio.c:85: undefined reference to `uio_mmap'
9| collect2: error: ld returned 1 exit status
10| make[2]: *** [lsuio] Error 1
11-- CUT --
12
13To solve this error and make libuio to compile with both 4.x and 5.x,
14
151. We can remove 'uio_mmap' inline function definition in uio_mmap.c, and move
16 that definition into uio_helper.h file (which is included by lsuio.c) and
17 replace inline with "static inline". Similarly it can be done to other
18 uio_single_munmap and uio_munmap inline functions
19
202. Add 'extern' keyword in front of inline functions declaration, to make
21 inlined function as externally visible function, and to link with other TUs.
22
23Going with option 1.
24
25Upstream-Status: Pending
26
27Signed-off-by: Jagadeesh Krishnanjanappa <jkrishnanjanappa@mvista.com>
28
29--- git_org/src/uio_helper.h 2015-10-20 02:37:04.183075855 -0400
30+++ git/src/uio_helper.h 2015-10-20 03:34:24.659970136 -0400
31@@ -61,11 +61,11 @@ struct uio_info_t {
32
33 /* function prototypes */
34
35-inline char* uio_lib_name(void);
36-inline char* uio_lib_version(void);
37-inline int uio_lib_ifcurrent(void);
38-inline int uio_lib_ifrevision(void);
39-inline int uio_lib_ifage(void);
40+static inline char* uio_lib_name(void);
41+static inline char* uio_lib_version(void);
42+static inline int uio_lib_ifcurrent(void);
43+static inline int uio_lib_ifrevision(void);
44+static inline int uio_lib_ifage(void);
45
46 int uio_get_mem_size(struct uio_info_t* info, int map_num);
47 int uio_get_mem_addr(struct uio_info_t* info, int map_num);
48@@ -76,10 +76,30 @@ int uio_get_all_info(struct uio_info_t*
49 int uio_get_device_attributes(struct uio_info_t* info);
50
51 void* uio_single_mmap(struct uio_info_t* info, int map_num, int fd);
52-inline void uio_mmap(struct uio_info_t* info, int fd);
53
54-inline void uio_single_munmap(struct uio_info_t* info, int map_num);
55-inline void uio_munmap(struct uio_info_t* info);
56+static inline void uio_mmap(struct uio_info_t* info, int fd);
57+static inline void uio_mmap(struct uio_info_t* info, int fd)
58+{
59+ int map_num;
60+ if (!fd) return;
61+ for (map_num= 0; map_num < MAX_UIO_MAPS; map_num++)
62+ uio_single_mmap(info, map_num, fd);
63+}
64+
65+static inline void uio_single_munmap(struct uio_info_t* info, int map_num);
66+static inline void uio_single_munmap(struct uio_info_t* info, int map_num)
67+{
68+ munmap(info->maps[map_num].internal_addr, info->maps[map_num].size);
69+ info->maps[map_num].mmap_result = UIO_MMAP_NOT_DONE;
70+}
71+
72+static inline void uio_munmap(struct uio_info_t* info);
73+static inline void uio_munmap(struct uio_info_t* info)
74+{
75+ int i;
76+ for (i = 0; i < MAX_UIO_MAPS; i++)
77+ uio_single_munmap(info, i);
78+}
79
80 void uio_free_dev_attrs(struct uio_info_t* info);
81 void uio_free_info(struct uio_info_t* info);
82--- git_org/src/uio_mmap.c 2015-10-20 02:37:04.183075855 -0400
83+++ git/src/uio_mmap.c 2015-10-20 03:34:45.060003208 -0400
84@@ -22,11 +22,3 @@
85 #include <stdlib.h>
86
87 #include "uio_helper.h"
88-
89-inline void uio_mmap(struct uio_info_t* info, int fd)
90-{
91- int map_num;
92- if (!fd) return;
93- for (map_num= 0; map_num < MAX_UIO_MAPS; map_num++)
94- uio_single_mmap(info, map_num, fd);
95-}
96--- git_org/src/uio_munmap.c 2015-10-20 02:37:04.183075855 -0400
97+++ git/src/uio_munmap.c 2015-10-20 03:34:59.636026835 -0400
98@@ -22,10 +22,3 @@
99 #include <stdlib.h>
100
101 #include "uio_helper.h"
102-
103-inline void uio_munmap(struct uio_info_t* info)
104-{
105- int i;
106- for (i = 0; i < MAX_UIO_MAPS; i++)
107- uio_single_munmap(info, i);
108-}
109\ No newline at end of file
110--- git_org/src/uio_single_munmap.c 2015-10-20 02:37:04.183075855 -0400
111+++ git/src/uio_single_munmap.c 2015-10-20 03:52:55.005763023 -0400
112@@ -24,9 +24,3 @@
113 #include <sys/mman.h>
114
115 #include "uio_helper.h"
116-
117-inline void uio_single_munmap(struct uio_info_t* info, int map_num)
118-{
119- munmap(info->maps[map_num].internal_addr, info->maps[map_num].size);
120- info->maps[map_num].mmap_result = UIO_MMAP_NOT_DONE;
121-}