예제 #1
0
/*
 * DD 2016-10-11
 * The builtin function __builtin_strchr() should be supported
 *
 */
int main()                                                                  
{                                                                               
  char buffer1[40] = "computer program";                                      
  char * ptr;                                                                   
  int    ch = 'p';                                                              

  ptr = __builtin_strchr( buffer1, ch );                                                  
  //printf( "The first occurrence of %c in '%s' is '%s'\n", ch, buffer1, ptr);                                                 
}  
예제 #2
0
파일: pr36513.c 프로젝트: sylvestre/gcc
int main1 ()
{
  char *s, t;
  (__extension__ (__builtin_constant_p (t) 
		  && !__builtin_constant_p (s) 
		  && (t) == '\0' 
		  ? (char *) __rawmemchr (s, t) 
		  : __builtin_strchr (s, t)));
  return 0;
}
예제 #3
0
파일: pr34029-1.c 프로젝트: 0day-ci/gcc
int
foo (const char *x)
{
  const char *a;
  int b = 0;

  a = __builtin_strchr (s, '.');
  if (a == 0)
    b = 1;
  else if ((a = __builtin_strchr (a + 1, '.')) == 0)
    b = 1;
  else if (__builtin_strncmp (s, x, a - s))
    b = 1;
  else if (__builtin_strncmp (a + 1, x + (a - s + 1), 4) < 0)
    b = 1;

  if (b)
    return 4;
  return 0;
}
예제 #4
0
파일: pr53908.c 프로젝트: 0day-ci/gcc
static int
is_basic(char **user)
{
  char *passwd_ptr;
  char *authent = foo();
  passwd_ptr = __builtin_strchr(authent, ':');
  if (passwd_ptr != ((void *)0)) {
    *user = g_strdup(authent);
    return 0;
  }
  return -1;
}
예제 #5
0
int main(int argc, char **argv) {
  int a;
  a = __builtin_bswap32(a);
  a = __builtin_bswap64(a);
  a = __builtin_constant_p(1);
  a = __builtin_constant_p("string");
  char *b = __builtin_strchr("string", 's');
  a = __builtin_expect(1, a);
  a = __builtin_strlen("string");
  a = __builtin_strcmp("string1", "string2");
  a = __builtin_offsetof(struct point, y);
  char c[100];
  b = __builtin_strcpy(c, "a");
  b = __builtin_strncpy(c, "a", 1);
  a = __builtin_ctzl(a);
  varargsfn(0);
  __builtin_prefetch(b);
  __builtin_prefetch(b, 1);
  __builtin_prefetch(b, 1, 1);
  return a;
}
예제 #6
0
static int
callback (void *data, uintptr_t pc, const char *filename, int lineno,
	  const char *function)
{
  struct callers_data *arg = (struct callers_data *) data;
  Location *loc;

  /* Skip split stack functions.  */
  if (function != NULL)
    {
      const char *p;

      p = function;
      if (__builtin_strncmp (p, "___", 3) == 0)
	++p;
      if (__builtin_strncmp (p, "__morestack_", 12) == 0)
	return 0;
    }
  else if (filename != NULL)
    {
      const char *p;

      p = strrchr (filename, '/');
      if (p == NULL)
	p = filename;
      if (__builtin_strncmp (p, "/morestack.S", 12) == 0)
	return 0;
    }

  /* Skip thunks and recover functions.  There is no equivalent to
     these functions in the gc toolchain, so returning them here means
     significantly different results for runtime.Caller(N).  */
  if (function != NULL)
    {
      const char *p;

      p = __builtin_strchr (function, '.');
      if (p != NULL && __builtin_strncmp (p + 1, "$thunk", 6) == 0)
	return 0;
      p = __builtin_strrchr (function, '$');
      if (p != NULL && __builtin_strcmp(p, "$recover") == 0)
	return 0;
    }

  if (arg->skip > 0)
    {
      --arg->skip;
      return 0;
    }

  loc = &arg->locbuf[arg->index];
  loc->pc = pc;

  /* The libbacktrace library says that these strings might disappear,
     but with the current implementation they won't.  We can't easily
     allocate memory here, so for now assume that we can save a
     pointer to the strings.  */
  loc->filename = runtime_gostringnocopy ((const byte *) filename);
  loc->function = runtime_gostringnocopy ((const byte *) function);

  loc->lineno = lineno;
  ++arg->index;
  return arg->index >= arg->max;
}
예제 #7
0
static int
callback (void *data, uintptr_t pc, const char *filename, int lineno,
	  const char *function)
{
  struct callers_data *arg = (struct callers_data *) data;
  Location *loc;

  /* Skip split stack functions.  */
  if (function != NULL)
    {
      const char *p;

      p = function;
      if (__builtin_strncmp (p, "___", 3) == 0)
	++p;
      if (__builtin_strncmp (p, "__morestack_", 12) == 0)
	return 0;
    }
  else if (filename != NULL)
    {
      const char *p;

      p = strrchr (filename, '/');
      if (p == NULL)
	p = filename;
      if (__builtin_strncmp (p, "/morestack.S", 12) == 0)
	return 0;
    }

  /* Skip thunks and recover functions.  There is no equivalent to
     these functions in the gc toolchain, so returning them here means
     significantly different results for runtime.Caller(N).  */
  if (function != NULL)
    {
      const char *p;

      p = __builtin_strchr (function, '.');
      if (p != NULL && __builtin_strncmp (p + 1, "$thunk", 6) == 0)
	return 0;
      p = __builtin_strrchr (function, '$');
      if (p != NULL && __builtin_strcmp(p, "$recover") == 0)
	return 0;
    }

  if (arg->skip > 0)
    {
      --arg->skip;
      return 0;
    }

  loc = &arg->locbuf[arg->index];
  loc->pc = pc;

  /* The libbacktrace library says that these strings might disappear,
     but with the current implementation they won't.  We can't easily
     allocate memory here, so for now assume that we can save a
     pointer to the strings.  */
  loc->filename = runtime_gostringnocopy ((const byte *) filename);
  loc->function = runtime_gostringnocopy ((const byte *) function);

  loc->lineno = lineno;
  ++arg->index;

  /* There is no point to tracing past certain runtime functions.
     Stopping the backtrace here can avoid problems on systems that
     don't provide proper unwind information for makecontext, such as
     Solaris (http://gcc.gnu.org/PR52583 comment #21).  */
  if (function != NULL)
    {
      if (__builtin_strcmp (function, "makecontext") == 0)
	return 1;
      if (filename != NULL)
	{
	  const char *p;

	  p = strrchr (filename, '/');
	  if (p == NULL)
	    p = filename;
	  if (__builtin_strcmp (p, "/proc.c") == 0)
	    {
	      if (__builtin_strcmp (function, "kickoff") == 0
		  || __builtin_strcmp (function, "runtime_mstart") == 0
		  || __builtin_strcmp (function, "runtime_main") == 0)
		return 1;
	    }
	}
    }

  return arg->index >= arg->max;
}