Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mockup-generator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dosek-verification
mockup-generator
Commits
72daabf4
Commit
72daabf4
authored
Oct 7, 2016
by
Hans-Peter Deifel
Browse files
Options
Downloads
Patches
Plain Diff
Add prelude code for mockup
parent
934fd078
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
files/mockup_prelude.cc
+122
-0
122 additions, 0 deletions
files/mockup_prelude.cc
with
122 additions
and
0 deletions
files/mockup_prelude.cc
0 → 100644
+
122
−
0
View file @
72daabf4
#include
"os.h"
#include
"test/test.h"
#include
"machine.h"
#include
<stdio.h>
void
os_main
(
void
)
{
StartOS
(
0
);
}
void
PreIdleHook
()
{
ShutdownMachine
();
}
int
_decisionMaker
(
int
i
)
{
printf
(
"Decision %d: "
,
i
);
int
res
=
(
getchar
()
==
'0'
)
?
0
:
1
;
getchar
();
// newline
return
res
;
}
extern
"C"
{
extern
const
uint32_t
_sdata_os_canonical
,
_edata_os_canonical
;
extern
const
uint32_t
_sdata_arch_canonical
,
_edata_arch_canonical
;
}
// **********************************************************************
// Murmur3 implementation
//
// See https://en.wikipedia.org/wiki/MurmurHash and
// http://programmers.stackexchange.com/a/145633
//
// Adapted almost literally from:
// https://github.com/aappleby/smhasher/blob/61a0530f28277f2e850bfc39600ce61d02b518de/src/MurmurHash3.cpp
// **********************************************************************
#define ROTL32(x, y) ((x << y) | (x >> (32 - y)))
uint32_t
murmur3_32
(
const
char
*
key
,
uint32_t
len
,
uint32_t
seed
)
{
const
uint8_t
*
data
=
(
const
uint8_t
*
)
key
;
const
int
nblocks
=
len
/
4
;
uint32_t
h1
=
seed
;
const
uint32_t
c1
=
0xcc9e2d51
;
const
uint32_t
c2
=
0x1b873593
;
// body
const
uint32_t
*
blocks
=
(
const
uint32_t
*
)(
data
+
nblocks
*
4
);
for
(
int
i
=
-
nblocks
;
i
<
0
;
i
++
)
{
uint32_t
k1
=
blocks
[
i
];
k1
*=
c1
;
k1
=
ROTL32
(
k1
,
15
);
k1
*=
c2
;
h1
^=
k1
;
h1
=
ROTL32
(
h1
,
13
);
h1
=
h1
*
5
+
0xe6546b64
;
}
// tail
const
uint8_t
*
tail
=
(
const
uint8_t
*
)(
data
+
nblocks
*
4
);
uint32_t
k1
=
0
;
switch
(
len
&
3
)
{
case
3
:
k1
^=
tail
[
2
]
<<
16
;
// intentional fallthrough
case
2
:
k1
^=
tail
[
1
]
<<
8
;
// intentional fallthrough
case
1
:
k1
^=
tail
[
0
];
k1
*=
c1
;
k1
=
ROTL32
(
k1
,
15
);
k1
*=
c2
;
h1
^=
k1
;
}
// finalization
h1
^=
len
;
h1
^=
h1
>>
16
;
h1
*=
0x85ebca6b
;
h1
^=
h1
>>
13
;
h1
*=
0xc2b2ae35
;
h1
^=
h1
>>
16
;
return
h1
;
}
// **********************************************************************
// End Murmur3
// **********************************************************************
uint32_t
hash_os_state
()
{
const
char
*
start
=
(
const
char
*
)
&
_sdata_os_canonical
;
const
char
*
end
=
(
const
char
*
)
&
_edata_os_canonical
;
uint32_t
len
=
end
-
start
;
uint32_t
seed
=
0
;
// be deterministic
uint32_t
first_hash
=
murmur3_32
(
start
,
len
,
seed
);
start
=
(
const
char
*
)
&
_sdata_arch_canonical
;
end
=
(
const
char
*
)
&
_edata_arch_canonical
;
len
=
end
-
start
;
uint32_t
second_hash
=
murmur3_32
(
start
,
len
,
seed
);
return
first_hash
^
second_hash
;
}
void
_print_os_state
(
int
line
)
{
kout
<<
"Line "
<<
line
<<
" in state "
;
kout
<<
"0x"
<<
hex
<<
hash_os_state
()
<<
dec
<<
endl
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment