1875 #ifdef HAS_OPENDIR |
1875 #ifdef HAS_OPENDIR |
1876 if (__isExternalAddressLike(dirPointer)) { |
1876 if (__isExternalAddressLike(dirPointer)) { |
1877 closedir( (DIR *)(__FILEVal(dirPointer)) ); |
1877 closedir( (DIR *)(__FILEVal(dirPointer)) ); |
1878 } |
1878 } |
1879 #endif |
1879 #endif |
1880 %} |
1880 %}. |
|
1881 self primitiveFailed |
1881 ! |
1882 ! |
1882 |
1883 |
1883 nextLinkInfoFrom:aDirectoryStream dirPointer:dirPointer |
1884 nextLinkInfoFrom:aDirectoryStream dirPointer:dirPointer |
1884 "return a FileStatusInfo entry for the next entry, when reading from a directory. |
1885 "return a FileStatusInfo entry for the next entry, when reading from a directory. |
1885 Under UNIX, the returned fileStatuInfo ONLY contains the name of the file, |
1886 Under UNIX, the returned fileStatuInfo ONLY contains the name of the file, |
4659 caseSensitiveFilenames |
4663 caseSensitiveFilenames |
4660 "return true, if the OS has caseSensitive file naming. |
4664 "return true, if the OS has caseSensitive file naming. |
4661 On MSDOS, this will return false; |
4665 On MSDOS, this will return false; |
4662 on a real OS, we return true." |
4666 on a real OS, we return true." |
4663 |
4667 |
|
4668 "/ actually, this is wrong and may depend on the mounted volume; |
|
4669 "/ so we need a query for a particular directory (and/or volume). |
4664 ^ true |
4670 ^ true |
4665 |
4671 |
4666 "Modified: / 5.6.1998 / 18:35:18 / cg" |
4672 "Modified: / 5.6.1998 / 18:35:18 / cg" |
4667 ! |
4673 ! |
4668 |
4674 |
9695 clock resolution value." |
9701 clock resolution value." |
9696 |
9702 |
9697 |seconds micros error| |
9703 |seconds micros error| |
9698 |
9704 |
9699 %{ |
9705 %{ |
|
9706 #ifdef __SCHTEAM__ |
|
9707 { |
|
9708 long nanos = System.nanoTime(); |
|
9709 |
|
9710 return context._RETURN( STInteger._new(nanos / 1000) ); |
|
9711 } |
|
9712 /* NOTREACHED */ |
|
9713 #else |
9700 unsigned long _secs, _micros; |
9714 unsigned long _secs, _micros; |
9701 |
9715 |
9702 #if defined(_POSIX_MONOTONIC_CLOCK) && defined(CLOCK_MONOTONIC) && !defined(NO_CLOCK_GETTIME) |
9716 # if defined(_POSIX_MONOTONIC_CLOCK) && defined(CLOCK_MONOTONIC) && !defined(NO_CLOCK_GETTIME) |
9703 struct timespec ts; |
9717 struct timespec ts; |
9704 static int has_clock_gettime = 1; |
9718 static int has_clock_gettime = 1; |
9705 |
9719 |
9706 if (has_clock_gettime) { |
9720 if (has_clock_gettime) { |
9707 if (clock_gettime(CLOCK_MONOTONIC, &ts) != -1) { |
9721 if (clock_gettime(CLOCK_MONOTONIC, &ts) != -1) { |
9714 * fall through to alternative implementation |
9728 * fall through to alternative implementation |
9715 */ |
9729 */ |
9716 has_clock_gettime = 0; |
9730 has_clock_gettime = 0; |
9717 } |
9731 } |
9718 } |
9732 } |
9719 #endif |
9733 # endif |
9720 |
9734 |
9721 #if defined(HAS_GETTIMEOFDAY) |
9735 # if defined(HAS_GETTIMEOFDAY) |
9722 struct timeval tb; |
9736 struct timeval tb; |
9723 |
9737 |
9724 gettimeofday(&tb, NULL /* &tzb */); |
9738 gettimeofday(&tb, NULL /* &tzb */); |
9725 if (tb.tv_usec >= (1000000)) { |
9739 if (tb.tv_usec >= (1000000)) { |
9726 error = @symbol(bad); |
9740 error = @symbol(bad); |
9727 goto err; |
9741 goto err; |
9728 } |
9742 } |
9729 |
9743 |
9730 _secs = tb.tv_sec; |
9744 _secs = tb.tv_sec; |
9731 _micros = tb.tv_usec; |
9745 _micros = tb.tv_usec; |
9732 #endif |
9746 # endif |
9733 |
9747 |
9734 out: |
9748 out: |
9735 |
9749 |
9736 #if __POINTER_SIZE__ == 8 |
9750 # if __POINTER_SIZE__ == 8 |
9737 { |
9751 { |
9738 unsigned INT rslt; |
9752 unsigned INT rslt; |
9739 |
9753 |
9740 rslt = (unsigned INT)_secs * 1000000 + _micros; |
9754 rslt = (unsigned INT)_secs * 1000000 + _micros; |
9741 RETURN (__MKUINT(rslt)); |
9755 RETURN (__MKUINT(rslt)); |
9742 } |
9756 } |
9743 #else |
9757 # else |
9744 # ifdef HAS_LONGLONG |
9758 # ifdef HAS_LONGLONG |
9745 { |
9759 { |
9746 unsigned long long rslt; |
9760 unsigned long long rslt; |
9747 |
9761 |
9748 rslt = (unsigned long long)_secs * 1000000 + _micros; |
9762 rslt = (unsigned long long)_secs * 1000000 + _micros; |
9749 RETURN (__MKLARGEINT64(1, (unsigned INT)(rslt & 0xFFFFFFFF), (unsigned INT)(rslt >> 32))); |
9763 RETURN (__MKLARGEINT64(1, (unsigned INT)(rslt & 0xFFFFFFFF), (unsigned INT)(rslt >> 32))); |
9750 } |
9764 } |
9751 # else |
9765 # else |
9752 seconds = __MKUINT(_secs); |
9766 seconds = __MKUINT(_secs); |
9753 micros = __MKUINT(_micros); |
9767 micros = __MKUINT(_micros); |
9754 # endif /* long long */ |
9768 # endif /* long long */ |
9755 #endif /* __POINTER_SIZE__ == 8 */ |
9769 # endif /* __POINTER_SIZE__ == 8 */ |
9756 err:; |
9770 err:; |
|
9771 #endif /* not SCHTEAM */ |
9757 %}. |
9772 %}. |
9758 |
9773 |
9759 seconds notNil ifTrue:[ |
9774 seconds notNil ifTrue:[ |
9760 ^ (seconds * 1000000) + micros |
9775 ^ (seconds * 1000000) + micros |
9761 ]. |
9776 ]. |
9785 Don't use this method in application code since it is an internal (private) |
9800 Don't use this method in application code since it is an internal (private) |
9786 interface. For compatibility with ST-80, use Time millisecondClockValue. |
9801 interface. For compatibility with ST-80, use Time millisecondClockValue. |
9787 " |
9802 " |
9788 |
9803 |
9789 %{ /* NOCONTEXT */ |
9804 %{ /* NOCONTEXT */ |
9790 |
9805 #ifdef __SCHTEAM__ |
|
9806 { |
|
9807 long millis = System.currentTimeMillis(); |
|
9808 return context._RETURN( STInteger._new(millis) ); |
|
9809 } |
|
9810 /* NOTREACHED */ |
|
9811 #else |
9791 unsigned long t = 0; |
9812 unsigned long t = 0; |
9792 |
9813 |
9793 #if defined(_POSIX_MONOTONIC_CLOCK) && defined(CLOCK_MONOTONIC) && !defined(NO_CLOCK_GETTIME) |
9814 # if defined(_POSIX_MONOTONIC_CLOCK) && defined(CLOCK_MONOTONIC) && !defined(NO_CLOCK_GETTIME) |
9794 static has_clock_gettime = 1; |
9815 static has_clock_gettime = 1; |
9795 struct timespec ts; |
9816 struct timespec ts; |
9796 |
9817 |
9797 if (has_clock_gettime) { |
9818 if (has_clock_gettime) { |
9798 if (clock_gettime(CLOCK_MONOTONIC, &ts) != -1) { |
9819 if (clock_gettime(CLOCK_MONOTONIC, &ts) != -1) { |
9804 * fall through to alternative implementation |
9825 * fall through to alternative implementation |
9805 */ |
9826 */ |
9806 has_clock_gettime = 0; |
9827 has_clock_gettime = 0; |
9807 } |
9828 } |
9808 } |
9829 } |
9809 #endif /* _POSIX_MONOTONIC_CLOCK */ |
9830 # endif /* _POSIX_MONOTONIC_CLOCK */ |
9810 |
9831 |
9811 #if defined(_SC_CLK_TCK) |
9832 # if defined(_SC_CLK_TCK) |
9812 /* |
9833 /* |
9813 * We prefer times here, since it is monotonic and immune to clock changes |
9834 * We prefer times here, since it is monotonic and immune to clock changes |
9814 * but: it has less precision! |
9835 * but: it has less precision! |
9815 */ |
9836 */ |
9816 # include <sys/times.h> |
9837 # include <sys/times.h> |
9817 |
9838 |
9818 static int millisecondsPerTick; |
9839 static int millisecondsPerTick; |
9819 clock_t ticks; |
9840 clock_t ticks; |
9820 struct tms tb; |
9841 struct tms tb; |
9821 |
9842 |
9835 if (ticks == -1) |
9856 if (ticks == -1) |
9836 goto err; |
9857 goto err; |
9837 |
9858 |
9838 t = ticks * millisecondsPerTick; |
9859 t = ticks * millisecondsPerTick; |
9839 |
9860 |
9840 #else /* !times */ |
9861 # else /* !times */ |
9841 |
9862 |
9842 /* assume HAS_GETTIMEOFDAY |
9863 /* assume HAS_GETTIMEOFDAY |
9843 * - will result in a linkage error if not fixed. |
9864 * - will result in a linkage error if not fixed. |
9844 */ |
9865 */ |
9845 |
9866 |
9846 struct timeval tb; |
9867 struct timeval tb; |
9847 |
9868 |
9848 gettimeofday(&tb, NULL); |
9869 gettimeofday(&tb, NULL); |
9849 t = tb.tv_sec*1000 + tb.tv_usec/1000; |
9870 t = tb.tv_sec*1000 + tb.tv_usec/1000; |
9850 #endif |
9871 # endif |
9851 |
9872 |
9852 out: |
9873 out: |
9853 RETURN ( __mkSmallInteger(t & 0x1FFFFFFF) ); |
9874 RETURN ( __mkSmallInteger(t & 0x1FFFFFFF) ); |
9854 |
9875 |
9855 err:; |
9876 err:; |
|
9877 #endif /* not SCHTEAM */ |
9856 %}. |
9878 %}. |
9857 self primitiveFailed |
9879 self primitiveFailed |
9858 |
9880 |
9859 |
9881 |
9860 " |
9882 " |
9878 |
9900 |
9879 |
9901 |
9880 |seconds millis| |
9902 |seconds millis| |
9881 |
9903 |
9882 %{ |
9904 %{ |
|
9905 #ifdef __SCHTEAM__ |
|
9906 { |
|
9907 long millisSince1970 = java.lang.System.currentTimeMillis(); |
|
9908 return context._RETURN( STInteger._new(millisSince1970)); |
|
9909 } |
|
9910 /* NOTREACHED */ |
|
9911 #else |
|
9912 |
9883 unsigned long _secs, _millis; |
9913 unsigned long _secs, _millis; |
9884 |
9914 # if !defined(HAS_GETTIMEOFDAY) |
9885 #if !defined(HAS_GETTIMEOFDAY) |
9915 # if defined(HAS_FTIME) |
9886 # if defined(HAS_FTIME) |
|
9887 { |
9916 { |
9888 struct timeb timebuffer; |
9917 struct timeb timebuffer; |
9889 |
9918 |
9890 ftime(&timebuffer); |
9919 ftime(&timebuffer); |
9891 _secs = timebuffer.time; |
9920 _secs = timebuffer.time; |
9892 _millis = timebuffer.millitm; |
9921 _millis = timebuffer.millitm; |
9893 } |
9922 } |
9894 # define HAVE_TIME |
9923 # define HAVE_TIME |
9895 # endif /* HAS_FTIME */ |
9924 # endif /* HAS_FTIME */ |
9896 #endif /* no HAS_GETTIMEOFDAY */ |
9925 # endif /* no HAS_GETTIMEOFDAY */ |
9897 |
9926 |
9898 #ifndef HAVE_TIME |
9927 # ifndef HAVE_TIME |
9899 /* |
9928 /* |
9900 * use HAS_GETTIMEOFDAY even if HAS_GETTIMEOFDAY is undefined here. |
9929 * use HAS_GETTIMEOFDAY even if HAS_GETTIMEOFDAY is undefined here. |
9901 * Will result in a linkage error if not fixed and neither ftime() nor time() is used. |
9930 * Will result in a linkage error if not fixed and neither ftime() nor time() is used. |
9902 */ |
9931 */ |
9903 |
9932 |
9911 gettimeofday(&tb, NULL /* &tzb */); |
9940 gettimeofday(&tb, NULL /* &tzb */); |
9912 |
9941 |
9913 _secs = tb.tv_sec; |
9942 _secs = tb.tv_sec; |
9914 _millis = tb.tv_usec / 1000; |
9943 _millis = tb.tv_usec / 1000; |
9915 } |
9944 } |
9916 #endif |
9945 # endif |
9917 |
9946 |
9918 #if __POINTER_SIZE__ == 8 |
9947 # if __POINTER_SIZE__ == 8 |
9919 { |
9948 { |
9920 unsigned INT rslt; |
9949 unsigned INT rslt; |
9921 |
9950 |
9922 rslt = (unsigned INT)_secs * 1000 + _millis; |
9951 rslt = (unsigned INT)_secs * 1000 + _millis; |
9923 RETURN (__MKUINT(rslt)); |
9952 RETURN (__MKUINT(rslt)); |
9924 } |
9953 } |
9925 #else |
9954 # else |
9926 # ifdef HAS_LONGLONG |
9955 # ifdef HAS_LONGLONG |
9927 { |
9956 { |
9928 unsigned long long rslt; |
9957 unsigned long long rslt; |
9929 |
9958 |
9930 rslt = (unsigned long long)_secs * 1000 + _millis; |
9959 rslt = (unsigned long long)_secs * 1000 + _millis; |
9931 RETURN (__MKLARGEINT64(1, (unsigned INT)(rslt & 0xFFFFFFFF), (unsigned INT)(rslt >> 32))); |
9960 RETURN (__MKLARGEINT64(1, (unsigned INT)(rslt & 0xFFFFFFFF), (unsigned INT)(rslt >> 32))); |
9932 } |
9961 } |
9933 # else |
9962 # else |
9934 seconds = __MKUINT(_secs); |
9963 seconds = __MKUINT(_secs); |
9935 millis = __MKUINT(_millis); |
9964 millis = __MKUINT(_millis); |
9936 # endif /* long long */ |
9965 # endif /* long long */ |
9937 #endif /* __POINTER_SIZE__ == 8 */ |
9966 # endif /* __POINTER_SIZE__ == 8 */ |
|
9967 #endif /* SCHTEAM */ |
9938 %}. |
9968 %}. |
9939 |
|
9940 seconds notNil ifTrue:[ |
9969 seconds notNil ifTrue:[ |
9941 ^ (seconds * 1000) + millis |
9970 ^ (seconds * 1000) + millis |
9942 ]. |
9971 ]. |
9943 |
9972 |
9944 self primitiveFailed. |
9973 self primitiveFailed. |
14243 ! ! |
14272 ! ! |
14244 |
14273 |
14245 !UnixOperatingSystem class methodsFor:'documentation'! |
14274 !UnixOperatingSystem class methodsFor:'documentation'! |
14246 |
14275 |
14247 version |
14276 version |
14248 ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.436 2015-04-21 19:41:36 cg Exp $' |
14277 ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.437 2015-04-24 08:17:57 cg Exp $' |
14249 ! |
14278 ! |
14250 |
14279 |
14251 version_CVS |
14280 version_CVS |
14252 ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.436 2015-04-21 19:41:36 cg Exp $' |
14281 ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.437 2015-04-24 08:17:57 cg Exp $' |
14253 ! ! |
14282 ! ! |
14254 |
14283 |
14255 |
14284 |
14256 UnixOperatingSystem initialize! |
14285 UnixOperatingSystem initialize! |
14257 UnixOperatingSystem::ELFConstants initialize! |
14286 UnixOperatingSystem::ELFConstants initialize! |