public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: Sebastian Huber <sebastian.huber@embedded-brains.de>
To: newlib@sourceware.org
Subject: [PATCH 4/8] Move ARM access.c from machine to sys
Date: Mon, 22 May 2017 12:04:00 -0000	[thread overview]
Message-ID: <1495454672-9131-4-git-send-email-sebastian.huber@embedded-brains.de> (raw)
In-Reply-To: <1495454672-9131-1-git-send-email-sebastian.huber@embedded-brains.de>

The implementation of the POSIX access() function is nothing machine
specific like memcpy(), etc.  Move it back to the system domain.  This
avoids problems due to the include search order of the Newlib/GCC build
which picks up machine includes before system includes.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
---
 newlib/libc/machine/arm/Makefile.am |  2 +-
 newlib/libc/machine/arm/Makefile.in | 13 +++----------
 newlib/libc/machine/arm/access.c    | 33 ---------------------------------
 newlib/libc/sys/arm/Makefile.am     |  2 +-
 newlib/libc/sys/arm/Makefile.in     | 10 ++++++++--
 newlib/libc/sys/arm/access.c        | 33 +++++++++++++++++++++++++++++++++
 6 files changed, 46 insertions(+), 47 deletions(-)
 delete mode 100644 newlib/libc/machine/arm/access.c
 create mode 100644 newlib/libc/sys/arm/access.c

diff --git a/newlib/libc/machine/arm/Makefile.am b/newlib/libc/machine/arm/Makefile.am
index 6b67050..9bd35e7 100644
--- a/newlib/libc/machine/arm/Makefile.am
+++ b/newlib/libc/machine/arm/Makefile.am
@@ -8,7 +8,7 @@ AM_CCASFLAGS = $(INCLUDES)
 
 noinst_LIBRARIES = lib.a
 
-lib_a_SOURCES = setjmp.S access.c strcmp.S strcpy.c \
+lib_a_SOURCES = setjmp.S strcmp.S strcpy.c \
 		aeabi_memcpy.c aeabi_memcpy-armv7a.S \
 		aeabi_memmove.c aeabi_memmove-soft.S \
 		aeabi_memset.c aeabi_memset-soft.S aeabi_memclr.c
diff --git a/newlib/libc/machine/arm/Makefile.in b/newlib/libc/machine/arm/Makefile.in
index a0e4cc2..d9dbcd5 100644
--- a/newlib/libc/machine/arm/Makefile.in
+++ b/newlib/libc/machine/arm/Makefile.in
@@ -69,9 +69,8 @@ LIBRARIES = $(noinst_LIBRARIES)
 ARFLAGS = cru
 lib_a_AR = $(AR) $(ARFLAGS)
 lib_a_LIBADD =
-am_lib_a_OBJECTS = lib_a-setjmp.$(OBJEXT) lib_a-access.$(OBJEXT) \
-	lib_a-strcmp.$(OBJEXT) lib_a-strcpy.$(OBJEXT) \
-	lib_a-aeabi_memcpy.$(OBJEXT) \
+am_lib_a_OBJECTS = lib_a-setjmp.$(OBJEXT) lib_a-strcmp.$(OBJEXT) \
+	lib_a-strcpy.$(OBJEXT) lib_a-aeabi_memcpy.$(OBJEXT) \
 	lib_a-aeabi_memcpy-armv7a.$(OBJEXT) \
 	lib_a-aeabi_memmove.$(OBJEXT) \
 	lib_a-aeabi_memmove-soft.$(OBJEXT) \
@@ -206,7 +205,7 @@ AUTOMAKE_OPTIONS = cygnus
 INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
 AM_CCASFLAGS = $(INCLUDES)
 noinst_LIBRARIES = lib.a
-lib_a_SOURCES = setjmp.S access.c strcmp.S strcpy.c aeabi_memcpy.c \
+lib_a_SOURCES = setjmp.S strcmp.S strcpy.c aeabi_memcpy.c \
 	aeabi_memcpy-armv7a.S aeabi_memmove.c aeabi_memmove-soft.S \
 	aeabi_memset.c aeabi_memset-soft.S aeabi_memclr.c \
 	memchr-stub.c memchr.S memcpy-stub.c memcpy.S strlen-stub.c \
@@ -338,12 +337,6 @@ lib_a-strlen.obj: strlen.S
 .c.obj:
 	$(COMPILE) -c `$(CYGPATH_W) '$<'`
 
-lib_a-access.o: access.c
-	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-access.o `test -f 'access.c' || echo '$(srcdir)/'`access.c
-
-lib_a-access.obj: access.c
-	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-access.obj `if test -f 'access.c'; then $(CYGPATH_W) 'access.c'; else $(CYGPATH_W) '$(srcdir)/access.c'; fi`
-
 lib_a-strcpy.o: strcpy.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strcpy.o `test -f 'strcpy.c' || echo '$(srcdir)/'`strcpy.c
 
