Tarantool development patches archive
 help / color / mirror / Atom feed
From: "Timur Safin" <tsafin@tarantool.org>
To: 'Vladislav Shpilevoy' <v.shpilevoy@tarantool.org>,
	tarantool-patches@dev.tarantool.org, alyapunov@tarantool.org,
	gorcunov@gmail.com
Subject: Re: [Tarantool-patches] [PATCH v2 small 1/1] lsregion: introduce aligned alloc
Date: Tue, 19 May 2020 19:21:38 +0300	[thread overview]
Message-ID: <36fa01d62df9$94ec0250$bec406f0$@tarantool.org> (raw)
In-Reply-To: <194d73cbb844795fbe2a9a6599bb684f4e6a0cf2.1589584903.git.v.shpilevoy@tarantool.org>

Other than small note below it's looking great, but please keep in mind...

: From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
: Subject: [PATCH v2 small 1/1] lsregion: introduce aligned alloc
: 


: @@ -32,59 +32,62 @@
:  #include "lsregion.h"
: 
:  void *
: -lsregion_alloc_slow(struct lsregion *lsregion, size_t size, int64_t id)
: +lsregion_aligned_reserve_slow(struct lsregion *lsregion, size_t size,
: +			      size_t alignment, void **unaligned)
:  {
: -	struct lslab *slab = NULL;
: -	size_t slab_size = lsregion->arena->slab_size;
: +	void *pos;
: +	struct lslab *slab;
: +	struct slab_arena *arena = lsregion->arena;
: +	size_t slab_size = arena->slab_size;
: 
:  	/* If there is an existing slab then try to use it. */
:  	if (! rlist_empty(&lsregion->slabs.slabs)) {
:  		slab = rlist_last_entry(&lsregion->slabs.slabs, struct lslab,
:  					next_in_list);
:  		assert(slab != NULL);
: +		*unaligned = lslab_pos(slab);
: +		pos = (void *)small_align((size_t)*unaligned, alignment);
: +		if (pos + size <= lslab_end(slab))
: +			return pos;

Void* pointer arithmetic is non-standard, gcc extension, and I'd 
avoid to use it in a longer run. There are compilers is which still 
not support it. 

Timur

  parent reply	other threads:[~2020-05-19 16:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-15 23:21 Vladislav Shpilevoy
2020-05-19 16:16 ` Aleksandr Lyapunov
2020-05-19 16:21 ` Timur Safin [this message]
2020-05-19 21:29   ` Vladislav Shpilevoy
2020-05-19 21:48     ` Timur Safin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='36fa01d62df9$94ec0250$bec406f0$@tarantool.org' \
    --to=tsafin@tarantool.org \
    --cc=alyapunov@tarantool.org \
    --cc=gorcunov@gmail.com \
    --cc=tarantool-patches@dev.tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v2 small 1/1] lsregion: introduce aligned alloc' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox