chiark / gitweb /
sema: New program for hacking with semaphores.
[misc] / fence.h
diff --git a/fence.h b/fence.h
new file mode 100644 (file)
index 0000000..a78b9f7
--- /dev/null
+++ b/fence.h
@@ -0,0 +1,59 @@
+/* -*-c-*-
+ *
+ * Bodge to control memory access ordering
+ *
+ * (c) 2016 Mark Wooding
+ */
+
+/*----- Licensing notice --------------------------------------------------*
+ *
+ * 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 2 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, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef FENCE_H
+#define FENCE_H
+
+#ifdef __cplusplus
+  extern "C" {
+#endif
+
+/*----- Header files ------------------------------------------------------*/
+
+#include <mLib/macros.h>
+
+/*----- Functions provided ------------------------------------------------*/
+
+/* --- @compiler_fence@ --- *
+ *
+ * Arguments:  some pointers to things
+ *
+ * Returns:    Nothing.
+ *
+ * Use:                Actually doesn't do anything at all, but in a separate
+ *             translation unit so that the compiler can't tell that.  So it
+ *             won't be able to move memory accesses to the addressed
+ *             objects across the call.
+ */
+
+#define FENCE_END ((void *)0)
+EXECL_LIKE(0) void compiler_fence(void */*p*/, ...);
+
+/*----- That's all, folks -------------------------------------------------*/
+
+#ifdef __cplusplus
+  }
+#endif
+
+#endif