Changeset b312247 in mainline


Ignore:
Timestamp:
2005-05-19T13:16:34Z (20 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7135cf2
Parents:
f3ebb64
Message:

Add BSD license and copyright line.
Coding style and small improvements.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/fp/fp0/test.c

    rf3ebb64 rb312247  
    1 
    2 
     1/*
     2 * Copyright (C) 2005 Jakub Vana
     3 * All rights reserved.
     4 *
     5 * Redistribution and use in source and binary forms, with or without
     6 * modification, are permitted provided that the following conditions
     7 * are met:
     8 *
     9 * - Redistributions of source code must retain the above copyright
     10 *   notice, this list of conditions and the following disclaimer.
     11 * - Redistributions in binary form must reproduce the above copyright
     12 *   notice, this list of conditions and the following disclaimer in the
     13 *   documentation and/or other materials provided with the distribution.
     14 * - The name of the author may not be used to endorse or promote products
     15 *   derived from this software without specific prior written permission.
     16 *
     17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27 */
    328
    429#include <arch/interrupt.h>
     
    1237#include <mm/tlb.h>
    1338
    14 
    15 
    1639#include <test.h>
    1740#include <arch.h>
     
    1942#include <proc/thread.h>
    2043
    21 
    22 
    23 
    24 thread_t *thread_create(void (* func)(void *), void *arg, task_t *task, int flags);
    25 
    26 
    27 static void thread(void *data)
     44static void e(void *data)
    2845{
    29   while(1)
    30   {
    31     double e,d,le,f;
    32     le=-1;
    33     e=0;
    34     f=1;
    35     for(d=1;e!=le;d*=f,f+=1) {le=e;e=e+1/d;}
     46        while(1) {
     47                double e,d,le,f;
     48                le=-1;
     49                e=0;
     50                f=1;
     51                for(d=1;e!=le;d*=f,f+=1) {
     52                        le=e;
     53                        e=e+1/d;
     54                }
    3655   
    37     if((int)(100000000*e)==271828182) printf("THREAD:%s e OK\n",(char*)data);
    38     else panic("THREAD:%s e Failed\n",(char*)data);
    39 
    40    
    41 //    printf("100000000*e:%d\n");
    42   }
    43   //printf("TEST:%s\n",(char*)data); 
     56                if((int)(100000000*e)==271828182) printf("tid%d: e OK\n", THREAD->tid);
     57                else panic("tid%d: e FAILED (100000000*e=%d)\n", THREAD->tid, (int) 100000000*e);
     58        }
    4459}
    4560
     
    4863void test(void)
    4964{
    50   thread_t *t;
    51  
    52   t=thread_create(thread, (void*)"0", TASK,0);
    53   thread_ready(t);
     65        thread_t *t;
     66        int i;
    5467
    55 
    56 
    57   t=thread_create(thread, (void*)"1", TASK,0);
    58   thread_ready(t);
    59 
    60 
    61 
    62   t=thread_create(thread, (void*)"2", TASK,0);
    63   thread_ready(t);
    64 
    65   t=thread_create(thread, (void*)"3", TASK,0);
    66   thread_ready(t);
    67   while(1);
     68        for (i=0; i<4; i++) { 
     69                t = thread_create(e, NULL, TASK, 0);
     70                thread_ready(t);
     71        }
    6872
    6973}
    70 
Note: See TracChangeset for help on using the changeset viewer.