coin-Bcp
BCP_os.hpp
Go to the documentation of this file.
1 // Copyright (C) 2000, International Business Machines
2 // Corporation and others. All Rights Reserved.
3 #ifndef _BCP_OS_H
4 #define _BCP_OS_H
5 
6 #include <cstdio>
7 #include "BcpConfig.h"
8 
9 //-----------------------------------------------------------------------------
10 #ifdef HAVE_SYS_RESOURCE_H
11 # include <sys/resource.h>
12 #else
13 # define setpriority(x,y,z)
14 #endif
15 //-----------------------------------------------------------------------------
16 #ifdef HAVE_UNISTD_H
17 # include <unistd.h>
18 #endif
19 
20 #ifdef HAVE_PROCESS_H
21 # include <process.h>
22 #endif
23 
24 #ifndef HAVE_GETHOSTNAME
25 # define gethostname(x,y)
26 #endif
27 
28 #ifdef HAVE_GETPID
29 # define GETPID (getpid())
30 #else
31 # define GETPID (0)
32 #endif
33 //-----------------------------------------------------------------------------
34 
35 #ifdef HAVE_SYS_SYSINFO_H
36 #include <sys/sysinfo.h>
37 #endif
38 static inline long BCP_free_mem()
39 {
40 #ifdef HAVE_SYSINFO
41  struct sysinfo info;
42  sysinfo(&info);
43  return info.mem_unit*info.freeram;
44 #else
45  return -1;
46 #endif
47 }
48 //-----------------------------------------------------------------------------
49 
50 #ifdef HAVE_MALLINFO
51 #include <malloc.h>
52 #endif
53 
54 static inline long BCP_used_heap()
55 {
56 #ifdef HAVE_MALLINFO
57  struct mallinfo info = mallinfo();
58  return info.usmblks + info.uordblks;;
59 #else
60  return -1;
61 #endif
62 }
63 //-----------------------------------------------------------------------------
64 
65 #endif
static long BCP_used_heap()
Definition: BCP_os.hpp:54
static long BCP_free_mem()
Definition: BCP_os.hpp:38