Back to index

php5  5.3.10
Defines | Functions
php_reentrancy.h File Reference
#include "php.h"
#include <sys/types.h>
#include <time.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define HAVE_LOCALTIME   1
#define HAVE_GMTIME   1
#define HAVE_ASCTIME   1
#define HAVE_CTIME   1
#define PHP_NEED_REENTRANCY   1
#define PHP_NEED_REENTRANCY   1
#define PHP_NEED_REENTRANCY   1
#define PHP_NEED_REENTRANCY   1

Functions

PHPAPI int php_readdir_r (DIR *dirp, struct dirent *entry, struct dirent **result)
PHPAPI struct tm * php_localtime_r (const time_t *const timep, struct tm *p_tm)
PHPAPI char * php_ctime_r (const time_t *clock, char *buf)
PHPAPI char * php_asctime_r (const struct tm *tm, char *buf)
PHPAPI struct tm * php_gmtime_r (const time_t *const timep, struct tm *p_tm)
PHPAPI char * php_strtok_r (char *s, const char *delim, char **last)
PHPAPI int php_rand_r (unsigned int *seed)
void reentrancy_startup (void)
void reentrancy_shutdown (void)

Define Documentation

#define HAVE_ASCTIME   1

Definition at line 37 of file php_reentrancy.h.

#define HAVE_CTIME   1

Definition at line 38 of file php_reentrancy.h.

#define HAVE_GMTIME   1

Definition at line 36 of file php_reentrancy.h.

#define HAVE_LOCALTIME   1

Definition at line 35 of file php_reentrancy.h.

#define PHP_NEED_REENTRANCY   1

Definition at line 95 of file php_reentrancy.h.

#define PHP_NEED_REENTRANCY   1

Definition at line 95 of file php_reentrancy.h.

#define PHP_NEED_REENTRANCY   1

Definition at line 95 of file php_reentrancy.h.

#define PHP_NEED_REENTRANCY   1

Definition at line 95 of file php_reentrancy.h.


Function Documentation

PHPAPI char* php_asctime_r ( const struct tm *  tm,
char *  buf 
)

Definition at line 215 of file reentrancy.c.

{
       char *tmp;
       
       local_lock(ASCTIME_R);

       tmp = asctime(tm);
       strcpy(buf, tmp);

       local_unlock(ASCTIME_R);

       return buf;
}

Here is the caller graph for this function:

PHPAPI char* php_ctime_r ( const time_t *  clock,
char *  buf 
)

Definition at line 197 of file reentrancy.c.

{
       char *tmp;
       
       local_lock(CTIME_R);

       tmp = ctime(clock);
       strcpy(buf, tmp);

       local_unlock(CTIME_R);
       
       return buf;
}
PHPAPI struct tm* php_gmtime_r ( const time_t *const  timep,
struct tm *  p_tm 
) [read]

Definition at line 233 of file reentrancy.c.

{
       struct tm *tmp;
       
       local_lock(GMTIME_R);

       tmp = gmtime(timep);
       if (tmp) {
              memcpy(p_tm, tmp, sizeof(struct tm));
              tmp = p_tm;
       }
       
       local_unlock(GMTIME_R);

       return tmp;
}

Here is the caller graph for this function:

PHPAPI struct tm* php_localtime_r ( const time_t *const  timep,
struct tm *  p_tm 
) [read]

Definition at line 176 of file reentrancy.c.

{
       struct tm *tmp;
       
       local_lock(LOCALTIME_R);

       tmp = localtime(timep);
       if (tmp) {
              memcpy(p_tm, tmp, sizeof(struct tm));
              tmp = p_tm;
       }
       
       local_unlock(LOCALTIME_R);

       return tmp;
}

Here is the caller graph for this function:

PHPAPI int php_rand_r ( unsigned int seed)

Definition at line 322 of file reentrancy.c.

{
       u_long val = (u_long) *ctx;
       *ctx = do_rand(&val);
       return (int) *ctx;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PHPAPI int php_readdir_r ( DIR dirp,
struct dirent entry,
struct dirent **  result 
)

Definition at line 128 of file reentrancy.c.

{
#if defined(HAVE_OLD_READDIR_R)
       int ret = 0;
       
       /* We cannot rely on the return value of readdir_r
          as it differs between various platforms
          (HPUX returns 0 on success whereas Solaris returns non-zero)
        */
       entry->d_name[0] = '\0';
       readdir_r(dirp, entry);
       
       if (entry->d_name[0] == '\0') {
              *result = NULL;
              ret = errno;
       } else {
              *result = entry;
       }
       return ret;
#else
       struct dirent *ptr;
       int ret = 0;

       local_lock(READDIR_R);
       
       errno = 0;
       
       ptr = readdir(dirp);
       
       if (!ptr && errno != 0)
              ret = errno;

       if (ptr)
              memcpy(entry, ptr, sizeof(*ptr));

       *result = ptr;

       local_unlock(READDIR_R);

       return ret;
#endif
}

Here is the call graph for this function:

PHPAPI char* php_strtok_r ( char *  s,
const char *  delim,
char **  last 
)

Definition at line 380 of file reentrancy.c.

{
    char *spanp;
    int c, sc;
    char *tok;

    if (s == NULL && (s = *last) == NULL)
    {
       return NULL;
    }

    /*
     * Skip (span) leading delimiters (s += strspn(s, delim), sort of).
     */
cont:
    c = *s++;
    for (spanp = (char *)delim; (sc = *spanp++) != 0; )
    {
       if (c == sc)
       {
           goto cont;
       }
    }

    if (c == 0)             /* no non-delimiter characters */
    {
       *last = NULL;
       return NULL;
    }
    tok = s - 1;

    /*
     * Scan token (scan for delimiters: s += strcspn(s, delim), sort of).
     * Note that delim must have one NUL; we stop if we see that, too.
     */
    for (;;)
    {
       c = *s++;
       spanp = (char *)delim;
       do
       {
           if ((sc = *spanp++) == c)
           {
              if (c == 0)
              {
                  s = NULL;
              }
              else
              {
                  char *w = s - 1;
                  *w = '\0';
              }
              *last = s;
              return tok;
           }
       }
       while (sc != 0);
    }
    /* NOTREACHED */
}

Here is the call graph for this function:

Here is the caller graph for this function:

void reentrancy_shutdown ( void  )

Definition at line 263 of file reentrancy.c.

{
       int i;

       for (i = 0; i < NUMBER_OF_LOCKS; i++) {
              tsrm_mutex_free(reentrant_locks[i]);
       }
}

Here is the caller graph for this function:

void reentrancy_startup ( void  )

Definition at line 254 of file reentrancy.c.

{
       int i;

       for (i = 0; i < NUMBER_OF_LOCKS; i++) {
              reentrant_locks[i] = tsrm_mutex_alloc();
       }
}

Here is the caller graph for this function: