aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2006-07-28 22:14:49 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2006-07-28 22:14:49 +0000
commit173525f1d66d38e2f83ebbda4c3778c7007850b6 (patch)
treef5b50f449931ed02dc5edd889c1ccb481e053563
parentf768188647ec3c0ba83664c214d7622127812a52 (diff)
Add the function attribute "pure" or "const" to various functions that perform
int to string or string to int operations. "pure" essentially says that this function has no side effects aside from its result, and the result depends on nothing else other than its arguments and global variables. "const" is a more strict form of "pure", where the function also doesn't access any global variables. From the gcc manual: "Such a function can be subject to common subexpression elimination and loop optimization just as an arithmetic operator would be." This also tells the compiler that it is safe to call the function fewer times than the code says to, given the same arguments, since the result will always be the same. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@38452 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--channels/chan_sip.c14
-rw-r--r--include/asterisk/channel.h6
2 files changed, 10 insertions, 10 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 3a712fa18..3530b2824 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -1286,8 +1286,8 @@ static void sip_poke_all_peers(void);
/*--- Applications, functions, CLI and manager command helpers */
static const char *sip_nat_mode(const struct sip_pvt *p);
static int sip_show_inuse(int fd, int argc, char *argv[]);
-static char *transfermode2str(enum transfermodes mode);
-static char *nat2str(int nat);
+static char *transfermode2str(enum transfermodes mode) __attribute__ ((const));
+static char *nat2str(int nat) __attribute__ ((const));
static int peer_status(struct sip_peer *peer, char *status, int statuslen);
static int sip_show_users(int fd, int argc, char *argv[]);
static int _sip_show_peers(int fd, int *total, struct mansession *s, struct message *m, int argc, char *argv[]);
@@ -1295,8 +1295,8 @@ static int manager_sip_show_peers( struct mansession *s, struct message *m );
static int sip_show_peers(int fd, int argc, char *argv[]);
static int sip_show_objects(int fd, int argc, char *argv[]);
static void print_group(int fd, unsigned int group, int crlf);
-static const char *dtmfmode2str(int mode);
-static const char *insecure2str(int port, int invite);
+static const char *dtmfmode2str(int mode) __attribute__ ((const));
+static const char *insecure2str(int port, int invite) __attribute__ ((const));
static void cleanup_stale_contexts(char *new, char *old);
static void print_codec_to_cli(int fd, struct ast_codec_pref *pref);
static const char *domain_mode_to_text(const enum domain_mode mode);
@@ -1308,7 +1308,7 @@ static int _sip_show_peer(int type, int fd, struct mansession *s, struct message
static int sip_show_user(int fd, int argc, char *argv[]);
static int sip_show_registry(int fd, int argc, char *argv[]);
static int sip_show_settings(int fd, int argc, char *argv[]);
-static const char *subscription_type2str(enum subscriptiontype subtype);
+static const char *subscription_type2str(enum subscriptiontype subtype) __attribute__ ((pure));
static const struct cfsubscription_types *find_subscription_type(enum subscriptiontype subtype);
static int __sip_show_channels(int fd, int argc, char *argv[], int subscriptions);
static int sip_show_channels(int fd, int argc, char *argv[]);
@@ -1384,7 +1384,7 @@ static int sip_prune_realtime(int fd, int argc, char *argv[]);
static int ast_sip_ouraddrfor(struct in_addr *them, struct in_addr *us);
static void sip_registry_destroy(struct sip_registry *reg);
static int sip_register(char *value, int lineno);
-static char *regstate2str(enum sipregistrystate regstate);
+static char *regstate2str(enum sipregistrystate regstate) __attribute__ ((const));
static int sip_reregister(void *data);
static int __sip_do_register(struct sip_registry *r);
static int sip_reg_timeout(void *data);
@@ -1401,7 +1401,7 @@ static int find_sip_method(const char *msg);
static unsigned int parse_sip_options(struct sip_pvt *pvt, const char *supported);
static void parse_request(struct sip_request *req);
static const char *get_header(const struct sip_request *req, const char *name);
-static char *referstatus2str(enum referstatus rstatus);
+static char *referstatus2str(enum referstatus rstatus) __attribute__ ((pure));
static int method_match(enum sipmethod id, const char *name);
static void parse_copy(struct sip_request *dst, const struct sip_request *src);
static char *get_in_brackets(char *tmp);
diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h
index fe2b33ed9..1af18717e 100644
--- a/include/asterisk/channel.h
+++ b/include/asterisk/channel.h
@@ -955,14 +955,14 @@ int ast_channel_masquerade(struct ast_channel *original, struct ast_channel *clo
* Give a name to a cause code
* Returns the text form of the binary cause code given
*/
-const char *ast_cause2str(int state);
+const char *ast_cause2str(int state) __attribute__ ((pure));
/*! Convert the string form of a cause code to a number */
/*!
* \param name string form of the cause
* Returns the cause code
*/
-int ast_str2cause(const char *name);
+int ast_str2cause(const char *name) __attribute__ ((pure));
/*! Gives the string form of a given channel state */
/*!
@@ -979,7 +979,7 @@ char *ast_state2str(int state);
* See above
* Returns the text form of the binary transfer capbility
*/
-char *ast_transfercapability2str(int transfercapability);
+char *ast_transfercapability2str(int transfercapability) __attribute__ ((const));
/* Options: Some low-level drivers may implement "options" allowing fine tuning of the
low level channel. See frame.h for options. Note that many channel drivers may support