Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[internal] get the reason bspack build script working with esy #2153

Closed
wants to merge 33 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
8f195cf
almost to jsoo
jaredly Aug 21, 2018
e660347
gettin it workin
jaredly Aug 21, 2018
1675c55
working with esy
jaredly Aug 21, 2018
79fa2cc
ignore
jaredly Aug 21, 2018
a9925c5
cleanup
jaredly Aug 21, 2018
d118601
more cleanup
jaredly Aug 21, 2018
b9f17a8
more cleanup
jaredly Aug 21, 2018
d4461ad
version default
jaredly Aug 21, 2018
9677c52
locks
jaredly Aug 21, 2018
5eb1090
vendor bspack
jaredly Aug 21, 2018
e876003
missed that too
jaredly Aug 22, 2018
a912b5e
cleanup
jaredly Aug 22, 2018
4c709b3
gnu sed
jaredly Aug 22, 2018
1aca9a2
fix version number
jaredly Sep 12, 2018
22a520c
Merge branch 'master' into joo. Conflicts: bspacks/reason_bspack.sh
jchavarri Nov 24, 2019
23d08c1
Add ppx_derivers to bspacks deps
jchavarri Nov 25, 2019
28e4c96
Fix paths to esy sandbox
jchavarri Nov 25, 2019
1d05e43
Native build passing
jchavarri Nov 25, 2019
7b335f1
Fix refmt_js api
jchavarri Nov 26, 2019
d667cb8
Merge pull request #2 from jchavarri/joo
jaredly Nov 27, 2019
e92ca99
quiet esy.lock
jaredly Nov 28, 2019
9c0248d
get bspack.ml from github
jchavarri Nov 28, 2019
74e623a
actually remove bspack and fix paths
jchavarri Nov 28, 2019
20a8f01
Merge pull request #3 from jchavarri/joo
jaredly Nov 30, 2019
6a8a441
Merge branch 'master' into joo
jaredly Dec 2, 2019
a56fc71
igonre output directory
jaredly Dec 2, 2019
5b79c17
use sandboxes! yay
jaredly Dec 2, 2019
b5d3aef
rm old
jaredly Dec 2, 2019
458baa1
Merge branch 'master' into joo
jaredly Dec 12, 2019
fd11d9d
simplify
jaredly Dec 12, 2019
654f582
generated
jaredly Dec 12, 2019
dbd1034
undo that
jaredly Dec 12, 2019
e3eec8a
do the prerelease thing
jaredly Dec 12, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
missed that too
  • Loading branch information
jaredly committed Aug 22, 2018
commit e876003939b1ae3f995dcebe12361aff8c313eac
146 changes: 146 additions & 0 deletions bspacks/bin/ext_basic_hash_stubs.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
#include "caml/hash.h"
#include "caml/mlvalues.h"
#include <string.h>
#include <stdint.h>
typedef uint32_t uint32;

#define FINAL_MIX(h) \
h ^= h >> 16; \
h *= 0x85ebca6b; \
h ^= h >> 13; \
h *= 0xc2b2ae35; \
h ^= h >> 16;

#define ROTL32(x,n) ((x) << n | (x) >> (32-n))

#define MIX(h,d) \
d *= 0xcc9e2d51; \
d = ROTL32(d, 15); \
d *= 0x1b873593; \
h ^= d; \
h = ROTL32(h, 13); \
h = h * 5 + 0xe6546b64;

CAMLprim value caml_bs_hash_string (value obj){

uint32 h = 0;
h = caml_hash_mix_string(h,obj);
FINAL_MIX(h);
return Val_int(h & 0x3FFFFFFFU);
}

CAMLprim value caml_bs_hash_int ( value d){
uint32 h = 0;
h = caml_hash_mix_intnat(h,d);
FINAL_MIX(h);
return Val_int(h & 0x3FFFFFFFU);
}

CAMLprim value caml_bs_hash_string_and_int (value obj, value d){
uint32 h = 0;
h = caml_hash_mix_string(h,obj);
h = caml_hash_mix_intnat(h,d);
FINAL_MIX(h);
return Val_int(h & 0x3FFFFFFFU);
}

CAMLprim value caml_bs_hash_string_and_small_int(value obj, value d){
uint32 h = 0;
h = caml_hash_mix_string(h,obj);
MIX(h,d);
FINAL_MIX(h);
return Val_int(h & 0x3FFFFFFFU);
}

CAMLprim value caml_bs_hash_small_int(value d){
uint32 h = 0;
// intnat stamp = Long_val(d);
// FIXME: unused value
MIX(h,d);
FINAL_MIX(h);
return Val_int(h & 0x3FFFFFFFU);
}

CAMLprim value caml_int_array_blit(
value a1, value ofs1,
value a2, value ofs2,
value n)
{
memmove(&Field(a2, Long_val(ofs2)),
&Field(a1, Long_val(ofs1)),
Long_val(n) * sizeof(value));
return Val_unit;
}
/*
* http:https://stackoverflow.com/questions/664014/what-integer-hash-function-are-good-that-accepts-an-integer-hash-key
* https://en.wikipedia.org/wiki/MurmurHash
* http:https://zimbry.blogspot.it/2011/09/better-bit-mixing-improving-on.html
* http:https://eternallyconfuzzled.com/tuts/algorithms/jsw_tut_hashing.aspx
* We gave up the idea to hash Ident.t (take only one argument)
* customized hash function for Ident.t, first
* argument is stamp, second argument is string
* It's not just introducing c stubs, we need make a clear line
* which part of our libraries depends on Ident.t
*/
CAMLprim value caml_bs_hash_stamp_and_name(value d, value obj ){
uint32 h = 0;
intnat stamp = Long_val(d);
if (stamp){
MIX(h,d);
} else {
h = caml_hash_mix_string(h,obj);
}

FINAL_MIX(h);
return Val_int(h & 0x3FFFFFFFU);
}





// https://github.com/ocaml/ocaml/pull/255/files
#define Val_long_clang(x) ((intnat) (((uintnat)(x) << 1)) + 1)

CAMLprim value caml_string_length_based_compare(value s1, value s2)
{
mlsize_t len1, len2;
mlsize_t temp;
int res;
if (s1 == s2) return Val_int(0);

len1 = Wosize_val(s1);
temp = Bsize_wsize(len1) - 1 ;
len1 = temp - Byte(s1,temp);

len2 = Wosize_val(s2);
temp = Bsize_wsize(len2) - 1 ;
len2 = temp - Byte(s2,temp);

if (len1 != len2)
{
if (len1 < len2 ) {
return Val_long_clang(-1);
} else {
return Val_long_clang(1);
}
}
else {

res = memcmp(String_val(s1), String_val(s2), len1);
if(res < 0) return Val_long_clang(-1);
if(res > 0) return Val_long_clang(1);
return Val_long_clang(0);

}
}





/* local variables: */
/* compile-command: "ocamlopt.opt -c ext_basic_hash_stubs.c" */
/* end: */