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

WIP: Freebsd fixes #11

Open
wants to merge 5 commits into
base: master
from

Conversation

Projects
None yet
2 participants
@illwieckz
Copy link
Member

commented Jun 2, 2019

This is a list of commits aiming to fix crunch build on FreeBSD. The task is not complete yet since I now face this issue and I don't know yet how to fix it:

[ 93%] Building CXX object crnlib/CMakeFiles/crn.dir/crn_threading_pthreads.cpp.o
…/crunch/crnlib/crn_threading_pthreads.cpp: In function 'crnlib::crn_thread_id_t crnlib::crn_get_current_thread_id()':
…/crunch/crnlib/crn_threading_pthreads.cpp:43:53: error: invalid static_cast from type 'pthread_t' {aka 'pthread*'} to type 'crnlib::crn_thread_id_t' {aka 'long long unsigned int'}
   return static_cast<crn_thread_id_t>(pthread_self());

about a code that is already marked as non-portable:

crn_thread_id_t crn_get_current_thread_id() {
// FIXME: Not portable
return static_cast<crn_thread_id_t>(pthread_self());
}

The first commit is enough to allow crn_decomp.h in third-party projects. I did this fix to enable crn support in NetRadiant and q3map2 on FreeBSD, but that would enable crn support in Dæmon engine on FreeBSD too.

@illwieckz

This comment has been minimized.

Copy link
Member Author

commented Jun 2, 2019

@devnexen as a FreeBSD user, would you know how to fix this non-portable cast?

@devnexen

This comment has been minimized.

Copy link

commented Jun 2, 2019

a pthread_t is an opaque type in FreeBSD maybe this deserves a try.

@illwieckz

This comment has been minimized.

Copy link
Member Author

commented Jun 2, 2019

Thank you for your quick response! What would be thr_self() argument in that case?

@devnexen

This comment has been minimized.

Copy link

commented Jun 2, 2019

Well, theoretically, what can be tried here is something like this
unsigned long tid; thr_self(&tid); return static_cast<crn_thread_id_t>(tid);

@illwieckz

This comment has been minimized.

Copy link
Member Author

commented Jun 2, 2019

Hmmm, I did that (without unsigned):

  long tid;
  thr_self(&tid);
  return static_cast<crn_thread_id_t>(tid);

And it now builds but crunch does not work and I don't know yet if it fails because of that fix being wrong or one of my other fixes being wrong:

crunch: Advanced DXTn Texture Compressor - https://github.com/BinomialLLC/crunch
Copyright (c) 2010-2016 Richard Geldreich, Jr. and Binomial LLC
crnlib version v1.04 x64 Built Jun  2 2019, 18:23:36

Warning: No files found: /usr/home/illwieckz/dev/crunch/build/water_p.png
Error: No files found to process!
/home/illwieckz/dev/crunch/crnlib/crn_mem.cpp(121): Assertion failed: "crnlib_free: bad ptr"

/home/illwieckz/dev/crunch/crnlib/crn_mem.cpp(121): Assertion failed: "crnlib_free: bad ptr"

As it looks related to memory, I maybe did a mistake with the fopen/fseeko/ftello stuff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.