1 include(CheckCXXSourceCompiles)
2 include(CheckCXXSourceRuns)
3 include(CheckCXXSymbolExists)
4 include(CheckFunctionExists)
5 include(CheckIncludeFiles)
6 include(CheckStructHasMember)
8 include(CheckLibraryExists)
10 if(CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
11 set(CMAKE_REQUIRED_INCLUDES /usr/local/include)
12 elseif(CMAKE_SYSTEM_NAME STREQUAL SunOS)
13 set(CMAKE_REQUIRED_INCLUDES /opt/local/include)
15 if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin AND NOT CMAKE_SYSTEM_NAME STREQUAL FreeBSD AND NOT CMAKE_SYSTEM_NAME STREQUAL NetBSD)
16 set(CMAKE_REQUIRED_DEFINITIONS "-D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809L")
19 list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_FILE_OFFSET_BITS=64)
21 check_include_files(ieeefp.h HAVE_IEEEFP_H)
22 check_include_files(alloca.h HAVE_ALLOCA_H)
23 check_include_files(sys/vmparam.h HAVE_SYS_VMPARAM_H)
24 check_include_files(mach/vm_types.h HAVE_MACH_VM_TYPES_H)
25 check_include_files(mach/vm_param.h HAVE_MACH_VM_PARAM_H)
26 check_include_files("sys/param.h;sys/types.h;machine/npx.h" HAVE_MACHINE_NPX_H)
27 check_include_files("sys/param.h;sys/cdefs.h;machine/reg.h" HAVE_MACHINE_REG_H)
28 check_include_files(machine/vmparam.h HAVE_MACHINE_VMPARAM_H)
29 check_include_files(procfs.h HAVE_PROCFS_H)
30 check_include_files(crt_externs.h HAVE_CRT_EXTERNS_H)
31 check_include_files(sys/time.h HAVE_SYS_TIME_H)
32 check_include_files(pthread_np.h HAVE_PTHREAD_NP_H)
33 check_include_files(sys/lwp.h HAVE_SYS_LWP_H)
34 check_include_files(libunwind.h HAVE_LIBUNWIND_H)
35 check_include_files(runetype.h HAVE_RUNETYPE_H)
36 check_include_files(lttng/tracepoint.h HAVE_LTTNG_TRACEPOINT_H)
37 check_include_files(uuid/uuid.h HAVE_LIBUUID_H)
38 check_include_files(uuid.h HAVE_BSD_UUID_H)
40 check_function_exists(kqueue HAVE_KQUEUE)
41 check_function_exists(getpwuid_r HAVE_GETPWUID_R)
42 check_library_exists(pthread pthread_suspend "" HAVE_PTHREAD_SUSPEND)
43 check_library_exists(pthread pthread_suspend_np "" HAVE_PTHREAD_SUSPEND_NP)
44 check_library_exists(pthread pthread_continue "" HAVE_PTHREAD_CONTINUE)
45 check_library_exists(pthread pthread_continue_np "" HAVE_PTHREAD_CONTINUE_NP)
46 check_library_exists(pthread pthread_resume_np "" HAVE_PTHREAD_RESUME_NP)
47 check_library_exists(pthread pthread_attr_get_np "" HAVE_PTHREAD_ATTR_GET_NP)
48 check_library_exists(pthread pthread_getattr_np "" HAVE_PTHREAD_GETATTR_NP)
49 check_library_exists(pthread pthread_sigqueue "" HAVE_PTHREAD_SIGQUEUE)
50 check_function_exists(sigreturn HAVE_SIGRETURN)
51 check_function_exists(_thread_sys_sigreturn HAVE__THREAD_SYS_SIGRETURN)
52 set(CMAKE_REQUIRED_LIBRARIES m)
53 check_function_exists(copysign HAVE_COPYSIGN)
54 set(CMAKE_REQUIRED_LIBRARIES)
55 check_function_exists(fsync HAVE_FSYNC)
56 check_function_exists(futimes HAVE_FUTIMES)
57 check_function_exists(utimes HAVE_UTIMES)
58 check_function_exists(sysctl HAVE_SYSCTL)
59 check_function_exists(sysconf HAVE_SYSCONF)
60 check_function_exists(localtime_r HAVE_LOCALTIME_R)
61 check_function_exists(gmtime_r HAVE_GMTIME_R)
62 check_function_exists(timegm HAVE_TIMEGM)
63 check_function_exists(_snwprintf HAVE__SNWPRINTF)
64 check_function_exists(poll HAVE_POLL)
65 check_function_exists(statvfs HAVE_STATVFS)
66 check_function_exists(thread_self HAVE_THREAD_SELF)
67 check_function_exists(_lwp_self HAVE__LWP_SELF)
68 check_function_exists(pthread_mach_thread_np HAVE_MACH_THREADS)
69 check_function_exists(thread_set_exception_ports HAVE_MACH_EXCEPTIONS)
70 check_function_exists(vm_allocate HAVE_VM_ALLOCATE)
71 check_function_exists(vm_read HAVE_VM_READ)
72 check_function_exists(directio HAVE_DIRECTIO)
73 check_function_exists(semget HAS_SYSV_SEMAPHORES)
74 check_function_exists(pthread_mutex_init HAS_PTHREAD_MUTEXES)
75 check_function_exists(ttrace HAVE_TTRACE)
77 check_struct_has_member ("struct stat" st_atimespec "sys/types.h;sys/stat.h" HAVE_STAT_TIMESPEC)
78 check_struct_has_member ("struct stat" st_atimensec "sys/types.h;sys/stat.h" HAVE_STAT_NSEC)
79 check_struct_has_member ("struct tm" tm_gmtoff time.h HAVE_TM_GMTOFF)
80 check_struct_has_member ("ucontext_t" uc_mcontext.gregs[0] ucontext.h HAVE_GREGSET_T)
82 set(CMAKE_EXTRA_INCLUDE_FILES machine/reg.h)
83 check_type_size("struct reg" BSD_REGS_T)
84 set(CMAKE_EXTRA_INCLUDE_FILES)
85 set(CMAKE_EXTRA_INCLUDE_FILES asm/ptrace.h)
86 check_type_size("struct pt_regs" PT_REGS)
87 set(CMAKE_EXTRA_INCLUDE_FILES)
88 set(CMAKE_EXTRA_INCLUDE_FILES signal.h)
89 check_type_size(siginfo_t SIGINFO_T)
90 set(CMAKE_EXTRA_INCLUDE_FILES)
91 set(CMAKE_EXTRA_INCLUDE_FILES ucontext.h)
92 check_type_size(ucontext_t UCONTEXT_T)
93 set(CMAKE_EXTRA_INCLUDE_FILES)
94 set(CMAKE_EXTRA_INCLUDE_FILES pthread.h)
95 check_type_size(pthread_rwlock_t PTHREAD_RWLOCK_T)
96 set(CMAKE_EXTRA_INCLUDE_FILES)
97 set(CMAKE_EXTRA_INCLUDE_FILE procfs.h)
98 check_type_size(prwatch_t PRWATCH_T)
99 set(CMAKE_EXTRA_INCLUDE_FILE)
100 check_type_size(off_t SIZEOF_OFF_T)
102 check_cxx_symbol_exists(SYS_yield sys/syscall.h HAVE_YIELD_SYSCALL)
103 check_cxx_symbol_exists(INFTIM poll.h HAVE_INFTIM)
104 check_cxx_symbol_exists(CHAR_BIT limits.h HAVE_CHAR_BIT)
105 check_cxx_symbol_exists(_DEBUG sys/user.h USER_H_DEFINES_DEBUG)
106 check_cxx_symbol_exists(_SC_PHYS_PAGES unistd.h HAVE__SC_PHYS_PAGES)
107 check_cxx_symbol_exists(_SC_AVPHYS_PAGES unistd.h HAVE__SC_AVPHYS_PAGES)
109 check_cxx_source_runs("
110 #include <sys/param.h>
116 char resolvedPath[PATH_MAX];
117 #elif defined(MAXPATHLEN)
118 char resolvedPath[MAXPATHLEN];
120 char resolvedPath[1024];
122 path = realpath(\"a_nonexistent_file\", resolvedPath);
127 }" REALPATH_SUPPORTS_NONEXISTENT_FILES)
128 check_cxx_source_runs("
134 sscanf(\"5000000000\", \"%qu\", &n);
135 exit (n != 5000000000);
136 }" SSCANF_SUPPORT_ll)
137 check_cxx_source_runs("
145 char * strin = \"12.34e\";
147 ret = sscanf (strin, \"%e\", &f);
151 }" SSCANF_CANNOT_HANDLE_MISSING_EXPONENT)
152 check_cxx_source_runs("
157 char buf[256] = { 0 };
158 snprintf(buf, 0x7fffffff, \"%#x\", 0x12345678);
163 }" HAVE_LARGE_SNPRINTF_SUPPORT)
164 check_cxx_source_runs("
169 #include <sys/stat.h>
170 #include <sys/types.h>
171 #include <sys/time.h>
176 fd_set readFDs, writeFDs, exceptFDs;
177 struct timeval time = { 0 };
178 char * filename = NULL;
180 filename = (char *)malloc(L_tmpnam * sizeof(char)); /* ok to leak this at exit */
181 if (NULL == filename) {
185 /* On some platforms (e.g. HP-UX) the multithreading c-runtime does not
186 support the tmpnam(NULL) semantics, and it returns NULL. Therefore
187 we need to use the tmpnam(pbuffer) version.
189 if (NULL == tmpnam(filename)) {
192 if (mkfifo(filename, S_IRWXU) != 0) {
193 if (unlink(filename) != 0) {
196 if (mkfifo(filename, S_IRWXU) != 0) {
200 fd = open(filename, O_RDWR | O_NONBLOCK);
208 FD_SET(fd, &readFDs);
209 numFDs = select(fd + 1, &readFDs, &writeFDs, &exceptFDs, &time);
214 /* numFDs is zero if select() works correctly */
216 }" HAVE_BROKEN_FIFO_SELECT)
217 check_cxx_source_runs("
224 #include <sys/types.h>
225 #include <sys/event.h>
226 #include <sys/time.h>
227 #include <sys/stat.h>
234 struct kevent ke, keChangeList;
235 struct timespec ts = { 0, 0 };
237 char * filename = NULL;
239 filename = (char *)malloc(L_tmpnam * sizeof(char)); /* ok to leak this at exit */
240 if (NULL == filename)
245 /* On some platforms (e.g. HP-UX) the multithreading c-runtime does not
246 support the tmpnam(NULL) semantics, and it returns NULL. Therefore
247 we need to use the tmpnam(pbuffer) version.
249 if (NULL == tmpnam(filename)) {
252 if (mkfifo(filename, S_IRWXU) != 0) {
253 if (unlink(filename) != 0) {
256 if (mkfifo(filename, S_IRWXU) != 0) {
260 fd = open(filename, O_RDWR | O_NONBLOCK);
265 EV_SET(&keChangeList, fd, EVFILT_READ, EV_ADD | EV_CLEAR, 0, 0, NULL);
267 iRet = kevent(ikq, &keChangeList, 1, &ke, 1, &ts);
272 /* iRet is zero is kevent() works correctly */
274 }" HAVE_BROKEN_FIFO_KEVENT)
275 set(CMAKE_REQUIRED_LIBRARIES pthread)
276 check_cxx_source_runs("
285 struct sched_param schedParam;
289 if (0 != pthread_getschedparam(pthread_self(), &policy, &schedParam))
294 max_priority = sched_get_priority_max(policy);
295 min_priority = sched_get_priority_min(policy);
297 exit(-1 == max_priority || -1 == min_priority);
298 }" HAVE_SCHED_GET_PRIORITY)
299 set(CMAKE_REQUIRED_LIBRARIES pthread)
300 check_cxx_source_runs("
306 if (sched_getcpu() >= 0)
311 }" HAVE_SCHED_GETCPU)
312 set(CMAKE_REQUIRED_LIBRARIES)
313 check_cxx_source_runs("
316 #include <sys/time.h>
322 ret = gettimeofday(&tv, NULL);
325 }" HAVE_WORKING_GETTIMEOFDAY)
326 check_cxx_source_runs("
329 #include <sys/time.h>
335 ret = clock_gettime(CLOCK_REALTIME, &ts);
338 }" HAVE_WORKING_CLOCK_GETTIME)
339 check_cxx_source_runs("
342 #include <sys/time.h>
348 ret = clock_gettime(CLOCK_MONOTONIC, &ts);
351 }" HAVE_CLOCK_MONOTONIC)
352 check_cxx_source_runs("
355 #include <sys/time.h>
361 ret = clock_gettime(CLOCK_MONOTONIC_COARSE, &ts);
364 }" HAVE_CLOCK_MONOTONIC_COARSE)
365 check_cxx_source_runs("
367 #include <mach/mach_time.h>
372 mach_timebase_info_data_t timebaseInfo;
373 ret = mach_timebase_info(&timebaseInfo);
374 mach_absolute_time();
376 }" HAVE_MACH_ABSOLUTE_TIME)
377 check_cxx_source_runs("
380 #include <sys/time.h>
386 ret = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts);
389 }" HAVE_CLOCK_THREAD_CPUTIME)
390 check_cxx_source_runs("
392 #include <sys/types.h>
393 #include <sys/mman.h>
400 devzero = open(\"/dev/zero\", O_RDWR);
404 retval = mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, devzero, 0);
405 if (retval == (void *)-1) {
409 }" HAVE_MMAP_DEV_ZERO)
410 check_cxx_source_runs("
413 #include <sys/types.h>
414 #include <sys/mman.h>
418 #define MAP_ANON MAP_ANONYMOUS
426 pagesize = getpagesize();
427 fd = open(\"/etc/passwd\", O_RDONLY);
431 ptr = mmap(NULL, pagesize, PROT_NONE, MAP_ANON | MAP_PRIVATE, -1, 0);
432 if (ptr == MAP_FAILED) {
435 hint = mmap(NULL, pagesize, PROT_NONE, MAP_ANON | MAP_PRIVATE, -1, 0);
436 if (hint == MAP_FAILED) {
439 if (munmap(ptr, pagesize) != 0) {
442 if (munmap(hint, pagesize) != 0) {
445 ptr = mmap(hint, pagesize, PROT_NONE, MAP_FIXED | MAP_PRIVATE, fd, 0);
446 if (ptr == MAP_FAILED || ptr != hint) {
450 }" MMAP_IGNORES_HINT)
451 check_cxx_source_runs("
452 #include <sys/types.h>
453 #include <sys/mman.h>
459 #define MAP_ANON MAP_ANONYMOUS
462 void *handle_signal(int signal) {
463 /* If we reach this, we've crashed due to mmap honoring
470 struct sigaction action;
472 ptr = (int *) mmap(NULL, getpagesize(), PROT_NONE,
473 MAP_ANON | MAP_PRIVATE, -1, 0);
474 if (ptr == (int *) MAP_FAILED) {
477 action.sa_handler = &handle_signal;
479 sigemptyset(&action.sa_mask);
480 if (sigaction(SIGBUS, &action, NULL) != 0) {
483 if (sigaction(SIGSEGV, &action, NULL) != 0) {
486 /* This will drop us into the signal handler if PROT_NONE
490 }" MMAP_ANON_IGNORES_PROTECTION)
491 check_cxx_source_runs("
494 #include <sys/types.h>
495 #include <sys/mman.h>
498 #define MAP_ANON MAP_ANONYMOUS
504 void * pAddr = MAP_FAILED;
507 MemSize = getpagesize();
508 pAddr = mmap(0x0, MemSize, PROT_NONE, MAP_PRIVATE | MAP_ANON, -1, 0);
509 if (pAddr == MAP_FAILED)
512 pAddr = mmap(pAddr, MemSize, PROT_WRITE | PROT_READ, MAP_FIXED | MAP_PRIVATE | MAP_ANON, -1, 0);
513 if (pAddr == MAP_FAILED)
516 munmap(pAddr, MemSize); // don't care of this
518 }" MMAP_DOESNOT_ALLOW_REMAP)
519 check_cxx_source_runs("
524 #include <sys/types.h>
525 #include <sys/mman.h>
527 #define MEM_SIZE 1024
534 void * pAddr0, * pAddr1;
536 fname = (char *)malloc(MEM_SIZE);
539 strcpy(fname, \"/tmp/name/multiplemaptestXXXXXX\");
545 ret = write (fd, (void *)fname, MEM_SIZE);
549 pAddr0 = mmap(0, MEM_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
550 pAddr1 = mmap(0, MEM_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
552 /* In theory we should look for (pAddr1 == MAP_FAILED) && (pAddr1 != MAP_FAILED)
553 but in case the first test also failed, i.e. we failed to run the test,
554 let's assume that the system might not allow multiple shared mapping of the
555 same file region in the same process. The code enabled in this case is
556 only a fall-back code path. In case the double mmap actually works, virtually
557 nothing will change and the normal code path will be executed */
558 if (pAddr1 == MAP_FAILED)
564 munmap (pAddr0, MEM_SIZE);
566 munmap (pAddr1, MEM_SIZE);
572 }" ONE_SHARED_MAPPING_PER_FILEREGION_PER_PROCESS)
573 set(CMAKE_REQUIRED_LIBRARIES pthread)
574 check_cxx_source_runs("
579 void *start_routine(void *param) { return NULL; }
586 result = pthread_create(&tid, NULL, start_routine, NULL);
594 }" PTHREAD_CREATE_MODIFIES_ERRNO)
595 set(CMAKE_REQUIRED_LIBRARIES)
596 set(CMAKE_REQUIRED_LIBRARIES pthread)
597 check_cxx_source_runs("
599 #include <semaphore.h>
607 result = sem_init(&sema, 0, 0);
617 }" SEM_INIT_MODIFIES_ERRNO)
618 set(CMAKE_REQUIRED_LIBRARIES)
619 check_cxx_source_runs("
629 #elif defined(MAXPATHLEN)
630 char path[MAXPATHLEN];
635 sprintf(path, \"/proc/%u/$1\", getpid());
642 set(CMAKE_REQUIRED_LIBRARIES m)
643 check_cxx_source_runs("
648 if (!isnan(acos(10))) {
652 }" HAVE_COMPATIBLE_ACOS)
653 set(CMAKE_REQUIRED_LIBRARIES)
654 set(CMAKE_REQUIRED_LIBRARIES m)
655 check_cxx_source_runs("
660 if (!isnan(asin(10))) {
664 }" HAVE_COMPATIBLE_ASIN)
665 set(CMAKE_REQUIRED_LIBRARIES)
666 set(CMAKE_REQUIRED_LIBRARIES m)
667 check_cxx_source_runs("
672 double infinity = 1.0 / 0.0;
673 if (!isnan(pow(1.0, infinity))) {
676 if (pow(0.0, -1) != infinity) {
680 }" HAVE_COMPATIBLE_POW)
681 set(CMAKE_REQUIRED_LIBRARIES)
682 set(CMAKE_REQUIRED_LIBRARIES m)
683 check_cxx_source_runs("
687 int main(int argc, char **argv) {
690 result = pow(-3.2e-10, -5e14 + 1);
691 if (result != -1.0 / 0.0) {
695 }" HAVE_VALID_NEGATIVE_INF_POW)
696 set(CMAKE_REQUIRED_LIBRARIES)
697 set(CMAKE_REQUIRED_LIBRARIES m)
698 check_cxx_source_runs("
702 int main(int argc, char **argv) {
705 result = pow(-3.5, 3e100);
706 if (result != 1.0 / 0.0) {
710 }" HAVE_VALID_POSITIVE_INF_POW)
711 set(CMAKE_REQUIRED_LIBRARIES)
712 set(CMAKE_REQUIRED_LIBRARIES m)
713 check_cxx_source_runs("
718 double pi = 3.14159265358979323846;
721 result = atan2(0.0, -0.0);
722 if (fabs(pi - result) > 0.0000001) {
726 result = atan2(-0.0, -0.0);
727 if (fabs(-pi - result) > 0.0000001) {
731 result = atan2 (-0.0, 0.0);
732 if (result != 0.0 || copysign (1.0, result) > 0) {
736 result = atan2 (0.0, 0.0);
737 if (result != 0.0 || copysign (1.0, result) < 0) {
742 }" HAVE_COMPATIBLE_ATAN2)
743 set(CMAKE_REQUIRED_LIBRARIES)
744 set(CMAKE_REQUIRED_LIBRARIES m)
745 check_cxx_source_runs("
750 double d = exp(1.0), e = M_E;
752 /* Used memcmp rather than == to test that the doubles are equal to
753 prevent gcc's optimizer from using its 80 bit internal long
754 doubles. If you use ==, then on BSD you get a false negative since
755 exp(1.0) == M_E to 64 bits, but not 80.
758 if (memcmp (&d, &e, sizeof (double)) == 0) {
762 }" HAVE_COMPATIBLE_EXP)
763 set(CMAKE_REQUIRED_LIBRARIES)
764 set(CMAKE_REQUIRED_LIBRARIES m)
765 check_cxx_source_runs("
770 if (!isnan(log(-10000))) {
774 }" HAVE_COMPATIBLE_LOG)
775 set(CMAKE_REQUIRED_LIBRARIES)
776 set(CMAKE_REQUIRED_LIBRARIES m)
777 check_cxx_source_runs("
782 if (!isnan(log10(-10000))) {
786 }" HAVE_COMPATIBLE_LOG10)
787 set(CMAKE_REQUIRED_LIBRARIES)
788 check_cxx_source_runs("
799 szFileName = tempnam(\".\", \"tmp\");
801 /* open the file write-only */
802 pFile = fopen(szFileName, \"a\");
807 if (ungetc('A', pFile) != EOF)
813 }" UNGETC_NOT_RETURN_EOF)
814 set(CMAKE_REQUIRED_LIBRARIES pthread)
815 check_cxx_source_runs("
818 #include <semaphore.h>
822 if (sem_init(&sema, 0, 0) == -1){
826 }" HAS_POSIX_SEMAPHORES)
827 set(CMAKE_REQUIRED_LIBRARIES)
828 check_cxx_source_runs("
829 #include <sys/types.h>
837 struct passwd sPasswd;
838 struct passwd *pPasswd;
840 int bufLen = sizeof(buf)/sizeof(buf[0]);
841 int euid = geteuid();
844 errno = 0; // clear errno
845 ret = getpwuid_r(euid, &sPasswd, buf, bufLen, &pPasswd);
854 return 1; // assume errno is NOT set for all other cases
855 }" GETPWUID_R_SETS_ERRNO)
856 check_cxx_source_runs("
863 char *fileName = \"/dev/zero\";
867 * Open the file in append mode and try to read some text.
868 * And, make sure ferror() is set.
870 fp = fopen (fileName, \"a\");
872 (fread (buf, sizeof(buf), 1, fp) > 0) ||
880 * Now that ferror() is set, try to close the file.
881 * If we get an error, we can conclude that this
882 * fgets() depended on the previous ferror().
884 if ( fclose(fp) != 0 )
890 }" FILE_OPS_CHECK_FERROR_OF_PREVIOUS_CALL)
891 set(CMAKE_REQUIRED_DEFINITIONS)
893 set(SYNCHMGR_SUSPENSION_SAFE_CONDITION_SIGNALING 1)
894 set(ERROR_FUNC_FOR_GLOB_HAS_FIXED_PARAMS 1)
896 check_cxx_source_compiles("
897 #include <libunwind.h>
898 #include <ucontext.h>
900 int main(int argc, char **argv)
902 unw_context_t libUnwindContext;
905 libUnwindContext = uContext;
907 }" UNWIND_CONTEXT_IS_UCONTEXT_T)
909 if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
910 if(NOT HAVE_LIBUUID_H)
911 unset(HAVE_LIBUUID_H CACHE)
912 message(FATAL_ERROR "Cannot find libuuid. Try installing uuid-dev or the appropriate packages for your platform")
914 set(HAVE_COREFOUNDATION 1)
915 set(HAVE__NSGETENVIRON 1)
916 set(DEADLOCK_WHEN_THREAD_IS_SUSPENDED_WHILE_BLOCKED_ON_MUTEX 1)
917 set(PAL_PTRACE "ptrace((cmd), (pid), (caddr_t)(addr), (data))")
918 set(PAL_PT_ATTACH PT_ATTACH)
919 set(PAL_PT_DETACH PT_DETACH)
920 set(PAL_PT_READ_D PT_READ_D)
921 set(PAL_PT_WRITE_D PT_WRITE_D)
922 set(HAS_FTRUNCATE_LENGTH_ISSUE 1)
923 elseif(CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
924 if(NOT HAVE_LIBUNWIND_H)
925 unset(HAVE_LIBUNWIND_H CACHE)
926 message(FATAL_ERROR "Cannot find libunwind. Try installing libunwind8 and libunwind8-dev (or the appropriate packages for your platform)")
928 if(NOT HAVE_BSD_UUID_H)
929 unset(HAVE_BSD_UUID_H CACHE)
930 message(FATAL_ERROR "Cannot find uuid.h")
932 set(DEADLOCK_WHEN_THREAD_IS_SUSPENDED_WHILE_BLOCKED_ON_MUTEX 0)
933 set(PAL_PTRACE "ptrace((cmd), (pid), (caddr_t)(addr), (data))")
934 set(PAL_PT_ATTACH PT_ATTACH)
935 set(PAL_PT_DETACH PT_DETACH)
936 set(PAL_PT_READ_D PT_READ_D)
937 set(PAL_PT_WRITE_D PT_WRITE_D)
938 set(HAS_FTRUNCATE_LENGTH_ISSUE 0)
940 if(EXISTS "/lib/libc.so.7")
941 set(FREEBSD_LIBC "/lib/libc.so.7")
943 message(FATAL_ERROR "Cannot find libc on this system.")
946 elseif(CMAKE_SYSTEM_NAME STREQUAL NetBSD)
947 if(NOT HAVE_LIBUNWIND_H)
948 unset(HAVE_LIBUNWIND_H CACHE)
949 message(WARNING "Cannot find libunwind. Try installing libunwind8 and libunwind8-dev (or the appropriate packages for your platform)")
951 if(NOT HAVE_BSD_UUID_H)
952 unset(HAVE_BSD_UUID_H CACHE)
953 message(FATAL_ERROR "Cannot find uuid.h")
955 set(DEADLOCK_WHEN_THREAD_IS_SUSPENDED_WHILE_BLOCKED_ON_MUTEX 0)
956 set(PAL_PTRACE "ptrace((cmd), (pid), (void*)(addr), (data))")
957 set(PAL_PT_ATTACH PT_ATTACH)
958 set(PAL_PT_DETACH PT_DETACH)
959 set(PAL_PT_READ_D PT_READ_D)
960 set(PAL_PT_WRITE_D PT_WRITE_D)
961 set(HAS_FTRUNCATE_LENGTH_ISSUE 0)
963 elseif(CMAKE_SYSTEM_NAME STREQUAL SunOS)
964 if(NOT HAVE_LIBUNWIND_H)
965 unset(HAVE_LIBUNWIND_H CACHE)
966 message(FATAL_ERROR "Cannot find libunwind. Try installing libunwind8 and libunwind8-dev (or the appropriate packages for your platform)")
968 if(NOT HAVE_LIBUUID_H)
969 unset(HAVE_LIBUUID_H CACHE)
970 message(FATAL_ERROR "Cannot find libuuid. Try installing uuid-dev or the appropriate packages for your platform")
972 set(DEADLOCK_WHEN_THREAD_IS_SUSPENDED_WHILE_BLOCKED_ON_MUTEX 0)
973 set(PAL_PTRACE "ptrace((cmd), (pid), (caddr_t)(addr), (data))")
974 set(PAL_PT_ATTACH PT_ATTACH)
975 set(PAL_PT_DETACH PT_DETACH)
976 set(PAL_PT_READ_D PT_READ_D)
977 set(PAL_PT_WRITE_D PT_WRITE_D)
978 set(HAS_FTRUNCATE_LENGTH_ISSUE 0)
979 else() # Anything else is Linux
980 if(NOT HAVE_LIBUNWIND_H)
981 unset(HAVE_LIBUNWIND_H CACHE)
982 message(FATAL_ERROR "Cannot find libunwind. Try installing libunwind8 and libunwind8-dev (or the appropriate packages for your platform)")
984 if(NOT HAVE_LTTNG_TRACEPOINT_H)
985 unset(HAVE_LTTNG_TRACEPOINT_H CACHE)
986 message(FATAL_ERROR "Cannot find liblttng-ust-dev. Try installing liblttng-ust-dev (or the appropriate packages for your platform)")
988 if(NOT HAVE_LIBUUID_H)
989 unset(HAVE_LIBUUID_H CACHE)
990 message(FATAL_ERROR "Cannot find libuuid. Try installing uuid-dev or the appropriate packages for your platform")
992 set(DEADLOCK_WHEN_THREAD_IS_SUSPENDED_WHILE_BLOCKED_ON_MUTEX 0)
993 set(PAL_PTRACE "ptrace((cmd), (pid), (void*)(addr), (data))")
994 set(PAL_PT_ATTACH PTRACE_ATTACH)
995 set(PAL_PT_DETACH PTRACE_DETACH)
996 set(PAL_PT_READ_D PTRACE_PEEKDATA)
997 set(PAL_PT_WRITE_D PTRACE_POKEDATA)
998 set(HAS_FTRUNCATE_LENGTH_ISSUE 0)
999 endif(CMAKE_SYSTEM_NAME STREQUAL Darwin)
1001 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)