Bonita Montero <Bonita.Montero@gmail.com>: Oct 01 02:53PM +0200 > later. C++ doesn't support VLAs at all, so there's no need for a C++ > compiler to indicate its lack of support, and the C++ standard doesn't > require it to do so. It might help to port C99-code to C++ when C++ would define this macro appropriately. Code could conditionally disable VLA-dependent parts. |
scott@slp53.sl.home (Scott Lurndal): Oct 01 03:19PM >The compiler usually uses RPB to remember the frame-pointer-address >at the prolog of the function. EBP is more suitable because it can >be restored in one step by the x86 LEAVE-instruction. So what? The RSP is restored automatically by the ret instruction. int f(unsigned long len) { char *f = alloca(len); for (int i=0; i < 0; i++) { *f++ = '\0'; } return 0; } gcc output: 0000000000400540 <f>: #include <alloca.h> #include <stdlib.h> int f(unsigned long len) { 400540: 55 push %rbp 400541: 48 89 e5 mov %rsp,%rbp 400544: 48 83 ec 20 sub $0x20,%rsp 400548: 48 89 7d e8 mov %rdi,-0x18(%rbp) char *f = alloca(len); 40054c: 48 8b 45 e8 mov -0x18(%rbp),%rax 400550: 48 8d 50 0f lea 0xf(%rax),%rdx 400554: b8 10 00 00 00 mov $0x10,%eax 400559: 48 83 e8 01 sub $0x1,%rax 40055d: 48 01 d0 add %rdx,%rax 400560: b9 10 00 00 00 mov $0x10,%ecx 400565: ba 00 00 00 00 mov $0x0,%edx 40056a: 48 f7 f1 div %rcx 40056d: 48 6b c0 10 imul $0x10,%rax,%rax 400571: 48 29 c4 sub %rax,%rsp <===== Alloca(len) 400574: 48 89 e0 mov %rsp,%rax <===== Remember f in %rax 400577: 48 83 c0 0f add $0xf,%rax <===== Align it 40057b: 48 c1 e8 04 shr $0x4,%rax 40057f: 48 c1 e0 04 shl $0x4,%rax 400583: 48 89 45 f8 mov %rax,-0x8(%rbp) <== And save in stack frame for (int i=0; i < 0; i++) { 400587: c7 45 f4 00 00 00 00 movl $0x0,-0xc(%rbp) 40058e: eb 13 jmp 4005a3 <f+0x63> *f++ = '\0'; 400590: 48 8b 45 f8 mov -0x8(%rbp),%rax 400594: 48 8d 50 01 lea 0x1(%rax),%rdx 400598: 48 89 55 f8 mov %rdx,-0x8(%rbp) 40059c: c6 00 00 movb $0x0,(%rax) 40059f: 83 45 f4 01 addl $0x1,-0xc(%rbp) 4005a3: 83 7d f4 00 cmpl $0x0,-0xc(%rbp) 4005a7: 78 e7 js 400590 <f+0x50> *f++ = '\0'; } return 0; 4005a9: b8 00 00 00 00 mov $0x0,%eax } 4005ae: c9 leaveq 4005af: c3 retq |
Bonita Montero <Bonita.Montero@gmail.com>: Oct 01 05:31PM +0200 >> at the prolog of the function. EBP is more suitable because it can >> be restored in one step by the x86 LEAVE-instruction. > So what? The RSP is restored automatically by the ret instruction. Yes, but LEAVE does three instructions in one step. Usually this results in the same uOPs, but it is only one slot in the decoder. |
Manfred <noname@add.invalid>: Oct 01 05:45PM +0200 On 9/30/2019 8:01 PM, Soviet_Mario wrote: > ah, if not to annoying, TURNING OFF most if not all optimizationz (maybe > the example is too minimal to be sort of resolved at compile time :\) > tnx in advance AFAIU this is a feature of the language and compiler, not of QT, so probably your limitation is not because you use QT per se, but instead because C++ does not have VLAs. Trying to force VLAs via asm in C++ would probably open a can of worms not worth the benefit. A more viable alternative could be having the code that needs VLAs implemented in C modules linked to C++, or switch to std::vector. If it is directly coupled to QT itself, e.g. GUI handlers, then the performance gap of using std::vector is most probably neglectable. (and, of course, there still is _alloca() if it is supported by the compiler) |
Melzzzzz <Melzzzzz@zzzzz.com>: Oct 01 06:49PM >>> C++ hasn't VLAs. >> No, neiter has alloca... > Doesn't matter since most compilers support alloca(). Which one does not supports VLA and supports alloca? -- press any key to continue or any other to quit... U ničemu ja ne uživam kao u svom statusu INVALIDA -- Zli Zec Na divljem zapadu i nije bilo tako puno nasilja, upravo zato jer su svi bili naoruzani. -- Mladen Gogala |
Melzzzzz <Melzzzzz@zzzzz.com>: Oct 01 06:58PM >> So what? The RSP is restored automatically by the ret instruction. > Yes, but LEAVE does three instructions in one step. Usually this > results in the same uOPs, but it is only one slot in the decoder. I never saw any compiler that uses `leave`. Especially since RBP doesn't have to be used as optimization... -- press any key to continue or any other to quit... U ničemu ja ne uživam kao u svom statusu INVALIDA -- Zli Zec Na divljem zapadu i nije bilo tako puno nasilja, upravo zato jer su svi bili naoruzani. -- Mladen Gogala |
David Brown <david.brown@hesbynett.no>: Oct 01 09:10PM +0200 On 01/10/2019 17:31, Bonita Montero wrote: >> So what? The RSP is restored automatically by the ret instruction. > Yes, but LEAVE does three instructions in one step. Usually this > results in the same uOPs, but it is only one slot in the decoder. I don't know this case, but typically on modern cpus "complex" instructions like "leave" are slower than manual expanding the instructions using "pop", "ret", etc. The easiest way to find out is to do a test compile (godbolt.org is great for it) making sure you have cpu-specific tuning flags and optimisations enabled, and look at the output. The compiler writers know better than most of us which instruction patterns are the most efficient. |
Bonita Montero <Bonita.Montero@gmail.com>: Oct 01 09:20PM +0200 >>> No, neiter has alloca... >> Doesn't matter since most compilers support alloca(). > Which one does not supports VLA and supports alloca? I'm using C++ and C++ hasn't VLAs. But almost any C++-compiler supports alloca(). |
Bonita Montero <Bonita.Montero@gmail.com>: Oct 01 09:24PM +0200 >> Yes, but LEAVE does three instructions in one step. Usually this >> results in the same uOPs, but it is only one slot in the decoder. > I never saw any compiler that uses `leave`. MSVC and gcc always use LEAVE when you have dynamic stack-frames with VLAs (gcc) or alloca(). Here's an example of gcc with VLAs: #include <stddef.h> void f( size_t s ) { int volatile a[s]; a[s - 1] = 123; } .file "x.c" .text .p2align 4,,15 .globl f .type f, @function f: .LFB0: .cfi_startproc leaq 18(,%rdi,4), %rax pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 subq $1, %rdi andq $-16, %rax movq %rsp, %rbp .cfi_def_cfa_register 6 subq %rax, %rsp movl $123, (%rsp,%rdi,4) leave .cfi_def_cfa 7, 8 ret .cfi_endproc .LFE0: .size f, .-f .ident "GCC: (Debian 6.3.0-18+deb9u1) 6.3.0 20170516" .section .note.GNU-stack,"",@progbits |
Bonita Montero <Bonita.Montero@gmail.com>: Oct 01 09:25PM +0200 > I don't know this case, but typically on modern cpus "complex" > instructions like "leave" are slower than manual expanding the > instructions using "pop", "ret", etc. That's wrong. |
scott@slp53.sl.home (Scott Lurndal): Oct 01 08:39PM >>> Doesn't matter since most compilers support alloca(). >> Which one does not supports VLA and supports alloca? >I'm using C++ and C++ hasn't VLAs. g++ does, as an extension. |
scott@slp53.sl.home (Scott Lurndal): Oct 01 08:44PM >> instructions like "leave" are slower than manual expanding the >> instructions using "pop", "ret", etc. >That's wrong. From the Intel optimization guide: The Intel 64 and IA-32 architectures have several commonly used instructions for parameter passing and procedure entry and exit: PUSH, POP, CALL, LEAVE and RET. These instructions implicitly update the stack pointer register (RSP), maintaining a combined control and parameter stack without software intervention. These instruc- tions are typically implemented by several ops in previous microarchitectures. The Stack Pointer Tracker moves all these implicit RSP updates to logic contained in the decoders themselves. The feature provides the following benefits: · Improves decode bandwidth, as PUSH, POP and RET are single op instructions in Intel Core microarchitecture. · Conserves execution bandwidth as the RSP updates do not compete for execution resources. · Improves parallelism in the out of order execution engine as the implicit serial dependencies between ops are removed. · Improves power efficiency as the RSP updates are carried out on small, dedicated hardware. Assembly/Compiler Coding Rule 31. (ML impact, M generality) Avoid using complex instructions (for example, enter, leave, or loop) that have more than four µops and require multiple cycles to decode. Use sequences of simple instructions instead. Complex instructions may save architectural registers, but incur a penalty of 4 µops to set up parameters for the microsequencer ROM. |
Chris Vine <chris@cvine--nospam--.freeserve.co.uk>: Oct 01 01:53PM +0100 On Tue, 1 Oct 2019 13:25:12 +0200 > There are even some public figures who have made fools of themselves by > comparing "software pirates" or "media pirates" to /real/ pirates on the > Somalian coast. These semantic discussions are a waste of time. What does it matter if breaching copyright (the principles but not details of which are mainly uniform within the "western" world) is "piracy" or "theft". It is unlawful and can render you liable to civil damages, and is normally a criminal offence if done for profit (it is within the EU, North America and some other places). |
Chris Vine <chris@cvine--nospam--.freeserve.co.uk>: Oct 01 02:07PM +0100 On 30 Sep 2019 14:47:24 GMT > completely legal. Only sharing (therefore, downloading with torrents > qualify) is not. For some reason it's different only with computer > programs and games. Then you are not in the EU or North America. As regards the EU, the current EU Copyright Directive is Directive 2019/790, supplementing Directive 2001/29/EC, and would preclude these things. Elsewhere, I am surprised that downloading books and movies is legal under the World Intellectual Property Organization treaties but if you tell me it is, so be it. I also can't see what difference it makes whether it is propagated by a torrent or not. Are you in China? |
David Brown <david.brown@hesbynett.no>: Oct 01 03:33PM +0200 On 01/10/2019 14:53, Chris Vine wrote: > unlawful and can render you liable to civil damages, and is normally a > criminal offence if done for profit (it is within the EU, North America > and some other places). Of course it matters. If you steal something from me, I no longer have it. If you copy something I wrote, I still have the original. Calling copyright infringement "theft" is wrong. Calling it "piracy" is downright silly. Driving 10 km/h over the speed limit is illegal, because it increases the risk of dangerous accidents. So if you are caught doing it, you get a fine - and hopefully as a result, you won't do it again. Do you think it would be a good idea to call it attempted mass murder, on the basis that you might have killed someone? Copyright infringement is illegal, and you should not do it. That does not mean it is theft, piracy, or a crime. No fair justice system would treat it that way. So why would you want to mix the terms? But you are right that such semantic discussions are mostly a waste of time, as people rarely take any new understanding to heart and continue to muddle their terms. Hopefully, however, the guy whose question started this branch, has learned a little from it. |
Chris Vine <chris@cvine--nospam--.freeserve.co.uk>: Oct 01 04:10PM +0100 On Tue, 1 Oct 2019 15:33:35 +0200 > time, as people rarely take any new understanding to heart and continue > to muddle their terms. Hopefully, however, the guy whose question > started this branch, has learned a little from it. On the principle of "theft", I don't agree. If you steal a book of mine you deprive me of it. If you unlawfully copy the book and deliberately make it available for download online, you deprive me of book sales. The wrong is analogous if not direct. You are liable to me in civil damages for my losses, and a court can issue an injunction on my application restraining the unlawful publication. You wrong as a matter of fact about criminality. Not all breach of copyright is a criminal offence in addition to being a civil wrong, but where done for profit it usually is. You are simply wrong that for breaches of copyright "it does not mean it is ... a crime". In the UK the provision in question is section 107 of the Copyright, Designs and Patents Act 1988 as amended and you can read it at your leisure here: http://www.legislation.gov.uk/ukpga/1988/48/section/107 . Article 61 of the Agreement on Trade-Related Aspects of Intellectual Property Rights (covering all members of the World Trade Organization) requires that signatory countries establish criminal procedures and penalties in cases of "willful trademark counterfeiting or copyright piracy on a commercial scale". Directive 2001/29/EC is more opaque about criminal offences: Article 8.1 says that "Member States shall provide appropriate sanctions and remedies in respect of infringements of the rights and obligations set out in this Directive and shall take all the measures necessary to ensure that those sanctions and remedies are applied. The sanctions thus provided for shall be effective, proportionate and dissuasive." The need for them to be dissuasive implies criminal sanction for willful commercial breach of copyright and I believe all EU members have in fact implemented such sanctions, if only because they are also members of TRIPS. The paucity of your argument is made evident by your implication that I was comparing copyright infringement to mass murder, or any other kind of unlawful killing for that matter. No fair reading of my post could possibly imply that. Nor for that matter do I think that when people refer to copyright "piracy" (I did not) they are making a similar suggestion. I do say that there is an analogy to theft. And I do say that the semantic arguments are a waste of time. |
queequeg@trust.no1 (Queequeg): Oct 01 04:10PM > Then you are not in the EU or North America. I'm in Poland, which unfortunately is part of the EU. > As regards the EU, the current EU Copyright Directive is Directive > 2019/790, supplementing Directive 2001/29/EC, and would preclude these > things. I don't know about EU laws, but Polish law allows it. http://www.copyright.gov.pl/media/download_gallery/Act%20on%20Copyright%20and%20Related%20Rights.pdf See articles 23 and 116. > I also can't see what difference it makes whether it is propagated by > a torrent or not. I don't know details of the bittorrent protocol, but it's widely agreed that if you use it to download a file, you're inherently sharing it. Maybe there are (modified?) clients that allow you to only download without uploading even a tiny bit... -- https://www.youtube.com/watch?v=9lSzL1DqQn0 |
Keith Thompson <kst-u@mib.org>: Oct 01 11:50AM -0700 >> blowing severity of that misconduct committed out of proportions. > Yes, it is certainly true that people talk about "music piracy" or > "software piracy". "Piracy" is a commonly used term for copyright infringement. You made several posts saying simply that it's "never piracy" before you got around to letting anyone know what point you were making (that you disagree with the way the word is used). I'm not saying that piracy is or is not an appropriate term. I'm saying that you wasted everyone's time by not making your point clearly, and by continuing this off-topic discussion *which is not about C++*. -- Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst> Will write code for food. void Void(void) { Void(); } /* The recursive call of the void */ |
Chris Vine <chris@cvine--nospam--.freeserve.co.uk>: Oct 01 07:58PM +0100 On 01 Oct 2019 16:10:09 GMT > that if you use it to download a file, you're inherently sharing it. Maybe > there are (modified?) clients that allow you to only download without > uploading even a tiny bit... Thank you for the link. However, I cannot see how your summary of the law in Poland is consistent with it, having regard to the economic rights given to copyright owners under Division 2 of Chapter 3 and the permitted use exceptions in Division 3 of that Chapter. Those provisions give rise to civil liabilities (Chapter 9), but I note that the criminal sanctions under Chapter 14 are also somewhat far reaching. This seems to me to be a relatively unexceptional implementation of Directive 2001/29/EC, not far distant from the implementation in the UK. Bittorent seems to me to be completely irrelevant. |
David Brown <david.brown@hesbynett.no>: Oct 01 09:07PM +0200 On 01/10/2019 17:10, Chris Vine wrote: > The wrong is analogous if not direct. You are liable to me in civil > damages for my losses, and a court can issue an injunction on my > application restraining the unlawful publication. I think you are misunderstanding what "theft" means. If you have a physical book, and I take it from you unlawfully, it is stealing - you no longer have the book, and I have it. If you have a computer file and I copy it unlawfully, it is not theft of the file - you still have the file. If you had planned to make money from that file, and can't now that I have an unlawful copy that I pass on to others, it is not theft of the file - you still have the file. It is not theft of your lost income, because you never had that income to take (it is potential income, not real money), and I don't have the money either. If it is over a certain limit, it is a crime - but it is not theft. If I break your fingers, thus depriving you from income from working as a programmer, I am committing a crime - but I did not steal your fingers. You are also mixing up crimes with unlawful actions. A "crime" is when you do something against the state - you can be arrested by police, charged in a criminal court, and jailed or fined by the court - if proven guilty beyond all reasonable doubt. In civil lawsuits, you do something against another person that does not harm the state - such as copyright infringement, breaking a contract, etc. You cannot be arrested for it, but you can be summed to a civil court. The case is decided on "burden of evidence" (i.e., a fair fight between the parties), and the losing part must pay compensation to the winner, and perhaps abide by injunctions - but you cannot be imprisoned. (This is based on my rough understanding, and on an average for Western judicial systems. Don't take it as legal advice!) > You wrong as a matter of fact about criminality. Not all breach of > copyright is a criminal offence in addition to being a civil wrong, No breach of copyright is a criminal office - it is a civil offence. > but > where done for profit it usually is. You are simply wrong that for > breaches of copyright "it does not mean it is ... a crime". Depriving someone of their expected income can be a criminal offence. In some jurisdictions, there are additional laws making things like breaking encryption systems a criminal offence. But it is not the copyright breach that is the crime - it is the other matters or consequences of it. (And even when it leads to a crime, that crime is not "theft" and it most certainly is not "piracy".) > refer to copyright "piracy" (I did not) they are making a similar > suggestion. I do say that there is an analogy to theft. And I do say > that the semantic arguments are a waste of time. I did not in any way imply that you viewed copyright infringement as being akin to mass murder. (I /have/ seen public figures claim it is as bad as real piracy, which can involve murders - but I am not suggesting at all that you think that.) And I agree that when people talk about "software piracy" they do not mean "real piracy". But they often /do/ think it is theft, which is wrong. I believe we agree that simple copyright infringement is typically a civil matter, leading perhaps to being sued for compensation. And we agree that more serious cases, such as when copies are sold or the the rightful owner loses significant money, can be crimes. What we do not agree on is the name of the crime (when it is a crime). AFAIK, it is never "theft". And it is never "piracy" - though people use that term. People also incorrectly call it a crime, "theft" or "piracy" even for cases that are not a crime at all. I believe you will not find anyone in this newsgroup who could honestly deny having ever breached a copyright. But I believe you will find very few who would admit to being a criminal, a thief, or a pirate. The terms /do/ matter. But it is probably still a waste of time arguing about the terms. |
Chris Vine <chris@cvine--nospam--.freeserve.co.uk>: Oct 01 08:22PM +0100 On Tue, 01 Oct 2019 11:50:55 -0700 > I'm saying that you wasted everyone's time by not making your point > clearly, and by continuing this off-topic discussion *which is not > about C++*. A fair point as regards topicality, but any C++ source code is a protected work under copyright, and both (a) commercial exploitation of that code, and (b) protection of open source code, depends on effective copyright protection. On point (b), the GPL (copyleft) would be worthless without effective controls on copying. Proprietary code may also be protected by patents which is another kettle of fish. But the topic is sort-of on topic, particularly given the original posting which prompted it. |
Chris Vine <chris@cvine--nospam--.freeserve.co.uk>: Oct 01 08:29PM +0100 On Tue, 1 Oct 2019 21:07:39 +0200 > I think you are misunderstanding what "theft" means. [snip] I said copyright infringement, particularly for commercial purposes, was analogous to theft. It is. > No breach of copyright is a criminal office - it is a civil offence. [snip] You are completely and utterly wrong, and bewilderingly so. I gave you links to the provisions which indicate what copyright infringement is a criminal offence (to which another poster has now added Polish law). I hope for honesty on your part so I assume you have not got around to reading any of it. |
Keith Thompson <kst-u@mib.org>: Oct 01 12:52PM -0700 David Brown <david.brown@hesbynett.no> writes: [161 lines deleted] > But it is probably still a waste of time arguing about the terms. Yes. -- Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst> Will write code for food. void Void(void) { Void(); } /* The recursive call of the void */ |
Manfred <noname@add.invalid>: Oct 01 03:20PM +0200 On 10/1/2019 9:20 AM, David Brown wrote: > interested in others' appearances, personal life, etc. - programmers are > rarely the most social of people, and they are relatively immune to the > social pressures that are often behind prejudice. This part of the story. > background will be different outside of North America, Europe and > Australasia, but the gender dominance will not.) This is a hard barrier > to entry for people who don't fit the programmer norm. It is true that the majority may be male, but If a young woman > wants to study programming at university, she will be faced with "Why do > you want to be a programmer? It's a guy thing - for nerds who live in > their parent's basement". This is where I disagree. I don't think it is realistic. It is not even realistic any more in jobs like car repairing, metal industry or similar stereotypes, much less in a young job market as SW development. I agree with the opinion of Richard on this point. Other programmers either don't care, or are >> is a distant memory to anyone who was alive at the time. >> At this point, the barrier is one of individual motivation and >> interest and nothing more. This is where I agree. > There is no barrier that we, the programmers themselves, have erected. > Yet there is still a barrier. It is a matter of personal interest and motivation, it is not a barrier. |
Frederick Gotham <cauldwell.thomas@gmail.com>: Oct 01 05:49AM -0700 On Tuesday, October 1, 2019 at 12:37:59 PM UTC+1, Frederick Gotham wrote: > The very first time you compile your program, it creates dependency files (*.c.d and *.cpp.d), so if you change a header file and then go to recompile the program, it should only recompile the source files that included that one header file. Actually this doesn't work. If you delete all the ".d" files then it doesn't re-create them like it should. |
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
No comments:
Post a Comment