Skip to content
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

z/OS xlc++ support changes #404

Merged
merged 2 commits into from
Aug 4, 2017
Merged

Conversation

brandonbryan12
Copy link

xlc++ on IBM z/OS does not support casting a pthread_t to a long. The following changes will fix the issue while still supporting other compilers.
Developed in consultation with @adnanhemani

@brandonbryan12 brandonbryan12 changed the title initial z/OS xlc++ support changes z/OS xlc++ support changes Aug 3, 2017
src/java.cpp Outdated
@@ -14,7 +14,8 @@

#define DYNAMIC_PROXY_JS_ERROR -4

long v8ThreadId;
long v8ThreadIdWIN32;
Copy link
Owner

Choose a reason for hiding this comment

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

Could this be replaced with

#ifdef WIN32
  typedef long v8ThreadId;
#else
  typedef pthread_t v8ThreadId;
#endif

and change the usages to use the new type v8ThreadId?

Copy link
Author

Choose a reason for hiding this comment

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

Good catch, and great solution, although I don't believe xlc++ can handle the edit. I get the following error on compilation:

invalid operands to binary expression
('threadId' (aka 'pthread_t') and 'threadId')
if((isWIN32 && (myThreadId == v8ThreadId)) || (!isWIN32 && pthread_equal(myThreadId, v8ThreadId))) {

This is being thrown on:
myThreadId == v8ThreadId
even though it should have short circuited on the isWIN32 check

Copy link
Owner

Choose a reason for hiding this comment

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

I was hoping that by using the typedef you could get rid of a lot of the edits below. For example my_getThreadId could just be written:

v8ThreadId my_getThreadId() {		
  #ifdef WIN32
    return GetCurrentThreadId();
  #else
    return pthread_self();
  #endif
}

then we should be able to get rid of the isWIN32 logic all together.

If you want to use pthread_equal could #define v8ThreadIdEquals(a,b) ...

Copy link
Author

Choose a reason for hiding this comment

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

I went ahead and took the logic out of the condition and put it into a function v8ThreadIdEquals instead. Everything is working perfectly for me on z/OS and OSX

@joeferner joeferner merged commit 978903c into joeferner:master Aug 4, 2017
@joeferner
Copy link
Owner

wonderful thanks for the changes

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