OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [branches/] [newlib/] [newlib/] [newlib/] [libc/] [stdio/] [tmpnam.c] - Diff between revs 39 and 56

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 39 Rev 56
Line 123... Line 123...
      t = _open_r (ptr, result, O_RDONLY, 0);
      t = _open_r (ptr, result, O_RDONLY, 0);
      if (t == -1)
      if (t == -1)
        {
        {
          if (ptr->_errno == ENOSYS)
          if (ptr->_errno == ENOSYS)
            {
            {
              result[0] = '0';
              result[0] = '\0';
              return 0;
              return 0;
            }
            }
          break;
          break;
        }
        }
      _close_r (ptr, t);
      _close_r (ptr, t);
Line 143... Line 143...
  char *result;
  char *result;
  int pid;
  int pid;
 
 
  if (s == NULL)
  if (s == NULL)
    {
    {
      result = _malloc_r (p, L_tmpnam + 1);
      /* ANSI states we must use an internal static buffer if s is NULL */
      /* ANSI says that a static buf must be used - so
 
       if malloc fails, we have one. */
 
      if (result == NULL)
 
        result = p->_emergency;
        result = p->_emergency;
    }
    }
  else
  else
    {
    {
      result = s;
      result = s;
Line 167... Line 164...
}
}
 
 
char *
char *
_DEFUN (_tempnam_r, (p, dir, pfx),
_DEFUN (_tempnam_r, (p, dir, pfx),
        struct _reent *p _AND
        struct _reent *p _AND
        char *dir _AND
        _CONST char *dir _AND
        char *pfx)
        _CONST char *pfx)
{
{
  char *filename;
  char *filename;
  int length;
  int length;
 
  _CONST char *prefix = (pfx) ? pfx : "";
  if (dir == NULL && (dir = getenv ("TMPDIR")) == NULL)
  if (dir == NULL && (dir = getenv ("TMPDIR")) == NULL)
    dir = P_tmpdir;
    dir = P_tmpdir;
 
 
  length = strlen (dir) + strlen (pfx) + 10 + 1;        /* two 8 digit
  /* two 8 digit numbers + . / */
                                                           numbers + . / */
  length = strlen (dir) + strlen (prefix) + (4 * sizeof (int)) + 2 + 1;
 
 
  filename = _malloc_r (p, length);
  filename = _malloc_r (p, length);
  if (filename)
  if (filename)
    {
    {
      if (! worker (p, filename, dir, pfx,
      if (! worker (p, filename, dir, prefix,
                    _getpid_r (p) ^ (int) (_POINTER_INT) p, &p->_inc))
                    _getpid_r (p) ^ (int) (_POINTER_INT) p, &p->_inc))
        return NULL;
        return NULL;
    }
    }
  return filename;
  return filename;
}
}
 
 
#ifndef _REENT_ONLY
#ifndef _REENT_ONLY
 
 
char *
char *
_DEFUN (tempnam, (dir, pfx),
_DEFUN (tempnam, (dir, pfx),
        char *dir _AND
        _CONST char *dir _AND
        char *pfx)
        _CONST char *pfx)
{
{
  return _tempnam_r (_REENT, dir, pfx);
  return _tempnam_r (_REENT, dir, pfx);
}
}
 
 
char *
char *

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.