Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Merge pull request #10831 from ocaml-multicore/multicore-pr
Multicore OCaml integration.
Commenting on lines
to
Commenting on lines
to
Showing
573 changed files
with
22,955 additions
and 14,062 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,134 @@ | |||
/**************************************************************************/ | |||
/* */ | |||
/* OCaml */ | |||
/* */ | |||
/* Stephen Dolan, University of Cambridge */ | |||
/* */ | |||
/* Copyright 2015 University of Cambridge */ | |||
/* */ | |||
/* All rights reserved. This file is distributed under the terms of */ | |||
/* the GNU Lesser General Public License version 2.1, with the */ | |||
/* special exception on linking described in the file LICENSE. */ | |||
/* */ | |||
/**************************************************************************/ | |||
|
|||
#include "caml/config.h" | |||
#include "caml/memory.h" | |||
#include "caml/addrmap.h" | |||
|
|||
#define MAX_CHAIN 100 | |||
|
|||
Caml_inline uintnat pos_initial(struct addrmap* t, value key) | |||
{ | |||
uintnat pos = (uintnat)key; | |||
pos *= 0xcc9e2d51; | |||
pos ^= (pos >> 17); | |||
|
|||
CAMLassert(Is_power_of_2(t->size)); | |||
return pos & (t->size - 1); | |||
} | |||
|
|||
Caml_inline uintnat pos_next(struct addrmap* t, uintnat pos) | |||
{ | |||
return (pos + 1) & (t->size - 1); | |||
} | |||
|
|||
int caml_addrmap_contains(struct addrmap* t, value key) | |||
{ | |||
uintnat pos, i; | |||
|
|||
CAMLassert(Is_block(key)); | |||
if (!t->entries) return 0; | |||
|
|||
for (i = 0, pos = pos_initial(t, key); | |||
i < MAX_CHAIN; | |||
i++, pos = pos_next(t, pos)) { | |||
if (t->entries[pos].key == ADDRMAP_INVALID_KEY) break; | |||
if (t->entries[pos].key == key) return 1; | |||
} | |||
return 0; | |||
} | |||
|
|||
value caml_addrmap_lookup(struct addrmap* t, value key) | |||
{ | |||
uintnat pos; | |||
|
|||
CAMLassert(Is_block(key)); | |||
CAMLassert(t->entries); | |||
|
|||
for (pos = pos_initial(t, key); ; pos = pos_next(t, pos)) { | |||
CAMLassert(t->entries[pos].key != ADDRMAP_INVALID_KEY); | |||
if (t->entries[pos].key == key) | |||
return t->entries[pos].value; | |||
} | |||
} | |||
|
|||
static void addrmap_alloc(struct addrmap* t, uintnat sz) | |||
{ | |||
uintnat i; | |||
CAMLassert(Is_power_of_2(sz)); | |||
t->entries = caml_stat_alloc(sizeof(struct addrmap_entry) * sz); | |||
t->size = sz; | |||
for (i = 0; i < sz; i++) { | |||
t->entries[i].key = ADDRMAP_INVALID_KEY; | |||
t->entries[i].value = ADDRMAP_NOT_PRESENT; | |||
} | |||
} | |||
|
|||
void caml_addrmap_clear(struct addrmap* t) { | |||
caml_stat_free(t->entries); | |||
t->entries = 0; | |||
t->size = 0; | |||
} | |||
|
|||
|
|||
|
|||
value* caml_addrmap_insert_pos(struct addrmap* t, value key) { | |||
uintnat i, pos; | |||
CAMLassert(Is_block(key)); | |||
if (!t->entries) { | |||
/* first call, initialise table with a small initial size */ | |||
addrmap_alloc(t, 256); | |||
} | |||
for (i = 0, pos = pos_initial(t, key); | |||
i < MAX_CHAIN; | |||
i++, pos = pos_next(t, pos)) { | |||
if (t->entries[pos].key == ADDRMAP_INVALID_KEY) { | |||
t->entries[pos].key = key; | |||
} | |||
if (t->entries[pos].key == key) { | |||
return &t->entries[pos].value; | |||
} | |||
} | |||
/* failed to insert, rehash and try again */ | |||
{ | |||
struct addrmap_entry* old_table = t->entries; | |||
uintnat old_size = t->size; | |||
addrmap_alloc(t, old_size * 2); | |||
for (i = 0; i < old_size; i++) { | |||
if (old_table[i].key != ADDRMAP_INVALID_KEY) { | |||
value* p = caml_addrmap_insert_pos(t, old_table[i].key); | |||
CAMLassert(*p == ADDRMAP_NOT_PRESENT); | |||
*p = old_table[i].value; | |||
} | |||
} | |||
caml_stat_free(old_table); | |||
} | |||
return caml_addrmap_insert_pos(t, key); | |||
} | |||
|
|||
void caml_addrmap_insert(struct addrmap* t, value k, value v) { | |||
value* p = caml_addrmap_insert_pos(t, k); | |||
CAMLassert(*p == ADDRMAP_NOT_PRESENT); | |||
*p = v; | |||
} | |||
|
|||
void caml_addrmap_iter(struct addrmap* t, void (*f)(value, value)) { | |||
addrmap_iterator i; | |||
for (i = caml_addrmap_iterator(t); | |||
caml_addrmap_iter_ok(t, i); | |||
i = caml_addrmap_next(t, i)) { | |||
f(caml_addrmap_iter_key(t, i), | |||
caml_addrmap_iter_value(t, i)); | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,97 @@ | |||
/**************************************************************************/ | |||
/* */ | |||
/* OCaml */ | |||
/* */ | |||
/* Stephen Dolan, University of Cambridge */ | |||
/* */ | |||
/* Copyright 2015 University of Cambridge */ | |||
/* */ | |||
/* All rights reserved. This file is distributed under the terms of */ | |||
/* the GNU Lesser General Public License version 2.1, with the */ | |||
/* special exception on linking described in the file LICENSE. */ | |||
/* */ | |||
/**************************************************************************/ | |||
#include "mlvalues.h" | |||
|
|||
#ifndef CAML_ADDRMAP_H | |||
#define CAML_ADDRMAP_H | |||
|
|||
/* An addrmap is a value -> value hashmap, where | |||
the values are blocks */ | |||
|
|||
struct addrmap_entry { value key, value; }; | |||
struct addrmap { | |||
struct addrmap_entry* entries; | |||
uintnat size; | |||
}; | |||
|
|||
#define ADDRMAP_INIT {0,0} | |||
|
|||
int caml_addrmap_contains(struct addrmap* t, value k); | |||
value caml_addrmap_lookup(struct addrmap* t, value k); | |||
|
|||
#define ADDRMAP_NOT_PRESENT ((value)(0)) | |||
#define ADDRMAP_INVALID_KEY ((value)(0)) | |||
|
|||
value* caml_addrmap_insert_pos(struct addrmap* t, value k); | |||
|
|||
/* must not already be present */ | |||
void caml_addrmap_insert(struct addrmap* t, value k, value v); | |||
|
|||
void caml_addrmap_clear(struct addrmap* t); | |||
|
|||
void caml_addrmap_iter(struct addrmap* t, void (*f)(value, value)); | |||
|
|||
/* iteration */ | |||
typedef uintnat addrmap_iterator; | |||
Caml_inline addrmap_iterator caml_addrmap_iter_ok(struct addrmap* t, | |||
addrmap_iterator i) | |||
{ | |||
if (i < t->size) { | |||
CAMLassert(t->entries[i].key != ADDRMAP_INVALID_KEY); | |||
return 1; | |||
} else { | |||
return 0; | |||
} | |||
} | |||
|
|||
Caml_inline addrmap_iterator caml_addrmap_next(struct addrmap* t, | |||
addrmap_iterator i) | |||
{ | |||
if (!t->entries) return (uintnat)(-1); | |||
i++; | |||
while (i < t->size && t->entries[i].key == ADDRMAP_INVALID_KEY) { | |||
i++; | |||
} | |||
caml_addrmap_iter_ok(t, i); /* just for assert-checks */ | |||
return i; | |||
} | |||
|
|||
Caml_inline value caml_addrmap_iter_key(struct addrmap* t, | |||
addrmap_iterator i) | |||
{ | |||
CAMLassert(caml_addrmap_iter_ok(t, i)); | |||
return t->entries[i].key; | |||
} | |||
|
|||
Caml_inline value caml_addrmap_iter_value(struct addrmap* t, | |||
addrmap_iterator i) | |||
{ | |||
CAMLassert(caml_addrmap_iter_ok(t, i)); | |||
return t->entries[i].value; | |||
} | |||
|
|||
Caml_inline value* caml_addrmap_iter_val_pos(struct addrmap* t, | |||
addrmap_iterator i) | |||
{ | |||
CAMLassert(caml_addrmap_iter_ok(t, i)); | |||
return &t->entries[i].value; | |||
} | |||
|
|||
Caml_inline addrmap_iterator caml_addrmap_iterator(struct addrmap* t) | |||
{ | |||
return caml_addrmap_next(t, (uintnat)(-1)); | |||
} | |||
|
|||
|
|||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,87 @@ | |||
/**************************************************************************/ | |||
/* */ | |||
/* OCaml */ | |||
/* */ | |||
/* KC Sivaramakrishnan, Indian Institute of Technology, Madras */ | |||
/* Stephen Dolan, University of Cambridge */ | |||
/* */ | |||
/* Copyright 2018 Indian Institute of Technology, Madras */ | |||
/* Copyright 2018 University of Cambridge */ | |||
/* */ | |||
/* All rights reserved. This file is distributed under the terms of */ | |||
/* the GNU Lesser General Public License version 2.1, with the */ | |||
/* special exception on linking described in the file LICENSE. */ | |||
/* */ | |||
/**************************************************************************/ | |||
#ifndef CAML_ATOMIC_H | |||
#define CAML_ATOMIC_H | |||
|
|||
#ifndef CAML_NAME_SPACE | |||
#include "compatibility.h" | |||
#endif | |||
#include "config.h" | |||
#include "misc.h" | |||
|
|||
/* On platforms supporting C11 atomics, this file just includes <stdatomic.h>. | |||
On other platforms, this file includes platform-specific stubs for | |||
the subset of C11 atomics needed by the OCaml runtime | |||
*/ | |||
|
|||
#ifdef __cplusplus | |||
|
|||
extern "C++" { | |||
#include <atomic> | |||
#define ATOMIC_UINTNAT_INIT(x) (x) | |||
typedef std::atomic<uintnat> atomic_uintnat; | |||
typedef std::atomic<intnat> atomic_intnat; | |||
using std::memory_order_relaxed; | |||
using std::memory_order_acquire; | |||
using std::memory_order_release; | |||
using std::memory_order_acq_rel; | |||
using std::memory_order_seq_cst; | |||
} | |||
|
|||
#elif defined(HAS_STDATOMIC_H) | |||
|
|||
#include <stdatomic.h> | |||
#define ATOMIC_UINTNAT_INIT(x) (x) | |||
typedef _Atomic uintnat atomic_uintnat; | |||
typedef _Atomic intnat atomic_intnat; | |||
|
|||
#elif defined(__GNUC__) | |||
|
|||
/* Support for versions of gcc which have built-in atomics but do not | |||
expose stdatomic.h (e.g. gcc 4.8) */ | |||
typedef enum memory_order { | |||
memory_order_relaxed = __ATOMIC_RELAXED, | |||
memory_order_acquire = __ATOMIC_ACQUIRE, | |||
memory_order_release = __ATOMIC_RELEASE, | |||
memory_order_acq_rel = __ATOMIC_ACQ_REL, | |||
memory_order_seq_cst = __ATOMIC_SEQ_CST | |||
} memory_order; | |||
|
|||
#define ATOMIC_UINTNAT_INIT(x) { (x) } | |||
typedef struct { uintnat repr; } atomic_uintnat; | |||
typedef struct { intnat repr; } atomic_intnat; | |||
|
|||
#define atomic_load_explicit(x, m) __atomic_load_n(&(x)->repr, (m)) | |||
#define atomic_load(x) atomic_load_explicit((x), memory_order_seq_cst) | |||
#define atomic_store_explicit(x, v, m) __atomic_store_n(&(x)->repr, (v), (m)) | |||
#define atomic_store(x, v) atomic_store_explicit((x), (v), memory_order_seq_cst) | |||
#define atomic_compare_exchange_strong(x, oldv, newv) \ | |||
__atomic_compare_exchange_n( \ | |||
&(x)->repr, \ | |||
(oldv), (newv), 0, \ | |||
memory_order_seq_cst, memory_order_seq_cst) | |||
#define atomic_exchange(x, newv) \ | |||
__atomic_exchange_n(&(x)->repr, (newv), memory_order_seq_cst) | |||
#define atomic_fetch_add(x, n) \ | |||
__atomic_fetch_add(&(x)->repr, (n), memory_order_seq_cst) | |||
#define atomic_thread_fence __atomic_thread_fence | |||
|
|||
#else | |||
#error "C11 atomics are unavailable on this platform. See camlatomic.h" | |||
#endif | |||
|
|||
#endif /* CAML_ATOMIC_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
You’re not receiving notifications from this thread.