libjf API reference guide

Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

jf_recind_list.h

Go to the documentation of this file.
00001 /* 00002 * Copyright 2005 Tiian 00003 * {In real life Tiian is Christian Ferrari} 00004 * This file is part of "libjf" package. 00005 * 00006 * "libjf" is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU Lesser General Public License as published by 00008 * the Free Software Foundation; either version 2.1 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * "libjf" is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public License 00017 * along with ; if not, write to the Free Software 00018 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 */ 00020 #include <jf/jf_config.h> 00021 00022 00023 00024 #ifndef JF_RECIND_LIST_H 00025 #define JF_RECIND_LIST_H 00026 00027 00028 00029 #include <jf/jf_errors.h> 00030 #include <jf/jf_wrappers.h> 00031 #include <jf/jf_trace.h> 00032 00033 00034 00035 /* save old JF_TRACE_MODULE and set a new value */ 00036 #ifdef JF_TRACE_MODULE 00037 # define JF_TRACE_MODULE_SAVE JF_TRACE_MODULE 00038 # undef JF_TRACE_MODULE 00039 #else 00040 # undef JF_TRACE_MODULE_SAVE 00041 #endif /* JF_TRACE_MODULE */ 00042 #define JF_TRACE_MODULE JF_TRACE_MOD_LIB_RECIND_LIST 00043 00044 00045 00049 #define JF_RECIND_OPER_UNKNOWN 0x0 00050 00054 #define JF_RECIND_OPER_MUST_COMMIT 0x1 00055 00059 #define JF_RECIND_OPER_MUST_ROLLBACK 0x2 00060 00064 #define JF_RECIND_NULL_OFFSET -1 00065 00066 00067 00068 #ifdef __cplusplus 00069 extern "C" { 00070 #endif /* __cplusplus */ 00071 00072 00073 00079 typedef struct { 00085 jf_word_t uow_type; 00089 size_t size; 00093 jf_offset_t *array; 00094 } jf_recind_list_t; 00095 00096 00097 00102 void jf_recind_list_reset(jf_recind_list_t *ril); 00103 00104 00105 00110 static inline void jf_recind_list_create(jf_recind_list_t *ril) { 00111 jf_recind_list_reset(ril); } 00112 00113 00114 00121 void jf_recind_list_destroy(jf_recind_list_t *ril); 00122 00123 00124 00130 static inline int jf_recind_list_is_safe(const jf_recind_list_t *ril) { 00131 return (ril->array != NULL && ril->size > 0) || 00132 (ril->array == NULL && ril->size == 0); } 00133 00134 00135 00142 int jf_recind_list_add(jf_recind_list_t *ril, jf_offset_t elem); 00143 00144 00145 00152 static inline int jf_recind_list_set_uow_type( 00153 jf_recind_list_t *ril, jf_word_t uow_type) { 00154 #ifdef _EXTRA_CHECK 00155 if (uow_type != JF_RECIND_OPER_UNKNOWN && 00156 uow_type != JF_RECIND_OPER_MUST_COMMIT && 00157 uow_type != JF_RECIND_OPER_MUST_ROLLBACK) 00158 return JF_RC_OUT_OF_RANGE; 00159 #endif /* _EXTRA_CHECK */ 00160 ril->uow_type = uow_type; 00161 return JF_RC_OK; 00162 } 00163 00164 00165 00173 static inline jf_word_t jf_recind_list_get_uow_type( 00174 const jf_recind_list_t *ril) { 00175 return ril->uow_type; } 00176 00177 00178 00184 static inline size_t jf_recind_list_get_size( 00185 const jf_recind_list_t *ril) { 00186 return ril->size; } 00187 00188 00189 00196 static inline jf_offset_t jf_recind_list_get_elem( 00197 const jf_recind_list_t *ril, size_t pos) { 00198 #ifdef _EXTRA_CHECK 00199 if (pos < 0 || pos >= ril->size) 00200 return JF_RECIND_NULL_OFFSET; 00201 else 00202 #endif /* _EXTRA_CHECK */ 00203 return ril->array[pos]; 00204 } 00205 00206 00207 00208 #ifdef __cplusplus 00209 } 00210 #endif /* __cplusplus */ 00211 00212 00213 00214 /* restore old value of JF_TRACE_MODULE */ 00215 #ifdef JF_TRACE_MODULE_SAVE 00216 # undef JF_TRACE_MODULE 00217 # define JF_TRACE_MODULE JF_TRACE_MODULE_SAVE 00218 # undef JF_TRACE_MODULE_SAVE 00219 #endif /* JF_TRACE_MODULE_SAVE */ 00220 00221 00222 00223 #endif /* JF_RECIND_LIST_H */

Copyright 2005 © Tiian