ipliteral was not recognizing "ipv6" prefix.
[exim.git] / src / OS / os.c-GNU
CommitLineData
61ec970d
PH
1/* $Cambridge: exim/src/OS/os.c-GNU,v 1.1 2004/10/06 15:07:39 ph10 Exp $ */
2
3/*************************************************
4* Exim - an Internet mail transport agent *
5*************************************************/
6
7/* See the file NOTICE for conditions of use and distribution. */
8
9/* GNU-specific code. This is concatenated onto the generic src/os.c file.
10GNU/Hurd has approximately the same way to determine the load average as NeXT,
11so a variant of this could also be in the generic os.c file. See the GNU EMacs
12getloadavg.c file, from which this snippet was derived. getloadavg.c from Emacs
13is copyrighted by the FSF under the terms of the GPLv2 or any later version.
14Changes are hereby placed under the same license, as requested by the GPL. */
15
16#ifndef OS_LOAD_AVERAGE
17#define OS_LOAD_AVERAGE
18
19#include <mach.h>
20
21static processor_set_t default_set;
22static int getloadavg_initialized;
23
24int
25os_getloadavg (void)
26{
27host_t host;
28struct processor_set_basic_info info;
29unsigned info_count;
30
31if (!getloadavg_initialized)
32 {
33 if (processor_set_default (mach_host_self(), &default_set) == KERN_SUCCESS)
34 getloadavg_initialized = 1;
35 }
36
37if (getloadavg_initialized)
38 {
39 info_count = PROCESSOR_SET_BASIC_INFO_COUNT;
40 if (processor_set_info(default_set, PROCESSOR_SET_BASIC_INFO, &host,
41 (processor_set_info_t)&info, &info_count) != KERN_SUCCESS)
42 getloadavg_initialized = 0;
43 else
44 {
45 #if LOAD_SCALE == 1000
46 return info.load_average;
47 #else
48 return (int) (((double) info.load_average * 1000) / LOAD_SCALE));
49 #endif
50 }
51 }
52
53return -1;
54}
55#endif /* OS_LOAD_AVERAGE */
56
57/* End of os.c-GNU */