-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #611 from pguyot/w21/unix-file-nif
Implement basic POSIX file functions as nifs NIFs are compiled if platform features common POSIX functions `open`, `close`, `read`, `write` and `unlink`. Implementation is non-blocking and a more complete implementation of a file module may require `enif_select`, at least to work with FIFO pipes and devices. On ESP32, implementation depends on vfs_fat driver which is always blocking (and does not support select). Qemu-based test writes to a (virtual) SD card. However, support for SD card still requires C code to mount it which is not the object of this PR. These changes are made under both the "Apache 2.0" and the "GNU Lesser General Public License 2.1 or later" license terms (dual license). SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
- Loading branch information
Showing
22 changed files
with
872 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# | ||
# This file is part of AtomVM. | ||
# | ||
# Copyright 2023 Paul Guyot <[email protected]> | ||
# | ||
# 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. | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later | ||
# | ||
|
||
include(CheckSymbolExists) | ||
include(CheckCSourceCompiles) | ||
|
||
function(define_if_symbol_exists target symbol header scope macro) | ||
check_symbol_exists(${symbol} ${header} ${macro}) | ||
if (${macro}) | ||
target_compile_definitions(${target} ${scope} ${macro}) | ||
endif(${macro}) | ||
endfunction() | ||
function(define_if_function_exists target symbol header scope macro) | ||
check_c_source_compiles(" | ||
#include <${header}> | ||
int main(int argc) | ||
{ | ||
return ((int*)(&${symbol}))[argc]; | ||
}" ${macro}) | ||
if (${macro}) | ||
target_compile_definitions(${target} ${scope} ${macro}) | ||
endif(${macro}) | ||
endfunction() |
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
Oops, something went wrong.