ctf: compile plugin as C++
[babeltrace.git] / src / common / mmap-align.h
index c42cdeb34da234b02490db1f0cf25c6fe877893f..7c16493530eef9043d82ac1744141b7eba0ad085 100644 (file)
@@ -1,28 +1,12 @@
-#ifndef _BABELTRACE_MMAP_ALIGN_H
-#define _BABELTRACE_MMAP_ALIGN_H
-
 /*
- * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
+ * SPDX-License-Identifier: MIT
  *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
+ * Copyright 2010 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  */
 
+#ifndef _BABELTRACE_MMAP_ALIGN_H
+#define _BABELTRACE_MMAP_ALIGN_H
+
 #include "common/align.h"
 #include <stdlib.h>
 #include <stdint.h>
@@ -38,7 +22,7 @@
  * cannot be forced, so we allocate at an address chosen by the OS.
  */
 
-struct mmap_align {
+struct mmap_align_data {
        void *page_aligned_addr;        /* mmap address, aligned to floor */
        size_t page_aligned_length;     /* mmap length, containing range */
 
@@ -49,22 +33,22 @@ struct mmap_align {
 static inline
 off_t get_page_aligned_offset(off_t offset, int log_level)
 {
-       return ALIGN_FLOOR(offset, bt_mmap_get_offset_align_size(log_level));
+       return BT_ALIGN_FLOOR(offset, bt_mmap_get_offset_align_size(log_level));
 }
 
 static inline
-struct mmap_align *mmap_align(size_t length, int prot,
+struct mmap_align_data *mmap_align(size_t length, int prot,
                int flags, int fd, off_t offset, int log_level)
 {
-       struct mmap_align *mma;
+       struct mmap_align_data *mma;
        off_t page_aligned_offset;      /* mmap offset, aligned to floor */
        size_t page_size;
 
        page_size = bt_common_get_page_size(log_level);
 
-       mma = malloc(sizeof(*mma));
+       mma = (struct mmap_align_data *) malloc(sizeof(*mma));
        if (!mma)
-               return MAP_FAILED;
+               return (struct mmap_align_data *) MAP_FAILED;
        mma->length = length;
        page_aligned_offset = get_page_aligned_offset(offset, log_level);
        /*
@@ -73,19 +57,19 @@ struct mmap_align *mmap_align(size_t length, int prot,
         * require a 2 pages page_aligned_length if the range crosses a page
         * boundary.
         */
-       mma->page_aligned_length = ALIGN(length + offset - page_aligned_offset, page_size);
+       mma->page_aligned_length = BT_ALIGN(length + offset - page_aligned_offset, page_size);
        mma->page_aligned_addr = bt_mmap(NULL, mma->page_aligned_length,
                prot, flags, fd, page_aligned_offset, log_level);
        if (mma->page_aligned_addr == MAP_FAILED) {
                free(mma);
-               return MAP_FAILED;
+               return (struct mmap_align_data *) MAP_FAILED;
        }
        mma->addr = ((uint8_t *) mma->page_aligned_addr) + (offset - page_aligned_offset);
        return mma;
 }
 
 static inline
-int munmap_align(struct mmap_align *mma)
+int munmap_align(struct mmap_align_data *mma)
 {
        void *page_aligned_addr;
        size_t page_aligned_length;
@@ -97,7 +81,7 @@ int munmap_align(struct mmap_align *mma)
 }
 
 static inline
-void *mmap_align_addr(struct mmap_align *mma)
+void *mmap_align_addr(struct mmap_align_data *mma)
 {
        return mma->addr;
 }
@@ -106,7 +90,7 @@ void *mmap_align_addr(struct mmap_align *mma)
  * Helper for special-cases, normally unused.
  */
 static inline
-void mmap_align_set_addr(struct mmap_align *mma, void *addr)
+void mmap_align_set_addr(struct mmap_align_data *mma, void *addr)
 {
        mma->addr = addr;
 }
This page took 0.024732 seconds and 4 git commands to generate.