Changeset 90a8125 for libcfa/src


Ignore:
Timestamp:
Jun 3, 2022, 3:10:01 PM (3 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, master, pthread-emulation, qualifiedEnum
Children:
7affcda
Parents:
bf0263c (diff), fc134a48 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

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

Location:
libcfa/src
Files:
54 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/Makefile.am

    rbf0263c r90a8125  
    3333# The built sources must not depend on the installed inst_headers_src
    3434AM_CFAFLAGS = -quiet -cfalib -I$(srcdir)/stdhdr -I$(srcdir)/concurrency $(if $(findstring ${gdbwaittarget}, ${@}), -XCFA --gdb) @CONFIG_CFAFLAGS@
    35 AM_CFLAGS = -g -Wall -Werror=return-type -Wno-unused-function -fPIC -fexceptions -pthread @ARCH_FLAGS@ @CONFIG_CFLAGS@
     35AM_CFLAGS = -g -Wall -Werror=return-type -Wno-unused-function -fPIC -fexceptions -fvisibility=hidden -pthread @ARCH_FLAGS@ @CONFIG_CFLAGS@
    3636AM_CCASFLAGS = -g -Wall -Werror=return-type -Wno-unused-function @ARCH_FLAGS@ @CONFIG_CFLAGS@
    3737CFACC = @CFACC@
     
    194194
    195195prelude.o : prelude.cfa extras.cf gcc-builtins.cf builtins.cf @LOCAL_CFACC@ @CFACPP@
    196         ${AM_V_GEN}$(CFACOMPILE) -quiet -XCFA,-l ${<} -c -o ${@}
     196        ${AM_V_GEN}$(CFACOMPILE) -quiet -XCFA,-l ${<} -c -fvisibility=default -o ${@}
    197197
    198198prelude.lo: prelude.cfa extras.cf gcc-builtins.cf builtins.cf @LOCAL_CFACC@ @CFACPP@
    199199        ${AM_V_GEN}$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile \
    200         $(CFACOMPILE) -quiet -XCFA,-l ${<} -c -o ${@}
     200        $(CFACOMPILE) -quiet -XCFA,-l ${<} -c -fvisibility=default -o ${@}
    201201
    202202concurrency/io/call.cfa: $(srcdir)/concurrency/io/call.cfa.in
  • libcfa/src/algorithms/range_iterator.cfa

    rbf0263c r90a8125  
    2020#include <fstream.hfa>
    2121
    22 void main(RangeIter & this) {
     22#include "bits/defs.hfa"
     23
     24void main(RangeIter & this) libcfa_public {
    2325        for() {
    2426                this._start = -1;
  • libcfa/src/assert.cfa

    rbf0263c r90a8125  
    1919#include <unistd.h>                                                             // STDERR_FILENO
    2020#include "bits/debug.hfa"
     21#include "bits/defs.hfa"
    2122
    2223extern "C" {
     
    2627
    2728        // called by macro assert in assert.h
    28         void __assert_fail( const char assertion[], const char file[], unsigned int line, const char function[] ) {
     29        // would be cool to remove libcfa_public but it's needed for libcfathread
     30        void __assert_fail( const char assertion[], const char file[], unsigned int line, const char function[] ) libcfa_public {
    2931                __cfaabi_bits_print_safe( STDERR_FILENO, CFA_ASSERT_FMT ".\n", assertion, __progname, function, line, file );
    3032                abort();
     
    3234
    3335        // called by macro assertf
    34         void __assert_fail_f( const char assertion[], const char file[], unsigned int line, const char function[], const char fmt[], ... ) {
     36        // would be cool to remove libcfa_public but it's needed for libcfathread
     37        void __assert_fail_f( const char assertion[], const char file[], unsigned int line, const char function[], const char fmt[], ... ) libcfa_public {
    3538                __cfaabi_bits_acquire();
    3639                __cfaabi_bits_print_nolock( STDERR_FILENO, CFA_ASSERT_FMT ": ", assertion, __progname, function, line, file );
  • libcfa/src/bits/debug.cfa

    rbf0263c r90a8125  
    2121#include <unistd.h>
    2222
     23#include "bits/defs.hfa"
     24
    2325enum { buffer_size = 4096 };
    2426static char buffer[ buffer_size ];
    2527
    2628extern "C" {
    27         void __cfaabi_bits_write( int fd, const char in_buffer[], int len ) {
     29        // would be cool to remove libcfa_public but it's needed for libcfathread
     30        void __cfaabi_bits_write( int fd, const char in_buffer[], int len ) libcfa_public {
    2831                // ensure all data is written
    2932                for ( int count = 0, retcode; count < len; count += retcode ) {
     
    4447        void __cfaabi_bits_release() __attribute__((__weak__)) {}
    4548
    46         int __cfaabi_bits_print_safe  ( int fd, const char fmt[], ... ) __attribute__(( format(printf, 2, 3) )) {
     49        // would be cool to remove libcfa_public but it's needed for libcfathread
     50        int __cfaabi_bits_print_safe  ( int fd, const char fmt[], ... ) __attribute__(( format(printf, 2, 3) )) libcfa_public {
    4751                va_list args;
    4852
  • libcfa/src/bits/defs.hfa

    rbf0263c r90a8125  
    3636#define __cfa_dlink(x) struct { struct x * next; struct x * back; } __dlink_substitute
    3737#endif
     38
     39#define libcfa_public __attribute__((visibility("default")))
    3840
    3941#ifdef __cforall
  • libcfa/src/bits/weakso_locks.cfa

    rbf0263c r90a8125  
    1818#include "bits/weakso_locks.hfa"
    1919
     20#pragma GCC visibility push(default)
     21
    2022void  ?{}( blocking_lock &, bool, bool ) {}
    2123void ^?{}( blocking_lock & ) {}
  • libcfa/src/common.cfa

    rbf0263c r90a8125  
    1818#include <stdlib.h>                                     // div_t, *div
    1919
     20#pragma GCC visibility push(default)
     21
    2022//---------------------------------------
    2123
  • libcfa/src/concurrency/alarm.cfa

    rbf0263c r90a8125  
    141141//=============================================================================================
    142142
    143 void sleep( Duration duration ) {
     143void sleep( Duration duration ) libcfa_public {
    144144        alarm_node_t node = { active_thread(), duration, 0`s };
    145145
  • libcfa/src/concurrency/clib/cfathread.cfa

    rbf0263c r90a8125  
    237237
    238238typedef ThreadCancelled(cfathread_object) cfathread_exception;
    239 typedef ThreadCancelled_vtable(cfathread_object) cfathread_vtable;
     239typedef vtable(ThreadCancelled(cfathread_object)) cfathread_vtable;
    240240
    241241void defaultResumptionHandler(ThreadCancelled(cfathread_object) & except) {
     
    283283
    284284typedef ThreadCancelled(__cfainit) __cfainit_exception;
    285 typedef ThreadCancelled_vtable(__cfainit) __cfainit_vtable;
     285typedef vtable(ThreadCancelled(__cfainit)) __cfainit_vtable;
    286286
    287287void defaultResumptionHandler(ThreadCancelled(__cfainit) & except) {
     
    326326}
    327327
     328#pragma GCC visibility push(default)
     329
    328330//================================================================================
    329331// Main Api
    330332extern "C" {
    331         int cfathread_cluster_create(cfathread_cluster_t * cl) __attribute__((nonnull(1))) {
     333        int cfathread_cluster_create(cfathread_cluster_t * cl) __attribute__((nonnull(1))) libcfa_public {
    332334                *cl = new();
    333335                return 0;
    334336        }
    335337
    336         cfathread_cluster_t cfathread_cluster_self(void) {
     338        cfathread_cluster_t cfathread_cluster_self(void) libcfa_public {
    337339                return active_cluster();
    338340        }
    339341
    340         int cfathread_cluster_print_stats( cfathread_cluster_t cl ) {
     342        int cfathread_cluster_print_stats( cfathread_cluster_t cl ) libcfa_public {
    341343                #if !defined(__CFA_NO_STATISTICS__)
    342344                        print_stats_at_exit( *cl, CFA_STATS_READY_Q | CFA_STATS_IO );
  • libcfa/src/concurrency/coroutine.cfa

    rbf0263c r90a8125  
    4848//-----------------------------------------------------------------------------
    4949forall(T &)
    50 void copy(CoroutineCancelled(T) * dst, CoroutineCancelled(T) * src) {
     50void copy(CoroutineCancelled(T) * dst, CoroutineCancelled(T) * src) libcfa_public {
    5151        dst->virtual_table = src->virtual_table;
    5252        dst->the_coroutine = src->the_coroutine;
     
    5555
    5656forall(T &)
    57 const char * msg(CoroutineCancelled(T) *) {
     57const char * msg(CoroutineCancelled(T) *) libcfa_public {
    5858        return "CoroutineCancelled(...)";
    5959}
     
    6262forall(T & | is_coroutine(T))
    6363void __cfaehm_cancelled_coroutine(
    64                 T & cor, coroutine$ * desc, EHM_DEFAULT_VTABLE(CoroutineCancelled, (T)) ) {
     64                T & cor, coroutine$ * desc, EHM_DEFAULT_VTABLE(CoroutineCancelled(T)) ) libcfa_public {
    6565        verify( desc->cancellation );
    6666        desc->state = Cancelled;
     
    8989
    9090void __stack_prepare( __stack_info_t * this, size_t create_size );
    91 void __stack_clean  ( __stack_info_t * this );
     91static void __stack_clean  ( __stack_info_t * this );
    9292
    9393//-----------------------------------------------------------------------------
     
    114114}
    115115
    116 void ?{}( coroutine$ & this, const char name[], void * storage, size_t storageSize ) with( this ) {
     116void ?{}( coroutine$ & this, const char name[], void * storage, size_t storageSize ) libcfa_public with( this ) {
    117117        (this.context){0p, 0p};
    118118        (this.stack){storage, storageSize};
     
    124124}
    125125
    126 void ^?{}(coroutine$& this) {
     126void ^?{}(coroutine$& this) libcfa_public {
    127127        if(this.state != Halted && this.state != Start && this.state != Primed) {
    128128                coroutine$ * src = active_coroutine();
     
    146146// Part of the Public API
    147147// Not inline since only ever called once per coroutine
    148 forall(T & | is_coroutine(T) | { EHM_DEFAULT_VTABLE(CoroutineCancelled, (T)); })
    149 void prime(T& cor) {
     148forall(T & | is_coroutine(T) | { EHM_DEFAULT_VTABLE(CoroutineCancelled(T)); })
     149void prime(T& cor) libcfa_public {
    150150        coroutine$* this = get_coroutine(cor);
    151151        assert(this->state == Start);
     
    155155}
    156156
    157 [void *, size_t] __stack_alloc( size_t storageSize ) {
     157static [void *, size_t] __stack_alloc( size_t storageSize ) {
    158158        const size_t stack_data_size = libCeiling( sizeof(__stack_t), 16 ); // minimum alignment
    159159        assert(__page_size != 0l);
     
    193193}
    194194
    195 void __stack_clean  ( __stack_info_t * this ) {
     195static void __stack_clean  ( __stack_info_t * this ) {
    196196        void * storage = this->storage->limit;
    197197
     
    215215}
    216216
    217 void __stack_prepare( __stack_info_t * this, size_t create_size ) {
     217void __stack_prepare( __stack_info_t * this, size_t create_size ) libcfa_public {
    218218        const size_t stack_data_size = libCeiling( sizeof(__stack_t), 16 ); // minimum alignment
    219219        bool userStack;
  • libcfa/src/concurrency/coroutine.hfa

    rbf0263c r90a8125  
    2222//-----------------------------------------------------------------------------
    2323// Exception thrown from resume when a coroutine stack is cancelled.
    24 EHM_FORALL_EXCEPTION(CoroutineCancelled, (coroutine_t &), (coroutine_t)) (
     24forall(coroutine_t &)
     25exception CoroutineCancelled {
    2526        coroutine_t * the_coroutine;
    2627        exception_t * the_exception;
    27 );
     28};
    2829
    2930forall(T &)
     
    3738// Anything that implements this trait can be resumed.
    3839// Anything that is resumed is a coroutine.
    39 trait is_coroutine(T & | IS_RESUMPTION_EXCEPTION(CoroutineCancelled, (T))) {
     40trait is_coroutine(T & | IS_RESUMPTION_EXCEPTION(CoroutineCancelled(T))) {
    4041        void main(T & this);
    4142        coroutine$ * get_coroutine(T & this);
     
    6061//-----------------------------------------------------------------------------
    6162// Public coroutine API
    62 forall(T & | is_coroutine(T) | { EHM_DEFAULT_VTABLE(CoroutineCancelled, (T)); })
     63forall(T & | is_coroutine(T) | { EHM_DEFAULT_VTABLE(CoroutineCancelled(T)); })
    6364void prime(T & cor);
    6465
     
    113114
    114115extern void __stack_prepare( __stack_info_t * this, size_t size /* ignored if storage already allocated */);
    115 extern void __stack_clean  ( __stack_info_t * this );
    116 
    117116
    118117// Suspend implementation inlined for performance
     
    141140forall(T & | is_coroutine(T))
    142141void __cfaehm_cancelled_coroutine(
    143         T & cor, coroutine$ * desc, EHM_DEFAULT_VTABLE(CoroutineCancelled, (T)) );
     142        T & cor, coroutine$ * desc, EHM_DEFAULT_VTABLE(CoroutineCancelled(T)) );
    144143
    145144// Resume implementation inlined for performance
    146 forall(T & | is_coroutine(T) | { EHM_DEFAULT_VTABLE(CoroutineCancelled, (T)); })
     145forall(T & | is_coroutine(T) | { EHM_DEFAULT_VTABLE(CoroutineCancelled(T)); })
    147146static inline T & resume(T & cor) {
    148147        // optimization : read TLS once and reuse it
  • libcfa/src/concurrency/exception.cfa

    rbf0263c r90a8125  
    6464extern "C" {
    6565
    66 struct exception_context_t * this_exception_context(void) {
     66struct exception_context_t * this_exception_context(void) libcfa_public {
    6767        return &__get_stack( active_coroutine() )->exception_context;
    6868}
    6969
    70 _Unwind_Reason_Code __cfaehm_cancellation_unwind( struct _Unwind_Exception * unwind_exception ) {
     70_Unwind_Reason_Code __cfaehm_cancellation_unwind( struct _Unwind_Exception * unwind_exception ) libcfa_public {
    7171        _Unwind_Stop_Fn stop_func;
    7272        void * stop_param;
  • libcfa/src/concurrency/invoke.c

    rbf0263c r90a8125  
    3636extern void enable_interrupts( _Bool poll );
    3737
    38 void __cfactx_invoke_coroutine(
     38libcfa_public void __cfactx_invoke_coroutine(
    3939        void (*main)(void *),
    4040        void *this
     
    7070}
    7171
    72 void __cfactx_coroutine_unwind(struct _Unwind_Exception * storage, struct coroutine$ * cor) __attribute__ ((__noreturn__));
     72libcfa_public void __cfactx_coroutine_unwind(struct _Unwind_Exception * storage, struct coroutine$ * cor) __attribute__ ((__noreturn__));
    7373void __cfactx_coroutine_unwind(struct _Unwind_Exception * storage, struct coroutine$ * cor) {
    7474        _Unwind_Reason_Code ret = _Unwind_ForcedUnwind( storage, __cfactx_coroutine_unwindstop, cor );
     
    7777}
    7878
    79 void __cfactx_invoke_thread(
     79libcfa_public void __cfactx_invoke_thread(
    8080        void (*main)(void *),
    8181        void *this
     
    9898}
    9999
    100 void __cfactx_start(
     100libcfa_public void __cfactx_start(
    101101        void (*main)(void *),
    102102        struct coroutine$ * cor,
  • libcfa/src/concurrency/io.cfa

    rbf0263c r90a8125  
    221221                        const unsigned long long ctsc = rdtscl();
    222222
    223                         if(proc->io.target == MAX) {
     223                        if(proc->io.target == UINT_MAX) {
    224224                                uint64_t chaos = __tls_rand();
    225225                                unsigned ext = chaos & 0xff;
     
    232232                        else {
    233233                                const unsigned target = proc->io.target;
    234                                 /* paranoid */ verify( io.tscs[target].tv != MAX );
     234                                /* paranoid */ verify( io.tscs[target].tv != ULLONG_MAX );
    235235                                HELP: if(target < ctxs_count) {
    236236                                        const unsigned long long cutoff = calc_cutoff(ctsc, ctx->cq.id, ctxs_count, io.data, io.tscs, __shard_factor.io);
     
    246246                                        __STATS__( true, io.calls.helped++; )
    247247                                }
    248                                 proc->io.target = MAX;
     248                                proc->io.target = UINT_MAX;
    249249                        }
    250250                }
     
    340340        // for convenience, return both the index and the pointer to the sqe
    341341        // sqe == &sqes[idx]
    342         struct $io_context * cfa_io_allocate(struct io_uring_sqe * sqes[], __u32 idxs[], __u32 want) {
     342        struct $io_context * cfa_io_allocate(struct io_uring_sqe * sqes[], __u32 idxs[], __u32 want) libcfa_public {
    343343                // __cfadbg_print_safe(io, "Kernel I/O : attempting to allocate %u\n", want);
    344344
     
    419419        }
    420420
    421         void cfa_io_submit( struct $io_context * inctx, __u32 idxs[], __u32 have, bool lazy ) __attribute__((nonnull (1))) {
     421        void cfa_io_submit( struct $io_context * inctx, __u32 idxs[], __u32 have, bool lazy ) __attribute__((nonnull (1))) libcfa_public {
    422422                // __cfadbg_print_safe(io, "Kernel I/O : attempting to submit %u (%s)\n", have, lazy ? "lazy" : "eager");
    423423
  • libcfa/src/concurrency/io/call.cfa.in

    rbf0263c r90a8125  
    139139// I/O Interface
    140140//=============================================================================================
     141#pragma GCC visibility push(default)
    141142"""
    142143
  • libcfa/src/concurrency/io/setup.cfa

    rbf0263c r90a8125  
    2626
    2727#if !defined(CFA_HAVE_LINUX_IO_URING_H)
    28         void ?{}(io_context_params & this) {}
     28        void ?{}(io_context_params & this) libcfa_public {}
    2929
    3030        void  ?{}($io_context & this, struct cluster & cl) {}
     
    6666#pragma GCC diagnostic pop
    6767
    68         void ?{}(io_context_params & this) {
     68        void ?{}(io_context_params & this) libcfa_public {
    6969                this.num_entries = 256;
    7070        }
  • libcfa/src/concurrency/io/types.hfa

    rbf0263c r90a8125  
    1717#pragma once
    1818
     19#include <limits.h>
     20
    1921extern "C" {
    2022        #include <linux/types.h>
     
    2527#include "iofwd.hfa"
    2628#include "kernel/fwd.hfa"
    27 #include "limits.hfa"
    2829
    2930#if defined(CFA_HAVE_LINUX_IO_URING_H)
     
    140141                const __u32 tail = *this->cq.tail;
    141142
    142                 if(head == tail) return MAX;
     143                if(head == tail) return ULLONG_MAX;
    143144
    144145                return this->cq.ts;
  • libcfa/src/concurrency/kernel.cfa

    rbf0263c r90a8125  
    389389
    390390// KERNEL_ONLY
    391 void returnToKernel() {
     391static void returnToKernel() {
    392392        /* paranoid */ verify( ! __preemption_enabled() );
    393393        coroutine$ * proc_cor = get_coroutine(kernelTLS().this_processor->runner);
     
    547547}
    548548
    549 void unpark( thread$ * thrd, unpark_hint hint ) {
     549void unpark( thread$ * thrd, unpark_hint hint ) libcfa_public {
    550550        if( !thrd ) return;
    551551
     
    558558}
    559559
    560 void park( void ) {
     560void park( void ) libcfa_public {
    561561        __disable_interrupts_checked();
    562562                /* paranoid */ verify( kernelTLS().this_thread->preempted == __NO_PREEMPTION );
     
    601601
    602602// KERNEL ONLY
    603 bool force_yield( __Preemption_Reason reason ) {
     603bool force_yield( __Preemption_Reason reason ) libcfa_public {
    604604        __disable_interrupts_checked();
    605605                thread$ * thrd = kernelTLS().this_thread;
     
    849849//-----------------------------------------------------------------------------
    850850// Debug
    851 bool threading_enabled(void) __attribute__((const)) {
     851bool threading_enabled(void) __attribute__((const)) libcfa_public {
    852852        return true;
    853853}
     
    856856// Statistics
    857857#if !defined(__CFA_NO_STATISTICS__)
    858         void print_halts( processor & this ) {
     858        void print_halts( processor & this ) libcfa_public {
    859859                this.print_halts = true;
    860860        }
     
    873873        }
    874874
    875         void crawl_cluster_stats( cluster & this ) {
     875        static void crawl_cluster_stats( cluster & this ) {
    876876                // Stop the world, otherwise stats could get really messed-up
    877877                // this doesn't solve all problems but does solve many
     
    889889
    890890
    891         void print_stats_now( cluster & this, int flags ) {
     891        void print_stats_now( cluster & this, int flags ) libcfa_public {
    892892                crawl_cluster_stats( this );
    893893                __print_stats( this.stats, flags, "Cluster", this.name, (void*)&this );
  • libcfa/src/concurrency/kernel.hfa

    rbf0263c r90a8125  
    4949
    5050// Coroutine used py processors for the 2-step context switch
    51 coroutine processorCtx_t {
     51
     52struct processorCtx_t {
     53        struct coroutine$ self;
    5254        struct processor * proc;
    5355};
  • libcfa/src/concurrency/kernel/cluster.cfa

    rbf0263c r90a8125  
    4949
    5050// returns the maximum number of processors the RWLock support
    51 __attribute__((weak)) unsigned __max_processors() {
     51__attribute__((weak)) unsigned __max_processors() libcfa_public {
    5252        const char * max_cores_s = getenv("CFA_MAX_PROCESSORS");
    5353        if(!max_cores_s) {
     
    233233                                        if(is_empty(sl)) {
    234234                                                assert( sl.anchor.next == 0p );
    235                                                 assert( sl.anchor.ts   == -1llu );
     235                                                assert( sl.anchor.ts   == MAX );
    236236                                                assert( mock_head(sl)  == sl.prev );
    237237                                        } else {
    238238                                                assert( sl.anchor.next != 0p );
    239                                                 assert( sl.anchor.ts   != -1llu );
     239                                                assert( sl.anchor.ts   != MAX );
    240240                                                assert( mock_head(sl)  != sl.prev );
    241241                                        }
     
    259259                /* paranoid */ verifyf( it, "Unexpected null iterator, at index %u of %u\n", i, count);
    260260                it->rdq.id = valrq;
    261                 it->rdq.target = MAX;
     261                it->rdq.target = UINT_MAX;
    262262                valrq += __shard_factor.readyq;
    263263                #if defined(CFA_HAVE_LINUX_IO_URING_H)
    264264                        it->io.ctx->cq.id = valio;
    265                         it->io.target = MAX;
     265                        it->io.target = UINT_MAX;
    266266                        valio += __shard_factor.io;
    267267                #endif
     
    472472        this.prev = mock_head(this);
    473473        this.anchor.next = 0p;
    474         this.anchor.ts   = -1llu;
     474        this.anchor.ts   = MAX;
    475475        #if !defined(__CFA_NO_STATISTICS__)
    476476                this.cnt  = 0;
     
    484484        /* paranoid */ verify( &mock_head(this)->link.ts   == &this.anchor.ts   );
    485485        /* paranoid */ verify( mock_head(this)->link.next == 0p );
    486         /* paranoid */ verify( mock_head(this)->link.ts   == -1llu );
     486        /* paranoid */ verify( mock_head(this)->link.ts   == MAX );
    487487        /* paranoid */ verify( mock_head(this) == this.prev );
    488488        /* paranoid */ verify( __alignof__(__intrusive_lane_t) == 128 );
     
    495495        // Make sure the list is empty
    496496        /* paranoid */ verify( this.anchor.next == 0p );
    497         /* paranoid */ verify( this.anchor.ts   == -1llu );
     497        /* paranoid */ verify( this.anchor.ts   == MAX );
    498498        /* paranoid */ verify( mock_head(this)  == this.prev );
    499499}
  • libcfa/src/concurrency/kernel/cluster.hfa

    rbf0263c r90a8125  
    1919#include "kernel/private.hfa"
    2020
    21 #include "limits.hfa"
     21#include <limits.h>
    2222
    2323//-----------------------------------------------------------------------
     
    3737
    3838static inline void touch_tsc(__timestamp_t * tscs, size_t idx, unsigned long long ts_prev, unsigned long long ts_next) {
    39         if (ts_next == MAX) return;
     39        if (ts_next == ULLONG_MAX) return;
    4040        unsigned long long now = rdtscl();
    4141        unsigned long long pma = __atomic_load_n(&tscs[ idx ].ma, __ATOMIC_RELAXED);
     
    5959        for(i; shard_factor) {
    6060                unsigned long long ptsc = ts(data[start + i]);
    61                 if(ptsc != -1ull) {
     61                if(ptsc != ULLONG_MAX) {
    6262                        /* paranoid */ verify( start + i < count );
    6363                        unsigned long long tsc = moving_average(ctsc, ptsc, tscs[start + i].ma);
  • libcfa/src/concurrency/kernel/private.hfa

    rbf0263c r90a8125  
    109109//-----------------------------------------------------------------------------
    110110// Processor
    111 void main(processorCtx_t *);
     111void main(processorCtx_t &);
     112static inline coroutine$* get_coroutine(processorCtx_t & this) { return &this.self; }
    112113
    113114void * __create_pthread( pthread_t *, void * (*)(void *), void * );
  • libcfa/src/concurrency/kernel/startup.cfa

    rbf0263c r90a8125  
    120120#endif
    121121
    122 cluster              * mainCluster;
     122cluster              * mainCluster libcfa_public;
    123123processor            * mainProcessor;
    124124thread$              * mainThread;
     
    169169};
    170170
    171 void ?{}( current_stack_info_t & this ) {
     171static void ?{}( current_stack_info_t & this ) {
    172172        __stack_context_t ctx;
    173173        CtxGet( ctx );
     
    209209        // Construct the processor context of the main processor
    210210        void ?{}(processorCtx_t & this, processor * proc) {
    211                 (this.__cor){ "Processor" };
    212                 this.__cor.starter = 0p;
     211                (this.self){ "Processor" };
     212                this.self.starter = 0p;
    213213                this.proc = proc;
    214214        }
     
    507507        self_mon_p = &self_mon;
    508508        link.next = 0p;
    509         link.ts   = -1llu;
     509        link.ts   = MAX;
    510510        preferred = ready_queue_new_preferred();
    511511        last_proc = 0p;
     
    526526// Construct the processor context of non-main processors
    527527static void ?{}(processorCtx_t & this, processor * proc, current_stack_info_t * info) {
    528         (this.__cor){ info };
     528        (this.self){ info };
    529529        this.proc = proc;
    530530}
     
    578578}
    579579
    580 void ?{}(processor & this, const char name[], cluster & _cltr, thread$ * initT) {
     580void ?{}(processor & this, const char name[], cluster & _cltr, thread$ * initT) libcfa_public {
    581581        ( this.terminated ){};
    582582        ( this.runner ){};
     
    591591}
    592592
    593 void ?{}(processor & this, const char name[], cluster & _cltr) {
     593void ?{}(processor & this, const char name[], cluster & _cltr) libcfa_public {
    594594        (this){name, _cltr, 0p};
    595595}
    596596
    597597extern size_t __page_size;
    598 void ^?{}(processor & this) with( this ){
     598void ^?{}(processor & this) libcfa_public with( this ) {
    599599        /* paranoid */ verify( !__atomic_load_n(&do_terminate, __ATOMIC_ACQUIRE) );
    600600        __cfadbg_print_safe(runtime_core, "Kernel : core %p signaling termination\n", &this);
     
    623623}
    624624
    625 void ?{}(cluster & this, const char name[], Duration preemption_rate, unsigned num_io, const io_context_params & io_params) with( this ) {
     625void ?{}(cluster & this, const char name[], Duration preemption_rate, unsigned num_io, const io_context_params & io_params) libcfa_public with( this ) {
    626626        this.name = name;
    627627        this.preemption_rate = preemption_rate;
     
    658658}
    659659
    660 void ^?{}(cluster & this) {
     660void ^?{}(cluster & this) libcfa_public {
    661661        destroy(this.io.arbiter);
    662662
  • libcfa/src/concurrency/locks.cfa

    rbf0263c r90a8125  
    2424#include <stdlib.hfa>
    2525
     26#pragma GCC visibility push(default)
     27
    2628//-----------------------------------------------------------------------------
    2729// info_thread
     
    116118}
    117119
    118 void pop_and_set_new_owner( blocking_lock & this ) with( this ) {
     120static void pop_and_set_new_owner( blocking_lock & this ) with( this ) {
    119121        thread$ * t = &try_pop_front( blocked_threads );
    120122        owner = t;
     
    192194        void ^?{}( alarm_node_wrap(L) & this ) { }
    193195
    194         void timeout_handler ( alarm_node_wrap(L) & this ) with( this ) {
     196        static void timeout_handler ( alarm_node_wrap(L) & this ) with( this ) {
    195197                // This condition_variable member is called from the kernel, and therefore, cannot block, but it can spin.
    196198                lock( cond->lock __cfaabi_dbg_ctx2 );
     
    216218
    217219        // this casts the alarm node to our wrapped type since we used type erasure
    218         void alarm_node_wrap_cast( alarm_node_t & a ) { timeout_handler( (alarm_node_wrap(L) &)a ); }
     220        static void alarm_node_wrap_cast( alarm_node_t & a ) { timeout_handler( (alarm_node_wrap(L) &)a ); }
    219221}
    220222
     
    233235        void ^?{}( condition_variable(L) & this ){ }
    234236
    235         void process_popped( condition_variable(L) & this, info_thread(L) & popped ) with( this ) {
     237        static void process_popped( condition_variable(L) & this, info_thread(L) & popped ) with( this ) {
    236238                if(&popped != 0p) {
    237239                        popped.signalled = true;
     
    278280        int counter( condition_variable(L) & this ) with(this) { return count; }
    279281
    280         size_t queue_and_get_recursion( condition_variable(L) & this, info_thread(L) * i ) with(this) {
     282        static size_t queue_and_get_recursion( condition_variable(L) & this, info_thread(L) * i ) with(this) {
    281283                // add info_thread to waiting queue
    282284                insert_last( blocked_threads, *i );
     
    291293
    292294        // helper for wait()'s' with no timeout
    293         void queue_info_thread( condition_variable(L) & this, info_thread(L) & i ) with(this) {
     295        static void queue_info_thread( condition_variable(L) & this, info_thread(L) & i ) with(this) {
    294296                lock( lock __cfaabi_dbg_ctx2 );
    295297                size_t recursion_count = queue_and_get_recursion(this, &i);
     
    308310
    309311        // helper for wait()'s' with a timeout
    310         void queue_info_thread_timeout( condition_variable(L) & this, info_thread(L) & info, Duration t, Alarm_Callback callback ) with(this) {
     312        static void queue_info_thread_timeout( condition_variable(L) & this, info_thread(L) & info, Duration t, Alarm_Callback callback ) with(this) {
    311313                lock( lock __cfaabi_dbg_ctx2 );
    312314                size_t recursion_count = queue_and_get_recursion(this, &info);
     
    343345        // fast_cond_var
    344346        void  ?{}( fast_cond_var(L) & this ){
    345                 this.blocked_threads{}; 
     347                this.blocked_threads{};
    346348                #ifdef __CFA_DEBUG__
    347349                this.lock_used = 0p;
  • libcfa/src/concurrency/monitor.cfa

    rbf0263c r90a8125  
    4444static inline void restore( monitor$ * ctx [], __lock_size_t count, __spinlock_t * locks [], unsigned int /*in */ recursions [], __waitfor_mask_t /*in */ masks [] );
    4545
     46static inline void ?{}(__condition_node_t & this, thread$ * waiting_thread, __lock_size_t count, uintptr_t user_info );
     47static inline void ?{}(__condition_criterion_t & this );
     48static inline void ?{}(__condition_criterion_t & this, monitor$ * target, __condition_node_t * owner );
     49
    4650static inline void init     ( __lock_size_t count, monitor$ * monitors [], __condition_node_t & waiter, __condition_criterion_t criteria [] );
    4751static inline void init_push( __lock_size_t count, monitor$ * monitors [], __condition_node_t & waiter, __condition_criterion_t criteria [] );
     
    243247
    244248// Leave single monitor
    245 void __leave( monitor$ * this ) {
     249static void __leave( monitor$ * this ) {
    246250        // Lock the monitor spinlock
    247251        lock( this->lock __cfaabi_dbg_ctx2 );
     
    278282
    279283// Leave single monitor for the last time
    280 void __dtor_leave( monitor$ * this, bool join ) {
     284static void __dtor_leave( monitor$ * this, bool join ) {
    281285        __cfaabi_dbg_debug_do(
    282286                if( active_thread() != this->owner ) {
     
    344348// Ctor for monitor guard
    345349// Sorts monitors before entering
    346 void ?{}( monitor_guard_t & this, monitor$ * m [], __lock_size_t count, fptr_t func ) {
     350void ?{}( monitor_guard_t & this, monitor$ * m [], __lock_size_t count, fptr_t func ) libcfa_public {
    347351        thread$ * thrd = active_thread();
    348352
     
    369373}
    370374
    371 void ?{}( monitor_guard_t & this, monitor$ * m [], __lock_size_t count ) {
     375void ?{}( monitor_guard_t & this, monitor$ * m [], __lock_size_t count ) libcfa_public {
    372376        this{ m, count, 0p };
    373377}
     
    375379
    376380// Dtor for monitor guard
    377 void ^?{}( monitor_guard_t & this ) {
     381void ^?{}( monitor_guard_t & this ) libcfa_public {
    378382        // __cfaabi_dbg_print_safe( "MGUARD : leaving %d\n", this.count);
    379383
     
    389393// Ctor for monitor guard
    390394// Sorts monitors before entering
    391 void ?{}( monitor_dtor_guard_t & this, monitor$ * m [], fptr_t func, bool join ) {
     395void ?{}( monitor_dtor_guard_t & this, monitor$ * m [], fptr_t func, bool join ) libcfa_public {
    392396        // optimization
    393397        thread$ * thrd = active_thread();
     
    409413
    410414// Dtor for monitor guard
    411 void ^?{}( monitor_dtor_guard_t & this ) {
     415void ^?{}( monitor_dtor_guard_t & this ) libcfa_public {
    412416        // Leave the monitors in order
    413417        __dtor_leave( this.m, this.join );
     
    419423//-----------------------------------------------------------------------------
    420424// Internal scheduling types
    421 void ?{}(__condition_node_t & this, thread$ * waiting_thread, __lock_size_t count, uintptr_t user_info ) {
     425static void ?{}(__condition_node_t & this, thread$ * waiting_thread, __lock_size_t count, uintptr_t user_info ) {
    422426        this.waiting_thread = waiting_thread;
    423427        this.count = count;
     
    426430}
    427431
    428 void ?{}(__condition_criterion_t & this ) with( this ) {
     432static void ?{}(__condition_criterion_t & this ) with( this ) {
    429433        ready  = false;
    430434        target = 0p;
     
    433437}
    434438
    435 void ?{}(__condition_criterion_t & this, monitor$ * target, __condition_node_t & owner ) {
     439static void ?{}(__condition_criterion_t & this, monitor$ * target, __condition_node_t & owner ) {
    436440        this.ready  = false;
    437441        this.target = target;
     
    442446//-----------------------------------------------------------------------------
    443447// Internal scheduling
    444 void wait( condition & this, uintptr_t user_info = 0 ) {
     448void wait( condition & this, uintptr_t user_info = 0 ) libcfa_public {
    445449        brand_condition( this );
    446450
     
    496500}
    497501
    498 bool signal( condition & this ) {
     502bool signal( condition & this ) libcfa_public {
    499503        if( is_empty( this ) ) { return false; }
    500504
     
    538542}
    539543
    540 bool signal_block( condition & this ) {
     544bool signal_block( condition & this ) libcfa_public {
    541545        if( !this.blocked.head ) { return false; }
    542546
     
    586590
    587591// Access the user_info of the thread waiting at the front of the queue
    588 uintptr_t front( condition & this ) {
     592uintptr_t front( condition & this ) libcfa_public {
    589593        verifyf( !is_empty(this),
    590594                "Attempt to access user data on an empty condition.\n"
     
    608612//              setup mask
    609613//              block
    610 void __waitfor_internal( const __waitfor_mask_t & mask, int duration ) {
     614void __waitfor_internal( const __waitfor_mask_t & mask, int duration ) libcfa_public {
    611615        // This statment doesn't have a contiguous list of monitors...
    612616        // Create one!
     
    994998// Can't be accepted since a mutex stmt is effectively an anonymous routine
    995999// Thus we do not need a monitor group
    996 void lock( monitor$ * this ) {
     1000void lock( monitor$ * this ) libcfa_public {
    9971001        thread$ * thrd = active_thread();
    9981002
     
    10461050// Leave routine for mutex stmt
    10471051// Is just a wrapper around __leave for the is_lock trait to see
    1048 void unlock( monitor$ * this ) { __leave( this ); }
     1052void unlock( monitor$ * this ) libcfa_public { __leave( this ); }
    10491053
    10501054// Local Variables: //
  • libcfa/src/concurrency/monitor.hfa

    rbf0263c r90a8125  
    119119}
    120120
    121 void ?{}(__condition_node_t & this, thread$ * waiting_thread, __lock_size_t count, uintptr_t user_info );
    122 void ?{}(__condition_criterion_t & this );
    123 void ?{}(__condition_criterion_t & this, monitor$ * target, __condition_node_t * owner );
     121// void ?{}(__condition_node_t & this, thread$ * waiting_thread, __lock_size_t count, uintptr_t user_info );
     122// void ?{}(__condition_criterion_t & this );
     123// void ?{}(__condition_criterion_t & this, monitor$ * target, __condition_node_t * owner );
    124124
    125125struct condition {
  • libcfa/src/concurrency/preemption.cfa

    rbf0263c r90a8125  
    3838#endif
    3939
    40 __attribute__((weak)) Duration default_preemption() {
     40__attribute__((weak)) Duration default_preemption() libcfa_public {
    4141        const char * preempt_rate_s = getenv("CFA_DEFAULT_PREEMPTION");
    4242        if(!preempt_rate_s) {
     
    238238//----------
    239239// special case for preemption since used often
    240 __attribute__((optimize("no-reorder-blocks"))) bool __preemption_enabled() {
     240__attribute__((optimize("no-reorder-blocks"))) bool __preemption_enabled() libcfa_public {
    241241        // create a assembler label before
    242242        // marked as clobber all to avoid movement
     
    276276// Get data from the TLS block
    277277// struct asm_region __cfaasm_get;
    278 uintptr_t __cfatls_get( unsigned long int offset ) __attribute__((__noinline__)); //no inline to avoid problems
     278uintptr_t __cfatls_get( unsigned long int offset ) __attribute__((__noinline__, visibility("default"))); //no inline to avoid problems
    279279uintptr_t __cfatls_get( unsigned long int offset ) {
    280280        // create a assembler label before
     
    295295extern "C" {
    296296        // Disable interrupts by incrementing the counter
    297         void disable_interrupts() {
     297        __attribute__((__noinline__, visibility("default"))) void disable_interrupts() libcfa_public {
    298298                // create a assembler label before
    299299                // marked as clobber all to avoid movement
     
    326326        // Enable interrupts by decrementing the counter
    327327        // If counter reaches 0, execute any pending __cfactx_switch
    328         void enable_interrupts( bool poll ) {
     328        void enable_interrupts( bool poll ) libcfa_public {
    329329                // Cache the processor now since interrupts can start happening after the atomic store
    330330                processor   * proc = __cfaabi_tls.this_processor;
     
    362362//-----------------------------------------------------------------------------
    363363// Kernel Signal Debug
    364 void __cfaabi_check_preemption() {
     364void __cfaabi_check_preemption() libcfa_public {
    365365        bool ready = __preemption_enabled();
    366366        if(!ready) { abort("Preemption should be ready"); }
  • libcfa/src/concurrency/ready_queue.cfa

    rbf0263c r90a8125  
    125125        const unsigned long long ctsc = rdtscl();
    126126
    127         if(proc->rdq.target == MAX) {
     127        if(proc->rdq.target == UINT_MAX) {
    128128                uint64_t chaos = __tls_rand();
    129129                unsigned ext = chaos & 0xff;
     
    137137                const unsigned target = proc->rdq.target;
    138138                __cfadbg_print_safe(ready_queue, "Kernel : %u considering helping %u, tcsc %llu\n", this, target, readyQ.tscs[target].tv);
    139                 /* paranoid */ verify( readyQ.tscs[target].tv != MAX );
     139                /* paranoid */ verify( readyQ.tscs[target].tv != ULLONG_MAX );
    140140                if(target < lanes_count) {
    141141                        const unsigned long long cutoff = calc_cutoff(ctsc, proc->rdq.id, lanes_count, cltr->sched.readyQ.data, cltr->sched.readyQ.tscs, __shard_factor.readyq);
     
    147147                        }
    148148                }
    149                 proc->rdq.target = MAX;
     149                proc->rdq.target = UINT_MAX;
    150150        }
    151151
     
    245245// get preferred ready for new thread
    246246unsigned ready_queue_new_preferred() {
    247         unsigned pref = MAX;
     247        unsigned pref = UINT_MAX;
    248248        if(struct thread$ * thrd = publicTLS_get( this_thread )) {
    249249                pref = thrd->preferred;
  • libcfa/src/concurrency/ready_subqueue.hfa

    rbf0263c r90a8125  
    3232        /* paranoid */ verify( this.lock );
    3333        /* paranoid */ verify( node->link.next == 0p );
    34         /* paranoid */ verify( node->link.ts  == MAX  );
     34        /* paranoid */ verify( __atomic_load_n(&node->link.ts, __ATOMIC_RELAXED) == MAX  );
    3535        /* paranoid */ verify( this.prev->link.next == 0p );
    36         /* paranoid */ verify( this.prev->link.ts   == MAX  );
     36        /* paranoid */ verify( __atomic_load_n(&this.prev->link.ts, __ATOMIC_RELAXED)   == MAX  );
    3737        if( this.anchor.next == 0p ) {
    3838                /* paranoid */ verify( this.anchor.next == 0p );
    39                 /* paranoid */ verify( this.anchor.ts  == MAX );
    40                 /* paranoid */ verify( this.anchor.ts  != 0  );
     39                /* paranoid */ verify( __atomic_load_n(&this.anchor.ts, __ATOMIC_RELAXED) == MAX );
     40                /* paranoid */ verify( __atomic_load_n(&this.anchor.ts, __ATOMIC_RELAXED) != 0  );
    4141                /* paranoid */ verify( this.prev == mock_head( this ) );
    4242        } else {
    4343                /* paranoid */ verify( this.anchor.next != 0p );
    44                 /* paranoid */ verify( this.anchor.ts  != MAX );
    45                 /* paranoid */ verify( this.anchor.ts  != 0  );
     44                /* paranoid */ verify( __atomic_load_n(&this.anchor.ts, __ATOMIC_RELAXED) != MAX );
     45                /* paranoid */ verify( __atomic_load_n(&this.anchor.ts, __ATOMIC_RELAXED) != 0  );
    4646                /* paranoid */ verify( this.prev != mock_head( this ) );
    4747        }
     
    6262        /* paranoid */ verify( this.lock );
    6363        /* paranoid */ verify( this.anchor.next != 0p );
    64         /* paranoid */ verify( this.anchor.ts  != MAX );
    65         /* paranoid */ verify( this.anchor.ts   != 0  );
     64        /* paranoid */ verify( __atomic_load_n(&this.anchor.ts, __ATOMIC_RELAXED) != MAX );
     65        /* paranoid */ verify( __atomic_load_n(&this.anchor.ts, __ATOMIC_RELAXED) != 0   );
    6666
    6767        // Get the relevant nodes locally
    6868        thread$ * node = this.anchor.next;
    6969        this.anchor.next = node->link.next;
    70         this.anchor.ts   = node->link.ts;
     70        __atomic_store_n(&this.anchor.ts, __atomic_load_n(&node->link.ts, __ATOMIC_RELAXED), __ATOMIC_RELAXED);
    7171        bool is_empty = this.anchor.next == 0p;
    7272        node->link.next = 0p;
    73         node->link.ts   = MAX;
     73        __atomic_store_n(&node->link.ts, ULLONG_MAX, __ATOMIC_RELAXED);
    7474        #if !defined(__CFA_NO_STATISTICS__)
    7575                this.cnt--;
     
    7979        if(is_empty) this.prev = mock_head( this );
    8080
     81        unsigned long long ats = __atomic_load_n(&this.anchor.ts, __ATOMIC_RELAXED);
    8182        /* paranoid */ verify( node->link.next == 0p );
    82         /* paranoid */ verify( node->link.ts   == MAX );
    83         /* paranoid */ verify( node->link.ts   != 0  );
    84         /* paranoid */ verify( this.anchor.ts  != 0 );
    85         /* paranoid */ verify( (this.anchor.ts == MAX) == is_empty );
    86         return [node, this.anchor.ts];
     83        /* paranoid */ verify( __atomic_load_n(&node->link.ts , __ATOMIC_RELAXED) == MAX );
     84        /* paranoid */ verify( __atomic_load_n(&node->link.ts , __ATOMIC_RELAXED) != 0   );
     85        /* paranoid */ verify( ats != 0 );
     86        /* paranoid */ verify( (ats == MAX) == is_empty );
     87        return [node, ats];
    8788}
    8889
     
    9697        // Cannot verify 'emptiness' here since it may not be locked
    9798        /* paranoid */ verify(this.anchor.ts != 0);
    98         return this.anchor.ts;
     99        /* paranoid */ static_assert(__atomic_always_lock_free(sizeof(this.anchor.ts), &this.anchor.ts));
     100        return __atomic_load_n(&this.anchor.ts, __ATOMIC_RELAXED);
    99101}
  • libcfa/src/concurrency/thread.cfa

    rbf0263c r90a8125  
    1919#include "thread.hfa"
    2020
     21#include "exception.hfa"
    2122#include "kernel/private.hfa"
    22 #include "exception.hfa"
     23#include "limits.hfa"
    2324
    2425#define __CFA_INVOKE_PRIVATE__
     
    2627
    2728extern uint32_t __global_random_seed, __global_random_prime, __global_random_mask;
     29
     30#pragma GCC visibility push(default)
    2831
    2932//-----------------------------------------------------------------------------
     
    4245        curr_cluster = &cl;
    4346        link.next = 0p;
    44         link.ts   = -1llu;
     47        link.ts   = MAX;
    4548        preferred = ready_queue_new_preferred();
    4649        last_proc = 0p;
     
    8689}
    8790
    88 forall(T & | is_thread(T) | IS_EXCEPTION(ThreadCancelled, (T))
    89     | { EHM_DEFAULT_VTABLE(ThreadCancelled, (T)); })
     91forall(T & | is_thread(T) | IS_EXCEPTION(ThreadCancelled(T))
     92    | { EHM_DEFAULT_VTABLE(ThreadCancelled(T)); })
    9093void ?{}( thread_dtor_guard_t & this,
    9194                T & thrd, void(*cancelHandler)(ThreadCancelled(T) &)) {
     
    165168
    166169//-----------------------------------------------------------------------------
    167 forall(T & | is_thread(T) | IS_RESUMPTION_EXCEPTION(ThreadCancelled, (T))
    168     | { EHM_DEFAULT_VTABLE(ThreadCancelled, (T)); })
     170forall(T & | is_thread(T) | IS_RESUMPTION_EXCEPTION(ThreadCancelled(T))
     171        | { EHM_DEFAULT_VTABLE(ThreadCancelled(T)); })
    169172T & join( T & this ) {
    170173        thread_dtor_guard_t guard = { this, defaultResumptionHandler };
  • libcfa/src/concurrency/thread.hfa

    rbf0263c r90a8125  
    3232};
    3333
    34 EHM_FORALL_EXCEPTION(ThreadCancelled, (thread_t &), (thread_t)) (
     34forall(thread_t &)
     35exception ThreadCancelled {
    3536        thread_t * the_thread;
    3637        exception_t * the_exception;
    37 );
     38};
    3839
    3940forall(T &)
     
    7980};
    8081
    81 forall( T & | is_thread(T) | IS_EXCEPTION(ThreadCancelled, (T))
    82     | { EHM_DEFAULT_VTABLE(ThreadCancelled, (T)); })
     82forall( T & | is_thread(T) | IS_EXCEPTION(ThreadCancelled(T))
     83        | { EHM_DEFAULT_VTABLE(ThreadCancelled(T)); })
    8384void ?{}( thread_dtor_guard_t & this, T & thrd, void(*)(ThreadCancelled(T) &) );
    8485void ^?{}( thread_dtor_guard_t & this );
     
    126127//----------
    127128// join
    128 forall( T & | is_thread(T) | IS_RESUMPTION_EXCEPTION(ThreadCancelled, (T))
    129     | { EHM_DEFAULT_VTABLE(ThreadCancelled, (T)); })
     129forall( T & | is_thread(T) | IS_RESUMPTION_EXCEPTION(ThreadCancelled(T))
     130        | { EHM_DEFAULT_VTABLE(ThreadCancelled(T)); })
    130131T & join( T & this );
    131132
  • libcfa/src/containers/maybe.cfa

    rbf0263c r90a8125  
    1717#include <assert.h>
    1818
     19#pragma GCC visibility push(default)
    1920
    2021forall(T)
  • libcfa/src/containers/result.cfa

    rbf0263c r90a8125  
    1717#include <assert.h>
    1818
     19#pragma GCC visibility push(default)
    1920
    2021forall(T, E)
  • libcfa/src/containers/string.cfa

    rbf0263c r90a8125  
    1818#include <stdlib.hfa>
    1919
     20#pragma GCC visibility push(default)
    2021
    2122/*
  • libcfa/src/containers/string_sharectx.hfa

    rbf0263c r90a8125  
    1616#pragma once
    1717
     18#pragma GCC visibility push(default)
     19
    1820//######################### String Sharing Context #########################
    1921
    2022struct VbyteHeap;
    2123
    22 // A string_sharectx 
     24// A string_sharectx
    2325//
    2426// Usage:
  • libcfa/src/containers/vector.cfa

    rbf0263c r90a8125  
    1818#include <stdlib.hfa>
    1919
     20#pragma GCC visibility push(default)
     21
    2022forall(T, allocator_t | allocator_c(T, allocator_t))
    21 void copy_internal(vector(T, allocator_t)* this, vector(T, allocator_t)* other);
     23static void copy_internal(vector(T, allocator_t)* this, vector(T, allocator_t)* other);
    2224
    2325//------------------------------------------------------------------------------
     
    8385
    8486forall(T, allocator_t | allocator_c(T, allocator_t))
    85 void copy_internal(vector(T, allocator_t)* this, vector(T, allocator_t)* other)
     87static void copy_internal(vector(T, allocator_t)* this, vector(T, allocator_t)* other)
    8688{
    8789        this->size = other->size;
  • libcfa/src/device/cpu.cfa

    rbf0263c r90a8125  
    3131}
    3232
     33#include "bits/defs.hfa"
    3334#include "algorithms/range_iterator.hfa"
    3435
     
    456457}
    457458
    458 cpu_info_t cpu_info;
     459libcfa_public cpu_info_t cpu_info;
  • libcfa/src/exception.c

    rbf0263c r90a8125  
    2727#include "stdhdr/assert.h"
    2828#include "virtual.h"
     29
     30#pragma GCC visibility push(default)
     31
    2932#include "lsda.h"
    3033
     
    261264#else // defined( __ARM_ARCH )
    262265        // The return code from _Unwind_RaiseException seems to be corrupt on ARM at end of stack.
    263         // This workaround tries to keep default exception handling working. 
     266        // This workaround tries to keep default exception handling working.
    264267        if ( ret == _URC_FATAL_PHASE1_ERROR || ret == _URC_FATAL_PHASE2_ERROR ) {
    265268#endif
  • libcfa/src/exception.hfa

    rbf0263c r90a8125  
    1010// Created On       : Thu Apr  7 10:25:00 2020
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Thr Apr  8 15:16:00 2021
    13 // Update Count     : 4
     12// Last Modified On : Wed May 25 17:20:00 2022
     13// Update Count     : 5
    1414//
    1515
     
    1818// -----------------------------------------------------------------------------------------------
    1919
    20 // EHM_EXCEPTION(exception_name)(fields...);
    21 // Create an exception (a virtual structure that inherits from exception_t)
    22 // with the given name and fields.
    23 #define EHM_EXCEPTION(exception_name) \
    24         _EHM_TYPE_ID_STRUCT(exception_name, ); \
    25         _EHM_TYPE_ID_VALUE(exception_name, ); \
    26         _EHM_VIRTUAL_TABLE_STRUCT(exception_name, , ); \
    27         _EHM_EXCEPTION_STRUCT(exception_name, , )
     20// EHM_DEFAULT_VTABLE(exception_type)
     21// Create a declaration for a (possibly polymorphic) default vtable.
     22// Mostly used by and for the currency module.
     23#define EHM_DEFAULT_VTABLE(type) vtable(type) & const _default_vtable
    2824
    29 // EHM_EXTERN_VTABLE(exception_name, table_name);
    30 // Forward declare a virtual table called table_name for exception_name type.
    31 #define EHM_EXTERN_VTABLE(exception_name, table_name) \
    32         _EHM_EXTERN_VTABLE(exception_name, , table_name)
    33 
    34 // EHM_VIRTUAL_TABLE(exception_name, table_name);
    35 // Define a virtual table called table_name for exception_name type.
    36 #define EHM_VIRTUAL_TABLE(exception_name, table_name) \
    37         _EHM_DEFINE_COPY(exception_name, ) \
    38         _EHM_DEFINE_MSG(exception_name, ) \
    39         _EHM_VIRTUAL_TABLE(exception_name, , table_name)
    40 
    41 // EHM_FORALL_EXCEPTION(exception_name, (assertions), (parameters))(fields...);
    42 // As EHM_EXCEPTION but for polymorphic types instead of monomorphic ones.
    43 // The assertions list should include all polymorphic parameters and
    44 // assertions inside a parentisized list. Parameters should include all the
    45 // polymorphic parameter names inside a parentisized list (same order).
    46 #define EHM_FORALL_EXCEPTION(exception_name, assertions, parameters) \
    47         _EHM_TYPE_ID_STRUCT(exception_name, forall assertions); \
    48         _EHM_VIRTUAL_TABLE_STRUCT(exception_name, forall assertions, parameters); \
    49         _EHM_EXCEPTION_STRUCT(exception_name, forall assertions, parameters)
    50 
    51 // EHM_FORALL_EXTERN_VTABLE(exception_name, (arguments), table_name);
    52 // As EHM_EXTERN_VTABLE but for polymorphic types instead of monomorphic ones.
    53 // Arguments should be the parentisized list of polymorphic arguments.
    54 #define EHM_FORALL_EXTERN_VTABLE(exception_name, arguments, table_name) \
    55         _EHM_EXTERN_VTABLE(exception_name, arguments, table_name)
    56 
    57 // EHM_FORALL_VIRTUAL_TABLE(exception_name, (arguments), table_name);
    58 // As EHM_VIRTUAL_TABLE but for polymorphic types instead of monomorphic ones.
    59 // Arguments should be the parentisized list of polymorphic arguments.
    60 #define EHM_FORALL_VIRTUAL_TABLE(exception_name, arguments, table_name) \
    61         _EHM_TYPE_ID_VALUE(exception_name, arguments); \
    62         _EHM_DEFINE_COPY(exception_name, arguments) \
    63         _EHM_DEFINE_MSG(exception_name, arguments) \
    64         _EHM_VIRTUAL_TABLE(exception_name, arguments, table_name)
    65 
    66 // EHM_DEFAULT_VTABLE(exception_name, (arguments))
    67 // Create a declaration for a (possibly polymorphic) default vtable.
    68 #define EHM_DEFAULT_VTABLE(exception_name, arguments) \
    69         _EHM_VTABLE_TYPE(exception_name) arguments & const _default_vtable
    70 
    71 // IS_EXCEPTION(exception_name [, (...parameters)])
    72 // IS_RESUMPTION_EXCEPTION(exception_name [, (parameters...)])
    73 // IS_TERMINATION_EXCEPTION(exception_name [, (parameters...)])
    74 // Create an assertion that exception_name, possibly with the qualifing parameters, is the given
    75 // kind of exception with the standard vtable with the same parameters if applicable.
    76 #define IS_EXCEPTION(...) _IS_EXCEPTION(is_exception, __VA_ARGS__, , ~)
    77 #define IS_RESUMPTION_EXCEPTION(...) _IS_EXCEPTION(is_resumption_exception, __VA_ARGS__, , ~)
    78 #define IS_TERMINATION_EXCEPTION(...) _IS_EXCEPTION(is_termination_exception, __VA_ARGS__, , ~)
    79 
    80 // Macros starting with a leading underscore are internal.
    81 
    82 // Create an exception type definition. must be tailing, can be polymorphic.
    83 #define _EHM_EXCEPTION_STRUCT(exception_name, forall_clause, parameters) \
    84         forall_clause struct exception_name { \
    85                 _EHM_VTABLE_TYPE(exception_name) parameters const * virtual_table; \
    86                 _CLOSE
    87 
    88 // Create a (possibly polymorphic) virtual table forward declaration.
    89 #define _EHM_EXTERN_VTABLE(exception_name, arguments, table_name) \
    90         extern const _EHM_VTABLE_TYPE(exception_name) arguments table_name
    91 
    92 // Create a (possibly polymorphic) virtual table definition.
    93 #define _EHM_VIRTUAL_TABLE(exception_type, arguments, table_name) \
    94         const _EHM_VTABLE_TYPE(exception_type) arguments table_name @= { \
    95                 .__cfavir_typeid : &_EHM_TYPE_ID_NAME(exception_type), \
    96                 .size : sizeof(struct exception_type arguments), \
    97                 .copy : copy, \
    98                 .^?{} : ^?{}, \
    99                 .msg : msg, \
    100         }
    101 
    102 // Create a (possibly polymorphic) copy function from an assignment operator.
    103 #define _EHM_DEFINE_FORALL_COPY(exception_name, forall_clause, parameters) \
    104         forall_clause void copy(exception_name parameters * this, \
    105                         exception_name parameters * that) { \
    106                 *this = *that; \
    107         }
    108 
    109 #define _EHM_DEFINE_COPY(exception_name, arguments) \
    110         void copy(exception_name arguments * this, exception_name arguments * that) { \
    111                 *this = *that; \
    112         }
    113 
    114 // Create a (possibly polymorphic) msg function
    115 #define _EHM_DEFINE_FORALL_MSG(exception_name, forall_clause, parameters) \
    116         forall_clause const char * msg(exception_name parameters * this) { \
    117                 return #exception_name #parameters; \
    118         }
    119 
    120 #define _EHM_DEFINE_MSG(exception_name, arguments) \
    121         const char * msg(exception_name arguments * this) { \
    122                 return #exception_name #arguments; \
    123         }
    124 
    125 // Produces the C compatable name of the virtual table type for a virtual type.
    126 #define _EHM_VTABLE_TYPE(type_name) struct _GLUE2(type_name,_vtable)
    127 
    128 // Create the vtable type for exception name.
    129 #define _EHM_VIRTUAL_TABLE_STRUCT(exception_name, forall_clause, parameters) \
    130         forall_clause struct exception_name; \
    131         forall_clause _EHM_VTABLE_TYPE(exception_name) { \
    132                 _EHM_TYPE_ID_TYPE(exception_name) parameters const * __cfavir_typeid; \
    133                 size_t size; \
    134                 void (*copy)(exception_name parameters * this, exception_name parameters * other); \
    135                 void (*^?{})(exception_name parameters & this); \
    136                 const char * (*msg)(exception_name parameters * this); \
    137         }
    138 
    139 // Define the function required to satify the trait for exceptions.
    140 #define _EHM_TRAIT_FUNCTION(exception_name, forall_clause, parameters) \
    141         forall_clause inline void mark_exception( \
    142                 exception_name parameters const &, \
    143                 _EHM_VTABLE_TYPE(exception_name) parameters const &) {} \
    144 
    145 #define __EHM_TRAIT_FUNCTION(exception_name, forall_clause, parameters) \
    146         forall_clause inline _EHM_VTABLE_TYPE(exception_name) parameters const & \
    147                         get_exception_vtable(exception_name parameters const & this) { \
    148                 /* This comes before the structure definition, but we know the offset. */ \
    149                 /* return (_EHM_VTABLE_TYPE(exception_name) parameters const &)this; */ \
    150                 assert(false); \
    151         }
    152 
    153 // Generates a new type-id structure. This is used to mangle the name of the
    154 // type-id instance so it also includes polymorphic information. Must be the
    155 // direct decendent of exception_t.
    156 // The second field is used to recover type information about the exception.
    157 #define _EHM_TYPE_ID_STRUCT(exception_name, forall_clause) \
    158         forall_clause _EHM_TYPE_ID_TYPE(exception_name) { \
    159                 __cfavir_type_info const * parent; \
    160         }
    161 
    162 // Generate a new type-id value.
    163 #define _EHM_TYPE_ID_VALUE(exception_name, arguments) \
    164         __attribute__((cfa_linkonce)) \
    165         _EHM_TYPE_ID_TYPE(exception_name) arguments const \
    166                         _EHM_TYPE_ID_NAME(exception_name) = { \
    167                 &__cfatid_exception_t, \
    168         }
    169 
    170 // _EHM_TYPE_ID_STRUCT and _EHM_TYPE_ID_VALUE are the two that would need to
    171 // be updated to extend the hierarchy if we are still using macros when that
    172 // is added.
    173 
    174 // Produce the C compatable name of the type-id type for an exception type.
    175 #define _EHM_TYPE_ID_TYPE(exception_name) \
    176         struct _GLUE2(__cfatid_struct_, exception_name)
    177 
    178 // Produce the name of the instance of the type-id for an exception type.
    179 #define _EHM_TYPE_ID_NAME(exception_name) _GLUE2(__cfatid_,exception_name)
    180 
    181 #define _IS_EXCEPTION(kind, exception_name, parameters, ...) \
    182         kind(exception_name parameters, _EHM_VTABLE_TYPE(exception_name) parameters)
    183 
    184 // Internal helper macros:
    185 #define _CLOSE(...) __VA_ARGS__ }
    186 #define _GLUE2(left, right) left##right
     25// IS_EXCEPTION(exception_type)
     26// IS_RESUMPTION_EXCEPTION(exception_type)
     27// IS_TERMINATION_EXCEPTION(exception_type)
     28// Create an assertion that exception_type is the given kind of exception.
     29// This is used to mimic associated types so the vtable type is unmentioned.
     30#define IS_EXCEPTION(type) is_exception(type, vtable(type))
     31#define IS_RESUMPTION_EXCEPTION(type) is_resumption_exception(type, vtable(type))
     32#define IS_TERMINATION_EXCEPTION(type) is_termination_exception(type, vtable(type))
  • libcfa/src/fstream.cfa

    rbf0263c r90a8125  
    2222#include <assert.h>
    2323#include <errno.h>                                                                              // errno
     24
     25#pragma GCC visibility push(default)
    2426
    2527// *********************************** ofstream ***********************************
     
    118120                // abort | IO_MSG "open output file \"" | name | "\"" | nl | strerror( errno );
    119121        } // if
    120         (os){ file };                                                                           // initialize 
     122        (os){ file };                                                                           // initialize
    121123} // open
    122124
     
    157159        va_list args;
    158160        va_start( args, format );
    159                
     161
    160162        int len;
    161163    for ( cnt; 10 ) {
     
    241243                // abort | IO_MSG "open input file \"" | name | "\"" | nl | strerror( errno );
    242244        } // if
    243         (is){ file };                                                                           // initialize 
     245        (is){ file };                                                                           // initialize
    244246} // open
    245247
  • libcfa/src/fstream.hfa

    rbf0263c r90a8125  
    1818#include "bits/weakso_locks.hfa"                                                // mutex_lock
    1919#include "iostream.hfa"
    20 #include <exception.hfa>
    2120
    2221
  • libcfa/src/heap.cfa

    rbf0263c r90a8125  
    3636static bool traceHeap = false;
    3737
    38 inline bool traceHeap() { return traceHeap; }
    39 
    40 bool traceHeapOn() {
     38inline bool traceHeap() libcfa_public { return traceHeap; }
     39
     40bool traceHeapOn() libcfa_public {
    4141        bool temp = traceHeap;
    4242        traceHeap = true;
     
    4444} // traceHeapOn
    4545
    46 bool traceHeapOff() {
     46bool traceHeapOff() libcfa_public {
    4747        bool temp = traceHeap;
    4848        traceHeap = false;
     
    5050} // traceHeapOff
    5151
    52 bool traceHeapTerm() { return false; }
     52bool traceHeapTerm() libcfa_public { return false; }
    5353
    5454
    5555static bool prtFree = false;
    5656
    57 bool prtFree() {
     57static bool prtFree() {
    5858        return prtFree;
    5959} // prtFree
    6060
    61 bool prtFreeOn() {
     61static bool prtFreeOn() {
    6262        bool temp = prtFree;
    6363        prtFree = true;
     
    6565} // prtFreeOn
    6666
    67 bool prtFreeOff() {
     67static bool prtFreeOff() {
    6868        bool temp = prtFree;
    6969        prtFree = false;
     
    388388static unsigned int maxBucketsUsed;                                             // maximum number of buckets in use
    389389// extern visibility, used by runtime kernel
    390 size_t __page_size;                                                                             // architecture pagesize
    391 int __map_prot;                                                                                 // common mmap/mprotect protection
     390// would be cool to remove libcfa_public but it's needed for libcfathread
     391libcfa_public size_t __page_size;                                                       // architecture pagesize
     392libcfa_public int __map_prot;                                                           // common mmap/mprotect protection
    392393
    393394
     
    727728
    728729
    729 size_t prtFree( Heap & manager ) with( manager ) {
     730static size_t prtFree( Heap & manager ) with( manager ) {
    730731        size_t total = 0;
    731732        #ifdef __STATISTICS__
     
    879880        // Allocates size bytes and returns a pointer to the allocated memory.  The contents are undefined. If size is 0,
    880881        // then malloc() returns a unique pointer value that can later be successfully passed to free().
    881         void * malloc( size_t size ) {
     882        void * malloc( size_t size ) libcfa_public {
    882883                #ifdef __STATISTICS__
    883884                if ( likely( size > 0 ) ) {
     
    894895
    895896        // Same as malloc() except size bytes is an array of dim elements each of elemSize bytes.
    896         void * aalloc( size_t dim, size_t elemSize ) {
     897        void * aalloc( size_t dim, size_t elemSize ) libcfa_public {
    897898                size_t size = dim * elemSize;
    898899                #ifdef __STATISTICS__
     
    910911
    911912        // Same as aalloc() with memory set to zero.
    912         void * calloc( size_t dim, size_t elemSize ) {
     913        void * calloc( size_t dim, size_t elemSize ) libcfa_public {
    913914                size_t size = dim * elemSize;
    914915          if ( unlikely( size ) == 0 ) {                        // 0 BYTE ALLOCATION RETURNS NULL POINTER
     
    951952        // not 0p, then the call is equivalent to free(oaddr). Unless oaddr is 0p, it must have been returned by an earlier
    952953        // call to malloc(), alloc(), calloc() or realloc(). If the area pointed to was moved, a free(oaddr) is done.
    953         void * resize( void * oaddr, size_t size ) {
     954        void * resize( void * oaddr, size_t size ) libcfa_public {
    954955                // If size is equal to 0, either NULL or a pointer suitable to be passed to free() is returned.
    955956          if ( unlikely( size == 0 ) ) {                                        // special cases
     
    996997        // Same as resize() but the contents are unchanged in the range from the start of the region up to the minimum of
    997998        // the old and new sizes.
    998         void * realloc( void * oaddr, size_t size ) {
     999        void * realloc( void * oaddr, size_t size ) libcfa_public {
    9991000                // If size is equal to 0, either NULL or a pointer suitable to be passed to free() is returned.
    10001001          if ( unlikely( size == 0 ) ) {                                        // special cases
     
    10601061
    10611062        // Same as realloc() except the new allocation size is large enough for an array of nelem elements of size elsize.
    1062         void * reallocarray( void * oaddr, size_t dim, size_t elemSize ) {
     1063        void * reallocarray( void * oaddr, size_t dim, size_t elemSize ) libcfa_public {
    10631064                return realloc( oaddr, dim * elemSize );
    10641065        } // reallocarray
     
    10661067
    10671068        // Same as malloc() except the memory address is a multiple of alignment, which must be a power of two. (obsolete)
    1068         void * memalign( size_t alignment, size_t size ) {
     1069        void * memalign( size_t alignment, size_t size ) libcfa_public {
    10691070                #ifdef __STATISTICS__
    10701071                if ( likely( size > 0 ) ) {
     
    10811082
    10821083        // Same as aalloc() with memory alignment.
    1083         void * amemalign( size_t alignment, size_t dim, size_t elemSize ) {
     1084        void * amemalign( size_t alignment, size_t dim, size_t elemSize ) libcfa_public {
    10841085                size_t size = dim * elemSize;
    10851086                #ifdef __STATISTICS__
     
    10971098
    10981099        // Same as calloc() with memory alignment.
    1099         void * cmemalign( size_t alignment, size_t dim, size_t elemSize ) {
     1100        void * cmemalign( size_t alignment, size_t dim, size_t elemSize ) libcfa_public {
    11001101                size_t size = dim * elemSize;
    11011102          if ( unlikely( size ) == 0 ) {                                        // 0 BYTE ALLOCATION RETURNS NULL POINTER
     
    11361137        // Same as memalign(), but ISO/IEC 2011 C11 Section 7.22.2 states: the value of size shall be an integral multiple
    11371138        // of alignment. This requirement is universally ignored.
    1138         void * aligned_alloc( size_t alignment, size_t size ) {
     1139        void * aligned_alloc( size_t alignment, size_t size ) libcfa_public {
    11391140                return memalign( alignment, size );
    11401141        } // aligned_alloc
     
    11451146        // is 0, then posix_memalign() returns either 0p, or a unique pointer value that can later be successfully passed to
    11461147        // free(3).
    1147         int posix_memalign( void ** memptr, size_t alignment, size_t size ) {
     1148        int posix_memalign( void ** memptr, size_t alignment, size_t size ) libcfa_public {
    11481149          if ( unlikely( alignment < libAlign() || ! is_pow2( alignment ) ) ) return EINVAL; // check alignment
    11491150                *memptr = memalign( alignment, size );
     
    11541155        // Allocates size bytes and returns a pointer to the allocated memory. The memory address shall be a multiple of the
    11551156        // page size.  It is equivalent to memalign(sysconf(_SC_PAGESIZE),size).
    1156         void * valloc( size_t size ) {
     1157        void * valloc( size_t size ) libcfa_public {
    11571158                return memalign( __page_size, size );
    11581159        } // valloc
     
    11601161
    11611162        // Same as valloc but rounds size to multiple of page size.
    1162         void * pvalloc( size_t size ) {
     1163        void * pvalloc( size_t size ) libcfa_public {
    11631164                return memalign( __page_size, ceiling2( size, __page_size ) ); // round size to multiple of page size
    11641165        } // pvalloc
     
    11681169        // or realloc().  Otherwise, or if free(ptr) has already been called before, undefined behaviour occurs. If ptr is
    11691170        // 0p, no operation is performed.
    1170         void free( void * addr ) {
     1171        void free( void * addr ) libcfa_public {
    11711172          if ( unlikely( addr == 0p ) ) {                                       // special case
    11721173                        #ifdef __STATISTICS__
     
    11891190
    11901191        // Returns the alignment of an allocation.
    1191         size_t malloc_alignment( void * addr ) {
     1192        size_t malloc_alignment( void * addr ) libcfa_public {
    11921193          if ( unlikely( addr == 0p ) ) return libAlign();      // minimum alignment
    11931194                Heap.Storage.Header * header = HeaderAddr( addr );
     
    12011202
    12021203        // Returns true if the allocation is zero filled, e.g., allocated by calloc().
    1203         bool malloc_zero_fill( void * addr ) {
     1204        bool malloc_zero_fill( void * addr ) libcfa_public {
    12041205          if ( unlikely( addr == 0p ) ) return false;           // null allocation is not zero fill
    12051206                Heap.Storage.Header * header = HeaderAddr( addr );
     
    12121213
    12131214        // Returns original total allocation size (not bucket size) => array size is dimension * sizeof(T).
    1214         size_t malloc_size( void * addr ) {
     1215        size_t malloc_size( void * addr ) libcfa_public {
    12151216          if ( unlikely( addr == 0p ) ) return 0;                       // null allocation has zero size
    12161217                Heap.Storage.Header * header = HeaderAddr( addr );
     
    12241225        // Returns the number of usable bytes in the block pointed to by ptr, a pointer to a block of memory allocated by
    12251226        // malloc or a related function.
    1226         size_t malloc_usable_size( void * addr ) {
     1227        size_t malloc_usable_size( void * addr ) libcfa_public {
    12271228          if ( unlikely( addr == 0p ) ) return 0;                       // null allocation has 0 size
    12281229                Heap.Storage.Header * header;
     
    12361237
    12371238        // Prints (on default standard error) statistics about memory allocated by malloc and related functions.
    1238         void malloc_stats( void ) {
     1239        void malloc_stats( void ) libcfa_public {
    12391240                #ifdef __STATISTICS__
    12401241                printStats();
     
    12451246
    12461247        // Changes the file descriptor where malloc_stats() writes statistics.
    1247         int malloc_stats_fd( int fd __attribute__(( unused )) ) {
     1248        int malloc_stats_fd( int fd __attribute__(( unused )) ) libcfa_public {
    12481249                #ifdef __STATISTICS__
    12491250                int temp = stats_fd;
     
    12591260        // The string is printed on the file stream stream.  The exported string includes information about all arenas (see
    12601261        // malloc).
    1261         int malloc_info( int options, FILE * stream __attribute__(( unused )) ) {
     1262        int malloc_info( int options, FILE * stream __attribute__(( unused )) ) libcfa_public {
    12621263          if ( options != 0 ) { errno = EINVAL; return -1; }
    12631264                #ifdef __STATISTICS__
     
    12711272        // Adjusts parameters that control the behaviour of the memory-allocation functions (see malloc). The param argument
    12721273        // specifies the parameter to be modified, and value specifies the new value for that parameter.
    1273         int mallopt( int option, int value ) {
     1274        int mallopt( int option, int value ) libcfa_public {
    12741275          if ( value < 0 ) return 0;
    12751276                choose( option ) {
     
    12851286
    12861287        // Attempt to release free memory at the top of the heap (by calling sbrk with a suitable argument).
    1287         int malloc_trim( size_t ) {
     1288        int malloc_trim( size_t ) libcfa_public {
    12881289                return 0;                                                                               // => impossible to release memory
    12891290        } // malloc_trim
     
    12941295        // structure dynamically allocated via malloc, and a pointer to that data structure is returned as the function
    12951296        // result.  (The caller must free this memory.)
    1296         void * malloc_get_state( void ) {
     1297        void * malloc_get_state( void ) libcfa_public {
    12971298                return 0p;                                                                              // unsupported
    12981299        } // malloc_get_state
     
    13011302        // Restores the state of all malloc internal bookkeeping variables to the values recorded in the opaque data
    13021303        // structure pointed to by state.
    1303         int malloc_set_state( void * ) {
     1304        int malloc_set_state( void * ) libcfa_public {
    13041305                return 0;                                                                               // unsupported
    13051306        } // malloc_set_state
     
    13071308
    13081309        // Sets the amount (bytes) to extend the heap when there is insufficent free storage to service an allocation.
    1309         __attribute__((weak)) size_t malloc_expansion() { return __CFA_DEFAULT_HEAP_EXPANSION__; }
     1310        __attribute__((weak)) size_t malloc_expansion() libcfa_public { return __CFA_DEFAULT_HEAP_EXPANSION__; }
    13101311
    13111312        // Sets the crossover point between allocations occuring in the sbrk area or separately mmapped.
    1312         __attribute__((weak)) size_t malloc_mmap_start() { return __CFA_DEFAULT_MMAP_START__; }
     1313        __attribute__((weak)) size_t malloc_mmap_start() libcfa_public { return __CFA_DEFAULT_MMAP_START__; }
    13131314
    13141315        // Amount subtracted to adjust for unfreed program storage (debug only).
    1315         __attribute__((weak)) size_t malloc_unfreed() { return __CFA_DEFAULT_HEAP_UNFREED__; }
     1316        __attribute__((weak)) size_t malloc_unfreed() libcfa_public { return __CFA_DEFAULT_HEAP_UNFREED__; }
    13161317} // extern "C"
    13171318
    13181319
    13191320// Must have CFA linkage to overload with C linkage realloc.
    1320 void * resize( void * oaddr, size_t nalign, size_t size ) {
     1321void * resize( void * oaddr, size_t nalign, size_t size ) libcfa_public {
    13211322        // If size is equal to 0, either NULL or a pointer suitable to be passed to free() is returned.
    13221323  if ( unlikely( size == 0 ) ) {                                                // special cases
     
    13801381
    13811382
    1382 void * realloc( void * oaddr, size_t nalign, size_t size ) {
     1383void * realloc( void * oaddr, size_t nalign, size_t size ) libcfa_public {
    13831384        // If size is equal to 0, either NULL or a pointer suitable to be passed to free() is returned.
    13841385  if ( unlikely( size == 0 ) ) {                                                // special cases
  • libcfa/src/interpose.cfa

    rbf0263c r90a8125  
    3636//=============================================================================================
    3737
    38 void preload_libgcc(void) {
     38static void preload_libgcc(void) {
    3939        dlopen( "libgcc_s.so.1", RTLD_NOW );
    4040        if ( const char * error = dlerror() ) abort( "interpose_symbol : internal error pre-loading libgcc, %s\n", error );
     
    4242
    4343typedef void (* generic_fptr_t)(void);
    44 generic_fptr_t interpose_symbol( const char symbol[], const char version[] ) {
     44static generic_fptr_t interpose_symbol( const char symbol[], const char version[] ) {
    4545        const char * error;
    4646
     
    8383//=============================================================================================
    8484
    85 void sigHandler_segv( __CFA_SIGPARMS__ );
    86 void sigHandler_ill ( __CFA_SIGPARMS__ );
    87 void sigHandler_fpe ( __CFA_SIGPARMS__ );
    88 void sigHandler_abrt( __CFA_SIGPARMS__ );
    89 void sigHandler_term( __CFA_SIGPARMS__ );
    90 
    91 struct {
     85static void sigHandler_segv( __CFA_SIGPARMS__ );
     86static void sigHandler_ill ( __CFA_SIGPARMS__ );
     87static void sigHandler_fpe ( __CFA_SIGPARMS__ );
     88static void sigHandler_abrt( __CFA_SIGPARMS__ );
     89static void sigHandler_term( __CFA_SIGPARMS__ );
     90
     91static struct {
    9292        void (* exit)( int ) __attribute__(( __noreturn__ ));
    9393        void (* abort)( void ) __attribute__(( __noreturn__ ));
    9494} __cabi_libc;
    9595
    96 int cfa_main_returned;
     96libcfa_public int cfa_main_returned;
    9797
    9898extern "C" {
     
    148148
    149149// Forward declare abort after the __typeof__ call to avoid ambiguities
    150 void exit( int status, const char fmt[], ... ) __attribute__(( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ ));
    151 void abort( const char fmt[], ... ) __attribute__(( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ ));
    152 void abort( bool signalAbort, const char fmt[], ... ) __attribute__(( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ ));
    153 void __abort( bool signalAbort, const char fmt[], va_list args ) __attribute__(( __nothrow__, __leaf__, __noreturn__ ));
     150libcfa_public void exit( int status, const char fmt[], ... ) __attribute__(( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ ));
     151libcfa_public void abort( const char fmt[], ... ) __attribute__(( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ ));
     152libcfa_public void abort( bool signalAbort, const char fmt[], ... ) __attribute__(( format(printf, 2, 3), __nothrow__, __leaf__, __noreturn__ ));
     153libcfa_public void __abort( bool signalAbort, const char fmt[], va_list args ) __attribute__(( __nothrow__, __leaf__, __noreturn__ ));
    154154
    155155extern "C" {
    156         void abort( void ) __attribute__(( __nothrow__, __leaf__, __noreturn__ )) {
     156        libcfa_public void abort( void ) __attribute__(( __nothrow__, __leaf__, __noreturn__ )) {
    157157                abort( false, "%s", "" );
    158158        }
    159159
    160         void __cabi_abort( const char fmt[], ... ) __attribute__(( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ )) {
     160        libcfa_public void __cabi_abort( const char fmt[], ... ) __attribute__(( format(printf, 1, 2), __nothrow__, __leaf__, __noreturn__ )) {
    161161                va_list argp;
    162162                va_start( argp, fmt );
     
    165165        }
    166166
    167         void exit( int status ) __attribute__(( __nothrow__, __leaf__, __noreturn__ )) {
     167        libcfa_public void exit( int status ) __attribute__(( __nothrow__, __leaf__, __noreturn__ )) {
    168168                __cabi_libc.exit( status );
    169169        }
  • libcfa/src/iostream.cfa

    rbf0263c r90a8125  
    3232#include "bitmanip.hfa"                                                                 // high1
    3333
     34#pragma GCC visibility push(default)
    3435
    3536// *********************************** ostream ***********************************
  • libcfa/src/limits.cfa

    rbf0263c r90a8125  
    2020#include <complex.h>
    2121#include "limits.hfa"
     22
     23#pragma GCC visibility push(default)
    2224
    2325// Integral Constants
  • libcfa/src/memory.cfa

    rbf0263c r90a8125  
    1616#include "memory.hfa"
    1717#include "stdlib.hfa"
     18
     19#pragma GCC visibility push(default)
    1820
    1921// Internal data object.
  • libcfa/src/parseargs.cfa

    rbf0263c r90a8125  
    2424#include "common.hfa"
    2525#include "limits.hfa"
     26
     27#pragma GCC visibility push(default)
    2628
    2729extern int cfa_args_argc __attribute__((weak));
  • libcfa/src/parseconfig.cfa

    rbf0263c r90a8125  
    1414
    1515
     16#pragma GCC visibility push(default)
     17
    1618// *********************************** exceptions ***********************************
    1719
    1820
    1921// TODO: Add names of missing config entries to exception (see further below)
    20 static vtable(Missing_Config_Entries) Missing_Config_Entries_vt;
     22vtable(Missing_Config_Entries) Missing_Config_Entries_vt;
    2123
    2224[ void ] ?{}( & Missing_Config_Entries this, unsigned int num_missing ) {
     
    3133
    3234
    33 static vtable(Parse_Failure) Parse_Failure_vt;
     35vtable(Parse_Failure) Parse_Failure_vt;
    3436
    3537[ void ] ?{}( & Parse_Failure this, [] char failed_key, [] char failed_value ) {
     
    5355
    5456
    55 static vtable(Validation_Failure) Validation_Failure_vt;
     57vtable(Validation_Failure) Validation_Failure_vt;
    5658
    5759[ void ] ?{}( & Validation_Failure this, [] char failed_key, [] char failed_value ) {
     
    110112
    111113
    112 [ bool ] comments( & ifstream in, [] char name ) {
     114static [ bool ] comments( & ifstream in, [] char name ) {
    113115        while () {
    114116                in | name;
  • libcfa/src/rational.cfa

    rbf0263c r90a8125  
    1717#include "fstream.hfa"
    1818#include "stdlib.hfa"
     19
     20#pragma GCC visibility push(default)
    1921
    2022forall( T | Arithmetic( T ) ) {
  • libcfa/src/startup.cfa

    rbf0263c r90a8125  
    4141        } // __cfaabi_appready_shutdown
    4242
    43         void disable_interrupts() __attribute__(( weak )) {}
    44         void enable_interrupts() __attribute__(( weak )) {}
     43        void disable_interrupts() __attribute__(( weak )) libcfa_public {}
     44        void enable_interrupts() __attribute__(( weak )) libcfa_public {}
    4545
    4646
     
    6464struct __spinlock_t;
    6565extern "C" {
    66         void __cfaabi_dbg_record_lock(struct __spinlock_t & this, const char prev_name[]) __attribute__(( weak )) {}
     66        void __cfaabi_dbg_record_lock(struct __spinlock_t & this, const char prev_name[]) __attribute__(( weak )) libcfa_public {}
    6767}
    6868
  • libcfa/src/stdlib.cfa

    rbf0263c r90a8125  
    2525#include <complex.h>                                                                    // _Complex_I
    2626#include <assert.h>
     27
     28#pragma GCC visibility push(default)
    2729
    2830//---------------------------------------
     
    225227#define GENERATOR LCG
    226228
    227 uint32_t __global_random_seed;                                                  // sequential/concurrent
    228 uint32_t __global_random_state;                                                 // sequential only
     229// would be cool to make hidden but it's needed for libcfathread
     230__attribute__((visibility("default"))) uint32_t __global_random_seed;                                                   // sequential/concurrent
     231__attribute__((visibility("hidden"))) uint32_t __global_random_state;                                                   // sequential only
    229232
    230233void set_seed( PRNG & prng, uint32_t seed_ ) with( prng ) { state = seed = seed_; GENERATOR( state ); } // set seed
  • libcfa/src/strstream.cfa

    rbf0263c r90a8125  
    1 // 
     1//
    22// Cforall Version 1.0.0 Copyright (C) 2021 University of Waterloo
    3 // 
     3//
    44// The contents of this file are covered under the licence agreement in the
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // strstream.cfa -- 
    8 // 
     7// strstream.cfa --
     8//
    99// Author           : Peter A. Buhr
    1010// Created On       : Thu Apr 22 22:24:35 2021
     
    1212// Last Modified On : Sun Oct 10 16:13:20 2021
    1313// Update Count     : 101
    14 // 
     14//
    1515
    1616#include "strstream.hfa"
     
    2424#include <unistd.h>                                                                             // sbrk, sysconf
    2525
     26#pragma GCC visibility push(default)
    2627
    2728// *********************************** strstream ***********************************
  • libcfa/src/time.cfa

    rbf0263c r90a8125  
    1818#include <stdio.h>                                                                              // snprintf
    1919#include <assert.h>
     20
     21#pragma GCC visibility push(default)
    2022
    2123static char * nanomsd( long int ns, char * buf ) {              // most significant digits
  • libcfa/src/virtual.c

    rbf0263c r90a8125  
    1616#include "virtual.h"
    1717#include "assert.h"
     18
     19#pragma GCC visibility push(default)
    1820
    1921int __cfavir_is_parent(
Note: See TracChangeset for help on using the changeset viewer.