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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgo/] [go/] [bytes/] [indexbyte.c] - Blame information for rev 858

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 747 jeremybenn
/* indexbyte.c -- implement bytes.IndexByte for Go.
2
 
3
   Copyright 2009 The Go Authors. All rights reserved.
4
   Use of this source code is governed by a BSD-style
5
   license that can be found in the LICENSE file.  */
6
 
7
#include <stddef.h>
8
 
9
#include "array.h"
10
 
11
/* This is in C so that the compiler can optimize it appropriately.
12
   We deliberately don't split the stack in case it does call the
13
   library function, which shouldn't need much stack space.  */
14
 
15
int IndexByte (struct __go_open_array, char)
16
  asm ("libgo_bytes.bytes.IndexByte")
17
  __attribute__ ((no_split_stack));
18
 
19
int
20
IndexByte (struct __go_open_array s, char b)
21
{
22
  char *p;
23
 
24
  p = __builtin_memchr (s.__values, b, s.__count);
25
  if (p == NULL)
26
    return -1;
27
  return p - (char *) s.__values;
28
}
29
 
30
/* Comparison.  */
31
 
32
_Bool Equal (struct __go_open_array a, struct __go_open_array b)
33
  asm ("libgo_bytes.bytes.Equal")
34
  __attribute__ ((no_split_stack));
35
 
36
_Bool
37
Equal (struct __go_open_array a, struct __go_open_array b)
38
{
39
  if (a.__count != b.__count)
40
    return 0;
41
  return __builtin_memcmp (a.__values, b.__values, a.__count) == 0;
42
}

powered by: WebSVN 2.1.0

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