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

Revision dbe4ddb10315479fc00086f08e25d968b4b43c49 authored by Travis Bradshaw on 31 January 2012, 19:41:34 UTC, committed by Travis Bradshaw on 31 January 2012, 19:41:34 UTC
The Quake III Arena sources as originally released under the GPL license on August 20, 2005.
0 parent
  • Files
  • Changes
  • c6f07c2
  • /
  • lcc
  • /
  • lib
  • /
  • bbexit.c
Raw File Download

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.

  • revision
  • directory
  • content
revision badge
swh:1:rev:dbe4ddb10315479fc00086f08e25d968b4b43c49
directory badge
swh:1:dir:9c66fc44b7312aaff77239a9f5ecac8f2b8b2b24
content badge
swh:1:cnt:471d60665fad4020cc18e0a522c4ff9289c8c32d

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.

  • revision
  • directory
  • content
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
bbexit.c
#include <stdio.h>
#include <stdlib.h>


struct callsite {
	char *file, *name;
	union coordinate {
		struct { unsigned int index:6,x:10,y:16; } be;
		struct { unsigned int y:16,x:10,index:6; } le;
		unsigned int coord;
	} u;
} *_caller;

static struct _bbdata {
	struct _bbdata *link;
	unsigned npoints, *counts;
	union coordinate *coords;
	char **files;
	struct func {
		struct func *link;
		struct caller {
			struct caller *link;
			struct callsite *caller;
			unsigned count;
		} *callers;
		char *name;
		union coordinate src;
	} *funcs;
} tail, *_bblist = &tail;

static void unpack(unsigned int coord, int *index, int *x, int *y) {
	static union { int x; char endian; } little = { 1 };
	union coordinate u;

	u.coord = coord;
	if (little.endian) {
		*index = u.le.index;
		*x = u.le.x;
		*y = u.le.y;
	} else {
		*index = u.be.index;
		*x = u.be.x;
		*y = u.be.y;
	}
}				

static void profout(struct _bbdata *p, FILE *fp) {
	int i, index, x, y;
	struct func *f;
	struct caller *q;

	for (i = 0; p->files[i]; i++)
		;
	fprintf(fp, "%d\n", i);
	for (i = 0; p->files[i]; i++)
		fprintf(fp, "%s\n", p->files[i]);
	for (i = 0, f = p->funcs; f; i++, f = f->link)
		if (q = f->callers)
			for (i--; q; q = q->link)
				i++;
	fprintf(fp, "%d\n", i);
	for (f = p->funcs; f; f = f->link) {
		int n = 0;
		for (q = f->callers; q; n += q->count, q = q->link) {
			unpack(f->src.coord, &index, &x, &y);
			fprintf(fp, "%s %d %d %d %d", f->name, index, x, y, q->count);
			if (q->caller) {
				unpack(q->caller->u.coord, &index, &x, &y);
				fprintf(fp, " %s %s %d %d\n", q->caller->name, q->caller->file, x, y);
			} else
				fprintf(fp, " ? ? 0 0\n");
		}
		if (n == 0) {
			unpack(f->src.coord, &index, &x, &y);
			fprintf(fp, "%s %d %d %d 0 ? ? 0 0\n", f->name, index, x, y);
		}
	}		
	fprintf(fp, "%d\n", p->npoints);
	for (i = 0; i < p->npoints; i++) {
		unpack(p->coords[i].coord, &index, &x, &y);
		fprintf(fp, "%d %d %d %d\n", index, x, y, p->counts[i]);
	}
}

static void bbexit(void) {
	FILE *fp;

	if (_bblist != &tail && (fp = fopen("prof.out", "a"))) {
		for ( ; _bblist != &tail; _bblist = _bblist->link)
			profout(_bblist, fp);
		fclose(fp);
	}
}

void _epilogue(struct func *callee) {
	_caller = 0;
}

void _prologue(struct func *callee, struct _bbdata *yylink) {
	static struct caller callers[4096];
	static int next;
	struct caller *p;

	if (!yylink->link) {
		yylink->link = _bblist;
		_bblist = yylink;
		if (next == 0)
			atexit(bbexit);
	}
	for (p = callee->callers; p; p = p->link)
		if (p->caller == _caller) {
			p->count++;
			break;
		}
	if (!p && next < sizeof callers/sizeof callers[0]) {
		p = &callers[next++];
		p->caller = _caller;
		p->count = 1;
		p->link = callee->callers;
		callee->callers = p;
	}
	_caller = 0;
}
The diff you're trying to view is too large. Only the first 1000 changed files have been loaded.
Showing with 0 additions and 0 deletions (0 / 0 diffs computed)
swh spinner

Computing file changes ...

back to top

Software Heritage — Copyright (C) 2015–2026, 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— Content policy— Contact— JavaScript license information— Web API