With 78, 111 and 85 bytes respectively (on x86-64), the functions iwe_stream_add_event(), iwe_stream_add_point() and iwe_stream_add_value() really shouldn't be inlines. It appears that at least my compiler already decided the same, and created a single instance of each one of them for each file using it, but that's still a number of instances in the system overall, which this reduces.
Unified · Split
| @@ -505,25 +505,8 @@ static inline int iwe_stream_event_len_adjust(struct iw_request_info *info, · 504 unmodified lines | |||
| 505 | /* | 505 | /* |
| 506 | * Wrapper to add an Wireless Event to a stream of events. | 506 | * Wrapper to add an Wireless Event to a stream of events. |
| 507 | */ | 507 | */ |
| 508 | static inline char * | 508 | char *iwe_stream_add_event(struct iw_request_info *info, char *stream, |
| 509 | iwe_stream_add_event(struct iw_request_info *info, char *stream, char *ends, | 509 | char *ends, struct iw_event *iwe, int event_len); |
| 510 | struct iw_event *iwe, int event_len) | ||
| 511 | { | ||
| 512 | int lcp_len = iwe_stream_lcp_len(info); | ||
| 513 | |||
| 514 | event_len = iwe_stream_event_len_adjust(info, event_len); | ||
| 515 | |||
| 516 | /* Check if it's possible */ | ||
| 517 | if(likely((stream + event_len) < ends)) { | ||
| 518 | iwe->len = event_len; | ||
| 519 | /* Beware of alignement issues on 64 bits */ | ||
| 520 | memcpy(stream, (char *) iwe, IW_EV_LCP_PK_LEN); | ||
| 521 | memcpy(stream + lcp_len, &iwe->u, | ||
| 522 | event_len - lcp_len); | ||
| 523 | stream += event_len; | ||
| 524 | } | ||
| 525 | return stream; | ||
| 526 | } | ||
| 527 | 510 | ||
| 528 | static inline char * | 511 | static inline char * |
| 529 | iwe_stream_add_event_check(struct iw_request_info *info, char *stream, | 512 | iwe_stream_add_event_check(struct iw_request_info *info, char *stream, |
| @@ -541,27 +524,8 @@ iwe_stream_add_event_check(struct iw_request_info *info, char *stream, · 11 unmodified lines | |||
| 541 | * Wrapper to add an short Wireless Event containing a pointer to a | 524 | * Wrapper to add an short Wireless Event containing a pointer to a |
| 542 | * stream of events. | 525 | * stream of events. |
| 543 | */ | 526 | */ |
| 544 | static inline char * | 527 | char *iwe_stream_add_point(struct iw_request_info *info, char *stream, |
| 545 | iwe_stream_add_point(struct iw_request_info *info, char *stream, char *ends, | 528 | char *ends, struct iw_event *iwe, char *extra); |
| 546 | struct iw_event *iwe, char *extra) | ||
| 547 | { | ||
| 548 | int event_len = iwe_stream_point_len(info) + iwe->u.data.length; | ||
| 549 | int point_len = iwe_stream_point_len(info); | ||
| 550 | int lcp_len = iwe_stream_lcp_len(info); | ||
| 551 | |||
| 552 | /* Check if it's possible */ | ||
| 553 | if(likely((stream + event_len) < ends)) { | ||
| 554 | iwe->len = event_len; | ||
| 555 | memcpy(stream, (char *) iwe, IW_EV_LCP_PK_LEN); | ||
| 556 | memcpy(stream + lcp_len, | ||
| 557 | ((char *) &iwe->u) + IW_EV_POINT_OFF, | ||
| 558 | IW_EV_POINT_PK_LEN - IW_EV_LCP_PK_LEN); | ||
| 559 | if (iwe->u.data.length && extra) | ||
| 560 | memcpy(stream + point_len, extra, iwe->u.data.length); | ||
| 561 | stream += event_len; | ||
| 562 | } | ||
| 563 | return stream; | ||
| 564 | } | ||
| 565 | 529 | ||
| 566 | static inline char * | 530 | static inline char * |
| 567 | iwe_stream_add_point_check(struct iw_request_info *info, char *stream, | 531 | iwe_stream_add_point_check(struct iw_request_info *info, char *stream, |
| @@ -580,25 +544,8 @@ iwe_stream_add_point_check(struct iw_request_info *info, char *stream, · 12 unmodified lines | |||
| 580 | * Be careful, this one is tricky to use properly : | 544 | * Be careful, this one is tricky to use properly : |
| 581 | * At the first run, you need to have (value = event + IW_EV_LCP_LEN). | 545 | * At the first run, you need to have (value = event + IW_EV_LCP_LEN). |
| 582 | */ | 546 | */ |
| 583 | static inline char * | 547 | char *iwe_stream_add_value(struct iw_request_info *info, char *event, |
| 584 | iwe_stream_add_value(struct iw_request_info *info, char *event, char *value, | 548 | char *value, char *ends, struct iw_event *iwe, |
| 585 | char *ends, struct iw_event *iwe, int event_len) | 549 | int event_len); |
| 586 | { | ||
| 587 | int lcp_len = iwe_stream_lcp_len(info); | ||
| 588 | |||
| 589 | /* Don't duplicate LCP */ | ||
| 590 | event_len -= IW_EV_LCP_LEN; | ||
| 591 | |||
| 592 | /* Check if it's possible */ | ||
| 593 | if(likely((value + event_len) < ends)) { | ||
| 594 | /* Add new value */ | ||
| 595 | memcpy(value, &iwe->u, event_len); | ||
| 596 | value += event_len; | ||
| 597 | /* Patch LCP */ | ||
| 598 | iwe->len = value - event; | ||
| 599 | memcpy(event, (char *) iwe, lcp_len); | ||
| 600 | } | ||
| 601 | return value; | ||
| 602 | } | ||
| 603 | 550 | ||
| 604 | #endif /* _IW_HANDLER_H */ | 551 | #endif /* _IW_HANDLER_H */ |
| @@ -1119,3 +1119,70 @@ int compat_wext_handle_ioctl(struct net *net, unsigned int cmd, · 1118 unmodified lines | |||
| 1119 | return ret; | 1119 | return ret; |
| 1120 | } | 1120 | } |
| 1121 | #endif | 1121 | #endif |
| 1122 | |||
| 1123 | char *iwe_stream_add_event(struct iw_request_info *info, char *stream, | ||
| 1124 | char *ends, struct iw_event *iwe, int event_len) | ||
| 1125 | { | ||
| 1126 | int lcp_len = iwe_stream_lcp_len(info); | ||
| 1127 | |||
| 1128 | event_len = iwe_stream_event_len_adjust(info, event_len); | ||
| 1129 | |||
| 1130 | /* Check if it's possible */ | ||
| 1131 | if (likely((stream + event_len) < ends)) { | ||
| 1132 | iwe->len = event_len; | ||
| 1133 | /* Beware of alignement issues on 64 bits */ | ||
| 1134 | memcpy(stream, (char *) iwe, IW_EV_LCP_PK_LEN); | ||
| 1135 | memcpy(stream + lcp_len, &iwe->u, | ||
| 1136 | event_len - lcp_len); | ||
| 1137 | stream += event_len; | ||
| 1138 | } | ||
| 1139 | |||
| 1140 | return stream; | ||
| 1141 | } | ||
| 1142 | EXPORT_SYMBOL(iwe_stream_add_event); | ||
| 1143 | |||
| 1144 | char *iwe_stream_add_point(struct iw_request_info *info, char *stream, | ||
| 1145 | char *ends, struct iw_event *iwe, char *extra) | ||
| 1146 | { | ||
| 1147 | int event_len = iwe_stream_point_len(info) + iwe->u.data.length; | ||
| 1148 | int point_len = iwe_stream_point_len(info); | ||
| 1149 | int lcp_len = iwe_stream_lcp_len(info); | ||
| 1150 | |||
| 1151 | /* Check if it's possible */ | ||
| 1152 | if (likely((stream + event_len) < ends)) { | ||
| 1153 | iwe->len = event_len; | ||
| 1154 | memcpy(stream, (char *) iwe, IW_EV_LCP_PK_LEN); | ||
| 1155 | memcpy(stream + lcp_len, | ||
| 1156 | ((char *) &iwe->u) + IW_EV_POINT_OFF, | ||
| 1157 | IW_EV_POINT_PK_LEN - IW_EV_LCP_PK_LEN); | ||
| 1158 | if (iwe->u.data.length && extra) | ||
| 1159 | memcpy(stream + point_len, extra, iwe->u.data.length); | ||
| 1160 | stream += event_len; | ||
| 1161 | } | ||
| 1162 | |||
| 1163 | return stream; | ||
| 1164 | } | ||
| 1165 | EXPORT_SYMBOL(iwe_stream_add_point); | ||
| 1166 | |||
| 1167 | char *iwe_stream_add_value(struct iw_request_info *info, char *event, | ||
| 1168 | char *value, char *ends, struct iw_event *iwe, | ||
| 1169 | int event_len) | ||
| 1170 | { | ||
| 1171 | int lcp_len = iwe_stream_lcp_len(info); | ||
| 1172 | |||
| 1173 | /* Don't duplicate LCP */ | ||
| 1174 | event_len -= IW_EV_LCP_LEN; | ||
| 1175 | |||
| 1176 | /* Check if it's possible */ | ||
| 1177 | if (likely((value + event_len) < ends)) { | ||
| 1178 | /* Add new value */ | ||
| 1179 | memcpy(value, &iwe->u, event_len); | ||
| 1180 | value += event_len; | ||
| 1181 | /* Patch LCP */ | ||
| 1182 | iwe->len = value - event; | ||
| 1183 | memcpy(event, (char *) iwe, lcp_len); | ||
| 1184 | } | ||
| 1185 | |||
| 1186 | return value; | ||
| 1187 | } | ||
| 1188 | EXPORT_SYMBOL(iwe_stream_add_value); | ||