xref: /original-bsd/lib/libc/compat-43/gethostid.c (revision 327c59da)
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.1 (Berkeley) 04/04/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], size;
24 	long value;
25 
26 	mib[0] = CTL_KERN;
27 	mib[1] = KERN_HOSTID;
28 	size = sizeof value;
29 	if (sysctl(mib, 2, &value, &size, NULL, 0) == -1)
30 		return (-1);
31 	return (value);
32 }
33