previous: >>108058648#define __NR_pause 34https://man7.org/linux/man-pages/man2/pause.2.htmlsimple and to the point. i love that in a syscall. honestly, this seems like a pretty handy tool. kind of like a ghetto condition variable, or a sleep, etc. just have to be particular about your signaling. with that being said, i've never actually used this syscall, and i'm not aware of anyone who has, either. what about you, anons?relevant resources: man manman syscallshttps://man7.org/linux/man-pages/https://linux.die.net/man/https://elixir.bootlin.com/linux/https://elixir.bootlin.com/musl/https://elixir.bootlin.com/glibc/
#define __NR_pause 34
man man
man syscalls
>>108066842she can't even tie her own shoelaces, lamao
>>108066842>simple and to the point.
>>108066980shrimple as
>>108066842i don't trust myself with such low level primitivesI'll stick to more declarative concurrency constructs
>>108066842I'm kinda new to this and started learning C recently and I have a question: is it possible to use a syscall without libc? so far the only way I know of how to do this is inline assembly, but at that point you're really writing assembly and not C, so does C have sort of keyword as sort of catch all syscaller? something like syscall(eax, ebx, ecx, edx, ...etc) that expands to appropriate inline assembly at compile time?
>>108066961Lol
>>108067368>is it possible to use a syscall without libc?yes>so far the only way I know of how to do this is inline assemblythat is the only way to do it>so does C have sort of keyword as sort of catch all syscaller?no. copy paste this into your codebase: https://elixir.bootlin.com/musl/v1.2.5/source/arch/x86_64/syscall_arch.h
>>108067368>>108067401oh, and then of course you can use a varargs macro to call the appropriate syscall function
>>108067401Okay I guess C is only really just assembly with macros, I think I get why people call it a low level language even though I still think it's high level, but it is the lowest high level language IMO.>https://elixir.bootlin.com/musl/v1.2.5/source/arch/x86_64/syscall_arch.hThanks! I was actually looking for the source code of these syscalls.
>>108067368>>108067471C has nothing to do with syscalls. The system call is just a special instruction that jumps to a specified address and saves the state so it can return to the program that called it, and it sometimes switches CPU modes too. There is no way to use that instruction in C, so you have to use assembly which is the same thing you would do in any other language. There's nothing special about system calls at all, if you know how they work. It's just save the return address somewhere, get a new address from somewhere else, change the CPU mode to allow privileged instructions, then jump to the new address. C has no way to use any of those privileged instructions either.
>>108066842Seems sort of similar to SIGSTOP? Unless you're waiting for some kind of more general signal from a process that isn't in on the pause() shenanigans?>>108067471>Okay I guess C is only really just assembly with macrosNot exactly. Inline assembly is a non-standard feature, the traditional approach is to write the code in a separate assembly file and then link that into your program as a library.Usually if you dig into a library it's C code all the way down. You only get assembly for certain funny hardware tricks like syscalls and for extreme optimization.The main thing that sets C apart from other popular natively compiled languages is that it doesn't add (much) invisible code for cleanup and memory management and such. The only code that runs is the code that you write out explicitly.