diff mbox

Support older versions of glibc

Message ID 1402608702-20910-1-git-send-email-steve.mcintyre@linaro.org
State New
Headers show

Commit Message

Steve McIntyre June 12, 2014, 9:31 p.m. UTC
From: Steve McIntyre <steve.mcintyre@linaro.org>

sendmmsg() was new in glibc version 2.14. Some platforms may still be
using older versions of glibc; for those platforms, fall back to
multiple sendmsg() calls instead. It may be slightly slower, but will
at least work.

Signed-off-by: Steve McIntyre <steve.mcintyre@linaro.org>
---
 platform/linux-generic/source/odp_packet_socket.c |    8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Maxim Uvarov June 12, 2014, 9:56 p.m. UTC | #1
what about recvmmsg?

On 06/12/2014 02:31 PM, steve.mcintyre@linaro.org wrote:
> From: Steve McIntyre <steve.mcintyre@linaro.org>
>
> sendmmsg() was new in glibc version 2.14. Some platforms may still be
> using older versions of glibc; for those platforms, fall back to
> multiple sendmsg() calls instead. It may be slightly slower, but will
> at least work.
>
> Signed-off-by: Steve McIntyre <steve.mcintyre@linaro.org>
> ---
>   platform/linux-generic/source/odp_packet_socket.c |    8 ++++++++
>   1 file changed, 8 insertions(+)
>
> diff --git a/platform/linux-generic/source/odp_packet_socket.c b/platform/linux-generic/source/odp_packet_socket.c
> index 8809abc..e1db61f 100644
> --- a/platform/linux-generic/source/odp_packet_socket.c
> +++ b/platform/linux-generic/source/odp_packet_socket.c
> @@ -361,11 +361,19 @@ int send_pkt_sock_mmsg(pkt_sock_t * const pkt_sock,
>   	}
>   
>   	flags = MSG_DONTWAIT;
> +#if __GLIBC_PREREQ (2,14)
>   	for (i = 0; i < len; i += sent_msgs) {
>   		ret = sendmmsg(sockfd, &msgvec[i], len - i, flags);
>   		sent_msgs = ret > 0 ? (unsigned)ret : 0;
>   		flags = 0;	/* blocking for next rounds */
>   	}
> +#else
> +	for (i = 0; i < len; i += sent_msgs) {
> +		ret = sendmsg(sockfd, (const struct msghdr *)&msgvec[i], flags);
> +		sent_msgs = ret > 0 ? 1 : 0;
> +		flags = 0;	/* blocking for next rounds */
> +	}			
^-- git am warns on white spaces here.

Why ifdef is for hole cycle? Not for only 1 line?

Best regards,
Maxim.

> +#endif
>   
>   	for (i = 0; i < len; i++)
>   		odp_packet_free(pkt_table[i]);
Steve McIntyre June 12, 2014, 10 p.m. UTC | #2
On Thu, Jun 12, 2014 at 02:56:23PM -0700, Maxim Uvarov wrote:
>what about recvmmsg?

recvmmsg has been around much longer - since glibc 2.12. That's way
older than any systems I have. :-)

Cheers,
Steve McIntyre July 9, 2014, 10:46 p.m. UTC | #3
Any interest in this still, or drop it?

On Thu, Jun 12, 2014 at 10:31:42PM +0100, steve.mcintyre@linaro.org wrote:
>From: Steve McIntyre <steve.mcintyre@linaro.org>
>
>sendmmsg() was new in glibc version 2.14. Some platforms may still be
>using older versions of glibc; for those platforms, fall back to
>multiple sendmsg() calls instead. It may be slightly slower, but will
>at least work.
>
>Signed-off-by: Steve McIntyre <steve.mcintyre@linaro.org>
>---
> platform/linux-generic/source/odp_packet_socket.c |    8 ++++++++
> 1 file changed, 8 insertions(+)
>
>diff --git a/platform/linux-generic/source/odp_packet_socket.c b/platform/linux-generic/source/odp_packet_socket.c
>index 8809abc..e1db61f 100644
>--- a/platform/linux-generic/source/odp_packet_socket.c
>+++ b/platform/linux-generic/source/odp_packet_socket.c
>@@ -361,11 +361,19 @@ int send_pkt_sock_mmsg(pkt_sock_t * const pkt_sock,
> 	}
> 
> 	flags = MSG_DONTWAIT;
>+#if __GLIBC_PREREQ (2,14)
> 	for (i = 0; i < len; i += sent_msgs) {
> 		ret = sendmmsg(sockfd, &msgvec[i], len - i, flags);
> 		sent_msgs = ret > 0 ? (unsigned)ret : 0;
> 		flags = 0;	/* blocking for next rounds */
> 	}
>+#else
>+	for (i = 0; i < len; i += sent_msgs) {
>+		ret = sendmsg(sockfd, (const struct msghdr *)&msgvec[i], flags);
>+		sent_msgs = ret > 0 ? 1 : 0;
>+		flags = 0;	/* blocking for next rounds */
>+	}			
>+#endif
> 
> 	for (i = 0; i < len; i++)
> 		odp_packet_free(pkt_table[i]);
>-- 
>1.7.10.4
>
>
Cheers,
Maxim Uvarov July 10, 2014, 12:06 p.m. UTC | #4
On 07/10/2014 02:46 AM, Steve McIntyre wrote:
> Any interest in this still, or drop it?

