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

  • dc00990
  • /
  • cfreeze.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.

  • content
  • directory
content badge
swh:1:cnt:07475969e0b2b36940d1bfa5c7c5159f7d250cf9
directory badge
swh:1:dir:dc0099034dd5f21861eb1fb07610d9ddfec61e63

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
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
cfreeze.c
// Check old freeze/melt semantics.  Example from 'lglib.h' (Lingeling).

#include "../../src/ccadical.h"

#ifdef NDEBUG
#undef NDEBUG
#endif

#include <assert.h>
#include <fcntl.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <unistd.h>

void illegal (void (*f)(CCaDiCaL *, int), CCaDiCaL * cadical, int lit) {
  pid_t child = fork (), other;
  int status;
  if (!child) {
    int null = open ("/dev/null", O_WRONLY);
    dup2 (null, 2);
    f (cadical, lit);
    close (2);
    exit (0);
  }
  other = wait (&status);
  assert (other == child);
  assert (!WIFEXITED (status));
  assert (WIFSIGNALED (status));
  assert (WTERMSIG (status) == SIGABRT);
}

int main () {

  CCaDiCaL * cadical = ccadical_init ();
  int res;

  ccadical_set_option (cadical, "check", 1);
  ccadical_set_option (cadical, "checkfrozen", 1);

  ccadical_add (cadical, -14);
  ccadical_add (cadical, 2);
  ccadical_add (cadical, 0);                              // binary clause

  ccadical_add (cadical, 14);
  ccadical_add (cadical, -1);
  ccadical_add (cadical, 0);                             // binary clause

  ccadical_assume (cadical, 1);                          // assume '1'
  ccadical_freeze (cadical, 1);                          // will use '1' below
  ccadical_freeze (cadical, 14);                         // will use '14 too
  assert (ccadical_frozen (cadical, 1));
  assert (ccadical_frozen (cadical, 14));
  res = ccadical_solve (cadical);
  assert (res == 10);
  (void) ccadical_val (cadical, 1);                       // fine
  (void) ccadical_val (cadical, 2);                       // fine
  (void) ccadical_val (cadical, 3);                       // fine !
  (void) ccadical_val (cadical, 14);                      // fine

  illegal (ccadical_add, cadical, 2);                     // ILLEGAL
  illegal (ccadical_assume, cadical, 2);                  // ILLEGAL

  ccadical_add (cadical, -14);
  ccadical_add (cadical, 1);
  ccadical_add (cadical, 0);                              // binary clause

  ccadical_add (cadical, 15);
  ccadical_add (cadical, 0);                              // fine!
  ccadical_melt (cadical, 14);                            // '1' discarded

  res = ccadical_solve (cadical);
  assert (res == 10);
  assert (ccadical_frozen (cadical, 1));
  (void) ccadical_val (cadical, 1);                       // fine
  (void) ccadical_val (cadical, 2);                       // fine
  (void) ccadical_val (cadical, 3);                       // fine
  (void) ccadical_val (cadical, 14);                      // fine
  (void) ccadical_val (cadical, 15);                      // fine

  illegal (ccadical_assume, cadical, 2);                  // ILLEGAL
  illegal (ccadical_assume, cadical, 14);                 // ILLEGAL

  ccadical_add (cadical, 1);                              // still frozen
  ccadical_melt (cadical, 1);
  ccadical_add (cadical, 0);
  res = ccadical_solve (cadical);
  assert (res == 10);                                     // TODO right?
  ccadical_reset (cadical);

  return 0;
}

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