The carbon star luminosity functions in the Magellanic Clouds