spitshell=''
src=''
ssizetype=''
+st_dev_sign=''
+st_dev_size=''
st_ino_sign=''
st_ino_size=''
startperl=''
fi
$rm_try
+: Check the size of st_dev
+$echo " "
+$echo "Checking the size of st_dev..." >&4
+$cat > try.c <<EOCP
+#include <sys/stat.h>
+#include <stdio.h>
+#$i_stdlib I_STDLIB
+#ifdef I_STDLIB
+#include <stdlib.h>
+#endif
+int main() {
+ struct stat st;
+ printf("%d\n", (int)sizeof(st.st_dev));
+ exit(0);
+}
+EOCP
+set try
+if eval $compile_ok; then
+ val=`$run ./try`
+ case "$val" in
+ '') st_dev_size=4
+ $echo "(I can't execute the test program--guessing $st_dev_size.)" >&4
+ ;;
+ *) st_dev_size=$val
+ $echo "Your st_dev is $st_dev_size bytes long."
+ ;;
+ esac
+else
+ st_dev_size=4
+ $echo "(I can't compile the test program--guessing $st_dev_size.)" >&4
+fi
+$rm_try
+
+: Check if st_dev is signed
+$echo " "
+$echo "Checking the sign of st_dev..." >&4
+$cat > try.c <<EOCP
+#include <sys/stat.h>
+#include <stdio.h>
+int main() {
+ struct stat foo;
+ foo.st_dev = -1;
+ if (foo.st_dev < 0)
+ printf("-1\n");
+ else
+ printf("1\n");
+}
+EOCP
+set try
+if eval $compile; then
+ val=`$run ./try`
+ case "$val" in
+ '') st_dev_sign=1
+ $echo "(I can't execute the test program--guessing unsigned.)" >&4
+ ;;
+ *) st_dev_sign=$val
+ case "$st_dev_sign" in
+ 1) $echo "Your st_dev is unsigned." ;;
+ -1) $echo "Your st_dev is signed." ;;
+ esac
+ ;;
+ esac
+else
+ st_dev_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 <stdio.h>' | $cppstdin $cppminus > stdioh
srandom_r_proto='$srandom_r_proto'
src='$src'
ssizetype='$ssizetype'
+st_dev_sign='$st_dev_sign'
+st_dev_size='$st_dev_size'
st_ino_sign='$st_ino_sign'
st_ino_size='$st_ino_size'
startperl='$startperl'
srandom_r_proto='0'
src='.'
ssizetype='ssize_t'
+st_dev_sign='1'
+st_dev_size='4'
st_ino_sign='1'
st_ino_size='4'
startperl='#!/usr/bin/perl'
srandom_r_proto='0'
src='.'
ssizetype='ssize_t'
+st_dev_sign='1'
+st_dev_size='4'
st_ino_sign='1'
st_ino_size='4'
startperl='#!/usr/bin/perl'
srandom_r_proto='0'
src=''
ssizetype='int'
+st_dev_sign='1'
+st_dev_size='4'
st_ino_sign='1'
st_ino_size='4'
startperl='#!perl'
srandom_r_proto='REENTRANT_PROTO_I_TS'
src='.'
ssizetype='ssize_t'
+st_dev_sign='1'
+st_dev_size='4'
st_ino_sign='1'
st_ino_size='8'
startperl='#!/opt/perl/bin/perl5.35.4'
*/
#define SELECT_MIN_BITS $selectminbits /**/
+/* ST_DEV_SIZE:
+ * This variable contains the size of struct stat's st_dev in bytes.
+ */
+/* ST_DEV_SIGN:
+ * This symbol holds the signedness of struct stat's st_dev.
+ * 1 for unsigned, -1 for signed.
+ */
/* ST_INO_SIZE:
* This variable contains the size of struct stat's st_ino in bytes.
*/
* 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 */
$ WC "ssizetype='int'"
$ WC "startperl=" + startperl ! This one's special--no enclosing single quotes
$ WC "static_ext='" + static_ext + "'"
+$ WC "st_dev_size='"4"'"
+$ WC "st_dev_sign='1'"
$ WC "st_ino_size='" + st_ino_size + "'"
$ WC "st_ino_sign='1'"
$ WC "stdchar='" + stdchar + "'"
srandom_r_proto='0'
src='.'
ssizetype='ssize_t'
+st_dev_sign='1'
+st_dev_size='4'
st_ino_sign='1'
st_ino_size='4'
startperl='#!/bin/perl'
if (max) {
EXTEND(SP, max);
EXTEND_MORTAL(max);
+#if ST_DEV_SIZE < IVSIZE || (ST_DEV_SIZE == IVSIZE && ST_DEV_SIGN < 0)
mPUSHi(PL_statcache.st_dev);
+#elif ST_DEV_SIZE == IVSIZE
+ mPUSHu(PL_statcache.st_dev);
+#else
+# if ST_DEV_SIGN < 0
+ if (LIKELY((IV)PL_statcache.st_dev == PL_statcache.st_dev)) {
+ mPUSHi((IV)PL_statcache.st_dev);
+ }
+# else
+ if (LIKELY((UV)PL_statcache.st_dev == PL_statcache.st_dev)) {
+ mPUSHu((UV)PL_statcache.st_dev);
+ }
+# endif
+ else {
+ char buf[sizeof(PL_statcache.st_dev)*3+1];
+ /* sv_catpvf() casts 'j' size values down to IV, so it
+ isn't suitable for use here.
+ */
+# if defined(I_INTTYPES) && defined(HAS_SNPRINTF)
+# if ST_DEV_SIGN < 0
+ int size = snprintf(buf, sizeof(buf), "%" PRIdMAX, (intmax_t)PL_statcache.st_dev);
+# else
+ int size = snprintf(buf, sizeof(buf), "%" PRIuMAX, (uintmax_t)PL_statcache.st_dev);
+# endif
+ STATIC_ASSERT_STMT(sizeof(intmax_t) >= sizeof(PL_statcache.st_dev));
+ mPUSHp(buf, size);
+# else
+# error extraordinarily large st_dev but no inttypes.h or no snprintf
+# endif
+ }
+#endif
{
/*
* We try to represent st_ino as a native IV or UV where
my $Errno_loaded = eval { require Errno };
-plan tests => 110;
+plan tests => 111;
my $Perl = which_perl();
unlink $link;
}
+ SKIP:
+{
+ # test needs a FreeBSD /usr/bin/stat
+ # /tmp is typically tmpfs on a new FreeBSD
+ $^O eq "freebsd"
+ or skip "only checking freebsd for now", 1;
+ -x "/usr/bin/stat"
+ or skip "no /usr/bin/stat", 1;
+ my @s = stat "/tmp";
+ @s or skip "No /tmp found", 1;
+ my $test = `/usr/bin/stat -f '%d %i' /tmp`;
+ $test && $test =~ /^-?\d+ -?\d+/
+ or skip "stat didn't return an expected result";
+ chomp $test;
+ is("$s[0] $s[1]", $test,
+ "perl stat didn't match system stat utility");
+}
+
END {
chmod 0666, $tmpfile;
unlink_all $tmpfile;
*/
#define SELECT_MIN_BITS 32 /**/
+/* ST_DEV_SIZE:
+ * This variable contains the size of struct stat's st_dev in bytes.
+ */
+/* ST_DEV_SIGN:
+ * This symbol holds the signedness of struct stat's st_dev.
+ * 1 for unsigned, -1 for signed.
+ */
/* ST_INO_SIZE:
* This variable contains the size of struct stat's st_ino in bytes.
*/
* 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 */
#endif
/* Generated from:
- * f88762343858d290ac1b2bce8613d97ce15c18eada7a5a587fb9b8a8053d0d7f config_h.SH
- * 24570f2ff38b22b436d34127ff85a3f3a075a4dea1359c56f16196bdbe376b1c uconfig.sh
+ * 4769474cd122c46e0efc0224475eb6401d7837cf93c9484af644422d1c5a68e3 config_h.SH
+ * 9aacfe7bf1c55c60b2116e885bafc3f0852a9f52f1ba926d598dd6aa271aa8a2 uconfig.sh
* ex: set ro: */
srandom_r_proto='0'
src='.'
ssizetype=int
+st_dev_sign='1'
+st_dev_size='4'
st_ino_sign='1'
st_ino_size='4'
startperl='#!perl'
srandom_r_proto='0'
src='.'
ssizetype=long
+st_dev_sign='1'
+st_dev_size='4'
st_ino_sign='1'
st_ino_size='8'
startperl='#!perl'
srandom_r_proto='0'
src=''
ssizetype='int'
+st_dev_sign='1'
+st_dev_size='4'
st_ino_sign='1'
st_ino_size='4'
startperl='#!perl'
srandom_r_proto='0'
src=''
ssizetype='int'
+st_dev_sign='1'
+st_dev_size='4'
st_ino_sign='1'
st_ino_size='4'
startperl='#!perl'