<commit_before>/*
 *  Licensed to the Apache Software Foundation (ASF) under one or more
 *  contributor license agreements.  See the NOTICE file distributed with
 *  this work for additional information regarding copyright ownership.
 *  The ASF licenses this file to You under the Apache License, Version 2.0
 *  (the "License"); you may not use this file except in compliance with
 *  the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
/** 
 * @author <NAME>
 * @version $Revision: 1.1.2.1.4.5 $
 */  
#include <assert.h>

#include "platform_lowlevel.h"
#include "vm_trace.h"

#include "zipsup.h"
#include "environment.h"
#include "properties.h"
#include "vmi.h"

extern VMInterfaceFunctions_ vmi_impl;
VMInterface vmi = &vmi_impl;

HyPortLibrary portLib;
HyPortLibrary* portLibPointer = NULL;
HyZipCachePool* zipCachePool = NULL;

VMInterface* JNICALL 
VMI_GetVMIFromJNIEnv(JNIEnv *env) 
{
    TRACE("GetVMIFromJNIEnv(): returning " << &vmi);
    return &vmi;
}

VMInterface* JNICALL 
VMI_GetVMIFromJavaVM(JavaVM *vm) 
{
    TRACE("VMI_GetVMIFromJavaVM(): returning " << &vmi);
    return &vmi;
}

/*
 * FIXME: support for previous drop from partner - to be removed.
 */
char* VMI_bootstrapClassPath(JNIEnv *env)
{
    assert(/* vmi.dll: VMI_bootstrapClassPath unimplemented. */0);
    return NULL;
}

/*
 * FIXME: support for previous drop from partner - to be removed.
 */
void VMI_fullVersionString(JNIEnv *env, char *fullversion, int size)
{
    assert(/* vmi.dll: VMI_fullVersionString unimplemented. */0);
    return;
}

/*
 * FIXME: support for previous drop from partner - to be removed.
 */
char* VMI_VMVersion(JNIEnv *env)
{
    assert(/* vmi.dll: VMI_VMVersion unimplemented. */0);
    return NULL;
}

/*
 * FIXME: support for previous drop from partner - to be removed.
 */
JavaVMInitArgs* VMI_initArgsFromEnv(JNIEnv *env)
{
    assert(/* vmi.dll: VMI_initArgsFromEnv unimplemented. */0);
    return NULL;
}

/*
 * FIXME: support for previous drop from partner - to be removed.
 */
HyZipCachePool* VMI_zipCachePool(JNIEnv *env)
{

    assert(/* vmi.dll:  unimplemented. */0);
    return NULL;
}

//////////////////////////////////////
//  VMI structure member functions  //
//////////////////////////////////////

vmiError JNICALL CheckVersion(VMInterface *vmi, vmiVersion *version)
{
    assert(/* vmi.dll:  unimplemented. */0);
    return VMI_ERROR_UNIMPLEMENTED;
}

JavaVM *JNICALL GetJavaVM(VMInterface *vmi)
{
    assert(/* vmi.dll:  unimplemented. */0);
    return NULL;
}

//#ifdef __cplusplus
//extern "C" {
//#endif
//JNIEXPORT int j9port_allocate_library(void *version, J9PortLibrary **portLibrary);
//#ifdef __cplusplus
//}
//#endif
 
HyPortLibrary *JNICALL GetPortLibrary(VMInterface *vmi)
{
    static int initialized = 0;

    if (! initialized)
    {
        // First, try to get the portlib pointer from global env (must have been put there during args parse)
        portLibPointer = (HyPortLibrary*)VM_Global_State::loader_env->portLib;
        if (NULL != portLibPointer) {
			initialized = 1;
            return portLibPointer;
        }
        // If the above fails, initialize portlib here
        int rc;
        HyPortLibraryVersion portLibraryVersion;
        HYPORT_SET_VERSION(&portLibraryVersion, HYPORT_CAPABILITY_MASK);

        rc = hyport_init_library(&portLib, &portLibraryVersion, 
                sizeof(HyPortLibrary));
        TRACE("vmi->GetPortLibrary() initializing: rc = " << rc);

        if (0 != rc) return NULL;
<commit_msg>some minor cleanup<commit_after>/*
 *  Licensed to the Apache Software Foundation (ASF) under one or more
 *  contributor license agreements.  See the NOTICE file distributed with
 *  this work for additional information regarding copyright ownership.
 *  The ASF licenses this file to You under the Apache License, Version 2.0
 *  (the "License"); you may not use this file except in compliance with
 *  the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
/** 
 * @author <NAME>
 * @version $Revision: 1.1.2.1.4.5 $
 */  
#include <assert.h>

#include "platform_lowlevel.h"
#include "vm_trace.h"

#include "zipsup.h"
#include "environment.h"
#include "properties.h"
#include "vmi.h"

extern VMInterfaceFunctions_ vmi_impl;
VMInterface vmi = &vmi_impl;

HyPortLibrary portLib;
HyPortLibrary* portLibPointer = NULL;
HyZipCachePool* zipCachePool = NULL;

VMInterface* JNICALL 
VMI_GetVMIFromJNIEnv(JNIEnv *env) 
{
    TRACE("GetVMIFromJNIEnv(): returning " << &vmi);
    return &vmi;
}

VMInterface* JNICALL 
VMI_GetVMIFromJavaVM(JavaVM *vm) 
{
    TRACE("VMI_GetVMIFromJavaVM(): returning " << &vmi);
    return &vmi;
}


//////////////////////////////////////
//  VMI structure member functions  //
//////////////////////////////////////

vmiError JNICALL CheckVersion(VMInterface *vmi, vmiVersion *version)
{
    assert(/* vmi.dll:  unimplemented. */0);
    return VMI_ERROR_UNIMPLEMENTED;
}

JavaVM *JNICALL GetJavaVM(VMInterface *vmi)
{
    assert(/* vmi.dll:  unimplemented. */0);
    return NULL;
}
 
HyPortLibrary *JNICALL GetPortLibrary(VMInterface *vmi)
{
    static int initialized = 0;

    if (! initialized)
    {
        // First, try to get the portlib pointer from global env (must have been put there during args parse)
        portLibPointer = (HyPortLibrary*)VM_Global_State::loader_env->portLib;
        if (NULL != portLibPointer) {
			initialized = 1;
            return portLibPointer;
        }
        // If the above fails, initialize portlib here
        int rc;
        HyPortLibraryVersion portLibraryVersion;
        HYPORT_SET_VERSION(&portLibraryVersion, HYPORT_CAPABILITY_MASK);

        rc = hyport_init_library(&portLib, &portLibraryVersion, 
                sizeof(HyPortLibrary));
        TRACE("vmi->GetPortLibrary() initializing: rc = " << rc);

        if (0 != rc) return NULL;

{'fraction_non_alphanumeric': 0.12460112444917186, 'fraction_numerical': 0.005622245859291901, 'mean_word_length': 3.1763959390862944, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4468606', 'n_tokens_mistral': 2090, 'n_tokens_neox': 2045, 'n_words': 624}