Skip to content

Instantly share code, notes, and snippets.

@icebarf
icebarf / README.md
Last active October 17, 2025 14:01
shared object stuff
$ g++ -o libcode.so code.cpp -ldl -rdynamic -shared -fPIC -std=c++20
$ g++ -o main main.cpp -rdynamic -std=c++20 -Os

The -rdynamic flag when compiling the executable adds the unused symbols to the table so we can use the definition from the main/executable file in the shared object's foo() call.

@icebarf
icebarf / fcfs_impl_from_class.cpp
Last active April 3, 2025 08:56
Various Process scheduling algorithms asked to be implemented in OS Lab
/* FCFS Example Program by Amritpal Singh is marked with CC0 1.0 Universal.
* To view a copy of this license, visit
* https://creativecommons.org/publicdomain/zero/1.0/
* Copy of Program at:
* https://gist.github.com/icebarf/8815aaed5bcca117518369c6428d7cb3/#file-fcfs_impl_from_class-cpp
*/
#include <cstdint>
#include <cstdio>
@icebarf
icebarf / generic_list.c
Last active April 28, 2024 15:28
A meme generic linked list implementation in C.
#include "generic_list.h"
#include <string.h>
#define UNUSED(X) (void)X
// supply your own
typedef struct iNode
{
size_t index;
struct iNode *next;