diff --git a/newlib/libc/machine/arm/access.c b/newlib/libc/machine/arm/access.c
deleted file mode 100644
index 980682e..0000000
--- a/newlib/libc/machine/arm/access.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/* This is file ACCESS.C */
-/*
- * Copyright (C) 1993 DJ Delorie
- * All rights reserved.
- *
- * Redistribution, modification, 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/Makefile.am b/newlib/libc/sys/arm/Makefile.am
index 3d8aa9d..711872d 100644
--- a/newlib/libc/sys/arm/Makefile.am
+++ b/newlib/libc/sys/arm/Makefile.am
@@ -14,7 +14,7 @@ else
 extra_objs =
 endif
 
-lib_a_SOURCES = aeabi_atexit.c
+lib_a_SOURCES = access.c aeabi_atexit.c
 lib_a_LIBADD = $(extra_objs)
 EXTRA_lib_a_SOURCES = trap.S syscalls.c libcfunc.c
 lib_a_DEPENDENCIES = $(extra_objs)
diff --git a/newlib/libc/sys/arm/Makefile.in b/newlib/libc/sys/arm/Makefile.in
index ba0f92b..c01e4e2 100644
--- a/newlib/libc/sys/arm/Makefile.in
+++ b/newlib/libc/sys/arm/Makefile.in
@@ -70,7 +70,7 @@ ARFLAGS = cru
 lib_a_AR = $(AR) $(ARFLAGS)
 @MAY_SUPPLY_SYSCALLS_TRUE@am__DEPENDENCIES_1 = $(lpfx)libcfunc.o \
 @MAY_SUPPLY_SYSCALLS_TRUE@	$(lpfx)trap.o $(lpfx)syscalls.o
-am_lib_a_OBJECTS = lib_a-aeabi_atexit.$(OBJEXT)
+am_lib_a_OBJECTS = lib_a-access.$(OBJEXT) lib_a-aeabi_atexit.$(OBJEXT)
 lib_a_OBJECTS = $(am_lib_a_OBJECTS)
 DEFAULT_INCLUDES = -I.@am__isrc@
 depcomp =
@@ -198,7 +198,7 @@ AM_CCASFLAGS = $(INCLUDES)
 noinst_LIBRARIES = lib.a
 @MAY_SUPPLY_SYSCALLS_FALSE@extra_objs = 
 @MAY_SUPPLY_SYSCALLS_TRUE@extra_objs = $(lpfx)libcfunc.o $(lpfx)trap.o $(lpfx)syscalls.o
-lib_a_SOURCES = aeabi_atexit.c
+lib_a_SOURCES = access.c aeabi_atexit.c
 lib_a_LIBADD = $(extra_objs)
 EXTRA_lib_a_SOURCES = trap.S syscalls.c libcfunc.c
 lib_a_DEPENDENCIES = $(extra_objs)
@@ -276,6 +276,12 @@ lib_a-trap.obj: trap.S
 .c.obj:
 	$(COMPILE) -c `$(CYGPATH_W) '$<'`
 
+lib_a-access.o: access.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-access.o `test -f 'access.c' || echo '$(srcdir)/'`access.c
+
+lib_a-access.obj: access.c
+	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-access.obj `if test -f 'access.c'; then $(CYGPATH_W) 'access.c'; else $(CYGPATH_W) '$(srcdir)/access.c'; fi`
+
 lib_a-aeabi_atexit.o: aeabi_atexit.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-aeabi_atexit.o `test -f 'aeabi_atexit.c' || echo '$(srcdir)/'`aeabi_atexit.c
 
diff --git a/newlib/libc/sys/arm/access.c b/newlib/libc/sys/arm/access.c
new file mode 100644
index 0000000..980682e
--- /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, modification, 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;
+}
+	
-- 
1.8.4.5

  parent reply	other threads:[~2017-05-22 12:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-22 12:04 [PATCH 1/8] Add generic <machine/_align.h> for RTEMS Sebastian Huber
2017-05-22 12:04 ` [PATCH 8/8] Add de-facto standard <sys/ioctl.h> " Sebastian Huber
2017-05-22 12:04 ` [PATCH 5/8] Add __bitcount*() to RTEMS <machine/types.h> Sebastian Huber
2017-05-22 12:04 ` Sebastian Huber [this message]
2017-05-22 12:04 ` [PATCH 2/8] FreeBSD compatibility for RTEMS <sys/param.h> Sebastian Huber
2017-05-22 12:04 ` [PATCH 3/8] Increase MSIZE for RTEMS Sebastian Huber
2017-05-22 12:04 ` [PATCH 6/8] FreeBSD compatibility for RTEMS <sys/cpuset.h> Sebastian Huber
2017-05-22 12:09 ` [PATCH 1/8] Add generic <machine/_align.h> for RTEMS Sebastian Huber

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1495454672-9131-4-git-send-email-sebastian.huber@embedded-brains.de \
    --to=sebastian.huber@embedded-brains.de \
    --cc=newlib@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).