Skip to content

Commit

Permalink
Add a new __sentinel attribute.
Browse files Browse the repository at this point in the history
The sentinel attribute was originally implemented in OpenBSD's gcc and
later adopted by upstream GCC 4.0 (and clang). From the OpenBSD's
gcc-local manpage:

-   gcc recognizes the extra attribute __sentinel__, which can be used to
    mark varargs function that need a NULL pointer to mark argument
    termination, like execl(3).  This exposes latent bugs for 64-bit
    architectures, where a terminating 0 will expand to a 32-bit int, and
    not a full-fledged 64-bits pointer.

While here sort the visibility attributes.

Hinted-by:	OpenBSD
  • Loading branch information
pgiffuni committed Jun 29, 2015
1 parent 7bb3697 commit 1374252
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions sys/sys/cdefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -469,11 +469,13 @@
#endif

#if __GNUC_PREREQ__(4, 0)
#define __hidden __attribute__((__visibility__("hidden")))
#define __sentinel __attribute__((__sentinel__))
#define __exported __attribute__((__visibility__("default")))
#define __hidden __attribute__((__visibility__("hidden")))
#else
#define __hidden
#define __sentinel
#define __exported
#define __hidden
#endif

/*
Expand Down

0 comments on commit 1374252

Please sign in to comment.