mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Denys Vlasenko <vda.linux@googlemail.com>
To: Rich Felker <dalias@libc.org>
Cc: Denys Vlasenko <vda.linux@googlemail.com>,
	musl <musl@lists.openwall.com>
Subject: [PATCH] reduce size of struct __libc by using narrower integers
Date: Tue,  6 Mar 2018 17:55:02 +0100	[thread overview]
Message-ID: <20180306165502.23633-1-vda.linux@googlemail.com> (raw)

can_do_threads, threaded and secure are boolean flags, can use bytes
instead of full word ints.

tls_align and page_size are surely smaller than 4GB, no need to use
potentially 64-bit size_t.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
CC: musl <musl@lists.openwall.com>
---
 ldso/dynlink.c      |  3 ++-
 src/internal/libc.h | 11 ++++++-----
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/ldso/dynlink.c b/ldso/dynlink.c
index 9bf6924b..67d36395 100644
--- a/ldso/dynlink.c
+++ b/ldso/dynlink.c
@@ -124,8 +124,9 @@ static jmp_buf *rtld_fail;
 static pthread_rwlock_t lock;
 static struct debug debug;
 static struct tls_module *tls_tail;
-static size_t tls_cnt, tls_offset, tls_align = MIN_TLS_ALIGN;
+static size_t tls_cnt, tls_offset;
 static size_t static_tls_cnt;
+static unsigned tls_align = MIN_TLS_ALIGN;
 static pthread_mutex_t init_fini_lock = { ._m_type = PTHREAD_MUTEX_RECURSIVE };
 static struct fdpic_loadmap *app_loadmap;
 static struct fdpic_dummy_loadmap app_dummy_loadmap;
diff --git a/src/internal/libc.h b/src/internal/libc.h
index 5e145183..3cd44e90 100644
--- a/src/internal/libc.h
+++ b/src/internal/libc.h
@@ -18,14 +18,15 @@ struct tls_module {
 };
 
 struct __libc {
-	int can_do_threads;
-	int threaded;
-	int secure;
+	char can_do_threads;
+	char threaded;
+	char secure;
 	volatile int threads_minus_1;
 	size_t *auxv;
 	struct tls_module *tls_head;
-	size_t tls_size, tls_align, tls_cnt;
-	size_t page_size;
+	size_t tls_size, tls_cnt;
+	unsigned tls_align;
+	unsigned page_size;
 	struct __locale_struct global_locale;
 };
 
-- 
2.16.2



             reply	other threads:[~2018-03-06 16:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-06 16:55 Denys Vlasenko [this message]
2018-03-06 17:21 ` Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180306165502.23633-1-vda.linux@googlemail.com \
    --to=vda.linux@googlemail.com \
    --cc=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).