int main (void) { /* Valid. */ fadvise (stdin, FADVISE_SEQUENTIAL); fdadvise (fileno (stdin), 0, 0, FADVISE_RANDOM); /* Ignored. */ fadvise (NULL, FADVISE_RANDOM); /* Invalid. */ fdadvise (42, 0, 0, FADVISE_RANDOM); /* Unfortunately C enums are not types. One could hack type safety by wrapping in a struct, but it's probably not worth the complexity in this case. */ fadvise (stdin, FADVISE_SEQUENTIAL + FADVISE_RANDOM); fadvise (stdin, 4242); return 0; }
void fadvise (FILE *fp, fadvice_t advice) { if (fp) fdadvise (fileno (fp), 0, 0, advice); }