<commit_before>/*
 * File:  xptr.h
 * Copyright (C) 2004 The Institute for System Programming of the Russian Academy of Sciences (ISP RAS)
 */


#ifndef __XPTR_H
#define __XPTR_H

#include "common/sedna.h"
#include "common/base.h"

#ifndef NULL
#define NULL_WAS_NOT_DEFINED
#define NULL	0
#endif

// File incapsulates xptr notion. It has been written for 32-bit architecture
// but with the goal to be easyly ported to 64-bit architecture

#define TMP_LAYER_STARTS_WITH	0x40000000
#define INVALID_LAYER			0xFFFFFFFF

// user this macros when you want obtain pointer in terms of process' virtual
// address space
#define XADDR(p)				((p).addr)
#define CONSTRUCT_XPTR(l, a)	(xptr(l, a))
#define BLOCKXPTR(a)			xptr(a.layer,(void*)((__uint32)((a).addr) & PAGE_BIT_MASK))

// works only in transaction, does not work is SM
//#define ADDR2XPTR(a)			xptr(*(t_layer*)(((__uint32)(a)) & PAGE_BIT_MASK), (void*)(a))
// this one works both in transaction and SM
//#define ADDR2XPTR(a)			xptr(*(xptr*)(((__uint32)(a)) & PAGE_BIT_MASK) + (((__uint32)(a)) & PAGE_REVERSE_BIT_MASK))
#define ADDR2XPTR(a)			xptr(*(t_layer*)(((__uint32)(a)) & PAGE_BIT_MASK),					\
                                     (void*)(*(__uint32*)((((__uint32)(a)) & PAGE_BIT_MASK) + sizeof(t_layer)) + (((__uint32)(a)) & PAGE_REVERSE_BIT_MASK)))

#define TEST_XPTR(p)			(*(t_layer*)((__uint32)((p).addr) & PAGE_BIT_MASK) == (p).layer)
// old and don't work   !!!
//#define TEST_XPTR(p)			(*(xptr*)((__uint32)((p).addr) & PAGE_BIT_MASK) == (p))


#define ALIGN_ADDR(a)			((void*)((__uint32)(a) & PAGE_BIT_MASK))
// new wave in VMM :)
//#define ALIGN_XADDR(p)			((void*)((__uint32)((p).addr) & PAGE_BIT_MASK))
//#define TEST_XPTR(p, a)			((*(t_layer*)a == (p).layer) && (((xptr*)a)->addr == a))

#define LAYERS_EQUAL(a, p)      (*(t_layer*)((__uint32)(a) & PAGE_BIT_MASK) == ((p).layer))



#define IS_TMP_BLOCK(p)			((p).layer >= TMP_LAYER_STARTS_WITH)
#define IS_DATA_BLOCK(p)		((p).layer <  TMP_LAYER_STARTS_WITH)

#define IS_TMP_BLOCK_LP(ptr)	(((vmm_sm_blk_hdr*)(ptr))->p.layer >= TMP_LAYER_STARTS_WITH)
#define IS_DATA_BLOCK_LP(ptr)	(((vmm_sm_blk_hdr*)(ptr))->p.layer <  TMP_LAYER_STARTS_WITH)



/* type for layer */
typedef int t_layer;

/* Struct for Extended Virtual Address Space Pointer */
struct xptr
{
    t_layer	layer;
    void *	addr;

    xptr() { layer = 0; addr = NULL; }
    xptr(t_layer layer, void *addr) { this->layer = layer; this->addr = addr; }
    xptr(const xptr& x) { layer = x.layer; addr = x.addr; }

    xptr &operator +=(int n)
	{ 
		addr = (char*)(addr) + n;

		if ((unsigned int)addr >= LAYER_ADDRESS_SPACE_BOUNDARY_INT)
		{
			layer++;
			addr = (void*)((int)addr - LAYER_ADDRESS_SPACE_SIZE);
		}

		return *this; 
	}
    xptr &operator -=(int n) 
    { 
        addr = (char*)(addr) - n; 
        
        if ((unsigned int)addr < LAYER_ADDRESS_SPACE_START_ADDR_INT)
		{
			layer--;
			addr = (void*)((int)addr + LAYER_ADDRESS_SPACE_SIZE);
		}
        
        return *this; 
    }<commit_msg>xptr no copy constructor<commit_after>/*
 * File:  xptr.h
 * Copyright (C) 2004 The Institute for System Programming of the Russian Academy of Sciences (ISP RAS)
 */


#ifndef __XPTR_H
#define __XPTR_H

#include "common/sedna.h"
#include "common/base.h"

#ifndef NULL
#define NULL_WAS_NOT_DEFINED
#define NULL	0
#endif

// File incapsulates xptr notion. It has been written for 32-bit architecture
// but with the goal to be easyly ported to 64-bit architecture

#define TMP_LAYER_STARTS_WITH	0x40000000
#define INVALID_LAYER			0xFFFFFFFF

// user this macros when you want obtain pointer in terms of process' virtual
// address space
#define XADDR(p)				((p).addr)
#define CONSTRUCT_XPTR(l, a)	(xptr(l, a))
#define BLOCKXPTR(a)			xptr(a.layer,(void*)((__uint32)((a).addr) & PAGE_BIT_MASK))

// works only in transaction, does not work is SM
//#define ADDR2XPTR(a)			xptr(*(t_layer*)(((__uint32)(a)) & PAGE_BIT_MASK), (void*)(a))
// this one works both in transaction and SM
//#define ADDR2XPTR(a)			xptr(*(xptr*)(((__uint32)(a)) & PAGE_BIT_MASK) + (((__uint32)(a)) & PAGE_REVERSE_BIT_MASK))
#define ADDR2XPTR(a)			xptr(*(t_layer*)(((__uint32)(a)) & PAGE_BIT_MASK),					\
                                     (void*)(*(__uint32*)((((__uint32)(a)) & PAGE_BIT_MASK) + sizeof(t_layer)) + (((__uint32)(a)) & PAGE_REVERSE_BIT_MASK)))

#define TEST_XPTR(p)			(*(t_layer*)((__uint32)((p).addr) & PAGE_BIT_MASK) == (p).layer)
// old and don't work   !!!
//#define TEST_XPTR(p)			(*(xptr*)((__uint32)((p).addr) & PAGE_BIT_MASK) == (p))


#define ALIGN_ADDR(a)			((void*)((__uint32)(a) & PAGE_BIT_MASK))
// new wave in VMM :)
//#define ALIGN_XADDR(p)			((void*)((__uint32)((p).addr) & PAGE_BIT_MASK))
//#define TEST_XPTR(p, a)			((*(t_layer*)a == (p).layer) && (((xptr*)a)->addr == a))

#define LAYERS_EQUAL(a, p)      (*(t_layer*)((__uint32)(a) & PAGE_BIT_MASK) == ((p).layer))



#define IS_TMP_BLOCK(p)			((p).layer >= TMP_LAYER_STARTS_WITH)
#define IS_DATA_BLOCK(p)		((p).layer <  TMP_LAYER_STARTS_WITH)

#define IS_TMP_BLOCK_LP(ptr)	(((vmm_sm_blk_hdr*)(ptr))->p.layer >= TMP_LAYER_STARTS_WITH)
#define IS_DATA_BLOCK_LP(ptr)	(((vmm_sm_blk_hdr*)(ptr))->p.layer <  TMP_LAYER_STARTS_WITH)



/* type for layer */
typedef int t_layer;

/* Struct for Extended Virtual Address Space Pointer */
struct xptr
{
    t_layer	layer;
    void *	addr;

    xptr() : layer(0), addr(NULL) {}
    xptr(t_layer _layer, void *_addr) : layer(_layer), addr(_addr) {}

// Uncomment next line as soon as somebody is able to explain what is it needed for
//   xptr(const xptr& x) { layer = x.layer; addr = x.addr; }

    xptr &operator +=(int n)
	{ 
		addr = (char*)(addr) + n;

		if ((unsigned int)addr >= LAYER_ADDRESS_SPACE_BOUNDARY_INT)
		{
			layer++;
			addr = (void*)((int)addr - LAYER_ADDRESS_SPACE_SIZE);
		}

		return *this; 
	}
    xptr &operator -=(int n) 
    { 
        addr = (char*)(addr) - n; 
        
        if ((unsigned int)addr < LAYER_ADDRESS_SPACE_START_ADDR_INT)
		{
			layer--;
			addr = (void*)((int)addr + LAYER_ADDRESS_SPACE_SIZE);
		}
        
        return *this; 
    }
{'fraction_non_alphanumeric': 0.17191882527635705, 'fraction_numerical': 0.01616894901831381, 'mean_word_length': 3.900565885206144, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 4, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7618603', 'n_tokens_mistral': 2531, 'n_tokens_neox': 2387, 'n_words': 525}