diff options
author | Shashank | 2017-05-29 12:40:26 +0530 |
---|---|---|
committer | Shashank | 2017-05-29 12:40:26 +0530 |
commit | 0345245e860375a32c9a437c4a9d9cae807134e9 (patch) | |
tree | ad51ecbfa7bcd3cc5f09834f1bb8c08feaa526a4 /modules/time/src | |
download | scilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.tar.gz scilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.tar.bz2 scilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.zip |
CMSCOPE changed
Diffstat (limited to 'modules/time/src')
-rwxr-xr-x | modules/time/src/c/.deps/.dirstamp | 0 | ||||
-rwxr-xr-x | modules/time/src/c/.deps/libscitime_algo_la-getdate.Plo | 122 | ||||
-rwxr-xr-x | modules/time/src/c/.deps/libscitime_algo_la-realtime.Plo | 92 | ||||
-rwxr-xr-x | modules/time/src/c/.deps/libscitime_algo_la-timer.Plo | 84 | ||||
-rwxr-xr-x | modules/time/src/c/.dirstamp | 0 | ||||
-rwxr-xr-x | modules/time/src/c/.libs/libscitime_algo_la-getdate.o | bin | 0 -> 17888 bytes | |||
-rwxr-xr-x | modules/time/src/c/.libs/libscitime_algo_la-realtime.o | bin | 0 -> 9392 bytes | |||
-rwxr-xr-x | modules/time/src/c/.libs/libscitime_algo_la-timer.o | bin | 0 -> 10200 bytes | |||
-rwxr-xr-x | modules/time/src/c/DllmainTime.c | 34 | ||||
-rwxr-xr-x | modules/time/src/c/getdate.c | 284 | ||||
-rwxr-xr-x | modules/time/src/c/getdate.h | 53 | ||||
-rwxr-xr-x | modules/time/src/c/libscitime_algo_la-getdate.lo | 12 | ||||
-rwxr-xr-x | modules/time/src/c/libscitime_algo_la-realtime.lo | 12 | ||||
-rwxr-xr-x | modules/time/src/c/libscitime_algo_la-timer.lo | 12 | ||||
-rwxr-xr-x | modules/time/src/c/realtime.c | 147 | ||||
-rwxr-xr-x | modules/time/src/c/time.rc | 96 | ||||
-rwxr-xr-x | modules/time/src/c/timer.c | 103 |
17 files changed, 1051 insertions, 0 deletions
diff --git a/modules/time/src/c/.deps/.dirstamp b/modules/time/src/c/.deps/.dirstamp new file mode 100755 index 000000000..e69de29bb --- /dev/null +++ b/modules/time/src/c/.deps/.dirstamp diff --git a/modules/time/src/c/.deps/libscitime_algo_la-getdate.Plo b/modules/time/src/c/.deps/libscitime_algo_la-getdate.Plo new file mode 100755 index 000000000..a8cc37d95 --- /dev/null +++ b/modules/time/src/c/.deps/libscitime_algo_la-getdate.Plo @@ -0,0 +1,122 @@ +src/c/libscitime_algo_la-getdate.lo: src/c/getdate.c \ + /usr/include/stdc-predef.h /usr/include/x86_64-linux-gnu/sys/time.h \ + /usr/include/features.h /usr/include/x86_64-linux-gnu/sys/cdefs.h \ + /usr/include/x86_64-linux-gnu/bits/wordsize.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \ + /usr/include/x86_64-linux-gnu/bits/types.h \ + /usr/include/x86_64-linux-gnu/bits/typesizes.h /usr/include/time.h \ + /usr/include/x86_64-linux-gnu/bits/time.h \ + /usr/include/x86_64-linux-gnu/sys/select.h \ + /usr/include/x86_64-linux-gnu/bits/select.h \ + /usr/include/x86_64-linux-gnu/bits/sigset.h \ + /usr/include/x86_64-linux-gnu/bits/select2.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h /usr/include/xlocale.h \ + /usr/include/stdio.h /usr/include/libio.h /usr/include/_G_config.h \ + /usr/include/wchar.h /usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h \ + /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \ + /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \ + /usr/include/x86_64-linux-gnu/bits/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/stdio2.h src/c/getdate.h \ + ../../modules/core/includes/MALLOC.h \ + ../../modules/core/includes/sci_mem_alloc.h /usr/include/stdlib.h \ + /usr/include/x86_64-linux-gnu/bits/waitflags.h \ + /usr/include/x86_64-linux-gnu/bits/waitstatus.h /usr/include/endian.h \ + /usr/include/x86_64-linux-gnu/bits/endian.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \ + /usr/include/x86_64-linux-gnu/sys/types.h \ + /usr/include/x86_64-linux-gnu/sys/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h /usr/include/alloca.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib.h \ + ../../modules/core/includes/transposeMatrix.h + +/usr/include/stdc-predef.h: + +/usr/include/x86_64-linux-gnu/sys/time.h: + +/usr/include/features.h: + +/usr/include/x86_64-linux-gnu/sys/cdefs.h: + +/usr/include/x86_64-linux-gnu/bits/wordsize.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs-64.h: + +/usr/include/x86_64-linux-gnu/bits/types.h: + +/usr/include/x86_64-linux-gnu/bits/typesizes.h: + +/usr/include/time.h: + +/usr/include/x86_64-linux-gnu/bits/time.h: + +/usr/include/x86_64-linux-gnu/sys/select.h: + +/usr/include/x86_64-linux-gnu/bits/select.h: + +/usr/include/x86_64-linux-gnu/bits/sigset.h: + +/usr/include/x86_64-linux-gnu/bits/select2.h: + +/usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h: + +/usr/include/xlocale.h: + +/usr/include/stdio.h: + +/usr/include/libio.h: + +/usr/include/_G_config.h: + +/usr/include/wchar.h: + +/usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h: + +/usr/include/x86_64-linux-gnu/bits/stdio_lim.h: + +/usr/include/x86_64-linux-gnu/bits/sys_errlist.h: + +/usr/include/x86_64-linux-gnu/bits/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/stdio2.h: + +src/c/getdate.h: + +../../modules/core/includes/MALLOC.h: + +../../modules/core/includes/sci_mem_alloc.h: + +/usr/include/stdlib.h: + +/usr/include/x86_64-linux-gnu/bits/waitflags.h: + +/usr/include/x86_64-linux-gnu/bits/waitstatus.h: + +/usr/include/endian.h: + +/usr/include/x86_64-linux-gnu/bits/endian.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap-16.h: + +/usr/include/x86_64-linux-gnu/sys/types.h: + +/usr/include/x86_64-linux-gnu/sys/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h: + +/usr/include/alloca.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib.h: + +../../modules/core/includes/transposeMatrix.h: diff --git a/modules/time/src/c/.deps/libscitime_algo_la-realtime.Plo b/modules/time/src/c/.deps/libscitime_algo_la-realtime.Plo new file mode 100755 index 000000000..5e7aacb33 --- /dev/null +++ b/modules/time/src/c/.deps/libscitime_algo_la-realtime.Plo @@ -0,0 +1,92 @@ +src/c/libscitime_algo_la-realtime.lo: src/c/realtime.c \ + /usr/include/stdc-predef.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/x86_64-linux-gnu/sys/cdefs.h \ + /usr/include/x86_64-linux-gnu/bits/wordsize.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h \ + /usr/include/x86_64-linux-gnu/bits/types.h \ + /usr/include/x86_64-linux-gnu/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h \ + /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \ + /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \ + /usr/include/x86_64-linux-gnu/bits/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/stdio2.h includes/realtime.h \ + ../../modules/core/includes/machine.h \ + /usr/include/x86_64-linux-gnu/sys/time.h /usr/include/time.h \ + /usr/include/x86_64-linux-gnu/bits/time.h \ + /usr/include/x86_64-linux-gnu/sys/select.h \ + /usr/include/x86_64-linux-gnu/bits/select.h \ + /usr/include/x86_64-linux-gnu/bits/sigset.h \ + /usr/include/x86_64-linux-gnu/bits/select2.h /usr/include/unistd.h \ + /usr/include/x86_64-linux-gnu/bits/posix_opt.h \ + /usr/include/x86_64-linux-gnu/bits/environments.h \ + /usr/include/x86_64-linux-gnu/bits/confname.h /usr/include/getopt.h \ + /usr/include/x86_64-linux-gnu/bits/unistd.h + +/usr/include/stdc-predef.h: + +/usr/include/stdio.h: + +/usr/include/features.h: + +/usr/include/x86_64-linux-gnu/sys/cdefs.h: + +/usr/include/x86_64-linux-gnu/bits/wordsize.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs-64.h: + +/usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h: + +/usr/include/x86_64-linux-gnu/bits/types.h: + +/usr/include/x86_64-linux-gnu/bits/typesizes.h: + +/usr/include/libio.h: + +/usr/include/_G_config.h: + +/usr/include/wchar.h: + +/usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h: + +/usr/include/x86_64-linux-gnu/bits/stdio_lim.h: + +/usr/include/x86_64-linux-gnu/bits/sys_errlist.h: + +/usr/include/x86_64-linux-gnu/bits/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/stdio2.h: + +includes/realtime.h: + +../../modules/core/includes/machine.h: + +/usr/include/x86_64-linux-gnu/sys/time.h: + +/usr/include/time.h: + +/usr/include/x86_64-linux-gnu/bits/time.h: + +/usr/include/x86_64-linux-gnu/sys/select.h: + +/usr/include/x86_64-linux-gnu/bits/select.h: + +/usr/include/x86_64-linux-gnu/bits/sigset.h: + +/usr/include/x86_64-linux-gnu/bits/select2.h: + +/usr/include/unistd.h: + +/usr/include/x86_64-linux-gnu/bits/posix_opt.h: + +/usr/include/x86_64-linux-gnu/bits/environments.h: + +/usr/include/x86_64-linux-gnu/bits/confname.h: + +/usr/include/getopt.h: + +/usr/include/x86_64-linux-gnu/bits/unistd.h: diff --git a/modules/time/src/c/.deps/libscitime_algo_la-timer.Plo b/modules/time/src/c/.deps/libscitime_algo_la-timer.Plo new file mode 100755 index 000000000..d002b91aa --- /dev/null +++ b/modules/time/src/c/.deps/libscitime_algo_la-timer.Plo @@ -0,0 +1,84 @@ +src/c/libscitime_algo_la-timer.lo: src/c/timer.c \ + /usr/include/stdc-predef.h /usr/include/stdio.h /usr/include/features.h \ + /usr/include/x86_64-linux-gnu/sys/cdefs.h \ + /usr/include/x86_64-linux-gnu/bits/wordsize.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h \ + /usr/include/x86_64-linux-gnu/bits/types.h \ + /usr/include/x86_64-linux-gnu/bits/typesizes.h /usr/include/libio.h \ + /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h \ + /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \ + /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \ + /usr/include/x86_64-linux-gnu/bits/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/stdio2.h /usr/include/time.h \ + /usr/include/x86_64-linux-gnu/bits/time.h /usr/include/xlocale.h \ + /usr/include/x86_64-linux-gnu/sys/time.h \ + /usr/include/x86_64-linux-gnu/sys/select.h \ + /usr/include/x86_64-linux-gnu/bits/select.h \ + /usr/include/x86_64-linux-gnu/bits/sigset.h \ + /usr/include/x86_64-linux-gnu/bits/select2.h \ + /usr/include/x86_64-linux-gnu/sys/resource.h \ + /usr/include/x86_64-linux-gnu/bits/resource.h includes/timer.h \ + ../../modules/core/includes/machine.h + +/usr/include/stdc-predef.h: + +/usr/include/stdio.h: + +/usr/include/features.h: + +/usr/include/x86_64-linux-gnu/sys/cdefs.h: + +/usr/include/x86_64-linux-gnu/bits/wordsize.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs-64.h: + +/usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h: + +/usr/include/x86_64-linux-gnu/bits/types.h: + +/usr/include/x86_64-linux-gnu/bits/typesizes.h: + +/usr/include/libio.h: + +/usr/include/_G_config.h: + +/usr/include/wchar.h: + +/usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h: + +/usr/include/x86_64-linux-gnu/bits/stdio_lim.h: + +/usr/include/x86_64-linux-gnu/bits/sys_errlist.h: + +/usr/include/x86_64-linux-gnu/bits/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/stdio2.h: + +/usr/include/time.h: + +/usr/include/x86_64-linux-gnu/bits/time.h: + +/usr/include/xlocale.h: + +/usr/include/x86_64-linux-gnu/sys/time.h: + +/usr/include/x86_64-linux-gnu/sys/select.h: + +/usr/include/x86_64-linux-gnu/bits/select.h: + +/usr/include/x86_64-linux-gnu/bits/sigset.h: + +/usr/include/x86_64-linux-gnu/bits/select2.h: + +/usr/include/x86_64-linux-gnu/sys/resource.h: + +/usr/include/x86_64-linux-gnu/bits/resource.h: + +includes/timer.h: + +../../modules/core/includes/machine.h: diff --git a/modules/time/src/c/.dirstamp b/modules/time/src/c/.dirstamp new file mode 100755 index 000000000..e69de29bb --- /dev/null +++ b/modules/time/src/c/.dirstamp diff --git a/modules/time/src/c/.libs/libscitime_algo_la-getdate.o b/modules/time/src/c/.libs/libscitime_algo_la-getdate.o Binary files differnew file mode 100755 index 000000000..dc512549a --- /dev/null +++ b/modules/time/src/c/.libs/libscitime_algo_la-getdate.o diff --git a/modules/time/src/c/.libs/libscitime_algo_la-realtime.o b/modules/time/src/c/.libs/libscitime_algo_la-realtime.o Binary files differnew file mode 100755 index 000000000..e00b54acd --- /dev/null +++ b/modules/time/src/c/.libs/libscitime_algo_la-realtime.o diff --git a/modules/time/src/c/.libs/libscitime_algo_la-timer.o b/modules/time/src/c/.libs/libscitime_algo_la-timer.o Binary files differnew file mode 100755 index 000000000..c5680d57e --- /dev/null +++ b/modules/time/src/c/.libs/libscitime_algo_la-timer.o diff --git a/modules/time/src/c/DllmainTime.c b/modules/time/src/c/DllmainTime.c new file mode 100755 index 000000000..4ace23a3b --- /dev/null +++ b/modules/time/src/c/DllmainTime.c @@ -0,0 +1,34 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) INRIA - Allan CORNET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +/*--------------------------------------------------------------------------*/ +#include <windows.h> +/*--------------------------------------------------------------------------*/ +#pragma comment(lib,"../../bin/libintl.lib") +/*--------------------------------------------------------------------------*/ +int WINAPI DllMain (HINSTANCE hInstance , DWORD reason, PVOID pvReserved) +{ + switch (reason) + { + case DLL_PROCESS_ATTACH: + break; + case DLL_PROCESS_DETACH: + break; + case DLL_THREAD_ATTACH: + break; + case DLL_THREAD_DETACH: + break; + } + return 1; +} +/*--------------------------------------------------------------------------*/ + diff --git a/modules/time/src/c/getdate.c b/modules/time/src/c/getdate.c new file mode 100755 index 000000000..ca7560e94 --- /dev/null +++ b/modules/time/src/c/getdate.c @@ -0,0 +1,284 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) INRIA - + * Copyright (C) DIGITEO - 2012 - Allan CORNET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ +/*--------------------------------------------------------------------------*/ +#ifdef _MSC_VER +#include <sys/timeb.h> +#else +#include <sys/time.h> +#endif +#include <time.h> +#include <stdio.h> +#include "getdate.h" +#include "MALLOC.h" +#include "transposeMatrix.h" +/*--------------------------------------------------------------------------*/ +#define YEAR_INDEX 0 +#define MONTH_INDEX 1 +#define WEEK_NUMBER_INDEX 2 +#define DAY_OF_YEAR_INDEX 3 +#define WEEKDAY_INDEX 4 +#define DAY_OF_MONTH_INDEX 5 +#define HOUR_OF_DAY_INDEX 6 +#define MINUTE_INDEX 7 +#define SECOND_INDEX 8 +#define MILLISECOND_INDEX 9 +/*--------------------------------------------------------------------------*/ +#define ISO_WEEK_START_WDAY 1 /* Monday */ +#define ISO_WEEK1_WDAY 4 /* Thursday */ +#define YDAY_MINIMUM (-366) +#define TM_YEAR_BASE 1900 +#ifndef __isleap +/* Nonzero if YEAR is a leap year (every 4 years, +except every 100th isn't, and every 400th is). */ +# define __isleap(year) \ + ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0)) +#endif +/*--------------------------------------------------------------------------*/ +static int week_number (struct tm *tp); +static int week_days (int yday, int wday); +/*--------------------------------------------------------------------------*/ +double *getCurrentDateAsDoubleVector(int *iErr) +{ + double *dVector = (double*) MALLOC(sizeof(double) * NB_ELEMNT_ARRAY_GETDATE); + *iErr = 1; + if (dVector) + { + struct tm *nowstruct = NULL; + double milliseconds = 0.; +#ifdef _MSC_VER + /* manages date up through 23:59:59, December 31, 3000 */ + /* previous version was limited to 19:14:07 January 18, 2038, UTC. */ + __time64_t long_time; + struct __timeb64 tstruct; + _ftime64(&tstruct); + long_time = tstruct.time; + nowstruct = _localtime64(&long_time); +#else + struct timeval timebuffer; + gettimeofday(&timebuffer, NULL); + nowstruct = localtime(&timebuffer); +#endif + +#ifdef _MSC_VER + milliseconds = (double)(tstruct.millitm); +#else + milliseconds = (double)(timebuffer.tv_usec / 1000); /* micro to ms */ +#endif + if (milliseconds < 0) + { + milliseconds = 0.; + } + + if (nowstruct) + { + dVector[YEAR_INDEX] = (double)(1900 + nowstruct->tm_year); + dVector[MONTH_INDEX] = (double)(1 + nowstruct->tm_mon); + dVector[WEEK_NUMBER_INDEX] = (double)(week_number(nowstruct)); + dVector[DAY_OF_YEAR_INDEX] = (double)(1 + nowstruct->tm_yday); + dVector[WEEKDAY_INDEX] = (double)(1 + nowstruct->tm_wday); + dVector[DAY_OF_MONTH_INDEX] = (double)(nowstruct->tm_mday); + dVector[HOUR_OF_DAY_INDEX] = (double)(nowstruct->tm_hour); + dVector[MINUTE_INDEX] = (double)(nowstruct->tm_min); + dVector[SECOND_INDEX] = (double)(nowstruct->tm_sec); + dVector[MILLISECOND_INDEX] = (double)milliseconds; + *iErr = 0; + } + } + return dVector; +} +/*--------------------------------------------------------------------------*/ +double getCurrentDateAsUnixTimeConvention(void) +{ + double dValue = 0.; +#ifdef _MSC_VER + /* manages date up through 23:59:59, December 31, 3000 */ + /* previous version was limited to 19:14:07 January 18, 2038, UTC. */ + struct __timeb64 tstruct; + _ftime64(&tstruct); + dValue = (double)tstruct.time; +#else + time_t t; + time(&t); + dValue = (double)t; +#endif + + if (dValue < 0.) + { + dValue = 0.; + } + return dValue; +} +/*--------------------------------------------------------------------------*/ +double * getConvertedDateAsDoubleVector(double dDate, int *iErr) +{ + double *dVector = (double*) MALLOC(sizeof(double) * NB_ELEMNT_ARRAY_GETDATE); + *iErr = 1; + if (dVector) + { + struct tm *tstruct = NULL; + double milliseconds = 0.; +#ifdef _MSC_VER + __time64_t instantT = (__time64_t)dDate; + tstruct = _localtime64(&instantT); +#else + time_t instantT = (time_t)dDate; + tstruct = localtime(&instantT); +#endif + milliseconds = dDate - (double)instantT; + if (milliseconds > 0) + { + if (milliseconds > 999) + { + milliseconds = (double)999; + } + } + else + { + milliseconds = 0.; + } + + if (tstruct) + { + dVector[YEAR_INDEX] = (double)(1900 + tstruct->tm_year); + dVector[MONTH_INDEX] = (double)(1 + tstruct->tm_mon); + dVector[WEEK_NUMBER_INDEX] = (double)(week_number(tstruct)); + dVector[DAY_OF_YEAR_INDEX] = (double)(1 + tstruct->tm_yday); + dVector[WEEKDAY_INDEX] = (double)(1 + tstruct->tm_wday); + dVector[DAY_OF_MONTH_INDEX] = (double)(tstruct->tm_mday); + dVector[HOUR_OF_DAY_INDEX] = (double)(tstruct->tm_hour); + dVector[MINUTE_INDEX] = (double)(tstruct->tm_min); + dVector[SECOND_INDEX] = (double)(tstruct->tm_sec); + dVector[MILLISECOND_INDEX] = (double)milliseconds; + *iErr = 0; + } + else + { + *iErr = 2; + } + } + return dVector; +} +/*--------------------------------------------------------------------------*/ +double *getConvertedDateAsMatrixOfDouble(double *dDates, int nbElements, int *iErr) +{ + double *dResults = NULL; + int lenResults = nbElements * NB_ELEMNT_ARRAY_GETDATE; + *iErr = 1; + + dResults = (double*)MALLOC(sizeof(double) * lenResults); + if (dResults) + { + int k = 0; + int j = 0; + + int m = 0; + int n = 0; + + double *dResTmp = NULL; + + for (k = 0; k < lenResults; k++) + { + dResults[k] = 0; + } + + *iErr = 0; + for (k = 0; k < nbElements; k++) + { + int iErr2 = 0; + double *dConverted = getConvertedDateAsDoubleVector(dDates[k], &iErr2); + if (iErr2 == 0) + { + int n = 0; + for (n = 0; n < NB_ELEMNT_ARRAY_GETDATE; n++) + { + dResults[j] = dConverted[n]; + j++; + } + FREE(dConverted); + dConverted = NULL; + } + else + { + FREE(dResults); + FREE(dConverted); + dResults = NULL; + *iErr = iErr2; + return NULL; + } + } + + m = nbElements; + n = NB_ELEMNT_ARRAY_GETDATE; + dResTmp = transposeMatrixDouble(n, m, dResults); + if (dResTmp) + { + FREE(dResults); + dResults = dResTmp; + *iErr = 0; + } + else + { + *iErr = 1; + } + + } + return dResults; +} +/*--------------------------------------------------------------------------*/ +/* week_days computes +* The number of days from the first day of the first ISO week of this +* year to the year day YDAY with week day WDAY. ISO weeks start on +* Monday; the first ISO week has the year's first Thursday. YDAY may +* be as small as YDAY_MINIMUM. */ +/*--------------------------------------------------------------------------*/ +static int week_days (int yday, int wday) +{ + /* Add enough to the first operand of % to make it nonnegative. */ + int big_enough_multiple_of_7 = (-YDAY_MINIMUM / 7 + 2) * 7; + return (yday - (yday - wday + ISO_WEEK1_WDAY + big_enough_multiple_of_7) % 7 + ISO_WEEK1_WDAY - ISO_WEEK_START_WDAY); +} +/*--------------------------------------------------------------------------*/ +/* week_number computes +* the ISO 8601 week number as a decimal number +* [01,53]. In the ISO 8601 week-based system, weeks +* begin on a Monday and week 1 of the year is the +* week that includes both January 4th and the first +* Thursday of the year. If the first Monday of +* January is the 2nd, 3rd, or 4th, the preceding +* days are part of the last week of the preceding +* year. */ +static int week_number(struct tm *tp) +{ + int year = tp->tm_year + TM_YEAR_BASE; + int days = week_days (tp->tm_yday, tp->tm_wday); + + if (days < 0) + { + /* This ISO week belongs to the previous year. */ + year--; + days = week_days (tp->tm_yday + (365 + __isleap(year)), tp->tm_wday); + } + else + { + int d = week_days (tp->tm_yday - (365 + __isleap(year)), tp->tm_wday); + if (0 <= d) + { + /* This ISO week belongs to the next year. */ + year++; + days = d; + } + } + return ( (int)days / 7 + 1); +} +/*--------------------------------------------------------------------------*/ + diff --git a/modules/time/src/c/getdate.h b/modules/time/src/c/getdate.h new file mode 100755 index 000000000..82aa2d06e --- /dev/null +++ b/modules/time/src/c/getdate.h @@ -0,0 +1,53 @@ +/*--------------------------------------------------------------------------*/ + +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) INRIA - Sylvestre LEDRU + * Copyright (C) DIGITEO - 2012 - Allan CORNET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +/*--------------------------------------------------------------------------*/ +#ifndef __GETDATE_H__ +#define __GETDATE_H__ + +#define NB_ELEMNT_ARRAY_GETDATE 10 + +/** +* Get Current Date as vector of double +* @param[out] ierr 0 eqs. OK +* return an array of double +*/ +double *getCurrentDateAsDoubleVector(int *iErr); + +/** +* Get Current Date as Unix Time convention +* return a double +*/ +double getCurrentDateAsUnixTimeConvention(void); + +/** +* Convert a double (Unix Time Convention) to an human date +* (a vector of double) +* @param[in] date as a double +* @param[out] ierr 0 eqs. OK +* return an array of double +*/ +double *getConvertedDateAsDoubleVector(double dDate, int *iErr); + +/** +* Convert doubles (Unix Time Convention) to an human dates +* (a matrix of double) +* @param[in] date as a double +* @param[out] ierr 0 eqs. OK +* return an array of double +*/ +double *getConvertedDateAsMatrixOfDouble(double *dDates, int nbElements, int *iErr); + +#endif /* __GETDATE_H__ */ diff --git a/modules/time/src/c/libscitime_algo_la-getdate.lo b/modules/time/src/c/libscitime_algo_la-getdate.lo new file mode 100755 index 000000000..1b2de5827 --- /dev/null +++ b/modules/time/src/c/libscitime_algo_la-getdate.lo @@ -0,0 +1,12 @@ +# src/c/libscitime_algo_la-getdate.lo - a libtool object file +# Generated by libtool (GNU libtool) 2.4.2 +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# Name of the PIC object. +pic_object='.libs/libscitime_algo_la-getdate.o' + +# Name of the non-PIC object +non_pic_object=none + diff --git a/modules/time/src/c/libscitime_algo_la-realtime.lo b/modules/time/src/c/libscitime_algo_la-realtime.lo new file mode 100755 index 000000000..3e16a67c3 --- /dev/null +++ b/modules/time/src/c/libscitime_algo_la-realtime.lo @@ -0,0 +1,12 @@ +# src/c/libscitime_algo_la-realtime.lo - a libtool object file +# Generated by libtool (GNU libtool) 2.4.2 +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# Name of the PIC object. +pic_object='.libs/libscitime_algo_la-realtime.o' + +# Name of the non-PIC object +non_pic_object=none + diff --git a/modules/time/src/c/libscitime_algo_la-timer.lo b/modules/time/src/c/libscitime_algo_la-timer.lo new file mode 100755 index 000000000..3c28c0dd1 --- /dev/null +++ b/modules/time/src/c/libscitime_algo_la-timer.lo @@ -0,0 +1,12 @@ +# src/c/libscitime_algo_la-timer.lo - a libtool object file +# Generated by libtool (GNU libtool) 2.4.2 +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# Name of the PIC object. +pic_object='.libs/libscitime_algo_la-timer.o' + +# Name of the non-PIC object +non_pic_object=none + diff --git a/modules/time/src/c/realtime.c b/modules/time/src/c/realtime.c new file mode 100755 index 000000000..a61042994 --- /dev/null +++ b/modules/time/src/c/realtime.c @@ -0,0 +1,147 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) INRIA - + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +/*--------------------------------------------------------------------------*/ +#include <stdio.h> +#include "realtime.h" + +#ifdef _MSC_VER +#include <windows.h> +#else +#include <sys/time.h> +#include <unistd.h> + +#ifndef __GNUC__ +#define inline +#endif +#endif +/*--------------------------------------------------------------------------*/ +#ifdef _MSC_VER +static double simulation_start = 0; +static double simulation_scale = 0; +static __int64 realtime_start = 0; +static int simulation_doinit = 1; +union +{ + FILETIME ftFileTime; + __int64 ftInt64; +} ftRealTime; +#else +static double simulation_start = 0; +static double simulation_scale = 0; +static unsigned long long realtime_start = 0; +static int simulation_doinit = 1; +#endif + +/*--------------------------------------------------------------------------*/ +#ifndef _MSC_VER +static inline unsigned long long TIME2ULL(struct timeval t) +{ + unsigned long long result; + result = (unsigned long long)t.tv_sec * 1000000 + t.tv_usec; + return result; +} +#endif +/*--------------------------------------------------------------------------*/ +#ifndef _MSC_VER +static inline struct timeval ULL2TIME(unsigned long long t) +{ + struct timeval result; + result.tv_sec = t / 1000000; + result.tv_usec = t % 1000000; + return result; +} +#endif +/*--------------------------------------------------------------------------*/ +#ifndef _MSC_VER +int C2F(realtimeinit)(double *t, double *scale) +{ + struct timeval now; + + gettimeofday(&now, 0); + realtime_start = TIME2ULL(now); + simulation_doinit = 1; + simulation_scale = *scale; + return 0; +} +#endif +/*--------------------------------------------------------------------------*/ +#ifndef _MSC_VER +int C2F(realtime)(double *t) +{ + struct timeval now; + unsigned long long realtime_diff; + double simulation_diff; + long long delay; + + if (simulation_doinit) + { + simulation_doinit = 0; + simulation_start = *t; + } + gettimeofday(&now, 0); + realtime_diff = TIME2ULL(now) - realtime_start; + simulation_diff = (*t - simulation_start) * simulation_scale; + delay = (long long)(simulation_diff * 1000000) - realtime_diff; + + if (delay > 0) + { + struct timeval d ; + d = ULL2TIME(delay); + select(0, 0, 0, 0, &d); + } + return 0; +} +#endif +/*--------------------------------------------------------------------------*/ +#ifdef _MSC_VER +int C2F(realtimeinit)(double *t, double *scale) +{ + SYSTEMTIME st; + GetSystemTime(&st); + SystemTimeToFileTime(&st, &ftRealTime.ftFileTime); + + realtime_start = ftRealTime.ftInt64; + simulation_doinit = 1; + simulation_scale = *scale; + return 0; +} +#endif +/*--------------------------------------------------------------------------*/ +#ifdef _MSC_VER +int C2F(realtime)(double *t) +{ + __int64 realtime_diff; + double simulation_diff; + __int64 delay; + SYSTEMTIME st; + + if (simulation_doinit) + { + simulation_doinit = 0; + simulation_start = *t; + } + GetSystemTime(&st); + SystemTimeToFileTime(&st, &ftRealTime.ftFileTime); + + realtime_diff = ftRealTime.ftInt64 - realtime_start; + simulation_diff = (*t - simulation_start) * simulation_scale; + delay = (__int64)(simulation_diff * 10000000) - realtime_diff; + + if (delay > 0) + { + Sleep((DWORD)(delay / 10000)); + } + return 0; +} +#endif +/*--------------------------------------------------------------------------*/ diff --git a/modules/time/src/c/time.rc b/modules/time/src/c/time.rc new file mode 100755 index 000000000..578160595 --- /dev/null +++ b/modules/time/src/c/time.rc @@ -0,0 +1,96 @@ +// Microsoft Visual C++ generated resource script. +// + + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +//#include "afxres.h" +#define APSTUDIO_HIDDEN_SYMBOLS +#include "windows.h" +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// French (France) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FRA) +#ifdef _WIN32 +LANGUAGE LANG_FRENCH, SUBLANG_FRENCH +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 5,5,2,0 + PRODUCTVERSION 5,5,2,0 + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040c04b0" + BEGIN + VALUE "FileDescription", "time module" + VALUE "FileVersion", "5, 5, 2, 0" + VALUE "InternalName", "time module" + VALUE "LegalCopyright", "Copyright (C) 2017" + VALUE "OriginalFilename", "time.dll" + VALUE "ProductName", " time module" + VALUE "ProductVersion", "5, 5, 2, 0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x40c, 1200 + END +END + +#endif // French (France) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/modules/time/src/c/timer.c b/modules/time/src/c/timer.c new file mode 100755 index 000000000..dd78004a6 --- /dev/null +++ b/modules/time/src/c/timer.c @@ -0,0 +1,103 @@ +/* +* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +* Copyright (C) INRIA - Allan CORNET +* Copyright (C) DIGITEO - 2009-2010 - Allan CORNET +* +* This file must be used under the terms of the CeCILL. +* This source file is licensed as described in the file COPYING, which +* you should have received as part of this distribution. The terms +* are also available at +* http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt +* +*/ + +/*--------------------------------------------------------------------------*/ +#include <stdio.h> +#include <time.h> + +#ifndef _MSC_VER +#include <sys/time.h> +#include <sys/resource.h> /* getrusage */ +#else +#include <windows.h> +#endif +#include "timer.h" +/* +http://msdn.microsoft.com/en-us/library/ms683223(VS.85).aspx +http://www.opengroup.org/onlinepubs/000095399/functions/getrusage.html +*/ +/*--------------------------------------------------------------------------*/ +static double previousTimerValue = 0.0; +/*--------------------------------------------------------------------------*/ +static int init_clock = 1; +/*--------------------------------------------------------------------------*/ +int C2F(timer)(double *etime) +{ + *etime = scilab_timer(); + return(0); +} +/*--------------------------------------------------------------------------*/ +double scilab_timer(void) +{ + double etime = 0.0; + double now = 0.0; + double usertime = 0.0, systime = 0.0; + +#ifdef _MSC_VER + FILETIME creation_time, exit_time, kernel_time, user_time; + unsigned long long utime, stime; + + GetProcessTimes (GetCurrentProcess (), &creation_time, &exit_time, + &kernel_time, &user_time); + + utime = ((unsigned long long) user_time.dwHighDateTime << 32) + + (unsigned) user_time.dwLowDateTime; + + stime = ((unsigned long long) kernel_time.dwHighDateTime << 32) + + (unsigned) kernel_time.dwLowDateTime; + + usertime = (double)(utime / 1.0e7); + systime = (double)(stime / 1.0e7); + + now = (double)(usertime + systime); + + if (init_clock == 1) + { + init_clock = 0; + previousTimerValue = now ; + // initialization forced here 0 - 0 > -0 or +0 + etime = 0.0; + } +#else + struct rusage rbuff; + getrusage (RUSAGE_SELF, &rbuff); + + usertime = (double)((float) (rbuff.ru_utime).tv_sec + + (float) (rbuff.ru_utime).tv_usec / 1000000.0); + + systime = (double)((float) (rbuff.ru_stime).tv_sec + + (float) (rbuff.ru_stime).tv_usec / 1000000.0); + + now = (double)(usertime + systime); + + if (init_clock == 1) + { + init_clock = 0; + previousTimerValue = now ; + // initialization forced here 0 - 0 > -0 or +0 + etime = 0.0; + } +#endif + else + { + etime = (double)(now - previousTimerValue); + if (etime < 0.0) + { + previousTimerValue = 0.0; + etime = 0.0; + } + } + previousTimerValue = now ; + return etime; +} +/*--------------------------------------------------------------------------*/ |