blob: 533d3e1fe56fa72177b96b3425950fb3fda886bb [file] [edit]
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
///
/// \file
/// This file contains the bare-metal implementation of fseek.
///
//===----------------------------------------------------------------------===//
#include "src/stdio/fseek.h"
#include "hdr/errno_macros.h"
#include "src/__support/OSUtil/io.h"
#include "src/__support/common.h"
#include "src/__support/libc_errno.h"
#include "src/__support/macros/config.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(int, fseek, (::FILE * stream, long offset, int whence)) {
if (stream == nullptr) {
libc_errno = EINVAL;
return -1;
}
off_t off = offset;
int result = __llvm_libc_stdio_seek(stream, &off, whence);
if (result < 0) {
libc_errno = -result;
return -1;
}
return 0;
}
} // namespace LIBC_NAMESPACE_DECL