sim,base: make checkpointMapIn warn if an unknown key is found
[gem5.git] / src / base / atomicio.hh
index 5e703f315e7f8835c2938b42ce10d8a9de81b924..572ca18022687aac12b77bb0078a6e3fb1d43fdb 100644 (file)
@@ -24,8 +24,6 @@
  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * Authors: Nathan Binkert
  */
 
 #ifndef __BASE_ATOMICIO_HH__
 ssize_t atomic_read(int fd, void *s, size_t n);
 ssize_t atomic_write(int fd, const void *s, size_t n);
 
+/**
+ * Statically allocate a string and write it to a file descriptor.
+ *
+ * @warning The return value will from atomic_write will be ignored
+ * which means that errors will be ignored. This is normally fine as
+ * this macro is intended to be used in fatal signal handlers where
+ * error handling might not be feasible.
+ */
+#define STATIC_MSG(fd, m)                                       \
+    do {                                                        \
+        static const char msg[] = m;                            \
+        atomic_write(fd, msg, sizeof(msg) - 1);                 \
+    } while (0)
+
+/**
+ * Statically allocate a string and write it to STDERR.
+ *
+ * @warning The return value will from atomic_write will be ignored
+ * which means that errors will be ignored. This is normally fine as
+ * this macro is intended to be used in fatal signal handlers where
+ * error handling might not be feasible.
+ */
+#define STATIC_ERR(m) STATIC_MSG(STDERR_FILENO, m)
+
 #endif // __BASE_ATOMICIO_HH__