-
Notifications
You must be signed in to change notification settings - Fork 4.8k
/
configure.cmake
1136 lines (961 loc) · 24.6 KB
/
configure.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
include(CheckCCompilerFlag)
include(CheckCSourceCompiles)
include(CheckCSourceRuns)
include(CheckIncludeFiles)
include(CheckPrototypeDefinition)
include(CheckStructHasMember)
include(CheckSymbolExists)
include(CheckTypeSize)
include(CheckLibraryExists)
include(CheckFunctionExists)
if (CLR_CMAKE_TARGET_OSX)
# Xcode's clang does not include /usr/local/include by default, but brew's does.
# This ensures an even playing field.
include_directories(SYSTEM /usr/local/include)
add_compile_options(-Wno-poison-system-directories)
elseif (CLR_CMAKE_TARGET_FREEBSD)
include_directories(SYSTEM ${CROSS_ROOTFS}/usr/local/include)
set(CMAKE_REQUIRED_INCLUDES ${CROSS_ROOTFS}/usr/local/include)
elseif (CLR_CMAKE_TARGET_SUNOS)
# requires /opt/tools when building in Global Zone (GZ)
include_directories(SYSTEM /opt/local/include /opt/tools/include)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector")
endif ()
if(CLR_CMAKE_USE_SYSTEM_LIBUNWIND)
# This variable can be set and used by the coreclr and installer builds.
# Libraries doesn't need it, but not using it makes the build fail. So
# just check and ignore the variable.
endif()
# We compile with -Werror, so we need to make sure these code fragments compile without warnings.
# Older CMake versions (3.8) do not assign the result of their tests, causing unused-value errors
# which are not distinguished from the test failing. So no error for that one.
# For clang-5.0 avoid errors like "unused variable 'err' [-Werror,-Wunused-variable]".
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror -Wno-error=unused-value -Wno-error=unused-variable")
if (CMAKE_C_COMPILER_ID MATCHES "Clang")
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Wno-error=builtin-requires-header")
endif()
# Apple platforms like macOS/iOS allow targeting older operating system versions with a single SDK,
# the mere presence of a symbol in the SDK doesn't tell us whether the deployment target really supports it.
# The compiler raises a warning when using an unsupported API, turn that into an error so check_symbol_exists()
# can correctly identify whether the API is supported on the target.
check_c_compiler_flag("-Wunguarded-availability" "C_SUPPORTS_WUNGUARDED_AVAILABILITY")
if(C_SUPPORTS_WUNGUARDED_AVAILABILITY)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Wunguarded-availability")
endif()
# in_pktinfo: Find whether this struct exists
check_include_files(
"sys/socket.h;linux/in.h"
HAVE_LINUX_IN_H)
if (HAVE_LINUX_IN_H)
set (SOCKET_INCLUDES linux/in.h)
else ()
set (SOCKET_INCLUDES netinet/in.h)
endif ()
check_c_source_compiles(
"
#include <sys/socket.h>
#include <${SOCKET_INCLUDES}>
int main(void)
{
struct in_pktinfo pktinfo;
return 0;
}
"
HAVE_IN_PKTINFO)
check_c_source_compiles(
"
#include <sys/socket.h>
#include <${SOCKET_INCLUDES}>
int main(void)
{
struct ip_mreqn mreqn;
return 0;
}
"
HAVE_IP_MREQN)
# /in_pktinfo
check_c_source_compiles(
"
#include <sys/vfs.h>
int main(void)
{
struct statfs s;
return 0;
}
"
HAVE_STATFS_VFS)
check_c_source_compiles(
"
#include <sys/mount.h>
int main(void)
{
struct statfs s;
return 0;
}
"
HAVE_STATFS_MOUNT)
check_c_source_compiles(
"
#include <fcntl.h>
int main(void)
{
struct flock64 l;
return 0;
}
"
HAVE_FLOCK64)
check_symbol_exists(
O_CLOEXEC
fcntl.h
HAVE_O_CLOEXEC)
check_symbol_exists(
F_DUPFD_CLOEXEC
fcntl.h
HAVE_F_DUPFD_CLOEXEC)
check_symbol_exists(
F_DUPFD
fcntl.h
HAVE_F_DUPFD)
check_symbol_exists(
F_FULLFSYNC
fcntl.h
HAVE_F_FULLFSYNC)
check_function_exists(
getifaddrs
HAVE_GETIFADDRS)
check_symbol_exists(
fork
unistd.h
HAVE_FORK)
check_symbol_exists(
lseek64
unistd.h
HAVE_LSEEK64)
check_symbol_exists(
mmap64
sys/mman.h
HAVE_MMAP64)
check_symbol_exists(
ftruncate64
unistd.h
HAVE_FTRUNCATE64)
check_symbol_exists(
posix_fadvise64
fcntl.h
HAVE_POSIX_FADVISE64)
check_symbol_exists(
stat64
sys/stat.h
HAVE_STAT64)
check_symbol_exists(
vfork
unistd.h
HAVE_VFORK)
check_symbol_exists(
pipe
unistd.h
HAVE_PIPE)
check_symbol_exists(
pipe2
unistd.h
HAVE_PIPE2)
check_symbol_exists(
getmntinfo
sys/mount.h
HAVE_MNTINFO)
check_symbol_exists(
strcpy_s
string.h
HAVE_STRCPY_S)
check_symbol_exists(
strlcat
string.h
HAVE_STRLCAT)
check_symbol_exists(
posix_fadvise
fcntl.h
HAVE_POSIX_ADVISE)
check_symbol_exists(
fallocate
fcntl.h
HAVE_FALLOCATE)
check_symbol_exists(
preadv
sys/uio.h
HAVE_PREADV)
check_symbol_exists(
pwritev
sys/uio.h
HAVE_PWRITEV)
check_symbol_exists(
ioctl
sys/ioctl.h
HAVE_IOCTL)
check_symbol_exists(
sched_getaffinity
"sched.h"
HAVE_SCHED_GETAFFINITY)
check_symbol_exists(
sched_setaffinity
"sched.h"
HAVE_SCHED_SETAFFINITY)
check_symbol_exists(
sched_getcpu
"sched.h"
HAVE_SCHED_GETCPU)
check_symbol_exists(
pthread_setcancelstate
"pthread.h"
HAVE_PTHREAD_SETCANCELSTATE)
check_include_files(
gnu/lib-names.h
HAVE_GNU_LIBNAMES_H)
check_symbol_exists(
TIOCGWINSZ
"sys/ioctl.h"
HAVE_TIOCGWINSZ)
check_symbol_exists(
cfsetspeed
termios.h
HAVE_CFSETSPEED)
check_symbol_exists(
cfmakeraw
termios.h
HAVE_CFMAKERAW)
check_struct_has_member(
"struct utsname"
domainname
"sys/utsname.h"
HAVE_UTSNAME_DOMAINNAME)
check_struct_has_member(
"struct stat"
st_birthtimespec
"sys/types.h;sys/stat.h"
HAVE_STAT_BIRTHTIME)
check_struct_has_member(
"struct stat"
st_flags
"sys/types.h;sys/stat.h"
HAVE_STAT_FLAGS)
check_symbol_exists(
lchflags
"sys/types.h;sys/stat.h"
HAVE_LCHFLAGS)
check_struct_has_member(
"struct stat"
st_atimespec
"sys/types.h;sys/stat.h"
HAVE_STAT_TIMESPEC)
check_struct_has_member(
"struct stat"
st_atim
"sys/types.h;sys/stat.h"
HAVE_STAT_TIM)
check_struct_has_member(
"struct stat"
st_atimensec
"sys/types.h;sys/stat.h"
HAVE_STAT_NSEC)
check_struct_has_member(
"struct dirent"
d_namlen
"dirent.h"
HAVE_DIRENT_NAME_LEN)
check_struct_has_member(
"struct statfs"
f_fstypename
"sys/mount.h"
HAVE_STATFS_FSTYPENAME)
check_struct_has_member(
"struct statvfs"
f_fstypename
"sys/mount.h"
HAVE_STATVFS_FSTYPENAME)
set(CMAKE_EXTRA_INCLUDE_FILES dirent.h)
# statfs: Find whether this struct exists
if (HAVE_STATFS_FSTYPENAME OR HAVE_STATVFS_FSTYPENAME)
set (STATFS_INCLUDES sys/mount.h)
else ()
set (STATFS_INCLUDES sys/statfs.h)
endif ()
set(CMAKE_EXTRA_INCLUDE_FILES ${STATFS_INCLUDES})
check_symbol_exists(
"statfs"
${STATFS_INCLUDES}
HAVE_STATFS)
check_symbol_exists(
"getrlimit"
"sys/resource.h"
HAVE_GETRLIMIT)
check_symbol_exists(
"setrlimit"
"sys/resource.h"
HAVE_SETRLIMIT)
check_type_size(
"struct statfs"
STATFS_SIZE
BUILTIN_TYPES_ONLY)
set(CMAKE_EXTRA_INCLUDE_FILES) # reset CMAKE_EXTRA_INCLUDE_FILES
# /statfs
check_c_source_compiles(
"
#include <string.h>
int main(void)
{
char buffer[1];
char c = *strerror_r(0, buffer, 0);
return 0;
}
"
HAVE_GNU_STRERROR_R)
check_c_source_compiles(
"
#include <dirent.h>
#include <stddef.h>
int main(void)
{
DIR* dir = NULL;
struct dirent* entry = NULL;
struct dirent* result;
readdir_r(dir, entry, &result);
return 0;
}
"
HAVE_READDIR_R)
check_c_source_compiles(
"
#include <sys/types.h>
#include <sys/event.h>
int main(void)
{
struct kevent event;
void* data;
EV_SET(&event, 0, EVFILT_READ, 0, 0, 0, data);
return 0;
}
"
KEVENT_HAS_VOID_UDATA)
# do not use sendfile() on iOS/tvOS, it causes SIGSYS at runtime on devices
if(NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS)
check_c_source_compiles(
"
#include <sys/sendfile.h>
int main(void) { int i = sendfile(0, 0, 0, 0); return 0; }
"
HAVE_SENDFILE_4)
check_c_source_compiles(
"
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/uio.h>
int main(void) { int i = sendfile(0, 0, 0, NULL, NULL, 0); return 0; }
"
HAVE_SENDFILE_6)
check_c_source_compiles(
"
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/uio.h>
int main(void) { int i = sendfile(0, 0, 0, 0, NULL, NULL, 0); return 0; }
"
HAVE_SENDFILE_7)
endif()
check_symbol_exists(
fcopyfile
copyfile.h
HAVE_FCOPYFILE)
check_include_files(
"sys/sockio.h"
HAVE_SYS_SOCKIO_H)
check_include_files(
"linux/ethtool.h"
HAVE_ETHTOOL_H)
check_include_files(
"sys/poll.h"
HAVE_SYS_POLL_H)
check_include_files(
"sys/proc_info.h"
HAVE_SYS_PROCINFO_H)
check_include_files(
"time.h;linux/errqueue.h"
HAVE_LINUX_ERRQUEUE_H)
check_symbol_exists(
epoll_create1
sys/epoll.h
HAVE_EPOLL)
check_symbol_exists(
gethostname
unistd.h
HAVE_GETHOSTNAME)
check_symbol_exists(
getnameinfo
netdb.h
HAVE_GETNAMEINFO)
check_struct_has_member("struct sockaddr_un" sun_path "sys/types.h;sys/un.h" HAVE_SOCKADDR_UN_SUN_PATH)
check_symbol_exists(
accept4
sys/socket.h
HAVE_ACCEPT4)
set(PREVIOUS_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
if(CLR_CMAKE_TARGET_HAIKU)
set(CMAKE_REQUIRED_LIBRARIES "bsd")
endif()
check_symbol_exists(
kqueue
"sys/types.h;sys/event.h"
HAVE_KQUEUE)
set(CMAKE_REQUIRED_LIBRARIES ${PREVIOUS_CMAKE_REQUIRED_LIBRARIES})
check_symbol_exists(
disconnectx
"sys/socket.h"
HAVE_DISCONNECTX)
check_symbol_exists(
connectx
"sys/socket.h"
HAVE_CONNECTX)
set(PREVIOUS_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
set(CMAKE_REQUIRED_FLAGS "-Werror -Wsign-conversion")
check_c_source_compiles(
"
#include <stddef.h>
#include <sys/types.h>
#include <netdb.h>
int main(void)
{
const struct sockaddr *addr;
socklen_t addrlen = 0;
char *host = NULL;
socklen_t hostlen = 0;
char *serv = NULL;
socklen_t servlen = 0;
int flags = 0;
int result = getnameinfo(addr, addrlen, host, hostlen, serv, servlen, flags);
return 0;
}
"
HAVE_GETNAMEINFO_SIGNED_FLAGS)
set(CMAKE_REQUIRED_FLAGS ${PREVIOUS_CMAKE_REQUIRED_FLAGS})
set(HAVE_SUPPORT_FOR_DUAL_MODE_IPV4_PACKET_INFO 0)
if (CLR_CMAKE_TARGET_LINUX)
if (NOT CLR_CMAKE_TARGET_ANDROID)
set(CMAKE_REQUIRED_LIBRARIES rt)
endif ()
set(HAVE_SUPPORT_FOR_DUAL_MODE_IPV4_PACKET_INFO 1)
endif ()
check_symbol_exists(
malloc_size
malloc/malloc.h
HAVE_MALLOC_SIZE)
check_symbol_exists(
malloc_usable_size
malloc.h
HAVE_MALLOC_USABLE_SIZE)
check_symbol_exists(
malloc_usable_size
malloc_np.h
HAVE_MALLOC_USABLE_SIZE_NP)
check_symbol_exists(
posix_memalign
stdlib.h
HAVE_POSIX_MEMALIGN)
if(CLR_CMAKE_TARGET_IOS)
# Manually set results from check_c_source_runs() since it's not possible to actually run it during CMake configure checking
unset(HAVE_SHM_OPEN_THAT_WORKS_WELL_ENOUGH_WITH_MMAP)
unset(HAVE_ALIGNED_ALLOC) # only exists on iOS 13+
set(HAVE_CLOCK_MONOTONIC 1)
set(HAVE_CLOCK_REALTIME 1)
unset(HAVE_FORK) # exists but blocked by kernel
elseif(CLR_CMAKE_TARGET_MACCATALYST)
# Manually set results from check_c_source_runs() since it's not possible to actually run it during CMake configure checking
unset(HAVE_SHM_OPEN_THAT_WORKS_WELL_ENOUGH_WITH_MMAP)
unset(HAVE_ALIGNED_ALLOC) # only exists on iOS 13+
set(HAVE_CLOCK_MONOTONIC 1)
set(HAVE_CLOCK_REALTIME 1)
unset(HAVE_FORK) # exists but blocked by kernel
elseif(CLR_CMAKE_TARGET_TVOS)
# Manually set results from check_c_source_runs() since it's not possible to actually run it during CMake configure checking
unset(HAVE_SHM_OPEN_THAT_WORKS_WELL_ENOUGH_WITH_MMAP)
unset(HAVE_ALIGNED_ALLOC) # only exists on iOS 13+
set(HAVE_CLOCK_MONOTONIC 1)
set(HAVE_CLOCK_REALTIME 1)
unset(HAVE_FORK) # exists but blocked by kernel
elseif(CLR_CMAKE_TARGET_ANDROID)
# Manually set results from check_c_source_runs() since it's not possible to actually run it during CMake configure checking
unset(HAVE_SHM_OPEN_THAT_WORKS_WELL_ENOUGH_WITH_MMAP)
unset(HAVE_ALIGNED_ALLOC) # only exists on newer Android
set(HAVE_CLOCK_MONOTONIC 1)
set(HAVE_CLOCK_REALTIME 1)
elseif(CLR_CMAKE_TARGET_WASI)
set(HAVE_FORK 0)
unset(HAVE_GETNAMEINFO) # WASIp2 libc has empty function with TODO and abort()
elseif(CLR_CMAKE_TARGET_BROWSER)
set(HAVE_FORK 0)
else()
check_symbol_exists(
aligned_alloc
stdlib.h
HAVE_ALIGNED_ALLOC)
check_c_source_runs(
"
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
int main(void)
{
int fd = shm_open(\"/corefx_configure_shm_open\", O_CREAT | O_RDWR, 0777);
if (fd == -1)
return -1;
shm_unlink(\"/corefx_configure_shm_open\");
// NOTE: PROT_EXEC and MAP_PRIVATE don't work well with shm_open
// on at least the current version of Mac OS X
if (mmap(NULL, 1, PROT_EXEC, MAP_PRIVATE, fd, 0) == MAP_FAILED)
return -1;
return 0;
}
"
HAVE_SHM_OPEN_THAT_WORKS_WELL_ENOUGH_WITH_MMAP)
check_c_source_runs(
"
#include <stdlib.h>
#include <time.h>
#include <sys/time.h>
int main(void)
{
int ret;
struct timespec ts;
ret = clock_gettime(CLOCK_MONOTONIC, &ts);
exit(ret);
return 0;
}
"
HAVE_CLOCK_MONOTONIC)
check_c_source_runs(
"
#include <stdlib.h>
#include <time.h>
#include <sys/time.h>
int main(void)
{
int ret;
struct timespec ts;
ret = clock_gettime(CLOCK_REALTIME, &ts);
exit(ret);
return 0;
}
"
HAVE_CLOCK_REALTIME)
endif()
check_symbol_exists(
clock_gettime_nsec_np
time.h
HAVE_CLOCK_GETTIME_NSEC_NP)
check_library_exists(pthread pthread_create "" HAVE_LIBPTHREAD)
check_library_exists(c pthread_create "" HAVE_PTHREAD_IN_LIBC)
if (HAVE_LIBPTHREAD)
set(PTHREAD_LIBRARY pthread)
elseif (HAVE_PTHREAD_IN_LIBC)
set(PTHREAD_LIBRARY c)
endif()
if (NOT CLR_CMAKE_TARGET_WASI)
check_library_exists(${PTHREAD_LIBRARY} pthread_condattr_setclock "" HAVE_PTHREAD_CONDATTR_SETCLOCK)
endif()
check_symbol_exists(
futimes
sys/time.h
HAVE_FUTIMES)
check_symbol_exists(
futimens
sys/stat.h
HAVE_FUTIMENS)
check_symbol_exists(
fchmod
sys/stat.h
HAVE_FCHMOD)
check_symbol_exists(
chmod
sys/stat.h
HAVE_CHMOD)
check_symbol_exists(
utimensat
sys/stat.h
HAVE_UTIMENSAT)
check_symbol_exists(
lutimes
sys/time.h
HAVE_LUTIMES)
set (PREVIOUS_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
set (CMAKE_REQUIRED_FLAGS "-Werror -Wsign-conversion")
check_c_source_compiles(
"
#include <netinet/in.h>
#include <netinet/tcp.h>
int main(void)
{
struct ipv6_mreq opt;
unsigned int index = 0;
opt.ipv6mr_interface = index;
return 0;
}
"
IPV6MR_INTERFACE_UNSIGNED)
check_include_files(
"sys/inotify.h"
HAVE_SYS_INOTIFY_H)
check_c_source_compiles(
"
#include <sys/inotify.h>
int main(void)
{
intptr_t fd;
uint32_t wd;
return inotify_rm_watch(fd, wd);
}
"
INOTIFY_RM_WATCH_WD_UNSIGNED)
set (CMAKE_REQUIRED_FLAGS ${PREVIOUS_CMAKE_REQUIRED_FLAGS})
check_prototype_definition(
getpriority
"int getpriority(int which, int who)"
0
"sys/resource.h"
PRIORITY_REQUIRES_INT_WHO)
check_prototype_definition(
kevent
"int kevent(int kg, const struct kevent* chagelist, int nchanges, struct kevent* eventlist, int nevents, const struct timespec* timeout)"
0
"sys/types.h;sys/event.h"
KEVENT_REQUIRES_INT_PARAMS)
check_prototype_definition(
statfs
"int statfs(const char *path, struct statfs *buf)"
0
${STATFS_INCLUDES}
HAVE_NON_LEGACY_STATFS)
check_prototype_definition(
ioctl
"int ioctl(int fd, int request, ...)"
0
"sys/ioctl.h"
HAVE_IOCTL_WITH_INT_REQUEST)
check_c_source_compiles(
"
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
int main(void)
{
return mkstemps(\"abc\", 3);
}
"
HAVE_MKSTEMPS)
check_c_source_compiles(
"
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
int main(void)
{
return mkstemp(\"abc\");
}
"
HAVE_MKSTEMP)
if (NOT HAVE_MKSTEMPS AND NOT HAVE_MKSTEMP AND NOT CLR_CMAKE_TARGET_WASI)
message(FATAL_ERROR "Cannot find mkstemps nor mkstemp on this platform.")
endif()
check_c_source_compiles(
"
#include <sys/types.h>
#include <sys/socketvar.h>
#include <sys/queue.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/tcp.h>
#include <netinet/tcp_var.h>
int main(void) { return 0; }
"
HAVE_NETINET_TCP_VAR_H)
check_c_source_compiles(
"
#include <sys/types.h>
#include <sys/socketvar.h>
#include <sys/queue.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/ip_var.h>
#include <netinet/udp.h>
#include <netinet/udp_var.h>
int main(void) { return 0; }
"
HAVE_NETINET_UDP_VAR_H)
check_c_source_compiles(
"
#include <sys/types.h>
#include <sys/socketvar.h>
#include <sys/queue.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/ip_var.h>
int main(void) { return 0; }
"
HAVE_NETINET_IP_VAR_H)
check_c_source_compiles(
"
#include <sys/types.h>
#include <sys/socketvar.h>
#include <sys/queue.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
#include <netinet/icmp_var.h>
int main(void) { return 0; }
"
HAVE_NETINET_ICMP_VAR_H)
check_include_files(
sys/cdefs.h
HAVE_SYS_CDEFS_H)
if (HAVE_SYS_CDEFS_H)
set(CMAKE_REQUIRED_DEFINITIONS "-DHAVE_SYS_CDEFS_H")
endif()
# If sys/cdefs is not included on Android, this check will fail because
# __BEGIN_DECLS is not defined
check_c_source_compiles(
"
#ifdef HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
#endif
#include <netinet/tcp.h>
int main(void) { int x = TCP_ESTABLISHED; return x; }
"
HAVE_TCP_H_TCPSTATE_ENUM)
set(CMAKE_REQUIRED_DEFINITIONS)
check_symbol_exists(
TCPS_ESTABLISHED
"netinet/tcp_fsm.h"
HAVE_TCP_FSM_H)
check_symbol_exists(
getgrouplist
"unistd.h;grp.h"
HAVE_GETGROUPLIST)
check_include_files(
"syslog.h"
HAVE_SYSLOG_H)
check_include_files(
"termios.h"
HAVE_TERMIOS_H)
check_include_files(
"dlfcn.h"
HAVE_DLFCN_H)
check_include_files(
"sys/statvfs.h"
HAVE_SYS_STATVFS_H)
check_include_files(
"net/if.h"
HAVE_NET_IF_H)
check_include_files(
"pthread.h"
HAVE_PTHREAD_H)
if(CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS)
set(HAVE_IOS_NET_ROUTE_H 1)
set(HAVE_IOS_NET_IFMEDIA_H 1)
set(HAVE_IOS_NETINET_TCPFSM_H 1)
set(HAVE_IOS_NETINET_IP_VAR_H 1)
set(HAVE_IOS_NETINET_ICMP_VAR_H 1)
set(HAVE_IOS_NETINET_UDP_VAR_H 1)
set(CMAKE_EXTRA_INCLUDE_FILES
sys/types.h
"${CMAKE_CURRENT_SOURCE_DIR}/System.Native/ios/net/route.h"
)
else()
set(CMAKE_EXTRA_INCLUDE_FILES sys/types.h net/if.h net/route.h)
endif()
check_type_size(
"struct rt_msghdr"
HAVE_RT_MSGHDR
BUILTIN_TYPES_ONLY)
check_type_size(
"struct rt_msghdr2"
HAVE_RT_MSGHDR2
BUILTIN_TYPES_ONLY)
set(CMAKE_EXTRA_INCLUDE_FILES) # reset CMAKE_EXTRA_INCLUDE_FILES
set(CMAKE_EXTRA_INCLUDE_FILES net/if.h)
check_type_size(
"struct if_msghdr2"
HAVE_IF_MSGHDR2
BUILTIN_TYPES_ONLY)
set(CMAKE_EXTRA_INCLUDE_FILES) # reset CMAKE_EXTRA_INCLUDE_FILES
if (CLR_CMAKE_TARGET_LINUX)
# sysctl is deprecated on Linux
set(HAVE_SYS_SYSCTL_H 0)
else ()
check_include_files(
"sys/types.h;sys/sysctl.h"
HAVE_SYS_SYSCTL_H)
endif()
check_include_files(
"sys/ioctl.h"
HAVE_SYS_IOCTL_H)
check_include_files(
"sys/filio.h"
HAVE_SYS_FILIO_H)
check_include_files(
"sys/types.h;netpacket/packet.h"
HAVE_NETPACKET_PACKET_H)
check_include_files(
"net/if_arp.h"
HAVE_NET_IF_ARP_H)
check_include_files(
"sys/mntent.h"
HAVE_SYS_MNTENT_H)
check_include_files(
"stdint.h;net/if_media.h"
HAVE_NET_IFMEDIA_H)
check_include_files(
linux/rtnetlink.h
HAVE_LINUX_RTNETLINK_H)
check_include_files(
linux/can.h
HAVE_LINUX_CAN_H)
check_include_files(
IOKit/serial/ioss.h
HAVE_IOSS_H)
check_symbol_exists(
getpeereid
unistd.h
HAVE_GETPEEREID)
check_symbol_exists(
getdomainname
unistd.h
HAVE_GETDOMAINNAME)
# getdomainname on OSX takes an 'int' instead of a 'size_t'
# check if compiling with 'size_t' would cause a warning
set (PREVIOUS_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
set (CMAKE_REQUIRED_FLAGS "-Werror -Weverything")
check_c_source_compiles(
"
#include <unistd.h>
int main(void)
{
size_t namelen = 20;
char name[20];
int dummy = getdomainname(name, namelen);
(void)dummy;
return 0;
}
"
HAVE_GETDOMAINNAME_SIZET)