Changeset 77acd07d


Ignore:
Timestamp:
Feb 7, 2018, 4:50:57 PM (7 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
3f8ab8f, c659968
Parents:
396fd72 (diff), 3d5f2ef1 (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:
src/libcfa
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/bits/defs.h

    r396fd72 r77acd07d  
    1 // 
     1//
    22// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
    33//
    44// The contents of this file are covered under the licence agreement in the
    55// file "LICENCE" distributed with Cforall.
    6 // 
    7 // defs.h -- 
    8 // 
     6//
     7// defs.h --
     8//
    99// Author           : Thierry Delisle
    1010// Created On       : Thu Nov  9 13:24:10 2017
     
    1212// Last Modified On : Tue Jan  2 09:17:06 2018
    1313// Update Count     : 2
    14 // 
     14//
    1515
    1616#pragma once
     
    3434
    3535#ifdef __cforall
     36#ifndef __NO_ABORT_OVERLOAD
     37void abort ( const char fmt[], ... ) __attribute__ ((__nothrow__, __leaf__, __noreturn__));
     38#endif
    3639extern "C" {
    3740#endif
  • src/libcfa/interpose.c

    r396fd72 r77acd07d  
    2828}
    2929
     30#define __NO_ABORT_OVERLOAD // no abort overload avoid ambiguities
    3031#include "bits/debug.h"
    3132#include "bits/defs.h"
    3233#include "bits/signal.h"
    3334#include "startup.h"
     35
     36//=============================================================================================
     37// Interposing helpers
     38//=============================================================================================
    3439
    3540typedef void (*generic_fptr_t)(void);
     
    6974}
    7075
    71 
    72 __typeof__( exit ) libc_exit __attribute__(( noreturn ));
    73 __typeof__( abort ) libc_abort __attribute__(( noreturn ));
    74 
    7576forall(dtype T)
    76 static inline void assign_ptr( T** symbol_ptr, const char * symbol_name, const char * version) {
     77static inline void ptr_from_symbol( T** symbol_ptr, const char * symbol_name, const char * version) {
    7778        union {
    7879                generic_fptr_t gp;
     
    8586}
    8687
    87 #define INIT_REALRTN( x, ver ) assign_ptr( (void**)&libc_##x, #x, ver)
     88#define INTERPOSE_LIBC( x, ver ) ptr_from_symbol( (void**)&__cabi_libc.x, #x, ver)
     89
     90//=============================================================================================
     91// Terminating Signals logic
     92//=============================================================================================
    8893
    8994void sigHandler_segv ( __CFA_SIGPARMS__ );
     
    9297void sigHandler_abort( __CFA_SIGPARMS__ );
    9398
     99struct {
     100        __typeof__( exit  ) exit  __attribute__(( noreturn ));
     101        __typeof__( abort ) abort __attribute__(( noreturn ));
     102} __cabi_libc;
     103
    94104extern "C" {
    95105        void __cfaabi_interpose_startup(void)  __attribute__(( constructor( STARTUP_PRIORITY_CORE ) ));
     
    97107                const char *version = NULL;
    98108
    99                 INIT_REALRTN( abort, version );
    100                 INIT_REALRTN( exit, version );
     109                INTERPOSE_LIBC( abort, version );
     110                INTERPOSE_LIBC( exit , version );
    101111
    102112                __cfaabi_sigaction( SIGSEGV, sigHandler_segv , SA_SIGINFO ); // Failure handler
     
    112122//=============================================================================================
    113123
     124// Forward declare abort after the __typeof__ call to avoid ambiguities
     125void abort ( const char fmt[], ... ) __attribute__ ((__nothrow__, __leaf__, __noreturn__));
     126
    114127extern "C" {
    115128        void abort( void ) __attribute__ ((__nothrow__, __leaf__, __noreturn__)) {
     
    117130        }
    118131
     132        void abortf( const char fmt[], ... ) __attribute__ ((__nothrow__, __leaf__, __noreturn__)) {
     133                va_list argp;
     134                va_start( argp, fmt );
     135                abort( fmt, argp );
     136                va_end( argp );
     137        }
     138
    119139        void exit( int __status ) __attribute__ ((__nothrow__, __leaf__, __noreturn__)) {
    120                 libc_exit(__status);
    121         }
    122 }
    123 
    124 void abort( const char fmt[], ... ) __attribute__ ((__nothrow__, __leaf__, __noreturn__)) {
    125         va_list argp;
    126         va_start( argp, fmt );
    127         abortf( fmt, argp );
    128         va_end( argp );
     140                __cabi_libc.exit(__status);
     141        }
    129142}
    130143
     
    137150static int abort_lastframe;
    138151
    139 extern "C" {
    140         void abortf( const char fmt[], ... ) __attribute__ ((__nothrow__, __leaf__, __noreturn__)) {
    141                 void * kernel_data = kernel_abort();                    // must be done here to lock down kernel
    142                 int len;
    143 
    144                 abort_lastframe = kernel_abort_lastframe();
    145                 len = snprintf( abort_text, abort_text_size, "Cforall Runtime error (UNIX pid:%ld) ", (long int)getpid() ); // use UNIX pid (versus getPid)
     152void abort( const char fmt[], ... ) __attribute__ ((__nothrow__, __leaf__, __noreturn__)) {
     153        void * kernel_data = kernel_abort();                    // must be done here to lock down kernel
     154        int len;
     155
     156        abort_lastframe = kernel_abort_lastframe();
     157        len = snprintf( abort_text, abort_text_size, "Cforall Runtime error (UNIX pid:%ld) ", (long int)getpid() ); // use UNIX pid (versus getPid)
     158        __cfaabi_dbg_bits_write( abort_text, len );
     159
     160        if ( fmt ) {
     161                va_list args;
     162                va_start( args, fmt );
     163
     164                len = vsnprintf( abort_text, abort_text_size, fmt, args );
     165                va_end( args );
    146166                __cfaabi_dbg_bits_write( abort_text, len );
    147167
    148                 if ( fmt ) {
    149                         va_list args;
    150                         va_start( args, fmt );
    151 
    152                         len = vsnprintf( abort_text, abort_text_size, fmt, args );
    153                         va_end( args );
    154                         __cfaabi_dbg_bits_write( abort_text, len );
    155 
    156                         if ( fmt[strlen( fmt ) - 1] != '\n' ) {         // add optional newline if missing at the end of the format text
    157                                 __cfaabi_dbg_bits_write( "\n", 1 );
    158                         }
    159                 }
    160 
    161                 kernel_abort_msg( kernel_data, abort_text, abort_text_size );
    162                 libc_abort();
    163         }
     168                if ( fmt[strlen( fmt ) - 1] != '\n' ) {         // add optional newline if missing at the end of the format text
     169                        __cfaabi_dbg_bits_write( "\n", 1 );
     170                }
     171        }
     172
     173        kernel_abort_msg( kernel_data, abort_text, abort_text_size );
     174        __cabi_libc.abort();
    164175}
    165176
Note: See TracChangeset for help on using the changeset viewer.