full C impl.