Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

FORTH IF HONK THEN


devel / comp.lang.c / Effect of CPP tags

SubjectAuthor
* Effect of CPP tagsJanis Papanagnou
+- Re: Effect of CPP tagsLowell Gilbert
+* Re: Effect of CPP tagsKaz Kylheku
|`* Re: Effect of CPP tagsSpiros Bousbouras
| `- Re: Effect of CPP tagsTim Rentsch
+* Re: Effect of CPP tagsJanis Papanagnou
|+* Re: Effect of CPP tagsLowell Gilbert
||+* Re: Effect of CPP tagsKeith Thompson
|||`* Re: Effect of CPP tagsKaz Kylheku
||| `* Re: Effect of CPP tagsKeith Thompson
|||  `* Re: Effect of CPP tagsTim Rentsch
|||   `* Re: Effect of CPP tagsKaz Kylheku
|||    +- Re: Effect of CPP tagsJames Kuyper
|||    +* Re: Effect of CPP tagsJames Kuyper
|||    |`* Re: Effect of CPP tagsKaz Kylheku
|||    | +* Re: Effect of CPP tagsJames Kuyper
|||    | |`- Re: Effect of CPP tagsTim Rentsch
|||    | `* Re: Effect of CPP tagsTim Rentsch
|||    |  `* Re: Effect of CPP tagsKeith Thompson
|||    |   +- Re: Effect of CPP tagsDavid Brown
|||    |   +* Re: Effect of CPP tagsTim Rentsch
|||    |   |`- Re: Effect of CPP tagsKeith Thompson
|||    |   `- Re: Effect of CPP tagsTim Rentsch
|||    `- Re: Effect of CPP tagsTim Rentsch
||+* Re: Effect of CPP tagsKaz Kylheku
|||+- Re: Effect of CPP tagsKaz Kylheku
|||`* Re: Effect of CPP tagsLowell Gilbert
||| `- Re: Effect of CPP tagsJanis Papanagnou
||`* Re: Effect of CPP tagsJanis Papanagnou
|| `- Re: Effect of CPP tagsKaz Kylheku
|+- Re: Effect of CPP tagsKaz Kylheku
|`* Re: Effect of CPP tagsScott Lurndal
| +* Re: Effect of CPP tagsJanis Papanagnou
| |`* Re: Effect of CPP tagsKeith Thompson
| | +* Re: Effect of CPP tagsScott Lurndal
| | |`* Re: Effect of CPP tagsDavid Brown
| | | `* Re: Effect of CPP tagsJames Kuyper
| | |  `- Re: Effect of CPP tagsDavid Brown
| | `- Re: Effect of CPP tagsTim Rentsch
| `- usleep (Was: Effect of CPP tags)Kenny McCormack
+* Re: Effect of CPP tagsLawrence D'Oliveiro
|`* Re: Effect of CPP tagsBart
| +* Re: Effect of CPP tagsDavid Brown
| |`* Re: Effect of CPP tagsKeith Thompson
| | `* Re: Effect of CPP tagsKaz Kylheku
| |  `* Re: Effect of CPP tagsBart
| |   +* Re: Effect of CPP tagsLawrence D'Oliveiro
| |   |`* Re: Effect of CPP tagsBart
| |   | `* Re: Effect of CPP tagsLawrence D'Oliveiro
| |   |  `* Re: Effect of CPP tagsBart
| |   |   +* Re: Effect of CPP tagsScott Lurndal
| |   |   |+* Re: Effect of CPP tagsDavid Brown
| |   |   ||`- Re: Effect of CPP tagsBGB
| |   |   |`* Re: Effect of CPP tagsBart
| |   |   | `- Re: Effect of CPP tagsDavid Brown
| |   |   `- Re: Effect of CPP tagsLawrence D'Oliveiro
| |   `* Re: Effect of CPP tagsDavid Brown
| |    +* Re: Effect of CPP tagsBart
| |    |+- Re: Effect of CPP tagsScott Lurndal
| |    |+* Re: Effect of CPP tagsKaz Kylheku
| |    ||+* Re: Effect of CPP tagsBart
| |    |||`* Re: Effect of CPP tagsBart
| |    ||| +- Re: Effect of CPP tagsKeith Thompson
| |    ||| `* Re: Effect of CPP tagsKaz Kylheku
| |    |||  `* Re: Effect of CPP tagsKeith Thompson
| |    |||   +* Re: Effect of CPP tagsJanis Papanagnou
| |    |||   |`- Re: Effect of CPP tagsKeith Thompson
| |    |||   `- Re: Effect of CPP tagsKaz Kylheku
| |    ||`- Re: Effect of CPP tagsScott Lurndal
| |    |`- Re: Effect of CPP tagsDavid Brown
| |    `* Re: Effect of CPP tagsLawrence D'Oliveiro
| |     +* Re: Effect of CPP tagsChris M. Thomasson
| |     |`* Re: Effect of CPP tagsLawrence D'Oliveiro
| |     | `* Re: Effect of CPP tagsChris M. Thomasson
| |     |  `* Re: Effect of CPP tagsLawrence D'Oliveiro
| |     |   +- Re: Effect of CPP tagsChris M. Thomasson
| |     |   +- Re: Effect of CPP tagsChris M. Thomasson
| |     |   +- Re: Effect of CPP tagsKaz Kylheku
| |     |   `- Re: Effect of CPP tagsBlue-Maned_Hawk
| |     +* Re: Effect of CPP tagsDavid Brown
| |     |+* Re: Effect of CPP tagsBart
| |     ||+* Re: Effect of CPP tagsDavid Brown
| |     |||+- Re: Effect of CPP tagsBlue-Maned_Hawk
| |     |||`* Re: Effect of CPP tagsBart
| |     ||| `* Re: Effect of CPP tagsDavid Brown
| |     |||  `* Re: Effect of CPP tagsBart
| |     |||   +* Re: Effect of CPP tagsChris M. Thomasson
| |     |||   |`- Re: Effect of CPP tagsChris M. Thomasson
| |     |||   +* Re: Effect of CPP tagstTh
| |     |||   |+- Re: Effect of CPP tagsLawrence D'Oliveiro
| |     |||   |+- Re: Effect of CPP tagsKaz Kylheku
| |     |||   |`* Re: Effect of CPP tagsBart
| |     |||   | `* Re: Effect of CPP tagsScott Lurndal
| |     |||   |  `* Re: Effect of CPP tagsBart
| |     |||   |   `* Re: Effect of CPP tagsDavid Brown
| |     |||   |    +* Re: Effect of CPP tagsKaz Kylheku
| |     |||   |    |`* Re: Effect of CPP tagsDavid Brown
| |     |||   |    | `- Re: Effect of CPP tagsKaz Kylheku
| |     |||   |    `* Re: Effect of CPP tagsBart
| |     |||   |     +* Re: Effect of CPP tagsScott Lurndal
| |     |||   |     |`* Re: Effect of CPP tagsBart
| |     |||   |     `* Re: Effect of CPP tagsDavid Brown
| |     |||   `* Re: Effect of CPP tagsDavid Brown
| |     ||`* Re: Effect of CPP tagsBlue-Maned_Hawk
| |     |`* Re: Effect of CPP tagsLawrence D'Oliveiro
| |     `* Re: Effect of CPP tagsKaz Kylheku
| +- Re: Effect of CPP tagsRichard Damon
| +* Re: Effect of CPP tagsKaz Kylheku
| +* Re: Effect of CPP tagsBlue-Maned_Hawk
| `- Re: Effect of CPP tagsLawrence D'Oliveiro
`* Re: Effect of CPP tagsTim Rentsch

Pages:123456789101112131415161718192021222324252627
Re: Effect of CPP tags

<uo4190$121on$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=30961&group=comp.lang.c#30961

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (bart)
Newsgroups: comp.lang.c
Subject: Re: Effect of CPP tags
Date: Mon, 15 Jan 2024 19:32:49 +0000
Organization: A noiseless patient Spider
Lines: 103
Message-ID: <uo4190$121on$1@dont-email.me>
References: <umet9d$3hir9$1@dont-email.me> <unso1g$3lb69$2@dont-email.me>
<20240112200241.728@kylheku.com> <untu7e$3u3nv$1@dont-email.me>
<87o7dolxkj.fsf@nosuchdomain.example.com> <unv3ec$48rm$1@dont-email.me>
<87jzoclss6.fsf@nosuchdomain.example.com> <86h6jfls0e.fsf@linuxsc.com>
<uo18fc$ht87$2@dont-email.me> <fYVoN.171150$c3Ea.139646@fx10.iad>
<uo1ec0$iquj$1@dont-email.me> <87o7dndln6.fsf@gmail.com>
<uo35hj$th5s$1@dont-email.me> <87h6jev9c6.fsf@gmail.com>
<uo3u9h$11i75$1@dont-email.me> <csfpN.200177$7sbb.184012@fx16.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 15 Jan 2024 19:32:48 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="b61795cafc08ad158449b8aa5b6459f9";
logging-data="1115927"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ojI2Dz58pU+nSMlmInL9d+NTtDZt6kl0="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:4ZlW5bOsOirkBL+6fmSSM03kkUg=
In-Reply-To: <csfpN.200177$7sbb.184012@fx16.iad>
Content-Language: en-GB
 by: bart - Mon, 15 Jan 2024 19:32 UTC

On 15/01/2024 19:12, Scott Lurndal wrote:
> bart <bc@freeuk.com> writes:
>> On 15/01/2024 16:40, Gabriel Rolland wrote:
>>> bart <bc@freeuk.com> writes:
>>
>>> This has been answered better than I could by David Brown.
>>
>> I'm not reading DB's comments today.
>
> Your loss.
>
>>
>>> The executable. Unix treatment of file extension is non existent,
>>> true. So I don't bother with file extensions much. But I have yet to go
>>> on comp.os.windows to explain how confusing file extensions are.
>>
>> This is not a Linux newsgroup. It's a language group.
>>
>> But I expect you do use file extensions.
>
> Sure, for convenience, not necessity. Some very useful tools,
> such as make, have default rules for common file name suffixes,
> but there's nothing that prevents one from supplying their own
> rules.
>
>> Otherwise any file in one of
>> your folders be absolutely anything: text, source in any language,
>> document, binary data, object file, executable ...
>
> It's a directory, not a folder.
>
> And yes, any file in a directory can be pretty much anything the
> user wants it to be. c_code_main is a perfectly legal name for
> a c source file

True:

c:\c>copy hello.c c_code_main
1 file(s) copied.

c:\c>mcc c_code_main.
Compiling c_code_main. to c_code_main.exe

Although some compilers appear to have a problem with it:

c:\c>gcc c_code_main.
C:\tdm\bin\ld.exe:c_code_main.: file format not recognized; treating
as linker script
C:\tdm\bin\ld.exe:c_code_main.:2: syntax error
collect2.exe: error: ld returned 1 exit status

They still need that scrap of info that was imparted by the extension,
either as .c or as -xc

> while b235 is a perfectly legal name for the
> executable file generated by a C compiler from the source file
> c_code_main.

It might well be. On Linux of course they tend not to have extensions,
for a very simple reason: it would get rapidly tedious to have to type,
many 1000s of times:

./b235.elf

or whatever extension is chosen.

>>
>> I'm imagine if 'abc' was a C source file, you'd have to put the object
>> file 'abc' in a separate folder, and the executable 'abc' in a third
>> one? Otherwise they will clash.
>
> $ cat /tmp/z
> #include <stdio.h>
>
> int
> main(int argc, const char **argv, const char **envp, const char **auxv)
> {
> printf("Hello World\n");
>
> return 0;
> }
> $ cat /tmp/z | cc -x c -o a -
> $ ./a
> Hello World
> $

Not sure what you're demonstrating here. Except how you're evading the
issue by avoiding intermediate files altogether.

Brilliant. Not sure how it plays with makefiles though which seem to
deal extensively with .o files.

>
>> Programs that deal with them will of course check that they are what
>> they say they are.
>
> And how, exactly, will they do that for a text file?

How does Linux deal with that same problem?

Re: Effect of CPP tags

<GkgpN.74448$m4d.70292@fx43.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=30962&group=comp.lang.c#30962

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx43.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Effect of CPP tags
Newsgroups: comp.lang.c
References: <umet9d$3hir9$1@dont-email.me> <untu7e$3u3nv$1@dont-email.me> <87o7dolxkj.fsf@nosuchdomain.example.com> <unv3ec$48rm$1@dont-email.me> <87jzoclss6.fsf@nosuchdomain.example.com> <86h6jfls0e.fsf@linuxsc.com> <uo18fc$ht87$2@dont-email.me> <fYVoN.171150$c3Ea.139646@fx10.iad> <uo1ec0$iquj$1@dont-email.me> <87o7dndln6.fsf@gmail.com> <uo35hj$th5s$1@dont-email.me> <87h6jev9c6.fsf@gmail.com> <uo3u9h$11i75$1@dont-email.me> <csfpN.200177$7sbb.184012@fx16.iad> <uo4190$121on$1@dont-email.me>
Lines: 16
Message-ID: <GkgpN.74448$m4d.70292@fx43.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Mon, 15 Jan 2024 20:12:22 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Mon, 15 Jan 2024 20:12:22 GMT
X-Received-Bytes: 1458
 by: Scott Lurndal - Mon, 15 Jan 2024 20:12 UTC

bart <bc@freeuk.com> writes:
>On 15/01/2024 19:12, Scott Lurndal wrote:
>
>>
>>> Programs that deal with them will of course check that they are what
>>> they say they are.
>>
>> And how, exactly, will they do that for a text file?
>
>How does Linux deal with that same problem?

Linux doesn't.

The gnu C compiler will produce errors if the input isn't valid C,
I suppose you could call that checking that they are what
they say they are.

Re: Effect of CPP tags

<uo43r7$12f4m$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=30963&group=comp.lang.c#30963

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: Effect of CPP tags
Date: Mon, 15 Jan 2024 21:16:39 +0100
Organization: A noiseless patient Spider
Lines: 107
Message-ID: <uo43r7$12f4m$1@dont-email.me>
References: <umet9d$3hir9$1@dont-email.me> <unrocu$3h2ah$1@dont-email.me>
<unrpn1$3h8jl$1@dont-email.me> <unrro8$3hj71$1@dont-email.me>
<unruru$3i29g$1@dont-email.me> <uns9c6$3jis4$1@dont-email.me>
<20240112134536.695@kylheku.com> <unskit$3l154$1@dont-email.me>
<87zfxakqjd.fsf@nosuchdomain.example.com> <unso1g$3lb69$2@dont-email.me>
<20240112200241.728@kylheku.com> <untu7e$3u3nv$1@dont-email.me>
<87o7dolxkj.fsf@nosuchdomain.example.com> <unv3ec$48rm$1@dont-email.me>
<87jzoclss6.fsf@nosuchdomain.example.com> <86h6jfls0e.fsf@linuxsc.com>
<uo18fc$ht87$2@dont-email.me> <fYVoN.171150$c3Ea.139646@fx10.iad>
<uo1ec0$iquj$1@dont-email.me> <87o7dndln6.fsf@gmail.com>
<uo35hj$th5s$1@dont-email.me> <87h6jev9c6.fsf@gmail.com>
<uo3u9h$11i75$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 15 Jan 2024 20:16:39 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="458fb376bb81d7875fc07c3cdf434733";
logging-data="1129622"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/L54JDEiDX0G9dj7F97igJR0rhCzB0mRQ="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:udD7c85TOJ1gIFlgx/OXh9y30hA=
In-Reply-To: <uo3u9h$11i75$1@dont-email.me>
Content-Language: en-GB
 by: David Brown - Mon, 15 Jan 2024 20:16 UTC

On 15/01/2024 19:41, bart wrote:
> On 15/01/2024 16:40, Gabriel Rolland wrote:
>> bart <bc@freeuk.com> writes:
>
>> This has been answered better than I could by David Brown.
>
> I'm not reading DB's comments today.

Maybe you will look later - or maybe others will find them interesting.
I am clear in my opinions in my posts, but I have also written a great
deal that is primarily to help you. If you don't pay attention to that,
it's not going to help your reputation of being wilfully ignorant and
disregarding help and advice.

>
>> The executable. Unix treatment of file extension is non existent,
>> true. So I don't bother with file extensions much. But I have yet to go
>> on comp.os.windows to explain how confusing file extensions are.
>
> This is not a Linux newsgroup. It's a language group.

So why are you concerned here with Linux's use, or lack thereof, of file
extensions?

>
> But I expect you do use file extensions. Otherwise any file in one of
> your folders be absolutely anything: text, source in any language,
> document, binary data, object file, executable ...
>
> I'm imagine if 'abc' was a C source file, you'd have to put the object
> file 'abc' in a separate folder, and the executable 'abc' in a third
> one? Otherwise they will clash.
>
> So extensions serve useful purposes for both machine, and human users.
>

Sure, file extensions can be very useful. They can also be deceiving,
which is why it is a huge security hole in Windows (though I'd hesitate
to agree with Scott that it is the /biggest/ hole in Windows) to treat
them as so important. It tells me something when a file has .txt, or
..c, or .md at the end. It also gives programs useful information if
they have to deal with multiple file types that cannot be identified
clearly. But it is not something a system should rely on for something
important, and programs should allow file extensions to be overridden.

Thus gcc will assume "file.c" is a C file, while "file.f" is a Fortran
file. But you can override that if you want. And file extension is
irrelevant to *nix OS's for identifying if a file should be executed or
not. Everyone wins, no one loses - unlike the Windows user who
double-clicks on a malware file called "Readme.txt.exe" and the OS has
"helpfully" hidden the ".exe" bit.

> Suppose you write an application as myprog.c. You distribute it for
> people to build. The instructions could have been as simple as:
>
>     gcc myprog.c
>
> and it will create myprog which can be invoked as ./myprog, or as
> myprog.exe which on Windows is invoked as just myprog.
>

Yes, gcc could have been made that way. I expect people would have been
fine with that. But it's not made that way, and most people seem fine
with what gcc actually does. I doubt there are many people who think
defaulting to a.out is a particular advantage these days (presumably it
was a good idea historically), but I doubt that there are many who are
bothered by it.

> But because of this stupid quirk in gcc that could have been fixed in
> three lines of code, millions of people have to add extra instructions:
>
>     gcc myprog.c -o myprog
>
> You don't get this in other languages.

gcc is not a language. But without having tried every other compiler
(for C or other languages), I'd be loath to claim there are no other
compilers that also have a default output file. I don't think you have
either.

I believe, however, that I can honestly say I don't know if any of the
other C compilers (or linkers, as that's more accurate) I have used over
the decades have a default output file, and what it might be. I've
always specified the output filename I want.

>
> It is just Wrong.
>
> Hardcoding the name of an output file is something a beginner might do,
> or in the early stages of an an application (I do that myself).
>
> But that program version is never going to see the light of day. So how
> the hell did that idiotic behaviour of gcc (and the worse one of as)
> ever escape into the wild? QoI was lacking.
>

Do you not think that someone else might have noticed if it were such an
issue? Have you ever heard anyone else complain? gcc is something like
four decades old, and *nix and C compilers are another decade older.

> Meanwhile everybody is defending it, and there are even people like you
> saying that is an advantage!
>

Maybe to some people it /is/ an advantage. Have you ever considered that?

Re: Effect of CPP tags

<uo443s$12ct8$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=30964&group=comp.lang.c#30964

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c
Subject: Re: Effect of CPP tags
Date: Mon, 15 Jan 2024 12:21:16 -0800
Organization: A noiseless patient Spider
Lines: 79
Message-ID: <uo443s$12ct8$1@dont-email.me>
References: <umet9d$3hir9$1@dont-email.me> <unmqsg$2jvva$1@dont-email.me>
<unmu6b$2kh81$1@dont-email.me> <20240110133135.834@kylheku.com>
<unn65q$2lr2i$1@dont-email.me> <20240110182957.444@kylheku.com>
<unokb1$2vmkh$1@dont-email.me> <20240111081109.274@kylheku.com>
<unpd89$33jlu$1@dont-email.me> <20240111133742.530@kylheku.com>
<unpt44$35qn1$1@dont-email.me> <unrfgs$3fo6l$1@dont-email.me>
<unrocu$3h2ah$1@dont-email.me> <65eoN.26119$9cLc.94@fx02.iad>
<unrum2$3i13c$1@dont-email.me> <_cgoN.55370$TSTa.20120@fx47.iad>
<uns6ji$3j39k$1@dont-email.me> <86wmsbltiw.fsf@linuxsc.com>
<uo1835$ht87$1@dont-email.me> <8734uzfro0.fsf@nosuchdomain.example.com>
<uo2cue$qedi$1@dont-email.me> <87y1crdu5s.fsf@nosuchdomain.example.com>
<uo2jrh$r6eh$1@dont-email.me> <uo3be8$u3sc$3@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 15 Jan 2024 20:21:16 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="7d1243cd4c6e96d6c76da6ed921f8d21";
logging-data="1127336"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18X8AvVibCRjpGhZ1HuqPWyWItqosFO5yA="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:d2y+XQJl4Q5gAFwOyI8ISUiWflI=
In-Reply-To: <uo3be8$u3sc$3@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Mon, 15 Jan 2024 20:21 UTC

On 1/15/2024 5:20 AM, David Brown wrote:
> On 15/01/2024 07:37, Chris M. Thomasson wrote:
>> On 1/14/2024 9:47 PM, Keith Thompson wrote:
>>> "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> writes:
>>>> On 1/14/2024 2:58 PM, Keith Thompson wrote:
>>>> [...]
>>>>> I already mentioned that GNU as doesn't write machine code to the
>>>>> terminal.  (I discussed problems that could occor *if it did*.)
>>>>> Did you
>>>>> miss that?  I know you're seeing at least *some* of my posts.
>>>>> Yes, it writes its output to "a.out" by default, for historical
>>>>> reasons.
>>>>> It also has an option to specify the name of the output file -- an
>>>>> option that is almost always used in practice.  Invoking the "as"
>>>>> command directly is relatively rare.
>>>>
>>>> Rare until you have to use it.
>>>
>>> And still rare after you have to use it.  Are you using the word "rare"
>>> in some non-standard sense?
>>>
>>>>                                 Fwiw, keep in mind that this was well
>>>> before C++11. Take the sensitive sync algorithms (compiler
>>>> reordering's, ect...) out of the realm of C/C++ and code them up using
>>>> assembly language. The declarations can be in C with CDECL ABI.
>>>
>>> How is any of that relevant?  Are you saying that invoking the "as"
>>> command directly *isn't* relatively rare?
>>
>> I am saying that I had to create my own sync primitives in pure
>> assembly language back them. So, I would use as to assemble them. No
>> problem. Nothing strange, just that I had to do it. Whether or not
>> that is rare, well, that's another story? The commands were in a
>> makefile anyway. Is that rare?
>>
>
> It is a /long/ time since I have found any point in writing pure
> assembly files.  I do sometimes need to write assembly code - but
> writing it as gcc inline assembly makes it far easier because the
> compiler handles all the mess of register allocation and otherwise
> getting optimal integration with C (or C++).
>
> It also seems a bit odd to use non-portable assembly to implement sync
> primitives equivalent to those later standardised in C11/C++11.  gcc has
> had builtin functions for atomic accesses for decades (C11/C++ merely
> changed the spellings and standardised them), and higher level features
> like mutexes are provided by the OS.
>
> Still, you use the tools you like, as you like to use them.

Fair enough! Well, back in the day, I was very worried about a "rouge"
compiler making a mistake in my sync code, one little mistake would ruin
its correctness. So, I said, okay. I only have to target a couple of
archs, okay let get to work. So, I wrote my asm in externally assembled
files, one for each arch I had to target. Fwiw, here is my main
rational. It worked for me! If you think it is "moronic", so be it. No
problem at all. It was before C++11 and I was "nervous", so try to take
some pity on me, thanks... ;^)

https://web.archive.org/web/20070823190955/http://appcore.home.comcast.net/

Btw, can you view that link? Thanks David.

>>> Even if you needed to invoke "as" directly (and not, for example, via
>>> "gcc"), it's still trivial to tell it the names of the input and output
>>> files.  I just typed "as hello.s -o hello.o" on my system, and it worked
>>> just fine.  And "gcc -c hello.s" did essentially the same thing.
>>
>> Well, I used as directly. Just like with MASM. That is rare? ;^)
>
> Yes.
>

Well, shit happens! Once C++11 came out, I said ahhhh! I can possibly
remove that externally assembled sync code of mine wrt porting it over
to standard C/C++11.

BTW, GCC has a nasty bug wrt trylock...

Re: Effect of CPP tags

<uo44ch$12fes$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=30965&group=comp.lang.c#30965

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: Effect of CPP tags
Date: Mon, 15 Jan 2024 21:25:53 +0100
Organization: A noiseless patient Spider
Lines: 30
Message-ID: <uo44ch$12fes$1@dont-email.me>
References: <umet9d$3hir9$1@dont-email.me> <unn65q$2lr2i$1@dont-email.me>
<20240110182957.444@kylheku.com> <unokb1$2vmkh$1@dont-email.me>
<20240111081109.274@kylheku.com> <unpd89$33jlu$1@dont-email.me>
<20240111133742.530@kylheku.com> <unpt44$35qn1$1@dont-email.me>
<unrfgs$3fo6l$1@dont-email.me> <unrocu$3h2ah$1@dont-email.me>
<20240112132216.285@kylheku.com> <uo0je6$e8fv$1@dont-email.me>
<20240114115640.506@kylheku.com> <uo24di$lo8r$1@dont-email.me>
<uo3ilc$vjmt$1@dont-email.me> <YYdpN.177805$c3Ea.78753@fx10.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 15 Jan 2024 20:25:53 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="458fb376bb81d7875fc07c3cdf434733";
logging-data="1129948"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+fPr9Df9xNHeqfPKtqEclDqcCOX7ZOIk0="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:hF1DOhrVNXM4cPTmUDf4rrWR6Dw=
In-Reply-To: <YYdpN.177805$c3Ea.78753@fx10.iad>
Content-Language: en-GB
 by: David Brown - Mon, 15 Jan 2024 20:25 UTC

On 15/01/2024 18:30, Scott Lurndal wrote:
> David Brown <david.brown@hesbynett.no> writes:
>> On 15/01/2024 03:14, bart wrote:
>
> <snip>
>
>> The only compiler I used with an inline
>> assembly of comparable power and integration to gcc's, but a different
>> syntax, was Diab Data.
>
> Now there's a name I haven't heard in decades. What ever happened
> to them? We worked with them back in the early 90's using their
> 88100 compiler. It was impressive, particularly compared to the
> PCC port that Motorola provided. Greenhills was ok, but diab
> produced better code. gcc was still pretty primitive in those days.
>
> A good Norweigian company.

A good /Swedish/ company, not Norwegian!

The compiler was bought by Wind River, and I don't think it is very
relevant now.

I only ever got to play with the compiler for a short while, back in the
late 1990's, for the m68k. Our company couldn't afford it at the time
as it was /not/ cheap. But it had powerful optimisation for its day.

I've never been much fond of Greenhills, though I have not had much use
of it (some customers have).

Re: Effect of CPP tags

<uo44fg$12ct8$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=30966&group=comp.lang.c#30966

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c
Subject: Re: Effect of CPP tags
Date: Mon, 15 Jan 2024 12:27:28 -0800
Organization: A noiseless patient Spider
Lines: 19
Message-ID: <uo44fg$12ct8$2@dont-email.me>
References: <umet9d$3hir9$1@dont-email.me> <unkkp3$26g9o$1@dont-email.me>
<87ttnmnjdb.fsf@nosuchdomain.example.com> <unkp1b$270v8$1@dont-email.me>
<ZSmnN.151217$c3Ea.70659@fx10.iad> <unkuhp$27i0v$2@dont-email.me>
<unlqqa$2eqts$2@dont-email.me> <U7ynN.143065$Wp_8.30410@fx17.iad>
<unmmnd$2jair$1@dont-email.me> <87edepnich.fsf@nosuchdomain.example.com>
<unmqsg$2jvva$1@dont-email.me> <unmu6b$2kh81$1@dont-email.me>
<20240110133135.834@kylheku.com> <unn65q$2lr2i$1@dont-email.me>
<20240110182957.444@kylheku.com> <unokb1$2vmkh$1@dont-email.me>
<20240111081109.274@kylheku.com> <unpd89$33jlu$1@dont-email.me>
<20240111133742.530@kylheku.com> <unpt44$35qn1$1@dont-email.me>
<unrfgs$3fo6l$1@dont-email.me> <unrocu$3h2ah$1@dont-email.me>
<20240112132216.285@kylheku.com> <uo0je6$e8fv$1@dont-email.me>
<20240114115640.506@kylheku.com> <uo24di$lo8r$1@dont-email.me>
<20240114222417.720@kylheku.com> <20240114231905.155@kylheku.com>
<uo3l28$1010j$1@dont-email.me> <uo3mhi$1073t$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 15 Jan 2024 20:27:28 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="7d1243cd4c6e96d6c76da6ed921f8d21";
logging-data="1127336"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/9lunwE5fkdEdmJ0VF2G4rN+lqhOuf1LM="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:dZF9QkJikj4hyFgYlaszOhk11RQ=
Content-Language: en-US
In-Reply-To: <uo3mhi$1073t$1@dont-email.me>
 by: Chris M. Thomasson - Mon, 15 Jan 2024 20:27 UTC

On 1/15/2024 8:29 AM, David Brown wrote:
> On 15/01/2024 17:04, David Brown wrote:
>> On 15/01/2024 08:40, Kaz Kylheku wrote:
>
>>> A mul_add primitive might make sense if the processor had such a thing
>>> in one instruction.
>>>
>>> With GCC inline assembly, you want to only put the essentials into it:
>>> only do what is necessary and only bundle together what must be
>>> bundled.
>>>
>>
>> Yes.  For inline assembly, simple is not really important, but small
>> is beautiful!  Say exactly what you mean, no more and no less, and let
>> the compiler do what it does best.
[...]

Wrt inline GCC assembly, remember __volatile__ and memory? ;^)

Re: Effect of CPP tags

<uo44h7$12ct8$3@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=30967&group=comp.lang.c#30967

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!news.1d4.us!usenet.goja.nl.eu.org!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c
Subject: Re: Effect of CPP tags
Date: Mon, 15 Jan 2024 12:28:23 -0800
Organization: A noiseless patient Spider
Lines: 4
Message-ID: <uo44h7$12ct8$3@dont-email.me>
References: <umet9d$3hir9$1@dont-email.me> <unke3h$25ia0$1@dont-email.me>
<unkhql$25uof$1@dont-email.me> <unkkp3$26g9o$1@dont-email.me>
<87ttnmnjdb.fsf@nosuchdomain.example.com> <unkp1b$270v8$1@dont-email.me>
<ZSmnN.151217$c3Ea.70659@fx10.iad> <unkuhp$27i0v$2@dont-email.me>
<unlqqa$2eqts$2@dont-email.me> <U7ynN.143065$Wp_8.30410@fx17.iad>
<unmmnd$2jair$1@dont-email.me> <87edepnich.fsf@nosuchdomain.example.com>
<unmqsg$2jvva$1@dont-email.me> <unmu6b$2kh81$1@dont-email.me>
<20240110133135.834@kylheku.com> <unn65q$2lr2i$1@dont-email.me>
<20240110182957.444@kylheku.com> <unokb1$2vmkh$1@dont-email.me>
<20240111081109.274@kylheku.com> <unpd89$33jlu$1@dont-email.me>
<20240111133742.530@kylheku.com> <unpt44$35qn1$1@dont-email.me>
<unrfgs$3fo6l$1@dont-email.me> <unrocu$3h2ah$1@dont-email.me>
<20240112132216.285@kylheku.com> <uo0je6$e8fv$1@dont-email.me>
<20240114115640.506@kylheku.com> <uo24di$lo8r$1@dont-email.me>
<20240114222417.720@kylheku.com> <uo3eli$uv97$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 15 Jan 2024 20:28:23 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="7d1243cd4c6e96d6c76da6ed921f8d21";
logging-data="1127336"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/+zF6C/MxStR1Kk2uR6UYkJ4GyFixUdCY="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:uzHRcL4RVfvLbHtQQ1gcJ3h624g=
In-Reply-To: <uo3eli$uv97$1@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Mon, 15 Jan 2024 20:28 UTC

On 1/15/2024 6:15 AM, bart wrote:
[...]

Iirc, Microsoft got rid of inline assembly for 64 bit targets a while back.

Re: Effect of CPP tags

<uo44m5$12ct8$4@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=30968&group=comp.lang.c#30968

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c
Subject: Re: Effect of CPP tags
Date: Mon, 15 Jan 2024 12:31:00 -0800
Organization: A noiseless patient Spider
Lines: 43
Message-ID: <uo44m5$12ct8$4@dont-email.me>
References: <umet9d$3hir9$1@dont-email.me> <20240111081109.274@kylheku.com>
<unpd89$33jlu$1@dont-email.me> <20240111133742.530@kylheku.com>
<unpt44$35qn1$1@dont-email.me> <unrfgs$3fo6l$1@dont-email.me>
<unrocu$3h2ah$1@dont-email.me> <20240112132216.285@kylheku.com>
<uo0je6$e8fv$1@dont-email.me> <20240114115640.506@kylheku.com>
<uo24di$lo8r$1@dont-email.me> <20240114222417.720@kylheku.com>
<uo3eli$uv97$1@dont-email.me> <6pbpN.200172$7sbb.118143@fx16.iad>
<uo3jth$vqg9$1@dont-email.me> <B1epN.177806$c3Ea.53953@fx10.iad>
<uo3v2u$11mbu$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 15 Jan 2024 20:31:01 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="7d1243cd4c6e96d6c76da6ed921f8d21";
logging-data="1127336"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/KTfW+SNNd1ku2rK46NhCNID7sEf8Pqdg="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:p+eCShM8L60E3BZtr8Cb0c6N8bc=
Content-Language: en-US
In-Reply-To: <uo3v2u$11mbu$1@dont-email.me>
 by: Chris M. Thomasson - Mon, 15 Jan 2024 20:31 UTC

On 1/15/2024 10:55 AM, bart wrote:
> On 15/01/2024 17:35, Scott Lurndal wrote:
>> bart <bc@freeuk.com> writes:
>
>>> You're having a laugh, surely?
>>
>> No.  I'm serious. [DWORD] is useless cruft.
>
> I don't use [DWORD], whatever that means.
>
> Meanwhile %% in front of every register name, f after a label, and ""
> and \n and \t on every line is useful cruft!
>
>>> AT&T is bad enough even without the
>>> travesty of it displayed here:
>>>
>>>                "jmp    2f\n"
>>>                "3:\tmovsx %%bx, %%rbx\n\t"
>>
>> If you don't understand the standard C escapes, you really
>> should go back to read the standard carefluly.
>
> I understand C escape codes. I am asking WHAT THE FUCK ARE THEY DOING IN
> EVERY LINE OF AN ASSEMBLY PROGRAM?
>
> You're doing this on purpose aren't you?
>
>
>>
>>>
>>> What's with the strings, newline and tab escapes? What's that 'f' for?
>>
>> RTFM for the architecture dependent assembler that the compiler
>> driver will end up calling to build the output object file.
>
> So you don't actually know.
>
> Just admit that my approach to inline assembler is better and give it up.

inline assembler is not my cup of tea. If I work for a team that uses
it, well I can use it as well... However, I might not have a big smile
on my face when I am working on it. My boss says, hey man, if you don't
smile right now you are fired. Well, I would smile for sure! ;^)

Re: Effect of CPP tags

<SLgpN.41334$5Hnd.11118@fx03.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=30969&group=comp.lang.c#30969

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!weretis.net!feeder6.news.weretis.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx03.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Effect of CPP tags
Newsgroups: comp.lang.c
References: <umet9d$3hir9$1@dont-email.me> <unokb1$2vmkh$1@dont-email.me> <20240111081109.274@kylheku.com> <unpd89$33jlu$1@dont-email.me> <20240111133742.530@kylheku.com> <unpt44$35qn1$1@dont-email.me> <unrfgs$3fo6l$1@dont-email.me> <unrocu$3h2ah$1@dont-email.me> <20240112132216.285@kylheku.com> <uo0je6$e8fv$1@dont-email.me> <20240114115640.506@kylheku.com> <uo24di$lo8r$1@dont-email.me> <uo3ilc$vjmt$1@dont-email.me> <YYdpN.177805$c3Ea.78753@fx10.iad> <uo44ch$12fes$1@dont-email.me>
Lines: 24
Message-ID: <SLgpN.41334$5Hnd.11118@fx03.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Mon, 15 Jan 2024 20:41:22 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Mon, 15 Jan 2024 20:41:22 GMT
X-Received-Bytes: 1882
 by: Scott Lurndal - Mon, 15 Jan 2024 20:41 UTC

David Brown <david.brown@hesbynett.no> writes:
>On 15/01/2024 18:30, Scott Lurndal wrote:
>> David Brown <david.brown@hesbynett.no> writes:
>>> On 15/01/2024 03:14, bart wrote:
>>
>> <snip>
>>
>>> The only compiler I used with an inline
>>> assembly of comparable power and integration to gcc's, but a different
>>> syntax, was Diab Data.
>>
>> Now there's a name I haven't heard in decades. What ever happened
>> to them? We worked with them back in the early 90's using their
>> 88100 compiler. It was impressive, particularly compared to the
>> PCC port that Motorola provided. Greenhills was ok, but diab
>> produced better code. gcc was still pretty primitive in those days.
>>
>> A good Norweigian company.
>
>A good /Swedish/ company, not Norwegian!

Hm. I could have sworn the folks we dealt with were
in Norway - perhaps a branch office?

Make (was: Re: Effect of CPP tags)

<uo46fs$12l9o$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=30970&group=comp.lang.c#30970

  copy link   Newsgroups: comp.lang.c comp.unix.programmer
Followup: comp.unix.programmer
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: val...@cultnix.org (vallor)
Newsgroups: comp.lang.c,comp.unix.programmer
Subject: Make (was: Re: Effect of CPP tags)
Followup-To: comp.unix.programmer
Date: Mon, 15 Jan 2024 21:01:48 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <uo46fs$12l9o$2@dont-email.me>
References: <umet9d$3hir9$1@dont-email.me> <unedki$13tlb$1@dont-email.me>
<unegb1$148mk$2@dont-email.me> <ungr21$1hleq$1@dont-email.me>
<unh5p4$1j81h$1@dont-email.me> <unhjme$1ld24$1@dont-email.me>
<uni64g$1nrsb$1@dont-email.me> <unislv$1u3j0$1@dont-email.me>
<unj9l0$1vr6j$1@dont-email.me> <unjmqs$21nsj$1@dont-email.me>
<unk0q8$23dum$1@dont-email.me> <unk4tm$2408t$1@dont-email.me>
<unkblm$2566s$1@dont-email.me> <8734v6p5s1.fsf@nosuchdomain.example.com>
<unke3h$25ia0$1@dont-email.me> <qhjnN.136894$Ama9.92332@fx12.iad>
<unkgvp$25vrm$1@dont-email.me> <unll0n$2e1i8$1@dont-email.me>
<unm1jm$2ft22$1@dont-email.me> <unm5du$2ggel$1@dont-email.me>
<unm9o7$2h6ig$1@dont-email.me> <unmeee$2hvj3$1@dont-email.me>
<unmpbl$2joe1$1@dont-email.me> <unn99q$1guu$1@news.gegeweb.eu>
<unnfdb$2n5b9$1@dont-email.me> <unpa3o$32vrk$1@dont-email.me>
<unpc54$33efd$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 15 Jan 2024 21:01:48 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="32cef619020e1b0dadc1caa5a7639021";
logging-data="1135928"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19xwncsGWLvlbQJK4aVXkbA"
User-Agent: Pan/0.155 (Kherson; fc5a80b gitlab.gnome.org/GNOME/pan.git;
x86_64-pc-linux-gnu)
Cancel-Lock: sha1:AGTqdGWRFV+VLMmIWfxUHagCLf0=
X-Face: \}2`P"_@pS86<'EM:'b.Ml}8IuMK"pV"?FReF$'c.S%u9<Q#U*4QO)$l81M`{Q/n
XL'`91kd%N::LG:=*\35JS0prp\VJN^<s"b#bff@fA7]5lJA.jn,x_d%Md$,{.EZ
 by: vallor - Mon, 15 Jan 2024 21:01 UTC

