@@ -2185,10 +2185,21 @@ if not has_malloc_trim and get_option('malloc_trim').enabled()
2185
2185
endif
2186
2186
endif
2187
2187
2188
- gnu_source_prefix = '''
2188
+ osdep_prefix = '''
2189
2189
#ifndef _GNU_SOURCE
2190
2190
#define _GNU_SOURCE
2191
2191
#endif
2192
+
2193
+ #include <stddef.h>
2194
+ #include <sys/types.h>
2195
+
2196
+ #include <limits.h>
2197
+ /* Put unistd.h before time.h as that triggers localtime_r/gmtime_r
2198
+ * function availability on recentish Mingw-w64 platforms. */
2199
+ #include <unistd.h>
2200
+ #include <time.h>
2201
+ #include <errno.h>
2202
+ #include <fcntl.h>
2192
2203
'''
2193
2204
2194
2205
have_vhost_user_blk_server = get_option (' vhost_user_blk_server' ) \
@@ -2703,7 +2714,7 @@ config_host_data.set('CONFIG_FIEMAP',
2703
2714
cc.has_header(' linux/fiemap.h' ) and
2704
2715
cc.has_header_symbol(' linux/fs.h' , ' FS_IOC_FIEMAP' ))
2705
2716
config_host_data.set(' CONFIG_GETCPU' ,
2706
- cc.has_header_symbol(' sched.h' , ' getcpu' , prefix : gnu_source_prefix ))
2717
+ cc.has_header_symbol(' sched.h' , ' getcpu' , prefix : osdep_prefix ))
2707
2718
config_host_data.set(' CONFIG_GETRANDOM' ,
2708
2719
cc.has_function(' getrandom' ) and
2709
2720
cc.has_header_symbol(' sys/random.h' , ' GRND_NONBLOCK' ))
@@ -2748,8 +2759,7 @@ config_host_data.set('HAVE_UTMPX',
2748
2759
config_host_data.set(' CONFIG_EVENTFD' , cc.links('''
2749
2760
#include <sys/eventfd.h>
2750
2761
int main(void) { return eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC); }''' ))
2751
- config_host_data.set(' CONFIG_FDATASYNC' , cc.links(gnu_source_prefix + '''
2752
- #include <unistd.h>
2762
+ config_host_data.set(' CONFIG_FDATASYNC' , cc.links(osdep_prefix + '''
2753
2763
int main(void) {
2754
2764
#if defined(_POSIX_SYNCHRONIZED_IO) && _POSIX_SYNCHRONIZED_IO > 0
2755
2765
return fdatasync(0);
@@ -2758,10 +2768,8 @@ config_host_data.set('CONFIG_FDATASYNC', cc.links(gnu_source_prefix + '''
2758
2768
#endif
2759
2769
}''' ))
2760
2770
2761
- has_madvise = cc.links(gnu_source_prefix + '''
2762
- #include <sys/types.h>
2771
+ has_madvise = cc.links(osdep_prefix + '''
2763
2772
#include <sys/mman.h>
2764
- #include <stddef.h>
2765
2773
int main(void) { return madvise(NULL, 0, MADV_DONTNEED); }''' )
2766
2774
missing_madvise_proto = false
2767
2775
if has_madvise
@@ -2771,21 +2779,18 @@ if has_madvise
2771
2779
# missing-prototype case, we try again with a definitely-bogus prototype.
2772
2780
# This will only compile if the system headers don't provide the prototype;
2773
2781
# otherwise the conflicting prototypes will cause a compiler error.
2774
- missing_madvise_proto = cc.links(gnu_source_prefix + '''
2775
- #include <sys/types.h>
2782
+ missing_madvise_proto = cc.links(osdep_prefix + ''' >
2776
2783
#include <sys/mman.h>
2777
- #include <stddef.h>
2778
2784
extern int madvise(int);
2779
2785
int main(void) { return madvise(0); }''' )
2780
2786
endif
2781
2787
config_host_data.set(' CONFIG_MADVISE' , has_madvise)
2782
2788
config_host_data.set(' HAVE_MADVISE_WITHOUT_PROTOTYPE' , missing_madvise_proto)
2783
2789
2784
- config_host_data.set(' CONFIG_MEMFD' , cc.links(gnu_source_prefix + '''
2790
+ config_host_data.set(' CONFIG_MEMFD' , cc.links(osdep_prefix + '''
2785
2791
#include <sys/mman.h>
2786
2792
int main(void) { return memfd_create("foo", MFD_ALLOW_SEALING); }''' ))
2787
- config_host_data.set(' CONFIG_OPEN_BY_HANDLE' , cc.links(gnu_source_prefix + '''
2788
- #include <fcntl.h>
2793
+ config_host_data.set(' CONFIG_OPEN_BY_HANDLE' , cc.links(osdep_prefix + '''
2789
2794
#if !defined(AT_EMPTY_PATH)
2790
2795
# error missing definition
2791
2796
#else
@@ -2796,13 +2801,12 @@ config_host_data.set('CONFIG_OPEN_BY_HANDLE', cc.links(gnu_source_prefix + '''
2796
2801
# i.e. errno is set and -1 is returned. That's not really how POSIX defines the
2797
2802
# function. On the flip side, it has madvise() which is preferred anyways.
2798
2803
if host_os != ' darwin'
2799
- config_host_data.set(' CONFIG_POSIX_MADVISE' , cc.links(gnu_source_prefix + '''
2804
+ config_host_data.set(' CONFIG_POSIX_MADVISE' , cc.links(osdep_prefix + '''
2800
2805
#include <sys/mman.h>
2801
- #include <stddef.h>
2802
2806
int main(void) { return posix_madvise(NULL, 0, POSIX_MADV_DONTNEED); }''' ))
2803
2807
endif
2804
2808
2805
- config_host_data.set(' CONFIG_PTHREAD_SETNAME_NP_W_TID' , cc.links(gnu_source_prefix + '''
2809
+ config_host_data.set(' CONFIG_PTHREAD_SETNAME_NP_W_TID' , cc.links(osdep_prefix + '''
2806
2810
#include <pthread.h>
2807
2811
2808
2812
static void *f(void *p) { return NULL; }
@@ -2813,7 +2817,7 @@ config_host_data.set('CONFIG_PTHREAD_SETNAME_NP_W_TID', cc.links(gnu_source_pref
2813
2817
pthread_setname_np(thread, "QEMU");
2814
2818
return 0;
2815
2819
}''' , dependencies : threads))
2816
- config_host_data.set(' CONFIG_PTHREAD_SETNAME_NP_WO_TID' , cc.links(gnu_source_prefix + '''
2820
+ config_host_data.set(' CONFIG_PTHREAD_SETNAME_NP_WO_TID' , cc.links(osdep_prefix + '''
2817
2821
#include <pthread.h>
2818
2822
2819
2823
static void *f(void *p) { pthread_setname_np("QEMU"); return NULL; }
@@ -2823,7 +2827,7 @@ config_host_data.set('CONFIG_PTHREAD_SETNAME_NP_WO_TID', cc.links(gnu_source_pre
2823
2827
pthread_create(&thread, 0, f, 0);
2824
2828
return 0;
2825
2829
}''' , dependencies : threads))
2826
- config_host_data.set(' CONFIG_PTHREAD_SET_NAME_NP' , cc.links(gnu_source_prefix + '''
2830
+ config_host_data.set(' CONFIG_PTHREAD_SET_NAME_NP' , cc.links(osdep_prefix + '''
2827
2831
#include <pthread.h>
2828
2832
#include <pthread_np.h>
2829
2833
@@ -2835,9 +2839,8 @@ config_host_data.set('CONFIG_PTHREAD_SET_NAME_NP', cc.links(gnu_source_prefix +
2835
2839
pthread_set_name_np(thread, "QEMU");
2836
2840
return 0;
2837
2841
}''' , dependencies : threads))
2838
- config_host_data.set(' CONFIG_PTHREAD_CONDATTR_SETCLOCK' , cc.links(gnu_source_prefix + '''
2842
+ config_host_data.set(' CONFIG_PTHREAD_CONDATTR_SETCLOCK' , cc.links(osdep_prefix + '''
2839
2843
#include <pthread.h>
2840
- #include <time.h>
2841
2844
2842
2845
int main(void)
2843
2846
{
@@ -2846,7 +2849,7 @@ config_host_data.set('CONFIG_PTHREAD_CONDATTR_SETCLOCK', cc.links(gnu_source_pre
2846
2849
pthread_condattr_setclock(&attr, CLOCK_MONOTONIC);
2847
2850
return 0;
2848
2851
}''' , dependencies : threads))
2849
- config_host_data.set(' CONFIG_PTHREAD_AFFINITY_NP' , cc.links(gnu_source_prefix + '''
2852
+ config_host_data.set(' CONFIG_PTHREAD_AFFINITY_NP' , cc.links(osdep_prefix + '''
2850
2853
#include <pthread.h>
2851
2854
2852
2855
static void *f(void *p) { return NULL; }
@@ -2863,15 +2866,10 @@ config_host_data.set('CONFIG_PTHREAD_AFFINITY_NP', cc.links(gnu_source_prefix +
2863
2866
CPU_FREE(cpuset);
2864
2867
return 0;
2865
2868
}''' , dependencies : threads))
2866
- config_host_data.set(' CONFIG_SIGNALFD' , cc.links(gnu_source_prefix + '''
2869
+ config_host_data.set(' CONFIG_SIGNALFD' , cc.links(osdep_prefix + '''
2867
2870
#include <sys/signalfd.h>
2868
- #include <stddef.h>
2869
2871
int main(void) { return signalfd(-1, NULL, SFD_CLOEXEC); }''' ))
2870
- config_host_data.set(' CONFIG_SPLICE' , cc.links(gnu_source_prefix + '''
2871
- #include <unistd.h>
2872
- #include <fcntl.h>
2873
- #include <limits.h>
2874
-
2872
+ config_host_data.set(' CONFIG_SPLICE' , cc.links(osdep_prefix + '''
2875
2873
int main(void)
2876
2874
{
2877
2875
int len, fd = 0;
@@ -2880,13 +2878,13 @@ config_host_data.set('CONFIG_SPLICE', cc.links(gnu_source_prefix + '''
2880
2878
return 0;
2881
2879
}''' ))
2882
2880
2883
- config_host_data.set(' HAVE_MLOCKALL' , cc.links(gnu_source_prefix + '''
2881
+ config_host_data.set(' HAVE_MLOCKALL' , cc.links(osdep_prefix + '''
2884
2882
#include <sys/mman.h>
2885
2883
int main(void) {
2886
2884
return mlockall(MCL_FUTURE);
2887
2885
}''' ))
2888
2886
2889
- config_host_data.set(' HAVE_MLOCK_ONFAULT' , cc.links(gnu_source_prefix + '''
2887
+ config_host_data.set(' HAVE_MLOCK_ONFAULT' , cc.links(osdep_prefix + '''
2890
2888
#include <sys/mman.h>
2891
2889
int main(void) {
2892
2890
return mlockall(MCL_FUTURE | MCL_ONFAULT);
@@ -2895,7 +2893,7 @@ config_host_data.set('HAVE_MLOCK_ONFAULT', cc.links(gnu_source_prefix + '''
2895
2893
have_l2tpv3 = false
2896
2894
if get_option (' l2tpv3' ).allowed() and have_system
2897
2895
have_l2tpv3 = cc.has_type(' struct mmsghdr' ,
2898
- prefix : gnu_source_prefix + '''
2896
+ prefix : osdep_prefix + '''
2899
2897
#include <sys/socket.h>
2900
2898
#include <linux/ip.h>''' )
2901
2899
endif
@@ -3011,13 +3009,13 @@ if has_int128_type
3011
3009
endif
3012
3010
endif
3013
3011
3014
- config_host_data.set(' CONFIG_GETAUXVAL' , cc.links(gnu_source_prefix + '''
3012
+ config_host_data.set(' CONFIG_GETAUXVAL' , cc.links(osdep_prefix + '''
3015
3013
#include <sys/auxv.h>
3016
3014
int main(void) {
3017
3015
return getauxval(AT_HWCAP) == 0;
3018
3016
}''' ))
3019
3017
3020
- config_host_data.set(' CONFIG_ELF_AUX_INFO' , cc.links(gnu_source_prefix + '''
3018
+ config_host_data.set(' CONFIG_ELF_AUX_INFO' , cc.links(osdep_prefix + '''
3021
3019
#include <sys/auxv.h>
3022
3020
int main(void) {
3023
3021
unsigned long hwcap = 0;
@@ -3130,9 +3128,7 @@ config_host_data.set('CONFIG_MEMBARRIER', get_option('membarrier') \
3130
3128
.allowed())
3131
3129
3132
3130
have_afalg = get_option (' crypto_afalg' ) \
3133
- .require(cc.compiles(gnu_source_prefix + '''
3134
- #include <errno.h>
3135
- #include <sys/types.h>
3131
+ .require(cc.compiles(osdep_prefix + '''
3136
3132
#include <sys/socket.h>
3137
3133
#include <linux/if_alg.h>
3138
3134
int main(void) {
0 commit comments