Re: technology discussion → does the world need a "new" C ?

Liste des GroupesRevenir à l c 
Sujet : Re: technology discussion → does the world need a "new" C ?
De : bc (at) *nospam* freeuk.com (bart)
Groupes : comp.lang.c
Date : 09. Jul 2024, 15:54:06
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v6jiud$1dsjb$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
User-Agent : Mozilla Thunderbird
On 09/07/2024 15:31, David Brown wrote:
On 08/07/2024 19:39, BGB wrote:

Though, this one seems to be a common point of divergence between "SysV" and "Microsoft" ABIs. Sometimes a target will have an ABI defined, and the MS version was almost the same, just typically differing in that it passes structs by reference and provides a spill space for register arguments.
>
 I don't think it is helpful that you keep mixing /logical/ terms with /implementation/ terms.
 In C, there is no "pass by reference" or "return by reference".  It is all done by value.
Arrays are passed by reference:
   void F(int a[20]) {}
   int main(void) {
     int x[20];
     F(x);
   }
Although the type of 'a' inside 'F' will be int* rather than int(*)[20].

So if you have these structs and declarations :
 struct small { uint16_t a; uint16_t b; };
struct big { uint32_t xs[10]; };
 struct small foos(struct small y);
struct big foob(struct big y);
 Then compilers will typically implement "x = foos(y)" as though it were:
      extern uint32_t foos(uint32_t ab);
     uint32_t _1 = foos(y.a << 16) | (y.b);
     struct small x = { _1 >> 16, _1 & 0xffff };
 And they will typically implement "x = foosb(y)" as though it were:
      extern void foob(struct big * ret, const struct big * xs);
     struct big x;
     foob(&x, &y);
 From what I've seen, structs that are not small enough to be passed in registers, are copied to a temporary, and the address of that temporary is passed.
This seems to be the case even when the struct param is marked 'const'.
(My compiler won't create a copy when the parameter is 'const'. I assumed that was how gcc did it; I was wrong.)
This is for Win64 ABI, however an ABI will only say they are passed by reference; it will not stipulate making a copy. That is up to the language implementation.

Date Sujet#  Auteur
5 Jul 24 * Re: technology discussion → does the world need a "new" C ?305BGB
5 Jul 24 +* Re: technology discussion → does the world need a "new" C ?2Lawrence D'Oliveiro
5 Jul 24 i`- Re: technology discussion → does the world need a "new" C ?1yeti
5 Jul 24 +* Re: technology discussion → does the world need a "new" C ?275Keith Thompson
5 Jul 24 i+- Re: technology discussion → does the world need a "new" C ?1Lawrence D'Oliveiro
15 Jul 25 i`- 
5 Jul 24 +* Re: technology discussion → does the world need a "new" C ?26bart
5 Jul 24 i+- Re: technology discussion → does the world need a "new" C ?1BGB
6 Jul 24 i`* Re: technology discussion → does the world need a "new" C ?24Lawrence D'Oliveiro
6 Jul 24 i +* Re: technology discussion → does the world need a "new" C ?17Keith Thompson
6 Jul 24 i i+- Re: technology discussion → does the world need a "new" C ?1Janis Papanagnou
6 Jul 24 i i`* Re: technology discussion → does the world need a "new" C ?15Lawrence D'Oliveiro
6 Jul 24 i i +- Re: technology discussion → does the world need a "new" C ?1Ben Bacarisse
6 Jul 24 i i +- Re: technology discussion → does the world need a "new" C ?1Keith Thompson
7 Jul 24 i i +* Re: technology discussion → does the world need a "new" C ?10James Kuyper
10 Jul 24 i i i`* Re: technology discussion → does the world need a "new" C ?9Lawrence D'Oliveiro
10 Jul 24 i i i `* Re: technology discussion → does the world need a "new" C ?8James Kuyper
11 Jul 24 i i i  `* Re: technology discussion → does the world need a "new" C ?7Lawrence D'Oliveiro
11 Jul 24 i i i   +* Re: technology discussion → does the world need a "new" C ?2David Brown
11 Jul 24 i i i   i`- Re: technology discussion → does the world need a "new" C ?1Malcolm McLean
11 Jul 24 i i i   +* Re: technology discussion → does the world need a "new" C ?3bart
11 Jul 24 i i i   i`* Re: technology discussion → does the world need a "new" C ?2Chris M. Thomasson
12 Jul 24 i i i   i `- Re: technology discussion → does the world need a "new" C ?1Chris M. Thomasson
11 Jul 24 i i i   `- Re: technology discussion → does the world need a "new" C ?1James Kuyper
7 Jul 24 i i +- Re: technology discussion → does the world need a "new" C ?1Tim Rentsch
25 Aug 24 i i `- Re: technology discussion ? does the world need a "new" C ?1dave thompson 2
6 Jul 24 i +- Re: technology discussion → does the world need a "new" C ?1Janis Papanagnou
6 Jul 24 i +- Re: technology discussion → does the world need a "new" C ?1James Kuyper
6 Jul 24 i `* Re: technology discussion → does the world need a "new" C ?4bart
7 Jul 24 i  `* Re: technology discussion → does the world need a "new" C ?3Keith Thompson
7 Jul 24 i   `* Re: technology discussion → does the world need a "new" C ?2bart
7 Jul 24 i    `- Re: technology discussion → does the world need a "new" C ?1Keith Thompson
5 Jul 24 `- Re: technology discussion → does the world need a "new" C ?1lexi hale

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal