[Pvfs2-cvs] commit by pcarns in pvfs2-1/src/common/misc: pint-mem.c module.mk.in pint-mem.h

CVS commit program cvs at parl.clemson.edu
Wed Dec 10 09:50:37 EST 2008


Update of /projects/cvsroot/pvfs2-1/src/common/misc
In directory parlweb1:/tmp/cvs-serv20563/src/common/misc

Modified Files:
	module.mk.in pint-mem.h 
Added Files:
	pint-mem.c 
Log Message:
Move mem alignment functions into a separate .c file so that _XOPEN_SOURCE
isn't set in header file.  On some systems features.h will have already
been processed before reaching pint-mem.h and won't export posix_memalign()
properly.


--- /dev/null	2004-06-24 14:04:38.000000000 -0400
+++ pint-mem.c	2008-12-10 09:50:37.000000000 -0500
@@ -0,0 +1,58 @@
+/* 
+ * (C) 2001 Clemson University and The University of Chicago 
+ *
+ * See COPYING in top-level directory.
+ */
+
+#define _XOPEN_SOURCE 600
+#include <errno.h>
+#include <stdlib.h>
+#ifdef HAVE_MALLOC_H
+#include <malloc.h>
+#endif
+
+/* PINT_mem_aligned_alloc()
+ *
+ * allocates a memory region of the specified size and returns a 
+ * pointer to the region.  The address of the memory will be evenly
+ * divisible by alignment.
+ *
+ * returns pointer to memory on success, NULL on failure
+ */
+inline void* PINT_mem_aligned_alloc(size_t size, size_t alignment)
+{
+    int ret;
+    void *ptr;
+
+    ret = posix_memalign(&ptr, alignment, size);
+    if(ret != 0)
+    {
+        errno = ret;
+        return NULL;
+    }
+    return ptr;
+}
+
+/* PINT_mem_aligned_free()
+ *
+ * frees memory region previously allocated with
+ * PINT_mem_aligned_alloc()
+ *
+ * no return value
+ */
+inline void PINT_mem_aligned_free(void *ptr)
+{
+    free(ptr);
+    return;
+}
+
+/*
+ * Local variables:
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ * End:
+ *
+ * vim: ts=8 sts=4 sw=4 expandtab
+ */
+
+

Index: module.mk.in
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/common/misc/module.mk.in,v
diff -p -u -r1.35 -r1.36
--- module.mk.in	20 Nov 2008 01:16:53 -0000	1.35
+++ module.mk.in	10 Dec 2008 14:50:37 -0000	1.36
@@ -20,7 +20,8 @@ LIBSRC += $(DIR)/server-config.c \
 	  $(DIR)/state-machine-fns.c \
 	  $(DIR)/fsck-utils.c \
 	  $(DIR)/pint-eattr.c \
-	  $(DIR)/pint-hint.c
+	  $(DIR)/pint-hint.c \
+	  $(DIR)/pint-mem.c
 SERVERSRC += $(DIR)/server-config.c \
              $(DIR)/server-config-mgr.c \
              $(DIR)/str-utils.c \
@@ -38,6 +39,7 @@ SERVERSRC += $(DIR)/server-config.c \
 	     $(DIR)/realpath.c \
 	     $(DIR)/msgpairarray.c \
 	     $(DIR)/pint-eattr.c \
+	     $(DIR)/pint-mem.c \
 	     $(DIR)/pint-hint.c
 
 LIBBMISRC += $(DIR)/str-utils.c \

Index: pint-mem.h
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/common/misc/pint-mem.h,v
diff -p -u -r1.3 -r1.4
--- pint-mem.h	11 Nov 2008 19:25:51 -0000	1.3
+++ pint-mem.h	10 Dec 2008 14:50:37 -0000	1.4
@@ -7,47 +7,9 @@
 #ifndef __PINT_MEM_H
 #define __PINT_MEM_H
 
-#define _XOPEN_SOURCE 600
+extern void* PINT_mem_aligned_alloc(size_t size, size_t alignment);
+extern void PINT_mem_aligned_free(void *ptr);
 
-#include <stdlib.h>
-#ifdef HAVE_MALLOC_H
-#include <malloc.h>
-#endif
-
-/* PINT_mem_aligned_alloc()
- *
- * allocates a memory region of the specified size and returns a 
- * pointer to the region.  The address of the memory will be evenly
- * divisible by alignment.
- *
- * returns pointer to memory on success, NULL on failure
- */
-static inline void* PINT_mem_aligned_alloc(size_t size, size_t alignment)
-{
-    int ret;
-    void *ptr;
-
-    ret = posix_memalign(&ptr, alignment, size);
-    if(ret != 0)
-    {
-        errno = ret;
-        return NULL;
-    }
-    return ptr;
-}
-
-/* PINT_mem_aligned_free()
- *
- * frees memory region previously allocated with
- * PINT_mem_aligned_alloc()
- *
- * no return value
- */
-static inline void PINT_mem_aligned_free(void *ptr)
-{
-    free(ptr);
-    return;
-}
 #endif /* __PINT_MEM_H */
 
 /*



More information about the Pvfs2-cvs mailing list