summaryrefslogtreecommitdiff
path: root/libpwdgrp
diff options
context:
space:
mode:
authorDenys Vlasenko2015-01-02 22:31:07 +0100
committerDenys Vlasenko2015-01-02 22:31:07 +0100
commit908b6e5dfdbc81322680ce939e5415161c637bb4 (patch)
treed3a5d43b353963cf0ac8faa79b5839c611e63c40 /libpwdgrp
parent1da09cfacf1c4789cc74322857a098c2ddb06e31 (diff)
downloadbusybox-908b6e5dfdbc81322680ce939e5415161c637bb4.zip
busybox-908b6e5dfdbc81322680ce939e5415161c637bb4.tar.gz
libpwdgrp: use FAST_FUNC to make "matching ABI" optimization more likely to succeed
See bb_internal_get*nam_r size reduction: function old new delta bb_internal_getpwent_r 167 176 +9 getXXnam_r 204 206 +2 sulogin_main 326 325 -1 su_main 471 470 -1 read_line_input 3832 3831 -1 print_stat 865 864 -1 prepare_socket_fd 283 282 -1 load_crontab 777 776 -1 fork_job 456 455 -1 do_shm 884 883 -1 do_sem 637 636 -1 do_msg 783 782 -1 complete_username 124 123 -1 bb_internal_getgrouplist 71 70 -1 xgetpwuid 27 25 -2 xgetpwnam 27 25 -2 xgetgrnam 27 25 -2 xgetgrgid 27 25 -2 uid2uname 18 16 -2 login_main 980 978 -2 gid2group 18 16 -2 get_shell_name 54 52 -2 change_identity 50 48 -2 bb_internal_initgroups 50 48 -2 argstr 1261 1259 -2 print_perms 177 174 -3 inetd_main 2077 2074 -3 run_applet_no_and_exit 446 442 -4 fileaction_setowngrp 89 85 -4 deluser_main 312 308 -4 bb_internal_getpwuid 19 15 -4 bb_internal_getpwnam 11 7 -4 bb_internal_getgrnam 14 10 -4 bb_internal_getgrgid 19 15 -4 adduser_main 865 861 -4 passwd_main 989 984 -5 get_passwd 97 92 -5 data_extract_all 887 882 -5 check_user_passwd 490 485 -5 get_groups 81 75 -6 ftpd_main 2178 2171 -7 bb_internal_getspnam_r 42 18 -24 bb_internal_getpwnam_r 39 15 -24 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/41 up/down: 11/-153) Total: -142 bytes text data bss dec hex filename 923167 928 17676 941771 e5ecb busybox_old 923023 928 17676 941627 e5e3b busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libpwdgrp')
-rw-r--r--libpwdgrp/pwd_grp.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/libpwdgrp/pwd_grp.c b/libpwdgrp/pwd_grp.c
index ed83701..0d8e2bb 100644
--- a/libpwdgrp/pwd_grp.c
+++ b/libpwdgrp/pwd_grp.c
@@ -288,7 +288,7 @@ static void *convert_to_struct(const char *def, const unsigned char *off,
/****** getXXnam/id_r */
-static int getXXnam_r(const char *name, uintptr_t db_and_field_pos, char *buffer, size_t buflen,
+static int FAST_FUNC getXXnam_r(const char *name, uintptr_t db_and_field_pos, char *buffer, size_t buflen,
void *result)
{
void *struct_buf = *(void**)result;
@@ -316,18 +316,18 @@ static int getXXnam_r(const char *name, uintptr_t db_and_field_pos, char *buffer
return errno;
}
-int getpwnam_r(const char *name, struct passwd *struct_buf, char *buffer, size_t buflen,
+int FAST_FUNC getpwnam_r(const char *name, struct passwd *struct_buf, char *buffer, size_t buflen,
struct passwd **result)
{
/* Why the "store buffer address in result" trick?
* This way, getXXnam_r has the same ABI signature as getpwnam_r,
- * hopefully compiler can optimize tall call better in this case.
+ * hopefully compiler can optimize tail call better in this case.
*/
*result = struct_buf;
return getXXnam_r(name, (0 << 2) + 0, buffer, buflen, result);
}
#if ENABLE_USE_BB_SHADOW
-int getspnam_r(const char *name, struct spwd *struct_buf, char *buffer, size_t buflen,
+int FAST_FUNC getspnam_r(const char *name, struct spwd *struct_buf, char *buffer, size_t buflen,
struct spwd **result)
{
*result = struct_buf;
@@ -337,7 +337,7 @@ int getspnam_r(const char *name, struct spwd *struct_buf, char *buffer, size_t b
/****** getXXent_r */
-static int getXXent_r(void *struct_buf, char *buffer, size_t buflen,
+static int FAST_FUNC getXXent_r(void *struct_buf, char *buffer, size_t buflen,
void *result,
unsigned db_idx)
{
@@ -374,14 +374,14 @@ static int getXXent_r(void *struct_buf, char *buffer, size_t buflen,
return errno;
}
-int getpwent_r(struct passwd *struct_buf, char *buffer, size_t buflen, struct passwd **result)
+int FAST_FUNC getpwent_r(struct passwd *struct_buf, char *buffer, size_t buflen, struct passwd **result)
{
return getXXent_r(struct_buf, buffer, buflen, result, 0);
}
/****** getXXnam/id */
-static void *getXXnam(const char *name, unsigned db_and_field_pos)
+static void* FAST_FUNC getXXnam(const char *name, unsigned db_and_field_pos)
{
char *buf;
void *result;
@@ -409,39 +409,39 @@ static void *getXXnam(const char *name, unsigned db_and_field_pos)
return result;
}
-struct passwd *getpwnam(const char *name)
+struct passwd* FAST_FUNC getpwnam(const char *name)
{
return getXXnam(name, (0 << 2) + 0);
}
-struct group *getgrnam(const char *name)
+struct group* FAST_FUNC getgrnam(const char *name)
{
return getXXnam(name, (1 << 2) + 0);
}
-struct passwd *getpwuid(uid_t id)
+struct passwd* FAST_FUNC getpwuid(uid_t id)
{
return getXXnam(utoa(id), (0 << 2) + 2);
}
-struct group *getgrgid(gid_t id)
+struct group* FAST_FUNC getgrgid(gid_t id)
{
return getXXnam(utoa(id), (1 << 2) + 2);
}
/****** end/setXXend */
-void endpwent(void)
+void FAST_FUNC endpwent(void)
{
if (has_S && S.db[0].fp) {
fclose(S.db[0].fp);
S.db[0].fp = NULL;
}
}
-void setpwent(void)
+void FAST_FUNC setpwent(void)
{
if (has_S && S.db[0].fp) {
rewind(S.db[0].fp);
}
}
-void endgrent(void)
+void FAST_FUNC endgrent(void)
{
if (has_S && S.db[1].fp) {
fclose(S.db[1].fp);
@@ -491,7 +491,7 @@ static gid_t* FAST_FUNC getgrouplist_internal(int *ngroups_ptr,
return group_list;
}
-int initgroups(const char *user, gid_t gid)
+int FAST_FUNC initgroups(const char *user, gid_t gid)
{
int ngroups;
gid_t *group_list = getgrouplist_internal(&ngroups, user, gid);
@@ -501,7 +501,7 @@ int initgroups(const char *user, gid_t gid)
return ngroups;
}
-int getgrouplist(const char *user, gid_t gid, gid_t *groups, int *ngroups)
+int FAST_FUNC getgrouplist(const char *user, gid_t gid, gid_t *groups, int *ngroups)
{
int ngroups_old = *ngroups;
gid_t *group_list = getgrouplist_internal(ngroups, user, gid);