git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Shawn O. Pearce" <spearce@spearce.org>
To: Simon 'corecode' Schubert <corecode@fs.ei.tum.de>
Cc: Morten Welinder <mwelinder@gmail.com>,
	Junio C Hamano <junkio@cox.net>,
	git@vger.kernel.org
Subject: Re: [PATCH 2/2] Use fixed-size integers for .idx file I/O
Date: Thu, 18 Jan 2007 10:21:08 -0500	[thread overview]
Message-ID: <20070118152107.GA15428@spearce.org> (raw)
In-Reply-To: <45AF8A86.7070101@fs.ei.tum.de>

Simon 'corecode' Schubert <corecode@fs.ei.tum.de> wrote:
> Morten Welinder wrote:
> >>-                       return ntohl(*((unsigned int *) ((char *) 
> >>index + (24 * mi))));
> >>+                       return ntohl(*((uint32_t *)((char *)index + 
> >>(24 * mi))));
> >
> >Is that pointer gymnastics guaranteed to work?  I.e., how do we know
> >that we can access an uint32_t (or unsigned) at such an address?
> 
> if index is always aligned to a 4-byte boundary, this is safe.  apart from 
> that, the problem already existed.

Its always 4-byte aligned here.  The index is mmap()'d as one huge
chunk so the first byte of the index is page aligned.  The index
starts out with 256 4-byte words, then is composed of 24 byte units
(20 byte SHA1, 4 byte offset).  So no worries with the current file
format, or code.

Yes, we're taking the leap of faith that any currently-used processor
will work on 32 bit unsigned integers if they are 4 byte aligned in
memory.  Maybe someone has a processor that this isn't true for, but
a lot of other software would probably break on that same system...

-- 
Shawn.

  parent reply	other threads:[~2007-01-18 15:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-18  7:24 [PATCH 2/2] Use fixed-size integers for .idx file I/O Junio C Hamano
2007-01-18 14:51 ` Morten Welinder
2007-01-18 14:56   ` Simon 'corecode' Schubert
2007-01-18 15:15     ` Johannes Schindelin
2007-01-18 15:21     ` Shawn O. Pearce [this message]
2007-01-18 15:30       ` Johannes Schindelin

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=20070118152107.GA15428@spearce.org \
    --to=spearce@spearce.org \
    --cc=corecode@fs.ei.tum.de \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    --cc=mwelinder@gmail.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).