Path: csiph.com!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.lang.c
Subject: Re: How to avoid an overflow during multiplication?
Date: Mon, 24 Jan 2022 08:01:45 -0800
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <86v8y9m8ba.fsf@linuxsc.com>
References: <877dbk36qu.fsf@nosuchdomain.example.com> <86v8ydp57h.fsf@linuxsc.com> <9_BGJ.170561$X2_b.72894@fx09.ams4> <86mtjopoq5.fsf@linuxsc.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="d742d26243a9575adb46fc0e29496190"; logging-data="3706"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/LeLRGQbxlG8PhcFJ2LDDjxugZgF8jX44="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:piExMmGx03sHKRvkGzVDNVAbxx8= sha1:Mj5bpAOsPjnCxsSsAy2du1ft8/4=
Xref: csiph.com comp.lang.c:164583
scott@slp53.sl.home (Scott Lurndal) writes:
> Tim Rentsch writes:
>
>> scott@slp53.sl.home (Scott Lurndal) writes:
>>
>>> [...] I've seen some pretty long functions that are not easily
>>> amenable to factorization into smaller functions for structural
>>> or performance reasons.
>>
>> Can you post an example or two of those? Ideally one of each, one
>> where structure impedes refactoring and one where performance
>> impedes refactoring.
>
> Probably not without violating various non-disclosure or employment
> agreements.
Surely you can find some example that wouldn't go against your
existing agreements. Probably even one of the covered examples
would be okay if stripped of comments and had all the identifers
changed to randomly chosen names (and for good measure take out
all extra horizontal white space). The code doesn't have to
compile, just show the "shape" of the function; it's unlikely
that would be giving away any kind of trade secrets. And it
doesn't have to be one of the very longest functions; in fact
between 50 and 100 lines is probably easier than some super long
monster. (Having said that, I wouldn't mind a much longer
function if that's the best you can find.)
> One in particular is the code to handle page table walks in
> an ARM64 processor simulator. Another was handling the fork()
> system call in a unix-derived MPP operating system. Both in C++.
This is comp.lang.c. My question is about C code, not C++ code.
C++ is a completely different animal.