Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/newlib
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2002-03-13 00:25:12 +0300
committerJeff Johnston <jjohnstn@redhat.com>2002-03-13 00:25:12 +0300
commitd2a246ad722cc6df6005b8a1c42489bc839eb0d0 (patch)
tree72677c4e833faf495ae22638ad5855eff777fc14 /newlib
parentcb4589f49d8de32d27cd5c69274b4b8cd23d3351 (diff)
2002-03-12 Richard Earnshaw <rearnsha@arm.com>
* libc/sys/arm/access.c: New file. * libc/sys/arm/Makefile.am (lib_a_SOURCES): Add access.c. * libc/sys/arm/Makefile.in: Regenerate. * libc/sys/arm/syscalls.c (_stat): New function.
Diffstat (limited to 'newlib')
-rw-r--r--newlib/ChangeLog7
-rw-r--r--newlib/libc/sys/arm/Makefile.am2
-rw-r--r--newlib/libc/sys/arm/Makefile.in4
-rw-r--r--newlib/libc/sys/arm/access.c33
-rw-r--r--newlib/libc/sys/arm/syscalls.c17
5 files changed, 60 insertions, 3 deletions
diff --git a/newlib/ChangeLog b/newlib/ChangeLog
index f2cb305ad..1a83e4519 100644
--- a/newlib/ChangeLog
+++ b/newlib/ChangeLog
@@ -1,3 +1,10 @@
+2002-03-12 Richard Earnshaw <rearnsha@arm.com>
+
+ * libc/sys/arm/access.c: New file.
+ * libc/sys/arm/Makefile.am (lib_a_SOURCES): Add access.c.
+ * libc/sys/arm/Makefile.in: Regenerate.
+ * libc/sys/arm/syscalls.c (_stat): New function.
+
2002-03-11 Michael Meissner <meissner@redhat.com>
* libc/machine/mips/Makefile.am (lib_a_SOURCES): Add Mips specific
diff --git a/newlib/libc/sys/arm/Makefile.am b/newlib/libc/sys/arm/Makefile.am
index 1af0f8ddd..3d1a594aa 100644
--- a/newlib/libc/sys/arm/Makefile.am
+++ b/newlib/libc/sys/arm/Makefile.am
@@ -6,7 +6,7 @@ INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
noinst_LIBRARIES = lib.a
-lib_a_SOURCES = syscalls.c libcfunc.c trap.S setjmp.S
+lib_a_SOURCES = access.c syscalls.c libcfunc.c trap.S setjmp.S
all: crt0.o
diff --git a/newlib/libc/sys/arm/Makefile.in b/newlib/libc/sys/arm/Makefile.in
index 08c2ba9c2..087f5fbda 100644
--- a/newlib/libc/sys/arm/Makefile.in
+++ b/newlib/libc/sys/arm/Makefile.in
@@ -84,7 +84,7 @@ INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
noinst_LIBRARIES = lib.a
-lib_a_SOURCES = syscalls.c libcfunc.c trap.S setjmp.S
+lib_a_SOURCES = access.c syscalls.c libcfunc.c trap.S setjmp.S
ACLOCAL_AMFLAGS = -I ../../..
CONFIG_STATUS_DEPENDENCIES = $(newlib_basedir)/configure.host
@@ -98,7 +98,7 @@ DEFS = @DEFS@ -I. -I$(srcdir)
CPPFLAGS = @CPPFLAGS@
LIBS = @LIBS@
lib_a_LIBADD =
-lib_a_OBJECTS = syscalls.o libcfunc.o trap.o setjmp.o
+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)
diff --git a/newlib/libc/sys/arm/access.c b/newlib/libc/sys/arm/access.c
new file mode 100644
index 000000000..8e08b3a7f
--- /dev/null
+++ b/newlib/libc/sys/arm/access.c
@@ -0,0 +1,33 @@
+/* This is file ACCESS.C */
+/*
+ * Copyright (C) 1993 DJ Delorie
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms is permitted
+ * provided that the above copyright notice and following paragraph are
+ * duplicated in all such forms.
+ *
+ * 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;
+}
+
diff --git a/newlib/libc/sys/arm/syscalls.c b/newlib/libc/sys/arm/syscalls.c
index 0483d4893..3662a4687 100644
--- a/newlib/libc/sys/arm/syscalls.c
+++ b/newlib/libc/sys/arm/syscalls.c
@@ -21,6 +21,7 @@ int _gettimeofday _PARAMS ((struct timeval *, struct timezone *));
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));
@@ -515,6 +516,22 @@ _fstat (int file, struct stat * st)
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;
+
+ memset (st, 0, sizeof (* st));
+ st->st_mode = S_IFREG | S_IREAD;
+ st->st_blksize = 1024;
+ _swiclose (file); /* Not interested in the error. */
+ return 0;
+}
+
int
_link (void)
{