merge revs
   vg_libpthread.c       1.90.2.10
   vg_libpthread_unimp.c 1.30.2.5

Implement (sort-of) pthread_attr_{set,get}guardsize.


git-svn-id: svn://svn.valgrind.org/valgrind/trunk@1240 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/coregrind/vg_libpthread.c b/coregrind/vg_libpthread.c
index 42f51d6..aba1490 100644
--- a/coregrind/vg_libpthread.c
+++ b/coregrind/vg_libpthread.c
@@ -302,7 +302,9 @@
 {
    /* Just initialise the fields which we might look at. */
    attr->__detachstate = PTHREAD_CREATE_JOINABLE;
-   return 0;
+   /* Linuxthreads sets this field to the value __getpagesize(), so I
+      guess the following is OK. */
+   attr->__guardsize = VKI_BYTES_PER_PAGE;   return 0;
 }
 
 int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate)
@@ -433,6 +435,7 @@
 
 
 /* Bogus ... */
+__attribute__((weak))
 int pthread_attr_getstackaddr ( const pthread_attr_t * attr,
                                 void ** stackaddr )
 {
@@ -444,6 +447,7 @@
 }
 
 /* Not bogus (!) */
+__attribute__((weak))
 int pthread_attr_getstacksize ( const pthread_attr_t * _attr, 
                                 size_t * __stacksize )
 {
@@ -471,6 +475,32 @@
 }
 
 
+/* This is completely bogus.  We reject all attempts to change it from
+   VKI_BYTES_PER_PAGE.  I don't have a clue what it's for so it seems
+   safest to be paranoid. */
+__attribute__((weak)) 
+int pthread_attr_setguardsize(pthread_attr_t *attr, size_t guardsize)
+{
+   static int moans = N_MOANS;
+
+   if (guardsize == VKI_BYTES_PER_PAGE)
+      return 0;
+
+   if (moans-- > 0) 
+       ignored("pthread_attr_setguardsize: ignoring guardsize != 4096");
+
+   return 0;
+}
+
+/* A straight copy of the LinuxThreads code. */
+__attribute__((weak)) 
+int pthread_attr_getguardsize(const pthread_attr_t *attr, size_t *guardsize)
+{
+   *guardsize = attr->__guardsize;
+   return 0;
+}  
+
+
 /* --------------------------------------------------- 
    Helper functions for running a thread 
    and for clearing up afterwards.