Fix windows and cpp compatibility (#2887)

This commit is contained in:
billow 2022-08-08 23:57:30 +08:00 committed by GitHub
parent 1c9f93f7ef
commit 215e49253d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 6 deletions

View file

@ -51,6 +51,7 @@ include_files = [
'rz_types_overflow.h',
'rz_util.h',
'rz_vector.h',
'rz_windows.h',
'rz_windows_heap.h',
]
install_headers(include_files, install_dir: rizin_incdir)

View file

@ -12,16 +12,22 @@
#define ASCTIME_BUF_MINLEN 26
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _MSC_VER
struct timeval;
struct timezone {
struct rz_timezone {
int tz_minuteswest; /* minutes W of Greenwich */
int tz_dsttime; /* type of dst correction */
};
#else
#define rz_timezone timezone
#endif
RZ_API int rz_time_gettimeofday(struct timeval *p, struct timezone *tz);
RZ_API int rz_time_gettimeofday(struct timeval *p, struct rz_timezone *tz);
// wall clock time in microseconds
RZ_API ut64 rz_time_now(void);
@ -58,4 +64,8 @@ RZ_API struct tm *rz_gmtime_r(RZ_NONNULL const time_t *time, RZ_NONNULL struct t
} while (0)
#endif
#ifdef __cplusplus
}
#endif
#endif

View file

@ -23,10 +23,10 @@
* information.
*
* \param p Pointer to a \p timeval structure that will be filled by this function
* \param tz Pointer to a \p timezone structure that will be filled by this function
* \param tz Pointer to a \p rz_timezone structure that will be filled by this function
* \return 0 if the function succeeds, -1 on error
*/
RZ_API int rz_time_gettimeofday(struct timeval *p, struct timezone *tz) {
RZ_API int rz_time_gettimeofday(struct timeval *p, struct rz_timezone *tz) {
// ULARGE_INTEGER ul; // As specified on MSDN.
ut64 ul = 0;
static int tzflag = 0;
@ -72,10 +72,10 @@ RZ_API int rz_time_gettimeofday(struct timeval *p, struct timezone *tz) {
* information.
*
* \param p Pointer to a \p timeval structure that will be filled by this function
* \param tz Pointer to a \p timezone structure that will be filled by this function
* \param tz Pointer to a \p rz_timezone structure that will be filled by this function
* \return 0 if the function succeeds, -1 on error
*/
RZ_API int rz_time_gettimeofday(struct timeval *p, struct timezone *tz) {
RZ_API int rz_time_gettimeofday(struct timeval *p, struct rz_timezone *tz) {
return gettimeofday(p, tz);
}
#endif