diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2014-02-14 13:22:51 +0200 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2014-02-14 13:22:51 +0200 |
commit | a6131306dd49537de45afdfdc6d4ad2dcac7655b (patch) | |
tree | 20d9dab2f13c21b7134f284b6650c6430fb4243b /extension/time.c | |
parent | 4311907208592a2c617251a5cd3792d97f94be6a (diff) | |
download | egawk-a6131306dd49537de45afdfdc6d4ad2dcac7655b.tar.gz egawk-a6131306dd49537de45afdfdc6d4ad2dcac7655b.tar.bz2 egawk-a6131306dd49537de45afdfdc6d4ad2dcac7655b.zip |
VMS updates.
Diffstat (limited to 'extension/time.c')
-rw-r--r-- | extension/time.c | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/extension/time.c b/extension/time.c index b1e9a40a..c336df88 100644 --- a/extension/time.c +++ b/extension/time.c @@ -1,25 +1,24 @@ /* * time.c - Builtin functions that provide time-related functions. - * */ /* * Copyright (C) 2012, 2013 * the Free Software Foundation, Inc. - * + * * This file is part of GAWK, the GNU implementation of the * AWK Programming Language. - * + * * GAWK is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. - * + * * GAWK is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA @@ -46,18 +45,28 @@ #undef gettimeofday #endif #ifdef __ia64__ -/* nanosleep not working on IA64 */ +/* nanosleep not working correctly on IA64 */ static int -vms_fake_nanosleep(const struct timespec *rqdly, struct timespec *rmdly) +vms_fake_nanosleep(struct timespec *rqdly, struct timespec *rmdly) { int result; + struct timespec mtime1, mtime2; - result = sleep(rqdly->tv_sec); - if (result == 0) { + result = nanosleep(rqdly, &mtime1); + if (result == 0) return 0; - } else { - return -1; + + /* On IA64 it returns 100 nanoseconds early with an error */ + if ((mtime1.tv_sec == 0) && (mtime1.tv_nsec <= 100)) { + mtime1.tv_nsec += 100; + result = nanosleep(&mtime1, &mtime2); + if (result == 0) + return 0; + if ((mtime2.tv_sec == 0) && (mtime2.tv_nsec <= 100)) { + return 0; + } } + return result; } #define nanosleep(x,y) vms_fake_nanosleep(x, y) #endif |