Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/GAP/src/hpc/   (Algebra von RWTH Aachen Version 4.15.1©)  Datei vom 18.9.2025 mit Größe 1 kB image not shown  

Quelle  region.c   Sprache: C

 
/****************************************************************************
**
**  This file is part of GAP, a system for computational discrete algebra.
**
**  Copyright of GAP belongs to its developers, whose names are too numerous
**  to list here. Please refer to the COPYRIGHT file for details.
**
**  SPDX-License-Identifier: GPL-2.0-or-later
*/


#include "region.h"

#ifdef USE_BOEHM_GC
#include "../boehm_gc.h"
#endif
#include "../gasman.h"
#include "../objects.h"

// #include "misc.h"
#include "thread.h"
#include "guards.h"


#include <pthread.h>


static void LockFinalizer(void * lock, void * data)
{
    pthread_rwlock_destroy(lock);
}

Region * NewRegion(void)
{
    Region *           result;
    pthread_rwlock_t * lock;
    Obj                region_obj;
#ifdef DISABLE_GC
    result = calloc(1, sizeof(Region) + (MAX_THREADS + 1));
    lock = malloc(sizeof(*lock));
#elif defined(USE_BOEHM_GC)
    result = GC_malloc(sizeof(Region) + (MAX_THREADS + 1));
    lock = GC_malloc_atomic(sizeof(*lock));
    GC_register_finalizer(lock, LockFinalizer, NULL, NULL, NULL);
#else
    #error Not yet implemented for this garbage collector
#endif
    pthread_rwlock_init(lock, NULL);
    region_obj = NewBag(T_REGION, sizeof(Region *));
    MakeBagPublic(region_obj);
    *(Region **)(PTR_BAG(region_obj)) = result;
    result->obj = region_obj;
    result->lock = lock;
    return result;
}

Region * RegionBag(Bag bag)
{
    Region * result = REGION(bag);
    MEMBAR_READ();
    return result;
}

Bag MakeBagPublic(Bag bag)
{
    MEMBAR_WRITE();
    SET_REGION(bag, 0);
    return bag;
}

Bag MakeBagReadOnly(Bag bag)
{
    MEMBAR_WRITE();
    SET_REGION(bag, ReadOnlyRegion);
    return bag;
}

void RetypeBagIfWritable(Obj obj, UInt new_type)
{
    if (CheckWriteAccess(obj))
        RetypeBag(obj, new_type);
}

90%


¤ Dauer der Verarbeitung: 0.13 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung ist noch experimentell.