commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r801716 - in /commons/sandbox/runtime/trunk/src/main/native: Makefile.in Makefile.msc.in include/acr.h include/acr_time.h include/arch/windows/acr_arch.h include/arch/windows/acr_arch_private.h os/unix/time.c os/win32/time.c
Date Thu, 06 Aug 2009 16:55:02 GMT
Author: mturk
Date: Thu Aug  6 16:55:01 2009
New Revision: 801716

URL: http://svn.apache.org/viewvc?rev=801716&view=rev
Log:
Add skeleton time functions

Added:
    commons/sandbox/runtime/trunk/src/main/native/include/acr_time.h   (with props)
    commons/sandbox/runtime/trunk/src/main/native/os/unix/time.c   (with props)
    commons/sandbox/runtime/trunk/src/main/native/os/win32/time.c   (with props)
Modified:
    commons/sandbox/runtime/trunk/src/main/native/Makefile.in
    commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in
    commons/sandbox/runtime/trunk/src/main/native/include/acr.h
    commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h
    commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch_private.h

Modified: commons/sandbox/runtime/trunk/src/main/native/Makefile.in
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/Makefile.in?rev=801716&r1=801715&r2=801716&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/Makefile.in (original)
+++ commons/sandbox/runtime/trunk/src/main/native/Makefile.in Thu Aug  6 16:55:01 2009
@@ -105,6 +105,7 @@
 	$(SRCDIR)/os/unix/pmutex.$(OBJ) \
 	$(SRCDIR)/os/unix/shm.$(OBJ) \
 	$(SRCDIR)/os/unix/syslog.$(OBJ) \
+	$(SRCDIR)/os/unix/time.$(OBJ) \
 	$(SRCDIR)/os/unix/uuid.$(OBJ) \
 	$(SRCDIR)/os/unix/uutils.$(OBJ) \
 	$(SRCDIR)/os/linux/execmem.$(OBJ) \
@@ -125,6 +126,7 @@
 	$(SRCDIR)/os/unix/pmutex.$(OBJ) \
 	$(SRCDIR)/os/unix/shm.$(OBJ) \
 	$(SRCDIR)/os/unix/syslog.$(OBJ) \
+	$(SRCDIR)/os/unix/time.$(OBJ) \
 	$(SRCDIR)/os/unix/uuid.$(OBJ) \
 	$(SRCDIR)/os/unix/uutils.$(OBJ) \
 	$(SRCDIR)/os/solaris/platform.$(OBJ) \
@@ -142,6 +144,7 @@
 	$(SRCDIR)/os/unix/user.$(OBJ) \
 	$(SRCDIR)/os/unix/shm.$(OBJ) \
 	$(SRCDIR)/os/unix/syslog.$(OBJ) \
+	$(SRCDIR)/os/unix/time.$(OBJ) \
 	$(SRCDIR)/os/unix/uuid.$(OBJ) \
 	$(SRCDIR)/os/unix/uutils.$(OBJ) \
 	$(SRCDIR)/os/darwin/platform.$(OBJ) \
@@ -161,6 +164,7 @@
 	$(SRCDIR)/os/unix/pmutex.$(OBJ) \
 	$(SRCDIR)/os/unix/shm.$(OBJ) \
 	$(SRCDIR)/os/unix/syslog.$(OBJ) \
+	$(SRCDIR)/os/unix/time.$(OBJ) \
 	$(SRCDIR)/os/unix/uuid.$(OBJ) \
 	$(SRCDIR)/os/unix/uutils.$(OBJ) \
 	$(SRCDIR)/os/hpux/platform.$(OBJ) \

Modified: commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in?rev=801716&r1=801715&r2=801716&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in (original)
+++ commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in Thu Aug  6 16:55:01 2009
@@ -98,6 +98,7 @@
 	$(SRCDIR)/os/win32/syslog.$(OBJ) \
 	$(SRCDIR)/os/win32/group.$(OBJ) \
 	$(SRCDIR)/os/win32/user.$(OBJ) \
+	$(SRCDIR)/os/win32/time.$(OBJ) \
 	$(SRCDIR)/os/win32/uuid.$(OBJ) \
 	$(SRCDIR)/os/win32/variant.$(OBJ) \
 	$(SRCDIR)/os/win32/wusec.$(OBJ)

Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr.h?rev=801716&r1=801715&r2=801716&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr.h Thu Aug  6 16:55:01 2009
@@ -205,6 +205,7 @@
 typedef  __int64            acr_int64_t;
 typedef  unsigned __int64   acr_uint64_t;
 typedef  __int64            acr_off_t;
+typedef  __int64            acr_time_t;
 typedef  int                acr_socklen_t;
 /* API char type on windows is always WCHAR */
 typedef  wchar_t            acr_pchar_t;
@@ -215,9 +216,11 @@
 typedef  ssize_t            acr_ssize_t;
 #ifdef _LP64 /* 64-bit Solaris */
 typedef  long               acr_int64_t;
+typedef  long               acr_time_t;
 typedef  unsigned long      acr_uint64_t;
 #else
 typedef  long long          acr_int64_t;
+typedef  long long          acr_time_t;
 typedef  unsigned long long acr_uint64_t;
 #endif
 #if HAVE_OFF64_T
@@ -242,9 +245,13 @@
 #endif
 
 #if CC_SIZEOF_LONG == 8
-#define  ACR_SL_ALIGN(T, X) T X
-#else
-#define  ACR_SL_ALIGN(T, X) T X; long __align_##X
+#define ACR_INT64_C(val)   (val##L)
+#define ACR_UINT64_C(val)  (val##UL)
+#define ACR_SL_ALIGN(T, X) T X
+#else
+#define ACR_INT64_C(val)   (val##LL)
+#define ACR_UINT64_C(val)  (val##ULL)
+#define ACR_SL_ALIGN(T, X) T X; long __align_##X
 #endif
 
 #define ACR_SIZE_T_MAX      ((acr_size_t)~0 - 8192)

Added: commons/sandbox/runtime/trunk/src/main/native/include/acr_time.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_time.h?rev=801716&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_time.h (added)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_time.h Thu Aug  6 16:55:01 2009
@@ -0,0 +1,54 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _ACR_TIME_H
+#define _ACR_TIME_H
+
+#include "acr.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file acr_time.h
+ * @brief
+ *
+ * ACR Time Library
+ *
+ */
+
+/**
+ * Mechanism to properly type acr_time_t literals
+ */
+#define ACR_TIME_C(val) ACR_INT64_C(val)
+
+/** 
+ * Number of microseconds since 00:00:00 january 1, 1970 UTC
+ */
+ACR_DECLARE(acr_time_t) ACR_TimeNow(void);
+
+/**
+ * Number of microseconds per second
+ */
+#define ACR_USEC_PER_SEC ACR_TIME_C(1000000)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ACR_TIME_H */
+

Propchange: commons/sandbox/runtime/trunk/src/main/native/include/acr_time.h
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h?rev=801716&r1=801715&r2=801716&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch.h Thu Aug
 6 16:55:01 2009
@@ -300,6 +300,29 @@
 #define ACR_IOH_FLAGS(H)    acr_ioh_tab[(H) & acr_ioh_mask].flags
 #define ACR_IOH(H)          acr_ioh_tab[(H) & acr_ioh_mask].h
 
+static ACR_INLINE void FileTimeToAcrTime(acr_time_t *result, FILETIME *input)
+{
+    /* Convert FILETIME one 64 bit number so we can work with it. */
+    *result = input->dwHighDateTime;
+    *result = (*result) << 32;
+    *result |= input->dwLowDateTime;
+    *result /= 10;    /* Convert from 100 nano-sec periods to micro-seconds. */
+    *result -= ACR_DELTA_EPOCH_IN_USEC;  /* Convert from Windows epoch to Unix epoch */
+    return;
+}
+
+
+static ACR_INLINE void AcrTimeToFileTime(LPFILETIME pft, acr_time_t t)
+{
+    LONGLONG ll;
+    t += ACR_DELTA_EPOCH_IN_USEC;
+    ll = t * 10;
+    pft->dwLowDateTime = (DWORD)ll;
+    pft->dwHighDateTime = (DWORD) (ll >> 32);
+    return;
+}
+
+
 /*
  * ---------------------------------------------------------------------
  * end   of POSIX utilities

Modified: commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch_private.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch_private.h?rev=801716&r1=801715&r2=801716&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch_private.h
(original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch_private.h
Thu Aug  6 16:55:01 2009
@@ -63,6 +63,12 @@
 #define ACR_JNI_PLATFORM_DECLARE(RT, CL, FN)  \
     JNIEXPORT RT JNICALL Java_org_apache_commons_runtime_platform_windows_##CL##_##FN
 
+/* Number of micro-seconds between the beginning of the Windows epoch
+ * (Jan. 1, 1601) and the Unix epoch (Jan. 1, 1970) 
+ */
+#define ACR_DELTA_EPOCH_IN_USEC   11644473600000000LL
+
+
 /**
  * Local functions from wusec.c
  */

Added: commons/sandbox/runtime/trunk/src/main/native/os/unix/time.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/time.c?rev=801716&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/time.c (added)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/time.c Thu Aug  6 16:55:01 2009
@@ -0,0 +1,38 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "acr.h"
+#include "acr_private.h"
+#include "acr_arch.h"
+#include "acr_error.h"
+#include "acr_memory.h"
+#include "acr_string.h"
+#include "acr_descriptor.h"
+#include "acr_time.h"
+
+ACR_DECLARE(acr_time_t) ACR_TimeNow(void)
+{
+    LONGLONG   aprtime = 0;
+    FILETIME   time;
+    SYSTEMTIME st;
+
+    GetSystemTime(&st);
+    SystemTimeToFileTime(&st, &time);
+    FileTimeToAcrTime(&aprtime, &time);
+
+    return aprtime; 
+}
+

Propchange: commons/sandbox/runtime/trunk/src/main/native/os/unix/time.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/runtime/trunk/src/main/native/os/win32/time.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/time.c?rev=801716&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/time.c (added)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/time.c Thu Aug  6 16:55:01 2009
@@ -0,0 +1,31 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "acr.h"
+#include "acr_private.h"
+#include "acr_arch.h"
+#include "acr_error.h"
+#include "acr_memory.h"
+#include "acr_string.h"
+#include "acr_descriptor.h"
+#include "acr_time.h"
+
+/* NB NB NB NB This returns GMT!!!!!!!!!! */
+ACR_DECLARE(acr_time_t) ACR_TimeNow(void)
+{
+
+}
+

Propchange: commons/sandbox/runtime/trunk/src/main/native/os/win32/time.c
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message