WARNING: This server is unstable and will be retired in the next days. If you want to keep this forum available, please request immediately a migration on the Nabble Support forum. Forums that don't receive any migration request will be deleted forever.

alloca in HP NonStop

View: New views
10 Messages — Rating Filter:   Alert me  

alloca in HP NonStop

by Joachim Schmitz-4 :: Rate this Message:

| View Threaded | Show Only this Message

Hi folks

Here's how one could go about to take advantage of the builtin _alloca on HP NonStop in GNUlib:

/usr/local/bin/diff -EBbu ./alloca.in.h.orig ./alloca.in.h
--- ./alloca.in.h.orig  2011-03-12 03:14:26.000000000 -0600
+++ ./alloca.in.h       2012-06-28 02:20:06.000000000 -0500
@@ -46,6 +46,20 @@
 #  define alloca _alloca
 # elif defined __DECC && defined __VMS
 #  define alloca __ALLOCA
+# elif defined __TANDEM /* HP NonStop */
+#  ifdef _TNS_E_TARGET) /* TNS/E, Itanium */
+#   if (__H_Series_RVU >= 622) /* as of O/S release H06.22 resp. J06.11 */
+#    include <builtin.h> /* for _alloca() and the pragma */
+#   else /* the gist of builtin.h for systems lacking it */
+#    define  _BUILTIN
+#    ifdef  __cplusplus
+      extern "C"
+#    endif
+     void *_alloca(unsigned short); /* note the different prototype */
+#    pragma intrinsic(_alloca) /* enable compiler builtin _alloca */
+#   endif
+#   define alloca _alloca /* map _alloca to alloca */
+#  endif /* on other/older HP NonStop targets (TNS, RISC and TNS/R, MIPS) use GNUlib's alloca() */
 # else
 #  include <stddef.h>
#  ifdef  __cplusplus

Instead of the check for being on the right release (__H_Series_RVU >= 622), we could also check for HAVE_BUILTIN_H or some such. Or drop it an just take the else branch.
What is missing, and I have no idea where/how this needs to get added, is the corresponding checks for configure.

Bye, Jojo





Re: alloca in HP NonStop

by Paul Eggert :: Rate this Message:

| View Threaded | Show Only this Message

On 06/28/2012 09:41 AM, Joachim Schmitz wrote:
> Or drop it an just take the else branch.

Yes, that sounds simpler.  Also, how about the following
ideas for simplification:

Don't bother checking __TANDEM; _TNS_E_TARGET should suffice.
This fixes what appears to be a bug on older Tandem systems.

Don't define _BUILTIN (couldn't see why this mattered).

Omit most comments (not really needed here; it's pretty
explanatory).

Use GNU style (space before paren) in pragma.

In short, how about the following patch instead?

---
 ChangeLog       |    7 +++++++
 lib/alloca.in.h |    7 +++++++
 2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e7f7883..979d18a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2012-07-02  Paul Eggert  <eggert@...>
+
+ alloca: add support for HP NonStop TNS/E native
+ * lib/alloca.in.h (alloca): Support the new host.
+ From a suggestion by Joachim Schmitz in
+ <http://lists.gnu.org/archive/html/bug-gnulib/2012-06/msg00355.html>.
+
 2012-07-02  Pádraig Brady  <P@...>
 
  fsusage: remove code not needed on non GNU/Linux systems.
diff --git a/lib/alloca.in.h b/lib/alloca.in.h
index 99be048..0f5ce34 100644
--- a/lib/alloca.in.h
+++ b/lib/alloca.in.h
@@ -42,6 +42,13 @@
 # elif defined _MSC_VER
 #  include <malloc.h>
 #  define alloca _alloca
+# elif defined _TNS_E_TARGET /* HP NonStop TNS/E native */
+#  ifdef  __cplusplus
+    extern "C"
+#  endif
+   void *_alloca (unsigned short);
+#  pragma intrinsic (_alloca)
+#  define alloca _alloca
 # elif defined __DECC && defined __VMS
 #  define alloca __ALLOCA
 # else


RE: alloca in HP NonStop

by Joachim Schmitz-4 :: Rate this Message:

| View Threaded | Show Only this Message

> From: Paul Eggert [mailto:eggert@...]
> Sent: Tuesday, July 03, 2012 2:38 AM
> To: Joachim Schmitz
> Cc: bug-gnulib@...
> Subject: Re: alloca in HP NonStop
>
> On 06/28/2012 09:41 AM, Joachim Schmitz wrote:
> > Or drop it an just take the else branch.
>
> Yes, that sounds simpler.  Also, how about the following ideas for simplification:
>
> Don't bother checking __TANDEM; _TNS_E_TARGET should suffice.
> This fixes what appears to be a bug on older Tandem systems.

Well, rather a missfeature of the older platforms and their compilers to not have that builtin _alloca
Our code always check for __TANDEM && _TNS_E_TARGET, I guess that is for a good reason, so I'd rather keep that.
Also is is similar to
# elif defined __DECC && defined __VMS

I had my code after that, you placed it before that, any special reason?

> Don't define _BUILTIN (couldn't see why this mattered).

Yes, I had that to prevent <builtin.h> multiple inclusion, but come to think of it a check for #ifdef alloca (in our code, it is in GNUlib already) should help too.

> Omit most comments (not really needed here; it's pretty explanatory).

Sure, I just had them in to explain why I did what.

> Use GNU style (space before paren) in pragma.

Sure
 

> In short, how about the following patch instead?
>
> ---
>  ChangeLog       |    7 +++++++
>  lib/alloca.in.h |    7 +++++++
>  2 files changed, 14 insertions(+), 0 deletions(-)
>
> diff --git a/ChangeLog b/ChangeLog
> index e7f7883..979d18a 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,3 +1,10 @@
> +2012-07-02  Paul Eggert  <eggert@...>
> +
> + alloca: add support for HP NonStop TNS/E native
> + * lib/alloca.in.h (alloca): Support the new host.
> + From a suggestion by Joachim Schmitz in
> + <http://lists.gnu.org/archive/html/bug-gnulib/2012-
> 06/msg00355.html>.
> +
>  2012-07-02  Pádraig Brady  <P@...>
>
>   fsusage: remove code not needed on non GNU/Linux systems.
> diff --git a/lib/alloca.in.h b/lib/alloca.in.h index 99be048..0f5ce34 100644
> --- a/lib/alloca.in.h
> +++ b/lib/alloca.in.h
> @@ -42,6 +42,13 @@
>  # elif defined _MSC_VER
>  #  include <malloc.h>
>  #  define alloca _alloca
> +# elif defined _TNS_E_TARGET /* HP NonStop TNS/E native */

Drop the 'native', it is superfluous, on TNS/E we don't have non-native in this context
As mentioned above I'd rather add a check for __TANDEM

> +#  ifdef __cplusplus
> +    extern "C"

I' don't quite understand, why not the entire alloca.in.h is bracketed by this.
At least now that it is used in 2 places?

> +#  endif
> +   void *_alloca (unsigned short);
> +#  pragma intrinsic (_alloca)
> +#  define alloca _alloca
>  # elif defined __DECC && defined __VMS
>  #  define alloca __ALLOCA

As the DEC/VMS part seems much simpler, I'd move it above the NonStop part?

>  # else

Bye, Jojo



Re: alloca in HP NonStop

by Paul Eggert :: Rate this Message:

| View Threaded | Show Only this Message

On 07/02/2012 11:40 PM, Joachim Schmitz wrote:
> I' don't quite understand, why not the entire alloca.in.h is bracketed by this.
> At least now that it is used in 2 places?

We can't bracket the entire file, since (as far as I know)
it's not safe to put #include inside 'extern "C" { ... }'.
How about the following patch instead?
It tries to address your other comments.

diff --git a/ChangeLog b/ChangeLog
index e7f7883..9dda6c7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2012-07-03  Paul Eggert  <eggert@...>
+
+ alloca: add support for HP NonStop TNS/E native
+ * lib/alloca.in.h (alloca): Support the new host.
+ From a suggestion by Joachim Schmitz in
+ <http://lists.gnu.org/archive/html/bug-gnulib/2012-06/msg00355.html>.
+
 2012-07-02  Pádraig Brady  <P@...>
 
  fsusage: remove code not needed on non GNU/Linux systems.
diff --git a/lib/alloca.in.h b/lib/alloca.in.h
index 99be048..ed8aad3 100644
--- a/lib/alloca.in.h
+++ b/lib/alloca.in.h
@@ -45,11 +45,18 @@
 # elif defined __DECC && defined __VMS
 #  define alloca __ALLOCA
 # else
-#  include <stddef.h>
+#  if defined __TANDEM && defined _TNS_E_TARGET
+#   pragma intrinsic (_alloca)
+#   define alloca _alloca
+typedef unsigned short _GL_ALLOCA_SIZE_T;
+#  else
+#   include <stddef.h>
+typedef size_t _GL_ALLOCA_SIZE_T;
+#  endif
 #  ifdef  __cplusplus
 extern "C"
 #  endif
-void *alloca (size_t);
+void *alloca (_GL_ALLOCA_SIZE_T);
 # endif
 #endif
 


RE: alloca in HP NonStop

by Joachim Schmitz-4 :: Rate this Message:

| View Threaded | Show Only this Message

> From: Paul Eggert [mailto:eggert@...]
> Sent: Tuesday, July 03, 2012 10:45 AM
> To: Joachim Schmitz
> Cc: bug-gnulib@...
> Subject: Re: alloca in HP NonStop
>
> On 07/02/2012 11:40 PM, Joachim Schmitz wrote:
> > I' don't quite understand, why not the entire alloca.in.h is bracketed by this.
> > At least now that it is used in 2 places?
>
> We can't bracket the entire file, since (as far as I know) it's not safe to put
> #include inside 'extern "C" { ... }'.
> How about the following patch instead?
> It tries to address your other comments.
>
> diff --git a/ChangeLog b/ChangeLog
> index e7f7883..9dda6c7 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,3 +1,10 @@
> +2012-07-03  Paul Eggert  <eggert@...>
> +
> + alloca: add support for HP NonStop TNS/E native
> + * lib/alloca.in.h (alloca): Support the new host.
> + From a suggestion by Joachim Schmitz in
> + <http://lists.gnu.org/archive/html/bug-gnulib/2012-
> 06/msg00355.html>.
> +
>  2012-07-02  Pádraig Brady  <P@...>
>
>   fsusage: remove code not needed on non GNU/Linux systems.
> diff --git a/lib/alloca.in.h b/lib/alloca.in.h index 99be048..ed8aad3 100644
> --- a/lib/alloca.in.h
> +++ b/lib/alloca.in.h
> @@ -45,11 +45,18 @@
>  # elif defined __DECC && defined __VMS
>  #  define alloca __ALLOCA
>  # else
> -#  include <stddef.h>
> +#  if defined __TANDEM && defined _TNS_E_TARGET
> +#   pragma intrinsic (_alloca)
> +#   define alloca _alloca
> +typedef unsigned short _GL_ALLOCA_SIZE_T; #  else
> +#   include <stddef.h>
> +typedef size_t _GL_ALLOCA_SIZE_T;
> +#  endif
>  #  ifdef  __cplusplus
>  extern "C"
>  #  endif
> -void *alloca (size_t);
> +void *alloca (_GL_ALLOCA_SIZE_T);
>  # endif
>  #endif

Doesn't work, we need the prototype for _alloca() too.

Bye, Jojo



RE: alloca in HP NonStop

by Joachim Schmitz-4 :: Rate this Message:

| View Threaded | Show Only this Message

> From: Joachim Schmitz [mailto:jojo@...]
> Sent: Tuesday, July 03, 2012 11:54 AM
> To: 'Paul Eggert'
> Cc: 'bug-gnulib@...'
> Subject: RE: alloca in HP NonStop
>
> > From: Paul Eggert [mailto:eggert@...]
> > Sent: Tuesday, July 03, 2012 10:45 AM
> > To: Joachim Schmitz
> > Cc: bug-gnulib@...
> > Subject: Re: alloca in HP NonStop
> >
> > On 07/02/2012 11:40 PM, Joachim Schmitz wrote:
> > > I' don't quite understand, why not the entire alloca.in.h is bracketed by this.
> > > At least now that it is used in 2 places?
> >
> > We can't bracket the entire file, since (as far as I know) it's not
> > safe to put #include inside 'extern "C" { ... }'.
> > How about the following patch instead?
> > It tries to address your other comments.
> >
> > diff --git a/ChangeLog b/ChangeLog
> > index e7f7883..9dda6c7 100644
> > --- a/ChangeLog
> > +++ b/ChangeLog
> > @@ -1,3 +1,10 @@
> > +2012-07-03  Paul Eggert  <eggert@...>
> > +
> > + alloca: add support for HP NonStop TNS/E native
> > + * lib/alloca.in.h (alloca): Support the new host.
> > + From a suggestion by Joachim Schmitz in
> > + <http://lists.gnu.org/archive/html/bug-gnulib/2012-
> > 06/msg00355.html>.
> > +
> >  2012-07-02  Pádraig Brady  <P@...>
> >
> >   fsusage: remove code not needed on non GNU/Linux systems.
> > diff --git a/lib/alloca.in.h b/lib/alloca.in.h index 99be048..ed8aad3
> > 100644
> > --- a/lib/alloca.in.h
> > +++ b/lib/alloca.in.h
> > @@ -45,11 +45,18 @@
> >  # elif defined __DECC && defined __VMS  #  define alloca __ALLOCA  #
> > else -#  include <stddef.h>
> > +#  if defined __TANDEM && defined _TNS_E_TARGET
> > +#   pragma intrinsic (_alloca)
> > +#   define alloca _alloca
> > +typedef unsigned short _GL_ALLOCA_SIZE_T; #  else
> > +#   include <stddef.h>
> > +typedef size_t _GL_ALLOCA_SIZE_T;
> > +#  endif
> >  #  ifdef  __cplusplus
> >  extern "C"
> >  #  endif
> > -void *alloca (size_t);
> > +void *alloca (_GL_ALLOCA_SIZE_T);
> >  # endif
> >  #endif
>
> Doesn't work, we need the prototype for _alloca() too.

Or rather: we need that prototype before the pragma

Bye, Jojo



Re: alloca in HP NonStop

by Paul Eggert :: Rate this Message:

| View Threaded | Show Only this Message

On 07/03/2012 02:56 AM, Joachim Schmitz wrote:
> Or rather: we need that prototype before the pragma

OK, in that case we might as well not refactor.
I pushed the following instead:

---
 ChangeLog       |    7 +++++++
 lib/alloca.in.h |    7 +++++++
 2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index e7f7883..9dda6c7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2012-07-03  Paul Eggert  <eggert@...>
+
+ alloca: add support for HP NonStop TNS/E native
+ * lib/alloca.in.h (alloca): Support the new host.
+ From a suggestion by Joachim Schmitz in
+ <http://lists.gnu.org/archive/html/bug-gnulib/2012-06/msg00355.html>.
+
 2012-07-02  Pádraig Brady  <P@...>
 
  fsusage: remove code not needed on non GNU/Linux systems.
diff --git a/lib/alloca.in.h b/lib/alloca.in.h
index 99be048..b9f8bbe 100644
--- a/lib/alloca.in.h
+++ b/lib/alloca.in.h
@@ -44,6 +44,13 @@
 #  define alloca _alloca
 # elif defined __DECC && defined __VMS
 #  define alloca __ALLOCA
+# elif defined __TANDEM && defined _TNS_E_TARGET
+#  ifdef  __cplusplus
+extern "C"
+#  endif
+void *_alloca (unsigned short);
+#  pragma intrinsic (_alloca)
+#  define alloca _alloca
 # else
 #  include <stddef.h>
 #  ifdef  __cplusplus
--
1.7.6.5



RE: alloca in HP NonStop

by Joachim Schmitz-4 :: Rate this Message:

| View Threaded | Show Only this Message

> From: Paul Eggert [mailto:eggert@...]
> Sent: Tuesday, July 03, 2012 7:13 PM
> To: Joachim Schmitz
> Cc: bug-gnulib@...
> Subject: Re: alloca in HP NonStop
>
> On 07/03/2012 02:56 AM, Joachim Schmitz wrote:
> > Or rather: we need that prototype before the pragma
>
> OK, in that case we might as well not refactor.
> I pushed the following instead:

Good stuff, thanks. Still missing seems the detection of this by configure?

Bye, Jojo



Re: alloca in HP NonStop

by Paul Eggert :: Rate this Message:

| View Threaded | Show Only this Message

On 07/04/2012 12:05 AM, Joachim Schmitz wrote:
> Still missing seems the detection of this by configure?

As things stand, I don't see why 'configure' needs to
detect anything.  You mentioned the possibility of
it detecting <builtins.h> but the code works fine
without needing HAVE_BUILTINS_H.  So I assume this
issue is OK as-is; if not please let us know.


RE: alloca in HP NonStop

by Joachim Schmitz-4 :: Rate this Message:

| View Threaded | Show Only this Message

> From: Paul Eggert [mailto:eggert@...]
> Sent: Wednesday, July 04, 2012 9:10 AM
> To: Joachim Schmitz
> Cc: bug-gnulib@...
> Subject: Re: alloca in HP NonStop
>
> On 07/04/2012 12:05 AM, Joachim Schmitz wrote:
> > Still missing seems the detection of this by configure?
>
> As things stand, I don't see why 'configure' needs to detect anything.  You
> mentioned the possibility of it detecting <builtins.h> but the code works fine
> without needing HAVE_BUILTINS_H.  So I assume this issue is OK as-is; if not
> please let us know.

Without changes configure does not detect that we do have a working alloca and then uses gnulib's implementation from alloca.c:

...
checking for working alloca.h... no
checking for alloca... no   <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
checking whether `alloca.c' needs Cray hooks... no
checking stack direction for C alloca... -1
checking for C/C++ restrict keyword... restrict
...


Oh, I see alloca.c internaly skips all code if, after #include <alloca.h> alloca is defined, so I guess I can rest my case...
Got confused by the above configure output.

Bye, Jojo