1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #pragma ident "@(#)shm_ops.h 1.12 09/05/26 SMI" 28 29 #ifndef _DISKOMIZER_SHM_OPS_H 30 #define _DISKOMIZER_SHM_OPS_H 31 32 #ifdef __cplusplus 33 extern "C" { 34 #endif 35 36 #include <sys/types.h> 37 struct shm_flags { 38 unsigned execute : 1; 39 unsigned write : 1; 40 unsigned allow_detach : 1; 41 unsigned always_detach : 1; 42 unsigned keep_shm : 1; 43 unsigned leave_attached: 1; 44 unsigned private : 26; 45 }; 46 typedef struct shm_flags shm_flags; 47 typedef enum { 48 SHM_DETACH_ERR, 49 SHM_DETACH_OK, 50 SHM_DETACH_DONE 51 } shm_det_status; 52 struct shm_ops { 53 const char *(*name)(void *handle); 54 const char *(*longname)(void *handle); 55 /* init returns an opaque handle */ 56 void * (*init)(long a, long b, shm_flags flags); 57 void * (*attach)(void *handle); 58 shm_det_status (*detach)(void *handle); 59 void (*destroy)(void *handle); 60 ulong_t (*max_size)(void); 61 int (*is_short_of_mem)(void); 62 /* Called when all allocations have been done */ 63 void (*complete)(void *handle); 64 void (*fini)(void); 65 /* int (*garbage_collect)(void * addr, size_t size); */ 66 }; 67 extern struct shm_ops shm_shm_ops; 68 extern struct shm_ops shm_ism_ops; 69 extern struct shm_ops shm_bestshm_ops; 70 extern struct shm_ops shm_mmap_ops; 71 extern struct shm_ops shm_mmap_no_frag_ops; 72 extern struct shm_ops shm_best_ops; 73 extern struct shm_ops *shm_ops; 74 extern struct shm_ops *choose_shm_ops(const char *key); 75 extern void * alloc_mem(long a, long b); 76 #define ROUND_UP(A, B) ((A) % (B) == 0 ? (A) : ((A) + (B) - ((A) % (B)))) 77 78 #ifdef __cplusplus 79 } 80 #endif 81 82 #endif /* _DISKOMIZER_SHM_OPS_H */ 83