On Thu, 11 Jan 2024 18:31:00 +0000, bart <bc@freeuk.com> wrote in
<unpc54$33efd$1@dont-email.me>:

> See? It's built in to my compiler. No separate 'make' is needed.

"You die on weird hills."

I've been using make for 32 years. I'd love to discuss
it with you -- but not in c.l.c.

[ fu2: comp.unix.programmer ]

--
-v

Re: Effect of CPP tags

<87ttnedz70.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=30975&group=comp.lang.c#30975

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!rocksolid2!news.neodome.net!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: Effect of CPP tags
Date: Mon, 15 Jan 2024 14:11:31 -0800
Organization: None to speak of
Lines: 25
Message-ID: <87ttnedz70.fsf@nosuchdomain.example.com>
References: <umet9d$3hir9$1@dont-email.me> <unkuhp$27i0v$2@dont-email.me>
<unlqqa$2eqts$2@dont-email.me> <U7ynN.143065$Wp_8.30410@fx17.iad>
<unmmnd$2jair$1@dont-email.me>
<87edepnich.fsf@nosuchdomain.example.com>
<unmqsg$2jvva$1@dont-email.me> <unmu6b$2kh81$1@dont-email.me>
<20240110133135.834@kylheku.com> <unn65q$2lr2i$1@dont-email.me>
<20240110182957.444@kylheku.com> <unokb1$2vmkh$1@dont-email.me>
<20240111081109.274@kylheku.com> <unpd89$33jlu$1@dont-email.me>
<20240111133742.530@kylheku.com> <unpt44$35qn1$1@dont-email.me>
<unrfgs$3fo6l$1@dont-email.me> <unrocu$3h2ah$1@dont-email.me>
<unrpn1$3h8jl$1@dont-email.me> <unrro8$3hj71$1@dont-email.me>
<uo35sv$tj3v$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="4eb0dcbeed37984f760cfe11931e9557";
logging-data="1164134"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Q8TKPrx693tBylFLcVD1W"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:shpLjr6x9NS2KLK0P6SSUQXQHw8=
sha1:XCgj2+oDH48nKycQJTprDNC+dOk=
 by: Keith Thompson - Mon, 15 Jan 2024 22:11 UTC

David Brown <david.brown@hesbynett.no> writes:
> On 12/01/2024 18:09, bart wrote:
[...]
>> I'm separating the fundamental build-process for a program from what
>> is needed for interactive development and testing.
[...]
>> Makefiles you see supplied with open source projects don't generally
>> make that distinction.
>
> Why should they? An optimal deployment build makefile is likely to be
> different from an optimal development build makefile. But should the
> open source developers make that effort? For a big project that is
> used across a wide range of systems, targeting automatic builds by
> non-developers, the answer is probably yes.
[...]

Is it? Most open source projects I've seen use "make" both for
developer incremental builds and end user full builds. My experience is
that this works just fine -- especially given make's ability to do
parallel builds.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Medtronic
void Void(void) { Void(); } /* The recursive call of the void */

Re: Effect of CPP tags

<20240115152033.334@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=30977&group=comp.lang.c#30977

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 433-929-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: Effect of CPP tags
Date: Mon, 15 Jan 2024 23:24:07 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 34
Message-ID: <20240115152033.334@kylheku.com>
References: <umet9d$3hir9$1@dont-email.me>
<87ttnmnjdb.fsf@nosuchdomain.example.com> <unkp1b$270v8$1@dont-email.me>
<ZSmnN.151217$c3Ea.70659@fx10.iad> <unkuhp$27i0v$2@dont-email.me>
<unlqqa$2eqts$2@dont-email.me> <U7ynN.143065$Wp_8.30410@fx17.iad>
<unmmnd$2jair$1@dont-email.me> <87edepnich.fsf@nosuchdomain.example.com>
<unmqsg$2jvva$1@dont-email.me> <unmu6b$2kh81$1@dont-email.me>
<20240110133135.834@kylheku.com> <unn65q$2lr2i$1@dont-email.me>
<20240110182957.444@kylheku.com> <unokb1$2vmkh$1@dont-email.me>
<20240111081109.274@kylheku.com> <unpd89$33jlu$1@dont-email.me>
<20240111133742.530@kylheku.com> <unpt44$35qn1$1@dont-email.me>
<unrfgs$3fo6l$1@dont-email.me> <unrocu$3h2ah$1@dont-email.me>
<20240112132216.285@kylheku.com> <uo0je6$e8fv$1@dont-email.me>
<20240114115640.506@kylheku.com> <uo24di$lo8r$1@dont-email.me>
<20240114222417.720@kylheku.com> <20240114231905.155@kylheku.com>
<uo3l28$1010j$1@dont-email.me> <uo3mhi$1073t$1@dont-email.me>
<uo44fg$12ct8$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 15 Jan 2024 23:24:07 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="0e4d96b6e3e7b220599d4efcc49ca97f";
logging-data="1181838"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18eflLHOlW/DZhk5CN9LSXVGi+Zdl+7Fg0="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:SyGd9+zn4lTh2AnOoqVewFycIzc=
 by: Kaz Kylheku - Mon, 15 Jan 2024 23:24 UTC

On 2024-01-15, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
> On 1/15/2024 8:29 AM, David Brown wrote:
>> On 15/01/2024 17:04, David Brown wrote:
>>> On 15/01/2024 08:40, Kaz Kylheku wrote:
>>
>>>> A mul_add primitive might make sense if the processor had such a thing
>>>> in one instruction.
>>>>
>>>> With GCC inline assembly, you want to only put the essentials into it:
>>>> only do what is necessary and only bundle together what must be
>>>> bundled.
>>>>
>>>
>>> Yes.  For inline assembly, simple is not really important, but small
>>> is beautiful!  Say exactly what you mean, no more and no less, and let
>>> the compiler do what it does best.
> [...]
>
> Wrt inline GCC assembly, remember __volatile__ and memory? ;^)

The volatile is only important if you're writing sync primitives, so the
compiler won't move loads or stores to one side or the other of the
inline assembly. If you're just doing some calculation, it's
counterproductive to tell the compiler not to move the code.

"memory" is only needed if your inline code clobbers memory. E.g.
one of the operands is a pointer, and the code writes through it.
That location isn't one of the output operands.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca
NOTE: If you use Google Groups, I don't see you, unless you're whitelisted.

Re: Effect of CPP tags

<20240115152642.593@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=30978&group=comp.lang.c#30978

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 433-929-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: Effect of CPP tags
Date: Mon, 15 Jan 2024 23:28:34 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 14
Message-ID: <20240115152642.593@kylheku.com>
References: <umet9d$3hir9$1@dont-email.me> <unso1g$3lb69$2@dont-email.me>
<20240112200241.728@kylheku.com> <untu7e$3u3nv$1@dont-email.me>
<87o7dolxkj.fsf@nosuchdomain.example.com> <unv3ec$48rm$1@dont-email.me>
<87jzoclss6.fsf@nosuchdomain.example.com> <86h6jfls0e.fsf@linuxsc.com>
<uo18fc$ht87$2@dont-email.me> <fYVoN.171150$c3Ea.139646@fx10.iad>
<uo1ec0$iquj$1@dont-email.me> <87o7dndln6.fsf@gmail.com>
<uo35hj$th5s$1@dont-email.me> <87h6jev9c6.fsf@gmail.com>
<uo3u9h$11i75$1@dont-email.me> <csfpN.200177$7sbb.184012@fx16.iad>
<uo4190$121on$1@dont-email.me>
Injection-Date: Mon, 15 Jan 2024 23:28:34 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="0e4d96b6e3e7b220599d4efcc49ca97f";
logging-data="1181838"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+CyyKMSdYnLs8LT0hiYmVlH5rK06YVTLc="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:mejpFA5nWQRieod3hK53g/S0Htw=
 by: Kaz Kylheku - Mon, 15 Jan 2024 23:28 UTC

On 2024-01-15, bart <bc@freeuk.com> wrote:
> c:\c>copy hello.c c_code_main
> 1 file(s) copied.

There goes that damned AT&T instruction syntax for file copying, same
like in Unix.

Doesn't it bother you that it isn't: copy destination source?

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca
NOTE: If you use Google Groups, I don't see you, unless you're whitelisted.

Re: Effect of CPP tags

<uo4h6h$14are$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=30982&group=comp.lang.c#30982

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!nntp.comgw.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (bart)
Newsgroups: comp.lang.c
Subject: Re: Effect of CPP tags
Date: Tue, 16 Jan 2024 00:04:35 +0000
Organization: A noiseless patient Spider
Lines: 21
Message-ID: <uo4h6h$14are$2@dont-email.me>
References: <umet9d$3hir9$1@dont-email.me> <unso1g$3lb69$2@dont-email.me>
<20240112200241.728@kylheku.com> <untu7e$3u3nv$1@dont-email.me>
<87o7dolxkj.fsf@nosuchdomain.example.com> <unv3ec$48rm$1@dont-email.me>
<87jzoclss6.fsf@nosuchdomain.example.com> <86h6jfls0e.fsf@linuxsc.com>
<uo18fc$ht87$2@dont-email.me> <fYVoN.171150$c3Ea.139646@fx10.iad>
<uo1ec0$iquj$1@dont-email.me> <87o7dndln6.fsf@gmail.com>
<uo35hj$th5s$1@dont-email.me> <87h6jev9c6.fsf@gmail.com>
<uo3u9h$11i75$1@dont-email.me> <csfpN.200177$7sbb.184012@fx16.iad>
<uo4190$121on$1@dont-email.me> <20240115152642.593@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 16 Jan 2024 00:04:33 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="fcbb89fd40114758fadb19769f6fd3cc";
logging-data="1190766"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+x3FYR0AwScuaBCsPId3nhkpkqrbifwDY="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:PPJZ7gv3mOqfL6zQt6ZkhoL6UL4=
Content-Language: en-GB
In-Reply-To: <20240115152642.593@kylheku.com>
 by: bart - Tue, 16 Jan 2024 00:04 UTC

