This is the mail archive of the newlib@sources.redhat.com mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH/RFA add "access" function for ARM



This patch adds the access() function for the ARM to newlib.  
Implementation isn't perfect, since there isn't really enough information 
available to do the job properly; but it's enough to make most of the f77 
tests in the gcc testsuite that rely on this function pass.

If this is ok, could someone please install it.

R.

PS, I'm not on this mailing list; please cc me directly on any follow up.

<date>  Richard Earnshaw  <rearnsha@arm.com>

	* sys/arm/access.c: New file.
	* sys/arm/Makefile.am (lib_a_SOURCES): Add it
	* sys/arm/Makefile.in: Regenerate.
	* sys/arm/syscalls.c (_stat): New function.


Index: libc/sys/arm/Makefile.am
===================================================================
RCS file: /cvs/src/src/newlib/libc/sys/arm/Makefile.am,v
retrieving revision 1.1.1.1
diff -p -r1.1.1.1 Makefile.am
*** Makefile.am	2000/02/17 19:39:49	1.1.1.1
--- Makefile.am	2002/03/08 17:58:13
*************** INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLA
*** 6,12 ****
  
  noinst_LIBRARIES = lib.a
  
! lib_a_SOURCES = syscalls.c libcfunc.c trap.S setjmp.S
  
  all: crt0.o
  
--- 6,12 ----
  
  noinst_LIBRARIES = lib.a
  
! lib_a_SOURCES = access.c syscalls.c libcfunc.c trap.S setjmp.S
  
  all: crt0.o
  
Index: libc/sys/arm/Makefile.in
===================================================================
RCS file: /cvs/src/src/newlib/libc/sys/arm/Makefile.in,v
retrieving revision 1.2
diff -p -r1.2 Makefile.in
*** Makefile.in	2001/12/13 23:49:59	1.2
--- Makefile.in	2002/03/08 17:58:14
*************** INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLA
*** 84,90 ****
  
  noinst_LIBRARIES = lib.a
  
! lib_a_SOURCES = syscalls.c libcfunc.c trap.S setjmp.S
  
  ACLOCAL_AMFLAGS = -I ../../..
  CONFIG_STATUS_DEPENDENCIES = $(newlib_basedir)/configure.host
--- 84,90 ----
  
  noinst_LIBRARIES = lib.a
  
! lib_a_SOURCES = access.c syscalls.c libcfunc.c trap.S setjmp.S
  
  ACLOCAL_AMFLAGS = -I ../../..
  CONFIG_STATUS_DEPENDENCIES = $(newlib_basedir)/configure.host
*************** DEFS = @DEFS@ -I. -I$(srcdir) 
*** 98,104 ****
  CPPFLAGS = @CPPFLAGS@
  LIBS = @LIBS@
  lib_a_LIBADD = 
! lib_a_OBJECTS =  syscalls.o libcfunc.o trap.o setjmp.o
  CFLAGS = @CFLAGS@
  COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
  CCLD = $(CC)
--- 98,104 ----
  CPPFLAGS = @CPPFLAGS@
  LIBS = @LIBS@
  lib_a_LIBADD = 
! lib_a_OBJECTS =  access.o syscalls.o libcfunc.o trap.o setjmp.o
  CFLAGS = @CFLAGS@
  COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
  CCLD = $(CC)
Index: libc/sys/arm/syscalls.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/sys/arm/syscalls.c,v
retrieving revision 1.4
diff -p -r1.4 syscalls.c
*** syscalls.c	2002/01/17 16:39:53	1.4
--- syscalls.c	2002/03/08 17:58:14
*************** int     _gettimeofday	_PARAMS ((struct t
*** 21,26 ****
--- 21,27 ----
  void    _raise 		_PARAMS ((void));
  int     _unlink		_PARAMS ((void));
  int     _link 		_PARAMS ((void));
+ int     _stat 		_PARAMS ((const char *, struct stat *));
  int     _fstat 		_PARAMS ((int, struct stat *));
  caddr_t _sbrk		_PARAMS ((int));
  int     _getpid		_PARAMS ((int));
*************** int
*** 509,518 ****
  _fstat (int file, struct stat * st)
  {
    memset (st, 0, sizeof (* st));
!   st->st_mode = S_IFCHR;
    st->st_blksize = 1024;
    return 0;
    file = file;
  }
  
  int
--- 510,533 ----
  _fstat (int file, struct stat * st)
  {
    memset (st, 0, sizeof (* st));
!   st->st_mode = S_IFREG | S_IREAD;
    st->st_blksize = 1024;
    return 0;
    file = file;
+ }
+ 
+ int _stat (const char *fname, struct stat *st)
+ {
+   int file;
+ 
+   /* The best we can do is try to open the file readonly.  If it exists,
+      then we can guess a few things about it.  */
+   if ((file = _open (fname, O_RDONLY)) < 0)
+     return -1;
+ 
+   _fstat (file, st);
+   _swiclose (file); /* Not interested in the error.  */
+   return 0;
  }
  
  int
Index: libc/sys/arm/access.c
*** /dev/null	Fri Mar  8 18:02:01 2002
--- libc/sys/arm/access.c	Thu Jan 18 17:42:23 2001
***************
*** 0 ****
--- 1,34 ----
+ /* This is file ACCESS.C */
+ /*
+ ** Copyright (C) 1993 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954
+ **
+ ** This file is distributed under the terms listed in the document
+ ** "copying.dj", available from DJ Delorie at the address above.
+ ** A copy of "copying.dj" should accompany this file; if not, a copy
+ ** should be available from where this file was obtained.  This file
+ ** may not be distributed without a verbatim copy of "copying.dj".
+ **
+ ** This file is distributed WITHOUT ANY WARRANTY; without even the implied
+ ** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ */
+ 
+ #include <fcntl.h>
+ #include <sys/stat.h>
+ #include <unistd.h>
+ 
+ int access(const char *fn, int flags)
+ {
+   struct stat s;
+   if (stat(fn, &s))
+     return -1;
+   if (s.st_mode & S_IFDIR)
+     return 0;
+   if (flags & W_OK)
+   {
+     if (s.st_mode & S_IWRITE)
+       return 0;
+     return -1;
+   }
+   return 0;
+ }
+ 	

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]