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