• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ intptr_t函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中intptr_t函数的典型用法代码示例。如果您正苦于以下问题:C++ intptr_t函数的具体用法?C++ intptr_t怎么用?C++ intptr_t使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了intptr_t函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
    }
}
开发者ID:JoesephMother,项目名称:frameworks_base,代码行数:40,代码来源:MemoryDealerEclair.cpp


示例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();
  }
}
开发者ID:RemyYang,项目名称:FastHumanDetection,代码行数:22,代码来源:ui.cpp


示例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]);
    }
  }
开发者ID:FredChap,项目名称:myforthprocessor,代码行数:22,代码来源:bytes_sparc.hpp


示例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, &region) < 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;
}
开发者ID:CyanMobile,项目名称:android_device_huawei_u8800_cyanmobile,代码行数:39,代码来源:mapper.cpp


示例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
}
开发者ID:3dsfr3ak,项目名称:android_frameworks_native,代码行数:22,代码来源:MemoryHeapPmem.cpp


示例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;
}
开发者ID:zukisoft,项目名称:vm,代码行数:23,代码来源:LzopStreamReader.cpp


示例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;
}
开发者ID:Michaelangel007,项目名称:openclamdrenderer,代码行数:23,代码来源:OVR_String.cpp


示例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;
}
开发者ID:bobot,项目名称:CVC4.old-svn,代码行数:23,代码来源:memory_mapped_input_buffer.cpp


示例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;
}
开发者ID:Angels-group,项目名称:platform_hardware_imx,代码行数:23,代码来源:mapper.cpp


示例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;
}
开发者ID:tweakoz,项目名称:micro_ork,代码行数:23,代码来源:fixedvector.hpp


示例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);
    }
}
开发者ID:e0234,项目名称:android_frameworks_base,代码行数:37,代码来源:HWComposer.cpp


示例12:

c_Closure::~c_Closure() {
  // same as ar->hasThis()
  if (m_thisOrClass && !(intptr_t(m_thisOrClass) & 1LL)) {
    m_thisOrClass->decRefCount();
  }
}
开发者ID:HendrikGrunstra,项目名称:hiphop-php,代码行数:6,代码来源:ext_closure.cpp


示例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();
开发者ID:RemyYang,项目名称:FastHumanDetection,代码行数:67,代码来源:ui.cpp


示例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 = &sectors[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;
		}
	}
开发者ID:BadSanta1980,项目名称:gzdoom,代码行数:80,代码来源:p_udmf.cpp


示例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);
}
开发者ID:weilandetian,项目名称:Yoyo,代码行数:83,代码来源:CNSImageProvider.cpp


示例16: clear_address_bits

inline address       clear_address_bits(address x, int m)     { return address(intptr_t(x) & ~m); }
开发者ID:BaHbKaTX,项目名称:openjdk,代码行数:1,代码来源:globalDefinitions.hpp


示例17: set_address_bits

inline address       set_address_bits(address x, int m)       { return address(intptr_t(x) | m); }
开发者ID:BaHbKaTX,项目名称:openjdk,代码行数:1,代码来源:globalDefinitions.hpp


示例18: l

bool ConcurrentTableSharedStore::storeImpl(const String& key,
                                           const Variant& value,
                                           int64_t ttl,
                                           bool overwrite,
                                           bool limit_ttl) {
  StoreValue *sval;
  auto svar = APCHandle::Create(value, false, APCHandleLevel::Outer, false);
  auto keyLen = key.size();
  ReadLock l(m_lock);
  char* const kcp = strdup(key.data());
  bool present;
  time_t expiry = 0;
  bool overwritePrime = false;
  {
    Map::accessor acc;
    APCHandle* current = nullptr;
    present = !m_vars.insert(acc, kcp);
    sval = &acc->second;
    if (present) {
      free(kcp);
      if (!overwrite && !sval->expired()) {
        svar.handle->unreferenceRoot(svar.size);
        return false;
      }
      sval->data.match(
        [&] (APCHandle* handle) {
          current = handle;
          // If ApcTTLLimit is set, then only primed keys can have
          // expire == 0.
          overwritePrime = sval->expire == 0;
        },
        [&] (char*) {
          // Was inFile, but won't be anymore.
          sval->data = nullptr;
          sval->dataSize = 0;
          overwritePrime = true;
        }
      );
    } else {
      APCStats::getAPCStats().addKey(keyLen);
    }

    int64_t adjustedTtl = adjust_ttl(ttl, overwritePrime || !limit_ttl);
    if (check_noTTL(key.data(), key.size())) {
      adjustedTtl = 0;
    }

    if (current) {
      if (sval->expire == 0 && adjustedTtl != 0) {
        APCStats::getAPCStats().removeAPCValue(
          sval->dataSize, current, true, sval->expired());
        APCStats::getAPCStats().addAPCValue(svar.handle, svar.size, false);
      } else {
        APCStats::getAPCStats().updateAPCValue(
          svar.handle, svar.size, current, sval->dataSize,
          sval->expire == 0, sval->expired());
      }
      current->unreferenceRoot(sval->dataSize);
    } else {
      APCStats::getAPCStats().addAPCValue(svar.handle, svar.size, present);
    }

    sval->set(svar.handle, adjustedTtl);
    sval->dataSize = svar.size;
    expiry = sval->expire;
    if (expiry) {
      auto ikey = intptr_t(acc->first);
      if (m_expMap.insert({ ikey, 0 })) {
        m_expQueue.push({ ikey, expiry });
      }
    }
  }

  if (apcExtension::ExpireOnSets) {
    purgeExpired();
  }

  return true;
}
开发者ID:BruceZu,项目名称:hhvm,代码行数:79,代码来源:concurrent-shared-store.cpp


示例19: getpid

