skia2/third_party/icu/SkLoadICU.h
Hal Canary 9dc532dd13 SkLoadICU: s/LoadLibrary/LoadLibraryA/
Bug: skia:8695
Change-Id: I71515d6c58e92147e74127bceb0b365164a358be
Reviewed-on: https://skia-review.googlesource.com/c/186084
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Hal Canary <halcanary@google.com>
2019-01-23 16:13:40 +00:00

53 lines
1.4 KiB
C

/*
* Copyright 2018 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef load_icu_DEFINED
#define load_icu_DEFINED
#include "SkTypes.h"
#ifdef SK_BUILD_FOR_WIN
#include "../private/SkLeanWindows.h"
#include "unicode/uvernum.h"
#include "unicode/udata.h"
#define ICU_UTIL_DATA_SYMBOL "icudt" U_ICU_VERSION_SHORT "_dat"
#define ICU_UTIL_DATA_SHARED_MODULE_NAME "icudt.dll"
inline void SkLoadICU() {
HMODULE module = LoadLibraryA(ICU_UTIL_DATA_SHARED_MODULE_NAME);
if (!module) {
SK_ABORT("Failed to load " ICU_UTIL_DATA_SHARED_MODULE_NAME "\n");
}
FARPROC addr = GetProcAddress(module, ICU_UTIL_DATA_SYMBOL);
if (!addr) {
SK_ABORT("Symbol " ICU_UTIL_DATA_SYMBOL " missing in "
ICU_UTIL_DATA_SHARED_MODULE_NAME ".\n");
}
UErrorCode err = U_ZERO_ERROR;
udata_setCommonData(reinterpret_cast<void*>(addr), &err);
if (err != U_ZERO_ERROR) {
SkDebugf("udata_setCommonData() returned %d.\n", (int)err);
SK_ABORT("");
}
udata_setFileAccess(UDATA_ONLY_PACKAGES, &err);
if (err != U_ZERO_ERROR) {
SkDebugf("udata_setFileAccess() returned %d.\n", (int)err);
SK_ABORT("");
}
}
#undef ICU_UTIL_DATA_SHARED_MODULE_NAME
#undef ICU_UTIL_DATA_SYMBOL
#else
inline void SkLoadICU() {}
#endif // SK_BUILD_FOR_WIN
#endif // load_icu_DEFINED