/* See LICENSE of license details. */

#include "stub.h"
#include "weak_under_alias.h"
#include <errno.h>
#include <sys/types.h>
#include <unistd.h>
#if defined(SEMIHOSTING)
#include "semihosting.h"
#endif

off_t __wrap_lseek(int fd, off_t ptr, int dir) {
#if defined(SEMIHOSTING)
  if (sh_istty(fd))
    return 0;
  sh_seek(fd, ptr);
  return ptr;
#endif
  if (isatty(fd))
    return 0;

  return _stub(EBADF);
}

weak_under_alias(lseek);