From patchwork Sun Nov 3 17:11:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Adhemerval Zanella (Code Review)" X-Patchwork-Id: 1188601 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-106564-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=gnutoolchain-gerrit.osci.io Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="bbuJZdfr"; dkim-atps=neutral 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 475jCz3Mtkz9sP4 for ; Mon, 4 Nov 2019 04:12:31 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:cc:message-id:subject:references :reply-to:mime-version:content-transfer-encoding:content-type; q=dns; s=default; b=l5B14d85G5n1M8rtrn/yeQka4dXEIKChiyDiDsEFPzY Kqfeg/zY/IlKhLepOB/wuBWpZDawKw2phPXCdTNcVf/zeLlBVDYFoYd3bLH8ZYTu V/tjhJ022cGV+HYafjkVxz2hkRhoKqZTjUx7nqNxN4w11l//1vQdFVIJAqE3VFus = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:cc:message-id:subject:references :reply-to:mime-version:content-transfer-encoding:content-type; s=default; bh=wczJcUQGo3/T5q7lWelV/1f1wxw=; b=bbuJZdfrCs/g+x20f hHExWPxu1uYFpVxTQ+9umayKvITCLmSCqE8LH7zYipDt/ry2xqiNsUP4iBPMPhYP eD9yarU5Ovs2WmIVUCAEy3zi/pjWlc+78ab0l/9oFXd1LyqGEORr2fR6khVgdL9X pk4ie5RjUMjPTd0Dq+hb8ci9OM= Received: (qmail 3009 invoked by alias); 3 Nov 2019 17:11:58 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 2767 invoked by uid 89); 3 Nov 2019 17:11:57 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=simplifies, redefine, Redefine X-HELO: mx1.osci.io X-Gerrit-PatchSet: 1 Date: Sun, 3 Nov 2019 12:11:46 -0500 From: "Florian Weimer (Code Review)" To: libc-alpha@sourceware.org Cc: Florian Weimer Message-ID: Auto-Submitted: auto-generated X-Gerrit-MessageType: newchange Subject: [review] Redefine _IO_iconv_t to store a single gconv step pointer [BZ #25097] X-Gerrit-Change-Id: I8b4c489b619a53154712ff32e1b6f13bb92d4203 X-Gerrit-Change-Number: 490 X-Gerrit-ChangeURL: X-Gerrit-Commit: 96ab757f9cd22bc880e0fcbe65a012c3726a9b87 References: Reply-To: fweimer@redhat.com, fweimer@redhat.com, libc-alpha@sourceware.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Gerrit/3.0.3-75-g9005159e5d Change URL: https://gnutoolchain-gerrit.osci.io/r/c/glibc/+/490 ...................................................................... Redefine _IO_iconv_t to store a single gconv step pointer [BZ #25097] libio can only deal with gconv conversions which consist of a single step. Not using __gconv_info simplifies the data structures somewhat. This eliminates a new GCC 10 warning about subscribing an inner zero-length array. Tested on x86_64-linux-gnu with mainline GCC. Built with build-many-glibcs.py, also with mainline GCC. Due to GCC PR 92039, there are failures left on 32-bit architectures with float128 support. Change-Id: I8b4c489b619a53154712ff32e1b6f13bb92d4203 --- M libio/fileops.c M libio/iofclose.c M libio/iofwide.c M libio/libio.h 4 files changed, 46 insertions(+), 57 deletions(-) diff --git a/libio/fileops.c b/libio/fileops.c index d84dd7c..f81646d 100644 --- a/libio/fileops.c +++ b/libio/fileops.c @@ -331,23 +331,19 @@ cc = fp->_codecvt = &fp->_wide_data->_codecvt; - cc->__cd_in.__cd.__nsteps = fcts.towc_nsteps; - cc->__cd_in.__cd.__steps = fcts.towc; + cc->__cd_in.step = fcts.towc; - cc->__cd_in.__cd.__data[0].__invocation_counter = 0; - cc->__cd_in.__cd.__data[0].__internal_use = 1; - cc->__cd_in.__cd.__data[0].__flags = __GCONV_IS_LAST; - cc->__cd_in.__cd.__data[0].__statep = &result->_wide_data->_IO_state; + cc->__cd_in.step_data.__invocation_counter = 0; + cc->__cd_in.step_data.__internal_use = 1; + cc->__cd_in.step_data.__flags = __GCONV_IS_LAST; + cc->__cd_in.step_data.__statep = &result->_wide_data->_IO_state; - cc->__cd_out.__cd.__nsteps = fcts.tomb_nsteps; - cc->__cd_out.__cd.__steps = fcts.tomb; + cc->__cd_out.step = fcts.tomb; - cc->__cd_out.__cd.__data[0].__invocation_counter = 0; - cc->__cd_out.__cd.__data[0].__internal_use = 1; - cc->__cd_out.__cd.__data[0].__flags - = __GCONV_IS_LAST | __GCONV_TRANSLIT; - cc->__cd_out.__cd.__data[0].__statep = - &result->_wide_data->_IO_state; + cc->__cd_out.step_data.__invocation_counter = 0; + cc->__cd_out.step_data.__internal_use = 1; + cc->__cd_out.step_data.__flags = __GCONV_IS_LAST | __GCONV_TRANSLIT; + cc->__cd_out.step_data.__statep = &result->_wide_data->_IO_state; /* From now on use the wide character callback functions. */ _IO_JUMPS_FILE_plus (fp) = fp->_wide_data->_wide_vtable; diff --git a/libio/iofclose.c b/libio/iofclose.c index 398b86d..3c648d6 100644 --- a/libio/iofclose.c +++ b/libio/iofclose.c @@ -62,8 +62,8 @@ struct _IO_codecvt *cc = fp->_codecvt; __libc_lock_lock (__gconv_lock); - __gconv_release_step (cc->__cd_in.__cd.__steps); - __gconv_release_step (cc->__cd_out.__cd.__steps); + __gconv_release_step (cc->__cd_in.step); + __gconv_release_step (cc->__cd_out.step); __libc_lock_unlock (__gconv_lock); } else diff --git a/libio/iofwide.c b/libio/iofwide.c index 10e2d66..3acebba 100644 --- a/libio/iofwide.c +++ b/libio/iofwide.c @@ -80,22 +80,19 @@ assert (fcts.towc_nsteps == 1); assert (fcts.tomb_nsteps == 1); - cc->__cd_in.__cd.__nsteps = fcts.towc_nsteps; - cc->__cd_in.__cd.__steps = fcts.towc; + cc->__cd_in.step = fcts.towc; - cc->__cd_in.__cd.__data[0].__invocation_counter = 0; - cc->__cd_in.__cd.__data[0].__internal_use = 1; - cc->__cd_in.__cd.__data[0].__flags = __GCONV_IS_LAST; - cc->__cd_in.__cd.__data[0].__statep = &fp->_wide_data->_IO_state; + cc->__cd_in.step_data.__invocation_counter = 0; + cc->__cd_in.step_data.__internal_use = 1; + cc->__cd_in.step_data.__flags = __GCONV_IS_LAST; + cc->__cd_in.step_data.__statep = &fp->_wide_data->_IO_state; - cc->__cd_out.__cd.__nsteps = fcts.tomb_nsteps; - cc->__cd_out.__cd.__steps = fcts.tomb; + cc->__cd_out.step = fcts.tomb; - cc->__cd_out.__cd.__data[0].__invocation_counter = 0; - cc->__cd_out.__cd.__data[0].__internal_use = 1; - cc->__cd_out.__cd.__data[0].__flags - = __GCONV_IS_LAST | __GCONV_TRANSLIT; - cc->__cd_out.__cd.__data[0].__statep = &fp->_wide_data->_IO_state; + cc->__cd_out.step_data.__invocation_counter = 0; + cc->__cd_out.step_data.__internal_use = 1; + cc->__cd_out.step_data.__flags = __GCONV_IS_LAST | __GCONV_TRANSLIT; + cc->__cd_out.step_data.__statep = &fp->_wide_data->_IO_state; } /* From now on use the wide character callback functions. */ @@ -117,14 +114,14 @@ { enum __codecvt_result result; - struct __gconv_step *gs = codecvt->__cd_out.__cd.__steps; + struct __gconv_step *gs = codecvt->__cd_out.step; int status; size_t dummy; const unsigned char *from_start_copy = (unsigned char *) from_start; - codecvt->__cd_out.__cd.__data[0].__outbuf = (unsigned char *) to_start; - codecvt->__cd_out.__cd.__data[0].__outbufend = (unsigned char *) to_end; - codecvt->__cd_out.__cd.__data[0].__statep = statep; + codecvt->__cd_out.step_data.__outbuf = (unsigned char *) to_start; + codecvt->__cd_out.step_data.__outbufend = (unsigned char *) to_end; + codecvt->__cd_out.step_data.__statep = statep; __gconv_fct fct = gs->__fct; #ifdef PTR_DEMANGLE @@ -133,12 +130,12 @@ #endif status = DL_CALL_FCT (fct, - (gs, codecvt->__cd_out.__cd.__data, &from_start_copy, + (gs, &codecvt->__cd_out.step_data, &from_start_copy, (const unsigned char *) from_end, NULL, &dummy, 0, 0)); *from_stop = (wchar_t *) from_start_copy; - *to_stop = (char *) codecvt->__cd_out.__cd.__data[0].__outbuf; + *to_stop = (char *) codecvt->__cd_out.step_data.__outbuf; switch (status) { @@ -169,14 +166,14 @@ { enum __codecvt_result result; - struct __gconv_step *gs = codecvt->__cd_in.__cd.__steps; + struct __gconv_step *gs = codecvt->__cd_in.step; int status; size_t dummy; const unsigned char *from_start_copy = (unsigned char *) from_start; - codecvt->__cd_in.__cd.__data[0].__outbuf = (unsigned char *) to_start; - codecvt->__cd_in.__cd.__data[0].__outbufend = (unsigned char *) to_end; - codecvt->__cd_in.__cd.__data[0].__statep = statep; + codecvt->__cd_in.step_data.__outbuf = (unsigned char *) to_start; + codecvt->__cd_in.step_data.__outbufend = (unsigned char *) to_end; + codecvt->__cd_in.step_data.__statep = statep; __gconv_fct fct = gs->__fct; #ifdef PTR_DEMANGLE @@ -185,12 +182,12 @@ #endif status = DL_CALL_FCT (fct, - (gs, codecvt->__cd_in.__cd.__data, &from_start_copy, + (gs, &codecvt->__cd_in.step_data, &from_start_copy, (const unsigned char *) from_end, NULL, &dummy, 0, 0)); *from_stop = (const char *) from_start_copy; - *to_stop = (wchar_t *) codecvt->__cd_in.__cd.__data[0].__outbuf; + *to_stop = (wchar_t *) codecvt->__cd_in.step_data.__outbuf; switch (status) { @@ -217,16 +214,16 @@ __libio_codecvt_encoding (struct _IO_codecvt *codecvt) { /* See whether the encoding is stateful. */ - if (codecvt->__cd_in.__cd.__steps[0].__stateful) + if (codecvt->__cd_in.step->__stateful) return -1; /* Fortunately not. Now determine the input bytes for the conversion necessary for each wide character. */ - if (codecvt->__cd_in.__cd.__steps[0].__min_needed_from - != codecvt->__cd_in.__cd.__steps[0].__max_needed_from) + if (codecvt->__cd_in.step->__min_needed_from + != codecvt->__cd_in.step->__max_needed_from) /* Not a constant value. */ return 0; - return codecvt->__cd_in.__cd.__steps[0].__min_needed_from; + return codecvt->__cd_in.step->__min_needed_from; } @@ -238,12 +235,12 @@ int result; const unsigned char *cp = (const unsigned char *) from_start; wchar_t to_buf[max]; - struct __gconv_step *gs = codecvt->__cd_in.__cd.__steps; + struct __gconv_step *gs = codecvt->__cd_in.step; size_t dummy; - codecvt->__cd_in.__cd.__data[0].__outbuf = (unsigned char *) to_buf; - codecvt->__cd_in.__cd.__data[0].__outbufend = (unsigned char *) &to_buf[max]; - codecvt->__cd_in.__cd.__data[0].__statep = statep; + codecvt->__cd_in.step_data.__outbuf = (unsigned char *) to_buf; + codecvt->__cd_in.step_data.__outbufend = (unsigned char *) &to_buf[max]; + codecvt->__cd_in.step_data.__statep = statep; __gconv_fct fct = gs->__fct; #ifdef PTR_DEMANGLE @@ -252,7 +249,7 @@ #endif DL_CALL_FCT (fct, - (gs, codecvt->__cd_in.__cd.__data, &cp, + (gs, &codecvt->__cd_in.step_data, &cp, (const unsigned char *) from_end, NULL, &dummy, 0, 0)); diff --git a/libio/libio.h b/libio/libio.h index bed324e..3be2fe8 100644 --- a/libio/libio.h +++ b/libio/libio.h @@ -48,14 +48,10 @@ #include #include -typedef union +typedef struct { - struct __gconv_info __cd; - struct - { - struct __gconv_info __cd; - struct __gconv_step_data __data; - } __combined; + struct __gconv_step *step; + struct __gconv_step_data step_data; } _IO_iconv_t; #include