Last active
May 13, 2024 07:16
-
-
Save chrislattman/f550ead7a1f19fee57984da8c17fefed to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <sys/syscall.h> // includes SYS_write | |
#include <unistd.h> // includes STDOUT_FILENO | |
#include <string.h> | |
// #include <stdio.h> | |
#if defined(__APPLE__) | |
#ifndef _SYS_SYSCALL_H_ | |
#define SYS_write 4 | |
#endif | |
#elif defined(__linux__) | |
#ifndef _SYSCALL_H | |
#if defined(__amd64__) | |
#define SYS_write 1 | |
#elif defined(__aarch64__) | |
#define SYS_write 64 | |
#endif | |
#endif | |
#endif | |
int main(void) | |
{ | |
const char *str = "Hello, world!\n"; | |
size_t len = strlen(str); | |
// printf("%s", str); | |
// puts(str); | |
// write(STDOUT_FILENO, str, len); | |
syscall(SYS_write, STDOUT_FILENO, str, len); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment