aboutsummaryrefslogtreecommitdiff
path: root/archive
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2018-06-16 03:47:09 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2018-06-16 03:47:09 +0000
commit11f6f1f439415e57696f473b1475f190018741c7 (patch)
tree257a3b14baae2b5f3860e04bdbfde2ca0f4715e2 /archive
parente05f7acda57fbbbad555df38fef89aa70447b590 (diff)
downloadsg3_utils-11f6f1f439415e57696f473b1475f190018741c7.tar.gz
rescan-scsi-bus.sh: add --ignore-rev; sg_persist: add RLR_C bit to Read capabilities; sg_pt_freebsd+win32: fix SNTL error crashes
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@778 6180dd3e-e324-4e3e-922d-17de1ae2f315
Diffstat (limited to 'archive')
-rw-r--r--archive/align_b4_memalign.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/archive/align_b4_memalign.c b/archive/align_b4_memalign.c
new file mode 100644
index 00000000..87602027
--- /dev/null
+++ b/archive/align_b4_memalign.c
@@ -0,0 +1,19 @@
+/* Code fragment of how to get a buffer of heap that has a specific
+ * alignment, typically 'page' size which is 4096 bytes. */
+
+ uint8_t * wrkBuff; /* will get pointer to heap allocation */
+ uint8_t * wrkPos; /* will get aligned pointer within wrkBuff */
+ uint32_t sz_of_aligned = 1234; /* number of aligned bytes required */
+
+ int psz;
+
+#if defined(HAVE_SYSCONF) && defined(_SC_PAGESIZE)
+ psz = sysconf(_SC_PAGESIZE); /* POSIX.1 (was getpagesize()) */
+#else
+ psz = 4096; /* give up, pick likely figure */
+#endif
+
+
+ /* perhaps use posix_memalign() instead. Yes but not always available */
+ wrkBuff = (uint8_t *)malloc(sz_of_aligned + psz);
+ wrkPos = (uint8_t *)(((sg_uintptr_t)wrkBuff + psz - 1) & (~(psz - 1)));