* [PATCH 1/2] sim: unify sim-load.o building
@ 2021-06-13 3:39 Mike Frysinger
2021-06-13 3:39 ` [PATCH 2/2 v3] sim: start unifying portability shims Mike Frysinger
0 siblings, 1 reply; 2+ messages in thread
From: Mike Frysinger @ 2021-06-13 3:39 UTC (permalink / raw)
To: gdb-patches
Since this file does not rely on any port-specific settings, move it
up to building as part of the common step so we only do it once in a
multibuild.
---
sim/Makefile.in | 50 ++++++++++++++++++++++++++++++++++++---
sim/common/Make-common.in | 6 +++--
sim/common/defs.h | 4 ++++
sim/common/local.mk | 6 +++++
4 files changed, 61 insertions(+), 5 deletions(-)
diff --git a/sim/common/Make-common.in b/sim/common/Make-common.in
index 999b1eea00a9..8454d165830f 100644
--- a/sim/common/Make-common.in
+++ b/sim/common/Make-common.in
@@ -179,7 +179,6 @@ SIM_NEW_COMMON_OBJS = \
sim-hrw.o \
sim-io.o \
sim-info.o \
- sim-load.o \
sim-memopt.o \
sim-model.o \
sim-module.o \
@@ -254,7 +253,10 @@ LIBDEPS = $(BFD_LIB) $(OPCODES_LIB) $(LIBINTL_DEP) $(LIBIBERTY_LIB)
EXTRA_LIBS = $(BFD_LIB) $(OPCODES_LIB) $(LIBINTL) $(LIBIBERTY_LIB) \
$(CONFIG_LIBS) $(SIM_EXTRA_LIBS) $(LIBDL) $(LIBGNU) $(LIBGNU_EXTRA_LIBS)
-COMMON_OBJS = ../common/version.o
+COMMON_OBJS_NAMES = \
+ sim-load.o \
+ version.o
+COMMON_OBJS = $(COMMON_OBJS_NAMES:%=../common/common_libcommon_a-%)
LIB_OBJS = callback.o modules.o syscall.o targ-map.o $(COMMON_OBJS) $(SIM_OBJS)
diff --git a/sim/common/defs.h b/sim/common/defs.h
index 4b5da7bfa369..21ad2a44d3ba 100644
--- a/sim/common/defs.h
+++ b/sim/common/defs.h
@@ -37,6 +37,8 @@
/* Include arch-specific sim's various configure tests. */
#include "config.h"
+#ifndef SIM_COMMON_BUILD
+
/* Reset macros that our config.h will provide. */
#undef PACKAGE
#undef PACKAGE_BUGREPORT
@@ -52,3 +54,5 @@
#endif
#endif
+
+#endif
diff --git a/sim/common/local.mk b/sim/common/local.mk
index 357be755578f..a340febfcdd1 100644
--- a/sim/common/local.mk
+++ b/sim/common/local.mk
@@ -28,7 +28,13 @@ SIM_ALL_RECURSIVE_DEPS += \
# NB: libcommon.a isn't used directly by ports. We need a target for common
# objects to be a part of, and ports use the individual objects directly.
noinst_LIBRARIES += %D%/libcommon.a
+%C%_libcommon_a_CPPFLAGS = \
+ $(AM_CPPFLAGS) \
+ -DSIM_COMMON_BUILD \
+ -I../bfd \
+ -I..
%C%_libcommon_a_SOURCES = \
+ %D%/sim-load.c \
%D%/version.c
%D%/version.c: $(srcroot)/gdb/version.in $(srcroot)/bfd/version.h $(srcdir)/%D%/create-version.sh
--
2.31.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 2/2 v3] sim: start unifying portability shims
2021-06-13 3:39 [PATCH 1/2] sim: unify sim-load.o building Mike Frysinger
@ 2021-06-13 3:39 ` Mike Frysinger
0 siblings, 0 replies; 2+ messages in thread
From: Mike Frysinger @ 2021-06-13 3:39 UTC (permalink / raw)
To: gdb-patches
There are some functions that gnulib does not yet provide fallbacks
for, so start a common file of our own for holding existing stubs.
---
sim/Makefile.in | 19 +++++++++++
sim/bfin/interp.c | 20 +-----------
sim/common/Make-common.in | 1 +
sim/common/local.mk | 1 +
sim/common/portability.c | 67 +++++++++++++++++++++++++++++++++++++++
sim/common/portability.h | 47 +++++++++++++++++++++++++++
sim/cris/traps.c | 1 +
sim/m32r/traps-linux.c | 1 +
8 files changed, 138 insertions(+), 19 deletions(-)
create mode 100644 sim/common/portability.c
create mode 100644 sim/common/portability.h
diff --git a/sim/bfin/interp.c b/sim/bfin/interp.c
index 2e9696f8bfe1..10de001d7ce7 100644
--- a/sim/bfin/interp.c
+++ b/sim/bfin/interp.c
@@ -30,6 +30,7 @@
#include <unistd.h>
#include <sys/time.h>
+#include "portability.h"
#include "sim/callback.h"
#include "gdb/signals.h"
#include "sim-main.h"
@@ -74,25 +75,6 @@
#include "dv-bfin_cec.h"
#include "dv-bfin_mmu.h"
-#ifndef HAVE_GETUID
-# define getuid() 0
-#endif
-#ifndef HAVE_GETGID
-# define getgid() 0
-#endif
-#ifndef HAVE_GETEUID
-# define geteuid() 0
-#endif
-#ifndef HAVE_GETEGID
-# define getegid() 0
-#endif
-#ifndef HAVE_SETUID
-# define setuid(uid) -1
-#endif
-#ifndef HAVE_SETGID
-# define setgid(gid) -1
-#endif
-
static const char cb_linux_stat_map_32[] =
/* Linux kernel 32bit layout: */
"st_dev,2:space,2:st_ino,4:st_mode,2:st_nlink,2:st_uid,2:st_gid,2:st_rdev,2:"
diff --git a/sim/common/Make-common.in b/sim/common/Make-common.in
index 8454d165830f..7a5bbc1a985c 100644
--- a/sim/common/Make-common.in
+++ b/sim/common/Make-common.in
@@ -254,6 +254,7 @@ EXTRA_LIBS = $(BFD_LIB) $(OPCODES_LIB) $(LIBINTL) $(LIBIBERTY_LIB) \
$(CONFIG_LIBS) $(SIM_EXTRA_LIBS) $(LIBDL) $(LIBGNU) $(LIBGNU_EXTRA_LIBS)
COMMON_OBJS_NAMES = \
+ portability.o \
sim-load.o \
version.o
COMMON_OBJS = $(COMMON_OBJS_NAMES:%=../common/common_libcommon_a-%)
diff --git a/sim/common/local.mk b/sim/common/local.mk
index a340febfcdd1..076335d0b427 100644
--- a/sim/common/local.mk
+++ b/sim/common/local.mk
@@ -34,6 +34,7 @@ noinst_LIBRARIES += %D%/libcommon.a
-I../bfd \
-I..
%C%_libcommon_a_SOURCES = \
+ %D%/portability.c \
%D%/sim-load.c \
%D%/version.c
diff --git a/sim/common/portability.c b/sim/common/portability.c
new file mode 100644
index 000000000000..f0ccc46d37eb
--- /dev/null
+++ b/sim/common/portability.c
@@ -0,0 +1,67 @@
+/* Portability shims for missing OS support.
+ Copyright (C) 2021 Free Software Foundation, Inc.
+ Contributed by Mike Frysinger.
+
+This file is part of the GNU Simulators.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* This must come before any other includes. */
+#include "defs.h"
+
+#include <unistd.h>
+
+#include "portability.h"
+
+#ifndef HAVE_GETEGID
+int getegid(void)
+{
+ return 0;
+}
+#endif
+
+#ifndef HAVE_GETEUID
+int geteuid(void)
+{
+ return 0;
+}
+#endif
+
+#ifndef HAVE_GETGID
+int getgid(void)
+{
+ return 0;
+}
+#endif
+
+#ifndef HAVE_GETUID
+int getuid(void)
+{
+ return 0;
+}
+#endif
+
+#ifndef HAVE_SETGID
+int setgid(int gid)
+{
+ return -1;
+}
+#endif
+
+#ifndef HAVE_SETUID
+int setuid(int uid)
+{
+ return -1;
+}
+#endif
diff --git a/sim/common/portability.h b/sim/common/portability.h
new file mode 100644
index 000000000000..12971f6a1075
--- /dev/null
+++ b/sim/common/portability.h
@@ -0,0 +1,47 @@
+/* Portability shims for missing OS support.
+ Copyright (C) 2021 Free Software Foundation, Inc.
+ Contributed by Mike Frysinger.
+
+This file is part of the GNU Simulators.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef PORTABILITY_H
+#define PORTABILITY_H
+
+#ifndef HAVE_GETEGID
+int getegid(void);
+#endif
+
+#ifndef HAVE_GETEUID
+int geteuid(void);
+#endif
+
+#ifndef HAVE_GETGID
+int getgid(void);
+#endif
+
+#ifndef HAVE_GETUID
+int getuid(void);
+#endif
+
+#ifndef HAVE_SETGID
+int setgid(int gid);
+#endif
+
+#ifndef HAVE_SETUID
+int setuid(int uid);
+#endif
+
+#endif
diff --git a/sim/cris/traps.c b/sim/cris/traps.c
index 99344a283df9..a55f7dfb9927 100644
--- a/sim/cris/traps.c
+++ b/sim/cris/traps.c
@@ -20,6 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* This must come before any other includes. */
#include "defs.h"
+#include "portability.h"
#include "sim-main.h"
#include "sim-syscall.h"
#include "sim-options.h"
diff --git a/sim/m32r/traps-linux.c b/sim/m32r/traps-linux.c
index 63ed13788a51..1e3a08497e90 100644
--- a/sim/m32r/traps-linux.c
+++ b/sim/m32r/traps-linux.c
@@ -20,6 +20,7 @@
/* This must come before any other includes. */
#include "defs.h"
+#include "portability.h"
#include "sim-main.h"
#include "sim-syscall.h"
#include "syscall.h"
--
2.31.1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-06-13 3:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-13 3:39 [PATCH 1/2] sim: unify sim-load.o building Mike Frysinger
2021-06-13 3:39 ` [PATCH 2/2 v3] sim: start unifying portability shims Mike Frysinger
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).