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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgo/] [runtime/] [go-strplus.c] - Blame information for rev 820

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

Line No. Rev Author Line
1 747 jeremybenn
/* go-strplus.c -- the go string append function.
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 "go-string.h"
8
#include "runtime.h"
9
#include "arch.h"
10
#include "malloc.h"
11
 
12
struct __go_string
13
__go_string_plus (struct __go_string s1, struct __go_string s2)
14
{
15
  int len;
16
  unsigned char *retdata;
17
  struct __go_string ret;
18
 
19
  if (s1.__length == 0)
20
    return s2;
21
  else if (s2.__length == 0)
22
    return s1;
23
 
24
  len = s1.__length + s2.__length;
25
  retdata = runtime_mallocgc (len, FlagNoPointers, 1, 0);
26
  __builtin_memcpy (retdata, s1.__data, s1.__length);
27
  __builtin_memcpy (retdata + s1.__length, s2.__data, s2.__length);
28
  ret.__data = retdata;
29
  ret.__length = len;
30
  return ret;
31
}

powered by: WebSVN 2.1.0

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