Changeset 3489ea6


Ignore:
Timestamp:
Jun 15, 2021, 5:18:59 PM (3 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
3814957
Parents:
5e2ed05
Message:

Started work on kernel_getcpu

Location:
libcfa/src/concurrency
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/kernel/startup.cfa

    r5e2ed05 r3489ea6  
    137137};
    138138
     139#if   defined(CFA_HAVE_LINUX_LIBRSEQ)
     140        // No data needed
     141#elif defined(CFA_HAVE_LINUX_RSEQ_H)
     142        extern "Cforall" {
     143                thread_local volatile struct rseq __cfaabi_rseq;
     144        }
     145#else
     146        // No data needed
     147#endif
     148
    139149//-----------------------------------------------------------------------------
    140150// Struct to steal stack
  • libcfa/src/concurrency/kernel_private.hfa

    r5e2ed05 r3489ea6  
    1616#pragma once
    1717
     18#if !defined(__cforall_thread__)
     19        #error kernel_private.hfa should only be included in libcfathread source
     20#endif
     21
    1822#include "kernel.hfa"
    1923#include "thread.hfa"
     
    2226#include "stats.hfa"
    2327
     28extern "C" {
     29#if   defined(CFA_HAVE_LINUX_LIBRSEQ)
     30        #include <rseq/rseq.h>
     31#elif defined(CFA_HAVE_LINUX_RSEQ_H)
     32        #include <linux/rseq.h>
     33#else
     34        #ifndef _GNU_SOURCE
     35        #error kernel_private requires gnu_source
     36        #endif
     37        #include <sched.h>
     38#endif
     39}
     40
    2441//-----------------------------------------------------------------------------
    2542// Scheduler
    26 
    27 
    2843extern "C" {
    2944        void disable_interrupts() OPTIONAL_THREAD;
     
    3954
    4055//-----------------------------------------------------------------------------
     56// Hardware
     57
     58#if   defined(CFA_HAVE_LINUX_LIBRSEQ)
     59        // No data needed
     60#elif defined(CFA_HAVE_LINUX_RSEQ_H)
     61        extern "Cforall" {
     62                extern __attribute__((aligned(128))) thread_local volatile struct rseq __cfaabi_rseq;
     63        }
     64#else
     65        // No data needed
     66#endif
     67
     68static inline int __kernel_getcpu() {
     69        /* paranoid */ verify( ! __preemption_enabled() );
     70#if   defined(CFA_HAVE_LINUX_LIBRSEQ)
     71        return rseq_current_cpu_raw();
     72#elif defined(CFA_HAVE_LINUX_RSEQ_H)
     73        return __cfaabi_rseq.cpu_id;
     74#else
     75        return sched_getcpu();
     76#endif
     77}
     78
     79//-----------------------------------------------------------------------------
    4180// Processor
    4281void main(processorCtx_t *);
     
    4483void * __create_pthread( pthread_t *, void * (*)(void *), void * );
    4584void __destroy_pthread( pthread_t pthread, void * stack, void ** retval );
    46 
    47 
    4885
    4986extern cluster * mainCluster;
Note: See TracChangeset for help on using the changeset viewer.