Skip to content

Instantly share code, notes, and snippets.

@vchernov
vchernov / Makefile
Created March 21, 2013 20:26
General-purpose Makefile for C++ programs
CXX = g++
LINKER = g++
AR = ar cr
LINKER_SO = g++ -shared
# package name
PACKAGE = $(shell basename $(shell pwd))
# platform
PLATFORM = $(shell uname -s)
@vchernov
vchernov / timeval_add.cpp
Last active November 1, 2020 07:46
timeval arithmetic
// calculates addition of positive arguments
void add(const timeval& a, const timeval& b, timeval& result)
{
result.tv_sec = a.tv_sec + b.tv_sec;
result.tv_usec = a.tv_usec + b.tv_usec;
if (result.tv_usec >= 1000000)
{
result.tv_sec++;
result.tv_usec -= 1000000;
}