Deutsch   English   Français   Italiano  
<vc1j87$tqv5$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: David Brown <david.brown@hesbynett.no>
Newsgroups: comp.lang.c++
Subject: Re: counting_semaphore question
Date: Fri, 13 Sep 2024 16:46:31 +0200
Organization: A noiseless patient Spider
Lines: 69
Message-ID: <vc1j87$tqv5$1@dont-email.me>
References: <vbrqjj$3hvsd$1@dont-email.me>
 <vbs01c$3j5mc$1@raubtier-asyl.eternal-september.org>
 <vbs0tm$3jf62$1@dont-email.me>
 <vbs1al$3jgnp$1@raubtier-asyl.eternal-september.org>
 <vbs2fm$3jp23$1@dont-email.me> <87ikv1i2yk.fsf@bsb.me.uk>
 <vbuhk4$7hu2$1@dont-email.me> <vbuu5g$a0rk$1@dont-email.me>
 <vbuv8g$a8h2$1@dont-email.me> <vc0mnm$nseo$1@dont-email.me>
 <vc0pfm$oj79$1@dont-email.me> <vc15lt$qr6p$1@dont-email.me>
 <vc1e8f$sojp$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 13 Sep 2024 16:46:32 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="62baffe00b005c9dd99479aa197dcc2f";
	logging-data="977893"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+fLkFgIl1biRedPgBG7l9TmRoYKa3wgAI="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
 Thunderbird/102.11.0
Cancel-Lock: sha1:2UWrwTG7NXQ3E0+5SgmK6v09YKY=
In-Reply-To: <vc1e8f$sojp$1@dont-email.me>
Content-Language: en-GB
Bytes: 4026

On 13/09/2024 15:21, Muttley@dastardlyhq.com wrote:
> On Fri, 13 Sep 2024 12:54:53 +0200
> David Brown <david.brown@hesbynett.no> boringly babbled:
>> On 13/09/2024 09:26, Muttley@dastardlyhq.com wrote:
>>> Clearly you've never done any low level networking where id fields are fixed
>>> sized and will eventually wrap. Eg, TCP sequence number. I'm sure there are
>>> a myriad of other examples.
>>
>> Clearly you can make up a complete load of drivel with no basis in reality.
> 
> Oh dear, someones been caught out and is throwing his toys out the pram.
> 
>> So let me be /clear/ here.  There is /no/ valid use of incrementing
>> something beyond its maximum value.  The whole concept makes no sense.
> 
> Bollocks.
> 
>> There /are/ lots of valid uses of wrapping types.  Sequence numbers in
>> low-level networking would be one example of that - one which I /have/
>> used countless times in my work.  But that is not incrementing beyond a
>> max value - it is using a modulo wrapping increment to give a result
>> /within/ the valid range, not beyond it.
> 
> Oh right, so for 32 bit TCP seq number instead of just doing:
> 
> ++tcp->seq_num;
> 
> which would autonatically wrap after 2^32, in your world we'd have do to:
> 
> tcp->seq_num = (uint32_t)(((uint_64_t)tcp->seq_num + 1) % 0x100000000L);
> 
> Really?
> 
> Don't be an ass.

What /are/ you talking about?  Do you even know how arithmetic works in 
C++ ?

If you have "uint32_t seq_num = 0xffffffff;", then write "seq_num++;", 
you are /not/ "incrementing beyond its maximum value".  You are 
incrementing modulo 2 ^ 32, because that's how the operation works in C++.

And if you have "int32_t seq_num;" and are using "++" to increment it 
and think you have wrapping, then you are writing crap code.


> 
>>> If you think thats clear I'd hate to see what you consider obtuse.
>>>
>>
>> Have you ever considered that /you/ might be the problem here?  Other
>> people seem to understand it fine.  Consider the common factor in all
>> your difficulties understanding the template parameter.
> 
> If it wasn't so vague I wouldn't have needed to ask the question.
> 

It is not vague.  Did you actually read the cppreference link, or the 
C++ standards?

>> But does all this mean that you now understand what the integer template
>> parameter is for, and what it does?  And do you understand how to use
>> the counting semaphore?  If so, that's great.
> 
> Aww bless, so kind.
> 

You really are a poor excuse for a human being.