Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable compiler __attribute__ assistance #345

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion calma/CalmaRead.c
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ calmaParseUnits(void)
*/

void
CalmaReadError(char *format, ...)
CalmaReadError(const char *format, ...)
{
va_list args;
OFFTYPE filepos;
Expand Down
2 changes: 1 addition & 1 deletion calma/calma.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ extern bool CalmaWrite(CellDef *rootDef, FILE *f);
extern void CalmaReadFile(FILETYPE file, char *filename);
extern void CalmaTechInit(void);
extern bool CalmaGenerateArray(FILE *f, TileType type, int llx, int lly, int pitch, int cols, int rows);
extern void CalmaReadError(char *format, ...);
extern void CalmaReadError(const char *format, ...) ATTR_FORMAT_PRINTF_1;

/* C99 compat */
extern void calmaDelContacts(void);
Expand Down
4 changes: 2 additions & 2 deletions cif/CIFrdutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ Plane *cifReadPlane; /* Plane into which to paint material

/* VARARGS1 */
void
CIFReadError(char *format, ...)
CIFReadError(const char *format, ...)
{
va_list args;

Expand All @@ -153,7 +153,7 @@ CIFReadError(char *format, ...)


void
CIFReadWarning(char *format, ...)
CIFReadWarning(const char *format, ...)
{
va_list args;

Expand Down
4 changes: 2 additions & 2 deletions cif/CIFread.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ extern int CIFEdgeDirection(CIFPath *first, CIFPath *last);

/* Variable argument procedures require complete prototype */

extern void CIFReadError(char *format, ...);
extern void CIFReadWarning(char *format, ...);
extern void CIFReadError(const char *format, ...) ATTR_FORMAT_PRINTF_1;
extern void CIFReadWarning(const char *format, ...) ATTR_FORMAT_PRINTF_1;

/* Variables shared by the CIF-reading modules, see CIFreadutils.c
* for more details:
Expand Down
2 changes: 1 addition & 1 deletion drc/DRCtech.c
Original file line number Diff line number Diff line change
Expand Up @@ -1020,7 +1020,7 @@ DRCTechAddRule(sectionName, argc, argv)
char *argv[];
{
int which, distance, mdist;
char *fmt;
const char *fmt;
static const struct
{
const char *rk_keyword; /* Initial keyword */
Expand Down
2 changes: 1 addition & 1 deletion ext2sim/ext2sim.c
Original file line number Diff line number Diff line change
Expand Up @@ -1603,7 +1603,7 @@ int simnodeVisit(node, res, cap)
EFNodeName *nn;
HierName *hierName;
bool isGlob;
char *fmt;
const char *fmt;
EFAttr *ap;

if (esDevNodesOnly && node->efnode_client == (ClientData) NULL)
Expand Down
2 changes: 1 addition & 1 deletion ext2spice/ext2hier.c
Original file line number Diff line number Diff line change
Expand Up @@ -1423,7 +1423,7 @@ spcnodeHierVisit(hc, node, res, cap)
EFNodeName *nn;
HierName *hierName;
bool isConnected = FALSE;
char *fmt, *nsn;
const char *fmt, *nsn;
EFAttr *ap;

if (node->efnode_client)
Expand Down
5 changes: 3 additions & 2 deletions ext2spice/ext2spice.c
Original file line number Diff line number Diff line change
Expand Up @@ -3669,7 +3669,8 @@ spcnodeVisit(node, res, cap)
EFNodeName *nn;
HierName *hierName;
bool isConnected = FALSE;
char *fmt, *nsn;
const char *fmt;
char *nsn;
EFAttr *ap;

if (node->efnode_client)
Expand Down Expand Up @@ -3731,7 +3732,7 @@ nodeVisitDebug(node, res, cap)
{
EFNodeName *nn;
HierName *hierName;
char *fmt, *nsn;
char *nsn;
EFAttr *ap;

hierName = (HierName *) node->efnode_name->efnn_hier;
Expand Down
2 changes: 1 addition & 1 deletion extflat/EFerr.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ extern int Tcl_printf();
*/

void
efReadError(char *fmt, ...)
efReadError(const char *fmt, ...)
{
va_list args;

Expand Down
2 changes: 1 addition & 1 deletion extflat/extflat.h
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ extern int efHierSrArray();
extern int efHierSrUses();
extern int efHierVisitDevs();
extern EFNode *efNodeMerge();
extern void efReadError();
extern void efReadError(const char *fmt, ...) ATTR_FORMAT_PRINTF_1;
extern int efReadLine();
extern bool efSymAdd();
extern bool efSymAddFile();
Expand Down
1 change: 1 addition & 0 deletions graphics/grOGL1.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ GrOGLInit()
{
TxError("No suitable visual!\n");
MainExit(1);
ATTR_UNREACHABLE;
}
}
grXscrn = grVisualInfo->screen;
Expand Down
4 changes: 2 additions & 2 deletions lef/lefInt.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ void LefReadLayerSection();

LefMapping *defMakeInverseLayerMap();

void LefError(int, char *, ...); /* Variable argument procedure requires */
/* parameter list. */
/* Variable argument procedure requires parameter list. */
void LefError(int, const char *, ...) ATTR_FORMAT_PRINTF_2;

/* C99 compat */
extern void LefRead();
Expand Down
2 changes: 1 addition & 1 deletion lef/lefRead.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ LefNextToken(f, ignore_eol)
*/

void
LefError(int type, char *fmt, ...)
LefError(int type, const char *fmt, ...)
{
static int errors = 0, warnings = 0, messages = 0;
va_list args;
Expand Down
2 changes: 1 addition & 1 deletion tcltk/tclmagic.c
Original file line number Diff line number Diff line change
Expand Up @@ -1028,7 +1028,7 @@ TxFlush()
/*--------------------------------------------------------------*/

int
Tcl_printf(FILE *f, char *fmt, va_list args_in)
Tcl_printf(FILE *f, const char *fmt, va_list args_in)
{
va_list args;
static char outstr[128] = "puts -nonewline std";
Expand Down
8 changes: 4 additions & 4 deletions textio/textio.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ extern void TxUseMore();
extern void TxStopMore();

/* printing procedures with variable arguments lists */
extern void TxError(char *, ...);
extern void TxErrorV(char *, va_list args);
extern void TxPrintf(char *, ...);
extern char *TxPrintString(char *, ...);
extern void TxError(const char *, ...) ATTR_FORMAT_PRINTF_1;
extern void TxErrorV(const char *, va_list args);
extern void TxPrintf(const char *, ...) ATTR_FORMAT_PRINTF_1;
extern char *TxPrintString(const char *, ...) ATTR_FORMAT_PRINTF_1;

/* input procedures */
extern char *TxGetLinePrompt();
Expand Down
2 changes: 1 addition & 1 deletion textio/textioInt.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ extern bool TxGetInputEvent();

/* Routines with variable argument lists */

extern void txFprintfBasic(FILE *, ...);
extern void txFprintfBasic(FILE *, const char *fmt, ...) ATTR_FORMAT_PRINTF_2;

/* C99 compat */
void txCommandsInit();
Expand Down
16 changes: 7 additions & 9 deletions textio/txOutput.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,11 @@ static bool txPrintFlag = TRUE;
*/

void
txFprintfBasic(FILE *f, ...)
txFprintfBasic(FILE *f, const char *fmt, ...)
{
va_list args;
char *fmt;

va_start(args, f);
fmt = va_arg(args, char *);
va_start(args, fmt);
Vfprintf(f, fmt, args);
va_end(args);
}
Expand Down Expand Up @@ -110,7 +108,7 @@ txFprintfBasic(FILE *f, ...)
*/

void
TxPrintf(char *fmt, ...)
TxPrintf(const char *fmt, ...)
{
va_list args;
FILE *f;
Expand Down Expand Up @@ -161,7 +159,7 @@ TxPrintf(char *fmt, ...)
*/

char *
TxPrintString(char *fmt, ...)
TxPrintString(const char *fmt, ...)
{
va_list args;
static char *outstr = NULL;
Expand Down Expand Up @@ -302,15 +300,15 @@ TxFlush()
*/

void
TxError(char *fmt, ...) {
TxError(const char *fmt, ...) {
va_list args;
va_start(args, fmt);
TxErrorV(fmt, args);
va_end(args);
}

void
TxErrorV(char *fmt, va_list args)
TxErrorV(const char *fmt, va_list args)
{
FILE *f;

Expand Down Expand Up @@ -467,7 +465,7 @@ TxStopMore()
#ifdef NEED_VFPRINTF

int
vfprintf(FILR *iop, char *fmt, va_list args_in)
vfprintf(FILR *iop, const char *fmt, va_list args_in)
{
va_list ap;
int len;
Expand Down
4 changes: 2 additions & 2 deletions utils/LIBtextio.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ TxFlush()
*/

void
TxError(char *fmt, ...)
TxError(const char *fmt, ...)
{
va_list ap;

Expand Down Expand Up @@ -126,7 +126,7 @@ TxError(char *fmt, ...)
*/

void
TxPrintf(char *fmt, ...)
TxPrintf(const char *fmt, ...)
{
va_list ap;

Expand Down
2 changes: 1 addition & 1 deletion utils/geometry.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ GeoNameToPos(name, manhattan, verbose)
{"west", GEO_WEST, TRUE},
{0}
};
char *fmt;
const char *fmt;
const struct pos *pp;
int pos;

Expand Down
30 changes: 30 additions & 0 deletions utils/magic.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,36 @@ extern char AbortMessage[];
#define PaLockZOpen PaLockOpen
#endif

/* ------------ modern compiler support -------------------------------- */

#if defined(__GNUC__) || defined(__clang__)
#define ATTR_FORMAT_PRINTF_1 __attribute__((format (printf,1,2)))
#define ATTR_FORMAT_PRINTF_2 __attribute__((format (printf,2,3)))
#define ATTR_SENTINEL __attribute__ ((sentinel))
#define ATTR_UNREACHABLE __builtin_unreachable()
#define ATTR_NORETURN __attribute__((noreturn))
#define __unused__(x) x __attribute__((unused))

#define ANALYSER_CSTRING(n) __attribute__((null_terminated_string_arg(n)))
#define ANALYSER_FD_ARG(fd) __attribute__((fd_arg(fd)))
#define ANALYSER_MALLOC(dealloc, idx) __attribute__((malloc, malloc(dealloc, idx)))
#define ANALYSER_NONNULL(n...) __attribute__((nonnull(n)))
#define ANALYSER_RETURNS_NONNULL __attribute__((returns_nonnull))
#else
#define ATTR_FORMAT_PRINTF_1 /* */
#define ATTR_FORMAT_PRINTF_2 /* */
#define ATTR_SENTINEL /* */
#define ATTR_UNREACHABLE /* */
#define ATTR_NORETURN /* */
#define __unused__(x) x

#define ANALYSER_CSTRING(n) /* */
#define ANALYSER_FD_ARG(fd) /* */
#define ANALYSER_MALLOC(dealloc, idx) /* */
#define ANALYSER_NONNULL(n...) /* */
#define ANALYSER_RETURNS_NONNULL /* */
#endif

/* ---------------- Start of Machine Configuration Section ----------------- */

/* ------- Configuration: Handle Missing Routines/Definitions ------- */
Expand Down
2 changes: 1 addition & 1 deletion utils/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ extern Transform RootToEditTransform;

/* global procedures */

extern void MainExit(int); /* a way of exiting that cleans up after itself */
extern void MainExit(int) ATTR_NORETURN; /* a way of exiting that cleans up after itself */
extern void magicMain();

/* C99 compat */
Expand Down
2 changes: 1 addition & 1 deletion utils/tech.c
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ TechPrintLine()
}

void
TechError(char *fmt, ...)
TechError(const char *fmt, ...)
{
va_list args;

Expand Down
2 changes: 1 addition & 1 deletion utils/tech.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ extern bool TechOverridesDefault; /* Set TRUE if technology was specified on

/* ----------------- Exported procedures ---------------- */

extern void TechError(char *, ...);
extern void TechError(const char *, ...) ATTR_FORMAT_PRINTF_1;
extern void TechAddClient();
extern void TechAddAlias();

Expand Down
Loading