From patchwork Thu Jun 25 00:44:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roland McGrath X-Patchwork-Id: 7342 Received: (qmail 57883 invoked by alias); 25 Jun 2015 00:45:00 -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 57871 invoked by uid 89); 25 Jun 2015 00:44:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.7 required=5.0 tests=AWL, BAYES_20, KAM_LAZY_DOMAIN_SECURITY autolearn=no version=3.3.2 X-HELO: topped-with-meat.com MIME-Version: 1.0 From: Roland McGrath To: "GNU C. Library" Subject: [COMMITTED PATCH] Use unsigned types for counters in AIO code. Message-Id: <20150625004456.8C4A12C3B00@topped-with-meat.com> Date: Wed, 24 Jun 2015 17:44:56 -0700 (PDT) X-CMAE-Score: 0 X-CMAE-Analysis: v=2.1 cv=SvUDtp+0 c=1 sm=1 tr=0 a=WkljmVdYkabdwxfqvArNOQ==:117 a=14OXPxybAAAA:8 a=kj9zAlcOel0A:10 a=hOe2yjtxAAAA:8 a=5ObN0V5aMqrlLmsQ6FwA:9 a=CjuIK1q_8ugA:10 Verified on x86_64-linux-gnu, i686-linux-gnu, and arm-linux-gnueabihf, that no generated code changes nontrivially. Thanks, Roland 2015-06-24 Roland McGrath * sysdeps/pthread/aio_misc.h (struct waitlist): Change type of field counterp to 'volatile unsigned int *'. * sysdeps/pthread/aio_suspend.c [DONT_NEED_AIO_MISC_COND] (do_aio_misc_wait): Give argument CNTR type 'unsigned int *'. (aio_suspend): Give local variable CNTR type 'unsigned int'. * sysdeps/pthread/lio_listio.c (lio_listio_internal): Give local variable TOTAL type 'volatile unsigned int'. (struct async_waitlist): Change type of field counter to 'unsigned int'. diff --git a/sysdeps/nptl/aio_misc.h b/sysdeps/nptl/aio_misc.h index fb69b0f..d5d1c08 100644 --- a/sysdeps/nptl/aio_misc.h +++ b/sysdeps/nptl/aio_misc.h @@ -34,8 +34,8 @@ #define AIO_MISC_WAIT(result, futex, timeout, cancel) \ do { \ - volatile int *futexaddr = &futex; \ - int oldval = futex; \ + volatile unsigned int *futexaddr = &futex; \ + unsigned int oldval = futex; \ \ if (oldval != 0) \ { \ diff --git a/sysdeps/pthread/aio_misc.h b/sysdeps/pthread/aio_misc.h index ffb0983..5d3fb61 100644 --- a/sysdeps/pthread/aio_misc.h +++ b/sysdeps/pthread/aio_misc.h @@ -51,7 +51,7 @@ struct waitlist #endif int *result; - volatile int *counterp; + volatile unsigned int *counterp; /* The next field is used in asynchronous `lio_listio' operations. */ struct sigevent *sigevp; #ifdef BROKEN_THREAD_SIGNALS diff --git a/sysdeps/pthread/aio_suspend.c b/sysdeps/pthread/aio_suspend.c index 920f18a..641eafb 100644 --- a/sysdeps/pthread/aio_suspend.c +++ b/sysdeps/pthread/aio_suspend.c @@ -94,13 +94,13 @@ cleanup (void *arg) #ifdef DONT_NEED_AIO_MISC_COND static int __attribute__ ((noinline)) -do_aio_misc_wait(int *cntr, const struct timespec *timeout) +do_aio_misc_wait (unsigned int *cntr, const struct timespec *timeout) { - int result = 0; + int result = 0; - AIO_MISC_WAIT(result, *cntr, timeout, 1); + AIO_MISC_WAIT (result, *cntr, timeout, 1); - return result; + return result; } #endif @@ -124,7 +124,7 @@ aio_suspend (list, nent, timeout) int cnt; bool any = false; int result = 0; - int cntr = 1; + unsigned int cntr = 1; /* Request the mutex. */ pthread_mutex_lock (&__aio_requests_mutex); @@ -180,7 +180,7 @@ aio_suspend (list, nent, timeout) pthread_cleanup_push (cleanup, &clparam); #ifdef DONT_NEED_AIO_MISC_COND - result = do_aio_misc_wait(&cntr, timeout); + result = do_aio_misc_wait (&cntr, timeout); #else if (timeout == NULL) result = pthread_cond_wait (&cond, &__aio_requests_mutex); diff --git a/sysdeps/pthread/lio_listio.c b/sysdeps/pthread/lio_listio.c index bfbf221..ac7ce40 100644 --- a/sysdeps/pthread/lio_listio.c +++ b/sysdeps/pthread/lio_listio.c @@ -35,7 +35,7 @@ /* We need this special structure to handle asynchronous I/O. */ struct async_waitlist { - int counter; + unsigned int counter; struct sigevent sigev; struct waitlist list[0]; }; @@ -61,7 +61,7 @@ lio_listio_internal (int mode, struct aiocb *const list[], int nent, struct sigevent defsigev; struct requestlist *requests[nent]; int cnt; - volatile int total = 0; + volatile unsigned int total = 0; int result = 0; if (sig == NULL) @@ -83,7 +83,7 @@ lio_listio_internal (int mode, struct aiocb *const list[], int nent, requests[cnt] = __aio_enqueue_request ((aiocb_union *) list[cnt], (list[cnt]->aio_lio_opcode - | LIO_OPCODE_BASE)); + | LIO_OPCODE_BASE)); if (requests[cnt] != NULL) /* Successfully enqueued. */