Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:13:31

0001 
0002 /*--------------------------------------------------------------------*/
0003 /*--- Process-related libc stuff               pub_tool_libcproc.h ---*/
0004 /*--------------------------------------------------------------------*/
0005 
0006 /*
0007    This file is part of Valgrind, a dynamic binary instrumentation
0008    framework.
0009 
0010    Copyright (C) 2000-2017 Julian Seward
0011       jseward@acm.org
0012 
0013    This program is free software; you can redistribute it and/or
0014    modify it under the terms of the GNU General Public License as
0015    published by the Free Software Foundation; either version 2 of the
0016    License, or (at your option) any later version.
0017 
0018    This program is distributed in the hope that it will be useful, but
0019    WITHOUT ANY WARRANTY; without even the implied warranty of
0020    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0021    General Public License for more details.
0022 
0023    You should have received a copy of the GNU General Public License
0024    along with this program; if not, see <http://www.gnu.org/licenses/>.
0025 
0026    The GNU General Public License is contained in the file COPYING.
0027 */
0028 
0029 #ifndef __PUB_TOOL_LIBCPROC_H
0030 #define __PUB_TOOL_LIBCPROC_H
0031 
0032 #include "pub_tool_basics.h"   // VG_ macro
0033 #include "pub_tool_vki.h"      // vki_rlimit
0034 
0035 /* ---------------------------------------------------------------------
0036    Command-line and environment stuff
0037    ------------------------------------------------------------------ */
0038 
0039 /* Client environment. */
0040 extern HChar** VG_(client_envp);
0041 
0042 /* Looks up VG_(client_envp) */
0043 extern HChar* VG_(getenv) ( const HChar* name );
0044 
0045 /* Path to all our library/aux files */
0046 extern const HChar *VG_(libdir);
0047 
0048 // The name of the LD_PRELOAD-equivalent variable.  It varies across
0049 // platforms.
0050 extern const HChar* VG_(LD_PRELOAD_var_name);
0051 
0052 /* Resolves filename of VG_(cl_exec_fd) and copies it to the buffer. 
0053    Buffer must not be NULL and buf_size must be at least 1.
0054    If buffer is not large enough it is terminated with '\0' only
0055    when 'terminate_with_NUL == True'. */
0056 extern void VG_(client_fname)(HChar *buffer, SizeT buf_size,
0057                               Bool terminate_with_NUL);
0058 
0059 /* Concatenates client exename and command line arguments into
0060    the buffer. Buffer must not be NULL and buf_size must be
0061    at least 1. Buffer is always terminated with '\0'. */
0062 extern void VG_(client_cmd_and_args)(HChar *buffer, SizeT buf_size);
0063 
0064 /* ---------------------------------------------------------------------
0065    Important syscalls
0066    ------------------------------------------------------------------ */
0067 
0068 extern Int  VG_(waitpid)( Int pid, Int *status, Int options );
0069 extern Int  VG_(system) ( const HChar* cmd );
0070 extern Int  VG_(spawn)  ( const HChar *filename, const HChar **argv );
0071 extern Int  VG_(fork)   ( void);
0072 extern void VG_(execv)  ( const HChar* filename, const HChar** argv );
0073 extern Int  VG_(sysctl) ( Int *name, UInt namelen, void *oldp, SizeT *oldlenp, const void *newp, SizeT newlen );
0074 
0075 /* ---------------------------------------------------------------------
0076    Resource limits and capabilities
0077    ------------------------------------------------------------------ */
0078 
0079 extern Int VG_(getrlimit) ( Int resource, struct vki_rlimit *rlim );
0080 extern Int VG_(setrlimit) ( Int resource, const struct vki_rlimit *rlim );
0081 extern Int VG_(prctl) (Int option, 
0082                        ULong arg2, ULong arg3, ULong arg4, ULong arg5);
0083 
0084 /* ---------------------------------------------------------------------
0085    pids, etc
0086    ------------------------------------------------------------------ */
0087 
0088 extern Int VG_(gettid)  ( void );
0089 extern Int VG_(getpid)  ( void );
0090 extern Int VG_(getppid) ( void );
0091 extern Int VG_(getpgrp) ( void );
0092 extern Int VG_(geteuid) ( void );
0093 extern Int VG_(getegid) ( void );
0094 
0095 /* ---------------------------------------------------------------------
0096    Timing
0097    ------------------------------------------------------------------ */
0098 
0099 // Returns the number of milliseconds passed since the program started
0100 // (roughly;  it gets initialised partway through Valgrind's initialisation
0101 // steps).  This is wallclock time.
0102 extern UInt VG_(read_millisecond_timer) ( void );
0103 
0104 extern Int  VG_(gettimeofday)(struct vki_timeval *tv, struct vki_timezone *tz);
0105 
0106 #  if defined(VGO_linux) || defined(VGO_solaris) || defined(VGO_freebsd)
0107 /* Get the clock value as specified by clk_id.  Asserts if unsuccesful.  */
0108 extern void VG_(clock_gettime)(struct vki_timespec *ts, vki_clockid_t clk_id);
0109 #  elif defined(VGO_darwin)
0110   /* It seems clock_gettime is only available on recent Darwin versions.
0111      For the moment, let's assume it is not available.  */
0112 #  else
0113 #    error "Unknown OS"
0114 #  endif
0115 
0116 // Returns the number of milliseconds of user cpu time we have used,
0117 // as reported by 'getrusage'.
0118 extern UInt VG_(get_user_milliseconds)(void);
0119 
0120 /* ---------------------------------------------------------------------
0121    atfork
0122    ------------------------------------------------------------------ */
0123 
0124 typedef void (*vg_atfork_t)(ThreadId);
0125 extern void VG_(atfork)(vg_atfork_t pre, vg_atfork_t parent, vg_atfork_t child);
0126 
0127 
0128 #endif   // __PUB_TOOL_LIBCPROC_H
0129 
0130 /*--------------------------------------------------------------------*/
0131 /*--- end                                                          ---*/
0132 /*--------------------------------------------------------------------*/