void BacktraceNames::FromAddr( const void *p )
{
    int fds[2];
    pid_t pid;
    pid_t ppid = getpid(); /* Do this before fork()ing! */
    
    Offset = 0;
    Address = intptr_t(p);

    if (pipe(fds) != 0)
    {
        fprintf(stderr, "FromAddr pipe() failed: %s\n", strerror(errno));
        return;
    }

    pid = fork();
    if (pid == -1)
    {
        fprintf(stderr, "FromAddr fork() failed: %s\n", strerror(errno));
        return;
    }

    if (pid == 0)
    {
        close(fds[0]);
        for (int fd = 3; fd < 1024; ++fd)
            if (fd != fds[1])
                close(fd);
        dup2(fds[1], fileno(stdout));
        close(fds[1]);

        char *addy;
        asprintf(&addy, "0x%x", long(p));
        char *p;
        asprintf(&p, "%d", ppid);

        execl("/usr/bin/atos", "/usr/bin/atos", "-p", p, addy, NULL);
        
        fprintf(stderr, "execl(atos) failed: %s\n", strerror(errno));
        free(addy);
        free(p);
        _exit(1);
    }
    
    close(fds[1]);
    char f[1024];
    bzero(f, 1024);
    int len = read(fds[0], f, 1024);

    Symbol = "";
    File = "";

    if (len == -1)
    {
        fprintf(stderr, "FromAddr read() failed: %s\n", strerror(errno));
        return;
    }
    CStringArray mangledAndFile;

    split(f, " ", mangledAndFile, true);
    if (mangledAndFile.size() == 0)
        return;
    Symbol = mangledAndFile[0];
    /* eg
     * -[NSApplication run]
     * +[SomeClass initialize]
     */
    if (Symbol[0] == '-' || Symbol[0] == '+')
    {
        Symbol = mangledAndFile[0] + " " + mangledAndFile[1];
        /* eg
         * (crt.c:300)
         * (AppKit)
         */
        if (mangledAndFile.size() == 3)
        {
            File = mangledAndFile[2];
            size_t pos = File.find('(');
            size_t start = (pos == File.npos ? 0 : pos+1);
            pos = File.rfind(')') - 1;
            File = File.substr(start, pos);
        }
        return;
    }
    /* eg
     * __start   -> _start
     * _SDL_main -> SDL_main
     */
    if (Symbol[0] == '_')
        Symbol = Symbol.substr(1);
    
    /* eg, the full line:
     * __Z1Ci (in a.out) (asmtest.cc:33)
     * _main (in a.out) (asmtest.cc:52)
     */
    if (mangledAndFile.size() > 3)
    {
        File = mangledAndFile[3];
        size_t pos = File.find('(');
        size_t start = (pos == File.npos ? 0 : pos+1);
//.........这里部分代码省略.........
开发者ID:Prcuvu,项目名称:StepMania-3.95,代码行数:101,代码来源:BacktraceNames.cpp


示例20: abstract_synth

sc_synth::sc_synth(int node_id, sc_synth_definition_ptr const & prototype):
    abstract_synth(node_id, prototype)
{
    World const & world = sc_factory->world;
    const bool rt_synthesis = world.mRealTime;

    mNode.mWorld = &sc_factory->world;
    rgen.init((uint32_t)(uint64_t)this);

    /* initialize sc wrapper class */
    mRGen = &rgen;
    mSubsampleOffset = world.mSubsampleOffset;
    mSampleOffset = world.mSampleOffset;
    mLocalAudioBusUnit = 0;
    mLocalControlBusUnit = 0;

    localBufNum = 0;
    localMaxBufNum = 0;

    mNode.mID = node_id;

    sc_synthdef const & synthdef = *prototype;

    const size_t parameter_count = synthdef.parameter_count();
    const size_t constants_count = synthdef.constants.size();

    /* we allocate one memory chunk */
    const size_t wire_buffer_alignment = 64 * 8; // align to cache line boundaries
    const size_t alloc_size = prototype->memory_requirement();

    const size_t sample_alloc_size = world.mBufLength * synthdef.buffer_count
        + wire_buffer_alignment /* for alignment */;

    const size_t total_alloc_size = alloc_size + sample_alloc_size*sizeof(sample);

    char * raw_chunk = rt_synthesis ? (char*)rt_pool.malloc(total_alloc_size)
                                    : (char*)malloc(total_alloc_size);

    if (raw_chunk == nullptr)
        throw std::bad_alloc();

    linear_allocator allocator(raw_chunk);

    /* prepare controls */
    mNumControls = parameter_count;
    mControls     = allocator.alloc<float>(parameter_count);
    mControlRates = allocator.alloc<int>(parameter_count);
    mMapControls  = allocator.alloc<float*>(parameter_count);

    /* initialize controls */
    for (size_t i = 0; i != parameter_count; ++i) {
        mControls[i] = synthdef.parameters[i]; /* initial parameters */
        mMapControls[i] = &mControls[i];       /* map to control values */
        mControlRates[i] = 0;                  /* init to 0*/
    }

    /* allocate constant wires */
    mWire = allocator.alloc<Wire>(constants_count);
    for (size_t i = 0; i != synthdef.constants.size(); ++i) {
        Wire * wire = mWire + i;
        wire->mFromUnit = 0;
        wire->mCalcRate = 0;
        wire->mBuffer = 0;
        wire->mScalarValue = get_constant(i);
    }

    unit_count = prototype->unit_count();
    calc_unit_count = prototype->calc_unit_count();
    units        = allocator.alloc<Unit*>(unit_count);
    calc_units   = allocator.alloc<Unit*>(calc_unit_count + 1); // over-allocate to allow prefetching
    unit_buffers = allocator.alloc<sample>(sample_alloc_size);

    const int alignment_mask = wire_buffer_alignment - 1;
    unit_buffers = (sample*) ((intptr_t(unit_buffers) + alignment_mask) & ~alignment_mask);     /* next aligned pointer */

    /* allocate unit generators */
    sc_factory->allocate_ugens(synthdef.graph.size());
    for (size_t i = 0; i != synthdef.graph.size(); ++i) {
        sc_synthdef::unit_spec_t const & spec = synthdef.graph[i];
        units[i] = spec.prototype->construct(spec, this, &sc_factory->world, allocator);
    }

    for (size_t i = 0; i != synthdef.calc_unit_indices.size(); ++i) {
        int32_t index = synthdef.calc_unit_indices[i];
        calc_units[i] = units[index];
    }

    assert((char*)mControls + alloc_size <= allocator.alloc<char>()); // ensure the memory boundaries
}
开发者ID:kulicuu,项目名称:supercollider,代码行数:89,代码来源:sc_synth.cpp



注:本文中的intptr_t函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ intr_context函数代码示例发布时间:2022-05-30
下一篇:
C++ impl_from_IHTMLXMLHttpRequest函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap