mirror of
https://github.com/golang/go.git
synced 2025-05-30 19:52:53 +00:00
cmd/cc,runtime: change preprocessor to expand macros inside of
#pragma textflag and #pragma dataflag directives. Update dataflag directives to use symbols instead of integer constants. R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/13310043
This commit is contained in:
parent
f5f0e40e80
commit
ed467db6d8
@ -567,7 +567,19 @@ pragfpround(void)
|
|||||||
void
|
void
|
||||||
pragtextflag(void)
|
pragtextflag(void)
|
||||||
{
|
{
|
||||||
textflag = getnsn();
|
Sym *s;
|
||||||
|
|
||||||
|
s = getsym();
|
||||||
|
if(s == S) {
|
||||||
|
textflag = getnsn();
|
||||||
|
} else {
|
||||||
|
if(s->macro) {
|
||||||
|
macexpand(s, symb);
|
||||||
|
}
|
||||||
|
if(symb[0] < '0' || symb[0] > '9')
|
||||||
|
yyerror("pragma textflag not an integer");
|
||||||
|
textflag = atoi(symb);
|
||||||
|
}
|
||||||
while(getnsc() != '\n')
|
while(getnsc() != '\n')
|
||||||
;
|
;
|
||||||
if(debug['f'])
|
if(debug['f'])
|
||||||
@ -577,7 +589,19 @@ pragtextflag(void)
|
|||||||
void
|
void
|
||||||
pragdataflag(void)
|
pragdataflag(void)
|
||||||
{
|
{
|
||||||
dataflag = getnsn();
|
Sym *s;
|
||||||
|
|
||||||
|
s = getsym();
|
||||||
|
if(s == S) {
|
||||||
|
dataflag = getnsn();
|
||||||
|
} else {
|
||||||
|
if(s->macro) {
|
||||||
|
macexpand(s, symb);
|
||||||
|
}
|
||||||
|
if(symb[0] < '0' || symb[0] > '9')
|
||||||
|
yyerror("pragma dataflag not an integer");
|
||||||
|
dataflag = atoi(symb);
|
||||||
|
}
|
||||||
while(getnsc() != '\n')
|
while(getnsc() != '\n')
|
||||||
;
|
;
|
||||||
if(debug['f'])
|
if(debug['f'])
|
||||||
|
@ -7,13 +7,13 @@
|
|||||||
// all agree on these values.
|
// all agree on these values.
|
||||||
|
|
||||||
// Don't profile the marked routine. This flag is deprecated.
|
// Don't profile the marked routine. This flag is deprecated.
|
||||||
#define NOPROF (1<<0)
|
#define NOPROF 1
|
||||||
// It is ok for the linker to get multiple of these symbols. It will
|
// It is ok for the linker to get multiple of these symbols. It will
|
||||||
// pick one of the duplicates to use.
|
// pick one of the duplicates to use.
|
||||||
#define DUPOK (1<<1)
|
#define DUPOK 2
|
||||||
// Don't insert stack check preamble.
|
// Don't insert stack check preamble.
|
||||||
#define NOSPLIT (1<<2)
|
#define NOSPLIT 4
|
||||||
// Put this data in a read-only section.
|
// Put this data in a read-only section.
|
||||||
#define RODATA (1<<3)
|
#define RODATA 8
|
||||||
// This data contains no pointers.
|
// This data contains no pointers.
|
||||||
#define NOPTR (1<<4)
|
#define NOPTR 16
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include "hashmap.h"
|
#include "hashmap.h"
|
||||||
#include "type.h"
|
#include "type.h"
|
||||||
#include "race.h"
|
#include "race.h"
|
||||||
|
#include "../../cmd/ld/textflag.h"
|
||||||
|
|
||||||
// This file contains the implementation of Go's map type.
|
// This file contains the implementation of Go's map type.
|
||||||
//
|
//
|
||||||
@ -524,7 +525,7 @@ hash_lookup(MapType *t, Hmap *h, byte **keyp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// When an item is not found, fast versions return a pointer to this zeroed memory.
|
// When an item is not found, fast versions return a pointer to this zeroed memory.
|
||||||
#pragma dataflag 16 // no pointers
|
#pragma dataflag RODATA
|
||||||
static uint8 empty_value[MAXVALUESIZE];
|
static uint8 empty_value[MAXVALUESIZE];
|
||||||
|
|
||||||
// Specialized versions of mapaccess1 for specific types.
|
// Specialized versions of mapaccess1 for specific types.
|
||||||
@ -593,7 +594,6 @@ static uint8 empty_value[MAXVALUESIZE];
|
|||||||
#define SLOW_EQ(x,y) runtime·memeq((x).str, (y).str, (x).len)
|
#define SLOW_EQ(x,y) runtime·memeq((x).str, (y).str, (x).len)
|
||||||
#define MAYBE_EQ(x,y) (*(CHECKTYPE*)(x).str == *(CHECKTYPE*)(y).str && *(CHECKTYPE*)((x).str + (x).len - sizeof(CHECKTYPE)) == *(CHECKTYPE*)((y).str + (x).len - sizeof(CHECKTYPE)))
|
#define MAYBE_EQ(x,y) (*(CHECKTYPE*)(x).str == *(CHECKTYPE*)(y).str && *(CHECKTYPE*)((x).str + (x).len - sizeof(CHECKTYPE)) == *(CHECKTYPE*)((y).str + (x).len - sizeof(CHECKTYPE)))
|
||||||
#include "hashmap_fast.c"
|
#include "hashmap_fast.c"
|
||||||
#include "../../cmd/ld/textflag.h"
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
hash_insert(MapType *t, Hmap *h, void *key, void *value)
|
hash_insert(MapType *t, Hmap *h, void *key, void *value)
|
||||||
|
@ -17,7 +17,7 @@ package runtime
|
|||||||
#include "../../cmd/ld/textflag.h"
|
#include "../../cmd/ld/textflag.h"
|
||||||
|
|
||||||
// Mark mheap as 'no pointers', it does not contain interesting pointers but occupies ~45K.
|
// Mark mheap as 'no pointers', it does not contain interesting pointers but occupies ~45K.
|
||||||
#pragma dataflag 16
|
#pragma dataflag NOPTR
|
||||||
MHeap runtime·mheap;
|
MHeap runtime·mheap;
|
||||||
|
|
||||||
int32 runtime·checking;
|
int32 runtime·checking;
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include "typekind.h"
|
#include "typekind.h"
|
||||||
#include "hashmap.h"
|
#include "hashmap.h"
|
||||||
#include "funcdata.h"
|
#include "funcdata.h"
|
||||||
|
#include "../../cmd/ld/textflag.h"
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
Debug = 0,
|
Debug = 0,
|
||||||
@ -299,7 +300,7 @@ struct BufferList
|
|||||||
uint32 busy;
|
uint32 busy;
|
||||||
byte pad[CacheLineSize];
|
byte pad[CacheLineSize];
|
||||||
};
|
};
|
||||||
#pragma dataflag 16 // no pointers
|
#pragma dataflag NOPTR
|
||||||
static BufferList bufferList[MaxGcproc];
|
static BufferList bufferList[MaxGcproc];
|
||||||
|
|
||||||
static Type *itabtype;
|
static Type *itabtype;
|
||||||
|
@ -169,7 +169,7 @@ runtime·get_random_data(byte **rnd, int32 *rnd_len)
|
|||||||
*rnd = runtime·startup_random_data;
|
*rnd = runtime·startup_random_data;
|
||||||
*rnd_len = runtime·startup_random_data_len;
|
*rnd_len = runtime·startup_random_data_len;
|
||||||
} else {
|
} else {
|
||||||
#pragma dataflag 16 // no pointers
|
#pragma dataflag NOPTR
|
||||||
static byte urandom_data[HashRandomBytes];
|
static byte urandom_data[HashRandomBytes];
|
||||||
int32 fd;
|
int32 fd;
|
||||||
fd = runtime·open("/dev/urandom", 0 /* O_RDONLY */, 0);
|
fd = runtime·open("/dev/urandom", 0 /* O_RDONLY */, 0);
|
||||||
|
@ -324,7 +324,7 @@ runtime·memlimit(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma dataflag 16 // no pointers
|
#pragma dataflag NOPTR
|
||||||
static int8 badsignal[] = "runtime: signal received on thread not created by Go.\n";
|
static int8 badsignal[] = "runtime: signal received on thread not created by Go.\n";
|
||||||
|
|
||||||
// This runs on a foreign stack, without an m or a g. No stack split.
|
// This runs on a foreign stack, without an m or a g. No stack split.
|
||||||
|
@ -478,7 +478,7 @@ runtime·memlimit(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma dataflag 16 // no pointers
|
#pragma dataflag NOPTR
|
||||||
int8 runtime·badsignalmsg[] = "runtime: signal received on thread not created by Go.\n";
|
int8 runtime·badsignalmsg[] = "runtime: signal received on thread not created by Go.\n";
|
||||||
int32 runtime·badsignallen = sizeof runtime·badsignalmsg - 1;
|
int32 runtime·badsignallen = sizeof runtime·badsignalmsg - 1;
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
package sync
|
package sync
|
||||||
#include "runtime.h"
|
#include "runtime.h"
|
||||||
#include "arch_GOARCH.h"
|
#include "arch_GOARCH.h"
|
||||||
|
#include "../../cmd/ld/textflag.h"
|
||||||
|
|
||||||
typedef struct SemaWaiter SemaWaiter;
|
typedef struct SemaWaiter SemaWaiter;
|
||||||
struct SemaWaiter
|
struct SemaWaiter
|
||||||
@ -50,7 +51,7 @@ struct semtable
|
|||||||
SemaRoot;
|
SemaRoot;
|
||||||
uint8 pad[CacheLineSize-sizeof(SemaRoot)];
|
uint8 pad[CacheLineSize-sizeof(SemaRoot)];
|
||||||
};
|
};
|
||||||
#pragma dataflag 16 /* mark semtable as 'no pointers', hiding from garbage collector */
|
#pragma dataflag NOPTR /* mark semtable as 'no pointers', hiding from garbage collector */
|
||||||
static struct semtable semtable[SEMTABLESZ];
|
static struct semtable semtable[SEMTABLESZ];
|
||||||
|
|
||||||
static SemaRoot*
|
static SemaRoot*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user