extern void VG_(close) ( Int fd );
extern Int VG_(read) ( Int fd, void* buf, Int count);
extern Int VG_(write) ( Int fd, void* buf, Int count);
+extern Int VG_(stat) ( Char* file_name, struct vki_stat* buf );
extern Int VG_(fcntl) ( Int fd, Int cmd, Int arg );
extern Int VG_(munmap)( void* start, Int length );
+extern void* VG_(brk) ( void* end_data_segment );
+
/* Print a (panic) message, and abort. */
extern void VG_(panic) ( Char* str )
};
+/* STAT stuff
+ from /usr/src/linux-2.4.9-31/include/asm-i386/stat.h */
+struct vki_stat {
+ unsigned short st_dev;
+ unsigned short __pad1;
+ unsigned long st_ino;
+ unsigned short st_mode;
+ unsigned short st_nlink;
+ unsigned short st_uid;
+ unsigned short st_gid;
+ unsigned short st_rdev;
+ unsigned short __pad2;
+ unsigned long st_size;
+ unsigned long st_blksize;
+ unsigned long st_blocks;
+ unsigned long st_atime;
+ unsigned long __unused1;
+ unsigned long st_mtime;
+ unsigned long __unused2;
+ unsigned long st_ctime;
+ unsigned long __unused3;
+ unsigned long __unused4;
+ unsigned long __unused5;
+};
+
+
#endif /* ndef __VG_KERNELIFACE_H */
/*--------------------------------------------------------------------*/
}
-
-/* ONLY HERE for sbrk() */
-#include <unistd.h>
-
/* Initialise the memory audit system. */
void VGM_(init_memory_audit) ( void )
{
/* Record the end of the data segment, so that vg_syscall_mem.c
can make sense of calls to brk().
*/
- VGM_(curr_dataseg_end) = (Addr)sbrk(0);
+ VGM_(curr_dataseg_end) = (Addr)VG_(brk)(0);
if (VGM_(curr_dataseg_end) == (Addr)(-1))
VG_(panic)("vgm_init_memory_audit: can't determine data-seg end");
args[4] = (UInt)timeout;
res = vg_do_syscall1(__NR_select, (UInt)(&(args[0])) );
return VG_(is_kerror)(res) ? -1 : res;
- return res;
}
/* Returns -1 on error, 0 if ok, 1 if interrupted. */
return 0;
}
+void* VG_(brk) ( void* end_data_segment )
+{
+ Int res;
+ res = vg_do_syscall1(__NR_brk, (UInt)end_data_segment);
+ return (void*)( VG_(is_kerror)(res) ? -1 : res );
+}
+
/* ---------------------------------------------------------------------
printf implementation. The key function, vg_vprintf(), emits chars
return res;
}
+Int VG_(stat) ( Char* file_name, struct vki_stat* buf )
+{
+ Int res;
+ res = vg_do_syscall2(__NR_stat, (UInt)file_name, (UInt)buf);
+ return
+ VG_(is_kerror)(res) ? (-1) : 0;
+}
+
/* Misc functions looking for a proper home. */
/* We do getenv without libc's help by snooping around in
*/
#include "vg_include.h"
-#include "vg_unsafe.h"
#include <elf.h> /* ELF defns */
#include <a.out.h> /* stabs defns */
Bool ok;
Addr oimage;
Int n_oimage;
- struct stat stat_buf;
+ struct vki_stat stat_buf;
/* for the .stabs reader */
Int curr_filenmoff;
line number info out of it. It will be munmapped immediately
thereafter; it is only aboard transiently. */
- i = stat(si->filename, &stat_buf);
+ i = VG_(stat)(si->filename, &stat_buf);
if (i != 0) {
vg_symerr("Can't stat .so/.exe (to determine its size)?!");
return;
return;
}
- oimage = (Addr)VG_(mmap)( NULL, n_oimage, PROT_READ, MAP_PRIVATE, fd, 0 );
+ oimage = (Addr)VG_(mmap)( NULL, n_oimage,
+ VKI_PROT_READ, VKI_MAP_PRIVATE, fd, 0 );
if (oimage == ((Addr)(-1))) {
VG_(message)(Vg_UserMsg,
"mmap failed on %s", si->filename );
extern void VG_(close) ( Int fd );
extern Int VG_(read) ( Int fd, void* buf, Int count);
extern Int VG_(write) ( Int fd, void* buf, Int count);
+extern Int VG_(stat) ( Char* file_name, struct vki_stat* buf );
extern Int VG_(fcntl) ( Int fd, Int cmd, Int arg );
extern Int VG_(munmap)( void* start, Int length );
+extern void* VG_(brk) ( void* end_data_segment );
+
/* Print a (panic) message, and abort. */
extern void VG_(panic) ( Char* str )
};
+/* STAT stuff
+ from /usr/src/linux-2.4.9-31/include/asm-i386/stat.h */
+struct vki_stat {
+ unsigned short st_dev;
+ unsigned short __pad1;
+ unsigned long st_ino;
+ unsigned short st_mode;
+ unsigned short st_nlink;
+ unsigned short st_uid;
+ unsigned short st_gid;
+ unsigned short st_rdev;
+ unsigned short __pad2;
+ unsigned long st_size;
+ unsigned long st_blksize;
+ unsigned long st_blocks;
+ unsigned long st_atime;
+ unsigned long __unused1;
+ unsigned long st_mtime;
+ unsigned long __unused2;
+ unsigned long st_ctime;
+ unsigned long __unused3;
+ unsigned long __unused4;
+ unsigned long __unused5;
+};
+
+
#endif /* ndef __VG_KERNELIFACE_H */
/*--------------------------------------------------------------------*/
}
-
-/* ONLY HERE for sbrk() */
-#include <unistd.h>
-
/* Initialise the memory audit system. */
void VGM_(init_memory_audit) ( void )
{
/* Record the end of the data segment, so that vg_syscall_mem.c
can make sense of calls to brk().
*/
- VGM_(curr_dataseg_end) = (Addr)sbrk(0);
+ VGM_(curr_dataseg_end) = (Addr)VG_(brk)(0);
if (VGM_(curr_dataseg_end) == (Addr)(-1))
VG_(panic)("vgm_init_memory_audit: can't determine data-seg end");
args[4] = (UInt)timeout;
res = vg_do_syscall1(__NR_select, (UInt)(&(args[0])) );
return VG_(is_kerror)(res) ? -1 : res;
- return res;
}
/* Returns -1 on error, 0 if ok, 1 if interrupted. */
return 0;
}
+void* VG_(brk) ( void* end_data_segment )
+{
+ Int res;
+ res = vg_do_syscall1(__NR_brk, (UInt)end_data_segment);
+ return (void*)( VG_(is_kerror)(res) ? -1 : res );
+}
+
/* ---------------------------------------------------------------------
printf implementation. The key function, vg_vprintf(), emits chars
return res;
}
+Int VG_(stat) ( Char* file_name, struct vki_stat* buf )
+{
+ Int res;
+ res = vg_do_syscall2(__NR_stat, (UInt)file_name, (UInt)buf);
+ return
+ VG_(is_kerror)(res) ? (-1) : 0;
+}
+
/* Misc functions looking for a proper home. */
/* We do getenv without libc's help by snooping around in
*/
#include "vg_include.h"
-#include "vg_unsafe.h"
#include <elf.h> /* ELF defns */
#include <a.out.h> /* stabs defns */
Bool ok;
Addr oimage;
Int n_oimage;
- struct stat stat_buf;
+ struct vki_stat stat_buf;
/* for the .stabs reader */
Int curr_filenmoff;
line number info out of it. It will be munmapped immediately
thereafter; it is only aboard transiently. */
- i = stat(si->filename, &stat_buf);
+ i = VG_(stat)(si->filename, &stat_buf);
if (i != 0) {
vg_symerr("Can't stat .so/.exe (to determine its size)?!");
return;
return;
}
- oimage = (Addr)VG_(mmap)( NULL, n_oimage, PROT_READ, MAP_PRIVATE, fd, 0 );
+ oimage = (Addr)VG_(mmap)( NULL, n_oimage,
+ VKI_PROT_READ, VKI_MAP_PRIVATE, fd, 0 );
if (oimage == ((Addr)(-1))) {
VG_(message)(Vg_UserMsg,
"mmap failed on %s", si->filename );