Esempio n. 1
0
/*
 * Prepares the specified hook interface for first use.
 *
 * This function may be called directly.
 *
 * Returns 0 on success, non-zero on failure
 */
intptr_t
J9HookInitializeInterface(struct J9HookInterface **hookInterface, OMRPortLibrary *portLib, size_t interfaceSize)
{
	J9CommonHookInterface *commonInterface = (J9CommonHookInterface *)hookInterface;

	memset(commonInterface, 0, interfaceSize);

	commonInterface->hookInterface = (J9HookInterface *)GLOBAL_TABLE(hookFunctionTable);

	commonInterface->size = interfaceSize;

	if (omrthread_monitor_init_with_name(&commonInterface->lock, 0, "Hook Interface")) {
		J9HookShutdownInterface(hookInterface);
		return J9HOOK_ERR_NOMEM;
	}

	commonInterface->pool = pool_new(sizeof(J9HookRecord), 0, 0, 0, OMR_GET_CALLSITE(), OMRMEM_CATEGORY_VM, POOL_FOR_PORT((OMRPortLibrary *)portLib));
	if (commonInterface->pool == NULL) {
		J9HookShutdownInterface(hookInterface);
		return J9HOOK_ERR_NOMEM;
	}

	commonInterface->nextAgentID = J9HOOK_AGENTID_DEFAULT + 1;
	commonInterface->portLib = portLib;
	commonInterface->threshold4Trace = OMRHOOK_DEFAULT_THRESHOLD_IN_MILLISECONDS_WARNING_CALLBACK_ELAPSED_TIME;

	commonInterface->eventSize = (interfaceSize - sizeof(J9CommonHookInterface)) / (sizeof(U_8) + sizeof(OMREventInfo4Dump) + sizeof(J9HookRecord*));
	return 0;
}
Esempio n. 2
0
/*
 * Prepares the specified hook interface for first use.
 *
 * This function may be called directly.
 *
 * Returns 0 on success, non-zero on failure
 */
intptr_t
J9HookInitializeInterface(struct J9HookInterface **hookInterface, OMRPortLibrary *portLib, size_t interfaceSize)
{
	J9CommonHookInterface *commonInterface = (J9CommonHookInterface *)hookInterface;

	memset(commonInterface, 0, interfaceSize);

	commonInterface->hookInterface = (J9HookInterface *)GLOBAL_TABLE(hookFunctionTable);

	commonInterface->size = interfaceSize;

	if (omrthread_monitor_init_with_name(&commonInterface->lock, 0, "Hook Interface")) {
		J9HookShutdownInterface(hookInterface);
		return J9HOOK_ERR_NOMEM;
	}

	commonInterface->pool = pool_new(sizeof(J9HookRecord), 0, 0, 0, OMR_GET_CALLSITE(), OMRMEM_CATEGORY_VM, POOL_FOR_PORT((OMRPortLibrary *)portLib));
	if (commonInterface->pool == NULL) {
		J9HookShutdownInterface(hookInterface);
		return J9HOOK_ERR_NOMEM;
	}

	commonInterface->nextAgentID = J9HOOK_AGENTID_DEFAULT + 1;

	return 0;
}