Skip to content

Commit

Permalink
runtime: use correct types for maxstring and concatstring
Browse files Browse the repository at this point in the history
Updates #6046.
This CL just does maxstring and concatstring. There are other functions
to fix but doing them a few at a time will help isolate any (unlikely)
breakages these changes bring up in architectures I can't test
myself.

R=golang-dev, dave, iant
CC=golang-dev
https://golang.org/cl/12519044
  • Loading branch information
robpike committed Aug 6, 2013
1 parent ad119b9 commit 98a80b9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
2 changes: 0 additions & 2 deletions src/pkg/runtime/print.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,6 @@ runtime·printpointer(void *p)
void
runtime·printstring(String v)
{
extern uint32 runtime·maxstring;

if(v.len > runtime·maxstring) {
gwrite("[string too long]", 17);
return;
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/runtime/runtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ extern int8* runtime·goos;
extern int32 runtime·ncpu;
extern bool runtime·iscgo;
extern void (*runtime·sysargs)(int32, uint8**);
extern uint32 runtime·maxstring;
extern uintptr runtime·maxstring;
extern uint32 runtime·Hchansize;
extern uint32 runtime·cpuid_ecx;
extern uint32 runtime·cpuid_edx;
Expand Down
8 changes: 4 additions & 4 deletions src/pkg/runtime/string.goc
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ runtime·findnullw(uint16 *s)
return l;
}

uint32 runtime·maxstring = 256; // a hint for print
uintptr runtime·maxstring = 256; // a hint for print

static String
gostringsize(intgo l)
{
String s;
uint32 ms;
uintptr ms;

if(l == 0)
return runtime·emptystring;
Expand All @@ -51,7 +51,7 @@ gostringsize(intgo l)
s.str[l] = 0;
for(;;) {
ms = runtime·maxstring;
if((uint32)l <= ms || runtime·cas(&runtime·maxstring, ms, (uint32)l))
if((uintptr)l <= ms || runtime·casp((void**)&runtime·maxstring, (void*)ms, (void*)l))
break;
}
return s;
Expand Down Expand Up @@ -176,7 +176,7 @@ concatstring(intgo n, String *s)
// not have a fixed size argument count.
#pragma textflag 7
void
runtime·concatstring(int32 n, String s1, ...)
runtime·concatstring(intgo n, String s1, ...)
{
(&s1)[n] = concatstring(n, &s1);
}
Expand Down

0 comments on commit 98a80b9

Please sign in to comment.