Include stdint.h in chan.h

This fixes compilation issues since chan uses int32_t and int64_t.
Fix deadlock problem identified in issue #12

This fixes a deadlock issue caused by FIFO condition variables where
reader tries to signal writer but instead signals other waiting readers.
The solution is to use two condition variables, one for readers and one
for writers.