Add some platform abstractions.
(This is a merge of http://go/wvgerrit/70303) This adds a platform.h file to abstract some of the differences between Windows and POSIX platforms. This includes ntohl, setenv, and ssize_t. Bug: 122953649 Test: Android Unit Tests Change-Id: I3235f3f284b53d24d7365ff3f4a06dcd9b403697
This commit is contained in:
21
libwvdrmengine/cdm/util/src/platform.cpp
Normal file
21
libwvdrmengine/cdm/util/src/platform.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
// Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary
|
||||
// source code may only be used and distributed under the Widevine Master
|
||||
// License Agreement.
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
#include "stdlib.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
int setenv(const char* key, const char* value, int overwrite) {
|
||||
if (!overwrite) {
|
||||
size_t size;
|
||||
errno_t err = getenv_s(&size, nullptr, 0, key);
|
||||
if (err != 0 || size != 0)
|
||||
return err; // Return 0 if it exists, but don't change.
|
||||
}
|
||||
return _putenv_s(key, value);
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user