Example #1
0
TET_IMPORT long *tet_thr_sequence()
{
	/* find tet_sequence address for this thread */

	void *rtval;

#  ifdef TET_STRICT_POSIX_THREADS
	static long child_tet_sequence;

	if (IS_CHILD_OF_MULTITHREAD_PARENT)
		return(&child_tet_sequence);
#  endif

	rtval = 0;
	TET_THR_GETSPECIFIC(tet_sequence_key, &rtval);
	if (rtval == 0)
	{
		/* No tet_sequence has been set up for this thread - probably
		   because it was not created with tet_thr_create().
		   Try and allocate a new tet_sequence. */

		rtval = malloc(sizeof(long));
		TET_THR_SETSPECIFIC(tet_sequence_key, rtval);
		rtval = 0;
		TET_THR_GETSPECIFIC(tet_sequence_key, &rtval);
		if (rtval == 0)
			fatal(0, "could not set up tet_sequence for new thread in tet_thr_sequence", (char *)0);
		*((long *)rtval) = 0;
	}

	return (long *)rtval;
}
Example #2
0
TET_IMPORT pid_t *tet_thr_child()
{
    /* find tet_child address for this thread */

    void *rtval;

    rtval = 0;
    TET_THR_GETSPECIFIC(tet_child_key, &rtval);
    if (rtval == 0)
    {
        /* No tet_child has been set up for this thread - probably
           because it was not created with tet_thr_create().
           Try and allocate a new tet_child. */

        rtval = malloc(sizeof(pid_t));
        TET_THR_SETSPECIFIC(tet_child_key, rtval);
        rtval = 0;
        TET_THR_GETSPECIFIC(tet_child_key, &rtval);
        if (rtval == 0)
            fatal(0, "could not set up tet_child for new thread in tet_thr_child", (char *)0);
        *((pid_t *)rtval) = 0;
    }

    return (pid_t *)rtval;
}