1*eca53ba6SRoland Levillain // Copyright 2017 Google LLC 2*eca53ba6SRoland Levillain // 3*eca53ba6SRoland Levillain // Licensed under the Apache License, Version 2.0 (the "License"); 4*eca53ba6SRoland Levillain // you may not use this file except in compliance with the License. 5*eca53ba6SRoland Levillain // You may obtain a copy of the License at 6*eca53ba6SRoland Levillain // 7*eca53ba6SRoland Levillain // http://www.apache.org/licenses/LICENSE-2.0 8*eca53ba6SRoland Levillain // 9*eca53ba6SRoland Levillain // Unless required by applicable law or agreed to in writing, software 10*eca53ba6SRoland Levillain // distributed under the License is distributed on an "AS IS" BASIS, 11*eca53ba6SRoland Levillain // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12*eca53ba6SRoland Levillain // See the License for the specific language governing permissions and 13*eca53ba6SRoland Levillain // limitations under the License. 14*eca53ba6SRoland Levillain 15*eca53ba6SRoland Levillain // An interface for the filesystem that allows mocking the filesystem in 16*eca53ba6SRoland Levillain // unittests. 17*eca53ba6SRoland Levillain #ifndef CPU_FEATURES_INCLUDE_INTERNAL_FILESYSTEM_H_ 18*eca53ba6SRoland Levillain #define CPU_FEATURES_INCLUDE_INTERNAL_FILESYSTEM_H_ 19*eca53ba6SRoland Levillain 20*eca53ba6SRoland Levillain #include <stddef.h> 21*eca53ba6SRoland Levillain #include <stdint.h> 22*eca53ba6SRoland Levillain 23*eca53ba6SRoland Levillain #include "cpu_features_macros.h" 24*eca53ba6SRoland Levillain 25*eca53ba6SRoland Levillain CPU_FEATURES_START_CPP_NAMESPACE 26*eca53ba6SRoland Levillain 27*eca53ba6SRoland Levillain // Same as linux "open(filename, O_RDONLY)", retries automatically on EINTR. 28*eca53ba6SRoland Levillain int CpuFeatures_OpenFile(const char* filename); 29*eca53ba6SRoland Levillain 30*eca53ba6SRoland Levillain // Same as linux "read(file_descriptor, buffer, buffer_size)", retries 31*eca53ba6SRoland Levillain // automatically on EINTR. 32*eca53ba6SRoland Levillain int CpuFeatures_ReadFile(int file_descriptor, void* buffer, size_t buffer_size); 33*eca53ba6SRoland Levillain 34*eca53ba6SRoland Levillain // Same as linux "close(file_descriptor)". 35*eca53ba6SRoland Levillain void CpuFeatures_CloseFile(int file_descriptor); 36*eca53ba6SRoland Levillain 37*eca53ba6SRoland Levillain CPU_FEATURES_END_CPP_NAMESPACE 38*eca53ba6SRoland Levillain 39*eca53ba6SRoland Levillain #endif // CPU_FEATURES_INCLUDE_INTERNAL_FILESYSTEM_H_ 40