KO Myung-Hun wrote:
> utimes() of OS/2 kLIBC has some limitations.
> 
> 1. OS/2 itself supports a file date since 1980 year.
> 2. OS/2 itself supports even seconds for a file time.
> 3. utimes() of OS/2 kLIBC does not work on an opened file.
> 
> * m4/utimes.m4: Detect utimes() correctly on OS/2 kLIBC.
> ---
>  m4/utimes.m4 | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
> 

Updated to consider local time correctly.

-- 
KO Myung-Hun

Using Mozilla SeaMonkey 2.7.2
Under OS/2 Warp 4 for Korean with FixPak #15
In VirtualBox v4.1.32 on Intel Core i7-3615QM 2.30GHz with 8GB RAM

Korean OS/2 User Community : http://www.ecomstation.co.kr

From 440495e7323223e60d30e4e90dcb8e016a2d1f60 Mon Sep 17 00:00:00 2001
From: KO Myung-Hun <k...@chollian.net>
Date: Fri, 28 Nov 2014 16:43:14 +0900
Subject: [PATCH] utimes: detect utimes() correctly on OS/2 kLIBC

utimes() of OS/2 kLIBC has some limitations.

1. OS/2 itself supports a file date since 1980 year in local time.
2. OS/2 itself supports even seconds for a file time.
3. utimes() of OS/2 kLIBC does not work on an opened file.

* m4/utimes.m4: Detect utimes() correctly on OS/2 kLIBC.
---
 m4/utimes.m4 | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/m4/utimes.m4 b/m4/utimes.m4
index c361357..aaecd64 100644
--- a/m4/utimes.m4
+++ b/m4/utimes.m4
@@ -1,5 +1,5 @@
 # Detect some bugs in glibc's implementation of utimes.
-# serial 3
+# serial 4
 
 dnl Copyright (C) 2003-2005, 2009-2014 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
@@ -45,7 +45,10 @@ main ()
 {
   int result = 0;
   char const *file = "conftest.utimes";
-  static struct timeval timeval[2] = {{9, 10}, {999999, 999999}};
+  /* On OS/2, a file date should be since 1980 year in local time
+     and even seconds.  */
+  static struct timeval timeval[2] = {{315620000 + 10, 10},
+                                      {315620000 + 1000000, 999998}};
 
   /* Test whether utimes() essentially works.  */
   {
@@ -82,11 +85,16 @@ main ()
           result |= 1;
         else if (fstat (fd, &st0) != 0)
           result |= 1;
+        /* utimes() of OS/2 kLIBC does not work on an opened file */
+        else if (close (fd) != 0)
+          result |= 1;
         else if (utimes (file, timeval) != 0)
           result |= 2;
         else if (utimes (file, NULL) != 0)
           result |= 8;
-        else if (fstat (fd, &st1) != 0)
+        else if (lstat (file, &st1) != 0)
+          result |= 1;
+        else if ((fd = open (file, O_WRONLY)) < 0)
           result |= 1;
         else if (write (fd, "\n", 1) != 1)
           result |= 1;
-- 
1.8.5.2

Reply via email to