- alloca()-support - 1 Update
- Rolling link list - 2 Updates
- strange issue ... - 9 Updates
- Why I'm now trailing main's int - 2 Updates
- Compile a program from all C and C++ files in current folder - 2 Updates
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Oct 05 02:08PM -0700 On 10/2/2019 3:47 PM, Anton Shepelev wrote: >> Will have more time to get back to you later on tonight. >> However, take a deep look at reaps: >> https://people.cs.umass.edu/~emery/pubs/berger-oopsla2002.pdf [...] I was using it for systems that did not have malloc. Here is a example usage: This region allocator does not force all allocations to be aligned up to a so-called maximum alignment like `malloc' and friends are required to do. For instance, allocations for a single char will not be forced to waste the extra alignment space. This can have benefits in space constrained environments (e.g., embedded devices). Also, its static in nature and can be fed with a buffer residing on the stack. There are no underlying calls to `malloc'. This can be useful in free standing environments that do not support heap allocation. One other thing. Its a pure region allocator which means you do not need to free individual objects. You can free the entire region. This is more efficient than calling `malloc()/free()' for each object. For instance, you can destroy all the nodes in a linked list just by freeing the region(s) in which the nodes were allocated from. There is no need to traverse the list to free its nodes. Its a sort of "manual" garbage collection... ;^) You can use it like: _________________________________________________________________ #include <ralloc.h> struct foo { struct foo* next; }; #include <stdio.h> void crunch() { char local_buffer[1024]; struct region local_region; struct foo* head1 = NULL; struct foo* head2 = NULL; size_t i, r; rinit(&local_region, local_buffer, sizeof(local_buffer)); for (r = 0; r < 1024; ++r) { size_t c = 0; for (i = 0; i < 64; ++i) { struct foo* foo = ralloct(&local_region, 2, struct foo); if (foo) { foo->next = head1; head1 = foo; ++foo; foo->next = head2; head2 = foo; c += 2; } } while (head1) { head1 = head1->next; --c; } while (head2) { head2 = head2->next; --c; } assert(! c); rflush(&local_region); } } int main(void) { crunch(); crunch(); crunch(); return 0; } _________________________________________________________________ |
Jorgen Grahn <grahn+nntp@snipabacken.se>: Oct 05 06:39AM On Fri, 2019-10-04, Rick C. Hodgin wrote: > range are no longer of any interest and can fall off the list. Kind > of like having a console window with content shown on the screen for > a fixed size, but without a scroll-back buffer. I didn't read carefully, but isn't that a circular buffer? - Maybe Boost has something. - You could wrap std::list or std::deque lightly. - You could wrap std::array if you're after the efficiency aspects of a circular buffer. /Jorgen -- // Jorgen Grahn <grahn@ Oo o. . . \X/ snipabacken.se> O o . |
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Oct 05 10:35AM -0400 On 10/5/2019 2:39 AM, Jorgen Grahn wrote: > - You could wrap std::list or std::deque lightly. > - You could wrap std::array if you're after the efficiency aspects > of a circular buffer. Kind of. With a linked list you could insert nodes in the middle, but if they're all just push_back() then it is. I was just wondering if something template / stock already existed. -- Rick C. Hodgin |
David Brown <david.brown@hesbynett.no>: Oct 05 11:52AM +0200 On 04/10/2019 19:42, Bonita Montero wrote: > I quoted the C++17 standard which says that a definition isn't necessary > when the member isn't odr-accessed and Wikipedia says that this is since > C++11. Did you specify C++17 standard when you compiled? IIRC, gcc defaults to C++14 (or, more accurately, g++14) these days. It is entirely possible, likely even, that when using C++17 there are extra assembly declarations generated to make it work without an extra definition. |
Bonita Montero <Bonita.Montero@gmail.com>: Oct 05 12:41PM +0200 >> C++11. > Did you specify C++17 standard when you compiled? IIRC, gcc > defaults to C++14 (or, more accurately, g++14) these days. The above rule is since C++11. |
Melzzzzz <Melzzzzz@zzzzz.com>: Oct 05 11:04AM > I quoted the C++17 standard which says that a definition isn't necessary > when the member isn't odr-accessed and Wikipedia says that this is since > C++11. This is pretty impossible if you generate object file. This is only possible if you make executable from all source files. -- 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 05 01:09PM +0200 On 05/10/2019 12:41, Bonita Montero wrote: >> Did you specify C++17 standard when you compiled? IIRC, gcc >> defaults to C++14 (or, more accurately, g++14) these days. > The above rule is since C++11. C++17 has changed some of the details here. Since you won't show the code, and don't give details of the builds, it's impossible to guess where your problem lies. One possibility is that your code is affected by these details, and you are using different standards on the different compilers. <https://en.cppreference.com/w/cpp/language/static> The other likely possibility is that your code has an error, but some compilers (or linkers) are more forgiving of that error than others. The possibility that you are right and gcc has a bug exists, but is /way/ down on the list of likelihoods. If you post a small, compilable snippet demonstrating the issue, then we can figure it out. If gcc has a bug, then we will all learn something, and an issue can be filed so that gcc gets fixed. If the bug is in your code or your understanding, then /you/ will learn something - as might others following the thread. But if you continue to hide the problem, we have no choice but to assume you are wrong and you don't want to be corrected. |
Bonita Montero <Bonita.Montero@gmail.com>: Oct 05 01:21PM +0200 >> The above rule is since C++11. > C++17 has changed some of the details here. No, I've quoted from the C++17 draft-standard. It says the same cppreference and the Wikipedia says. And the example-code is also the samle like on cppreference. |
Bonita Montero <Bonita.Montero@gmail.com>: Oct 05 01:23PM +0200 >> C++11. > This is pretty impossible if you generate object file. This is only > possible if you make executable from all source files. Boy, you're so stupid. |
Melzzzzz <Melzzzzz@zzzzz.com>: Oct 05 11:32AM >> This is pretty impossible if you generate object file. This is only >> possible if you make executable from all source files. > Boy, you're so stupid. If I am stupid, you are batshit stupid... -- 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 |
Bo Persson <bo@bo-persson.se>: Oct 05 01:53PM +0200 On 2019-10-05 at 13:21, Bonita Montero wrote: > No, I've quoted from the C++17 draft-standard. It says the same > cppreference and the Wikipedia says. And the example-code is also > the samle like on cppreference. If you *are* coding for C++17, you can use constexpr for the constants and avoid the problem entirely. If you don't use C+17, it doesn't matter what the newest standard says. Bo Perssob |
Bonita Montero <Bonita.Montero@gmail.com>: Oct 05 04:35PM +0200 >> the samle like on cppreference. > If you *are* coding for C++17, you can use constexpr for the constants > and avoid the problem entirely. I use static const. > If you don't use C+17, it doesn't matter what the newest standard says. Google, and you find out that this is identical with C++17 an C++11. |
David Brown <david.brown@hesbynett.no>: Oct 05 01:00PM +0200 On 04/10/2019 18:56, Alf P. Steinbach wrote: > Visual C++ 2019 doesn't support C++11 and newer values of `__cplusplus` > by default, and at some point not too far back earlier versions simply > didn't support it at all. Really? I never use MSVC, so I must accept your word for that. People have been writing: #ifdef __cplusplus extern "C" {
Subscribe to:
Post Comments (Atom)
|
No comments:
Post a Comment