Changes in / [2fa5bd2:aca6a54c]


Ignore:
Files:
2 deleted
73 edited

Legend:

Unmodified
Added
Removed
  • Jenkinsfile

    r2fa5bd2 raca6a54c  
    102102
    103103                echo GitLogMessage()
    104 
    105                 // This is a complete hack but it solves problems with automake thinking it needs to regenerate makefiles
    106                 // We fudged automake/missing to handle that but automake stills bakes prints inside the makefiles
    107                 // and these cause more problems.
    108                 sh 'find . -name Makefile.in -exec touch {} +'
    109104        }
    110105}
  • automake/missing

    • Property mode changed from 120000 to 100644
    r2fa5bd2 raca6a54c  
    1 /usr/share/automake-1.15/missing
     1#! /bin/sh
     2# Tdelisle : having the Makefiles.in automatically regenerated causes problems
     3#            when using multiple versions of automake, even if only on end user machines
     4#            therefore I am disabling that feature by commenting this script
     5exit 0
  • benchmark/Makefile.in

    r2fa5bd2 raca6a54c  
    352352LTCFACOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
    353353        $(LIBTOOLFLAGS) --mode=compile $(CFACC) $(DEFS) \
    354         $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(AM_CFLAGS) $(CFAFLAGS) $(CFLAGS)
     354        $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(CFAFLAGS) \
     355        $(AM_CFLAGS) $(CFLAGS)
    355356
    356357AM_V_CFA = $(am__v_CFA_@AM_V@)
  • driver/cc1.cc

    r2fa5bd2 raca6a54c  
    335335        #endif // __DEBUG_H__
    336336
    337         enum {
    338                 Color_Auto   = 0,
    339                 Color_Always = 1,
    340                 Color_Never  = 2,
    341         } color_arg = Color_Auto;
    342 
    343         const char * color_names[3] = { "--colors=auto", "--colors=always", "--colors=never" };
    344 
    345337        // process all the arguments
    346338
     
    349341                if ( prefix( arg, "-" ) ) {
    350342                        // strip inappropriate flags
    351 
    352                         if ( prefix( arg, "-fdiagnostics-color=" ) ) {
    353                                 string choice = arg.substr(20);
    354                                      if(choice == "always") color_arg = Color_Always;
    355                                 else if(choice == "never" ) color_arg = Color_Never;
    356                                 else if(choice == "auto"  ) color_arg = Color_Auto;
    357                         } else if ( arg == "-fno-diagnostics-color" ) {
    358                                 color_arg = Color_Auto;
    359                         }
    360343
    361344                        if ( arg == "-quiet" || arg == "-version" || arg == "-fpreprocessed" ||
     
    457440                        cargs[ncargs++] = cfa_cpp_out.c_str();
    458441                } // if
    459 
    460                 cargs[ncargs++] = color_names[color_arg];
    461 
    462442                cargs[ncargs] = nullptr;                                                // terminate argument list
    463443
  • driver/cfa.cc

    r2fa5bd2 raca6a54c  
    401401                args[nargs++] = "-Xlinker";
    402402                args[nargs++] = "--undefined=__cfaabi_appready_startup";
    403                 args[nargs++] = "-z";
    404                 args[nargs++] = "execstack";
    405403
    406404                // include the cfa library in case it is needed
     
    411409                args[nargs++] = "-Wl,--pop-state";
    412410                args[nargs++] = "-lcfa";
    413                 args[nargs++] = "-pthread";
     411                args[nargs++] = "-lpthread";
    414412                args[nargs++] = "-ldl";
    415413                args[nargs++] = "-lrt";
  • libcfa/configure

    r2fa5bd2 raca6a54c  
    30003000case $CONFIGURATION in
    30013001        "debug"   )
    3002                 CONFIG_CFLAGS="-O0 -g"
     3002                CONFIG_CFLAGS="-Og -g"
    30033003                CONFIG_CFAFLAGS="-debug"
    30043004                CONFIG_BUILDLIB="yes"
  • libcfa/configure.ac

    r2fa5bd2 raca6a54c  
    6868case $CONFIGURATION in
    6969        "debug"   )
    70                 CONFIG_CFLAGS="-O0 -g"
     70                CONFIG_CFLAGS="-Og -g"
    7171                CONFIG_CFAFLAGS="-debug"
    7272                CONFIG_BUILDLIB="yes"
  • libcfa/prelude/builtins.c

    r2fa5bd2 raca6a54c  
    1010// Created On       : Fri Jul 21 16:21:03 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Nov 21 16:31:39 2019
    13 // Update Count     : 101
     12// Last Modified On : Tue Jun 25 18:06:52 2019
     13// Update Count     : 97
    1414//
    1515
     
    6969
    7070// universal typed pointer constant
    71 static inline forall( dtype DT ) DT * intptr( uintptr_t addr ) { return (DT *)addr; }
     71// Compiler issue: there is a problem with anonymous types that do not have a size.
     72static inline forall( dtype DT | sized(DT) ) DT * intptr( uintptr_t addr ) { return (DT *)addr; }
    7273
    7374// exponentiation operator implementation
  • libcfa/prelude/sync-builtins.cf

    r2fa5bd2 raca6a54c  
    11char __sync_fetch_and_add(volatile char *, char,...);
     2char __sync_fetch_and_add_1(volatile char *, char,...);
    23signed char __sync_fetch_and_add(volatile signed char *, signed char,...);
     4signed char __sync_fetch_and_add_1(volatile signed char *, signed char,...);
    35unsigned char __sync_fetch_and_add(volatile unsigned char *, unsigned char,...);
     6unsigned char __sync_fetch_and_add_1(volatile unsigned char *, unsigned char,...);
    47signed short __sync_fetch_and_add(volatile signed short *, signed short,...);
     8signed short __sync_fetch_and_add_2(volatile signed short *, signed short,...);
    59unsigned short __sync_fetch_and_add(volatile unsigned short *, unsigned short,...);
     10unsigned short __sync_fetch_and_add_2(volatile unsigned short *, unsigned short,...);
    611signed int __sync_fetch_and_add(volatile signed int *, signed int,...);
     12signed int __sync_fetch_and_add_4(volatile signed int *, signed int,...);
    713unsigned int __sync_fetch_and_add(volatile unsigned int *, unsigned int,...);
    8 signed long int __sync_fetch_and_add(volatile signed long int *, signed long int,...);
    9 unsigned long int __sync_fetch_and_add(volatile unsigned long int *, unsigned long int,...);
     14unsigned int __sync_fetch_and_add_4(volatile unsigned int *, unsigned int,...);
    1015signed long long int __sync_fetch_and_add(volatile signed long long int *, signed long long int,...);
     16signed long long int __sync_fetch_and_add_8(volatile signed long long int *, signed long long int,...);
    1117unsigned long long int __sync_fetch_and_add(volatile unsigned long long int *, unsigned long long int,...);
     18unsigned long long int __sync_fetch_and_add_8(volatile unsigned long long int *, unsigned long long int,...);
    1219#if defined(__SIZEOF_INT128__)
    1320signed __int128 __sync_fetch_and_add(volatile signed __int128 *, signed __int128,...);
     21signed __int128 __sync_fetch_and_add_16(volatile signed __int128 *, signed __int128,...);
    1422unsigned __int128 __sync_fetch_and_add(volatile unsigned __int128 *, unsigned __int128,...);
     23unsigned __int128 __sync_fetch_and_add_16(volatile unsigned __int128 *, unsigned __int128,...);
    1524#endif
    1625
    1726char __sync_fetch_and_sub(volatile char *, char,...);
     27char __sync_fetch_and_sub_1(volatile char *, char,...);
    1828signed char __sync_fetch_and_sub(volatile signed char *, signed char,...);
     29signed char __sync_fetch_and_sub_1(volatile signed char *, signed char,...);
    1930unsigned char __sync_fetch_and_sub(volatile unsigned char *, unsigned char,...);
     31unsigned char __sync_fetch_and_sub_1(volatile unsigned char *, unsigned char,...);
    2032signed short __sync_fetch_and_sub(volatile signed short *, signed short,...);
     33signed short __sync_fetch_and_sub_2(volatile signed short *, signed short,...);
    2134unsigned short __sync_fetch_and_sub(volatile unsigned short *, unsigned short,...);
     35unsigned short __sync_fetch_and_sub_2(volatile unsigned short *, unsigned short,...);
    2236signed int __sync_fetch_and_sub(volatile signed int *, signed int,...);
     37signed int __sync_fetch_and_sub_4(volatile signed int *, signed int,...);
    2338unsigned int __sync_fetch_and_sub(volatile unsigned int *, unsigned int,...);
    24 signed long int __sync_fetch_and_sub(volatile signed long int *, signed long int,...);
    25 unsigned long int __sync_fetch_and_sub(volatile unsigned long int *, unsigned long int,...);
     39unsigned int __sync_fetch_and_sub_4(volatile unsigned int *, unsigned int,...);
    2640signed long long int __sync_fetch_and_sub(volatile signed long long int *, signed long long int,...);
     41signed long long int __sync_fetch_and_sub_8(volatile signed long long int *, signed long long int,...);
    2742unsigned long long int __sync_fetch_and_sub(volatile unsigned long long int *, unsigned long long int,...);
     43unsigned long long int __sync_fetch_and_sub_8(volatile unsigned long long int *, unsigned long long int,...);
    2844#if defined(__SIZEOF_INT128__)
    2945signed __int128 __sync_fetch_and_sub(volatile signed __int128 *, signed __int128,...);
     46signed __int128 __sync_fetch_and_sub_16(volatile signed __int128 *, signed __int128,...);
    3047unsigned __int128 __sync_fetch_and_sub(volatile unsigned __int128 *, unsigned __int128,...);
     48unsigned __int128 __sync_fetch_and_sub_16(volatile unsigned __int128 *, unsigned __int128,...);
    3149#endif
    3250
    3351char __sync_fetch_and_or(volatile char *, char,...);
     52char __sync_fetch_and_or_1(volatile char *, char,...);
    3453signed char __sync_fetch_and_or(volatile signed char *, signed char,...);
     54signed char __sync_fetch_and_or_1(volatile signed char *, signed char,...);
    3555unsigned char __sync_fetch_and_or(volatile unsigned char *, unsigned char,...);
     56unsigned char __sync_fetch_and_or_1(volatile unsigned char *, unsigned char,...);
    3657signed short __sync_fetch_and_or(volatile signed short *, signed short,...);
     58signed short __sync_fetch_and_or_2(volatile signed short *, signed short,...);
    3759unsigned short __sync_fetch_and_or(volatile unsigned short *, unsigned short,...);
     60unsigned short __sync_fetch_and_or_2(volatile unsigned short *, unsigned short,...);
    3861signed int __sync_fetch_and_or(volatile signed int *, signed int,...);
     62signed int __sync_fetch_and_or_4(volatile signed int *, signed int,...);
    3963unsigned int __sync_fetch_and_or(volatile unsigned int *, unsigned int,...);
    40 signed long int __sync_fetch_and_or(volatile signed long int *, signed long int,...);
    41 unsigned long int __sync_fetch_and_or(volatile unsigned long int *, unsigned long int,...);
     64unsigned int __sync_fetch_and_or_4(volatile unsigned int *, unsigned int,...);
    4265signed long long int __sync_fetch_and_or(volatile signed long long int *, signed long long int,...);
     66signed long long int __sync_fetch_and_or_8(volatile signed long long int *, signed long long int,...);
    4367unsigned long long int __sync_fetch_and_or(volatile unsigned long long int *, unsigned long long int,...);
     68unsigned long long int __sync_fetch_and_or_8(volatile unsigned long long int *, unsigned long long int,...);
    4469#if defined(__SIZEOF_INT128__)
    4570signed __int128 __sync_fetch_and_or(volatile signed __int128 *, signed __int128,...);
     71signed __int128 __sync_fetch_and_or_16(volatile signed __int128 *, signed __int128,...);
    4672unsigned __int128 __sync_fetch_and_or(volatile unsigned __int128 *, unsigned __int128,...);
     73unsigned __int128 __sync_fetch_and_or_16(volatile unsigned __int128 *, unsigned __int128,...);
    4774#endif
    4875
    4976char __sync_fetch_and_and(volatile char *, char,...);
     77char __sync_fetch_and_and_1(volatile char *, char,...);
    5078signed char __sync_fetch_and_and(volatile signed char *, signed char,...);
     79signed char __sync_fetch_and_and_1(volatile signed char *, signed char,...);
    5180unsigned char __sync_fetch_and_and(volatile unsigned char *, unsigned char,...);
     81unsigned char __sync_fetch_and_and_1(volatile unsigned char *, unsigned char,...);
    5282signed short __sync_fetch_and_and(volatile signed short *, signed short,...);
     83signed short __sync_fetch_and_and_2(volatile signed short *, signed short,...);
    5384unsigned short __sync_fetch_and_and(volatile unsigned short *, unsigned short,...);
     85unsigned short __sync_fetch_and_and_2(volatile unsigned short *, unsigned short,...);
    5486signed int __sync_fetch_and_and(volatile signed int *, signed int,...);
     87signed int __sync_fetch_and_and_4(volatile signed int *, signed int,...);
    5588unsigned int __sync_fetch_and_and(volatile unsigned int *, unsigned int,...);
    56 signed long int __sync_fetch_and_and(volatile signed long int *, signed long int,...);
    57 unsigned long int __sync_fetch_and_and(volatile unsigned long int *, unsigned long int,...);
     89unsigned int __sync_fetch_and_and_4(volatile unsigned int *, unsigned int,...);
    5890signed long long int __sync_fetch_and_and(volatile signed long long int *, signed long long int,...);
     91signed long long int __sync_fetch_and_and_8(volatile signed long long int *, signed long long int,...);
    5992unsigned long long int __sync_fetch_and_and(volatile unsigned long long int *, unsigned long long int,...);
     93unsigned long long int __sync_fetch_and_and_8(volatile unsigned long long int *, unsigned long long int,...);
    6094#if defined(__SIZEOF_INT128__)
    6195signed __int128 __sync_fetch_and_and(volatile signed __int128 *, signed __int128,...);
     96signed __int128 __sync_fetch_and_and_16(volatile signed __int128 *, signed __int128,...);
    6297unsigned __int128 __sync_fetch_and_and(volatile unsigned __int128 *, unsigned __int128,...);
     98unsigned __int128 __sync_fetch_and_and_16(volatile unsigned __int128 *, unsigned __int128,...);
    6399#endif
    64100
    65101char __sync_fetch_and_xor(volatile char *, char,...);
     102char __sync_fetch_and_xor_1(volatile char *, char,...);
    66103signed char __sync_fetch_and_xor(volatile signed char *, signed char,...);
     104signed char __sync_fetch_and_xor_1(volatile signed char *, signed char,...);
    67105unsigned char __sync_fetch_and_xor(volatile unsigned char *, unsigned char,...);
     106unsigned char __sync_fetch_and_xor_1(volatile unsigned char *, unsigned char,...);
    68107signed short __sync_fetch_and_xor(volatile signed short *, signed short,...);
     108signed short __sync_fetch_and_xor_2(volatile signed short *, signed short,...);
    69109unsigned short __sync_fetch_and_xor(volatile unsigned short *, unsigned short,...);
     110unsigned short __sync_fetch_and_xor_2(volatile unsigned short *, unsigned short,...);
    70111signed int __sync_fetch_and_xor(volatile signed int *, signed int,...);
     112signed int __sync_fetch_and_xor_4(volatile signed int *, signed int,...);
    71113unsigned int __sync_fetch_and_xor(volatile unsigned int *, unsigned int,...);
    72 signed long int __sync_fetch_and_xor(volatile signed long int *, signed long int,...);
    73 unsigned long int __sync_fetch_and_xor(volatile unsigned long int *, unsigned long int,...);
     114unsigned int __sync_fetch_and_xor_4(volatile unsigned int *, unsigned int,...);
    74115signed long long int __sync_fetch_and_xor(volatile signed long long int *, signed long long int,...);
     116signed long long int __sync_fetch_and_xor_8(volatile signed long long int *, signed long long int,...);
    75117unsigned long long int __sync_fetch_and_xor(volatile unsigned long long int *, unsigned long long int,...);
     118unsigned long long int __sync_fetch_and_xor_8(volatile unsigned long long int *, unsigned long long int,...);
    76119#if defined(__SIZEOF_INT128__)
    77120signed __int128 __sync_fetch_and_xor(volatile signed __int128 *, signed __int128,...);
     121signed __int128 __sync_fetch_and_xor_16(volatile signed __int128 *, signed __int128,...);
    78122unsigned __int128 __sync_fetch_and_xor(volatile unsigned __int128 *, unsigned __int128,...);
     123unsigned __int128 __sync_fetch_and_xor_16(volatile unsigned __int128 *, unsigned __int128,...);
    79124#endif
    80125
    81126char __sync_fetch_and_nand(volatile char *, char,...);
     127char __sync_fetch_and_nand_1(volatile char *, char,...);
    82128signed char __sync_fetch_and_nand(volatile signed char *, signed char,...);
     129signed char __sync_fetch_and_nand_1(volatile signed char *, signed char,...);
    83130unsigned char __sync_fetch_and_nand(volatile unsigned char *, unsigned char,...);
     131unsigned char __sync_fetch_and_nand_1(volatile unsigned char *, unsigned char,...);
    84132signed short __sync_fetch_and_nand(volatile signed short *, signed short,...);
     133signed short __sync_fetch_and_nand_2(volatile signed short *, signed short,...);
    85134unsigned short __sync_fetch_and_nand(volatile unsigned short *, unsigned short,...);
     135unsigned short __sync_fetch_and_nand_2(volatile unsigned short *, unsigned short,...);
    86136signed int __sync_fetch_and_nand(volatile signed int *, signed int,...);
     137signed int __sync_fetch_and_nand_4(volatile signed int *, signed int,...);
    87138unsigned int __sync_fetch_and_nand(volatile unsigned int *, unsigned int,...);
    88 signed long int __sync_fetch_and_nand(volatile signed long int *, signed long int,...);
    89 unsigned long int __sync_fetch_and_nand(volatile unsigned long int *, unsigned long int,...);
     139unsigned int __sync_fetch_and_nand_4(volatile unsigned int *, unsigned int,...);
    90140signed long long int __sync_fetch_and_nand(volatile signed long long int *, signed long long int,...);
     141signed long long int __sync_fetch_and_nand_8(volatile signed long long int *, signed long long int,...);
    91142unsigned long long int __sync_fetch_and_nand(volatile unsigned long long int *, unsigned long long int,...);
     143unsigned long long int __sync_fetch_and_nand_8(volatile unsigned long long int *, unsigned long long int,...);
    92144#if defined(__SIZEOF_INT128__)
    93145signed __int128 __sync_fetch_and_nand(volatile signed __int128 *, signed __int128,...);
     146signed __int128 __sync_fetch_and_nand_16(volatile signed __int128 *, signed __int128,...);
    94147unsigned __int128 __sync_fetch_and_nand(volatile unsigned __int128 *, unsigned __int128,...);
     148unsigned __int128 __sync_fetch_and_nand_16(volatile unsigned __int128 *, unsigned __int128,...);
    95149#endif
    96150
    97151char __sync_add_and_fetch(volatile char *, char,...);
     152char __sync_add_and_fetch_1(volatile char *, char,...);
    98153signed char __sync_add_and_fetch(volatile signed char *, signed char,...);
     154signed char __sync_add_and_fetch_1(volatile signed char *, signed char,...);
    99155unsigned char __sync_add_and_fetch(volatile unsigned char *, unsigned char,...);
     156unsigned char __sync_add_and_fetch_1(volatile unsigned char *, unsigned char,...);
    100157signed short __sync_add_and_fetch(volatile signed short *, signed short,...);
     158signed short __sync_add_and_fetch_2(volatile signed short *, signed short,...);
    101159unsigned short __sync_add_and_fetch(volatile unsigned short *, unsigned short,...);
     160unsigned short __sync_add_and_fetch_2(volatile unsigned short *, unsigned short,...);
    102161signed int __sync_add_and_fetch(volatile signed int *, signed int,...);
     162signed int __sync_add_and_fetch_4(volatile signed int *, signed int,...);
    103163signed int __sync_add_and_fetch(volatile signed int *, signed int,...);
    104 signed long int __sync_add_and_fetch(volatile signed long int *, signed long int,...);
    105 unsigned long int __sync_add_and_fetch(volatile unsigned long int *, unsigned long int,...);
     164signed int __sync_add_and_fetch_4(volatile signed int *, signed int,...);
    106165signed long long int __sync_add_and_fetch(volatile signed long long int *, signed long long int,...);
     166signed long long int __sync_add_and_fetch_8(volatile signed long long int *, signed long long int,...);
    107167unsigned long long int __sync_add_and_fetch(volatile unsigned long long int *, unsigned long long int,...);
     168unsigned long long int __sync_add_and_fetch_8(volatile unsigned long long int *, unsigned long long int,...);
    108169#if defined(__SIZEOF_INT128__)
    109170signed __int128 __sync_add_and_fetch(volatile signed __int128 *, signed __int128,...);
     171signed __int128 __sync_add_and_fetch_16(volatile signed __int128 *, signed __int128,...);
    110172unsigned __int128 __sync_add_and_fetch(volatile unsigned __int128 *, unsigned __int128,...);
     173unsigned __int128 __sync_add_and_fetch_16(volatile unsigned __int128 *, unsigned __int128,...);
    111174#endif
    112175
    113176char __sync_sub_and_fetch(volatile char *, char,...);
     177char __sync_sub_and_fetch_1(volatile char *, char,...);
    114178signed char __sync_sub_and_fetch(volatile signed char *, signed char,...);
     179signed char __sync_sub_and_fetch_1(volatile signed char *, signed char,...);
    115180unsigned char __sync_sub_and_fetch(volatile unsigned char *, unsigned char,...);
     181unsigned char __sync_sub_and_fetch_1(volatile unsigned char *, unsigned char,...);
    116182signed short __sync_sub_and_fetch(volatile signed short *, signed short,...);
     183signed short __sync_sub_and_fetch_2(volatile signed short *, signed short,...);
    117184unsigned short __sync_sub_and_fetch(volatile unsigned short *, unsigned short,...);
     185unsigned short __sync_sub_and_fetch_2(volatile unsigned short *, unsigned short,...);
    118186signed int __sync_sub_and_fetch(volatile signed int *, signed int,...);
     187signed int __sync_sub_and_fetch_4(volatile signed int *, signed int,...);
    119188unsigned int __sync_sub_and_fetch(volatile unsigned int *, unsigned int,...);
    120 signed long int __sync_sub_and_fetch(volatile signed long int *, signed long int,...);
    121 unsigned long int __sync_sub_and_fetch(volatile unsigned long int *, unsigned long int,...);
     189unsigned int __sync_sub_and_fetch_4(volatile unsigned int *, unsigned int,...);
    122190signed long long int __sync_sub_and_fetch(volatile signed long long int *, signed long long int,...);
     191signed long long int __sync_sub_and_fetch_8(volatile signed long long int *, signed long long int,...);
    123192unsigned long long int __sync_sub_and_fetch(volatile unsigned long long int *, unsigned long long int,...);
     193unsigned long long int __sync_sub_and_fetch_8(volatile unsigned long long int *, unsigned long long int,...);
    124194#if defined(__SIZEOF_INT128__)
    125195signed __int128 __sync_sub_and_fetch(volatile signed __int128 *, signed __int128,...);
     196signed __int128 __sync_sub_and_fetch_16(volatile signed __int128 *, signed __int128,...);
    126197unsigned __int128 __sync_sub_and_fetch(volatile unsigned __int128 *, unsigned __int128,...);
     198unsigned __int128 __sync_sub_and_fetch_16(volatile unsigned __int128 *, unsigned __int128,...);
    127199#endif
    128200
    129201char __sync_or_and_fetch(volatile char *, char,...);
     202char __sync_or_and_fetch_1(volatile char *, char,...);
    130203signed char __sync_or_and_fetch(volatile signed char *, signed char,...);
     204signed char __sync_or_and_fetch_1(volatile signed char *, signed char,...);
    131205unsigned char __sync_or_and_fetch(volatile unsigned char *, unsigned char,...);
     206unsigned char __sync_or_and_fetch_1(volatile unsigned char *, unsigned char,...);
    132207signed short __sync_or_and_fetch(volatile signed short *, signed short,...);
     208signed short __sync_or_and_fetch_2(volatile signed short *, signed short,...);
    133209unsigned short __sync_or_and_fetch(volatile unsigned short *, unsigned short,...);
     210unsigned short __sync_or_and_fetch_2(volatile unsigned short *, unsigned short,...);
    134211signed int __sync_or_and_fetch(volatile signed int *, signed int,...);
     212signed int __sync_or_and_fetch_4(volatile signed int *, signed int,...);
    135213unsigned int __sync_or_and_fetch(volatile unsigned int *, unsigned int,...);
    136 signed long int __sync_or_and_fetch(volatile signed long int *, signed long int,...);
    137 unsigned long int __sync_or_and_fetch(volatile unsigned long int *, unsigned long int,...);
     214unsigned int __sync_or_and_fetch_4(volatile unsigned int *, unsigned int,...);
    138215signed long long int __sync_or_and_fetch(volatile signed long long int *, signed long long int,...);
     216signed long long int __sync_or_and_fetch_8(volatile signed long long int *, signed long long int,...);
    139217unsigned long long int __sync_or_and_fetch(volatile unsigned long long int *, unsigned long long int,...);
     218unsigned long long int __sync_or_and_fetch_8(volatile unsigned long long int *, unsigned long long int,...);
    140219#if defined(__SIZEOF_INT128__)
    141220signed __int128 __sync_or_and_fetch(volatile signed __int128 *, signed __int128,...);
     221signed __int128 __sync_or_and_fetch_16(volatile signed __int128 *, signed __int128,...);
    142222unsigned __int128 __sync_or_and_fetch(volatile unsigned __int128 *, unsigned __int128,...);
     223unsigned __int128 __sync_or_and_fetch_16(volatile unsigned __int128 *, unsigned __int128,...);
    143224#endif
    144225
    145226char __sync_and_and_fetch(volatile char *, char,...);
     227char __sync_and_and_fetch_1(volatile char *, char,...);
    146228signed char __sync_and_and_fetch(volatile signed char *, signed char,...);
     229signed char __sync_and_and_fetch_1(volatile signed char *, signed char,...);
    147230unsigned char __sync_and_and_fetch(volatile unsigned char *, unsigned char,...);
     231unsigned char __sync_and_and_fetch_1(volatile unsigned char *, unsigned char,...);
    148232signed short __sync_and_and_fetch(volatile signed short *, signed short,...);
     233signed short __sync_and_and_fetch_2(volatile signed short *, signed short,...);
    149234unsigned short __sync_and_and_fetch(volatile unsigned short *, unsigned short,...);
     235unsigned short __sync_and_and_fetch_2(volatile unsigned short *, unsigned short,...);
    150236signed int __sync_and_and_fetch(volatile signed int *, signed int,...);
     237signed int __sync_and_and_fetch_4(volatile signed int *, signed int,...);
    151238unsigned int __sync_and_and_fetch(volatile unsigned int *, unsigned int,...);
    152 signed long int __sync_and_and_fetch(volatile signed long int *, signed long int,...);
    153 unsigned long int __sync_and_and_fetch(volatile unsigned long int *, unsigned long int,...);
     239unsigned int __sync_and_and_fetch_4(volatile unsigned int *, unsigned int,...);
    154240signed long long int __sync_and_and_fetch(volatile signed long long int *, signed long long int,...);
     241signed long long int __sync_and_and_fetch_8(volatile signed long long int *, signed long long int,...);
    155242unsigned long long int __sync_and_and_fetch(volatile unsigned long long int *, unsigned long long int,...);
     243unsigned long long int __sync_and_and_fetch_8(volatile unsigned long long int *, unsigned long long int,...);
    156244#if defined(__SIZEOF_INT128__)
    157245signed __int128 __sync_and_and_fetch(volatile signed __int128 *, signed __int128,...);
     246signed __int128 __sync_and_and_fetch_16(volatile signed __int128 *, signed __int128,...);
    158247unsigned __int128 __sync_and_and_fetch(volatile unsigned __int128 *, unsigned __int128,...);
     248unsigned __int128 __sync_and_and_fetch_16(volatile unsigned __int128 *, unsigned __int128,...);
    159249#endif
    160250
    161251char __sync_xor_and_fetch(volatile char *, char,...);
     252char __sync_xor_and_fetch_1(volatile char *, char,...);
    162253signed char __sync_xor_and_fetch(volatile signed char *, signed char,...);
     254signed char __sync_xor_and_fetch_1(volatile signed char *, signed char,...);
    163255unsigned char __sync_xor_and_fetch(volatile unsigned char *, unsigned char,...);
     256unsigned char __sync_xor_and_fetch_1(volatile unsigned char *, unsigned char,...);
    164257signed short __sync_xor_and_fetch(volatile signed short *, signed short,...);
     258signed short __sync_xor_and_fetch_2(volatile signed short *, signed short,...);
    165259unsigned short __sync_xor_and_fetch(volatile unsigned short *, unsigned short,...);
     260unsigned short __sync_xor_and_fetch_2(volatile unsigned short *, unsigned short,...);
    166261signed int __sync_xor_and_fetch(volatile signed int *, signed int,...);
     262signed int __sync_xor_and_fetch_4(volatile signed int *, signed int,...);
    167263unsigned int __sync_xor_and_fetch(volatile unsigned int *, unsigned int,...);
    168 signed long int __sync_xor_and_fetch(volatile signed long int *, signed long int,...);
    169 unsigned long int __sync_xor_and_fetch(volatile unsigned long int *, unsigned long int,...);
     264unsigned int __sync_xor_and_fetch_4(volatile unsigned int *, unsigned int,...);
    170265signed long long int __sync_xor_and_fetch(volatile signed long long int *, signed long long int,...);
     266signed long long int __sync_xor_and_fetch_8(volatile signed long long int *, signed long long int,...);
    171267unsigned long long int __sync_xor_and_fetch(volatile unsigned long long int *, unsigned long long int,...);
     268unsigned long long int __sync_xor_and_fetch_8(volatile unsigned long long int *, unsigned long long int,...);
    172269#if defined(__SIZEOF_INT128__)
    173270signed __int128 __sync_xor_and_fetch(volatile signed __int128 *, signed __int128,...);
     271signed __int128 __sync_xor_and_fetch_16(volatile signed __int128 *, signed __int128,...);
    174272unsigned __int128 __sync_xor_and_fetch(volatile unsigned __int128 *, unsigned __int128,...);
     273unsigned __int128 __sync_xor_and_fetch_16(volatile unsigned __int128 *, unsigned __int128,...);
    175274#endif
    176275
    177276char __sync_nand_and_fetch(volatile char *, char,...);
     277char __sync_nand_and_fetch_1(volatile char *, char,...);
    178278signed char __sync_nand_and_fetch(volatile signed char *, signed char,...);
     279signed char __sync_nand_and_fetch_1(volatile signed char *, signed char,...);
    179280unsigned char __sync_nand_and_fetch(volatile unsigned char *, unsigned char,...);
     281unsigned char __sync_nand_and_fetch_1(volatile unsigned char *, unsigned char,...);
    180282signed short __sync_nand_and_fetch(volatile signed short *, signed short,...);
     283signed short __sync_nand_and_fetch_2(volatile signed short *, signed short,...);
    181284unsigned short __sync_nand_and_fetch(volatile unsigned short *, unsigned short,...);
     285unsigned short __sync_nand_and_fetch_2(volatile unsigned short *, unsigned short,...);
    182286signed int __sync_nand_and_fetch(volatile signed int *, signed int,...);
     287signed int __sync_nand_and_fetch_4(volatile signed int *, signed int,...);
    183288unsigned int __sync_nand_and_fetch(volatile unsigned int *, unsigned int,...);
    184 signed long int __sync_nand_and_fetch(volatile signed long int *, signed long int,...);
    185 unsigned long int __sync_nand_and_fetch(volatile unsigned long int *, unsigned long int,...);
     289unsigned int __sync_nand_and_fetch_4(volatile unsigned int *, unsigned int,...);
    186290signed long long int __sync_nand_and_fetch(volatile signed long long int *, signed long long int,...);
     291signed long long int __sync_nand_and_fetch_8(volatile signed long long int *, signed long long int,...);
    187292unsigned long long int __sync_nand_and_fetch(volatile unsigned long long int *, unsigned long long int,...);
     293unsigned long long int __sync_nand_and_fetch_8(volatile unsigned long long int *, unsigned long long int,...);
    188294#if defined(__SIZEOF_INT128__)
    189295signed __int128 __sync_nand_and_fetch(volatile signed __int128 *, signed __int128,...);
     296signed __int128 __sync_nand_and_fetch_16(volatile signed __int128 *, signed __int128,...);
    190297unsigned __int128 __sync_nand_and_fetch(volatile unsigned __int128 *, unsigned __int128,...);
     298unsigned __int128 __sync_nand_and_fetch_16(volatile unsigned __int128 *, unsigned __int128,...);
    191299#endif
    192300
    193301_Bool __sync_bool_compare_and_swap(volatile char *, char, char,...);
     302_Bool __sync_bool_compare_and_swap_1(volatile char *, char, char,...);
    194303_Bool __sync_bool_compare_and_swap(volatile signed char *, signed char, signed char,...);
     304_Bool __sync_bool_compare_and_swap_1(volatile signed char *, signed char, signed char,...);
    195305_Bool __sync_bool_compare_and_swap(volatile unsigned char *, unsigned char, unsigned char,...);
     306_Bool __sync_bool_compare_and_swap_1(volatile unsigned char *, unsigned char, unsigned char,...);
    196307_Bool __sync_bool_compare_and_swap(volatile short *, signed short, signed short,...);
     308_Bool __sync_bool_compare_and_swap_2(volatile short *, signed short, signed short,...);
    197309_Bool __sync_bool_compare_and_swap(volatile short *, unsigned short, unsigned short,...);
     310_Bool __sync_bool_compare_and_swap_2(volatile short *, unsigned short, unsigned short,...);
    198311_Bool __sync_bool_compare_and_swap(volatile signed int *, signed int, signed int,...);
     312_Bool __sync_bool_compare_and_swap_4(volatile signed int *, signed int, signed int,...);
    199313_Bool __sync_bool_compare_and_swap(volatile unsigned int *, unsigned int, unsigned int,...);
    200 _Bool __sync_bool_compare_and_swap(volatile signed long int *, signed long int, signed long int,...);
    201 _Bool __sync_bool_compare_and_swap(volatile unsigned long int *, unsigned long int, unsigned long int,...);
     314_Bool __sync_bool_compare_and_swap_4(volatile unsigned int *, unsigned int, unsigned int,...);
    202315_Bool __sync_bool_compare_and_swap(volatile signed long long int *, signed long long int, signed long long int,...);
     316_Bool __sync_bool_compare_and_swap_8(volatile signed long long int *, signed long long int, signed long long int,...);
    203317_Bool __sync_bool_compare_and_swap(volatile unsigned long long int *, unsigned long long int, unsigned long long int,...);
     318_Bool __sync_bool_compare_and_swap_8(volatile unsigned long long int *, unsigned long long int, unsigned long long int,...);
    204319#if defined(__SIZEOF_INT128__)
    205320_Bool __sync_bool_compare_and_swap(volatile signed __int128 *, signed __int128, signed __int128,...);
     321_Bool __sync_bool_compare_and_swap_16(volatile signed __int128 *, signed __int128, signed __int128,...);
    206322_Bool __sync_bool_compare_and_swap(volatile unsigned __int128 *, unsigned __int128, unsigned __int128,...);
     323_Bool __sync_bool_compare_and_swap_16(volatile unsigned __int128 *, unsigned __int128, unsigned __int128,...);
    207324#endif
    208325forall(dtype T) _Bool __sync_bool_compare_and_swap(T * volatile *, T *, T*, ...);
    209326
    210327char __sync_val_compare_and_swap(volatile char *, char, char,...);
     328char __sync_val_compare_and_swap_1(volatile char *, char, char,...);
    211329signed char __sync_val_compare_and_swap(volatile signed char *, signed char, signed char,...);
     330signed char __sync_val_compare_and_swap_1(volatile signed char *, signed char, signed char,...);
    212331unsigned char __sync_val_compare_and_swap(volatile unsigned char *, unsigned char, unsigned char,...);
     332unsigned char __sync_val_compare_and_swap_1(volatile unsigned char *, unsigned char, unsigned char,...);
    213333signed short __sync_val_compare_and_swap(volatile signed short *, signed short, signed short,...);
     334signed short __sync_val_compare_and_swap_2(volatile signed short *, signed short, signed short,...);
    214335unsigned short __sync_val_compare_and_swap(volatile unsigned short *, unsigned short, unsigned short,...);
     336unsigned short __sync_val_compare_and_swap_2(volatile unsigned short *, unsigned short, unsigned short,...);
    215337signed int __sync_val_compare_and_swap(volatile signed int *, signed int, signed int,...);
     338signed int __sync_val_compare_and_swap_4(volatile signed int *, signed int, signed int,...);
    216339unsigned int __sync_val_compare_and_swap(volatile unsigned int *, unsigned int, unsigned int,...);
    217 signed long int __sync_val_compare_and_swap(volatile signed long int *, signed long int, signed long int,...);
    218 unsigned long int __sync_val_compare_and_swap(volatile unsigned long int *, unsigned long int, unsigned long int,...);
     340unsigned int __sync_val_compare_and_swap_4(volatile unsigned int *, unsigned int, unsigned int,...);
    219341signed long long int __sync_val_compare_and_swap(volatile signed long long int *, signed long long int, signed long long int,...);
     342signed long long int __sync_val_compare_and_swap_8(volatile signed long long int *, signed long long int, signed long long int,...);
    220343unsigned long long int __sync_val_compare_and_swap(volatile unsigned long long int *, unsigned long long int, unsigned long long int,...);
     344unsigned long long int __sync_val_compare_and_swap_8(volatile unsigned long long int *, unsigned long long int, unsigned long long int,...);
    221345#if defined(__SIZEOF_INT128__)
    222346signed __int128 __sync_val_compare_and_swap(volatile signed __int128 *, signed __int128, signed __int128,...);
     347signed __int128 __sync_val_compare_and_swap_16(volatile signed __int128 *, signed __int128, signed __int128,...);
    223348unsigned __int128 __sync_val_compare_and_swap(volatile unsigned __int128 *, unsigned __int128, unsigned __int128,...);
     349unsigned __int128 __sync_val_compare_and_swap_16(volatile unsigned __int128 *, unsigned __int128, unsigned __int128,...);
    224350#endif
    225351forall(dtype T) T * __sync_val_compare_and_swap(T * volatile *, T *, T*,...);
    226352
    227353char __sync_lock_test_and_set(volatile char *, char,...);
     354char __sync_lock_test_and_set_1(volatile char *, char,...);
    228355signed char __sync_lock_test_and_set(volatile signed char *, signed char,...);
     356signed char __sync_lock_test_and_set_1(volatile signed char *, signed char,...);
    229357unsigned char __sync_lock_test_and_set(volatile unsigned char *, unsigned char,...);
     358unsigned char __sync_lock_test_and_set_1(volatile unsigned char *, unsigned char,...);
    230359signed short __sync_lock_test_and_set(volatile signed short *, signed short,...);
     360signed short __sync_lock_test_and_set_2(volatile signed short *, signed short,...);
    231361unsigned short __sync_lock_test_and_set(volatile unsigned short *, unsigned short,...);
     362unsigned short __sync_lock_test_and_set_2(volatile unsigned short *, unsigned short,...);
    232363signed int __sync_lock_test_and_set(volatile signed int *, signed int,...);
     364signed int __sync_lock_test_and_set_4(volatile signed int *, signed int,...);
    233365unsigned int __sync_lock_test_and_set(volatile unsigned int *, unsigned int,...);
    234 signed long int __sync_lock_test_and_set(volatile signed long int *, signed long int,...);
    235 unsigned long int __sync_lock_test_and_set(volatile unsigned long int *, unsigned long int,...);
     366unsigned int __sync_lock_test_and_set_4(volatile unsigned int *, unsigned int,...);
    236367signed long long int __sync_lock_test_and_set(volatile signed long long int *, signed long long int,...);
     368signed long long int __sync_lock_test_and_set_8(volatile signed long long int *, signed long long int,...);
    237369unsigned long long int __sync_lock_test_and_set(volatile unsigned long long int *, unsigned long long int,...);
     370unsigned long long int __sync_lock_test_and_set_8(volatile unsigned long long int *, unsigned long long int,...);
    238371#if defined(__SIZEOF_INT128__)
    239372signed __int128 __sync_lock_test_and_set(volatile signed __int128 *, signed __int128,...);
     373signed __int128 __sync_lock_test_and_set_16(volatile signed __int128 *, signed __int128,...);
    240374unsigned __int128 __sync_lock_test_and_set(volatile unsigned __int128 *, unsigned __int128,...);
     375unsigned __int128 __sync_lock_test_and_set_16(volatile unsigned __int128 *, unsigned __int128,...);
    241376#endif
    242377
    243378void __sync_lock_release(volatile char *,...);
     379void __sync_lock_release_1(volatile char *,...);
    244380void __sync_lock_release(volatile signed char *,...);
     381void __sync_lock_release_1(volatile signed char *,...);
    245382void __sync_lock_release(volatile unsigned char *,...);
     383void __sync_lock_release_1(volatile unsigned char *,...);
    246384void __sync_lock_release(volatile signed short *,...);
     385void __sync_lock_release_2(volatile signed short *,...);
    247386void __sync_lock_release(volatile unsigned short *,...);
     387void __sync_lock_release_2(volatile unsigned short *,...);
    248388void __sync_lock_release(volatile signed int *,...);
     389void __sync_lock_release_4(volatile signed int *,...);
    249390void __sync_lock_release(volatile unsigned int *,...);
    250 void __sync_lock_release(volatile signed long int *,...);
    251 void __sync_lock_release(volatile unsigned long int *,...);
     391void __sync_lock_release_4(volatile unsigned int *,...);
    252392void __sync_lock_release(volatile signed long long int *,...);
     393void __sync_lock_release_8(volatile signed long long int *,...);
    253394void __sync_lock_release(volatile unsigned long long int *,...);
     395void __sync_lock_release_8(volatile unsigned long long int *,...);
    254396#if defined(__SIZEOF_INT128__)
    255397void __sync_lock_release(volatile signed __int128 *,...);
     398void __sync_lock_release_16(volatile signed __int128 *,...);
    256399void __sync_lock_release(volatile unsigned __int128 *,...);
     400void __sync_lock_release_16(volatile unsigned __int128 *,...);
    257401#endif
    258402
     
    270414_Bool __atomic_test_and_set(volatile signed int *, int);
    271415_Bool __atomic_test_and_set(volatile unsigned int *, int);
    272 _Bool __atomic_test_and_set(volatile signed long int *, int);
    273 _Bool __atomic_test_and_set(volatile unsigned long int *, int);
    274416_Bool __atomic_test_and_set(volatile signed long long int *, int);
    275417_Bool __atomic_test_and_set(volatile unsigned long long int *, int);
     
    287429void __atomic_clear(volatile signed int *, int);
    288430void __atomic_clear(volatile unsigned int *, int);
    289 void __atomic_clear(volatile signed long int *, int);
    290 void __atomic_clear(volatile unsigned long int *, int);
    291431void __atomic_clear(volatile signed long long int *, int);
    292432void __atomic_clear(volatile unsigned long long int *, int);
     
    296436#endif
    297437
    298 _Bool __atomic_exchange_n(volatile _Bool *, _Bool, int);
    299 void __atomic_exchange(volatile _Bool *, volatile _Bool *, volatile _Bool *, int);
    300438char __atomic_exchange_n(volatile char *, char, int);
     439char __atomic_exchange_1(volatile char *, char, int);
    301440void __atomic_exchange(volatile char *, volatile char *, volatile char *, int);
    302441signed char __atomic_exchange_n(volatile signed char *, signed char, int);
     442signed char __atomic_exchange_1(volatile signed char *, signed char, int);
    303443void __atomic_exchange(volatile signed char *, volatile signed char *, volatile signed char *, int);
    304444unsigned char __atomic_exchange_n(volatile unsigned char *, unsigned char, int);
     445unsigned char __atomic_exchange_1(volatile unsigned char *, unsigned char, int);
    305446void __atomic_exchange(volatile unsigned char *, volatile unsigned char *, volatile unsigned char *, int);
    306447signed short __atomic_exchange_n(volatile signed short *, signed short, int);
     448signed short __atomic_exchange_2(volatile signed short *, signed short, int);
    307449void __atomic_exchange(volatile signed short *, volatile signed short *, volatile signed short *, int);
    308450unsigned short __atomic_exchange_n(volatile unsigned short *, unsigned short, int);
     451unsigned short __atomic_exchange_2(volatile unsigned short *, unsigned short, int);
    309452void __atomic_exchange(volatile unsigned short *, volatile unsigned short *, volatile unsigned short *, int);
    310453signed int __atomic_exchange_n(volatile signed int *, signed int, int);
     454signed int __atomic_exchange_4(volatile signed int *, signed int, int);
    311455void __atomic_exchange(volatile signed int *, volatile signed int *, volatile signed int *, int);
    312456unsigned int __atomic_exchange_n(volatile unsigned int *, unsigned int, int);
     457unsigned int __atomic_exchange_4(volatile unsigned int *, unsigned int, int);
    313458void __atomic_exchange(volatile unsigned int *, volatile unsigned int *, volatile unsigned int *, int);
    314 signed long int __atomic_exchange_n(volatile signed long int *, signed long int, int);
    315 void __atomic_exchange(volatile signed long int *, volatile signed long int *, volatile signed long int *, int);
    316 unsigned long int __atomic_exchange_n(volatile unsigned long int *, unsigned long int, int);
    317 void __atomic_exchange(volatile unsigned long int *, volatile unsigned long int *, volatile unsigned long int *, int);
    318459signed long long int __atomic_exchange_n(volatile signed long long int *, signed long long int, int);
     460signed long long int __atomic_exchange_8(volatile signed long long int *, signed long long int, int);
    319461void __atomic_exchange(volatile signed long long int *, volatile signed long long int *, volatile signed long long int *, int);
    320462unsigned long long int __atomic_exchange_n(volatile unsigned long long int *, unsigned long long int, int);
     463unsigned long long int __atomic_exchange_8(volatile unsigned long long int *, unsigned long long int, int);
    321464void __atomic_exchange(volatile unsigned long long int *, volatile unsigned long long int *, volatile unsigned long long int *, int);
    322465#if defined(__SIZEOF_INT128__)
    323466signed __int128 __atomic_exchange_n(volatile signed __int128 *, signed __int128, int);
     467signed __int128 __atomic_exchange_16(volatile signed __int128 *, signed __int128, int);
    324468void __atomic_exchange(volatile signed __int128 *, volatile signed __int128 *, volatile signed __int128 *, int);
    325469unsigned __int128 __atomic_exchange_n(volatile unsigned __int128 *, unsigned __int128, int);
     470unsigned __int128 __atomic_exchange_16(volatile unsigned __int128 *, unsigned __int128, int);
    326471void __atomic_exchange(volatile unsigned __int128 *, volatile unsigned __int128 *, volatile unsigned __int128 *, int);
    327472#endif
     
    332477void __atomic_load(const volatile _Bool *, volatile _Bool *, int);
    333478char __atomic_load_n(const volatile char *, int);
     479char __atomic_load_1(const volatile char *, int);
    334480void __atomic_load(const volatile char *, volatile char *, int);
    335481signed char __atomic_load_n(const volatile signed char *, int);
     482signed char __atomic_load_1(const volatile signed char *, int);
    336483void __atomic_load(const volatile signed char *, volatile signed char *, int);
    337484unsigned char __atomic_load_n(const volatile unsigned char *, int);
     485unsigned char __atomic_load_1(const volatile unsigned char *, int);
    338486void __atomic_load(const volatile unsigned char *, volatile unsigned char *, int);
    339487signed short __atomic_load_n(const volatile signed short *, int);
     488signed short __atomic_load_2(const volatile signed short *, int);
    340489void __atomic_load(const volatile signed short *, volatile signed short *, int);
    341490unsigned short __atomic_load_n(const volatile unsigned short *, int);
     491unsigned short __atomic_load_2(const volatile unsigned short *, int);
    342492void __atomic_load(const volatile unsigned short *, volatile unsigned short *, int);
    343493signed int __atomic_load_n(const volatile signed int *, int);
     494signed int __atomic_load_4(const volatile signed int *, int);
    344495void __atomic_load(const volatile signed int *, volatile signed int *, int);
    345496unsigned int __atomic_load_n(const volatile unsigned int *, int);
     497unsigned int __atomic_load_4(const volatile unsigned int *, int);
    346498void __atomic_load(const volatile unsigned int *, volatile unsigned int *, int);
    347 signed long int __atomic_load_n(const volatile signed long int *, int);
    348 void __atomic_load(const volatile signed long int *, volatile signed long int *, int);
    349 unsigned long int __atomic_load_n(const volatile unsigned long int *, int);
    350 void __atomic_load(const volatile unsigned long int *, volatile unsigned long int *, int);
    351499signed long long int __atomic_load_n(const volatile signed long long int *, int);
     500signed long long int __atomic_load_8(const volatile signed long long int *, int);
    352501void __atomic_load(const volatile signed long long int *, volatile signed long long int *, int);
    353502unsigned long long int __atomic_load_n(const volatile unsigned long long int *, int);
     503unsigned long long int __atomic_load_8(const volatile unsigned long long int *, int);
    354504void __atomic_load(const volatile unsigned long long int *, volatile unsigned long long int *, int);
    355505#if defined(__SIZEOF_INT128__)
    356506signed __int128 __atomic_load_n(const volatile signed __int128 *, int);
     507signed __int128 __atomic_load_16(const volatile signed __int128 *, int);
    357508void __atomic_load(const volatile signed __int128 *, volatile signed __int128 *, int);
    358509unsigned __int128 __atomic_load_n(const volatile unsigned __int128 *, int);
     510unsigned __int128 __atomic_load_16(const volatile unsigned __int128 *, int);
    359511void __atomic_load(const volatile unsigned __int128 *, volatile unsigned __int128 *, int);
    360512#endif
     
    363515
    364516_Bool __atomic_compare_exchange_n(volatile char *, char *, char, _Bool, int, int);
     517_Bool __atomic_compare_exchange_1(volatile char *, char *, char, _Bool, int, int);
    365518_Bool __atomic_compare_exchange  (volatile char *, char *, char *, _Bool, int, int);
    366519_Bool __atomic_compare_exchange_n(volatile signed char *, signed char *, signed char, _Bool, int, int);
     520_Bool __atomic_compare_exchange_1(volatile signed char *, signed char *, signed char, _Bool, int, int);
    367521_Bool __atomic_compare_exchange  (volatile signed char *, signed char *, signed char *, _Bool, int, int);
    368522_Bool __atomic_compare_exchange_n(volatile unsigned char *, unsigned char *, unsigned char, _Bool, int, int);
     523_Bool __atomic_compare_exchange_1(volatile unsigned char *, unsigned char *, unsigned char, _Bool, int, int);
    369524_Bool __atomic_compare_exchange  (volatile unsigned char *, unsigned char *, unsigned char *, _Bool, int, int);
    370525_Bool __atomic_compare_exchange_n(volatile signed short *, signed short *, signed short, _Bool, int, int);
     526_Bool __atomic_compare_exchange_2(volatile signed short *, signed short *, signed short, _Bool, int, int);
    371527_Bool __atomic_compare_exchange  (volatile signed short *, signed short *, signed short *, _Bool, int, int);
    372528_Bool __atomic_compare_exchange_n(volatile unsigned short *, unsigned short *, unsigned short, _Bool, int, int);
     529_Bool __atomic_compare_exchange_2(volatile unsigned short *, unsigned short *, unsigned short, _Bool, int, int);
    373530_Bool __atomic_compare_exchange  (volatile unsigned short *, unsigned short *, unsigned short *, _Bool, int, int);
    374531_Bool __atomic_compare_exchange_n(volatile signed int *, signed int *, signed int, _Bool, int, int);
     532_Bool __atomic_compare_exchange_4(volatile signed int *, signed int *, signed int, _Bool, int, int);
    375533_Bool __atomic_compare_exchange  (volatile signed int *, signed int *, signed int *, _Bool, int, int);
    376534_Bool __atomic_compare_exchange_n(volatile unsigned int *, unsigned int *, unsigned int, _Bool, int, int);
     535_Bool __atomic_compare_exchange_4(volatile unsigned int *, unsigned int *, unsigned int, _Bool, int, int);
    377536_Bool __atomic_compare_exchange  (volatile unsigned int *, unsigned int *, unsigned int *, _Bool, int, int);
    378 _Bool __atomic_compare_exchange_n(volatile signed long int *, signed long int *, signed long int, _Bool, int, int);
    379 _Bool __atomic_compare_exchange  (volatile signed long int *, signed long int *, signed long int *, _Bool, int, int);
    380 _Bool __atomic_compare_exchange_n(volatile unsigned long int *, unsigned long int *, unsigned long int, _Bool, int, int);
    381 _Bool __atomic_compare_exchange  (volatile unsigned long int *, unsigned long int *, unsigned long int *, _Bool, int, int);
    382537_Bool __atomic_compare_exchange_n(volatile signed long long int *, signed long long int *, signed long long int, _Bool, int, int);
     538_Bool __atomic_compare_exchange_8(volatile signed long long int *, signed long long int *, signed long long int, _Bool, int, int);
    383539_Bool __atomic_compare_exchange  (volatile signed long long int *, signed long long int *, signed long long int *, _Bool, int, int);
    384540_Bool __atomic_compare_exchange_n(volatile unsigned long long int *, unsigned long long int *, unsigned long long int, _Bool, int, int);
     541_Bool __atomic_compare_exchange_8(volatile unsigned long long int *, unsigned long long int *, unsigned long long int, _Bool, int, int);
    385542_Bool __atomic_compare_exchange  (volatile unsigned long long int *, unsigned long long int *, unsigned long long int *, _Bool, int, int);
    386543#if defined(__SIZEOF_INT128__)
    387544_Bool __atomic_compare_exchange_n (volatile signed __int128 *, signed __int128 *, signed __int128, _Bool, int, int);
     545_Bool __atomic_compare_exchange_16(volatile signed __int128 *, signed __int128 *, signed __int128, _Bool, int, int);
    388546_Bool __atomic_compare_exchange   (volatile signed __int128 *, signed __int128 *, signed __int128 *, _Bool, int, int);
    389547_Bool __atomic_compare_exchange_n (volatile unsigned __int128 *, unsigned __int128 *, unsigned __int128, _Bool, int, int);
     548_Bool __atomic_compare_exchange_16(volatile unsigned __int128 *, unsigned __int128 *, unsigned __int128, _Bool, int, int);
    390549_Bool __atomic_compare_exchange   (volatile unsigned __int128 *, unsigned __int128 *, unsigned __int128 *, _Bool, int, int);
    391550#endif
     
    396555void __atomic_store(volatile _Bool *, _Bool *, int);
    397556void __atomic_store_n(volatile char *, char, int);
     557void __atomic_store_1(volatile char *, char, int);
    398558void __atomic_store(volatile char *, char *, int);
    399559void __atomic_store_n(volatile signed char *, signed char, int);
     560void __atomic_store_1(volatile signed char *, signed char, int);
    400561void __atomic_store(volatile signed char *, signed char *, int);
    401562void __atomic_store_n(volatile unsigned char *, unsigned char, int);
     563void __atomic_store_1(volatile unsigned char *, unsigned char, int);
    402564void __atomic_store(volatile unsigned char *, unsigned char *, int);
    403565void __atomic_store_n(volatile signed short *, signed short, int);
     566void __atomic_store_2(volatile signed short *, signed short, int);
    404567void __atomic_store(volatile signed short *, signed short *, int);
    405568void __atomic_store_n(volatile unsigned short *, unsigned short, int);
     569void __atomic_store_2(volatile unsigned short *, unsigned short, int);
    406570void __atomic_store(volatile unsigned short *, unsigned short *, int);
    407571void __atomic_store_n(volatile signed int *, signed int, int);
     572void __atomic_store_4(volatile signed int *, signed int, int);
    408573void __atomic_store(volatile signed int *, signed int *, int);
    409574void __atomic_store_n(volatile unsigned int *, unsigned int, int);
     575void __atomic_store_4(volatile unsigned int *, unsigned int, int);
    410576void __atomic_store(volatile unsigned int *, unsigned int *, int);
    411 void __atomic_store_n(volatile signed long int *, signed long int, int);
    412 void __atomic_store(volatile signed long int *, signed long int *, int);
    413 void __atomic_store_n(volatile unsigned long int *, unsigned long int, int);
    414 void __atomic_store(volatile unsigned long int *, unsigned long int *, int);
    415577void __atomic_store_n(volatile signed long long int *, signed long long int, int);
     578void __atomic_store_8(volatile signed long long int *, signed long long int, int);
    416579void __atomic_store(volatile signed long long int *, signed long long int *, int);
    417580void __atomic_store_n(volatile unsigned long long int *, unsigned long long int, int);
     581void __atomic_store_8(volatile unsigned long long int *, unsigned long long int, int);
    418582void __atomic_store(volatile unsigned long long int *, unsigned long long int *, int);
    419583#if defined(__SIZEOF_INT128__)
    420584void __atomic_store_n(volatile signed __int128 *, signed __int128, int);
     585void __atomic_store_16(volatile signed __int128 *, signed __int128, int);
    421586void __atomic_store(volatile signed __int128 *, signed __int128 *, int);
    422587void __atomic_store_n(volatile unsigned __int128 *, unsigned __int128, int);
     588void __atomic_store_16(volatile unsigned __int128 *, unsigned __int128, int);
    423589void __atomic_store(volatile unsigned __int128 *, unsigned __int128 *, int);
    424590#endif
     
    427593
    428594char __atomic_add_fetch  (volatile char *, char, int);
     595char __atomic_add_fetch_1(volatile char *, char, int);
    429596signed char __atomic_add_fetch  (volatile signed char *, signed char, int);
     597signed char __atomic_add_fetch_1(volatile signed char *, signed char, int);
    430598unsigned char __atomic_add_fetch  (volatile unsigned char *, unsigned char, int);
     599unsigned char __atomic_add_fetch_1(volatile unsigned char *, unsigned char, int);
    431600signed short __atomic_add_fetch  (volatile signed short *, signed short, int);
     601signed short __atomic_add_fetch_2(volatile signed short *, signed short, int);
    432602unsigned short __atomic_add_fetch  (volatile unsigned short *, unsigned short, int);
     603unsigned short __atomic_add_fetch_2(volatile unsigned short *, unsigned short, int);
    433604signed int __atomic_add_fetch  (volatile signed int *, signed int, int);
     605signed int __atomic_add_fetch_4(volatile signed int *, signed int, int);
    434606unsigned int __atomic_add_fetch  (volatile unsigned int *, unsigned int, int);
    435 signed long int __atomic_add_fetch  (volatile signed long int *, signed long int, int);
    436 unsigned long int __atomic_add_fetch  (volatile unsigned long int *, unsigned long int, int);
     607unsigned int __atomic_add_fetch_4(volatile unsigned int *, unsigned int, int);
    437608signed long long int __atomic_add_fetch  (volatile signed long long int *, signed long long int, int);
     609signed long long int __atomic_add_fetch_8(volatile signed long long int *, signed long long int, int);
    438610unsigned long long int __atomic_add_fetch  (volatile unsigned long long int *, unsigned long long int, int);
     611unsigned long long int __atomic_add_fetch_8(volatile unsigned long long int *, unsigned long long int, int);
    439612#if defined(__SIZEOF_INT128__)
    440613signed __int128 __atomic_add_fetch   (volatile signed __int128 *, signed __int128, int);
     614signed __int128 __atomic_add_fetch_16(volatile signed __int128 *, signed __int128, int);
    441615unsigned __int128 __atomic_add_fetch   (volatile unsigned __int128 *, unsigned __int128, int);
     616unsigned __int128 __atomic_add_fetch_16(volatile unsigned __int128 *, unsigned __int128, int);
    442617#endif
    443618
    444619char __atomic_sub_fetch  (volatile char *, char, int);
     620char __atomic_sub_fetch_1(volatile char *, char, int);
    445621signed char __atomic_sub_fetch  (volatile signed char *, signed char, int);
     622signed char __atomic_sub_fetch_1(volatile signed char *, signed char, int);
    446623unsigned char __atomic_sub_fetch  (volatile unsigned char *, unsigned char, int);
     624unsigned char __atomic_sub_fetch_1(volatile unsigned char *, unsigned char, int);
    447625signed short __atomic_sub_fetch  (volatile signed short *, signed short, int);
     626signed short __atomic_sub_fetch_2(volatile signed short *, signed short, int);
    448627unsigned short __atomic_sub_fetch  (volatile unsigned short *, unsigned short, int);
     628unsigned short __atomic_sub_fetch_2(volatile unsigned short *, unsigned short, int);
    449629signed int __atomic_sub_fetch  (volatile signed int *, signed int, int);
     630signed int __atomic_sub_fetch_4(volatile signed int *, signed int, int);
    450631unsigned int __atomic_sub_fetch  (volatile unsigned int *, unsigned int, int);
    451 signed long long int __atomic_sub_fetch  (volatile signed long int *, signed long int, int);
    452 unsigned long long int __atomic_sub_fetch  (volatile unsigned long int *, unsigned long int, int);
     632unsigned int __atomic_sub_fetch_4(volatile unsigned int *, unsigned int, int);
    453633signed long long int __atomic_sub_fetch  (volatile signed long long int *, signed long long int, int);
     634signed long long int __atomic_sub_fetch_8(volatile signed long long int *, signed long long int, int);
    454635unsigned long long int __atomic_sub_fetch  (volatile unsigned long long int *, unsigned long long int, int);
     636unsigned long long int __atomic_sub_fetch_8(volatile unsigned long long int *, unsigned long long int, int);
    455637#if defined(__SIZEOF_INT128__)
    456638signed __int128 __atomic_sub_fetch   (volatile signed __int128 *, signed __int128, int);
     639signed __int128 __atomic_sub_fetch_16(volatile signed __int128 *, signed __int128, int);
    457640unsigned __int128 __atomic_sub_fetch   (volatile unsigned __int128 *, unsigned __int128, int);
     641unsigned __int128 __atomic_sub_fetch_16(volatile unsigned __int128 *, unsigned __int128, int);
    458642#endif
    459643
    460644char __atomic_and_fetch  (volatile char *, char, int);
     645char __atomic_and_fetch_1(volatile char *, char, int);
    461646signed char __atomic_and_fetch  (volatile signed char *, signed char, int);
     647signed char __atomic_and_fetch_1(volatile signed char *, signed char, int);
    462648unsigned char __atomic_and_fetch  (volatile unsigned char *, unsigned char, int);
     649unsigned char __atomic_and_fetch_1(volatile unsigned char *, unsigned char, int);
    463650signed short __atomic_and_fetch  (volatile signed short *, signed short, int);
     651signed short __atomic_and_fetch_2(volatile signed short *, signed short, int);
    464652unsigned short __atomic_and_fetch  (volatile unsigned short *, unsigned short, int);
     653unsigned short __atomic_and_fetch_2(volatile unsigned short *, unsigned short, int);
    465654signed int __atomic_and_fetch  (volatile signed int *, signed int, int);
     655signed int __atomic_and_fetch_4(volatile signed int *, signed int, int);
    466656unsigned int __atomic_and_fetch  (volatile unsigned int *, unsigned int, int);
    467 signed long int __atomic_and_fetch  (volatile signed long int *, signed long int, int);
    468 unsigned long int __atomic_and_fetch  (volatile unsigned long int *, unsigned long int, int);
     657unsigned int __atomic_and_fetch_4(volatile unsigned int *, unsigned int, int);
    469658signed long long int __atomic_and_fetch  (volatile signed long long int *, signed long long int, int);
     659signed long long int __atomic_and_fetch_8(volatile signed long long int *, signed long long int, int);
    470660unsigned long long int __atomic_and_fetch  (volatile unsigned long long int *, unsigned long long int, int);
     661unsigned long long int __atomic_and_fetch_8(volatile unsigned long long int *, unsigned long long int, int);
    471662#if defined(__SIZEOF_INT128__)
    472663signed __int128 __atomic_and_fetch   (volatile signed __int128 *, signed __int128, int);
     664signed __int128 __atomic_and_fetch_16(volatile signed __int128 *, signed __int128, int);
    473665unsigned __int128 __atomic_and_fetch   (volatile unsigned __int128 *, unsigned __int128, int);
     666unsigned __int128 __atomic_and_fetch_16(volatile unsigned __int128 *, unsigned __int128, int);
    474667#endif
    475668
    476669char __atomic_nand_fetch  (volatile char *, char, int);
     670char __atomic_nand_fetch_1(volatile char *, char, int);
    477671signed char __atomic_nand_fetch  (volatile signed char *, signed char, int);
     672signed char __atomic_nand_fetch_1(volatile signed char *, signed char, int);
    478673unsigned char __atomic_nand_fetch  (volatile unsigned char *, unsigned char, int);
     674unsigned char __atomic_nand_fetch_1(volatile unsigned char *, unsigned char, int);
    479675signed short __atomic_nand_fetch  (volatile signed short *, signed short, int);
     676signed short __atomic_nand_fetch_2(volatile signed short *, signed short, int);
    480677unsigned short __atomic_nand_fetch  (volatile unsigned short *, unsigned short, int);
     678unsigned short __atomic_nand_fetch_2(volatile unsigned short *, unsigned short, int);
    481679signed int __atomic_nand_fetch  (volatile signed int *, signed int, int);
     680signed int __atomic_nand_fetch_4(volatile signed int *, signed int, int);
    482681unsigned int __atomic_nand_fetch  (volatile unsigned int *, unsigned int, int);
    483 signed long int __atomic_nand_fetch  (volatile signed long int *, signed long int, int);
    484 unsigned long int __atomic_nand_fetch  (volatile unsigned long int *, unsigned long int, int);
     682unsigned int __atomic_nand_fetch_4(volatile unsigned int *, unsigned int, int);
    485683signed long long int __atomic_nand_fetch  (volatile signed long long int *, signed long long int, int);
     684signed long long int __atomic_nand_fetch_8(volatile signed long long int *, signed long long int, int);
    486685unsigned long long int __atomic_nand_fetch  (volatile unsigned long long int *, unsigned long long int, int);
     686unsigned long long int __atomic_nand_fetch_8(volatile unsigned long long int *, unsigned long long int, int);
    487687#if defined(__SIZEOF_INT128__)
    488688signed __int128 __atomic_nand_fetch   (volatile signed __int128 *, signed __int128, int);
     689signed __int128 __atomic_nand_fetch_16(volatile signed __int128 *, signed __int128, int);
    489690unsigned __int128 __atomic_nand_fetch   (volatile unsigned __int128 *, unsigned __int128, int);
     691unsigned __int128 __atomic_nand_fetch_16(volatile unsigned __int128 *, unsigned __int128, int);
    490692#endif
    491693
    492694char __atomic_xor_fetch  (volatile char *, char, int);
     695char __atomic_xor_fetch_1(volatile char *, char, int);
    493696signed char __atomic_xor_fetch  (volatile signed char *, signed char, int);
     697signed char __atomic_xor_fetch_1(volatile signed char *, signed char, int);
    494698unsigned char __atomic_xor_fetch  (volatile unsigned char *, unsigned char, int);
     699unsigned char __atomic_xor_fetch_1(volatile unsigned char *, unsigned char, int);
    495700signed short __atomic_xor_fetch  (volatile signed short *, signed short, int);
     701signed short __atomic_xor_fetch_2(volatile signed short *, signed short, int);
    496702unsigned short __atomic_xor_fetch  (volatile unsigned short *, unsigned short, int);
     703unsigned short __atomic_xor_fetch_2(volatile unsigned short *, unsigned short, int);
    497704signed int __atomic_xor_fetch  (volatile signed int *, signed int, int);
     705signed int __atomic_xor_fetch_4(volatile signed int *, signed int, int);
    498706unsigned int __atomic_xor_fetch  (volatile unsigned int *, unsigned int, int);
    499 signed long int __atomic_xor_fetch  (volatile signed long int *, signed long int, int);
    500 unsigned long int __atomic_xor_fetch  (volatile unsigned long int *, unsigned long int, int);
     707unsigned int __atomic_xor_fetch_4(volatile unsigned int *, unsigned int, int);
    501708signed long long int __atomic_xor_fetch  (volatile signed long long int *, signed long long int, int);
     709signed long long int __atomic_xor_fetch_8(volatile signed long long int *, signed long long int, int);
    502710unsigned long long int __atomic_xor_fetch  (volatile unsigned long long int *, unsigned long long int, int);
     711unsigned long long int __atomic_xor_fetch_8(volatile unsigned long long int *, unsigned long long int, int);
    503712#if defined(__SIZEOF_INT128__)
    504713signed __int128 __atomic_xor_fetch   (volatile signed __int128 *, signed __int128, int);
     714signed __int128 __atomic_xor_fetch_16(volatile signed __int128 *, signed __int128, int);
    505715unsigned __int128 __atomic_xor_fetch   (volatile unsigned __int128 *, unsigned __int128, int);
     716unsigned __int128 __atomic_xor_fetch_16(volatile unsigned __int128 *, unsigned __int128, int);
    506717#endif
    507718
    508719char __atomic_or_fetch  (volatile char *, char, int);
     720char __atomic_or_fetch_1(volatile char *, char, int);
    509721signed char __atomic_or_fetch  (volatile signed char *, signed char, int);
     722signed char __atomic_or_fetch_1(volatile signed char *, signed char, int);
    510723unsigned char __atomic_or_fetch  (volatile unsigned char *, unsigned char, int);
     724unsigned char __atomic_or_fetch_1(volatile unsigned char *, unsigned char, int);
    511725signed short __atomic_or_fetch  (volatile signed short *, signed short, int);
     726signed short __atomic_or_fetch_2(volatile signed short *, signed short, int);
    512727unsigned short __atomic_or_fetch  (volatile unsigned short *, unsigned short, int);
     728unsigned short __atomic_or_fetch_2(volatile unsigned short *, unsigned short, int);
    513729signed int __atomic_or_fetch  (volatile signed int *, signed int, int);
     730signed int __atomic_or_fetch_4(volatile signed int *, signed int, int);
    514731unsigned int __atomic_or_fetch  (volatile unsigned int *, unsigned int, int);
    515 signed long int __atomic_or_fetch  (volatile signed long int *, signed long int, int);
    516 unsigned long int __atomic_or_fetch  (volatile unsigned long int *, unsigned long int, int);
     732unsigned int __atomic_or_fetch_4(volatile unsigned int *, unsigned int, int);
    517733signed long long int __atomic_or_fetch  (volatile signed long long int *, signed long long int, int);
     734signed long long int __atomic_or_fetch_8(volatile signed long long int *, signed long long int, int);
    518735unsigned long long int __atomic_or_fetch  (volatile unsigned long long int *, unsigned long long int, int);
     736unsigned long long int __atomic_or_fetch_8(volatile unsigned long long int *, unsigned long long int, int);
    519737#if defined(__SIZEOF_INT128__)
    520738signed __int128 __atomic_or_fetch   (volatile signed __int128 *, signed __int128, int);
     739signed __int128 __atomic_or_fetch_16(volatile signed __int128 *, signed __int128, int);
    521740unsigned __int128 __atomic_or_fetch   (volatile unsigned __int128 *, unsigned __int128, int);
     741unsigned __int128 __atomic_or_fetch_16(volatile unsigned __int128 *, unsigned __int128, int);
    522742#endif
    523743
    524744char __atomic_fetch_add  (volatile char *, char, int);
     745char __atomic_fetch_add_1(volatile char *, char, int);
    525746signed char __atomic_fetch_add  (volatile signed char *, signed char, int);
     747signed char __atomic_fetch_add_1(volatile signed char *, signed char, int);
    526748unsigned char __atomic_fetch_add  (volatile unsigned char *, unsigned char, int);
     749unsigned char __atomic_fetch_add_1(volatile unsigned char *, unsigned char, int);
    527750signed short __atomic_fetch_add  (volatile signed short *, signed short, int);
     751signed short __atomic_fetch_add_2(volatile signed short *, signed short, int);
    528752unsigned short __atomic_fetch_add  (volatile unsigned short *, unsigned short, int);
     753unsigned short __atomic_fetch_add_2(volatile unsigned short *, unsigned short, int);
    529754signed int __atomic_fetch_add  (volatile signed int *, signed int, int);
     755signed int __atomic_fetch_add_4(volatile signed int *, signed int, int);
    530756unsigned int __atomic_fetch_add  (volatile unsigned int *, unsigned int, int);
    531 signed long int __atomic_fetch_add  (volatile signed long int *, signed long int, int);
    532 unsigned long int __atomic_fetch_add  (volatile unsigned long int *, unsigned long int, int);
     757unsigned int __atomic_fetch_add_4(volatile unsigned int *, unsigned int, int);
    533758signed long long int __atomic_fetch_add  (volatile signed long long int *, signed long long int, int);
     759signed long long int __atomic_fetch_add_8(volatile signed long long int *, signed long long int, int);
    534760unsigned long long int __atomic_fetch_add  (volatile unsigned long long int *, unsigned long long int, int);
     761unsigned long long int __atomic_fetch_add_8(volatile unsigned long long int *, unsigned long long int, int);
    535762#if defined(__SIZEOF_INT128__)
    536763signed __int128 __atomic_fetch_add   (volatile signed __int128 *, signed __int128, int);
     764signed __int128 __atomic_fetch_add_16(volatile signed __int128 *, signed __int128, int);
    537765unsigned __int128 __atomic_fetch_add   (volatile unsigned __int128 *, unsigned __int128, int);
     766unsigned __int128 __atomic_fetch_add_16(volatile unsigned __int128 *, unsigned __int128, int);
    538767#endif
    539768
    540769char __atomic_fetch_sub  (volatile char *, char, int);
     770char __atomic_fetch_sub_1(volatile char *, char, int);
    541771signed char __atomic_fetch_sub  (volatile signed char *, signed char, int);
     772signed char __atomic_fetch_sub_1(volatile signed char *, signed char, int);
    542773unsigned char __atomic_fetch_sub  (volatile unsigned char *, unsigned char, int);
     774unsigned char __atomic_fetch_sub_1(volatile unsigned char *, unsigned char, int);
    543775signed short __atomic_fetch_sub  (volatile signed short *, signed short, int);
     776signed short __atomic_fetch_sub_2(volatile signed short *, signed short, int);
    544777unsigned short __atomic_fetch_sub  (volatile unsigned short *, unsigned short, int);
     778unsigned short __atomic_fetch_sub_2(volatile unsigned short *, unsigned short, int);
    545779signed int __atomic_fetch_sub  (volatile signed int *, signed int, int);
     780signed int __atomic_fetch_sub_4(volatile signed int *, signed int, int);
    546781unsigned int __atomic_fetch_sub  (volatile unsigned int *, unsigned int, int);
    547 signed long int __atomic_fetch_sub  (volatile signed long int *, signed long int, int);
    548 unsigned long int __atomic_fetch_sub  (volatile unsigned long int *, unsigned long int, int);
     782unsigned int __atomic_fetch_sub_4(volatile unsigned int *, unsigned int, int);
    549783signed long long int __atomic_fetch_sub  (volatile signed long long int *, signed long long int, int);
     784signed long long int __atomic_fetch_sub_8(volatile signed long long int *, signed long long int, int);
    550785unsigned long long int __atomic_fetch_sub  (volatile unsigned long long int *, unsigned long long int, int);
     786unsigned long long int __atomic_fetch_sub_8(volatile unsigned long long int *, unsigned long long int, int);
    551787#if defined(__SIZEOF_INT128__)
    552788signed __int128 __atomic_fetch_sub   (volatile signed  __int128 *, signed __int128, int);
     789signed __int128 __atomic_fetch_sub_16(volatile signed  __int128 *, signed __int128, int);
    553790unsigned __int128 __atomic_fetch_sub   (volatile unsigned  __int128 *, unsigned __int128, int);
     791unsigned __int128 __atomic_fetch_sub_16(volatile unsigned  __int128 *, unsigned __int128, int);
    554792#endif
    555793
    556794char __atomic_fetch_and  (volatile char *, char, int);
     795char __atomic_fetch_and_1(volatile char *, char, int);
    557796signed char __atomic_fetch_and  (volatile signed char *, signed char, int);
     797signed char __atomic_fetch_and_1(volatile signed char *, signed char, int);
    558798unsigned char __atomic_fetch_and  (volatile unsigned char *, unsigned char, int);
     799unsigned char __atomic_fetch_and_1(volatile unsigned char *, unsigned char, int);
    559800signed short __atomic_fetch_and  (volatile signed short *, signed short, int);
     801signed short __atomic_fetch_and_2(volatile signed short *, signed short, int);
    560802unsigned short __atomic_fetch_and  (volatile unsigned short *, unsigned short, int);
     803unsigned short __atomic_fetch_and_2(volatile unsigned short *, unsigned short, int);
    561804signed int __atomic_fetch_and  (volatile signed int *, signed int, int);
     805signed int __atomic_fetch_and_4(volatile signed int *, signed int, int);
    562806unsigned int __atomic_fetch_and  (volatile unsigned int *, unsigned int, int);
    563 signed long int __atomic_fetch_and  (volatile signed long int *, signed long int, int);
    564 unsigned long int __atomic_fetch_and  (volatile unsigned long int *, unsigned long int, int);
     807unsigned int __atomic_fetch_and_4(volatile unsigned int *, unsigned int, int);
    565808signed long long int __atomic_fetch_and  (volatile signed long long int *, signed long long int, int);
     809signed long long int __atomic_fetch_and_8(volatile signed long long int *, signed long long int, int);
    566810unsigned long long int __atomic_fetch_and  (volatile unsigned long long int *, unsigned long long int, int);
     811unsigned long long int __atomic_fetch_and_8(volatile unsigned long long int *, unsigned long long int, int);
    567812#if defined(__SIZEOF_INT128__)
    568813signed __int128 __atomic_fetch_and   (volatile signed __int128 *, signed __int128, int);
     814signed __int128 __atomic_fetch_and_16(volatile signed __int128 *, signed __int128, int);
    569815unsigned __int128 __atomic_fetch_and   (volatile unsigned __int128 *, unsigned __int128, int);
     816unsigned __int128 __atomic_fetch_and_16(volatile unsigned __int128 *, unsigned __int128, int);
    570817#endif
    571818
    572819char __atomic_fetch_nand  (volatile char *, char, int);
     820char __atomic_fetch_nand_1(volatile char *, char, int);
    573821signed char __atomic_fetch_nand  (volatile signed char *, signed char, int);
     822signed char __atomic_fetch_nand_1(volatile signed char *, signed char, int);
    574823unsigned char __atomic_fetch_nand  (volatile unsigned char *, unsigned char, int);
     824unsigned char __atomic_fetch_nand_1(volatile unsigned char *, unsigned char, int);
    575825signed short __atomic_fetch_nand  (volatile signed short *, signed short, int);
     826signed short __atomic_fetch_nand_2(volatile signed short *, signed short, int);
    576827unsigned short __atomic_fetch_nand  (volatile unsigned short *, unsigned short, int);
     828unsigned short __atomic_fetch_nand_2(volatile unsigned short *, unsigned short, int);
    577829signed int __atomic_fetch_nand  (volatile signed int *, signed int, int);
     830signed int __atomic_fetch_nand_4(volatile signed int *, signed int, int);
    578831unsigned int __atomic_fetch_nand  (volatile unsigned int *, unsigned int, int);
    579 signed long int __atomic_fetch_nand  (volatile signed long int *, signed long int, int);
    580 unsigned long int __atomic_fetch_nand  (volatile unsigned long int *, unsigned long int, int);
     832unsigned int __atomic_fetch_nand_4(volatile unsigned int *, unsigned int, int);
    581833signed long long int __atomic_fetch_nand  (volatile signed long long int *, signed long long int, int);
     834signed long long int __atomic_fetch_nand_8(volatile signed long long int *, signed long long int, int);
    582835unsigned long long int __atomic_fetch_nand  (volatile unsigned long long int *, unsigned long long int, int);
     836unsigned long long int __atomic_fetch_nand_8(volatile unsigned long long int *, unsigned long long int, int);
    583837#if defined(__SIZEOF_INT128__)
    584838signed __int128 __atomic_fetch_nand   (volatile signed __int128 *, signed __int128, int);
     839signed __int128 __atomic_fetch_nand_16(volatile signed __int128 *, signed __int128, int);
    585840unsigned __int128 __atomic_fetch_nand   (volatile unsigned __int128 *, unsigned __int128, int);
     841unsigned __int128 __atomic_fetch_nand_16(volatile unsigned __int128 *, unsigned __int128, int);
    586842#endif
    587843
    588844char __atomic_fetch_xor  (volatile char *, char, int);
     845char __atomic_fetch_xor_1(volatile char *, char, int);
    589846signed char __atomic_fetch_xor  (volatile signed char *, signed char, int);
     847signed char __atomic_fetch_xor_1(volatile signed char *, signed char, int);
    590848unsigned char __atomic_fetch_xor  (volatile unsigned char *, unsigned char, int);
     849unsigned char __atomic_fetch_xor_1(volatile unsigned char *, unsigned char, int);
    591850signed short __atomic_fetch_xor  (volatile signed short *, signed short, int);
     851signed short __atomic_fetch_xor_2(volatile signed short *, signed short, int);
    592852unsigned short __atomic_fetch_xor  (volatile unsigned short *, unsigned short, int);
     853unsigned short __atomic_fetch_xor_2(volatile unsigned short *, unsigned short, int);
    593854signed int __atomic_fetch_xor  (volatile signed int *, signed int, int);
     855signed int __atomic_fetch_xor_4(volatile signed int *, signed int, int);
    594856unsigned int __atomic_fetch_xor  (volatile unsigned int *, unsigned int, int);
    595 signed long int __atomic_fetch_xor  (volatile signed long int *, signed long int, int);
    596 unsigned long int __atomic_fetch_xor  (volatile unsigned long int *, unsigned long int, int);
     857unsigned int __atomic_fetch_xor_4(volatile unsigned int *, unsigned int, int);
    597858signed long long int __atomic_fetch_xor  (volatile signed long long int *, signed long long int, int);
     859signed long long int __atomic_fetch_xor_8(volatile signed long long int *, signed long long int, int);
    598860unsigned long long int __atomic_fetch_xor  (volatile unsigned long long int *, unsigned long long int, int);
     861unsigned long long int __atomic_fetch_xor_8(volatile unsigned long long int *, unsigned long long int, int);
    599862#if defined(__SIZEOF_INT128__)
    600863signed __int128 __atomic_fetch_xor   (volatile signed __int128 *, signed __int128, int);
     864signed __int128 __atomic_fetch_xor_16(volatile signed __int128 *, signed __int128, int);
    601865unsigned __int128 __atomic_fetch_xor   (volatile unsigned __int128 *, unsigned __int128, int);
     866unsigned __int128 __atomic_fetch_xor_16(volatile unsigned __int128 *, unsigned __int128, int);
    602867#endif
    603868
    604869char __atomic_fetch_or  (volatile char *, char, int);
     870char __atomic_fetch_or_1(volatile char *, char, int);
    605871signed char __atomic_fetch_or  (volatile signed char *, signed char, int);
     872signed char __atomic_fetch_or_1(volatile signed char *, signed char, int);
    606873unsigned char __atomic_fetch_or  (volatile unsigned char *, unsigned char, int);
     874unsigned char __atomic_fetch_or_1(volatile unsigned char *, unsigned char, int);
    607875signed short __atomic_fetch_or  (volatile signed short *, signed short, int);
     876signed short __atomic_fetch_or_2(volatile signed short *, signed short, int);
    608877unsigned short __atomic_fetch_or  (volatile unsigned short *, unsigned short, int);
     878unsigned short __atomic_fetch_or_2(volatile unsigned short *, unsigned short, int);
    609879signed int __atomic_fetch_or  (volatile signed int *, signed int, int);
     880signed int __atomic_fetch_or_4(volatile signed int *, signed int, int);
    610881unsigned int __atomic_fetch_or  (volatile unsigned int *, unsigned int, int);
    611 signed long int __atomic_fetch_or  (volatile signed long int *, signed long int, int);
    612 unsigned long int __atomic_fetch_or  (volatile unsigned long int *, unsigned long int, int);
     882unsigned int __atomic_fetch_or_4(volatile unsigned int *, unsigned int, int);
    613883signed long long int __atomic_fetch_or  (volatile signed long long int *, signed long long int, int);
     884signed long long int __atomic_fetch_or_8(volatile signed long long int *, signed long long int, int);
    614885unsigned long long int __atomic_fetch_or  (volatile unsigned long long int *, unsigned long long int, int);
     886unsigned long long int __atomic_fetch_or_8(volatile unsigned long long int *, unsigned long long int, int);
    615887#if defined(__SIZEOF_INT128__)
    616888signed __int128 __atomic_fetch_or   (volatile signed __int128 *, signed __int128, int);
     889signed __int128 __atomic_fetch_or_16(volatile signed __int128 *, signed __int128, int);
    617890unsigned __int128 __atomic_fetch_or   (volatile unsigned __int128 *, unsigned __int128, int);
     891unsigned __int128 __atomic_fetch_or_16(volatile unsigned __int128 *, unsigned __int128, int);
    618892#endif
    619893
  • libcfa/src/Makefile.am

    r2fa5bd2 raca6a54c  
    3333# The built sources must not depend on the installed headers
    3434AM_CFAFLAGS = -quiet -cfalib -I$(srcdir)/stdhdr $(if $(findstring ${gdbwaittarget}, ${@}), -XCFA --gdb) @CONFIG_CFAFLAGS@
    35 AM_CFLAGS = -g -Wall -Wno-unused-function -fPIC -pthread @ARCH_FLAGS@ @CONFIG_CFLAGS@
     35AM_CFLAGS = -g -Wall -Wno-unused-function -fPIC @ARCH_FLAGS@ @CONFIG_CFLAGS@
    3636AM_CCASFLAGS = -g -Wall -Wno-unused-function @ARCH_FLAGS@ @CONFIG_CFLAGS@
    3737CFACC = @CFACC@
  • libcfa/src/Makefile.in

    r2fa5bd2 raca6a54c  
    416416LTCFACOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
    417417        $(LIBTOOLFLAGS) --mode=compile $(CFACC) $(DEFS) \
    418         $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(AM_CFLAGS) $(CFAFLAGS) $(CFLAGS)
     418        $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(CFAFLAGS) \
     419        $(AM_CFLAGS) $(CFLAGS)
    419420
    420421AM_V_CFA = $(am__v_CFA_@AM_V@)
     
    444445# The built sources must not depend on the installed headers
    445446AM_CFAFLAGS = -quiet -cfalib -I$(srcdir)/stdhdr $(if $(findstring ${gdbwaittarget}, ${@}), -XCFA --gdb) @CONFIG_CFAFLAGS@
    446 AM_CFLAGS = -g -Wall -Wno-unused-function -fPIC -pthread @ARCH_FLAGS@ @CONFIG_CFLAGS@
     447AM_CFLAGS = -g -Wall -Wno-unused-function -fPIC @ARCH_FLAGS@ @CONFIG_CFLAGS@
    447448AM_CCASFLAGS = -g -Wall -Wno-unused-function @ARCH_FLAGS@ @CONFIG_CFLAGS@
    448449@BUILDLIB_FALSE@headers_nosrc =
  • libcfa/src/assert.cfa

    r2fa5bd2 raca6a54c  
    1010// Created On       : Mon Nov 28 12:27:26 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Nov 21 17:09:26 2019
    13 // Update Count     : 5
     12// Last Modified On : Thu Jul 20 15:10:26 2017
     13// Update Count     : 2
    1414//
    1515
     
    1717#include <stdarg.h>                                                             // varargs
    1818#include <stdio.h>                                                              // fprintf
    19 #include <unistd.h>                                                             // STDERR_FILENO
    2019#include "bits/debug.hfa"
    2120
     
    2726        // called by macro assert in assert.h
    2827        void __assert_fail( const char *assertion, const char *file, unsigned int line, const char *function ) {
    29                 __cfaabi_bits_print_safe( STDERR_FILENO, CFA_ASSERT_FMT ".\n", assertion, __progname, function, line, file );
     28                __cfaabi_dbg_bits_print_safe( CFA_ASSERT_FMT ".\n", assertion, __progname, function, line, file );
    3029                abort();
    3130        }
     
    3332        // called by macro assertf
    3433        void __assert_fail_f( const char *assertion, const char *file, unsigned int line, const char *function, const char *fmt, ... ) {
    35                 __cfaabi_bits_acquire();
    36                 __cfaabi_bits_print_nolock( STDERR_FILENO, CFA_ASSERT_FMT ": ", assertion, __progname, function, line, file );
     34                __cfaabi_dbg_bits_acquire();
     35                __cfaabi_dbg_bits_print_nolock( CFA_ASSERT_FMT ": ", assertion, __progname, function, line, file );
    3736
    3837                va_list args;
    3938                va_start( args, fmt );
    40                 __cfaabi_bits_print_vararg( STDERR_FILENO, fmt, args );
     39                __cfaabi_dbg_bits_print_vararg( fmt, args );
    4140                va_end( args );
    4241
    43                 __cfaabi_bits_print_nolock( STDERR_FILENO, "\n" );
    44                 __cfaabi_bits_release();
     42                __cfaabi_dbg_bits_print_nolock( "\n" );
     43                __cfaabi_dbg_bits_release();
    4544                abort();
    4645        }
  • libcfa/src/bits/align.hfa

    r2fa5bd2 raca6a54c  
    1010// Created On       : Mon Nov 28 12:27:26 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Nov 16 18:58:22 2019
    13 // Update Count     : 3
     12// Last Modified On : Fri Jul 21 23:05:35 2017
     13// Update Count     : 2
    1414//
    1515// This  library is free  software; you  can redistribute  it and/or  modify it
     
    3333
    3434// Minimum size used to align memory boundaries for memory allocations.
    35 //#define libAlign() (sizeof(double))
    36 // gcc-7 uses xmms instructions, which require 16 byte alignment.
    37 #define libAlign() (16)
     35#define libAlign() (sizeof(double))
    3836
    3937// Check for power of 2
  • libcfa/src/bits/debug.cfa

    r2fa5bd2 raca6a54c  
    1010// Created On       : Thu Mar 30 12:30:01 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Nov 21 17:16:30 2019
    13 // Update Count     : 10
     12// Last Modified On : Sun Jul 14 22:17:35 2019
     13// Update Count     : 4
    1414//
    1515
     
    2828extern "C" {
    2929
    30         void __cfaabi_bits_write( int fd, const char *in_buffer, int len ) {
     30        void __cfaabi_dbg_bits_write( const char *in_buffer, int len ) {
    3131                // ensure all data is written
    3232                for ( int count = 0, retcode; count < len; count += retcode ) {
     
    3434
    3535                        for ( ;; ) {
    36                                 retcode = write( fd, in_buffer, len - count );
     36                                retcode = write( STDERR_FILENO, in_buffer, len - count );
    3737
    3838                                // not a timer interrupt ?
     
    4444        }
    4545
    46         void __cfaabi_bits_acquire() __attribute__((__weak__)) {}
    47         void __cfaabi_bits_release() __attribute__((__weak__)) {}
     46        void __cfaabi_dbg_bits_acquire() __attribute__((__weak__)) {}
     47        void __cfaabi_dbg_bits_release() __attribute__((__weak__)) {}
    4848
    49         void __cfaabi_bits_print_safe  ( int fd, const char fmt[], ... ) __attribute__(( format(printf, 2, 3) )) {
     49        void __cfaabi_dbg_bits_print_safe  ( const char fmt[], ... ) __attribute__(( format(printf, 1, 2) )) {
    5050                va_list args;
    5151
    5252                va_start( args, fmt );
    53                 __cfaabi_bits_acquire();
     53                __cfaabi_dbg_bits_acquire();
    5454
    5555                int len = vsnprintf( buffer, buffer_size, fmt, args );
    56                 __cfaabi_bits_write( fd, buffer, len );
     56                __cfaabi_dbg_bits_write( buffer, len );
    5757
    58                 __cfaabi_bits_release();
     58                __cfaabi_dbg_bits_release();
    5959                va_end( args );
    6060        }
    6161
    62         void __cfaabi_bits_print_nolock( int fd, const char fmt[], ... ) __attribute__(( format(printf, 2, 3) )) {
     62        void __cfaabi_dbg_bits_print_nolock( const char fmt[], ... ) __attribute__(( format(printf, 1, 2) )) {
    6363                va_list args;
    6464
     
    6666
    6767                int len = vsnprintf( buffer, buffer_size, fmt, args );
    68                 __cfaabi_bits_write( fd, buffer, len );
     68                __cfaabi_dbg_bits_write( buffer, len );
    6969
    7070                va_end( args );
    7171        }
    7272
    73         void __cfaabi_bits_print_vararg( int fd, const char fmt[], va_list args ) {
     73        void __cfaabi_dbg_bits_print_vararg( const char fmt[], va_list args ) {
    7474                int len = vsnprintf( buffer, buffer_size, fmt, args );
    75                 __cfaabi_bits_write( fd, buffer, len );
     75                __cfaabi_dbg_bits_write( buffer, len );
    7676        }
    7777
    78         void __cfaabi_bits_print_buffer( int fd, char in_buffer[], int in_buffer_size, const char fmt[], ... ) __attribute__(( format(printf, 4, 5) )) {
     78        void __cfaabi_dbg_bits_print_buffer( char in_buffer[], int in_buffer_size, const char fmt[], ... ) __attribute__(( format(printf, 3, 4) )) {
    7979                va_list args;
    8080
     
    8282
    8383                int len = vsnprintf( in_buffer, in_buffer_size, fmt, args );
    84                 __cfaabi_bits_write( fd, in_buffer, len );
     84                __cfaabi_dbg_bits_write( in_buffer, len );
    8585
    8686                va_end( args );
  • libcfa/src/bits/debug.hfa

    r2fa5bd2 raca6a54c  
    1010// Created On       : Mon Nov 28 12:27:26 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Nov 21 17:06:58 2019
    13 // Update Count     : 8
     12// Last Modified On : Thu Feb  8 12:35:19 2018
     13// Update Count     : 2
    1414//
    1515
     
    3838        #include <stdio.h>
    3939
    40         extern void __cfaabi_bits_write( int fd, const char *buffer, int len );
    41         extern void __cfaabi_bits_acquire();
    42         extern void __cfaabi_bits_release();
    43         extern void __cfaabi_bits_print_safe  ( int fd, const char fmt[], ... ) __attribute__(( format(printf, 2, 3) ));
    44         extern void __cfaabi_bits_print_nolock( int fd, const char fmt[], ... ) __attribute__(( format(printf, 2, 3) ));
    45         extern void __cfaabi_bits_print_vararg( int fd, const char fmt[], va_list arg );
    46         extern void __cfaabi_bits_print_buffer( int fd, char buffer[], int buffer_size, const char fmt[], ... ) __attribute__(( format(printf, 4, 5) ));
     40      extern void __cfaabi_dbg_bits_write( const char *buffer, int len );
     41      extern void __cfaabi_dbg_bits_acquire();
     42      extern void __cfaabi_dbg_bits_release();
     43      extern void __cfaabi_dbg_bits_print_safe  ( const char fmt[], ... ) __attribute__(( format(printf, 1, 2) ));
     44      extern void __cfaabi_dbg_bits_print_nolock( const char fmt[], ... ) __attribute__(( format(printf, 1, 2) ));
     45      extern void __cfaabi_dbg_bits_print_vararg( const char fmt[], va_list arg );
     46      extern void __cfaabi_dbg_bits_print_buffer( char buffer[], int buffer_size, const char fmt[], ... ) __attribute__(( format(printf, 3, 4) ));
    4747#ifdef __cforall
    4848}
     
    5050
    5151#ifdef __CFA_DEBUG_PRINT__
    52         #define __cfaabi_dbg_write( buffer, len )         __cfaabi_bits_write( STDERR_FILENO, buffer, len )
    53         #define __cfaabi_dbg_acquire()                    __cfaabi_bits_acquire()
    54         #define __cfaabi_dbg_release()                    __cfaabi_bits_release()
    55         #define __cfaabi_dbg_print_safe(...)              __cfaabi_bits_print_safe   (__VA_ARGS__)
    56         #define __cfaabi_dbg_print_nolock(...)            __cfaabi_bits_print_nolock (__VA_ARGS__)
    57         #define __cfaabi_dbg_print_buffer(...)            __cfaabi_bits_print_buffer (__VA_ARGS__)
    58         #define __cfaabi_dbg_print_buffer_decl(...)       char __dbg_text[256]; int __dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __cfaabi_bits_write( __dbg_text, __dbg_len );
    59         #define __cfaabi_dbg_print_buffer_local(...)      __dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __cfaabi_dbg_write( __dbg_text, __dbg_len );
     52        #define __cfaabi_dbg_write( buffer, len )         __cfaabi_dbg_bits_write( buffer, len )
     53        #define __cfaabi_dbg_acquire()                    __cfaabi_dbg_bits_acquire()
     54        #define __cfaabi_dbg_release()                    __cfaabi_dbg_bits_release()
     55        #define __cfaabi_dbg_print_safe(...)              __cfaabi_dbg_bits_print_safe   (__VA_ARGS__)
     56        #define __cfaabi_dbg_print_nolock(...)            __cfaabi_dbg_bits_print_nolock (__VA_ARGS__)
     57        #define __cfaabi_dbg_print_buffer(...)            __cfaabi_dbg_bits_print_buffer (__VA_ARGS__)
     58        #define __cfaabi_dbg_print_buffer_decl(...)       char __dbg_text[256]; int __dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __cfaabi_dbg_bits_write( __dbg_text, __dbg_len );
     59        #define __cfaabi_dbg_print_buffer_local(...)      __dbg_len = snprintf( __dbg_text, 256, __VA_ARGS__ ); __cfaabi_dbg_bits_write( __dbg_text, __dbg_len );
    6060#else
    6161        #define __cfaabi_dbg_write(...)               ((void)0)
  • libcfa/src/bits/defs.hfa

    r2fa5bd2 raca6a54c  
    4747#define OPTIONAL_THREAD __attribute__((weak))
    4848#endif
    49 
    50 static inline long long rdtscl(void) {
    51     unsigned int lo, hi;
    52     __asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi));
    53     return ( (unsigned long long)lo)|( ((unsigned long long)hi)<<32 );
    54 }
  • libcfa/src/concurrency/alarm.cfa

    r2fa5bd2 raca6a54c  
    1010// Created On       : Fri Jun 2 11:31:25 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Dec  3 22:47:24 2019
    13 // Update Count     : 68
     12// Last Modified On : Fri May 25 06:25:47 2018
     13// Update Count     : 67
    1414//
    1515
     
    4040void __kernel_set_timer( Duration alarm ) {
    4141        verifyf(alarm >= 1`us || alarm == 0, "Setting timer to < 1us (%jins)", alarm.tv);
    42         setitimer( ITIMER_REAL, &(itimerval){ alarm }, 0p );
     42        setitimer( ITIMER_REAL, &(itimerval){ alarm }, NULL );
    4343}
    4444
     
    113113                        this->tail = &this->head;
    114114                }
    115                 head->next = 0p;
     115                head->next = NULL;
    116116        }
    117117        verify( validate( this ) );
     
    127127                this->tail = it;
    128128        }
    129         n->next = 0p;
     129        n->next = NULL;
    130130
    131131        verify( validate( this ) );
  • libcfa/src/concurrency/coroutine.cfa

    r2fa5bd2 raca6a54c  
    1010// Created On       : Mon Nov 28 12:27:26 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Dec  5 14:37:29 2019
    13 // Update Count     : 15
     12// Last Modified On : Fri Mar 30 17:20:57 2018
     13// Update Count     : 9
    1414//
    1515
     
    9090
    9191void ?{}( coroutine_desc & this, const char * name, void * storage, size_t storageSize ) with( this ) {
    92         (this.context){0p, 0p};
     92        (this.context){NULL, NULL};
    9393        (this.stack){storage, storageSize};
    9494        this.name = name;
    9595        state = Start;
    96         starter = 0p;
    97         last = 0p;
    98         cancellation = 0p;
     96        starter = NULL;
     97        last = NULL;
     98        cancellation = NULL;
    9999}
    100100
     
    131131
    132132[void *, size_t] __stack_alloc( size_t storageSize ) {
    133         const size_t stack_data_size = libCeiling( sizeof(__stack_t), 16 ); // minimum alignment
     133        static const size_t stack_data_size = libCeiling( sizeof(__stack_t), 16 ); // minimum alignment
    134134        assert(__page_size != 0l);
    135135        size_t size = libCeiling( storageSize, 16 ) + stack_data_size;
     
    157157
    158158void __stack_prepare( __stack_info_t * this, size_t create_size ) {
    159         const size_t stack_data_size = libCeiling( sizeof(__stack_t), 16 ); // minimum alignment
     159        static const size_t stack_data_size = libCeiling( sizeof(__stack_t), 16 ); // minimum alignment
    160160        bool userStack;
    161161        void * storage;
  • libcfa/src/concurrency/coroutine.hfa

    r2fa5bd2 raca6a54c  
    1010// Created On       : Mon Nov 28 12:27:26 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Dec  3 22:47:58 2019
    13 // Update Count     : 10
     12// Last Modified On : Fri Jun 21 17:49:39 2019
     13// Update Count     : 9
    1414//
    1515
     
    3838void ^?{}( coroutine_desc & this );
    3939
    40 static inline void ?{}( coroutine_desc & this)                                       { this{ "Anonymous Coroutine", 0p, 0 }; }
    41 static inline void ?{}( coroutine_desc & this, size_t stackSize)                     { this{ "Anonymous Coroutine", 0p, stackSize }; }
     40static inline void ?{}( coroutine_desc & this)                                       { this{ "Anonymous Coroutine", NULL, 0 }; }
     41static inline void ?{}( coroutine_desc & this, size_t stackSize)                     { this{ "Anonymous Coroutine", NULL, stackSize }; }
    4242static inline void ?{}( coroutine_desc & this, void * storage, size_t storageSize )  { this{ "Anonymous Coroutine", storage, storageSize }; }
    43 static inline void ?{}( coroutine_desc & this, const char * name)                    { this{ name, 0p, 0 }; }
    44 static inline void ?{}( coroutine_desc & this, const char * name, size_t stackSize ) { this{ name, 0p, stackSize }; }
     43static inline void ?{}( coroutine_desc & this, const char * name)                    { this{ name, NULL, 0 }; }
     44static inline void ?{}( coroutine_desc & this, const char * name, size_t stackSize ) { this{ name, NULL, stackSize }; }
    4545
    4646//-----------------------------------------------------------------------------
     
    8989        src->state = Active;
    9090
    91         if( unlikely(src->cancellation != 0p) ) {
     91        if( unlikely(src->cancellation != NULL) ) {
    9292                _CtxCoroutine_Unwind(src->cancellation, src);
    9393        }
     
    128128        coroutine_desc * dst = get_coroutine(cor);
    129129
    130         if( unlikely(dst->context.SP == 0p) ) {
     130        if( unlikely(dst->context.SP == NULL) ) {
    131131                __stack_prepare(&dst->stack, 65000);
    132132                CtxStart(&cor, CtxInvokeCoroutine);
  • libcfa/src/concurrency/invoke.h

    r2fa5bd2 raca6a54c  
    1010// Created On       : Tue Jan 17 12:27:26 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Dec  5 16:26:03 2019
    13 // Update Count     : 44
     12// Last Modified On : Sat Jun 22 18:19:13 2019
     13// Update Count     : 40
    1414//
    1515
     
    4646        #ifdef __cforall
    4747        extern "Cforall" {
    48                 extern __attribute__((aligned(128))) thread_local struct KernelThreadData {
     48                extern thread_local struct KernelThreadData {
    4949                        struct thread_desc    * volatile this_thread;
    5050                        struct processor      * volatile this_processor;
     
    5555                                volatile bool in_progress;
    5656                        } preemption_state;
    57 
    58                         uint32_t rand_seed;
    5957                } kernelTLS __attribute__ ((tls_model ( "initial-exec" )));
    6058        }
     
    207205
    208206                static inline void ?{}(__monitor_group_t & this) {
    209                         (this.data){0p};
     207                        (this.data){NULL};
    210208                        (this.size){0};
    211209                        (this.func){NULL};
  • libcfa/src/concurrency/kernel.cfa

    r2fa5bd2 raca6a54c  
    1010// Created On       : Tue Jan 17 12:27:26 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Dec  5 16:25:52 2019
    13 // Update Count     : 52
     12// Last Modified On : Thu Jun 20 17:21:23 2019
     13// Update Count     : 25
    1414//
    1515
     
    2626#include <signal.h>
    2727#include <unistd.h>
    28 #include <limits.h>                                                                             // PTHREAD_STACK_MIN
    29 #include <sys/mman.h>                                                                   // mprotect
    3028}
    3129
     
    4240//-----------------------------------------------------------------------------
    4341// Some assembly required
    44 #if defined( __i386 )
     42#if   defined( __i386 )
    4543        #define CtxGet( ctx )        \
    4644                __asm__ volatile (     \
     
    125123
    126124extern "C" {
    127         struct { __dllist_t(cluster) list; __spinlock_t lock; } __cfa_dbg_global_clusters;
     125struct { __dllist_t(cluster) list; __spinlock_t lock; } __cfa_dbg_global_clusters;
    128126}
    129127
     
    133131// Global state
    134132thread_local struct KernelThreadData kernelTLS __attribute__ ((tls_model ( "initial-exec" ))) = {
    135         NULL,                                                                                           // cannot use 0p
    136133        NULL,
    137         { 1, false, false },
    138         6u //this should be seeded better but due to a bug calling rdtsc doesn't work
     134        NULL,
     135        { 1, false, false }
    139136};
    140137
     
    142139// Struct to steal stack
    143140struct current_stack_info_t {
    144         __stack_t * storage;                                                            // pointer to stack object
    145         void * base;                                                                            // base of stack
    146         void * limit;                                                                           // stack grows towards stack limit
    147         void * context;                                                                         // address of cfa_context_t
     141        __stack_t * storage;            // pointer to stack object
     142        void *base;                             // base of stack
     143        void *limit;                    // stack grows towards stack limit
     144        void *context;                  // address of cfa_context_t
    148145};
    149146
     
    174171        name = "Main Thread";
    175172        state = Start;
    176         starter = 0p;
    177         last = 0p;
    178         cancellation = 0p;
     173        starter = NULL;
     174        last = NULL;
     175        cancellation = NULL;
    179176}
    180177
     
    187184        self_mon.recursion = 1;
    188185        self_mon_p = &self_mon;
    189         next = 0p;
    190 
    191         node.next = 0p;
    192         node.prev = 0p;
     186        next = NULL;
     187
     188        node.next = NULL;
     189        node.prev = NULL;
    193190        doregister(curr_cluster, this);
    194191
     
    214211        terminated{ 0 };
    215212        do_terminate = false;
    216         preemption_alarm = 0p;
     213        preemption_alarm = NULL;
    217214        pending_preemption = false;
    218215        runner.proc = &this;
     
    234231        }
    235232
    236         pthread_join( kernel_thread, 0p );
    237         free( this.stack );
     233        pthread_join( kernel_thread, NULL );
    238234}
    239235
     
    264260//Main of the processor contexts
    265261void main(processorCtx_t & runner) {
    266         // Because of a bug, we couldn't initialized the seed on construction
    267         // Do it here
    268         kernelTLS.rand_seed ^= rdtscl();
    269 
    270262        processor * this = runner.proc;
    271263        verify(this);
     
    281273                __cfaabi_dbg_print_safe("Kernel : core %p started\n", this);
    282274
    283                 thread_desc * readyThread = 0p;
    284                 for( unsigned int spin_count = 0; ! __atomic_load_n(&this->do_terminate, __ATOMIC_SEQ_CST); spin_count++ ) {
     275                thread_desc * readyThread = NULL;
     276                for( unsigned int spin_count = 0; ! __atomic_load_n(&this->do_terminate, __ATOMIC_SEQ_CST); spin_count++ )
     277                {
    285278                        readyThread = nextThread( this->cltr );
    286279
    287                         if(readyThread) {
     280                        if(readyThread)
     281                        {
    288282                                verify( ! kernelTLS.preemption_state.enabled );
    289283
     
    296290
    297291                                spin_count = 0;
    298                         } else {
     292                        }
     293                        else
     294                        {
    299295                                // spin(this, &spin_count);
    300296                                halt(this);
     
    409405        processor * proc = (processor *) arg;
    410406        kernelTLS.this_processor = proc;
    411         kernelTLS.this_thread    = 0p;
     407        kernelTLS.this_thread    = NULL;
    412408        kernelTLS.preemption_state.[enabled, disable_count] = [false, 1];
    413409        // SKULLDUGGERY: We want to create a context for the processor coroutine
     
    422418
    423419        //Set global state
    424         kernelTLS.this_thread = 0p;
     420        kernelTLS.this_thread    = NULL;
    425421
    426422        //We now have a proper context from which to schedule threads
     
    438434        __cfaabi_dbg_print_safe("Kernel : core %p main ended (%p)\n", proc, &proc->runner);
    439435
    440         return 0p;
    441 }
    442 
    443 static void Abort( int ret, const char * func ) {
    444         if ( ret ) {                                                                            // pthread routines return errno values
    445                 abort( "%s : internal error, error(%d) %s.", func, ret, strerror( ret ) );
    446         } // if
    447 } // Abort
    448 
    449 void * create_pthread( pthread_t * pthread, void * (*start)(void *), void * arg ) {
    450         pthread_attr_t attr;
    451 
    452         Abort( pthread_attr_init( &attr ), "pthread_attr_init" ); // initialize attribute
    453 
    454         size_t stacksize;
    455         // default stack size, normally defined by shell limit
    456         Abort( pthread_attr_getstacksize( &attr, &stacksize ), "pthread_attr_getstacksize" );
    457         assert( stacksize >= PTHREAD_STACK_MIN );
    458 
    459         void * stack;
    460         __cfaabi_dbg_debug_do(
    461                 stack = memalign( __page_size, stacksize + __page_size );
    462                 // pthread has no mechanism to create the guard page in user supplied stack.
    463                 if ( mprotect( stack, __page_size, PROT_NONE ) == -1 ) {
    464                         abort( "mprotect : internal error, mprotect failure, error(%d) %s.", errno, strerror( errno ) );
    465                 } // if
    466         );
    467         __cfaabi_dbg_no_debug_do(
    468                 stack = malloc( stacksize );
    469         );
    470 
    471         Abort( pthread_attr_setstack( &attr, stack, stacksize ), "pthread_attr_setstack" );
    472 
    473         Abort( pthread_create( pthread, &attr, start, arg ), "pthread_create" );
    474         return stack;
     436        return NULL;
    475437}
    476438
     
    478440        __cfaabi_dbg_print_safe("Kernel : Starting core %p\n", this);
    479441
    480         this->stack = create_pthread( &this->kernel_thread, CtxInvokeProcessor, (void *)this );
     442        pthread_create( &this->kernel_thread, NULL, CtxInvokeProcessor, (void*)this );
    481443
    482444        __cfaabi_dbg_print_safe("Kernel : core %p started\n", this);
     
    535497        verify( ! kernelTLS.preemption_state.enabled );
    536498
    537         verifyf( thrd->next == 0p, "Expected null got %p", thrd->next );
     499        verifyf( thrd->next == NULL, "Expected null got %p", thrd->next );
    538500
    539501        with( *thrd->curr_cluster ) {
     
    714676        void ?{}(processorCtx_t & this, processor * proc) {
    715677                (this.__cor){ "Processor" };
    716                 this.__cor.starter = 0p;
     678                this.__cor.starter = NULL;
    717679                this.proc = proc;
    718680        }
     
    723685                terminated{ 0 };
    724686                do_terminate = false;
    725                 preemption_alarm = 0p;
     687                preemption_alarm = NULL;
    726688                pending_preemption = false;
    727689                kernel_thread = pthread_self();
     
    857819        if(thrd) {
    858820                int len = snprintf( abort_text, abort_text_size, "Error occurred while executing thread %.256s (%p)", thrd->self_cor.name, thrd );
    859                 __cfaabi_bits_write( STDERR_FILENO, abort_text, len );
     821                __cfaabi_dbg_bits_write( abort_text, len );
    860822
    861823                if ( &thrd->self_cor != thrd->curr_cor ) {
    862824                        len = snprintf( abort_text, abort_text_size, " in coroutine %.256s (%p).\n", thrd->curr_cor->name, thrd->curr_cor );
    863                         __cfaabi_bits_write( STDERR_FILENO, abort_text, len );
     825                        __cfaabi_dbg_bits_write( abort_text, len );
    864826                }
    865827                else {
    866                         __cfaabi_bits_write( STDERR_FILENO, ".\n", 2 );
     828                        __cfaabi_dbg_bits_write( ".\n", 2 );
    867829                }
    868830        }
    869831        else {
    870832                int len = snprintf( abort_text, abort_text_size, "Error occurred outside of any thread.\n" );
    871                 __cfaabi_bits_write( STDERR_FILENO, abort_text, len );
     833                __cfaabi_dbg_bits_write( abort_text, len );
    872834        }
    873835}
     
    880842
    881843extern "C" {
    882         void __cfaabi_bits_acquire() {
     844        void __cfaabi_dbg_bits_acquire() {
    883845                lock( kernel_debug_lock __cfaabi_dbg_ctx2 );
    884846        }
    885847
    886         void __cfaabi_bits_release() {
     848        void __cfaabi_dbg_bits_release() {
    887849                unlock( kernel_debug_lock );
    888850        }
     
    917879
    918880void V(semaphore & this) with( this ) {
    919         thread_desc * thrd = 0p;
     881        thread_desc * thrd = NULL;
    920882        lock( lock __cfaabi_dbg_ctx2 );
    921883        count += 1;
  • libcfa/src/concurrency/kernel.hfa

    r2fa5bd2 raca6a54c  
    1010// Created On       : Tue Jan 17 12:27:26 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Dec  4 07:54:51 2019
    13 // Update Count     : 18
     12// Last Modified On : Sat Jun 22 11:39:17 2019
     13// Update Count     : 16
    1414//
    1515
     
    2020#include "invoke.h"
    2121#include "time_t.hfa"
    22 #include "coroutine.hfa"
    2322
    2423extern "C" {
     
    8988static inline void ?{}(FinishAction & this) {
    9089        this.action_code = No_Action;
    91         this.thrd = 0p;
    92         this.lock = 0p;
     90        this.thrd = NULL;
     91        this.lock = NULL;
    9392}
    9493static inline void ^?{}(FinishAction &) {}
     
    135134        semaphore terminated;
    136135
    137         // pthread Stack
    138         void * stack;
    139 
    140136        // Link lists fields
    141137        struct __dbg_node_proc {
  • libcfa/src/concurrency/kernel_private.hfa

    r2fa5bd2 raca6a54c  
    1010// Created On       : Mon Feb 13 12:27:26 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Nov 30 19:25:02 2019
    13 // Update Count     : 8
     12// Last Modified On : Thu Mar 29 14:06:40 2018
     13// Update Count     : 3
    1414//
    1515
     
    5757void main(processorCtx_t *);
    5858
    59 void * create_pthread( pthread_t *, void * (*)(void *), void * );
    60 
    6159static inline void wake_fast(processor * this) {
    6260        __cfaabi_dbg_print_safe("Kernel : Waking up processor %p\n", this);
     
    103101#define KERNEL_STORAGE(T,X) static char storage_##X[sizeof(T)]
    104102
    105 static inline uint32_t tls_rand() {
    106         kernelTLS.rand_seed ^= kernelTLS.rand_seed << 6;
    107         kernelTLS.rand_seed ^= kernelTLS.rand_seed >> 21;
    108         kernelTLS.rand_seed ^= kernelTLS.rand_seed << 7;
    109         return kernelTLS.rand_seed;
    110 }
    111 
    112103
    113104void doregister( struct cluster & cltr );
  • libcfa/src/concurrency/monitor.cfa

    r2fa5bd2 raca6a54c  
    1010// Created On       : Thd Feb 23 12:27:26 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Dec  4 07:55:14 2019
    13 // Update Count     : 10
     12// Last Modified On : Fri Mar 30 14:30:26 2018
     13// Update Count     : 9
    1414//
    1515
     
    363363        this.waiting_thread = waiting_thread;
    364364        this.count = count;
    365         this.next = 0p;
     365        this.next = NULL;
    366366        this.user_info = user_info;
    367367}
     
    369369void ?{}(__condition_criterion_t & this ) with( this ) {
    370370        ready  = false;
    371         target = 0p;
    372         owner  = 0p;
    373         next   = 0p;
     371        target = NULL;
     372        owner  = NULL;
     373        next   = NULL;
    374374}
    375375
     
    378378        this.target = target;
    379379        this.owner  = &owner;
    380         this.next   = 0p;
     380        this.next   = NULL;
    381381}
    382382
     
    387387
    388388        // Check that everything is as expected
    389         assertf( this.monitors != 0p, "Waiting with no monitors (%p)", this.monitors );
     389        assertf( this.monitors != NULL, "Waiting with no monitors (%p)", this.monitors );
    390390        verifyf( this.monitor_count != 0, "Waiting with 0 monitors (%"PRIiFAST16")", this.monitor_count );
    391391        verifyf( this.monitor_count < 32u, "Excessive monitor count (%"PRIiFAST16")", this.monitor_count );
     
    449449
    450450        // Lock all monitors
    451         lock_all( this.monitors, 0p, count );
     451        lock_all( this.monitors, NULL, count );
    452452
    453453        //Pop the head of the waiting queue
     
    471471
    472472        //Check that everything is as expected
    473         verifyf( this.monitors != 0p, "Waiting with no monitors (%p)", this.monitors );
     473        verifyf( this.monitors != NULL, "Waiting with no monitors (%p)", this.monitors );
    474474        verifyf( this.monitor_count != 0, "Waiting with 0 monitors (%"PRIiFAST16")", this.monitor_count );
    475475
     
    674674
    675675static inline void reset_mask( monitor_desc * this ) {
    676         this->mask.accepted = 0p;
    677         this->mask.data = 0p;
     676        this->mask.accepted = NULL;
     677        this->mask.data = NULL;
    678678        this->mask.size = 0;
    679679}
     
    816816        }
    817817
    818         __cfaabi_dbg_print_safe( "Kernel :  Runing %i (%p)\n", ready2run, ready2run ? node->waiting_thread : 0p );
    819         return ready2run ? node->waiting_thread : 0p;
     818        __cfaabi_dbg_print_safe( "Kernel :  Runing %i (%p)\n", ready2run, ready2run ? node->waiting_thread : NULL );
     819        return ready2run ? node->waiting_thread : NULL;
    820820}
    821821
     
    824824        if( !this.monitors ) {
    825825                // __cfaabi_dbg_print_safe( "Branding\n" );
    826                 assertf( thrd->monitors.data != 0p, "No current monitor to brand condition %p", thrd->monitors.data );
     826                assertf( thrd->monitors.data != NULL, "No current monitor to brand condition %p", thrd->monitors.data );
    827827                this.monitor_count = thrd->monitors.size;
    828828
  • libcfa/src/concurrency/monitor.hfa

    r2fa5bd2 raca6a54c  
    1010// Created On       : Thd Feb 23 12:27:26 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Dec  4 07:55:32 2019
    13 // Update Count     : 11
     12// Last Modified On : Sat Oct  7 18:06:45 2017
     13// Update Count     : 10
    1414//
    1515
     
    3131        entry_queue{};
    3232        signal_stack{};
    33         owner         = 0p;
     33        owner         = NULL;
    3434        recursion     = 0;
    35         mask.accepted = 0p;
    36         mask.data     = 0p;
     35        mask.accepted = NULL;
     36        mask.data     = NULL;
    3737        mask.size     = 0;
    38         dtor_node     = 0p;
     38        dtor_node     = NULL;
    3939}
    40 
    41 static inline void ^?{}(monitor_desc & ) {}
    4240
    4341struct monitor_guard_t {
     
    122120
    123121static inline void ?{}( condition & this ) {
    124         this.monitors = 0p;
     122        this.monitors = NULL;
    125123        this.monitor_count = 0;
    126124}
  • libcfa/src/concurrency/mutex.cfa

    r2fa5bd2 raca6a54c  
    1111// Author           : Thierry Delisle
    1212// Created On       : Fri May 25 01:37:11 2018
    13 // Last Modified By : Peter A. Buhr
    14 // Last Modified On : Wed Dec  4 09:16:39 2019
    15 // Update Count     : 1
     13// Last Modified By : Thierry Delisle
     14// Last Modified On : Fri May 25 01:37:51 2018
     15// Update Count     : 0
    1616//
    1717
     
    7373        this.lock{};
    7474        this.blocked_threads{};
    75         this.owner = 0p;
     75        this.owner = NULL;
    7676        this.recursion_count = 0;
    7777}
     
    8383void lock(recursive_mutex_lock & this) with(this) {
    8484        lock( lock __cfaabi_dbg_ctx2 );
    85         if( owner == 0p ) {
     85        if( owner == NULL ) {
    8686                owner = kernelTLS.this_thread;
    8787                recursion_count = 1;
     
    101101        bool ret = false;
    102102        lock( lock __cfaabi_dbg_ctx2 );
    103         if( owner == 0p ) {
     103        if( owner == NULL ) {
    104104                owner = kernelTLS.this_thread;
    105105                recursion_count = 1;
  • libcfa/src/concurrency/mutex.hfa

    r2fa5bd2 raca6a54c  
    1111// Author           : Thierry Delisle
    1212// Created On       : Fri May 25 01:24:09 2018
    13 // Last Modified By : Peter A. Buhr
    14 // Last Modified On : Wed Dec  4 09:16:53 2019
    15 // Update Count     : 1
     13// Last Modified By : Thierry Delisle
     14// Last Modified On : Fri May 25 01:24:12 2018
     15// Update Count     : 0
    1616//
    1717
     
    110110
    111111        static inline void ?{}(lock_scope(L) & this) {
    112                 this.locks = 0p;
     112                this.locks = NULL;
    113113                this.count = 0;
    114114        }
  • libcfa/src/concurrency/preemption.cfa

    r2fa5bd2 raca6a54c  
    1010// Created On       : Mon Jun 5 14:20:42 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Dec  5 16:34:05 2019
    13 // Update Count     : 43
     12// Last Modified On : Tue Jun  5 17:35:49 2018
     13// Update Count     : 37
    1414//
    1515
     
    2424#include <string.h>
    2525#include <unistd.h>
    26 #include <limits.h>                                                                             // PTHREAD_STACK_MIN
    2726}
    2827
     
    6564event_kernel_t * event_kernel;                        // kernel public handle to even kernel
    6665static pthread_t alarm_thread;                        // pthread handle to alarm thread
    67 static void * alarm_stack;                                                        // pthread stack for alarm thread
    6866
    6967static void ?{}(event_kernel_t & this) with( this ) {
     
    8381// Get next expired node
    8482static inline alarm_node_t * get_expired( alarm_list_t * alarms, Time currtime ) {
    85         if( !alarms->head ) return 0p;                                          // If no alarms return null
    86         if( alarms->head->alarm >= currtime ) return 0p;        // If alarms head not expired return null
    87         return pop(alarms);                                                                     // Otherwise just pop head
     83        if( !alarms->head ) return NULL;                          // If no alarms return null
     84        if( alarms->head->alarm >= currtime ) return NULL;        // If alarms head not expired return null
     85        return pop(alarms);                                       // Otherwise just pop head
    8886}
    8987
    9088// Tick one frame of the Discrete Event Simulation for alarms
    9189static void tick_preemption() {
    92         alarm_node_t * node = 0p;                                                       // Used in the while loop but cannot be declared in the while condition
    93         alarm_list_t * alarms = &event_kernel->alarms;          // Local copy for ease of reading
    94         Time currtime = __kernel_get_time();                            // Check current time once so everything "happens at once"
     90        alarm_node_t * node = NULL;                     // Used in the while loop but cannot be declared in the while condition
     91        alarm_list_t * alarms = &event_kernel->alarms;  // Local copy for ease of reading
     92        Time currtime = __kernel_get_time();                    // Check current time once so we everything "happens at once"
    9593
    9694        //Loop throught every thing expired
     
    245243        sigaddset( &mask, sig );
    246244
    247         if ( pthread_sigmask( SIG_UNBLOCK, &mask, 0p ) == -1 ) {
     245        if ( pthread_sigmask( SIG_UNBLOCK, &mask, NULL ) == -1 ) {
    248246            abort( "internal error, pthread_sigmask" );
    249247        }
     
    256254        sigaddset( &mask, sig );
    257255
    258         if ( pthread_sigmask( SIG_BLOCK, &mask, 0p ) == -1 ) {
     256        if ( pthread_sigmask( SIG_BLOCK, &mask, NULL ) == -1 ) {
    259257            abort( "internal error, pthread_sigmask" );
    260258        }
     
    303301
    304302        // Setup proper signal handlers
    305         __cfaabi_sigaction( SIGUSR1, sigHandler_ctxSwitch, SA_SIGINFO | SA_RESTART ); // CtxSwitch handler
     303        __cfaabi_sigaction( SIGUSR1, sigHandler_ctxSwitch, SA_SIGINFO | SA_RESTART );         // CtxSwitch handler
    306304
    307305        signal_block( SIGALRM );
    308306
    309         alarm_stack = create_pthread( &alarm_thread, alarm_loop, 0p );
     307        pthread_create( &alarm_thread, NULL, alarm_loop, NULL );
    310308}
    311309
     
    318316        sigset_t mask;
    319317        sigfillset( &mask );
    320         sigprocmask( SIG_BLOCK, &mask, 0p );
     318        sigprocmask( SIG_BLOCK, &mask, NULL );
    321319
    322320        // Notify the alarm thread of the shutdown
     
    325323
    326324        // Wait for the preemption thread to finish
    327 
    328         pthread_join( alarm_thread, 0p );
    329         free( alarm_stack );
     325        pthread_join( alarm_thread, NULL );
    330326
    331327        // Preemption is now fully stopped
     
    384380        static_assert( sizeof( sigset_t ) == sizeof( cxt->uc_sigmask ), "Expected cxt->uc_sigmask to be of sigset_t" );
    385381        #endif
    386         if ( pthread_sigmask( SIG_SETMASK, (sigset_t *)&(cxt->uc_sigmask), 0p ) == -1 ) {
     382        if ( pthread_sigmask( SIG_SETMASK, (sigset_t *)&(cxt->uc_sigmask), NULL ) == -1 ) {
    387383                abort( "internal error, sigprocmask" );
    388384        }
     
    403399        sigset_t mask;
    404400        sigfillset(&mask);
    405         if ( pthread_sigmask( SIG_BLOCK, &mask, 0p ) == -1 ) {
     401        if ( pthread_sigmask( SIG_BLOCK, &mask, NULL ) == -1 ) {
    406402            abort( "internal error, pthread_sigmask" );
    407403        }
     
    424420                                        {__cfaabi_dbg_print_buffer_decl( " KERNEL: Spurious wakeup %d.\n", err );}
    425421                                        continue;
    426                                 case EINVAL :
     422                        case EINVAL :
    427423                                        abort( "Timeout was invalid." );
    428424                                default:
     
    457453EXIT:
    458454        __cfaabi_dbg_print_safe( "Kernel : Preemption thread stopping\n" );
    459         return 0p;
     455        return NULL;
    460456}
    461457
     
    470466        sigset_t oldset;
    471467        int ret;
    472         ret = pthread_sigmask(0, 0p, &oldset);
     468        ret = pthread_sigmask(0, NULL, &oldset);
    473469        if(ret != 0) { abort("ERROR sigprocmask returned %d", ret); }
    474470
  • libcfa/src/concurrency/thread.cfa

    r2fa5bd2 raca6a54c  
    1010// Created On       : Tue Jan 17 12:27:26 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Dec  4 09:17:49 2019
    13 // Update Count     : 9
     12// Last Modified On : Fri Mar 30 17:19:52 2018
     13// Update Count     : 8
    1414//
    1515
     
    3333// Thread ctors and dtors
    3434void ?{}(thread_desc & this, const char * const name, cluster & cl, void * storage, size_t storageSize ) with( this ) {
    35         context{ 0p, 0p };
     35        context{ NULL, NULL };
    3636        self_cor{ name, storage, storageSize };
    3737        state = Start;
     
    4141        self_mon_p = &self_mon;
    4242        curr_cluster = &cl;
    43         next = 0p;
     43        next = NULL;
    4444
    45         node.next = 0p;
    46         node.prev = 0p;
     45        node.next = NULL;
     46        node.prev = NULL;
    4747        doregister(curr_cluster, this);
    4848
  • libcfa/src/concurrency/thread.hfa

    r2fa5bd2 raca6a54c  
    1010// Created On       : Tue Jan 17 12:27:26 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Dec  4 09:18:14 2019
    13 // Update Count     : 6
     12// Last Modified On : Fri Jun 21 17:51:33 2019
     13// Update Count     : 5
    1414//
    1515
     
    6161void ^?{}(thread_desc & this);
    6262
    63 static inline void ?{}(thread_desc & this)                                                                  { this{ "Anonymous Thread", *mainCluster, 0p, 65000 }; }
    64 static inline void ?{}(thread_desc & this, size_t stackSize )                                               { this{ "Anonymous Thread", *mainCluster, 0p, stackSize }; }
     63static inline void ?{}(thread_desc & this)                                                                  { this{ "Anonymous Thread", *mainCluster, NULL, 65000 }; }
     64static inline void ?{}(thread_desc & this, size_t stackSize )                                               { this{ "Anonymous Thread", *mainCluster, NULL, stackSize }; }
    6565static inline void ?{}(thread_desc & this, void * storage, size_t storageSize )                             { this{ "Anonymous Thread", *mainCluster, storage, storageSize }; }
    66 static inline void ?{}(thread_desc & this, struct cluster & cl )                                            { this{ "Anonymous Thread", cl, 0p, 65000 }; }
    67 static inline void ?{}(thread_desc & this, struct cluster & cl, size_t stackSize )                          { this{ "Anonymous Thread", cl, 0p, stackSize }; }
     66static inline void ?{}(thread_desc & this, struct cluster & cl )                                            { this{ "Anonymous Thread", cl, NULL, 65000 }; }
     67static inline void ?{}(thread_desc & this, struct cluster & cl, size_t stackSize )                          { this{ "Anonymous Thread", cl, NULL, stackSize }; }
    6868static inline void ?{}(thread_desc & this, struct cluster & cl, void * storage, size_t storageSize )        { this{ "Anonymous Thread", cl, storage, storageSize }; }
    69 static inline void ?{}(thread_desc & this, const char * const name)                                         { this{ name, *mainCluster, 0p, 65000 }; }
    70 static inline void ?{}(thread_desc & this, const char * const name, struct cluster & cl )                   { this{ name, cl, 0p, 65000 }; }
    71 static inline void ?{}(thread_desc & this, const char * const name, struct cluster & cl, size_t stackSize ) { this{ name, cl, 0p, stackSize }; }
     69static inline void ?{}(thread_desc & this, const char * const name)                                         { this{ name, *mainCluster, NULL, 65000 }; }
     70static inline void ?{}(thread_desc & this, const char * const name, struct cluster & cl )                   { this{ name, cl, NULL, 65000 }; }
     71static inline void ?{}(thread_desc & this, const char * const name, struct cluster & cl, size_t stackSize ) { this{ name, cl, NULL, stackSize }; }
    7272
    7373//-----------------------------------------------------------------------------
  • libcfa/src/fstream.cfa

    r2fa5bd2 raca6a54c  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Nov 29 06:56:46 2019
    13 // Update Count     : 355
     12// Last Modified On : Tue Sep 10 22:19:56 2019
     13// Update Count     : 354
    1414//
    1515
     
    6666} // ?{}
    6767
    68 void ^?{}( ofstream & os ) {
    69         close( os );
    70 } // ^?{}
    71 
    7268void sepOn( ofstream & os ) { os.sepOnOff = ! getNL( os ); }
    7369void sepOff( ofstream & os ) { os.sepOnOff = false; }
     
    199195} // ?{}
    200196
    201 void ^?{}( ifstream & is ) {
    202         close( is );
    203 } // ^?{}
    204 
    205197void nlOn( ifstream & os ) { os.nlOnOff = true; }
    206198void nlOff( ifstream & os ) { os.nlOnOff = false; }
  • libcfa/src/fstream.hfa

    r2fa5bd2 raca6a54c  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Nov 29 06:56:02 2019
    13 // Update Count     : 168
     12// Last Modified On : Mon Jul 15 18:10:23 2019
     13// Update Count     : 167
    1414//
    1515
     
    7272void ?{}( ofstream & os, const char * name, const char * mode );
    7373void ?{}( ofstream & os, const char * name );
    74 void ^?{}( ofstream & os );
    7574
    7675extern ofstream & sout, & stdout, & serr, & stderr;             // aliases
     
    102101void ?{}( ifstream & is, const char * name, const char * mode );
    103102void ?{}( ifstream & is, const char * name );
    104 void ^?{}( ifstream & is );
    105103
    106104extern ifstream & sin, & stdin;                                                 // aliases
  • libcfa/src/heap.cfa

    r2fa5bd2 raca6a54c  
    1010// Created On       : Tue Dec 19 21:58:35 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Dec  4 21:42:46 2019
    13 // Update Count     : 646
     12// Last Modified On : Fri Oct 18 07:42:09 2019
     13// Update Count     : 556
    1414//
    1515
     
    1818#include <stdio.h>                                                                              // snprintf, fileno
    1919#include <errno.h>                                                                              // errno
    20 #include <string.h>                                                                             // memset, memcpy
    2120extern "C" {
    2221#include <sys/mman.h>                                                                   // mmap, munmap
     
    2827#include "bits/locks.hfa"                                                               // __spinlock_t
    2928#include "startup.hfa"                                                                  // STARTUP_PRIORITY_MEMORY
    30 //#include "stdlib.hfa"                                                                 // bsearchl
     29#include "stdlib.hfa"                                                                   // bsearchl
    3130#include "malloc.h"
    3231
    33 #define MIN(x, y) (y > x ? x : y)
    3432
    3533static bool traceHeap = false;
    3634
    37 inline bool traceHeap() { return traceHeap; }
     35inline bool traceHeap() {
     36        return traceHeap;
     37} // traceHeap
    3838
    3939bool traceHeapOn() {
     
    4949} // traceHeapOff
    5050
    51 bool traceHeapTerm() { return false; }
    52 
    53 
    54 static bool prtFree = false;
    55 
    56 inline bool prtFree() {
    57         return prtFree;
    58 } // prtFree
    59 
    60 bool prtFreeOn() {
    61         bool temp = prtFree;
    62         prtFree = true;
     51
     52static bool checkFree = false;
     53
     54inline bool checkFree() {
     55        return checkFree;
     56} // checkFree
     57
     58bool checkFreeOn() {
     59        bool temp = checkFree;
     60        checkFree = true;
    6361        return temp;
    64 } // prtFreeOn
    65 
    66 bool prtFreeOff() {
    67         bool temp = prtFree;
    68         prtFree = false;
     62} // checkFreeOn
     63
     64bool checkFreeOff() {
     65        bool temp = checkFree;
     66        checkFree = false;
    6967        return temp;
    70 } // prtFreeOff
     68} // checkFreeOff
     69
     70
     71// static bool traceHeapTerm = false;
     72
     73// inline bool traceHeapTerm() {
     74//      return traceHeapTerm;
     75// } // traceHeapTerm
     76
     77// bool traceHeapTermOn() {
     78//      bool temp = traceHeapTerm;
     79//      traceHeapTerm = true;
     80//      return temp;
     81// } // traceHeapTermOn
     82
     83// bool traceHeapTermOff() {
     84//      bool temp = traceHeapTerm;
     85//      traceHeapTerm = false;
     86//      return temp;
     87// } // traceHeapTermOff
    7188
    7289
    7390enum {
    74         // Define the default extension heap amount in units of bytes. When the uC++ supplied heap reaches the brk address,
    75         // the brk address is extended by the extension amount.
     91        __CFA_DEFAULT_MMAP_START__ = (512 * 1024 + 1),
    7692        __CFA_DEFAULT_HEAP_EXPANSION__ = (1 * 1024 * 1024),
    77 
    78         // Define the mmap crossover point during allocation. Allocations less than this amount are allocated from buckets;
    79         // values greater than or equal to this value are mmap from the operating system.
    80         __CFA_DEFAULT_MMAP_START__ = (512 * 1024 + 1),
    8193};
    8294
     
    93105static unsigned int allocFree;                                                  // running total of allocations minus frees
    94106
    95 static void prtUnfreed() {
     107static void checkUnfreed() {
    96108        if ( allocFree != 0 ) {
    97109                // DO NOT USE STREAMS AS THEY MAY BE UNAVAILABLE AT THIS POINT.
    98                 char helpText[512];
    99                 int len = snprintf( helpText, sizeof(helpText), "CFA warning (UNIX pid:%ld) : program terminating with %u(0x%x) bytes of storage allocated but not freed.\n"
    100                                                         "Possible cause is unfreed storage allocated by the program or system/library routines called from the program.\n",
    101                                                         (long int)getpid(), allocFree, allocFree ); // always print the UNIX pid
    102                 __cfaabi_bits_write( STDERR_FILENO, helpText, len ); // print debug/nodebug
    103         } // if
    104 } // prtUnfreed
     110                // char helpText[512];
     111                // int len = snprintf( helpText, sizeof(helpText), "CFA warning (UNIX pid:%ld) : program terminating with %u(0x%x) bytes of storage allocated but not freed.\n"
     112                //                                      "Possible cause is unfreed storage allocated by the program or system/library routines called from the program.\n",
     113                //                                      (long int)getpid(), allocFree, allocFree ); // always print the UNIX pid
     114                // __cfaabi_dbg_bits_write( helpText, len );
     115        } // if
     116} // checkUnfreed
    105117
    106118extern "C" {
     
    111123        void heapAppStop() {                                                            // called by __cfaabi_appready_startdown
    112124                fclose( stdin ); fclose( stdout );
    113                 prtUnfreed();
     125                checkUnfreed();
    114126        } // heapAppStop
    115127} // extern "C"
    116128#endif // __CFA_DEBUG__
    117 
    118129
    119130// statically allocated variables => zero filled.
     
    123134static unsigned int maxBucketsUsed;                                             // maximum number of buckets in use
    124135
     136
     137// #comment TD : This defined is significantly different from the __ALIGN__ define from locks.hfa
     138#define ALIGN 16
    125139
    126140#define SPINLOCK 0
     
    133147// Recursive definitions: HeapManager needs size of bucket array and bucket area needs sizeof HeapManager storage.
    134148// Break recusion by hardcoding number of buckets and statically checking number is correct after bucket array defined.
    135 enum { NoBucketSizes = 91 };                                                    // number of buckets sizes
     149enum { NoBucketSizes = 93 };                                                    // number of buckets sizes
    136150
    137151struct HeapManager {
     
    180194                        } kind; // Kind
    181195                } header; // Header
    182                 char pad[libAlign() - sizeof( Header )];
     196                char pad[ALIGN - sizeof( Header )];
    183197                char data[0];                                                                   // storage
    184198        }; // Storage
    185199
    186         static_assert( libAlign() >= sizeof( Storage ), "libAlign() < sizeof( Storage )" );
     200        static_assert( ALIGN >= sizeof( Storage ), "ALIGN < sizeof( Storage )" );
    187201
    188202        struct FreeHeader {
     
    214228#define __STATISTICS__
    215229
    216 // Bucket size must be multiple of 16.
    217230// Powers of 2 are common allocation sizes, so make powers of 2 generate the minimum required size.
    218231static const unsigned int bucketSizes[] @= {                    // different bucket sizes
    219         16, 32, 48, 64 + sizeof(HeapManager.Storage), // 4
    220         96, 112, 128 + sizeof(HeapManager.Storage), // 3
    221         160, 192, 224, 256 + sizeof(HeapManager.Storage), // 4
    222         320, 384, 448, 512 + sizeof(HeapManager.Storage), // 4
    223         640, 768, 896, 1_024 + sizeof(HeapManager.Storage), // 4
    224         1_536, 2_048 + sizeof(HeapManager.Storage), // 2
    225         2_560, 3_072, 3_584, 4_096 + sizeof(HeapManager.Storage), // 4
    226         6_144, 8_192 + sizeof(HeapManager.Storage), // 2
    227         9_216, 10_240, 11_264, 12_288, 13_312, 14_336, 15_360, 16_384 + sizeof(HeapManager.Storage), // 8
    228         18_432, 20_480, 22_528, 24_576, 26_624, 28_672, 30_720, 32_768 + sizeof(HeapManager.Storage), // 8
    229         36_864, 40_960, 45_056, 49_152, 53_248, 57_344, 61_440, 65_536 + sizeof(HeapManager.Storage), // 8
    230         73_728, 81_920, 90_112, 98_304, 106_496, 114_688, 122_880, 131_072 + sizeof(HeapManager.Storage), // 8
    231         147_456, 163_840, 180_224, 196_608, 212_992, 229_376, 245_760, 262_144 + sizeof(HeapManager.Storage), // 8
    232         294_912, 327_680, 360_448, 393_216, 425_984, 458_752, 491_520, 524_288 + sizeof(HeapManager.Storage), // 8
    233         655_360, 786_432, 917_504, 1_048_576 + sizeof(HeapManager.Storage), // 4
    234         1_179_648, 1_310_720, 1_441_792, 1_572_864, 1_703_936, 1_835_008, 1_966_080, 2_097_152 + sizeof(HeapManager.Storage), // 8
    235         2_621_440, 3_145_728, 3_670_016, 4_194_304 + sizeof(HeapManager.Storage), // 4
     232        16, 32, 48, 64,
     233        64 + sizeof(HeapManager.Storage), 96, 112, 128, 128 + sizeof(HeapManager.Storage), 160, 192, 224,
     234        256 + sizeof(HeapManager.Storage), 320, 384, 448, 512 + sizeof(HeapManager.Storage), 640, 768, 896,
     235        1_024 + sizeof(HeapManager.Storage), 1_536, 2_048 + sizeof(HeapManager.Storage), 2_560, 3_072, 3_584, 4_096 + sizeof(HeapManager.Storage), 6_144,
     236        8_192 + sizeof(HeapManager.Storage), 9_216, 10_240, 11_264, 12_288, 13_312, 14_336, 15_360,
     237        16_384 + sizeof(HeapManager.Storage), 18_432, 20_480, 22_528, 24_576, 26_624, 28_672, 30_720,
     238        32_768 + sizeof(HeapManager.Storage), 36_864, 40_960, 45_056, 49_152, 53_248, 57_344, 61_440,
     239        65_536 + sizeof(HeapManager.Storage), 73_728, 81_920, 90_112, 98_304, 106_496, 114_688, 122_880,
     240        131_072 + sizeof(HeapManager.Storage), 147_456, 163_840, 180_224, 196_608, 212_992, 229_376, 245_760,
     241        262_144 + sizeof(HeapManager.Storage), 294_912, 327_680, 360_448, 393_216, 425_984, 458_752, 491_520,
     242        524_288 + sizeof(HeapManager.Storage), 655_360, 786_432, 917_504, 1_048_576 + sizeof(HeapManager.Storage), 1_179_648, 1_310_720, 1_441_792,
     243        1_572_864, 1_703_936, 1_835_008, 1_966_080, 2_097_152 + sizeof(HeapManager.Storage), 2_621_440, 3_145_728, 3_670_016,
     244        4_194_304 + sizeof(HeapManager.Storage)
    236245};
    237246
     
    242251static unsigned char lookup[LookupSizes];                               // O(1) lookup for small sizes
    243252#endif // FASTLOOKUP
    244 
    245253static int mmapFd = -1;                                                                 // fake or actual fd for anonymous file
     254
     255
    246256#ifdef __CFA_DEBUG__
    247257static bool heapBoot = 0;                                                               // detect recursion during boot
     
    249259static HeapManager heapManager __attribute__(( aligned (128) )) @= {}; // size of cache line to prevent false sharing
    250260
     261// #comment TD : The return type of this function should be commented
     262static inline bool setMmapStart( size_t value ) {
     263  if ( value < pageSize || bucketSizes[NoBucketSizes - 1] < value ) return true;
     264        mmapStart = value;                                                                      // set global
     265
     266        // find the closest bucket size less than or equal to the mmapStart size
     267        maxBucketsUsed = bsearchl( (unsigned int)mmapStart, bucketSizes, NoBucketSizes ); // binary search
     268        assert( maxBucketsUsed < NoBucketSizes );                       // subscript failure ?
     269        assert( mmapStart <= bucketSizes[maxBucketsUsed] ); // search failure ?
     270        return false;
     271} // setMmapStart
     272
     273
     274static void ?{}( HeapManager & manager ) with ( manager ) {
     275        pageSize = sysconf( _SC_PAGESIZE );
     276
     277        for ( unsigned int i = 0; i < NoBucketSizes; i += 1 ) { // initialize the free lists
     278                freeLists[i].blockSize = bucketSizes[i];
     279        } // for
     280
     281        #ifdef FASTLOOKUP
     282        unsigned int idx = 0;
     283        for ( unsigned int i = 0; i < LookupSizes; i += 1 ) {
     284                if ( i > bucketSizes[idx] ) idx += 1;
     285                lookup[i] = idx;
     286        } // for
     287        #endif // FASTLOOKUP
     288
     289        if ( setMmapStart( default_mmap_start() ) ) {
     290                abort( "HeapManager : internal error, mmap start initialization failure." );
     291        } // if
     292        heapExpand = default_heap_expansion();
     293
     294        char * End = (char *)sbrk( 0 );
     295        sbrk( (char *)libCeiling( (long unsigned int)End, libAlign() ) - End ); // move start of heap to multiple of alignment
     296        heapBegin = heapEnd = sbrk( 0 );                                        // get new start point
     297} // HeapManager
     298
     299
     300static void ^?{}( HeapManager & ) {
     301        #ifdef __STATISTICS__
     302        // if ( traceHeapTerm() ) {
     303        //      printStats();
     304        //      if ( checkfree() ) checkFree( heapManager, true );
     305        // } // if
     306        #endif // __STATISTICS__
     307} // ~HeapManager
     308
     309
     310static void memory_startup( void ) __attribute__(( constructor( STARTUP_PRIORITY_MEMORY ) ));
     311void memory_startup( void ) {
     312        #ifdef __CFA_DEBUG__
     313        if ( unlikely( heapBoot ) ) {                                           // check for recursion during system boot
     314                // DO NOT USE STREAMS AS THEY MAY BE UNAVAILABLE AT THIS POINT.
     315                abort( "boot() : internal error, recursively invoked during system boot." );
     316        } // if
     317        heapBoot = true;
     318        #endif // __CFA_DEBUG__
     319
     320        //assert( heapManager.heapBegin != 0 );
     321        //heapManager{};
     322        if ( heapManager.heapBegin == 0 ) heapManager{};
     323} // memory_startup
     324
     325static void memory_shutdown( void ) __attribute__(( destructor( STARTUP_PRIORITY_MEMORY ) ));
     326void memory_shutdown( void ) {
     327        ^heapManager{};
     328} // memory_shutdown
     329
    251330
    252331#ifdef __STATISTICS__
    253 // Heap statistics counters.
    254 static unsigned long long int mmap_storage;
     332static unsigned long long int mmap_storage;                             // heap statistics counters
    255333static unsigned int mmap_calls;
    256334static unsigned long long int munmap_storage;
     
    270348static unsigned long long int realloc_storage;
    271349static unsigned int realloc_calls;
    272 // Statistics file descriptor (changed by malloc_stats_fd).
    273 static int statfd = STDERR_FILENO;                                              // default stderr
     350
     351static int statfd;                                                                              // statistics file descriptor (changed by malloc_stats_fd)
     352
    274353
    275354// Use "write" because streams may be shutdown when calls are made.
    276355static void printStats() {
    277356        char helpText[512];
    278         __cfaabi_bits_print_buffer( STDERR_FILENO, helpText, sizeof(helpText),
     357        __cfaabi_dbg_bits_print_buffer( helpText, sizeof(helpText),
    279358                                                                        "\nHeap statistics:\n"
    280359                                                                        "  malloc: calls %u / storage %llu\n"
     
    326405                                                sbrk_calls, sbrk_storage
    327406                );
    328         __cfaabi_bits_write( fileno( stream ), helpText, len ); // ensures all bytes written or exit
    329         return len;
     407        return write( fileno( stream ), helpText, len );        // -1 => error
    330408} // printStatsXML
    331409#endif // __STATISTICS__
    332 
    333410
    334411// #comment TD : Is this the samething as Out-of-Memory?
     
    341418
    342419static inline void checkAlign( size_t alignment ) {
    343         if ( alignment < libAlign() || ! libPow2( alignment ) ) {
    344                 abort( "Alignment %zu for memory allocation is less than %d and/or not a power of 2.", alignment, libAlign() );
     420        if ( alignment < sizeof(void *) || ! libPow2( alignment ) ) {
     421                abort( "Alignment %zu for memory allocation is less than sizeof(void *) and/or not a power of 2.", alignment );
    345422        } // if
    346423} // checkAlign
     
    354431
    355432
    356 // thunk problem
     433static inline void checkHeader( bool check, const char * name, void * addr ) {
     434        if ( unlikely( check ) ) {                                                      // bad address ?
     435                abort( "Attempt to %s storage %p with address outside the heap.\n"
     436                           "Possible cause is duplicate free on same block or overwriting of memory.",
     437                           name, addr );
     438        } // if
     439} // checkHeader
     440
     441// #comment TD : function should be commented and/or have a more evocative name
     442//               this isn't either a check or a constructor which is what I would expect this function to be
     443static inline void fakeHeader( HeapManager.Storage.Header *& header, size_t & size, size_t & alignment ) {
     444        if ( unlikely( (header->kind.fake.alignment & 1) == 1 ) ) { // fake header ?
     445                size_t offset = header->kind.fake.offset;
     446                alignment = header->kind.fake.alignment & -2;   // remove flag from value
     447                #ifdef __CFA_DEBUG__
     448                checkAlign( alignment );                                                // check alignment
     449                #endif // __CFA_DEBUG__
     450                header = (HeapManager.Storage.Header *)((char *)header - offset);
     451        } // if
     452} // fakeHeader
     453
     454// #comment TD : Why is this a define
     455#define headerAddr( addr ) ((HeapManager.Storage.Header *)( (char *)addr - sizeof(HeapManager.Storage) ))
     456
     457static inline bool headers( const char * name, void * addr, HeapManager.Storage.Header *& header, HeapManager.FreeHeader *& freeElem, size_t & size, size_t & alignment ) with ( heapManager ) {
     458        header = headerAddr( addr );
     459
     460        if ( unlikely( heapEnd < addr ) ) {                                     // mmapped ?
     461                fakeHeader( header, size, alignment );
     462                size = header->kind.real.blockSize & -3;                // mmap size
     463                return true;
     464        } // if
     465
     466        #ifdef __CFA_DEBUG__
     467        checkHeader( addr < heapBegin || header < (HeapManager.Storage.Header *)heapBegin, name, addr ); // bad low address ?
     468        #endif // __CFA_DEBUG__
     469
     470        // #comment TD : This code looks weird...
     471        //               It's called as the first statement of both branches of the last if, with the same parameters in all cases
     472
     473        // header may be safe to dereference
     474        fakeHeader( header, size, alignment );
     475        #ifdef __CFA_DEBUG__
     476        checkHeader( header < (HeapManager.Storage.Header *)heapBegin || (HeapManager.Storage.Header *)heapEnd < header, name, addr ); // bad address ? (offset could be + or -)
     477        #endif // __CFA_DEBUG__
     478
     479        freeElem = (HeapManager.FreeHeader *)((size_t)header->kind.real.home & -3);
     480        #ifdef __CFA_DEBUG__
     481        if ( freeElem < &freeLists[0] || &freeLists[NoBucketSizes] <= freeElem ) {
     482                abort( "Attempt to %s storage %p with corrupted header.\n"
     483                           "Possible cause is duplicate free on same block or overwriting of header information.",
     484                           name, addr );
     485        } // if
     486        #endif // __CFA_DEBUG__
     487        size = freeElem->blockSize;
     488        return false;
     489} // headers
     490
     491
     492static inline void * extend( size_t size ) with ( heapManager ) {
     493        lock( extlock __cfaabi_dbg_ctx2 );
     494        ptrdiff_t rem = heapRemaining - size;
     495        if ( rem < 0 ) {
     496                // If the size requested is bigger than the current remaining storage, increase the size of the heap.
     497
     498                size_t increase = libCeiling( size > heapExpand ? size : heapExpand, libAlign() );
     499                if ( sbrk( increase ) == (void *)-1 ) {
     500                        unlock( extlock );
     501                        errno = ENOMEM;
     502                        return 0;
     503                } // if
     504                #ifdef __STATISTICS__
     505                sbrk_calls += 1;
     506                sbrk_storage += increase;
     507                #endif // __STATISTICS__
     508                #ifdef __CFA_DEBUG__
     509                // Set new memory to garbage so subsequent uninitialized usages might fail.
     510                memset( (char *)heapEnd + heapRemaining, '\377', increase );
     511                #endif // __CFA_DEBUG__
     512                rem = heapRemaining + increase - size;
     513        } // if
     514
     515        HeapManager.Storage * block = (HeapManager.Storage *)heapEnd;
     516        heapRemaining = rem;
     517        heapEnd = (char *)heapEnd + size;
     518        unlock( extlock );
     519        return block;
     520} // extend
     521
     522
    357523size_t Bsearchl( unsigned int key, const unsigned int * vals, size_t dim ) {
    358524        size_t l = 0, m, h = dim;
     
    369535
    370536
    371 static inline bool setMmapStart( size_t value ) {               // true => mmapped, false => sbrk
    372   if ( value < pageSize || bucketSizes[NoBucketSizes - 1] < value ) return true;
    373         mmapStart = value;                                                                      // set global
    374 
    375         // find the closest bucket size less than or equal to the mmapStart size
    376         maxBucketsUsed = Bsearchl( (unsigned int)mmapStart, bucketSizes, NoBucketSizes ); // binary search
    377         assert( maxBucketsUsed < NoBucketSizes );                       // subscript failure ?
    378         assert( mmapStart <= bucketSizes[maxBucketsUsed] ); // search failure ?
    379         return false;
    380 } // setMmapStart
    381 
    382 
    383 static inline void checkHeader( bool check, const char * name, void * addr ) {
    384         if ( unlikely( check ) ) {                                                      // bad address ?
    385                 abort( "Attempt to %s storage %p with address outside the heap.\n"
    386                            "Possible cause is duplicate free on same block or overwriting of memory.",
    387                            name, addr );
    388         } // if
    389 } // checkHeader
    390 
    391 
    392 static inline void fakeHeader( HeapManager.Storage.Header *& header, size_t & alignment ) {
    393         if ( unlikely( (header->kind.fake.alignment & 1) == 1 ) ) { // fake header ?
    394                 size_t offset = header->kind.fake.offset;
    395                 alignment = header->kind.fake.alignment & -2;   // remove flag from value
    396                 #ifdef __CFA_DEBUG__
    397                 checkAlign( alignment );                                                // check alignment
    398                 #endif // __CFA_DEBUG__
    399                 header = (HeapManager.Storage.Header *)((char *)header - offset);
    400         } // if
    401 } // fakeHeader
    402 
    403 
    404 // <-------+----------------------------------------------------> bsize (bucket size)
    405 // |header |addr
    406 //==================================================================================
    407 //                                | alignment
    408 // <-----------------<------------+-----------------------------> bsize (bucket size)
    409 //                   |fake-header | addr
    410 #define headerAddr( addr ) ((HeapManager.Storage.Header *)( (char *)addr - sizeof(HeapManager.Storage) ))
    411 
    412 // <-------<<--------------------- dsize ---------------------->> bsize (bucket size)
    413 // |header |addr
    414 //==================================================================================
    415 //                                | alignment
    416 // <------------------------------<<---------- dsize --------->>> bsize (bucket size)
    417 //                   |fake-header |addr
    418 #define dataStorage( bsize, addr, header ) (bsize - ( (char *)addr - (char *)header ))
    419 
    420 
    421 static inline bool headers( const char * name __attribute__(( unused )), void * addr, HeapManager.Storage.Header *& header, HeapManager.FreeHeader *& freeElem, size_t & size, size_t & alignment ) with ( heapManager ) {
    422         header = headerAddr( addr );
    423 
    424         if ( unlikely( heapEnd < addr ) ) {                                     // mmapped ?
    425                 fakeHeader( header, alignment );
    426                 size = header->kind.real.blockSize & -3;                // mmap size
    427                 return true;
    428         } // if
    429 
    430         #ifdef __CFA_DEBUG__
    431         checkHeader( addr < heapBegin || header < (HeapManager.Storage.Header *)heapBegin, name, addr ); // bad low address ?
    432         #endif // __CFA_DEBUG__
    433 
    434         // header may be safe to dereference
    435         fakeHeader( header, alignment );
    436         #ifdef __CFA_DEBUG__
    437         checkHeader( header < (HeapManager.Storage.Header *)heapBegin || (HeapManager.Storage.Header *)heapEnd < header, name, addr ); // bad address ? (offset could be + or -)
    438         #endif // __CFA_DEBUG__
    439 
    440         freeElem = (HeapManager.FreeHeader *)((size_t)header->kind.real.home & -3);
    441         #ifdef __CFA_DEBUG__
    442         if ( freeElem < &freeLists[0] || &freeLists[NoBucketSizes] <= freeElem ) {
    443                 abort( "Attempt to %s storage %p with corrupted header.\n"
    444                            "Possible cause is duplicate free on same block or overwriting of header information.",
    445                            name, addr );
    446         } // if
    447         #endif // __CFA_DEBUG__
    448         size = freeElem->blockSize;
    449         return false;
    450 } // headers
    451 
    452 
    453 static inline void * extend( size_t size ) with ( heapManager ) {
    454         lock( extlock __cfaabi_dbg_ctx2 );
    455         ptrdiff_t rem = heapRemaining - size;
    456         if ( rem < 0 ) {
    457                 // If the size requested is bigger than the current remaining storage, increase the size of the heap.
    458 
    459                 size_t increase = libCeiling( size > heapExpand ? size : heapExpand, libAlign() );
    460                 if ( sbrk( increase ) == (void *)-1 ) {
    461                         unlock( extlock );
    462                         errno = ENOMEM;
    463                         return 0p;
    464                 } // if
    465                 #ifdef __STATISTICS__
    466                 sbrk_calls += 1;
    467                 sbrk_storage += increase;
    468                 #endif // __STATISTICS__
    469                 #ifdef __CFA_DEBUG__
    470                 // Set new memory to garbage so subsequent uninitialized usages might fail.
    471                 memset( (char *)heapEnd + heapRemaining, '\377', increase );
    472                 #endif // __CFA_DEBUG__
    473                 rem = heapRemaining + increase - size;
    474         } // if
    475 
    476         HeapManager.Storage * block = (HeapManager.Storage *)heapEnd;
    477         heapRemaining = rem;
    478         heapEnd = (char *)heapEnd + size;
    479         unlock( extlock );
    480         return block;
    481 } // extend
    482 
    483 
    484537static inline void * doMalloc( size_t size ) with ( heapManager ) {
    485538        HeapManager.Storage * block;                                            // pointer to new block of storage
     
    488541        // along with the block and is a multiple of the alignment size.
    489542
    490   if ( unlikely( size > ~0ul - sizeof(HeapManager.Storage) ) ) return 0p;
     543  if ( unlikely( size > ~0ul - sizeof(HeapManager.Storage) ) ) return 0;
    491544        size_t tsize = size + sizeof(HeapManager.Storage);
    492545        if ( likely( tsize < mmapStart ) ) {                            // small size => sbrk
     
    521574                block = freeElem->freeList.pop();
    522575                #endif // SPINLOCK
    523                 if ( unlikely( block == 0p ) ) {                                // no free block ?
     576                if ( unlikely( block == 0 ) ) {                                 // no free block ?
    524577                        #if defined( SPINLOCK )
    525578                        unlock( freeElem->lock );
     
    530583
    531584                        block = (HeapManager.Storage *)extend( tsize ); // mutual exclusion on call
    532   if ( unlikely( block == 0p ) ) return 0p;
    533                 #if defined( SPINLOCK )
     585  if ( unlikely( block == 0 ) ) return 0;
     586                        #if defined( SPINLOCK )
    534587                } else {
    535588                        freeElem->freeList = block->header.kind.real.next;
    536589                        unlock( freeElem->lock );
    537                 #endif // SPINLOCK
     590                        #endif // SPINLOCK
    538591                } // if
    539592
    540593                block->header.kind.real.home = freeElem;                // pointer back to free list of apropriate size
    541594        } else {                                                                                        // large size => mmap
    542   if ( unlikely( size > ~0ul - pageSize ) ) return 0p;
     595  if ( unlikely( size > ~0ul - pageSize ) ) return 0;
    543596                tsize = libCeiling( tsize, pageSize );                  // must be multiple of page size
    544597                #ifdef __STATISTICS__
     
    558611        } // if
    559612
    560         void * addr = &(block->data);                                           // adjust off header to user bytes
     613        void * area = &(block->data);                                           // adjust off header to user bytes
    561614
    562615        #ifdef __CFA_DEBUG__
    563         assert( ((uintptr_t)addr & (libAlign() - 1)) == 0 ); // minimum alignment ?
     616        assert( ((uintptr_t)area & (libAlign() - 1)) == 0 ); // minimum alignment ?
    564617        __atomic_add_fetch( &allocFree, tsize, __ATOMIC_SEQ_CST );
    565618        if ( traceHeap() ) {
    566619                enum { BufferSize = 64 };
    567620                char helpText[BufferSize];
    568                 int len = snprintf( helpText, BufferSize, "%p = Malloc( %zu ) (allocated %zu)\n", addr, size, tsize );
    569                 // int len = snprintf( helpText, BufferSize, "Malloc %p %zu\n", addr, size );
    570                 __cfaabi_bits_write( STDERR_FILENO, helpText, len ); // print debug/nodebug
     621                int len = snprintf( helpText, BufferSize, "%p = Malloc( %zu ) (allocated %zu)\n", area, size, tsize );
     622                // int len = snprintf( helpText, BufferSize, "Malloc %p %zu\n", area, size );
     623                __cfaabi_dbg_bits_write( helpText, len );
    571624        } // if
    572625        #endif // __CFA_DEBUG__
    573626
    574         return addr;
     627        return area;
    575628} // doMalloc
    576629
     
    578631static inline void doFree( void * addr ) with ( heapManager ) {
    579632        #ifdef __CFA_DEBUG__
    580         if ( unlikely( heapManager.heapBegin == 0p ) ) {
     633        if ( unlikely( heapManager.heapBegin == 0 ) ) {
    581634                abort( "doFree( %p ) : internal error, called before heap is initialized.", addr );
    582635        } // if
     
    624677                char helpText[BufferSize];
    625678                int len = snprintf( helpText, sizeof(helpText), "Free( %p ) size:%zu\n", addr, size );
    626                 __cfaabi_bits_write( STDERR_FILENO, helpText, len ); // print debug/nodebug
     679                __cfaabi_dbg_bits_write( helpText, len );
    627680        } // if
    628681        #endif // __CFA_DEBUG__
     
    630683
    631684
    632 size_t prtFree( HeapManager & manager ) with ( manager ) {
     685size_t checkFree( HeapManager & manager ) with ( manager ) {
    633686        size_t total = 0;
    634687        #ifdef __STATISTICS__
    635         __cfaabi_bits_acquire();
    636         __cfaabi_bits_print_nolock( STDERR_FILENO, "\nBin lists (bin size : free blocks on list)\n" );
     688        __cfaabi_dbg_bits_acquire();
     689        __cfaabi_dbg_bits_print_nolock( "\nBin lists (bin size : free blocks on list)\n" );
    637690        #endif // __STATISTICS__
    638691        for ( unsigned int i = 0; i < maxBucketsUsed; i += 1 ) {
     
    643696
    644697                #if defined( SPINLOCK )
    645                 for ( HeapManager.Storage * p = freeLists[i].freeList; p != 0p; p = p->header.kind.real.next ) {
     698                for ( HeapManager.Storage * p = freeLists[i].freeList; p != 0; p = p->header.kind.real.next ) {
    646699                #else
    647                 for ( HeapManager.Storage * p = freeLists[i].freeList.top(); p != 0p; p = p->header.kind.real.next.top ) {
     700                for ( HeapManager.Storage * p = freeLists[i].freeList.top(); p != 0; p = p->header.kind.real.next.top ) {
    648701                #endif // SPINLOCK
    649702                        total += size;
     
    654707
    655708                #ifdef __STATISTICS__
    656                 __cfaabi_bits_print_nolock( STDERR_FILENO, "%7zu, %-7u  ", size, N );
    657                 if ( (i + 1) % 8 == 0 ) __cfaabi_bits_print_nolock( STDERR_FILENO, "\n" );
     709                __cfaabi_dbg_bits_print_nolock( "%7zu, %-7u  ", size, N );
     710                if ( (i + 1) % 8 == 0 ) __cfaabi_dbg_bits_print_nolock( "\n" );
    658711                #endif // __STATISTICS__
    659712        } // for
    660713        #ifdef __STATISTICS__
    661         __cfaabi_bits_print_nolock( STDERR_FILENO, "\ntotal free blocks:%zu\n", total );
    662         __cfaabi_bits_release();
     714        __cfaabi_dbg_bits_print_nolock( "\ntotal free blocks:%zu\n", total );
     715        __cfaabi_dbg_bits_release();
    663716        #endif // __STATISTICS__
    664717        return (char *)heapEnd - (char *)heapBegin - total;
    665 } // prtFree
    666 
    667 
    668 static void ?{}( HeapManager & manager ) with ( manager ) {
    669         pageSize = sysconf( _SC_PAGESIZE );
    670 
    671         for ( unsigned int i = 0; i < NoBucketSizes; i += 1 ) { // initialize the free lists
    672                 freeLists[i].blockSize = bucketSizes[i];
    673         } // for
    674 
    675         #ifdef FASTLOOKUP
    676         unsigned int idx = 0;
    677         for ( unsigned int i = 0; i < LookupSizes; i += 1 ) {
    678                 if ( i > bucketSizes[idx] ) idx += 1;
    679                 lookup[i] = idx;
    680         } // for
    681         #endif // FASTLOOKUP
    682 
    683         if ( setMmapStart( default_mmap_start() ) ) {
    684                 abort( "HeapManager : internal error, mmap start initialization failure." );
    685         } // if
    686         heapExpand = default_heap_expansion();
    687 
    688         char * end = (char *)sbrk( 0 );
    689         sbrk( (char *)libCeiling( (long unsigned int)end, libAlign() ) - end ); // move start of heap to multiple of alignment
    690         heapBegin = heapEnd = sbrk( 0 );                                        // get new start point
    691 } // HeapManager
    692 
    693 
    694 static void ^?{}( HeapManager & ) {
    695         #ifdef __STATISTICS__
    696         if ( traceHeapTerm() ) {
    697                 printStats();
    698                 // if ( prtfree() ) prtFree( heapManager, true );
    699         } // if
    700         #endif // __STATISTICS__
    701 } // ~HeapManager
    702 
    703 
    704 static void memory_startup( void ) __attribute__(( constructor( STARTUP_PRIORITY_MEMORY ) ));
    705 void memory_startup( void ) {
    706         #ifdef __CFA_DEBUG__
    707         if ( unlikely( heapBoot ) ) {                                           // check for recursion during system boot
    708                 // DO NOT USE STREAMS AS THEY MAY BE UNAVAILABLE AT THIS POINT.
    709                 abort( "boot() : internal error, recursively invoked during system boot." );
    710         } // if
    711         heapBoot = true;
    712         #endif // __CFA_DEBUG__
    713 
    714         //assert( heapManager.heapBegin != 0 );
    715         //heapManager{};
    716         if ( heapManager.heapBegin == 0p ) heapManager{};
    717 } // memory_startup
    718 
    719 static void memory_shutdown( void ) __attribute__(( destructor( STARTUP_PRIORITY_MEMORY ) ));
    720 void memory_shutdown( void ) {
    721         ^heapManager{};
    722 } // memory_shutdown
     718} // checkFree
    723719
    724720
    725721static inline void * mallocNoStats( size_t size ) {             // necessary for malloc statistics
    726722        //assert( heapManager.heapBegin != 0 );
    727         if ( unlikely( heapManager.heapBegin == 0p ) ) heapManager{}; // called before memory_startup ?
    728         void * addr = doMalloc( size );
    729         if ( unlikely( addr == 0p ) ) errno = ENOMEM;           // POSIX
    730         return addr;
     723        if ( unlikely( heapManager.heapBegin == 0 ) ) heapManager{}; // called before memory_startup ?
     724        void * area = doMalloc( size );
     725        if ( unlikely( area == 0 ) ) errno = ENOMEM;            // POSIX
     726        return area;
    731727} // mallocNoStats
    732 
    733 
    734 static inline void * callocNoStats( size_t noOfElems, size_t elemSize ) {
    735         size_t size = noOfElems * elemSize;
    736         char * addr = (char *)mallocNoStats( size );
    737   if ( unlikely( addr == 0p ) ) return 0p;
    738 
    739         HeapManager.Storage.Header * header;
    740         HeapManager.FreeHeader * freeElem;
    741         size_t bsize, alignment;
    742         bool mapped __attribute__(( unused )) = headers( "calloc", addr, header, freeElem, bsize, alignment );
    743         #ifndef __CFA_DEBUG__
    744         // Mapped storage is zero filled, but in debug mode mapped memory is scrubbed in doMalloc, so it has to be reset to zero.
    745         if ( ! mapped )
    746         #endif // __CFA_DEBUG__
    747                 // Zero entire data space even when > than size => realloc without a new allocation and zero fill works.
    748                 // <-------00000000000000000000000000000000000000000000000000000> bsize (bucket size)
    749                 // `-header`-addr                      `-size
    750                 memset( addr, '\0', bsize - sizeof(HeapManager.Storage) ); // set to zeros
    751 
    752         header->kind.real.blockSize |= 2;                                       // mark as zero filled
    753         return addr;
    754 } // callocNoStats
    755728
    756729
     
    772745        // subtract libAlign() because it is already the minimum alignment
    773746        // add sizeof(Storage) for fake header
    774         char * addr = (char *)mallocNoStats( size + alignment - libAlign() + sizeof(HeapManager.Storage) );
    775   if ( unlikely( addr == 0p ) ) return addr;
     747        // #comment TD : this is the only place that calls doMalloc without calling mallocNoStats, why ?
     748        char * area = (char *)doMalloc( size + alignment - libAlign() + sizeof(HeapManager.Storage) );
     749  if ( unlikely( area == 0 ) ) return area;
    776750
    777751        // address in the block of the "next" alignment address
    778         char * user = (char *)libCeiling( (uintptr_t)(addr + sizeof(HeapManager.Storage)), alignment );
     752        char * user = (char *)libCeiling( (uintptr_t)(area + sizeof(HeapManager.Storage)), alignment );
    779753
    780754        // address of header from malloc
    781         HeapManager.Storage.Header * realHeader = headerAddr( addr );
     755        HeapManager.Storage.Header * realHeader = headerAddr( area );
    782756        // address of fake header * before* the alignment location
    783757        HeapManager.Storage.Header * fakeHeader = headerAddr( user );
     
    789763        return user;
    790764} // memalignNoStats
    791 
    792 
    793 static inline void * cmemalignNoStats( size_t alignment, size_t noOfElems, size_t elemSize ) {
    794         size_t size = noOfElems * elemSize;
    795         char * addr = (char *)memalignNoStats( alignment, size );
    796   if ( unlikely( addr == 0p ) ) return 0p;
    797         HeapManager.Storage.Header * header;
    798         HeapManager.FreeHeader * freeElem;
    799         size_t bsize;
    800         bool mapped __attribute__(( unused )) = headers( "cmemalign", addr, header, freeElem, bsize, alignment );
    801         #ifndef __CFA_DEBUG__
    802         // Mapped storage is zero filled, but in debug mode mapped memory is scrubbed in doMalloc, so it has to be reset to zero.
    803         if ( ! mapped )
    804         #endif // __CFA_DEBUG__
    805                 memset( addr, '\0', dataStorage( bsize, addr, header ) ); // set to zeros
    806         header->kind.real.blockSize |= 2;                               // mark as zero filled
    807 
    808         return addr;
    809 } // cmemalignNoStats
    810765
    811766
     
    821776extern "C" {
    822777        // The malloc() function allocates size bytes and returns a pointer to the allocated memory. The memory is not
    823         // initialized. If size is 0, then malloc() returns either 0p, or a unique pointer value that can later be
     778        // initialized. If size is 0, then malloc() returns either NULL, or a unique pointer value that can later be
    824779        // successfully passed to free().
    825780        void * malloc( size_t size ) {
     
    833788
    834789        // The calloc() function allocates memory for an array of nmemb elements of size bytes each and returns a pointer to
    835         // the allocated memory. The memory is set to zero. If nmemb or size is 0, then calloc() returns either 0p, or a
     790        // the allocated memory. The memory is set to zero. If nmemb or size is 0, then calloc() returns either NULL, or a
    836791        // unique pointer value that can later be successfully passed to free().
    837792        void * calloc( size_t noOfElems, size_t elemSize ) {
     793                size_t size = noOfElems * elemSize;
    838794                #ifdef __STATISTICS__
    839795                __atomic_add_fetch( &calloc_calls, 1, __ATOMIC_SEQ_CST );
    840                 __atomic_add_fetch( &calloc_storage, noOfElems * elemSize, __ATOMIC_SEQ_CST );
    841                 #endif // __STATISTICS__
    842 
    843                 return callocNoStats( noOfElems, elemSize );
     796                __atomic_add_fetch( &calloc_storage, size, __ATOMIC_SEQ_CST );
     797                #endif // __STATISTICS__
     798
     799                char * area = (char *)mallocNoStats( size );
     800          if ( unlikely( area == 0 ) ) return 0;
     801
     802                HeapManager.Storage.Header * header;
     803                HeapManager.FreeHeader * freeElem;
     804                size_t asize, alignment;
     805                bool mapped __attribute__(( unused )) = headers( "calloc", area, header, freeElem, asize, alignment );
     806                #ifndef __CFA_DEBUG__
     807                // Mapped storage is zero filled, but in debug mode mapped memory is scrubbed in doMalloc, so it has to be reset to zero.
     808                if ( ! mapped )
     809                #endif // __CFA_DEBUG__
     810                        memset( area, '\0', asize - sizeof(HeapManager.Storage) ); // set to zeros
     811
     812                header->kind.real.blockSize |= 2;                               // mark as zero filled
     813                return area;
    844814        } // calloc
     815
     816        // #comment TD : Document this function
     817        void * cmemalign( size_t alignment, size_t noOfElems, size_t elemSize ) {
     818                size_t size = noOfElems * elemSize;
     819                #ifdef __STATISTICS__
     820                __atomic_add_fetch( &cmemalign_calls, 1, __ATOMIC_SEQ_CST );
     821                __atomic_add_fetch( &cmemalign_storage, size, __ATOMIC_SEQ_CST );
     822                #endif // __STATISTICS__
     823
     824                char * area = (char *)memalignNoStats( alignment, size );
     825          if ( unlikely( area == 0 ) ) return 0;
     826                HeapManager.Storage.Header * header;
     827                HeapManager.FreeHeader * freeElem;
     828                size_t asize;
     829                bool mapped __attribute__(( unused )) = headers( "cmemalign", area, header, freeElem, asize, alignment );
     830                #ifndef __CFA_DEBUG__
     831                // Mapped storage is zero filled, but in debug mode mapped memory is scrubbed in doMalloc, so it has to be reset to zero.
     832                if ( ! mapped )
     833                        #endif // __CFA_DEBUG__
     834                        memset( area, '\0', asize - ( (char *)area - (char *)header ) ); // set to zeros
     835                header->kind.real.blockSize |= 2;                               // mark as zero filled
     836
     837                return area;
     838        } // cmemalign
    845839
    846840        // The realloc() function changes the size of the memory block pointed to by ptr to size bytes. The contents will be
    847841        // unchanged in the range from the start of the region up to the minimum of the old and new sizes. If the new size
    848         // is larger than the old size, the added memory will not be initialized.  If ptr is 0p, then the call is
    849         // equivalent to malloc(size), for all values of size; if size is equal to zero, and ptr is not 0p, then the call
    850         // is equivalent to free(ptr). Unless ptr is 0p, it must have been returned by an earlier call to malloc(),
     842        // is larger than the old size, the added memory will not be initialized.  If ptr is NULL, then the call is
     843        // equivalent to malloc(size), for all values of size; if size is equal to zero, and ptr is not NULL, then the call
     844        // is equivalent to free(ptr). Unless ptr is NULL, it must have been returned by an earlier call to malloc(),
    851845        // calloc() or realloc(). If the area pointed to was moved, a free(ptr) is done.
    852         void * realloc( void * oaddr, size_t size ) {
     846        void * realloc( void * addr, size_t size ) {
    853847                #ifdef __STATISTICS__
    854848                __atomic_add_fetch( &realloc_calls, 1, __ATOMIC_SEQ_CST );
    855849                #endif // __STATISTICS__
    856850
    857                 // If size is equal to 0, either NULL or a pointer suitable to be passed to free() is returned.
    858           if ( unlikely( size == 0 ) ) { free( oaddr ); return mallocNoStats( size ); } // special cases
    859           if ( unlikely( oaddr == 0p ) ) return mallocNoStats( size );
     851          if ( unlikely( addr == 0 ) ) return mallocNoStats( size ); // special cases
     852          if ( unlikely( size == 0 ) ) { free( addr ); return 0; }
    860853
    861854                HeapManager.Storage.Header * header;
    862855                HeapManager.FreeHeader * freeElem;
    863                 size_t bsize, oalign = 0;
    864                 headers( "realloc", oaddr, header, freeElem, bsize, oalign );
    865 
    866                 size_t odsize = dataStorage( bsize, oaddr, header ); // data storage available in bucket
    867           if ( size <= odsize && odsize <= size * 2 ) { // allow up to 50% wasted storage in smaller size
    868                         // Do not know size of original allocation => cannot do 0 fill for any additional space because do not know
    869                         // where to start filling, i.e., do not overwrite existing values in space.
    870                         //
     856                size_t asize, alignment = 0;
     857                headers( "realloc", addr, header, freeElem, asize, alignment );
     858
     859                size_t usize = asize - ( (char *)addr - (char *)header ); // compute the amount of user storage in the block
     860                if ( usize >= size ) {                                                  // already sufficient storage
    871861                        // This case does not result in a new profiler entry because the previous one still exists and it must match with
    872862                        // the free for this memory.  Hence, this realloc does not appear in the profiler output.
    873                         return oaddr;
     863                        return addr;
    874864                } // if
    875865
     
    878868                #endif // __STATISTICS__
    879869
    880                 // change size and copy old content to new storage
    881 
    882                 void * naddr;
    883                 if ( unlikely( oalign != 0 ) ) {                                // previous request memalign?
    884                         if ( unlikely( header->kind.real.blockSize & 2 ) ) { // previous request zero fill
    885                                 naddr = cmemalignNoStats( oalign, 1, size ); // create new aligned area
    886                         } else {
    887                                 naddr = memalignNoStats( oalign, size ); // create new aligned area
    888                         } // if
     870                void * area;
     871                if ( unlikely( alignment != 0 ) ) {                             // previous request memalign?
     872                        area = memalign( alignment, size );                     // create new aligned area
    889873                } else {
    890                         if ( unlikely( header->kind.real.blockSize & 2 ) ) { // previous request zero fill
    891                                 naddr = callocNoStats( 1, size );               // create new area
    892                         } else {
    893                                 naddr = mallocNoStats( size );                  // create new area
    894                         } // if
     874                        area = mallocNoStats( size );                           // create new area
    895875                } // if
    896           if ( unlikely( naddr == 0p ) ) return 0p;
    897 
    898                 headers( "realloc", naddr, header, freeElem, bsize, oalign );
    899                 size_t ndsize = dataStorage( bsize, naddr, header ); // data storage avilable in bucket
    900                 // To preserve prior fill, the entire bucket must be copied versus the size.
    901                 memcpy( naddr, oaddr, MIN( odsize, ndsize ) );  // copy bytes
    902                 free( oaddr );
    903                 return naddr;
     876          if ( unlikely( area == 0 ) ) return 0;
     877                if ( unlikely( header->kind.real.blockSize & 2 ) ) { // previous request zero fill (calloc/cmemalign) ?
     878                        assert( (header->kind.real.blockSize & 1) == 0 );
     879                        bool mapped __attribute__(( unused )) = headers( "realloc", area, header, freeElem, asize, alignment );
     880                        #ifndef __CFA_DEBUG__
     881                        // Mapped storage is zero filled, but in debug mode mapped memory is scrubbed in doMalloc, so it has to be reset to zero.
     882                        if ( ! mapped )
     883                        #endif // __CFA_DEBUG__
     884                                memset( (char *)area + usize, '\0', asize - ( (char *)area - (char *)header ) - usize ); // zero-fill back part
     885                        header->kind.real.blockSize |= 2;                       // mark new request as zero fill
     886                } // if
     887                memcpy( area, addr, usize );                                    // copy bytes
     888                free( addr );
     889                return area;
    904890        } // realloc
    905891
     
    912898                #endif // __STATISTICS__
    913899
    914                 return memalignNoStats( alignment, size );
     900                void * area = memalignNoStats( alignment, size );
     901
     902                return area;
    915903        } // memalign
    916 
    917 
    918         // The cmemalign() function is the same as calloc() with memory alignment.
    919         void * cmemalign( size_t alignment, size_t noOfElems, size_t elemSize ) {
    920                 #ifdef __STATISTICS__
    921                 __atomic_add_fetch( &cmemalign_calls, 1, __ATOMIC_SEQ_CST );
    922                 __atomic_add_fetch( &cmemalign_storage, noOfElems * elemSize, __ATOMIC_SEQ_CST );
    923                 #endif // __STATISTICS__
    924 
    925                 return cmemalignNoStats( alignment, noOfElems, elemSize );
    926         } // cmemalign
    927904
    928905        // The function aligned_alloc() is the same as memalign(), except for the added restriction that size should be a
     
    935912        // The function posix_memalign() allocates size bytes and places the address of the allocated memory in *memptr. The
    936913        // address of the allocated memory will be a multiple of alignment, which must be a power of two and a multiple of
    937         // sizeof(void *). If size is 0, then posix_memalign() returns either 0p, or a unique pointer value that can later
     914        // sizeof(void *). If size is 0, then posix_memalign() returns either NULL, or a unique pointer value that can later
    938915        // be successfully passed to free(3).
    939916        int posix_memalign( void ** memptr, size_t alignment, size_t size ) {
    940917          if ( alignment < sizeof(void *) || ! libPow2( alignment ) ) return EINVAL; // check alignment
    941918                * memptr = memalign( alignment, size );
    942           if ( unlikely( * memptr == 0p ) ) return ENOMEM;
     919          if ( unlikely( * memptr == 0 ) ) return ENOMEM;
    943920                return 0;
    944921        } // posix_memalign
     
    953930        // The free() function frees the memory space pointed to by ptr, which must have been returned by a previous call to
    954931        // malloc(), calloc() or realloc().  Otherwise, or if free(ptr) has already been called before, undefined behavior
    955         // occurs. If ptr is 0p, no operation is performed.
     932        // occurs. If ptr is NULL, no operation is performed.
    956933        void free( void * addr ) {
    957934                #ifdef __STATISTICS__
     
    959936                #endif // __STATISTICS__
    960937
    961           if ( unlikely( addr == 0p ) ) {                                       // special case
    962                         // #ifdef __CFA_DEBUG__
    963                         // if ( traceHeap() ) {
    964                         //      #define nullmsg "Free( 0x0 ) size:0\n"
    965                         //      // Do not debug print free( 0p ), as it can cause recursive entry from sprintf.
    966                         //      __cfaabi_dbg_write( nullmsg, sizeof(nullmsg) - 1 );
    967                         // } // if
    968                         // #endif // __CFA_DEBUG__
     938                // #comment TD : To decrease nesting I would but the special case in the
     939                //               else instead, plus it reads more naturally to have the
     940                //               short / normal case instead
     941                if ( unlikely( addr == 0 ) ) {                                  // special case
     942                        #ifdef __CFA_DEBUG__
     943                        if ( traceHeap() ) {
     944                                #define nullmsg "Free( 0x0 ) size:0\n"
     945                                // Do not debug print free( 0 ), as it can cause recursive entry from sprintf.
     946                                __cfaabi_dbg_bits_write( nullmsg, sizeof(nullmsg) - 1 );
     947                        } // if
     948                        #endif // __CFA_DEBUG__
    969949                        return;
    970950                } // exit
     
    973953        } // free
    974954
    975 
    976         // The malloc_alignment() function returns the alignment of the allocation.
     955        // The mallopt() function adjusts parameters that control the behavior of the memory-allocation functions (see
     956        // malloc(3)). The param argument specifies the parameter to be modified, and value specifies the new value for that
     957        // parameter.
     958        int mallopt( int option, int value ) {
     959                choose( option ) {
     960                  case M_TOP_PAD:
     961                        if ( setHeapExpand( value ) ) fallthru default;
     962                  case M_MMAP_THRESHOLD:
     963                        if ( setMmapStart( value ) ) fallthru default;
     964                  default:
     965                        // #comment TD : 1 for unsopported feels wrong
     966                        return 1;                                                                       // success, or unsupported
     967                } // switch
     968                return 0;                                                                               // error
     969        } // mallopt
     970
     971        // The malloc_trim() function attempts to release free memory at the top of the heap (by calling sbrk(2) with a
     972        // suitable argument).
     973        int malloc_trim( size_t ) {
     974                return 0;                                                                               // => impossible to release memory
     975        } // malloc_trim
     976
     977        // The malloc_usable_size() function returns the number of usable bytes in the block pointed to by ptr, a pointer to
     978        // a block of memory allocated by malloc(3) or a related function.
     979        size_t malloc_usable_size( void * addr ) {
     980          if ( unlikely( addr == 0 ) ) return 0;                        // null allocation has 0 size
     981
     982                HeapManager.Storage.Header * header;
     983                HeapManager.FreeHeader * freeElem;
     984                size_t size, alignment;
     985
     986                headers( "malloc_usable_size", addr, header, freeElem, size, alignment );
     987                size_t usize = size - ( (char *)addr - (char *)header ); // compute the amount of user storage in the block
     988                return usize;
     989        } // malloc_usable_size
     990
     991
     992    // The malloc_alignment() function returns the alignment of the allocation.
    977993        size_t malloc_alignment( void * addr ) {
    978           if ( unlikely( addr == 0p ) ) return libAlign();      // minimum alignment
     994          if ( unlikely( addr == 0 ) ) return libAlign();       // minimum alignment
    979995                HeapManager.Storage.Header * header = headerAddr( addr );
    980996                if ( (header->kind.fake.alignment & 1) == 1 ) { // fake header ?
     
    9861002
    9871003
    988         // The malloc_zero_fill() function returns true if the allocation is zero filled, i.e., initially allocated by calloc().
     1004    // The malloc_zero_fill() function returns true if the allocation is zero filled, i.e., initially allocated by calloc().
    9891005        bool malloc_zero_fill( void * addr ) {
    990           if ( unlikely( addr == 0p ) ) return false;           // null allocation is not zero fill
     1006          if ( unlikely( addr == 0 ) ) return false;            // null allocation is not zero fill
    9911007                HeapManager.Storage.Header * header = headerAddr( addr );
    9921008                if ( (header->kind.fake.alignment & 1) == 1 ) { // fake header ?
     
    9971013
    9981014
    999         // The malloc_usable_size() function returns the number of usable bytes in the block pointed to by ptr, a pointer to
    1000         // a block of memory allocated by malloc(3) or a related function.
    1001         size_t malloc_usable_size( void * addr ) {
    1002           if ( unlikely( addr == 0p ) ) return 0;                       // null allocation has 0 size
    1003                 HeapManager.Storage.Header * header;
    1004                 HeapManager.FreeHeader * freeElem;
    1005                 size_t bsize, alignment;
    1006 
    1007                 headers( "malloc_usable_size", addr, header, freeElem, bsize, alignment );
    1008                 return dataStorage( bsize, addr, header );      // data storage in bucket
    1009         } // malloc_usable_size
    1010 
    1011 
    1012         // The malloc_stats() function prints (on default standard error) statistics about memory allocated by malloc(3) and
    1013         // related functions.
     1015    // The malloc_stats() function prints (on default standard error) statistics about memory allocated by malloc(3) and
     1016    // related functions.
    10141017        void malloc_stats( void ) {
    10151018                #ifdef __STATISTICS__
    10161019                printStats();
    1017                 if ( prtFree() ) prtFree( heapManager );
     1020                if ( checkFree() ) checkFree( heapManager );
    10181021                #endif // __STATISTICS__
    10191022        } // malloc_stats
    10201023
    10211024        // The malloc_stats_fd() function changes the file descripter where malloc_stats() writes the statistics.
    1022         int malloc_stats_fd( int fd __attribute__(( unused )) ) {
     1025        int malloc_stats_fd( int fd ) {
    10231026                #ifdef __STATISTICS__
    10241027                int temp = statfd;
     
    10301033        } // malloc_stats_fd
    10311034
    1032 
    1033         // The mallopt() function adjusts parameters that control the behavior of the memory-allocation functions (see
    1034         // malloc(3)). The param argument specifies the parameter to be modified, and value specifies the new value for that
    1035         // parameter.
    1036         int mallopt( int option, int value ) {
    1037                 choose( option ) {
    1038                   case M_TOP_PAD:
    1039                         if ( setHeapExpand( value ) ) return 1;
    1040                   case M_MMAP_THRESHOLD:
    1041                         if ( setMmapStart( value ) ) return 1;
    1042                 } // switch
    1043                 return 0;                                                                               // error, unsupported
    1044         } // mallopt
    1045 
    1046         // The malloc_trim() function attempts to release free memory at the top of the heap (by calling sbrk(2) with a
    1047         // suitable argument).
    1048         int malloc_trim( size_t ) {
    1049                 return 0;                                                                               // => impossible to release memory
    1050         } // malloc_trim
    1051 
    1052 
    10531035        // The malloc_info() function exports an XML string that describes the current state of the memory-allocation
    10541036        // implementation in the caller.  The string is printed on the file stream stream.  The exported string includes
    10551037        // information about all arenas (see malloc(3)).
    10561038        int malloc_info( int options, FILE * stream ) {
    1057                 if ( options != 0 ) { errno = EINVAL; return -1; }
    10581039                return printStatsXML( stream );
    10591040        } // malloc_info
     
    10651046        // structure is returned as the function result.  (It is the caller's responsibility to free(3) this memory.)
    10661047        void * malloc_get_state( void ) {
    1067                 return 0p;                                                                              // unsupported
     1048                return 0;                                                                               // unsupported
    10681049        } // malloc_get_state
    10691050
     
    10771058
    10781059
    1079 // Must have CFA linkage to overload with C linkage realloc.
    1080 void * realloc( void * oaddr, size_t nalign, size_t size ) {
    1081         #ifdef __STATISTICS__
    1082         __atomic_add_fetch( &realloc_calls, 1, __ATOMIC_SEQ_CST );
    1083         #endif // __STATISTICS__
    1084 
    1085         // If size is equal to 0, either NULL or a pointer suitable to be passed to free() is returned.
    1086   if ( unlikely( size == 0 ) ) { free( oaddr ); return mallocNoStats( size ); } // special cases
    1087   if ( unlikely( oaddr == 0p ) ) return mallocNoStats( size );
    1088 
    1089         if ( unlikely( nalign == 0 ) ) nalign = libAlign();     // reset alignment to minimum
    1090         #ifdef __CFA_DEBUG__
    1091         else
    1092                 checkAlign( nalign );                                                   // check alignment
    1093         #endif // __CFA_DEBUG__
    1094 
    1095         HeapManager.Storage.Header * header;
    1096         HeapManager.FreeHeader * freeElem;
    1097         size_t bsize, oalign = 0;
    1098         headers( "realloc", oaddr, header, freeElem, bsize, oalign );
    1099         size_t odsize = dataStorage( bsize, oaddr, header ); // data storage available in bucket
    1100 
    1101   if ( oalign != 0 && (uintptr_t)oaddr % nalign == 0 ) { // has alignment and just happens to work out
    1102                 headerAddr( oaddr )->kind.fake.alignment = nalign | 1; // update alignment (could be the same)
    1103                 return realloc( oaddr, size );
    1104         } // if
    1105 
    1106         #ifdef __STATISTICS__
    1107         __atomic_add_fetch( &realloc_storage, size, __ATOMIC_SEQ_CST );
    1108         #endif // __STATISTICS__
    1109 
    1110         // change size and copy old content to new storage
    1111 
    1112         void * naddr;
    1113         if ( unlikely( header->kind.real.blockSize & 2 ) ) { // previous request zero fill
    1114                 naddr = cmemalignNoStats( nalign, 1, size );    // create new aligned area
    1115         } else {
    1116                 naddr = memalignNoStats( nalign, size );                // create new aligned area
    1117         } // if
    1118 
    1119         headers( "realloc", naddr, header, freeElem, bsize, oalign );
    1120         size_t ndsize = dataStorage( bsize, naddr, header ); // data storage avilable in bucket
    1121         // To preserve prior fill, the entire bucket must be copied versus the size.
    1122         memcpy( naddr, oaddr, MIN( odsize, ndsize ) );          // copy bytes
    1123         free( oaddr );
    1124         return naddr;
    1125 } // realloc
    1126 
    1127 
    11281060// Local Variables: //
    11291061// tab-width: 4 //
  • libcfa/src/interpose.cfa

    r2fa5bd2 raca6a54c  
    1010// Created On       : Wed Mar 29 16:10:31 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Nov 30 07:09:42 2019
    13 // Update Count     : 119
     12// Last Modified On : Sun Jul 14 22:57:16 2019
     13// Update Count     : 116
    1414//
    1515
     
    163163        abort_lastframe = kernel_abort_lastframe();
    164164        len = snprintf( abort_text, abort_text_size, "Cforall Runtime error (UNIX pid:%ld) ", (long int)getpid() ); // use UNIX pid (versus getPid)
    165         __cfaabi_dbg_write( abort_text, len );
     165        __cfaabi_dbg_bits_write( abort_text, len );
    166166
    167167        if ( fmt ) {
     
    171171                len = vsnprintf( abort_text, abort_text_size, fmt, args );
    172172                va_end( args );
    173                 __cfaabi_dbg_write( abort_text, len );
     173                __cfaabi_dbg_bits_write( abort_text, len );
    174174
    175175                if ( fmt[strlen( fmt ) - 1] != '\n' ) {         // add optional newline if missing at the end of the format text
    176                         __cfaabi_dbg_write( "\n", 1 );
     176                        __cfaabi_dbg_bits_write( "\n", 1 );
    177177                }
    178178        }
     
    194194        // find executable name
    195195        *index( messages[0], '(' ) = '\0';
    196         __cfaabi_bits_print_nolock( STDERR_FILENO, "Stack back trace for: %s\n", messages[0]);
    197 
    198         for ( int i = Start; i < size - abort_lastframe && messages != 0p; i += 1 ) {
    199                 char * name = 0p, * offset_begin = 0p, * offset_end = 0p;
     196        __cfaabi_dbg_bits_print_nolock( "Stack back trace for: %s\n", messages[0]);
     197
     198        for ( int i = Start; i < size - abort_lastframe && messages != NULL; i += 1 ) {
     199                char * name = NULL, * offset_begin = NULL, * offset_end = NULL;
    200200
    201201                for ( char * p = messages[i]; *p; ++p ) {
    202                         //__cfaabi_bits_print_nolock( "X %s\n", p);
     202                        //__cfaabi_dbg_bits_print_nolock( "X %s\n", p);
    203203                        // find parantheses and +offset
    204204                        if ( *p == '(' ) {
     
    220220                        *offset_end++ = '\0';
    221221
    222                         __cfaabi_bits_print_nolock( STDERR_FILENO, "(%i) %s : %s + %s %s\n", frameNo, messages[i], name, offset_begin, offset_end);
     222                        __cfaabi_dbg_bits_print_nolock( "(%i) %s : %s + %s %s\n", frameNo, messages[i], name, offset_begin, offset_end);
    223223                } else {                                                                                // otherwise, print the whole line
    224                         __cfaabi_bits_print_nolock( STDERR_FILENO, "(%i) %s\n", frameNo, messages[i] );
     224                        __cfaabi_dbg_bits_print_nolock( "(%i) %s\n", frameNo, messages[i] );
    225225                }
    226226        }
  • libcfa/src/startup.cfa

    r2fa5bd2 raca6a54c  
    1010// Created On       : Tue Jul 24 16:21:57 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Nov 30 07:07:56 2019
    13 // Update Count     : 13
     12// Last Modified On : Wed Jul 25 16:42:01 2018
     13// Update Count     : 11
    1414//
    1515
    1616#include "startup.hfa"
    17 #include <time.h>                                                                               // tzset
     17#include <unistd.h>
     18
    1819
    1920extern "C" {
    2021    static void __cfaabi_appready_startup( void ) __attribute__(( constructor( STARTUP_PRIORITY_APPREADY ) ));
    2122    void __cfaabi_appready_startup( void ) {
    22                 tzset();                                                                                // initialize time global variables
    2323                #ifdef __CFA_DEBUG__
    2424                extern void heapAppStart();
  • libcfa/src/stdlib.cfa

    r2fa5bd2 raca6a54c  
    1010// Created On       : Thu Jan 28 17:10:29 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Nov 20 17:22:47 2019
    13 // Update Count     : 485
     12// Last Modified On : Tue Oct 22 08:57:52 2019
     13// Update Count     : 478
    1414//
    1515
     
    3030        T * alloc_set( T ptr[], size_t dim, char fill ) {       // realloc array with fill
    3131                size_t olen = malloc_usable_size( ptr );                // current allocation
    32                 void * nptr = (void *)realloc( (void *)ptr, dim * sizeof(T) ); // C realloc
     32                char * nptr = (char *)realloc( (void *)ptr, dim * sizeof(T) ); // C realloc
    3333                size_t nlen = malloc_usable_size( nptr );               // new allocation
    3434                if ( nlen > olen ) {                                                    // larger ?
    35                         memset( (char *)nptr + olen, (int)fill, nlen - olen ); // initialize added storage
     35                        memset( nptr + olen, (int)fill, nlen - olen ); // initialize added storage
    3636                } // if
    3737                return (T *)nptr;
    3838        } // alloc_set
    3939
     40        T * alloc_align( T ptr[], size_t align ) {                      // aligned realloc array
     41                char * nptr;
     42                size_t alignment = malloc_alignment( ptr );
     43                if ( align != alignment && (uintptr_t)ptr % align != 0 ) {
     44                        size_t olen = malloc_usable_size( ptr );        // current allocation
     45                        nptr = (char *)memalign( align, olen );
     46                        size_t nlen = malloc_usable_size( nptr );       // new allocation
     47                        size_t lnth = olen < nlen ? olen : nlen;        // min
     48                        memcpy( nptr, ptr, lnth );                                      // initialize storage
     49                        free( ptr );
     50                } else {
     51                        nptr = (char *)ptr;
     52                } // if
     53                return (T *)nptr;
     54        } // alloc_align
     55
     56        T * alloc_align( T ptr[], size_t align, size_t dim ) { // aligned realloc array
     57                char * nptr;
     58                size_t alignment = malloc_alignment( ptr );
     59                if ( align != alignment ) {
     60                        size_t olen = malloc_usable_size( ptr );        // current allocation
     61                        nptr = (char *)memalign( align, dim * sizeof(T) );
     62                        size_t nlen = malloc_usable_size( nptr );       // new allocation
     63                        size_t lnth = olen < nlen ? olen : nlen;        // min
     64                        memcpy( nptr, ptr, lnth );                                      // initialize storage
     65                        free( ptr );
     66                } else {
     67                        nptr = (char *)realloc( (void *)ptr, dim * sizeof(T) ); // C realloc
     68                } // if
     69                return (T *)nptr;
     70        } // alloc_align
     71
    4072        T * alloc_align_set( T ptr[], size_t align, char fill ) { // aligned realloc with fill
    4173                size_t olen = malloc_usable_size( ptr );                // current allocation
    42                 void * nptr = (void *)realloc( (void *)ptr, align, sizeof(T) ); // CFA realloc
    43                 // char * nptr = alloc_align( ptr, align );
     74                char * nptr = alloc_align( ptr, align );
    4475                size_t nlen = malloc_usable_size( nptr );               // new allocation
    4576                if ( nlen > olen ) {                                                    // larger ?
    46                         memset( (char *)nptr + olen, (int)fill, nlen - olen ); // initialize added storage
     77                        memset( nptr + olen, (int)fill, nlen - olen ); // initialize added storage
    4778                } // if
    4879                return (T *)nptr;
  • libcfa/src/stdlib.hfa

    r2fa5bd2 raca6a54c  
    1010// Created On       : Thu Jan 28 17:12:35 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Nov 29 23:08:02 2019
    13 // Update Count     : 400
     12// Last Modified On : Sun Oct 20 22:57:33 2019
     13// Update Count     : 390
    1414//
    1515
     
    2828} // extern "C"
    2929
    30 void * realloc( void * oaddr, size_t nalign, size_t size ); // CFA heap
    31 
    3230//---------------------------------------
    3331
     
    5250        } // calloc
    5351
    54         T * realloc( T * ptr, size_t size ) {                           // CFA realloc, eliminate return-type cast
     52        T * realloc( T * ptr, size_t size ) {
     53                if ( unlikely( ptr == 0 ) ) return malloc();
    5554                return (T *)(void *)realloc( (void *)ptr, size ); // C realloc
    5655        } // realloc
     
    6059        } // memalign
    6160
    62         T * cmemalign( size_t align, size_t dim  ) {
    63                 return (T *)cmemalign( align, dim, sizeof(T) ); // CFA cmemalign
    64         } // cmemalign
    65 
    6661        T * aligned_alloc( size_t align ) {
    6762                return (T *)aligned_alloc( align, sizeof(T) );  // C aligned_alloc
     
    8479
    8580        T * alloc( T ptr[], size_t dim ) {                                      // realloc
    86                 return (T *)(void *)realloc( (void *)ptr, dim * sizeof(T) ); // C realloc
     81                return realloc( ptr, dim * sizeof(T) );
    8782        } // alloc
    8883
     
    123118        } // alloc_align
    124119
    125         T * alloc_align( T ptr[], size_t align ) {                      // aligned realloc array
    126                 return (T *)(void *)realloc( (void *)ptr, align, sizeof(T) ); // CFA realloc
    127         } // alloc_align
    128 
    129         T * alloc_align( T ptr[], size_t align, size_t dim ) { // aligned realloc array
    130                 return (T *)(void *)realloc( (void *)ptr, align, dim * sizeof(T) ); // CFA realloc
    131         } // alloc_align
    132 
    133120        T * alloc_align_set( size_t align, char fill ) {
    134121                return (T *)memset( (T *)alloc_align( align ), (int)fill, sizeof(T) ); // initialize with fill value
     
    155142
    156143forall( dtype T | sized(T) ) {
     144        T * alloc_align( T ptr[], size_t align );                       // realign
     145        T * alloc_align( T ptr[], size_t align, size_t dim ); // aligned realloc array
    157146        T * alloc_align_set( T ptr[], size_t align, size_t dim, char fill ); // aligned realloc array with fill
    158147} // distribution
     
    210199
    211200static inline {
    212         int ato( const char * sptr ) { return (int)strtol( sptr, 0p, 10 ); }
    213         unsigned int ato( const char * sptr ) { return (unsigned int)strtoul( sptr, 0p, 10 ); }
    214         long int ato( const char * sptr ) { return strtol( sptr, 0p, 10 ); }
    215         unsigned long int ato( const char * sptr ) { return strtoul( sptr, 0p, 10 ); }
    216         long long int ato( const char * sptr ) { return strtoll( sptr, 0p, 10 ); }
    217         unsigned long long int ato( const char * sptr ) { return strtoull( sptr, 0p, 10 ); }
    218 
    219         float ato( const char * sptr ) { return strtof( sptr, 0p ); }
    220         double ato( const char * sptr ) { return strtod( sptr, 0p ); }
    221         long double ato( const char * sptr ) { return strtold( sptr, 0p ); }
    222 
    223         float _Complex ato( const char * sptr ) { return strto( sptr, 0p ); }
    224         double _Complex ato( const char * sptr ) { return strto( sptr, 0p ); }
    225         long double _Complex ato( const char * sptr ) { return strto( sptr, 0p ); }
     201        int ato( const char * sptr ) { return (int)strtol( sptr, 0, 10 ); }
     202        unsigned int ato( const char * sptr ) { return (unsigned int)strtoul( sptr, 0, 10 ); }
     203        long int ato( const char * sptr ) { return strtol( sptr, 0, 10 ); }
     204        unsigned long int ato( const char * sptr ) { return strtoul( sptr, 0, 10 ); }
     205        long long int ato( const char * sptr ) { return strtoll( sptr, 0, 10 ); }
     206        unsigned long long int ato( const char * sptr ) { return strtoull( sptr, 0, 10 ); }
     207
     208        float ato( const char * sptr ) { return strtof( sptr, 0 ); }
     209        double ato( const char * sptr ) { return strtod( sptr, 0 ); }
     210        long double ato( const char * sptr ) { return strtold( sptr, 0 ); }
     211
     212        float _Complex ato( const char * sptr ) { return strto( sptr, NULL ); }
     213        double _Complex ato( const char * sptr ) { return strto( sptr, NULL ); }
     214        long double _Complex ato( const char * sptr ) { return strto( sptr, NULL ); }
    226215} // distribution
    227216
  • longrun_tests/Makefile.in

    r2fa5bd2 raca6a54c  
    486486LTCFACOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
    487487        $(LIBTOOLFLAGS) --mode=compile $(CFACC) $(DEFS) \
    488         $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(AM_CFLAGS) $(CFAFLAGS) $(CFLAGS)
     488        $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(CFAFLAGS) \
     489        $(AM_CFLAGS) $(CFLAGS)
    489490
    490491AM_V_CFA = $(am__v_CFA_@AM_V@)
  • src/AST/Convert.cpp

    r2fa5bd2 raca6a54c  
    887887                auto expr = visitBaseExpr( node,
    888888                        new AsmExpr(
    889                                 new std::string(node->inout),
     889                                get<Expression>().accept1(node->inout),
    890890                                get<Expression>().accept1(node->constraint),
    891891                                get<Expression>().accept1(node->operand)
     
    22582258                        new ast::AsmExpr(
    22592259                                old->location,
    2260                                 old->inout,
     2260                                GET_ACCEPT_1(inout, Expr),
    22612261                                GET_ACCEPT_1(constraint, Expr),
    22622262                                GET_ACCEPT_1(operand, Expr)
  • src/AST/Expr.hpp

    r2fa5bd2 raca6a54c  
    556556class AsmExpr final : public Expr {
    557557public:
    558         std::string inout;
     558        ptr<Expr> inout;
    559559        ptr<Expr> constraint;
    560560        ptr<Expr> operand;
    561561
    562         AsmExpr( const CodeLocation & loc, const std::string & io, const Expr * con, const Expr * op )
     562        AsmExpr( const CodeLocation & loc, const Expr * io, const Expr * con, const Expr * op )
    563563        : Expr( loc ), inout( io ), constraint( con ), operand( op ) {}
    564564
  • src/AST/Pass.impl.hpp

    r2fa5bd2 raca6a54c  
    13001300                        maybe_accept( node, &AsmExpr::result );
    13011301                }
     1302                maybe_accept( node, &AsmExpr::inout      );
    13021303                maybe_accept( node, &AsmExpr::constraint );
    13031304                maybe_accept( node, &AsmExpr::operand    );
  • src/AST/Print.cpp

    r2fa5bd2 raca6a54c  
    10111011                os << "Asm Expression:" << endl;
    10121012                ++indent;
    1013                 if ( !node->inout.empty() ) os << "[" << node->inout << "] ";
     1013                if ( node->inout ) node->inout->accept( *this );
    10141014                if ( node->constraint ) node->constraint->accept( *this );
    10151015                if ( node->operand ) node->operand->accept( *this );
  • src/CodeGen/CodeGenerator.cc

    r2fa5bd2 raca6a54c  
    786786
    787787        void CodeGenerator::postvisit( AsmExpr * asmExpr ) {
    788                 if ( !asmExpr->inout.empty() ) {
     788                if ( asmExpr->get_inout() ) {
    789789                        output << "[ ";
    790                         output << asmExpr->inout;
     790                        asmExpr->get_inout()->accept( *visitor );
    791791                        output << " ] ";
    792792                } // if
    793                 asmExpr->constraint->accept( *visitor );
     793                asmExpr->get_constraint()->accept( *visitor );
    794794                output << " ( ";
    795                 asmExpr->operand->accept( *visitor );
     795                asmExpr->get_operand()->accept( *visitor );
    796796                output << " )";
    797797        }
  • src/Common/PassVisitor.impl.h

    r2fa5bd2 raca6a54c  
    24522452
    24532453        indexerScopedAccept( node->result    , *this );
     2454        maybeAccept_impl   ( node->inout     , *this );
    24542455        maybeAccept_impl   ( node->constraint, *this );
    24552456        maybeAccept_impl   ( node->operand   , *this );
     
    24632464
    24642465        indexerScopedAccept( node->result    , *this );
     2466        maybeAccept_impl   ( node->inout     , *this );
    24652467        maybeAccept_impl   ( node->constraint, *this );
    24662468        maybeAccept_impl   ( node->operand   , *this );
     
    24752477        indexerScopedMutate( node->env       , *this );
    24762478        indexerScopedMutate( node->result    , *this );
     2479        maybeMutate_impl   ( node->inout     , *this );
    24772480        maybeMutate_impl   ( node->constraint, *this );
    24782481        maybeMutate_impl   ( node->operand   , *this );
  • src/Common/SemanticError.cc

    r2fa5bd2 raca6a54c  
    149149// Helpers
    150150namespace ErrorHelpers {
    151         Colors colors = Colors::Auto;
    152 
    153         static inline bool with_colors() {
    154                 return colors == Colors::Auto ? isatty( STDERR_FILENO ) : bool(colors);
    155         }
    156 
    157151        const std::string & error_str() {
    158                 static std::string str = with_colors() ? "\e[31merror:\e[39m " : "error: ";
     152                static std::string str = isatty( STDERR_FILENO ) ? "\e[31merror:\e[39m " : "error: ";
    159153                return str;
    160154        }
    161155
    162156        const std::string & warning_str() {
    163                 static std::string str = with_colors() ? "\e[95mwarning:\e[39m " : "warning: ";
     157                static std::string str = isatty( STDERR_FILENO ) ? "\e[95mwarning:\e[39m " : "warning: ";
    164158                return str;
    165159        }
    166160
    167161        const std::string & bold_ttycode() {
    168                 static std::string str = with_colors() ? "\e[1m" : "";
     162                static std::string str = isatty( STDERR_FILENO ) ? "\e[1m" : "";
    169163                return str;
    170164        }
    171165
    172166        const std::string & reset_font_ttycode() {
    173                 static std::string str = with_colors() ? "\e[0m" : "";
     167                static std::string str = isatty( STDERR_FILENO ) ? "\e[0m" : "";
    174168                return str;
    175169        }
  • src/Common/SemanticError.h

    r2fa5bd2 raca6a54c  
    9797// Helpers
    9898namespace ErrorHelpers {
    99         enum class Colors {
    100                 Never = false,
    101                 Always = true,
    102                 Auto,
    103         };
    104 
    105         extern Colors colors;
    106 
    10799        const std::string & error_str();
    108100        const std::string & warning_str();
  • src/Concurrency/Keywords.cc

    r2fa5bd2 raca6a54c  
    5959
    6060                Declaration * postmutate( StructDecl * decl );
    61                 DeclarationWithType * postmutate( FunctionDecl * decl );
    6261
    6362                void handle( StructDecl * );
     
    7877                KeywordCastExpr::Target cast_target;
    7978
    80                 StructDecl   * type_decl = nullptr;
    81                 FunctionDecl * dtor_decl = nullptr;
     79                StructDecl* type_decl = nullptr;
    8280        };
    8381
     
    9997                        "__thrd",
    10098                        "get_thread",
    101                         "thread keyword requires threads to be in scope, add #include <thread.hfa>\n",
     99                        "thread keyword requires threads to be in scope, add #include <thread.hfa>",
    102100                        true,
    103101                        KeywordCastExpr::Thread
     
    131129                        "__cor",
    132130                        "get_coroutine",
    133                         "coroutine keyword requires coroutines to be in scope, add #include <coroutine.hfa>\n",
     131                        "coroutine keyword requires coroutines to be in scope, add #include <coroutine.hfa>",
    134132                        true,
    135133                        KeywordCastExpr::Coroutine
     
    163161                        "__mon",
    164162                        "get_monitor",
    165                         "monitor keyword requires monitors to be in scope, add #include <monitor.hfa>\n",
     163                        "monitor keyword requires monitors to be in scope, add #include <monitor.hfa>",
    166164                        false,
    167165                        KeywordCastExpr::Monitor
     
    286284        }
    287285
    288         DeclarationWithType * ConcurrentSueKeyword::postmutate( FunctionDecl * decl ) {
    289                 if( !type_decl ) return decl;
    290                 if( !CodeGen::isDestructor( decl->name ) ) return decl;
    291 
    292                 auto params = decl->type->parameters;
    293                 if( params.size() != 1 ) return decl;
    294 
    295                 auto type = dynamic_cast<ReferenceType*>( params.front()->get_type() );
    296                 if( !type ) return decl;
    297 
    298                 auto stype = dynamic_cast<StructInstType*>( type->base );
    299                 if( !stype ) return decl;
    300                 if( stype->baseStruct != type_decl ) return decl;
    301 
    302                 if( !dtor_decl ) dtor_decl = decl;
    303                 return decl;
    304         }
    305 
    306286        Expression * ConcurrentSueKeyword::postmutate( KeywordCastExpr * cast ) {
    307287                if ( cast_target == cast->target ) {
    308288                        // convert (thread &)t to (thread_desc &)*get_thread(t), etc.
    309289                        if( !type_decl ) SemanticError( cast, context_error );
    310                         if( !dtor_decl ) SemanticError( cast, context_error );
    311                         assert( cast->result == nullptr );
    312                         cast->set_result( new ReferenceType( noQualifiers, new StructInstType( noQualifiers, type_decl ) ) );
    313                         cast->concrete_target.field  = field_name;
    314                         cast->concrete_target.getter = getter_name;
     290                        Expression * arg = cast->arg;
     291                        cast->arg = nullptr;
     292                        delete cast;
     293                        return new CastExpr(
     294                                UntypedExpr::createDeref(
     295                                        new UntypedExpr( new NameExpr( getter_name ), { arg } )
     296                                ),
     297                                new ReferenceType(
     298                                        noQualifiers,
     299                                        new StructInstType( noQualifiers, type_decl ) )
     300                                );
    315301                }
    316302                return cast;
     
    322308
    323309                if( !type_decl ) SemanticError( decl, context_error );
    324                 if( !dtor_decl ) SemanticError( decl, context_error );
    325310
    326311                FunctionDecl * func = forwardDeclare( decl );
  • src/ControlStruct/MLEMutator.cc

    r2fa5bd2 raca6a54c  
    231231
    232232        Statement *MLEMutator::mutateLoop( Statement *bodyLoop, Entry &e ) {
     233                // ensure loop body is a block
     234                CompoundStmt *newBody;
     235                if ( ! (newBody = dynamic_cast<CompoundStmt *>( bodyLoop )) ) {
     236                        newBody = new CompoundStmt();
     237                        newBody->get_kids().push_back( bodyLoop );
     238                } // if
     239
    233240                // only generate these when needed
    234                 if( !e.isContUsed() && !e.isBreakUsed() ) return bodyLoop;
    235 
    236                 // ensure loop body is a block
    237                 CompoundStmt * newBody = new CompoundStmt();
    238                 newBody->get_kids().push_back( bodyLoop );
    239241
    240242                if ( e.isContUsed() ) {
  • src/GenPoly/Lvalue.cc

    r2fa5bd2 raca6a54c  
    6060                }
    6161
    62                 struct ReferenceConversions final : public WithStmtsToAdd, public WithGuards {
     62                struct ReferenceConversions final : public WithStmtsToAdd {
    6363                        Expression * postmutate( CastExpr * castExpr );
    6464                        Expression * postmutate( AddressExpr * addrExpr );
     
    7171
    7272                struct FixIntrinsicResult final : public WithGuards {
    73                         enum {
    74                                 NoSkip,
    75                                 Skip,
    76                                 SkipInProgress
    77                         } skip = NoSkip;
    78 
    79                         void premutate( AsmExpr * ) { GuardValue( skip ); skip = Skip; }
    80                         void premutate( ApplicationExpr * ) { GuardValue( skip ); skip = (skip == Skip) ? SkipInProgress : NoSkip; }
    81 
    82 
    8373                        Expression * postmutate( ApplicationExpr * appExpr );
    8474                        void premutate( FunctionDecl * funcDecl );
     
    172162
    173163                Expression * FixIntrinsicResult::postmutate( ApplicationExpr * appExpr ) {
    174                         if ( skip != SkipInProgress && isIntrinsicReference( appExpr ) ) {
     164                        if ( isIntrinsicReference( appExpr ) ) {
    175165                                // eliminate reference types from intrinsic applications - now they return lvalues
    176166                                ReferenceType * result = strict_dynamic_cast< ReferenceType * >( appExpr->result );
  • src/Parser/parser.yy

    r2fa5bd2 raca6a54c  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Dec  7 10:43:44 2019
    13 // Update Count     : 4394
     12// Last Modified On : Sun Aug  4 21:48:23 2019
     13// Update Count     : 4364
    1414//
    1515
     
    211211} // forCtrl
    212212
    213 KeywordCastExpr::Target Aggregate2Target( DeclarationNode::Aggregate aggr ) {
    214         KeywordCastExpr::Target target;
    215         switch ( aggr ) {
    216           case DeclarationNode::Coroutine: target = KeywordCastExpr::Coroutine; break;
    217           case DeclarationNode::Monitor: target = KeywordCastExpr::Monitor; break;
    218           case DeclarationNode::Thread: target = KeywordCastExpr::Thread; break;
    219           default: abort();
    220         } // switch
    221         return target;
    222 } // Aggregate2Target
    223 
    224213
    225214bool forall = false, yyy = false;                                               // aggregate have one or more forall qualifiers ?
     
    376365%type<decl> abstract_parameter_declaration
    377366
    378 %type<aggKey> aggregate_key aggregate_data aggregate_control
     367%type<aggKey> aggregate_key
    379368%type<decl> aggregate_type aggregate_type_nobody
    380369
     
    661650        | postfix_expression '.' '[' field_name_list ']'        // CFA, tuple field selector
    662651                { $$ = new ExpressionNode( build_fieldSel( $1, build_tuple( $4 ) ) ); }
    663         | postfix_expression '.' aggregate_control
    664                 { $$ = new ExpressionNode( build_keyword_cast( Aggregate2Target( $3 ), $1 ) ); }
    665652        | postfix_expression ARROW identifier
    666653                { $$ = new ExpressionNode( build_pfieldSel( $1, build_varref( $3 ) ) ); }
     
    806793        | '(' type_no_function ')' cast_expression
    807794                { $$ = new ExpressionNode( build_cast( $2, $4 ) ); }
    808         | '(' aggregate_control '&' ')' cast_expression         // CFA
    809                 { $$ = new ExpressionNode( build_keyword_cast( Aggregate2Target( $2 ), $5 ) ); }
     795                // keyword cast cannot be grouped because of reduction in aggregate_key
     796        | '(' GENERATOR '&' ')' cast_expression                         // CFA
     797                { $$ = new ExpressionNode( build_keyword_cast( KeywordCastExpr::Coroutine, $5 ) ); }
     798        | '(' COROUTINE '&' ')' cast_expression                         // CFA
     799                { $$ = new ExpressionNode( build_keyword_cast( KeywordCastExpr::Coroutine, $5 ) ); }
     800        | '(' THREAD '&' ')' cast_expression                            // CFA
     801                { $$ = new ExpressionNode( build_keyword_cast( KeywordCastExpr::Thread, $5 ) ); }
     802        | '(' MONITOR '&' ')' cast_expression                           // CFA
     803                { $$ = new ExpressionNode( build_keyword_cast( KeywordCastExpr::Monitor, $5 ) ); }
    810804                // VIRTUAL cannot be opt because of look ahead issues
    811805        | '(' VIRTUAL ')' cast_expression                                       // CFA
     
    14291423asm_operand:                                                                                    // GCC
    14301424        string_literal '(' constant_expression ')'
    1431                 { $$ = new ExpressionNode( new AsmExpr( nullptr, $1, maybeMoveBuild< Expression >( $3 ) ) ); }
    1432         | '[' IDENTIFIER ']' string_literal '(' constant_expression ')'
    1433                 { $$ = new ExpressionNode( new AsmExpr( $2, $4, maybeMoveBuild< Expression >( $6 ) ) ); }
     1425                { $$ = new ExpressionNode( new AsmExpr( maybeMoveBuild< Expression >( (ExpressionNode *)nullptr ), $1, maybeMoveBuild< Expression >( $3 ) ) ); }
     1426        | '[' constant_expression ']' string_literal '(' constant_expression ')'
     1427                { $$ = new ExpressionNode( new AsmExpr( maybeMoveBuild< Expression >( $2 ), $4, maybeMoveBuild< Expression >( $6 ) ) ); }
    14341428        ;
    14351429
     
    20652059
    20662060aggregate_key:
    2067         aggregate_data
    2068         | aggregate_control
    2069         ;
    2070 
    2071 aggregate_data:
    20722061        STRUCT
    20732062                { yyy = true; $$ = DeclarationNode::Struct; }
    20742063        | UNION
    20752064                { yyy = true; $$ = DeclarationNode::Union; }
    2076         | EXCEPTION                                                                                     // CFA
     2065        | EXCEPTION
    20772066                { yyy = true; $$ = DeclarationNode::Exception; }
    2078         ;
    2079 
    2080 aggregate_control:                                                                              // CFA
    2081         GENERATOR
     2067        | GENERATOR
    20822068                { yyy = true; $$ = DeclarationNode::Coroutine; }
    20832069        | COROUTINE
     
    21102096                        distInl( $3 );
    21112097                }
    2112         | INLINE aggregate_control ';'                                          // CFA
    2113                 { SemanticError( yylloc, "INLINE aggregate control currently unimplemented." ); $$ = nullptr; }
    21142098        | typedef_declaration ';'                                                       // CFA
    21152099        | cfa_field_declaring_list ';'                                          // CFA, new style field declaration
  • src/ResolvExpr/AlternativeFinder.cc

    r2fa5bd2 raca6a54c  
    6969                void postvisit( CastExpr * castExpr );
    7070                void postvisit( VirtualCastExpr * castExpr );
    71                 void postvisit( KeywordCastExpr * castExpr );
    7271                void postvisit( UntypedMemberExpr * memberExpr );
    7372                void postvisit( MemberExpr * memberExpr );
     
    12561255        }
    12571256
    1258         void AlternativeFinder::Finder::postvisit( KeywordCastExpr * castExpr ) {
    1259                 assertf( castExpr->get_result(), "Cast target should have been set in Validate." );
    1260                 auto ref = dynamic_cast<ReferenceType*>(castExpr->get_result());
    1261                 assert(ref);
    1262                 auto inst = dynamic_cast<StructInstType*>(ref->base);
    1263                 assert(inst);
    1264                 auto target = inst->baseStruct;
    1265 
    1266                 AlternativeFinder finder( indexer, env );
    1267 
    1268                 auto pick_alternatives = [target, this](AltList & found, bool expect_ref) {
    1269                         for(auto & alt : found) {
    1270                                 Type * expr = alt.expr->get_result();
    1271                                 if(expect_ref) {
    1272                                         auto res = dynamic_cast<ReferenceType*>(expr);
    1273                                         if(!res) { continue; }
    1274                                         expr = res->base;
    1275                                 }
    1276 
    1277                                 if(auto insttype = dynamic_cast<TypeInstType*>(expr)) {
    1278                                         auto td = alt.env.lookup(insttype->name);
    1279                                         if(!td) { continue; }
    1280                                         expr = td->type;
    1281                                 }
    1282 
    1283                                 if(auto base = dynamic_cast<StructInstType*>(expr)) {
    1284                                         if(base->baseStruct == target) {
    1285                                                 alternatives.push_back(
    1286                                                         std::move(alt)
    1287                                                 );
    1288                                         }
    1289                                 }
    1290                         }
    1291                 };
    1292 
    1293                 try {
    1294                         // Attempt 1 : turn (thread&)X into (thread_desc&)X.__thrd
    1295                         // Clone is purely for memory management
    1296                         std::unique_ptr<Expression> tech1 { new UntypedMemberExpr(new NameExpr(castExpr->concrete_target.field), castExpr->arg->clone()) };
    1297 
    1298                         // don't prune here, since it's guaranteed all alternatives will have the same type
    1299                         finder.findWithoutPrune( tech1.get() );
    1300                         pick_alternatives(finder.alternatives, false);
    1301 
    1302                         return;
    1303                 } catch(SemanticErrorException & ) {}
    1304 
    1305                 // Fallback : turn (thread&)X into (thread_desc&)get_thread(X)
    1306                 std::unique_ptr<Expression> fallback { UntypedExpr::createDeref( new UntypedExpr(new NameExpr(castExpr->concrete_target.getter), { castExpr->arg->clone() })) };
    1307                 // don't prune here, since it's guaranteed all alternatives will have the same type
    1308                 finder.findWithoutPrune( fallback.get() );
    1309 
    1310                 pick_alternatives(finder.alternatives, true);
    1311 
    1312                 // Whatever happens here, we have no more fallbacks
    1313         }
    1314 
    13151257        namespace {
    13161258                /// Gets name from untyped member expression (member must be NameExpr)
  • src/ResolvExpr/Resolver.cc

    r2fa5bd2 raca6a54c  
    485485                visit_children = false;
    486486                findVoidExpression( asmExpr->operand, indexer );
     487                if ( asmExpr->get_inout() ) {
     488                        findVoidExpression( asmExpr->inout, indexer );
     489                } // if
    487490        }
    488491
     
    13621365                asmExpr = ast::mutate_field(
    13631366                        asmExpr, &ast::AsmExpr::operand, findVoidExpression( asmExpr->operand, symtab ) );
     1367
     1368                if ( asmExpr->inout ) {
     1369                        asmExpr = ast::mutate_field(
     1370                                asmExpr, &ast::AsmExpr::inout, findVoidExpression( asmExpr->inout, symtab ) );
     1371                }
    13641372
    13651373                return asmExpr;
  • src/SynTree/Expression.cc

    r2fa5bd2 raca6a54c  
    527527}
    528528
    529 AsmExpr::AsmExpr( const AsmExpr & other ) : Expression( other ), inout( other.inout ), constraint( maybeClone( other.constraint ) ), operand( maybeClone( other.operand ) ) {}
     529AsmExpr::AsmExpr( const AsmExpr & other ) : Expression( other ), inout( maybeClone( other.inout ) ), constraint( maybeClone( other.constraint ) ), operand( maybeClone( other.operand ) ) {}
    530530
    531531
    532532void AsmExpr::print( std::ostream & os, Indenter indent ) const {
    533533        os << "Asm Expression: " << std::endl;
    534         if ( !inout.empty() ) os <<  "[" << inout << "] ";
     534        if ( inout ) inout->print( os, indent+1 );
    535535        if ( constraint ) constraint->print( os, indent+1 );
    536536        if ( operand ) operand->print( os, indent+1 );
  • src/SynTree/Expression.h

    r2fa5bd2 raca6a54c  
    231231        enum Target {
    232232                Coroutine, Thread, Monitor, NUMBER_OF_TARGETS
    233         };
    234         struct Concrete {
    235                 std::string field;
    236                 std::string getter;
    237         };
    238         Target target;
    239         Concrete concrete_target;
     233        } target;
    240234
    241235        KeywordCastExpr( Expression * arg, Target target );
     
    581575class AsmExpr : public Expression {
    582576  public:
    583         std::string inout;
     577        Expression * inout;
    584578        Expression * constraint;
    585579        Expression * operand;
    586580
    587         AsmExpr( const std::string * _inout, Expression * constraint, Expression * operand ) : inout( _inout ? *_inout : "" ), constraint( constraint ), operand( operand ) { delete _inout; }
     581        AsmExpr( Expression * inout, Expression * constraint, Expression * operand ) : inout( inout ), constraint( constraint ), operand( operand ) {}
    588582        AsmExpr( const AsmExpr & other );
    589         virtual ~AsmExpr() { delete constraint; delete operand; };
     583        virtual ~AsmExpr() { delete inout; delete constraint; delete operand; };
     584
     585        Expression * get_inout() const { return inout; }
     586        void set_inout( Expression * newValue ) { inout = newValue; }
     587
     588        Expression * get_constraint() const { return constraint; }
     589        void set_constraint( Expression * newValue ) { constraint = newValue; }
     590
     591        Expression * get_operand() const { return operand; }
     592        void set_operand( Expression * newValue ) { operand = newValue; }
    590593
    591594        virtual AsmExpr * clone() const override { return new AsmExpr( * this ); }
  • src/cfa.make

    r2fa5bd2 raca6a54c  
    44LTCFACOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
    55        $(LIBTOOLFLAGS) --mode=compile $(CFACC) $(DEFS) \
    6         $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(AM_CFLAGS) $(CFAFLAGS) $(CFLAGS)
     6        $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(CFAFLAGS) \
     7        $(AM_CFLAGS) $(CFLAGS)
    78
    89AM_V_CFA = $(am__v_CFA_@AM_V@)
  • src/main.cc

    r2fa5bd2 raca6a54c  
    407407
    408408
    409 static const char optstring[] = ":c:ghlLmNnpP:S:twW:D:";
     409static const char optstring[] = ":hlLmNnpP:S:twW:D:";
    410410
    411411enum { PreludeDir = 128 };
    412412static struct option long_opts[] = {
    413         { "colors", required_argument, nullptr, 'c' },
    414         { "gdb", no_argument, nullptr, 'g' },
    415413        { "help", no_argument, nullptr, 'h' },
    416414        { "libcfa", no_argument, nullptr, 'l' },
     
    424422        { "statistics", required_argument, nullptr, 'S' },
    425423        { "tree", no_argument, nullptr, 't' },
     424        { "gdb", no_argument, nullptr, 'g' },
    426425        { "", no_argument, nullptr, 0 },                                        // -w
    427426        { "", no_argument, nullptr, 0 },                                        // -W
     
    431430
    432431static const char * description[] = {
    433         "diagnostic color: never, always, or auto.",          // -c
    434         "wait for gdb to attach",                             // -g
    435         "print help message",                                 // -h
    436         "generate libcfa.c",                                  // -l
    437         "generate line marks",                                // -L
    438         "do not replace main",                                // -m
    439         "do not generate line marks",                         // -N
    440         "do not read prelude",                                // -n
     432        "print help message",                                                           // -h
     433        "generate libcfa.c",                                                            // -l
     434        "generate line marks",                                                          // -L
     435        "do not replace main",                                                          // -m
     436        "do not generate line marks",                                           // -N
     437        "do not read prelude",                                                          // -n
    441438        "generate prototypes for prelude functions",            // -p
    442         "print",                                              // -P
     439        "print",                                                                                        // -P
    443440        "<directory> prelude directory for debug/nodebug",      // no flag
    444441        "<option-list> enable profiling information:\n          counters,heap,time,all,none", // -S
    445         "building cfa standard lib",                          // -t
    446         "",                                                   // -w
    447         "",                                                   // -W
    448         "",                                                   // -D
     442        "building cfa standard lib",                                                                    // -t
     443        "wait for gdb to attach",                                                                       // -g
     444        "",                                                                                                     // -w
     445        "",                                                                                                     // -W
     446        "",                                                                                                     // -D
    449447}; // description
    450448
     
    514512        while ( (c = getopt_long( argc, argv, optstring, long_opts, nullptr )) != -1 ) {
    515513                switch ( c ) {
    516                   case 'c':                                                                             // diagnostic colors
    517                         if ( strcmp( optarg, "always" ) == 0 ) {
    518                                 ErrorHelpers::colors = ErrorHelpers::Colors::Always;
    519                         } else if ( strcmp( optarg, "never" ) == 0 ) {
    520                                 ErrorHelpers::colors = ErrorHelpers::Colors::Never;
    521                         } else if ( strcmp( optarg, "auto" ) == 0 ) {
    522                                 ErrorHelpers::colors = ErrorHelpers::Colors::Auto;
    523                         } // if
    524                         break;
    525514                  case 'h':                                                                             // help message
    526515                        usage( argv );                                                          // no return
  • tests/.expect/alloc.txt

    r2fa5bd2 raca6a54c  
    3030CFA resize array alloc
    31310xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef
    32 CFA resize array alloc
     32CFA resize array alloc, fill
    33330xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede
    34 CFA resize array alloc
     34CFA resize array alloc, fill
    35350xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef
    3636CFA resize array alloc, fill
    37 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede
     370xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0x1010101 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede 0xdededede
    3838
    3939C   memalign 42 42.5
  • tests/.expect/gccExtensions.x64.txt

    r2fa5bd2 raca6a54c  
    1212    asm volatile ( "mov %1, %0\n\t" "add $1, %0" : "=" "r" ( _X3dsti_2 ) :  :  );
    1313    asm volatile ( "mov %1, %0\n\t" "add $1, %0" : "=r" ( _X3dsti_2 ) : "r" ( _X3srci_2 ) :  );
    14     asm ( "mov %1, %0\n\t" "add $1, %0" : "=r" ( _X3dsti_2 ), "=r" ( _X3srci_2 ) : [ src ] "r" ( _X3dsti_2 ) : "r0" );
     14    asm ( "mov %1, %0\n\t" "add $1, %0" : "=r" ( _X3dsti_2 ), "=r" ( _X3srci_2 ) : [ _X3srci_2 ] "r" ( _X3dsti_2 ) : "r0" );
    1515    L2: L1: asm goto ( "frob %%r5, %1; jc %l[L1]; mov (%2), %%r5" :  : "r" ( _X3srci_2 ), "r" ( (&_X3dsti_2) ) : "r5", "memory" : L1, L2 );
    1616    double _Complex _X2c1Cd_2;
  • tests/.expect/gccExtensions.x86.txt

    r2fa5bd2 raca6a54c  
    1212    asm volatile ( "mov %1, %0\n\t" "add $1, %0" : "=" "r" ( _X3dsti_2 ) :  :  );
    1313    asm volatile ( "mov %1, %0\n\t" "add $1, %0" : "=r" ( _X3dsti_2 ) : "r" ( _X3srci_2 ) :  );
    14     asm ( "mov %1, %0\n\t" "add $1, %0" : "=r" ( _X3dsti_2 ), "=r" ( _X3srci_2 ) : [ src ] "r" ( _X3dsti_2 ) : "r0" );
     14    asm ( "mov %1, %0\n\t" "add $1, %0" : "=r" ( _X3dsti_2 ), "=r" ( _X3srci_2 ) : [ _X3srci_2 ] "r" ( _X3dsti_2 ) : "r0" );
    1515    L2: L1: asm goto ( "frob %%r5, %1; jc %l[L1]; mov (%2), %%r5" :  : "r" ( _X3srci_2 ), "r" ( (&_X3dsti_2) ) : "r5", "memory" : L1, L2 );
    1616    double _Complex _X2c1Cd_2;
  • tests/.expect/references.txt

    r2fa5bd2 raca6a54c  
    36363
    37373 9 { 1., 7. }, [1, 2, 3]
    38 4
    3938Destructing a Y
    4039Destructing a Y
  • tests/Makefile.am

    r2fa5bd2 raca6a54c  
    4646
    4747# adjust CC to current flags
    48 CC = $(if $(DISTCC_CFA_PATH),distcc $(DISTCC_CFA_PATH) ${ARCH_FLAGS},$(TARGET_CFA) ${DEBUG_FLAGS} ${ARCH_FLAGS})
     48CC = $(if $(DISTCC_CFA_PATH),distcc $(DISTCC_CFA_PATH),$(TARGET_CFA) ${DEBUG_FLAGS} ${ARCH_FLAGS})
    4949CFACC = $(CC)
    5050
     
    5353
    5454# adjusted CC but without the actual distcc call
    55 CFACCLOCAL = $(if $(DISTCC_CFA_PATH),$(DISTCC_CFA_PATH) ${ARCH_FLAGS},$(TARGET_CFA) ${DEBUG_FLAGS} ${ARCH_FLAGS})
     55CFACCLOCAL = $(if $(DISTCC_CFA_PATH),$(DISTCC_CFA_PATH),$(TARGET_CFA) ${DEBUG_FLAGS} ${ARCH_FLAGS})
    5656
    5757PRETTY_PATH=mkdir -p $(dir $(abspath ${@})) && cd ${srcdir} &&
  • tests/Makefile.in

    r2fa5bd2 raca6a54c  
    214214
    215215# adjust CC to current flags
    216 CC = $(if $(DISTCC_CFA_PATH),distcc $(DISTCC_CFA_PATH) ${ARCH_FLAGS},$(TARGET_CFA) ${DEBUG_FLAGS} ${ARCH_FLAGS})
     216CC = $(if $(DISTCC_CFA_PATH),distcc $(DISTCC_CFA_PATH),$(TARGET_CFA) ${DEBUG_FLAGS} ${ARCH_FLAGS})
    217217CCAS = @CCAS@
    218218CCASDEPMODE = @CCASDEPMODE@
     
    358358LTCFACOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
    359359        $(LIBTOOLFLAGS) --mode=compile $(CFACC) $(DEFS) \
    360         $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(AM_CFLAGS) $(CFAFLAGS) $(CFLAGS)
     360        $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CFAFLAGS) $(CFAFLAGS) \
     361        $(AM_CFLAGS) $(CFLAGS)
    361362
    362363AM_V_CFA = $(am__v_CFA_@AM_V@)
     
    404405
    405406# adjusted CC but without the actual distcc call
    406 CFACCLOCAL = $(if $(DISTCC_CFA_PATH),$(DISTCC_CFA_PATH) ${ARCH_FLAGS},$(TARGET_CFA) ${DEBUG_FLAGS} ${ARCH_FLAGS})
     407CFACCLOCAL = $(if $(DISTCC_CFA_PATH),$(DISTCC_CFA_PATH),$(TARGET_CFA) ${DEBUG_FLAGS} ${ARCH_FLAGS})
    407408PRETTY_PATH = mkdir -p $(dir $(abspath ${@})) && cd ${srcdir} &&
    408409avl_test_SOURCES = avltree/avl_test.cfa avltree/avl0.cfa avltree/avl1.cfa avltree/avl2.cfa avltree/avl3.cfa avltree/avl4.cfa avltree/avl-private.cfa
  • tests/alloc.cfa

    r2fa5bd2 raca6a54c  
    1010// Created On       : Wed Feb  3 07:56:22 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Nov 22 15:34:19 2019
    13 // Update Count     : 404
     12// Last Modified On : Sun Oct 20 21:45:21 2019
     13// Update Count     : 391
    1414//
    1515
     
    126126
    127127        p = alloc( p, 2 * dim );                            // CFA resize array alloc
    128         for ( i; dim ~ 2 * dim ) { p[i] = 0x1010101; }          // fill upper part
     128        for ( i; dim ~ 2 * dim ) { p[i] = 0x1010101; }
    129129        printf( "CFA resize array alloc\n" );
    130130        for ( i; 2 * dim ) { printf( "%#x ", p[i] ); }
     
    139139
    140140        p = alloc_set( p, 3 * dim, fill );                                      // CFA resize array alloc, fill
    141         printf( "CFA resize array alloc\n" );
     141        printf( "CFA resize array alloc, fill\n" );
    142142        for ( i; 3 * dim ) { printf( "%#x ", p[i] ); }
    143143        printf( "\n" );
     
    145145
    146146        p = alloc_set( p, dim, fill );                                          // CFA resize array alloc, fill
    147         printf( "CFA resize array alloc\n" );
     147        printf( "CFA resize array alloc, fill\n" );
    148148        for ( i; dim ) { printf( "%#x ", p[i] ); }
    149149        printf( "\n" );
  • tests/builtins/sync.cfa

    r2fa5bd2 raca6a54c  
    44void foo() {
    55        volatile _Bool * vpB = 0; _Bool vB = 0;
    6         volatile char * vpc = 0; char * rpc = 0; char vc = 0;
    7         volatile short * vps = 0; short * rps = 0; short vs = 0;
    8         volatile int * vpi = 0; int * rpi = 0; int vi = 0;
    9         volatile long int * vpl = 0; long int * rpl = 0; long int vl = 0;
    10         volatile long long int * vpll = 0; long long int * rpll = 0; long long int vll = 0;
    11         #if defined(__SIZEOF_INT128__)
    12         volatile __int128 * vplll = 0; __int128 * rplll = 0; __int128 vlll = 0;
     6        volatile char * vp1 = 0; char * rp1 = 0; char v1 = 0;
     7        volatile short * vp2 = 0; short * rp2 = 0; short v2 = 0;
     8        volatile int * vp4 = 0; int * rp4 = 0; int v4 = 0;
     9        volatile long long int * vp8 = 0; long long int * rp8 = 0; long long int v8 = 0;
     10        #if defined(__SIZEOF_INT128__)
     11        volatile __int128 * vp16 = 0; __int128 * rp16 = 0; __int128 v16 = 0;
    1312        #endif
    1413        struct type * volatile * vpp = 0; struct type ** rpp = 0; struct type * vp = 0;
    1514
    16         { char ret; ret = __sync_fetch_and_add(vpc, vc); }
    17         { short ret; ret = __sync_fetch_and_add(vps, vs); }
    18         { int ret; ret = __sync_fetch_and_add(vpi, vi); }
    19         { long int ret; ret = __sync_fetch_and_add(vpl, vl); }
    20         { long long int ret; ret = __sync_fetch_and_add(vpll, vll); }
    21         #if defined(__SIZEOF_INT128__)
    22         { __int128 ret; ret = __sync_fetch_and_add(vplll, vlll); }
    23         #endif
    24 
    25         { char ret; ret = __sync_fetch_and_sub(vpc, vc); }
    26         { short ret; ret = __sync_fetch_and_sub(vps, vs); }
    27         { int ret; ret = __sync_fetch_and_sub(vpi, vi); }
    28         { long int ret; ret = __sync_fetch_and_sub(vpl, vl); }
    29         { long long int ret; ret = __sync_fetch_and_sub(vpll, vll); }
    30         #if defined(__SIZEOF_INT128__)
    31         { __int128 ret; ret = __sync_fetch_and_sub(vplll, vlll); }
    32         #endif
    33 
    34         { char ret; ret = __sync_fetch_and_or(vpc, vc); }
    35         { short ret; ret = __sync_fetch_and_or(vps, vs); }
    36         { int ret; ret = __sync_fetch_and_or(vpi, vi); }
    37         { long int ret; ret = __sync_fetch_and_or(vpl, vl); }
    38         { long long int ret; ret = __sync_fetch_and_or(vpll, vll); }
    39         #if defined(__SIZEOF_INT128__)
    40         { __int128 ret; ret = __sync_fetch_and_or(vplll, vlll); }
    41         #endif
    42 
    43         { char ret; ret = __sync_fetch_and_and(vpc, vc); }
    44         { short ret; ret = __sync_fetch_and_and(vps, vs); }
    45         { int ret; ret = __sync_fetch_and_and(vpi, vi); }
    46         { long int ret; ret = __sync_fetch_and_and(vpl, vl); }
    47         { long long int ret; ret = __sync_fetch_and_and(vpll, vll); }
    48         #if defined(__SIZEOF_INT128__)
    49         { __int128 ret; ret = __sync_fetch_and_and(vplll, vlll); }
    50         #endif
    51 
    52         { char ret; ret = __sync_fetch_and_xor(vpc, vc); }
    53         { short ret; ret = __sync_fetch_and_xor(vps, vs); }
    54         { int ret; ret = __sync_fetch_and_xor(vpi, vi); }
    55         { long int ret; ret = __sync_fetch_and_xor(vpl, vl); }
    56         { long long int ret; ret = __sync_fetch_and_xor(vpll, vll); }
    57         #if defined(__SIZEOF_INT128__)
    58         { __int128 ret; ret = __sync_fetch_and_xor(vplll, vlll); }
    59         #endif
    60 
    61         { char ret; ret = __sync_fetch_and_nand(vpc, vc); }
    62         { short ret; ret = __sync_fetch_and_nand(vps, vs); }
    63         { int ret; ret = __sync_fetch_and_nand(vpi, vi); }
    64         { long int ret; ret = __sync_fetch_and_nand(vpl, vl); }
    65         { long long int ret; ret = __sync_fetch_and_nand(vpll, vll); }
    66         #if defined(__SIZEOF_INT128__)
    67         { __int128 ret; ret = __sync_fetch_and_nand(vplll, vlll); }
    68         { __int128 ret; ret = __sync_fetch_and_nand_16(vplll, vlll); }
    69         #endif
    70 
    71         { char ret; ret = __sync_add_and_fetch(vpc, vc); }
    72         { short ret; ret = __sync_add_and_fetch(vps, vs); }
    73         { int ret; ret = __sync_add_and_fetch(vpi, vi); }
    74         { long int ret; ret = __sync_add_and_fetch(vpl, vl); }
    75         { long long int ret; ret = __sync_add_and_fetch(vpll, vll); }
    76         #if defined(__SIZEOF_INT128__)
    77         { __int128 ret; ret = __sync_add_and_fetch(vplll, vlll); }
    78         #endif
    79 
    80         { char ret; ret = __sync_sub_and_fetch(vpc, vc); }
    81         { short ret; ret = __sync_sub_and_fetch(vps, vs); }
    82         { int ret; ret = __sync_sub_and_fetch(vpi, vi); }
    83         { long int ret; ret = __sync_sub_and_fetch(vpl, vl); }
    84         { long long int ret; ret = __sync_sub_and_fetch(vpll, vll); }
    85         #if defined(__SIZEOF_INT128__)
    86         { __int128 ret; ret = __sync_sub_and_fetch(vplll, vlll); }
    87         #endif
    88 
    89         { char ret; ret = __sync_or_and_fetch(vpc, vc); }
    90         { short ret; ret = __sync_or_and_fetch(vps, vs); }
    91         { int ret; ret = __sync_or_and_fetch(vpi, vi); }
    92         { long int ret; ret = __sync_or_and_fetch(vpl, vl); }
    93         { long long int ret; ret = __sync_or_and_fetch(vpll, vll); }
    94         #if defined(__SIZEOF_INT128__)
    95         { __int128 ret; ret = __sync_or_and_fetch(vplll, vlll); }
    96         #endif
    97 
    98         { char ret; ret = __sync_and_and_fetch(vpc, vc); }
    99         { short ret; ret = __sync_and_and_fetch(vps, vs); }
    100         { int ret; ret = __sync_and_and_fetch(vpi, vi); }
    101         { long int ret; ret = __sync_and_and_fetch(vpl, vl); }
    102         { long long int ret; ret = __sync_and_and_fetch(vpll, vll); }
    103         #if defined(__SIZEOF_INT128__)
    104         { __int128 ret; ret = __sync_and_and_fetch(vplll, vlll); }
    105         #endif
    106 
    107         { char ret; ret = __sync_xor_and_fetch(vpc, vc); }
    108         { short ret; ret = __sync_xor_and_fetch(vps, vs); }
    109         { int ret; ret = __sync_xor_and_fetch(vpi, vi); }
    110         { long int ret; ret = __sync_xor_and_fetch(vpl, vl); }
    111         { long long int ret; ret = __sync_xor_and_fetch(vpll, vll); }
    112         #if defined(__SIZEOF_INT128__)
    113         { __int128 ret; ret = __sync_xor_and_fetch(vplll, vlll); }
    114         #endif
    115 
    116         { char ret; ret = __sync_nand_and_fetch(vpc, vc); }
    117         { short ret; ret = __sync_nand_and_fetch(vps, vs); }
    118         { int ret; ret = __sync_nand_and_fetch(vpi, vi); }
    119         { long int ret; ret = __sync_nand_and_fetch(vpl, vl); }
    120         { long long int ret; ret = __sync_nand_and_fetch(vpll, vll); }
    121         #if defined(__SIZEOF_INT128__)
    122         { __int128 ret; ret = __sync_nand_and_fetch(vplll, vlll); }
    123         #endif
    124 
    125         { _Bool ret; ret = __sync_bool_compare_and_swap(vpc, vc, vc); }
    126         { _Bool ret; ret = __sync_bool_compare_and_swap(vps, vs, vs); }
    127         { _Bool ret; ret = __sync_bool_compare_and_swap(vpi, vi, vi); }
    128         { _Bool ret; ret = __sync_bool_compare_and_swap(vpl, vl, vl); }
    129         { _Bool ret; ret = __sync_bool_compare_and_swap(vpll, vll, vll); }
    130         #if defined(__SIZEOF_INT128__)
    131         { _Bool ret; ret = __sync_bool_compare_and_swap(vplll, vlll, vlll); }
     15        { char ret; ret = __sync_fetch_and_add(vp1, v1); }
     16        { char ret; ret = __sync_fetch_and_add_1(vp1, v1); }
     17        { short ret; ret = __sync_fetch_and_add(vp2, v2); }
     18        { short ret; ret = __sync_fetch_and_add_2(vp2, v2); }
     19        { int ret; ret = __sync_fetch_and_add(vp4, v4); }
     20        { int ret; ret = __sync_fetch_and_add_4(vp4, v4); }
     21        { long long int ret; ret = __sync_fetch_and_add(vp8, v8); }
     22        { long long int ret; ret = __sync_fetch_and_add_8(vp8, v8); }
     23        #if defined(__SIZEOF_INT128__)
     24        { __int128 ret; ret = __sync_fetch_and_add(vp16, v16); }
     25        { __int128 ret; ret = __sync_fetch_and_add_16(vp16, v16); }
     26        #endif
     27
     28        { char ret; ret = __sync_fetch_and_sub(vp1, v1); }
     29        { char ret; ret = __sync_fetch_and_sub_1(vp1, v1); }
     30        { short ret; ret = __sync_fetch_and_sub(vp2, v2); }
     31        { short ret; ret = __sync_fetch_and_sub_2(vp2, v2); }
     32        { int ret; ret = __sync_fetch_and_sub(vp4, v4); }
     33        { int ret; ret = __sync_fetch_and_sub_4(vp4, v4); }
     34        { long long int ret; ret = __sync_fetch_and_sub(vp8, v8); }
     35        { long long int ret; ret = __sync_fetch_and_sub_8(vp8, v8); }
     36        #if defined(__SIZEOF_INT128__)
     37        { __int128 ret; ret = __sync_fetch_and_sub(vp16, v16); }
     38        { __int128 ret; ret = __sync_fetch_and_sub_16(vp16, v16); }
     39        #endif
     40
     41        { char ret; ret = __sync_fetch_and_or(vp1, v1); }
     42        { char ret; ret = __sync_fetch_and_or_1(vp1, v1); }
     43        { short ret; ret = __sync_fetch_and_or(vp2, v2); }
     44        { short ret; ret = __sync_fetch_and_or_2(vp2, v2); }
     45        { int ret; ret = __sync_fetch_and_or(vp4, v4); }
     46        { int ret; ret = __sync_fetch_and_or_4(vp4, v4); }
     47        { long long int ret; ret = __sync_fetch_and_or(vp8, v8); }
     48        { long long int ret; ret = __sync_fetch_and_or_8(vp8, v8); }
     49        #if defined(__SIZEOF_INT128__)
     50        { __int128 ret; ret = __sync_fetch_and_or(vp16, v16); }
     51        { __int128 ret; ret = __sync_fetch_and_or_16(vp16, v16); }
     52        #endif
     53
     54        { char ret; ret = __sync_fetch_and_and(vp1, v1); }
     55        { char ret; ret = __sync_fetch_and_and_1(vp1, v1); }
     56        { short ret; ret = __sync_fetch_and_and(vp2, v2); }
     57        { short ret; ret = __sync_fetch_and_and_2(vp2, v2); }
     58        { int ret; ret = __sync_fetch_and_and(vp4, v4); }
     59        { int ret; ret = __sync_fetch_and_and_4(vp4, v4); }
     60        { long long int ret; ret = __sync_fetch_and_and(vp8, v8); }
     61        { long long int ret; ret = __sync_fetch_and_and_8(vp8, v8); }
     62        #if defined(__SIZEOF_INT128__)
     63        { __int128 ret; ret = __sync_fetch_and_and(vp16, v16); }
     64        { __int128 ret; ret = __sync_fetch_and_and_16(vp16, v16); }
     65        #endif
     66
     67        { char ret; ret = __sync_fetch_and_xor(vp1, v1); }
     68        { char ret; ret = __sync_fetch_and_xor_1(vp1, v1); }
     69        { short ret; ret = __sync_fetch_and_xor(vp2, v2); }
     70        { short ret; ret = __sync_fetch_and_xor_2(vp2, v2); }
     71        { int ret; ret = __sync_fetch_and_xor(vp4, v4); }
     72        { int ret; ret = __sync_fetch_and_xor_4(vp4, v4); }
     73        { long long int ret; ret = __sync_fetch_and_xor(vp8, v8); }
     74        { long long int ret; ret = __sync_fetch_and_xor_8(vp8, v8); }
     75        #if defined(__SIZEOF_INT128__)
     76        { __int128 ret; ret = __sync_fetch_and_xor(vp16, v16); }
     77        { __int128 ret; ret = __sync_fetch_and_xor_16(vp16, v16); }
     78        #endif
     79
     80        { char ret; ret = __sync_fetch_and_nand(vp1, v1); }
     81        { char ret; ret = __sync_fetch_and_nand_1(vp1, v1); }
     82        { short ret; ret = __sync_fetch_and_nand(vp2, v2); }
     83        { short ret; ret = __sync_fetch_and_nand_2(vp2, v2); }
     84        { int ret; ret = __sync_fetch_and_nand(vp4, v4); }
     85        { int ret; ret = __sync_fetch_and_nand_4(vp4, v4); }
     86        { long long int ret; ret = __sync_fetch_and_nand(vp8, v8); }
     87        { long long int ret; ret = __sync_fetch_and_nand_8(vp8, v8); }
     88        #if defined(__SIZEOF_INT128__)
     89        { __int128 ret; ret = __sync_fetch_and_nand(vp16, v16); }
     90        { __int128 ret; ret = __sync_fetch_and_nand_16(vp16, v16); }
     91        #endif
     92
     93        { char ret; ret = __sync_add_and_fetch(vp1, v1); }
     94        { char ret; ret = __sync_add_and_fetch_1(vp1, v1); }
     95        { short ret; ret = __sync_add_and_fetch(vp2, v2); }
     96        { short ret; ret = __sync_add_and_fetch_2(vp2, v2); }
     97        { int ret; ret = __sync_add_and_fetch(vp4, v4); }
     98        { int ret; ret = __sync_add_and_fetch_4(vp4, v4); }
     99        { long long int ret; ret = __sync_add_and_fetch(vp8, v8); }
     100        { long long int ret; ret = __sync_add_and_fetch_8(vp8, v8); }
     101        #if defined(__SIZEOF_INT128__)
     102        { __int128 ret; ret = __sync_add_and_fetch(vp16, v16); }
     103        { __int128 ret; ret = __sync_add_and_fetch_16(vp16, v16); }
     104        #endif
     105
     106        { char ret; ret = __sync_sub_and_fetch(vp1, v1); }
     107        { char ret; ret = __sync_sub_and_fetch_1(vp1, v1); }
     108        { short ret; ret = __sync_sub_and_fetch(vp2, v2); }
     109        { short ret; ret = __sync_sub_and_fetch_2(vp2, v2); }
     110        { int ret; ret = __sync_sub_and_fetch(vp4, v4); }
     111        { int ret; ret = __sync_sub_and_fetch_4(vp4, v4); }
     112        { long long int ret; ret = __sync_sub_and_fetch(vp8, v8); }
     113        { long long int ret; ret = __sync_sub_and_fetch_8(vp8, v8); }
     114        #if defined(__SIZEOF_INT128__)
     115        { __int128 ret; ret = __sync_sub_and_fetch(vp16, v16); }
     116        { __int128 ret; ret = __sync_sub_and_fetch_16(vp16, v16); }
     117        #endif
     118
     119        { char ret; ret = __sync_or_and_fetch(vp1, v1); }
     120        { char ret; ret = __sync_or_and_fetch_1(vp1, v1); }
     121        { short ret; ret = __sync_or_and_fetch(vp2, v2); }
     122        { short ret; ret = __sync_or_and_fetch_2(vp2, v2); }
     123        { int ret; ret = __sync_or_and_fetch(vp4, v4); }
     124        { int ret; ret = __sync_or_and_fetch_4(vp4, v4); }
     125        { long long int ret; ret = __sync_or_and_fetch(vp8, v8); }
     126        { long long int ret; ret = __sync_or_and_fetch_8(vp8, v8); }
     127        #if defined(__SIZEOF_INT128__)
     128        { __int128 ret; ret = __sync_or_and_fetch(vp16, v16); }
     129        { __int128 ret; ret = __sync_or_and_fetch_16(vp16, v16); }
     130        #endif
     131
     132        { char ret; ret = __sync_and_and_fetch(vp1, v1); }
     133        { char ret; ret = __sync_and_and_fetch_1(vp1, v1); }
     134        { short ret; ret = __sync_and_and_fetch(vp2, v2); }
     135        { short ret; ret = __sync_and_and_fetch_2(vp2, v2); }
     136        { int ret; ret = __sync_and_and_fetch(vp4, v4); }
     137        { int ret; ret = __sync_and_and_fetch_4(vp4, v4); }
     138        { long long int ret; ret = __sync_and_and_fetch(vp8, v8); }
     139        { long long int ret; ret = __sync_and_and_fetch_8(vp8, v8); }
     140        #if defined(__SIZEOF_INT128__)
     141        { __int128 ret; ret = __sync_and_and_fetch(vp16, v16); }
     142        { __int128 ret; ret = __sync_and_and_fetch_16(vp16, v16); }
     143        #endif
     144
     145        { char ret; ret = __sync_xor_and_fetch(vp1, v1); }
     146        { char ret; ret = __sync_xor_and_fetch_1(vp1, v1); }
     147        { short ret; ret = __sync_xor_and_fetch(vp2, v2); }
     148        { short ret; ret = __sync_xor_and_fetch_2(vp2, v2); }
     149        { int ret; ret = __sync_xor_and_fetch(vp4, v4); }
     150        { int ret; ret = __sync_xor_and_fetch_4(vp4, v4); }
     151        { long long int ret; ret = __sync_xor_and_fetch(vp8, v8); }
     152        { long long int ret; ret = __sync_xor_and_fetch_8(vp8, v8); }
     153        #if defined(__SIZEOF_INT128__)
     154        { __int128 ret; ret = __sync_xor_and_fetch(vp16, v16); }
     155        { __int128 ret; ret = __sync_xor_and_fetch_16(vp16, v16); }
     156        #endif
     157
     158        { char ret; ret = __sync_nand_and_fetch(vp1, v1); }
     159        { char ret; ret = __sync_nand_and_fetch_1(vp1, v1); }
     160        { short ret; ret = __sync_nand_and_fetch(vp2, v2); }
     161        { short ret; ret = __sync_nand_and_fetch_2(vp2, v2); }
     162        { int ret; ret = __sync_nand_and_fetch(vp4, v4); }
     163        { int ret; ret = __sync_nand_and_fetch_4(vp4, v4); }
     164        { long long int ret; ret = __sync_nand_and_fetch(vp8, v8); }
     165        { long long int ret; ret = __sync_nand_and_fetch_8(vp8, v8); }
     166        #if defined(__SIZEOF_INT128__)
     167        { __int128 ret; ret = __sync_nand_and_fetch(vp16, v16); }
     168        { __int128 ret; ret = __sync_nand_and_fetch_16(vp16, v16); }
     169        #endif
     170
     171        { _Bool ret; ret = __sync_bool_compare_and_swap(vp1, v1, v1); }
     172        { _Bool ret; ret = __sync_bool_compare_and_swap_1(vp1, v1, v1); }
     173        { _Bool ret; ret = __sync_bool_compare_and_swap(vp2, v2, v2); }
     174        { _Bool ret; ret = __sync_bool_compare_and_swap_2(vp2, v2, v2); }
     175        { _Bool ret; ret = __sync_bool_compare_and_swap(vp4, v4, v4); }
     176        { _Bool ret; ret = __sync_bool_compare_and_swap_4(vp4, v4, v4); }
     177        { _Bool ret; ret = __sync_bool_compare_and_swap(vp8, v8, v8); }
     178        { _Bool ret; ret = __sync_bool_compare_and_swap_8(vp8, v8, v8); }
     179        #if defined(__SIZEOF_INT128__)
     180        { _Bool ret; ret = __sync_bool_compare_and_swap(vp16, v16, v16); }
     181        { _Bool ret; ret = __sync_bool_compare_and_swap_16(vp16, v16,v16); }
    132182        #endif
    133183        { _Bool ret; ret = __sync_bool_compare_and_swap(vpp, vp, vp); }
    134184
    135         { char ret; ret = __sync_val_compare_and_swap(vpc, vc, vc); }
    136         { short ret; ret = __sync_val_compare_and_swap(vps, vs, vs); }
    137         { int ret; ret = __sync_val_compare_and_swap(vpi, vi, vi); }
    138         { long int ret; ret = __sync_val_compare_and_swap(vpl, vl, vl); }
    139         { long long int ret; ret = __sync_val_compare_and_swap(vpll, vll, vll); }
    140         #if defined(__SIZEOF_INT128__)
    141         { __int128 ret; ret = __sync_val_compare_and_swap(vplll, vlll, vlll); }
     185        { char ret; ret = __sync_val_compare_and_swap(vp1, v1, v1); }
     186        { char ret; ret = __sync_val_compare_and_swap_1(vp1, v1, v1); }
     187        { short ret; ret = __sync_val_compare_and_swap(vp2, v2, v2); }
     188        { short ret; ret = __sync_val_compare_and_swap_2(vp2, v2, v2); }
     189        { int ret; ret = __sync_val_compare_and_swap(vp4, v4, v4); }
     190        { int ret; ret = __sync_val_compare_and_swap_4(vp4, v4, v4); }
     191        { long long int ret; ret = __sync_val_compare_and_swap(vp8, v8, v8); }
     192        { long long int ret; ret = __sync_val_compare_and_swap_8(vp8, v8, v8); }
     193        #if defined(__SIZEOF_INT128__)
     194        { __int128 ret; ret = __sync_val_compare_and_swap(vp16, v16, v16); }
     195        { __int128 ret; ret = __sync_val_compare_and_swap_16(vp16, v16,v16); }
    142196        #endif
    143197        { struct type * ret; ret = __sync_val_compare_and_swap(vpp, vp, vp); }
    144198
    145199
    146         { char ret; ret = __sync_lock_test_and_set(vpc, vc); }
    147         { short ret; ret = __sync_lock_test_and_set(vps, vs); }
    148         { int ret; ret = __sync_lock_test_and_set(vpi, vi); }
    149         { long int ret; ret = __sync_lock_test_and_set(vpl, vl); }
    150         { long long int ret; ret = __sync_lock_test_and_set(vpll, vll); }
    151         #if defined(__SIZEOF_INT128__)
    152         { __int128 ret; ret = __sync_lock_test_and_set(vplll, vlll); }
    153         #endif
    154 
    155         { __sync_lock_release(vpc); }
    156         { __sync_lock_release(vps); }
    157         { __sync_lock_release(vpi); }
    158         { __sync_lock_release(vpl); }
    159         { __sync_lock_release(vpll); }
    160         #if defined(__SIZEOF_INT128__)
    161         { __sync_lock_release(vplll); }
     200        { char ret; ret = __sync_lock_test_and_set(vp1, v1); }
     201        { char ret; ret = __sync_lock_test_and_set_1(vp1, v1); }
     202        { short ret; ret = __sync_lock_test_and_set(vp2, v2); }
     203        { short ret; ret = __sync_lock_test_and_set_2(vp2, v2); }
     204        { int ret; ret = __sync_lock_test_and_set(vp4, v4); }
     205        { int ret; ret = __sync_lock_test_and_set_4(vp4, v4); }
     206        { long long int ret; ret = __sync_lock_test_and_set(vp8, v8); }
     207        { long long int ret; ret = __sync_lock_test_and_set_8(vp8, v8); }
     208        #if defined(__SIZEOF_INT128__)
     209        { __int128 ret; ret = __sync_lock_test_and_set(vp16, v16); }
     210        { __int128 ret; ret = __sync_lock_test_and_set_16(vp16, v16); }
     211        #endif
     212
     213        { __sync_lock_release(vp1); }
     214        { __sync_lock_release_1(vp1); }
     215        { __sync_lock_release(vp2); }
     216        { __sync_lock_release_2(vp2); }
     217        { __sync_lock_release(vp4); }
     218        { __sync_lock_release_4(vp4); }
     219        { __sync_lock_release(vp8); }
     220        { __sync_lock_release_8(vp8); }
     221        #if defined(__SIZEOF_INT128__)
     222        { __sync_lock_release(vp16); }
     223        { __sync_lock_release_16(vp16); }
    162224        #endif
    163225
     
    168230
    169231        { _Bool ret; ret = __atomic_test_and_set(vpB, vB); }
    170         { _Bool ret; ret = __atomic_test_and_set(vpc, vc); }
     232        { _Bool ret; ret = __atomic_test_and_set(vp1, v1); }
    171233        { __atomic_clear(vpB, vB); }
    172         { __atomic_clear(vpc, vc); }
    173 
    174         { char ret; ret = __atomic_exchange_n(vpc, vc, __ATOMIC_SEQ_CST); }
    175         { char ret; __atomic_exchange(vpc, &vc, &ret, __ATOMIC_SEQ_CST); }
    176         { short ret; ret = __atomic_exchange_n(vps, vs, __ATOMIC_SEQ_CST); }
    177         { short ret; __atomic_exchange(vps, &vs, &ret, __ATOMIC_SEQ_CST); }
    178         { int ret; ret = __atomic_exchange_n(vpi, vi, __ATOMIC_SEQ_CST); }
    179         { int ret; __atomic_exchange(vpi, &vi, &ret, __ATOMIC_SEQ_CST); }
    180         { long int ret; ret = __atomic_exchange_n(vpl, vl, __ATOMIC_SEQ_CST); }
    181         { long int ret; __atomic_exchange(vpl, &vl, &ret, __ATOMIC_SEQ_CST); }
    182         { long long int ret; ret = __atomic_exchange_n(vpll, vll, __ATOMIC_SEQ_CST); }
    183         { long long int ret; __atomic_exchange(vpll, &vll, &ret, __ATOMIC_SEQ_CST); }
    184         #if defined(__SIZEOF_INT128__)
    185         { __int128 ret; ret = __atomic_exchange_n(vplll, vlll, __ATOMIC_SEQ_CST); }
    186         { __int128 ret; __atomic_exchange(vplll, &vlll, &ret, __ATOMIC_SEQ_CST); }
     234        { __atomic_clear(vp1, v1); }
     235
     236        { char ret; ret = __atomic_exchange_n(vp1, v1, __ATOMIC_SEQ_CST); }
     237        { char ret; ret = __atomic_exchange_1(vp1, v1, __ATOMIC_SEQ_CST); }
     238        { char ret; __atomic_exchange(vp1, &v1, &ret, __ATOMIC_SEQ_CST); }
     239        { short ret; ret = __atomic_exchange_n(vp2, v2, __ATOMIC_SEQ_CST); }
     240        { short ret; ret = __atomic_exchange_2(vp2, v2, __ATOMIC_SEQ_CST); }
     241        { short ret; __atomic_exchange(vp2, &v2, &ret, __ATOMIC_SEQ_CST); }
     242        { int ret; ret = __atomic_exchange_n(vp4, v4, __ATOMIC_SEQ_CST); }
     243        { int ret; ret = __atomic_exchange_4(vp4, v4, __ATOMIC_SEQ_CST); }
     244        { int ret; __atomic_exchange(vp4, &v4, &ret, __ATOMIC_SEQ_CST); }
     245        { long long int ret; ret = __atomic_exchange_n(vp8, v8, __ATOMIC_SEQ_CST); }
     246        { long long int ret; ret = __atomic_exchange_8(vp8, v8, __ATOMIC_SEQ_CST); }
     247        { long long int ret; __atomic_exchange(vp8, &v8, &ret, __ATOMIC_SEQ_CST); }
     248        #if defined(__SIZEOF_INT128__)
     249        { __int128 ret; ret = __atomic_exchange_n(vp16, v16, __ATOMIC_SEQ_CST); }
     250        { __int128 ret; ret = __atomic_exchange_16(vp16, v16, __ATOMIC_SEQ_CST); }
     251        { __int128 ret; __atomic_exchange(vp16, &v16, &ret, __ATOMIC_SEQ_CST); }
    187252        #endif
    188253        { struct type * ret; ret = __atomic_exchange_n(vpp, vp, __ATOMIC_SEQ_CST); }
    189254        { struct type * ret; __atomic_exchange(vpp, &vp, &ret, __ATOMIC_SEQ_CST); }
    190255
    191         { char ret; ret = __atomic_load_n(vpc, __ATOMIC_SEQ_CST); }
    192         { char ret; __atomic_load(vpc, &ret, __ATOMIC_SEQ_CST); }
    193         { short ret; ret = __atomic_load_n(vps, __ATOMIC_SEQ_CST); }
    194         { short ret; __atomic_load(vps, &ret, __ATOMIC_SEQ_CST); }
    195         { int ret; ret = __atomic_load_n(vpi, __ATOMIC_SEQ_CST); }
    196         { int ret; __atomic_load(vpi, &ret, __ATOMIC_SEQ_CST); }
    197         { long int ret; ret = __atomic_load_n(vpl, __ATOMIC_SEQ_CST); }
    198         { long int ret; __atomic_load(vpl, &ret, __ATOMIC_SEQ_CST); }
    199         { long long int ret; ret = __atomic_load_n(vpll, __ATOMIC_SEQ_CST); }
    200         { long long int ret; __atomic_load(vpll, &ret, __ATOMIC_SEQ_CST); }
    201         #if defined(__SIZEOF_INT128__)
    202         { __int128 ret; ret = __atomic_load_n(vplll, __ATOMIC_SEQ_CST); }
    203         { __int128 ret; __atomic_load(vplll, &ret, __ATOMIC_SEQ_CST); }
     256        { char ret; ret = __atomic_load_n(vp1, __ATOMIC_SEQ_CST); }
     257        { char ret; ret = __atomic_load_1(vp1, __ATOMIC_SEQ_CST); }
     258        { char ret; __atomic_load(vp1, &ret, __ATOMIC_SEQ_CST); }
     259        { short ret; ret = __atomic_load_n(vp2, __ATOMIC_SEQ_CST); }
     260        { short ret; ret = __atomic_load_2(vp2, __ATOMIC_SEQ_CST); }
     261        { short ret; __atomic_load(vp2, &ret, __ATOMIC_SEQ_CST); }
     262        { int ret; ret = __atomic_load_n(vp4, __ATOMIC_SEQ_CST); }
     263        { int ret; ret = __atomic_load_4(vp4, __ATOMIC_SEQ_CST); }
     264        { int ret; __atomic_load(vp4, &ret, __ATOMIC_SEQ_CST); }
     265        { long long int ret; ret = __atomic_load_n(vp8, __ATOMIC_SEQ_CST); }
     266        { long long int ret; ret = __atomic_load_8(vp8, __ATOMIC_SEQ_CST); }
     267        { long long int ret; __atomic_load(vp8, &ret, __ATOMIC_SEQ_CST); }
     268        #if defined(__SIZEOF_INT128__)
     269        { __int128 ret; ret = __atomic_load_n(vp16, __ATOMIC_SEQ_CST); }
     270        { __int128 ret; ret = __atomic_load_16(vp16, __ATOMIC_SEQ_CST); }
     271        { __int128 ret; __atomic_load(vp16, &ret, __ATOMIC_SEQ_CST); }
    204272        #endif
    205273        { struct type * ret; ret = __atomic_load_n(vpp, __ATOMIC_SEQ_CST); }
    206274        { struct type * ret; __atomic_load(vpp, &ret, __ATOMIC_SEQ_CST); }
    207275
    208         { _Bool ret; ret = __atomic_compare_exchange_n(vpc, rpc, vc, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
    209         { _Bool ret; ret = __atomic_compare_exchange(vpc, rpc, &vc, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
    210         { _Bool ret; ret = __atomic_compare_exchange_n(vps, rps, vs, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
    211         { _Bool ret; ret = __atomic_compare_exchange(vps, rps, &vs, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
    212         { _Bool ret; ret = __atomic_compare_exchange_n(vpi, rpi, vi, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
    213         { _Bool ret; ret = __atomic_compare_exchange(vpi, rpi, &vi, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
    214         { _Bool ret; ret = __atomic_compare_exchange_n(vpl, rpl, vl, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
    215         { _Bool ret; ret = __atomic_compare_exchange(vpl, rpl, &vl, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
    216         { _Bool ret; ret = __atomic_compare_exchange_n(vpll, rpll, vll, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
    217         { _Bool ret; ret = __atomic_compare_exchange(vpll, rpll, &vll, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
    218         #if defined(__SIZEOF_INT128__)
    219         { _Bool ret; ret = __atomic_compare_exchange_n(vplll, rplll, vlll, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
    220         { _Bool ret; ret = __atomic_compare_exchange(vplll, rplll, &vlll, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
     276        { _Bool ret; ret = __atomic_compare_exchange_n(vp1, rp1, v1, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
     277        { _Bool ret; ret = __atomic_compare_exchange_1(vp1, rp1, v1, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
     278        { _Bool ret; ret = __atomic_compare_exchange(vp1, rp1, &v1, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
     279        { _Bool ret; ret = __atomic_compare_exchange_n(vp2, rp2, v2, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
     280        { _Bool ret; ret = __atomic_compare_exchange_2(vp2, rp2, v2, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
     281        { _Bool ret; ret = __atomic_compare_exchange(vp2, rp2, &v2, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
     282        { _Bool ret; ret = __atomic_compare_exchange_n(vp4, rp4, v4, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
     283        { _Bool ret; ret = __atomic_compare_exchange_4(vp4, rp4, v4, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
     284        { _Bool ret; ret = __atomic_compare_exchange(vp4, rp4, &v4, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
     285        { _Bool ret; ret = __atomic_compare_exchange_n(vp8, rp8, v8, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
     286        { _Bool ret; ret = __atomic_compare_exchange_8(vp8, rp8, v8, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
     287        { _Bool ret; ret = __atomic_compare_exchange(vp8, rp8, &v8, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
     288        #if defined(__SIZEOF_INT128__)
     289        { _Bool ret; ret = __atomic_compare_exchange_n(vp16, rp16, v16, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
     290        { _Bool ret; ret = __atomic_compare_exchange_16(vp16, rp16, v16, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
     291        { _Bool ret; ret = __atomic_compare_exchange(vp16, rp16, &v16, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
    221292        #endif
    222293        { _Bool ret; ret = __atomic_compare_exchange_n(vpp, rpp, vp, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
    223294        { _Bool ret; ret = __atomic_compare_exchange(vpp, rpp, &vp, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
    224295
    225         { __atomic_store_n(vpc, vc, __ATOMIC_SEQ_CST); }
    226         { __atomic_store(vpc, &vc, __ATOMIC_SEQ_CST); }
    227         { __atomic_store_n(vps, vs, __ATOMIC_SEQ_CST); }
    228         { __atomic_store(vps, &vs, __ATOMIC_SEQ_CST); }
    229         { __atomic_store_n(vpi, vi, __ATOMIC_SEQ_CST); }
    230         { __atomic_store(vpi, &vi, __ATOMIC_SEQ_CST); }
    231         { __atomic_store_n(vpl, vl, __ATOMIC_SEQ_CST); }
    232         { __atomic_store(vpl, &vl, __ATOMIC_SEQ_CST); }
    233         { __atomic_store_n(vpll, vll, __ATOMIC_SEQ_CST); }
    234         { __atomic_store(vpll, &vll, __ATOMIC_SEQ_CST); }
    235         #if defined(__SIZEOF_INT128__)
    236         { __atomic_store_n(vplll, vlll, __ATOMIC_SEQ_CST); }
    237         { __atomic_store(vplll, &vlll, __ATOMIC_SEQ_CST); }
     296        { __atomic_store_n(vp1, v1, __ATOMIC_SEQ_CST); }
     297        { __atomic_store_1(vp1, v1, __ATOMIC_SEQ_CST); }
     298        { __atomic_store(vp1, &v1, __ATOMIC_SEQ_CST); }
     299        { __atomic_store_n(vp2, v2, __ATOMIC_SEQ_CST); }
     300        { __atomic_store_2(vp2, v2, __ATOMIC_SEQ_CST); }
     301        { __atomic_store(vp2, &v2, __ATOMIC_SEQ_CST); }
     302        { __atomic_store_n(vp4, v4, __ATOMIC_SEQ_CST); }
     303        { __atomic_store_4(vp4, v4, __ATOMIC_SEQ_CST); }
     304        { __atomic_store(vp4, &v4, __ATOMIC_SEQ_CST); }
     305        { __atomic_store_n(vp8, v8, __ATOMIC_SEQ_CST); }
     306        { __atomic_store_8(vp8, v8, __ATOMIC_SEQ_CST); }
     307        { __atomic_store(vp8, &v8, __ATOMIC_SEQ_CST); }
     308        #if defined(__SIZEOF_INT128__)
     309        { __atomic_store_n(vp16, v16, __ATOMIC_SEQ_CST); }
     310        { __atomic_store_16(vp16, v16, __ATOMIC_SEQ_CST); }
     311        { __atomic_store(vp16, &v16, __ATOMIC_SEQ_CST); }
    238312        #endif
    239313        { __atomic_store_n(vpp, vp, __ATOMIC_SEQ_CST); }
    240314        { __atomic_store(vpp, &vp, __ATOMIC_SEQ_CST); }
    241315
    242         { char ret; ret = __atomic_add_fetch(vpc, vc, __ATOMIC_SEQ_CST); }
    243         { short ret; ret = __atomic_add_fetch(vps, vs, __ATOMIC_SEQ_CST); }
    244         { int ret; ret = __atomic_add_fetch(vpi, vi, __ATOMIC_SEQ_CST); }
    245         { long int ret; ret = __atomic_add_fetch(vpl, vl, __ATOMIC_SEQ_CST); }
    246         { long long int ret; ret = __atomic_add_fetch(vpll, vll, __ATOMIC_SEQ_CST); }
    247         #if defined(__SIZEOF_INT128__)
    248         { __int128 ret; ret = __atomic_add_fetch(vplll, vlll, __ATOMIC_SEQ_CST); }
    249         #endif
    250 
    251         { char ret; ret = __atomic_sub_fetch(vpc, vc, __ATOMIC_SEQ_CST); }
    252         { short ret; ret = __atomic_sub_fetch(vps, vs, __ATOMIC_SEQ_CST); }
    253         { int ret; ret = __atomic_sub_fetch(vpi, vi, __ATOMIC_SEQ_CST); }
    254         { long int ret; ret = __atomic_sub_fetch(vpl, vl, __ATOMIC_SEQ_CST); }
    255         { long long int ret; ret = __atomic_sub_fetch(vpll, vll, __ATOMIC_SEQ_CST); }
    256         #if defined(__SIZEOF_INT128__)
    257         { __int128 ret; ret = __atomic_sub_fetch(vplll, vlll, __ATOMIC_SEQ_CST); }
    258         #endif
    259 
    260         { char ret; ret = __atomic_and_fetch(vpc, vc, __ATOMIC_SEQ_CST); }
    261         { short ret; ret = __atomic_and_fetch(vps, vs, __ATOMIC_SEQ_CST); }
    262         { int ret; ret = __atomic_and_fetch(vpi, vi, __ATOMIC_SEQ_CST); }
    263         { long int ret; ret = __atomic_and_fetch(vpl, vl, __ATOMIC_SEQ_CST); }
    264         { long long int ret; ret = __atomic_and_fetch(vpll, vll, __ATOMIC_SEQ_CST); }
    265         #if defined(__SIZEOF_INT128__)
    266         { __int128 ret; ret = __atomic_and_fetch(vplll, vlll, __ATOMIC_SEQ_CST); }
    267         #endif
    268 
    269         { char ret; ret = __atomic_nand_fetch(vpc, vc, __ATOMIC_SEQ_CST); }
    270         { short ret; ret = __atomic_nand_fetch(vps, vs, __ATOMIC_SEQ_CST); }
    271         { int ret; ret = __atomic_nand_fetch(vpi, vi, __ATOMIC_SEQ_CST); }
    272         { long int ret; ret = __atomic_nand_fetch(vpl, vl, __ATOMIC_SEQ_CST); }
    273         { long long int ret; ret = __atomic_nand_fetch(vpll, vll, __ATOMIC_SEQ_CST); }
    274         #if defined(__SIZEOF_INT128__)
    275         { __int128 ret; ret = __atomic_nand_fetch(vplll, vlll, __ATOMIC_SEQ_CST); }
    276         #endif
    277 
    278         { char ret; ret = __atomic_xor_fetch(vpc, vc, __ATOMIC_SEQ_CST); }
    279         { short ret; ret = __atomic_xor_fetch(vps, vs, __ATOMIC_SEQ_CST); }
    280         { int ret; ret = __atomic_xor_fetch(vpi, vi, __ATOMIC_SEQ_CST); }
    281         { long int ret; ret = __atomic_xor_fetch(vpl, vl, __ATOMIC_SEQ_CST); }
    282         { long long int ret; ret = __atomic_xor_fetch(vpll, vll, __ATOMIC_SEQ_CST); }
    283         #if defined(__SIZEOF_INT128__)
    284         { __int128 ret; ret = __atomic_xor_fetch(vplll, vlll, __ATOMIC_SEQ_CST); }
    285         #endif
    286 
    287         { char ret; ret = __atomic_or_fetch(vpc, vc, __ATOMIC_SEQ_CST); }
    288         { short ret; ret = __atomic_or_fetch(vps, vs, __ATOMIC_SEQ_CST); }
    289         { int ret; ret = __atomic_or_fetch(vpi, vi, __ATOMIC_SEQ_CST); }
    290         { long int ret; ret = __atomic_or_fetch(vpl, vl, __ATOMIC_SEQ_CST); }
    291         { long long int ret; ret = __atomic_or_fetch(vpll, vll, __ATOMIC_SEQ_CST); }
    292         #if defined(__SIZEOF_INT128__)
    293         { __int128 ret; ret = __atomic_or_fetch(vplll, vlll, __ATOMIC_SEQ_CST); }
    294         #endif
    295 
    296         { char ret; ret = __atomic_fetch_add(vpc, vc, __ATOMIC_SEQ_CST); }
    297         { short ret; ret = __atomic_fetch_add(vps, vs, __ATOMIC_SEQ_CST); }
    298         { int ret; ret = __atomic_fetch_add(vpi, vi, __ATOMIC_SEQ_CST); }
    299         { long int ret; ret = __atomic_fetch_add(vpl, vl, __ATOMIC_SEQ_CST); }
    300         { long long int ret; ret = __atomic_fetch_add(vpll, vll, __ATOMIC_SEQ_CST); }
    301         #if defined(__SIZEOF_INT128__)
    302         { __int128 ret; ret = __atomic_fetch_add(vplll, vlll, __ATOMIC_SEQ_CST); }
    303         #endif
    304 
    305         { char ret; ret = __atomic_fetch_sub(vpc, vc, __ATOMIC_SEQ_CST); }
    306         { short ret; ret = __atomic_fetch_sub(vps, vs, __ATOMIC_SEQ_CST); }
    307         { int ret; ret = __atomic_fetch_sub(vpi, vi, __ATOMIC_SEQ_CST); }
    308         { long int ret; ret = __atomic_fetch_sub(vpl, vl, __ATOMIC_SEQ_CST); }
    309         { long long int ret; ret = __atomic_fetch_sub(vpll, vll, __ATOMIC_SEQ_CST); }
    310         #if defined(__SIZEOF_INT128__)
    311         { __int128 ret; ret = __atomic_fetch_sub(vplll, vlll, __ATOMIC_SEQ_CST); }
    312         #endif
    313 
    314         { char ret; ret = __atomic_fetch_and(vpc, vc, __ATOMIC_SEQ_CST); }
    315         { short ret; ret = __atomic_fetch_and(vps, vs, __ATOMIC_SEQ_CST); }
    316         { int ret; ret = __atomic_fetch_and(vpi, vi, __ATOMIC_SEQ_CST); }
    317         { long int ret; ret = __atomic_fetch_and(vpl, vl, __ATOMIC_SEQ_CST); }
    318         { long long int ret; ret = __atomic_fetch_and(vpll, vll, __ATOMIC_SEQ_CST); }
    319         #if defined(__SIZEOF_INT128__)
    320         { __int128 ret; ret = __atomic_fetch_and(vplll, vlll, __ATOMIC_SEQ_CST); }
    321         #endif
    322 
    323         { char ret; ret = __atomic_fetch_nand(vpc, vc, __ATOMIC_SEQ_CST); }
    324         { short ret; ret = __atomic_fetch_nand(vps, vs, __ATOMIC_SEQ_CST); }
    325         { int ret; ret = __atomic_fetch_nand(vpi, vi, __ATOMIC_SEQ_CST); }
    326         { long int ret; ret = __atomic_fetch_nand(vpl, vl, __ATOMIC_SEQ_CST); }
    327         { long long int ret; ret = __atomic_fetch_nand(vpll, vll, __ATOMIC_SEQ_CST); }
    328         #if defined(__SIZEOF_INT128__)
    329         { __int128 ret; ret = __atomic_fetch_nand(vplll, vlll, __ATOMIC_SEQ_CST); }
    330         #endif
    331 
    332         { char ret; ret = __atomic_fetch_xor(vpc, vc, __ATOMIC_SEQ_CST); }
    333         { short ret; ret = __atomic_fetch_xor(vps, vs, __ATOMIC_SEQ_CST); }
    334         { int ret; ret = __atomic_fetch_xor(vpi, vi, __ATOMIC_SEQ_CST); }
    335         { long int ret; ret = __atomic_fetch_xor(vpl, vl, __ATOMIC_SEQ_CST); }
    336         { long long int ret; ret = __atomic_fetch_xor(vpll, vll, __ATOMIC_SEQ_CST); }
    337         #if defined(__SIZEOF_INT128__)
    338         { __int128 ret; ret = __atomic_fetch_xor(vplll, vlll, __ATOMIC_SEQ_CST); }
    339         #endif
    340 
    341         { char ret; ret = __atomic_fetch_or(vpc, vc, __ATOMIC_SEQ_CST); }
    342         { short ret; ret = __atomic_fetch_or(vps, vs, __ATOMIC_SEQ_CST); }
    343         { int ret; ret = __atomic_fetch_or(vpi, vi, __ATOMIC_SEQ_CST); }
    344         { long int ret; ret = __atomic_fetch_or(vpl, vl, __ATOMIC_SEQ_CST); }
    345         { long long int ret; ret = __atomic_fetch_or(vpll, vll, __ATOMIC_SEQ_CST); }
    346         #if defined(__SIZEOF_INT128__)
    347         { __int128 ret; ret = __atomic_fetch_or(vplll, vlll, __ATOMIC_SEQ_CST); }
    348         #endif
    349 
    350         { _Bool ret; ret = __atomic_always_lock_free(sizeof(int), vpi); }
    351         { _Bool ret; ret = __atomic_is_lock_free(sizeof(int), vpi); }
     316        { char ret; ret = __atomic_add_fetch(vp1, v1, __ATOMIC_SEQ_CST); }
     317        { char ret; ret = __atomic_add_fetch_1(vp1, v1, __ATOMIC_SEQ_CST); }
     318        { short ret; ret = __atomic_add_fetch(vp2, v2, __ATOMIC_SEQ_CST); }
     319        { short ret; ret = __atomic_add_fetch_2(vp2, v2, __ATOMIC_SEQ_CST); }
     320        { int ret; ret = __atomic_add_fetch(vp4, v4, __ATOMIC_SEQ_CST); }
     321        { int ret; ret = __atomic_add_fetch_4(vp4, v4, __ATOMIC_SEQ_CST); }
     322        { long long int ret; ret = __atomic_add_fetch(vp8, v8, __ATOMIC_SEQ_CST); }
     323        { long long int ret; ret = __atomic_add_fetch_8(vp8, v8, __ATOMIC_SEQ_CST); }
     324        #if defined(__SIZEOF_INT128__)
     325        { __int128 ret; ret = __atomic_add_fetch(vp16, v16, __ATOMIC_SEQ_CST); }
     326        { __int128 ret; ret = __atomic_add_fetch_16(vp16, v16, __ATOMIC_SEQ_CST); }
     327        #endif
     328
     329        { char ret; ret = __atomic_sub_fetch(vp1, v1, __ATOMIC_SEQ_CST); }
     330        { char ret; ret = __atomic_sub_fetch_1(vp1, v1, __ATOMIC_SEQ_CST); }
     331        { short ret; ret = __atomic_sub_fetch(vp2, v2, __ATOMIC_SEQ_CST); }
     332        { short ret; ret = __atomic_sub_fetch_2(vp2, v2, __ATOMIC_SEQ_CST); }
     333        { int ret; ret = __atomic_sub_fetch(vp4, v4, __ATOMIC_SEQ_CST); }
     334        { int ret; ret = __atomic_sub_fetch_4(vp4, v4, __ATOMIC_SEQ_CST); }
     335        { long long int ret; ret = __atomic_sub_fetch(vp8, v8, __ATOMIC_SEQ_CST); }
     336        { long long int ret; ret = __atomic_sub_fetch_8(vp8, v8, __ATOMIC_SEQ_CST); }
     337        #if defined(__SIZEOF_INT128__)
     338        { __int128 ret; ret = __atomic_sub_fetch(vp16, v16, __ATOMIC_SEQ_CST); }
     339        { __int128 ret; ret = __atomic_sub_fetch_16(vp16, v16, __ATOMIC_SEQ_CST); }
     340        #endif
     341
     342        { char ret; ret = __atomic_and_fetch(vp1, v1, __ATOMIC_SEQ_CST); }
     343        { char ret; ret = __atomic_and_fetch_1(vp1, v1, __ATOMIC_SEQ_CST); }
     344        { short ret; ret = __atomic_and_fetch(vp2, v2, __ATOMIC_SEQ_CST); }
     345        { short ret; ret = __atomic_and_fetch_2(vp2, v2, __ATOMIC_SEQ_CST); }
     346        { int ret; ret = __atomic_and_fetch(vp4, v4, __ATOMIC_SEQ_CST); }
     347        { int ret; ret = __atomic_and_fetch_4(vp4, v4, __ATOMIC_SEQ_CST); }
     348        { long long int ret; ret = __atomic_and_fetch(vp8, v8, __ATOMIC_SEQ_CST); }
     349        { long long int ret; ret = __atomic_and_fetch_8(vp8, v8, __ATOMIC_SEQ_CST); }
     350        #if defined(__SIZEOF_INT128__)
     351        { __int128 ret; ret = __atomic_and_fetch(vp16, v16, __ATOMIC_SEQ_CST); }
     352        { __int128 ret; ret = __atomic_and_fetch_16(vp16, v16, __ATOMIC_SEQ_CST); }
     353        #endif
     354
     355        { char ret; ret = __atomic_nand_fetch(vp1, v1, __ATOMIC_SEQ_CST); }
     356        { char ret; ret = __atomic_nand_fetch_1(vp1, v1, __ATOMIC_SEQ_CST); }
     357        { short ret; ret = __atomic_nand_fetch(vp2, v2, __ATOMIC_SEQ_CST); }
     358        { short ret; ret = __atomic_nand_fetch_2(vp2, v2, __ATOMIC_SEQ_CST); }
     359        { int ret; ret = __atomic_nand_fetch(vp4, v4, __ATOMIC_SEQ_CST); }
     360        { int ret; ret = __atomic_nand_fetch_4(vp4, v4, __ATOMIC_SEQ_CST); }
     361        { long long int ret; ret = __atomic_nand_fetch(vp8, v8, __ATOMIC_SEQ_CST); }
     362        { long long int ret; ret = __atomic_nand_fetch_8(vp8, v8, __ATOMIC_SEQ_CST); }
     363        #if defined(__SIZEOF_INT128__)
     364        { __int128 ret; ret = __atomic_nand_fetch(vp16, v16, __ATOMIC_SEQ_CST); }
     365        { __int128 ret; ret = __atomic_nand_fetch_16(vp16, v16, __ATOMIC_SEQ_CST); }
     366        #endif
     367
     368        { char ret; ret = __atomic_xor_fetch(vp1, v1, __ATOMIC_SEQ_CST); }
     369        { char ret; ret = __atomic_xor_fetch_1(vp1, v1, __ATOMIC_SEQ_CST); }
     370        { short ret; ret = __atomic_xor_fetch(vp2, v2, __ATOMIC_SEQ_CST); }
     371        { short ret; ret = __atomic_xor_fetch_2(vp2, v2, __ATOMIC_SEQ_CST); }
     372        { int ret; ret = __atomic_xor_fetch(vp4, v4, __ATOMIC_SEQ_CST); }
     373        { int ret; ret = __atomic_xor_fetch_4(vp4, v4, __ATOMIC_SEQ_CST); }
     374        { long long int ret; ret = __atomic_xor_fetch(vp8, v8, __ATOMIC_SEQ_CST); }
     375        { long long int ret; ret = __atomic_xor_fetch_8(vp8, v8, __ATOMIC_SEQ_CST); }
     376        #if defined(__SIZEOF_INT128__)
     377        { __int128 ret; ret = __atomic_xor_fetch(vp16, v16, __ATOMIC_SEQ_CST); }
     378        { __int128 ret; ret = __atomic_xor_fetch_16(vp16, v16, __ATOMIC_SEQ_CST); }
     379        #endif
     380
     381        { char ret; ret = __atomic_or_fetch(vp1, v1, __ATOMIC_SEQ_CST); }
     382        { char ret; ret = __atomic_or_fetch_1(vp1, v1, __ATOMIC_SEQ_CST); }
     383        { short ret; ret = __atomic_or_fetch(vp2, v2, __ATOMIC_SEQ_CST); }
     384        { short ret; ret = __atomic_or_fetch_2(vp2, v2, __ATOMIC_SEQ_CST); }
     385        { int ret; ret = __atomic_or_fetch(vp4, v4, __ATOMIC_SEQ_CST); }
     386        { int ret; ret = __atomic_or_fetch_4(vp4, v4, __ATOMIC_SEQ_CST); }
     387        { long long int ret; ret = __atomic_or_fetch(vp8, v8, __ATOMIC_SEQ_CST); }
     388        { long long int ret; ret = __atomic_or_fetch_8(vp8, v8, __ATOMIC_SEQ_CST); }
     389        #if defined(__SIZEOF_INT128__)
     390        { __int128 ret; ret = __atomic_or_fetch(vp16, v16, __ATOMIC_SEQ_CST); }
     391        { __int128 ret; ret = __atomic_or_fetch_16(vp16, v16, __ATOMIC_SEQ_CST); }
     392        #endif
     393
     394        { char ret; ret = __atomic_fetch_add(vp1, v1, __ATOMIC_SEQ_CST); }
     395        { char ret; ret = __atomic_fetch_add_1(vp1, v1, __ATOMIC_SEQ_CST); }
     396        { short ret; ret = __atomic_fetch_add(vp2, v2, __ATOMIC_SEQ_CST); }
     397        { short ret; ret = __atomic_fetch_add_2(vp2, v2, __ATOMIC_SEQ_CST); }
     398        { int ret; ret = __atomic_fetch_add(vp4, v4, __ATOMIC_SEQ_CST); }
     399        { int ret; ret = __atomic_fetch_add_4(vp4, v4, __ATOMIC_SEQ_CST); }
     400        { long long int ret; ret = __atomic_fetch_add(vp8, v8, __ATOMIC_SEQ_CST); }
     401        { long long int ret; ret = __atomic_fetch_add_8(vp8, v8, __ATOMIC_SEQ_CST); }
     402        #if defined(__SIZEOF_INT128__)
     403        { __int128 ret; ret = __atomic_fetch_add(vp16, v16, __ATOMIC_SEQ_CST); }
     404        { __int128 ret; ret = __atomic_fetch_add_16(vp16, v16, __ATOMIC_SEQ_CST); }
     405        #endif
     406
     407        { char ret; ret = __atomic_fetch_sub(vp1, v1, __ATOMIC_SEQ_CST); }
     408        { char ret; ret = __atomic_fetch_sub_1(vp1, v1, __ATOMIC_SEQ_CST); }
     409        { short ret; ret = __atomic_fetch_sub(vp2, v2, __ATOMIC_SEQ_CST); }
     410        { short ret; ret = __atomic_fetch_sub_2(vp2, v2, __ATOMIC_SEQ_CST); }
     411        { int ret; ret = __atomic_fetch_sub(vp4, v4, __ATOMIC_SEQ_CST); }
     412        { int ret; ret = __atomic_fetch_sub_4(vp4, v4, __ATOMIC_SEQ_CST); }
     413        { long long int ret; ret = __atomic_fetch_sub(vp8, v8, __ATOMIC_SEQ_CST); }
     414        { long long int ret; ret = __atomic_fetch_sub_8(vp8, v8, __ATOMIC_SEQ_CST); }
     415        #if defined(__SIZEOF_INT128__)
     416        { __int128 ret; ret = __atomic_fetch_sub(vp16, v16, __ATOMIC_SEQ_CST); }
     417        { __int128 ret; ret = __atomic_fetch_sub_16(vp16, v16, __ATOMIC_SEQ_CST); }
     418        #endif
     419
     420        { char ret; ret = __atomic_fetch_and(vp1, v1, __ATOMIC_SEQ_CST); }
     421        { char ret; ret = __atomic_fetch_and_1(vp1, v1, __ATOMIC_SEQ_CST); }
     422        { short ret; ret = __atomic_fetch_and(vp2, v2, __ATOMIC_SEQ_CST); }
     423        { short ret; ret = __atomic_fetch_and_2(vp2, v2, __ATOMIC_SEQ_CST); }
     424        { int ret; ret = __atomic_fetch_and(vp4, v4, __ATOMIC_SEQ_CST); }
     425        { int ret; ret = __atomic_fetch_and_4(vp4, v4, __ATOMIC_SEQ_CST); }
     426        { long long int ret; ret = __atomic_fetch_and(vp8, v8, __ATOMIC_SEQ_CST); }
     427        { long long int ret; ret = __atomic_fetch_and_8(vp8, v8, __ATOMIC_SEQ_CST); }
     428        #if defined(__SIZEOF_INT128__)
     429        { __int128 ret; ret = __atomic_fetch_and(vp16, v16, __ATOMIC_SEQ_CST); }
     430        { __int128 ret; ret = __atomic_fetch_and_16(vp16, v16, __ATOMIC_SEQ_CST); }
     431        #endif
     432
     433        { char ret; ret = __atomic_fetch_nand(vp1, v1, __ATOMIC_SEQ_CST); }
     434        { char ret; ret = __atomic_fetch_nand_1(vp1, v1, __ATOMIC_SEQ_CST); }
     435        { short ret; ret = __atomic_fetch_nand(vp2, v2, __ATOMIC_SEQ_CST); }
     436        { short ret; ret = __atomic_fetch_nand_2(vp2, v2, __ATOMIC_SEQ_CST); }
     437        { int ret; ret = __atomic_fetch_nand(vp4, v4, __ATOMIC_SEQ_CST); }
     438        { int ret; ret = __atomic_fetch_nand_4(vp4, v4, __ATOMIC_SEQ_CST); }
     439        { long long int ret; ret = __atomic_fetch_nand(vp8, v8, __ATOMIC_SEQ_CST); }
     440        { long long int ret; ret = __atomic_fetch_nand_8(vp8, v8, __ATOMIC_SEQ_CST); }
     441        #if defined(__SIZEOF_INT128__)
     442        { __int128 ret; ret = __atomic_fetch_nand(vp16, v16, __ATOMIC_SEQ_CST); }
     443        { __int128 ret; ret = __atomic_fetch_nand_16(vp16, v16, __ATOMIC_SEQ_CST); }
     444        #endif
     445
     446        { char ret; ret = __atomic_fetch_xor(vp1, v1, __ATOMIC_SEQ_CST); }
     447        { char ret; ret = __atomic_fetch_xor_1(vp1, v1, __ATOMIC_SEQ_CST); }
     448        { short ret; ret = __atomic_fetch_xor(vp2, v2, __ATOMIC_SEQ_CST); }
     449        { short ret; ret = __atomic_fetch_xor_2(vp2, v2, __ATOMIC_SEQ_CST); }
     450        { int ret; ret = __atomic_fetch_xor(vp4, v4, __ATOMIC_SEQ_CST); }
     451        { int ret; ret = __atomic_fetch_xor_4(vp4, v4, __ATOMIC_SEQ_CST); }
     452        { long long int ret; ret = __atomic_fetch_xor(vp8, v8, __ATOMIC_SEQ_CST); }
     453        { long long int ret; ret = __atomic_fetch_xor_8(vp8, v8, __ATOMIC_SEQ_CST); }
     454        #if defined(__SIZEOF_INT128__)
     455        { __int128 ret; ret = __atomic_fetch_xor(vp16, v16, __ATOMIC_SEQ_CST); }
     456        { __int128 ret; ret = __atomic_fetch_xor_16(vp16, v16, __ATOMIC_SEQ_CST); }
     457        #endif
     458
     459        { char ret; ret = __atomic_fetch_or(vp1, v1, __ATOMIC_SEQ_CST); }
     460        { char ret; ret = __atomic_fetch_or_1(vp1, v1, __ATOMIC_SEQ_CST); }
     461        { short ret; ret = __atomic_fetch_or(vp2, v2, __ATOMIC_SEQ_CST); }
     462        { short ret; ret = __atomic_fetch_or_2(vp2, v2, __ATOMIC_SEQ_CST); }
     463        { int ret; ret = __atomic_fetch_or(vp4, v4, __ATOMIC_SEQ_CST); }
     464        { int ret; ret = __atomic_fetch_or_4(vp4, v4, __ATOMIC_SEQ_CST); }
     465        { long long int ret; ret = __atomic_fetch_or(vp8, v8, __ATOMIC_SEQ_CST); }
     466        { long long int ret; ret = __atomic_fetch_or_8(vp8, v8, __ATOMIC_SEQ_CST); }
     467        #if defined(__SIZEOF_INT128__)
     468        { __int128 ret; ret = __atomic_fetch_or(vp16, v16, __ATOMIC_SEQ_CST); }
     469        { __int128 ret; ret = __atomic_fetch_or_16(vp16, v16, __ATOMIC_SEQ_CST); }
     470        #endif
     471
     472        { _Bool ret; ret = __atomic_always_lock_free(sizeof(int), vp4); }
     473        { _Bool ret; ret = __atomic_is_lock_free(sizeof(int), vp4); }
    352474        { __atomic_thread_fence(__ATOMIC_SEQ_CST); }
    353475        { __atomic_signal_fence(__ATOMIC_SEQ_CST); }
  • tests/concurrent/preempt.cfa

    r2fa5bd2 raca6a54c  
    3636                if( (counter % 7) == this.value ) {
    3737                        __cfaabi_check_preemption();
    38                         int next = __atomic_add_fetch( &counter, 1, __ATOMIC_SEQ_CST );
     38                        int next = __atomic_add_fetch_4(&counter, 1, __ATOMIC_SEQ_CST);
    3939                        __cfaabi_check_preemption();
    4040                        if( (next % 100) == 0 ) printf("%d\n", (int)next);
  • tests/concurrent/signal/wait.cfa

    r2fa5bd2 raca6a54c  
    9898        }
    9999
    100         __atomic_fetch_sub( &waiter_left, 1,  __ATOMIC_SEQ_CST );
     100        __sync_fetch_and_sub_4( &waiter_left, 1);
    101101}
    102102
     
    109109        }
    110110
    111         __atomic_fetch_sub( &waiter_left, 1,  __ATOMIC_SEQ_CST );
     111        __sync_fetch_and_sub_4( &waiter_left, 1);
    112112}
    113113
     
    120120        }
    121121
    122         __atomic_fetch_sub( &waiter_left, 1,  __ATOMIC_SEQ_CST );
     122        __sync_fetch_and_sub_4( &waiter_left, 1);
    123123}
    124124
     
    131131        }
    132132
    133         __atomic_fetch_sub( &waiter_left, 1,  __ATOMIC_SEQ_CST );
     133        __sync_fetch_and_sub_4( &waiter_left, 1);
    134134}
    135135
  • tests/concurrent/thread.cfa

    r2fa5bd2 raca6a54c  
    77thread Second { semaphore* lock; };
    88
    9 void ?{}( First  & this, semaphore & lock ) { ((thread&)this){ "Thread 1" }; this.lock = &lock; }
    10 void ?{}( Second & this, semaphore & lock ) { ((thread&)this){ "Thread 2" }; this.lock = &lock; }
     9void ?{}( First  & this, semaphore & lock ) { ((thread&)this){"Thread 1"}; this.lock = &lock; }
     10void ?{}( Second & this, semaphore & lock ) { ((thread&)this){"Thread 2"}; this.lock = &lock; }
    1111
    1212void main(First& this) {
  • tests/heap.cfa

    r2fa5bd2 raca6a54c  
    1010// Created On       : Tue Nov  6 17:54:56 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Nov 24 12:34:51 2019
    13 // Update Count     : 28
     12// Last Modified On : Fri Jul 19 08:22:34 2019
     13// Update Count     : 19
    1414//
    1515
     
    3838        enum { NoOfAllocs = 5000, NoOfMmaps = 10 };
    3939        char * locns[NoOfAllocs];
    40         size_t amount;
    41         enum { limit = 64 * 1024 };                                                     // check alignments up to here
     40        int i;
    4241
    4342        // check alloc/free
     
    7574                size_t s = (i + 1) * 20;
    7675                char * area = (char *)malloc( s );
    77                 if ( area == 0p ) abort( "malloc/free out of memory" );
     76                if ( area == 0 ) abort( "malloc/free out of memory" );
    7877                area[0] = '\345'; area[s - 1] = '\345';                 // fill first/last
    7978                area[malloc_usable_size( area ) - 1] = '\345';  // fill ultimate byte
     
    8483                size_t s = i + 1;                                                               // +1 to make initialization simpler
    8584                locns[i] = (char *)malloc( s );
    86                 if ( locns[i] == 0p ) abort( "malloc/free out of memory" );
     85                if ( locns[i] == 0 ) abort( "malloc/free out of memory" );
    8786                locns[i][0] = '\345'; locns[i][s - 1] = '\345'; // fill first/last
    8887                locns[i][malloc_usable_size( locns[i] ) - 1] = '\345'; // fill ultimate byte
     
    10099                size_t s = i + default_mmap_start();                    // cross over point
    101100                char * area = (char *)malloc( s );
    102                 if ( area == 0p ) abort( "malloc/free out of memory" );
     101                if ( area == 0 ) abort( "malloc/free out of memory" );
    103102                area[0] = '\345'; area[s - 1] = '\345';                 // fill first/last
    104103                area[malloc_usable_size( area ) - 1] = '\345';  // fill ultimate byte
     
    109108                size_t s = i + default_mmap_start();                    // cross over point
    110109                locns[i] = (char *)malloc( s );
    111                 if ( locns[i] == 0p ) abort( "malloc/free out of memory" );
     110                if ( locns[i] == 0 ) abort( "malloc/free out of memory" );
    112111                locns[i][0] = '\345'; locns[i][s - 1] = '\345'; // fill first/last
    113112                locns[i][malloc_usable_size( locns[i] ) - 1] = '\345'; // fill ultimate byte
     
    125124                size_t s = (i + 1) * 20;
    126125                char * area = (char *)calloc( 5, s );
    127                 if ( area == 0p ) abort( "calloc/free out of memory" );
     126                if ( area == 0 ) abort( "calloc/free out of memory" );
    128127                if ( area[0] != '\0' || area[s - 1] != '\0' ||
    129128                         area[malloc_usable_size( area ) - 1] != '\0' ||
     
    137136                size_t s = i + 1;
    138137                locns[i] = (char *)calloc( 5, s );
    139                 if ( locns[i] == 0p ) abort( "calloc/free out of memory" );
     138                if ( locns[i] == 0 ) abort( "calloc/free out of memory" );
    140139                if ( locns[i][0] != '\0' || locns[i][s - 1] != '\0' ||
    141140                         locns[i][malloc_usable_size( locns[i] ) - 1] != '\0' ||
     
    156155                size_t s = i + default_mmap_start();                    // cross over point
    157156                char * area = (char *)calloc( 1, s );
    158                 if ( area == 0p ) abort( "calloc/free out of memory" );
     157                if ( area == 0 ) abort( "calloc/free out of memory" );
    159158                if ( area[0] != '\0' || area[s - 1] != '\0' ) abort( "calloc/free corrupt storage4.1" );
    160159                if ( area[malloc_usable_size( area ) - 1] != '\0' ) abort( "calloc/free corrupt storage4.2" );
     
    168167                size_t s = i + default_mmap_start();                    // cross over point
    169168                locns[i] = (char *)calloc( 1, s );
    170                 if ( locns[i] == 0p ) abort( "calloc/free out of memory" );
     169                if ( locns[i] == 0 ) abort( "calloc/free out of memory" );
    171170                if ( locns[i][0] != '\0' || locns[i][s - 1] != '\0' ||
    172171                         locns[i][malloc_usable_size( locns[i] ) - 1] != '\0' ||
     
    184183        // check memalign/free (sbrk)
    185184
     185        enum { limit = 64 * 1024 };                                                     // check alignments up to here
     186
    186187        for ( a; libAlign() ~= limit ~ a ) {                            // generate powers of 2
    187188                //sout | alignments[a];
    188189                for ( s; 1 ~ NoOfAllocs ) {                                             // allocation of size 0 can return null
    189190                        char * area = (char *)memalign( a, s );
    190                         if ( area == 0p ) abort( "memalign/free out of memory" );
    191                         //sout | i | area;
     191                        if ( area == 0 ) abort( "memalign/free out of memory" );
     192                        //sout | i | " " | area;
    192193                        if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment
    193194                                abort( "memalign/free bad alignment : memalign(%d,%d) = %p", (int)a, s, area );
    194195                        } // if
    195                         area[0] = '\345'; area[s - 1] = '\345';         // fill first/last byte
     196                        area[0] = '\345'; area[s - 1] = '\345'; // fill first/last byte
    196197                        area[malloc_usable_size( area ) - 1] = '\345'; // fill ultimate byte
    197198                        free( area );
     
    206207                        size_t s = i + default_mmap_start();            // cross over point
    207208                        char * area = (char *)memalign( a, s );
    208                         if ( area == 0p ) abort( "memalign/free out of memory" );
    209                         //sout | i | area;
     209                        if ( area == 0 ) abort( "memalign/free out of memory" );
     210                        //sout | i | " " | area;
    210211                        if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment
    211212                                abort( "memalign/free bad alignment : memalign(%d,%d) = %p", (int)a, (int)s, area );
     
    222223                // initial N byte allocation
    223224                char * area = (char *)calloc( 5, i );
    224                 if ( area == 0p ) abort( "calloc/realloc/free out of memory" );
     225                if ( area == 0 ) abort( "calloc/realloc/free out of memory" );
    225226                if ( area[0] != '\0' || area[i - 1] != '\0' ||
    226227                         area[malloc_usable_size( area ) - 1] != '\0' ||
     
    230231                for ( s; i ~ 256 * 1024 ~ 26 ) {                                // start at initial memory request
    231232                        area = (char *)realloc( area, s );                      // attempt to reuse storage
    232                         if ( area == 0p ) abort( "calloc/realloc/free out of memory" );
     233                        if ( area == 0 ) abort( "calloc/realloc/free out of memory" );
    233234                        if ( area[0] != '\0' || area[s - 1] != '\0' ||
    234235                                 area[malloc_usable_size( area ) - 1] != '\0' ||
     
    244245                size_t s = i + default_mmap_start();                    // cross over point
    245246                char * area = (char *)calloc( 1, s );
    246                 if ( area == 0p ) abort( "calloc/realloc/free out of memory" );
     247                if ( area == 0 ) abort( "calloc/realloc/free out of memory" );
    247248                if ( area[0] != '\0' || area[s - 1] != '\0' ||
    248249                         area[malloc_usable_size( area ) - 1] != '\0' ||
     
    252253                for ( r; i ~ 256 * 1024 ~ 26 ) {                                // start at initial memory request
    253254                        area = (char *)realloc( area, r );                      // attempt to reuse storage
    254                         if ( area == 0p ) abort( "calloc/realloc/free out of memory" );
     255                        if ( area == 0 ) abort( "calloc/realloc/free out of memory" );
    255256                        if ( area[0] != '\0' || area[r - 1] != '\0' ||
    256257                                 area[malloc_usable_size( area ) - 1] != '\0' ||
     
    262263        // check memalign/realloc/free
    263264
    264         amount = 2;
     265        size_t amount = 2;
    265266        for ( a; libAlign() ~= limit ~ a ) {                            // generate powers of 2
    266267                // initial N byte allocation
    267268                char * area = (char *)memalign( a, amount );    // aligned N-byte allocation
    268                 if ( area == 0p ) abort( "memalign/realloc/free out of memory" ); // no storage ?
    269                 //sout | alignments[a] | area;
     269                if ( area == 0 ) abort( "memalign/realloc/free out of memory" ); // no storage ?
     270                //sout | alignments[a] | " " | area;
    270271                if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment
    271272                        abort( "memalign/realloc/free bad alignment : memalign(%d,%d) = %p", (int)a, (int)amount, area );
     
    277278                        if ( area[0] != '\345' || area[s - 2] != '\345' ) abort( "memalign/realloc/free corrupt storage" );
    278279                        area = (char *)realloc( area, s );                      // attempt to reuse storage
    279                         if ( area == 0p ) abort( "memalign/realloc/free out of memory" ); // no storage ?
    280                         //sout | i | area;
     280                        if ( area == 0 ) abort( "memalign/realloc/free out of memory" ); // no storage ?
     281                        //sout | i | " " | area;
    281282                        if ( (size_t)area % a != 0 ) {                          // check for initial alignment
    282283                                abort( "memalign/realloc/free bad alignment %p", area );
     
    293294                for ( s; 1 ~ limit ) {                                                  // allocation of size 0 can return null
    294295                        char * area = (char *)cmemalign( a, 1, s );
    295                         if ( area == 0p ) abort( "cmemalign/free out of memory" );
    296                         //sout | i | area;
     296                        if ( area == 0 ) abort( "cmemalign/free out of memory" );
     297                        //sout | i | " " | area;
    297298                        if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment
    298299                                abort( "cmemalign/free bad alignment : cmemalign(%d,%d) = %p", (int)a, s, area );
     
    312313                // initial N byte allocation
    313314                char * area = (char *)cmemalign( a, 1, amount ); // aligned N-byte allocation
    314                 if ( area == 0p ) abort( "cmemalign/realloc/free out of memory" ); // no storage ?
    315                 //sout | alignments[a] | area;
     315                if ( area == 0 ) abort( "cmemalign/realloc/free out of memory" ); // no storage ?
     316                //sout | alignments[a] | " " | area;
    316317                if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment
    317318                        abort( "cmemalign/realloc/free bad alignment : cmemalign(%d,%d) = %p", (int)a, (int)amount, area );
     
    326327                        if ( area[0] != '\345' || area[s - 2] != '\345' ) abort( "cmemalign/realloc/free corrupt storage2" );
    327328                        area = (char *)realloc( area, s );                      // attempt to reuse storage
    328                         if ( area == 0p ) abort( "cmemalign/realloc/free out of memory" ); // no storage ?
    329                         //sout | i | area;
     329                        if ( area == 0 ) abort( "cmemalign/realloc/free out of memory" ); // no storage ?
     330                        //sout | i | " " | area;
    330331                        if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment
    331332                                abort( "cmemalign/realloc/free bad alignment %p", area );
     
    338339                free( area );
    339340        } // for
    340 
    341         // check memalign/realloc with align/free
    342 
    343         amount = 2;
    344         for ( a; libAlign() ~= limit ~ a ) {                            // generate powers of 2
    345                 // initial N byte allocation
    346                 char * area = (char *)memalign( a, amount );    // aligned N-byte allocation
    347                 if ( area == 0p ) abort( "memalign/realloc with align/free out of memory" ); // no storage ?
    348                 //sout | alignments[a] | area | endl;
    349                 if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment
    350                         abort( "memalign/realloc with align/free bad alignment : memalign(%d,%d) = %p", (int)a, (int)amount, area );
    351                 } // if
    352                 area[0] = '\345'; area[amount - 2] = '\345';    // fill first/penultimate byte
    353 
    354                 // Do not start this loop index at 0 because realloc of 0 bytes frees the storage.
    355                 for ( s; amount ~ 256 * 1024 ) {                                // start at initial memory request
    356                         if ( area[0] != '\345' || area[s - 2] != '\345' ) abort( "memalign/realloc/free corrupt storage" );
    357                         area = (char *)realloc( area, a * 2, s );       // attempt to reuse storage
    358                         if ( area == 0p ) abort( "memalign/realloc with align/free out of memory" ); // no storage ?
    359                         //sout | i | area | endl;
    360                         if ( (size_t)area % a * 2 != 0 ) {                      // check for initial alignment
    361                                 abort( "memalign/realloc with align/free bad alignment %p", area );
    362                         } // if
    363                         area[s - 1] = '\345';                                           // fill last byte
    364                 } // for
    365                 free( area );
    366         } // for
    367 
    368         // check cmemalign/realloc with align/free
    369 
    370         amount = 2;
    371         for ( size_t a = libAlign() + libAlign(); a <= limit; a += a ) { // generate powers of 2
    372                 // initial N byte allocation
    373                 char *area = (char *)cmemalign( a, 1, amount ); // aligned N-byte allocation
    374                 if ( area == 0p ) abort( "cmemalign/realloc with align/free out of memory" ); // no storage ?
    375                 //sout | alignments[a] | area | endl;
    376                 if ( (size_t)area % a != 0 || malloc_alignment( area ) != a ) { // check for initial alignment
    377                         abort( "cmemalign/realloc with align/free bad alignment : cmemalign(%d,%d) = %p", (int)a, (int)amount, area );
    378                 } // if
    379                 if ( area[0] != '\0' || area[amount - 1] != '\0' ||
    380                          area[malloc_usable_size( area ) - 1] != '\0' ||
    381                          ! malloc_zero_fill( area ) ) abort( "cmemalign/realloc with align/free corrupt storage1" );
    382                 area[0] = '\345'; area[amount - 2] = '\345';    // fill first/penultimate byte
    383 
    384                 // Do not start this loop index at 0 because realloc of 0 bytes frees the storage.
    385                 for ( int s = amount; s < 256 * 1024; s += 1 ) { // start at initial memory request
    386                         if ( area[0] != '\345' || area[s - 2] != '\345' ) abort( "cmemalign/realloc with align/free corrupt storage2" );
    387                         area = (char *)realloc( area, a * 2, s );       // attempt to reuse storage
    388                         if ( area == 0p ) abort( "cmemalign/realloc with align/free out of memory" ); // no storage ?
    389                         //sout | i | area | endl;
    390                         if ( (size_t)area % a * 2 != 0 || malloc_alignment( area ) != a * 2 ) { // check for initial alignment
    391                                 abort( "cmemalign/realloc with align/free bad alignment %p %jd %jd", area, malloc_alignment( area ), a * 2 );
    392                         } // if
    393                         if ( area[s - 1] != '\0' || area[s - 1] != '\0' ||
    394                                  area[malloc_usable_size( area ) - 1] != '\0' ||
    395                                  ! malloc_zero_fill( area ) ) abort( "cmemalign/realloc/free corrupt storage3" );
    396                         area[s - 1] = '\345';                                           // fill last byte
    397                 } // for
    398                 free( area );
    399         } // for
    400 
    401341        //sout | "worker" | thisTask() | "successful completion";
    402342} // Worker main
  • tests/linking/withthreads.cfa

    r2fa5bd2 raca6a54c  
    3434// Local Variables: //
    3535// tab-width: 4 //
    36 // compile-command: "cfa withthreads.cfa" //
     36// compile-command: "cfa nothreads.cfa" //
    3737// End: //
  • tests/raii/dtor-early-exit.cfa

    r2fa5bd2 raca6a54c  
    217217}
    218218
    219 void i() {
    220         // potential loop
    221         for() {
    222                 if(true) continue;
    223                 int t = 0;
    224         }
    225 }
    226 
    227219// TODO: implement __label__ and uncomment these lines
    228220void computedGoto() {
  • tests/references.cfa

    r2fa5bd2 raca6a54c  
    119119                f( 3, a + b, (S){ 1.0, 7.0 }, (int [3]){ 1, 2, 3 } ); // two rvalue to reference
    120120        }
    121 
    122         {
    123                 int a = 3;
    124                 int *p = &a;
    125                 asm (
    126                         "incl %[p]\n\t"
    127                         : [p] "+m" (*p)
    128                 );
    129                 printf("%d\n", a);
    130         }
    131121}
    132122
  • tests/test.py

    r2fa5bd2 raca6a54c  
    1010import tempfile
    1111import time
    12 
    13 import os
    14 import psutil
    15 import signal
    1612
    1713################################################################################
     
    225221        make('clean', output_file=subprocess.DEVNULL, error=subprocess.DEVNULL)
    226222
    227         # since python prints stacks by default on a interrupt, redo the interrupt handling to be silent
    228         def worker_init():
    229                 def sig_int(signal_num, frame):
    230                         pass
    231 
    232                 signal.signal(signal.SIGINT, sig_int)
    233 
    234223        # create the executor for our jobs and handle the signal properly
    235         pool = multiprocessing.Pool(jobs, worker_init)
     224        pool = multiprocessing.Pool(jobs)
    236225
    237226        failed = False
    238 
    239         def stop(x, y):
    240                 print("Tests interrupted by user", file=sys.stderr)
    241                 sys.exit(1)
    242         signal.signal(signal.SIGINT, stop)
    243227
    244228        # for each test to run
  • tests/time.cfa

    r2fa5bd2 raca6a54c  
    1010// Created On       : Tue Mar 27 17:24:56 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Nov 29 23:05:30 2019
    13 // Update Count     : 24
     12// Last Modified On : Thu Dec 20 23:09:21 2018
     13// Update Count     : 23
    1414//
    1515
     
    2020        Duration d1 = 3`h, d2 = 2`s, d3 = 3.375`s, d4 = 12`s, d5 = 1`s + 10_000`ns;
    2121        sout | d1 | d2 | d3 | d4 | d5;
     22        int i;
    2223        d1 = 0;
    2324        sout | d1 | d2 | d3;
Note: See TracChangeset for help on using the changeset viewer.