Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

https://github.com/Unipisa/CMM
13 July 2022, 09:41:13 UTC
  • Code
  • Branches (2)
  • Releases (8)
  • Visits
    • Branches
    • Releases
    • HEAD
    • refs/heads/SourceCode
    • refs/heads/master
    • 1.9
    • 1.8
    • 1.7
    • 1.6
    • 1.5
    • 1.4
    • 1.3
    • 1.1
  • db1a798
  • /
  • cmm
  • /
  • test9.cpp
Raw File Download
Take a new snapshot of a software origin

If the archived software origin currently browsed is not synchronized with its upstream version (for instance when new commits have been issued), you can explicitly request Software Heritage to take a new snapshot of it.

Use the form below to proceed. Once a request has been submitted and accepted, it will be processed as soon as possible. You can then check its processing state by visiting this dedicated page.
swh spinner

Processing "take a new snapshot" request ...

Permalinks

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
  • revision
  • snapshot
  • release
origin badgecontent badge Iframe embedding
swh:1:cnt:2aa1c9ef9a63b9adf5a0775e594906a569f8ae0f
origin badgedirectory badge Iframe embedding
swh:1:dir:78af2ccbb0a8bb0b518d4ba147a0eec0624b1f97
origin badgerevision badge
swh:1:rev:55778ad8b99c136e1886959c1f1333c776df14e1
origin badgesnapshot badge
swh:1:snp:4ac4ed834489429d51fc0fd004f10ddbf78d807a
origin badgerelease badge
swh:1:rel:a6a00f689665e8e5b730fb4706b03c463146259a
Citations

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
  • revision
  • snapshot
  • release
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Tip revision: 55778ad8b99c136e1886959c1f1333c776df14e1 authored by Giuseppe Attardi on 15 May 1997, 06:24:54 UTC
1.8 -
Tip revision: 55778ad
test9.cpp
#include "cmm.h"
#include <stream.h>

/*
 * Test contributed by Christian Heckler <chh@plato.uni-paderborn.de>
 *
 * Tests case when scavenge() allocates objects in page already scanned by
 * the collector.
 * This happens when current page contains pointer to large object, whose
 * page gets promoted and added to the queue. When this page is scanned,
 * objects it contains are moved to the current page, which however has been
 * already scanned.
 *
 */

extern "C" long random();

// For this values it works
//const int length1=10;
//const int length2=15;
//const int numberoflistallocs=2;

// For this values it (mostly) does not work
const int length1=50;
const int length2=50;
const int numberoflistallocs=2;


/*
   class TestClass: In the dynamic part of objects of
   this class first two pointers are stored and then
   "counter" number of longs. Counter is determined randomly
   for each object.
*/


class TestClass: public CmmVarObject
{
  public:
  long counter;

  void traverse();

  /* Set and get the first pointer */
  void TestClass::setp1(TestClass* p);
  TestClass* TestClass::getp1();

  /* Set and get the second pointer */
  void TestClass::setp2(TestClass* p);
  TestClass* TestClass::getp2();

  /* Set and test the longs */
  void TestClass::set(long l);
  int TestClass::test(long l);
};


/*
   traverse the two pointers in the dynamic part of the object
*/

void TestClass::traverse()
{
  TestClass **q = (TestClass**) (&counter+1);
  Cmm::heap->scavenge((CmmObject **) q);
  Cmm::heap->scavenge((CmmObject **) q+1);
}

void TestClass::setp1(TestClass* p)
{
  *((TestClass**)(&counter+1)) = p;
}

TestClass* TestClass::getp1()
{
  return *((TestClass**)(&counter+1));
}

void TestClass::setp2(TestClass* p)
{
  *((TestClass**)(&counter+2))= p;
}

TestClass* TestClass::getp2()
{
  return *(((TestClass**)(&counter+2)));
}


void TestClass::set(long l)
{
  long *pl;
  pl=(long*)((TestClass**)(&counter+3));
  for (long i=0; i<counter; i++, pl++)
    *pl=l;
}

int TestClass::test(long l)
{
  long *pl;
  pl=(long*)((TestClass**)(&counter+3));
  for (long i=0; i<counter; i++, pl++)
   if (*pl != l)
    return 0;

  return 1;
}


typedef TestClass* Classptr;

/* Create a list using the first pointer of each object */
void createlist1(Classptr p)
{
  long i;
  long counter;
  Classptr localpointer, newpointer;

  localpointer=p;
  localpointer->set(0);

  counter=(random()&700);
  newpointer = new(counter*sizeof(long)+2*sizeof(TestClass*)) TestClass;
  newpointer->counter=counter;

  localpointer->setp1(newpointer);

  localpointer = newpointer;

  for (i=1; i<length1; i++)
  {
    localpointer->set(i);
    localpointer->setp2(NULL);
    localpointer->setp1(NULL);

    counter=(random()&700);
    newpointer = new(counter*sizeof(long)+2*sizeof(TestClass*)) TestClass;
    newpointer->counter=counter;

    localpointer->setp1(newpointer);

    localpointer = newpointer;
  }
  localpointer->set(i);
  localpointer->setp1(NULL);
  localpointer->setp2(NULL);
}


/* Create a list using the first pointer of each object */
void createlist2(Classptr p)
{
  long i;
  Classptr localpointer, newpointer;
  long counter;

  localpointer=p;

  localpointer->set(0);

  counter=(random()&700);
  //cout << counter << " ";
  newpointer = new(counter*sizeof(long)+2*sizeof(TestClass*)) TestClass;
  newpointer->counter=counter;

  localpointer->setp2(newpointer);

  localpointer = newpointer;

  for (i=1; i<length2; i++)
  {
    localpointer->set(i);
    localpointer->setp1(NULL);
    localpointer->setp2(NULL);

    counter=(random()&700);
    newpointer = new(counter*sizeof(long)+2*sizeof(TestClass*)) TestClass;
    newpointer->counter=counter;

    localpointer->setp2(newpointer);

    localpointer = newpointer;
  }
  localpointer->set(i);
  localpointer->setp1(NULL);
  localpointer->setp2(NULL);
}


/* Test if list 1 is still correct */
int testlist1(Classptr p)
{
  for (long i=0; i<length1; i++)
  {
    if (!(p->test(i)))
    {
      cout << "Error in List 1 by (1," << i << ")! \n";
      exit(1);
    }
    p=p->getp1();
  }
}

/* Test if list 2 is still correct */
int testlist2(Classptr p)
{
  for (long i=0; i<length2; i++)
  {
    if (!(p->test(i)))
    {
      cout << "Error in List 2 by (2," << i << ")! \n";
      exit(1);
    }
    p=p->getp2();
  }
}


main()
{
  Classptr p0=NULL;
  int i, j, k;
  long count;

  cout << "Process 0 is initializing the base pointer of the two lists!\n";

  count=(random()&700);
  p0 = new(count*sizeof(long)+2*sizeof(TestClass*)) TestClass;
  p0->setp1(NULL);
  p0->setp2(NULL);
  p0->counter=count;

  cout << "Process 0 is initializing list 1!\n";
  for (i=0; i<numberoflistallocs; i++) createlist1(p0);
  cout << "Process 0 is testing list 1!\n";
  testlist1(p0);
  cout << "Process 0: 1 ok!\n";

  cout << "Process 0 is initializing list 2!\n";
  for (i=0; i<numberoflistallocs; i++) createlist2(p0);
  cout << "Process 0 is testing list 2!\n";
  testlist2(p0);
  cout << "Process 0: 2 ok!\n";
  cout << "Process 0 is testing list 1 again!\n";
  testlist1(p0);
  cout << "Process 0: 1 ok!\n";

}

Software Heritage — Copyright (C) 2015–2025, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Contact— JavaScript license information— Web API

back to top