Add some debug support code
[c11tester.git] / action.cc
1 #include <stdio.h>
2 #define __STDC_FORMAT_MACROS
3 #include <inttypes.h>
4 #include <stdlib.h>
5
6 #include "model.h"
7 #include "action.h"
8 #include "clockvector.h"
9 #include "common.h"
10 #include "threads-model.h"
11 #include "wildcard.h"
12
13 #define ACTION_INITIAL_CLOCK 0
14
15 /** @brief A special value to represent a successful trylock */
16 #define VALUE_TRYSUCCESS 1
17
18 /** @brief A special value to represent a failed trylock */
19 #define VALUE_TRYFAILED 0
20
21 /**
22  * @brief Construct a new ModelAction
23  *
24  * @param type The type of action
25  * @param order The memory order of this action. A "don't care" for non-ATOMIC
26  * actions (e.g., THREAD_* or MODEL_* actions).
27  * @param loc The location that this action acts upon
28  * @param value (optional) A value associated with the action (e.g., the value
29  * read or written). Defaults to a given macro constant, for debugging purposes.
30  * @param thread (optional) The Thread in which this action occurred. If NULL
31  * (default), then a Thread is assigned according to the scheduler.
32  */
33 ModelAction::ModelAction(action_type_t type, memory_order order, void *loc,
34                                                                                                  uint64_t value, Thread *thread) :
35         location(loc),
36         position(NULL),
37         reads_from(NULL),
38         last_fence_release(NULL),
39         cv(NULL),
40         rf_cv(NULL),
41         trace_ref(NULL),
42         thrdmap_ref(NULL),
43         action_ref(NULL),
44         func_act_ref(NULL),
45         value(value),
46         type(type),
47         original_type(ATOMIC_NOP),
48         order(order),
49         original_order(order),
50         seq_number(ACTION_INITIAL_CLOCK)
51 {
52         /* References to NULL atomic variables can end up here */
53         ASSERT(loc || type == ATOMIC_FENCE || type == ATOMIC_NOP);
54
55         Thread *t = thread ? thread : thread_current();
56         this->tid = t!= NULL ? t->get_id() : -1;
57 }
58
59
60 /**
61  * @brief Construct a new ModelAction for sleep actions
62  *
63  * @param type The type of action: THREAD_SLEEP
64  * @param order The memory order of this action. A "don't care" for non-ATOMIC
65  * actions (e.g., THREAD_* or MODEL_* actions).
66  * @param loc The location that this action acts upon
67  * @param value The time duration a thread is scheduled to sleep.
68  * @param _time The this sleep action is constructed
69  */
70 ModelAction::ModelAction(action_type_t type, memory_order order, uint64_t value, uint64_t _time) :
71         location(NULL),
72         position(NULL),
73         time(_time),
74         last_fence_release(NULL),
75         cv(NULL),
76         rf_cv(NULL),
77         trace_ref(NULL),
78         thrdmap_ref(NULL),
79         action_ref(NULL),
80         value(value),
81         type(type),
82         original_type(ATOMIC_NOP),
83         order(order),
84         original_order(order),
85         seq_number(ACTION_INITIAL_CLOCK)
86 {
87         Thread *t = thread_current();
88         this->tid = t!= NULL ? t->get_id() : -1;
89 }
90
91 /**
92  * @brief Construct a new ModelAction
93  *
94  * @param type The type of action
95  * @param order The memory order of this action. A "don't care" for non-ATOMIC
96  * actions (e.g., THREAD_* or MODEL_* actions).
97  * @param loc The location that this action acts upon
98  * @param value (optional) A value associated with the action (e.g., the value
99  * read or written). Defaults to a given macro constant, for debugging purposes.
100  * @param size (optional) The Thread in which this action occurred. If NULL
101  * (default), then a Thread is assigned according to the scheduler.
102  */
103 ModelAction::ModelAction(action_type_t type, memory_order order, void *loc,
104                                                                                                  uint64_t value, int size) :
105         location(loc),
106         position(NULL),
107         reads_from(NULL),
108         last_fence_release(NULL),
109         cv(NULL),
110         rf_cv(NULL),
111         trace_ref(NULL),
112         thrdmap_ref(NULL),
113         action_ref(NULL),
114         value(value),
115         type(type),
116         original_type(ATOMIC_NOP),
117         order(order),
118         original_order(order),
119         seq_number(ACTION_INITIAL_CLOCK)
120 {
121         /* References to NULL atomic variables can end up here */
122         ASSERT(loc);
123         this->size = size;
124         Thread *t = thread_current();
125         this->tid = t->get_id();
126 }
127
128
129 /**
130  * @brief Construct a new ModelAction with source line number (requires llvm support)
131  *
132  * @param type The type of action
133  * @param order The memory order of this action. A "don't care" for non-ATOMIC
134  * actions (e.g., THREAD_* or MODEL_* actions).
135  * @param loc The location that this action acts upon
136  * @param value (optional) A value associated with the action (e.g., the value
137  * read or written). Defaults to a given macro constant, for debugging purposes.
138  * @param size (optional) The Thread in which this action occurred. If NULL
139  * (default), then a Thread is assigned according to the scheduler.
140  */
141 ModelAction::ModelAction(action_type_t type, const char * position, memory_order order, void *loc,
142                                                                                                  uint64_t value, int size) :
143         location(loc),
144         position(position),
145         reads_from(NULL),
146         last_fence_release(NULL),
147         cv(NULL),
148         rf_cv(NULL),
149         trace_ref(NULL),
150         thrdmap_ref(NULL),
151         action_ref(NULL),
152         value(value),
153         type(type),
154         original_type(ATOMIC_NOP),
155         order(order),
156         original_order(order),
157         seq_number(ACTION_INITIAL_CLOCK)
158 {
159         /* References to NULL atomic variables can end up here */
160         ASSERT(loc);
161         this->size = size;
162         Thread *t = thread_current();
163         this->tid = t->get_id();
164 }
165
166
167 /**
168  * @brief Construct a new ModelAction with source line number (requires llvm support)
169  *
170  * @param type The type of action
171  * @param position The source line number of this atomic operation
172  * @param order The memory order of this action. A "don't care" for non-ATOMIC
173  * actions (e.g., THREAD_* or MODEL_* actions).
174  * @param loc The location that this action acts upon
175  * @param value (optional) A value associated with the action (e.g., the value
176  * read or written). Defaults to a given macro constant, for debugging purposes.
177  * @param thread (optional) The Thread in which this action occurred. If NULL
178  * (default), then a Thread is assigned according to the scheduler.
179  */
180 ModelAction::ModelAction(action_type_t type, const char * position, memory_order order,
181                                                                                                  void *loc, uint64_t value, Thread *thread) :
182         location(loc),
183         position(position),
184         reads_from(NULL),
185         last_fence_release(NULL),
186         cv(NULL),
187         rf_cv(NULL),
188         trace_ref(NULL),
189         thrdmap_ref(NULL),
190         action_ref(NULL),
191         value(value),
192         type(type),
193         original_type(ATOMIC_NOP),
194         order(order),
195         original_order(order),
196         seq_number(ACTION_INITIAL_CLOCK)
197 {
198         /* References to NULL atomic variables can end up here */
199         ASSERT(loc || type == ATOMIC_FENCE);
200
201         Thread *t = thread ? thread : thread_current();
202         this->tid = t->get_id();
203 }
204
205
206 /** @brief ModelAction destructor */
207 ModelAction::~ModelAction()
208 {
209         /**
210          * We can't free the clock vector:
211          * Clock vectors are snapshotting state. When we delete model actions,
212          * they are at the end of the node list and have invalid old clock
213          * vectors which have already been rolled back to an unallocated state.
214          */
215
216         /*
217            if (cv)
218                 delete cv; */
219 }
220
221 int ModelAction::getSize() const {
222         return size;
223 }
224
225 void ModelAction::copy_from_new(ModelAction *newaction)
226 {
227         seq_number = newaction->seq_number;
228 }
229
230 void ModelAction::set_seq_number(modelclock_t num)
231 {
232         ASSERT(seq_number == ACTION_INITIAL_CLOCK);
233         seq_number = num;
234 }
235
236 void ModelAction::reset_seq_number()
237 {
238         seq_number = 0;
239 }
240
241 bool ModelAction::is_thread_start() const
242 {
243         return type == THREAD_START;
244 }
245
246 bool ModelAction::is_thread_join() const
247 {
248         return type == THREAD_JOIN || type == PTHREAD_JOIN;
249 }
250
251 bool ModelAction::is_mutex_op() const
252 {
253         return type == ATOMIC_LOCK || type == ATOMIC_TRYLOCK || type == ATOMIC_UNLOCK || type == ATOMIC_WAIT || type == ATOMIC_TIMEDWAIT || type == ATOMIC_NOTIFY_ONE || type == ATOMIC_NOTIFY_ALL;
254 }
255
256 bool ModelAction::is_lock() const
257 {
258         return type == ATOMIC_LOCK;
259 }
260
261 bool ModelAction::is_sleep() const
262 {
263         return type == THREAD_SLEEP;
264 }
265
266 bool ModelAction::is_wait() const {
267         return type == ATOMIC_WAIT || type == ATOMIC_TIMEDWAIT;
268 }
269
270 bool ModelAction::is_notify() const {
271         return type == ATOMIC_NOTIFY_ONE || type == ATOMIC_NOTIFY_ALL;
272 }
273
274 bool ModelAction::is_notify_one() const {
275         return type == ATOMIC_NOTIFY_ONE;
276 }
277
278 bool ModelAction::is_unlock() const
279 {
280         return type == ATOMIC_UNLOCK;
281 }
282
283 bool ModelAction::is_trylock() const
284 {
285         return type == ATOMIC_TRYLOCK;
286 }
287
288 bool ModelAction::is_success_lock() const
289 {
290         return type == ATOMIC_LOCK || (type == ATOMIC_TRYLOCK && value == VALUE_TRYSUCCESS);
291 }
292
293 bool ModelAction::is_failed_trylock() const
294 {
295         return (type == ATOMIC_TRYLOCK && value == VALUE_TRYFAILED);
296 }
297
298 /** @return True if this operation is performed on a C/C++ atomic variable */
299 bool ModelAction::is_atomic_var() const
300 {
301         return is_read() || could_be_write();
302 }
303
304 bool ModelAction::is_read() const
305 {
306         return type == ATOMIC_READ || type == ATOMIC_RMWR || type == ATOMIC_RMWRCAS || type == ATOMIC_RMW;
307 }
308
309 bool ModelAction::is_write() const
310 {
311         return type == ATOMIC_WRITE || type == ATOMIC_RMW || type == ATOMIC_INIT || type == NONATOMIC_WRITE;
312 }
313
314 bool ModelAction::is_create() const
315 {
316         return type == THREAD_CREATE || type == PTHREAD_CREATE;
317 }
318
319 bool ModelAction::is_free() const
320 {
321         return type == READY_FREE;
322 }
323
324 bool ModelAction::could_be_write() const
325 {
326         return is_write() || is_rmwr();
327 }
328
329 bool ModelAction::is_yield() const
330 {
331         return type == THREAD_YIELD;
332 }
333
334 bool ModelAction::is_rmwr() const
335 {
336         return type == ATOMIC_RMWR || type == ATOMIC_RMWRCAS;
337 }
338
339 bool ModelAction::is_rmwrcas() const
340 {
341         return type == ATOMIC_RMWRCAS;
342 }
343
344 bool ModelAction::is_rmw() const
345 {
346         return type == ATOMIC_RMW;
347 }
348
349 bool ModelAction::is_rmwc() const
350 {
351         return type == ATOMIC_RMWC;
352 }
353
354 bool ModelAction::is_fence() const
355 {
356         return type == ATOMIC_FENCE;
357 }
358
359 bool ModelAction::is_initialization() const
360 {
361         return type == ATOMIC_INIT;
362 }
363
364 bool ModelAction::is_annotation() const
365 {
366         return type == ATOMIC_ANNOTATION;
367 }
368
369 bool ModelAction::is_relaxed() const
370 {
371         return order == std::memory_order_relaxed;
372 }
373
374 bool ModelAction::is_acquire() const
375 {
376         switch (order) {
377         case std::memory_order_acquire:
378         case std::memory_order_acq_rel:
379         case std::memory_order_seq_cst:
380                 return true;
381         default:
382                 return false;
383         }
384 }
385
386 bool ModelAction::is_release() const
387 {
388         switch (order) {
389         case std::memory_order_release:
390         case std::memory_order_acq_rel:
391         case std::memory_order_seq_cst:
392                 return true;
393         default:
394                 return false;
395         }
396 }
397
398 bool ModelAction::is_seqcst() const
399 {
400         return order == std::memory_order_seq_cst;
401 }
402
403 bool ModelAction::same_var(const ModelAction *act) const
404 {
405         if (act->is_wait() || is_wait()) {
406                 if (act->is_wait() && is_wait()) {
407                         if (((void *)value) == ((void *)act->value))
408                                 return true;
409                 } else if (is_wait()) {
410                         if (((void *)value) == act->location)
411                                 return true;
412                 } else if (act->is_wait()) {
413                         if (location == ((void *)act->value))
414                                 return true;
415                 }
416         }
417
418         return location == act->location;
419 }
420
421 bool ModelAction::same_thread(const ModelAction *act) const
422 {
423         return tid == act->tid;
424 }
425
426 void ModelAction::copy_typeandorder(ModelAction * act)
427 {
428         this->type = act->type;
429         this->order = act->order;
430 }
431
432 /**
433  * Get the Thread which is the operand of this action. This is only valid for
434  * THREAD_* operations (currently only for THREAD_CREATE and THREAD_JOIN). Note
435  * that this provides a central place for determining the conventions of Thread
436  * storage in ModelAction, where we generally aren't very type-safe (e.g., we
437  * store object references in a (void *) address.
438  *
439  * For THREAD_CREATE, this yields the Thread which is created.
440  * For THREAD_JOIN, this yields the Thread we are joining with.
441  *
442  * @return The Thread which this action acts on, if exists; otherwise NULL
443  */
444 Thread * ModelAction::get_thread_operand() const
445 {
446         if (type == THREAD_CREATE) {
447                 /* thread_operand is set in execution.cc */
448                 return thread_operand;
449         } else if (type == PTHREAD_CREATE) {
450                 return thread_operand;
451         } else if (type == THREAD_JOIN) {
452                 /* THREAD_JOIN uses (Thread *) for location */
453                 return (Thread *)get_location();
454         } else if (type == PTHREAD_JOIN) {
455                 // return NULL;
456                 // thread_operand is stored in execution::pthread_map;
457                 return (Thread *)get_location();
458         } else
459                 return NULL;
460 }
461
462 /**
463  * @brief Convert the read portion of an RMW
464  *
465  * Changes an existing read part of an RMW action into either:
466  *  -# a full RMW action in case of the completed write or
467  *  -# a READ action in case a failed action.
468  *
469  * @todo  If the memory_order changes, we may potentially need to update our
470  * clock vector.
471  *
472  * @param act The second half of the RMW (either RMWC or RMW)
473  */
474 void ModelAction::process_rmw(ModelAction *act)
475 {
476         this->order = act->order;
477         if (act->is_rmwc())
478                 this->type = ATOMIC_READ;
479         else if (act->is_rmw()) {
480                 this->type = ATOMIC_RMW;
481                 this->value = act->value;
482         }
483 }
484
485 /**
486  * @brief Check if this action should be backtracked with another, due to
487  * potential synchronization
488  *
489  * The is_synchronizing method should only explore interleavings if:
490  *  -# the operations are seq_cst and don't commute or
491  *  -# the reordering may establish or break a synchronization relation.
492  *
493  * Other memory operations will be dealt with by using the reads_from relation.
494  *
495  * @param act The action to consider exploring a reordering
496  * @return True, if we have to explore a reordering; otherwise false
497  */
498 bool ModelAction::could_synchronize_with(const ModelAction *act) const
499 {
500         // Same thread can't be reordered
501         if (same_thread(act))
502                 return false;
503
504         // Different locations commute
505         if (!same_var(act) && !is_fence() && !act->is_fence())
506                 return false;
507
508         // Explore interleavings of seqcst writes/fences to guarantee total
509         // order of seq_cst operations that don't commute
510         if ((could_be_write() || act->could_be_write() || is_fence() || act->is_fence()) && is_seqcst() && act->is_seqcst())
511                 return true;
512
513         // Explore synchronizing read/write pairs
514         if (is_acquire() && act->is_release() && is_read() && act->could_be_write())
515                 return true;
516
517         // lock just released...we can grab lock
518         if ((is_lock() || is_trylock()) && (act->is_unlock() || act->is_wait()))
519                 return true;
520
521         // lock just acquired...we can fail to grab lock
522         if (is_trylock() && act->is_success_lock())
523                 return true;
524
525         // other thread stalling on lock...we can release lock
526         if (is_unlock() && (act->is_trylock() || act->is_lock()))
527                 return true;
528
529         if (is_trylock() && (act->is_unlock() || act->is_wait()))
530                 return true;
531
532         if (is_notify() && act->is_wait())
533                 return true;
534
535         if (is_wait() && act->is_notify())
536                 return true;
537
538         // Otherwise handle by reads_from relation
539         return false;
540 }
541
542 bool ModelAction::is_conflicting_lock(const ModelAction *act) const
543 {
544         // Must be different threads to reorder
545         if (same_thread(act))
546                 return false;
547
548         // Try to reorder a lock past a successful lock
549         if (act->is_success_lock())
550                 return true;
551
552         // Try to push a successful trylock past an unlock
553         if (act->is_unlock() && is_trylock() && value == VALUE_TRYSUCCESS)
554                 return true;
555
556         // Try to push a successful trylock past a wait
557         if (act->is_wait() && is_trylock() && value == VALUE_TRYSUCCESS)
558                 return true;
559
560         return false;
561 }
562
563 /**
564  * Create a new clock vector for this action. Note that this function allows a
565  * user to clobber (and leak) a ModelAction's existing clock vector. A user
566  * should ensure that the vector has already either been rolled back
567  * (effectively "freed") or freed.
568  *
569  * @param parent A ModelAction from which to inherit a ClockVector
570  */
571 void ModelAction::create_cv(const ModelAction *parent)
572 {
573         if (parent)
574                 cv = new ClockVector(parent->cv, this);
575         else
576                 cv = new ClockVector(NULL, this);
577 }
578
579 void ModelAction::set_try_lock(bool obtainedlock)
580 {
581         value = obtainedlock ? VALUE_TRYSUCCESS : VALUE_TRYFAILED;
582 }
583
584 /**
585  * @brief Get the value read by this load
586  *
587  * We differentiate this function from ModelAction::get_write_value and
588  * ModelAction::get_value for the purpose of RMW's, which may have both a
589  * 'read' and a 'write' value.
590  *
591  * Note: 'this' must be a load.
592  *
593  * @return The value read by this load
594  */
595 uint64_t ModelAction::get_reads_from_value() const
596 {
597         ASSERT(is_read());
598         if (reads_from)
599                 return reads_from->get_write_value();
600
601         return VALUE_NONE;      // Only for new actions with no reads-from
602 }
603
604 /**
605  * @brief Get the value written by this store
606  *
607  * We differentiate this function from ModelAction::get_reads_from_value and
608  * ModelAction::get_value for the purpose of RMW's, which may have both a
609  * 'read' and a 'write' value.
610  *
611  * Note: 'this' must be a store.
612  *
613  * @return The value written by this store
614  */
615 uint64_t ModelAction::get_write_value() const
616 {
617         ASSERT(is_write());
618         return value;
619 }
620
621 /**
622  * @brief Get the value returned by this action
623  *
624  * For atomic reads (including RMW), an operation returns the value it read.
625  * For atomic writes, an operation returns the value it wrote. For other
626  * operations, the return value varies (sometimes is a "don't care"), but the
627  * value is simply stored in the "value" field.
628  *
629  * @return This action's return value
630  */
631 uint64_t ModelAction::get_return_value() const
632 {
633         if (is_read())
634                 return get_reads_from_value();
635         else if (is_write())
636                 return get_write_value();
637         else
638                 return value;
639 }
640
641 /**
642  * Update the model action's read_from action
643  * @param act The action to read from; should be a write
644  */
645 void ModelAction::set_read_from(ModelAction *act)
646 {
647         ASSERT(act);
648
649         reads_from = act;
650 }
651
652 /**
653  * Synchronize the current thread with the thread corresponding to the
654  * ModelAction parameter.
655  * @param act The ModelAction to synchronize with
656  * @return True if this is a valid synchronization; false otherwise
657  */
658 bool ModelAction::synchronize_with(const ModelAction *act)
659 {
660         if (*this < *act)
661                 return false;
662         cv->merge(act->cv);
663         return true;
664 }
665
666 bool ModelAction::has_synchronized_with(const ModelAction *act) const
667 {
668         return cv->synchronized_since(act);
669 }
670
671 /**
672  * Check whether 'this' happens before act, according to the memory-model's
673  * happens before relation. This is checked via the ClockVector constructs.
674  * @return true if this action's thread has synchronized with act's thread
675  * since the execution of act, false otherwise.
676  */
677 bool ModelAction::happens_before(const ModelAction *act) const
678 {
679         return act->cv->synchronized_since(this);
680 }
681
682 const char * ModelAction::get_type_str() const
683 {
684         switch (this->type) {
685         case THREAD_CREATE: return "thread create";
686         case THREAD_START: return "thread start";
687         case THREAD_YIELD: return "thread yield";
688         case THREAD_JOIN: return "thread join";
689         case THREAD_FINISH: return "thread finish";
690         case THREAD_SLEEP: return "thread sleep";
691         case THREADONLY_FINISH: return "pthread_exit finish";
692
693         case PTHREAD_CREATE: return "pthread create";
694         case PTHREAD_JOIN: return "pthread join";
695
696         case NONATOMIC_WRITE: return "nonatomic write";
697         case ATOMIC_READ: return "atomic read";
698         case ATOMIC_WRITE: return "atomic write";
699         case ATOMIC_RMW: return "atomic rmw";
700         case ATOMIC_FENCE: return "fence";
701         case ATOMIC_RMWR: return "atomic rmwr";
702         case ATOMIC_RMWRCAS: return "atomic rmwrcas";
703         case ATOMIC_RMWC: return "atomic rmwc";
704         case ATOMIC_INIT: return "init atomic";
705         case ATOMIC_LOCK: return "lock";
706         case ATOMIC_UNLOCK: return "unlock";
707         case ATOMIC_TRYLOCK: return "trylock";
708         case ATOMIC_WAIT: return "wait";
709         case ATOMIC_TIMEDWAIT: return "timed wait";
710         case ATOMIC_NOTIFY_ONE: return "notify one";
711         case ATOMIC_NOTIFY_ALL: return "notify all";
712         case ATOMIC_ANNOTATION: return "annotation";
713         default: return "unknown type";
714         };
715 }
716
717 const char * ModelAction::get_mo_str() const
718 {
719         switch (this->order) {
720         case std::memory_order_relaxed: return "relaxed";
721         case std::memory_order_acquire: return "acquire";
722         case std::memory_order_release: return "release";
723         case std::memory_order_acq_rel: return "acq_rel";
724         case std::memory_order_seq_cst: return "seq_cst";
725         default: return "unknown";
726         }
727 }
728
729 /** @brief Print nicely-formatted info about this ModelAction */
730 void ModelAction::print() const
731 {
732         const char *type_str = get_type_str(), *mo_str = get_mo_str();
733
734         model_print("%-4d %-2d   %-14s  %7s  %14p   %-#18" PRIx64,
735                                                         seq_number, id_to_int(tid), type_str, mo_str, location, get_return_value());
736         if (is_read()) {
737                 if (reads_from)
738                         model_print("  %-3d", reads_from->get_seq_number());
739                 else
740                         model_print("  ?  ");
741         }
742         if (cv) {
743                 if (is_read())
744                         model_print(" ");
745                 else
746                         model_print("      ");
747                 cv->print();
748         } else
749                 model_print("\n");
750 }
751
752 /** @brief Get a (likely) unique hash for this ModelAction */
753 unsigned int ModelAction::hash() const
754 {
755         unsigned int hash = (unsigned int)this->type;
756         hash ^= ((unsigned int)this->order) << 3;
757         hash ^= seq_number << 5;
758         hash ^= id_to_int(tid) << 6;
759
760         if (is_read()) {
761                 if (reads_from)
762                         hash ^= reads_from->get_seq_number();
763                 hash ^= get_reads_from_value();
764         }
765         return hash;
766 }
767
768 /**
769  * Only valid for LOCK, TRY_LOCK, UNLOCK, and WAIT operations.
770  * @return The mutex operated on by this action, if any; otherwise NULL
771  */
772 cdsc::mutex * ModelAction::get_mutex() const
773 {
774         if (is_trylock() || is_lock() || is_unlock())
775                 return (cdsc::mutex *)get_location();
776         else if (is_wait())
777                 return (cdsc::mutex *)get_value();
778         else
779                 return NULL;
780 }
781
782 /** @brief Swap type with original type */
783 void ModelAction::use_original_type()
784 {
785         action_type_t tmp = type;
786         type = original_type;
787         original_type = tmp;
788 }