OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [uclinux/] [uC-libc/] [sysdeps/] [closedir.c] - Blame information for rev 1767

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 199 simons
#define close __normal_close
2
#include <stdlib.h>
3
#include <unistd.h>
4
#include <errno.h>
5
#undef _POSIX_PTHREADS
6
#include <syscall.h>
7
#include "dirstream.h"
8
 
9
#undef close
10
static inline
11
_syscall1(int,close,int,fd)
12
 
13
int
14
closedir(DIR * dir)
15
{
16
  int fd;
17
 
18
  if (!dir) {
19
    errno = EBADF;
20
    return -1;
21
  }
22
 
23
  /* We need to check dd_fd. */
24
  if (dir->dd_fd == -1)
25
  {
26
    errno = EBADF;
27
    return -1;
28
  }
29
  fd = dir->dd_fd;
30
  dir->dd_fd = -1;
31
  free(dir->dd_buf);
32
  free(dir);
33
  return close(fd);
34
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.