Runtime optimization

master
MelwareDE 14 years ago
parent be8968c915
commit ffcf6757d6
  1. 1
      chan_capi.c
  2. 1
      chan_capi_chat.c
  3. 1
      chan_capi_command.c
  4. 25
      chan_capi_platform.h
  5. 3
      chan_capi_qsig_asn197ade.c
  6. 1
      chan_capi_qsig_asn197no.c
  7. 1
      chan_capi_qsig_core.c
  8. 1
      chan_capi_qsig_ecma.c
  9. 1
      chan_capi_rtp.c
  10. 1
      chan_capi_supplementary.c
  11. 5
      chan_capi_utils.c
  12. 2
      chan_capi_utils.h
  13. 26
      libcapi20/capi20.c
  14. 24
      libcapi20/capi20_platform.h

@ -26,6 +26,7 @@
#include <math.h>
#include <sys/types.h>
#include "chan_capi_platform.h"
#include "xlaw.h"
#include "chan_capi20.h"
#include "chan_capi.h"

@ -15,6 +15,7 @@
#include <errno.h>
#include <sys/signal.h>
#include "chan_capi_platform.h"
#include "chan_capi20.h"
#include "chan_capi.h"
#include "chan_capi_chat.h"

@ -33,6 +33,7 @@
#include <sys/types.h>
#include <ctype.h>
#include "chan_capi_platform.h"
#include "xlaw.h"
#include "chan_capi20.h"
#include "chan_capi.h"

@ -0,0 +1,25 @@
#ifndef __CHAN_CAPI_PLATFORM_H__
#define __CHAN_CAPI_PLATFORM_H__
#if __GNUC__ >= 3 /* { */
#ifndef likely
#define likely(x) __builtin_expect(!!(x), 1)
#endif
#ifndef unlikely
#define unlikely(x) __builtin_expect(!!(x), 0)
#endif
#else /* } { */
#ifndef likely
#define likely(x) (!!(__x__))
#endif
#ifndef unlikely
#define unlikely(__x__) (!!(__x__))
#endif
#endif /* } */
#endif

@ -18,7 +18,8 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "chan_capi_platform.h"
#include "chan_capi20.h"
#include "chan_capi.h"
#include "chan_capi_utils.h"

@ -19,6 +19,7 @@
#include <stdio.h>
#include <string.h>
#include "chan_capi_platform.h"
#include "chan_capi20.h"
#include "chan_capi.h"
#include "chan_capi_utils.h"

@ -15,6 +15,7 @@
#include <stdio.h>
#include <string.h>
#include "chan_capi_platform.h"
#include "chan_capi20.h"
#include "chan_capi.h"
#include "chan_capi_utils.h"

@ -15,6 +15,7 @@
#include <stdio.h>
#include <string.h>
#include "chan_capi_platform.h"
#include "chan_capi20.h"
#include "chan_capi.h"
#include "chan_capi_utils.h"

@ -19,6 +19,7 @@
#include <sys/types.h>
#include <sys/socket.h>
#include "chan_capi_platform.h"
#include "chan_capi20.h"
#include "chan_capi.h"
#include "chan_capi_rtp.h"

@ -13,6 +13,7 @@
#include <stdlib.h>
#include <unistd.h>
#include "chan_capi_platform.h"
#include "chan_capi20.h"
#include "chan_capi.h"
#include "chan_capi_supplementary.h"

@ -17,6 +17,7 @@
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include "chan_capi_platform.h"
#include "xlaw.h"
#include "chan_capi20.h"
#include "chan_capi.h"
@ -239,7 +240,7 @@ struct capi_pvt *capi_find_interface_by_plci(unsigned int plci)
{
struct capi_pvt *i;
if (plci == 0)
if (unlikely(plci == 0))
return NULL;
for (i = capi_iflist; i; i = i->next) {
@ -435,7 +436,7 @@ MESSAGE_EXCHANGE_ERROR capi_sendf(
va_start(ap, format);
for (i = 0; format[i]; i++) {
if (((p - (&msg[0])) + 12) >= sizeof(msg)) {
if (unlikely(((p - (&msg[0])) + 12) >= sizeof(msg))) {
cc_log(LOG_ERROR, "capi_sendf: message too big (%d)\n",
(int)(p - (&msg[0])));
return 0x1004;

@ -21,7 +21,7 @@ extern char *emptyid;
extern void cc_verbose_internal(char *text, ...);
static inline int cc_verbose_check(int o_v, int c_d) {
if ((o_v == 0) || (option_verbose > o_v)) {
if (unlikely((o_v == 0) || (option_verbose > o_v))) {
if ((!c_d) || ((c_d) && (capidebug))) {
return (1);
}

@ -25,6 +25,8 @@
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include "capi20_platform.h"
#include "capi20.h"
@ -311,9 +313,17 @@ static void write_capi_trace(int send, unsigned char *buf, int length, int datam
}
}
unsigned capi20_isinstalled (void)
static inline unsigned capi20_isinstalled_internal(void)
{
if (likely(capi_fd >= 0))
return CapiNoError;
return (capi20_isinstalled());
}
unsigned capi20_isinstalled(void)
{
if (capi_fd >= 0)
if (likely(capi_fd >= 0))
return CapiNoError;
/*----- open managment link -----*/
@ -696,10 +706,10 @@ capi20_put_message (unsigned ApplID, unsigned char *Msg)
int fd;
int datareq = 0;
if (capi20_isinstalled() != CapiNoError)
if (capi20_isinstalled_internal() != CapiNoError)
return CapiRegNotInstalled;
if (!validapplid(ApplID))
if (unlikely(!validapplid(ApplID)))
return CapiIllAppNr;
fd = applid2fd(ApplID);
@ -797,10 +807,10 @@ capi20_get_message (unsigned ApplID, unsigned char **Buf)
size_t bufsiz;
int rc, fd;
if (capi20_isinstalled() != CapiNoError)
if (capi20_isinstalled_internal() != CapiNoError)
return CapiRegNotInstalled;
if (!validapplid(ApplID))
if (unlikely(!validapplid(ApplID)))
return CapiIllAppNr;
fd = applid2fd(ApplID);
@ -1009,10 +1019,10 @@ capi20_waitformessage(unsigned ApplID, struct timeval *TimeOut)
FD_ZERO(&rfds);
if (capi20_isinstalled() != CapiNoError)
if (capi20_isinstalled_internal() != CapiNoError)
return CapiRegNotInstalled;
if (!validapplid(ApplID))
if (unlikely(!validapplid(ApplID)))
return CapiIllAppNr;
fd = applid2fd(ApplID);

@ -0,0 +1,24 @@
#ifndef __CAPI20_PLATFORM_H__
#define __CAPI20_PLATFORM_H__
#if __GNUC__ >= 3 /* { */
#ifndef likely
#define likely(x) __builtin_expect(!!(x), 1)
#endif
#ifndef unlikely
#define unlikely(x) __builtin_expect(!!(x), 0)
#endif
#else /* } { */
#ifndef likely
#define likely(x) (!!(__x__))
#endif
#ifndef unlikely
#define unlikely(__x__) (!!(__x__))
#endif
#endif /* } */
#endif
Loading…
Cancel
Save