Ignore:
Timestamp:
Jan 7, 2021, 2:55:57 PM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
58fe85a
Parents:
bdfc032 (diff), 44e37ef (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' into dkobets-vector

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/prelude/builtins.c

    rbdfc032 reef8dfb  
    99// Author           : Peter A. Buhr
    1010// Created On       : Fri Jul 21 16:21:03 2017
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Nov 21 16:31:39 2019
    13 // Update Count     : 101
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Tue Oct 27 14:42:00 2020
     13// Update Count     : 111
    1414//
     15
     16#define __cforall_builtins__
    1517
    1618// type that wraps a pointer and a destructor-like function - used in generating implicit destructor calls for struct members in user-defined functions
     
    4951void abort( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ ));
    5052
     53forall(dtype T)
     54static inline T & identity(T & i) {
     55        return i;
     56}
     57
     58// generator support
     59struct $generator {
     60        inline int;
     61};
     62
     63static inline void  ?{}($generator & this) { ((int&)this) = 0; }
     64static inline void ^?{}($generator &) {}
     65
     66trait is_generator(dtype T) {
     67      void main(T & this);
     68      $generator * get_generator(T & this);
     69};
     70
     71forall(dtype T | is_generator(T))
     72static inline T & resume(T & gen) {
     73        main(gen);
     74        return gen;
     75}
     76
    5177// implicit increment, decrement if += defined, and implicit not if != defined
    5278
     
    7096// universal typed pointer constant
    7197static inline forall( dtype DT ) DT * intptr( uintptr_t addr ) { return (DT *)addr; }
     98static inline forall( ftype FT ) FT * intptr( uintptr_t addr ) { return (FT *)addr; }
     99
     100#if defined(__SIZEOF_INT128__)
     101// constructor for 128-bit numbers (all constants are unsigned as +/- are operators)
     102static inline void ?{}( unsigned int128 & this, unsigned long int h, unsigned long int l ) {
     103        this = (unsigned int128)h << 64 | (unsigned int128)l;
     104} // ?{}
     105#endif // __SIZEOF_INT128__
    72106
    73107// exponentiation operator implementation
Note: See TracChangeset for help on using the changeset viewer.