summaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
Diffstat (limited to 'templates')
-rw-r--r--templates/func_deps4
-rw-r--r--templates/guts16
-rw-r--r--templates/port_deps5
-rw-r--r--templates/port_wrappers5
-rw-r--r--templates/pseudo_ports6
-rw-r--r--templates/wrapfuncs.c95
-rw-r--r--templates/wrapfuncs.h12
-rw-r--r--templates/wrapper_table24
8 files changed, 167 insertions, 0 deletions
diff --git a/templates/func_deps b/templates/func_deps
new file mode 100644
index 0000000..ace0a2f
--- /dev/null
+++ b/templates/func_deps
@@ -0,0 +1,4 @@
+@name func_deps.mk
+${funcdeps}
+@header
+# Per-function extra dependencies
diff --git a/templates/guts b/templates/guts
new file mode 100644
index 0000000..e2c9880
--- /dev/null
+++ b/templates/guts
@@ -0,0 +1,16 @@
+@name ports/${port}/guts/${name}.c
+@header
+@body
+/*
+ * Copyright (c) ${date} Wind River Systems; see
+ * guts/COPYRIGHT for information.
+ *
+ * ${comment}
+ * ${rc_decl}
+ */
+
+ ${rc_assign} real_${name}(${call_args});
+
+/* ${rc_return}
+ * }
+ */
diff --git a/templates/port_deps b/templates/port_deps
new file mode 100644
index 0000000..8f53db7
--- /dev/null
+++ b/templates/port_deps
@@ -0,0 +1,5 @@
+@name port_deps.mk
+@port
+${portdeps}
+@header
+# port dependencies
diff --git a/templates/port_wrappers b/templates/port_wrappers
new file mode 100644
index 0000000..7ff7ff8
--- /dev/null
+++ b/templates/port_wrappers
@@ -0,0 +1,5 @@
+@name port_wrappers.c
+@header
+/* additional hand-written wrappers for ports which provide them */
+@port
+${include}
diff --git a/templates/pseudo_ports b/templates/pseudo_ports
new file mode 100644
index 0000000..113a2b6
--- /dev/null
+++ b/templates/pseudo_ports
@@ -0,0 +1,6 @@
+@name pseudo_ports.h
+@header
+/* #defines for port-specific hackery */
+@port
+${define}
+${portdefs}
diff --git a/templates/wrapfuncs.c b/templates/wrapfuncs.c
new file mode 100644
index 0000000..3859183
--- /dev/null
+++ b/templates/wrapfuncs.c
@@ -0,0 +1,95 @@
+@name pseudo_wrapfuncs.c
+@header
+/* wrapper functions. generated automatically. */
+
+/* IF YOU ARE SEEING COMPILER ERRORS IN THIS FILE:
+ * If you are seeing a whole lot of errors, make sure you aren't actually
+ * trying to compile pseudo_wrapfuncs.c directly. This file is #included
+ * from pseudo_wrappers.c, which has a lot of needed include files and
+ * static declarations.
+ */
+
+/* This file is generated and should not be modified. See the makewrappers
+ * script if you want to modify this. */
+@body
+
+static ${type} (*real_${name})(${decl_args}) = ${real_init};
+
+${maybe_skip}
+
+${type}
+${name}(${decl_args}) {
+ sigset_t saved;
+ ${variadic_decl}
+ ${rc_decl}
+ PROFILE_START;
+
+${maybe_async_skip}
+
+ if (!pseudo_check_wrappers() || !real_$name) {
+ /* rc was initialized to the "failure" value */
+ pseudo_enosys("${name}");
+ PROFILE_DONE;
+ ${rc_return}
+ }
+
+ ${variadic_start}
+
+ if (pseudo_disabled) {
+ ${rc_assign} (*real_${name})(${call_args});
+ ${variadic_end}
+ PROFILE_DONE;
+ ${rc_return}
+ }
+
+ pseudo_debug(PDBGF_WRAPPER, "wrapper called: ${name}\n");
+ pseudo_sigblock(&saved);
+ pseudo_debug(PDBGF_WRAPPER | PDBGF_VERBOSE, "${name} - signals blocked, obtaining lock\n");
+ if (pseudo_getlock()) {
+ errno = EBUSY;
+ sigprocmask(SIG_SETMASK, &saved, NULL);
+ pseudo_debug(PDBGF_WRAPPER, "${name} failed to get lock, giving EBUSY.\n");
+ PROFILE_DONE;
+ ${def_return}
+ }
+
+ int save_errno;
+ if (antimagic > 0) {
+ /* call the real syscall */
+ pseudo_debug(PDBGF_SYSCALL, "${name} calling real syscall.\n");
+ ${rc_assign} (*real_${name})(${call_args});
+ } else {
+ ${fix_paths}
+ /* exec*() use this to restore the sig mask */
+ pseudo_saved_sigmask = saved;
+ ${rc_assign} wrap_$name(${call_args});
+ }
+ ${variadic_end}
+ save_errno = errno;
+ pseudo_droplock();
+ sigprocmask(SIG_SETMASK, &saved, NULL);
+ pseudo_debug(PDBGF_WRAPPER | PDBGF_VERBOSE, "${name} - yielded lock, restored signals\n");
+#if 0
+/* This can cause hangs on some recentish systems which use locale
+ * stuff for strerror...
+ */
+ pseudo_debug(PDBGF_WRAPPER, "wrapper completed: ${name} returns ${rc_format} (errno: %s)\n", ${rc_value}, strerror(save_errno));
+#endif
+ pseudo_debug(PDBGF_WRAPPER, "wrapper completed: ${name} returns ${rc_format} (errno: %d)\n", ${rc_value}, save_errno);
+ errno = save_errno;
+ PROFILE_DONE;
+ ${rc_return}
+}
+
+static ${type}
+wrap_${name}(${wrap_args}) {
+ $rc_decl
+ ${maybe_variadic_decl}
+ ${maybe_variadic_start}
+
+#include "ports/${port}/guts/${name}.c"
+
+ ${rc_return}
+}
+
+${end_maybe_skip}
diff --git a/templates/wrapfuncs.h b/templates/wrapfuncs.h
new file mode 100644
index 0000000..1ce4fcc
--- /dev/null
+++ b/templates/wrapfuncs.h
@@ -0,0 +1,12 @@
+@name pseudo_wrapfuncs.h
+@header
+/* wrapper functions. generated automatically. */
+
+/* This file is generated and should not be modified. See the makewrappers
+ * script if you want to modify this. */
+@body
+/* ${comment} */
+static ${type} wrap_${name}(${wrap_args});
+static ${type} (*real_${name})(${decl_args});
+${real_predecl}
+@footer
diff --git a/templates/wrapper_table b/templates/wrapper_table
new file mode 100644
index 0000000..bb30530
--- /dev/null
+++ b/templates/wrapper_table
@@ -0,0 +1,24 @@
+@name pseudo_wrapper_table.c
+@header
+/* The table of wrapper functions to populate */
+
+/* This file is generated and should not be modified. See the makewrappers
+ * script if you want to modify this. */
+typedef struct {
+ char *name; /* the name */
+ int (**real)(void); /* the underlying syscall */
+ int (*wrapper)(void); /* the wrapper from guts/name.c */
+ char *version; /* the version, if we know and care */
+} pseudo_function;
+
+static pseudo_function pseudo_functions[] = {
+@body
+ { /* ${comment}; */
+ "${name}${maybe_inode64}",
+ (int (**)(void)) &real_${name},
+ (int (*)(void)) wrap_${name},
+ ${version}
+ },
+@footer
+ { NULL, NULL, NULL, NULL },
+};