On 15/01/2024 23:28, Kaz Kylheku wrote:
> On 2024-01-15, bart <bc@freeuk.com> wrote:
>> c:\c>copy hello.c c_code_main
>> 1 file(s) copied.
>
> There goes that damned AT&T instruction syntax for file copying, same
> like in Unix.
>
> Doesn't it bother you that it isn't: copy destination source?

I haven't said anything about in which direction the data goes.

This is something that tends to depend on device, so Motorola went left
to right, and Zilog/Intel went right to left.

So it did seem odd for this x86 assembler to do the opposite of Intel.

However, doesn't it bother /you/ that AT&T also does the opposite of not
only how assignment works in C, but in most languages? That would be
more pertinent than somebody's choices of command-line syntax.

Re: Effect of CPP tags

<20240115152928.267@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=30983&group=comp.lang.c#30983

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!news.furie.org.uk!usenet.goja.nl.eu.org!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 433-929-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: Effect of CPP tags
Date: Tue, 16 Jan 2024 01:21:18 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 88
Message-ID: <20240115152928.267@kylheku.com>
References: <umet9d$3hir9$1@dont-email.me> <20240111081109.274@kylheku.com>
<unpd89$33jlu$1@dont-email.me> <20240111133742.530@kylheku.com>
<unpt44$35qn1$1@dont-email.me> <unrfgs$3fo6l$1@dont-email.me>
<unrocu$3h2ah$1@dont-email.me> <20240112132216.285@kylheku.com>
<uo0je6$e8fv$1@dont-email.me> <20240114115640.506@kylheku.com>
<uo24di$lo8r$1@dont-email.me> <20240114222417.720@kylheku.com>
<uo3eli$uv97$1@dont-email.me> <6pbpN.200172$7sbb.118143@fx16.iad>
<uo3jth$vqg9$1@dont-email.me> <B1epN.177806$c3Ea.53953@fx10.iad>
<uo3v2u$11mbu$1@dont-email.me>
Injection-Date: Tue, 16 Jan 2024 01:21:18 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="0e4d96b6e3e7b220599d4efcc49ca97f";
logging-data="1212047"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18EP2hPupM3QN1vGLHJug2zeFcXLlTdWzI="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:+9NSNgxPeDcg+aMdYF4KQCFsHR8=
 by: Kaz Kylheku - Tue, 16 Jan 2024 01:21 UTC

On 2024-01-15, bart <bc@freeuk.com> wrote:
> On 15/01/2024 17:35, Scott Lurndal wrote:
>> bart <bc@freeuk.com> writes:
>
>>> You're having a laugh, surely?
>>
>> No. I'm serious. [DWORD] is useless cruft.
>
> I don't use [DWORD], whatever that means.
>
> Meanwhile %% in front of every register name, f after a label, and ""
> and \n and \t on every line is useful cruft!
>
>>> AT&T is bad enough even without the
>>> travesty of it displayed here:
>>>
>>> "jmp 2f\n"
>>> "3:\tmovsx %%bx, %%rbx\n\t"
>>
>> If you don't understand the standard C escapes, you really
>> should go back to read the standard carefluly.
>
> I understand C escape codes. I am asking WHAT THE FUCK ARE THEY DOING IN
> EVERY LINE OF AN ASSEMBLY PROGRAM?

The instruction template is just a string literal to the
compiler. It specifies text to be inserted into the assembly
output.

Some assembly languages require the whitespace; you need
instructions to be on separate lines.

GCC does not look inside this template other than to replace
% codes like %0 (the first register).

In my example, I put the newlines and tabs together on the right

"imul %3, %2\n\t"
"add %1, %2\n\t"
"mov %1, %0\n\t"

Thanks to these newlines and tabs, the textual output (generated .s
file if we use gcc -S) has this in it:

#APP
# 24 "inline.c" 1
imul %edx, %esi
add %esi, %edi
mov %edi, %edi

# 0 "" 2
#NO_APP
movl 8(%rsp), %eax
movl 16(%rsp), %edx

GCC's code is using eight spaces; mine is tabs. The indentation on
imul is spaces: that was generated by GCC. You don't have to
indent your first instruction.

You can understand why GCC went with this textual templating approach, since
the number of back-end assembly languages is astonishing. In some cases, I
think, GCC supports more than one assembler syntax for the same architecture.
Historically it has worked with assemblers that didn't come from GNU.

It would not be practical for GNU C to have a bazillino assembly language
syntaxes in its grammar.

> Just admit that my approach to inline assembler is better and give it up.

Your approach to inline assembler has nicer looking syntax, but
semantically, it doesn't seem to be on same level as the GCC approach.

GCC's inline assembly does nice things that are might not be possible in your
implementation. (Or pretty much anyone else's).

Some of it has been sufficiently exemplified elsewhere in the thread.

GCC can choose registers for your inline assembly block, and will automatically
move between those registers and the operands they are connected to (if
necessary). The inline code seamlessly integrates with the code generated by
the compiler. You can write primitives that generate code as well as compiler
built-ins.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca
NOTE: If you use Google Groups, I don't see you, unless you're whitelisted.

Re: Effect of CPP tags

<uo4p1q$15bb0$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=30984&group=comp.lang.c#30984

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c
Subject: Re: Effect of CPP tags
Date: Mon, 15 Jan 2024 18:18:34 -0800
Organization: A noiseless patient Spider
Lines: 43
Message-ID: <uo4p1q$15bb0$1@dont-email.me>
References: <umet9d$3hir9$1@dont-email.me> <unkp1b$270v8$1@dont-email.me>
<ZSmnN.151217$c3Ea.70659@fx10.iad> <unkuhp$27i0v$2@dont-email.me>
<unlqqa$2eqts$2@dont-email.me> <U7ynN.143065$Wp_8.30410@fx17.iad>
<unmmnd$2jair$1@dont-email.me> <87edepnich.fsf@nosuchdomain.example.com>
<unmqsg$2jvva$1@dont-email.me> <unmu6b$2kh81$1@dont-email.me>
<20240110133135.834@kylheku.com> <unn65q$2lr2i$1@dont-email.me>
<20240110182957.444@kylheku.com> <unokb1$2vmkh$1@dont-email.me>
<20240111081109.274@kylheku.com> <unpd89$33jlu$1@dont-email.me>
<20240111133742.530@kylheku.com> <unpt44$35qn1$1@dont-email.me>
<unrfgs$3fo6l$1@dont-email.me> <unrocu$3h2ah$1@dont-email.me>
<20240112132216.285@kylheku.com> <uo0je6$e8fv$1@dont-email.me>
<20240114115640.506@kylheku.com> <uo24di$lo8r$1@dont-email.me>
<20240114222417.720@kylheku.com> <20240114231905.155@kylheku.com>
<uo3l28$1010j$1@dont-email.me> <uo3mhi$1073t$1@dont-email.me>
<uo44fg$12ct8$2@dont-email.me> <20240115152033.334@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 16 Jan 2024 02:18:34 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="c688ba3e2d40cc45c561f5c38b7e157a";
logging-data="1224032"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19iVnt9W/Cu52QlL5T7f0Q7jM56sVt4QIs="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:L2G+FlNKboCg9CKxL3AF8EEpSuk=
Content-Language: en-US
In-Reply-To: <20240115152033.334@kylheku.com>
 by: Chris M. Thomasson - Tue, 16 Jan 2024 02:18 UTC

On 1/15/2024 3:24 PM, Kaz Kylheku wrote:
> On 2024-01-15, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
>> On 1/15/2024 8:29 AM, David Brown wrote:
>>> On 15/01/2024 17:04, David Brown wrote:
>>>> On 15/01/2024 08:40, Kaz Kylheku wrote:
>>>
>>>>> A mul_add primitive might make sense if the processor had such a thing
>>>>> in one instruction.
>>>>>
>>>>> With GCC inline assembly, you want to only put the essentials into it:
>>>>> only do what is necessary and only bundle together what must be
>>>>> bundled.
>>>>>
>>>>
>>>> Yes.  For inline assembly, simple is not really important, but small
>>>> is beautiful!  Say exactly what you mean, no more and no less, and let
>>>> the compiler do what it does best.
>> [...]
>>
>> Wrt inline GCC assembly, remember __volatile__ and memory? ;^)
>
> The volatile is only important if you're writing sync primitives, so the
> compiler won't move loads or stores to one side or the other of the
> inline assembly. If you're just doing some calculation, it's
> counterproductive to tell the compiler not to move the code.
>
> "memory" is only needed if your inline code clobbers memory. E.g.
> one of the operands is a pointer, and the code writes through it.
> That location isn't one of the output operands.
>

I want my sync primitive code to be _un_abused by any "clever"
optimizations. I want it is as it is. No rouge compiler thinking that
link-time optimizations are all fun and joy, lets dance around the sync
instructions... Step on them, ruin them, make them incorrect. Even GCC
had a nasty error with an optimization wrt Pthread
pthread_mutex_trylock(). Simply ruined is correctness wrt the standard.

Some sarcastic comic relief: A setting for all compilers,
-ct_stay_away_from_my_asm_pretty_please Would that make some programmers
laugh out loud? lol. ;^)

Re: Effect of CPP tags

<uo4pbo$15bb0$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=30985&group=comp.lang.c#30985

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c
Subject: Re: Effect of CPP tags
Date: Mon, 15 Jan 2024 18:23:52 -0800
Organization: A noiseless patient Spider
Lines: 42
Message-ID: <uo4pbo$15bb0$2@dont-email.me>
References: <umet9d$3hir9$1@dont-email.me> <unso1g$3lb69$2@dont-email.me>
<20240112200241.728@kylheku.com> <untu7e$3u3nv$1@dont-email.me>
<87o7dolxkj.fsf@nosuchdomain.example.com> <unv3ec$48rm$1@dont-email.me>
<87jzoclss6.fsf@nosuchdomain.example.com> <86h6jfls0e.fsf@linuxsc.com>
<uo18fc$ht87$2@dont-email.me> <fYVoN.171150$c3Ea.139646@fx10.iad>
<uo1ec0$iquj$1@dont-email.me> <87o7dndln6.fsf@gmail.com>
<uo35hj$th5s$1@dont-email.me> <87h6jev9c6.fsf@gmail.com>
<uo3u9h$11i75$1@dont-email.me> <csfpN.200177$7sbb.184012@fx16.iad>
<uo4190$121on$1@dont-email.me> <20240115152642.593@kylheku.com>
<uo4h6h$14are$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 16 Jan 2024 02:23:52 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="c688ba3e2d40cc45c561f5c38b7e157a";
logging-data="1224032"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+JgOL1S54LOjD5SEp3g/nYoPEWeStPadI="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:m660XrgRb219P45KMzFVjG3HUC0=
In-Reply-To: <uo4h6h$14are$2@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Tue, 16 Jan 2024 02:23 UTC

On 1/15/2024 4:04 PM, bart wrote:
> On 15/01/2024 23:28, Kaz Kylheku wrote:
>> On 2024-01-15, bart <bc@freeuk.com> wrote:
>>>      c:\c>copy hello.c c_code_main
>>>           1 file(s) copied.
>>
>> There goes that damned AT&T instruction syntax for file copying, same
>> like in Unix.
>>
>> Doesn't it bother you that it isn't: copy destination source?
>
> I haven't said anything about in which direction the data goes.
>
> This is something that tends to depend on device, so Motorola went left
> to right, and Zilog/Intel went right to left.
>
> So it did seem odd for this x86 assembler to do the opposite of Intel.
>
> However, doesn't it bother /you/ that AT&T also does the opposite of not
> only how assignment works in C, but in most languages? That would be
> more pertinent than somebody's choices of command-line syntax.
>

Fwiw, just make both, I did AT&T syntax and Intel syntax files. Nice and
neat (I think so) with the C ABI, CDECL.

https://groups.google.com/g/comp.arch/c/6zvMwefWIWw/m/5nIzi8MPAgAJ
___________
Fwiw, I found some of my older 686 code I posted about way back in 2006.
The WayBack Machine is pretty nice!

http://web.archive.org/web/20060214112345/http://appcore.home.comcast.net/appcore/src/cpu/i686/ac_i686_gcc_asm.html

Here is a MASM version:

http://web.archive.org/web/20060214112539/http://appcore.home.comcast.net/appcore/src/cpu/i686/ac_i686_masm_asm.html
___________

No big deal, I just had to do it. So, once it was done, it was done. If
I needed another arch, I would code one up for it (per-arch asm file).
SPARC, no problem. Just keep in mind to NEVER put a memory barrier
instruction in a branch delay slot on SPARC. oh very bad...

Re: Effect of CPP tags

<uo5pdi$1dgnv$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=30990&group=comp.lang.c#30990

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (bart)
Newsgroups: comp.lang.c
Subject: Re: Effect of CPP tags
Date: Tue, 16 Jan 2024 11:30:56 +0000
Organization: A noiseless patient Spider
Lines: 104
Message-ID: <uo5pdi$1dgnv$1@dont-email.me>
References: <umet9d$3hir9$1@dont-email.me> <20240111081109.274@kylheku.com>
<unpd89$33jlu$1@dont-email.me> <20240111133742.530@kylheku.com>
<unpt44$35qn1$1@dont-email.me> <unrfgs$3fo6l$1@dont-email.me>
<unrocu$3h2ah$1@dont-email.me> <20240112132216.285@kylheku.com>
<uo0je6$e8fv$1@dont-email.me> <20240114115640.506@kylheku.com>
<uo24di$lo8r$1@dont-email.me> <20240114222417.720@kylheku.com>
<uo3eli$uv97$1@dont-email.me> <6pbpN.200172$7sbb.118143@fx16.iad>
<uo3jth$vqg9$1@dont-email.me> <B1epN.177806$c3Ea.53953@fx10.iad>
<uo3v2u$11mbu$1@dont-email.me> <20240115152928.267@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 16 Jan 2024 11:30:58 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="fcbb89fd40114758fadb19769f6fd3cc";
logging-data="1491711"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+i0cAHM7zjoCJcfBHBJs7K4gJCZPAB+Wc="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:pJwmEoAhtBmwkpA+rwnLqnWEXl0=
Content-Language: en-GB
In-Reply-To: <20240115152928.267@kylheku.com>
 by: bart - Tue, 16 Jan 2024 11:30 UTC

On 16/01/2024 01:21, Kaz Kylheku wrote:
> On 2024-01-15, bart <bc@freeuk.com> wrote:

[Inline assembly]

> The instruction template is just a string literal to the
> compiler. It specifies text to be inserted into the assembly
> output.
>
> Some assembly languages require the whitespace; you need
> instructions to be on separate lines.
>
> GCC does not look inside this template other than to replace
> % codes like %0 (the first register).
>
> In my example, I put the newlines and tabs together on the right
>
> "imul %3, %2\n\t"
> "add %1, %2\n\t"
> "mov %1, %0\n\t"
>
> Thanks to these newlines and tabs, the textual output (generated .s
> file if we use gcc -S) has this in it:
>
> #APP
> # 24 "inline.c" 1
> imul %edx, %esi
> add %esi, %edi
> mov %edi, %edi
>
> # 0 "" 2
> #NO_APP
> movl 8(%rsp), %eax
> movl 16(%rsp), %edx
>

This is still peculiar: why prioritise the appearance of the
intermediate code which I assume you're rarely going to look at?

It's the version with strings and escape codes that you're going to be
writing and maintaining, and that people will see in the C sources!

This is akin to a language allowing embedded C but you have to write it
like this:

clang{"\tprintf(\"A=%%d\\n\", a);\n"};

so that the generated version looks like:

printf("A=%d\n", a);

Except you can't refer to 'a' directly, you have to write it as %0 and
then have some extra mechanism to somehow map that to 'a'.

> You can understand why GCC went with this textual templating approach, since
> the number of back-end assembly languages is astonishing. In some cases, I
> think, GCC supports more than one assembler syntax for the same architecture.
> Historically it has worked with assemblers that didn't come from GNU.

gcc is a project 10s of 1000s of files. If a particular configuration
targets one architecture out of 100, it can also support the ASM syntax
for that architecture.

You don't need to have the ASM syntax embedded within the C grammar. Not
so specifically anyway; you allow a bunch of keyword and register tokens
within asm{...}.

Yes it's a bit harder, but if I can do it within a 0.3MB product, gcc
can do it within 24MB.

