Beispiel #1
0
void init_user(void *ptr) {
    int res;
    // on vient du main de master
    ptr = virtual_memory;


    _int(SYSCALL_SWITCH_0);
    memset(ptr,1,PAGE_SIZE * N/NB_PROCESS);
    printf("Current process : %d \n",current_process);
    _int(SYSCALL_SWITCH_1);
    memset(ptr,3,PAGE_SIZE * N/NB_PROCESS);
    printf("Current process : %d \n",current_process);


    /*int i;
    for(i=0; i<= (N/4);i++){
            _int(SYSCALL_SWITCH_0);
            memset(ptr, 1, PAGE_SIZE * (i));
            printf("Current process : %d \n",current_process);
            _int(SYSCALL_SWITCH_1);
            memset(ptr, 3, PAGE_SIZE * (i));
            printf("Current process : %d \n",current_process);
    }*/


    _int(SYSCALL_SWITCH_0);
    res = sum(ptr);
    printf("Resultat du processus 0 : %d \n",res); /* doit renvoyer la taille memoire */

    _int(SYSCALL_SWITCH_1);
    res = sum(ptr);
    printf("Resultat processus 1 : %d \n",res);
}
Beispiel #2
0
/*
 * \brief
 *    Wrap a periodic result to a interval of [a, b]
 * \param   x  The number to wrap/limit
 * \param   a  The interval first number
 * \param   b  The interval second number
 * \return  The wrapped number
 */
static double _wrap (double x, double a, double b)
{
   double   b_a = b-a;              /* take interval */
   int      p = _int(x)/_int(b_a);  /* find periods */

   x -= p*b_a;
   x += (x<a) ? b_a : 0;
   x -= (x>b) ? b_a : 0;
   return x;
}
Beispiel #3
0
 /**
     Assignment from integer initializer list.
     @param components color components.
     @return reference to this.
  */
 Color &operator = (const std::initializer_list<int> &components) {
     std::initializer_list<int>::const_iterator it = components.begin();
     switch (components.size()) {
         case 4: m_color.m_alpha = _int(*(it + 3));
         case 3: m_color.m_blue  = _int(*(it + 2));
         case 2: m_color.m_green = _int(*(it + 1));
         case 1: m_color.m_red   = _int(*it);
     }
     return *this;
 }
Beispiel #4
0
static
Value *
eval(const Ast *expr) {
	switch(expr->class) {
	case N_CALL:
		return call(expr);
	case N_ASSIGNMENT:
		return assignment(expr);
	case N_IDENTIFIER:
		return identifier(expr);
	case N_NEG:
		return _neg(expr);
	case N_NOT:
		return _not(expr);
	case N_EQ:
		return _eq(expr);
	case N_NEQ:
		return _neq(expr);
	case N_AND:
		return _and(expr);
	case N_IOR:
		return _ior(expr);
	case N_XOR:
		return _neq(expr); // alias
	case N_LT:
		return _lt(expr);
	case N_LE:
		return _le(expr);
	case N_GE:
		return _ge(expr);
	case N_GT:
		return _gt(expr);
	case N_ADD:
		return _add(expr);
	case N_SUB:
		return _sub(expr);
	case N_MUL:
		return _mul(expr);
	case N_DIV:
		return _div(expr);
	case N_POW:
		return _pow(expr);
	case N_MOD:
		return _mod(expr);
	case N_BOOLEAN:
		return _bool(expr);
	case N_INTEGER:
		return _int(expr);
	case N_FLOAT:
		return _float(expr);
	case N_STRING:
		return _string(expr);
	case N_SET:
		return _set(expr);
	case N_R:
		return _relation(expr);
	}
printf("EVALFAIL %d ", expr->class); pn(expr);
	assert(false && "should not be reached");
}
Beispiel #5
0
IDENT_MPTR_RAW * BetterString_$_splits_$_String(IDENT_MPTR_RAW *  b_, IDENT_MPTR_RAW *  s_, IDENT_MPTR_RAW * $_mptr_in)
{
    const_bstring b = b_->obj;
    String * s = s_->obj;
    bstring sBstring = bfromcstr(s->buffer);
    struct bstrList * result = bsplits(b,sBstring);

    _$_VARIABLE(_$_temp_vector);
    _$_VARIABLE(_$_temp_vector_item);
    _$_VARIABLE(_$_temp_betterstring);

    //printf("Parts %d ",result->qty);
    Vector_$_Vector_$_int(result->qty, _$_temp_vector, false, BetterString);
    /*
    Vector_$_putObjectAtIndex_$_Generic_$$_$_Generic_$$(_$v$_arr, _$v$_idx, _$v$_primIdx, _$v$_elem, _$v$_primElem,\
                                                    _$v$_mptr, _$v$_primRet, _$v$_typeRet)    */
    int i;

    for (i=0;i<result->qty;i++) {
        BetterString_$_BetterString_$_BetterString_$_(bstrcpy(result->entry[i]),_$_temp_betterstring);
        Vector_$_putObjectAtIndex_$_Generic_$$_$_Generic_$$(_$_temp_vector, i, true,
                                                            _$_temp_betterstring,
                                                            false, _$_temp_vector_item, false, _$_mptr);
    }
    _$_mptr_prepare(_$_temp_vector,$_mptr_in);
    bdestroy(sBstring);
    bstrListDestroy(result);
    return $_mptr_in;
}
Beispiel #6
0
/*!
 * \brief
 *    Calculate Fractional Julian day
 * \param   st    SPA time
 * \return  Fractional Julian day
 */
