-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change-Id: I6966eac26431373e6eccd70f9b31386daac5717d
- Loading branch information
1 parent
fd3e046
commit bec97aa
Showing
9 changed files
with
137 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
starboard/shared/modular/cobalt_layer_posix_file_abi_wrappers.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright 2024 The Cobalt Authors. All Rights Reserved. | ||
// | ||
// 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. | ||
|
||
#if SB_API_VERSION >= 16 | ||
|
||
#include <unistd.h> | ||
|
||
extern "C" { | ||
|
||
off_t __abi_wrap_lseek(int fildes, off_t offset, int whence); | ||
|
||
off_t lseek(int fildes, off_t offset, int whence) { | ||
return __abi_wrap_lseek(fildes, offset, whence); | ||
} | ||
|
||
ssize_t __abi_wrap_read(int fildes, void* buf, size_t nbyte); | ||
|
||
ssize_t read(int fildes, void* buf, size_t nbyte) { | ||
return __abi_wrap_read(int fildes, void* buf, size_t nbyte); | ||
} | ||
} | ||
|
||
#endif // SB_API_VERSION >= 16 |
26 changes: 26 additions & 0 deletions
26
starboard/shared/modular/starboard_layer_posix_file_abi_wrappers.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright 2024 The Cobalt Authors. All Rights Reserved. | ||
// | ||
// 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. | ||
|
||
#include "starboard/shared/modular/starboard_layer_posix_file_abi_wrappers.h" | ||
|
||
#include <sys/types.h> | ||
#include <unistd.h> | ||
|
||
musl_off_t __abi_wrap_lseek(int fildes, musl_off_t offset, int whence) { | ||
return static_cast<off_t>(lseek(fildes, static_cast<off_t>(offset), whence)); | ||
} | ||
|
||
ssize_t __abi_wrap_read(int fildes, void* buf, size_t nbyte) { | ||
return read(int fildes, void* buf, size_t nbyte); | ||
} |
62 changes: 62 additions & 0 deletions
62
starboard/shared/modular/starboard_layer_posix_file_abi_wrappers.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Copyright 2024 The Cobalt Authors. All Rights Reserved. | ||
// | ||
// 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. | ||
|
||
#ifndef STARBOARD_SHARED_MODULAR_STARBOARD_LAYER_POSIX_FILE_ABI_WRAPPERS_H_ | ||
#define STARBOARD_SHARED_MODULAR_STARBOARD_LAYER_POSIX_FILE_ABI_WRAPPERS_H_ | ||
|
||
#include <stdint.h> | ||
#include <sys/types.h> | ||
|
||
#include "starboard/export.h" | ||
|
||
// The `__abi_wrap_lseek` function converts from the musl's off_t | ||
// type to the platform's off_t which may have different sizes as | ||
// the definition is platform specific. | ||
// The `__abi_wrap_read` function converts ssize_t to int32_t or | ||
// int64_t depending on the platform. | ||
// | ||
// The wrapper is used by all modular builds, including Evergreen. | ||
// | ||
// For Evergreen-based modular builds, we will rely on the exported_symbols.cc | ||
// mapping logic to map calls to file IO functions to `__abi_wrap_` file IO | ||
// functions. | ||
// | ||
// For non-Evergreen modular builds, the Cobalt-side shared library will be | ||
// compiled with code that remaps calls to file IO functions to `__abi_wrap_` | ||
// file IO functions. | ||
|
||
// A matching type for the off_t definition in musl. | ||
typedef int64_t musl_off_t; | ||
|
||
#if SB_IS(ARCH_ARM64) || SB_IS(ARCH_X64) | ||
typedef int64_t ssize_t; | ||
#else | ||
typedef int32_t ssize_t; | ||
#endif | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
SB_EXPORT musl_off_t __abi_wrap_lseek(int fildes, | ||
musl_off_t offset, | ||
int whence); | ||
|
||
SB_EXPORT ssize_t __abi_wrap_read(int fildes, void* buf, size_t nbyte); | ||
|
||
#ifdef __cplusplus | ||
} // extern "C" | ||
#endif | ||
|
||
#endif // STARBOARD_SHARED_MODULAR_STARBOARD_LAYER_POSIX_FILE_ABI_WRAPPERS_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,6 +96,7 @@ | |
'free', | ||
'freeifaddrs', | ||
'freeaddrinfo', | ||
'fstat', | ||
'gettimeofday', | ||
'getifaddrs', | ||
'getaddrinfo', | ||
|