Skip to content

Commit

Permalink
Merge pull request #2858 from babsingh/macos_port_pr
Browse files Browse the repository at this point in the history
OpenJ9 fixes for OSX support [Part 1]
  • Loading branch information
DanHeidinga authored Sep 14, 2018
2 parents a367787 + 6c6a0c3 commit b04a51b
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 43 deletions.
7 changes: 2 additions & 5 deletions runtime/gc_realtime/BarrierSynchronization.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

/*******************************************************************************
* Copyright (c) 1991, 2014 IBM Corp. and others
* Copyright (c) 1991, 2018 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -45,7 +44,6 @@ class MM_BarrierSynchronization : public MM_BaseVirtual
J9JavaVM *_vm; /**< Retained to access VM functions. */
UDATA _vmResponsesRequiredForExclusiveVMAccess; /**< Used to support the (request/wait)ExclusiveVMAccess methods. */
UDATA _jniResponsesRequiredForExclusiveVMAccess; /**< Used to support the (request/wait)ExclusiveVMAccess methods. */
U_32 _tokenCount; /**< A counter for which ragged barrier we are currently on. */

/* Methods */
public:
Expand All @@ -59,8 +57,7 @@ class MM_BarrierSynchronization : public MM_BaseVirtual
MM_BarrierSynchronization(MM_EnvironmentBase *env) :
_vm((J9JavaVM *)env->getOmrVM()->_language_vm),
_vmResponsesRequiredForExclusiveVMAccess(0),
_jniResponsesRequiredForExclusiveVMAccess(0),
_tokenCount(0)
_jniResponsesRequiredForExclusiveVMAccess(0)
{
_typeId = __FUNCTION__;
}
Expand Down
7 changes: 3 additions & 4 deletions runtime/gc_realtime/MetronomeAlarm.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

/*******************************************************************************
* Copyright (c) 1991, 2017 IBM Corp. and others
* Copyright (c) 1991, 2018 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -246,13 +245,13 @@ MM_ITAlarm::initialize(MM_EnvironmentBase *env, MM_MetronomeAlarmThread* alarmTh
void
MM_RTCAlarm::sleep()
{
#if defined(LINUX)
#if defined(LINUX) && !defined(J9ZTPF)
UDATA data;
ssize_t readAmount = read(RTCfd, &data, sizeof(data));
if (readAmount == -1) {
perror("blocking read failed");
}
#endif
#endif /* defined(LINUX) && !defined(J9ZTPF) */
}

void
Expand Down
7 changes: 4 additions & 3 deletions runtime/gc_realtime/MetronomeAlarm.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

/*******************************************************************************
* Copyright (c) 1991, 2017 IBM Corp. and others
* Copyright (c) 1991, 2018 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -99,8 +98,10 @@ class MM_HRTAlarm : public MM_Alarm

class MM_RTCAlarm : public MM_Alarm
{
private:
private:
#if defined(LINUX) && !defined(J9ZTPF)
IDATA RTCfd;
#endif /* defined(LINUX) && !defined(J9ZTPF) */

public:
static MM_RTCAlarm * newInstance(MM_EnvironmentBase *env, MM_OSInterface* osInterface);
Expand Down
7 changes: 3 additions & 4 deletions runtime/util/cpplink.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

/*******************************************************************************
* Copyright (c) 1991, 2014 IBM Corp. and others
* Copyright (c) 1991, 2018 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand All @@ -25,7 +24,7 @@
#include <stdlib.h>
#include "j9user.h"

#if defined(LINUX)
#if defined(LINUX) || defined(OSX)
/* Hack - to satisfy the runtime linker we need a definition of this function, should never be called */
void __pure_virtual();
void __cxa_pure_virtual();
Expand All @@ -41,4 +40,4 @@ void __cxa_pure_virtual()
__pure_virtual();
}

#endif /* defined(LINUX) */
#endif /* defined(LINUX) || defined(OSX) */
52 changes: 25 additions & 27 deletions runtime/vm/statistics.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 1991, 2016 IBM Corp. and others
* Copyright (c) 1991, 2018 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand All @@ -25,26 +25,24 @@


void *
addStatistic (J9JavaVM* javaVM, U_8 * name, U_8 dataType)
addStatistic(J9JavaVM *javaVM, U_8 *name, U_8 dataType)
{
PORT_ACCESS_FROM_JAVAVM(javaVM);
J9Statistic *statistic = NULL;

IDATA stringSize = strlen((char*)name) + 1;
IDATA size = stringSize;
J9Statistic * statistic;
/* J9Statistic->name[1] accounts +1 for the null character. */
IDATA size = sizeof(*statistic) + (sizeof(char) * strlen((char *)name));

/* Adjust for the default size in the struct array of 4 */
size += offsetof(J9Statistic, name);
PORT_ACCESS_FROM_JAVAVM(javaVM);

/* Allocate and fill the structure */
statistic = j9mem_allocate_memory(size, OMRMEM_CATEGORY_VM);
if (statistic != NULL) {
if (NULL != statistic) {
statistic->dataSlot = 0;
statistic->dataType = (U_32) dataType;
strcpy((char*)&(statistic->name), (char*)name);
strcpy((char *)statistic->name, (char *)name);

/* Grab the monitor - if initialized (some statistics set prior to vmthinit.c) */
if (javaVM->statisticsMutex) {
if (NULL != javaVM->statisticsMutex) {
omrthread_monitor_enter(javaVM->statisticsMutex);
}

Expand All @@ -53,65 +51,65 @@ addStatistic (J9JavaVM* javaVM, U_8 * name, U_8 dataType)
javaVM->nextStatistic = statistic;

/* Release the monitor */
if (javaVM->statisticsMutex) {
if (NULL != javaVM->statisticsMutex) {
omrthread_monitor_exit(javaVM->statisticsMutex);
}
}

return (void *) statistic;
return (void *)statistic;
}


void
deleteStatistics (J9JavaVM* javaVM)
deleteStatistics(J9JavaVM *javaVM)
{
PORT_ACCESS_FROM_JAVAVM(javaVM);
J9Statistic *statistic = NULL;

J9Statistic * statistic;
PORT_ACCESS_FROM_JAVAVM(javaVM);

if (javaVM->statisticsMutex) {
if (NULL != javaVM->statisticsMutex) {
omrthread_monitor_enter(javaVM->statisticsMutex);
}

statistic = javaVM->nextStatistic;

/* Delete the linked list */
while (statistic != NULL) {
J9Statistic * nextStatistic = statistic->nextStatistic;
while (NULL != statistic) {
J9Statistic *nextStatistic = statistic->nextStatistic;
j9mem_free_memory(statistic);
statistic = nextStatistic;
}
javaVM->nextStatistic = NULL;

if (javaVM->statisticsMutex) {
if (NULL != javaVM->statisticsMutex) {
omrthread_monitor_exit(javaVM->statisticsMutex);
}
}


void *
getStatistic (J9JavaVM* javaVM, U_8 * name)
getStatistic(J9JavaVM *javaVM, U_8 *name)
{
J9Statistic * statistic;
J9Statistic *statistic = NULL;

if (javaVM->statisticsMutex) {
if (NULL != javaVM->statisticsMutex) {
omrthread_monitor_enter(javaVM->statisticsMutex);
}

statistic = javaVM->nextStatistic;

/* Walk the linked list */
while (statistic != NULL) {
if (strcmp((char*)name, (char*)&(statistic->name)) == 0) {
while (NULL != statistic) {
if (strcmp((char *)name, (char *)statistic->name) == 0) {
break;
}
statistic = statistic->nextStatistic;
}

if (javaVM->statisticsMutex) {
if (NULL != javaVM->statisticsMutex) {
omrthread_monitor_exit(javaVM->statisticsMutex);
}

return (void *) statistic;
return (void *)statistic;
}

0 comments on commit b04a51b

Please sign in to comment.