From patchwork Mon Aug 4 11:04:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 376244 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 6BBA4140077 for ; Mon, 4 Aug 2014 21:04:20 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=HyBx9zRkwlyNPMxhXW1pJsStRJ/r0x9vlUdzpsDz4E0djKsL7SBw/ gAJcqXAkZXP9Jmqt7O+5r9BZDpqPT68Cqfiw0X6eH7YQP3Uk4K1kYf1Rq5DyuB4F kM6p0HvXCtwEz1gZIANuH2e2T1Zn+oGCveLk8HrYN7tpU2IRoVxZjQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=prLMxCCCcquoUOKaN/UAcW9SW1s=; b=UOI4TSZ/U+WVmPMWDrLZ GTcjFC5k2YIwzb6P9+SN+k/t3cf6Gq22/AmB6g4fVXbV4FR2meGmz3HlFYU3w8t7 m1DLBmTFIDs0v+T8YRCr1twQfA4fazt11P3f/pwelqq9FCtCLDeDGmpuMqeYvJlj NXNavGFTX2+2GqSId7to9ow= Received: (qmail 24024 invoked by alias); 4 Aug 2014 11:04:13 -0000 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 Received: (qmail 24008 invoked by uid 89); 4 Aug 2014 11:04:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f46.google.com Received: from mail-pa0-f46.google.com (HELO mail-pa0-f46.google.com) (209.85.220.46) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 04 Aug 2014 11:04:10 +0000 Received: by mail-pa0-f46.google.com with SMTP id lj1so9796686pab.19 for ; Mon, 04 Aug 2014 04:04:08 -0700 (PDT) X-Received: by 10.66.141.76 with SMTP id rm12mr1461153pab.138.1407150248473; Mon, 04 Aug 2014 04:04:08 -0700 (PDT) Received: from bubble.grove.modra.org (CPE-58-160-155-134.oycza5.sa.bigpond.net.au. [58.160.155.134]) by mx.google.com with ESMTPSA id f16sm26218532pdm.43.2014.08.04.04.04.06 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 04 Aug 2014 04:04:07 -0700 (PDT) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id 395BEEA3744; Mon, 4 Aug 2014 20:34:03 +0930 (CST) Date: Mon, 4 Aug 2014 20:34:03 +0930 From: Alan Modra To: gcc-patches@gcc.gnu.org Subject: Prepare gcc for 64-bit obstacks Message-ID: <20140804110403.GA8921@bubble.grove.modra.org> Mail-Followup-To: gcc-patches@gcc.gnu.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Two small changes to gcc code to support newer obstacks: 1) gcc currently calls _obstack_begin, which requires some ugly casts on alloc and free functions, and the casts will change when/if 64-bit obstacks are available. It's cleaner to use the convenience functions provided in obstack.h. 2) Current upstream obstack.h makes obstack_base() return a void*, with the result that a few places in gcc need a (char *) cast. Bootstrapped and regression tested x86_64-linux and powerpc-linux, with both the new obstack.{h,c} and the old versions. OK to apply? gcc/ * gengtype.h (obstack_chunk_alloc, obstack_chunk_free): Remove cast. * coretypes.h (obstack_chunk_alloc, obstack_chunk_free): Likewise. (gcc_obstack_init): Use obstack_specify_allocation in place of _obstack_begin. * genautomata.c (next_sep_el): Cast result of obstack_base to (char *). (regexp_representation): Likewise. * godump.c (go_output_type): Likewise. gcc/java/ * mangle.c (finish_mangling): Cast result of obstack_base to (char *). * typeck.c (build_java_argument_signature): Likewise. (build_java_signature): Likewise. gcc/objc/ * objc-encoding.c (encode_array): Cast result of obstack_base. (encode_type): Likewise. libcpp/ * symtab.c (ht_create): Use obstack_specify_allocation in place of _obstack_begin. * files.c (_cpp_init_files): Likewise. * init.c (cpp_create_reader): Likewise. * identifiers.c (_cpp_init_hashtable): Likewise. Index: gcc/gengtype.h =================================================================== --- gcc/gengtype.h (revision 212477) +++ gcc/gengtype.h (working copy) @@ -20,8 +20,8 @@ #ifndef GCC_GENGTYPE_H #define GCC_GENGTYPE_H -#define obstack_chunk_alloc ((void *(*) (long)) xmalloc) -#define obstack_chunk_free ((void (*) (void *)) free) +#define obstack_chunk_alloc xmalloc +#define obstack_chunk_free free #define OBSTACK_CHUNK_SIZE 0 /* Sets of accepted source languages like C, C++, Ada... are Index: gcc/coretypes.h =================================================================== --- gcc/coretypes.h (revision 212477) +++ gcc/coretypes.h (working copy) @@ -158,13 +158,13 @@ struct basic_block_def; typedef struct basic_block_def *basic_block; typedef const struct basic_block_def *const_basic_block; -#define obstack_chunk_alloc ((void *(*) (long)) xmalloc) -#define obstack_chunk_free ((void (*) (void *)) free) +#define obstack_chunk_alloc xmalloc +#define obstack_chunk_free free #define OBSTACK_CHUNK_SIZE 0 -#define gcc_obstack_init(OBSTACK) \ - _obstack_begin ((OBSTACK), OBSTACK_CHUNK_SIZE, 0, \ - obstack_chunk_alloc, \ - obstack_chunk_free) +#define gcc_obstack_init(OBSTACK) \ + obstack_specify_allocation ((OBSTACK), OBSTACK_CHUNK_SIZE, 0, \ + obstack_chunk_alloc, \ + obstack_chunk_free) /* enum reg_class is target specific, so it should not appear in target-independent code or interfaces, like the target hook declarations Index: gcc/genautomata.c =================================================================== --- gcc/genautomata.c (revision 212477) +++ gcc/genautomata.c (working copy) @@ -1178,7 +1178,7 @@ next_sep_el (const char **pstr, int sep, int par_f } } obstack_1grow (&irp, '\0'); - out_str = obstack_base (&irp); + out_str = (char *) obstack_base (&irp); obstack_finish (&irp); *pstr = p; @@ -6873,7 +6873,7 @@ regexp_representation (regexp_t regexp) { form_regexp (regexp); obstack_1grow (&irp, '\0'); - return obstack_base (&irp); + return (char *) obstack_base (&irp); } /* The function frees memory allocated for last formed string @@ -9289,7 +9289,7 @@ initiate_automaton_gen (char **argv) obstack_grow (&irp, STANDARD_OUTPUT_DESCRIPTION_FILE_SUFFIX, strlen (STANDARD_OUTPUT_DESCRIPTION_FILE_SUFFIX) + 1); obstack_1grow (&irp, '\0'); - output_description_file_name = obstack_base (&irp); + output_description_file_name = (char *) obstack_base (&irp); obstack_finish (&irp); } Index: gcc/godump.c =================================================================== --- gcc/godump.c (revision 212477) +++ gcc/godump.c (working copy) @@ -921,7 +921,7 @@ go_output_type (struct godump_container *container ob = &container->type_obstack; obstack_1grow (ob, '\0'); - fputs (obstack_base (ob), go_dump_file); + fputs ((char *) obstack_base (ob), go_dump_file); obstack_free (ob, obstack_base (ob)); } Index: gcc/java/mangle.c =================================================================== --- gcc/java/mangle.c (revision 212477) +++ gcc/java/mangle.c (working copy) @@ -711,7 +711,7 @@ finish_mangling (void) compression_table = NULL_TREE; compression_next = 0; obstack_1grow (mangle_obstack, '\0'); - result = get_identifier (obstack_base (mangle_obstack)); + result = get_identifier ((char *) obstack_base (mangle_obstack)); obstack_free (mangle_obstack, obstack_base (mangle_obstack)); return result; Index: gcc/java/typeck.c =================================================================== --- gcc/java/typeck.c (revision 212477) +++ gcc/java/typeck.c (working copy) @@ -477,7 +477,7 @@ build_java_argument_signature (tree type) } obstack_1grow (&temporary_obstack, '\0'); - sig = get_identifier (obstack_base (&temporary_obstack)); + sig = get_identifier ((char *) obstack_base (&temporary_obstack)); TYPE_ARGUMENT_SIGNATURE (type) = sig; obstack_free (&temporary_obstack, obstack_base (&temporary_obstack)); } @@ -554,7 +554,7 @@ build_java_signature (tree type) obstack_grow0 (&temporary_obstack, IDENTIFIER_POINTER (t), IDENTIFIER_LENGTH (t)); - sig = get_identifier (obstack_base (&temporary_obstack)); + sig = get_identifier ((char *) obstack_base (&temporary_obstack)); obstack_free (&temporary_obstack, obstack_base (&temporary_obstack)); } Index: gcc/objc/objc-encoding.c =================================================================== --- gcc/objc/objc-encoding.c (revision 212477) +++ gcc/objc/objc-encoding.c (working copy) @@ -380,7 +380,7 @@ encode_array (tree type, int curtype, int format) identifier. */ { - char *enc = obstack_base (&util_obstack) + curtype; + char *enc = (char *) obstack_base (&util_obstack) + curtype; if (memchr (enc, '=', obstack_object_size (&util_obstack) - curtype) == NULL) { @@ -729,7 +729,7 @@ encode_type (tree type, int curtype, int format) to be rearranged for compatibility with gcc-3.3. */ if (code == POINTER_TYPE && obstack_object_size (&util_obstack) >= 3) { - char *enc = obstack_base (&util_obstack) + curtype; + char *enc = (char *) obstack_base (&util_obstack) + curtype; /* Rewrite "in const" from "nr" to "rn". */ if (curtype >= 1 && !strncmp (enc - 1, "nr", 2)) Index: libcpp/symtab.c =================================================================== --- libcpp/symtab.c (revision 212477) +++ libcpp/symtab.c (working copy) @@ -61,9 +61,7 @@ ht_create (unsigned int order) table = XCNEW (cpp_hash_table); /* Strings need no alignment. */ - _obstack_begin (&table->stack, 0, 0, - (void *(*) (long)) xmalloc, - (void (*) (void *)) free); + obstack_specify_allocation (&table->stack, 0, 0, xmalloc, free); obstack_alignment_mask (&table->stack) = 0; Index: libcpp/files.c =================================================================== --- libcpp/files.c (revision 212477) +++ libcpp/files.c (working copy) @@ -1267,9 +1267,8 @@ _cpp_init_files (cpp_reader *pfile) pfile->nonexistent_file_hash = htab_create_alloc (127, htab_hash_string, nonexistent_file_hash_eq, NULL, xcalloc, free); - _obstack_begin (&pfile->nonexistent_file_ob, 0, 0, - (void *(*) (long)) xmalloc, - (void (*) (void *)) free); + obstack_specify_allocation (&pfile->nonexistent_file_ob, 0, 0, + xmalloc, free); } /* Finalize everything in this source file. */ Index: libcpp/init.c =================================================================== --- libcpp/init.c (revision 212477) +++ libcpp/init.c (working copy) @@ -260,9 +260,7 @@ cpp_create_reader (enum c_lang lang, cpp_hash_tabl _cpp_expand_op_stack (pfile); /* Initialize the buffer obstack. */ - _obstack_begin (&pfile->buffer_ob, 0, 0, - (void *(*) (long)) xmalloc, - (void (*) (void *)) free); + obstack_specify_allocation (&pfile->buffer_ob, 0, 0, xmalloc, free); _cpp_init_files (pfile); Index: libcpp/identifiers.c =================================================================== --- libcpp/identifiers.c (revision 212477) +++ libcpp/identifiers.c (working copy) @@ -54,9 +54,7 @@ _cpp_init_hashtable (cpp_reader *pfile, cpp_hash_t table = ht_create (13); /* 8K (=2^13) entries. */ table->alloc_node = alloc_node; - _obstack_begin (&pfile->hash_ob, 0, 0, - (void *(*) (long)) xmalloc, - (void (*) (void *)) free); + obstack_specify_allocation (&pfile->hash_ob, 0, 0, xmalloc, free); } table->pfile = pfile;