static double _julian_day (spa_time_t st)
{
   double day_dec, julday, a;

   day_dec = st.day + (st.hour - st.timezone + (st.min + (st.sec + st.delta_ut1)/60.0)/60.0)/24.0;

   if (st.mon < 3) {
      st.mon += 12;
      st.year--;
   }

   julday = _int(365.25*(st.year+4716.0)) + _int(30.6001*(st.mon+1)) + day_dec - 1524.5;

   if (julday > 2299160.0) {
      a = _int(st.year/100);
      julday += (2 - a + _int(a/4));
   }

   return julday;
}
Beispiel #7
0
void user() { 

    void *ptr;
    int res;


    ptr = virtual_memory;

    _int(SYSCALL_SWITCH_0);
    memset(ptr, 1, PAGE_SIZE * N/2);
    _int(SYSCALL_SWITCH_1);
    memset(ptr, 3, PAGE_SIZE * N/2);

    _int(SYSCALL_SWITCH_0);
    res = sum(ptr);
    printf("Resultat processus 0 : %d\n",res);
    _int(SYSCALL_SWITCH_1);
    res = sum(ptr);
    printf("Resultat processus 1 : %d\n",res);
}
Beispiel #8
0
const t_julianDay jd(t_aTime aTime)
{
    assert(aTime.month > 0);

    if(aTime.month < 3)
    {
        // "If the date is in January or February, it is concidered to
        // be 13th or 14th month of the preceding year."

        --aTime.year;
        aTime.month += 12;
    }

    // TODO: from "A Physically-Based Night Sky Model" - 2001 - Wann Jensen et al.
    // "Local time is GMT with a zone correction. Terrestrial Time (TT)
    // is essentially the time kept by atomic clocks. As it is not corrected
    // for the slowing of the Earth’s rotation, it gains on GMT by about 
    // a second per year. The current difference T is about 64 sec in 2000.
    // It should be added to s in all equations for precise computation..."

    unsigned int s = aTime.second;

    const t_longf h(_day(aTime.hour, aTime.minute, s));

    signed int b = 0;

    const int i = aTime.year * 10000 + aTime.month * 100 + aTime.day;
    if(i >= 15821015)
    {
        // gregorian calendar
        const signed int a = _int(aTime.year * 0.01);
        b = 2 - a + _int(a * 0.25);
    }
    else if(i > 15821004)
        return 0.0; // The gregorian calender follows with 15. on the 4. 
                    // julian oktober in 1582 - poor people who missed a birthday these days :P

    return _int(365.25 * (aTime.year + 4716)) 
        + _int(30.600001 * (aTime.month + 1)) + aTime.day + h + b - 1524.5;
}
Beispiel #9
0
	void Test()
	{
	
		DBGTRACE(_T("--------------------------------------------------"));

		Variant _int(99);
		DBGTRACE(_T("%s : %d"), _int.GetString().c_str(), _int.GetInt());
		
		Variant _float(1.5f);
		DBGTRACE(_T("%s : %f"), _float.GetString().c_str(), _float.GetFloat());

		Variant _bool(true);
		DBGTRACE(_T("%s : %d"), _bool.GetString().c_str(), _bool.GetBool());
	}
Beispiel #10
0
inline int8_8 smul8_8(int8_8 x,int8_8 y)
{
int sign = 1;
int xx = _int(x);
if (xx<0)
{
  xx = (-1)* xx;
  sign *= -1;
}
int yy = _int(y);
if (yy<0)
{
 yy = (-1)*yy;
 sign *= -1;
}
int __s = xx * yy;
__s>>=8;
int rez = (sign == -1? (1<<15) : ((1<<15) -1));
if (__s > 1<<15)
{
	__s = rez;
}else sign==-1?__s=__s*sign-1:0;
return _int8_8(__s);
}
Beispiel #11
0
Object *BinaryEvaluator::evaluate(Object *u, IEvaluator *ev)
{
    Pair *p = PairUtil::cast_pair(u);
    if (!p) return u;

    Object  *q  = ev->evaluate(PairUtil::at(p, 1), ev), *r = ev->evaluate(PairUtil::at(p, 2), ev);

    int_t   *qi = _to_int(q),   *ri = _to_int(r);
    float_t *qf = _to_float(q), *rf = _to_float(r);

    if      (qi && ri) return _int  (evaluate((int)  *qi, (int)  *ri)); // both ints..
    else if (qf && rf) return _float(evaluate((float)*qf, (float)*rf)); // both floats..
    else if (qi && rf) return _float(evaluate((float)*qi, (float)*rf)); // q, int; r, float
    else if (qf && ri) return _float(evaluate((float)*qf, (float)*ri)); // q, float; r, int

    return p;
}
Beispiel #12
0
const t_aTime makeTime(
    t_julianDay julianDate
,   const short GMTOffset)
{
    assert(julianDate >= 0.0);

    julianDate += 0.5;

    const int z = _int(julianDate);
    const t_longf f = _frac(julianDate);

    long int a(z); // julian
    if(z >= 2299161) // gregorian
    {
        const int g = _int((z - 1867216.25) / 36524.25);
        a = z + 1 + g - _int(g / 4);
    }

    const int b = _int(a + 1524);
    const int c = _int((b - 122.1) / 365.25);
    const int d = _int(365.25 * c);
    const int e = _int((b - d) / 30.600001);


    const short day    = static_cast<short>(b - d - _int(30.600001 * e));
    const short month  = static_cast<short>(e < 14 ? e - 1 : e - 13);
    const short year   = static_cast<short>(month > 2 ? c - 4716 : c - 4715);

    const t_longf h = f * 24.0;
    const t_longf m = _frac(h) * 60.0;
    const t_longf s = _frac(m) * 60.0001;

    const short hour   = _short(h);
    const short minute = _short(m);
    const short second = _short(s);

    return t_aTime(year, month, day, hour, minute, second, GMTOffset);
}
void RomWriter::randomPut(unsigned int ptr, const void* wptr, unsigned int len) {
  if(!_int(ptr, wptr, len))
    raise("Нет места в прошивке");
}
bool RomWriter::put_ne(const void* wptr, unsigned int len) {
  return _int(ptr, wptr, len); 
}
void RomWriter::put(const void* wptr, uint len) {
  if(!_int(ptr, wptr, len)) 
    raise("Нет места в прошивке");
}
Beispiel #16
0
inline int8_8 mul8_8(int8_8 x,int8_8 y)
{
int __s = _int(x) * _int(y);
__s>>=8;
return _int8_8(__s);
}