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

  • 2837cec
  • /
  • c
  • /
  • debug.h
Raw File Download
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
content badge Iframe embedding
swh:1:cnt:49f2fc73a0f2dd6d75f35412d957922851cb1fea
directory badge Iframe embedding
swh:1:dir:fed0c944d4de09d9eb9eb6c7631f54d261e98a9a
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
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
debug.h
#ifndef __debug__
#define __debug__

#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <math.h>

#define I(x) { printf("%s: %ld\n",#x, (long)x); }
#define F(x) { printf("%s: %g\n",#x,x); }

#define VASSERT(condition) { if(!(condition)) { printf("ASSERT FAILED: %s @ %s (line %d)\n", #condition, __FILE__,  __LINE__ ); exit(EXIT_FAILURE);} }

static double __debug_sum__ = 0;
static long __debug_N__ = 0;
static char *__debug_name__;
static double __debug_min__ = INFINITY;
static double __debug_max__ = -INFINITY;

void _count(double x, char *name) {
	__debug_name__ = name;
	__debug_sum__ += x;	
	__debug_N__++;
    __debug_min__ = __debug_min__ < x ? __debug_min__ : x;
    __debug_max__ = __debug_max__ > x ? __debug_max__ : x;
}

void _describe(void) {
	static int firstTime = 1; 
	if (firstTime) {
		printf("Mean of %s is %g\n", __debug_name__, __debug_sum__/(double)__debug_N__);
		printf("Min of %s is %g\n", __debug_name__, __debug_min__);
		printf("Max of %s is %g\n", __debug_name__, __debug_max__);
		firstTime = 0;
	}
}

//void check_pointer(void *ptr, void *low, void *high) { }

#define DESCRIBE(x) {_count(x, #x); atexit(_describe); }

#endif

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