beignet-1.3.2-support-kfreebsd.patch 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. Description: Don't try to use sysinfo or CLOCK_MONOTONIC_RAW on non-Linux
  2. Fixes two FTBFS on kfreebsd due to use of Linux-specific features:
  3. https://buildd.debian.org/status/fetch.php?pkg=beignet&arch=kfreebsd-amd64&ver=1.0.1-3&stamp=1425101150
  4. https://buildd.debian.org/status/fetch.php?pkg=beignet&arch=kfreebsd-amd64&ver=1.1.1-1&stamp=1445338350
  5. Origin: https://github.com/freebsd/freebsd-ports-graphics/blob/opencl/lang/beignet/files/patch-src_cl__device__id.c https://github.com/freebsd/freebsd-ports-graphics/blob/master/lang/beignet/files/patch-src_cl__event.c
  6. Author: Koop Mast, Rebecca Palmer
  7. --- a/src/cl_device_id.c
  8. +++ b/src/cl_device_id.c
  9. @@ -34,7 +34,12 @@
  10. #include <stdio.h>
  11. #include <string.h>
  12. #include <stdlib.h>
  13. +#if defined(linux) || defined(__linux__) || defined(__LINUX__)
  14. #include <sys/sysinfo.h>
  15. +#else
  16. +#include <sys/types.h>
  17. +#include <sys/sysctl.h>
  18. +#endif
  19. #ifndef CL_VERSION_1_2
  20. #define CL_DEVICE_BUILT_IN_KERNELS 0x103F
  21. @@ -815,11 +820,24 @@ glk12eu_break:
  22. #define toMB(size) (size)&(UINT64_MAX<<20)
  23. /* Get the global_mem_size and max_mem_alloc size from
  24. * driver, system ram and hardware*/
  25. +#if defined(linux) || defined(__linux__) || defined(__LINUX__)
  26. struct sysinfo info;
  27. if (sysinfo(&info) == 0) {
  28. + uint64_t totalram = info.totalram * info.mem_unit;
  29. +#else
  30. + {
  31. + int mib[2];
  32. +
  33. + mib[0] = CTL_HW;
  34. + mib[1] = HW_USERMEM;
  35. +
  36. + uint64_t totalram;
  37. + size_t len;
  38. + len = sizeof(totalram);
  39. + sysctl(mib, 2, &totalram, &len, NULL, 0);
  40. +#endif
  41. uint64_t totalgpumem = ret->global_mem_size;
  42. uint64_t maxallocmem = ret->max_mem_alloc_size;
  43. - uint64_t totalram = info.totalram * info.mem_unit;
  44. /* In case to keep system stable we just use half
  45. * of the raw as global mem */
  46. ret->global_mem_size = toMB((totalram / 2 > totalgpumem) ?
  47. --- a/src/cl_event.c
  48. +++ b/src/cl_event.c
  49. @@ -22,6 +22,7 @@
  50. #include "cl_alloc.h"
  51. #include <string.h>
  52. #include <stdio.h>
  53. +#include <time.h>
  54. // TODO: Need to move it to some device related file later.
  55. static void