I tryed this and it worked for me:
#define MAXVAL(val1,val2) ((val1>val2) ? (val1):(val2) )
#define MINVAL(val1,val2) ((val1<val2) ? (val1):(val2) )
#define MEDIAN3(val1,val2,val3) MINVAL(MINVAL(MAXVAL(val1,val2),MAXVAL(val2,val3)),MAXVAL(val3,val1))
But since you need to sort the values to get the median I think some kind of simple bubble sort algorithm (http://de.wikipedia.org/wiki/Bubblesort) for 3 values should be the best solution.
-- EDIT --
This is a better solution:
#define MEDIAN3(val1,val2,val3) MAXVAL(MINVAL(MAXVAL(val1,val2),val3),MINVAL(val1,val2))
and minimal of 3 values macro:
#define MIN3(x,y,z) ( ( y ) <= ( z ) ? ((x) <= (y) ? (x) : (y)) : ((x) <= (z) ? (x) : (z)))