This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [gomp] OMP_STACKSIZE env variable
On Mon, Jun 12, 2006 at 12:26:00AM +0100, Richard Earnshaw wrote:
> error: 'PTHREAD_STACK_MIN' undeclared (first use in this function)
By my reading, this number isn't optional. But my use of it
here is merely for better error messages, so it's not worth
worrying about.
r~
* env.c (initialize_env): Avoid using PTHREAD_STACK_MIN when
undefined. Use GOMP_STACKSIZE not OMP_STACKSIZE for environment.
Index: env.c
===================================================================
--- env.c (revision 114614)
+++ env.c (working copy)
@@ -166,21 +166,27 @@ initialize_env (void)
pthread_attr_init (&gomp_thread_attr);
pthread_attr_setdetachstate (&gomp_thread_attr, PTHREAD_CREATE_DETACHED);
- if (parse_unsigned_long ("OMP_STACKSIZE", &stacksize))
+ if (parse_unsigned_long ("GOMP_STACKSIZE", &stacksize))
{
+ int err;
+
stacksize *= 1024;
- if (stacksize < PTHREAD_STACK_MIN)
- gomp_error ("Stack size less than minimum of %luk",
- PTHREAD_STACK_MIN / 1024ul
- + (PTHREAD_STACK_MIN % 1024 != 0));
- else
+ err = pthread_attr_setstacksize (&gomp_thread_attr, stacksize);
+
+#ifdef PTHREAD_STACK_MIN
+ if (err == EINVAL)
{
- int err = pthread_attr_setstacksize (&gomp_thread_attr, stacksize);
- if (err == EINVAL)
+ if (stacksize < PTHREAD_STACK_MIN)
+ gomp_error ("Stack size less than minimum of %luk",
+ PTHREAD_STACK_MIN / 1024ul
+ + (PTHREAD_STACK_MIN % 1024 != 0));
+ else
gomp_error ("Stack size larger than system limit");
- else if (err != 0)
- gomp_error ("Stack size change failed: %s", strerror (err));
}
+ else
+#endif
+ if (err != 0)
+ gomp_error ("Stack size change failed: %s", strerror (err));
}
}