Skip to content

Instantly share code, notes, and snippets.

@carloslack
carloslack / 0 - UNIX Fifth Edition
Created November 26, 2017 20:54 — forked from fogus/0 - UNIX Fifth Edition
UNIX V5, OpenBSD, Plan 9, FreeBSD, and GNU coreutils implementations of echo.c
main(argc, argv)
int argc;
char *argv[];
{
int i;
argc--;
for(i=1; i<=argc; i++)
printf("%s%c", argv[i], i==argc? '\n': ' ');
}
#!/bin/bash
# No execution (syntax check)
#set -n
# Debug
#set -x
# Deploy RDK image & rootfs into NFS directory
#
/*
* huebr
*/
#include <stdio.h>
#include <stdbool.h>
int arg(int x, const char *name)
{
printf("%s: %d %s\n", __func__, x, name);
return 0;
/**
* syscalltable.c
*
* A friend of mine asked few questions about
* (quite deprecated) syscall hooking tecnikz
* and went into a question asking why some sys_call_table
* entry ptr finders algorithms out there return a pointer to pointer (**), C doubts.
*
* I didn't look in detail, yet, at sys call table kernel impl so I
* started assuming (keep not looking closer because tonight I am feeling lazy)
/*
* shared.c
*
* _Old_ POC (the final version would be much more complex and interesting)
* code for an embedded device TV implementing
* a custom memory allocator for two 'clients', to each one
* is given a memory endpoint segmentation, one starting from
* left to right and the other one starting from right to left
* until they reach each other then we cannot allocate more slots.
*
#
# Example code reading/printing
# each given command line argument.
#
########################
# Sets current argument index into
# given register
.macro NARG reg
popl %eax
@carloslack
carloslack / hash.c
Last active December 13, 2015 18:48
Hash table: Chaining
#include <stdio.h>
#include <stdlib.h>
#define HASHTSIZ 512
typedef struct innerlist_t
{
int val;
struct innerlist_t *next;
}innerlist_t;