Real-variables characterization of generalized Stieltjes functions