--- a/UnixOperatingSystem.st Fri Apr 24 10:12:43 2015 +0200
+++ b/UnixOperatingSystem.st Fri Apr 24 10:17:57 2015 +0200
@@ -1877,7 +1877,8 @@
closedir( (DIR *)(__FILEVal(dirPointer)) );
}
#endif
-%}
+%}.
+ self primitiveFailed
!
nextLinkInfoFrom:aDirectoryStream dirPointer:dirPointer
@@ -2018,7 +2019,9 @@
%{ /* NOCONTEXT */
RETURN ( __mkSmallInteger(errno) );
-%}
+%}.
+ ^ 0
+
"
OperatingSystem currentErrorNumber
"
@@ -3446,7 +3449,6 @@
"/
"/ not supported by OS
"/
-
^ UnsupportedOperationSignal raise
"
@@ -4123,7 +4125,9 @@
%{
sync();
-%}.
+ RETURN (self);
+%}.
+ ^ self primitiveFailed
!
syncFileSystem:handle
@@ -4146,7 +4150,7 @@
self sync.
"
- '/etc/passwd' asFilename readStream syncFileSystem
+ '/etc/passwd' asFilename readStream syncFileSystem
"
!
@@ -4661,6 +4665,8 @@
On MSDOS, this will return false;
on a real OS, we return true."
+ "/ actually, this is wrong and may depend on the mounted volume;
+ "/ so we need a query for a particular directory (and/or volume).
^ true
"Modified: / 5.6.1998 / 18:35:18 / cg"
@@ -9697,9 +9703,17 @@
|seconds micros error|
%{
+#ifdef __SCHTEAM__
+ {
+ long nanos = System.nanoTime();
+
+ return context._RETURN( STInteger._new(nanos / 1000) );
+ }
+ /* NOTREACHED */
+#else
unsigned long _secs, _micros;
-#if defined(_POSIX_MONOTONIC_CLOCK) && defined(CLOCK_MONOTONIC) && !defined(NO_CLOCK_GETTIME)
+# if defined(_POSIX_MONOTONIC_CLOCK) && defined(CLOCK_MONOTONIC) && !defined(NO_CLOCK_GETTIME)
struct timespec ts;
static int has_clock_gettime = 1;
@@ -9716,9 +9730,9 @@
has_clock_gettime = 0;
}
}
-#endif
-
-#if defined(HAS_GETTIMEOFDAY)
+# endif
+
+# if defined(HAS_GETTIMEOFDAY)
struct timeval tb;
gettimeofday(&tb, NULL /* &tzb */);
@@ -9729,31 +9743,32 @@
_secs = tb.tv_sec;
_micros = tb.tv_usec;
-#endif
+# endif
out:
-#if __POINTER_SIZE__ == 8
+# if __POINTER_SIZE__ == 8
{
unsigned INT rslt;
rslt = (unsigned INT)_secs * 1000000 + _micros;
RETURN (__MKUINT(rslt));
}
-#else
-# ifdef HAS_LONGLONG
+# else
+# ifdef HAS_LONGLONG
{
unsigned long long rslt;
rslt = (unsigned long long)_secs * 1000000 + _micros;
RETURN (__MKLARGEINT64(1, (unsigned INT)(rslt & 0xFFFFFFFF), (unsigned INT)(rslt >> 32)));
}
-# else
+# else
seconds = __MKUINT(_secs);
micros = __MKUINT(_micros);
-# endif /* long long */
-#endif /* __POINTER_SIZE__ == 8 */
+# endif /* long long */
+# endif /* __POINTER_SIZE__ == 8 */
err:;
+#endif /* not SCHTEAM */
%}.
seconds notNil ifTrue:[
@@ -9787,10 +9802,16 @@
"
%{ /* NOCONTEXT */
-
+#ifdef __SCHTEAM__
+ {
+ long millis = System.currentTimeMillis();
+ return context._RETURN( STInteger._new(millis) );
+ }
+ /* NOTREACHED */
+#else
unsigned long t = 0;
-#if defined(_POSIX_MONOTONIC_CLOCK) && defined(CLOCK_MONOTONIC) && !defined(NO_CLOCK_GETTIME)
+# if defined(_POSIX_MONOTONIC_CLOCK) && defined(CLOCK_MONOTONIC) && !defined(NO_CLOCK_GETTIME)
static has_clock_gettime = 1;
struct timespec ts;
@@ -9806,14 +9827,14 @@
has_clock_gettime = 0;
}
}
-#endif /* _POSIX_MONOTONIC_CLOCK */
-
-#if defined(_SC_CLK_TCK)
+# endif /* _POSIX_MONOTONIC_CLOCK */
+
+# if defined(_SC_CLK_TCK)
/*
* We prefer times here, since it is monotonic and immune to clock changes
* but: it has less precision!
*/
-# include <sys/times.h>
+# include <sys/times.h>
static int millisecondsPerTick;
clock_t ticks;
@@ -9837,7 +9858,7 @@
t = ticks * millisecondsPerTick;
-#else /* !times */
+# else /* !times */
/* assume HAS_GETTIMEOFDAY
* - will result in a linkage error if not fixed.
@@ -9847,12 +9868,13 @@
gettimeofday(&tb, NULL);
t = tb.tv_sec*1000 + tb.tv_usec/1000;
-#endif
+# endif
out:
RETURN ( __mkSmallInteger(t & 0x1FFFFFFF) );
err:;
+#endif /* not SCHTEAM */
%}.
self primitiveFailed
@@ -9880,10 +9902,17 @@
|seconds millis|
%{
+#ifdef __SCHTEAM__
+ {
+ long millisSince1970 = java.lang.System.currentTimeMillis();
+ return context._RETURN( STInteger._new(millisSince1970));
+ }
+ /* NOTREACHED */
+#else
+
unsigned long _secs, _millis;
-
-#if !defined(HAS_GETTIMEOFDAY)
-# if defined(HAS_FTIME)
+# if !defined(HAS_GETTIMEOFDAY)
+# if defined(HAS_FTIME)
{
struct timeb timebuffer;
@@ -9891,11 +9920,11 @@
_secs = timebuffer.time;
_millis = timebuffer.millitm;
}
-# define HAVE_TIME
-# endif /* HAS_FTIME */
-#endif /* no HAS_GETTIMEOFDAY */
-
-#ifndef HAVE_TIME
+# define HAVE_TIME
+# endif /* HAS_FTIME */
+# endif /* no HAS_GETTIMEOFDAY */
+
+# ifndef HAVE_TIME
/*
* use HAS_GETTIMEOFDAY even if HAS_GETTIMEOFDAY is undefined here.
* Will result in a linkage error if not fixed and neither ftime() nor time() is used.
@@ -9913,30 +9942,30 @@
_secs = tb.tv_sec;
_millis = tb.tv_usec / 1000;
}
-#endif
-
-#if __POINTER_SIZE__ == 8
+# endif
+
+# if __POINTER_SIZE__ == 8
{
unsigned INT rslt;
rslt = (unsigned INT)_secs * 1000 + _millis;
RETURN (__MKUINT(rslt));
}
-#else
-# ifdef HAS_LONGLONG
+# else
+# ifdef HAS_LONGLONG
{
unsigned long long rslt;
rslt = (unsigned long long)_secs * 1000 + _millis;
RETURN (__MKLARGEINT64(1, (unsigned INT)(rslt & 0xFFFFFFFF), (unsigned INT)(rslt >> 32)));
}
-# else
+# else
seconds = __MKUINT(_secs);
millis = __MKUINT(_millis);
-# endif /* long long */
-#endif /* __POINTER_SIZE__ == 8 */
-%}.
-
+# endif /* long long */
+# endif /* __POINTER_SIZE__ == 8 */
+#endif /* SCHTEAM */
+%}.
seconds notNil ifTrue:[
^ (seconds * 1000) + millis
].
@@ -14245,11 +14274,11 @@
!UnixOperatingSystem class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.436 2015-04-21 19:41:36 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.437 2015-04-24 08:17:57 cg Exp $'
!
version_CVS
- ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.436 2015-04-21 19:41:36 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.437 2015-04-24 08:17:57 cg Exp $'
! !