Пример #1
0
static int
arenas_initialized_ctl(const size_t *mib, size_t miblen, void *oldp,
    size_t *oldlenp, void *newp, size_t newlen)
{
	int ret;
	unsigned nread, i;

	malloc_mutex_lock(&ctl_mtx);
	READONLY();
	if (*oldlenp != narenas * sizeof(bool)) {
		ret = EINVAL;
		nread = (*oldlenp < narenas * sizeof(bool))
		    ? (*oldlenp / sizeof(bool)) : narenas;
	} else {
		ret = 0;
		nread = narenas;
	}

	for (i = 0; i < nread; i++)
		((bool *)oldp)[i] = ctl_stats.arenas[i].initialized;

label_return:
	malloc_mutex_unlock(&ctl_mtx);
	return (ret);
}
Пример #2
0
static int
swap_prezeroed_ctl(const size_t *mib, size_t miblen, void *oldp,
    size_t *oldlenp, void *newp, size_t newlen)
{
	int ret;

	malloc_mutex_lock(&ctl_mtx);
	if (swap_enabled) {
		READONLY();
	} else {
		/*
		 * swap_prezeroed isn't actually used by the swap code until it
		 * is set during a successful chunk_swap_enabled() call.  We
		 * use it here to store the value that we'll pass to
		 * chunk_swap_enable() in a swap.fds mallctl().  This is not
		 * very clean, but the obvious alternatives are even worse.
		 */
		WRITE(swap_prezeroed, bool);
	}

	READ(swap_prezeroed, bool);

	ret = 0;
RETURN:
	malloc_mutex_unlock(&ctl_mtx);
	return (ret);
}
Пример #3
0
// cObject virtual functions
void cTest::GetVars( cVars& vars )
{
    cObject::GetVars( vars );
    Structs::GetVars( m_info, vars );

    vars << "Readiness"
         << dtSaHpiDimiReadyT
         << DATA( m_ready )
         << VAR_END();
    vars << "Status"
         << dtSaHpiDimiTestRunStatusT
         << DATA( m_status )
         << READONLY()
         << VAR_END();
    vars << "Progress"
         << dtSaHpiDimiTestPercentCompletedT
         << DATA( m_progress )
         << READONLY()
         << VAR_END();
    vars << "Next.RunDuration"
         << dtSaHpiTimeoutT
         << DATA( m_next.run_duration )
         << VAR_END();
    vars << "Next.TestErrorCode"
         << dtSaHpiDimiTestErrCodeT
         << DATA( m_next.err )
         << VAR_END();
    vars << "Next.TestResultString"
         << dtSaHpiTextBufferT
         << DATA( m_next.result_string )
         << VAR_END();
    vars << "Next.TestResultStringIsURI"
         << dtSaHpiBoolT
         << DATA( m_next.result_string_is_uri )
         << VAR_END();
}
Пример #4
0
static int
arena_i_purge_ctl(const size_t *mib, size_t miblen, void *oldp, size_t *oldlenp,
    void *newp, size_t newlen)
{
	int ret;

	READONLY();
	WRITEONLY();
	malloc_mutex_lock(&ctl_mtx);
	arena_purge(mib[1]);
	malloc_mutex_unlock(&ctl_mtx);

	ret = 0;
label_return:
	return (ret);
}
Пример #5
0
static int
thread_tcache_flush_ctl(const size_t *mib, size_t miblen, void *oldp,
    size_t *oldlenp, void *newp, size_t newlen)
{
	int ret;

	if (config_tcache == false)
		return (ENOENT);

	READONLY();
	WRITEONLY();

	tcache_flush();

	ret = 0;
label_return:
	return (ret);
}
Пример #6
0
static int
arenas_extend_ctl(const size_t *mib, size_t miblen, void *oldp, size_t *oldlenp,
    void *newp, size_t newlen)
{
	int ret;
	unsigned narenas;

	malloc_mutex_lock(&ctl_mtx);
	READONLY();
	if (ctl_grow()) {
		ret = EAGAIN;
		goto label_return;
	}
	narenas = ctl_stats.narenas - 1;
	READ(narenas, unsigned);

	ret = 0;
label_return:
	malloc_mutex_unlock(&ctl_mtx);
	return (ret);
}
Пример #7
0
static int
arenas_narenas_ctl(const size_t *mib, size_t miblen, void *oldp,
    size_t *oldlenp, void *newp, size_t newlen)
{
	int ret;
	unsigned narenas;

	malloc_mutex_lock(&ctl_mtx);
	READONLY();
	if (*oldlenp != sizeof(unsigned)) {
		ret = EINVAL;
		goto label_return;
	}
	narenas = ctl_stats.narenas;
	READ(narenas, unsigned);

	ret = 0;
label_return:
	malloc_mutex_unlock(&ctl_mtx);
	return (ret);
}
Пример #8
0
static int
swap_fds_ctl(const size_t *mib, size_t miblen, void *oldp, size_t *oldlenp,
    void *newp, size_t newlen)
{
	int ret;

	malloc_mutex_lock(&ctl_mtx);
	if (swap_enabled) {
		READONLY();
	} else if (newp != NULL) {
		size_t nfds = newlen / sizeof(int);

		{
			int fds[nfds];

			memcpy(fds, newp, nfds * sizeof(int));
			if (chunk_swap_enable(fds, nfds, swap_prezeroed)) {
				ret = EFAULT;
				goto RETURN;
			}
		}
	}

	if (oldp != NULL && oldlenp != NULL) {
		if (*oldlenp != swap_nfds * sizeof(int)) {
			size_t copylen = (swap_nfds * sizeof(int) <= *oldlenp)
			    ? swap_nfds * sizeof(int) : *oldlenp;

			memcpy(oldp, swap_fds, copylen);
			ret = EINVAL;
			goto RETURN;
		} else
			memcpy(oldp, swap_fds, *oldlenp);
	}

	ret = 0;
RETURN:
	malloc_mutex_unlock(&ctl_mtx);
	return (ret);
}