source: libcfa/src/virtual.c @ 44adf1b

Last change on this file since 44adf1b was 8108ba8, checked in by Thierry Delisle <tdelisle@…>, 2 years ago

Started to add basic visibility control to libcfa

  • Property mode set to 100644
File size: 876 bytes
RevLine 
[a5f0529]1//
2// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
7// virtual.c --
8//
9// Author           : Andrew Beach
10// Created On       : Tus Jul 11 15:10:00 2017
11// Last Modified By : Andrew Beach
[8f910430]12// Last Modified On : Mon May 17 11:01:00 2021
13// Update Count     : 2
[a5f0529]14//
15
16#include "virtual.h"
[ecfd758]17#include "assert.h"
[a5f0529]18
[8108ba8]19#pragma GCC visibility push(default)
20
[8f910430]21int __cfavir_is_parent(
22                __cfavir_type_id parent,
23                __cfavir_type_id child ) {
[ecfd758]24        assert( child );
[a5f0529]25        do {
26                if ( parent == child )
27                        return 1;
28                child = child->parent;
29        } while ( child );
30        return 0;
31}
32
[8f910430]33void * __cfavir_virtual_cast(
34                __cfavir_type_id parent,
35                __cfavir_type_id const * child ) {
[ecfd758]36        assert( child );
[8f910430]37        return (__cfavir_is_parent(parent, *child)) ? (void *)child : (void *)0;
[a5f0529]38}
Note: See TracBrowser for help on using the repository browser.