Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-22 10:47:27

0001 /*
0002  * Copyright (c) 2021-2023 Triad National Security, LLC. All rights reserved.
0003  * Copyright (c) 2022      Nanook Consulting.  All rights reserved.
0004  * $COPYRIGHT$
0005  *
0006  * Additional copyrights may follow
0007  *
0008  * $HEADER$
0009  */
0010 
0011 #ifndef PMIX_UTIL_SHMEM_H
0012 #define PMIX_UTIL_SHMEM_H
0013 
0014 #include "src/include/pmix_config.h"
0015 #include "include/pmix_common.h"
0016 #include "src/class/pmix_object.h"
0017 
0018 #include <sys/stat.h>
0019 
0020 /**
0021  * Bitmap container for pmix_shmem flags.
0022  */
0023 typedef uint8_t pmix_shmem_flags_t;
0024 
0025 typedef enum {
0026     /**
0027      * Indicates that during attach the requested address
0028      * must match the address returned by memory mapping.
0029      */
0030     PMIX_SHMEM_MUST_MAP_AT_RADDR = 0x01
0031 } pmix_shmem_flag_t;
0032 
0033 typedef struct pmix_shmem_t {
0034     /** Parent class. */
0035     pmix_object_t super;
0036     /** Flag indicating if attached to segment. */
0037     volatile bool attached;
0038     /** Size of shared-memory segment. */
0039     size_t size;
0040     /** Address of shared memory segment header. */
0041     void *hdr_address;
0042     /** Base data address of shared memory segment. */
0043     void *data_address;
0044     /** Buffer holding path to backing store. */
0045     char backing_path[PMIX_PATH_MAX];
0046 } pmix_shmem_t;
0047 PMIX_EXPORT PMIX_CLASS_DECLARATION(pmix_shmem_t);
0048 
0049 PMIX_EXPORT pmix_status_t
0050 pmix_shmem_segment_create(
0051     pmix_shmem_t *shmem,
0052     size_t size,
0053     const char *backing_path
0054 );
0055 
0056 PMIX_EXPORT pmix_status_t
0057 pmix_shmem_segment_attach(
0058     pmix_shmem_t *shmem,
0059     uintptr_t desired_base_address,
0060     pmix_shmem_flags_t flags
0061 );
0062 
0063 PMIX_EXPORT pmix_status_t
0064 pmix_shmem_segment_detach(
0065     pmix_shmem_t *shmem
0066 );
0067 
0068 PMIX_EXPORT pmix_status_t
0069 pmix_shmem_segment_unlink(
0070     pmix_shmem_t *shmem
0071 );
0072 
0073 /**
0074  * Change ownership of given shmem. Similar to chown(2).
0075  */
0076 PMIX_EXPORT pmix_status_t
0077 pmix_shmem_segment_chown(
0078     pmix_shmem_t *shmem,
0079     uid_t owner,
0080     gid_t group
0081 );
0082 
0083 /**
0084  * Change permissions of given shmem. Similar to chmod(2).
0085  */
0086 PMIX_EXPORT pmix_status_t
0087 pmix_shmem_segment_chmod(
0088     pmix_shmem_t *shmem,
0089     mode_t mode
0090 );
0091 
0092 /**
0093  * Returns size padded to page boundary.
0094  */
0095 PMIX_EXPORT size_t
0096 pmix_shmem_utils_pad_to_page(
0097     size_t size
0098 );
0099 
0100 #endif