> It would not be practical for GNU C to have a bazillino assembly language
> syntaxes in its grammar.
>
>> Just admit that my approach to inline assembler is better and give it up.
>
> Your approach to inline assembler has nicer looking syntax, but
> semantically, it doesn't seem to be on same level as the GCC approach.
>
> GCC's inline assembly does nice things that are might not be possible in your
> implementation. (Or pretty much anyone else's).
>
> Some of it has been sufficiently exemplified elsewhere in the thread.
>
> GCC can choose registers for your inline assembly block,

The point of ASM is that /you/ call the shots.

It's not just more natural syntax, but better integration within the
host language. More example, I can 'goto' to a label within an ASSEM
block, and 'jmp' out of the ASSEM block to a HLL label, or to an label
within a separate ASSEM block further on.

> and will automatically
> move between those registers and the operands they are connected to (if
> necessary). The inline code seamlessly integrates with the code generated by
> the compiler. You can write primitives that generate code as well as compiler
> built-ins.

OK. But it's not an 'assembler' as is generally understood. Mine is; it
looks exactly line normal assembly, and it is written inline to the HLL.

Although these days I keep such hybrid functions within their own modules.

Re: Effect of CPP tags

<uo5qp3$1dn2m$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=30992&group=comp.lang.c#30992

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (bart)
Newsgroups: comp.lang.c
Subject: Re: Effect of CPP tags
Date: Tue, 16 Jan 2024 11:54:10 +0000
Organization: A noiseless patient Spider
Lines: 53
Message-ID: <uo5qp3$1dn2m$1@dont-email.me>
References: <umet9d$3hir9$1@dont-email.me> <unkkp3$26g9o$1@dont-email.me>
<87ttnmnjdb.fsf@nosuchdomain.example.com> <unkp1b$270v8$1@dont-email.me>
<ZSmnN.151217$c3Ea.70659@fx10.iad> <unkuhp$27i0v$2@dont-email.me>
<unlqqa$2eqts$2@dont-email.me> <U7ynN.143065$Wp_8.30410@fx17.iad>
<unmmnd$2jair$1@dont-email.me> <87edepnich.fsf@nosuchdomain.example.com>
<unmqsg$2jvva$1@dont-email.me> <unmu6b$2kh81$1@dont-email.me>
<20240110133135.834@kylheku.com> <unn65q$2lr2i$1@dont-email.me>
<20240110182957.444@kylheku.com> <unokb1$2vmkh$1@dont-email.me>
<20240111081109.274@kylheku.com> <unpd89$33jlu$1@dont-email.me>
<20240111133742.530@kylheku.com> <unpt44$35qn1$1@dont-email.me>
<unrfgs$3fo6l$1@dont-email.me> <unrocu$3h2ah$1@dont-email.me>
<20240112132216.285@kylheku.com> <uo0je6$e8fv$1@dont-email.me>
<20240114115640.506@kylheku.com> <uo24di$lo8r$1@dont-email.me>
<20240114222417.720@kylheku.com> <20240114231905.155@kylheku.com>
<uo3l28$1010j$1@dont-email.me> <uo3mhi$1073t$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 16 Jan 2024 11:54:11 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="fcbb89fd40114758fadb19769f6fd3cc";
logging-data="1498198"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/yoeQdWSMPW2oGCdvi8ctaGjjCGDHXBRM="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:eUxGFu8+I8Ua5NX9JUu0cEhGS30=
Content-Language: en-GB
In-Reply-To: <uo3mhi$1073t$1@dont-email.me>
 by: bart - Tue, 16 Jan 2024 11:54 UTC

On 15/01/2024 16:29, David Brown wrote:
> On 15/01/2024 17:04, David Brown wrote:
>> On 15/01/2024 08:40, Kaz Kylheku wrote:
>
>>> A mul_add primitive might make sense if the processor had such a thing
>>> in one instruction.
>>>
>>> With GCC inline assembly, you want to only put the essentials into it:
>>> only do what is necessary and only bundle together what must be
>>> bundled.
>>>
>>
>> Yes.  For inline assembly, simple is not really important, but small
>> is beautiful!  Say exactly what you mean, no more and no less, and let
>> the compiler do what it does best.
>>
>>
>> And move to C++20.  Then you can write (for the mythical madd
>> instruction) :
>>
>> constexpr int mul_add(int x, int y, int z)
>> __attribute__((const))
>> {
>>   if (std::is_constant_evaluated()) {
>>      return x + y * z;
>>    } else {
>>      asm("madd %[x], %[y], %[z]"
>>          : [x] "+r" (x) : [y] "g" (y), [z] "g" (z));
>>     return x;
>>    }
>> }
>>
>>
>> Now the compiler can evaluate at compile time if the parameters are
>> known, or using the super-efficient madd instruction at runtime if
>> necessary.
>>
>
> Apologies for replying to my own post, but of course this can be done in
> C with gcc extensions (and when we have inline assembly, we are already
> relying on gcc extensions):
>
> static inline int mul_add(int x, int y, int z)
> __attribute__((const))
> {
>   if (__builtin_constant_p(x + y * z)) {
>      return x + y * z;
>   } else {
>      asm("madd %[x], %[y], %[z]"

Which processor is this for again?

Re: Effect of CPP tags

<uo5skp$1e106$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=30993&group=comp.lang.c#30993

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!news.furie.org.uk!usenet.goja.nl.eu.org!weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (bart)
Newsgroups: comp.lang.c
Subject: Re: Effect of CPP tags
Date: Tue, 16 Jan 2024 12:26:00 +0000
Organization: A noiseless patient Spider
Lines: 140
Message-ID: <uo5skp$1e106$1@dont-email.me>
References: <umet9d$3hir9$1@dont-email.me>
<8734v6p5s1.fsf@nosuchdomain.example.com> <unke3h$25ia0$1@dont-email.me>
<unkhql$25uof$1@dont-email.me> <unkkp3$26g9o$1@dont-email.me>
<87ttnmnjdb.fsf@nosuchdomain.example.com> <unkp1b$270v8$1@dont-email.me>
<ZSmnN.151217$c3Ea.70659@fx10.iad> <unkuhp$27i0v$2@dont-email.me>
<unlqqa$2eqts$2@dont-email.me> <U7ynN.143065$Wp_8.30410@fx17.iad>
<unmmnd$2jair$1@dont-email.me> <87edepnich.fsf@nosuchdomain.example.com>
<unmqsg$2jvva$1@dont-email.me> <unmu6b$2kh81$1@dont-email.me>
<20240110133135.834@kylheku.com> <unn65q$2lr2i$1@dont-email.me>
<20240110182957.444@kylheku.com> <unokb1$2vmkh$1@dont-email.me>
<20240111081109.274@kylheku.com> <unpd89$33jlu$1@dont-email.me>
<20240111133742.530@kylheku.com> <unpt44$35qn1$1@dont-email.me>
<unrfgs$3fo6l$1@dont-email.me> <unrocu$3h2ah$1@dont-email.me>
<20240112132216.285@kylheku.com> <uo0je6$e8fv$1@dont-email.me>
<20240114115640.506@kylheku.com> <uo24di$lo8r$1@dont-email.me>
<uo3ilc$vjmt$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 16 Jan 2024 12:26:01 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="fcbb89fd40114758fadb19769f6fd3cc";
logging-data="1508358"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19gJHeKBiYvFRs+U0per7ibe5lTOw6RUKs="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:tPjAKJoXQ0k3JRoxqe0FIeJ9Uwg=
Content-Language: en-GB
In-Reply-To: <uo3ilc$vjmt$1@dont-email.me>
 by: bart - Tue, 16 Jan 2024 12:26 UTC

On 15/01/2024 15:23, David Brown wrote:
> On 15/01/2024 03:14, bart wrote:

> You pass the relevant data into and out of the inline assembly.  If you
> think you need access to other symbols in the assembly, you are (almost
> certainly) doing things wrong.  You are trying to do the compiler's job
> behind its back, and that is not a good idea.

Not with gcc. You don't want to mess with that.

But /I/ use inline assembler when /I/ in in charge of the code.

>> If /I/ had to write extensive programs in gcc inline assembly, then
>> put a gun to my head now!
>
> If you are trying to write extensive programs in assembly, you are
> already getting it wrong.

I want to write HLL functions that may have a number of lines in
assembly, from one line up to a few dozen.

>  Inline assembly is for things that cannot be
> expressed in high level languages, or the very rare occasions where you
> know a way to do something in assembly that is very much more efficient
> than the compiler can generate, and the code is speed critical, and
> there are no built-ins for the task, and no target intrinsics provided
> by the processor manufacturer.
>
>>
>> Take this example in C:
>>
>>     int a;
>>
>>     void F(void) {
>>          int b=2, c=3;
>>          static int d=4;
>>
>>          a = b + c * d;
>>     }
>>
>> I will now show it in my language but with that assignment replaced by
>> inline assembly:
>>
>>      int a
>>
>>      proc F=
>>          int b:=2, c:=3
>>          static int d=4
>>
>>          assem
>>              mov   rax, [c]               # (note my ints are 64 bits)
>>              imul2 rax, [d]
>>              add   rax, [b]
>>              mov   [a], rax
>>          end
>>      end
>>
>> My question is: what would the C version look like with that line in
>> gcc inline assembly? (In both cases, 'a' should end up with the value
>> 14.)
>
> void F(void) {
>     int b = 2:
>     int c = 3;
>     static int d = 4;
>
>     asm ("imul2 %[c], %[d]\n\t"
>          "add %[c], %[b]"
>         : [c] "+g" (c) : [b] "g" (b), [d] "g" (d));
>     a = c;
> }

Sorry, but you've turned it into gobbledygook. My example was for x64
which is a 1.5 address machine, here you've turned it into a 2-address
machine. Could I make it 3-address? What are the rules?

It is a different language.

> The generated result (from <https://godbolt.org>) is :
>
> F():
>         mov     eax, 3
>         imul2 eax, 4
>         add eax, 2
>         mov     DWORD PTR a[rip], eax
>         ret

The initialisations I used were so I could test that it gave the correct
results. Without them, godbolt gives me this for the body of the function:

movl d.0(%rip), %edx
movl -8(%rbp), %eax
imul2 %eax, %edx
add %eax, -4(%rbp)
movl %eax, -8(%rbp)
movl -8(%rbp), %eax
movl %eax, a(%rip)

My version (which evaluates a=b+c*d; somehow your version modifies c)
gives me this (D0 == rax):

mov D0, [Dframe+test.f.c]
imul2 D0, [test.f.d]
add D0, [Dframe+test.f.b]
mov [test.a], D0

Unsurprisingly, this is exactly the ASM I typed (plus the necessary name
qualifiers). That is the entire point.

If I tweak your C version, make a,b,c,d all external statics, and apply
-O3, godbolt gives me this:

imul2 c(%rip), d(%rip)
add c(%rip), b(%rip)
movl c(%rip), %eax
movl %eax, a(%rip)
ret

This is slightly worrying: imul2 is not a valid instruction (it's
specific to my assembler). While add can't take two memory operands.

So it looks like it can only do so much checking. (Using gcc locally
gave valid assembly.)

So it all seems hit and miss.

I'll reply to the second half of your post later.

Let me just say that, in my interpreter, the extensive use of inline
assembly in one module, makes some programs run twice as fast, as a
gcc-O3-compiled C rendering.

It also lets me write trivial solutions to the LIBFFI problem.

It works.

Re: Effect of CPP tags

<uo5vuu$1f4l9$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=30996&group=comp.lang.c#30996

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: Effect of CPP tags
Date: Tue, 16 Jan 2024 14:22:37 +0100
Organization: A noiseless patient Spider
Lines: 58
Message-ID: <uo5vuu$1f4l9$1@dont-email.me>
References: <umet9d$3hir9$1@dont-email.me> <unso1g$3lb69$2@dont-email.me>
<20240112200241.728@kylheku.com> <untu7e$3u3nv$1@dont-email.me>
<87o7dolxkj.fsf@nosuchdomain.example.com> <unv3ec$48rm$1@dont-email.me>
<87jzoclss6.fsf@nosuchdomain.example.com> <86h6jfls0e.fsf@linuxsc.com>
<uo18fc$ht87$2@dont-email.me> <fYVoN.171150$c3Ea.139646@fx10.iad>
<uo1ec0$iquj$1@dont-email.me> <87o7dndln6.fsf@gmail.com>
<uo35hj$th5s$1@dont-email.me> <87h6jev9c6.fsf@gmail.com>
<uo3u9h$11i75$1@dont-email.me> <csfpN.200177$7sbb.184012@fx16.iad>
<uo4190$121on$1@dont-email.me> <20240115152642.593@kylheku.com>
<uo4h6h$14are$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 16 Jan 2024 13:22:38 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="bab081cccfd299fcf30f3b94f14b8bfe";
logging-data="1544873"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/rxH1pyAYC52hBvjqHS0oSiWhWt713yp8="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.11.0
Cancel-Lock: sha1:RasIrpQJk7JChg1c26lrObT7fug=
Content-Language: en-GB
In-Reply-To: <uo4h6h$14are$2@dont-email.me>
 by: David Brown - Tue, 16 Jan 2024 13:22 UTC

On 16/01/2024 01:04, bart wrote:
> On 15/01/2024 23:28, Kaz Kylheku wrote:
>> On 2024-01-15, bart <bc@freeuk.com> wrote:
>>>      c:\c>copy hello.c c_code_main
>>>           1 file(s) copied.
>>
>> There goes that damned AT&T instruction syntax for file copying, same
>> like in Unix.
>>
>> Doesn't it bother you that it isn't: copy destination source?
>
> I haven't said anything about in which direction the data goes.
>
> This is something that tends to depend on device, so Motorola went left
> to right, and Zilog/Intel went right to left.
>
> So it did seem odd for this x86 assembler to do the opposite of Intel.
>
> However, doesn't it bother /you/ that AT&T also does the opposite of not
> only how assignment works in C, but in most languages? That would be
> more pertinent than somebody's choices of command-line syntax.
>

AFAIUI, AT&T syntax was first for the PDP11, which used left to right
direction. It was later modified and adopted for x86 before Intel had
actually made a good assembly syntax (AFAIK).

I think it has become more common to use right-to-left ordering for
assemblies, but there has never been a real consensus.

In the early days, different groups made their own assemblers, and
sometimes their own assembly language or mnemonics. Certainly they
would use their own choice of directives and other syntax, keeping them
the same as they had for other targets. And if you already make
assemblers that have left-to-right syntax, then it makes sense to keep
that for new targets - it means more re-use of your assembler source
code, and more familiarity for users who deal with multiple targets.
The majority of people working on assembly code for the x86 on *nix
systems (at least early on) would have been familiar with the AT&T
syntax for PDP11, m68k, or other processors - keeping the same style for
x86 made their life easier.

Given a completely free choice, I'd probably choose Intel format for x86
rather than AT&T. But since I don't write x86 assembly, and can read
either format on godbolt, I don't mind much either way.

And given a completely free choice to design a new assembly language for
a processor (pre-existing or new), I think I'd go for a right-to-left
assignment. As you say, it fits better with most programming languages
(other than Forth, Cobol, and some programmable calculator languages).

As for other things like the % before register names - well, you either
have to have special markings for register names or you have to have
special marking for external symbols (at least those from HLL's that
don't carefully avoid clashes with register names). No choice is going
to be perfect for everyone's tastes.

Re: Effect of CPP tags

<uo6023$1f4l9$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=30997&group=comp.lang.c#30997

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!nntp.comgw.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: Effect of CPP tags
Date: Tue, 16 Jan 2024 14:24:19 +0100
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <uo6023$1f4l9$2@dont-email.me>
References: <umet9d$3hir9$1@dont-email.me>
<87ttnmnjdb.fsf@nosuchdomain.example.com> <unkp1b$270v8$1@dont-email.me>
<ZSmnN.151217$c3Ea.70659@fx10.iad> <unkuhp$27i0v$2@dont-email.me>
<unlqqa$2eqts$2@dont-email.me> <U7ynN.143065$Wp_8.30410@fx17.iad>
<unmmnd$2jair$1@dont-email.me> <87edepnich.fsf@nosuchdomain.example.com>
<unmqsg$2jvva$1@dont-email.me> <unmu6b$2kh81$1@dont-email.me>
<20240110133135.834@kylheku.com> <unn65q$2lr2i$1@dont-email.me>
<20240110182957.444@kylheku.com> <unokb1$2vmkh$1@dont-email.me>
<20240111081109.274@kylheku.com> <unpd89$33jlu$1@dont-email.me>
<20240111133742.530@kylheku.com> <unpt44$35qn1$1@dont-email.me>
<unrfgs$3fo6l$1@dont-email.me> <unrocu$3h2ah$1@dont-email.me>
<20240112132216.285@kylheku.com> <uo0je6$e8fv$1@dont-email.me>
<20240114115640.506@kylheku.com> <uo24di$lo8r$1@dont-email.me>
<20240114222417.720@kylheku.com> <20240114231905.155@kylheku.com>
<uo3l28$1010j$1@dont-email.me> <uo3mhi$1073t$1@dont-email.me>
<uo44fg$12ct8$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 16 Jan 2024 13:24:19 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="bab081cccfd299fcf30f3b94f14b8bfe";
logging-data="1544873"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18jE+2ko8sk0HkoBp4iGiaXKK69OASOht0="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.11.0
Cancel-Lock: sha1:zvXdkbLGdZOFDi6rLnSPNAqv3mQ=
Content-Language: en-GB
In-Reply-To: <uo44fg$12ct8$2@dont-email.me>
 by: David Brown - Tue, 16 Jan 2024 13:24 UTC

On 15/01/2024 21:27, Chris M. Thomasson wrote:
> On 1/15/2024 8:29 AM, David Brown wrote:
>> On 15/01/2024 17:04, David Brown wrote:
>>> On 15/01/2024 08:40, Kaz Kylheku wrote:
>>
>>>> A mul_add primitive might make sense if the processor had such a thing
>>>> in one instruction.
>>>>
>>>> With GCC inline assembly, you want to only put the essentials into it:
>>>> only do what is necessary and only bundle together what must be
>>>> bundled.
>>>>
>>>
>>> Yes.  For inline assembly, simple is not really important, but small
>>> is beautiful!  Say exactly what you mean, no more and no less, and
>>> let the compiler do what it does best.
> [...]
>
> Wrt inline GCC assembly, remember __volatile__ and memory? ;^)
>

Yes, these are useful, and I use them - when appropriate.

Re: Effect of CPP tags

<uo60su$1f9o7$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=30998&group=comp.lang.c#30998

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: Effect of CPP tags
Date: Tue, 16 Jan 2024 14:38:38 +0100
Organization: A noiseless patient Spider
Lines: 80
Message-ID: <uo60su$1f9o7$1@dont-email.me>
References: <umet9d$3hir9$1@dont-email.me> <ZSmnN.151217$c3Ea.70659@fx10.iad>
<unkuhp$27i0v$2@dont-email.me> <unlqqa$2eqts$2@dont-email.me>
<U7ynN.143065$Wp_8.30410@fx17.iad> <unmmnd$2jair$1@dont-email.me>
<87edepnich.fsf@nosuchdomain.example.com> <unmqsg$2jvva$1@dont-email.me>
<unmu6b$2kh81$1@dont-email.me> <20240110133135.834@kylheku.com>
<unn65q$2lr2i$1@dont-email.me> <20240110182957.444@kylheku.com>
<unokb1$2vmkh$1@dont-email.me> <20240111081109.274@kylheku.com>
<unpd89$33jlu$1@dont-email.me> <20240111133742.530@kylheku.com>
<unpt44$35qn1$1@dont-email.me> <unrfgs$3fo6l$1@dont-email.me>
<unrocu$3h2ah$1@dont-email.me> <20240112132216.285@kylheku.com>
<uo0je6$e8fv$1@dont-email.me> <20240114115640.506@kylheku.com>
<uo24di$lo8r$1@dont-email.me> <20240114222417.720@kylheku.com>
<20240114231905.155@kylheku.com> <uo3l28$1010j$1@dont-email.me>
<uo3mhi$1073t$1@dont-email.me> <uo44fg$12ct8$2@dont-email.me>
<20240115152033.334@kylheku.com> <uo4p1q$15bb0$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 16 Jan 2024 13:38:38 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="bab081cccfd299fcf30f3b94f14b8bfe";
logging-data="1550087"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+a6jKVKrtEY/1k5iDHy3KhWNh6ZlYtUAU="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.11.0
Cancel-Lock: sha1:WaeqWGRWP1iolJE1rxvhygHOnwg=
In-Reply-To: <uo4p1q$15bb0$1@dont-email.me>
Content-Language: en-GB
 by: David Brown - Tue, 16 Jan 2024 13:38 UTC

On 16/01/2024 03:18, Chris M. Thomasson wrote:
> On 1/15/2024 3:24 PM, Kaz Kylheku wrote:
>> On 2024-01-15, Chris M. Thomasson <chris.m.thomasson.1@gmail.com> wrote:
>>> On 1/15/2024 8:29 AM, David Brown wrote:
>>>> On 15/01/2024 17:04, David Brown wrote:
>>>>> On 15/01/2024 08:40, Kaz Kylheku wrote:
>>>>
>>>>>> A mul_add primitive might make sense if the processor had such a
>>>>>> thing
>>>>>> in one instruction.
>>>>>>
>>>>>> With GCC inline assembly, you want to only put the essentials into
>>>>>> it:
>>>>>> only do what is necessary and only bundle together what must be
>>>>>> bundled.
>>>>>>
>>>>>
>>>>> Yes.  For inline assembly, simple is not really important, but small
>>>>> is beautiful!  Say exactly what you mean, no more and no less, and let
>>>>> the compiler do what it does best.
>>> [...]
>>>
>>> Wrt inline GCC assembly, remember __volatile__ and memory? ;^)
>>
>> The volatile is only important if you're writing sync primitives, so the
>> compiler won't move loads or stores to one side or the other of the
>> inline assembly.

That is not what "volatile" means - either in normal C code, or for gcc
inline assembly!

>> If you're just doing some calculation, it's
>> counterproductive to tell the compiler not to move the code.
>>
>> "memory" is only needed if your inline code clobbers memory. E.g.
>> one of the operands is a pointer, and the code writes through it.
>> That location isn't one of the output operands.
>>
>
> I want my sync primitive code to be _un_abused by any "clever"
> optimizations. I want it is as it is.

What a strange idea!

I want the compiler to be clever and optimise code. But I want to tell
the compiler enough about my inline assembly so that it can optimise
appropriately.

For synchronisation inline assembly, a "memory" clobber is often
required - but usually it is not enough on its own (you need memory
barrier assembly instructions too). And for lots of other uses of
inline assembly, you don't want memory clobbers as they can be costly -
sometimes very wasteful.

"volatile" on inline assembly tells the compiler that the code may use
or cause side-effects other than just what it is told by the inputs,
outputs and clobbers. It will enforce an ordering with respect to other
volatile inline assembly, and other C volatile accesses - but it will
not be ordered with respect to other calculations, non-volatile inline
assembly, or non-volatile loads and stores.

You might think that using "volatile" and a "memory" clobber stops any
re-ordering of code in relation to your inline assembly, but you'd be
wrong. And if you think that, then perhaps an external assembly file is
the easiest way to get the guarantees you want.

> No rouge compiler thinking that
> link-time optimizations are all fun and joy, lets dance around the sync
> instructions... Step on them, ruin them, make them incorrect. Even GCC
> had a nasty error with an optimization wrt Pthread
> pthread_mutex_trylock(). Simply ruined is correctness wrt the standard.
>

You've mentioned this many times - do you have a reference that gives
the source of this function (at the time when there was an issue), and a
description or report of what you think gcc did wrong? I am curious as
to whether it was a bug in the code or a bug in gcc (gcc is certainly
not bug-free).

Re: Effect of CPP tags

<uo6143$1f9o7$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=30999&group=comp.lang.c#30999

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: Effect of CPP tags
Date: Tue, 16 Jan 2024 14:42:27 +0100
Organization: A noiseless patient Spider
Lines: 68
Message-ID: <uo6143$1f9o7$2@dont-email.me>
References: <umet9d$3hir9$1@dont-email.me>
<87ttnmnjdb.fsf@nosuchdomain.example.com> <unkp1b$270v8$1@dont-email.me>
<ZSmnN.151217$c3Ea.70659@fx10.iad> <unkuhp$27i0v$2@dont-email.me>
<unlqqa$2eqts$2@dont-email.me> <U7ynN.143065$Wp_8.30410@fx17.iad>
<unmmnd$2jair$1@dont-email.me> <87edepnich.fsf@nosuchdomain.example.com>
<unmqsg$2jvva$1@dont-email.me> <unmu6b$2kh81$1@dont-email.me>
<20240110133135.834@kylheku.com> <unn65q$2lr2i$1@dont-email.me>
<20240110182957.444@kylheku.com> <unokb1$2vmkh$1@dont-email.me>
<20240111081109.274@kylheku.com> <unpd89$33jlu$1@dont-email.me>
<20240111133742.530@kylheku.com> <unpt44$35qn1$1@dont-email.me>
<unrfgs$3fo6l$1@dont-email.me> <unrocu$3h2ah$1@dont-email.me>
<20240112132216.285@kylheku.com> <uo0je6$e8fv$1@dont-email.me>
<20240114115640.506@kylheku.com> <uo24di$lo8r$1@dont-email.me>
<20240114222417.720@kylheku.com> <20240114231905.155@kylheku.com>
<uo3l28$1010j$1@dont-email.me> <uo3mhi$1073t$1@dont-email.me>
<uo5qp3$1dn2m$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 16 Jan 2024 13:42:27 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="bab081cccfd299fcf30f3b94f14b8bfe";
logging-data="1550087"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Cr8tNXr0KQokDqfQcEAclgKfG6zsEM30="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.11.0
Cancel-Lock: sha1:u3vcb92pYhZnEiieFZ+WLwOR7KM=
In-Reply-To: <uo5qp3$1dn2m$1@dont-email.me>
Content-Language: en-GB
 by: David Brown - Tue, 16 Jan 2024 13:42 UTC

On 16/01/2024 12:54, bart wrote:
> On 15/01/2024 16:29, David Brown wrote:
>> On 15/01/2024 17:04, David Brown wrote:
>>> On 15/01/2024 08:40, Kaz Kylheku wrote:
>>
>>>> A mul_add primitive might make sense if the processor had such a thing
>>>> in one instruction.
>>>>
>>>> With GCC inline assembly, you want to only put the essentials into it:
>>>> only do what is necessary and only bundle together what must be
>>>> bundled.
>>>>
>>>
>>> Yes.  For inline assembly, simple is not really important, but small
>>> is beautiful!  Say exactly what you mean, no more and no less, and
>>> let the compiler do what it does best.
>>>
>>>
>>> And move to C++20.  Then you can write (for the mythical madd
>>> instruction) :
>>>
>>> constexpr int mul_add(int x, int y, int z)
>>> __attribute__((const))
>>> {
>>>   if (std::is_constant_evaluated()) {
>>>      return x + y * z;
>>>    } else {
>>>      asm("madd %[x], %[y], %[z]"
>>>          : [x] "+r" (x) : [y] "g" (y), [z] "g" (z));
>>>     return x;
>>>    }
>>> }
>>>
>>>
>>> Now the compiler can evaluate at compile time if the parameters are
>>> known, or using the super-efficient madd instruction at runtime if
>>> necessary.
>>>
>>
>> Apologies for replying to my own post, but of course this can be done
>> in C with gcc extensions (and when we have inline assembly, we are
>> already relying on gcc extensions):
>>
>> static inline int mul_add(int x, int y, int z)
>> __attribute__((const))
>> {
>>   if (__builtin_constant_p(x + y * z)) {
>>       return x + y * z;
>>    } else {
>>       asm("madd %[x], %[y], %[z]"
>
> Which processor is this for again?
>

It's for a cpu with a "madd" instruction that implements "x = x + y * z"
in a single instruction - as Kaz pointed out, doing this in inline
assembly would make sense if it the cpu had such a dedicated
instruction. Inline assembly is typically used in such situations,
where the processor has a more efficient instruction sequence than the
compiler can generate.

But this mythical cpu uses Intel-style assembly syntax, for your
convenience :-)

Re: Effect of CPP tags

<uo62gj$1finu$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=31000&group=comp.lang.c#31000

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: Effect of CPP tags
Date: Tue, 16 Jan 2024 15:06:10 +0100
Organization: A noiseless patient Spider
Lines: 129
Message-ID: <uo62gj$1finu$1@dont-email.me>
References: <umet9d$3hir9$1@dont-email.me> <20240111081109.274@kylheku.com>
<unpd89$33jlu$1@dont-email.me> <20240111133742.530@kylheku.com>
<unpt44$35qn1$1@dont-email.me> <unrfgs$3fo6l$1@dont-email.me>
<unrocu$3h2ah$1@dont-email.me> <20240112132216.285@kylheku.com>
<uo0je6$e8fv$1@dont-email.me> <20240114115640.506@kylheku.com>
<uo24di$lo8r$1@dont-email.me> <20240114222417.720@kylheku.com>
<uo3eli$uv97$1@dont-email.me> <6pbpN.200172$7sbb.118143@fx16.iad>
<uo3jth$vqg9$1@dont-email.me> <B1epN.177806$c3Ea.53953@fx10.iad>
<uo3v2u$11mbu$1@dont-email.me> <20240115152928.267@kylheku.com>
<uo5pdi$1dgnv$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 16 Jan 2024 14:06:11 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="bab081cccfd299fcf30f3b94f14b8bfe";
logging-data="1559294"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX191AiwkQ597M4XwDgE1bgBjRGcqZ7o/6q4="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.11.0
Cancel-Lock: sha1:B59JgdA4dIpii0aVHyGNWGCpQDY=
Content-Language: en-GB
In-Reply-To: <uo5pdi$1dgnv$1@dont-email.me>
 by: David Brown - Tue, 16 Jan 2024 14:06 UTC

On 16/01/2024 12:30, bart wrote:
> On 16/01/2024 01:21, Kaz Kylheku wrote:
>> On 2024-01-15, bart <bc@freeuk.com> wrote:
>
> [Inline assembly]
>
>> The instruction template is just a string literal to the
>> compiler. It specifies text to be inserted into the assembly
>> output.
>>
>> Some assembly languages require the whitespace; you need
>> instructions to be on separate lines.
>>
>> GCC does not look inside this template other than to replace
>> % codes like %0 (the first register).
>>
>> In my example, I put the newlines and tabs together on the right
>>
>>    "imul %3, %2\n\t"
>>    "add %1, %2\n\t"
>>    "mov %1, %0\n\t"
>>
>> Thanks to these newlines and tabs, the textual output (generated .s
>> file if we use gcc -S) has this in it:
>>
>> #APP
>> # 24 "inline.c" 1
>>          imul %edx, %esi
>>          add %esi, %edi
>>          mov %edi, %edi
>>
>> # 0 "" 2
>> #NO_APP
>>          movl    8(%rsp), %eax
>>          movl    16(%rsp), %edx
>>
>
> This is still peculiar: why prioritise the appearance of the
> intermediate code which I assume you're rarely going to look at?

It's often just habit. The tab character is entirely unnecessary, at
least for gas (other assemblers may complain about instructions
appearing at the start of the line). You do need some kind of
separation between the assembly instructions - if you don't use "\n",
then you could also use ";" (again, I know it works for gas). "\n\t" is
a common habit, however, and has the benefit of looking nice if you
examine the generated assembly - and if you are working with inline
assembly, sometimes that is a very useful thing to check.

>
> It's the version with strings and escape codes that you're going to be
> writing and maintaining, and that people will see in the C sources!
>

Well, you don't often write inline assembly - its rare to write it.
It's typically the kind of thing you write once for your particular
instruction, then stick it away in a header somewhere. You might use it
often, but you don't need to read or edit the code often.

In reality, you don't even often write the inline assembly yourself -
you include a manufacturer-supplied header full of "intrinsics" - small
inline assembly functions wrapping useful assembly instructions.

The whole thing would be nicer if C (or at least gcc) supported a
multi-line string syntax akin to Python's """ ... """ syntax. But it
doesn't. (Actually, such an extension could be very useful for lots of
things.)

>>> Just admit that my approach to inline assembler is better and give it
>>> up.
>>
>> Your approach to inline assembler has nicer looking syntax, but
>> semantically, it doesn't seem to be on same level as the GCC approach.
>>
>> GCC's inline assembly does nice things that are might not be possible
>> in your
>> implementation. (Or pretty much anyone else's).
>>
>> Some of it has been sufficiently exemplified elsewhere in the thread.
>>
>> GCC can choose registers for your inline assembly block,
>
> The point of ASM is that /you/ call the shots.

No.

The point of inline assembly is to do something that you can't do in C
alone (even with compiler extensions).

>
> It's not just more natural syntax, but better integration within the
> host language. More example, I can 'goto' to a label within an ASSEM
> block, and 'jmp' out of the ASSEM block to a HLL label, or to an label
> within a separate ASSEM block further on.
>

You can "goto" C labels in gcc inline assembly. I can't imagine much
real-world use for it, but you can do it. (You use "asm goto" and pass
the labels into the assembly expression.)

I think you are viewing inline assembly as a verbatim list of
instructions inserted blindly into the code generated by the compiler.
I view it more like an expression that fits into the flow of the C code,
and the flow of the generated code. It is working /with/ the compiler,
not /against/ it.

>> and will automatically
>> move between those registers and the operands they are connected to (if
>> necessary). The inline code seamlessly integrates with the code
>> generated by
>> the compiler.  You can write primitives that generate code as well as
>> compiler
>> built-ins.
>
> OK. But it's not an 'assembler' as is generally understood. Mine is; it
> looks exactly line normal assembly, and it is written inline to the HLL.
>

Exactly. gcc inline assembly is inline assembly - it is not an
assembler. (gcc also supports what it calls "basic assembly syntax" -
you create a "naked" function and give a list of assembly instructions.
This is typically used for things like specialised startup code in a
microcontroller, or for task switching in an RTOS.)

> Although these days I keep such hybrid functions within their own modules.
>

It's always good to keep things like this tidied away.


devel / comp.lang.c / Effect of CPP tags

Pages:123456789101112131415161718192021222324252627
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor