Back to home page

Enduro/X

 
 

    


0001 /**
0002  * @brief UBF library TLS storage
0003  *
0004  * @file ubf_tls.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 UBF_TLS_H
0035 #define UBF_TLS_H
0036 
0037 #ifdef  __cplusplus
0038 extern "C" {
0039 #endif
0040 
0041 /*---------------------------Includes-----------------------------------*/
0042 #include <pthread.h>
0043 #include <ndrstandard.h>
0044 #include <ubf.h>
0045 #include <ferror.h>
0046 /*---------------------------Externs------------------------------------*/
0047 /*---------------------------Macros-------------------------------------*/
0048     
0049 #define UBF_TLS_MAGIG          0x150519be
0050 #define UBF_TLS_ENTRY  if (NDRX_UNLIKELY(NULL==G_ubf_tls)) \
0051         {G_ubf_tls=(ubf_tls_t *)ndrx_ubf_tls_new(EXTRUE, EXTRUE);};
0052 /*---------------------------Enums--------------------------------------*/
0053 /*---------------------------Typedefs-----------------------------------*/
0054 
0055 /**
0056  * UBF Library TLS
0057  */
0058 typedef struct
0059 {
0060     int magic; /* have some magic for context data */
0061     
0062     /* fdatatype.c */
0063     short tbuf_s; /* =0; */
0064     long tbuf_l;/*=0; */
0065     int tbuf_i;/*=0; */
0066     char tbuf_c;/*=0; */
0067     float tbuf_f; /*=0.0; */
0068     double tbuf_d; /*=0.0; */
0069     
0070     ndrx_longptr_t tbuf_p;/*=0; */
0071     
0072     char *str_buf_ptr;/* = NULL; */
0073     int str_dat_len;/* = 0;*/
0074      
0075     char *carray_buf_ptr;/*  = NULL; */
0076     int carray_dat_len;/* = 0; */
0077     
0078     char M_ubf_error_msg_buf[MAX_ERROR_LEN+1];/* = {EOS}; */
0079     int M_ubf_error;/* = BMINVAL; */
0080     
0081     char errbuf[MAX_ERROR_LEN+1];
0082     
0083     /** fieldtable.c */
0084     char bfname_buf[64];
0085     
0086     /** ubf.c */
0087     Bnext_state_t bnext_state;
0088     
0089     /** storage for Bfind */
0090     ndrx_ubf_tls_bufval_t ndrx_Bfind_tls_stor;
0091     
0092     /** storage for Bfindlast */
0093     ndrx_ubf_tls_bufval_t ndrx_Bfindlast_tls_stor;
0094     
0095     int is_auto; /* is this auto-allocated (thus do the auto-free) */
0096     /* we should have lock inside */
0097     pthread_mutex_t mutex; /* initialize later with PTHREAD_MUTEX_INITIALIZER */
0098     
0099 } ubf_tls_t;
0100 
0101 /*---------------------------Globals------------------------------------*/
0102 extern NDRX_API __thread ubf_tls_t *G_ubf_tls; /* Enduro/X standard library TLS */
0103 /*---------------------------Statics------------------------------------*/
0104 /*---------------------------Prototypes---------------------------------*/
0105     
0106 #ifdef  __cplusplus
0107 }
0108 #endif
0109 
0110 #endif  /* UBF_CONTEXT_H */
0111 
0112 /* vim: set ts=4 sw=4 et smartindent: */