1 /* 2 * Copyright (C) 2002-2009, Edmundo Albuquerque de Souza e Silva. 3 * 4 * This file may be distributed under the terms of the Q Public License 5 * as defined by Trolltech AS of Norway and appearing in the file 6 * LICENSE.QPL included in the packaging of this file. 7 * 8 * THIS FILE IS PROVIDED AS IS WITH NO WARRANTY OF ANY KIND, INCLUDING 9 * THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 10 * PURPOSE. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, 11 * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING 12 * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 13 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION 14 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 * 16 */ 17 18 /*************************************************************************** 19 rmwinmask.h 20 ------------------- 21 begin : Feb 2002 22 Authors : Jorge Allyson Azevedo 23 Milena Scanferla 24 Daniel Sadoc 25 email : {allyson,milena,sadoc}@land.ufrj.br 26 ***************************************************************************/ 27 28 #ifdef HAVE_CONFIG_H 29 #include "../config.h" 30 #endif 31 32 #ifndef _RMWINMASK_H 33 34 #define _RMWINMASK_H 35 36 #include "rmcache.h" 37 #include "rminternals.h" 38 #include "rmstruct.h" 39 40 #include <pthread.h> 41 #include <string.h> 42 #include <signal.h> 43 #include <errno.h> 44 45 #include <sys/time.h> 46 #include <unistd.h> 47 #include <stdio.h> 48 #include <time.h> 49 50 51 52 extern pthread_mutex_t nak_window_mask_mutex; 53 54 /*********************** Routines to handle the window nack mask ************************************/ 55 56 57 #define min(a,b) ( ( (a)<(b))?a:b ) 58 59 #define MAX_WINDOW_SIZE 64 60 61 int window_mask_get_bit2(int *window_mask, int position); 62 63 int window_mask_sn_within_window(int *window_mask, int sn, MEMBER_STATUS *mstatus); 64 65 int window_mask_get_bit(int *window_mask, int sn, MEMBER_STATUS *mstatus); 66 67 68 int window_mask_set_bit2(int *window_mask, int position, int value); 69 70 71 72 int window_mask_set_bit(int *window_mask, int sn, MEMBER_STATUS *mstatus, int value); 73 74 75 int window_mask_numbers2array(int *window_mask, int hmask, int lmask); 76 77 int window_mask_array2numbers(int *window_mask, int *hmask, int *lmask, int mask_ini); 78 79 #define SHOW for( i = MAX_WINDOW_SIZE - 1; i >= 0 ; i--) \ 80 {\ 81 fprintf(stderr,"%d", c->sm_info.member_status.window_mask[ i ] );\ 82 if ( i == c->sm_info.member_status.window_ini )\ 83 fprintf ( stderr, "}" );\ 84 if ( i == c->sm_info.member_status.window_ini + c->sm_info.member_status.window_size ) \ 85 fprintf ( stderr, "{" ); \ 86 }\ 87 fprintf(stderr,"\n"); 88 89 90 #endif 91 92