Discussion:
OpenVMS needs __UNIX_PUTC macro defined for configure tests.
John E. Malmberg
2017-07-06 12:47:09 UTC
Permalink
Hello John,
* Config.h
OpenVMS needs __UNIX_PUTC macro defined for putc_unlocked
and friends to be visible.
The right place to do this (for a macro that affects multiple
gnulib modules) is the 'extensions' module.
This makes it visible to the modules being built, but not to the tests
in the configure script.

Which means that configure does not detect that OpenVMS provides
declarations and macros for "fputc_unlocked", "putc_unlocked", and
"putchar_unlocked"

Since configure did not detect them, this causes unlocked-io.h to
redefine the macros above for them with different enough definitions
that the OpenVMS C compiler emits a diagnostic.

Also on OpenVMS __UNIX_PUTC macro can not be used currently with the C++
compiler which defines "__cplusplus) due to an issue in that compiler
according to the stdio.h header file comments.

So would the fix be to just put all the logic in unlocked-io.h for it to
make visible the OpenVMS unlocked IO routines for C only?

Then it mostly does not matter if configure detects them, since they are
not available to the OpenVMS c++ compiler.

Regards,
-John
Bruno Haible
2017-07-06 14:33:21 UTC
Permalink
Post by John E. Malmberg
* Config.h
OpenVMS needs __UNIX_PUTC macro defined for putc_unlocked
and friends to be visible.
The right place to do this (for a macro that affects multiple
gnulib modules) is the 'extensions' module.
This makes it visible to the modules being built, but not to the tests
in the configure script.
No, m4/extensions.m4 is written in such a way that all definitions
inside AC_USE_SYSTEM_EXTENSIONS become active before the first test
in the configure script gets run.
Post by John E. Malmberg
Also on OpenVMS __UNIX_PUTC macro can not be used currently with the C++
compiler
Then how about
#ifndef __cplusplus
# define __UNIX_PUTC 1
#endif
?
Post by John E. Malmberg
So would the fix be to just put all the logic in unlocked-io.h for it to
make visible the OpenVMS unlocked IO routines for C only?
I guess that this would not work:
#include <stdio.h>
#include "unlocked-io.h"
would not make the unlocked IO routines visible, because <stdio.h> gets skipped
when it gets included a second time. Right?

Bruno
Paul Eggert
2017-07-06 22:04:30 UTC
Permalink
Post by Bruno Haible
#include <stdio.h>
#include "unlocked-io.h"
would not make the unlocked IO routines visible, because <stdio.h> gets skipped
when it gets included a second time. Right?
If we treat __UNIX_PUTC like we treat _GNU_SOURCE then we should be OK, since
__UNIX_PUTC will be defined in config.h and thus the first <stdio.h> will see it.
John E. Malmberg
2017-07-07 01:00:15 UTC
Permalink
Post by Paul Eggert
Post by Bruno Haible
#include <stdio.h>
#include "unlocked-io.h"
would not make the unlocked IO routines visible, because <stdio.h> gets skipped
when it gets included a second time. Right?
If we treat __UNIX_PUTC like we treat _GNU_SOURCE then we should be OK,
since __UNIX_PUTC will be defined in config.h and thus the first
<stdio.h> will see it.
I found out what the issue is. The OpenVMS stdio.h file makes the
unlocked IO routines only available as macros. There is no declaration.

Configure detects the macros, and that there is no declaration of them.

The unlocked-io.h since the HAVE_DECL_FPUTS_UNLOCKED is not defined,
redefines the "fputc_unlocked" to not work.

So unlocked-io.h would need to be modified to not replace the OpenVMS
stdio.h macros if they exist.

Regards,
-John
Bruno Haible
2017-07-07 07:43:04 UTC
Permalink
Post by John E. Malmberg
I found out what the issue is. The OpenVMS stdio.h file makes the
unlocked IO routines only available as macros. There is no declaration.
Configure detects the macros, and that there is no declaration of them.
The unlocked-io.h since the HAVE_DECL_FPUTS_UNLOCKED is not defined,
redefines the "fputc_unlocked" to not work.
So unlocked-io.h would need to be modified to not replace the OpenVMS
stdio.h macros if they exist.
OK, can you provide a patch to m4/unlocked-io.m4 and/or lib/unlocked-io.h?

Bruno
John E. Malmberg
2017-07-19 13:15:12 UTC
Permalink
Post by Bruno Haible
Post by John E. Malmberg
I found out what the issue is. The OpenVMS stdio.h file makes the
unlocked IO routines only available as macros. There is no declaration.
Configure detects the macros, and that there is no declaration of them.
The unlocked-io.h since the HAVE_DECL_FPUTS_UNLOCKED is not defined,
redefines the "fputc_unlocked" to not work.
So unlocked-io.h would need to be modified to not replace the OpenVMS
stdio.h macros if they exist.
OK, can you provide a patch to m4/unlocked-io.m4 and/or lib/unlocked-io.h?
Here is a patch that modifies m4/extensions to enable the unlocked
functions on OpenVMS.

I then modified lib/argp-namefrob.h and lib/unlocked-io.h to not replace
the OpenVMS macros.

I assume that there is a reason that lib/arg-namefrob.h is not just
including lib/unlocked-io.h.

I was not sure if mentioning that the unlocked functions currently are
not available for OpenVMS C++ programs due to an issue with the current
C++ compiler in the posix-functions documentation.

Regards,
-John

Loading...