Skip to content

Remove isdigit macro redefs, replace with OMR_ISDIGIT #7711

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Deigue
Copy link
Contributor

@Deigue Deigue commented Apr 2, 2025

Changes here remove the redefinition of isdigit() in
the a2e ctype.h headers. In order to fully make this
work functionally, the references/usages of isdigit()
are replaced with OMR_ISDIGIT to properly recognize
ascii digit literals. This is done by conditionally
using __isdigit_a() on z/OS platforms.


This is the cleaned-up changes from #7413 (for historical related comments)

@Deigue
Copy link
Contributor Author

Deigue commented Apr 2, 2025

@keithc-ca I unintentionally closed #7413 due to a force push earlier. Don't think I could reopen that, so I created this with the cleaned up suggestions.

I verified the advice by the cpp-team and made the replacements across omr and openj9, and also tested with both XLC and Open XL compilation and confirmed that this builds with the jdk21 zos with no issues for both.

The corresponding changes for OpenJ9 are here: eclipse-openj9/openj9#21555
Which might need to be merged at the same time as this one.

@babsingh Tagging for review/additional feedback, updates from #7413

@@ -1376,7 +1378,7 @@ OMR::Options::getNumericValue(const char *& option)
while (pendingOperation)
{
int64_t current = 0;
while (isdigit(*option))
while (__isdigit_a(*option))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's reasonable to define _AE_BIMODAL on all platforms, nor is it reasonable to assume that __isdigit_a() exists on all platforms.

I suggest we should introduce helper macros (e.g. omr_isdigit()) which would be suitably defined for each platform and uses of isdigit() would be replaced by uses of omr_isdigit(). The same approach should be applied for toupper(), tolower(), etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, I can define that in util/a2e/headers/ctype.h I guess.
Is there a __tolower_a() and __toupper_a() similarly available as well? Not able to find documentation around it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. omr_isdigit() would be defined in some OMR header file (perhaps after including ctype.h).

{
count[i] = atoi(s);
while(isdigit(s[0]))
while(OMR_ISDIGIT(s[0]))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While you're here, please add the missing space after while; see also lines 4421, 4444 and changes in other files.

#endif /* defined(J9ZOS390) */

#include <sstream>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was previously not included on z/OS: Have you verified that it is now safe to include?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the before code, I am seeing #include <sstream> in the J9ZOS390 clause already, inbetween the undef and defines.

That being said, it seems to be safe to include so far while compiling as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I misread the change. You are correct, sstream was included on all platforms before and should continue to be.

@@ -23,6 +23,8 @@
#ifndef OMRCOMP_H
#define OMRCOMP_H

#define _AE_BIMODAL
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be conditional:

#if defined(J9ZOS390)
#define _AE_BIMODAL
#endif /* defined(J9ZOS390) */

@keithc-ca
Copy link
Contributor

The summary and description should be updated to reflect the new plan.

@Deigue Deigue changed the title Remove isdigit macro redefs, replace with __isdigit_a Remove isdigit macro redefs, replace with OMR_ISDIGIT Apr 8, 2025
Changes here remove the redefinition of isdigit() in
the a2e ctype.h headers. In order to fully make this
work functionally, the references/usages of isdigit()
are replaced with OMR_ISDIGIT to properly recognize
ascii digit literals. This is done by conditionally
using __isdigit_a() on z/OS platforms.

Signed-off-by: Gaurav Chaudhari <[email protected]>
@Deigue
Copy link
Contributor Author

Deigue commented Apr 15, 2025

After having implemented the feedback, with the latest combination of changes from this and eclipse-openj9/openj9#21555 I am seeing the below errors:

/jit/team/gauravc/repos/openj9-openjdk-jdk21-zos/omr/compiler/control/OMROptions.cpp:4418:14: error: use of undeclared identifier '__isdigit_a'
 4418 |          if (OMR_ISDIGIT(s[0]))
      |              ^
/jit/team/gauravc/repos/openj9-openjdk-jdk21-zos/omr/include_core/omrcomp.h:621:24: note: expanded from macro 'OMR_ISDIGIT'
  621 | #define OMR_ISDIGIT(x) __isdigit_a(x)
      |                        ^
/jit/team/gauravc/repos/openj9-openjdk-jdk21-zos/omr/compiler/control/OMROptions.cpp:4421:20: error: use of undeclared identifier '__isdigit_a'
 4421 |             while (OMR_ISDIGIT(s[0]))
      |                    ^
/jit/team/gauravc/repos/openj9-openjdk-jdk21-zos/omr/include_core/omrcomp.h:621:24: note: expanded from macro 'OMR_ISDIGIT'
  621 | #define OMR_ISDIGIT(x) __isdigit_a(x)
      |                        ^
/jit/team/gauravc/repos/openj9-openjdk-jdk21-zos/omr/compiler/control/OMROptions.cpp:4441:14: error: use of undeclared identifier '__isdigit_a'
 4441 |          if (OMR_ISDIGIT(s[0]))
      |              ^
/jit/team/gauravc/repos/openj9-openjdk-jdk21-zos/omr/include_core/omrcomp.h:621:24: note: expanded from macro 'OMR_ISDIGIT'
  621 | #define OMR_ISDIGIT(x) __isdigit_a(x)
      |                        ^
/jit/team/gauravc/repos/openj9-openjdk-jdk21-zos/omr/compiler/control/OMROptions.cpp:4444:20: error: use of undeclared identifier '__isdigit_a'
 4444 |             while (OMR_ISDIGIT(s[0]))
      |                    ^
/jit/team/gauravc/repos/openj9-openjdk-jdk21-zos/omr/include_core/omrcomp.h:621:24: note: expanded from macro 'OMR_ISDIGIT'
  621 | #define OMR_ISDIGIT(x) __isdigit_a(x)
      |                        ^
5 warnings and 9 errors generated.
make[6]: *** [runtime/compiler/CMakeFiles/j9jit.dir/build.make:5974: runtime/compiler/CMakeFiles/j9jit.dir/jit/team/gauravc/repos/openj9-openjdk-jdk21-zos/omr/compiler/control/OMROptions.cpp.o] Error 1

From this it looks like #define AE_BIMODAL might have to be in each file referencing OMR_ISDIGIT() , does that sound right?

@keithc-ca
Copy link
Contributor

looks like #define AE_BIMODAL might have to be in each file referencing OMR_ISDIGIT() , does that sound right?

No, that doesn't sound right: That should be contained to the header file that defines OMR_ISDIGIT().

@Deigue
Copy link
Contributor Author

Deigue commented Apr 16, 2025

Strange ... I am trying to remove the #if defined(J9ZOS390) in omrcomp.h surrounding the AE_BIMODAL definition to see if it helps, but it would not make sense that part is not working as expected, while the conditional is working around pathing towards and picking the __isdigit_a() call later in that same file.
Also trying to add #include "omrcomp.h" explicitly to see if it makes a difference

If that doesn't work either, then not sure why error: use of undeclared identifier '__isdigit_a' (i.e. isdigit_a() remains undefined) , and will ask around to the compiler team for clarification with the pr changes context.

EDIT: Also trying to include <ctype.h> within omrcomp.h ... noticed that is missing, and might be the reason behind the problem in the first place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants