--- a/UnixOperatingSystem.st Wed Jul 16 16:07:30 2003 +0200
+++ b/UnixOperatingSystem.st Thu Jul 17 14:06:23 2003 +0200
@@ -7958,16 +7958,16 @@
day = __MKSMALLINT(tmPtr->tm_mday);
%}.
year isNil ifTrue:[
- i := self computeTimeAndDateFrom:osTime.
- year := i year.
- month := i month.
- day := i day.
+ i := self computeTimeAndDateFrom:osTime.
+ year := i year.
+ month := i month.
+ day := i day.
].
aBlock value:year value:month value:day
"
OperatingSystem computeDatePartsOf:0 for:[:y :m :d |
- y printCR. m printCR. d printCR
+ y printCR. m printCR. d printCR
]
"
!
@@ -8059,7 +8059,7 @@
"
OperatingSystem computeTimePartsOf:100 for:[:h :m :s :milli |
- Transcript show:h; space; show:m; space; show:s; space; showCR:milli.
+ Transcript show:h; space; show:m; space; show:s; space; showCR:milli.
]
"
!
@@ -8102,17 +8102,17 @@
|seconds millis micros|
%{
- long _seconds = 0;
- long _millis = 0;
- long _micros = 0;
+ long __seconds = 0;
+ long __millis = 0;
+ long __micros = 0;
#if !defined(HAS_GETTIMEOFDAY)
# if defined(HAS_FTIME)
struct timeb timebuffer;
ftime(&timebuffer);
- _seconds = timebuffer.time;
- _millis = timebuffer.millitm;
+ __seconds = timebuffer.time;
+ __millis = timebuffer.millitm;
# define HAVE_TIME
# endif
@@ -8125,9 +8125,9 @@
struct tms tb;
ticks = times(&tb);
- _seconds = ticks / HZ;
- ticks -= (_seconds * HZ);
- _millis = ticks * 1000 / HZ;
+ __seconds = ticks / HZ;
+ ticks -= (__seconds * HZ);
+ __millis = ticks * 1000 / HZ;
# define HAVE_TIME
# endif /* old SYSV stuff */
# endif
@@ -8143,21 +8143,20 @@
* bsd time
*/
struct timeval tb;
- /* struct timezone tzb; */
gettimeofday(&tb, NULL /* &tzb */);
- _seconds = tb.tv_sec;
- _micros = tb.tv_usec;
- if (_micros >= (1000*1000)) {
+ __seconds = tb.tv_sec;
+ __micros = tb.tv_usec;
+ if (__micros >= (1000*1000)) {
printf("oops\n");
}
#endif
#undef HAVE_TIME
- seconds = __MKINT(_seconds);
- millis = __MKINT(_millis);
- micros = __MKINT(_micros);
+ seconds = __MKINT(__seconds);
+ millis = __MKINT(__millis);
+ micros = __MKINT(__micros);
%}.
^ (((seconds * 1000) + millis) * 1000) + micros
@@ -8456,9 +8455,9 @@
tt = (TIME_T)t;
if (isLocalTime == true) {
- tmPtr = localtime(&tt);
+ tmPtr = localtime(&tt);
} else {
- tmPtr = gmtime(&tt);
+ tmPtr = gmtime(&tt);
}
hours = __MKSMALLINT(tmPtr->tm_hour);
minutes = __MKSMALLINT(tmPtr->tm_min);
@@ -8474,16 +8473,16 @@
dst = (tmPtr->tm_isdst == 0 ? false : true);
%}.
info
- year:year
- month:month
- day:day
- hours:hours
- minutes:minutes
- seconds:seconds
- utcOffset:utcOffset
- dst:dst
- dayInYear:yDay
- dayInWeek:wDay.
+ year:year
+ month:month
+ day:day
+ hours:hours
+ minutes:minutes
+ seconds:seconds
+ utcOffset:utcOffset
+ dst:dst
+ dayInYear:yDay
+ dayInWeek:wDay.
^ info
"
@@ -8986,9 +8985,9 @@
!
selectOnAnyReadable:readFdArray writable:writeFdArray exception:exceptFdArray
- readableInto:readableResultFdArray writableInto:writableResultFdArray
- exceptionInto:exceptionResultFdArray
- withTimeOut:millis
+ readableInto:readableResultFdArray writableInto:writableResultFdArray
+ exceptionInto:exceptionResultFdArray
+ withTimeOut:millis
"wait for any fd in readFdArray (an Array of integers) to become ready for reading,
writeFdArray to become ready for writing,
@@ -9018,26 +9017,26 @@
#endif
if (!__isSmallInteger(millis)) {
- goto fail;
+ goto fail;
}
if (readableResultFdArray != nil) {
- if (! __isArrayLike(readableResultFdArray)) {
- goto fail;
- }
- resultSizeReadable = __arraySize(readableResultFdArray);
+ if (! __isArrayLike(readableResultFdArray)) {
+ goto fail;
+ }
+ resultSizeReadable = __arraySize(readableResultFdArray);
}
if (writableResultFdArray != nil) {
- if (! __isArrayLike(writableResultFdArray)) {
- goto fail;
- }
- resultSizeWritable = __arraySize(writableResultFdArray);
+ if (! __isArrayLike(writableResultFdArray)) {
+ goto fail;
+ }
+ resultSizeWritable = __arraySize(writableResultFdArray);
}
if (exceptionResultFdArray != nil) {
- if (! __isArrayLike(exceptionResultFdArray)) {
- goto fail;
- }
- resultSizeException = __arraySize(exceptionResultFdArray);
+ if (! __isArrayLike(exceptionResultFdArray)) {
+ goto fail;
+ }
+ resultSizeException = __arraySize(exceptionResultFdArray);
}
FD_ZERO(&rset);
@@ -9046,114 +9045,114 @@
maxF = -1;
if (__isNonNilObject(readFdArray)) {
- int i, count;
-
- if (! __isArrayLike(readFdArray)) {
- goto fail;
- }
- count = __arraySize(readFdArray);
-
- for (i=0; i<count;i++) {
- OBJ fd;
-
- fd = __ArrayInstPtr(readFdArray)->a_element[i];
- if (fd != nil) {
- if (! __isSmallInteger(fd)) {
- if (@global(InfoPrinting) == true) {
- fprintf(stderr, "[OS] warning: funny read-fd (0x%x) given to select\n", fd);
- }
- } else {
- int f;
-
- f = __intVal(fd);
- if ((unsigned)f < FD_SETSIZE) {
- FD_SET(f, &rset);
- if (f > maxF) maxF = f;
- numFds++;
- } else {
- if (@global(InfoPrinting) == true) {
- fprintf(stderr, "[OS] warning: huge read-fd (0x%x) given to select\n", fd);
- }
- }
- }
- }
- }
+ int i, count;
+
+ if (! __isArrayLike(readFdArray)) {
+ goto fail;
+ }
+ count = __arraySize(readFdArray);
+
+ for (i=0; i<count;i++) {
+ OBJ fd;
+
+ fd = __ArrayInstPtr(readFdArray)->a_element[i];
+ if (fd != nil) {
+ if (! __isSmallInteger(fd)) {
+ if (@global(InfoPrinting) == true) {
+ fprintf(stderr, "[OS] warning: funny read-fd (0x%x) given to select\n", fd);
+ }
+ } else {
+ int f;
+
+ f = __intVal(fd);
+ if ((unsigned)f < FD_SETSIZE) {
+ FD_SET(f, &rset);
+ if (f > maxF) maxF = f;
+ numFds++;
+ } else {
+ if (@global(InfoPrinting) == true) {
+ fprintf(stderr, "[OS] warning: huge read-fd (0x%x) given to select\n", fd);
+ }
+ }
+ }
+ }
+ }
}
if (__isNonNilObject(writeFdArray)) {
- int i, count;
-
- if (! __isArrayLike(writeFdArray)) {
- goto fail;
- }
- count = __arraySize(writeFdArray);
- for (i=0; i<count;i++) {
- OBJ fd;
-
- fd = __ArrayInstPtr(writeFdArray)->a_element[i];
- if (fd != nil) {
- if (! __isSmallInteger(fd)) {
- if (@global(InfoPrinting) == true) {
- fprintf(stderr, "[OS] warning: funny write-fd (0x%x) given to select\n", fd);
- }
- } else {
- int f;
-
- f = __intVal(fd);
- if ((unsigned)f < FD_SETSIZE) {
- FD_SET(f, &wset);
- if (f > maxF) maxF = f;
- numFds++;
- } else {
- if (@global(InfoPrinting) == true) {
- fprintf(stderr, "[OS] warning: huge write-fd (0x%x) given to select\n", fd);
- }
- }
- }
- }
- }
+ int i, count;
+
+ if (! __isArrayLike(writeFdArray)) {
+ goto fail;
+ }
+ count = __arraySize(writeFdArray);
+ for (i=0; i<count;i++) {
+ OBJ fd;
+
+ fd = __ArrayInstPtr(writeFdArray)->a_element[i];
+ if (fd != nil) {
+ if (! __isSmallInteger(fd)) {
+ if (@global(InfoPrinting) == true) {
+ fprintf(stderr, "[OS] warning: funny write-fd (0x%x) given to select\n", fd);
+ }
+ } else {
+ int f;
+
+ f = __intVal(fd);
+ if ((unsigned)f < FD_SETSIZE) {
+ FD_SET(f, &wset);
+ if (f > maxF) maxF = f;
+ numFds++;
+ } else {
+ if (@global(InfoPrinting) == true) {
+ fprintf(stderr, "[OS] warning: huge write-fd (0x%x) given to select\n", fd);
+ }
+ }
+ }
+ }
+ }
}
if (__isNonNilObject(exceptFdArray)) {
- int i, count;
-
- if (! __isArrayLike(exceptFdArray)) {
- goto fail;
- }
- count = __arraySize(exceptFdArray);
- for (i=0; i<count;i++) {
- OBJ fd;
-
- fd = __ArrayInstPtr(exceptFdArray)->a_element[i];
- if (fd != nil) {
- if (! __isSmallInteger(fd)) {
- if (@global(InfoPrinting) == true) {
- fprintf(stderr, "[OS] warning: funny except-fd (0x%x) given to select\n", fd);
- }
- } else {
- int f;
-
- f = __intVal(fd);
- if ((unsigned)f < FD_SETSIZE) {
- FD_SET(f, &eset);
- if (f > maxF) maxF = f;
- numFds++;
- } else {
- if (@global(InfoPrinting) == true) {
- fprintf(stderr, "[OS] warning: huge except-fd (0x%x) given to select\n", fd);
- }
- }
- }
- }
- }
+ int i, count;
+
+ if (! __isArrayLike(exceptFdArray)) {
+ goto fail;
+ }
+ count = __arraySize(exceptFdArray);
+ for (i=0; i<count;i++) {
+ OBJ fd;
+
+ fd = __ArrayInstPtr(exceptFdArray)->a_element[i];
+ if (fd != nil) {
+ if (! __isSmallInteger(fd)) {
+ if (@global(InfoPrinting) == true) {
+ fprintf(stderr, "[OS] warning: funny except-fd (0x%x) given to select\n", fd);
+ }
+ } else {
+ int f;
+
+ f = __intVal(fd);
+ if ((unsigned)f < FD_SETSIZE) {
+ FD_SET(f, &eset);
+ if (f > maxF) maxF = f;
+ numFds++;
+ } else {
+ if (@global(InfoPrinting) == true) {
+ fprintf(stderr, "[OS] warning: huge except-fd (0x%x) given to select\n", fd);
+ }
+ }
+ }
+ }
+ }
}
t = __intVal(millis);
if (t) {
- wt.tv_sec = t / 1000;
- wt.tv_usec = (t % 1000) * 1000;
+ wt.tv_sec = t / 1000;
+ wt.tv_usec = (t % 1000) * 1000;
} else {
- wt.tv_sec = wt.tv_usec = 0;
+ wt.tv_sec = wt.tv_usec = 0;
}
/*
@@ -9164,79 +9163,79 @@
errno = 0;
if (t == 0) {
- /*
- * if there is no timeout time, we can stay here interruptable.
- */
- do {
- ret = select(maxF+1, &rset, &wset, &eset, &wt);
- } while ((ret < 0) && (errno == EINTR));
+ /*
+ * if there is no timeout time, we can stay here interruptable.
+ */
+ do {
+ ret = select(maxF+1, &rset, &wset, &eset, &wt);
+ } while ((ret < 0) && (errno == EINTR));
} else {
- do {
- ret = select(maxF+1, &rset, &wset, &eset, &wt);
- /*
- * for now: dont loop; if we did, we had to adjust the vt-timeval;
- * could otherwise stay in this loop forever ...
- * Premature ret (before the time expired) must be handled by the caller.
- * A good solution is to update the wt-timeval and redo the select.
- */
- } while (0 /* (ret < 0) && (errno == EINTR) */ );
+ do {
+ ret = select(maxF+1, &rset, &wset, &eset, &wt);
+ /*
+ * for now: dont loop; if we did, we had to adjust the vt-timeval;
+ * could otherwise stay in this loop forever ...
+ * Premature ret (before the time expired) must be handled by the caller.
+ * A good solution is to update the wt-timeval and redo the select.
+ */
+ } while (0 /* (ret < 0) && (errno == EINTR) */ );
}
__END_INTERRUPTABLE__
if (ret > 0) {
- OBJ *__resultR = __arrayVal(readableResultFdArray);
- OBJ *__resultW = __arrayVal(writableResultFdArray);
- OBJ *__resultE = __arrayVal(exceptionResultFdArray);
- int i;
-
- for (i=0; i <= maxF; i++) {
- if (FD_ISSET(i, &rset)) {
- if (cntR < resultSizeReadable) {
- __resultR[cntR] = __MKSMALLINT(i);
- }
- cntR++;
- }
-
- if (FD_ISSET(i, &wset)) {
- if (cntW < resultSizeWritable) {
- __resultW[cntW] = __MKSMALLINT(i);
- }
- cntW++;
- }
-
- if (FD_ISSET(i, &eset)) {
- if (cntE < resultSizeException) {
- __resultE[cntE] = __MKSMALLINT(i);
- }
- cntE++;
- }
- }
- /* add a delimiter */
- if (cntR < resultSizeReadable) {
- __resultR[cntR] = nil;
- }
- if (cntW < resultSizeWritable) {
- __resultW[cntW] = nil;
- }
- if (cntE < resultSizeException) {
- __resultE[cntE] = nil;
- }
+ OBJ *__resultR = __arrayVal(readableResultFdArray);
+ OBJ *__resultW = __arrayVal(writableResultFdArray);
+ OBJ *__resultE = __arrayVal(exceptionResultFdArray);
+ int i;
+
+ for (i=0; i <= maxF; i++) {
+ if (FD_ISSET(i, &rset)) {
+ if (cntR < resultSizeReadable) {
+ __resultR[cntR] = __MKSMALLINT(i);
+ }
+ cntR++;
+ }
+
+ if (FD_ISSET(i, &wset)) {
+ if (cntW < resultSizeWritable) {
+ __resultW[cntW] = __MKSMALLINT(i);
+ }
+ cntW++;
+ }
+
+ if (FD_ISSET(i, &eset)) {
+ if (cntE < resultSizeException) {
+ __resultE[cntE] = __MKSMALLINT(i);
+ }
+ cntE++;
+ }
+ }
+ /* add a delimiter */
+ if (cntR < resultSizeReadable) {
+ __resultR[cntR] = nil;
+ }
+ if (cntW < resultSizeWritable) {
+ __resultW[cntW] = nil;
+ }
+ if (cntE < resultSizeException) {
+ __resultE[cntE] = nil;
+ }
- RETURN (__MKSMALLINT(cntR+cntW+cntE));
+ RETURN (__MKSMALLINT(cntR+cntW+cntE));
} else {
- if (ret < 0) {
- if (errno == EINTR) {
- errno = 0;
- @global(LastErrorNumber) = nil;
- } else {
- if (@global(InfoPrinting) == true) {
- fprintf(stderr, "OS [info]: select errno = %d\n", errno);
- }
- @global(LastErrorNumber) = __MKSMALLINT(errno);
- }
- } else {
- @global(LastErrorNumber) = nil;
- }
+ if (ret < 0) {
+ if (errno == EINTR) {
+ errno = 0;
+ @global(LastErrorNumber) = nil;
+ } else {
+ if (@global(InfoPrinting) == true) {
+ fprintf(stderr, "OS [info]: select errno = %d\n", errno);
+ }
+ @global(LastErrorNumber) = __MKSMALLINT(errno);
+ }
+ } else {
+ @global(LastErrorNumber) = nil;
+ }
}
/*
@@ -9276,159 +9275,159 @@
#endif
if (__isSmallInteger(millis)) {
- FD_ZERO(&rset);
- FD_ZERO(&wset);
- FD_ZERO(&eset);
-
- maxF = -1;
- if (__isNonNilObject(readFdArray)) {
- if (! __isArrayLike(readFdArray)) {
- goto fail;
- }
- count = __arraySize(readFdArray);
-
- for (i=0; i<count;i++) {
- fd = __ArrayInstPtr(readFdArray)->a_element[i];
- if (fd != nil) {
- if (! __isSmallInteger(fd)) {
- if (@global(InfoPrinting) == true) {
- fprintf(stderr, "[OS] warning: funny read-fd (0x%x) given to select\n", fd);
- }
- } else {
- f = __intVal(fd);
- if ((unsigned)f < FD_SETSIZE) {
- FD_SET(f, &rset);
- if (f > maxF) maxF = f;
- numFds++;
- } else {
- if (@global(InfoPrinting) == true) {
- fprintf(stderr, "[OS] warning: huge read-fd (0x%x) given to select\n", fd);
- }
- }
- }
- }
- }
- }
-
- if (__isNonNilObject(writeFdArray)) {
- if (! __isArrayLike(writeFdArray)) {
- goto fail;
- }
- count = __arraySize(writeFdArray);
- for (i=0; i<count;i++) {
- fd = __ArrayInstPtr(writeFdArray)->a_element[i];
- if (fd != nil) {
- if (! __isSmallInteger(fd)) {
- if (@global(InfoPrinting) == true) {
- fprintf(stderr, "[OS] warning: funny write-fd (0x%x) given to select\n", fd);
- }
- } else {
- f = __intVal(fd);
- if ((unsigned)f < FD_SETSIZE) {
- FD_SET(f, &wset);
- if (f > maxF) maxF = f;
- numFds++;
- } else {
- if (@global(InfoPrinting) == true) {
- fprintf(stderr, "[OS] warning: huge write-fd (0x%x) given to select\n", fd);
- }
- }
- }
- }
- }
- }
-
- if (__isNonNilObject(exceptFdArray)) {
- if (! __isArrayLike(exceptFdArray)) {
- goto fail;
- }
- count = __arraySize(exceptFdArray);
- for (i=0; i<count;i++) {
- fd = __ArrayInstPtr(exceptFdArray)->a_element[i];
- if (fd != nil) {
- if (! __isSmallInteger(fd)) {
- if (@global(InfoPrinting) == true) {
- fprintf(stderr, "[OS] warning: funny except-fd (0x%x) given to select\n", fd);
- }
- } else {
- f = __intVal(fd);
- if ((unsigned)f < FD_SETSIZE) {
- FD_SET(f, &eset);
- if (f > maxF) maxF = f;
- numFds++;
- } else {
- if (@global(InfoPrinting) == true) {
- fprintf(stderr, "[OS] warning: huge except-fd (0x%x) given to select\n", fd);
- }
- }
- }
- }
- }
- }
-
- t = __intVal(millis);
- if (t) {
- wt.tv_sec = t / 1000;
- wt.tv_usec = (t % 1000) * 1000;
- } else {
- wt.tv_sec = wt.tv_usec = 0;
- }
-
- /*
- * make certain, that interrupt gets us out of the select
- * However, we must then care for moved objects.
- */
- __BEGIN_INTERRUPTABLE__
- errno = 0;
-
- if (t == 0) {
- /*
- * if there is no timeout time, we can stay here interruptable.
- */
- do {
- ret = select(maxF+1, &rset, &wset, &eset, &wt);
- } while ((ret < 0) && (errno == EINTR));
- } else {
- do {
- ret = select(maxF+1, &rset, &wset, &eset, &wt);
- /*
- * for now: dont loop; if we did, we had to adjust the vt-timeval;
- * could otherwise stay in this loop forever ...
- * Premature ret (before the time expired) must be handled by the caller.
- * A good solution is to update the wt-timeval and redo the select.
- */
- } while (0 /* (ret < 0) && (errno == EINTR) */ );
- }
- __END_INTERRUPTABLE__
-
- if (ret > 0) {
- for (i=0; i <= maxF; i++) {
- if (FD_ISSET(i, &rset)
- || FD_ISSET(i, &wset)
- || FD_ISSET(i, &eset)) {
- RETURN ( __MKSMALLINT(i) );
- }
- }
- } else {
- if (ret < 0) {
- if (errno == EINTR) {
- errno = 0;
- @global(LastErrorNumber) = nil;
- } else {
- if (@global(InfoPrinting) == true) {
- fprintf(stderr, "OS [info]: select errno = %d\n", errno);
- }
- @global(LastErrorNumber) = __MKSMALLINT(errno);
- }
- } else {
- @global(LastErrorNumber) = nil;
- }
- }
-
- /*
- * Return nil (means time expired or interrupted)
- */
- RETURN ( nil );
+ FD_ZERO(&rset);
+ FD_ZERO(&wset);
+ FD_ZERO(&eset);
+
+ maxF = -1;
+ if (__isNonNilObject(readFdArray)) {
+ if (! __isArrayLike(readFdArray)) {
+ goto fail;
+ }
+ count = __arraySize(readFdArray);
+
+ for (i=0; i<count;i++) {
+ fd = __ArrayInstPtr(readFdArray)->a_element[i];
+ if (fd != nil) {
+ if (! __isSmallInteger(fd)) {
+ if (@global(InfoPrinting) == true) {
+ fprintf(stderr, "[OS] warning: funny read-fd (0x%x) given to select\n", fd);
+ }
+ } else {
+ f = __intVal(fd);
+ if ((unsigned)f < FD_SETSIZE) {
+ FD_SET(f, &rset);
+ if (f > maxF) maxF = f;
+ numFds++;
+ } else {
+ if (@global(InfoPrinting) == true) {
+ fprintf(stderr, "[OS] warning: huge read-fd (0x%x) given to select\n", fd);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (__isNonNilObject(writeFdArray)) {
+ if (! __isArrayLike(writeFdArray)) {
+ goto fail;
+ }
+ count = __arraySize(writeFdArray);
+ for (i=0; i<count;i++) {
+ fd = __ArrayInstPtr(writeFdArray)->a_element[i];
+ if (fd != nil) {
+ if (! __isSmallInteger(fd)) {
+ if (@global(InfoPrinting) == true) {
+ fprintf(stderr, "[OS] warning: funny write-fd (0x%x) given to select\n", fd);
+ }
+ } else {
+ f = __intVal(fd);
+ if ((unsigned)f < FD_SETSIZE) {
+ FD_SET(f, &wset);
+ if (f > maxF) maxF = f;
+ numFds++;
+ } else {
+ if (@global(InfoPrinting) == true) {
+ fprintf(stderr, "[OS] warning: huge write-fd (0x%x) given to select\n", fd);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (__isNonNilObject(exceptFdArray)) {
+ if (! __isArrayLike(exceptFdArray)) {
+ goto fail;
+ }
+ count = __arraySize(exceptFdArray);
+ for (i=0; i<count;i++) {
+ fd = __ArrayInstPtr(exceptFdArray)->a_element[i];
+ if (fd != nil) {
+ if (! __isSmallInteger(fd)) {
+ if (@global(InfoPrinting) == true) {
+ fprintf(stderr, "[OS] warning: funny except-fd (0x%x) given to select\n", fd);
+ }
+ } else {
+ f = __intVal(fd);
+ if ((unsigned)f < FD_SETSIZE) {
+ FD_SET(f, &eset);
+ if (f > maxF) maxF = f;
+ numFds++;
+ } else {
+ if (@global(InfoPrinting) == true) {
+ fprintf(stderr, "[OS] warning: huge except-fd (0x%x) given to select\n", fd);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ t = __intVal(millis);
+ if (t) {
+ wt.tv_sec = t / 1000;
+ wt.tv_usec = (t % 1000) * 1000;
+ } else {
+ wt.tv_sec = wt.tv_usec = 0;
+ }
+
+ /*
+ * make certain, that interrupt gets us out of the select
+ * However, we must then care for moved objects.
+ */
+ __BEGIN_INTERRUPTABLE__
+ errno = 0;
+
+ if (t == 0) {
+ /*
+ * if there is no timeout time, we can stay here interruptable.
+ */
+ do {
+ ret = select(maxF+1, &rset, &wset, &eset, &wt);
+ } while ((ret < 0) && (errno == EINTR));
+ } else {
+ do {
+ ret = select(maxF+1, &rset, &wset, &eset, &wt);
+ /*
+ * for now: dont loop; if we did, we had to adjust the vt-timeval;
+ * could otherwise stay in this loop forever ...
+ * Premature ret (before the time expired) must be handled by the caller.
+ * A good solution is to update the wt-timeval and redo the select.
+ */
+ } while (0 /* (ret < 0) && (errno == EINTR) */ );
+ }
+ __END_INTERRUPTABLE__
+
+ if (ret > 0) {
+ for (i=0; i <= maxF; i++) {
+ if (FD_ISSET(i, &rset)
+ || FD_ISSET(i, &wset)
+ || FD_ISSET(i, &eset)) {
+ RETURN ( __MKSMALLINT(i) );
+ }
+ }
+ } else {
+ if (ret < 0) {
+ if (errno == EINTR) {
+ errno = 0;
+ @global(LastErrorNumber) = nil;
+ } else {
+ if (@global(InfoPrinting) == true) {
+ fprintf(stderr, "OS [info]: select errno = %d\n", errno);
+ }
+ @global(LastErrorNumber) = __MKSMALLINT(errno);
+ }
+ } else {
+ @global(LastErrorNumber) = nil;
+ }
+ }
+
+ /*
+ * Return nil (means time expired or interrupted)
+ */
+ RETURN ( nil );
}
fail: ;
@@ -9462,17 +9461,17 @@
# endif
# if defined(DELAY_FLAG)
if (__isSmallInteger(fd)) {
- int f = __intVal(fd);
-
- flags = fcntl(f, F_GETFL, 0);
- if (aBoolean == true) {
- ret = fcntl(f, F_SETFL, flags & ~DELAY_FLAG);
- } else {
- ret = fcntl(f, F_SETFL, flags | DELAY_FLAG);
- }
- if (ret >= 0) {
- RETURN ((flags & DELAY_FLAG) ? false : true );
- }
+ int f = __intVal(fd);
+
+ flags = fcntl(f, F_GETFL, 0);
+ if (aBoolean == true) {
+ ret = fcntl(f, F_SETFL, flags & ~DELAY_FLAG);
+ } else {
+ ret = fcntl(f, F_SETFL, flags | DELAY_FLAG);
+ }
+ if (ret >= 0) {
+ RETURN ((flags & DELAY_FLAG) ? false : true );
+ }
}
# undef DELAY_FLAG
# endif
@@ -10784,24 +10783,24 @@
int ret, cnt = 0;
if (hostName == nil) {
- __hostName = 0;
+ __hostName = 0;
} else if (__isString(hostName) || __isSymbol(hostName)) {
- __hostName = __stringVal(hostName);
+ __hostName = __stringVal(hostName);
} else {
- error = @symbol(badArgument1);
- goto err;
+ error = @symbol(badArgument1);
+ goto err;
}
if (serviceName == nil) {
- __serviceName = 0;
+ __serviceName = 0;
} else if (__isString(serviceName) || __isSymbol(serviceName)) {
- __serviceName = __stringVal(serviceName);
+ __serviceName = __stringVal(serviceName);
} else {
- error = @symbol(badArgument2);
- goto err;
+ error = @symbol(badArgument2);
+ goto err;
}
if (__hostName == 0 && __serviceName == 0) {
- error = @symbol(badArgument);
- goto err;
+ error = @symbol(badArgument);
+ goto err;
}
{
@@ -10815,98 +10814,98 @@
memset(&hints, 0, sizeof(hints));
if (__isSmallInteger(domain))
- hints.ai_family = __intVal(domain);
+ hints.ai_family = __intVal(domain);
if (__isSmallInteger(type))
- hints.ai_socktype = __intVal(type);
+ hints.ai_socktype = __intVal(type);
if (__isSmallInteger(proto))
- hints.ai_protocol = __intVal(proto);
+ hints.ai_protocol = __intVal(proto);
do {
- __BEGIN_INTERRUPTABLE__
- ret = getaddrinfo(__hostName, __serviceName, &hints, &info);
- __END_INTERRUPTABLE__
+ __BEGIN_INTERRUPTABLE__
+ ret = getaddrinfo(__hostName, __serviceName, &hints, &info);
+ __END_INTERRUPTABLE__
} while (ret == EAI_SYSTEM && errno == EINTR);
if (ret != 0) {
- switch (ret) {
- case EAI_FAMILY:
- error = @symbol(badProtocol);
- break;
- case EAI_SOCKTYPE:
- error = @symbol(badSocketType);
- break;
- case EAI_BADFLAGS:
- error = @symbol(badFlags);
- break;
- case EAI_NONAME:
- error = @symbol(unknownHost);
- break;
- case EAI_SERVICE:
- error = @symbol(unknownService);
- break;
- case EAI_ADDRFAMILY :
- error = @symbol(unknownHostForProtocol);
- break;
- case EAI_NODATA:
- error = @symbol(noAddress);
- break;
- case EAI_MEMORY:
- error = @symbol(allocationFailure);
- break;
- case EAI_FAIL:
- error = @symbol(permanentFailure);
- break;
- case EAI_AGAIN:
- error = @symbol(tryAgain);
- break;
- case EAI_SYSTEM:
- error = @symbol(systemError);
- break;
- default:
- error = @symbol(unknownError);
- }
- errorString = __MKSTRING(gai_strerror(ret));
- goto err;
+ switch (ret) {
+ case EAI_FAMILY:
+ error = @symbol(badProtocol);
+ break;
+ case EAI_SOCKTYPE:
+ error = @symbol(badSocketType);
+ break;
+ case EAI_BADFLAGS:
+ error = @symbol(badFlags);
+ break;
+ case EAI_NONAME:
+ error = @symbol(unknownHost);
+ break;
+ case EAI_SERVICE:
+ error = @symbol(unknownService);
+ break;
+ case EAI_ADDRFAMILY :
+ error = @symbol(unknownHostForProtocol);
+ break;
+ case EAI_NODATA:
+ error = @symbol(noAddress);
+ break;
+ case EAI_MEMORY:
+ error = @symbol(allocationFailure);
+ break;
+ case EAI_FAIL:
+ error = @symbol(permanentFailure);
+ break;
+ case EAI_AGAIN:
+ error = @symbol(tryAgain);
+ break;
+ case EAI_SYSTEM:
+ error = @symbol(systemError);
+ break;
+ default:
+ error = @symbol(unknownError);
+ }
+ errorString = __MKSTRING(gai_strerror(ret));
+ goto err;
}
for (cnt=0, infop=info; infop; infop=infop->ai_next)
- cnt++;
+ cnt++;
result = __ARRAY_NEW_INT(cnt);
if (result == nil) {
- error = @symbol(allocationFailure);
- goto err;
+ error = @symbol(allocationFailure);
+ goto err;
}
for (infop=info, cnt=0; infop; infop=infop->ai_next, cnt++) {
- OBJ o, resp;
-
- resp = __ARRAY_NEW_INT(6);
- if (resp == nil) {
- error = @symbol(allocationFailure);
- goto err;
- }
-
- __ArrayInstPtr(result)->a_element[cnt] = resp;
- __STORE(result, resp);
- __ArrayInstPtr(resp)->a_element[0] = __MKSMALLINT(infop->ai_flags);
- __ArrayInstPtr(resp)->a_element[1] = __MKSMALLINT(infop->ai_family);
- __ArrayInstPtr(resp)->a_element[2] = __MKSMALLINT(infop->ai_socktype);
- __ArrayInstPtr(resp)->a_element[3] = __MKSMALLINT(infop->ai_protocol);
- o = __BYTEARRAY_NEW_INT(infop->ai_addrlen);
- if (o == nil) {
- error = @symbol(allocationFailure);
- goto err;
- }
- memcpy(__byteArrayVal(o), infop->ai_addr, infop->ai_addrlen);
+ OBJ o, resp;
+
+ resp = __ARRAY_NEW_INT(6);
+ if (resp == nil) {
+ error = @symbol(allocationFailure);
+ goto err;
+ }
+
+ __ArrayInstPtr(result)->a_element[cnt] = resp;
+ __STORE(result, resp);
+ __ArrayInstPtr(resp)->a_element[0] = __MKSMALLINT(infop->ai_flags);
+ __ArrayInstPtr(resp)->a_element[1] = __MKSMALLINT(infop->ai_family);
+ __ArrayInstPtr(resp)->a_element[2] = __MKSMALLINT(infop->ai_socktype);
+ __ArrayInstPtr(resp)->a_element[3] = __MKSMALLINT(infop->ai_protocol);
+ o = __BYTEARRAY_NEW_INT(infop->ai_addrlen);
+ if (o == nil) {
+ error = @symbol(allocationFailure);
+ goto err;
+ }
+ memcpy(__byteArrayVal(o), infop->ai_addr, infop->ai_addrlen);
__ArrayInstPtr(resp)->a_element[4] = o;
- __STORE(resp, o);
- if (infop->ai_canonname) {
- o = __MKSTRING(infop->ai_canonname);
- if (o == nil) {
- error = @symbol(allocationFailure);
- goto err;
- }
- __ArrayInstPtr(resp)->a_element[5] = o;
- __STORE(resp, o);
- }
+ __STORE(resp, o);
+ if (infop->ai_canonname) {
+ o = __MKSTRING(infop->ai_canonname);
+ if (o == nil) {
+ error = @symbol(allocationFailure);
+ goto err;
+ }
+ __ArrayInstPtr(resp)->a_element[5] = o;
+ __STORE(resp, o);
+ }
}
err:
@@ -10923,130 +10922,130 @@
int i;
if (__serviceName) {
- struct servent *sp;
- char *__proto = 0;
-
- if (__isString(protoArg) || __isSymbol(protoArg))
- __proto = __stringVal(protoArg);
-
- sp = getservbyname(__serviceName, __proto);
- if (sp == NULL) {
- errorString = @symbol(unknownService);
- error = __mkSmallInteger(-3);
- goto err;
- }
- port = sp->s_port;
+ struct servent *sp;
+ char *__proto = 0;
+
+ if (__isString(protoArg) || __isSymbol(protoArg))
+ __proto = __stringVal(protoArg);
+
+ sp = getservbyname(__serviceName, __proto);
+ if (sp == NULL) {
+ errorString = @symbol(unknownService);
+ error = __mkSmallInteger(-3);
+ goto err;
+ }
+ port = sp->s_port;
}
if (__hostName) {
# ifdef USE_H_ERRNO
- do {
- /* __BEGIN_INTERRUPTABLE__ is dangerous, because gethostbyname
- * uses a static data area
- */
- __BEGIN_INTERRUPTABLE__
- hp = gethostbyname(__hostName);
- __END_INTERRUPTABLE__
- } while ((hp == NULL)
- && (
- (h_errno == TRY_AGAIN)
- || errno == EINTR
+ do {
+ /* __BEGIN_INTERRUPTABLE__ is dangerous, because gethostbyname
+ * uses a static data area
+ */
+ __BEGIN_INTERRUPTABLE__
+ hp = gethostbyname(__hostName);
+ __END_INTERRUPTABLE__
+ } while ((hp == NULL)
+ && (
+ (h_errno == TRY_AGAIN)
+ || errno == EINTR
# ifdef IRIX5_3
- || (errno == ECONNREFUSED)
+ || (errno == ECONNREFUSED)
# endif
- )
- );
- if (hp == 0) {
- switch (h_errno) {
- case HOST_NOT_FOUND:
- errorString = @symbol(unknownHost);
- break;
- case NO_ADDRESS:
- errorString = @symbol(noAddress);
- break;
- case NO_RECOVERY:
- errorString = @symbol(permanentFailure);
- break;
- case TRY_AGAIN:
- errorString = @symbol(tryAgain);
- break;
- default:
- errorString = @symbol(unknownError);
- break;
- }
- error = __mkSmallInteger(h_errno);
- goto err;
- }
+ )
+ );
+ if (hp == 0) {
+ switch (h_errno) {
+ case HOST_NOT_FOUND:
+ errorString = @symbol(unknownHost);
+ break;
+ case NO_ADDRESS:
+ errorString = @symbol(noAddress);
+ break;
+ case NO_RECOVERY:
+ errorString = @symbol(permanentFailure);
+ break;
+ case TRY_AGAIN:
+ errorString = @symbol(tryAgain);
+ break;
+ default:
+ errorString = @symbol(unknownError);
+ break;
+ }
+ error = __mkSmallInteger(h_errno);
+ goto err;
+ }
# else /* !USE_H_ERRNO */
- hp = gethostbyname(__hostName);
- if (hp == 0) {
- errorString = @symbol(unknownHost);
- error = __mkSmallInteger(-1);
- goto err;
- }
+ hp = gethostbyname(__hostName);
+ if (hp == 0) {
+ errorString = @symbol(unknownHost);
+ error = __mkSmallInteger(-1);
+ goto err;
+ }
# endif /* !USE_H_ERRNO*/
- if (__isSmallInteger(domain) && hp->h_addrtype != __smallIntegerVal(domain)) {
- errorString = @symbol(unknownHost);
- error = __mkSmallInteger(-2);
- goto err;
- }
-
- for (cnt = 0, addrpp = hp->h_addr_list; *addrpp; addrpp++)
- cnt++;
- addrpp = hp->h_addr_list;
+ if (__isSmallInteger(domain) && hp->h_addrtype != __smallIntegerVal(domain)) {
+ errorString = @symbol(unknownHost);
+ error = __mkSmallInteger(-2);
+ goto err;
+ }
+
+ for (cnt = 0, addrpp = hp->h_addr_list; *addrpp; addrpp++)
+ cnt++;
+ addrpp = hp->h_addr_list;
} else {
- cnt = 1;
+ cnt = 1;
}
result = __ARRAY_NEW_INT(cnt);
if (result == nil) {
- error = @symbol(allocationFailure);
- goto err;
+ error = @symbol(allocationFailure);
+ goto err;
}
for (i = 0; i < cnt; i++) {
- OBJ o, resp;
- struct sockaddr_in *sa;
-
- resp = __ARRAY_NEW_INT(6);
- if (resp == nil) {
- error = @symbol(allocationFailure);
- goto err;
- }
-
- __ArrayInstPtr(result)->a_element[i] = resp;
- __STORE(result, resp);
- __ArrayInstPtr(resp)->a_element[0] = __mkSmallInteger(0);
- __ArrayInstPtr(resp)->a_element[2] = type;
- __ArrayInstPtr(resp)->a_element[3] = proto;
- o = __BYTEARRAY_NEW_INT(sizeof(*sa));
- if (o == nil) {
- error = @symbol(allocationFailure);
- goto err;
- }
- __ArrayInstPtr(resp)->a_element[4] = o;
- __STORE(resp, o);
- sa = (struct sockaddr_in *)__byteArrayVal(o);
- sa->sin_port = port;
-
- if (__hostName) {
- sa->sin_family = hp->h_addrtype;
- memcpy(&sa->sin_addr, *addrpp, hp->h_length);
- __ArrayInstPtr(resp)->a_element[1] = __mkSmallInteger(hp->h_addrtype);
- if (hp->h_name) {
- o = __MKSTRING(hp->h_name);
- if (o == nil) {
- error = @symbol(allocationFailure);
- goto err;
- }
- __ArrayInstPtr(resp)->a_element[5] = o;
- __STORE(resp, o);
- }
- addrpp++;
- } else{
- __ArrayInstPtr(resp)->a_element[1] = domain;
- }
+ OBJ o, resp;
+ struct sockaddr_in *sa;
+
+ resp = __ARRAY_NEW_INT(6);
+ if (resp == nil) {
+ error = @symbol(allocationFailure);
+ goto err;
+ }
+
+ __ArrayInstPtr(result)->a_element[i] = resp;
+ __STORE(result, resp);
+ __ArrayInstPtr(resp)->a_element[0] = __mkSmallInteger(0);
+ __ArrayInstPtr(resp)->a_element[2] = type;
+ __ArrayInstPtr(resp)->a_element[3] = proto;
+ o = __BYTEARRAY_NEW_INT(sizeof(*sa));
+ if (o == nil) {
+ error = @symbol(allocationFailure);
+ goto err;
+ }
+ __ArrayInstPtr(resp)->a_element[4] = o;
+ __STORE(resp, o);
+ sa = (struct sockaddr_in *)__byteArrayVal(o);
+ sa->sin_port = port;
+
+ if (__hostName) {
+ sa->sin_family = hp->h_addrtype;
+ memcpy(&sa->sin_addr, *addrpp, hp->h_length);
+ __ArrayInstPtr(resp)->a_element[1] = __mkSmallInteger(hp->h_addrtype);
+ if (hp->h_name) {
+ o = __MKSTRING(hp->h_name);
+ if (o == nil) {
+ error = @symbol(allocationFailure);
+ goto err;
+ }
+ __ArrayInstPtr(resp)->a_element[5] = o;
+ __STORE(resp, o);
+ }
+ addrpp++;
+ } else{
+ __ArrayInstPtr(resp)->a_element[1] = domain;
+ }
}
err:;
@@ -11057,44 +11056,44 @@
#endif
%}.
error notNil ifTrue:[
- NameLookupError raiseWith:error errorString:errorString.
+ NameLookupError raiseWith:error errorString:errorString.
].
1 to:result size do:[:i |
- |entry dom info|
-
- info := SocketAddressInfo new.
- entry := result at:i.
- info flags:(entry at:1).
- info domain:(dom := OperatingSystem domainSymbolOf:(entry at:2)).
- info type:(OperatingSystem socketTypeSymbolOf:(entry at:3)).
- info protocol:(self protocolSymbolOf:(entry at:4)).
- info socketAddress:((SocketAddress newDomain:dom) fromBytes:(entry at:5)).
- info canonicalName:(entry at:6).
- result at:i put:info
+ |entry dom info|
+
+ info := SocketAddressInfo new.
+ entry := result at:i.
+ info flags:(entry at:1).
+ info domain:(dom := OperatingSystem domainSymbolOf:(entry at:2)).
+ info type:(OperatingSystem socketTypeSymbolOf:(entry at:3)).
+ info protocol:(self protocolSymbolOf:(entry at:4)).
+ info socketAddress:((SocketAddress newDomain:dom) fromBytes:(entry at:5)).
+ info canonicalName:(entry at:6).
+ result at:i put:info
].
^ result
"
self getAddressInfo:'localhost' serviceName:nil
- domain:nil type:nil protocol:nil flags:nil
+ domain:nil type:nil protocol:nil flags:nil
self getAddressInfo:'localhost' serviceName:nil
- domain:#inet type:#stream protocol:nil flags:nil
+ domain:#inet type:#stream protocol:nil flags:nil
self getAddressInfo:'localhost' serviceName:nil
- domain:#inet type:#stream protocol:#tcp flags:nil
+ domain:#inet type:#stream protocol:#tcp flags:nil
self getAddressInfo:'blurb.exept.de' serviceName:nil
- domain:#inet type:nil protocol:nil flags:nil
+ domain:#inet type:nil protocol:nil flags:nil
self getAddressInfo:'1.2.3.4' serviceName:'bla'
- domain:#inet type:nil protocol:nil flags:nil
+ domain:#inet type:nil protocol:nil flags:nil
self getAddressInfo:'localhost' serviceName:'echo'
- domain:#inet type:nil protocol:nil flags:nil
+ domain:#inet type:nil protocol:nil flags:nil
self getAddressInfo:nil serviceName:'echo'
- domain:#inet type:nil protocol:nil flags:nil
+ domain:#inet type:nil protocol:nil flags:nil
self getAddressInfo:nil serviceName:nil
- domain:#inet type:nil protocol:nil flags:nil
+ domain:#inet type:nil protocol:nil flags:nil
self getAddressInfo:'www.google.de' serviceName:nil
- domain:nil type:nil protocol:nil flags:nil
+ domain:nil type:nil protocol:nil flags:nil
self getAddressInfo:'smc1' serviceName:nil
- domain:nil type:nil protocol:nil flags:nil
+ domain:nil type:nil protocol:nil flags:nil
"
!
@@ -11811,7 +11810,7 @@
domainCode := OperatingSystem domainCodeOf:domainArg.
typeCode := OperatingSystem socketTypeCodeOf:typeArg.
protocolArg notNil ifTrue:[
- protocolNumber := self class protocolCodeOf:protocolArg
+ protocolNumber := self class protocolCodeOf:protocolArg
].
%{
@@ -11820,23 +11819,23 @@
int on = 1;
if (__INST(fd) != nil) {
- error = @symbol(internalError);
- goto err;
+ error = @symbol(internalError);
+ goto err;
}
if (! __isSmallInteger(domainCode)) {
- error = @symbol(badArgument1);
- goto err;
+ error = @symbol(badArgument1);
+ goto err;
}
if (! __isSmallInteger(typeArg)) {
- error = @symbol(badArgument2);
- goto err;
+ error = @symbol(badArgument2);
+ goto err;
}
if (protocolNumber != nil) {
- if (!__isSmallInteger(protocolNumber)) {
- error = @symbol(badArgument3);
- goto err;
- }
- proto = __smallIntegerVal(protocolNumber);
+ if (!__isSmallInteger(protocolNumber)) {
+ error = @symbol(badArgument3);
+ goto err;
+ }
+ proto = __smallIntegerVal(protocolNumber);
}
dom = __smallIntegerVal(domainCode);
@@ -11848,20 +11847,20 @@
againSocket:
sock = socket(dom, typ, proto);
if (sock < 0) {
- if (errno == EINTR) {
- __HANDLE_INTERRUPTS__;
- goto againSocket;
- } else
+ if (errno == EINTR) {
+ __HANDLE_INTERRUPTS__;
+ goto againSocket;
+ } else
# if defined(EPROTONOSUPPORT) /* for SGI */
- if (errno == EPROTONOSUPPORT && proto != 0) {
- proto = 0;
- goto againSocket;
- } else
-# endif
- {
- error = __mkSmallInteger(errno);
- goto err;
- }
+ if (errno == EPROTONOSUPPORT && proto != 0) {
+ proto = 0;
+ goto againSocket;
+ } else
+# endif
+ {
+ error = __mkSmallInteger(errno);
+ goto err;
+ }
}
__INST(fd) = __mkSmallInteger(sock);
@@ -11871,7 +11870,7 @@
# endif /* NOSOCKET */
%}.
error notNil ifTrue:[
- ^ self error:error.
+ ^ self error:error.
].
self register.
@@ -12151,7 +12150,7 @@
!UnixOperatingSystem class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.178 2003-07-16 14:07:30 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/UnixOperatingSystem.st,v 1.179 2003-07-17 12:06:23 cg Exp $'
! !
UnixOperatingSystem initialize!