![]() |
|
|||
0001 /** 0002 * @brief Mutli-buffer TLV handler 0003 * 0004 * @file multibuf.h 0005 */ 0006 /* ----------------------------------------------------------------------------- 0007 * Enduro/X Middleware Platform for Distributed Transaction Processing 0008 * Copyright (C) 2009-2016, ATR Baltic, Ltd. All Rights Reserved. 0009 * Copyright (C) 2017-2023, Mavimax, Ltd. All Rights Reserved. 0010 * This software is released under one of the following licenses: 0011 * AGPL (with Java and Go exceptions) or Mavimax's license for commercial use. 0012 * See LICENSE file for full text. 0013 * ----------------------------------------------------------------------------- 0014 * AGPL license: 0015 * 0016 * This program is free software; you can redistribute it and/or modify it under 0017 * the terms of the GNU Affero General Public License, version 3 as published 0018 * by the Free Software Foundation; 0019 * 0020 * This program is distributed in the hope that it will be useful, but WITHOUT ANY 0021 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 0022 * PARTICULAR PURPOSE. See the GNU Affero General Public License, version 3 0023 * for more details. 0024 * 0025 * You should have received a copy of the GNU Affero General Public License along 0026 * with this program; if not, write to the Free Software Foundation, Inc., 0027 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 0028 * 0029 * ----------------------------------------------------------------------------- 0030 * A commercial use license is available from Mavimax, Ltd 0031 * contact@mavimax.com 0032 * ----------------------------------------------------------------------------- 0033 */ 0034 #ifndef __MULTIBUF_H 0035 #define __MULTIBUF_H 0036 0037 #ifdef __cplusplus 0038 extern "C" { 0039 #endif 0040 0041 /*---------------------------Includes-----------------------------------*/ 0042 #include <ndrstandard.h> 0043 #include <ndrx_config.h> 0044 #include <atmi_int.h> 0045 /*---------------------------Externs------------------------------------*/ 0046 /*---------------------------Macros-------------------------------------*/ 0047 0048 #define NDRX_MBUF_TBITS 4 /**< Number of type id bits */ 0049 0050 /** Data type tag offset */ 0051 #define NDRX_MBUF_OFFSET (sizeof(int)*8-NDRX_MBUF_TBITS) 0052 /** get the buffer type encoded as last bits */ 0053 #define NDRX_MBUF_TYPE(X) (X>>(sizeof(int)*8-NDRX_MBUF_TBITS)) 0054 0055 /** get the call info bit */ 0056 #define NDRX_MBUF_CALLINFOBIT 0x4000000 0057 0058 /** get the tag */ 0059 #define NDRX_MBUF_TAGTAG(X) (X & (0x3FFFFFF)) 0060 0061 #define NDRX_MBUF_TAG_CALLINFO 0 /**< Call info reserved tag */ 0062 #define NDRX_MBUF_TAG_PRIMARY 1 /**< Base buffer */ 0063 #define NDRX_MBUF_TAG_PTR_BASE 2 /**< Virtual pointer base tag (start) */ 0064 /* Tags 2+ - are virtual pointers */ 0065 0066 /*---------------------------Enums--------------------------------------*/ 0067 /*---------------------------Typedefs-----------------------------------*/ 0068 0069 /** 0070 * This is multibuf TLV entry 0071 * The buffer type needs to be stored here too. 0072 * Ta 0073 */ 0074 typedef struct 0075 { 0076 /**< This is logical tag number started from 0, 0077 * last 4 bit are buffer type 0078 */ 0079 unsigned int tag; 0080 long len; /**< this is data length, use long for 8 byte alignment */ 0081 0082 /** Memory data of the buffer padded up 0083 * till the modulus of EX_ALIGNMENT_BYTES is 0 0084 */ 0085 char data[0]; 0086 } ndrx_mbuf_tlv_t; 0087 0088 /** 0089 * This is list of virtual pointers descriptors 0090 */ 0091 typedef struct 0092 { 0093 char *data; /**< pointer to allocated memory block */ 0094 long len; /**< buffer len */ 0095 int btype; /**< cached buffer type */ 0096 } ndrx_mbuf_vptrs_t; 0097 0098 /** 0099 * In case if we export ptr field, we firstly add new ptr to growlist 0100 * and in second time we verify that this pointer is already exported 0101 * If already exported, use already mapped vptr. 0102 * (this is hash of real pointers) 0103 */ 0104 typedef struct 0105 { 0106 char *ptr; /**< pointer to atmi buffer */ 0107 int tag; /**< mapped tag */ 0108 0109 EX_hash_handle hh; /**< makes this structure hashable */ 0110 } ndrx_mbuf_ptrs_t; 0111 0112 /*---------------------------Globals------------------------------------*/ 0113 /*---------------------------Statics------------------------------------*/ 0114 /*---------------------------Prototypes---------------------------------*/ 0115 extern NDRX_API ndrx_mbuf_ptrs_t* ndrx_mbuf_ptr_find(ndrx_mbuf_ptrs_t **ptrs, char *ptr); 0116 extern NDRX_API ndrx_mbuf_ptrs_t * ndrx_mbuf_ptr_add(ndrx_mbuf_ptrs_t **ptrs, char *ptr, int tag); 0117 extern NDRX_API void ndrx_mbuf_ptr_free(ndrx_mbuf_ptrs_t **ptrs); 0118 0119 #ifdef __cplusplus 0120 } 0121 #endif 0122 0123 #endif /* __MULTIBUF_H */ 0124 0125 /* vim: set ts=4 sw=4 et smartindent: */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |