Merge ^/head r305081 through r305086.
This commit is contained in:
commit
43be9368ea
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/projects/clang390-import/; revision=305087
@ -1912,6 +1912,13 @@ underscores.
|
||||
|
||||
@table @code
|
||||
|
||||
@item __COUNTER__
|
||||
This macro expands to sequential integral values starting from 0. In
|
||||
conjuction with the @code{##} operator, this provides a convenient means to
|
||||
generate unique identifiers. Care must be taken to ensure that
|
||||
@code{__COUNTER__} is not expanded prior to inclusion of precompiled headers
|
||||
which use it. Otherwise, the precompiled headers will not be used.
|
||||
|
||||
@item __GNUC__
|
||||
@itemx __GNUC_MINOR__
|
||||
@itemx __GNUC_PATCHLEVEL__
|
||||
|
@ -12,6 +12,17 @@
|
||||
PR preprocessor/14331
|
||||
* lex.c (_cpp_get_fresh_line): Don't warn if no newline at EOF.
|
||||
|
||||
2007-05-24 Ollie Wild <aaw@google.com> (r125041)
|
||||
|
||||
* macro.c (_cpp_builtin_macro_text): Handle BT_COUNTER.
|
||||
* pch.c (cpp_write_pch_deps): Save __COUNTER__ state.
|
||||
(cpp_write_pch_state): Save __COUNTER__ state.
|
||||
(cpp_valid_state): Check valid __COUNTER__ state.
|
||||
(cpp_read_state): Read new __COUNTER__ state.
|
||||
* include/cpplib.h (enum builtin_type): Add BT_COUNTER enumerator.
|
||||
* init.c (builtin_array): Add __COUNTER__/BT_COUNTER.
|
||||
* internal.h (struct cpp_reader): Add counter member.
|
||||
|
||||
2007-05-21 Ian Lance Taylor <iant@google.com> (r124929)
|
||||
|
||||
* internal.h (struct cpp_reader): Add new fields:
|
||||
|
@ -458,7 +458,8 @@ struct cpp_reader
|
||||
of precompiled headers. */
|
||||
struct cpp_savedstate *savedstate;
|
||||
|
||||
unsigned int nextcounter;
|
||||
/* Next value of __COUNTER__ macro. */
|
||||
unsigned int counter;
|
||||
};
|
||||
|
||||
/* Character classes. Based on the more primitive macros in safe-ctype.h.
|
||||
|
@ -268,7 +268,7 @@ _cpp_builtin_macro_text (cpp_reader *pfile, cpp_hashnode *node)
|
||||
if (CPP_OPTION (pfile, directives_only) && pfile->state.in_directive)
|
||||
cpp_error (pfile, CPP_DL_ERROR,
|
||||
"__COUNTER__ expanded inside directive with -fdirectives-only");
|
||||
number = pfile->nextcounter++;
|
||||
number = pfile->counter++;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -337,6 +337,14 @@ cpp_write_pch_deps (cpp_reader *r, FILE *f)
|
||||
/* Free the saved state. */
|
||||
free (ss);
|
||||
r->savedstate = NULL;
|
||||
|
||||
/* Save the next value of __COUNTER__. */
|
||||
if (fwrite (&r->counter, sizeof (r->counter), 1, f) != 1)
|
||||
{
|
||||
cpp_errno (r, CPP_DL_ERROR, "while writing precompiled header");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -361,6 +369,15 @@ cpp_write_pch_state (cpp_reader *r, FILE *f)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Save the next __COUNTER__ value. When we include a precompiled header,
|
||||
we need to start at the offset we would have if the header had been
|
||||
included normally. */
|
||||
if (fwrite (&r->counter, sizeof (r->counter), 1, f) != 1)
|
||||
{
|
||||
cpp_errno (r, CPP_DL_ERROR, "while writing precompiled header");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -423,6 +440,7 @@ cpp_valid_state (cpp_reader *r, const char *name, int fd)
|
||||
struct ht_node_list nl = { 0, 0, 0 };
|
||||
unsigned char *first, *last;
|
||||
unsigned int i;
|
||||
unsigned int counter;
|
||||
|
||||
/* Read in the list of identifiers that must be defined
|
||||
Check that they are defined in the same way. */
|
||||
@ -524,7 +542,23 @@ cpp_valid_state (cpp_reader *r, const char *name, int fd)
|
||||
}
|
||||
|
||||
free(nl.defs);
|
||||
nl.defs = NULL;
|
||||
free (undeftab);
|
||||
undeftab = NULL;
|
||||
|
||||
/* Read in the next value of __COUNTER__.
|
||||
Check that (a) __COUNTER__ was not used in the pch or (b) __COUNTER__
|
||||
has not been used in this translation unit. */
|
||||
if (read (fd, &counter, sizeof (counter)) != sizeof (counter))
|
||||
goto error;
|
||||
if (counter && r->counter)
|
||||
{
|
||||
if (CPP_OPTION (r, warn_invalid_pch))
|
||||
cpp_error (r, CPP_DL_WARNING_SYSHDR,
|
||||
"%s: not used because `__COUNTER__' is invalid",
|
||||
name);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* We win! */
|
||||
return 0;
|
||||
@ -631,6 +665,7 @@ cpp_read_state (cpp_reader *r, const char *name, FILE *f,
|
||||
{
|
||||
size_t i;
|
||||
struct lexer_state old_state;
|
||||
unsigned int counter;
|
||||
|
||||
/* Restore spec_nodes, which will be full of references to the old
|
||||
hashtable entries and so will now be invalid. */
|
||||
@ -690,6 +725,12 @@ cpp_read_state (cpp_reader *r, const char *name, FILE *f,
|
||||
if (! _cpp_read_file_entries (r, f))
|
||||
goto error;
|
||||
|
||||
if (fread (&counter, sizeof (counter), 1, f) != 1)
|
||||
goto error;
|
||||
|
||||
if (!r->counter)
|
||||
r->counter = counter;
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
|
@ -112,7 +112,7 @@ static int send_tncmd(void (*)(int, int), const char *, char *);
|
||||
static int setmod(int);
|
||||
static int clearmode(int);
|
||||
static int modehelp(void);
|
||||
static int sourceroute(struct addrinfo *, char *, char **, int *, int *, int *);
|
||||
static int sourceroute(struct addrinfo *, char *, unsigned char **, int *, int *, int *);
|
||||
|
||||
typedef struct {
|
||||
const char *name; /* command name */
|
||||
@ -2171,7 +2171,7 @@ switch_af(struct addrinfo **aip)
|
||||
int
|
||||
tn(int argc, char *argv[])
|
||||
{
|
||||
char *srp = 0;
|
||||
unsigned char *srp = 0;
|
||||
int proto, opt;
|
||||
int srlen;
|
||||
int srcroute = 0, result;
|
||||
@ -2844,10 +2844,10 @@ cmdrc(char *m1, char *m2)
|
||||
* setsockopt, as socket protocol family.
|
||||
*/
|
||||
static int
|
||||
sourceroute(struct addrinfo *ai, char *arg, char **cpp, int *lenp, int *protop, int *optp)
|
||||
sourceroute(struct addrinfo *ai, char *arg, unsigned char **cpp, int *lenp, int *protop, int *optp)
|
||||
{
|
||||
static char buf[1024 + ALIGNBYTES]; /*XXX*/
|
||||
char *cp, *cp2, *lsrp, *ep;
|
||||
unsigned char *cp, *cp2, *lsrp, *ep;
|
||||
struct sockaddr_in *_sin;
|
||||
#ifdef INET6
|
||||
struct sockaddr_in6 *sin6;
|
||||
|
@ -2050,7 +2050,7 @@ abort_squared(int dummy)
|
||||
void
|
||||
abort_remote(FILE *din)
|
||||
{
|
||||
char buf[BUFSIZ];
|
||||
unsigned char buf[BUFSIZ];
|
||||
int nfnd;
|
||||
|
||||
if (cout == NULL) {
|
||||
|
@ -157,13 +157,16 @@ static void
|
||||
fcntl_tests_1(int fd)
|
||||
{
|
||||
uint32_t fcntlrights;
|
||||
cap_rights_t rights;
|
||||
|
||||
CHECK(cap_fcntls_limit(fd, CAP_FCNTL_GETFL) == 0);
|
||||
fcntlrights = 0;
|
||||
CHECK(cap_fcntls_get(fd, &fcntlrights) == 0);
|
||||
CHECK(fcntlrights == CAP_FCNTL_GETFL);
|
||||
|
||||
CHECK(cap_rights_limit(fd, CAP_ALL & ~CAP_FCNTL) == 0);
|
||||
CAP_ALL(&rights);
|
||||
cap_rights_clear(&rights, CAP_FCNTL);
|
||||
CHECK(cap_rights_limit(fd, &rights) == 0);
|
||||
|
||||
fcntlrights = CAP_FCNTL_ALL;
|
||||
CHECK(cap_fcntls_get(fd, &fcntlrights) == 0);
|
||||
@ -206,8 +209,11 @@ static void
|
||||
fcntl_tests_2(int fd)
|
||||
{
|
||||
uint32_t fcntlrights;
|
||||
cap_rights_t rights;
|
||||
|
||||
CHECK(cap_rights_limit(fd, CAP_ALL & ~CAP_FCNTL) == 0);
|
||||
CAP_ALL(&rights);
|
||||
cap_rights_clear(&rights, CAP_FCNTL);
|
||||
CHECK(cap_rights_limit(fd, &rights) == 0);
|
||||
|
||||
fcntlrights = CAP_FCNTL_ALL;
|
||||
CHECK(cap_fcntls_get(fd, &fcntlrights) == 0);
|
||||
|
@ -131,6 +131,7 @@ static void
|
||||
ioctl_tests_1(int fd)
|
||||
{
|
||||
unsigned long cmds[2];
|
||||
cap_rights_t rights;
|
||||
|
||||
cmds[0] = FIOCLEX;
|
||||
CHECK(cap_ioctls_limit(fd, cmds, 1) == 0);
|
||||
@ -139,7 +140,10 @@ ioctl_tests_1(int fd)
|
||||
CHECK(cmds[0] == FIOCLEX);
|
||||
CHECK(cmds[1] == 0);
|
||||
|
||||
CHECK(cap_rights_limit(fd, CAP_ALL & ~CAP_IOCTL) == 0);
|
||||
CAP_ALL(&rights);
|
||||
cap_rights_clear(&rights, CAP_IOCTL);
|
||||
|
||||
CHECK(cap_rights_limit(fd, &rights) == 0);
|
||||
CHECK(cap_ioctls_get(fd, cmds, nitems(cmds)) == 0);
|
||||
|
||||
cmds[0] = FIOCLEX;
|
||||
@ -173,8 +177,12 @@ static void
|
||||
ioctl_tests_2(int fd)
|
||||
{
|
||||
unsigned long cmds[2];
|
||||
cap_rights_t rights;
|
||||
|
||||
CHECK(cap_rights_limit(fd, CAP_ALL & ~CAP_IOCTL) == 0);
|
||||
CAP_ALL(&rights);
|
||||
cap_rights_clear(&rights, CAP_IOCTL);
|
||||
|
||||
CHECK(cap_rights_limit(fd, &rights) == 0);
|
||||
CHECK(cap_ioctls_get(fd, cmds, nitems(cmds)) == 0);
|
||||
|
||||
cmds[0] = FIOCLEX;
|
||||
|
Loading…
Reference in New Issue
Block a user