Skip to content
Permalink
3471efde50
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
86 lines (65 sloc) 2.33 KB
#pragma message("touching: "__FILE__)
#include "common.h"
/* Assuming MAXSEG is defined.
Size of each block of the dynamic array.
Must be a positive integer.*/
/* Assuming DYNARR_TYPE is defined.
The data type of the array.
Must be a valid one-word type without space, *, etc. (use typedef if necessary)
*/
#ifndef MAXSEG
#pragma message("MAXSEG must be defined before including " __FILE__)
#elif MAXSEG <= 0
#pragma message("MAXSEG has non positive value: " MAXSEG)
#elif !defined(DYNARR_TYPE)
#pragma message("DYNARR_TYPE must be defined before including " __FILE__)
#else
// everything is fine
#include "dynarr_freenodelist.h"
// declarations
// swap two integers, or pointers, without using temporary storage
__inline void int_swap(unsigned int *var1, unsigned int *var2) {
(*var1) = (*var1) ^ (*var2);
(*var2) = (*var1) ^ (*var2);
(*var1) = (*var1) ^ (*var2);
}
// external definitions for allocating/resizing blocks
extern int seg_bank_alloc_next();
extern int seg_bank_increase_max();
#define SEG_ARR_NAME pSegArr
#define FREESEG_LIST_NAME pFreeSegList
#define FREESEG_INVALID_LIST_NAME pFreeSegInvalidList
#define SEG_INSERT_POS iInsertPos
#define EMPTY_INDEX 0
#define EMPTY_BYTE 0
#define NULL_SEG emptySeg
#define SEG_INSERT_POS_BEGIN 1
// Node blocks
#if _REGION_
// maximum number of segment banks
// this should be a very big number
// this number should never be reached
#define MAX_SEG_BANKS INT_MAX
// array containing size (# of segments) of each segment bank
#define SEG_BANK_SIZE_ARR pSegBankSizeArr
// array containing last valid index of each segment bank
#define SEG_BANK_INDEX_LIMIT_ARR pSegBankIndexLimitArr
// Number of active segment banks
#define NUM_SEG_BANKS NumSegBanks
#define CURRENT_SEG_BANK (NUM_SEG_BANKS - 1)
// actual segment banks
#define SEG_BANKS_ARR pSegBanksArr
// coordinates in the 2-D segment allocation
#define BANK_INDEX_FROM_SEG_INDEX(index) \
( ((unsigned int)(index)) >> LOG_MAXSEG )
#define BANK_FROM_SEG_INDEX(index) SEG_BANKS_ARR[BANK_INDEX_FROM_SEG_INDEX(index)]
#define SLOT_FROM_SEG_INDEX(index) (((unsigned int)(index)) & MAXSEG_REMAINDER_BITMASK)
// pointer to the segment
#define PTR_SEG_FROM_INDEX(index) \
(BANK_FROM_SEG_INDEX(index) + NUM_SEG_MEMBERS_IN_ARR * SLOT_FROM_SEG_INDEX(index) )
#endif
/* The dynamic array data structure */
struct TYPED_NAME(DynArr){
int a;
};
#endif