diff options
Diffstat (limited to 'share/examples/FreeBSD_version')
-rw-r--r-- | share/examples/FreeBSD_version/FreeBSD_version.c | 17 | ||||
-rw-r--r-- | share/examples/FreeBSD_version/Makefile | 8 | ||||
-rw-r--r-- | share/examples/FreeBSD_version/README | 4 |
3 files changed, 29 insertions, 0 deletions
diff --git a/share/examples/FreeBSD_version/FreeBSD_version.c b/share/examples/FreeBSD_version/FreeBSD_version.c new file mode 100644 index 0000000..e9d8c76 --- /dev/null +++ b/share/examples/FreeBSD_version/FreeBSD_version.c @@ -0,0 +1,17 @@ +#if __FreeBSD__ == 0 /* 1.0 did not define __FreeBSD__ */ +#define __FreeBSD_version 199401 +#elif __FreeBSD__ == 1 /* 1.1 defined it to be 1 */ +#define __FreeBSD_version 199405 +#else /* 2.0 and higher define it to be 2 */ +#include <osreldate.h> /* and this works */ +#endif + +int main(void) { + extern int getosreldate(void); + printf("Compilation release date: %d\n", __FreeBSD_version); +#if __FreeBSD_version >= 199408 + printf("Execution environment release date: %d\n", getosreldate()); +#else + printf("Execution environment release date: can't tell\n"); +#endif +} diff --git a/share/examples/FreeBSD_version/Makefile b/share/examples/FreeBSD_version/Makefile new file mode 100644 index 0000000..685c234 --- /dev/null +++ b/share/examples/FreeBSD_version/Makefile @@ -0,0 +1,8 @@ +# $Id$ + +PROG= FreeBSD_version +NOMAN= + +install: + +.include <bsd.prog.mk> diff --git a/share/examples/FreeBSD_version/README b/share/examples/FreeBSD_version/README new file mode 100644 index 0000000..acf9eb1 --- /dev/null +++ b/share/examples/FreeBSD_version/README @@ -0,0 +1,4 @@ +This is an example of how to determine the version of FreeBSD that +a program was compiled on, and maybe running on (if 2.0 or better). + +This program is in the public domain. |