From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id 7DB12385C338; Wed, 10 Aug 2022 16:13:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7DB12385C338 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: make import_address a static inline function X-Act-Checkin: newlib-cygwin X-Git-Author: Corinna Vinschen X-Git-Refname: refs/heads/master X-Git-Oldrev: 56b7fd620fce86ab86cae2d22985cf7a385e3c5b X-Git-Newrev: 5851a633bd9fe45a60b180f4d0b89fda90f34972 Message-Id: <20220810161351.7DB12385C338@sourceware.org> Date: Wed, 10 Aug 2022 16:13:51 +0000 (GMT) X-BeenThere: cygwin-cvs@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component git logs List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Aug 2022 16:13:51 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D5851a633bd9= fe45a60b180f4d0b89fda90f34972 commit 5851a633bd9fe45a60b180f4d0b89fda90f34972 Author: Corinna Vinschen Date: Wed Aug 10 16:55:04 2022 +0200 Cygwin: make import_address a static inline function =20 It's used in malloc_init only and we never need it anywhere else, hopefully. =20 Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/local_includes/miscfuncs.h | 3 --- winsup/cygwin/miscfuncs.cc | 19 ------------------- winsup/cygwin/mm/malloc_wrapper.cc | 22 +++++++++++++++++++++- 3 files changed, 21 insertions(+), 23 deletions(-) diff --git a/winsup/cygwin/local_includes/miscfuncs.h b/winsup/cygwin/local= _includes/miscfuncs.h index eac1dbe20..947b52c2c 100644 --- a/winsup/cygwin/local_includes/miscfuncs.h +++ b/winsup/cygwin/local_includes/miscfuncs.h @@ -77,9 +77,6 @@ public: =20 extern "C" void yield (); =20 -#define import_address(x) __import_address ((void *)(x)) -void * __import_address (void *); - #define caller_return_address() \ __caller_return_address (__builtin_return_address (0)) void * __caller_return_address (void *); diff --git a/winsup/cygwin/miscfuncs.cc b/winsup/cygwin/miscfuncs.cc index f46e349e5..0af2e0217 100644 --- a/winsup/cygwin/miscfuncs.cc +++ b/winsup/cygwin/miscfuncs.cc @@ -315,25 +315,6 @@ NT_readline::gets () } } =20 -/* Return an address from the import jmp table of main program. */ -void * -__import_address (void *imp) -{ - __try - { - if (*((uint16_t *) imp) =3D=3D 0x25ff) - { - const char *ptr =3D (const char *) imp; - const uintptr_t *jmpto =3D (uintptr_t *) - (ptr + 6 + *(int32_t *)(ptr + 2)); - return (void *) *jmpto; - } - } - __except (NO_ERROR) {} - __endtry - return NULL; -} - /* Helper function to generate the correct caller address. For external calls, the return address on the stack is _sigbe. In that case the actual caller return address is on the cygtls stack. Use this function diff --git a/winsup/cygwin/mm/malloc_wrapper.cc b/winsup/cygwin/mm/malloc_w= rapper.cc index 2842e5398..5af39d361 100644 --- a/winsup/cygwin/mm/malloc_wrapper.cc +++ b/winsup/cygwin/mm/malloc_wrapper.cc @@ -27,6 +27,25 @@ extern "C" struct mallinfo dlmallinfo (); static bool use_internal =3D true; static bool internal_malloc_determined; =20 +/* Return an address from the import jmp table of main program. */ +static inline void * +import_address (void *imp) +{ + __try + { + if (*((uint16_t *) imp) =3D=3D 0x25ff) + { + const char *ptr =3D (const char *) imp; + const uintptr_t *jmpto =3D (uintptr_t *) + (ptr + 6 + *(int32_t *)(ptr + 2)); + return (void *) *jmpto; + } + } + __except (NO_ERROR) {} + __endtry + return NULL; +} + /* These routines are used by the application if it doesn't provide its own malloc. */ =20 @@ -284,7 +303,8 @@ malloc_init () /* Decide if we are using our own version of malloc by testing the i= mport address from user_data. */ use_internal =3D user_data->malloc =3D=3D malloc - || import_address (user_data->malloc) =3D=3D &_sigfe_malloc; + || import_address ((void *) user_data->malloc) + =3D=3D &_sigfe_malloc; malloc_printf ("using %s malloc", use_internal ? "internal" : "exter= nal"); internal_malloc_determined =3D true; }