diff --git a/Configure b/Configure index dd19ad4e81..4d5c3ed691 100755 --- a/Configure +++ b/Configure @@ -860,8 +860,6 @@ d_statfs_f_flags='' d_statfs_s='' d_static_inline='' perl_static_inline='' -d_thread_local='' -perl_thread_local='' d_fstatvfs='' d_statvfs='' d_stdio_cnt_lval='' @@ -906,6 +904,8 @@ d_tcgetpgrp='' d_tcsetpgrp='' d_telldirproto='' d_tgamma='' +d_thread_local='' +perl_thread_local='' d_time='' timetype='' d_asctime64='' @@ -4671,7 +4671,7 @@ esac # (Does this syntax conflict with something else that was valid C89?) # We also add a declaration after a statement to detect whether the compiler # (or the user supplied -Accflags) consider such declarations to be errors. -# This causes ./Configure with -Accflags="-Werror=declaration-after-statement" +# This causes 'Configure with -Accflags="-Werror=declaration-after-statement"' # to fail hard and early. # # Annoyingly -std=c99 will cause gcc to tell glibc not to define prototypes for @@ -4720,7 +4720,6 @@ no) echo >&4 "Your C compiler doesn't seem to be able to compile C99 code" esac $rm -f try try.* - : What should the include directory be ? : Use sysroot if set, so findhdr looks in the right place. echo " " @@ -19287,129 +19286,6 @@ eval $setvar $rm -f a.[co] b.[co] $rm_try -: see what flavor, if any, of thread local storage is supported -echo " " -echo "Checking to see if your system supports C11 thread local storage..." -$cat > try.c <<'EOCP' -#include -#include -#include - -static int plus_one = 1; -static int minus_one = -1; - -PROBE_MACRO int *minion; - -int callback (const void *a, const void *b) { - int val_a = *minion * *(const int *)a; - int val_b = *minion * *(const int *)b; - return val_a < val_b ? -1 : val_a > val_b; -} - -#define SIZE 8 - -void *thread_function(void *arg) { - /* thread local variables should start zeroed in each thread. */ - if (minion != NULL) { - fprintf(stderr, "__thread variable started with %p, should be NULL\n", - minion); - exit(2); - } - minion = &minus_one; - - int array[SIZE]; - unsigned int i; - for (i = 0; i < SIZE; ++i) { - /* "Hash randomisation" - this array isn't in sorted order: */ - array[i ^ 5] = i * i; - } - - qsort(array, SIZE, sizeof(int), callback); - - int bad = 0; - for (i = 0; i < SIZE; ++i) { - int want = (SIZE - 1 - i) * (SIZE - 1 - i); - int have = array[i]; - if (want != have) { - ++bad; - fprintf(stderr, "array[%u] - want %i, have %i\n", i, want, have); - } - } - if (bad) - exit(3); - - return NULL; -} - -int main(int argc, char **argv) { - if (minion != NULL) { - fprintf(stderr, "__thread variable started with %p, should be NULL\n", - minion); - exit(4); - } - - minion = &plus_one; - - pthread_t tid; - int result = pthread_create(&tid, NULL, thread_function, NULL); - if (result) { - fprintf(stderr, "pthread_create failed (%d)\n", result); - exit(5); - } - - result = pthread_join(tid, NULL); - if (result) { - fprintf(stderr, "pthread_join failed (%d)\n", result); - exit(6); - } - - if (minion == NULL) { - fprintf(stderr, "__thread variable should not be NULL\n"); - exit(7); - } - if (!(minion == &plus_one && *minion == 1)) { - fprintf(stderr, "__thread variable should be %d @ %p, not %d @ %p\n", - 1, &plus_one, *minion, minion); - exit(8); - } - - return 0; -} -EOCP - -# Respect a hint (or previous) value for perl_thread_local, if there is one. -case "$perl_thread_local" in -'') # Check the various possibilities, and break out on success. - for thread_local in _Thread_local __thread; do - set try -DPROBE_MACRO=$thread_local - if eval $compile && $run ./try; then - $echo "Your compiler supports $thread_local." >&4 - val=$define - perl_thread_local="$thread_local"; - break; - fi - $echo "Your compiler does NOT support $thread_local." >&4 - val="$undef" - done - ;; -*thread*|*Thread*) # Some variant of thread local exists. - echo "Keeping your $hint value of $perl_thread_local." - val=$define - ;; -*) # Unrecognized previous value -- blindly trust the supplied - # value and hope it makes sense. Use old value for - # d_thread_local, if there is one. - echo "Keeping your $hint value of $perl_thread_local." - case "$d_thread_local" in - '') val=$define ;; - *) val=$d_thread_local ;; - esac - ;; -esac -set d_thread_local -eval $setvar -$rm_try - : Check stream access $cat >&4 < try.c <<'EOCP' +#include +#include +#include + +static int plus_one = 1; +static int minus_one = -1; + +PROBE_MACRO int *minion; + +int callback (const void *a, const void *b) { + int val_a = *minion * *(const int *)a; + int val_b = *minion * *(const int *)b; + return val_a < val_b ? -1 : val_a > val_b; +} + +#define SIZE 8 + +void *thread_function(void *arg) { + /* thread local variables should start zeroed in each thread. */ + if (minion != NULL) { + fprintf(stderr, "__thread variable started with %p, should be NULL\n", + minion); + exit(2); + } + minion = &minus_one; + + int array[SIZE]; + unsigned int i; + for (i = 0; i < SIZE; ++i) { + /* "Hash randomisation" - this array isn't in sorted order: */ + array[i ^ 5] = i * i; + } + + qsort(array, SIZE, sizeof(int), callback); + + int bad = 0; + for (i = 0; i < SIZE; ++i) { + int want = (SIZE - 1 - i) * (SIZE - 1 - i); + int have = array[i]; + if (want != have) { + ++bad; + fprintf(stderr, "array[%u] - want %i, have %i\n", i, want, have); + } + } + if (bad) + exit(3); + + return NULL; +} + +int main(int argc, char **argv) { + if (minion != NULL) { + fprintf(stderr, "__thread variable started with %p, should be NULL\n", + minion); + exit(4); + } + + minion = &plus_one; + + pthread_t tid; + int result = pthread_create(&tid, NULL, thread_function, NULL); + if (result) { + fprintf(stderr, "pthread_create failed (%d)\n", result); + exit(5); + } + + result = pthread_join(tid, NULL); + if (result) { + fprintf(stderr, "pthread_join failed (%d)\n", result); + exit(6); + } + + if (minion == NULL) { + fprintf(stderr, "__thread variable should not be NULL\n"); + exit(7); + } + if (!(minion == &plus_one && *minion == 1)) { + fprintf(stderr, "__thread variable should be %d @ %p, not %d @ %p\n", + 1, &plus_one, *minion, minion); + exit(8); + } + + return 0; +} +EOCP + +# Respect a hint (or previous) value for perl_thread_local, if there is one. +case "$perl_thread_local" in +'') # Check the various possibilities, and break out on success. + for thread_local in _Thread_local __thread; do + set try -DPROBE_MACRO=$thread_local + if eval $compile && $run ./try; then + $echo "Your compiler supports $thread_local." >&4 + val=$define + perl_thread_local="$thread_local"; + break; + fi + $echo "Your compiler does NOT support $thread_local." >&4 + val="$undef" + done + ;; +*thread*|*Thread*) # Some variant of thread local exists. + echo "Keeping your $hint value of $perl_thread_local." + val=$define + ;; +*) # Unrecognized previous value -- blindly trust the supplied + # value and hope it makes sense. Use old value for + # d_thread_local, if there is one. + echo "Keeping your $hint value of $perl_thread_local." + case "$d_thread_local" in + '') val=$define ;; + *) val=$d_thread_local ;; + esac + ;; +esac +set d_thread_local +eval $setvar +$rm_try + : see if time exists echo " " if test "X$d_time" = X -o X"$timetype" = X; then @@ -22857,74 +22856,6 @@ EOM fi $rm_try -: Check the size of st_ino -$echo " " -$echo "Checking the size of st_ino..." >&4 -$cat > try.c < -#include -#$i_stdlib I_STDLIB -#ifdef I_STDLIB -#include -#endif -int main() { - struct stat st; - printf("%d\n", (int)sizeof(st.st_ino)); - exit(0); -} -EOCP -set try -if eval $compile_ok; then - val=`$run ./try` - case "$val" in - '') st_ino_size=4 - $echo "(I can't execute the test program--guessing $st_ino_size.)" >&4 - ;; - *) st_ino_size=$val - $echo "Your st_ino is $st_ino_size bytes long." - ;; - esac -else - st_ino_size=4 - $echo "(I can't compile the test program--guessing $st_ino_size.)" >&4 -fi -$rm_try - -: Check if st_ino is signed -$echo " " -$echo "Checking the sign of st_ino..." >&4 -$cat > try.c < -#include -int main() { - struct stat foo; - foo.st_ino = -1; - if (foo.st_ino < 0) - printf("-1\n"); - else - printf("1\n"); -} -EOCP -set try -if eval $compile; then - val=`$run ./try` - case "$val" in - '') st_ino_sign=1 - $echo "(I can't execute the test program--guessing unsigned.)" >&4 - ;; - *) st_ino_sign=$val - case "$st_ino_sign" in - 1) $echo "Your st_ino is unsigned." ;; - -1) $echo "Your st_ino is signed." ;; - esac - ;; - esac -else - st_ino_sign=1 - $echo "(I can't compile the test program--guessing unsigned.)" >&4 -fi -$rm_try - : Check the size of st_dev $echo " " $echo "Checking the size of st_dev..." >&4 @@ -22993,6 +22924,74 @@ else fi $rm_try +: Check the size of st_ino +$echo " " +$echo "Checking the size of st_ino..." >&4 +$cat > try.c < +#include +#$i_stdlib I_STDLIB +#ifdef I_STDLIB +#include +#endif +int main() { + struct stat st; + printf("%d\n", (int)sizeof(st.st_ino)); + exit(0); +} +EOCP +set try +if eval $compile_ok; then + val=`$run ./try` + case "$val" in + '') st_ino_size=4 + $echo "(I can't execute the test program--guessing $st_ino_size.)" >&4 + ;; + *) st_ino_size=$val + $echo "Your st_ino is $st_ino_size bytes long." + ;; + esac +else + st_ino_size=4 + $echo "(I can't compile the test program--guessing $st_ino_size.)" >&4 +fi +$rm_try + +: Check if st_ino is signed +$echo " " +$echo "Checking the sign of st_ino..." >&4 +$cat > try.c < +#include +int main() { + struct stat foo; + foo.st_ino = -1; + if (foo.st_ino < 0) + printf("-1\n"); + else + printf("1\n"); +} +EOCP +set try +if eval $compile; then + val=`$run ./try` + case "$val" in + '') st_ino_sign=1 + $echo "(I can't execute the test program--guessing unsigned.)" >&4 + ;; + *) st_ino_sign=$val + case "$st_ino_sign" in + 1) $echo "Your st_ino is unsigned." ;; + -1) $echo "Your st_ino is signed." ;; + esac + ;; + esac +else + st_ino_sign=1 + $echo "(I can't compile the test program--guessing unsigned.)" >&4 +fi +$rm_try + : see what type of char stdio uses. echo " " echo '#include ' | $cppstdin $cppminus > stdioh diff --git a/Porting/Glossary b/Porting/Glossary index d836c0a1cb..2dcb565190 100644 --- a/Porting/Glossary +++ b/Porting/Glossary @@ -5314,6 +5314,13 @@ ssizetype (ssizetype.U): of bytes or an error condition. It must be a signed type. We will pick a type such that sizeof(SSize_t) == sizeof(Size_t). +st_dev_sign (st_dev_def.U): + This variable contains the signedness of struct stat's st_dev. + 1 for unsigned, -1 for signed. + +st_dev_size (st_dev_def.U): + This variable contains the size of struct stat's st_dev in bytes. + st_ino_sign (st_ino_def.U): This variable contains the signedness of struct stat's st_ino. 1 for unsigned, -1 for signed. diff --git a/config_h.SH b/config_h.SH index 9652cad49d..b817483315 100755 --- a/config_h.SH +++ b/config_h.SH @@ -1073,18 +1073,6 @@ sed <$CONFIG_H -e 's!^#undef\(.*/\)\*!/\*#define\1 \*!' -e 's!^#un #$d_static_inline HAS_STATIC_INLINE /**/ #define PERL_STATIC_INLINE $perl_static_inline /**/ -/* PERL_THREAD_LOCAL: - * This symbol, if defined, gives a linkage specification for thread-local - * storage. For example, for a C11 compiler this will be _Thread_local. - * Beware, some compilers are sensitive to the C language standard they are - * told to parse. For example, suncc defaults to C11, so our probe will - * report that _Thread_local can be used. However, if the -std=c99 is later - * added to the compiler flags, then _Thread_local will become a syntax - * error. Hence it is important for these flags to be consistent between - * probing and use. - */ -#$d_thread_local PERL_THREAD_LOCAL $perl_thread_local /**/ - /* USE_STDIO_PTR: * This symbol is defined if the _ptr and _cnt fields (or similar) * of the stdio FILE structure can be used to access the stdio buffer @@ -4217,6 +4205,9 @@ sed <$CONFIG_H -e 's!^#undef\(.*/\)\*!/\*#define\1 \*!' -e 's!^#un * This symbol holds the signedness of struct stat's st_dev. * 1 for unsigned, -1 for signed. */ +#define ST_DEV_SIGN $st_dev_sign /* st_dev sign */ +#define ST_DEV_SIZE $st_dev_size /* st_dev size */ + /* ST_INO_SIZE: * This variable contains the size of struct stat's st_ino in bytes. */ @@ -4224,8 +4215,6 @@ sed <$CONFIG_H -e 's!^#undef\(.*/\)\*!/\*#define\1 \*!' -e 's!^#un * This symbol holds the signedness of struct stat's st_ino. * 1 for unsigned, -1 for signed. */ -#define ST_DEV_SIGN $st_dev_sign /* st_dev sign */ -#define ST_DEV_SIZE $st_dev_size /* st_dev size */ #define ST_INO_SIGN $st_ino_sign /* st_ino sign */ #define ST_INO_SIZE $st_ino_size /* st_ino size */ @@ -5187,6 +5176,18 @@ sed <$CONFIG_H -e 's!^#undef\(.*/\)\*!/\*#define\1 \*!' -e 's!^#un */ #$d_strtold_l HAS_STRTOLD_L /**/ +/* PERL_THREAD_LOCAL: + * This symbol, if defined, gives a linkage specification for thread-local + * storage. For example, for a C11 compiler this will be _Thread_local. + * Beware, some compilers are sensitive to the C language standard they are + * told to parse. For example, suncc defaults to C11, so our probe will + * report that _Thread_local can be used. However, if the -std=c99 is later + * added to the compiler flags, then _Thread_local will become a syntax + * error. Hence it is important for these flags to be consistent between + * probing and use. + */ +#$d_thread_local PERL_THREAD_LOCAL $perl_thread_local /**/ + /* HAS_TMPNAM_R: * This symbol, if defined, indicates that the tmpnam_r routine * is available to tmpnam re-entrantly. diff --git a/uconfig.h b/uconfig.h index f8b920c5ea..9265bc647d 100644 --- a/uconfig.h +++ b/uconfig.h @@ -1038,18 +1038,6 @@ /*#define HAS_STATIC_INLINE / **/ #define PERL_STATIC_INLINE static /**/ -/* PERL_THREAD_LOCAL: - * This symbol, if defined, gives a linkage specification for thread-local - * storage. For example, for a C11 compiler this will be _Thread_local. - * Beware, some compilers are sensitive to the C language standard they are - * told to parse. For example, suncc defaults to C11, so our probe will - * report that _Thread_local can be used. However, if the -std=c99 is later - * added to the compiler flags, then _Thread_local will become a syntax - * error. Hence it is important for these flags to be consistent between - * probing and use. - */ -/*#define PERL_THREAD_LOCAL / **/ - /* USE_STDIO_PTR: * This symbol is defined if the _ptr and _cnt fields (or similar) * of the stdio FILE structure can be used to access the stdio buffer @@ -4182,6 +4170,9 @@ * This symbol holds the signedness of struct stat's st_dev. * 1 for unsigned, -1 for signed. */ +#define ST_DEV_SIGN 1 /* st_dev sign */ +#define ST_DEV_SIZE 4 /* st_dev size */ + /* ST_INO_SIZE: * This variable contains the size of struct stat's st_ino in bytes. */ @@ -4189,8 +4180,6 @@ * This symbol holds the signedness of struct stat's st_ino. * 1 for unsigned, -1 for signed. */ -#define ST_DEV_SIGN 1 /* st_dev sign */ -#define ST_DEV_SIZE 4 /* st_dev size */ #define ST_INO_SIGN 1 /* st_ino sign */ #define ST_INO_SIZE 4 /* st_ino size */ @@ -5152,6 +5141,18 @@ */ /*#define HAS_STRTOLD_L / **/ +/* PERL_THREAD_LOCAL: + * This symbol, if defined, gives a linkage specification for thread-local + * storage. For example, for a C11 compiler this will be _Thread_local. + * Beware, some compilers are sensitive to the C language standard they are + * told to parse. For example, suncc defaults to C11, so our probe will + * report that _Thread_local can be used. However, if the -std=c99 is later + * added to the compiler flags, then _Thread_local will become a syntax + * error. Hence it is important for these flags to be consistent between + * probing and use. + */ +/*#define PERL_THREAD_LOCAL / **/ + /* HAS_TMPNAM_R: * This symbol, if defined, indicates that the tmpnam_r routine * is available to tmpnam re-entrantly. @@ -5339,6 +5340,6 @@ #endif /* Generated from: - * a551aebc3302cae7ae872b150e8a40760112ce0046e2a26fa4e86e2cfc9f0719 config_h.SH + * 87e5998978daf803d19866c43bca24d7c01dc74119650db16f8d18d83f355da9 config_h.SH * 192cfd7d6b90e7961582dadbf7e6ae6de3e4fa6ffde19a0f7148a8572ec635f9 uconfig.sh * ex: set ro: */