compat: Add libutils shim

* This is required because some old libraries still rely on the
  strncpy16() function.

Change-Id: I77da329d1296d946f43ffe6708444b1d25607342
This commit is contained in:
R0rt1z2 2023-07-19 19:18:44 +00:00 committed by Sebastiano Barezzi
parent 895a614971
commit 118bd4294f
No known key found for this signature in database
GPG key ID: 763BD3AE91A7A13F
2 changed files with 30 additions and 0 deletions

View file

@ -335,6 +335,14 @@ cc_library_shared {
vendor_available: true, vendor_available: true,
} }
cc_library_shared {
name: "libutils_shim",
shared_libs: ["libutils"],
srcs: ["libutils/String16.cpp"],
system_ext_specific: true,
vendor_available: true,
}
cc_library { cc_library {
name: "libip_checksum_shim", name: "libip_checksum_shim",
whole_static_libs: [ whole_static_libs: [

22
libutils/String16.cpp Normal file
View file

@ -0,0 +1,22 @@
/*
* Copyright (C) 2023 The LineageOS Project
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdio.h>
extern "C" {
char16_t* strncpy16(char16_t* dst, const char16_t* src, size_t n) {
char16_t* q = dst;
const char16_t* p = src;
char ch;
while (n) {
n--;
*q++ = ch = *p++;
if (!ch) break;
}
*q = 0;
return dst;
}
}