mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-15 00:44:19 +09:00
Merge pull request #11077 from akallabeth/tzsimplify
Tzsimplify and primitives benchmark fix
This commit is contained in:
@@ -165,6 +165,7 @@ fail:
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if defined(HAVE_CPU_OPTIMIZED_PRIMITIVES) && defined(WITH_OPENCL)
|
||||
static BOOL primitives_YUV_benchmark_run(primitives_YUV_benchmark* bench, primitives_t* prims,
|
||||
UINT64 runTime, UINT32* computations)
|
||||
{
|
||||
@@ -196,6 +197,7 @@ static BOOL primitives_YUV_benchmark_run(primitives_YUV_benchmark* bench, primit
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
static BOOL primitives_autodetect_best(primitives_t* prims)
|
||||
{
|
||||
@@ -222,7 +224,11 @@ static BOOL primitives_autodetect_best(primitives_t* prims)
|
||||
|
||||
#if !defined(HAVE_CPU_OPTIMIZED_PRIMITIVES) || !defined(WITH_OPENCL)
|
||||
{
|
||||
#if defined(HAVE_CPU_OPTIMIZED_PRIMITIVES) || defined(WITH_OPENCL)
|
||||
struct prim_benchmark* cur = &testcases[1];
|
||||
#else
|
||||
struct prim_benchmark* cur = &testcases[0];
|
||||
#endif
|
||||
cur->prims = primitives_get_by_type(cur->flags);
|
||||
if (!cur->prims)
|
||||
{
|
||||
|
||||
@@ -30,7 +30,7 @@ if(WITH_TIMEZONE_FROM_FILE)
|
||||
install(FILES TimeZoneNameMap.json DESTINATION ${WINPR_RESOURCE_ROOT})
|
||||
endif()
|
||||
|
||||
set(SRCS TimeZoneNameMapUtils.c TimeZoneNameMap.h timezone.c)
|
||||
set(SRCS TimeZoneNameMapUtils.c TimeZoneNameMap.h timezone.c timezone.h)
|
||||
if(WITH_TIMEZONE_COMPILED)
|
||||
list(APPEND SRCS TimeZoneNameMap_static.h)
|
||||
endif()
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include <winpr/string.h>
|
||||
#include "timezone.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@@ -73,25 +74,14 @@ static void append_timezone(const char* dir, const char* name)
|
||||
if (!tz)
|
||||
return;
|
||||
|
||||
const char* otz = getenv("TZ");
|
||||
char* oldtz = NULL;
|
||||
if (otz)
|
||||
oldtz = _strdup(otz);
|
||||
setenv("TZ", tz, 1);
|
||||
tzset();
|
||||
char* oldtz = setNewAndSaveOldTZ(tz);
|
||||
|
||||
const time_t t = time(NULL);
|
||||
struct tm lt = { 0 };
|
||||
(void)localtime_r(&t, <);
|
||||
append(tz, lt.tm_zone);
|
||||
if (oldtz)
|
||||
{
|
||||
setenv("TZ", oldtz, 1);
|
||||
free(oldtz);
|
||||
}
|
||||
else
|
||||
unsetenv("TZ");
|
||||
restoreSavedTZ(oldtz);
|
||||
free(tz);
|
||||
tzset();
|
||||
}
|
||||
|
||||
static void handle_link(const char* base, const char* dir, const char* name);
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <winpr/assert.h>
|
||||
#include <winpr/file.h>
|
||||
#include "../log.h"
|
||||
#include "timezone.h"
|
||||
|
||||
#define TAG WINPR_TAG("timezone")
|
||||
|
||||
@@ -875,31 +876,12 @@ DWORD EnumDynamicTimeZoneInformation(const DWORD dwIndex,
|
||||
const time_t t = time(NULL);
|
||||
struct tm tres = { 0 };
|
||||
|
||||
const char* tz = getenv("TZ");
|
||||
char* tzcopy = NULL;
|
||||
if (tz)
|
||||
{
|
||||
size_t tzianalen = 0;
|
||||
winpr_asprintf(&tzcopy, &tzianalen, "TZ=%s", tz);
|
||||
}
|
||||
char* tzcopy = entry->Iana ? setNewAndSaveOldTZ(entry->Iana) : NULL;
|
||||
|
||||
char* tziana = NULL;
|
||||
{
|
||||
size_t tzianalen = 0;
|
||||
winpr_asprintf(&tziana, &tzianalen, "TZ=%s", entry->Iana);
|
||||
}
|
||||
if (tziana)
|
||||
putenv(tziana);
|
||||
|
||||
tzset();
|
||||
struct tm* local_time = localtime_r(&t, &tres);
|
||||
free(tziana);
|
||||
if (tzcopy)
|
||||
putenv(tzcopy);
|
||||
else
|
||||
unsetenv("TZ");
|
||||
free(tzcopy);
|
||||
tzset();
|
||||
|
||||
if (entry->Iana)
|
||||
restoreSavedTZ(tzcopy);
|
||||
|
||||
if (local_time)
|
||||
dynamic_time_zone_from_localtime(local_time, lpTimeZoneInformation);
|
||||
@@ -936,3 +918,32 @@ DWORD GetDynamicTimeZoneInformationEffectiveYears(
|
||||
return ERROR_FILE_NOT_FOUND;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(_WIN32)
|
||||
char* setNewAndSaveOldTZ(const char* val)
|
||||
{
|
||||
// NOLINTBEGIN(concurrency-mt-unsafe)
|
||||
const char* otz = getenv("TZ");
|
||||
char* oldtz = NULL;
|
||||
if (otz)
|
||||
oldtz = _strdup(otz);
|
||||
setenv("TZ", val, 1);
|
||||
tzset();
|
||||
// NOLINTEND(concurrency-mt-unsafe)
|
||||
return oldtz;
|
||||
}
|
||||
|
||||
void restoreSavedTZ(char* saved)
|
||||
{
|
||||
// NOLINTBEGIN(concurrency-mt-unsafe)
|
||||
if (saved)
|
||||
{
|
||||
setenv("TZ", saved, 1);
|
||||
free(saved);
|
||||
}
|
||||
else
|
||||
unsetenv("TZ");
|
||||
tzset();
|
||||
// NOLINTEND(concurrency-mt-unsafe)
|
||||
}
|
||||
#endif
|
||||
|
||||
26
winpr/libwinpr/timezone/timezone.h
Normal file
26
winpr/libwinpr/timezone/timezone.h
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* WinPR: Windows Portable Runtime
|
||||
* Time Zone
|
||||
*
|
||||
* Copyright 2025 Armin Novak <anovak@thincast.com>
|
||||
* Copyright 2025 Thincast Technologies GmbH
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(_WIN32)
|
||||
char* setNewAndSaveOldTZ(const char* val);
|
||||
void restoreSavedTZ(char* saved);
|
||||
#endif
|
||||
Reference in New Issue
Block a user