Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
abc
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
abc
Commits
264dfc7e
Commit
264dfc7e
authored
Nov 27, 2021
by
whitequark
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extend WASI platform support for glucose2.
Abort on OOM since there are no C++ exceptions yet.
parent
f6fa2ddc
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
0 deletions
+20
-0
src/sat/glucose2/Alloc.h
+8
-0
src/sat/glucose2/Vec.h
+8
-0
src/sat/glucose2/XAlloc.h
+4
-0
No files found.
src/sat/glucose2/Alloc.h
View file @
264dfc7e
...
...
@@ -100,7 +100,11 @@ void RegionAllocator<T>::capacity(uint32_t min_cap)
cap
+=
delta
;
if
(
cap
<=
prev_cap
)
#ifdef __wasm
abort
();
#else
throw
OutOfMemoryException
();
#endif
}
//printf(" .. (%p) cap = %u\n", this, cap);
...
...
@@ -122,7 +126,11 @@ RegionAllocator<T>::alloc(int size)
// Handle overflow:
if
(
sz
<
prev_sz
)
#ifdef __wasm
abort
();
#else
throw
OutOfMemoryException
();
#endif
return
prev_sz
;
}
...
...
src/sat/glucose2/Vec.h
View file @
264dfc7e
...
...
@@ -102,14 +102,22 @@ void vec<T>::capacity(int min_cap) {
if
(
cap
>=
min_cap
)
return
;
int
add
=
imax
((
min_cap
-
cap
+
1
)
&
~
1
,
((
cap
>>
1
)
+
2
)
&
~
1
);
// NOTE: grow by approximately 3/2
if
(
add
>
INT_MAX
-
cap
||
(((
data
=
(
T
*
)
::
realloc
(
data
,
(
cap
+=
add
)
*
sizeof
(
T
)))
==
NULL
)
&&
errno
==
ENOMEM
))
#ifdef __wasm
abort
();
#else
throw
OutOfMemoryException
();
#endif
}
template
<
class
T
>
void
vec
<
T
>::
prelocate
(
int
ext_cap
)
{
if
(
cap
>=
ext_cap
)
return
;
if
(
ext_cap
>
INT_MAX
||
(((
data
=
(
T
*
)
::
realloc
(
data
,
ext_cap
*
sizeof
(
T
)))
==
NULL
)
&&
errno
==
ENOMEM
))
#ifdef __wasm
abort
();
#else
throw
OutOfMemoryException
();
#endif
cap
=
ext_cap
;
}
...
...
src/sat/glucose2/XAlloc.h
View file @
264dfc7e
...
...
@@ -39,7 +39,11 @@ static inline void* xrealloc(void *ptr, size_t size)
{
void
*
mem
=
realloc
(
ptr
,
size
);
if
(
mem
==
NULL
&&
errno
==
ENOMEM
){
#ifdef __wasm
abort
();
#else
throw
OutOfMemoryException
();
#endif
}
else
{
return
mem
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment