Set version to 3.22.0-RC2
[valgrind.git] / include / pub_tool_libcproc.h
blob5f11693cd907b20e3a43d7ca97fa9a98ea61984f
2 /*--------------------------------------------------------------------*/
3 /*--- Process-related libc stuff pub_tool_libcproc.h ---*/
4 /*--------------------------------------------------------------------*/
6 /*
7 This file is part of Valgrind, a dynamic binary instrumentation
8 framework.
10 Copyright (C) 2000-2017 Julian Seward
11 jseward@acm.org
13 This program is free software; you can redistribute it and/or
14 modify it under the terms of the GNU General Public License as
15 published by the Free Software Foundation; either version 2 of the
16 License, or (at your option) any later version.
18 This program is distributed in the hope that it will be useful, but
19 WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, see <http://www.gnu.org/licenses/>.
26 The GNU General Public License is contained in the file COPYING.
29 #ifndef __PUB_TOOL_LIBCPROC_H
30 #define __PUB_TOOL_LIBCPROC_H
32 #include "pub_tool_basics.h" // VG_ macro
33 #include "pub_tool_vki.h" // vki_rlimit
35 /* ---------------------------------------------------------------------
36 Command-line and environment stuff
37 ------------------------------------------------------------------ */
39 /* Client environment. */
40 extern HChar** VG_(client_envp);
42 /* Looks up VG_(client_envp) */
43 extern HChar* VG_(getenv) ( const HChar* name );
45 /* Path to all our library/aux files */
46 extern const HChar *VG_(libdir);
48 // The name of the LD_PRELOAD-equivalent variable. It varies across
49 // platforms.
50 extern const HChar* VG_(LD_PRELOAD_var_name);
52 /* Resolves filename of VG_(cl_exec_fd) and copies it to the buffer.
53 Buffer must not be NULL and buf_size must be at least 1.
54 If buffer is not large enough it is terminated with '\0' only
55 when 'terminate_with_NUL == True'. */
56 extern void VG_(client_fname)(HChar *buffer, SizeT buf_size,
57 Bool terminate_with_NUL);
59 /* Concatenates client exename and command line arguments into
60 the buffer. Buffer must not be NULL and buf_size must be
61 at least 1. Buffer is always terminated with '\0'. */
62 extern void VG_(client_cmd_and_args)(HChar *buffer, SizeT buf_size);
64 /* ---------------------------------------------------------------------
65 Important syscalls
66 ------------------------------------------------------------------ */
68 extern Int VG_(waitpid)( Int pid, Int *status, Int options );
69 extern Int VG_(system) ( const HChar* cmd );
70 extern Int VG_(spawn) ( const HChar *filename, const HChar **argv );
71 extern Int VG_(fork) ( void);
72 extern void VG_(execv) ( const HChar* filename, const HChar** argv );
73 extern Int VG_(sysctl) ( Int *name, UInt namelen, void *oldp, SizeT *oldlenp, const void *newp, SizeT newlen );
75 /* ---------------------------------------------------------------------
76 Resource limits and capabilities
77 ------------------------------------------------------------------ */
79 extern Int VG_(getrlimit) ( Int resource, struct vki_rlimit *rlim );
80 extern Int VG_(setrlimit) ( Int resource, const struct vki_rlimit *rlim );
81 extern Int VG_(prctl) (Int option,
82 ULong arg2, ULong arg3, ULong arg4, ULong arg5);
84 /* ---------------------------------------------------------------------
85 pids, etc
86 ------------------------------------------------------------------ */
88 extern Int VG_(gettid) ( void );
89 extern Int VG_(getpid) ( void );
90 extern Int VG_(getppid) ( void );
91 extern Int VG_(getpgrp) ( void );
92 extern Int VG_(geteuid) ( void );
93 extern Int VG_(getegid) ( void );
95 /* ---------------------------------------------------------------------
96 Timing
97 ------------------------------------------------------------------ */
99 // Returns the number of milliseconds passed since the program started
100 // (roughly; it gets initialised partway through Valgrind's initialisation
101 // steps). This is wallclock time.
102 extern UInt VG_(read_millisecond_timer) ( void );
104 extern Int VG_(gettimeofday)(struct vki_timeval *tv, struct vki_timezone *tz);
106 # if defined(VGO_linux) || defined(VGO_solaris) || defined(VGO_freebsd)
107 /* Get the clock value as specified by clk_id. Asserts if unsuccesful. */
108 extern void VG_(clock_gettime)(struct vki_timespec *ts, vki_clockid_t clk_id);
109 # elif defined(VGO_darwin)
110 /* It seems clock_gettime is only available on recent Darwin versions.
111 For the moment, let's assume it is not available. */
112 # else
113 # error "Unknown OS"
114 # endif
116 // Returns the number of milliseconds of user cpu time we have used,
117 // as reported by 'getrusage'.
118 extern UInt VG_(get_user_milliseconds)(void);
120 /* ---------------------------------------------------------------------
121 atfork
122 ------------------------------------------------------------------ */
124 typedef void (*vg_atfork_t)(ThreadId);
125 extern void VG_(atfork)(vg_atfork_t pre, vg_atfork_t parent, vg_atfork_t child);
128 #endif // __PUB_TOOL_LIBCPROC_H
130 /*--------------------------------------------------------------------*/
131 /*--- end ---*/
132 /*--------------------------------------------------------------------*/