Skip to content

Instantly share code, notes, and snippets.

@develhox
develhox / mutex.h
Created April 13, 2015 19:35
C99 Mutex implementation to avoid same-thread deadlock and define locked portions of code
#ifndef __MUTEX_H__
#define __MUTEX_H__
#include <pthread.h>
/**
* Mutex type
*/
typedef struct {
pthread_mutex_t mutex; // pthread mutex
@develhox
develhox / switchs.h
Last active November 5, 2023 14:25
Switch operand implementation for the strings
#ifndef __SWITCHS_H__
#define __SWITCHS_H__
#include <string.h>
#include <regex.h>
#include <stdbool.h>
/** Begin a switch for the string x */
#define switchs(x) \
{ char *ss__sw = (x); bool ss__done = false; bool ss__cont = false; \