mirror of
https://github.com/cemu-project/vcpkg.git
synced 2025-02-23 11:07:10 +01:00
New port: MIT gettimeofday implementation (#2063)
* [gettimeofday] create CONTROL * [gettimeofday] add source file * [gettimeofday] add header * [gettimeofday] create portfile * [gettimeofday] add cmakelists.txt * [gettimeofday/portfile] require static * [gettimeofday/portfile] set source path * [gettimeofday] create license * [gettimeofday] remove duplicate headers
This commit is contained in:
parent
79ebd26605
commit
29f62852bd
14
ports/gettimeofday/CMakeLists.txt
Normal file
14
ports/gettimeofday/CMakeLists.txt
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.8)
|
||||||
|
project(gettimeofday C)
|
||||||
|
|
||||||
|
add_library(gettimeofday gettimeofday.c gettimeofday.def)
|
||||||
|
|
||||||
|
install(TARGETS gettimeofday
|
||||||
|
RUNTIME DESTINATION bin
|
||||||
|
ARCHIVE DESTINATION lib
|
||||||
|
LIBRARY DESTINATION lib
|
||||||
|
)
|
||||||
|
|
||||||
|
if(CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||||
|
install(FILES gettimeofday.h DESTINATION include)
|
||||||
|
endif()
|
3
ports/gettimeofday/CONTROL
Normal file
3
ports/gettimeofday/CONTROL
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Source: gettimeofday
|
||||||
|
Version: 2017-10-14-1
|
||||||
|
Description: An implementation of gettimeofday for WIN32
|
33
ports/gettimeofday/LICENSE
Normal file
33
ports/gettimeofday/LICENSE
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* Copied from PostgreSQL source:
|
||||||
|
* http://doxygen.postgresql.org/gettimeofday_8c_source.html
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* gettimeofday.c
|
||||||
|
* Win32 gettimeofday() replacement
|
||||||
|
*
|
||||||
|
* src/port/gettimeofday.c
|
||||||
|
*
|
||||||
|
* Copyright (c) 2003 SRA, Inc.
|
||||||
|
* Copyright (c) 2003 SKC, Inc.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software and
|
||||||
|
* its documentation for any purpose, without fee, and without a
|
||||||
|
* written agreement is hereby granted, provided that the above
|
||||||
|
* copyright notice and this paragraph and the following two
|
||||||
|
* paragraphs appear in all copies.
|
||||||
|
*
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT,
|
||||||
|
* INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
|
||||||
|
* LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
|
||||||
|
* DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED
|
||||||
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS
|
||||||
|
* IS" BASIS, AND THE AUTHOR HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE,
|
||||||
|
* SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
||||||
|
*/
|
67
ports/gettimeofday/gettimeofday.c
Normal file
67
ports/gettimeofday/gettimeofday.c
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
* Copied from PostgreSQL source:
|
||||||
|
* http://doxygen.postgresql.org/gettimeofday_8c_source.html
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* gettimeofday.c
|
||||||
|
* Win32 gettimeofday() replacement
|
||||||
|
*
|
||||||
|
* src/port/gettimeofday.c
|
||||||
|
*
|
||||||
|
* Copyright (c) 2003 SRA, Inc.
|
||||||
|
* Copyright (c) 2003 SKC, Inc.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software and
|
||||||
|
* its documentation for any purpose, without fee, and without a
|
||||||
|
* written agreement is hereby granted, provided that the above
|
||||||
|
* copyright notice and this paragraph and the following two
|
||||||
|
* paragraphs appear in all copies.
|
||||||
|
*
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT,
|
||||||
|
* INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
|
||||||
|
* LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
|
||||||
|
* DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED
|
||||||
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
* A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS
|
||||||
|
* IS" BASIS, AND THE AUTHOR HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE,
|
||||||
|
* SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
|
||||||
|
#include <winsock2.h>
|
||||||
|
|
||||||
|
|
||||||
|
/* FILETIME of Jan 1 1970 00:00:00. */
|
||||||
|
static const unsigned __int64 epoch = 116444736000000000Ui64;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* timezone information is stored outside the kernel so tzp isn't used anymore.
|
||||||
|
*
|
||||||
|
* Note: this function is not for Win32 high precision timing purpose. See
|
||||||
|
* elapsed_time().
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
gettimeofday(struct timeval * tp, struct timezone * tzp)
|
||||||
|
{
|
||||||
|
FILETIME file_time;
|
||||||
|
SYSTEMTIME system_time;
|
||||||
|
ULARGE_INTEGER ularge;
|
||||||
|
|
||||||
|
GetSystemTime(&system_time);
|
||||||
|
SystemTimeToFileTime(&system_time, &file_time);
|
||||||
|
ularge.LowPart = file_time.dwLowDateTime;
|
||||||
|
ularge.HighPart = file_time.dwHighDateTime;
|
||||||
|
|
||||||
|
tp->tv_sec = (long) ((ularge.QuadPart - epoch) / 10000000L);
|
||||||
|
tp->tv_usec = (long) (system_time.wMilliseconds * 1000);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* _MSC_VER */
|
2
ports/gettimeofday/gettimeofday.def
Normal file
2
ports/gettimeofday/gettimeofday.def
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
EXPORTS
|
||||||
|
gettimeofday
|
16
ports/gettimeofday/gettimeofday.h
Normal file
16
ports/gettimeofday/gettimeofday.h
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#ifndef _MY_GETTIMEOFDAY_H_
|
||||||
|
#define _MY_GETTIMEOFDAY_H_
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
|
||||||
|
#include <winsock2.h>
|
||||||
|
int gettimeofday(struct timeval * tp, struct timezone * tzp);
|
||||||
|
|
||||||
|
struct timespec {
|
||||||
|
time_t tv_sec;
|
||||||
|
time_t tv_nsec;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* _MSC_VER */
|
||||||
|
|
||||||
|
#endif /* _MY_GETTIMEOFDAY_H_ */
|
11
ports/gettimeofday/portfile.cmake
Normal file
11
ports/gettimeofday/portfile.cmake
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
include(vcpkg_common_functions)
|
||||||
|
|
||||||
|
vcpkg_configure_cmake(
|
||||||
|
SOURCE_PATH ${CMAKE_CURRENT_LIST_DIR}
|
||||||
|
PREFER_NINJA
|
||||||
|
)
|
||||||
|
|
||||||
|
vcpkg_install_cmake()
|
||||||
|
vcpkg_copy_pdbs()
|
||||||
|
|
||||||
|
file(INSTALL ${CMAKE_CURRENT_LIST_DIR}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/gettimeofday RENAME copyright)
|
Loading…
x
Reference in New Issue
Block a user