In include/uapi/linux/tipc_config.h, there's a comment that it includes arpa/inet.h for ntohs; but ntohs is not defined in any UAPI header. For now, reuse the definitions from include/linux/byteorder/generic.h, since the various conversion functions do exist in UAPI headers: include/uapi/linux/byteorder/big_endian.h include/uapi/linux/byteorder/little_endian.h We would like to get to the point where we can build UAPI header tests with -nostdinc, meaning that kernel UAPI headers should not have a circular dependency on libc headers.
Showing the changes to include/uapi/linux (1 of 1 file). Show all
Unified · Split
| @@ -43,10 +43,6 @@ · 42 unmodified lines | ||
| 43 | 43 | #include <linux/tipc.h> |
| 44 | 44 | #include <asm/byteorder.h> |
| 45 | 45 | |
| 46 | −#ifndef __KERNEL__ | |
| 47 | −#include <arpa/inet.h> /* for ntohs etc. */ | |
| 48 | −#endif | |
| 49 | − | |
| 50 | 46 | /* |
| 51 | 47 | * Configuration |
| 52 | 48 | * |
| @@ -269,33 +265,33 @@ static inline int TLV_OK(const void *tlv, __u16 space) · 216 unmodified lines | ||
| 269 | 265 | */ |
| 270 | 266 | |
| 271 | 267 | return (space >= TLV_SPACE(0)) && |
| 272 | − (ntohs(((struct tlv_desc *)tlv)->tlv_len) <= space); | |
| 268 | + (__be16_to_cpu(((struct tlv_desc *)tlv)->tlv_len) <= space); | |
| 273 | 269 | } |
| 274 | 270 | |
| 275 | 271 | static inline int TLV_CHECK(const void *tlv, __u16 space, __u16 exp_type) |
| 276 | 272 | { |
| 277 | 273 | return TLV_OK(tlv, space) && |
| 278 | − (ntohs(((struct tlv_desc *)tlv)->tlv_type) == exp_type); | |
| 274 | + (__be16_to_cpu(((struct tlv_desc *)tlv)->tlv_type) == exp_type); | |
| 279 | 275 | } |
| 280 | 276 | |
| 281 | 277 | static inline int TLV_GET_LEN(struct tlv_desc *tlv) |
| 282 | 278 | { |
| 283 | − return ntohs(tlv->tlv_len); | |
| 279 | + return __be16_to_cpu(tlv->tlv_len); | |
| 284 | 280 | } |
| 285 | 281 | |
| 286 | 282 | static inline void TLV_SET_LEN(struct tlv_desc *tlv, __u16 len) |
| 287 | 283 | { |
| 288 | − tlv->tlv_len = htons(len); | |
| 284 | + tlv->tlv_len = __cpu_to_be16(len); | |
| 289 | 285 | } |
| 290 | 286 | |
| 291 | 287 | static inline int TLV_CHECK_TYPE(struct tlv_desc *tlv, __u16 type) |
| 292 | 288 | { |
| 293 | − return (ntohs(tlv->tlv_type) == type); | |
| 289 | + return (__be16_to_cpu(tlv->tlv_type) == type); | |
| 294 | 290 | } |
| 295 | 291 | |
| 296 | 292 | static inline void TLV_SET_TYPE(struct tlv_desc *tlv, __u16 type) |
| 297 | 293 | { |
| 298 | − tlv->tlv_type = htons(type); | |
| 294 | + tlv->tlv_type = __cpu_to_be16(type); | |
| 299 | 295 | } |
| 300 | 296 | |
| 301 | 297 | static inline int TLV_SET(void *tlv, __u16 type, void *data, __u16 len) |
| @@ -305,8 +301,8 @@ static inline int TLV_SET(void *tlv, __u16 type, void *data, __u16 len) · 3 unmodified lines | ||
| 305 | 301 | |
| 306 | 302 | tlv_len = TLV_LENGTH(len); |
| 307 | 303 | tlv_ptr = (struct tlv_desc *)tlv; |
| 308 | − tlv_ptr->tlv_type = htons(type); | |
| 309 | − tlv_ptr->tlv_len = htons(tlv_len); | |
| 304 | + tlv_ptr->tlv_type = __cpu_to_be16(type); | |
| 305 | + tlv_ptr->tlv_len = __cpu_to_be16(tlv_len); | |
| 310 | 306 | if (len && data) { |
| 311 | 307 | memcpy(TLV_DATA(tlv_ptr), data, len); |
| 312 | 308 | memset((char *)TLV_DATA(tlv_ptr) + len, 0, TLV_SPACE(len) - tlv_len); |
| @@ -348,7 +344,7 @@ static inline void *TLV_LIST_DATA(struct tlv_list_desc *list) · 35 unmodified lines | ||
| 348 | 344 | |
| 349 | 345 | static inline void TLV_LIST_STEP(struct tlv_list_desc *list) |
| 350 | 346 | { |
| 351 | − __u16 tlv_space = TLV_ALIGN(ntohs(list->tlv_ptr->tlv_len)); | |
| 347 | + __u16 tlv_space = TLV_ALIGN(__be16_to_cpu(list->tlv_ptr->tlv_len)); | |
| 352 | 348 | |
| 353 | 349 | list->tlv_ptr = (struct tlv_desc *)((char *)list->tlv_ptr + tlv_space); |
| 354 | 350 | list->tlv_space -= tlv_space; |
| @@ -404,9 +400,9 @@ static inline int TCM_SET(void *msg, __u16 cmd, __u16 flags, · 49 unmodified lines | ||
| 404 | 400 | |
| 405 | 401 | msg_len = TCM_LENGTH(data_len); |
| 406 | 402 | tcm_hdr = (struct tipc_cfg_msg_hdr *)msg; |
| 407 | − tcm_hdr->tcm_len = htonl(msg_len); | |
| 408 | − tcm_hdr->tcm_type = htons(cmd); | |
| 409 | − tcm_hdr->tcm_flags = htons(flags); | |
| 403 | + tcm_hdr->tcm_len = __cpu_to_be32(msg_len); | |
| 404 | + tcm_hdr->tcm_type = __cpu_to_be16(cmd); | |
| 405 | + tcm_hdr->tcm_flags = __cpu_to_be16(flags); | |
| 410 | 406 | if (data_len && data) { |
| 411 | 407 | memcpy(TCM_DATA(msg), data, data_len); |
| 412 | 408 | memset((char *)TCM_DATA(msg) + data_len, 0, TCM_SPACE(data_len) - msg_len); |