diff options
Diffstat (limited to 'extension')
-rw-r--r-- | extension/ChangeLog | 4 | ||||
-rw-r--r-- | extension/time.c | 31 |
2 files changed, 24 insertions, 11 deletions
diff --git a/extension/ChangeLog b/extension/ChangeLog index 965e0c66..bde626de 100644 --- a/extension/ChangeLog +++ b/extension/ChangeLog @@ -1,3 +1,7 @@ +2014-02-12 John E. Malmberg <wb8tyw@qsl.net> + + * time.c: Better hack for nanosleep bug based on feedback from HP. + 2013-12-29 John E. Malmberg <wb8tyw@qsl.net> * filefuncs.c: Fix compile on VMS. 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 |