Skip to content

Commit

Permalink
cross-platform compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
wannesm committed Oct 11, 2023
1 parent 7ef0333 commit 743c701
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions pysdd/lib/libsdd-2.0/src/basic/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ SddNode* new_sdd_node(SddNodeType type, SddNodeSize size, Vtree* vtree, SddManag
else { //allocate decomposition
assert(size > 0);
//allocate decomposition node
int bucket = (size < GC_BUCKETS_COUNT? size: 0);
size_t bucket = (size < GC_BUCKETS_COUNT? size: 0);
node = manager->gc_node_lists[bucket];
if(node != NULL) { //allocating from gc list
--manager->gc_node_count;
Expand Down Expand Up @@ -156,7 +156,7 @@ void gc_sdd_node(SddNode* node, SddManager* manager) {
++manager->gc_node_count;
manager->gc_element_count += node->size; //no change for literal sdds

int bucket = (node->size < GC_BUCKETS_COUNT? node->size: 0); //literal sdds go into bucket 0
size_t bucket = (node->size < GC_BUCKETS_COUNT? node->size: 0); //literal sdds go into bucket 0
node->next = manager->gc_node_lists[bucket];
manager->gc_node_lists[bucket] = node; //add node to corresponding bucket

Expand Down
8 changes: 4 additions & 4 deletions pysdd/lib/libsdd-2.0/src/manager/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,16 +268,16 @@ void sdd_manager_minimize_limited(SddManager* manager) {


// these are checked by exceeded_limits(), invoked by l_apply
void sdd_manager_set_vtree_search_time_limit(float time_limit, SddManager* manager) {
void sdd_manager_set_vtree_search_time_limit(clock_t time_limit, SddManager* manager) {
manager->vtree_ops.search_time_limit = time_limit*CLOCKS_PER_SEC;
}
void sdd_manager_set_vtree_fragment_time_limit(float time_limit, SddManager* manager) {
void sdd_manager_set_vtree_fragment_time_limit(clock_t time_limit, SddManager* manager) {
manager->vtree_ops.fragment_time_limit = time_limit*CLOCKS_PER_SEC;
}
void sdd_manager_set_vtree_operation_time_limit(float time_limit, SddManager* manager) {
void sdd_manager_set_vtree_operation_time_limit(clock_t time_limit, SddManager* manager) {
manager->vtree_ops.op_time_limit = time_limit*CLOCKS_PER_SEC;
}
void sdd_manager_set_vtree_apply_time_limit(float time_limit, SddManager* manager) {
void sdd_manager_set_vtree_apply_time_limit(clock_t time_limit, SddManager* manager) {
manager->vtree_ops.apply_time_limit = time_limit*CLOCKS_PER_SEC;
}
void sdd_manager_set_vtree_operation_memory_limit(float memory_limit, SddManager* manager) {
Expand Down
4 changes: 2 additions & 2 deletions pysdd/lib/libsdd-2.0/src/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,15 +186,15 @@ char* read_file(const char* filename) {
// lookup file size
// AC: I don't think this is the best way to do this
fseek(file,0,SEEK_END);
unsigned int file_size = ftell(file);
size_t file_size = ftell(file);
rewind(file);

// allocate memory
char* buffer;
CALLOC(buffer,char,file_size+1,"read_file");

// read the whole file
unsigned int result = fread(buffer,sizeof(char),file_size,file);
size_t result = fread(buffer,sizeof(char),file_size,file);
if (result != file_size) {
printf("Could not read the file %s\n",filename);
exit(1);
Expand Down
2 changes: 1 addition & 1 deletion pysdd/lib/libsdd-2.0/src/vtrees/static.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ Vtree* new_random_vtree(SddLiteral var_count) {
SddLiteral* labels = (SddLiteral*) calloc(var_count,sizeof(SddLiteral));
for(SddLiteral i=0; i<var_count; i++) labels[i] = i+1; //assign labels
SddLiteral unused_count = var_count;
srand(time(NULL));
srand((unsigned int)time(NULL));
Vtree* vtree = new_random_vtree_aux(var_count,labels,&unused_count);
free(labels);
return vtree;
Expand Down
4 changes: 2 additions & 2 deletions pysdd/lib/sdd-2.0/src/fnf/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ static char* read_file(const char* filename) {

// lookup file size
fseek(file,0,SEEK_END);
unsigned int file_size = ftell(file);
size_t file_size = ftell(file);
rewind(file);

// allocate memory
char* buffer = (char*)calloc(file_size+1,sizeof(char));

// read the whole file
unsigned int result = fread(buffer,sizeof(char),file_size,file);
size_t result = fread(buffer,sizeof(char),file_size,file);
if (result != file_size) {
printf("Could not read the file %s\n",filename);
exit(1);
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ def __init__(self, attrs=None):

c_args = {
'unix': ['-O3', '-Wall'],
'msvc': ['/Ox', '/fp:fast', '/favor:INTEL64', '/Og'],
# 'msvc': ['/Ox', '/fp:fast', '/favor:INTEL64', '/Og'],
'msvc': ['/Ox', '/fp:fast'],
'mingw32': ['-O3', '-march=native']
}
c_args_debug = {
Expand Down

0 comments on commit 743c701

Please sign in to comment.