Fix more -Wshorten-64-to-32 warnings.
[oota-llvm.git] / include / llvm / System / Process.h
1 //===- llvm/System/Process.h ------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file declares the llvm::sys::Process class.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_SYSTEM_PROCESS_H
15 #define LLVM_SYSTEM_PROCESS_H
16
17 #include "llvm/System/TimeValue.h"
18 #include "llvm/System/IncludeFile.h"
19
20 namespace llvm {
21 namespace sys {
22
23   /// This class provides an abstraction for getting information about the
24   /// currently executing process.
25   /// @since 1.4
26   /// @brief An abstraction for operating system processes.
27   class Process {
28     /// @name Accessors
29     /// @{
30     public:
31       /// This static function will return the operating system's virtual memory
32       /// page size.
33       /// @returns The number of bytes in a virtual memory page.
34       /// @throws nothing
35       /// @brief Get the virtual memory page size
36       static unsigned GetPageSize();
37
38       /// This static function will return the total amount of memory allocated
39       /// by the process. This only counts the memory allocated via the malloc,
40       /// calloc and realloc functions and includes any "free" holes in the
41       /// allocated space.
42       /// @throws nothing
43       /// @brief Return process memory usage.
44       static size_t GetMallocUsage();
45
46       /// This static function will return the total memory usage of the
47       /// process. This includes code, data, stack and mapped pages usage. Notei
48       /// that the value returned here is not necessarily the Running Set Size,
49       /// it is the total virtual memory usage, regardless of mapped state of
50       /// that memory.
51       static size_t GetTotalMemoryUsage();
52
53       /// This static function will set \p user_time to the amount of CPU time
54       /// spent in user (non-kernel) mode and \p sys_time to the amount of CPU
55       /// time spent in system (kernel) mode.  If the operating system does not
56       /// support collection of these metrics, a zero TimeValue will be for both
57       /// values.
58       static void GetTimeUsage(
59         TimeValue& elapsed,
60           ///< Returns the TimeValue::now() giving current time
61         TimeValue& user_time,
62           ///< Returns the current amount of user time for the process
63         TimeValue& sys_time
64           ///< Returns the current amount of system time for the process
65       );
66
67       /// This static function will return the process' current user id number.
68       /// Not all operating systems support this feature. Where it is not
69       /// supported, the function should return 65536 as the value.
70       static int GetCurrentUserId();
71
72       /// This static function will return the process' current group id number.
73       /// Not all operating systems support this feature. Where it is not
74       /// supported, the function should return 65536 as the value.
75       static int GetCurrentGroupId();
76
77       /// This function makes the necessary calls to the operating system to
78       /// prevent core files or any other kind of large memory dumps that can
79       /// occur when a program fails.
80       /// @brief Prevent core file generation.
81       static void PreventCoreFiles();
82
83       /// This function determines if the standard input is connected directly
84       /// to a user's input (keyboard probably), rather than coming from a file
85       /// or pipe.
86       static bool StandardInIsUserInput();
87
88       /// This function determines if the standard output is connected to a
89       /// "tty" or "console" window. That is, the output would be displayed to
90       /// the user rather than being put on a pipe or stored in a file.
91       static bool StandardOutIsDisplayed();
92
93       /// This function determines if the standard error is connected to a
94       /// "tty" or "console" window. That is, the output would be displayed to
95       /// the user rather than being put on a pipe or stored in a file.
96       static bool StandardErrIsDisplayed();
97
98     /// @}
99   };
100 }
101 }
102
103 FORCE_DEFINING_FILE_TO_BE_LINKED(SystemProcess)
104
105 #endif