本文整理汇总了C++中intptr_t函数的典型用法代码示例。如果您正苦于以下问题:C++ intptr_t函数的具体用法?C++ intptr_t怎么用?C++ intptr_t使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了intptr_t函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getOffset
SimpleMemory::~SimpleMemory()
{
size_t freedOffset = getOffset();
size_t freedSize = getSize();
// keep the size to unmap in excess
size_t pagesize = getpagesize();
size_t start = freedOffset;
size_t end = start + freedSize;
start &= ~(pagesize-1);
end = (end + pagesize-1) & ~(pagesize-1);
// give back to the kernel the pages we don't need
size_t free_start = freedOffset;
size_t free_end = free_start + freedSize;
if (start < free_start)
start = free_start;
if (end > free_end)
end = free_end;
start = (start + pagesize-1) & ~(pagesize-1);
end &= ~(pagesize-1);
if (start < end) {
void* const start_ptr = (void*)(intptr_t(getHeap()->base()) + start);
size_t size = end-start;
#ifndef NDEBUG
memset(start_ptr, 0xdf, size);
#endif
// MADV_REMOVE is not defined on Dapper based Goobuntu
#ifdef MADV_REMOVE
if (size) {
int err = madvise(start_ptr, size, MADV_REMOVE);
LOGW_IF(err, "madvise(%p, %u, MADV_REMOVE) returned %s",
start_ptr, size, err<0 ? strerror(errno) : "Ok");
}
#endif
}
}
示例2: fhd_candidate_selection_grid
void fhd_candidate_selection_grid(fhd_ui* ui, int btn_width, int btn_height) {
for (int i = 0; i < ui->fhd->candidates_len; i++) {
fhd_texture* texture = &ui->textures[i];
bool selected = ui->selected_candidates[i];
void* handle = (void*)intptr_t(texture->handle);
if (selected) {
if (ImGui::ImageButton(
handle, ImVec2(btn_width, btn_height), ImVec2(0, 0), ImVec2(1, 1),
4, ImVec4(1.f, 1.f, 1.f, 1.f), ImVec4(0.f, 1.f, 0.f, 1.f))) {
ui->selected_candidates[i] = false;
}
} else {
if (ImGui::ImageButton(handle, ImVec2(btn_width, btn_height),
ImVec2(0, 0), ImVec2(1, 1), 2)) {
ui->selected_candidates[i] = true;
}
}
if (i % 7 < 6) ImGui::SameLine();
}
}
示例3: get_native_u8
static inline u8 get_native_u8(address p) {
switch (intptr_t(p) & 7) {
case 0: return *(u8*)p;
case 4: return ( u8( ((u4*)p)[0] ) << 32 )
| ( u8( ((u4*)p)[1] ) );
case 2: return ( u8( ((u2*)p)[0] ) << 48 )
| ( u8( ((u2*)p)[1] ) << 32 )
| ( u8( ((u2*)p)[2] ) << 16 )
| ( u8( ((u2*)p)[3] ) );
default: return ( u8(p[0]) << 56 )
| ( u8(p[1]) << 48 )
| ( u8(p[2]) << 40 )
| ( u8(p[3]) << 32 )
| ( u8(p[4]) << 24 )
| ( u8(p[5]) << 16 )
| ( u8(p[6]) << 8 )
| u8(p[7]);
}
}
示例4: gralloc_perform
int gralloc_perform(struct gralloc_module_t const* module,
int operation, ... )
{
int res = -EINVAL;
va_list args;
va_start(args, operation);
switch (operation) {
case GRALLOC_MODULE_PERFORM_CREATE_HANDLE_FROM_BUFFER: {
int fd = va_arg(args, int);
size_t size = va_arg(args, size_t);
size_t offset = va_arg(args, size_t);
void* base = va_arg(args, void*);
// validate that it's indeed a pmem buffer
pmem_region region;
if (ioctl(fd, PMEM_GET_SIZE, ®ion) < 0) {
break;
}
native_handle_t** handle = va_arg(args, native_handle_t**);
private_handle_t* hnd = (private_handle_t*)native_handle_create(
private_handle_t::sNumFds, private_handle_t::sNumInts);
hnd->magic = private_handle_t::sMagic;
hnd->fd = fd;
hnd->flags = private_handle_t::PRIV_FLAGS_USES_PMEM;
hnd->size = size;
hnd->offset = offset;
hnd->base = intptr_t(base) + offset;
hnd->lockState = private_handle_t::LOCK_STATE_MAPPED;
*handle = (native_handle_t *)hnd;
res = 0;
break;
}
}
va_end(args);
return res;
}
示例5: mSize
SubRegionMemory::SubRegionMemory(const sp<MemoryHeapPmem>& heap,
ssize_t offset, size_t size)
: MemoryHeapPmem::MemoryPmem(heap), mSize(size), mOffset(offset)
{
#ifndef NDEBUG
void* const start_ptr = (void*)(intptr_t(getHeap()->base()) + offset);
memset(start_ptr, 0xda, size);
#endif
#ifdef HAVE_ANDROID_OS
if (size > 0) {
const size_t pagesize = getpagesize();
size = (size + pagesize-1) & ~(pagesize-1);
int our_fd = heap->heapID();
struct pmem_region sub = { offset, size };
int err = ioctl(our_fd, PMEM_MAP, &sub);
ALOGE_IF(err<0, "PMEM_MAP failed (%s), "
"mFD=%d, sub.offset=%lu, sub.size=%lu",
strerror(errno), our_fd, sub.offset, sub.len);
}
#endif
}
示例6: intptr_t
LzopStreamReader::LzopStreamReader(const void* base, size_t length)
{
header_t header; // LZOP header information
if(!base) throw Exception(E_POINTER);
if(length == 0) throw Exception(E_INVALIDARG);
intptr_t baseptr = intptr_t(base);
// Verify the magic number and read the LZOP header information
baseptr = ReadMagic(baseptr, &length);
baseptr = ReadHeader(baseptr, &length, &header);
// Initialize the decompression block member variables
m_block = m_blockcurrent = NULL;
m_blocklen = 0;
m_blockremain = 0;
// Initialize the LZO input stream member variables
m_lzopos = baseptr;
m_lzoremain = length;
m_lzoflags = header.flags;
}
示例7: GetData
String String::ToLower() const
{
uint32_t c;
const char* psource = GetData()->Data;
const char* pend = psource + GetData()->GetSize();
String str;
intptr_t bufferOffset = 0;
char buffer[512];
while(psource < pend)
{
do {
c = UTF8Util::DecodeNextChar_Advance0(&psource);
UTF8Util::EncodeChar(buffer, &bufferOffset, OVR_towlower(wchar_t(c)));
} while ((psource < pend) && (bufferOffset < intptr_t(sizeof(buffer)-8)));
// Append string a piece at a time.
str.AppendString(buffer, bufferOffset);
bufferOffset = 0;
}
return str;
}
示例8: MemoryMapFile
static ANTLR3_UINT32 MemoryMapFile(pANTLR3_INPUT_STREAM input,
const std::string& filename) {
errno = 0;
struct stat st;
if(stat(filename.c_str(), &st) == -1) {
return ANTLR3_ERR_NOFILE;
}
input->sizeBuf = st.st_size;
int fd = open(filename.c_str(), O_RDONLY);
if(fd == -1) {
return ANTLR3_ERR_NOFILE;
}
input->data = mmap(0, input->sizeBuf, PROT_READ, MAP_PRIVATE, fd, 0);
errno = 0;
if(intptr_t(input->data) == -1) {
return ANTLR3_ERR_NOMEM;
}
return ANTLR3_SUCCESS;
}
示例9: gralloc_map
static int gralloc_map(gralloc_module_t const* module,
buffer_handle_t handle,
void** vaddr)
{
private_handle_t* hnd = (private_handle_t*)handle;
if (!(hnd->flags & private_handle_t::PRIV_FLAGS_FRAMEBUFFER)) {
size_t size = hnd->size;
#if PMEM_HACK
size += hnd->offset;
#endif
void* mappedAddress = mmap(0, size,
PROT_READ|PROT_WRITE, MAP_SHARED, hnd->fd, 0);
if (mappedAddress == MAP_FAILED) {
LOGE("Could not mmap %s", strerror(errno));
return -errno;
}
hnd->base = intptr_t(mappedAddress) + hnd->offset;
//LOGD("gralloc_map() succeeded fd=%d, off=%d, size=%d, vaddr=%p",
// hnd->fd, hnd->offset, hnd->size, mappedAddress);
}
*vaddr = (void*)hnd->base;
return 0;
}
示例10: OrkAssert
typename fixedvector<T,kmax>::iterator fixedvector<T,kmax>::iterator::operator-(intptr_t i) const// sub
{
OrkAssert( mpfixedary );
iterator temp( *this );
iter_type isize = iter_type(mpfixedary->size());
if( temp.mindex >= isize )
{
temp.mindex = npos;
}
else if( temp.mindex==npos && (i<=isize) )
{
temp.mindex = intptr_t(isize)-i;
}
else if( temp.mindex < 0 )
{
temp.mindex = npos;
}
else
{
temp.mindex-=i;
}
return temp;
}
示例11: snprintf
void HWComposer::dump(String8& result, char* buffer, size_t SIZE,
const Vector< sp<LayerBase> >& visibleLayersSortedByZ) const {
if (mHwc && mList) {
result.append("Hardware Composer state:\n");
snprintf(buffer, SIZE, " numHwLayers=%u, flags=%08x\n",
mList->numHwLayers, mList->flags);
result.append(buffer);
result.append(
" type | handle | hints | flags | tr | blend | format | source crop | frame name \n"
"----------+----------+----------+----------+----+-------+----------+---------------------------+--------------------------------\n");
// " ________ | ________ | ________ | ________ | __ | _____ | ________ | [_____,_____,_____,_____] | [_____,_____,_____,_____]
for (size_t i=0 ; i<mList->numHwLayers ; i++) {
const hwc_layer_t& l(mList->hwLayers[i]);
const sp<LayerBase> layer(visibleLayersSortedByZ[i]);
int32_t format = -1;
if (layer->getLayer() != NULL) {
const sp<GraphicBuffer>& buffer(layer->getLayer()->getActiveBuffer());
if (buffer != NULL) {
format = buffer->getPixelFormat();
}
}
snprintf(buffer, SIZE,
" %8s | %08x | %08x | %08x | %02x | %05x | %08x | [%5d,%5d,%5d,%5d] | [%5d,%5d,%5d,%5d] %s\n",
l.compositionType ? "OVERLAY" : "FB",
intptr_t(l.handle), l.hints, l.flags, l.transform, l.blending, format,
l.sourceCrop.left, l.sourceCrop.top, l.sourceCrop.right, l.sourceCrop.bottom,
l.displayFrame.left, l.displayFrame.top, l.displayFrame.right, l.displayFrame.bottom,
layer->getName().string());
result.append(buffer);
}
}
if (mHwc && mHwc->common.version >= 1 && mHwc->dump) {
mHwc->dump(mHwc, buffer, SIZE);
result.append(buffer);
}
}
示例12:
c_Closure::~c_Closure() {
// same as ar->hasThis()
if (m_thisOrClass && !(intptr_t(m_thisOrClass) & 1LL)) {
m_thisOrClass->decRefCount();
}
}
示例13: main
//.........这里部分代码省略.........
ImGui::InputFloat("seg k depth", &ui.fhd->depth_segmentation_threshold);
ImGui::InputFloat("seg k normals", &ui.fhd->normal_segmentation_threshold);
ImGui::SliderFloat("##min_reg_dim", &ui.fhd->min_region_size, 8.f, 100.f,
"min region dimension %.1f");
ImGui::SliderFloat("##merge_dist_x", &ui.fhd->max_merge_distance, 0.1f, 2.f,
"max h merge dist (m) %.2f");
ImGui::SliderFloat("##merge_dist_y", &ui.fhd->max_vertical_merge_distance,
0.1f, 3.f, "max v merge dist (m) %.2f");
ImGui::SliderFloat("##min_inlier", &ui.fhd->min_inlier_fraction, 0.5f, 1.f,
"RANSAC min inlier ratio %.2f");
ImGui::SliderFloat("##max_plane_dist", &ui.fhd->ransac_max_plane_distance,
0.01f, 1.f, "RANSAC max plane dist %.2f");
ImGui::SliderFloat("##reg_height_min", &ui.fhd->min_region_height, 0.1f,
3.f, "min region height (m) %.2f");
ImGui::SliderFloat("##reg_height_max", &ui.fhd->max_region_height, 0.1f,
3.f, "max region height (m) %.2f");
ImGui::SliderFloat("##reg_width_min", &ui.fhd->min_region_width, 0.1f, 1.f,
"min region width (m) %.2f");
ImGui::SliderFloat("##reg_width_max", &ui.fhd->max_region_height, 0.1f,
1.5f, "max region width (m) %.2f");
ImGui::SliderInt("##min_depth_seg_size", &ui.fhd->min_depth_segment_size, 4,
200, "min depth seg size");
ImGui::SliderInt("##min_normal_seg_size", &ui.fhd->min_normal_segment_size,
4, 200, "min normal seg size");
ImGui::EndChild();
ImGui::SameLine();
ImGui::BeginGroup();
ImDrawList* draw_list = ImGui::GetWindowDrawList();
ImVec2 p = ImGui::GetCursorScreenPos();
ImGui::Image((void*)intptr_t(ui.depth_texture.handle), ImVec2(512, 424));
ImU32 rect_color = ImColor(240, 240, 20);
for (int i = 0; i < detector.candidates_len; i++) {
const fhd_candidate* candidate = &detector.candidates[i];
if (candidate->weight >= 1.f) {
const fhd_image_region region = candidate->depth_position;
const float x = p.x + float(region.x);
const float y = p.y + float(region.y);
const float w = float(region.width);
const float h = float(region.height);
ImVec2 points[4] = {
ImVec2(x, y),
ImVec2(x + w, y),
ImVec2(x + w, y + h),
ImVec2(x, y + h)
};
draw_list->AddPolyline(points, 4, rect_color, true, 4.f, true);
}
}
ImGui::BeginGroup();
ImGui::Image((void*)intptr_t(ui.normals_texture.handle), ImVec2(256, 212));
ImGui::SameLine();
ImGui::Image((void*)intptr_t(ui.normals_seg_texture.handle),
ImVec2(256, 212));
ImGui::EndGroup();
ImGui::BeginGroup();
ImGui::Image((void*)intptr_t(ui.downscaled_depth.handle), ImVec2(256, 212));
ImGui::SameLine();
示例14: ProcessLineDefs
void ProcessLineDefs()
{
int sidecount = 0;
for(unsigned i = 0, skipped = 0; i < ParsedLines.Size();)
{
// Relocate the vertices
intptr_t v1i = intptr_t(ParsedLines[i].v1);
intptr_t v2i = intptr_t(ParsedLines[i].v2);
if (v1i >= numvertexes || v2i >= numvertexes || v1i < 0 || v2i < 0)
{
I_Error ("Line %d has invalid vertices: %zd and/or %zd.\nThe map only contains %d vertices.", i+skipped, v1i, v2i, numvertexes);
}
else if (v1i == v2i ||
(vertexes[v1i].x == vertexes[v2i].x && vertexes[v1i].y == vertexes[v2i].y))
{
Printf ("Removing 0-length line %d\n", i+skipped);
ParsedLines.Delete(i);
ForceNodeBuild = true;
skipped++;
}
else
{
ParsedLines[i].v1 = &vertexes[v1i];
ParsedLines[i].v2 = &vertexes[v2i];
if (ParsedLines[i].sidedef[0] != NULL)
sidecount++;
if (ParsedLines[i].sidedef[1] != NULL)
sidecount++;
linemap.Push(i+skipped);
i++;
}
}
numlines = ParsedLines.Size();
numsides = sidecount;
lines = new line_t[numlines];
sides = new side_t[numsides];
int line, side;
for(line = 0, side = 0; line < numlines; line++)
{
short tempalpha[2] = { SHRT_MIN, SHRT_MIN };
lines[line] = ParsedLines[line];
for(int sd = 0; sd < 2; sd++)
{
if (lines[line].sidedef[sd] != NULL)
{
int mapside = int(intptr_t(lines[line].sidedef[sd]))-1;
if (mapside < sidecount)
{
sides[side] = ParsedSides[mapside];
sides[side].linedef = &lines[line];
sides[side].sector = §ors[intptr_t(sides[side].sector)];
lines[line].sidedef[sd] = &sides[side];
P_ProcessSideTextures(!isExtended, &sides[side], sides[side].sector, &ParsedSideTextures[mapside],
lines[line].special, lines[line].args[0], &tempalpha[sd], missingTex);
side++;
}
else
{
lines[line].sidedef[sd] = NULL;
}
}
}
P_AdjustLine(&lines[line]);
P_FinishLoadingLineDef(&lines[line], tempalpha[0]);
}
assert(side <= numsides);
if (side < numsides)
{
Printf("Map had %d invalid side references\n", numsides - side);
numsides = side;
}
}
示例15: ASSERT
void CNSImageProvider::cnsResponse(const unsigned char* src, int width, int height,
int srcOfs, short* cns, float regVar)
{
ASSERT(CNSResponse::SCALE == 128);
__m128i offset = _mm_set1_epi8(static_cast<unsigned char>(CNSResponse::OFFSET));
// Image noise of variance \c regVar increases Gauss*I^2 by 16*regVar
// an additional factor of 16 is needed, since Gauss*I^2 is multiplied by 16
__m128 regVarF = _mm_set1_ps(16 * 16 * regVar);
// A pure X-gradient gives: sobelX=8, sobelY=0, gaussI=0, gaussI2=8
// hence the fraction sobelX/sqrt(16*gaussI2-gaussI*gaussI)=1/sqrt(2)
// The assembler code implicitly multiplies with 2^(5-16), so
// to get the desired CNSResponse::SCALE, we multiply with
__m128 scaleF = _mm_set1_ps(CNSResponse::SCALE / std::pow(2.f, 5.f - 16.f) * std::sqrt(2.f));
// Buffers for intermediate values for two lines
alignas(16) IntermediateValues iv[2][Image::maxResolutionWidth / 8]; // always 8 Pixel in one IntermediateValues object
ASSERT((reinterpret_cast<size_t>(cns) & 0xf) == 0);
int srcY = 0; // line in the source image
// *** Go through two lines to fill up the intermediate Buffers
// This is exactly the same code as below apart from the final computations being removed
ASSERT(intptr_t(src) % 16 == 0);
ASSERT(srcOfs % 8 == 0);
ASSERT(width % 8 == 0);
for(int i = 0; i < 2; ++i, ++srcY)
{
IntermediateValues* ivCurrent = &iv[srcY & 1][0];
IntermediateValues* ivLast = &iv[1 - (srcY & 1)][0];
const __m128i* pStart = reinterpret_cast<const __m128i*>(src + srcY * srcOfs - (srcY * srcOfs % 16 != 0 ? 8 : 0));
const __m128i* pEnd = (pStart + width / 16) + (srcY * srcOfs % 16 != 0 ? 1 : 0);
__m128i lastSrc, src;
const __m128i* p = pStart;
lastSrc = src = _mm_load_si128(p); //TODO change me (prev)
for(; p != pEnd; ++ivCurrent, ++ivLast)
{
__m128i imgL, img, imgR;
__m128i imgL2, img2, imgR2;
load2x8PixelUsingSSE(imgL, img, imgR, imgL2, img2, imgR2, lastSrc, src, ++p);
filters(*ivCurrent, *ivLast, imgL, img, imgR);
filters(*(++ivCurrent), *(++ivLast), imgL2, img2, imgR2);
}
}
// **** Now continue until the end of the image
int yEnd = height;
for(; srcY != yEnd; ++srcY)
{
IntermediateValues* ivCurrent = &iv[srcY & 1][0];
IntermediateValues* ivLast = &iv[1 - (srcY & 1)][0];
const __m128i* pStart = reinterpret_cast<const __m128i*>(src + srcY * srcOfs);
const __m128i* pEnd = (pStart + width / 16);
short* myCns = cns + (srcY - 1) * srcOfs;
__m128i lastSrc, src;
const __m128i* p = pStart;
lastSrc = src = _mm_load_si128(p); //TODO change me (prev)
for(; p < pEnd; ++ivCurrent, ++ivLast, myCns += 8)
{
__m128i imgL, img, imgR;
__m128i imgL2, img2, imgR2;
__m128i sobelX, sobelY, gaussI;
__m128 gaussI2A, gaussI2B;
load2x8PixelUsingSSE(imgL, img, imgR, imgL2, img2, imgR2, lastSrc, src, ++p);
filters(*ivCurrent, *ivLast, sobelX, sobelY, gaussI, gaussI2A, gaussI2B, imgL, img, imgR);
cnsFormula(*reinterpret_cast<__m128i*>(myCns), sobelX, sobelY, gaussI, gaussI2A, gaussI2B, scaleF, regVarF, offset);
filters(*(++ivCurrent), *(++ivLast), sobelX, sobelY, gaussI, gaussI2A, gaussI2B, imgL2, img2, imgR2);
cnsFormula(*reinterpret_cast<__m128i*>(myCns += 8), sobelX, sobelY, gaussI, gaussI2A, gaussI2B, scaleF, regVarF, offset);
}
// Left and right margin: set cns to offset (means 0) and ds to the source pixel
myCns[-1] = myCns[-width] = static_cast<short>(static_cast<unsigned short>(CNSResponse::OFFSET + (CNSResponse::OFFSET << 8)));
}
// **** Finally set the top and bottom margin in the cns output if necessary
fillWithCNSOffsetUsingSSE(cns, width);
fillWithCNSOffsetUsingSSE(cns + (height - 1) * srcOfs, width);
}