Skip to content

Instantly share code, notes, and snippets.

@bnoordhuis
Created November 9, 2011 11:46
Show Gist options
  • Select an option

  • Save bnoordhuis/1351207 to your computer and use it in GitHub Desktop.

Select an option

Save bnoordhuis/1351207 to your computer and use it in GitHub Desktop.
#undef _GNU_SOURCE
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <linux/version.h>
#include <features.h>
#undef HAVE_FUTIMES
#undef HAVE_PIPE2
#undef HAVE_ACCEPT4
/* futimes() requires linux >= 2.6.22 and glib >= 2.6 */
#if LINUX_VERSION_CODE >= 0x20616 && __GLIBC_PREREQ(2, 6)
# define HAVE_FUTIMES 1
#endif
/* pipe2() requires linux >= 2.6.27 and glibc >= 2.9 */
#if LINUX_VERSION_CODE >= 0x2061B && __GLIBC_PREREQ(2, 9)
# define HAVE_PIPE2 1
#endif
/* accept4() requires linux >= 2.6.28 and glib >= 2.10 */
#if LINUX_VERSION_CODE >= 0x2061C && __GLIBC_PREREQ(2, 10)
# define HAVE_ACCEPT4 1
#endif
int main(void) {
printf("linux %d.%d.%d, glibc %d.%d\n",
(LINUX_VERSION_CODE >> 16) & 255, (LINUX_VERSION_CODE >> 8) & 255, LINUX_VERSION_CODE & 255,
__GLIBC__, __GLIBC_MINOR__);
#if HAVE_FUTIMES
puts("futimes");
#endif
#if HAVE_PIPE2
puts("pipe2");
#endif
#if HAVE_ACCEPT4
puts("accept4");
#endif
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment