eal: add generic thread-local-storage functions