1From f3e3e8fa703e88b76b22c5486277dfca3c85a24b Mon Sep 17 00:00:00 2001 2From: Khem Raj <raj.khem@gmail.com> 3Date: Mon, 10 Apr 2017 14:56:18 -0700 4Subject: [PATCH] Declare the define visivility attribute together 5 6clang ignores the visibility attribute if its not 7defined before the definition. As a result these 8symbols become hidden and consumers of this library 9fail to link due to these missing symbols 10 11Signed-off-by: Khem Raj <raj.khem@gmail.com> 12--- 13Upstream-Status: Pending 14 15 doxygen.cfg.in | 2 +- 16 src/internal.h | 5 ++--- 17 src/libnetfilter_acct.c | 41 ++++++++++++++--------------------------- 18 3 files changed, 17 insertions(+), 31 deletions(-) 19 20diff --git a/doxygen.cfg.in b/doxygen.cfg.in 21index 7f4bd04..fe64d48 100644 22--- a/doxygen.cfg.in 23+++ b/doxygen.cfg.in 24@@ -72,7 +72,7 @@ RECURSIVE = YES 25 EXCLUDE = 26 EXCLUDE_SYMLINKS = NO 27 EXCLUDE_PATTERNS = */.git/* .*.d 28-EXCLUDE_SYMBOLS = EXPORT_SYMBOL nfacct 29+EXCLUDE_SYMBOLS = nfacct 30 EXAMPLE_PATH = 31 EXAMPLE_PATTERNS = 32 EXAMPLE_RECURSIVE = NO 33diff --git a/src/internal.h b/src/internal.h 34index f0cc2e1..e5c5ffd 100644 35--- a/src/internal.h 36+++ b/src/internal.h 37@@ -3,10 +3,9 @@ 38 39 #include "config.h" 40 #ifdef HAVE_VISIBILITY_HIDDEN 41-# define __visible __attribute__((visibility("default"))) 42-# define EXPORT_SYMBOL(x) typeof(x) (x) __visible 43+# define __EXPORT __attribute__((visibility("default"))) 44 #else 45-# define EXPORT_SYMBOL 46+# define __EXPORT 47 #endif 48 49 #include <endian.h> 50diff --git a/src/libnetfilter_acct.c b/src/libnetfilter_acct.c 51index b0bcf67..0220d14 100644 52--- a/src/libnetfilter_acct.c 53+++ b/src/libnetfilter_acct.c 54@@ -76,21 +76,19 @@ struct nfacct { 55 * In case of success, this function returns a valid pointer, otherwise NULL 56 * s returned and errno is appropriately set. 57 */ 58-struct nfacct *nfacct_alloc(void) 59+struct nfacct __EXPORT *nfacct_alloc(void) 60 { 61 return calloc(1, sizeof(struct nfacct)); 62 } 63-EXPORT_SYMBOL(nfacct_alloc); 64 65 /** 66 * nfacct_free - release one accounting object 67 * \param nfacct pointer to the accounting object 68 */ 69-void nfacct_free(struct nfacct *nfacct) 70+void __EXPORT nfacct_free(struct nfacct *nfacct) 71 { 72 free(nfacct); 73 } 74-EXPORT_SYMBOL(nfacct_free); 75 76 /** 77 * nfacct_attr_set - set one attribute of the accounting object 78@@ -98,7 +96,7 @@ EXPORT_SYMBOL(nfacct_free); 79 * \param type attribute type you want to set 80 * \param data pointer to data that will be used to set this attribute 81 */ 82-void 83+void __EXPORT 84 nfacct_attr_set(struct nfacct *nfacct, enum nfacct_attr_type type, 85 const void *data) 86 { 87@@ -126,7 +124,6 @@ nfacct_attr_set(struct nfacct *nfacct, enum nfacct_attr_type type, 88 break; 89 } 90 } 91-EXPORT_SYMBOL(nfacct_attr_set); 92 93 /** 94 * nfacct_attr_set_str - set one attribute the accounting object 95@@ -134,13 +131,12 @@ EXPORT_SYMBOL(nfacct_attr_set); 96 * \param type attribute type you want to set 97 * \param name string that will be used to set this attribute 98 */ 99-void 100+void __EXPORT 101 nfacct_attr_set_str(struct nfacct *nfacct, enum nfacct_attr_type type, 102 const char *name) 103 { 104 nfacct_attr_set(nfacct, type, name); 105 } 106-EXPORT_SYMBOL(nfacct_attr_set_str); 107 108 /** 109 * nfacct_attr_set_u64 - set one attribute the accounting object 110@@ -148,20 +144,19 @@ EXPORT_SYMBOL(nfacct_attr_set_str); 111 * \param type attribute type you want to set 112 * \param value unsigned 64-bits integer 113 */ 114-void 115+void __EXPORT 116 nfacct_attr_set_u64(struct nfacct *nfacct, enum nfacct_attr_type type, 117 uint64_t value) 118 { 119 nfacct_attr_set(nfacct, type, &value); 120 } 121-EXPORT_SYMBOL(nfacct_attr_set_u64); 122 123 /** 124 * nfacct_attr_unset - unset one attribute the accounting object 125 * \param nfacct pointer to the accounting object 126 * \param type attribute type you want to set 127 */ 128-void 129+void __EXPORT 130 nfacct_attr_unset(struct nfacct *nfacct, enum nfacct_attr_type type) 131 { 132 switch(type) { 133@@ -182,7 +177,6 @@ nfacct_attr_unset(struct nfacct *nfacct, enum nfacct_attr_type type) 134 break; 135 } 136 } 137-EXPORT_SYMBOL(nfacct_attr_unset); 138 139 /** 140 * nfacct_attr_get - get one attribute the accounting object 141@@ -192,7 +186,7 @@ EXPORT_SYMBOL(nfacct_attr_unset); 142 * This function returns a valid pointer to the attribute data. If a 143 * unsupported attribute is used, this returns NULL. 144 */ 145-const void *nfacct_attr_get(struct nfacct *nfacct, enum nfacct_attr_type type) 146+const void __EXPORT *nfacct_attr_get(struct nfacct *nfacct, enum nfacct_attr_type type) 147 { 148 const void *ret = NULL; 149 150@@ -220,7 +214,6 @@ const void *nfacct_attr_get(struct nfacct *nfacct, enum nfacct_attr_type type) 151 } 152 return ret; 153 } 154-EXPORT_SYMBOL(nfacct_attr_get); 155 156 /** 157 * nfacct_attr_get_str - get one attribute the accounting object 158@@ -230,12 +223,11 @@ EXPORT_SYMBOL(nfacct_attr_get); 159 * This function returns a valid pointer to the beginning of the string. 160 * If the attribute is unsupported, this returns NULL. 161 */ 162-const char * 163+const char __EXPORT * 164 nfacct_attr_get_str(struct nfacct *nfacct, enum nfacct_attr_type type) 165 { 166 return nfacct_attr_get(nfacct, type); 167 } 168-EXPORT_SYMBOL(nfacct_attr_get_str); 169 170 /** 171 * nfacct_attr_get_u64 - get one attribute the accounting object 172@@ -245,12 +237,11 @@ EXPORT_SYMBOL(nfacct_attr_get_str); 173 * This function returns a unsigned 64-bits integer. If the attribute is 174 * unsupported, this returns NULL. 175 */ 176-uint64_t nfacct_attr_get_u64(struct nfacct *nfacct, enum nfacct_attr_type type) 177+uint64_t __EXPORT nfacct_attr_get_u64(struct nfacct *nfacct, enum nfacct_attr_type type) 178 { 179 const void *ret = nfacct_attr_get(nfacct, type); 180 return ret ? *((uint64_t *)ret) : 0; 181 } 182-EXPORT_SYMBOL(nfacct_attr_get_u64); 183 184 static int 185 nfacct_snprintf_plain(char *buf, size_t rem, struct nfacct *nfacct, 186@@ -424,8 +415,8 @@ err: 187 * This function returns -1 in case that some mandatory attributes are 188 * missing. On sucess, it returns 0. 189 */ 190-int nfacct_snprintf(char *buf, size_t size, struct nfacct *nfacct, 191- uint16_t type, uint16_t flags) 192+int __EXPORT nfacct_snprintf(char *buf, size_t size, struct nfacct *nfacct, 193+ uint16_t type, uint16_t flags) 194 { 195 int ret = 0; 196 197@@ -445,7 +436,6 @@ int nfacct_snprintf(char *buf, size_t size, struct nfacct *nfacct, 198 } 199 return ret; 200 } 201-EXPORT_SYMBOL(nfacct_snprintf); 202 203 /** 204 * @} 205@@ -484,7 +474,7 @@ EXPORT_SYMBOL(nfacct_snprintf); 206 * - Command NFNL_MSG_ACCT_DEL, to delete one specific nfacct object (if 207 * unused, otherwise you hit EBUSY). 208 */ 209-struct nlmsghdr * 210+struct nlmsghdr __EXPORT * 211 nfacct_nlmsg_build_hdr(char *buf, uint8_t cmd, uint16_t flags, uint32_t seq) 212 { 213 struct nlmsghdr *nlh; 214@@ -502,14 +492,13 @@ nfacct_nlmsg_build_hdr(char *buf, uint8_t cmd, uint16_t flags, uint32_t seq) 215 216 return nlh; 217 } 218-EXPORT_SYMBOL(nfacct_nlmsg_build_hdr); 219 220 /** 221 * nfacct_nlmsg_build_payload - build payload from accounting object 222 * \param nlh: netlink message that you want to use to add the payload. 223 * \param nfacct: pointer to a accounting object 224 */ 225-void nfacct_nlmsg_build_payload(struct nlmsghdr *nlh, struct nfacct *nfacct) 226+void __EXPORT nfacct_nlmsg_build_payload(struct nlmsghdr *nlh, struct nfacct *nfacct) 227 { 228 if (nfacct->bitset & (1 << NFACCT_ATTR_NAME)) 229 mnl_attr_put_strz(nlh, NFACCT_NAME, nfacct->name); 230@@ -526,7 +515,6 @@ void nfacct_nlmsg_build_payload(struct nlmsghdr *nlh, struct nfacct *nfacct) 231 if (nfacct->bitset & (1 << NFACCT_ATTR_QUOTA)) 232 mnl_attr_put_u64(nlh, NFACCT_QUOTA, htobe64(nfacct->quota)); 233 } 234-EXPORT_SYMBOL(nfacct_nlmsg_build_payload); 235 236 static int nfacct_nlmsg_parse_attr_cb(const struct nlattr *attr, void *data) 237 { 238@@ -563,7 +551,7 @@ static int nfacct_nlmsg_parse_attr_cb(const struct nlattr *attr, void *data) 239 * This function returns -1 in case that some mandatory attributes are 240 * missing. On sucess, it returns 0. 241 */ 242-int 243+int __EXPORT 244 nfacct_nlmsg_parse_payload(const struct nlmsghdr *nlh, struct nfacct *nfacct) 245 { 246 struct nlattr *tb[NFACCT_MAX+1] = {}; 247@@ -589,7 +577,6 @@ nfacct_nlmsg_parse_payload(const struct nlmsghdr *nlh, struct nfacct *nfacct) 248 249 return 0; 250 } 251-EXPORT_SYMBOL(nfacct_nlmsg_parse_payload); 252 253 /** 254 * @} 255-- 2562.12.2 257 258