photog.social is one of the many independent Mastodon servers you can use to participate in the fediverse.
🌈 An inclusive place for your photos, silliness, and convos! 🌈

Administered by:

Server stats:

263
active users

#define

0 posts0 participants0 posts today
Harry Sintonen<p>So how does CVS use pagealign_xalloc? Like this:</p><p>/* Allocate more buffer_data structures. */<br>/* Get a new buffer_data structure. */<br>static struct buffer_data *<br>get_buffer_data (void)<br>{<br> struct buffer_data *ret;</p><p> ret = xmalloc (sizeof (struct buffer_data));<br> ret-&gt;text = pagealign_xalloc (BUFFER_DATA_SIZE);</p><p> return ret;<br>}</p><p>Surely BUFFER_DATA_SIZE will be something sensible? Unfortunately it is not:</p><p><a href="https://infosec.exchange/tags/define" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>define</span></a> BUFFER_DATA_SIZE getpagesize ()</p><p>So it will by create total_data_size / pagesize number of list nodes in the linear list. Maybe it's not that bad if the nodes are released in an optimal order?</p><p>The pagealign code stores new nodes always to the head of its list:</p><p> new_node-&gt;next = memnode_table;<br> memnode_table = new_node;</p><p>The datanodes in CVS code are however inserted into a list tail:</p><p> newdata = get_buffer_data ();<br> if (newdata == NULL)<br> {<br> (*buf-&gt;memory_error) (buf);<br> return;<br> }</p><p> if (buf-&gt;data == NULL)<br> buf-&gt;data = newdata;<br> else<br> buf-&gt;last-&gt;next = newdata;<br> newdata-&gt;next = NULL;<br> buf-&gt;last = newdata;</p><p>This creates a pathological situation where the nodes in the aligned list are in worst possible order as buf_free_datas() walks the internal list in first to last node, calling the pagealign_free:</p><p>static inline void<br>buf_free_datas (struct buffer_data *first, struct buffer_data *last)<br>{<br> struct buffer_data *b, *n, *p;<br> b = first;<br> do<br> {<br> p = b;<br> n = b-&gt;next;<br> pagealign_free (b-&gt;text);<br> free (b);<br> b = n;<br> } while (p != last);<br>}</p><p>In short: This is very bad. It will be slow as heck as soon as large amounts of data is processed by this code.</p><p>So imagine you have 2GB buffer allocated by using this code on a system that has 4KB pagesize. This would result in 524288 nodes. Each node would be stored in two lists, in first one they're last-head and in the other they're last-tail.</p><p>When the buf_free_datas is called for this buffer, it will walk totalnodes - index pagealign nodes for each of the released nodes. First iteration is (524288 - 1) "unnecessary" node walks, second (524288 - 2) and so forth. In other terms "sum of all integers smaller than itself", so in total totalnodes * (totalnodes - 1) / 2 extra operations.</p><p>This gives 137438691328 iterations.</p>
Daniel Collin<p><span class="h-card" translate="no"><a href="https://mastodon.gamedev.place/@michaellabbe" class="u-url mention" rel="nofollow noopener" target="_blank">@<span>michaellabbe</span></a></span> While this my own code only I enforce it at API boundary, but I provide a macro like this S("My string") that is like this </p><p><a href="https://mastodon.gamedev.place/tags/define" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>define</span></a> STRING_ENSURE_STRING_LITERAL(x) ("" x "")<br><a href="https://mastodon.gamedev.place/tags/define" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>define</span></a> S(str) ((struct String){ .data = STRING_ENSURE_STRING_LITERAL(str), .length = sizeof(str) - 1, .is_static = 1 })</p><p>I also have a string_from_cstr("foo") in case it's really needed, but rarely it isn't I have found.</p>
Joe Groff<p><span class="h-card" translate="no"><a href="https://infosec.exchange/@david_chisnall" class="u-url mention" rel="nofollow noopener" target="_blank">@<span>david_chisnall</span></a></span> you can use `typeof` for this too</p><p><a href="https://f.duriansoftware.com/tags/define" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>define</span></a> Const(x) typeof(const typeof(x))<br><a href="https://f.duriansoftware.com/tags/define" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>define</span></a> Volatile(x) typeof(volatile typeof(x))</p><p>Const(int *) pointer_that_is_const;<br>Const(int) * pointer_to_const;</p>
Oriel Jutty :hhHHHAAAH:<p><span class="h-card" translate="no"><a href="https://mastodon.social/@Aradayn" class="u-url mention" rel="nofollow noopener" target="_blank">@<span>Aradayn</span></a></span> <span class="h-card" translate="no"><a href="https://icosahedron.website/@bstacey" class="u-url mention" rel="nofollow noopener" target="_blank">@<span>bstacey</span></a></span> </p><pre><code>#include &lt;stdio.h&gt;<br>#include &lt;string.h&gt;<br><br>#define FOR_EACH(letter, word) \<br> for (const char *_p = "." #word; (_p = strchr(_p + 1, *#letter)); )<br><br>int main(void) {<br> FOR_EACH(b, blueberry) {<br> puts("yay");<br> }<br>}<br></code></pre>
Foone🏳️‍⚧️<p><span class="h-card" translate="no"><a href="https://oldbytes.space/@gloriouscow" class="u-url mention" rel="nofollow noopener" target="_blank">@<span>gloriouscow</span></a></span> my money is on timing. can you <a href="https://digipres.club/tags/define" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>define</span></a> every printf into a usleep() or such?</p>
Dan Sugalski<p><span class="h-card"><a href="https://queer.party/@beccadax" class="u-url mention" rel="nofollow noopener" target="_blank">@<span>beccadax</span></a></span> <span class="h-card"><a href="https://mastodon.social/@siracusa" class="u-url mention" rel="nofollow noopener" target="_blank">@<span>siracusa</span></a></span> Ah, it's easy to tell -- signals! That's where both UNIX and C end... in tears.</p><p>(Separately, for the OP, this is why you should always have a header somewhere that <a href="https://weatherishappening.network/tags/define" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>define</span></a>'s TRUE 0 and FALSE 1, just in case! Not that you'd want to use it everywhere, of course, that'd just be silly)</p>
Markus Osterhoff<p>Aha, ich war mal kurn in den Quellcode abgetaucht.</p><p>./app/tools/gimplevelstool.c Zeile 458 setzt die Höhe dieser Dreiecke auf CONTROL_HEIGHT, was ein <a href="https://troet.cafe/tags/define" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>define</span></a> mit Wert 10 ist, also nur compile-time-konfigurierbar, nicht nachträglich.</p><p>./app/widgets/gimphandlebar.c ab Zeile 176 werden die drei Dreiecke mittels `cairo_(move|line)_to` gemalt.</p><p>Jetzt erstmal bisschen Wald, später dann einen Patch schreiben und neu kompilieren.</p><p>gimp 2.10.38-r2, Gentoo, falls es bei Euch in anderen Zeilen ist.</p>
Matteꙮ Italia<p><span class="h-card" translate="no"><a href="https://mastodon.social/@ShadSterling" class="u-url mention" rel="nofollow noopener" target="_blank">@<span>ShadSterling</span></a></span> <span class="h-card" translate="no"><a href="https://mastodon.social/@hisham_hm" class="u-url mention" rel="nofollow noopener" target="_blank">@<span>hisham_hm</span></a></span> <span class="h-card" translate="no"><a href="https://mastodon.social/@mcc" class="u-url mention" rel="nofollow noopener" target="_blank">@<span>mcc</span></a></span> for the "forward compatibility" part, the Linux base system generally has got you covered, although a big difference with Win32 is that the Linux kernel APIs cover only a small fraction of the Win32 functionality, and the rest is generally provided by other libraries/software, which may not give the same guarantees (and may or may not be easily bundled). Being able to easily target old versions of the platform IMO is important to let the "stable platform" continue being useful through the years; in Win32-land that was generally easy: APIs minimum OS versions are marked, there's a single "big" version number to target (and to <a href="https://hachyderm.io/tags/define" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>define</span></a>), and the API was really rich since ages (pretty much the only stuff that I'm missing targeting Windows XP are modern concurrency primitives).</p>
Alexis, ENDLESS HORNETS<p>Oh lol nm I misspelled the <code>#define</code>. I guess maybe I should figure out how to run the linter on this, huh? :neofox_laugh_sweat:</p>
Alexis, ENDLESS HORNETS<p>Oh come <em>onnnnnnn</em> I turned off that <code>#define</code></p>
Alexis, ENDLESS HORNETS<p>...after navigating the several missing dependencies and misset <code>#define</code>s on this rather unusual system, and because I forgot to run <code>make bootstrap</code>...</p>
Mark T. Tomczak<p><span class="h-card" translate="no"><a href="https://hachyderm.io/@jenniferplusplus" class="u-url mention" rel="nofollow noopener" target="_blank">@<span>jenniferplusplus</span></a></span> Shit, there's a name for this epistemological error and I can't remember what it is right now.</p><p>It's the one where "You see a cow in a field and you point to it and go 'oh hey, there's a cow in that field.' Turns out it's a cow statue. <em>But</em>, there's a cow sleeping behind the statue that you can't see and you don't know about, completely unrelated to the cow statue. You were right about the number of cows in the field, but you weren't <em>right</em>-right because your true conclusion depends on faulty premises."</p><p>I need to rememorize the name of this one because it comes up <em>all the time</em> in software engineering (one of my first "WTFs" as a baby intern was looking at some code where a flag was passed in from an entirely different family of flags, just completely bonkers wrong, like answering the question "Should I stop or go" with "POT ROAST!".... except both "GO" and "POT_ROAST" were <code>#define</code> to be 1 so the code worked for <em>years</em>).</p>
Changelog<p>💥 It's Changelog &amp; Friends!</p><p>Welcome back to <a href="https://changelog.social/tags/define" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>define</span></a>, our game of obscure jargon, fake definitions, and expert tomfoolery. This time we're joined by three Changelog++ members, to see who has the best vocabulary and who can trick everyone else into thinking that they do.</p><p>👉 <a href="https://changelog.am/103" rel="nofollow noopener" translate="no" target="_blank"><span class="invisible">https://</span><span class="">changelog.am/103</span><span class="invisible"></span></a> <a href="https://changelog.social/tags/podcast" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>podcast</span></a></p>
witch_t *navi<a href="https://stackoverflow.com/questions/33051108/how-to-get-around-the-linux-too-many-arguments-limit/33278482" rel="nofollow noopener" target="_blank">https://stackoverflow.com/questions/33051108/how-to-get-around-the-linux-too-many-arguments-limit/33278482</a><br><br>&gt; I have to pass 256Kb of text as an argument to the "aws sqs"<br><br>what, uhhh, what<br><br>&gt; MAX_ARG_STRLEN is defined as 32 times the page size in linux/include/uapi/linux/binfmts.h:<br>&gt; The default page size is 4 KB so you cannot pass arguments longer than 128 KB.<br>&gt; I modified linux/include/uapi/linux/binfmts.h to <a class="hashtag" href="https://social.vlhl.dev/tag/define" rel="nofollow noopener" target="_blank">#define</a> MAX_ARG_STRLEN (PAGE_SIZE * 64), recompiled my kernel and now your code produces<br><br>casually patching the kernel to send a quarter megabyte as a *single* argument oh my god i'm laughing hard
Kushal Das :python: :tor: 🇸🇪<p><a href="https://toots.dgplug.org/tags/define" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>define</span></a> anxiety HIGH</p>
Freya (it/its)𒀭𒈹𒍠𒊩<p>Solaris you're cursed. We've had to add</p><p><a href="https://chaosfem.tw/tags/ifndef" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>ifndef</span></a> NI_MAXHOST<br><a href="https://chaosfem.tw/tags/define" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>define</span></a> NI_MAXHOST 1025 // As per POSIX recommendation<br><a href="https://chaosfem.tw/tags/endif" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>endif</span></a></p><p><a href="https://chaosfem.tw/tags/ifndef" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>ifndef</span></a> NI_MAXSERV<br><a href="https://chaosfem.tw/tags/define" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>define</span></a> NI_MAXSERV 32 // As per POSIX recommendation<br><a href="https://chaosfem.tw/tags/endif" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>endif</span></a></p><p>To like 6 C source files to get pgsql to build</p>
Joe Groff<p><span class="h-card" translate="no"><a href="https://mastodon.social/@whitequark" class="u-url mention" rel="nofollow noopener" target="_blank">@<span>whitequark</span></a></span> thing is, i think you could actually make this work</p><p>```<br>enum class old_t { OLD };</p><p><a href="https://f.duriansoftware.com/tags/define" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>define</span></a> old new (old_t::OLD)</p><p>class Oldable {<br> static void *operator new(size_t size, align_val_t align, old_t);<br>}</p><p>Oldable *foo() { return old Oldable; }<br>```</p>
SpaceLifeForm<p><span class="h-card" translate="no"><a href="https://newsie.social/@TheConversationUS" class="u-url mention" rel="nofollow noopener" target="_blank">@<span>TheConversationUS</span></a></span> </p><p><a href="https://infosec.exchange/tags/Define" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>Define</span></a> SMALLTOWN ANYTOWN</p>
Biason::Julio::new();<pre><code>#define IMAGING_PIXEL_RGB(im, x, y) ((im)-&gt;image[(y)][(x) * 4])<br>#define IMAGING_PIXEL_RGBA(im, x, y) ((im)-&gt;image[(y)][(x) * 4])<br>#define IMAGING_PIXEL_CMYK(im, x, y) ((im)-&gt;image[(y)][(x) * 4])<br></code></pre><p>I'm still wondering why would you keep the image in Y-by-X in memory, but still access it X-by-Y.</p>
Una, lost&found<p><code>#define ACC_V120_THRESHOLD 1</code></p>