Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A Metaconfig probe for malloc_usable_size #17066

Closed
p5pRT opened this issue Jun 30, 2019 · 6 comments
Closed

A Metaconfig probe for malloc_usable_size #17066

p5pRT opened this issue Jun 30, 2019 · 6 comments

Comments

@p5pRT
Copy link

p5pRT commented Jun 30, 2019

Migrated from rt.perl.org#134237 (status was 'pending release')

Searchable as RT134237$

@p5pRT
Copy link
Author

p5pRT commented Jun 30, 2019

From rich+perl@hyphen-dash-hyphen.info

Hi,

As mentioned on IRC, malloc_usable_size
(http​://man7.org/linux/man-pages/man3/malloc_usable_size.3.html) seems
to be pretty common amongst Linux and BSD malloc implementations
nowadays. Metaconfig has a probe for the similar malloc_size on
Darwin, added in
https://perl5.git.perl.org/metaconfig.git/commit/83994881900edacd8c4e4d6534b1545554bb8274

Should a probe for malloc_usable_size should have its own file or be
appended to d_malloc_size.U due to the functional similarity?
Speculative patches are attached. (Once in, the intention is to add an
alternative definition to Perl_safesysmalloc_size.)

xenu pointed out that it would be useful to capture the minimum
allocation in a variable (e.g. MIN_MALLOC_SIZE). Where would be the
best place to do so?

Best Regards,
Richard

@p5pRT
Copy link
Author

p5pRT commented Jun 30, 2019

From rich+perl@hyphen-dash-hyphen.info

0001-New-check-for-malloc_usable_size.patch
From 906636b8242ef18a4f41befe1bec3be59a7d8ac4 Mon Sep 17 00:00:00 2001
From: Richard Leach <rich+perl@hyphen-dash-hyphen.info>
Date: Tue, 25 Jun 2019 22:08:12 +0100
Subject: [PATCH] New check for malloc_usable_size

---
 U/perl/d_malloc_useable_size.U | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100644 U/perl/d_malloc_useable_size.U

diff --git a/U/perl/d_malloc_useable_size.U b/U/perl/d_malloc_useable_size.U
new file mode 100644
index 0000000..bdd9dd6
--- /dev/null
+++ b/U/perl/d_malloc_useable_size.U
@@ -0,0 +1,26 @@
+?RCS: $Id$
+?RCS:
+?RCS: Copyright (c) 2019, Richard Leach
+?RCS: 
+?RCS: You may redistribute only under the terms of the Artistic Licence,
+?RCS: as specified in the README file that comes with the distribution.
+?RCS: You may reuse parts of this distribution only within the terms of
+?RCS: that same Artistic Licence; a copy of which may be found at the root
+?RCS: of the source tree for dist 3.0.
+?RCS:
+?MAKE:d_malloc_usable_size: Inlibc
+?MAKE:	-pick add $@ %<
+?S:d_malloc_usable_size:
+?S:	This symbol, if defined, indicates that the malloc_usable_size
+?S:	routine is available for use.
+?S:.
+?C:HAS_MALLOC_USABLE_SIZE:
+?C:	This symbol, if defined, indicates that the malloc_usable_size
+?C:	routine is available for use.
+?C:.
+?H:#$d_malloc_usable_size HAS_MALLOC_USABLE_SIZE		/**/
+?H:.
+?LINT:set d_malloc_usable_size
+: see if malloc_usable_size exists
+set malloc_usable_size d_malloc_usable_size
+eval $inlibc
-- 
2.17.0.windows.1

@p5pRT
Copy link
Author

p5pRT commented Jun 30, 2019

From rich+perl@hyphen-dash-hyphen.info

0001-Add-check-for-malloc_usable_size.patch
From 14605a33d8c588654bd0b904016f7ab68050abcf Mon Sep 17 00:00:00 2001
From: Richard Leach <rich+perl@hyphen-dash-hyphen.info>
Date: Tue, 25 Jun 2019 22:14:51 +0100
Subject: [PATCH] Add check for malloc_usable_size

---
 U/perl/d_malloc_size.U | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/U/perl/d_malloc_size.U b/U/perl/d_malloc_size.U
index 3d6e083..071426a 100644
--- a/U/perl/d_malloc_size.U
+++ b/U/perl/d_malloc_size.U
@@ -8,7 +8,7 @@
 ?RCS: that same Artistic License; a copy of which may be found at the root
 ?RCS: of the source tree for dist 3.0.
 ?RCS:
-?MAKE:d_malloc_size d_malloc_good_size: Inlibc
+?MAKE:d_malloc_size d_malloc_good_size d_malloc_usable_size: Inlibc
 ?MAKE:	-pick add $@ %<
 ?S:d_malloc_size:
 ?S:	This symbol, if defined, indicates that the malloc_size
@@ -18,6 +18,10 @@
 ?S:	This symbol, if defined, indicates that the malloc_good_size
 ?S:	routine is available for use.
 ?S:.
+?S:d_malloc_usable_size:
+?S:	This symbol, if defined, indicates that the malloc_usable_size
+?S:	routine is available for use.
+?S:.
 ?C:HAS_MALLOC_SIZE:
 ?C:	This symbol, if defined, indicates that the malloc_size
 ?C:	routine is available for use.
@@ -30,8 +34,15 @@
 ?C:.
 ?H:#$d_malloc_good_size HAS_MALLOC_GOOD_SIZE	/**/
 ?H:.
+?C:HAS_MALLOC_USABLE_SIZE:
+?C:	This symbol, if defined, indicates that the malloc_usable_size
+?C:	routine is available for use.
+?C:.
+?H:#$d_malloc_usable_size HAS_MALLOC_USABLE_SIZE		/**/
+?H:.
 ?LINT:set d_malloc_size
 ?LINT:set d_malloc_good_size
+?LINT:set d_malloc_usable_size
 : see if malloc_size exists
 set malloc_size d_malloc_size
 eval $inlibc
@@ -40,3 +51,6 @@ eval $inlibc
 set malloc_good_size d_malloc_good_size
 eval $inlibc
 
+: see if malloc_usable_size exists
+set malloc_usable_size d_malloc_usable_size
+eval $inlibc
-- 
2.17.0.windows.1

@p5pRT
Copy link
Author

p5pRT commented Sep 19, 2019

From @tonycoz

On Sun, 30 Jun 2019 01​:17​:03 -0700, rich+perl@​hyphen-dash-hyphen.info wrote​:

Hi,

As mentioned on IRC, malloc_usable_size
(http​://man7.org/linux/man-pages/man3/malloc_usable_size.3.html) seems
to be pretty common amongst Linux and BSD malloc implementations
nowadays. Metaconfig has a probe for the similar malloc_size on
Darwin, added in
https://perl5.git.perl.org/metaconfig.git/commit/83994881900edacd8c4e4d6534b1545554bb8274

Should a probe for malloc_usable_size should have its own file or be
appended to d_malloc_size.U due to the functional similarity?
Speculative patches are attached. (Once in, the intention is to add an
alternative definition to Perl_safesysmalloc_size.)

xenu pointed out that it would be useful to capture the minimum
allocation in a variable (e.g. MIN_MALLOC_SIZE). Where would be the
best place to do so?

This was applied to metaconfig in 57477b4​:

Perl/metaconfig@57477b4

and in perl in blead as e62a081.

Thanks,
Tony

@p5pRT
Copy link
Author

p5pRT commented Sep 19, 2019

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Sep 19, 2019

@tonycoz - Status changed from 'open' to 'pending release'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant