From patchwork Tue Mar 20 09:41:17 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tristan Gingold X-Patchwork-Id: 147772 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id B144AB6EF4 for ; Tue, 20 Mar 2012 20:41:50 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1332841311; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:From:Content-Type:Content-Transfer-Encoding:Subject: Date:Message-Id:To:Mime-Version:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=pJClC5pBNps9xyubcNgARtEoABw=; b=soDembkQXS6xXci HRbkzF9WPuwtMH50hVC/xhME9TF8rJXE+5+hb9TIubc3pw48AbHXrhoqphEPHyI1 sfDMQ0Qofx5Vpw4xoJU1HlZ46xQOvViSrtiVtlDY4pLEp2YO824B/YO2ZcptuaPk C2i52aeP+0Qsr/xxXGnzVEQNGrjE= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:From:Content-Type:Content-Transfer-Encoding:Subject:Date:Message-Id:To:Mime-Version:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=Hq1errGoguF+deNVVjog8SrcIISsjNiULYLdYIgYAgG/TuLcAMgeUxzulkenXF MRERWakTapabScvesKYFizpUHw0mzUszuIiPTlUx8oNbINm1wH9ZoE6RdONNa4WG E1xOy5SxSg61IUOrYBUb3ozMKoUy8OpS3kj6GSriO/PkM=; Received: (qmail 17688 invoked by alias); 20 Mar 2012 09:41:43 -0000 Received: (qmail 17676 invoked by uid 22791); 20 Mar 2012 09:41:41 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (194.98.77.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 20 Mar 2012 09:41:18 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 1C3E129003B for ; Tue, 20 Mar 2012 10:41:20 +0100 (CET) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2RMSSus7RrIW for ; Tue, 20 Mar 2012 10:41:20 +0100 (CET) Received: from ulanbator.act-europe.fr (ulanbator.act-europe.fr [10.10.1.67]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id 09F7F290035 for ; Tue, 20 Mar 2012 10:41:20 +0100 (CET) From: Tristan Gingold Subject: [Patch]: ggc-page.c: use uintptr_t instead of size_t Date: Tue, 20 Mar 2012 10:41:17 +0100 Message-Id: <1D19B2AB-617E-4C04-8F07-9940C1F47685@adacore.com> To: GCC Patches Mime-Version: 1.0 (Apple Message framework v1257) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hi, ggc-page.c uses size_t to cast pointers to an integer type. Unfortunately, this isn't portable for systems (such as … VMS) where size_t precision is less than pointers precision. Fortunately, thanks to configure, uintptr_t type is always present, so this path simply replaces size_t by uintptr_t for such conversions (but still keeping size_t for size expressions). I haven't tried to convert ggc-zone.c, because it requires mmap (which is not usable as is on VMS). Tested by cross bootstrapping for VMS. Ok for trunk ? Tristan. gcc/ 2012-03-20 Tristan Gingold * ggc-page.c (PAGE_L1_SIZE, PAGE_L2_SIZE, LOOKUP_L1, LOOKUP_L2) (ggc_allocated_p, lookup_page_table_entry, set_page_table_entry) (alloc_page, init_ggc, clear_marks, struct ggc_pch_data) (ggc_pch_this_base): Use uintptr_t instead of size_t. diff --git a/gcc/ggc-page.c b/gcc/ggc-page.c index ee796cb..ff23092 100644 --- a/gcc/ggc-page.c +++ b/gcc/ggc-page.c @@ -121,14 +121,14 @@ along with GCC; see the file COPYING3. If not see #define PAGE_L1_BITS (8) #define PAGE_L2_BITS (32 - PAGE_L1_BITS - G.lg_pagesize) -#define PAGE_L1_SIZE ((size_t) 1 << PAGE_L1_BITS) -#define PAGE_L2_SIZE ((size_t) 1 << PAGE_L2_BITS) +#define PAGE_L1_SIZE ((uintptr_t) 1 << PAGE_L1_BITS) +#define PAGE_L2_SIZE ((uintptr_t) 1 << PAGE_L2_BITS) #define LOOKUP_L1(p) \ - (((size_t) (p) >> (32 - PAGE_L1_BITS)) & ((1 << PAGE_L1_BITS) - 1)) + (((uintptr_t) (p) >> (32 - PAGE_L1_BITS)) & ((1 << PAGE_L1_BITS) - 1)) #define LOOKUP_L2(p) \ - (((size_t) (p) >> G.lg_pagesize) & ((1 << PAGE_L2_BITS) - 1)) + (((uintptr_t) (p) >> G.lg_pagesize) & ((1 << PAGE_L2_BITS) - 1)) /* The number of objects per allocation page, for objects on a page of the indicated ORDER. */ @@ -560,7 +560,7 @@ ggc_allocated_p (const void *p) base = &G.lookup[0]; #else page_table table = G.lookup; - size_t high_bits = (size_t) p & ~ (size_t) 0xffffffff; + uintptr_t high_bits = (uintptr_t) p & ~ (uintptr_t) 0xffffffff; while (1) { if (table == NULL) @@ -592,7 +592,7 @@ lookup_page_table_entry (const void *p) base = &G.lookup[0]; #else page_table table = G.lookup; - size_t high_bits = (size_t) p & ~ (size_t) 0xffffffff; + uintptr_t high_bits = (uintptr_t) p & ~ (uintptr_t) 0xffffffff; while (table->high_bits != high_bits) table = table->next; base = &table->table[0]; @@ -617,7 +617,7 @@ set_page_table_entry (void *p, page_entry *entry) base = &G.lookup[0]; #else page_table table; - size_t high_bits = (size_t) p & ~ (size_t) 0xffffffff; + uintptr_t high_bits = (uintptr_t) p & ~ (uintptr_t) 0xffffffff; for (table = G.lookup; table; table = table->next) if (table->high_bits == high_bits) goto found; @@ -826,7 +826,7 @@ alloc_page (unsigned order) alloc_size = entry_size + G.pagesize - 1; allocation = XNEWVEC (char, alloc_size); - page = (char *) (((size_t) allocation + G.pagesize - 1) & -G.pagesize); + page = (char *) (((uintptr_t) allocation + G.pagesize - 1) & -G.pagesize); head_slop = page - allocation; if (multiple_pages) tail_slop = ((size_t) allocation + alloc_size) & (G.pagesize - 1); @@ -1662,13 +1662,13 @@ init_ggc (void) { char *p = alloc_anon (NULL, G.pagesize, true); struct page_entry *e; - if ((size_t)p & (G.pagesize - 1)) + if ((uintptr_t)p & (G.pagesize - 1)) { /* How losing. Discard this one and try another. If we still can't get something useful, give up. */ p = alloc_anon (NULL, G.pagesize, true); - gcc_assert (!((size_t)p & (G.pagesize - 1))); + gcc_assert (!((uintptr_t)p & (G.pagesize - 1))); } /* We have a good page, might as well hold onto it... */ @@ -1782,7 +1782,7 @@ clear_marks (void) size_t bitmap_size = BITMAP_SIZE (num_objects + 1); /* The data should be page-aligned. */ - gcc_assert (!((size_t) p->page & (G.pagesize - 1))); + gcc_assert (!((uintptr_t) p->page & (G.pagesize - 1))); /* Pages that aren't in the topmost context are not collected; nevertheless, we need their in-use bit vectors to store GC @@ -2204,7 +2204,7 @@ struct ggc_pch_ondisk struct ggc_pch_data { struct ggc_pch_ondisk d; - size_t base[NUM_ORDERS]; + uintptr_t base[NUM_ORDERS]; size_t written[NUM_ORDERS]; }; @@ -2247,7 +2247,7 @@ ggc_pch_total_size (struct ggc_pch_data *d) void ggc_pch_this_base (struct ggc_pch_data *d, void *base) { - size_t a = (size_t) base; + uintptr_t a = (uintptr_t) base; unsigned i; for (i = 0; i < NUM_ORDERS; i++)