|
leper khan posted:I just realized I could use setjmp longjmp to solve a problem I've been having. You wrote bad code OP. There is never a reason to use longjmp unless you are doing some very hacky poo poo in bare-metal land. edit: Maybe emulating exceptions is a valid excuse to use longjmp. Is that what you are trying to do? FlapYoJacks fucked around with this message at 05:52 on Sep 27, 2023 |
# ? Sep 27, 2023 05:49 |
|
|
# ? May 26, 2024 19:18 |
|
it is kind of fascinating that longjmp is a thing that exists as a standard. it is basically the impulse "eh, i'll just rewrite the stack and bit and set the program counter to where i wanted to be, what can really go wrong?" made into a really bad function. there's almost no legitimate use of it of course, as you basically need to be in a place where you'd be comfortable just operating on that stuff directly *anyway*, and if you are in that position you're probably in a bit of software where you have the infrastructure for doing it more idiomatically.
|
# ? Sep 27, 2023 09:36 |
|
eschaton posted:if setjmp and longjmp are somehow “solving” a problem for you, then something is seriously wrong with your approach I'm trying to optimize out reads and writes to memory in a couple specific cases. I don't really have a choice on using the slow memory or not, since I don't have enough fast memory for my sim and I'd like to reserve it for the program stack.
|
# ? Sep 27, 2023 14:46 |
|
Re: exceptions. Basically yes, I have a top level construct that executes through a queue and I want to early out the top level executor if I make a particular transition in one of the jobs.
|
# ? Sep 27, 2023 14:49 |
|
using longjmp in the right place is fine, you cowards if you're already programming in C, why not take advantage of what few primitive are actually provided to you
|
# ? Sep 27, 2023 14:54 |
|
i think it boils down to "if you have to ask, you probably don't need it"
|
# ? Sep 27, 2023 15:16 |
|
calling it "a primitive" is such a generous characterization of longjmp. also simply don't code in c.
|
# ? Sep 27, 2023 15:16 |
|
Cybernetic Vermin posted:simply don't code, c, myeeeah
|
# ? Sep 27, 2023 15:18 |
|
Cybernetic Vermin posted:calling it "a primitive" is such a generous characterization of longjmp. you can either use it well or use it poorly or choose to not use it at all, just like any other wrench in your toolbelt Cybernetic Vermin posted:also simply don't code in c.
|
# ? Sep 27, 2023 15:40 |
|
Cybernetic Vermin posted:calling it "a primitive" is such a generous characterization of longjmp. What other options do I have? I'd rather not write ASM and manually port to other architectures. And not all platforms I'm targeting have a C++ compiler.
|
# ? Sep 27, 2023 15:46 |
|
leper khan posted:What other options do I have? I'd rather not write ASM and manually port to other architectures. And not all platforms I'm targeting have a C++ compiler. If you were really set on a longjmp alternative you could consider some abstraction layer like libunwind (I'm sure there are others, too, this is just the one that came to mind) or you could continue and just use longjmp for what by all accounts sounds like a reasonable use for it e: or you could port your codebase to a superior language with continuations
|
# ? Sep 27, 2023 15:49 |
|
Dijkstracula posted:If you were really set on a longjmp alternative you could consider some abstraction layer like libunwind (I'm sure there are others, too, this is just the one that came to mind) I need to read the programming manual for my compiler before I use setjmp. It might not support it lol.
|
# ? Sep 27, 2023 15:55 |
|
leper khan posted:I need to read the programming manual for my compiler before I use setjmp. It might not support it lol. if your compiler is standards-conforming it will as it's part of the language standard and not, like, a POSIX or GNU extension or something
|
# ? Sep 27, 2023 15:58 |
|
Dijkstracula posted:if your compiler is standards-conforming it will as it's part of the language standard and not, like, a POSIX or GNU extension or something It's from the 90s I'm not making assumptions
|
# ? Sep 27, 2023 15:59 |
|
leper khan posted:It's from the 90s I'm not making assumptions yeah, fair, truly who could say in the wild world of (I'm assuming) ancient embedded software development
|
# ? Sep 27, 2023 16:02 |
|
Dijkstracula posted:I'm gonna do it, I'm gonna code in C!!!
|
# ? Sep 27, 2023 16:46 |
|
coding in C is the best, it’s how you make the spookiest code
|
# ? Sep 27, 2023 17:32 |
|
Sweeper posted:coding in C is the best, it’s how you make the spookiest code the reason for the season
|
# ? Sep 27, 2023 17:44 |
|
Dijkstracula posted:yeah, fair, truly who could say in the wild world of (I'm assuming) ancient embedded software development Ancient embedded software development for Japanese handheld game consoles. Special versions of dead compilers specific to whatever terrible barely unique processor. The real solve is I need better hobbies.
|
# ? Sep 27, 2023 17:51 |
|
leper khan posted:The real solve is I need better hobbies.
|
# ? Sep 27, 2023 17:52 |
|
Dijkstracula posted:such as porting C compilers to ancient Japanese handheld game consoles I know someone doing that and I'm unironically eagerly awaiting their efforts.
|
# ? Sep 27, 2023 17:53 |
|
out of curiosity, what's the hardware, are you posting updates to a project log or anything
|
# ? Sep 27, 2023 17:54 |
|
Sweeper posted:coding in C is the best, it’s how you make the spookiest code I still love this video https://www.youtube.com/watch?v=Snr113r5ocY
|
# ? Sep 27, 2023 18:19 |
|
spookiest compiler flag? -ffast-math?
|
# ? Sep 27, 2023 18:27 |
|
Dijkstracula posted:out of curiosity, what's the hardware, are you posting updates to a project log or anything Wonderswan and wonderswan color are my primary targets. Avoiding posting too much about the project because I haven't scrubbed all the unlicensed art out of it yet (only one thing left; I should just get that patched out) I have working ports to a bunch of hardware. Ran into some issues with the neo geo pocket toolchain [compiler hard crashes on my project without logging anything] (which I really want to make work for cross play between ngp and dreamcast). There's some recent improvements in toolchains for pc engine, but I'm not sure if I'd be able to fit the game without the ram from supergrafx.
|
# ? Sep 27, 2023 19:05 |
|
Dijkstracula posted:using longjmp in the right place is fine, you cowards you should be using getcontext/setcontext/makecontext/swapcontext instead
|
# ? Sep 27, 2023 19:20 |
|
pseudorandom name posted:you should be using getcontext/setcontext/makecontext/swapcontext instead those are pretty slow though, just roll your own fast stack swapping code for every arch
|
# ? Sep 27, 2023 19:25 |
|
Sweeper posted:spookiest compiler flag? -ffast-math? -w
|
# ? Sep 27, 2023 19:29 |
|
Sweeper posted:spookiest compiler flag? -ffast-math? -Ofast. really should be called -Ounsafe
|
# ? Sep 27, 2023 19:50 |
|
-Onoooooo
|
# ? Sep 27, 2023 21:58 |
|
gotta -Ofast
|
# ? Sep 27, 2023 22:49 |
|
-Wall is kinda spooky because it leaves many warnings spookily turned off!
|
# ? Sep 27, 2023 22:56 |
|
-funroll-loops it's got 'fun' right in the name!
|
# ? Sep 27, 2023 23:07 |
|
The_Franz posted:-funroll-loops certainly the silliest compiler flag
|
# ? Sep 27, 2023 23:55 |
|
-OooooOOOOooooOOOOOooo
|
# ? Sep 28, 2023 00:40 |
|
i always laugh at -Wextra
|
# ? Sep 28, 2023 00:50 |
|
Dijkstracula posted:well of course it is a language primitive, no more or less so than local goto keyword or signals or any other non-structured control flow mechanism that is part of the language it’s not though, it’s part of the standard library
|
# ? Sep 28, 2023 01:03 |
|
leper khan posted:What other options do I have? I'd rather not write ASM and manually port to other architectures. And not all platforms I'm targeting have a C++ compiler. sure they do, LLVM has a backend that can generate ANSI C89 so you can use clang++ as a glorified CFront it may have bitrotted over the past decade though so you may need to do some forward-porting work first
|
# ? Sep 28, 2023 01:05 |
|
as we all know, the c standard library is a well-designed and complete collection of functions which behave consistently across platforms, compilers, and libc implementations, so every c programmer can feel confident in making use of them
|
# ? Sep 28, 2023 01:09 |
|
|
# ? May 26, 2024 19:18 |
|
eschaton posted:it’s not though, it’s part of the standard library Why is this a distinction that matters? The language spec says what goes into the standard library, and setjmp is defined in it, so unless you really want to get nitpicky about "goto is a lexical token whereas setjmp is a macro that expands to something implementation-specific", as far as anyone actually cares they are both components of the language
|
# ? Sep 28, 2023 01:17 |