{"id":485295,"date":"2026-06-28T02:50:35","date_gmt":"2026-06-28T02:50:35","guid":{"rendered":"https:\/\/savepearlharbor.com\/?p=485295"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=485295","title":{"rendered":"OSDEV: \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0430\u043b\u043b\u043e\u043a\u0430\u0442\u043e\u0440\u0430 \u043d\u0430 \u0421++ \u0447\u0430\u0441\u0442\u044c 5. osdev-libstdc"},"content":{"rendered":"<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width \"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/bfb\/6ee\/737\/bfb6ee737010a996381aeeb878f6fc66.png\" width=\"1536\" height=\"1024\" sizes=\"auto, (max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/getpro\/habr\/upload_files\/bfb\/6ee\/737\/bfb6ee737010a996381aeeb878f6fc66.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/bfb\/6ee\/737\/bfb6ee737010a996381aeeb878f6fc66.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u041f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e!<\/p>\n<p>\u042d\u0442\u043e \u043e\u0431\u0437\u043e\u0440\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0430 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u0441\u043e\u0432\u0441\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u0430\u044f. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0443\u0436\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 <a href=\"https:\/\/habr.com\/ru\/articles\/1047178\/\" rel=\"noopener noreferrer nofollow\">\u0430\u043b\u043b\u043e\u043a\u0430\u0442\u043e\u0440<\/a>. \u042f \u043b\u0438\u0448\u044c \u0441\u0442\u0430\u0432\u043b\u044e \u0432 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u0441\u0442\u044c \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0435\u0439 \u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0438 \u0432 <a href=\"https:\/\/github.com\/GNUDimarik\/osdev-libstdc\" rel=\"noopener noreferrer nofollow\">osdev-libstdc<\/a> \u0432\u043f\u043e\u043b\u043d\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 aligned_alloc, malloc, calloc, realloc \u0438 free. \u0418\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u0430:<\/p>\n<pre><code class=\"cpp\">namespace{static dux::spin_lock gLock;}__MAYBE_BEGIN_STD_NAMESPACEvoid *aligned_alloc(size_t alignment, size_t size){    __STD_NAMESPACE::lock_guard g(gLock);    return mem_malloc_aligned(alignment, size);}void *calloc(size_t num, size_t size){    __STD_NAMESPACE::lock_guard g(gLock);    return mem_calloc(num, size);}void free(void *ptr){    __STD_NAMESPACE::lock_guard g(gLock);    mem_free(ptr);}void *malloc(size_t size){    __STD_NAMESPACE::lock_guard g(gLock);    return mem_malloc(size);}void *realloc(void *ptr, size_t new_size){    __STD_NAMESPACE::lock_guard g(gLock);    return mem_realloc(ptr, new_size);}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:87px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0414\u0443\u043c\u0430\u044e \u043d\u0430 \u044d\u0442\u043e\u043c \u044f \u043c\u043e\u0433\u0443 \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0436\u0438\u0440\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443 \u043d\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0430\u043b\u043b\u043e\u043a\u0430\u0442\u043e\u0440\u0430 \u0434\u043b\u044f malloc \u0434\u043b\u044f \u0441\u0432\u043e\u0439 \u041e\u0421.<\/p>\n<p>\u0414\u0430\u043b\u044c\u0448\u0435 \u0443\u0436\u0435 \u043f\u0438\u0448\u0435\u043c ABI \u0441 \u0447\u0430\u0441\u0442\u044f\u043c\u0438 <a href=\"https:\/\/github.com\/libcxxrt\/libcxxrt\" rel=\"noopener noreferrer nofollow\">libcxxrt<\/a>. \u0414\u0443\u043c\u0430\u044e \u0434\u0430\u0436\u0435 demangler \u043f\u0440\u0438\u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0431\u0435\u0437 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 \u0442\u0430\u043a\u043e\u0439 osdev-libstdc &#8230;<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 new\/delete.<\/p>\n<p>\u0414\u043e \u043d\u043e\u0432\u044b\u0445 \u0432\u0441\u0442\u0440\u0435\u0447!<\/p>\n<\/div>\n<p>\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/1052784\/\">https:\/\/habr.com\/ru\/articles\/1052784\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e!\u042d\u0442\u043e \u043e\u0431\u0437\u043e\u0440\u043d\u0430\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u043d\u0430 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u0441\u043e\u0432\u0441\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u0430\u044f. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0443\u0436\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u0430\u043b\u043b\u043e\u043a\u0430\u0442\u043e\u0440. \u042f \u043b\u0438\u0448\u044c \u0441\u0442\u0430\u0432\u043b\u044e \u0432 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u0441\u0442\u044c \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0435\u0439 \u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0438 \u0432 osdev-libstdc \u0432\u043f\u043e\u043b\u043d\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 aligned_alloc, malloc, calloc, realloc \u0438 free. \u0418\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u043d\u0430:namespace{static dux::spin_lock gLock;}__MAYBE_BEGIN_STD_NAMESPACEvoid *aligned_alloc(size_t alignment, size_t size){    __STD_NAMESPACE::lock_guard g(gLock);    return mem_malloc_aligned(alignment, size);}void *calloc(size_t num, size_t size){    __STD_NAMESPACE::lock_guard g(gLock);    return mem_calloc(num, size);}void free(void *ptr){    __STD_NAMESPACE::lock_guard g(gLock);    mem_free(ptr);}void *malloc(size_t size){    __STD_NAMESPACE::lock_guard g(gLock);    return mem_malloc(size);}void *realloc(void *ptr, size_t new_size){    __STD_NAMESPACE::lock_guard g(gLock);    return mem_realloc(ptr, new_size);}\u0414\u0443\u043c\u0430\u044e \u043d\u0430 \u044d\u0442\u043e\u043c \u044f \u043c\u043e\u0433\u0443 \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0436\u0438\u0440\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443 \u043d\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0430\u043b\u043b\u043e\u043a\u0430\u0442\u043e\u0440\u0430 \u0434\u043b\u044f malloc \u0434\u043b\u044f \u0441\u0432\u043e\u0439 \u041e\u0421.\u0414\u0430\u043b\u044c\u0448\u0435 \u0443\u0436\u0435 \u043f\u0438\u0448\u0435\u043c ABI \u0441 \u0447\u0430\u0441\u0442\u044f\u043c\u0438 libcxxrt. \u0414\u0443\u043c\u0430\u044e \u0434\u0430\u0436\u0435 demangler \u043f\u0440\u0438\u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0431\u0435\u0437 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 \u0442\u0430\u043a\u043e\u0439 osdev-libstdc &#8230;\u0414\u0430\u043b\u0435\u0435 new\/delete.\u0414\u043e \u043d\u043e\u0432\u044b\u0445 \u0432\u0441\u0442\u0440\u0435\u0447!\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 https:\/\/habr.com\/ru\/articles\/1052784\/<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-485295","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/485295","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=485295"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/485295\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=485295"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=485295"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=485295"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}