Changeset 168c007 for src/tests


Ignore:
Timestamp:
Mar 21, 2017, 12:50:27 PM (9 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
da6d4566, f5392c1
Parents:
94a8123 (diff), e04b636 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:/u/cforall/software/cfa/cfa-cc

Location:
src/tests
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/tests/coroutine.c

    r94a8123 r168c007  
    22#include <coroutine>
    33
    4 struct Fibonacci {
     4coroutine Fibonacci {
    55      int fn; // used for communication
    6       coroutine_desc c;
    76};
    87
     
    1110}
    1211
    13 coroutine_desc* get_coroutine(Fibonacci* this) {
    14       return &this->c;
    15 }
    16 
    1712void main(Fibonacci* this) {
    18 #ifdef MORE_DEBUG
    19       sout | "Starting main of coroutine " | this | endl;
    20       sout | "Started from " | this->c.last | endl;
    21 #endif
    2213      int fn1, fn2;             // retained between resumes
    2314      this->fn = 0;
     
    4536int main() {
    4637      Fibonacci f1, f2;
    47 #ifdef MORE_DEBUG     
    48       Fibonacci *pf1 = &f1, *pf2 = &f2;
    49       coroutine_desc *cf1 = &f1.c, *cf2 = &f2.c;
    50       covptr_t  *vf1 = vtable(pf1), *vf2 = vtable(pf2);
    51       coroutine_desc *cv1 = get_coroutine(vf1), *cv2 = get_coroutine(vf2);
    52       Fibonacci *ov1 = (Fibonacci *)get_object(vf1), *ov2 = (Fibonacci *)get_object(vf2);
    53 
    54       sout | "User coroutines : " | pf1 | ' ' | pf2 | endl;
    55       sout | "Coroutine data  : " | cf1 | ' ' | cf2 | endl;
    56       sout | "Vptr address    : " | vf1 | ' ' | vf2 | endl;
    57       sout | "Vptr obj data   : " | ov1 | ' ' | ov2 | endl;
    58       sout | "Vptr cor data   : " | cv1 | ' ' | cv2 | endl;
    59 #endif
    6038      for ( int i = 1; i <= 10; i += 1 ) {
    6139            sout | next(&f1) | ' ' | next(&f2) | endl;
  • src/tests/monitor.c

    r94a8123 r168c007  
    1313}
    1414
     15monitor_desc * get_monitor( global_t * this ) {
     16        return &this->m;
     17}
     18
    1519static global_t global;
    1620
    17 void increment( /*mutex*/ global_t * this ) {
    18         monitor_desc * mon = &this->m;
    19         monitor_guard_t g1 = { &mon };
    20         {
    21                 monitor_guard_t g2 = { &mon };
    22                 {
    23                         monitor_guard_t g3 = { &mon };
    24                         this->value += 1;
    25                 }
    26         }
     21void increment3( global_t * mutex this ) {
     22        this->value += 1;
    2723}
    2824
    29 struct MyThread { thread_desc t; };
     25void increment2( global_t * mutex this ) {
     26        increment3( this );
     27}
     28
     29void increment( global_t * mutex this ) {
     30        increment2( this );
     31}
     32
     33struct MyThread { thread_desc __thrd; };
    3034
    3135DECL_THREAD(MyThread);
  • src/tests/multi-monitor.c

    r94a8123 r168c007  
    66static int global12, global23, global13;
    77
    8 static monitor_desc m1, m2, m3;
     8struct monitor_t {
     9        monitor_desc m;
     10};
    911
    10 void increment( /*mutex*/ monitor_desc * p1, /*mutex*/ monitor_desc * p2, int * value ) {
    11         monitor_desc * mons[] = { p1, p2 };
    12         monitor_guard_t g = { mons, 2 };
     12monitor_desc * get_monitor( monitor_t * this ) {
     13        return &this->m;
     14}
     15
     16static monitor_t m1, m2, m3;
     17
     18void increment( monitor_t * mutex p1, monitor_t * mutex p2, int * value ) {
    1319        *value += 1;
    1420}
    1521
    1622struct MyThread {
    17         thread_desc t;
     23        thread_desc __thrd;
    1824        int target;
    1925};
  • src/tests/thread.c

    r94a8123 r168c007  
    44#include <thread>
    55
    6 struct First { thread_desc t; signal_once* lock; };
    7 struct Second { thread_desc t; signal_once* lock; };
     6struct First { thread_desc __thrd; signal_once* lock; };
     7struct Second { thread_desc __thrd; signal_once* lock; };
    88
    99DECL_THREAD(First);
Note: See TracChangeset for help on using the changeset viewer.