Re: [PATCH 09/16] Read index-v5
- From
Thomas Gummerer <t.gummerer@gmail.com>
- Date
- Aug 2, 2012, 14:04 UTC
- Message-ID
- <20120802140453.GC1000@tgummerer.unibz.it>
- In-Reply-To
- <CACsJy8Co8warnQg+fKmXnO_wt=dTPBjRRe+Apic6-GBrTr_3rg@mail.gmail.com>
On 08/02, Nguyen Thai Ngoc Duy wrote:
> General note. I wonder if we should create a separate source file for > v5 (at least the low level handling part). Partial reading/writing > will come (hopefully soon) and read-cache.c on master is already close > to 2000 lines.
To me it would make sense, but we'd probably have to split it to at least 3 files, one for index-v2, one for index-v5 and one for the general functions/api.
Show 13 quoted lines
> On Thu, Aug 2, 2012 at 6:01 PM, Thomas Gummerer <t.gummerer@gmail.com> wrote:
> > +static struct cache_entry *cache_entry_from_ondisk_v5(struct ondisk_cache_entry_v5 *ondisk,
> > + struct directory_entry *de,
> > + char *name,
> > + size_t len,
> > + size_t prefix_len)
> > +{
> > + struct cache_entry *ce = xmalloc(cache_entry_size(len + de->de_pathlen));
> > + int flags;
> > +
> > + flags = ntoh_s(ondisk->flags);
>
> huh? ntoh_s (and ntoh_l below)? search/replace problem?No, they are correct, Junio introduced this functions with index-v4 for systems which need aligned access. They are defined as written below.
Show 21 quoted lines
> #ifndef NEEDS_ALIGNED_ACCESS
> #define ntoh_s(var) ntohs(var)
> #define ntoh_l(var) ntohl(var)
> #else
> static inline uint16_t ntoh_s_force_align(void *p)
> {
> uint16_t x;
> memcpy(&x, p, sizeof(x));
> return ntohs(x);
> }
> static inline uint32_t ntoh_l_force_align(void *p)
> {
> uint32_t x;
> memcpy(&x, p, sizeof(x));
> return ntohl(x);
> }
> #define ntoh_s(var)
> ntoh_s_force_align(&(var))
> #define ntoh_l(var)
> ntoh_l_force_align(&(var))
> #endif> > + ce->ce_ctime.sec = 0; > > + ce->ce_mtime.sec = ntoh_l(ondisk->mtime.sec); > -- > Duy