Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/prelude/builtins.c

    rc960331 r0a25c34  
    99// Author           : Peter A. Buhr
    1010// Created On       : Fri Jul 21 16:21:03 2017
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Tue Oct 27 14:42:00 2020
    13 // Update Count     : 111
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Thu Nov 21 16:31:39 2019
     13// Update Count     : 101
    1414//
    15 
    16 #define __cforall_builtins__
    1715
    1816// type that wraps a pointer and a destructor-like function - used in generating implicit destructor calls for struct members in user-defined functions
     
    5149void abort( const char fmt[], ... ) __attribute__ (( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ ));
    5250
    53 forall(dtype T)
    54 static inline T & identity(T & i) {
    55         return i;
    56 }
    57 
    58 // generator support
    59 struct $generator {
    60         inline int;
    61 };
    62 
    63 static inline void  ?{}($generator & this) { ((int&)this) = 0; }
    64 static inline void ^?{}($generator &) {}
    65 
    66 trait is_generator(dtype T) {
    67       void main(T & this);
    68       $generator * get_generator(T & this);
    69 };
    70 
    71 forall(dtype T | is_generator(T))
    72 static inline T & resume(T & gen) {
    73         main(gen);
    74         return gen;
    75 }
    76 
    7751// implicit increment, decrement if += defined, and implicit not if != defined
    7852
     
    9670// universal typed pointer constant
    9771static inline forall( dtype DT ) DT * intptr( uintptr_t addr ) { return (DT *)addr; }
    98 static 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)
    102 static 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__
    10672
    10773// exponentiation operator implementation
Note: See TracChangeset for help on using the changeset viewer.