return 0;
}
+
+/* Pretty bogus. Avoid if possible. */
+int pthread_getattr_np (pthread_t thread, pthread_attr_t *attr)
+{
+ int detached;
+ size_t limit;
+ ensure_valgrind("pthread_getattr_np");
+ kludged("pthread_getattr_np");
+ limit = VG_PTHREAD_STACK_SIZE - VG_AR_CLIENT_STACKBASE_REDZONE_SZB
+ - 1000; /* paranoia */
+ attr->__detachstate = PTHREAD_CREATE_JOINABLE;
+ attr->__schedpolicy = SCHED_OTHER;
+ attr->__schedparam.sched_priority = 0;
+ attr->__inheritsched = PTHREAD_EXPLICIT_SCHED;
+ attr->__scope = PTHREAD_SCOPE_SYSTEM;
+ attr->__guardsize = VKI_BYTES_PER_PAGE;
+ attr->__stackaddr = NULL;
+ attr->__stackaddr_set = 0;
+ attr->__stacksize = limit;
+ VALGRIND_MAGIC_SEQUENCE(detached, (-1) /* default */,
+ VG_USERREQ__SET_OR_GET_DETACH,
+ 2 /* get */, thread, 0, 0);
+ assert(detached == 0 || detached == 1);
+ if (detached)
+ attr->__detachstate = PTHREAD_CREATE_DETACHED;
+ return 0;
+}
+
+
+/* Bogus ... */
+int pthread_attr_getstackaddr ( const pthread_attr_t * attr,
+ void ** stackaddr )
+{
+ ensure_valgrind("pthread_attr_getstackaddr");
+ kludged("pthread_attr_getstackaddr");
+ if (stackaddr)
+ *stackaddr = NULL;
+ return 0;
+}
+
+/* Not bogus (!) */
+int pthread_attr_getstacksize ( const pthread_attr_t * _attr,
+ size_t * __stacksize )
+{
+ size_t limit;
+ ensure_valgrind("pthread_attr_getstacksize");
+ limit = VG_PTHREAD_STACK_SIZE - VG_AR_CLIENT_STACKBASE_REDZONE_SZB
+ - 1000; /* paranoia */
+ if (__stacksize)
+ *__stacksize = limit;
+ return 0;
+}
+
/* ---------------------------------------------------
Helper functions for running a thread
and for clearing up afterwards.
//void pthread_detach ( void ) { unimp("pthread_detach"); }
//void pthread_equal ( void ) { unimp("pthread_equal"); }
//void pthread_exit ( void ) { unimp("pthread_exit"); }
-void pthread_getattr_np ( void ) { unimp("pthread_getattr_np"); }
+//void pthread_getattr_np ( void ) { unimp("pthread_getattr_np"); }
void pthread_getcpuclockid ( void ) { unimp("pthread_getcpuclockid"); }
//void pthread_getschedparam ( void ) { unimp("pthread_getschedparam"); }
//void pthread_getspecific ( void ) { unimp("pthread_getspecific"); }
#define VKI_SIGTERM 15
#define VKI_SIGUSR1 10
-/* The following are copied from /usr/include/bits/mman.h, which in
- turn claims to have got them from the kernel headers. */
+/* The following are copied from include/asm-i386/mman.h .*/
#define VKI_PROT_READ 0x1 /* Page can be read. */
#define VKI_PROT_WRITE 0x2 /* Page can be written. */
#define VKI_PROT_EXEC 0x4 /* Page can be executed. */
#define VKI_MAP_ANONYMOUS 0x20 /* Don't use a file. */
#define VKI_MAP_PRIVATE 0x02 /* Changes are private. */
+#define VKI_MAP_FIXED 0x10 /* Interpret addr exactly */
/* Copied from /usr/src/linux-2.4.9-13/include/asm/errno.h */
return 0;
}
+
+/* Pretty bogus. Avoid if possible. */
+int pthread_getattr_np (pthread_t thread, pthread_attr_t *attr)
+{
+ int detached;
+ size_t limit;
+ ensure_valgrind("pthread_getattr_np");
+ kludged("pthread_getattr_np");
+ limit = VG_PTHREAD_STACK_SIZE - VG_AR_CLIENT_STACKBASE_REDZONE_SZB
+ - 1000; /* paranoia */
+ attr->__detachstate = PTHREAD_CREATE_JOINABLE;
+ attr->__schedpolicy = SCHED_OTHER;
+ attr->__schedparam.sched_priority = 0;
+ attr->__inheritsched = PTHREAD_EXPLICIT_SCHED;
+ attr->__scope = PTHREAD_SCOPE_SYSTEM;
+ attr->__guardsize = VKI_BYTES_PER_PAGE;
+ attr->__stackaddr = NULL;
+ attr->__stackaddr_set = 0;
+ attr->__stacksize = limit;
+ VALGRIND_MAGIC_SEQUENCE(detached, (-1) /* default */,
+ VG_USERREQ__SET_OR_GET_DETACH,
+ 2 /* get */, thread, 0, 0);
+ assert(detached == 0 || detached == 1);
+ if (detached)
+ attr->__detachstate = PTHREAD_CREATE_DETACHED;
+ return 0;
+}
+
+
+/* Bogus ... */
+int pthread_attr_getstackaddr ( const pthread_attr_t * attr,
+ void ** stackaddr )
+{
+ ensure_valgrind("pthread_attr_getstackaddr");
+ kludged("pthread_attr_getstackaddr");
+ if (stackaddr)
+ *stackaddr = NULL;
+ return 0;
+}
+
+/* Not bogus (!) */
+int pthread_attr_getstacksize ( const pthread_attr_t * _attr,
+ size_t * __stacksize )
+{
+ size_t limit;
+ ensure_valgrind("pthread_attr_getstacksize");
+ limit = VG_PTHREAD_STACK_SIZE - VG_AR_CLIENT_STACKBASE_REDZONE_SZB
+ - 1000; /* paranoia */
+ if (__stacksize)
+ *__stacksize = limit;
+ return 0;
+}
+
/* ---------------------------------------------------
Helper functions for running a thread
and for clearing up afterwards.
//void pthread_detach ( void ) { unimp("pthread_detach"); }
//void pthread_equal ( void ) { unimp("pthread_equal"); }
//void pthread_exit ( void ) { unimp("pthread_exit"); }
-void pthread_getattr_np ( void ) { unimp("pthread_getattr_np"); }
+//void pthread_getattr_np ( void ) { unimp("pthread_getattr_np"); }
void pthread_getcpuclockid ( void ) { unimp("pthread_getcpuclockid"); }
//void pthread_getschedparam ( void ) { unimp("pthread_getschedparam"); }
//void pthread_getspecific ( void ) { unimp("pthread_getspecific"); }
/* Process Valgrind's command-line opts (from env var VG_OPTS). */
process_cmd_line_options();
+ /* Hook to delay things long enough so we can get the pid and
+ attach GDB in another shell. */
+ if (0) {
+ Int p, q;
+ for (p = 0; p < 50000; p++)
+ for (q = 0; q < 50000; q++) ;
+ }
+
/* Initialise the scheduler, and copy the client's state from
baseBlock into VG_(threads)[1]. This has to come before signal
initialisations. */
/* Start calibration of our RDTSC-based clock. */
VG_(start_rdtsc_calibration)();
- /* Hook to delay things long enough so we can get the pid and
- attach GDB in another shell. */
- /* {extern unsigned int sleep(unsigned int seconds); sleep(10);} */
-
if (VG_(clo_instrument) || VG_(clo_cachesim)) {
VGP_PUSHCC(VgpInitAudit);
VGM_(init_memory_audit)();
#define VKI_SIGTERM 15
#define VKI_SIGUSR1 10
-/* The following are copied from /usr/include/bits/mman.h, which in
- turn claims to have got them from the kernel headers. */
+/* The following are copied from include/asm-i386/mman.h .*/
#define VKI_PROT_READ 0x1 /* Page can be read. */
#define VKI_PROT_WRITE 0x2 /* Page can be written. */
#define VKI_PROT_EXEC 0x4 /* Page can be executed. */
#define VKI_MAP_ANONYMOUS 0x20 /* Don't use a file. */
#define VKI_MAP_PRIVATE 0x02 /* Changes are private. */
+#define VKI_MAP_FIXED 0x10 /* Interpret addr exactly */
/* Copied from /usr/src/linux-2.4.9-13/include/asm/errno.h */
return 0;
}
+
+/* Pretty bogus. Avoid if possible. */
+int pthread_getattr_np (pthread_t thread, pthread_attr_t *attr)
+{
+ int detached;
+ size_t limit;
+ ensure_valgrind("pthread_getattr_np");
+ kludged("pthread_getattr_np");
+ limit = VG_PTHREAD_STACK_SIZE - VG_AR_CLIENT_STACKBASE_REDZONE_SZB
+ - 1000; /* paranoia */
+ attr->__detachstate = PTHREAD_CREATE_JOINABLE;
+ attr->__schedpolicy = SCHED_OTHER;
+ attr->__schedparam.sched_priority = 0;
+ attr->__inheritsched = PTHREAD_EXPLICIT_SCHED;
+ attr->__scope = PTHREAD_SCOPE_SYSTEM;
+ attr->__guardsize = VKI_BYTES_PER_PAGE;
+ attr->__stackaddr = NULL;
+ attr->__stackaddr_set = 0;
+ attr->__stacksize = limit;
+ VALGRIND_MAGIC_SEQUENCE(detached, (-1) /* default */,
+ VG_USERREQ__SET_OR_GET_DETACH,
+ 2 /* get */, thread, 0, 0);
+ assert(detached == 0 || detached == 1);
+ if (detached)
+ attr->__detachstate = PTHREAD_CREATE_DETACHED;
+ return 0;
+}
+
+
+/* Bogus ... */
+int pthread_attr_getstackaddr ( const pthread_attr_t * attr,
+ void ** stackaddr )
+{
+ ensure_valgrind("pthread_attr_getstackaddr");
+ kludged("pthread_attr_getstackaddr");
+ if (stackaddr)
+ *stackaddr = NULL;
+ return 0;
+}
+
+/* Not bogus (!) */
+int pthread_attr_getstacksize ( const pthread_attr_t * _attr,
+ size_t * __stacksize )
+{
+ size_t limit;
+ ensure_valgrind("pthread_attr_getstacksize");
+ limit = VG_PTHREAD_STACK_SIZE - VG_AR_CLIENT_STACKBASE_REDZONE_SZB
+ - 1000; /* paranoia */
+ if (__stacksize)
+ *__stacksize = limit;
+ return 0;
+}
+
/* ---------------------------------------------------
Helper functions for running a thread
and for clearing up afterwards.
//void pthread_detach ( void ) { unimp("pthread_detach"); }
//void pthread_equal ( void ) { unimp("pthread_equal"); }
//void pthread_exit ( void ) { unimp("pthread_exit"); }
-void pthread_getattr_np ( void ) { unimp("pthread_getattr_np"); }
+//void pthread_getattr_np ( void ) { unimp("pthread_getattr_np"); }
void pthread_getcpuclockid ( void ) { unimp("pthread_getcpuclockid"); }
//void pthread_getschedparam ( void ) { unimp("pthread_getschedparam"); }
//void pthread_getspecific ( void ) { unimp("pthread_getspecific"); }
/* Process Valgrind's command-line opts (from env var VG_OPTS). */
process_cmd_line_options();
+ /* Hook to delay things long enough so we can get the pid and
+ attach GDB in another shell. */
+ if (0) {
+ Int p, q;
+ for (p = 0; p < 50000; p++)
+ for (q = 0; q < 50000; q++) ;
+ }
+
/* Initialise the scheduler, and copy the client's state from
baseBlock into VG_(threads)[1]. This has to come before signal
initialisations. */
/* Start calibration of our RDTSC-based clock. */
VG_(start_rdtsc_calibration)();
- /* Hook to delay things long enough so we can get the pid and
- attach GDB in another shell. */
- /* {extern unsigned int sleep(unsigned int seconds); sleep(10);} */
-
if (VG_(clo_instrument) || VG_(clo_cachesim)) {
VGP_PUSHCC(VgpInitAudit);
VGM_(init_memory_audit)();