xref: /original-bsd/lib/libc/compat-43/gethostid.c (revision f4546c36)
1 /*
2  * Copyright (c) 1989 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #if defined(LIBC_SCCS) && !defined(lint)
9 static char sccsid[] = "@(#)gethostid.c	5.2 (Berkeley) 05/24/93";
10 #endif /* LIBC_SCCS and not lint */
11 
12 #include <sys/param.h>
13 #include <sys/sysctl.h>
14 
15 #if __STDC__
16 long
17 gethostid(void)
18 #else
19 long
20 gethostid()
21 #endif
22 {
23 	int mib[2];
24 	size_t size;
25 	long value;
26 
27 	mib[0] = CTL_KERN;
28 	mib[1] = KERN_HOSTID;
29 	size = sizeof value;
30 	if (sysctl(mib, 2, &value, &size, NULL, 0) == -1)
31 		return (-1);
32 	return (value);
33 }
34