Beispiel #1
0
static int allocate_transition_tls(int id)
{
    /* Libc function to initialize TLS-based locale info for ctype functions. */
    extern void __ctype_init(void);

    /* We want to free and then reallocate the tls rather than simply
     * reinitializing it because its size may have changed.  TODO: not sure if
     * this is right.  0-ing is one thing, but freeing and reallocating can be
     * expensive, esp if syscalls are involved.  Check out glibc's
     * allocatestack.c for what might work. */
    free_transition_tls(id);

    void *tcb = allocate_tls();
    if (!tcb) {
        errno = ENOMEM;
        return -1;
    }

    /* Setup some intitial TLS data for the newly allocated transition tls. */
    void *temp_tcb = get_tls_desc();
    set_tls_desc(tcb);
    begin_safe_access_tls_vars();
    __vcoreid = id;
    __vcore_context = TRUE;
    __ctype_init();
    end_safe_access_tls_vars();
    set_tls_desc(temp_tcb);

    /* Install the new tls into the vcpd. */
    set_vcpd_tls_desc(id, tcb);
    return 0;
}
Beispiel #2
0
static int allocate_transition_tls(int id)
{
	/* We want to free and then reallocate the tls rather than simply 
	 * reinitializing it because its size may have changed.  TODO: not sure if
	 * this is right.  0-ing is one thing, but freeing and reallocating can be
	 * expensive, esp if syscalls are involved.  Check out glibc's
	 * allocatestack.c for what might work. */
	free_transition_tls(id);

	void *tcb = allocate_tls();
	if (!tcb) {
		errno = ENOMEM;
		return -1;
	}
	set_vcpd_tls_desc(id, tcb);
	return 0;
}