I would like to apply this in case if somebody else use old glibc. Do 
you think that changing it according to my notes make sense?

Best regards,
Maxim.

>
> On Thu, Jun 12, 2014 at 10:31:42PM +0100, steve.mcintyre@linaro.org wrote:
>> From: Steve McIntyre <steve.mcintyre@linaro.org>
>>
>> sendmmsg() was new in glibc version 2.14. Some platforms may still be
>> using older versions of glibc; for those platforms, fall back to
>> multiple sendmsg() calls instead. It may be slightly slower, but will
>> at least work.
>>
>> Signed-off-by: Steve McIntyre <steve.mcintyre@linaro.org>
>> ---
>> platform/linux-generic/source/odp_packet_socket.c |    8 ++++++++
>> 1 file changed, 8 insertions(+)
>>
>> diff --git a/platform/linux-generic/source/odp_packet_socket.c b/platform/linux-generic/source/odp_packet_socket.c
>> index 8809abc..e1db61f 100644
>> --- a/platform/linux-generic/source/odp_packet_socket.c
>> +++ b/platform/linux-generic/source/odp_packet_socket.c
>> @@ -361,11 +361,19 @@ int send_pkt_sock_mmsg(pkt_sock_t * const pkt_sock,
>> 	}
>>
>> 	flags = MSG_DONTWAIT;
>> +#if __GLIBC_PREREQ (2,14)
>> 	for (i = 0; i < len; i += sent_msgs) {
>> 		ret = sendmmsg(sockfd, &msgvec[i], len - i, flags);
>> 		sent_msgs = ret > 0 ? (unsigned)ret : 0;
>> 		flags = 0;	/* blocking for next rounds */
>> 	}
>> +#else
>> +	for (i = 0; i < len; i += sent_msgs) {
>> +		ret = sendmsg(sockfd, (const struct msghdr *)&msgvec[i], flags);
>> +		sent_msgs = ret > 0 ? 1 : 0;
>> +		flags = 0;	/* blocking for next rounds */
>> +	}			
>> +#endif
>>
>> 	for (i = 0; i < len; i++)
>> 		odp_packet_free(pkt_table[i]);
>> -- 
>> 1.7.10.4
>>
>>
> Cheers,
diff mbox

Patch

diff --git a/platform/linux-generic/source/odp_packet_socket.c b/platform/linux-generic/source/odp_packet_socket.c
index 8809abc..e1db61f 100644
--- a/platform/linux-generic/source/odp_packet_socket.c
+++ b/platform/linux-generic/source/odp_packet_socket.c
@@ -361,11 +361,19 @@  int send_pkt_sock_mmsg(pkt_sock_t * const pkt_sock,
 	}
 
 	flags = MSG_DONTWAIT;
+#if __GLIBC_PREREQ (2,14)
 	for (i = 0; i < len; i += sent_msgs) {
 		ret = sendmmsg(sockfd, &msgvec[i], len - i, flags);
 		sent_msgs = ret > 0 ? (unsigned)ret : 0;
 		flags = 0;	/* blocking for next rounds */
 	}
+#else
+	for (i = 0; i < len; i += sent_msgs) {
+		ret = sendmsg(sockfd, (const struct msghdr *)&msgvec[i], flags);
+		sent_msgs = ret > 0 ? 1 : 0;
+		flags = 0;	/* blocking for next rounds */
+	}			
+#endif
 
 	for (i = 0; i < len; i++)
 		odp_packet_free(pkt_table[i]);