From 0a73d05f8a5fc4d37c2c7ae9b16daba304e37c6e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wilfried=20G=C3=B6esgens?= Date: Tue, 18 May 2010 22:52:46 +0000 Subject: [PATCH] * INLINE doesn't work across several objects as of C99; we just survive it the way its now because of gcc is sluggish here. (see http://clang.llvm.org/docs/UsersManual.html#c_modes for details) Move the INLINE function into the header, make it static INLINE as sugested by jyasskin and sabre --- citadel/context.c | 16 --------- citadel/context.h | 19 ++++++++++- citadel/file_ops.c | 2 +- citadel/ldap.c | 2 +- citadel/modules/expire/expire_policy.c | 2 +- citadel/room_ops.c | 2 +- citadel/user_ops.c | 35 ++------------------ citadel/user_ops.h | 46 ++++++++++++++++++++++++-- 8 files changed, 69 insertions(+), 55 deletions(-) diff --git a/citadel/context.c b/citadel/context.c index b00f6c07c..03638d299 100644 --- a/citadel/context.c +++ b/citadel/context.c @@ -583,22 +583,6 @@ void InitializeMasterCC(void) { -/* - * Bind a thread to a context. (It's inline merely to speed things up.) - */ -INLINE void become_session(CitContext *which_con) { -/* - pid_t tid = syscall(SYS_gettid); -*/ - citthread_setspecific(MyConKey, (void *)which_con ); -/* - CtdlLogPrintf(CTDL_DEBUG, "[%d]: Now doing %s\n", - (int) tid, - ((which_con != NULL) && (which_con->ServiceName != NULL)) ? - which_con->ServiceName:""); -*/ -} - /* * Set the "async waiting" flag for a session, if applicable diff --git a/citadel/context.h b/citadel/context.h index 42e0b2898..7a71d3b96 100644 --- a/citadel/context.h +++ b/citadel/context.h @@ -154,7 +154,6 @@ void RemoveContext (struct CitContext *); CitContext *CreateNewContext (void); void context_cleanup(void); void kill_session (int session_to_kill); -INLINE void become_session(struct CitContext *which_con); void InitializeMasterCC(void); void dead_session_purge(int force); void set_async_waiting(struct CitContext *ccptr); @@ -169,4 +168,22 @@ int CtdlTerminateOtherSession (int session_num); #define TERM_ALLOWED 0x02 #define TERM_KILLED 0x03 #define TERM_NOTALLOWED -1 + +/* + * Bind a thread to a context. (It's inline merely to speed things up.) + */ +static INLINE void become_session(CitContext *which_con) { +/* + pid_t tid = syscall(SYS_gettid); +*/ + citthread_setspecific(MyConKey, (void *)which_con ); +/* + CtdlLogPrintf(CTDL_DEBUG, "[%d]: Now doing %s\n", + (int) tid, + ((which_con != NULL) && (which_con->ServiceName != NULL)) ? + which_con->ServiceName:""); +*/ +} + + #endif /* CONTEXT_H */ diff --git a/citadel/file_ops.c b/citadel/file_ops.c index 0438b244e..f303ac28c 100644 --- a/citadel/file_ops.c +++ b/citadel/file_ops.c @@ -35,7 +35,6 @@ #include "config.h" #include "file_ops.h" #include "sysdep_decls.h" -#include "user_ops.h" #include "support.h" #include "room_ops.h" #include "msgbase.h" @@ -47,6 +46,7 @@ #endif #include "ctdl_module.h" +#include "user_ops.h" /* * network_talking_to() -- concurrency checker diff --git a/citadel/ldap.c b/citadel/ldap.c index 1ea3bb09b..2e293276e 100644 --- a/citadel/ldap.c +++ b/citadel/ldap.c @@ -56,7 +56,6 @@ int ctdl_require_ldap_version = 3; #include "citadel.h" #include "server.h" #include "database.h" -#include "user_ops.h" #include "sysdep_decls.h" #include "support.h" #include "room_ops.h" @@ -70,6 +69,7 @@ int ctdl_require_ldap_version = 3; #include "threads.h" #include "citadel_ldap.h" #include "ctdl_module.h" +#include "user_ops.h" #ifdef HAVE_LDAP #define LDAP_DEPRECATED 1 /* Suppress libldap's warning that we are using deprecated API calls */ diff --git a/citadel/modules/expire/expire_policy.c b/citadel/modules/expire/expire_policy.c index 5bf69953c..9b2faf1a5 100644 --- a/citadel/modules/expire/expire_policy.c +++ b/citadel/modules/expire/expire_policy.c @@ -31,11 +31,11 @@ #include "room_ops.h" #include "sysdep_decls.h" #include "support.h" -#include "user_ops.h" #include "msgbase.h" #include "citserver.h" #include "ctdl_module.h" +#include "user_ops.h" /* * Retrieve the applicable expire policy for a specific room diff --git a/citadel/room_ops.c b/citadel/room_ops.c index baf2b4bf6..0cba9768b 100644 --- a/citadel/room_ops.c +++ b/citadel/room_ops.c @@ -35,7 +35,6 @@ #include "room_ops.h" #include "sysdep_decls.h" #include "support.h" -#include "user_ops.h" #include "msgbase.h" #include "citserver.h" #include "control.h" @@ -43,6 +42,7 @@ #include "threads.h" #include "ctdl_module.h" +#include "user_ops.h" struct floor *floorcache[MAXFLOORS]; diff --git a/citadel/user_ops.c b/citadel/user_ops.c index 4da586ef8..294767c68 100644 --- a/citadel/user_ops.c +++ b/citadel/user_ops.c @@ -38,7 +38,6 @@ #include "citadel.h" #include "server.h" #include "database.h" -#include "user_ops.h" #include "sysdep_decls.h" #include "support.h" #include "room_ops.h" @@ -55,42 +54,14 @@ #include "ctdl_module.h" +////#define CTDL_INLINE_USR INLINE +#include "user_ops.h" + /* These pipes are used to talk to the chkpwd daemon, which is forked during startup */ int chkpwd_write_pipe[2]; int chkpwd_read_pipe[2]; -INLINE long cutuserkey(char *username) { - long len; - len = strlen(username); - if (len >= USERNAME_SIZE) - { - CtdlLogPrintf (CTDL_EMERG, "Username to long: %s", username); - cit_backtrace (); - len = USERNAME_SIZE - 1; - ((char*)username)[USERNAME_SIZE - 1]='\0'; - } - return len; -} - -/* - * makeuserkey() - convert a username into the format used as a database key - * (it's just the username converted into lower case) - */ -INLINE void makeuserkey(char *key, const char *username, long len) { - int i; - - if (len >= USERNAME_SIZE) - { - CtdlLogPrintf (CTDL_EMERG, "Username to long: %s", username); - cit_backtrace (); - len = USERNAME_SIZE - 1; - } - for (i=0; i<=len; ++i) { - key[i] = tolower(username[i]); - } -} - /* * getuser() - retrieve named user into supplied buffer. diff --git a/citadel/user_ops.h b/citadel/user_ops.h index 8355e3e78..41899ad91 100644 --- a/citadel/user_ops.h +++ b/citadel/user_ops.h @@ -1,3 +1,7 @@ +#ifndef __USER_OPS_H__ +#define __USER_OPS_H__ + +#include /* $Id$ */ int hash (char *str); /* getuser is deprecated, use CtdlGetUser instead */ @@ -54,7 +58,45 @@ void start_chkpwd_daemon(void); #define RENAMEUSER_ALREADY_EXISTS 3 /* An account with the desired new name already exists */ int rename_user(char *oldname, char *newname); -INLINE void makeuserkey(char *key, const char *username, long len); -INLINE long cutuserkey(char *username); + +///#ifndef CTDL_INLINE_USR +////#define CTDL_INLINE_USR static INLINE +///#endif + +///CTDL_INLINE_USR +static INLINE long cutuserkey(char *username) { + long len; + len = strlen(username); + if (len >= USERNAME_SIZE) + { + CtdlLogPrintf (CTDL_EMERG, "Username to long: %s", username); + cit_backtrace (); + len = USERNAME_SIZE - 1; + ((char*)username)[USERNAME_SIZE - 1]='\0'; + } + return len; +} + +/* + * makeuserkey() - convert a username into the format used as a database key + * (it's just the username converted into lower case) + */ +///CTDL_INLINE_USR +static INLINE void makeuserkey(char *key, const char *username, long len) { + int i; + + if (len >= USERNAME_SIZE) + { + CtdlLogPrintf (CTDL_EMERG, "Username to long: %s", username); + cit_backtrace (); + len = USERNAME_SIZE - 1; + } + for (i=0; i<=len; ++i) { + key[i] = tolower(username[i]); + } +} + int internal_create_user (const char *username, long len, struct ctdluser *usbuf, uid_t uid); + +#endif -- 2.30.2