112027Sjungma@eit.uni-kl.de/*
212027Sjungma@eit.uni-kl.de * QuickThreads -- Threads-building toolkit.
312027Sjungma@eit.uni-kl.de * Copyright (c) 1993 by David Keppel
412027Sjungma@eit.uni-kl.de *
512027Sjungma@eit.uni-kl.de * Permission to use, copy, modify and distribute this software and
612027Sjungma@eit.uni-kl.de * its documentation for any purpose and without fee is hereby
712027Sjungma@eit.uni-kl.de * granted, provided that the above copyright notice and this notice
812027Sjungma@eit.uni-kl.de * appear in all copies.  This software is provided as a
912027Sjungma@eit.uni-kl.de * proof-of-concept and for demonstration purposes; there is no
1012027Sjungma@eit.uni-kl.de * representation about the suitability of this software for any
1112027Sjungma@eit.uni-kl.de * purpose.
1212027Sjungma@eit.uni-kl.de */
1312027Sjungma@eit.uni-kl.de
1412027Sjungma@eit.uni-kl.de
1512027Sjungma@eit.uni-kl.de#include <stdarg.h>
1612027Sjungma@eit.uni-kl.de#include "qt.h"
1712027Sjungma@eit.uni-kl.de
1812027Sjungma@eit.uni-kl.de// This static is used to find the end of the stack for variable
1912027Sjungma@eit.uni-kl.de
2012027Sjungma@eit.uni-kl.destatic void *qt_sp_bottom_save;
2112027Sjungma@eit.uni-kl.de
2212027Sjungma@eit.uni-kl.de/* We actually don't know how the compiler accomodates arguments in the
2312027Sjungma@eit.uni-kl.de * va_list. In some implementation (e.g. Linux PPC) we cannot scan the
2412027Sjungma@eit.uni-kl.de * list as an array. To avoid this problem, this version of "qt_varg",
2512027Sjungma@eit.uni-kl.de * retrieves arguments by means of the standard "va_arg" macro defined
2612027Sjungma@eit.uni-kl.de * in stdargs.h.
2712027Sjungma@eit.uni-kl.de *
2812027Sjungma@eit.uni-kl.de * Notice that we still suppose that the number of arguments is given
2912027Sjungma@eit.uni-kl.de * by nbytes/sizeof(qt_word_t) and we load the stack of "qt_vstart"
3012027Sjungma@eit.uni-kl.de * assuming that all parameters are alligned to the size of qt_word_t.
3112027Sjungma@eit.uni-kl.de *
3212027Sjungma@eit.uni-kl.de * Marco Bucci <marco.bucci@inwind.it>
3312027Sjungma@eit.uni-kl.de * December 2002
3412027Sjungma@eit.uni-kl.de */
3512027Sjungma@eit.uni-kl.de
3612027Sjungma@eit.uni-kl.de/*
3712027Sjungma@eit.uni-kl.de
3812027Sjungma@eit.uni-kl.deqt_t *qt_vargs (qt_t *sp, int nbytes, void *vargs,
3912027Sjungma@eit.uni-kl.de	  void *pt, qt_startup_t *startup,
4012027Sjungma@eit.uni-kl.de	  qt_vuserf_t *vuserf, qt_cleanup_t *cleanup)
4112027Sjungma@eit.uni-kl.de
4212027Sjungma@eit.uni-kl.de*/
4312027Sjungma@eit.uni-kl.de
4412027Sjungma@eit.uni-kl.de  qt_t *
4512027Sjungma@eit.uni-kl.deqt_vargs_stdarg (qt_t *sp, int nbytes, va_list vargs,
4612027Sjungma@eit.uni-kl.de	  void *pt, qt_startup_t *startup,
4712027Sjungma@eit.uni-kl.de	  qt_vuserf_t *vuserf, qt_cleanup_t *cleanup)
4812027Sjungma@eit.uni-kl.de
4912027Sjungma@eit.uni-kl.de
5012027Sjungma@eit.uni-kl.de
5112027Sjungma@eit.uni-kl.de{
5212027Sjungma@eit.uni-kl.de	int i;
5312027Sjungma@eit.uni-kl.de	qt_word_t arg;
5412027Sjungma@eit.uni-kl.de
5512027Sjungma@eit.uni-kl.de	sp = QUICKTHREADS_VARGS_MD0 (sp, nbytes);
5612027Sjungma@eit.uni-kl.de
5712027Sjungma@eit.uni-kl.de	for ( i=0;i<(int)(nbytes/sizeof(qt_word_t)); i++)
5812027Sjungma@eit.uni-kl.de    {
5912027Sjungma@eit.uni-kl.de    	arg = va_arg(vargs, qt_word_t);
6012027Sjungma@eit.uni-kl.de      	QUICKTHREADS_SPUT (QUICKTHREADS_VARGS_ADJUST(sp), i, arg);
6112027Sjungma@eit.uni-kl.de    }
6212027Sjungma@eit.uni-kl.de
6312027Sjungma@eit.uni-kl.de	QUICKTHREADS_VARGS_MD1 (QUICKTHREADS_VADJ(sp));
6412027Sjungma@eit.uni-kl.de	QUICKTHREADS_SPUT (QUICKTHREADS_VADJ(sp), QUICKTHREADS_VARGT_INDEX, pt);
6512027Sjungma@eit.uni-kl.de	QUICKTHREADS_SPUT (QUICKTHREADS_VADJ(sp), QUICKTHREADS_VSTARTUP_INDEX, startup);
6612027Sjungma@eit.uni-kl.de	QUICKTHREADS_SPUT (QUICKTHREADS_VADJ(sp), QUICKTHREADS_VUSERF_INDEX, vuserf);
6712027Sjungma@eit.uni-kl.de	QUICKTHREADS_SPUT (QUICKTHREADS_VADJ(sp), QUICKTHREADS_VCLEANUP_INDEX, cleanup);
6812027Sjungma@eit.uni-kl.de	return ((qt_t *)QUICKTHREADS_VADJ(sp));
6912027Sjungma@eit.uni-kl.de}
70