handmade.social is one of the many independent Mastodon servers you can use to participate in the fediverse.
handmade.social is for all handmade artisans to create accounts for their Etsy and other handmade business shops.

Server stats:

36
active users

#cplusplus

0 posts0 participants0 posts today

Due to the impending shutdown of my old server, I'm moving here from my account @deoxys314@neovibe.app. And so a new #Introduction is in order! I'm a software developer with a degree in #Geology and #GIS. I mostly work in #Python and #CPlusPlus. My personal interests include #Dinosaurs (#Stegosaurus is my favorite), #LEGO, #mtg, #MagicTheGathering, #Math, #cooking and #Reading, to name a few.

I have some old posts I'll bring over here, mostly longer threads that are worth preserving.

Was writing C++ code that deals with very large files in memory. Sometimes the files in question are larger than physical memory. I wrote my C++ code to catch memory allocation failures and terminate gracefully,

But that is not what happens. On modern Unixes, the kernel's OOM (out-of-memory) process will kill a process to terminate it before the process itself gets a a chance to terminate gracefully.

How do folks deal with this?

stackoverflow.com/questions/58
#linux #macOS #cpp #cplusplus

Stack OverflowDetecting that a child process was killed because the OS is out of memoryI'm working on a large-scale application that spawns numerous processes for dealing with various tasks. In some situations, the OS will kill one of my processes because of memory pressure. That's o...

TIL: zero size types take up no space in the calling conventions for x86_64.
Hence tag dispatch is totally invisible, not taking up any of the useful calling registers or padding out the stack space. This is not the case for armv8, these tags take space.
godbolt.org/z/nadE7ne7K
So I think that means that it is preferable to do tag dispatch as the last argument of a function. The idea is not to waste useful registers. Is that a good take?

godbolt.orgCompiler Explorer - C++struct Tag {}; void dispatch(Tag, int, int); void dispatch(int, Tag, int); void dispatch(int, int, Tag); // what happen when we spill to the stack // edi, esi, edx, ecx, r8d, r9d .... stack // w0, w1, w2, w3, w4, w5, w6, w7, .... stack void dispatch(int, int, int, int, int, int, /*x86_64*/ int, int, /*armv8-a*/ int, Tag, int); void test() { dispatch(Tag(), 1, 2); dispatch(3, Tag(), 4); dispatch(5, 6, Tag()); dispatch(7, 8, 9, 10, 11, 12, 13, 14, 15, Tag(), 16); }